Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: APCLADX1

APCLADX1.m

Go to the documentation of this file.
APCLADX1 ; IHS/CMI/LAB - process dx by age report ;
 ;;2.0;IHS PCC SUITE;**11**;MAY 14, 2009;Build 58
 ;
 ;cmi/anch/maw 9/7/2007 code set versioning in POVX
 ;
 S APCLBT=$H,APCLJOB=$J,APCLGRAN=0
 D XTMP^APCLOSUT("APCLADX","PCC DX BY AGE REPORT")
 S APCLNN=APCLBIN,APCLA="" F I=1:1 S APCLX=$P(APCLNN,";",I) Q:APCLX=""  D SETA
 S APCLDOBS=APCLA
V ; Run by visit date
 S APCLODAT=$O(^AUPNVSIT("B",APCLSD)) I APCLODAT="" S APCLET=$H Q
 S APCLODAT=APCLSD_".9999" F  S APCLODAT=$O(^AUPNVSIT("B",APCLODAT)) Q:APCLODAT=""!((APCLODAT\1)>APCLED)  D V1
 S APCLET=$H
 Q
V1 ;
 S APCLVDFN=0 F  S APCLVDFN=$O(^AUPNVSIT("B",APCLODAT,APCLVDFN)) Q:APCLVDFN'=+APCLVDFN  I $D(^AUPNVSIT(APCLVDFN,0)) S APCLVREC=^(0) D PROC,EOJ
 Q
PROC ;
 K APCLSKIP
 Q:$$DEMO^APCLUTL($P(APCLVREC,U,5),$G(APCLDEMO))
 Q:'$P(APCLVREC,U,9)
 Q:$P(APCLVREC,U,11)
 I $D(APCLSC),$P(APCLVREC,U,7)'=APCLSC Q
 I $D(APCLTYPE),$P(APCLVREC,U,3)'=APCLTYPE Q
 S APCLF2=$P(APCLVREC,U,5) Q:'APCLF2  Q:'$D(^DPT(APCLF2,0))  S APCLF2=^(0)
 I $D(APCLSEX),APCLSEX'=$P(APCLF2,U,2) Q
 I $D(APCLFAC),APCLFAC'=$P(APCLVREC,U,6) Q
PROV I '$D(APCLPROV) G CLN
 N % K APCLFOUN S %="" F  S %=$O(^AUPNVPRV("AD",APCLVDFN,%)) Q:%=""  I $D(^AUPNVPRV(%,0)),$P(^(0),U,4)="P",APCLPROV=+^(0) S APCLFOUN=""
 Q:'$D(APCLFOUN)
CLN I $D(APCLCLN),APCLCLN'=$P(APCLVREC,U,8) Q
 Q:'$D(^AUPNVPOV("AD",APCLVDFN))
POV S APCLPOVN=""
 S APCLC=0 F  S APCLPOVN=$O(^AUPNVPOV("AD",APCLVDFN,APCLPOVN)) Q:'APCLPOVN  Q:'$D(^AUPNVPOV(APCLPOVN,0))  S APCLPOV=+^(0),APCLPREC=^(0),APCLC=APCLC+1 D POVX
 Q
 ;
POVX ;
 ;I '$D(^ICD9($P(APCLPREC,U))) Q
 I +$$ICDDX^ICDEX(APCLPOV)=-1 Q
 I $D(APCLPRIM),$D(APCLSC),APCLSC="H",$P(APCLPREC,U,12)'="P" Q
 I $D(APCLPRIM),APCLC>1 Q
 ;S APCLCODE=$P(^ICD9(APCLPOV,0),U)_" ",APCLNARR=$P(^(0),U,3)
 S APCLCODE=$$VAL^XBDIQ1(9000010.07,APCLPOVN,.01)_" ",APCLNARR=$P($$ICDDX^ICDEX(APCLPOV),U,4)
 D SET
 Q
EOJ K APCLVLOC,APCLVREC,APCLSKIP,APCL1,APCL2,APCLX,APCLY,APCLDISC,APCLAGE
 Q
 ;
 ;
SET ;
 S APCLAGE="" D GETAGE
 Q:'APCLAGE
 S ^(APCLNARR)=$S($D(^XTMP("APCLADX",APCLJOB,APCLBT,"TOTAL","CODE",APCLCODE,APCLNARR)):^(APCLNARR)+1,1:1)
 S ^(APCLAGE)=$S($D(^XTMP("APCLADX",APCLJOB,APCLBT,"TOTAL","AGE",APCLAGE)):^(APCLAGE)+1,1:1)
 S ^(APCLAGE)=$S($D(^XTMP("APCLADX",APCLJOB,APCLBT,"TALLY",APCLCODE,APCLNARR,APCLAGE)):^(APCLAGE)+1,1:1)
 S APCLGRAN=APCLGRAN+1
 Q
GETAGE ;
 S APCLDOB=$P(^DPT($P(APCLVREC,U,5),0),U,3) Q:APCLDOB=""
ATT ;
 F I=1:1 S APCLNN=$P(APCLA,";",I) Q:APCLNN=""  S APCLX=$P(APCLNN,"-"),APCLY=$P(APCLNN,"-",2) I APCLDOB'<APCLX,APCLDOB'>APCLY  S APCLAGE=I Q
 Q
 ;
SETA S APCLY=$P(APCLX,"-"),APCLZ=$P(APCLX,"-",2)
 I APCLA]"" S APCLA=APCLA_";"
 S APCLA=APCLA_(DT+1-(10000*(APCLZ+1)))_"-"_(DT-(APCLY*10000))
 S ^XTMP("APCLADX",APCLJOB,APCLBT,"TOTAL","AGE",I)=0
 Q
 ;