APCLDV3P ; IHS/CMI/LAB - list refusals ;
;;2.0;IHS PCC SUITE;**10**;MAY 14, 2009;Build 88
;
;
PRINT ;EP - called from xbdbque
D PRINT1
D DONE
Q
PRINT1 ;
S APCLPG=0 K APCLQUIT
K APCLLSTP
I '$D(^XTMP("APCLDV3",APCLJ,APCLH)) D HEADER W !!,"No data to report.",! G DONE
D COVPAGE
Q:$$END
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)
I APCLTMPL="L" D LIST Q
;store search template
S X=0 F S X=$O(^XTMP("APCLDV3",APCLJ,APCLH,"PTS",X)) Q:X'=+X S ^DIBT(APCLSTMP,1,X)=""
W !!,"Search template ",$P(^DIBT(APCLSTMP,0),U)," has been created.",!
Q
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("APCLDV3",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("APCLDV3",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 LISTING FOR SELECTED PATIENTS ***",80),!
D LOCHDR^APCLDV1P,COMMHDR^APCLDV1P
S X="Screening Dates: "_$$FMTE^XLFDT(APCLBD)_" to "_$$FMTE^XLFDT(APCLED) W $$CTR(X,80),!
W !?35,"DATE",!,"PATIENT NAME",?22,"HRN",?29,"AGE",?35,"SCREENED",?44,"RESULT",?61,"CLINIC"
W !,$TR($J("",80)," ","-")
Q
DONE ;
K ^TMP($J)
K ^XTMP("APCLDV3",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("APCLDV3",APCLJ,APCLH,"VSTS",APCLX)) Q:APCLX'=+APCLX S APCLY=^XTMP("APCLDV3",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)
..I 'APCLDP W ! Q
..K APCLZ S X=$$VAL^XBDIQ1(9002011.55,DFN,.02) I X]"" S APCLZ("MENTAL HEALTH")=X
..S X=$$VAL^XBDIQ1(9002011.55,DFN,.03) I X]"" S APCLZ("SOCIAL SERVICES")=X
..S X=$$VAL^XBDIQ1(9002011.55,DFN,.04) I X]"" S APCLZ("CHEMICAL DEPENDENCY")=X
..S X=$$VAL^XBDIQ1(9000001,DFN,.14) I X]"" S APCLZ("DESIGNATED PRIMARY PROVIDER")=X
..S APCLXX=0 F S APCLXX=$O(^BDPRECN("C",DFN,APCLXX)) Q:APCLXX'=+APCLXX D
...S A=$$VAL^XBDIQ1(90360.1,APCLXX,.01) I '$D(APCLZ(A)) S APCLZ(A)=$$VAL^XBDIQ1(90360.1,APCLXX,.03)
..Q:'$D(APCLZ)
..W !?3," Designated Providers: "
..S APCLZ="",APCLC=0 F S APCLZ=$O(APCLZ(APCLZ)) Q:APCLZ=""!($D(APCLQUIT)) D
...Q:$$END
...S APCLC=APCLC+1
...W:APCLC'=1 ! W ?31,$S(APCLZ="DESIGNATED PRIMARY PROVIDER":"PRIMARY CARE",1:APCLZ),": ",APCLZ(APCLZ)
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)
;
COVPAGE ;EP
W:$D(IOF) @IOF
W !?20,"********** IPV/DV SCREENING FOR SELECTED PATIENTS **********"
W !!,"REPORT REQUESTED BY: ",$P(^VA(200,DUZ,0),U)
W !!,"The following report contains an IPV/DV screening report based on the",!,"following criteria:"
SHOW ;
W !!?6,"Patient must have had a screening between ",$$FMTE^XLFDT(APCLBD)," and ",$$FMTE^XLFDT(APCLED),!
;W:APCLTYPE="S" !!?6,"Search Template: ",$P(^DIBT(APCLSEAT,0),U),!
W !?6,"Gender: ",$S(APCLSEX="F":"FEMALES ONLY",APCLSEX="M":"MALES ONLY",APCLSEX="U":"UNKNOWN",APCLSEX="MFU":"ALL GENDERS",1:"")
I $D(APCLAGET) W !?6,"Age of Patients included: ",$P(APCLAGET,"-")," to ",$P(APCLAGET,"-",2)
I '$D(APCLAGET) W !?6,"All Ages included"
W !?6,"Patients must have had a screening during the time period with one of ",!?6,"the following screening results:"
W ! S X="" F S X=$O(APCLREST(X)) Q:X'=+X D
.I X=1 W ?8,"NEGATIVE"
.I X=2 W " ","PRESENT"
.I X=3 W " ","PAST"
.I X=4 W " ","PRESENT AND PAST"
.I X=5 W " ","REFUSED"
.I X=6 W " ","UNABLE TO SCREEN"
.I X=7 W !?8,"SCREENINGS WITH NO RECORDED RESULT"
I $D(APCLCLNT) W !,"Screenings done in the following clinics are included:" D
.S X=0 F S X=$O(APCLCLNT(X)) Q:X'=+X W !?10,$P(^DIC(40.7,X,0),U)," ("_$P(^DIC(40.7,X,0),U,2)_")"
I '$D(APCLCLNT),APCLEXBH W !,"Screenings done in ALL clinics included"
I 'APCLEXBH W !,"Behavioral Health Clinics excluded, all other clinics included."
I APCLDESP]"" W !,"Only patients whose Designated Primary Care Provider is ",!?6,$P(^VA(200,APCLDESP,0),U)," are included"
I APCLPPUN W !,"Only patients who had a visit on which a screeening was done",!?6,"but the primary provider on the visit was UNKNOWN are included."
I APCLSPUN W !,"Only patients who had a visit on which a screeening was done",!?6,"but the screening provider on the visit was UNKNOWN are included."
I '$D(APCLPROV) W !,"Visits to any Primary Provider are included"
I '$D(APCLSPRV) W !,"Visits on which any provider did the screening are included"
I $D(APCLPROV) W !,"Only screenings on which ",$P(^VA(200,APCLPROV,0),U)," was the primary provider",!?6,"on the visit are included"
I $D(APCLSPRV) W !,"Only screenings on which ",$P(^VA(200,APCLSPRV,0),U)," was the primary provider",!?6,"on the visit are included"
D PAUSE
Q
PAUSE ;
Q:$E(IOST)'="C"
Q:IO'=IO(0)
S DIR(0)="E",DIR("A")="Press return to continue or '^' to quit" D ^DIR K DIR,DA
S:$D(DIRUT) APCLQUIT=1
W:$D(IOF) @IOF
Q
APCLDV3P ; IHS/CMI/LAB - list refusals ;
+1 ;;2.0;IHS PCC SUITE;**10**;MAY 14, 2009;Build 88
+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("APCLDV3",APCLJ,APCLH))
DO HEADER
WRITE !!,"No data to report.",!
GOTO DONE
+4 DO COVPAGE
+5 IF $$END
QUIT
+6 DO HEADER
+7 SET APCLTOT=APCLCNT
+8 SET APCLPTOT=$$PTOT
+9 WRITE !," Total Number of Visits with Screening",?40,$JUSTIFY($$COM(APCLTOT,0),8)
+10 WRITE !," Total Number of Patients Screened",?40,$JUSTIFY($$COM(APCLPTOT,0),8)
+11 IF APCLTMPL="L"
DO LIST
QUIT
+12 ;store search template
+13 SET X=0
FOR
SET X=$ORDER(^XTMP("APCLDV3",APCLJ,APCLH,"PTS",X))
IF X'=+X
QUIT
SET ^DIBT(APCLSTMP,1,X)=""
+14 WRITE !!,"Search template ",$PIECE(^DIBT(APCLSTMP,0),U)," has been created.",!
+15 QUIT
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("APCLDV3",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("APCLDV3",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 LISTING FOR SELECTED PATIENTS ***",80),!
+4 DO LOCHDR^APCLDV1P
DO COMMHDR^APCLDV1P
+5 SET X="Screening Dates: "_$$FMTE^XLFDT(APCLBD)_" to "_$$FMTE^XLFDT(APCLED)
WRITE $$CTR(X,80),!
+6 WRITE !?35,"DATE",!,"PATIENT NAME",?22,"HRN",?29,"AGE",?35,"SCREENED",?44,"RESULT",?61,"CLINIC"
+7 WRITE !,$TRANSLATE($JUSTIFY("",80)," ","-")
+8 QUIT
DONE ;
+1 KILL ^TMP($JOB)
+2 KILL ^XTMP("APCLDV3",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("APCLDV3",APCLJ,APCLH,"VSTS",APCLX))
IF APCLX'=+APCLX
QUIT
SET APCLY=^XTMP("APCLDV3",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)
+37 IF 'APCLDP
WRITE !
QUIT
+38 KILL APCLZ
SET X=$$VAL^XBDIQ1(9002011.55,DFN,.02)
IF X]""
SET APCLZ("MENTAL HEALTH")=X
+39 SET X=$$VAL^XBDIQ1(9002011.55,DFN,.03)
IF X]""
SET APCLZ("SOCIAL SERVICES")=X
+40 SET X=$$VAL^XBDIQ1(9002011.55,DFN,.04)
IF X]""
SET APCLZ("CHEMICAL DEPENDENCY")=X
+41 SET X=$$VAL^XBDIQ1(9000001,DFN,.14)
IF X]""
SET APCLZ("DESIGNATED PRIMARY PROVIDER")=X
+42 SET APCLXX=0
FOR
SET APCLXX=$ORDER(^BDPRECN("C",DFN,APCLXX))
IF APCLXX'=+APCLXX
QUIT
Begin DoDot:3
+43 SET A=$$VAL^XBDIQ1(90360.1,APCLXX,.01)
IF '$DATA(APCLZ(A))
SET APCLZ(A)=$$VAL^XBDIQ1(90360.1,APCLXX,.03)
End DoDot:3
+44 IF '$DATA(APCLZ)
QUIT
+45 WRITE !?3," Designated Providers: "
+46 SET APCLZ=""
SET APCLC=0
FOR
SET APCLZ=$ORDER(APCLZ(APCLZ))
IF APCLZ=""!($DATA(APCLQUIT))
QUIT
Begin DoDot:3
+47 IF $$END
QUIT
+48 SET APCLC=APCLC+1
+49 IF APCLC'=1
WRITE !
WRITE ?31,$SELECT(APCLZ="DESIGNATED PRIMARY PROVIDER":"PRIMARY CARE",1:APCLZ),": ",APCLZ(APCLZ)
End DoDot:3
End DoDot:2
End DoDot:1
+50 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 ;
COVPAGE ;EP
+1 IF $DATA(IOF)
WRITE @IOF
+2 WRITE !?20,"********** IPV/DV SCREENING FOR SELECTED PATIENTS **********"
+3 WRITE !!,"REPORT REQUESTED BY: ",$PIECE(^VA(200,DUZ,0),U)
+4 WRITE !!,"The following report contains an IPV/DV screening report based on the",!,"following criteria:"
SHOW ;
+1 WRITE !!?6,"Patient must have had a screening between ",$$FMTE^XLFDT(APCLBD)," and ",$$FMTE^XLFDT(APCLED),!
+2 ;W:APCLTYPE="S" !!?6,"Search Template: ",$P(^DIBT(APCLSEAT,0),U),!
+3 WRITE !?6,"Gender: ",$SELECT(APCLSEX="F":"FEMALES ONLY",APCLSEX="M":"MALES ONLY",APCLSEX="U":"UNKNOWN",APCLSEX="MFU":"ALL GENDERS",1:"")
+4 IF $DATA(APCLAGET)
WRITE !?6,"Age of Patients included: ",$PIECE(APCLAGET,"-")," to ",$PIECE(APCLAGET,"-",2)
+5 IF '$DATA(APCLAGET)
WRITE !?6,"All Ages included"
+6 WRITE !?6,"Patients must have had a screening during the time period with one of ",!?6,"the following screening results:"
+7 WRITE !
SET X=""
FOR
SET X=$ORDER(APCLREST(X))
IF X'=+X
QUIT
Begin DoDot:1
+8 IF X=1
WRITE ?8,"NEGATIVE"
+9 IF X=2
WRITE " ","PRESENT"
+10 IF X=3
WRITE " ","PAST"
+11 IF X=4
WRITE " ","PRESENT AND PAST"
+12 IF X=5
WRITE " ","REFUSED"
+13 IF X=6
WRITE " ","UNABLE TO SCREEN"
+14 IF X=7
WRITE !?8,"SCREENINGS WITH NO RECORDED RESULT"
End DoDot:1
+15 IF $DATA(APCLCLNT)
WRITE !,"Screenings done in the following clinics are included:"
Begin DoDot:1
+16 SET X=0
FOR
SET X=$ORDER(APCLCLNT(X))
IF X'=+X
QUIT
WRITE !?10,$PIECE(^DIC(40.7,X,0),U)," ("_$PIECE(^DIC(40.7,X,0),U,2)_")"
End DoDot:1
+17 IF '$DATA(APCLCLNT)
IF APCLEXBH
WRITE !,"Screenings done in ALL clinics included"
+18 IF 'APCLEXBH
WRITE !,"Behavioral Health Clinics excluded, all other clinics included."
+19 IF APCLDESP]""
WRITE !,"Only patients whose Designated Primary Care Provider is ",!?6,$PIECE(^VA(200,APCLDESP,0),U)," are included"
+20 IF APCLPPUN
WRITE !,"Only patients who had a visit on which a screeening was done",!?6,"but the primary provider on the visit was UNKNOWN are included."
+21 IF APCLSPUN
WRITE !,"Only patients who had a visit on which a screeening was done",!?6,"but the screening provider on the visit was UNKNOWN are included."
+22 IF '$DATA(APCLPROV)
WRITE !,"Visits to any Primary Provider are included"
+23 IF '$DATA(APCLSPRV)
WRITE !,"Visits on which any provider did the screening are included"
+24 IF $DATA(APCLPROV)
WRITE !,"Only screenings on which ",$PIECE(^VA(200,APCLPROV,0),U)," was the primary provider",!?6,"on the visit are included"
+25 IF $DATA(APCLSPRV)
WRITE !,"Only screenings on which ",$PIECE(^VA(200,APCLSPRV,0),U)," was the primary provider",!?6,"on the visit are included"
+26 DO PAUSE
+27 QUIT
PAUSE ;
+1 IF $EXTRACT(IOST)'="C"
QUIT
+2 IF IO'=IO(0)
QUIT
+3 SET DIR(0)="E"
SET DIR("A")="Press return to continue or '^' to quit"
DO ^DIR
KILL DIR,DA
+4 IF $DATA(DIRUT)
SET APCLQUIT=1
+5 IF $DATA(IOF)
WRITE @IOF
+6 QUIT