APCLDV2P ; IHS/CMI/LAB - list refusals ;
;;2.0;IHS PCC SUITE;;MAY 14, 2009
;
;
PRINT ;EP - called from xbdbque
D PRINT1
D DONE
Q
PRINT1 ;
S APCLPG=0 K APCLQUIT
K APCLLSTP
I '$D(^XTMP("APCLDV2",APCLJ,APCLH)) D HEADER W !!,"No data to report.",! G DONE
D HEADER
S APCLTOT=APCLCNT
S APCLPTOT=$$PTOT
W !," Total Number of Visits with Screening",?40,$J($$COM(APCLTOT,0),8)
W !," Total Number of Patients screened",?40,$J($$COM(APCLPTOT,0),8)
D RES
Q:$$END
D GENDER
Q:$$END
D AGE
Q:$$END
D PRVSC
Q:$$END
D PRVV
Q:$$END
D DESPRV
Q:$$END
D CLINIC
Q:$$END
D DATE
Q:$$END
K ^TMP($J)
I APCLLIST D LIST
Q
RES ;
Q:'$D(APCLTALL(1))
;TALLY BY RESULT FIRST
K APCLRES S X=0 F S X=$O(^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X)) Q:X'=+X D
.S APCLY=^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X)
.S R=$P(APCLY,U,3) S:R="" R="NO RESULT RECORDED" S APCLRES(R)=$G(APCLRES(R))+1
W !
W !," By Result",!
S APCLX="" F S APCLX=$O(APCLRES(APCLX)) Q:APCLX=""!($D(APCLQUIT)) D
.S Y=$L(APCLX),Y=38-Y W !?Y,APCLX,?40,$J($$COM($G(APCLRES(APCLX)),0),8),?55,$$PER(APCLRES(APCLX),APCLTOT) K APCLRES(APCLX)
Q
GENDER ;
Q:'$D(APCLTALL(2))
;TALLY BY GENDER OF PATIENT
K APCLRES S X=0 F S X=$O(^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X)) Q:X'=+X D
.S APCLY=^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X)
.S R=$P(APCLY,U,6) S APCLRES(R)=$G(APCLRES(R))+1
W !
W !," By Gender",!
S APCLX="" F S APCLX=$O(APCLRES(APCLX)) Q:APCLX=""!($D(APCLQUIT)) D
.Q:$$END
.S Y=$L(APCLX),Y=38-Y W !?Y,APCLX,?40,$J($$COM($G(APCLRES(APCLX)),0),8),?55,$$PER(APCLRES(APCLX),APCLTOT) K APCLRES(APCLX)
.Q
Q
AGE ;
Q:'$D(APCLTALL(3))
;TALLY BY age OF PATIENT
K APCLRES S X=0 F S X=$O(^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X)) Q:X'=+X D
.S APCLY=^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X)
.S R=$P(APCLY,U,5) S APCLRES(R)=$G(APCLRES(R))+1
W !
W !," By Age",!
S APCLX="" F S APCLX=$O(APCLRES(APCLX)) Q:APCLX=""!($D(APCLQUIT)) D
.Q:$$END
.S Y=$L(APCLX_" yrs"),Y=38-Y W !?Y,APCLX," yrs",?40,$J($$COM($G(APCLRES(APCLX)),0),8),?55,$$PER(APCLRES(APCLX),APCLTOT) K APCLRES(APCLX)
Q
PRVSC ;
Q:'$D(APCLTALL(4))
;TALLY BY PRIMARY provider OF service
K APCLRES S X=0 F S X=$O(^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X)) Q:X'=+X D
.S APCLY=^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X)
.S R=$P(APCLY,U,16) S:R="" R="UNKNOWN" S APCLRES(R)=$G(APCLRES(R))+1
W !
W !," By Provider who screened",!
S APCLX="" F S APCLX=$O(APCLRES(APCLX)) Q:APCLX=""!($D(APCLQUIT)) D
.Q:$$END
.S Y=$L(APCLX),Y=38-Y W !?Y,APCLX,?40,$J($$COM($G(APCLRES(APCLX)),0),8),?55,$$PER(APCLRES(APCLX),APCLTOT) K APCLRES(APCLX)
Q
PRVV ;
Q:'$D(APCLTALL(5))
K APCLRES S X=0 F S X=$O(^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X)) Q:X'=+X D
.S APCLY=^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X)
.S R=$P(APCLY,U,2) S APCLRES(R)=$G(APCLRES(R))+1
W !
W !," By Primary Provider of Visit",!
S APCLX="" F S APCLX=$O(APCLRES(APCLX)) Q:APCLX=""!($D(APCLQUIT)) D
.Q:$$END
.S Y=$L(APCLX),Y=38-Y W !?Y,APCLX,?40,$J($$COM($G(APCLRES(APCLX)),0),8),?55,$$PER(APCLRES(APCLX),APCLTOT) K APCLRES(APCLX)
Q
DESPRV ;
Q:'$D(APCLTALL(6))
K APCLRES S X=0 F S X=$O(^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X)) Q:X'=+X D
.S APCLY=^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X)
.S R=$P(APCLY,U,17) S:R="" R="UNKNOWN" S APCLRES(R)=$G(APCLRES(R))+1
W !
W !," By Designated Primary Care Provider",!
S APCLX="" F S APCLX=$O(APCLRES(APCLX)) Q:APCLX=""!($D(APCLQUIT)) D
.Q:$$END
.S Y=$L(APCLX),Y=38-Y W !?Y,APCLX,?40,$J($$COM($G(APCLRES(APCLX)),0),8),?55,$$PER(APCLRES(APCLX),APCLTOT) K APCLRES(APCLX)
Q
CLINIC ;
Q:'$D(APCLTALL(7))
;TALLY BY clinic
K APCLRES S X=0 F S X=$O(^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X)) Q:X'=+X D
.S APCLY=^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X)
.S R=$P(APCLY,U,10) S:R="" R="UNKNOWN" S APCLRES(R)=$G(APCLRES(R))+1
W !
W !," By Clinic",!
S APCLX="" F S APCLX=$O(APCLRES(APCLX)) Q:APCLX=""!($D(APCLQUIT)) D
.Q:$$END
.S Y=$L(APCLX),Y=38-Y W !?Y,APCLX,?40,$J($$COM($G(APCLRES(APCLX)),0),8),?55,$$PER(APCLRES(APCLX),APCLTOT) K APCLRES(APCLX)
Q
DATE ;
Q:'$D(APCLTALL(8))
;TALLY BY date OF service
K ^TMP($J) S X=0 F S X=$O(^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X)) Q:X'=+X D
.S APCLY=^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X)
.S R=$P(APCLY,U,7) S ^TMP($J,R)=$G(^TMP($J,R))+1
W !
W !," By Date",!
S APCLX="" F S APCLX=$O(^TMP($J,APCLX)) Q:APCLX=""!($D(APCLQUIT)) D
.Q:$$END
.S Y=$L($$FMTE^XLFDT(APCLX)),Y=38-Y W !?Y,$$FMTE^XLFDT(APCLX),?40,$J($$COM($G(^TMP($J,APCLX)),0),8),?55,$$PER(^TMP($J,APCLX),APCLTOT) K ^TMP($J,APCLX)
Q
;
PER(N,D) ;return % of n/d
I 'D Q "0%"
NEW Z
S Z=N/D,Z=Z*100,Z=$J(Z,5,1)
Q $$STRIP^XLFSTR(Z," ")_"%"
COM(X,X2,X3) ;
D COMMA^%DTC
Q $$STRIP^XLFSTR(X," ")
END() ;
I $Y<(IOSL-3) Q 0
D HEADER
I $D(APCLQUIT) Q 1
Q 0
ENDL() ;
I $Y<(IOSL-8) Q 0
D HEADER
I $D(APCLQUIT) Q 1
Q 0
PTOT() ;
NEW C,X
S C=0
S X=0 F S X=$O(^XTMP("APCLDV2",APCLJ,APCLH,"PTS",X)) Q:X'=+X S C=C+1
Q C
TOT() ;
NEW C,X
S C=0
S X=0 F S X=$O(^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X)) Q:X'=+X S C=C+1
Q C
G:'APCLPG HEADER1
K DIR I $E(IOST)="C",IO=IO(0) W ! S DIR(0)="EO" D ^DIR K DIR I Y=0!(Y="^")!($D(DTOUT)) S APCLQUIT="" Q
W:$D(IOF) @IOF S APCLPG=APCLPG+1
W !?3,$P(^VA(200,DUZ,0),U,2),?35,$$FMTE^XLFDT(DT),?70,"Page ",APCLPG,!
W !,$$CTR("*** IPV SCREENING VISIT TALLY"_$S(APCLLIST:" AND VISIT LISTING",1:"")_" ***",80),!
S X="Screening Dates: "_$$FMTE^XLFDT(APCLBD)_" to "_$$FMTE^XLFDT(APCLED) W $$CTR(X,80),!
I APCLEXBH S X="This report includes Behavioral Health Clinics" W $$CTR(X,80),!
I 'APCLEXBH S X="This report excludes Behavioral Health Clinics" W $$CTR(X,80),!
D LOCHDR^APCLDV1P,COMMHDR^APCLDV1P
I $G(APCLLSTP) W !?35,"DATE",!,"PATIENT NAME",?22,"HRN",?29,"AGE",?35,"SCREENED",?44,"RESULT",?61,"CLINIC"
W !,$TR($J("",80)," ","-")
I '$G(APCLLSTP) W !?46,"#",?53,"% of patients"
Q
DONE ;
K ^TMP($J)
K ^XTMP("APCLDV2",APCLJ,APCLH)
D EOP
Q
CTR(X,Y) ;EP - Center X in a field Y wide.
Q $J("",$S($D(Y):Y,1:IOM)-$L(X)\2)_X
;----------
EOP ;EP - End of page.
Q:$E(IOST)'="C"
Q:IO'=IO(0)
Q:$D(ZTQUEUED)!'(IOT="TRM")!$D(IO("S"))
NEW DIR
K DIRUT,DFOUT,DLOUT,DTOUT,DUOUT
W !
S DIR("A")="End of Report. Press Enter",DIR(0)="E" D ^DIR
Q
;----------
USR() ;EP - Return name of current user from ^VA(200.
Q $S($G(DUZ):$S($D(^VA(200,DUZ,0)):$P(^(0),U),1:"UNKNOWN"),1:"DUZ UNDEFINED OR 0")
;----------
LOC() ;EP - Return location name from file 4 based on DUZ(2).
Q $S($G(DUZ(2)):$S($D(^DIC(4,DUZ(2),0)):$P(^(0),U),1:"UNKNOWN"),1:"DUZ(2) UNDEFINED OR 0")
;----------
LIST ;EP - called from xbdbque
S APCLPG=0 K APCLQUIT
S APCLLSTP=1
D HEADER
K ^TMP($J)
;resort by sort item
S APCLX=0 F S APCLX=$O(^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",APCLX)) Q:APCLX'=+APCLX S APCLY=^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",APCLX) D
.S DFN=$P(APCLY,U,9)
.D @APCLSORT
.I APCLSORV="" S APCLSORV="--"
.S ^TMP($J,"VSTS",APCLSORV,APCLX)=APCLY
.Q
S APCLSORV="" F S APCLSORV=$O(^TMP($J,"VSTS",APCLSORV)) Q:APCLSORV=""!($D(APCLQUIT)) D
.S APCLX=0 F S APCLX=$O(^TMP($J,"VSTS",APCLSORV,APCLX)) Q:APCLX'=+APCLX!($D(APCLQUIT)) D
..Q:$$ENDL
..S APCLY=^TMP($J,"VSTS",APCLSORV,APCLX),DFN=$P(APCLY,U,9)
..W !,$E($P(^DPT(DFN,0),U),1,20),?22,$$HRN^AUPNPAT(DFN,DUZ(2)),?29,$P(APCLY,U,5),?33,$P(^DPT(DFN,0),U,2),?35,$$DT($P(APCLY,U,7)),?44,$E($P(APCLY,U,3),1,16),?61,$E($P(APCLY,U,10),1,17)
..I $P(APCLY,U,4)]"" W !?3,"Comment: ",$P(APCLY,U,4)
..I $P(APCLY,U,1)="EX" S APCLV=$P(APCLY,U,15) I $D(^AUPNVPOV("AD",APCLV)) D
...S APCLC=0 W !?3,"DXs: "
...S APCLS=0 F S APCLS=$O(^AUPNVPOV("AD",APCLV,APCLS)) Q:APCLS'=+APCLS!($D(APCLQUIT)) D
....S APCLC=APCLC+1
....W:APCLC'=1 ! W ?8,$$VAL^XBDIQ1(9000010.07,APCLS,.01),?17,$E($$VAL^XBDIQ1(9000010.07,APCLS,.04),1,60)
..I $P(APCLY,U,1)="BH" S APCLV=$P(APCLY,U,15) I $D(^AMHRPRO("AD",APCLV)) D
...S APCLC=0 W !?3,"DXs: "
...S APCLS=0 F S APCLS=$O(^AMHRPRO("AD",APCLV,APCLS)) Q:APCLS'=+APCLS!($D(APCLQUIT)) D
....S APCLC=APCLC+1
....W:APCLC'=1 ! W ?8,$$VAL^XBDIQ1(9002011.01,APCLS,.01),?17,$E($$VAL^XBDIQ1(9002011.01,APCLS,.04),1,60)
..I $P(APCLY,U,1)="REF" S APCLD=$P(APCLY,U,7) D
...K APCLV S A="APCLV(",B=DFN_"^ALL VISITS;DURING "_$$FMTE^XLFDT(APCLD)_"-"_$$FMTE^XLFDT(APCLD),E=$$START1^APCLDF(B,A)
...I $D(APCLV) S APCLV1=0 F S APCLV1=$O(APCLV(APCLV1)) Q:APCLV1'=+APCLV1 S APCLV=$P(APCLV(APCLV1),U,5) D
....S APCLC=0 W !?3,"DXs: "
....S APCLS=0 F S APCLS=$O(^AUPNVPOV("AD",APCLV,APCLS)) Q:APCLS'=+APCLS!($D(APCLQUIT)) D
.....S APCLC=APCLC+1
.....W:APCLC'=1 ! W ?8,$$VAL^XBDIQ1(9000010.07,APCLS,.01),?17,$E($$VAL^XBDIQ1(9000010.07,APCLS,.04),1,60)
..W !?3,"Primary Provider on Visit: ",?31,$P(APCLY,U,2)
..W !?3," Primary who screened: ",?31,$P(APCLY,U,16)
Q
H ;
S APCLSORV=$$HRN^AUPNPAT(DFN,DUZ(2))
Q
N ;
S APCLSORV=$P(^DPT(DFN,0),U)
Q
P ;
S APCLSORV=$P(APCLY,U,2)
Q
R ;
S APCLSORV=$P(APCLY,U,3)
Q
D ;
S APCLSORV=$P(APCLY,U,7)
Q
A S APCLSORV=$P(APCLY,U,5)
Q
G ;
S APCLSORV=$P(APCLY,U,6)
Q
C ;
S APCLSORV=$P(APCLY,U,10)
Q
T ;
S %=$$HRN^AUPNPAT(DFN,DUZ(2))
S %=%+10000000,%=$E(%,7,8)_"-"_+$E(%,2,8)
S APCLSORV=%
Q
DT(D) ;EP
I D="" Q ""
Q $E(D,4,5)_"/"_$E(D,6,7)_"/"_$E(D,2,3)
;
APCLDV2P ; IHS/CMI/LAB - list refusals ;
+1 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
+2 ;
+3 ;
PRINT ;EP - called from xbdbque
+1 DO PRINT1
+2 DO DONE
+3 QUIT
PRINT1 ;
+1 SET APCLPG=0
KILL APCLQUIT
+2 KILL APCLLSTP
+3 IF '$DATA(^XTMP("APCLDV2",APCLJ,APCLH))
DO HEADER
WRITE !!,"No data to report.",!
GOTO DONE
+4 DO HEADER
+5 SET APCLTOT=APCLCNT
+6 SET APCLPTOT=$$PTOT
+7 WRITE !," Total Number of Visits with Screening",?40,$JUSTIFY($$COM(APCLTOT,0),8)
+8 WRITE !," Total Number of Patients screened",?40,$JUSTIFY($$COM(APCLPTOT,0),8)
+9 DO RES
+10 IF $$END
QUIT
+11 DO GENDER
+12 IF $$END
QUIT
+13 DO AGE
+14 IF $$END
QUIT
+15 DO PRVSC
+16 IF $$END
QUIT
+17 DO PRVV
+18 IF $$END
QUIT
+19 DO DESPRV
+20 IF $$END
QUIT
+21 DO CLINIC
+22 IF $$END
QUIT
+23 DO DATE
+24 IF $$END
QUIT
+25 KILL ^TMP($JOB)
+26 IF APCLLIST
DO LIST
+27 QUIT
RES ;
+1 IF '$DATA(APCLTALL(1))
QUIT
+2 ;TALLY BY RESULT FIRST
+3 KILL APCLRES
SET X=0
FOR
SET X=$ORDER(^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X))
IF X'=+X
QUIT
Begin DoDot:1
+4 SET APCLY=^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X)
+5 SET R=$PIECE(APCLY,U,3)
IF R=""
SET R="NO RESULT RECORDED"
SET APCLRES(R)=$GET(APCLRES(R))+1
End DoDot:1
+6 WRITE !
+7 WRITE !," By Result",!
+8 SET APCLX=""
FOR
SET APCLX=$ORDER(APCLRES(APCLX))
IF APCLX=""!($DATA(APCLQUIT))
QUIT
Begin DoDot:1
+9 SET Y=$LENGTH(APCLX)
SET Y=38-Y
WRITE !?Y,APCLX,?40,$JUSTIFY($$COM($GET(APCLRES(APCLX)),0),8),?55,$$PER(APCLRES(APCLX),APCLTOT)
KILL APCLRES(APCLX)
End DoDot:1
+10 QUIT
GENDER ;
+1 IF '$DATA(APCLTALL(2))
QUIT
+2 ;TALLY BY GENDER OF PATIENT
+3 KILL APCLRES
SET X=0
FOR
SET X=$ORDER(^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X))
IF X'=+X
QUIT
Begin DoDot:1
+4 SET APCLY=^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X)
+5 SET R=$PIECE(APCLY,U,6)
SET APCLRES(R)=$GET(APCLRES(R))+1
End DoDot:1
+6 WRITE !
+7 WRITE !," By Gender",!
+8 SET APCLX=""
FOR
SET APCLX=$ORDER(APCLRES(APCLX))
IF APCLX=""!($DATA(APCLQUIT))
QUIT
Begin DoDot:1
+9 IF $$END
QUIT
+10 SET Y=$LENGTH(APCLX)
SET Y=38-Y
WRITE !?Y,APCLX,?40,$JUSTIFY($$COM($GET(APCLRES(APCLX)),0),8),?55,$$PER(APCLRES(APCLX),APCLTOT)
KILL APCLRES(APCLX)
+11 QUIT
End DoDot:1
+12 QUIT
AGE ;
+1 IF '$DATA(APCLTALL(3))
QUIT
+2 ;TALLY BY age OF PATIENT
+3 KILL APCLRES
SET X=0
FOR
SET X=$ORDER(^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X))
IF X'=+X
QUIT
Begin DoDot:1
+4 SET APCLY=^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X)
+5 SET R=$PIECE(APCLY,U,5)
SET APCLRES(R)=$GET(APCLRES(R))+1
End DoDot:1
+6 WRITE !
+7 WRITE !," By Age",!
+8 SET APCLX=""
FOR
SET APCLX=$ORDER(APCLRES(APCLX))
IF APCLX=""!($DATA(APCLQUIT))
QUIT
Begin DoDot:1
+9 IF $$END
QUIT
+10 SET Y=$LENGTH(APCLX_" yrs")
SET Y=38-Y
WRITE !?Y,APCLX," yrs",?40,$JUSTIFY($$COM($GET(APCLRES(APCLX)),0),8),?55,$$PER(APCLRES(APCLX),APCLTOT)
KILL APCLRES(APCLX)
End DoDot:1
+11 QUIT
PRVSC ;
+1 IF '$DATA(APCLTALL(4))
QUIT
+2 ;TALLY BY PRIMARY provider OF service
+3 KILL APCLRES
SET X=0
FOR
SET X=$ORDER(^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X))
IF X'=+X
QUIT
Begin DoDot:1
+4 SET APCLY=^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X)
+5 SET R=$PIECE(APCLY,U,16)
IF R=""
SET R="UNKNOWN"
SET APCLRES(R)=$GET(APCLRES(R))+1
End DoDot:1
+6 WRITE !
+7 WRITE !," By Provider who screened",!
+8 SET APCLX=""
FOR
SET APCLX=$ORDER(APCLRES(APCLX))
IF APCLX=""!($DATA(APCLQUIT))
QUIT
Begin DoDot:1
+9 IF $$END
QUIT
+10 SET Y=$LENGTH(APCLX)
SET Y=38-Y
WRITE !?Y,APCLX,?40,$JUSTIFY($$COM($GET(APCLRES(APCLX)),0),8),?55,$$PER(APCLRES(APCLX),APCLTOT)
KILL APCLRES(APCLX)
End DoDot:1
+11 QUIT
PRVV ;
+1 IF '$DATA(APCLTALL(5))
QUIT
+2 KILL APCLRES
SET X=0
FOR
SET X=$ORDER(^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X))
IF X'=+X
QUIT
Begin DoDot:1
+3 SET APCLY=^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X)
+4 SET R=$PIECE(APCLY,U,2)
SET APCLRES(R)=$GET(APCLRES(R))+1
End DoDot:1
+5 WRITE !
+6 WRITE !," By Primary Provider of Visit",!
+7 SET APCLX=""
FOR
SET APCLX=$ORDER(APCLRES(APCLX))
IF APCLX=""!($DATA(APCLQUIT))
QUIT
Begin DoDot:1
+8 IF $$END
QUIT
+9 SET Y=$LENGTH(APCLX)
SET Y=38-Y
WRITE !?Y,APCLX,?40,$JUSTIFY($$COM($GET(APCLRES(APCLX)),0),8),?55,$$PER(APCLRES(APCLX),APCLTOT)
KILL APCLRES(APCLX)
End DoDot:1
+10 QUIT
DESPRV ;
+1 IF '$DATA(APCLTALL(6))
QUIT
+2 KILL APCLRES
SET X=0
FOR
SET X=$ORDER(^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X))
IF X'=+X
QUIT
Begin DoDot:1
+3 SET APCLY=^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X)
+4 SET R=$PIECE(APCLY,U,17)
IF R=""
SET R="UNKNOWN"
SET APCLRES(R)=$GET(APCLRES(R))+1
End DoDot:1
+5 WRITE !
+6 WRITE !," By Designated Primary Care Provider",!
+7 SET APCLX=""
FOR
SET APCLX=$ORDER(APCLRES(APCLX))
IF APCLX=""!($DATA(APCLQUIT))
QUIT
Begin DoDot:1
+8 IF $$END
QUIT
+9 SET Y=$LENGTH(APCLX)
SET Y=38-Y
WRITE !?Y,APCLX,?40,$JUSTIFY($$COM($GET(APCLRES(APCLX)),0),8),?55,$$PER(APCLRES(APCLX),APCLTOT)
KILL APCLRES(APCLX)
End DoDot:1
+10 QUIT
CLINIC ;
+1 IF '$DATA(APCLTALL(7))
QUIT
+2 ;TALLY BY clinic
+3 KILL APCLRES
SET X=0
FOR
SET X=$ORDER(^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X))
IF X'=+X
QUIT
Begin DoDot:1
+4 SET APCLY=^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X)
+5 SET R=$PIECE(APCLY,U,10)
IF R=""
SET R="UNKNOWN"
SET APCLRES(R)=$GET(APCLRES(R))+1
End DoDot:1
+6 WRITE !
+7 WRITE !," By Clinic",!
+8 SET APCLX=""
FOR
SET APCLX=$ORDER(APCLRES(APCLX))
IF APCLX=""!($DATA(APCLQUIT))
QUIT
Begin DoDot:1
+9 IF $$END
QUIT
+10 SET Y=$LENGTH(APCLX)
SET Y=38-Y
WRITE !?Y,APCLX,?40,$JUSTIFY($$COM($GET(APCLRES(APCLX)),0),8),?55,$$PER(APCLRES(APCLX),APCLTOT)
KILL APCLRES(APCLX)
End DoDot:1
+11 QUIT
DATE ;
+1 IF '$DATA(APCLTALL(8))
QUIT
+2 ;TALLY BY date OF service
+3 KILL ^TMP($JOB)
SET X=0
FOR
SET X=$ORDER(^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X))
IF X'=+X
QUIT
Begin DoDot:1
+4 SET APCLY=^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X)
+5 SET R=$PIECE(APCLY,U,7)
SET ^TMP($JOB,R)=$GET(^TMP($JOB,R))+1
End DoDot:1
+6 WRITE !
+7 WRITE !," By Date",!
+8 SET APCLX=""
FOR
SET APCLX=$ORDER(^TMP($JOB,APCLX))
IF APCLX=""!($DATA(APCLQUIT))
QUIT
Begin DoDot:1
+9 IF $$END
QUIT
+10 SET Y=$LENGTH($$FMTE^XLFDT(APCLX))
SET Y=38-Y
WRITE !?Y,$$FMTE^XLFDT(APCLX),?40,$JUSTIFY($$COM($GET(^TMP($JOB,APCLX)),0),8),?55,$$PER(^TMP($JOB,APCLX),APCLTOT)
KILL ^TMP($JOB,APCLX)
End DoDot:1
+11 QUIT
+12 ;
PER(N,D) ;return % of n/d
+1 IF 'D
QUIT "0%"
+2 NEW Z
+3 SET Z=N/D
SET Z=Z*100
SET Z=$JUSTIFY(Z,5,1)
+4 QUIT $$STRIP^XLFSTR(Z," ")_"%"
COM(X,X2,X3) ;
+1 DO COMMA^%DTC
+2 QUIT $$STRIP^XLFSTR(X," ")
END() ;
+1 IF $Y<(IOSL-3)
QUIT 0
+2 DO HEADER
+3 IF $DATA(APCLQUIT)
QUIT 1
+4 QUIT 0
ENDL() ;
+1 IF $Y<(IOSL-8)
QUIT 0
+2 DO HEADER
+3 IF $DATA(APCLQUIT)
QUIT 1
+4 QUIT 0
PTOT() ;
+1 NEW C,X
+2 SET C=0
+3 SET X=0
FOR
SET X=$ORDER(^XTMP("APCLDV2",APCLJ,APCLH,"PTS",X))
IF X'=+X
QUIT
SET C=C+1
+4 QUIT C
TOT() ;
+1 NEW C,X
+2 SET C=0
+3 SET X=0
FOR
SET X=$ORDER(^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",X))
IF X'=+X
QUIT
SET C=C+1
+4 QUIT C
+1 IF 'APCLPG
GOTO HEADER1
+2 KILL DIR
IF $EXTRACT(IOST)="C"
IF IO=IO(0)
WRITE !
SET DIR(0)="EO"
DO ^DIR
KILL DIR
IF Y=0!(Y="^")!($DATA(DTOUT))
SET APCLQUIT=""
QUIT
+1 IF $DATA(IOF)
WRITE @IOF
SET APCLPG=APCLPG+1
+2 WRITE !?3,$PIECE(^VA(200,DUZ,0),U,2),?35,$$FMTE^XLFDT(DT),?70,"Page ",APCLPG,!
+3 WRITE !,$$CTR("*** IPV SCREENING VISIT TALLY"_$SELECT(APCLLIST:" AND VISIT LISTING",1:"")_" ***",80),!
+4 SET X="Screening Dates: "_$$FMTE^XLFDT(APCLBD)_" to "_$$FMTE^XLFDT(APCLED)
WRITE $$CTR(X,80),!
+5 IF APCLEXBH
SET X="This report includes Behavioral Health Clinics"
WRITE $$CTR(X,80),!
+6 IF 'APCLEXBH
SET X="This report excludes Behavioral Health Clinics"
WRITE $$CTR(X,80),!
+7 DO LOCHDR^APCLDV1P
DO COMMHDR^APCLDV1P
+8 IF $GET(APCLLSTP)
WRITE !?35,"DATE",!,"PATIENT NAME",?22,"HRN",?29,"AGE",?35,"SCREENED",?44,"RESULT",?61,"CLINIC"
+9 WRITE !,$TRANSLATE($JUSTIFY("",80)," ","-")
+10 IF '$GET(APCLLSTP)
WRITE !?46,"#",?53,"% of patients"
+11 QUIT
DONE ;
+1 KILL ^TMP($JOB)
+2 KILL ^XTMP("APCLDV2",APCLJ,APCLH)
+3 DO EOP
+4 QUIT
CTR(X,Y) ;EP - Center X in a field Y wide.
+1 QUIT $JUSTIFY("",$SELECT($DATA(Y):Y,1:IOM)-$LENGTH(X)\2)_X
+2 ;----------
EOP ;EP - End of page.
+1 IF $EXTRACT(IOST)'="C"
QUIT
+2 IF IO'=IO(0)
QUIT
+3 IF $DATA(ZTQUEUED)!'(IOT="TRM")!$DATA(IO("S"))
QUIT
+4 NEW DIR
+5 KILL DIRUT,DFOUT,DLOUT,DTOUT,DUOUT
+6 WRITE !
+7 SET DIR("A")="End of Report. Press Enter"
SET DIR(0)="E"
DO ^DIR
+8 QUIT
+9 ;----------
USR() ;EP - Return name of current user from ^VA(200.
+1 QUIT $SELECT($GET(DUZ):$SELECT($DATA(^VA(200,DUZ,0)):$PIECE(^(0),U),1:"UNKNOWN"),1:"DUZ UNDEFINED OR 0")
+2 ;----------
LOC() ;EP - Return location name from file 4 based on DUZ(2).
+1 QUIT $SELECT($GET(DUZ(2)):$SELECT($DATA(^DIC(4,DUZ(2),0)):$PIECE(^(0),U),1:"UNKNOWN"),1:"DUZ(2) UNDEFINED OR 0")
+2 ;----------
LIST ;EP - called from xbdbque
+1 SET APCLPG=0
KILL APCLQUIT
+2 SET APCLLSTP=1
+3 DO HEADER
+4 KILL ^TMP($JOB)
+5 ;resort by sort item
+6 SET APCLX=0
FOR
SET APCLX=$ORDER(^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",APCLX))
IF APCLX'=+APCLX
QUIT
SET APCLY=^XTMP("APCLDV2",APCLJ,APCLH,"VSTS",APCLX)
Begin DoDot:1
+7 SET DFN=$PIECE(APCLY,U,9)
+8 DO @APCLSORT
+9 IF APCLSORV=""
SET APCLSORV="--"
+10 SET ^TMP($JOB,"VSTS",APCLSORV,APCLX)=APCLY
+11 QUIT
End DoDot:1
+12 SET APCLSORV=""
FOR
SET APCLSORV=$ORDER(^TMP($JOB,"VSTS",APCLSORV))
IF APCLSORV=""!($DATA(APCLQUIT))
QUIT
Begin DoDot:1
+13 SET APCLX=0
FOR
SET APCLX=$ORDER(^TMP($JOB,"VSTS",APCLSORV,APCLX))
IF APCLX'=+APCLX!($DATA(APCLQUIT))
QUIT
Begin DoDot:2
+14 IF $$ENDL
QUIT
+15 SET APCLY=^TMP($JOB,"VSTS",APCLSORV,APCLX)
SET DFN=$PIECE(APCLY,U,9)
+16 WRITE !,$EXTRACT($PIECE(^DPT(DFN,0),U),1,20),?22,$$HRN^AUPNPAT(DFN,DUZ(2)),?29,$PIECE(APCLY,U,5),?33,$PIECE(^DPT(DFN,0),U,2),?35,$$DT($PIECE(APCLY,U,7)),?44,$EXTRACT($PIECE(APCLY,U,3),1,16),?61,$EXTRACT($PIECE(APCLY,U,10),1,17)
+17 IF $PIECE(APCLY,U,4)]""
WRITE !?3,"Comment: ",$PIECE(APCLY,U,4)
+18 IF $PIECE(APCLY,U,1)="EX"
SET APCLV=$PIECE(APCLY,U,15)
IF $DATA(^AUPNVPOV("AD",APCLV))
Begin DoDot:3
+19 SET APCLC=0
WRITE !?3,"DXs: "
+20 SET APCLS=0
FOR
SET APCLS=$ORDER(^AUPNVPOV("AD",APCLV,APCLS))
IF APCLS'=+APCLS!($DATA(APCLQUIT))
QUIT
Begin DoDot:4
+21 SET APCLC=APCLC+1
+22 IF APCLC'=1
WRITE !
WRITE ?8,$$VAL^XBDIQ1(9000010.07,APCLS,.01),?17,$EXTRACT($$VAL^XBDIQ1(9000010.07,APCLS,.04),1,60)
End DoDot:4
End DoDot:3
+23 IF $PIECE(APCLY,U,1)="BH"
SET APCLV=$PIECE(APCLY,U,15)
IF $DATA(^AMHRPRO("AD",APCLV))
Begin DoDot:3
+24 SET APCLC=0
WRITE !?3,"DXs: "
+25 SET APCLS=0
FOR
SET APCLS=$ORDER(^AMHRPRO("AD",APCLV,APCLS))
IF APCLS'=+APCLS!($DATA(APCLQUIT))
QUIT
Begin DoDot:4
+26 SET APCLC=APCLC+1
+27 IF APCLC'=1
WRITE !
WRITE ?8,$$VAL^XBDIQ1(9002011.01,APCLS,.01),?17,$EXTRACT($$VAL^XBDIQ1(9002011.01,APCLS,.04),1,60)
End DoDot:4
End DoDot:3
+28 IF $PIECE(APCLY,U,1)="REF"
SET APCLD=$PIECE(APCLY,U,7)
Begin DoDot:3
+29 KILL APCLV
SET A="APCLV("
SET B=DFN_"^ALL VISITS;DURING "_$$FMTE^XLFDT(APCLD)_"-"_$$FMTE^XLFDT(APCLD)
SET E=$$START1^APCLDF(B,A)
+30 IF $DATA(APCLV)
SET APCLV1=0
FOR
SET APCLV1=$ORDER(APCLV(APCLV1))
IF APCLV1'=+APCLV1
QUIT
SET APCLV=$PIECE(APCLV(APCLV1),U,5)
Begin DoDot:4
+31 SET APCLC=0
WRITE !?3,"DXs: "
+32 SET APCLS=0
FOR
SET APCLS=$ORDER(^AUPNVPOV("AD",APCLV,APCLS))
IF APCLS'=+APCLS!($DATA(APCLQUIT))
QUIT
Begin DoDot:5
+33 SET APCLC=APCLC+1
+34 IF APCLC'=1
WRITE !
WRITE ?8,$$VAL^XBDIQ1(9000010.07,APCLS,.01),?17,$EXTRACT($$VAL^XBDIQ1(9000010.07,APCLS,.04),1,60)
End DoDot:5
End DoDot:4
End DoDot:3
+35 WRITE !?3,"Primary Provider on Visit: ",?31,$PIECE(APCLY,U,2)
+36 WRITE !?3," Primary who screened: ",?31,$PIECE(APCLY,U,16)
End DoDot:2
End DoDot:1
+37 QUIT
H ;
+1 SET APCLSORV=$$HRN^AUPNPAT(DFN,DUZ(2))
+2 QUIT
N ;
+1 SET APCLSORV=$PIECE(^DPT(DFN,0),U)
+2 QUIT
P ;
+1 SET APCLSORV=$PIECE(APCLY,U,2)
+2 QUIT
R ;
+1 SET APCLSORV=$PIECE(APCLY,U,3)
+2 QUIT
D ;
+1 SET APCLSORV=$PIECE(APCLY,U,7)
+2 QUIT
A SET APCLSORV=$PIECE(APCLY,U,5)
+1 QUIT
G ;
+1 SET APCLSORV=$PIECE(APCLY,U,6)
+2 QUIT
C ;
+1 SET APCLSORV=$PIECE(APCLY,U,10)
+2 QUIT
T ;
+1 SET %=$$HRN^AUPNPAT(DFN,DUZ(2))
+2 SET %=%+10000000
SET %=$EXTRACT(%,7,8)_"-"_+$EXTRACT(%,2,8)
+3 SET APCLSORV=%
+4 QUIT
DT(D) ;EP
+1 IF D=""
QUIT ""
+2 QUIT $EXTRACT(D,4,5)_"/"_$EXTRACT(D,6,7)_"/"_$EXTRACT(D,2,3)
+3 ;