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

APCLOS3.m

Go to the documentation of this file.
APCLOS3 ; IHS/CMI/LAB - CHS PORTION OF OS ;
 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
 ;IHS/CMI/LAB - fixed newborn counts, admitting dx patch 4
 ;
 ;IHS/TUCSON/LAB - modified routine to use B index on ACHSF to avoid
 ;errors - patch 1 - 06/02/97
 ;
CHS ;
 S APCLOS="APCLOS",APCLODAT=APCLFYB,APCLEDAT=APCLFYE D CHS0
 S APCLOS="APCLOSP",APCLODAT=APCLPYB,APCLEDAT=APCLPYE D CHS0
 K APCLODAT,APCLF,APCLN,APCLCHSR,APCLEDAT,APCLTOS,APCLPAY,APCLTOSE
 Q
CHS0 S APCLF=0 F  S APCLF=$O(^ACHSF("B",APCLF)) Q:APCLF'=+APCLF  I $D(^XTMP("APCLSU",APCLJOB,APCLBTH,$P(^ACHSF(APCLF,0),U))) D CHS1
 ;IHS/TUCSON/LAB - modified above to use B index patch 1 06/02/97
 Q
CHS1 ;
 S APCLN=0 F  S APCLN=$O(^ACHSF(APCLF,"D",APCLN)) Q:APCLN'=+APCLN  S APCLCHSR=^ACHSF(APCLF,"D",APCLN,0) D CHS2
 Q
CHS2 ;
 Q:$P(APCLCHSR,U,2)<APCLODAT
 Q:$P(APCLCHSR,U,2)>APCLEDAT
 ;I $E(APCLFY,2)'=$P(APCLCHSR,U,14) Q
 S APCLTOS=$P(APCLCHSR,U,4)
 S APCLPAY=$S($D(^ACHSF(APCLF,"D",APCLN,"PA")):$P(^ACHSF(APCLF,"D",APCLN,"PA"),U),1:"") S:APCLPAY="" APCLPAY=$P(APCLCHSR,U,9) S:APCLPAY="" APCLPAY=0
 K ^UTILITY("DIQ1",$J)
 K DIQ,DIC,DA,DR
 ;S DIC=9002080,DR=100,DA=APCLF,DA(9002080.01)=APCLN,DR(9002080.01)=3,DIQ(0)="E" D EN^DIQ1 K DIC,DA,DR,DIQ
 S APCLTOSE=$S(APCLTOS=1:"43 - HOSPITALIZATION",APCLTOS=2:"57 - DENTAL",APCLTOS=3:"64 - NON-HOSPITAL SERVICE",1:"UNKNOWN")
 ;S APCLTOSE=^UTILITY("DIQ1",$J,9002080.01,APCLF,APCLN)
 S:APCLTOS="" APCLTOS=9999999999
 S ^(APCLTOSE)=$S($D(^XTMP(APCLOS,APCLJOB,APCLBTH,"CHS",APCLTOS,APCLTOSE)):+^(APCLTOSE)+APCLPAY,1:APCLPAY)
 S ^(APCLTOSE)=$S($D(^XTMP(APCLOS,APCLJOB,APCLBTH,"CHSCOUNT",APCLTOS,APCLTOSE)):+^(APCLTOSE)+1,1:1)
 K ^UTILITY("DIQ1",$J)
 S ^("CHSTOTAL")=$S($D(^XTMP(APCLOS,APCLJOB,APCLBTH,"CHSTOTAL")):+^("CHSTOTAL")+APCLPAY,1:APCLPAY)
 Q
