AMHGAFS ; IHS/CMI/MAW - GAF - MULTIPLE PATS 03 Jun 2009 11:28 AM ;
;;4.0;IHS BEHAVIORAL HEALTH;**1,4**;JUN 18, 2010;Build 28
;
;
START ;
W:$D(IOF) @IOF
D EN^XBVK("AMH")
W !,$$CTR^AMHLEIN("GAF OUTCOME MEASURE - GAF Scores for Multiple Patients",80),!!
W !,"This option is used to list GAF Scores for multiple patients sorted"
W !,"by patient.",!
WHICH ;
W !!,"Please note: Only visits with GAF scores recorded will display on this",!,"list.",!
D DBHUSR^AMHUTIL
DATES ;
K AMHED,AMHBD
K DIR W ! S DIR(0)="D^::EXP",DIR("A")="Enter Beginning Date of Visit"
D ^DIR
G:$D(DIRUT) XIT
S AMHBD=Y
K DIR S DIR(0)="D^::EXP",DIR("A")="Enter Ending Date of Visit"
D ^DIR
G:$D(DIRUT) DATES
S AMHED=Y
;
I AMHED<AMHBD D G DATES
. W !!,$C(7),"Sorry, Ending Date MUST not be earlier than Beginning Date."
S AMHSD=$$FMADD^XLFDT(AMHBD,-1)_".9999"
PROG ;
S AMHPROG=""
S DIR(0)="S^O:ONE Program;A:ALL Programs",DIR("A")="List visits/GAF Scores for which PROGRAM",DIR("B")="A" KILL DA D ^DIR KILL DIR
G:$D(DIRUT) DATES
I Y="A" G PROV
S DIR(0)="9002011,.02",DIR("A")="Which PROGRAM" KILL DA D ^DIR KILL DIR
G:$D(DIRUT) PROG
I X="" G PROG
S AMHPROG=Y
PROV ;
S AMHPROV=""
S DIR(0)="S^A:All Providers;O:One Provider",DIR("A")="Include visits to",DIR("B")="A" K DA D ^DIR K DIR
G:$D(DIRUT) XIT
I Y="A" G DEMO
S DIC="^VA(200,",DIC(0)="AEMQ",DIC("A")="Which PROVIDER: " D ^DIC
K DIC,DA
I Y=-1 G PROV
S AMHPROV=+Y
DEMO ;
D DEMOCHK^AMHUTIL1(.AMHDEMO)
I AMHDEMO=-1 G PROV
ZIS ;
S DIR(0)="S^P:PRINT Output;B:BROWSE Output on Screen",DIR("A")="Do you wish to ",DIR("B")="P" K DA D ^DIR K DIR
I $D(DIRUT) G XIT
I $G(Y)="B" D BROWSE,XIT Q
S XBRC="PROC^AMHGAFS",XBRP="PRINT^AMHGAFS",XBNS="AMH",XBRX="XIT^AMHGAFS"
D ^XBDBQUE
XIT ;
K ZTSK,Y,AMHBD,AMHED,IO("Q")
D EN^XBVK("AMH")
Q
;
BROWSE ;
S XBRP="VIEWR^XBLM(""PRINT^AMHGAFS"")"
S XBNS="AMH",XBRC="PROC^AMHGAFS",XBRX="XIT^AMHRP4",XBIOP=0 D ^XBDBQUE
Q
;
PROC ;
;loop through visits and check GAF score
D XTMP^AMHUTIL("AMHGAFS","BH - GAF SCORES MULT PATS")
S (AMHBT,AMHBTH)=$H,AMHJOB=$J
F S AMHSD=$O(^AMHREC("B",AMHSD)) Q:AMHSD=""!($P(AMHSD,".")>$P(AMHED,".")) D
.S AMHVIEN=0 F S AMHVIEN=$O(^AMHREC("B",AMHSD,AMHVIEN)) Q:AMHVIEN'=+AMHVIEN D
..S AMHV0=$G(^AMHREC(AMHVIEN,0))
..Q:AMHV0=""
..S DFN=$P(AMHV0,U,8)
..Q:DFN=""
..I $P(AMHV0,U,14)="" Q ;no GAF score
..Q:'$$ALLOWVI^AMHUTIL(DUZ,AMHVIEN)
..Q:$$DEMO^AMHUTIL1(DFN,$G(AMHDEMO))
..I AMHPROG]"",$P(AMHV0,U,2)'=AMHPROG Q ;not correct program visit
..S AMHVPP=$$PPINT^AMHUTIL(AMHVIEN)
..I AMHVPP="",AMHPROV Q ;PRIM PROV blank and want certain PRIM PROVS
..I AMHPROV,AMHVPP'=AMHPROV Q ;not a PRIM PROV we want
..S ^XTMP("AMHGAFS",AMHJOB,AMHBTH,"PATS",$P(^DPT(DFN,0),U,1),DFN,(9999999-$P($P(^AMHREC(AMHVIEN,0),U),".")),AMHVIEN)=""
..Q
.Q
Q
PRINT ;EP - called from xbdbque
S AMHPG=0 K AMHQ D HEADER
I '$D(^XTMP("AMHGAFS",AMHJOB,AMHBTH)) W !!,"NO PATIENTS/GAF SCORES TO REPORT" G DONE
S AMHNAME="" F S AMHNAME=$O(^XTMP("AMHGAFS",AMHJOB,AMHBTH,"PATS",AMHNAME)) Q:AMHNAME=""!($D(AMHQ)) D
.S DFN=0 F S DFN=$O(^XTMP("AMHGAFS",AMHJOB,AMHBTH,"PATS",AMHNAME,DFN)) Q:DFN'=+DFN!($D(AMHQ)) D
..W ! S AMHDATE="" F S AMHDATE=$O(^XTMP("AMHGAFS",AMHJOB,AMHBTH,"PATS",AMHNAME,DFN,AMHDATE)) Q:AMHDATE=""!($D(AMHQ)) D
...S AMHV=0 F S AMHV=$O(^XTMP("AMHGAFS",AMHJOB,AMHBTH,"PATS",AMHNAME,DFN,AMHDATE,AMHV)) Q:AMHV'=+AMHV!($D(AMHQ)) D PRINT1
...Q
..Q
.Q
DONE ;
I $E(IOST)="C",IO=IO(0) S DIR(0)="EO",DIR("A")="End of report. PRESS RETURN" D ^DIR K DIR S:$D(DUOUT) DIRUT=1
K ^XTMP("AMHGAFS",AMHJOB,AMHBTH),AMHJOB,AMHBTH
Q
;
PRINT1 ;
I $Y>(IOSL-3) D HEADER Q:$D(AMHQ)
W !,$E(AMHNAME,1,15),?17,$$HRN^AUPNPAT(DFN,DUZ(2)),?24,$$D^AMHLEIN((9999999-AMHDATE))
W ?33,$P(^AMHREC(AMHV,0),U,14),?37,$E($P($G(^AMHREC(AMHV,11)),U,15),1,7)
W ?45,$E($$PPNAME^AMHUTIL(AMHV),1,9),?55,$P(^AMHREC(AMHV,0),U,2)
S X=$O(^AMHRPRO("AD",AMHV,0))
I X W ?58,$$VAL^XBDIQ1(9002011.01,X,.01)_"-"_$E($$VAL^XBDIQ1(9002011.01,X,.04),1,13)
Q
;----------
G:'AMHPG 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 AMHQ="" Q
W:$D(IOF) @IOF S AMHPG=AMHPG+1
W !?3,$P(^VA(200,DUZ,0),U,2),?35,$$FMTE^XLFDT(DT),?70,"Page ",AMHPG,!
W !,$$CTR^AMHLEIN("GAF SCORES FOR MULTIPLE PATIENTS",80),!
S X="Visit Dates: "_$$FMTE^XLFDT(AMHBD)_" to "_$$FMTE^XLFDT(AMHED) W $$CTR^AMHLEIN(X,80),!
I AMHPROG]"" S X="Program: "_$$EXTSET^XBFUNC(9002011,.02,AMHPROG) W $$CTR^AMHLEIN(X,80),!
I AMHPROG="" S X="Program: ALL" W $$CTR^AMHLEIN(X,80),!
I AMHPROV="" S X="Provider: ALL" W $$CTR^AMHLEIN(X,80),!
I AMHPROV S X="Provider: "_$P(^VA(200,AMHPROV,0),U) W $$CTR^AMHLEIN(X,80),!
W !,"PATIENT NAME",?17,"HRN",?24,"Date",?33,"GAF",?37,"TYPE",?45,"Provider",?55,"PG",?58,"Diagnosis/POV"
W !,$TR($J("",80)," ","-")
Q
AMHGAFS ; IHS/CMI/MAW - GAF - MULTIPLE PATS 03 Jun 2009 11:28 AM ;
+1 ;;4.0;IHS BEHAVIORAL HEALTH;**1,4**;JUN 18, 2010;Build 28
+2 ;
+3 ;
START ;
+1 IF $DATA(IOF)
WRITE @IOF
+2 DO EN^XBVK("AMH")
+3 WRITE !,$$CTR^AMHLEIN("GAF OUTCOME MEASURE - GAF Scores for Multiple Patients",80),!!
+4 WRITE !,"This option is used to list GAF Scores for multiple patients sorted"
+5 WRITE !,"by patient.",!
WHICH ;
+1 WRITE !!,"Please note: Only visits with GAF scores recorded will display on this",!,"list.",!
+2 DO DBHUSR^AMHUTIL
DATES ;
+1 KILL AMHED,AMHBD
+2 KILL DIR
WRITE !
SET DIR(0)="D^::EXP"
SET DIR("A")="Enter Beginning Date of Visit"
+3 DO ^DIR
+4 IF $DATA(DIRUT)
GOTO XIT
+5 SET AMHBD=Y
+6 KILL DIR
SET DIR(0)="D^::EXP"
SET DIR("A")="Enter Ending Date of Visit"
+7 DO ^DIR
+8 IF $DATA(DIRUT)
GOTO DATES
+9 SET AMHED=Y
+10 ;
+11 IF AMHED<AMHBD
Begin DoDot:1
+12 WRITE !!,$CHAR(7),"Sorry, Ending Date MUST not be earlier than Beginning Date."
End DoDot:1
GOTO DATES
+13 SET AMHSD=$$FMADD^XLFDT(AMHBD,-1)_".9999"
PROG ;
+1 SET AMHPROG=""
+2 SET DIR(0)="S^O:ONE Program;A:ALL Programs"
SET DIR("A")="List visits/GAF Scores for which PROGRAM"
SET DIR("B")="A"
KILL DA
DO ^DIR
KILL DIR
+3 IF $DATA(DIRUT)
GOTO DATES
+4 IF Y="A"
GOTO PROV
+5 SET DIR(0)="9002011,.02"
SET DIR("A")="Which PROGRAM"
KILL DA
DO ^DIR
KILL DIR
+6 IF $DATA(DIRUT)
GOTO PROG
+7 IF X=""
GOTO PROG
+8 SET AMHPROG=Y
PROV ;
+1 SET AMHPROV=""
+2 SET DIR(0)="S^A:All Providers;O:One Provider"
SET DIR("A")="Include visits to"
SET DIR("B")="A"
KILL DA
DO ^DIR
KILL DIR
+3 IF $DATA(DIRUT)
GOTO XIT
+4 IF Y="A"
GOTO DEMO
+5 SET DIC="^VA(200,"
SET DIC(0)="AEMQ"
SET DIC("A")="Which PROVIDER: "
DO ^DIC
+6 KILL DIC,DA
+7 IF Y=-1
GOTO PROV
+8 SET AMHPROV=+Y
DEMO ;
+1 DO DEMOCHK^AMHUTIL1(.AMHDEMO)
+2 IF AMHDEMO=-1
GOTO PROV
ZIS ;
+1 SET DIR(0)="S^P:PRINT Output;B:BROWSE Output on Screen"
SET DIR("A")="Do you wish to "
SET DIR("B")="P"
KILL DA
DO ^DIR
KILL DIR
+2 IF $DATA(DIRUT)
GOTO XIT
+3 IF $GET(Y)="B"
DO BROWSE
DO XIT
QUIT
+4 SET XBRC="PROC^AMHGAFS"
SET XBRP="PRINT^AMHGAFS"
SET XBNS="AMH"
SET XBRX="XIT^AMHGAFS"
+5 DO ^XBDBQUE
XIT ;
+1 KILL ZTSK,Y,AMHBD,AMHED,IO("Q")
+2 DO EN^XBVK("AMH")
+3 QUIT
+4 ;
BROWSE ;
+1 SET XBRP="VIEWR^XBLM(""PRINT^AMHGAFS"")"
+2 SET XBNS="AMH"
SET XBRC="PROC^AMHGAFS"
SET XBRX="XIT^AMHRP4"
SET XBIOP=0
DO ^XBDBQUE
+3 QUIT
+4 ;
PROC ;
+1 ;loop through visits and check GAF score
+2 DO XTMP^AMHUTIL("AMHGAFS","BH - GAF SCORES MULT PATS")
+3 SET (AMHBT,AMHBTH)=$HOROLOG
SET AMHJOB=$JOB
+4 FOR
SET AMHSD=$ORDER(^AMHREC("B",AMHSD))
IF AMHSD=""!($PIECE(AMHSD,".")>$PIECE(AMHED,"."))
QUIT
Begin DoDot:1
+5 SET AMHVIEN=0
FOR
SET AMHVIEN=$ORDER(^AMHREC("B",AMHSD,AMHVIEN))
IF AMHVIEN'=+AMHVIEN
QUIT
Begin DoDot:2
+6 SET AMHV0=$GET(^AMHREC(AMHVIEN,0))
+7 IF AMHV0=""
QUIT
+8 SET DFN=$PIECE(AMHV0,U,8)
+9 IF DFN=""
QUIT
+10 ;no GAF score
IF $PIECE(AMHV0,U,14)=""
QUIT
+11 IF '$$ALLOWVI^AMHUTIL(DUZ,AMHVIEN)
QUIT
+12 IF $$DEMO^AMHUTIL1(DFN,$GET(AMHDEMO))
QUIT
+13 ;not correct program visit
IF AMHPROG]""
IF $PIECE(AMHV0,U,2)'=AMHPROG
QUIT
+14 SET AMHVPP=$$PPINT^AMHUTIL(AMHVIEN)
+15 ;PRIM PROV blank and want certain PRIM PROVS
IF AMHVPP=""
IF AMHPROV
QUIT
+16 ;not a PRIM PROV we want
IF AMHPROV
IF AMHVPP'=AMHPROV
QUIT
+17 SET ^XTMP("AMHGAFS",AMHJOB,AMHBTH,"PATS",$PIECE(^DPT(DFN,0),U,1),DFN,(9999999-$PIECE($PIECE(^AMHREC(AMHVIEN,0),U),".")),AMHVIEN)=""
+18 QUIT
End DoDot:2
+19 QUIT
End DoDot:1
+20 QUIT
PRINT ;EP - called from xbdbque
+1 SET AMHPG=0
KILL AMHQ
DO HEADER
+2 IF '$DATA(^XTMP("AMHGAFS",AMHJOB,AMHBTH))
WRITE !!,"NO PATIENTS/GAF SCORES TO REPORT"
GOTO DONE
+3 SET AMHNAME=""
FOR
SET AMHNAME=$ORDER(^XTMP("AMHGAFS",AMHJOB,AMHBTH,"PATS",AMHNAME))
IF AMHNAME=""!($DATA(AMHQ))
QUIT
Begin DoDot:1
+4 SET DFN=0
FOR
SET DFN=$ORDER(^XTMP("AMHGAFS",AMHJOB,AMHBTH,"PATS",AMHNAME,DFN))
IF DFN'=+DFN!($DATA(AMHQ))
QUIT
Begin DoDot:2
+5 WRITE !
SET AMHDATE=""
FOR
SET AMHDATE=$ORDER(^XTMP("AMHGAFS",AMHJOB,AMHBTH,"PATS",AMHNAME,DFN,AMHDATE))
IF AMHDATE=""!($DATA(AMHQ))
QUIT
Begin DoDot:3
+6 SET AMHV=0
FOR
SET AMHV=$ORDER(^XTMP("AMHGAFS",AMHJOB,AMHBTH,"PATS",AMHNAME,DFN,AMHDATE,AMHV))
IF AMHV'=+AMHV!($DATA(AMHQ))
QUIT
DO PRINT1
+7 QUIT
End DoDot:3
+8 QUIT
End DoDot:2
+9 QUIT
End DoDot:1
DONE ;
+1 IF $EXTRACT(IOST)="C"
IF IO=IO(0)
SET DIR(0)="EO"
SET DIR("A")="End of report. PRESS RETURN"
DO ^DIR
KILL DIR
IF $DATA(DUOUT)
SET DIRUT=1
+2 KILL ^XTMP("AMHGAFS",AMHJOB,AMHBTH),AMHJOB,AMHBTH
+3 QUIT
+4 ;
PRINT1 ;
+1 IF $Y>(IOSL-3)
DO HEADER
IF $DATA(AMHQ)
QUIT
+2 WRITE !,$EXTRACT(AMHNAME,1,15),?17,$$HRN^AUPNPAT(DFN,DUZ(2)),?24,$$D^AMHLEIN((9999999-AMHDATE))
+3 WRITE ?33,$PIECE(^AMHREC(AMHV,0),U,14),?37,$EXTRACT($PIECE($GET(^AMHREC(AMHV,11)),U,15),1,7)
+4 WRITE ?45,$EXTRACT($$PPNAME^AMHUTIL(AMHV),1,9),?55,$PIECE(^AMHREC(AMHV,0),U,2)
+5 SET X=$ORDER(^AMHRPRO("AD",AMHV,0))
+6 IF X
WRITE ?58,$$VAL^XBDIQ1(9002011.01,X,.01)_"-"_$EXTRACT($$VAL^XBDIQ1(9002011.01,X,.04),1,13)
+7 QUIT
+8 ;----------
+1 IF 'AMHPG
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 AMHQ=""
QUIT
+1 IF $DATA(IOF)
WRITE @IOF
SET AMHPG=AMHPG+1
+2 WRITE !?3,$PIECE(^VA(200,DUZ,0),U,2),?35,$$FMTE^XLFDT(DT),?70,"Page ",AMHPG,!
+3 WRITE !,$$CTR^AMHLEIN("GAF SCORES FOR MULTIPLE PATIENTS",80),!
+4 SET X="Visit Dates: "_$$FMTE^XLFDT(AMHBD)_" to "_$$FMTE^XLFDT(AMHED)
WRITE $$CTR^AMHLEIN(X,80),!
+5 IF AMHPROG]""
SET X="Program: "_$$EXTSET^XBFUNC(9002011,.02,AMHPROG)
WRITE $$CTR^AMHLEIN(X,80),!
+6 IF AMHPROG=""
SET X="Program: ALL"
WRITE $$CTR^AMHLEIN(X,80),!
+7 IF AMHPROV=""
SET X="Provider: ALL"
WRITE $$CTR^AMHLEIN(X,80),!
+8 IF AMHPROV
SET X="Provider: "_$PIECE(^VA(200,AMHPROV,0),U)
WRITE $$CTR^AMHLEIN(X,80),!
+9 WRITE !,"PATIENT NAME",?17,"HRN",?24,"Date",?33,"GAF",?37,"TYPE",?45,"Provider",?55,"PG",?58,"Diagnosis/POV"
+10 WRITE !,$TRANSLATE($JUSTIFY("",80)," ","-")
+11 QUIT