APCLAL5P ; IHS/CMI/LAB - list refusals ;
;;2.0;IHS PCC SUITE;**2,8,11**;MAY 14, 2009;Build 58
;
;
PRINT ;EP - called from xbdbque
D PRINT1
D DONE
Q
PRINT1 ;
S APCRPG=0 K APCRQUIT
K APCRLSTP S APCRTALP=0
I '$D(^XTMP("APCLAL5",APCRJ,APCRH)) D HEADER W !!,"No data to report.",! G DONE
D HEADER
S APCRTOT=APCRCNT
S APCRPTOT=$$PTOT
W !," Total Number of Visits with Screening",?40,$J($$COM(APCRTOT,0),8)
W !," Total Number of Patients screened",?40,$J($$COM(APCRPTOT,0),8)
S X=0,C=0 F S X=$O(^DIBT(APCRSEAT,1,X)) Q:X'=+X S C=C+1
W !," Total Number of Patients in Template",?40,$J($$COM(C,0),8)
S APCRTALP=1
W !!?46,"#",?53,"% of patients screened"
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
D MH
Q:$$END
D SS
Q:$$END
D CD
Q:$$END
K ^TMP($J)
I APCRLIST D LIST
Q
RES ;
Q:'$D(APCRTALL(1))
;TALLY BY RESULT FIRST
K APCRRES S X=0 F S X=$O(^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X)) Q:X'=+X D
.S APCRY=^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X)
.S R=$P(APCRY,U,2) S R=$P(R,";")_" "_$P(R,";",2) S:R="" R="NO RESULT RECORDED" S APCRRES(R)=$G(APCRRES(R))+1
W !
W !," By Result",!
S APCRX="" F S APCRX=$O(APCRRES(APCRX)) Q:APCRX=""!($D(APCRQUIT)) D
.S Y=$L(APCRX),Y=38-Y W !?Y,APCRX,?40,$J($$COM($G(APCRRES(APCRX)),0),8),?55,$$PER(APCRRES(APCRX),APCRTOT) K APCRRES(APCRX)
Q
GENDER ;
Q:'$D(APCRTALL(2))
;TALLY BY GENDER OF PATIENT1
K APCRRES S X=0 F S X=$O(^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X)) Q:X'=+X D
.S APCRY=^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X)
.S R=$P(APCRY,U,3) S APCRRES(R)=$G(APCRRES(R))+1
W !
W !," By Gender",!
S APCRX="" F S APCRX=$O(APCRRES(APCRX)) Q:APCRX=""!($D(APCRQUIT)) D
.Q:$$END
.S Y=$L(APCRX),Y=38-Y W !?Y,APCRX,?40,$J($$COM($G(APCRRES(APCRX)),0),8),?55,$$PER(APCRRES(APCRX),APCRTOT) K APCRRES(APCRX)
.Q
Q
AGE ;
Q:'$D(APCRTALL(3))
;TALLY BY age OF PATIENT
K APCRRES S X=0 F S X=$O(^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X)) Q:X'=+X D
.S APCRY=^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X)
.S R=$P(APCRY,U,4) S APCRRES(R)=$G(APCRRES(R))+1
W !
W !," By Age",!
S APCRX="" F S APCRX=$O(APCRRES(APCRX)) Q:APCRX=""!($D(APCRQUIT)) D
.Q:$$END
.S Y=$L(APCRX_" yrs"),Y=38-Y W !?Y,APCRX," yrs",?40,$J($$COM($G(APCRRES(APCRX)),0),8),?55,$$PER(APCRRES(APCRX),APCRTOT) K APCRRES(APCRX)
Q
PRVSC ;
Q:'$D(APCRTALL(4))
;TALLY BY PRIMARY provider OF service
K APCRRES S X=0 F S X=$O(^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X)) Q:X'=+X D
.S APCRY=^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X)
.S R=$P(APCRY,U,5) S:R="" R="UNKNOWN" S APCRRES(R)=$G(APCRRES(R))+1
W !
W !," By Provider who screened",!
S APCRX="" F S APCRX=$O(APCRRES(APCRX)) Q:APCRX=""!($D(APCRQUIT)) D
.Q:$$END
.S Y=$L(APCRX),Y=38-Y W !?Y,APCRX,?40,$J($$COM($G(APCRRES(APCRX)),0),8),?55,$$PER(APCRRES(APCRX),APCRTOT) K APCRRES(APCRX)
Q
PRVV ;
Q:'$D(APCRTALL(7))
K APCRRES S X=0 F S X=$O(^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X)) Q:X'=+X D
.S APCRY=^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X)
.S R=$P(APCRY,U,7) S:R="" R="UNKNOWN" S APCRRES(R)=$G(APCRRES(R))+1
W !
W !," By Primary Provider of Visit",!
S APCRX="" F S APCRX=$O(APCRRES(APCRX)) Q:APCRX=""!($D(APCRQUIT)) D
.Q:$$END
.S Y=$L(APCRX),Y=38-Y W !?Y,APCRX,?40,$J($$COM($G(APCRRES(APCRX)),0),8),?55,$$PER(APCRRES(APCRX),APCRTOT) K APCRRES(APCRX)
Q
DESPRV ;
Q:'$D(APCRTALL(11))
K APCRRES S X=0 F S X=$O(^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X)) Q:X'=+X D
.S APCRY=^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X)
.S R=$P(APCRY,U,11) S:R="" R="UNKNOWN" S APCRRES(R)=$G(APCRRES(R))+1
W !
W !," By Designated Primary Care Provider",!
S APCRX="" F S APCRX=$O(APCRRES(APCRX)) Q:APCRX=""!($D(APCRQUIT)) D
.Q:$$END
.S Y=$L(APCRX),Y=38-Y W !?Y,APCRX,?40,$J($$COM($G(APCRRES(APCRX)),0),8),?55,$$PER(APCRRES(APCRX),APCRTOT) K APCRRES(APCRX)
Q
MH ;
Q:'$D(APCRTALL(8))
K APCRRES S X=0 F S X=$O(^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X)) Q:X'=+X D
.S APCRY=^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X)
.S R=$P(APCRY,U,8) S:R="" R="UNKNOWN" S APCRRES(R)=$G(APCRRES(R))+1
W !
W !," By Designated Mental Health Provider",!
S APCRX="" F S APCRX=$O(APCRRES(APCRX)) Q:APCRX=""!($D(APCRQUIT)) D
.Q:$$END
.S Y=$L(APCRX),Y=38-Y W !?Y,APCRX,?40,$J($$COM($G(APCRRES(APCRX)),0),8),?55,$$PER(APCRRES(APCRX),APCRTOT) K APCRRES(APCRX)
Q
SS ;
Q:'$D(APCRTALL(9))
K APCRRES S X=0 F S X=$O(^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X)) Q:X'=+X D
.S APCRY=^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X)
.S R=$P(APCRY,U,9) S:R="" R="UNKNOWN" S APCRRES(R)=$G(APCRRES(R))+1
W !
W !," By Designated Social Services Provider",!
S APCRX="" F S APCRX=$O(APCRRES(APCRX)) Q:APCRX=""!($D(APCRQUIT)) D
.Q:$$END
.S Y=$L(APCRX),Y=38-Y W !?Y,APCRX,?40,$J($$COM($G(APCRRES(APCRX)),0),8),?55,$$PER(APCRRES(APCRX),APCRTOT) K APCRRES(APCRX)
Q
CD ;
Q:'$D(APCRTALL(10))
K APCRRES S X=0 F S X=$O(^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X)) Q:X'=+X D
.S APCRY=^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X)
.S R=$P(APCRY,U,10) S:R="" R="UNKNOWN" S APCRRES(R)=$G(APCRRES(R))+1
W !
W !," By Designated A/SA Provider",!
S APCRX="" F S APCRX=$O(APCRRES(APCRX)) Q:APCRX=""!($D(APCRQUIT)) D
.Q:$$END
.S Y=$L(APCRX),Y=38-Y W !?Y,APCRX,?40,$J($$COM($G(APCRRES(APCRX)),0),8),?55,$$PER(APCRRES(APCRX),APCRTOT) K APCRRES(APCRX)
Q
CLINIC ;
Q:'$D(APCRTALL(5))
;TALLY BY clinic
K APCRRES S X=0 F S X=$O(^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X)) Q:X'=+X D
.S APCRY=^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X)
.S R=$P(APCRY,U,6) S:R="" R="UNKNOWN" S APCRRES(R)=$G(APCRRES(R))+1
W !
W !," By Clinic",!
S APCRX="" F S APCRX=$O(APCRRES(APCRX)) Q:APCRX=""!($D(APCRQUIT)) D
.Q:$$END
.S Y=$L(APCRX),Y=38-Y W !?Y,APCRX,?40,$J($$COM($G(APCRRES(APCRX)),0),8),?55,$$PER(APCRRES(APCRX),APCRTOT) K APCRRES(APCRX)
Q
DATE ;
Q:'$D(APCRTALL(6))
;TALLY BY date OF service
K ^TMP($J) S X=0 F S X=$O(^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X)) Q:X'=+X D
.S APCRY=^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X)
.S R=$P(APCRY,U,1) S ^TMP($J,R)=$G(^TMP($J,R))+1
W !
W !," By Date",!
S APCRX="" F S APCRX=$O(^TMP($J,APCRX)) Q:APCRX=""!($D(APCRQUIT)) D
.Q:$$END
.S Y=$L($$FMTE^XLFDT(APCRX)),Y=38-Y W !?Y,$$FMTE^XLFDT(APCRX),?40,$J($$COM($G(^TMP($J,APCRX)),0),8),?55,$$PER(^TMP($J,APCRX),APCRTOT) K ^TMP($J,APCRX)
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(APCRQUIT) Q 1
Q 0
ENDL() ;
I $Y<(IOSL-8) Q 0
D HEADER
I $D(APCRQUIT) Q 1
Q 0
PTOT() ;
NEW C,X
S C=0
S X=0 F S X=$O(^XTMP("APCLAL5",APCRJ,APCRH,"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("APCLAL5",APCRJ,APCRH,"VSTS",X)) Q:X'=+X S C=C+1
Q C
G:'APCRPG 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 APCRQUIT="" Q
W:$D(IOF) @IOF S APCRPG=APCRPG+1
W !?3,$P(^VA(200,DUZ,0),U,2),?35,$$FMTE^XLFDT(DT),?70,"Page ",APCRPG,!
W !,$$CTR("*** ALCOHOL SCREENING VISIT TALLY"_$S(APCRLIST:" AND VISIT LISTING",1:"")_" ***",80),!
S X="Screening Dates: "_$$FMTE^XLFDT(APCRBD)_" to "_$$FMTE^XLFDT(APCRED) W $$CTR(X,80),!
I APCLEXBH S X="This report includes data from the Behavioral Health Clinics" W $$CTR(X,80),!
I 'APCLEXBH S X="This report excludes data from the Behavioral Health Clinics" W $$CTR(X,80),!
S X="SEARCH TEMPLATE OF PATIENTS: "_$P(^DIBT(APCRSEAT,0),U) W $$CTR(X,80),!
I $G(APCRLSTP),APCRSCRD S X="Listing of those patients screened" W $$CTR(X,80),!
I $G(APCRLSTP),'APCRSCRD S X="Listing of those NOT Screened" W $$CTR(X,80),!
I $G(APCRLSTP) W !?35,"DATE",!,"PATIENT NAME",?22,"HRN",?29,"AGE",?35,"SCREENED",?55,"CLINIC"
W !,$TR($J("",80)," ","-")
I '$G(APCRLSTP) W !?46,"#",?53,"% of patients",$S(APCRTALP:" screened",1:"")
Q
DONE ;
K ^TMP($J)
K ^XTMP("APCLAL5",APCRJ,APCRH)
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 APCRPG=0 K APCRQUIT
S APCRLSTP=1,APCRSCRD=1
D HEADER
K ^TMP($J)
;resort by sort item
S APCRX=0 F S APCRX=$O(^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",APCRX)) Q:APCRX'=+APCRX S APCRY=^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",APCRX) D
.S DFN=$P(APCRY,U,15)
.D @APCRSORT
.I APCRSORV="" S APCRSORV="--"
.S ^TMP($J,"VSTS",APCRSORV,APCRX)=APCRY
.Q
S APCRSORV="" F S APCRSORV=$O(^TMP($J,"VSTS",APCRSORV)) Q:APCRSORV=""!($D(APCRQUIT)) D
.S APCRZ=0 F S APCRZ=$O(^TMP($J,"VSTS",APCRSORV,APCRZ)) Q:APCRZ'=+APCRZ!($D(APCRQUIT)) D
..Q:$$ENDL
..S APCRY=^TMP($J,"VSTS",APCRSORV,APCRZ),DFN=$P(APCRY,U,15)
..W !!,$E($P(^DPT(DFN,0),U),1,20),?22,$$HRN^AUPNPAT(DFN,DUZ(2)),?29,$P(APCRY,U,4),?33,$P(^DPT(DFN,0),U,2),?35,$$DT($P(APCRY,U,1)),?55,$E($P(APCRY,U,6),1,20)
..W !?3,"Type/Result: ",$P($P(APCRY,U,2),";")_" "_$P($P(APCRY,U,2),";",2)
..I $P(APCRY,U,12)]"" W !?3,"Comment: ",$P(APCRY,U,12)
..I $P(APCRY,U,20)="PCC" S APCRV=$P(APCRY,U,14) I APCRV,$D(^AUPNVPOV("AD",APCRV)) D
...S APCRC=0 W !?3,"DXs: "
...S APCRX=0 F S APCRX=$O(^AUPNVPOV("AD",APCRV,APCRX)) Q:APCRX'=+APCRX!($D(APCRQUIT)) D
....S APCRC=APCRC+1
....W:APCRC'=1 ! W ?8,$$VAL^XBDIQ1(9000010.07,APCRX,.01),?17,$E($$VAL^XBDIQ1(9000010.07,APCRX,.04),1,60)
..I $P(APCRY,U,20)="BH" S APCRV=$P(APCRY,U,15) I APCRV,$D(^AMHRPRO("AD",APCRV)) D
...S APCRC=0 W !?3,"DXs: "
...S APCRX=0 F S APCRX=$O(^AMHRPRO("AD",APCRV,APCRX)) Q:APCRX'=+APCRX!($D(APCRQUIT)) D
....S APCRC=APCRC+1
....W:APCRC'=1 ! W ?8,$$VAL^XBDIQ1(9002011.01,APCRX,.01),?17,$E($$VAL^XBDIQ1(9002011.01,APCRX,.04),1,60)
..W !?3,"Primary Provider on Visit: ",?31,$P(APCRY,U,7)
..W !?3," Provider who screened: ",?31,$P(APCRY,U,5)
S APCRSCRD=0
D HEADER
S DFN=0 F S DFN=$O(^DIBT(APCRSEAT,1,DFN)) Q:DFN'=+DFN!($D(APCRQUIT)) D
.Q:$D(^XTMP("APCLAL5",APCRJ,APCRH,"PTS",DFN))
.Q:$$END
.W !,$E($P(^DPT(DFN,0),U),1,20),?22,$$HRN^AUPNPAT(DFN,DUZ(2)),?29,$$AGE^AUPNPAT(DFN,DT),?33,$P(^DPT(DFN,0),U,2)
Q
H ;
S APCRSORV=$$HRN^AUPNPAT(DFN,DUZ(2))
Q
N ;
S APCRSORV=$P(^DPT(DFN,0),U)
Q
P ;
S APCRSORV=$P(APCRY,U,5)
Q
R ;
S APCRSORV=$P($P(APCRY,U,2),";")_" "_$P($P(APCRY,U,2),";",2)
Q
D ;
S APCRSORV=$P(APCRY,U,1)
Q
A S APCRSORV=$P(APCRY,U,4)
Q
G ;
S APCRSORV=$P(APCRY,U,3)
Q
C ;
S APCRSORV=$P(APCRY,U,6)
Q
T ;
S %=$$HRN^AUPNPAT(DFN,DUZ(2))
S %=%+10000000,%=$E(%,7,8)_"-"_+$E(%,2,8)
S APCRSORV=%
Q
DT(D) ;EP
I D="" Q ""
Q $E(D,4,5)_"/"_$E(D,6,7)_"/"_$E(D,2,3)
;
APCLAL5P ; IHS/CMI/LAB - list refusals ;
+1 ;;2.0;IHS PCC SUITE;**2,8,11**;MAY 14, 2009;Build 58
+2 ;
+3 ;
PRINT ;EP - called from xbdbque
+1 DO PRINT1
+2 DO DONE
+3 QUIT
PRINT1 ;
+1 SET APCRPG=0
KILL APCRQUIT
+2 KILL APCRLSTP
SET APCRTALP=0
+3 IF '$DATA(^XTMP("APCLAL5",APCRJ,APCRH))
DO HEADER
WRITE !!,"No data to report.",!
GOTO DONE
+4 DO HEADER
+5 SET APCRTOT=APCRCNT
+6 SET APCRPTOT=$$PTOT
+7 WRITE !," Total Number of Visits with Screening",?40,$JUSTIFY($$COM(APCRTOT,0),8)
+8 WRITE !," Total Number of Patients screened",?40,$JUSTIFY($$COM(APCRPTOT,0),8)
+9 SET X=0
SET C=0
FOR
SET X=$ORDER(^DIBT(APCRSEAT,1,X))
IF X'=+X
QUIT
SET C=C+1
+10 WRITE !," Total Number of Patients in Template",?40,$JUSTIFY($$COM(C,0),8)
+11 SET APCRTALP=1
+12 WRITE !!?46,"#",?53,"% of patients screened"
+13 DO RES
+14 IF $$END
QUIT
+15 DO GENDER
+16 IF $$END
QUIT
+17 DO AGE
+18 IF $$END
QUIT
+19 DO PRVSC
+20 IF $$END
QUIT
+21 DO PRVV
+22 IF $$END
QUIT
+23 DO DESPRV
+24 IF $$END
QUIT
+25 DO CLINIC
+26 IF $$END
QUIT
+27 DO DATE
+28 IF $$END
QUIT
+29 DO MH
+30 IF $$END
QUIT
+31 DO SS
+32 IF $$END
QUIT
+33 DO CD
+34 IF $$END
QUIT
+35 KILL ^TMP($JOB)
+36 IF APCRLIST
DO LIST
+37 QUIT
RES ;
+1 IF '$DATA(APCRTALL(1))
QUIT
+2 ;TALLY BY RESULT FIRST
+3 KILL APCRRES
SET X=0
FOR
SET X=$ORDER(^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X))
IF X'=+X
QUIT
Begin DoDot:1
+4 SET APCRY=^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X)
+5 SET R=$PIECE(APCRY,U,2)
SET R=$PIECE(R,";")_" "_$PIECE(R,";",2)
IF R=""
SET R="NO RESULT RECORDED"
SET APCRRES(R)=$GET(APCRRES(R))+1
End DoDot:1
+6 WRITE !
+7 WRITE !," By Result",!
+8 SET APCRX=""
FOR
SET APCRX=$ORDER(APCRRES(APCRX))
IF APCRX=""!($DATA(APCRQUIT))
QUIT
Begin DoDot:1
+9 SET Y=$LENGTH(APCRX)
SET Y=38-Y
WRITE !?Y,APCRX,?40,$JUSTIFY($$COM($GET(APCRRES(APCRX)),0),8),?55,$$PER(APCRRES(APCRX),APCRTOT)
KILL APCRRES(APCRX)
End DoDot:1
+10 QUIT
GENDER ;
+1 IF '$DATA(APCRTALL(2))
QUIT
+2 ;TALLY BY GENDER OF PATIENT1
+3 KILL APCRRES
SET X=0
FOR
SET X=$ORDER(^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X))
IF X'=+X
QUIT
Begin DoDot:1
+4 SET APCRY=^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X)
+5 SET R=$PIECE(APCRY,U,3)
SET APCRRES(R)=$GET(APCRRES(R))+1
End DoDot:1
+6 WRITE !
+7 WRITE !," By Gender",!
+8 SET APCRX=""
FOR
SET APCRX=$ORDER(APCRRES(APCRX))
IF APCRX=""!($DATA(APCRQUIT))
QUIT
Begin DoDot:1
+9 IF $$END
QUIT
+10 SET Y=$LENGTH(APCRX)
SET Y=38-Y
WRITE !?Y,APCRX,?40,$JUSTIFY($$COM($GET(APCRRES(APCRX)),0),8),?55,$$PER(APCRRES(APCRX),APCRTOT)
KILL APCRRES(APCRX)
+11 QUIT
End DoDot:1
+12 QUIT
AGE ;
+1 IF '$DATA(APCRTALL(3))
QUIT
+2 ;TALLY BY age OF PATIENT
+3 KILL APCRRES
SET X=0
FOR
SET X=$ORDER(^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X))
IF X'=+X
QUIT
Begin DoDot:1
+4 SET APCRY=^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X)
+5 SET R=$PIECE(APCRY,U,4)
SET APCRRES(R)=$GET(APCRRES(R))+1
End DoDot:1
+6 WRITE !
+7 WRITE !," By Age",!
+8 SET APCRX=""
FOR
SET APCRX=$ORDER(APCRRES(APCRX))
IF APCRX=""!($DATA(APCRQUIT))
QUIT
Begin DoDot:1
+9 IF $$END
QUIT
+10 SET Y=$LENGTH(APCRX_" yrs")
SET Y=38-Y
WRITE !?Y,APCRX," yrs",?40,$JUSTIFY($$COM($GET(APCRRES(APCRX)),0),8),?55,$$PER(APCRRES(APCRX),APCRTOT)
KILL APCRRES(APCRX)
End DoDot:1
+11 QUIT
PRVSC ;
+1 IF '$DATA(APCRTALL(4))
QUIT
+2 ;TALLY BY PRIMARY provider OF service
+3 KILL APCRRES
SET X=0
FOR
SET X=$ORDER(^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X))
IF X'=+X
QUIT
Begin DoDot:1
+4 SET APCRY=^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X)
+5 SET R=$PIECE(APCRY,U,5)
IF R=""
SET R="UNKNOWN"
SET APCRRES(R)=$GET(APCRRES(R))+1
End DoDot:1
+6 WRITE !
+7 WRITE !," By Provider who screened",!
+8 SET APCRX=""
FOR
SET APCRX=$ORDER(APCRRES(APCRX))
IF APCRX=""!($DATA(APCRQUIT))
QUIT
Begin DoDot:1
+9 IF $$END
QUIT
+10 SET Y=$LENGTH(APCRX)
SET Y=38-Y
WRITE !?Y,APCRX,?40,$JUSTIFY($$COM($GET(APCRRES(APCRX)),0),8),?55,$$PER(APCRRES(APCRX),APCRTOT)
KILL APCRRES(APCRX)
End DoDot:1
+11 QUIT
PRVV ;
+1 IF '$DATA(APCRTALL(7))
QUIT
+2 KILL APCRRES
SET X=0
FOR
SET X=$ORDER(^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X))
IF X'=+X
QUIT
Begin DoDot:1
+3 SET APCRY=^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X)
+4 SET R=$PIECE(APCRY,U,7)
IF R=""
SET R="UNKNOWN"
SET APCRRES(R)=$GET(APCRRES(R))+1
End DoDot:1
+5 WRITE !
+6 WRITE !," By Primary Provider of Visit",!
+7 SET APCRX=""
FOR
SET APCRX=$ORDER(APCRRES(APCRX))
IF APCRX=""!($DATA(APCRQUIT))
QUIT
Begin DoDot:1
+8 IF $$END
QUIT
+9 SET Y=$LENGTH(APCRX)
SET Y=38-Y
WRITE !?Y,APCRX,?40,$JUSTIFY($$COM($GET(APCRRES(APCRX)),0),8),?55,$$PER(APCRRES(APCRX),APCRTOT)
KILL APCRRES(APCRX)
End DoDot:1
+10 QUIT
DESPRV ;
+1 IF '$DATA(APCRTALL(11))
QUIT
+2 KILL APCRRES
SET X=0
FOR
SET X=$ORDER(^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X))
IF X'=+X
QUIT
Begin DoDot:1
+3 SET APCRY=^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X)
+4 SET R=$PIECE(APCRY,U,11)
IF R=""
SET R="UNKNOWN"
SET APCRRES(R)=$GET(APCRRES(R))+1
End DoDot:1
+5 WRITE !
+6 WRITE !," By Designated Primary Care Provider",!
+7 SET APCRX=""
FOR
SET APCRX=$ORDER(APCRRES(APCRX))
IF APCRX=""!($DATA(APCRQUIT))
QUIT
Begin DoDot:1
+8 IF $$END
QUIT
+9 SET Y=$LENGTH(APCRX)
SET Y=38-Y
WRITE !?Y,APCRX,?40,$JUSTIFY($$COM($GET(APCRRES(APCRX)),0),8),?55,$$PER(APCRRES(APCRX),APCRTOT)
KILL APCRRES(APCRX)
End DoDot:1
+10 QUIT
MH ;
+1 IF '$DATA(APCRTALL(8))
QUIT
+2 KILL APCRRES
SET X=0
FOR
SET X=$ORDER(^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X))
IF X'=+X
QUIT
Begin DoDot:1
+3 SET APCRY=^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X)
+4 SET R=$PIECE(APCRY,U,8)
IF R=""
SET R="UNKNOWN"
SET APCRRES(R)=$GET(APCRRES(R))+1
End DoDot:1
+5 WRITE !
+6 WRITE !," By Designated Mental Health Provider",!
+7 SET APCRX=""
FOR
SET APCRX=$ORDER(APCRRES(APCRX))
IF APCRX=""!($DATA(APCRQUIT))
QUIT
Begin DoDot:1
+8 IF $$END
QUIT
+9 SET Y=$LENGTH(APCRX)
SET Y=38-Y
WRITE !?Y,APCRX,?40,$JUSTIFY($$COM($GET(APCRRES(APCRX)),0),8),?55,$$PER(APCRRES(APCRX),APCRTOT)
KILL APCRRES(APCRX)
End DoDot:1
+10 QUIT
SS ;
+1 IF '$DATA(APCRTALL(9))
QUIT
+2 KILL APCRRES
SET X=0
FOR
SET X=$ORDER(^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X))
IF X'=+X
QUIT
Begin DoDot:1
+3 SET APCRY=^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X)
+4 SET R=$PIECE(APCRY,U,9)
IF R=""
SET R="UNKNOWN"
SET APCRRES(R)=$GET(APCRRES(R))+1
End DoDot:1
+5 WRITE !
+6 WRITE !," By Designated Social Services Provider",!
+7 SET APCRX=""
FOR
SET APCRX=$ORDER(APCRRES(APCRX))
IF APCRX=""!($DATA(APCRQUIT))
QUIT
Begin DoDot:1
+8 IF $$END
QUIT
+9 SET Y=$LENGTH(APCRX)
SET Y=38-Y
WRITE !?Y,APCRX,?40,$JUSTIFY($$COM($GET(APCRRES(APCRX)),0),8),?55,$$PER(APCRRES(APCRX),APCRTOT)
KILL APCRRES(APCRX)
End DoDot:1
+10 QUIT
CD ;
+1 IF '$DATA(APCRTALL(10))
QUIT
+2 KILL APCRRES
SET X=0
FOR
SET X=$ORDER(^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X))
IF X'=+X
QUIT
Begin DoDot:1
+3 SET APCRY=^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X)
+4 SET R=$PIECE(APCRY,U,10)
IF R=""
SET R="UNKNOWN"
SET APCRRES(R)=$GET(APCRRES(R))+1
End DoDot:1
+5 WRITE !
+6 WRITE !," By Designated A/SA Provider",!
+7 SET APCRX=""
FOR
SET APCRX=$ORDER(APCRRES(APCRX))
IF APCRX=""!($DATA(APCRQUIT))
QUIT
Begin DoDot:1
+8 IF $$END
QUIT
+9 SET Y=$LENGTH(APCRX)
SET Y=38-Y
WRITE !?Y,APCRX,?40,$JUSTIFY($$COM($GET(APCRRES(APCRX)),0),8),?55,$$PER(APCRRES(APCRX),APCRTOT)
KILL APCRRES(APCRX)
End DoDot:1
+10 QUIT
CLINIC ;
+1 IF '$DATA(APCRTALL(5))
QUIT
+2 ;TALLY BY clinic
+3 KILL APCRRES
SET X=0
FOR
SET X=$ORDER(^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X))
IF X'=+X
QUIT
Begin DoDot:1
+4 SET APCRY=^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X)
+5 SET R=$PIECE(APCRY,U,6)
IF R=""
SET R="UNKNOWN"
SET APCRRES(R)=$GET(APCRRES(R))+1
End DoDot:1
+6 WRITE !
+7 WRITE !," By Clinic",!
+8 SET APCRX=""
FOR
SET APCRX=$ORDER(APCRRES(APCRX))
IF APCRX=""!($DATA(APCRQUIT))
QUIT
Begin DoDot:1
+9 IF $$END
QUIT
+10 SET Y=$LENGTH(APCRX)
SET Y=38-Y
WRITE !?Y,APCRX,?40,$JUSTIFY($$COM($GET(APCRRES(APCRX)),0),8),?55,$$PER(APCRRES(APCRX),APCRTOT)
KILL APCRRES(APCRX)
End DoDot:1
+11 QUIT
DATE ;
+1 IF '$DATA(APCRTALL(6))
QUIT
+2 ;TALLY BY date OF service
+3 KILL ^TMP($JOB)
SET X=0
FOR
SET X=$ORDER(^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X))
IF X'=+X
QUIT
Begin DoDot:1
+4 SET APCRY=^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",X)
+5 SET R=$PIECE(APCRY,U,1)
SET ^TMP($JOB,R)=$GET(^TMP($JOB,R))+1
End DoDot:1
+6 WRITE !
+7 WRITE !," By Date",!
+8 SET APCRX=""
FOR
SET APCRX=$ORDER(^TMP($JOB,APCRX))
IF APCRX=""!($DATA(APCRQUIT))
QUIT
Begin DoDot:1
+9 IF $$END
QUIT
+10 SET Y=$LENGTH($$FMTE^XLFDT(APCRX))
SET Y=38-Y
WRITE !?Y,$$FMTE^XLFDT(APCRX),?40,$JUSTIFY($$COM($GET(^TMP($JOB,APCRX)),0),8),?55,$$PER(^TMP($JOB,APCRX),APCRTOT)
KILL ^TMP($JOB,APCRX)
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(APCRQUIT)
QUIT 1
+4 QUIT 0
ENDL() ;
+1 IF $Y<(IOSL-8)
QUIT 0
+2 DO HEADER
+3 IF $DATA(APCRQUIT)
QUIT 1
+4 QUIT 0
PTOT() ;
+1 NEW C,X
+2 SET C=0
+3 SET X=0
FOR
SET X=$ORDER(^XTMP("APCLAL5",APCRJ,APCRH,"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("APCLAL5",APCRJ,APCRH,"VSTS",X))
IF X'=+X
QUIT
SET C=C+1
+4 QUIT C
+1 IF 'APCRPG
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 APCRQUIT=""
QUIT
+1 IF $DATA(IOF)
WRITE @IOF
SET APCRPG=APCRPG+1
+2 WRITE !?3,$PIECE(^VA(200,DUZ,0),U,2),?35,$$FMTE^XLFDT(DT),?70,"Page ",APCRPG,!
+3 WRITE !,$$CTR("*** ALCOHOL SCREENING VISIT TALLY"_$SELECT(APCRLIST:" AND VISIT LISTING",1:"")_" ***",80),!
+4 SET X="Screening Dates: "_$$FMTE^XLFDT(APCRBD)_" to "_$$FMTE^XLFDT(APCRED)
WRITE $$CTR(X,80),!
+5 IF APCLEXBH
SET X="This report includes data from the Behavioral Health Clinics"
WRITE $$CTR(X,80),!
+6 IF 'APCLEXBH
SET X="This report excludes data from the Behavioral Health Clinics"
WRITE $$CTR(X,80),!
+7 SET X="SEARCH TEMPLATE OF PATIENTS: "_$PIECE(^DIBT(APCRSEAT,0),U)
WRITE $$CTR(X,80),!
+8 IF $GET(APCRLSTP)
IF APCRSCRD
SET X="Listing of those patients screened"
WRITE $$CTR(X,80),!
+9 IF $GET(APCRLSTP)
IF 'APCRSCRD
SET X="Listing of those NOT Screened"
WRITE $$CTR(X,80),!
+10 IF $GET(APCRLSTP)
WRITE !?35,"DATE",!,"PATIENT NAME",?22,"HRN",?29,"AGE",?35,"SCREENED",?55,"CLINIC"
+11 WRITE !,$TRANSLATE($JUSTIFY("",80)," ","-")
+12 IF '$GET(APCRLSTP)
WRITE !?46,"#",?53,"% of patients",$SELECT(APCRTALP:" screened",1:"")
+13 QUIT
DONE ;
+1 KILL ^TMP($JOB)
+2 KILL ^XTMP("APCLAL5",APCRJ,APCRH)
+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 APCRPG=0
KILL APCRQUIT
+2 SET APCRLSTP=1
SET APCRSCRD=1
+3 DO HEADER
+4 KILL ^TMP($JOB)
+5 ;resort by sort item
+6 SET APCRX=0
FOR
SET APCRX=$ORDER(^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",APCRX))
IF APCRX'=+APCRX
QUIT
SET APCRY=^XTMP("APCLAL5",APCRJ,APCRH,"VSTS",APCRX)
Begin DoDot:1
+7 SET DFN=$PIECE(APCRY,U,15)
+8 DO @APCRSORT
+9 IF APCRSORV=""
SET APCRSORV="--"
+10 SET ^TMP($JOB,"VSTS",APCRSORV,APCRX)=APCRY
+11 QUIT
End DoDot:1
+12 SET APCRSORV=""
FOR
SET APCRSORV=$ORDER(^TMP($JOB,"VSTS",APCRSORV))
IF APCRSORV=""!($DATA(APCRQUIT))
QUIT
Begin DoDot:1
+13 SET APCRZ=0
FOR
SET APCRZ=$ORDER(^TMP($JOB,"VSTS",APCRSORV,APCRZ))
IF APCRZ'=+APCRZ!($DATA(APCRQUIT))
QUIT
Begin DoDot:2
+14 IF $$ENDL
QUIT
+15 SET APCRY=^TMP($JOB,"VSTS",APCRSORV,APCRZ)
SET DFN=$PIECE(APCRY,U,15)
+16 WRITE !!,$EXTRACT($PIECE(^DPT(DFN,0),U),1,20),?22,$$HRN^AUPNPAT(DFN,DUZ(2)),?29,$PIECE(APCRY,U,4),?33,$PIECE(^DPT(DFN,0),U,2),?35,$$DT($PIECE(APCRY,U,1)),?55,$EXTRACT($PIECE(APCRY,U,6),1,20)
+17 WRITE !?3,"Type/Result: ",$PIECE($PIECE(APCRY,U,2),";")_" "_$PIECE($PIECE(APCRY,U,2),";",2)
+18 IF $PIECE(APCRY,U,12)]""
WRITE !?3,"Comment: ",$PIECE(APCRY,U,12)
+19 IF $PIECE(APCRY,U,20)="PCC"
SET APCRV=$PIECE(APCRY,U,14)
IF APCRV
IF $DATA(^AUPNVPOV("AD",APCRV))
Begin DoDot:3
+20 SET APCRC=0
WRITE !?3,"DXs: "
+21 SET APCRX=0
FOR
SET APCRX=$ORDER(^AUPNVPOV("AD",APCRV,APCRX))
IF APCRX'=+APCRX!($DATA(APCRQUIT))
QUIT
Begin DoDot:4
+22 SET APCRC=APCRC+1
+23 IF APCRC'=1
WRITE !
WRITE ?8,$$VAL^XBDIQ1(9000010.07,APCRX,.01),?17,$EXTRACT($$VAL^XBDIQ1(9000010.07,APCRX,.04),1,60)
End DoDot:4
End DoDot:3
+24 IF $PIECE(APCRY,U,20)="BH"
SET APCRV=$PIECE(APCRY,U,15)
IF APCRV
IF $DATA(^AMHRPRO("AD",APCRV))
Begin DoDot:3
+25 SET APCRC=0
WRITE !?3,"DXs: "
+26 SET APCRX=0
FOR
SET APCRX=$ORDER(^AMHRPRO("AD",APCRV,APCRX))
IF APCRX'=+APCRX!($DATA(APCRQUIT))
QUIT
Begin DoDot:4
+27 SET APCRC=APCRC+1
+28 IF APCRC'=1
WRITE !
WRITE ?8,$$VAL^XBDIQ1(9002011.01,APCRX,.01),?17,$EXTRACT($$VAL^XBDIQ1(9002011.01,APCRX,.04),1,60)
End DoDot:4
End DoDot:3
+29 WRITE !?3,"Primary Provider on Visit: ",?31,$PIECE(APCRY,U,7)
+30 WRITE !?3," Provider who screened: ",?31,$PIECE(APCRY,U,5)
End DoDot:2
End DoDot:1
+31 SET APCRSCRD=0
+32 DO HEADER
+33 SET DFN=0
FOR
SET DFN=$ORDER(^DIBT(APCRSEAT,1,DFN))
IF DFN'=+DFN!($DATA(APCRQUIT))
QUIT
Begin DoDot:1
+34 IF $DATA(^XTMP("APCLAL5",APCRJ,APCRH,"PTS",DFN))
QUIT
+35 IF $$END
QUIT
+36 WRITE !,$EXTRACT($PIECE(^DPT(DFN,0),U),1,20),?22,$$HRN^AUPNPAT(DFN,DUZ(2)),?29,$$AGE^AUPNPAT(DFN,DT),?33,$PIECE(^DPT(DFN,0),U,2)
End DoDot:1
+37 QUIT
H ;
+1 SET APCRSORV=$$HRN^AUPNPAT(DFN,DUZ(2))
+2 QUIT
N ;
+1 SET APCRSORV=$PIECE(^DPT(DFN,0),U)
+2 QUIT
P ;
+1 SET APCRSORV=$PIECE(APCRY,U,5)
+2 QUIT
R ;
+1 SET APCRSORV=$PIECE($PIECE(APCRY,U,2),";")_" "_$PIECE($PIECE(APCRY,U,2),";",2)
+2 QUIT
D ;
+1 SET APCRSORV=$PIECE(APCRY,U,1)
+2 QUIT
A SET APCRSORV=$PIECE(APCRY,U,4)
+1 QUIT
G ;
+1 SET APCRSORV=$PIECE(APCRY,U,3)
+2 QUIT
C ;
+1 SET APCRSORV=$PIECE(APCRY,U,6)
+2 QUIT
T ;
+1 SET %=$$HRN^AUPNPAT(DFN,DUZ(2))
+2 SET %=%+10000000
SET %=$EXTRACT(%,7,8)_"-"_+$EXTRACT(%,2,8)
+3 SET APCRSORV=%
+4 QUIT
DT(D) ;EP
+1 IF D=""
QUIT ""
+2 QUIT $EXTRACT(D,4,5)_"/"_$EXTRACT(D,6,7)_"/"_$EXTRACT(D,2,3)
+3 ;