APCLCP31 ; IHS/CMI/LAB - activity report ;
;;2.0;IHS PCC SUITE;;MAY 14, 2009
START ; EP - process report
S APCLBT=$H,APCLJOB=$J
K ^XTMP(APCLNSP,APCLJOB,APCLBT)
D XTMP^APCLOSUT(APCLNSP,"PCC ACTIVITY REPORT")
I $P(^APCLACTG(APCLACTG,0),U,2)]"",$P(^(0),U,3)]"",$P(^(0),U,4)]"" D I 1
.S APCLRRTN=$S($P($P(^APCLACTG(APCLACTG,0),U,2),"~",2)]"":$P($P(^APCLACTG(APCLACTG,0),U,2),"~")_"^"_$P($P(^APCLACTG(APCLACTG,0),U,2),"~",2),1:$P(^APCLACTG(APCLACTG,0),U,2)),APCLPIEC=$P(^(0),U,4),APCLGLOB="^"_$P(^(0),U,3)_"("
.S X=APCLRRTN X ^%ZOSF("TEST") I '$T S APCLRRTN="",APCLGLOB="^ICD9(",APCLPIEC=3 Q
E S APCLGLOB="^ICD9(",APCLRRTN="",APCLPIEC=3
I APCLRRTN]"" S APCLRRTN="^"_APCLRRTN
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)
Q:"DXECH"[$P(APCLVREC,U,7)
Q:"V"[$P(APCLVREC,U,3)
I $D(APCLLOC) Q:$P(APCLVREC,U,6)="" I '$D(APCLLOC($P(APCLVREC,U,6))) Q
I $D(APCLCLN) Q:$P(APCLVREC,U,8)="" I '$D(APCLCLN($P(APCLVREC,U,8))) Q
Q:'$D(^AUPNVPOV("AD",APCLVDFN))
Q:'$D(^AUPNVPRV("AD",APCLVDFN))
S APCLPRIM=""
S (APCL1,APCL2)=0 F L=0:0 S APCL2=$O(^AUPNVPRV("AD",APCLVDFN,APCL2)) Q:APCL2="" I $P(^AUPNVPRV(APCL2,0),U,4)="P" S APCL1=APCL1+1,APCLPRIM=APCL2
I APCL1=0 Q
I APCL1>1 Q
S APCLVLOC=$P(APCLVREC,U,6)
S APCLSU=$P(^AUTTLOC(APCLVLOC,0),U,5) I APCLSU="" S APCLSU="ZZZZ"
S APCLFOUN=0 D PROC2
Q:'APCLFOUN
D SET
Q
EOJ K APCLVLOC,APCLVREC,APCLSKIP,APCL1,APCL2,APCLX,APCLY,APCLPRIM,APCLSU,APCLDISC,@APCLSORV,APCLVTM,APCLVTT
Q
;
;
PROC2 ;
S APCLAP=$P(^AUPNVPRV(APCLPRIM,0),U)
I $P(^DD(9000010.06,.01,0),U,2)[200 S APCLDISC=$$PROVCLSC^XBFUNC1(APCLAP) G:'$D(^APCLACTG(APCLACTG,11,"AC",APCLDISC)) SEC G PROC21
S APCLY=$P(^DIC(6,APCLAP,0),U,4)
G:APCLY="" SEC
G:'$D(^DIC(7,APCLY,9999999)) SEC
S APCLDISC=$P(^DIC(7,APCLY,9999999),U) I '$D(^APCLACTG(APCLACTG,11,"AC",APCLDISC)) G SEC
PROC21 S APCLFOUN=1,APCLCHN=APCLPRIM
Q
SEC ;
S APCLX=0 F S APCLX=$O(^AUPNVPRV("AD",APCLVDFN,APCLX)) Q:APCLX'=+APCLX I $P(^AUPNVPRV(APCLX,0),U,4)="S" S APCLCHN=APCLX D
. S APCLAP=$P(^AUPNVPRV(APCLX,0),U)
. I $P(^DD(9000010.06,.01,0),U,2)[200 S APCLDISC=$$PROVCLSC^XBFUNC1(APCLAP) Q:'$D(^APCLACTG(APCLACTG,11,"AC",APCLDISC)) G SEC1
. S APCLY=$P(^DIC(6,APCLAP,0),U,4)
. I APCLY="" Q
. I '$D(^DIC(7,APCLY,9999999)) Q
. S APCLDISC=$P(^DIC(7,APCLY,9999999),U) I '$D(^APCLACTG(APCLACTG,11,"AC",APCLDISC)) Q
SEC1 . S APCLFOUN=APCLFOUN+1
. Q
Q
SET ;
I APCLSORV="APCLCODE" S APCLCODE="" D GETCODE Q:'APCLCODE
S ^("TOTAL")=$S($D(^XTMP(APCLNSP,APCLJOB,APCLBT,@APCLSECV,@APCLSORV,"TOTAL")):^("TOTAL")+1,1:1)
I $P(^AUPNVPRV(APCLCHN,0),U,4)="P" S ^("PRIM")=$S($D(^XTMP(APCLNSP,APCLJOB,APCLBT,@APCLSECV,@APCLSORV,"PRIM")):^("PRIM")+1,1:1)
I $P(^AUPNVPRV(APCLCHN,0),U,4)'="P" S ^("SEC")=$S($D(^XTMP(APCLNSP,APCLJOB,APCLBT,@APCLSECV,@APCLSORV,"SEC")):^("SEC")+1,1:1)
I '$D(^AUPNVTM("AD",APCLVDFN)) S ^("NOACT")=$S($D(^XTMP(APCLNSP,APCLJOB,APCLBT,@APCLSECV,"NOACT")):^("NOACT")+1,1:1) Q
S APCLVTM=$O(^AUPNVTM("AD",APCLVDFN,"")),APCLVACT=$P(^AUPNVTM(APCLVTM,0),U)*APCLFOUN,APCLVTT=$P(^AUPNVTM(APCLVTM,0),U,4)
S ^("ACT")=$S($D(^XTMP(APCLNSP,APCLJOB,APCLBT,@APCLSECV,@APCLSORV,"ACT")):^("ACT")+APCLVACT,1:APCLVACT)
I APCLVTT S ^("TT")=$S($D(^XTMP(APCLNSP,APCLJOB,APCLBT,@APCLSECV,@APCLSORV,"TT")):^("TT")+APCLVTT,1:APCLVTT)
Q
GETCODE ;
D GETPPOV
S APCLIPTR=$P(^AUPNVPOV(APCL1,0),U)
I $G(APCLRRTN)]"" D @APCLRRTN Q
S APCLCODE=APCLIPTR
Q
GETPPOV ;
I $P(APCLVREC,U,7)'="H" S APCL1=$O(^AUPNVPOV("AD",APCLVDFN,"")) Q
S (APCL1,APCL2)=0 F S APCL2=$O(^AUPNVPOV("AD",APCLVDFN,APCL2)) Q:APCL2'=+APCL2!(APCL1) I $P(^AUPNVPOV(APCL2,0),U,12)="P" S APCL1=APCL2
Q
APCLCP31 ; IHS/CMI/LAB - activity report ;
+1 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
START ; EP - process report
+1 SET APCLBT=$HOROLOG
SET APCLJOB=$JOB
+2 KILL ^XTMP(APCLNSP,APCLJOB,APCLBT)
+3 DO XTMP^APCLOSUT(APCLNSP,"PCC ACTIVITY REPORT")
+4 IF $PIECE(^APCLACTG(APCLACTG,0),U,2)]""
IF $PIECE(^(0),U,3)]""
IF $PIECE(^(0),U,4)]""
Begin DoDot:1
+5 SET APCLRRTN=$SELECT($PIECE($PIECE(^APCLACTG(APCLACTG,0),U,2),"~",2)]"":$PIECE($PIECE(^APCLACTG(APCLACTG,0),U,2),"~")_"^"_$PIECE($PIECE(^APCLACTG(APCLACTG,0),U,2),"~",2),1:$PIECE(^APCLACTG(APCLACTG,0),U,2))
SET APCLPIEC=$PIECE(^(0),U,4)
SET APCLGLOB="^"_$PIECE(^(0),U,3)_"("
+6 SET X=APCLRRTN
XECUTE ^%ZOSF("TEST")
IF '$TEST
SET APCLRRTN=""
SET APCLGLOB="^ICD9("
SET APCLPIEC=3
QUIT
End DoDot:1
IF 1
+7 IF '$TEST
SET APCLGLOB="^ICD9("
SET APCLRRTN=""
SET APCLPIEC=3
+8 IF APCLRRTN]""
SET APCLRRTN="^"_APCLRRTN
V ; Run by visit date
+1 SET APCLODAT=$ORDER(^AUPNVSIT("B",APCLSD))
IF APCLODAT=""
SET APCLET=$HOROLOG
QUIT
+2 SET APCLODAT=APCLSD_".9999"
FOR
SET APCLODAT=$ORDER(^AUPNVSIT("B",APCLODAT))
IF APCLODAT=""!((APCLODAT\1)>APCLED)
QUIT
DO V1
+3 SET APCLET=$HOROLOG
+4 QUIT
V1 ;
+1 SET APCLVDFN=0
FOR
SET APCLVDFN=$ORDER(^AUPNVSIT("B",APCLODAT,APCLVDFN))
IF APCLVDFN'=+APCLVDFN
QUIT
IF $DATA(^AUPNVSIT(APCLVDFN,0))
SET APCLVREC=^(0)
DO PROC
DO EOJ
+2 QUIT
PROC ;
+1 KILL APCLSKIP
+2 IF $$DEMO^APCLUTL($PIECE(APCLVREC,U,5),$GET(APCLDEMO))
QUIT
+3 IF '$PIECE(APCLVREC,U,9)
QUIT
+4 IF $PIECE(APCLVREC,U,11)
QUIT
+5 IF "DXECH"[$PIECE(APCLVREC,U,7)
QUIT
+6 IF "V"[$PIECE(APCLVREC,U,3)
QUIT
+7 IF $DATA(APCLLOC)
IF $PIECE(APCLVREC,U,6)=""
QUIT
IF '$DATA(APCLLOC($PIECE(APCLVREC,U,6)))
QUIT
+8 IF $DATA(APCLCLN)
IF $PIECE(APCLVREC,U,8)=""
QUIT
IF '$DATA(APCLCLN($PIECE(APCLVREC,U,8)))
QUIT
+9 IF '$DATA(^AUPNVPOV("AD",APCLVDFN))
QUIT
+10 IF '$DATA(^AUPNVPRV("AD",APCLVDFN))
QUIT
+11 SET APCLPRIM=""
+12 SET (APCL1,APCL2)=0
FOR L=0:0
SET APCL2=$ORDER(^AUPNVPRV("AD",APCLVDFN,APCL2))
IF APCL2=""
QUIT
IF $PIECE(^AUPNVPRV(APCL2,0),U,4)="P"
SET APCL1=APCL1+1
SET APCLPRIM=APCL2
+13 IF APCL1=0
QUIT
+14 IF APCL1>1
QUIT
+15 SET APCLVLOC=$PIECE(APCLVREC,U,6)
+16 SET APCLSU=$PIECE(^AUTTLOC(APCLVLOC,0),U,5)
IF APCLSU=""
SET APCLSU="ZZZZ"
+17 SET APCLFOUN=0
DO PROC2
+18 IF 'APCLFOUN
QUIT
+19 DO SET
+20 QUIT
EOJ KILL APCLVLOC,APCLVREC,APCLSKIP,APCL1,APCL2,APCLX,APCLY,APCLPRIM,APCLSU,APCLDISC,@APCLSORV,APCLVTM,APCLVTT
+1 QUIT
+2 ;
+3 ;
PROC2 ;
+1 SET APCLAP=$PIECE(^AUPNVPRV(APCLPRIM,0),U)
+2 IF $PIECE(^DD(9000010.06,.01,0),U,2)[200
SET APCLDISC=$$PROVCLSC^XBFUNC1(APCLAP)
IF '$DATA(^APCLACTG(APCLACTG,11,"AC",APCLDISC))
GOTO SEC
GOTO PROC21
+3 SET APCLY=$PIECE(^DIC(6,APCLAP,0),U,4)
+4 IF APCLY=""
GOTO SEC
+5 IF '$DATA(^DIC(7,APCLY,9999999))
GOTO SEC
+6 SET APCLDISC=$PIECE(^DIC(7,APCLY,9999999),U)
IF '$DATA(^APCLACTG(APCLACTG,11,"AC",APCLDISC))
GOTO SEC
PROC21 SET APCLFOUN=1
SET APCLCHN=APCLPRIM
+1 QUIT
SEC ;
+1 SET APCLX=0
FOR
SET APCLX=$ORDER(^AUPNVPRV("AD",APCLVDFN,APCLX))
IF APCLX'=+APCLX
QUIT
IF $PIECE(^AUPNVPRV(APCLX,0),U,4)="S"
SET APCLCHN=APCLX
Begin DoDot:1
+2 SET APCLAP=$PIECE(^AUPNVPRV(APCLX,0),U)
+3 IF $PIECE(^DD(9000010.06,.01,0),U,2)[200
SET APCLDISC=$$PROVCLSC^XBFUNC1(APCLAP)
IF '$DATA(^APCLACTG(APCLACTG,11,"AC",APCLDISC))
QUIT
GOTO SEC1
+4 SET APCLY=$PIECE(^DIC(6,APCLAP,0),U,4)
+5 IF APCLY=""
QUIT
+6 IF '$DATA(^DIC(7,APCLY,9999999))
QUIT
+7 SET APCLDISC=$PIECE(^DIC(7,APCLY,9999999),U)
IF '$DATA(^APCLACTG(APCLACTG,11,"AC",APCLDISC))
QUIT
SEC1 SET APCLFOUN=APCLFOUN+1
+1 QUIT
End DoDot:1
+2 QUIT
SET ;
+1 IF APCLSORV="APCLCODE"
SET APCLCODE=""
DO GETCODE
IF 'APCLCODE
QUIT
+2 SET ^("TOTAL")=$SELECT($DATA(^XTMP(APCLNSP,APCLJOB,APCLBT,@APCLSECV,@APCLSORV,"TOTAL")):^("TOTAL")+1,1:1)
+3 IF $PIECE(^AUPNVPRV(APCLCHN,0),U,4)="P"
SET ^("PRIM")=$SELECT($DATA(^XTMP(APCLNSP,APCLJOB,APCLBT,@APCLSECV,@APCLSORV,"PRIM")):^("PRIM")+1,1:1)
+4 IF $PIECE(^AUPNVPRV(APCLCHN,0),U,4)'="P"
SET ^("SEC")=$SELECT($DATA(^XTMP(APCLNSP,APCLJOB,APCLBT,@APCLSECV,@APCLSORV,"SEC")):^("SEC")+1,1:1)
+5 IF '$DATA(^AUPNVTM("AD",APCLVDFN))
SET ^("NOACT")=$SELECT($DATA(^XTMP(APCLNSP,APCLJOB,APCLBT,@APCLSECV,"NOACT")):^("NOACT")+1,1:1)
QUIT
+6 SET APCLVTM=$ORDER(^AUPNVTM("AD",APCLVDFN,""))
SET APCLVACT=$PIECE(^AUPNVTM(APCLVTM,0),U)*APCLFOUN
SET APCLVTT=$PIECE(^AUPNVTM(APCLVTM,0),U,4)
+7 SET ^("ACT")=$SELECT($DATA(^XTMP(APCLNSP,APCLJOB,APCLBT,@APCLSECV,@APCLSORV,"ACT")):^("ACT")+APCLVACT,1:APCLVACT)
+8 IF APCLVTT
SET ^("TT")=$SELECT($DATA(^XTMP(APCLNSP,APCLJOB,APCLBT,@APCLSECV,@APCLSORV,"TT")):^("TT")+APCLVTT,1:APCLVTT)
+9 QUIT
GETCODE ;
+1 DO GETPPOV
+2 SET APCLIPTR=$PIECE(^AUPNVPOV(APCL1,0),U)
+3 IF $GET(APCLRRTN)]""
DO @APCLRRTN
QUIT
+4 SET APCLCODE=APCLIPTR
+5 QUIT
GETPPOV ;
+1 IF $PIECE(APCLVREC,U,7)'="H"
SET APCL1=$ORDER(^AUPNVPOV("AD",APCLVDFN,""))
QUIT
+2 SET (APCL1,APCL2)=0
FOR
SET APCL2=$ORDER(^AUPNVPOV("AD",APCLVDFN,APCL2))
IF APCL2'=+APCL2!(APCL1)
QUIT
IF $PIECE(^AUPNVPOV(APCL2,0),U,12)="P"
SET APCL1=APCL2
+3 QUIT