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

APCLAP41.m

Go to the documentation of this file.
APCLAP41 ; IHS/CMI/LAB - APC REPORT PROCESS ;
 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
 ;
START ;
 S APCLBT=$H
 K ^XTMP("APCLAP4",APCLJOB,APCLBTH)
 D XTMP^APCLOSUT("APCLAP4","AVG # VISITS PER 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 only visits with service category of A, O, R, S
 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),"AORS"[$P(^(0),U,7) S APCLVREC=^(0) D PROC,EOJ
 Q
PROC ;
 ;K APCLSKIP
 ;Q:$D(^APCLCNTL(4,11,"B",$P(APCLVREC,U,3)))  ;LAB/TUCSON CHANGED CV TO C FOR VA USE
 Q:$$DEMO^APCLUTL($P(APCLVREC,U,5),$G(APCLDEMO))
 I $$CHKLOC^APCLOCCK(APCLLOC,$P(APCLVREC,U,6))=0 Q
 ;Q:'$D(^AUPNVPOV("AD",APCLVDFN))
 ;Q:'$D(^AUPNVPRV("AD",APCLVDFN))
 S APCLVLOC=$P(APCLVREC,U,6) Q:APCLVLOC=""
 S APCLCLIN=$P(APCLVREC,U,8)
 I APCLCLIN]"",$D(APCLCLNT),'$D(APCLCLNT(APCLCLIN)) Q
 Q:'$$APCWL^APCLV(APCLVDFN)
 I APCLCLIN="" S APCLCLIN=9999
CHKCL ;
 ;convert dental with med to pharmacy clinic
 ;G:$G(DUZ("AG"))["V" PROC1
 ;S X=$S(APCLCLIN="":"",$D(^DIC(40.7,APCLCLIN,0)):$P(^DIC(40.7,APCLCLIN,0),U,2),1:"")
 ;I X=56,'$D(^AUPNVMED("AD",APCLVDFN)) Q
 ;I X=56 S APCLCLIN=APCLRXCL
 ;Q:$D(^APCLCNTL(2,11,"B",X))
 ;
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("APCLAP4",APCLJOB,APCLBTH,"VISITS DOW",APCLSRT2)):^(APCLSRT2)+1,1:1)
 I '$D(^XTMP("APCLAP4",APCLJOB,APCLBTH,"DOW DATE",APCLDATE)) S ^XTMP("APCLAP4",APCLJOB,APCLBTH,"DOW DATE",APCLDATE)="",^(APCLSRT2)=$S($D(^XTMP("APCLAP4",APCLJOB,APCLBTH,"DOW #",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"
 Q