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

APCLRT11.m

Go to the documentation of this file.
APCLRT11 ; IHS/CMI/LAB - APC REPORT PROCESS ;
 ;;2.0;IHS PCC SUITE;**7**;MAY 14, 2009
 ;IHS/CMI/LAB - patch 5 fixed to only use 72 hours
 ;
START ;
 S APCLBT=$H
 K ^XTMP("APCLRT1",APCLJOB,APCLBTH)
 D XTMP^APCLOSUT("APCLRT1","PCC - RETURNS RPT 1")
 ;
V ; Run by visit date
 S APCLODAT=APCLSD_".9999" F  S APCLODAT=$O(^AUPNVSIT("B",APCLODAT)) Q:APCLODAT=""!((APCLODAT\1)>APCLED)  D V1
 ;
END ;
 S APCLET=$H
 D EOJ
 Q
V1 ;
 ;count only visits with a clinic = the value in APCLCLN
 S APCLVDFN="" F  S APCLVDFN=$O(^AUPNVSIT("B",APCLODAT,APCLVDFN)) Q:APCLVDFN'=+APCLVDFN  I $D(^AUPNVSIT(APCLVDFN,0)),$P(^(0),U,9),'$P(^(0),U,11) S APCLVREC=^(0) D PROC
 Q
PROC ;
 K APCLSKIP
 I APCLEINC=1 Q:'$D(^AUPNVPOV("AD",APCLVDFN))  Q:'$D(^AUPNVPRV("AD",APCLVDFN))
 Q:$$DEMO^APCLUTL($P(APCLVREC,U,5),$G(APCLDEMO))
 Q:$P(APCLVREC,U,8)=""
 I $G(APCLFCLN),APCLFCLN'=$P(APCLVREC,U,8) Q
 I $D(APCLLOC) S X=$P(APCLVREC,U,6) Q:X=""  Q:'$D(APCLLOC(X))
 ;I APCLLOC]"",APCLLOC'=$P(APCLVREC,U,6) Q
 I APCLPROV,$$PRIMPROV^APCLV(APCLVDFN,"I")'=APCLPROV Q
 ;Q:'$D(^AUPNVPOV("AD",APCLVDFN))  ;NOT YET CODED
 ;
 ; ==> go through all of this patients visits from visit date
 ; ==> to 3 days after visit date
 ; ==> APCLIVD=inverse date of vd
 ; ==> APCLFVD=inverse date of 3 days from then
 ;
 ; => add 3 days to current visit date
 S X1=$P($P(APCLVREC,U),"."),X2=3 D C^%DTC S APCL3D=X
 ; => calculate starting point for $O
 S APCLFVD=((9999999-APCL3D)-1)_".9999"
 S APCLIVD=9999999-$P($P(APCLVREC,U),".")
 F  S APCLFVD=$O(^AUPNVSIT("AA",$P(APCLVREC,U,5),APCLFVD)) Q:APCLFVD=""!($P(APCLFVD,".")>APCLIVD)  D
 .S APCLV=0 F  S APCLV=$O(^AUPNVSIT("AA",$P(APCLVREC,U,5),APCLFVD,APCLV)) Q:APCLV'=+APCLV  D
 ..I APCLTCLN,$P(^AUPNVSIT(APCLV,0),U,8)'=APCLTCLN Q
 ..Q:APCLV=APCLVDFN  ;quit if same visit
 ..I APCLSDX Q:$$PRIMPOV^APCLV(APCLVDFN,"C")'=$$PRIMPOV^APCLV(APCLV,"C")
 ..I APCLEINC Q:'$D(^AUPNVPOV("AD",APCLV))  Q:'$D(^AUPNVPRV("AD",APCLV))
 ..;Q:'$D(^AUPNVPOV("AD",APCLV))  ;no pov
 ..;S Y=$P(APCLVREC,U) D DD^%DT S APCLT1=$P(Y,"@",2),APCLT1=$TR(APCLT1,":","") ;IHS/CMI/LAB
 ..;S Y=$P(^AUPNVSIT(APCLV,0),U) D DD^%DT S APCLT2=$P(Y,"@",2),APCLT2=$TR(APCLT2,":","") ;IHS/CMI/LAB
 ..S Y=$$FMDIFF^XLFDT($P(^AUPNVSIT(APCLV,0),U),$P(APCLVREC,U),2)
 ..I APCLHR=7 Q:Y>259200
 ..;I APCLHR=4 Q:Y>172800
 ..;I $P($P(^AUPNVSIT(APCLV,0),U),".")=$P($P(APCLVREC,U),"."),APCLT1>APCLT2 Q
 ..S ^XTMP("APCLRT1",APCLJOB,APCLBTH,$P(APCLVREC,U,5),APCLVDFN,APCLV)=""
 Q
EOJ ;
 K APCLVREC,APCLVDFN,APCLV,APCLODAT
 Q
 ;