INPT ;
 S APCLNBCD=$O(^DIC(45.7,"CIHS","07","")),APCLNBC("APCLOS")=0,APCLNBC("APCLOSP")=0,APCLNBDY("APCLOS")=0,APCLNBDY("APCLOSP")=0 ;IHS/TUCSON/LAB - FIXED APCLNBC array and APCLNBDY array
 S APCLOS="APCLOS",%="^XTMP("""_APCLOS_""",APCLJOB,APCLBTH,",APCLA=%_"""INPTPOV"",APCLPOV)",APCLC=%_"""INPTPOVC"""_")",APCLB=%_"""INPTADMDX"",APCLADX)",APCLD=%_"""INPTADMDXC"""_")"
 S APCLODAT=APCLFYB-.0001,APCLEDAT=APCLFYE D V
 S APCLOS="APCLOSP",%="^XTMP("""_APCLOS_""",APCLJOB,APCLBTH,",APCLA=%_"""INPTPOV"",APCLPOV)",APCLC=%_"""INPTPOVC"""_")",APCLB=%_"""INPTADMDX"",APCLADX)",APCLD=%_"""INPTADMDXC"""_")"
 S APCLODAT=APCLPYB-.0001,APCLEDAT=APCLPYE D V
 D ALOS
 K APCLA,APCLODAT,APCLC,APCLHREC,APCL1,APCL2,APCLVREC,APCLPOV,%,APCLEDAT,APCLLOS,APCLVDFN,APCLVINP,APCLVLOC
 Q
 ;
V ; Run by visit date
 F  S APCLODAT=$O(^AUPNVINP("B",APCLODAT)) Q:APCLODAT=""!((APCLODAT\1)>APCLEDAT)  D V1
 D SET
 Q
V1 ;
 S APCLVINP="" F  S APCLVINP=$O(^AUPNVINP("B",APCLODAT,APCLVINP)) Q:APCLVINP'=+APCLVINP  I $D(^AUPNVINP(APCLVINP,0)) S APCLHREC=^(0) D PROC
 Q
PROC ;
 Q:$$DEMO^APCLUTL($P(APCLHREC,U,2),$G(APCLDEMO))
 S APCLVDFN=$P(APCLHREC,U,3)
 S APCLVREC=^AUPNVSIT(APCLVDFN,0)
 Q:$D(^APCLCNTL(4,11,"B",$P(APCLVREC,U,3)))  ;LAB/OHPRD changed CV to V for VA
 S APCLVLOC=$P(APCLVREC,U,6)
 Q:'$D(^XTMP("APCLSU",APCLJOB,APCLBTH,APCLVLOC))
 Q:'$D(^AUPNVPOV("AD",APCLVDFN))
 Q:'$D(^AUPNVPRV("AD",APCLVDFN))
PROC1 S (APCL1,APCL2)=0 F  S APCL2=$O(^AUPNVPOV("AD",APCLVDFN,APCL2)) Q:APCL2=""  I $P(^AUPNVPOV(APCL2,0),U,12)="P" S APCL1=APCL1+1,APCLPOV=$P(^(0),U)
 Q:APCL1=0
 Q:APCL1>1
 ;IHS/TUCSON/LAB - fixed setting of APCLNBC AND APCLNBDY
 I APCLNBCD]"",$P(APCLHREC,U,5)=APCLNBCD S APCLNBC(APCLOS)=APCLNBC(APCLOS)+1 D
 .S X1=$P(APCLODAT,"."),X2=$P((APCLVREC/1),".") D ^%DTC S APCLLOS=X S:APCLLOS=0 APCLLOS=1 S APCLNBDY(APCLOS)=APCLNBDY(APCLOS)+APCLLOS
 Q:$P(APCLHREC,U,5)=APCLNBCD
 S ^("DISCH")=$S($D(^XTMP(APCLOS,APCLJOB,APCLBTH,"DISCH")):(+^("DISCH")+1),1:1)
 S X1=$P(APCLODAT,"."),X2=$P((APCLVREC/1),".") D ^%DTC S APCLLOS=X S:APCLLOS=0 APCLLOS=1
 S ^("PATDAYS")=$S($D(^XTMP(APCLOS,APCLJOB,APCLBTH,"PATDAYS")):+^("PATDAYS")+APCLLOS,1:APCLLOS)
 D ADMDX
 Q:APCLPOV=""
 Q:'$D(^ICD9(APCLPOV,0))
 S X=APCLA
 ;
 I '$D(@X) S @X=0
 S %=@X,%=%+1,@X=%
 Q
 ;
 ;CMI/LAB - added the following to tally admitting dxs
ADMDX ;
 S APCLADX=$P(APCLHREC,U,12)
 Q:APCLADX=""
 Q:'$D(^ICD9(APCLADX,0))
 S X=APCLB
 I '$D(@X) S @X=0
 S %=@X,%=%+1,@X=%
 Q
SET ; 
 F APCLPOV=0:0 S APCLPOV=$O(@APCLA) Q:'APCLPOV  S %=^(APCLPOV) S ^XTMP(APCLOS,APCLJOB,APCLBTH,"INPTPOVC",9999999-%,APCLPOV)=%
 F APCLADX=0:0 S APCLADX=$O(@APCLB) Q:'APCLADX  S %=^(APCLADX) S ^XTMP(APCLOS,APCLJOB,APCLBTH,"INPTADMDXC",9999999-%,APCLADX)=%
 Q
ALOS ;
 S APCLOS="APCLOS" D ALOS1
 S APCLOS="APCLOSP" D ALOS1
 Q
ALOS1 ;
 Q:'$D(^XTMP(APCLOS,APCLJOB,APCLBTH,"DISCH"))
 S ^XTMP(APCLOS,APCLJOB,APCLBTH,"ALOS")=(^XTMP(APCLOS,APCLJOB,APCLBTH,"PATDAYS")/^XTMP(APCLOS,APCLJOB,APCLBTH,"DISCH"))
 S ^XTMP(APCLOS,APCLJOB,APCLBTH,"ALOS")=$J(^XTMP(APCLOS,APCLJOB,APCLBTH,"ALOS"),1,1)
 Q