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

APCLAP81.m

Go to the documentation of this file.
APCLAP81 ; IHS/CMI/LAB - APC Visit Counts All Svc Cat Process Routine ;
 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
 ;Report to tally average number of visits per day of week by clinic
 ;
START ;
 S APCLBT=$H
 K ^XTMP("APCLAP8",APCLJOB,APCLBTH)
 D XTMP^APCLOSUT("APCLAP8","PCC - AVG VISITS BY DAY")
 ;
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 visits for ALL service categories
 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,EOJ
 Q
PROC ;
 K APCLSKIP
 Q:$$DEMO^APCLUTL($P(APCLVREC,U,5),$G(APCLDEMO))
 Q:$D(^APCLCNTL(4,11,"B",$P(APCLVREC,U,3)))
 I $$CHKLOC^APCLOCCK(APCLLOC,$P(APCLVREC,U,6))=0 Q
 S APCLVLOC=$P(APCLVREC,U,6)
 Q:'$D(^AUPNVPOV("AD",APCLVDFN))
 Q:'$D(^AUPNVPRV("AD",APCLVDFN))
 S APCLCLIN=$P(APCLVREC,U,8)
 Q:APCLCLIN=""
 S APCLCNAM=$P(^DIC(40.7,APCLCLIN,0),U)
PROC1 ;
 S (APCL1,APCL2)=0 F  S APCL2=$O(^AUPNVPRV("AD",APCLVDFN,APCL2)) Q:APCL2=""  I $P(^AUPNVPRV(APCL2,0),U,4)="P" S APCL1=APCL1+1,APCLAP=$P(^(0),U)
 Q:APCL1'=1
 S APCLDISC="" D CHKDISC
 ;Q:$D(APCLSKIP)
 ;S APCLPPOV=$O(^AUPNVPOV("AD",APCLVDFN,"")) Q:'$D(^AUPNVPOV(APCLPPOV))
 ;S (APCLX,APCLICD)=$P(^ICD9($P(^AUPNVPOV(APCLPPOV,0),U),0),U)
 ;Q:APCLX=".9999"
 D DATE
 S ^(APCLSRT2)=$S($D(^XTMP("APCLAP8",APCLJOB,APCLBTH,"VISITS DOW",APCLCNAM,APCLSRT2)):^(APCLSRT2)+1,1:1)
 I '$D(^XTMP("APCLAP8",APCLJOB,APCLBTH,"DOW DATE",APCLCNAM,APCLDATE)) D
 .S ^XTMP("APCLAP8",APCLJOB,APCLBTH,"DOW DATE",APCLCNAM,APCLDATE)="",^(APCLSRT2)=$S($D(^XTMP("APCLAP8",APCLJOB,APCLBTH,"DOW #",APCLCNAM,APCLSRT2)):^(APCLSRT2)+1,1:1)
 Q
EOJ K APCLVLOC,APCLVREC,APCLCLIN,APCLSKIP,APCL1,APCL2,APCLAP,APCLDISC,APCLPPOV,APCLX,APCLHIGH,APCLDX,APCLLOW,APCLICD,APCLDA1,APCLDA2,APCLY,APCLSRT2,APCLDATE,APCLPROV,APCLSEC,APCLZ,APCLLOCC
 Q
 ;
CHKDISC ;
 I $P(^DD(9000010.06,.01,0),U,2)[6 G CHKDISC6
 S APCLDISC=$$PROVCLSC^XBFUNC1(APCLAP) I APCLDISC="UNKNOWN" S APCLDISC="??" Q
 S APCLLOCC=$E($P(^AUTTLOC(APCLVLOC,0),U,10),5,6)
 I (APCLDISC=13!(APCLDISC=32))&((APCLLOCC>49)!(APCLLOCC'=+APCLLOCC)) S APCLSKIP=1
 Q
 ;
CHKDISC6 ;
 I '$D(^DIC(6,APCLAP)) S APCLSKIP=1 Q
 S APCLY=$P(^DIC(6,APCLAP,0),U,4)
 I APCLY="" S APCLDISC="??" Q
 I '$D(^DIC(7,APCLY,9999999)) S APCLDISC="??" Q
 S APCLDISC=$P(^DIC(7,APCLY,9999999),U) I APCLDISC="" S APCLDISC="??" Q
 S APCLLOCC=$E($P(^AUTTLOC(APCLVLOC,0),U,10),5,6)
 I (APCLDISC=13!(APCLDISC=32))&((APCLLOCC>49)!(APCLLOCC'=+APCLLOCC)) S APCLSKIP=1
 Q
 ;
DATE ;
 S APCLDATE=$P(APCLODAT,".")
 S X=APCLDATE D H^%DTC S APCLSRT2=$P("SUNDAY;MONDAY;TUESDAY;WEDNESDAY;THURSDAY;FRIDAY;SATURDAY",";",%Y+1) I APCLSRT2="" S APCLSRT2="UNKNOWN"
 ;S X=APCLDATE D H^%DTC S APCLSRT2=%Y+1
 Q