PXRMGECQ ;SLC/JVS GEC-QUEUE'D Reports ;7/14/05 10:44
;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
Q
LOC ;by Location
N CAT,HF,DATE,DFN,Y,HFN,DFNXX,PAGE,I
D E^PXRMGECV("LOC",1,BDT,EDT,"F",0)
D LOCCNT
I FORMAT="F" S FOR=1
I FORMAT="D" S FOR=0
W @IOF
F I=1:1:78 W "="
;==
W !,"Complete GEC Referrals by Location"
W !,"From: "_$$FMTE^XLFDT(BDT,"5ZM")_" To: "_$$FMTE^XLFDT(EDT,"5ZM")
I FOR W !,"Location"
I FOR W !,?5,"Patient",?50,"Finish Date",!
I 'FOR W !,"Location^Location Count^Patient^SSN^Finish Date",!
F I=1:1:78 W "="
;==
S PAGE=1
S LOCN="" F S LOCN=$O(^TMP("PXRMGEC",$J,"TMPLOC",LOCN)) Q:LOCN="" D
.Q:LOCNP'=1&(LOCN'=LOCNP)
.I FOR W !,LOCN,?30,"Total # Patients Evaluated= ",$G(^TMP("PXRMGEC",$J,"LOCBB",LOCN)) D PAGE^PXRMGECZ
.I FOR W ! D PAGE^PXRMGECZ
.S DFNXX="" F S DFNXX=$O(^TMP("PXRMGEC",$J,"TMPLOC",LOCN,DFNXX)) Q:DFNXX="" D
..S VDT=0 F S VDT=$O(^TMP("PXRMGEC",$J,"TMPLOC",LOCN,DFNXX,VDT)) Q:VDT="" D
...I VDT["0000" I FOR W !,?5,DFNXX,?50,"Incomplete" D PAGE^PXRMGECZ
...E I FOR W !,?5,$P(DFNXX," ",1,$L(DFNXX," ")-1)," ("_$P(DFNXX," ",$L(DFNXX," "))_")",?50,$P($$FMTE^XLFDT(VDT,"5ZM"),"@",1) D PAGE^PXRMGECZ
...I 'FOR W !,LOCN,"^",$G(^TMP("PXRMGEC",$J,"LOCBB",LOCN)),"^",$P(DFNXX," ",1,$L(DFNXX," ")-1),"^",$P(DFNXX," ",$L(DFNXX," ")),"^",$P($$FMTE^XLFDT(VDT,"5ZM"),"@",1)
K ^TMP("PXRMGEC",$J)
S ZTREQ="@"
Q
DR ;by Date Range
N CAT,HF,DATE,DFN,Y,HFN,CNTREF,DIF,DIFF,PAGE,I
D E^PXRMGECV("HS1",INC,BDT,EDT,$S(INC=1:"F",1:"S"),DFNONLY)
I FORMAT="D" S FOR=0
I FORMAT="F" S FOR=1
W @IOF
F I=1:1:78 W "="
;==
W !,"Complete GEC Referrals by Date Range"
W !,"From: "_$$FMTE^XLFDT(BDT,"5ZM")_" To: "_$$FMTE^XLFDT(EDT,"5ZM")
W !,$S(INC=0:"Incomplete",INC=1:"Complete",INC=2:"Complete and Incomplete",1:"")_" Referrals"
I FOR W !,"Patient"
I INC=1 I FOR W !,?5,"Start Date",?20,"",?35,"Elapsed Time"
E I FOR W !,?5,"Start Date",?20,"Finished",?35,"Elapsed Time",?50,"Incomplete Status",!
I 'FOR W !,"Patient^SSN^Count^Start Date^Finished Date^Status",!
F I=1:1:78 W "="
;==
S PAGE=1
S DFN="" F S DFN=$O(^TMP("PXRMGEC",$J,"HS1",DFN)) Q:DFN="" D
.I FOR W ! D PAGE^PXRMGECZ
.I FOR W !,$P(DFN," ",1,$L(DFN," ")-1)," ("_$P(DFN," ",$L(DFN," "))_")",?31,"Total= ",$G(^TMP("PXRMGEC",$J,"REFDFNN",$P(DFN," "))) D PAGE^PXRMGECZ
.I FOR W ! D PAGE^PXRMGECZ
.S CNTREF="" F S CNTREF=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF)) Q:CNTREF="" D
..S DATE=0 F S DATE=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,DATE)) Q:DATE="" D
...S VDT=0 F S VDT=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,DATE,VDT)) Q:VDT="" D
....S DIFF="" I VDT>0 S DIFF=$$FMDIFF^XLFDT(VDT,DATE,1)+1
....S DIF="" S DIF=$$FMDIFF^XLFDT(DT,DATE,1)+1
....I VDT["0000" I FOR W !,?5,$P($$FMTE^XLFDT(DATE,"5ZM"),"@",1),?20,"",?35,$S(DIFF="":DIF_" Days",DIFF>0:DIFF_" Days",1:""),?50,$S(DIFF="":"Incomplete",1:"") D PAGE^PXRMGECZ
....E I FOR W !,?5,$P($$FMTE^XLFDT(DATE,"5ZM"),"@",1),?20,$P($$FMTE^XLFDT(VDT,"5ZM"),"@",1),?35,$S(DIFF="":DIF_" Days",DIFF>0:DIFF_" Days",1:""),?50,$S(DIFF="":"Incomplete",1:"") D PAGE^PXRMGECZ
....I 'FOR W !,$P(DFN," ",1,$L(DFN," ")-1),"^",$P(DFN," ",$L(DFN," "))
....I 'FOR W "^",$G(^TMP("PXRMGEC",$J,"REFDFNN",$P(DFN," "))),"^",$P($$FMTE^XLFDT(DATE,"5ZM"),"@",1),"^",$P($$FMTE^XLFDT(VDT,"5ZM"),"@",1),"^",$S(DIFF="":DIF,DIFF>0:DIFF,1:"") D PAGE^PXRMGECZ
K ^TMP("PXRMGEC",$J)
S ZTREQ="@"
Q
HS1 ;By Patient
N CAT,HF,DATE,DFN,Y,HFN,CNTREF,X,COMMENT,PAGE,DIV,NAME,DFNN,I
D E^PXRMGECV("HS1",1,BDT,EDT,"F",DFNONLY)
I FORMAT="D" S FOR=0
I FORMAT="F" S FOR=1
W !
F I=1:1:78 W "="
;==
W !,"GEC Patient"
W !,"From: "_$$FMTE^XLFDT(BDT,"5ZM")_" To: "_$$FMTE^XLFDT(EDT,"5ZM")
I FOR W !,"Patient"
I FOR W !," Category"
I FOR W !," Health Factor",?44,"Value",?55,"Date of Evaluation",!
I 'FOR W !,"Patient^SSN^Eval Count^Category^Health Factor^Value^Date of Evaluation",!
F I=1:1:78 W "="
;==
S PAGE=1,CNT=0
S DFN="" F S DFN=$O(^TMP("PXRMGEC",$J,"HS1",DFN)) Q:DFN="" D
.I FOR W ! D PAGE^PXRMGECZ
.S NAME=$P(DFN," ",1,$L(DFN," ")-1)
.S DFNN=$O(^DPT("B",NAME,0)) D
..Q:DFNN=""
..S STATUS=$S($D(^DPT(DFNN,.1)):"INPATIENT",1:"OUTPATIENT")
..S DIV=$$GET1^DIQ(2,DFNN,.19) I DIV="" S DIV="Unknown"
.S CNT=CNT+1
.I STATUS["IN" I FOR W !,CNT,") ",STATUS,", DIVISION:",DIV D PAGE^PXRMGECZ
.I STATUS["OU" I FOR W !,CNT,") ",STATUS D PAGE^PXRMGECZ
.I FOR W !,CNT,") ",$P(DFN," ",1,$L(DFN," ")-1)," (",$P(DFN," ",$L(DFN," "))_")",?50,"Total Number of referrals: ",$G(^TMP("PXRMGEC",$J,"REFDFNN",$P(DFN," "))) D PAGE^PXRMGECZ
.S CNTREF="" F S CNTREF=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF)) Q:CNTREF="" D
..I FOR W ! D PAGE^PXRMGECZ
..I FOR W !,"Next Referral" D PAGE^PXRMGECZ
..S DATE=0 F S DATE=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,DATE)) Q:DATE="" D
...S VDT=0 F S VDT=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,DATE,VDT)) Q:VDT="" D
....S CAT=0 F S CAT=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,DATE,VDT,CAT)) Q:CAT="" D
.....I FOR W !,?1,$P(CAT," ",3,6) D PAGE^PXRMGECZ
.....S DATEV=0 F S DATEV=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,DATE,VDT,CAT,DATEV)) Q:DATEV="" D
......S DA=0 F S DA=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,DATE,VDT,CAT,DATEV,DA)) Q:DA="" D
.......S HFN=$$HFNAME(DA)
.......I FOR W !,?4,$P(HFN,"^",1),?44,$P(HFN,"^",2),?55,$P($$FMTE^XLFDT(DATEV,"5ZM"),"@",1) D PAGE^PXRMGECZ
.......S COMMENT=$G(^AUPNVHF(DA,811))
.......I FOR I COMMENT'="" D COMQ^PXRMGECZ
.......I 'FOR W !,$P(DFN," ",1,$L(DFN," ")-1),"^",$P(DFN," ",$L(DFN," "))
.......I 'FOR W "^",$G(^TMP("PXRMGEC",$J,"REFDFNN",$P(DFN," "))),"^",$P(CAT," ",3,6),"^",$P(HFN,"^",1),"^",$P(HFN,"^",2),"^",$P($$FMTE^XLFDT(DATEV,"5ZM"),"@",1)
K ^TMP("PXRMGEC",$J)
S ZTREQ="@"
D ^%ZISC
Q
HFCD ;Health Factor Category Detailed
N CAT,HF,DATE,DFN,DFN1,FOR,HFDA,COMMENT,PAGE,I
I FORMAT="D" S FOR=0
I FORMAT="F" S FOR=1
D E^PXRMGECV("HFCD",1,BDT,EDT,"F",DFNONLY)
W !
F I=1:1:78 W "="
;==
W !,"GEC Health Factor Category Detailed Report"
W !,"From: "_$$FMTE^XLFDT(BDT,"5ZM")_" To: "_$$FMTE^XLFDT(EDT,"5ZM")
I FOR W !,"Category"
I FOR W !,?2,"Patient Name"
I FOR W !,?4,"Health Factors",?41,"Value",?47,"Date",!
I 'FOR W !,"Category^Patient^SSN^Health Factor^Value^Date",!
F I=1:1:78 W "="
;==
S PAGE=1
S CAT="" F S CAT=$O(^TMP("PXRMGEC",$J,"HFCD",CAT)) Q:CAT="" D
.S DFN1=0
.I FOR W !,$P(CAT," ",3,6) D PAGE^PXRMGECZ
.S DFN=0 F S DFN=$O(^TMP("PXRMGEC",$J,"HFCD",CAT,DFN)) Q:DFN="" D
..S HF="" F S HF=$O(^TMP("PXRMGEC",$J,"HFCD",CAT,DFN,HF)) Q:HF="" D
...S DATE=0 F S DATE=$O(^TMP("PXRMGEC",$J,"HFCD",CAT,DFN,HF,DATE)) Q:DATE="" D
....I FOR I DFN'=DFN1 W ! D PAGE^PXRMGECZ
....I FOR I DFN'=DFN1 W !,?2,$P($G(^DPT(DFN,0)),"^",1)_" ("_$P($G(^DPT(DFN,0)),"^",9)_")" W ! S DFN1=DFN D PAGE^PXRMGECZ
....S HFN=$$HFNAME(0,HF)
....S HFDA=$O(^TMP("PXRMGEC",$J,"HFCD",CAT,DFN,HF,DATE,0))
....I FOR W !,?4,$P(HFN,"^",1),?41,$P(HFN,"^",2),?47,$P($$FMTE^XLFDT(DATE,"5ZM"),"@",1) D PAGE^PXRMGECZ
....S COMMENT=$G(^AUPNVHF(HFDA,811))
....I FOR I COMMENT'="" D COMQ^PXRMGECZ
....I 'FOR W !,$P(CAT," ",3,5),"^",$P($G(^DPT(DFN,0)),"^",1)_"^"_$P($G(^DPT(DFN,0)),"^",9),"^",$P(HFN,"^",1),"^",$P(HFN,"^",2),"^",$P($$FMTE^XLFDT(DATE,"5ZM"),"@",1) D PAGE^PXRMGECZ
K ^TMP("PXRMGEC",$J)
S ZTREQ="@"
D ^%ZISC
Q
DFN2 ;By Provider Report
N DFN,DOCT,DIADA,DATEV,FLAG,REF,DFN1,PAGE,I
S REF="^TMP(""PXRMGEC"",$J)",DFN1=0
I FORMAT="D" S FOR=0
I FORMAT="F" S FOR=1
W @IOF
F I=1:1:78 W "="
;==
W !,"GEC Provider"
W !,"From: "_$$FMTE^XLFDT(BDT,"5ZM")_" To: "_$$FMTE^XLFDT(EDT,"5ZM")
W !,"Report Displays Counts of Complete Referrals Only"
I FOR W !,"Provider"
I FOR W !," Patient",?17,"Completion Date",?41,"Dialog",!
I 'FOR W !,"Provider^IEN^Patient^SSN^Dialog^Completion Date",!
F I=1:1:78 W "="
;==
S PAGE=1
D E^PXRMGECV("DFN",1,BDT,EDT,"F",0)
S DOCT=0 F S DOCT=$O(@REF@("DFN",DOCT)),FLAG=1 Q:DOCT="" D
.I PROV>0&('$D(PROVARY(DOCT))) Q
.I FOR W:FLAG=1 !!,$$GET1^DIQ(200,DOCT,.01)_" ("_DOCT_")" D PAGE^PXRMGECZ
.S DFN=0 F S DFN=$O(@REF@("DFN",DOCT,DFN)) Q:DFN="" D
..S DATEV=0 F S DATEV=$O(@REF@("DFN",DOCT,DFN,DATEV)) Q:DATEV="" D
...S DIADA=0 F S DIADA=$O(@REF@("DFN",DOCT,DFN,DATEV,DIADA)) Q:DIADA="" D
....I FOR W !,?2,$S(DFN'=DFN1!(FLAG=1):$P($G(^DPT(DFN,0)),"^",1)_" ("_$P($G(^DPT(DFN,0)),"^",9)_")"_" ("_$$CNT^PXRMGECL(DOCT,DFN)_" Evaluation(s) )",1:"") D PAGE^PXRMGECZ
....I FOR I DFN'=DFN1!(FLAG=1) W ! D PAGE^PXRMGECZ
....S FLAG=0
....W ?17,$P($$FMTE^XLFDT(DATEV,"5ZM"),"@",1,2),?41,$P($P($G(^PXRMD(801.41,DIADA,0)),"^",1)," ",3,6)
....S DFN1=DFN
....I 'FOR W !,$$GET1^DIQ(200,DOCT,.01),"^",DOCT,"^",$P($G(^DPT(DFN,0)),"^",1),"^",$P($G(^DPT(DFN,0)),"^",9)
....I 'FOR W "^",$P($P($G(^PXRMD(801.41,DIADA,0)),"^",1)," ",3,6),"^",$P($$FMTE^XLFDT(DATEV,"5ZM"),"@",1) D PAGE^PXRMGECZ
K ^TMP("PXRMGEC",$J)
S ZTREQ="@"
Q
;
LOCCNT ;Count Locations of Referrals
N LOC,VDT
S LOC="" F S LOC=$O(^TMP("PXRMGEC",$J,"LOCB",LOC)) Q:LOC="" D
.S VDT="" F S VDT=$O(^TMP("PXRMGEC",$J,"LOCB",LOC,VDT)) Q:VDT="" D
..I $D(^TMP("PXRMGEC",$J,"LOCBB",LOC)) S ^TMP("PXRMGEC",$J,"LOCBB",LOC)=$G(^TMP("PXRMGEC",$J,"LOCBB",LOC))+1
..E S ^TMP("PXRMGEC",$J,"LOCBB",LOC)=1
Q
;
HFNAME(DA,NAME) ;Decide to split name into columns
N WHOLE,FIRST,SECOND,REF,REF2,RESULT
I DA>0 D
.S WHOLE=$P($G(^AUTTHF($P($G(^AUPNVHF(DA,0)),"^",1),0)),"^",1)
E S WHOLE=NAME
S RESULT="^"
S REF="YESNOSTAGE 1STAGE 2STAGE 3STAGE4"
S REF2="12"
S FIRST=$P(WHOLE,"-",1,$L(WHOLE,"-")-1)
S SECOND=$P(WHOLE,"-",$L(WHOLE,"-"))
I REF[SECOND S RESULT=FIRST_"^"_SECOND
E S RESULT=WHOLE_"^"
I REF2[SECOND S RESULT=WHOLE_"^"
Q RESULT
;
PXRMGECQ ;SLC/JVS GEC-QUEUE'D Reports ;7/14/05 10:44
+1 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
+2 QUIT
LOC ;by Location
+1 NEW CAT,HF,DATE,DFN,Y,HFN,DFNXX,PAGE,I
+2 DO E^PXRMGECV("LOC",1,BDT,EDT,"F",0)
+3 DO LOCCNT
+4 IF FORMAT="F"
SET FOR=1
+5 IF FORMAT="D"
SET FOR=0
+6 WRITE @IOF
+7 FOR I=1:1:78
WRITE "="
+8 ;==
+9 WRITE !,"Complete GEC Referrals by Location"
+10 WRITE !,"From: "_$$FMTE^XLFDT(BDT,"5ZM")_" To: "_$$FMTE^XLFDT(EDT,"5ZM")
+11 IF FOR
WRITE !,"Location"
+12 IF FOR
WRITE !,?5,"Patient",?50,"Finish Date",!
+13 IF 'FOR
WRITE !,"Location^Location Count^Patient^SSN^Finish Date",!
+14 FOR I=1:1:78
WRITE "="
+15 ;==
+16 SET PAGE=1
+17 SET LOCN=""
FOR
SET LOCN=$ORDER(^TMP("PXRMGEC",$JOB,"TMPLOC",LOCN))
IF LOCN=""
QUIT
Begin DoDot:1
+18 IF LOCNP'=1&(LOCN'=LOCNP)
QUIT
+19 IF FOR
WRITE !,LOCN,?30,"Total # Patients Evaluated= ",$GET(^TMP("PXRMGEC",$JOB,"LOCBB",LOCN))
DO PAGE^PXRMGECZ
+20 IF FOR
WRITE !
DO PAGE^PXRMGECZ
+21 SET DFNXX=""
FOR
SET DFNXX=$ORDER(^TMP("PXRMGEC",$JOB,"TMPLOC",LOCN,DFNXX))
IF DFNXX=""
QUIT
Begin DoDot:2
+22 SET VDT=0
FOR
SET VDT=$ORDER(^TMP("PXRMGEC",$JOB,"TMPLOC",LOCN,DFNXX,VDT))
IF VDT=""
QUIT
Begin DoDot:3
+23 IF VDT["0000"
IF FOR
WRITE !,?5,DFNXX,?50,"Incomplete"
DO PAGE^PXRMGECZ
+24 IF '$TEST
IF FOR
WRITE !,?5,$PIECE(DFNXX," ",1,$LENGTH(DFNXX," ")-1)," ("_$PIECE(DFNXX," ",$LENGTH(DFNXX," "))_")",?50,$PIECE($$FMTE^XLFDT(VDT,"5ZM"),"@",1)
DO PAGE^PXRMGECZ
+25 IF 'FOR
WRITE !,LOCN,"^",$GET(^TMP("PXRMGEC",$JOB,"LOCBB",LOCN)),"^",$PIECE(DFNXX," ",1,$LENGTH(DFNXX," ")-1),"^",$PIECE(DFNXX," ",$LENGTH(DFNXX," ")),"^",$PIECE($$FMTE^XLFDT(VDT,"5ZM"),"@",1)
End DoDot:3
End DoDot:2
End DoDot:1
+26 KILL ^TMP("PXRMGEC",$JOB)
+27 SET ZTREQ="@"
+28 QUIT
DR ;by Date Range
+1 NEW CAT,HF,DATE,DFN,Y,HFN,CNTREF,DIF,DIFF,PAGE,I
+2 DO E^PXRMGECV("HS1",INC,BDT,EDT,$SELECT(INC=1:"F",1:"S"),DFNONLY)
+3 IF FORMAT="D"
SET FOR=0
+4 IF FORMAT="F"
SET FOR=1
+5 WRITE @IOF
+6 FOR I=1:1:78
WRITE "="
+7 ;==
+8 WRITE !,"Complete GEC Referrals by Date Range"
+9 WRITE !,"From: "_$$FMTE^XLFDT(BDT,"5ZM")_" To: "_$$FMTE^XLFDT(EDT,"5ZM")
+10 WRITE !,$SELECT(INC=0:"Incomplete",INC=1:"Complete",INC=2:"Complete and Incomplete",1:"")_" Referrals"
+11 IF FOR
WRITE !,"Patient"
+12 IF INC=1
IF FOR
WRITE !,?5,"Start Date",?20,"",?35,"Elapsed Time"
+13 IF '$TEST
IF FOR
WRITE !,?5,"Start Date",?20,"Finished",?35,"Elapsed Time",?50,"Incomplete Status",!
+14 IF 'FOR
WRITE !,"Patient^SSN^Count^Start Date^Finished Date^Status",!
+15 FOR I=1:1:78
WRITE "="
+16 ;==
+17 SET PAGE=1
+18 SET DFN=""
FOR
SET DFN=$ORDER(^TMP("PXRMGEC",$JOB,"HS1",DFN))
IF DFN=""
QUIT
Begin DoDot:1
+19 IF FOR
WRITE !
DO PAGE^PXRMGECZ
+20 IF FOR
WRITE !,$PIECE(DFN," ",1,$LENGTH(DFN," ")-1)," ("_$PIECE(DFN," ",$LENGTH(DFN," "))_")",?31,"Total= ",$GET(^TMP("PXRMGEC",$JOB,"REFDFNN",$PIECE(DFN," ")))
DO PAGE^PXRMGECZ
+21 IF FOR
WRITE !
DO PAGE^PXRMGECZ
+22 SET CNTREF=""
FOR
SET CNTREF=$ORDER(^TMP("PXRMGEC",$JOB,"HS1",DFN,CNTREF))
IF CNTREF=""
QUIT
Begin DoDot:2
+23 SET DATE=0
FOR
SET DATE=$ORDER(^TMP("PXRMGEC",$JOB,"HS1",DFN,CNTREF,DATE))
IF DATE=""
QUIT
Begin DoDot:3
+24 SET VDT=0
FOR
SET VDT=$ORDER(^TMP("PXRMGEC",$JOB,"HS1",DFN,CNTREF,DATE,VDT))
IF VDT=""
QUIT
Begin DoDot:4
+25 SET DIFF=""
IF VDT>0
SET DIFF=$$FMDIFF^XLFDT(VDT,DATE,1)+1
+26 SET DIF=""
SET DIF=$$FMDIFF^XLFDT(DT,DATE,1)+1
+27 IF VDT["0000"
IF FOR
WRITE !,?5,$PIECE($$FMTE^XLFDT(DATE,"5ZM"),"@",1),?20,"",?35,$SELECT(DIFF="":DIF_" Days",DIFF>0:DIFF_" Days",1:""),?50,$SELECT(DIFF="":"Incomplete",1:"")
DO PAGE^PXRMGECZ
+28 IF '$TEST
IF FOR
WRITE !,?5,$PIECE($$FMTE^XLFDT(DATE,"5ZM"),"@",1),?20,$PIECE($$FMTE^XLFDT(VDT,"5ZM"),"@",1),?35,$SELECT(DIFF="":DIF_" Days",DIFF>0:DIFF_" Days",1:""),?50,$SELECT(DIFF="":"Incomplete",1:"")
DO PAGE^PXRMGECZ
+29 IF 'FOR
WRITE !,$PIECE(DFN," ",1,$LENGTH(DFN," ")-1),"^",$PIECE(DFN," ",$LENGTH(DFN," "))
+30 IF 'FOR
WRITE "^",$GET(^TMP("PXRMGEC",$JOB,"REFDFNN",$PIECE(DFN," "))),"^",$PIECE($$FMTE^XLFDT(DATE,"5ZM"),"@",1),"^",$PIECE($$FMTE^XLFDT(VDT,"5ZM"),"@",1),"^",$SELECT(DIFF="":DIF,DIFF>0:DIFF,1:"")
DO PAGE^PXRMGECZ
End DoDot:4
End DoDot:3
End DoDot:2
End DoDot:1
+31 KILL ^TMP("PXRMGEC",$JOB)
+32 SET ZTREQ="@"
+33 QUIT
HS1 ;By Patient
+1 NEW CAT,HF,DATE,DFN,Y,HFN,CNTREF,X,COMMENT,PAGE,DIV,NAME,DFNN,I
+2 DO E^PXRMGECV("HS1",1,BDT,EDT,"F",DFNONLY)
+3 IF FORMAT="D"
SET FOR=0
+4 IF FORMAT="F"
SET FOR=1
+5 WRITE !
+6 FOR I=1:1:78
WRITE "="
+7 ;==
+8 WRITE !,"GEC Patient"
+9 WRITE !,"From: "_$$FMTE^XLFDT(BDT,"5ZM")_" To: "_$$FMTE^XLFDT(EDT,"5ZM")
+10 IF FOR
WRITE !,"Patient"
+11 IF FOR
WRITE !," Category"
+12 IF FOR
WRITE !," Health Factor",?44,"Value",?55,"Date of Evaluation",!
+13 IF 'FOR
WRITE !,"Patient^SSN^Eval Count^Category^Health Factor^Value^Date of Evaluation",!
+14 FOR I=1:1:78
WRITE "="
+15 ;==
+16 SET PAGE=1
SET CNT=0
+17 SET DFN=""
FOR
SET DFN=$ORDER(^TMP("PXRMGEC",$JOB,"HS1",DFN))
IF DFN=""
QUIT
Begin DoDot:1
+18 IF FOR
WRITE !
DO PAGE^PXRMGECZ
+19 SET NAME=$PIECE(DFN," ",1,$LENGTH(DFN," ")-1)
+20 SET DFNN=$ORDER(^DPT("B",NAME,0))
Begin DoDot:2
+21 IF DFNN=""
QUIT
+22 SET STATUS=$SELECT($DATA(^DPT(DFNN,.1)):"INPATIENT",1:"OUTPATIENT")
+23 SET DIV=$$GET1^DIQ(2,DFNN,.19)
IF DIV=""
SET DIV="Unknown"
End DoDot:2
+24 SET CNT=CNT+1
+25 IF STATUS["IN"
IF FOR
WRITE !,CNT,") ",STATUS,", DIVISION:",DIV
DO PAGE^PXRMGECZ
+26 IF STATUS["OU"
IF FOR
WRITE !,CNT,") ",STATUS
DO PAGE^PXRMGECZ
+27 IF FOR
WRITE !,CNT,") ",$PIECE(DFN," ",1,$LENGTH(DFN," ")-1)," (",$PIECE(DFN," ",$LENGTH(DFN," "))_")",?50,"Total Number of referrals: ",$GET(^TMP("PXRMGEC",$JOB,"REFDFNN",$PIECE(DFN," ")))
DO PAGE^PXRMGECZ
+28 SET CNTREF=""
FOR
SET CNTREF=$ORDER(^TMP("PXRMGEC",$JOB,"HS1",DFN,CNTREF))
IF CNTREF=""
QUIT
Begin DoDot:2
+29 IF FOR
WRITE !
DO PAGE^PXRMGECZ
+30 IF FOR
WRITE !,"Next Referral"
DO PAGE^PXRMGECZ
+31 SET DATE=0
FOR
SET DATE=$ORDER(^TMP("PXRMGEC",$JOB,"HS1",DFN,CNTREF,DATE))
IF DATE=""
QUIT
Begin DoDot:3
+32 SET VDT=0
FOR
SET VDT=$ORDER(^TMP("PXRMGEC",$JOB,"HS1",DFN,CNTREF,DATE,VDT))
IF VDT=""
QUIT
Begin DoDot:4
+33 SET CAT=0
FOR
SET CAT=$ORDER(^TMP("PXRMGEC",$JOB,"HS1",DFN,CNTREF,DATE,VDT,CAT))
IF CAT=""
QUIT
Begin DoDot:5
+34 IF FOR
WRITE !,?1,$PIECE(CAT," ",3,6)
DO PAGE^PXRMGECZ
+35 SET DATEV=0
FOR
SET DATEV=$ORDER(^TMP("PXRMGEC",$JOB,"HS1",DFN,CNTREF,DATE,VDT,CAT,DATEV))
IF DATEV=""
QUIT
Begin DoDot:6
+36 SET DA=0
FOR
SET DA=$ORDER(^TMP("PXRMGEC",$JOB,"HS1",DFN,CNTREF,DATE,VDT,CAT,DATEV,DA))
IF DA=""
QUIT
Begin DoDot:7
+37 SET HFN=$$HFNAME(DA)
+38 IF FOR
WRITE !,?4,$PIECE(HFN,"^",1),?44,$PIECE(HFN,"^",2),?55,$PIECE($$FMTE^XLFDT(DATEV,"5ZM"),"@",1)
DO PAGE^PXRMGECZ
+39 SET COMMENT=$GET(^AUPNVHF(DA,811))
+40 IF FOR
IF COMMENT'=""
DO COMQ^PXRMGECZ
+41 IF 'FOR
WRITE !,$PIECE(DFN," ",1,$LENGTH(DFN," ")-1),"^",$PIECE(DFN," ",$LENGTH(DFN," "))
+42 IF 'FOR
WRITE "^",$GET(^TMP("PXRMGEC",$JOB,"REFDFNN",$PIECE(DFN," "))),"^",$PIECE(CAT," ",3,6),"^",$PIECE(HFN,"^",1),"^",$PIECE(HFN,"^",2),"^",$PIECE($$FMTE^XLFDT(DATEV,"5ZM"),"@",1)
End DoDot:7
End DoDot:6
End DoDot:5
End DoDot:4
End DoDot:3
End DoDot:2
End DoDot:1
+43 KILL ^TMP("PXRMGEC",$JOB)
+44 SET ZTREQ="@"
+45 DO ^%ZISC
+46 QUIT
HFCD ;Health Factor Category Detailed
+1 NEW CAT,HF,DATE,DFN,DFN1,FOR,HFDA,COMMENT,PAGE,I
+2 IF FORMAT="D"
SET FOR=0
+3 IF FORMAT="F"
SET FOR=1
+4 DO E^PXRMGECV("HFCD",1,BDT,EDT,"F",DFNONLY)
+5 WRITE !
+6 FOR I=1:1:78
WRITE "="
+7 ;==
+8 WRITE !,"GEC Health Factor Category Detailed Report"
+9 WRITE !,"From: "_$$FMTE^XLFDT(BDT,"5ZM")_" To: "_$$FMTE^XLFDT(EDT,"5ZM")
+10 IF FOR
WRITE !,"Category"
+11 IF FOR
WRITE !,?2,"Patient Name"
+12 IF FOR
WRITE !,?4,"Health Factors",?41,"Value",?47,"Date",!
+13 IF 'FOR
WRITE !,"Category^Patient^SSN^Health Factor^Value^Date",!
+14 FOR I=1:1:78
WRITE "="
+15 ;==
+16 SET PAGE=1
+17 SET CAT=""
FOR
SET CAT=$ORDER(^TMP("PXRMGEC",$JOB,"HFCD",CAT))
IF CAT=""
QUIT
Begin DoDot:1
+18 SET DFN1=0
+19 IF FOR
WRITE !,$PIECE(CAT," ",3,6)
DO PAGE^PXRMGECZ
+20 SET DFN=0
FOR
SET DFN=$ORDER(^TMP("PXRMGEC",$JOB,"HFCD",CAT,DFN))
IF DFN=""
QUIT
Begin DoDot:2
+21 SET HF=""
FOR
SET HF=$ORDER(^TMP("PXRMGEC",$JOB,"HFCD",CAT,DFN,HF))
IF HF=""
QUIT
Begin DoDot:3
+22 SET DATE=0
FOR
SET DATE=$ORDER(^TMP("PXRMGEC",$JOB,"HFCD",CAT,DFN,HF,DATE))
IF DATE=""
QUIT
Begin DoDot:4
+23 IF FOR
IF DFN'=DFN1
WRITE !
DO PAGE^PXRMGECZ
+24 IF FOR
IF DFN'=DFN1
WRITE !,?2,$PIECE($GET(^DPT(DFN,0)),"^",1)_" ("_$PIECE($GET(^DPT(DFN,0)),"^",9)_")"
WRITE !
SET DFN1=DFN
DO PAGE^PXRMGECZ
+25 SET HFN=$$HFNAME(0,HF)
+26 SET HFDA=$ORDER(^TMP("PXRMGEC",$JOB,"HFCD",CAT,DFN,HF,DATE,0))
+27 IF FOR
WRITE !,?4,$PIECE(HFN,"^",1),?41,$PIECE(HFN,"^",2),?47,$PIECE($$FMTE^XLFDT(DATE,"5ZM"),"@",1)
DO PAGE^PXRMGECZ
+28 SET COMMENT=$GET(^AUPNVHF(HFDA,811))
+29 IF FOR
IF COMMENT'=""
DO COMQ^PXRMGECZ
+30 IF 'FOR
WRITE !,$PIECE(CAT," ",3,5),"^",$PIECE($GET(^DPT(DFN,0)),"^",1)_"^"_$PIECE($GET(^DPT(DFN,0)),"^",9),"^",$PIECE(HFN,"^",1),"^",$PIECE(HFN,"^",2),"^",$PIECE($$FMTE^XLFDT(DATE,"5ZM"),"@",1)
DO PAGE^PXRMGECZ
End DoDot:4
End DoDot:3
End DoDot:2
End DoDot:1
+31 KILL ^TMP("PXRMGEC",$JOB)
+32 SET ZTREQ="@"
+33 DO ^%ZISC
+34 QUIT
DFN2 ;By Provider Report
+1 NEW DFN,DOCT,DIADA,DATEV,FLAG,REF,DFN1,PAGE,I
+2 SET REF="^TMP(""PXRMGEC"",$J)"
SET DFN1=0
+3 IF FORMAT="D"
SET FOR=0
+4 IF FORMAT="F"
SET FOR=1
+5 WRITE @IOF
+6 FOR I=1:1:78
WRITE "="
+7 ;==
+8 WRITE !,"GEC Provider"
+9 WRITE !,"From: "_$$FMTE^XLFDT(BDT,"5ZM")_" To: "_$$FMTE^XLFDT(EDT,"5ZM")
+10 WRITE !,"Report Displays Counts of Complete Referrals Only"
+11 IF FOR
WRITE !,"Provider"
+12 IF FOR
WRITE !," Patient",?17,"Completion Date",?41,"Dialog",!
+13 IF 'FOR
WRITE !,"Provider^IEN^Patient^SSN^Dialog^Completion Date",!
+14 FOR I=1:1:78
WRITE "="
+15 ;==
+16 SET PAGE=1
+17 DO E^PXRMGECV("DFN",1,BDT,EDT,"F",0)
+18 SET DOCT=0
FOR
SET DOCT=$ORDER(@REF@("DFN",DOCT))
SET FLAG=1
IF DOCT=""
QUIT
Begin DoDot:1
+19 IF PROV>0&('$DATA(PROVARY(DOCT)))
QUIT
+20 IF FOR
IF FLAG=1
WRITE !!,$$GET1^DIQ(200,DOCT,.01)_" ("_DOCT_")"
DO PAGE^PXRMGECZ
+21 SET DFN=0
FOR
SET DFN=$ORDER(@REF@("DFN",DOCT,DFN))
IF DFN=""
QUIT
Begin DoDot:2
+22 SET DATEV=0
FOR
SET DATEV=$ORDER(@REF@("DFN",DOCT,DFN,DATEV))
IF DATEV=""
QUIT
Begin DoDot:3
+23 SET DIADA=0
FOR
SET DIADA=$ORDER(@REF@("DFN",DOCT,DFN,DATEV,DIADA))
IF DIADA=""
QUIT
Begin DoDot:4
+24 IF FOR
WRITE !,?2,$SELECT(DFN'=DFN1!(FLAG=1):$PIECE($GET(^DPT(DFN,0)),"^",1)_" ("_$PIECE($GET(^DPT(DFN,0)),"^",9)_")"_" ("_$$CNT^PXRMGECL(DOCT,DFN)_" Evaluation(s) )",1:"")
DO PAGE^PXRMGECZ
+25 IF FOR
IF DFN'=DFN1!(FLAG=1)
WRITE !
DO PAGE^PXRMGECZ
+26 SET FLAG=0
+27 WRITE ?17,$PIECE($$FMTE^XLFDT(DATEV,"5ZM"),"@",1,2),?41,$PIECE($PIECE($GET(^PXRMD(801.41,DIADA,0)),"^",1)," ",3,6)
+28 SET DFN1=DFN
+29 IF 'FOR
WRITE !,$$GET1^DIQ(200,DOCT,.01),"^",DOCT,"^",$PIECE($GET(^DPT(DFN,0)),"^",1),"^",$PIECE($GET(^DPT(DFN,0)),"^",9)
+30 IF 'FOR
WRITE "^",$PIECE($PIECE($GET(^PXRMD(801.41,DIADA,0)),"^",1)," ",3,6),"^",$PIECE($$FMTE^XLFDT(DATEV,"5ZM"),"@",1)
DO PAGE^PXRMGECZ
End DoDot:4
End DoDot:3
End DoDot:2
End DoDot:1
+31 KILL ^TMP("PXRMGEC",$JOB)
+32 SET ZTREQ="@"
+33 QUIT
+34 ;
LOCCNT ;Count Locations of Referrals
+1 NEW LOC,VDT
+2 SET LOC=""
FOR
SET LOC=$ORDER(^TMP("PXRMGEC",$JOB,"LOCB",LOC))
IF LOC=""
QUIT
Begin DoDot:1
+3 SET VDT=""
FOR
SET VDT=$ORDER(^TMP("PXRMGEC",$JOB,"LOCB",LOC,VDT))
IF VDT=""
QUIT
Begin DoDot:2
+4 IF $DATA(^TMP("PXRMGEC",$JOB,"LOCBB",LOC))
SET ^TMP("PXRMGEC",$JOB,"LOCBB",LOC)=$GET(^TMP("PXRMGEC",$JOB,"LOCBB",LOC))+1
+5 IF '$TEST
SET ^TMP("PXRMGEC",$JOB,"LOCBB",LOC)=1
End DoDot:2
End DoDot:1
+6 QUIT
+7 ;
HFNAME(DA,NAME) ;Decide to split name into columns
+1 NEW WHOLE,FIRST,SECOND,REF,REF2,RESULT
+2 IF DA>0
Begin DoDot:1
+3 SET WHOLE=$PIECE($GET(^AUTTHF($PIECE($GET(^AUPNVHF(DA,0)),"^",1),0)),"^",1)
End DoDot:1
+4 IF '$TEST
SET WHOLE=NAME
+5 SET RESULT="^"
+6 SET REF="YESNOSTAGE 1STAGE 2STAGE 3STAGE4"
+7 SET REF2="12"
+8 SET FIRST=$PIECE(WHOLE,"-",1,$LENGTH(WHOLE,"-")-1)
+9 SET SECOND=$PIECE(WHOLE,"-",$LENGTH(WHOLE,"-"))
+10 IF REF[SECOND
SET RESULT=FIRST_"^"_SECOND
+11 IF '$TEST
SET RESULT=WHOLE_"^"
+12 IF REF2[SECOND
SET RESULT=WHOLE_"^"
+13 QUIT RESULT
+14 ;