source: WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMGECQ.m@ 1005

Last change on this file since 1005 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 9.3 KB
Line 
1PXRMGECQ ;SLC/JVS GEC-QUEUE'D Reports ;7/14/05 10:44
2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
3 Q
4LOC ;by Location
5 N CAT,HF,DATE,DFN,Y,HFN,DFNXX,PAGE,I
6 D E^PXRMGECV("LOC",1,BDT,EDT,"F",0)
7 D LOCCNT
8 I FORMAT="F" S FOR=1
9 I FORMAT="D" S FOR=0
10 W @IOF
11 F I=1:1:78 W "="
12 ;==
13 W !,"Complete GEC Referrals by Location"
14 W !,"From: "_$$FMTE^XLFDT(BDT,"5ZM")_" To: "_$$FMTE^XLFDT(EDT,"5ZM")
15 I FOR W !,"Location"
16 I FOR W !,?5,"Patient",?50,"Finish Date",!
17 I 'FOR W !,"Location^Location Count^Patient^SSN^Finish Date",!
18 F I=1:1:78 W "="
19 ;==
20 S PAGE=1
21 S LOCN="" F S LOCN=$O(^TMP("PXRMGEC",$J,"TMPLOC",LOCN)) Q:LOCN="" D
22 .Q:LOCNP'=1&(LOCN'=LOCNP)
23 .I FOR W !,LOCN,?30,"Total # Patients Evaluated= ",$G(^TMP("PXRMGEC",$J,"LOCBB",LOCN)) D PAGE^PXRMGECZ
24 .I FOR W ! D PAGE^PXRMGECZ
25 .S DFNXX="" F S DFNXX=$O(^TMP("PXRMGEC",$J,"TMPLOC",LOCN,DFNXX)) Q:DFNXX="" D
26 ..S VDT=0 F S VDT=$O(^TMP("PXRMGEC",$J,"TMPLOC",LOCN,DFNXX,VDT)) Q:VDT="" D
27 ...I VDT["0000" I FOR W !,?5,DFNXX,?50,"Incomplete" D PAGE^PXRMGECZ
28 ...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
29 ...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)
30 K ^TMP("PXRMGEC",$J)
31 S ZTREQ="@"
32 Q
33DR ;by Date Range
34 N CAT,HF,DATE,DFN,Y,HFN,CNTREF,DIF,DIFF,PAGE,I
35 D E^PXRMGECV("HS1",INC,BDT,EDT,$S(INC=1:"F",1:"S"),DFNONLY)
36 I FORMAT="D" S FOR=0
37 I FORMAT="F" S FOR=1
38 W @IOF
39 F I=1:1:78 W "="
40 ;==
41 W !,"Complete GEC Referrals by Date Range"
42 W !,"From: "_$$FMTE^XLFDT(BDT,"5ZM")_" To: "_$$FMTE^XLFDT(EDT,"5ZM")
43 W !,$S(INC=0:"Incomplete",INC=1:"Complete",INC=2:"Complete and Incomplete",1:"")_" Referrals"
44 I FOR W !,"Patient"
45 I INC=1 I FOR W !,?5,"Start Date",?20,"",?35,"Elapsed Time"
46 E I FOR W !,?5,"Start Date",?20,"Finished",?35,"Elapsed Time",?50,"Incomplete Status",!
47 I 'FOR W !,"Patient^SSN^Count^Start Date^Finished Date^Status",!
48 F I=1:1:78 W "="
49 ;==
50 S PAGE=1
51 S DFN="" F S DFN=$O(^TMP("PXRMGEC",$J,"HS1",DFN)) Q:DFN="" D
52 .I FOR W ! D PAGE^PXRMGECZ
53 .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
54 .I FOR W ! D PAGE^PXRMGECZ
55 .S CNTREF="" F S CNTREF=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF)) Q:CNTREF="" D
56 ..S DATE=0 F S DATE=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,DATE)) Q:DATE="" D
57 ...S VDT=0 F S VDT=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,DATE,VDT)) Q:VDT="" D
58 ....S DIFF="" I VDT>0 S DIFF=$$FMDIFF^XLFDT(VDT,DATE,1)+1
59 ....S DIF="" S DIF=$$FMDIFF^XLFDT(DT,DATE,1)+1
60 ....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
61 ....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
62 ....I 'FOR W !,$P(DFN," ",1,$L(DFN," ")-1),"^",$P(DFN," ",$L(DFN," "))
63 ....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
64 K ^TMP("PXRMGEC",$J)
65 S ZTREQ="@"
66 Q
67HS1 ;By Patient
68 N CAT,HF,DATE,DFN,Y,HFN,CNTREF,X,COMMENT,PAGE,DIV,NAME,DFNN,I
69 D E^PXRMGECV("HS1",1,BDT,EDT,"F",DFNONLY)
70 I FORMAT="D" S FOR=0
71 I FORMAT="F" S FOR=1
72 W !
73 F I=1:1:78 W "="
74 ;==
75 W !,"GEC Patient"
76 W !,"From: "_$$FMTE^XLFDT(BDT,"5ZM")_" To: "_$$FMTE^XLFDT(EDT,"5ZM")
77 I FOR W !,"Patient"
78 I FOR W !," Category"
79 I FOR W !," Health Factor",?44,"Value",?55,"Date of Evaluation",!
80 I 'FOR W !,"Patient^SSN^Eval Count^Category^Health Factor^Value^Date of Evaluation",!
81 F I=1:1:78 W "="
82 ;==
83 S PAGE=1,CNT=0
84 S DFN="" F S DFN=$O(^TMP("PXRMGEC",$J,"HS1",DFN)) Q:DFN="" D
85 .I FOR W ! D PAGE^PXRMGECZ
86 .S NAME=$P(DFN," ",1,$L(DFN," ")-1)
87 .S DFNN=$O(^DPT("B",NAME,0)) D
88 ..Q:DFNN=""
89 ..S STATUS=$S($D(^DPT(DFNN,.1)):"INPATIENT",1:"OUTPATIENT")
90 ..S DIV=$$GET1^DIQ(2,DFNN,.19) I DIV="" S DIV="Unknown"
91 .S CNT=CNT+1
92 .I STATUS["IN" I FOR W !,CNT,") ",STATUS,", DIVISION:",DIV D PAGE^PXRMGECZ
93 .I STATUS["OU" I FOR W !,CNT,") ",STATUS D PAGE^PXRMGECZ
94 .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
95 .S CNTREF="" F S CNTREF=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF)) Q:CNTREF="" D
96 ..I FOR W ! D PAGE^PXRMGECZ
97 ..I FOR W !,"Next Referral" D PAGE^PXRMGECZ
98 ..S DATE=0 F S DATE=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,DATE)) Q:DATE="" D
99 ...S VDT=0 F S VDT=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,DATE,VDT)) Q:VDT="" D
100 ....S CAT=0 F S CAT=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,DATE,VDT,CAT)) Q:CAT="" D
101 .....I FOR W !,?1,$P(CAT," ",3,6) D PAGE^PXRMGECZ
102 .....S DATEV=0 F S DATEV=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,DATE,VDT,CAT,DATEV)) Q:DATEV="" D
103 ......S DA=0 F S DA=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,DATE,VDT,CAT,DATEV,DA)) Q:DA="" D
104 .......S HFN=$$HFNAME(DA)
105 .......I FOR W !,?4,$P(HFN,"^",1),?44,$P(HFN,"^",2),?55,$P($$FMTE^XLFDT(DATEV,"5ZM"),"@",1) D PAGE^PXRMGECZ
106 .......S COMMENT=$G(^AUPNVHF(DA,811))
107 .......I FOR I COMMENT'="" D COMQ^PXRMGECZ
108 .......I 'FOR W !,$P(DFN," ",1,$L(DFN," ")-1),"^",$P(DFN," ",$L(DFN," "))
109 .......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)
110 K ^TMP("PXRMGEC",$J)
111 S ZTREQ="@"
112 D ^%ZISC
113 Q
114HFCD ;Health Factor Category Detailed
115 N CAT,HF,DATE,DFN,DFN1,FOR,HFDA,COMMENT,PAGE,I
116 I FORMAT="D" S FOR=0
117 I FORMAT="F" S FOR=1
118 D E^PXRMGECV("HFCD",1,BDT,EDT,"F",DFNONLY)
119 W !
120 F I=1:1:78 W "="
121 ;==
122 W !,"GEC Health Factor Category Detailed Report"
123 W !,"From: "_$$FMTE^XLFDT(BDT,"5ZM")_" To: "_$$FMTE^XLFDT(EDT,"5ZM")
124 I FOR W !,"Category"
125 I FOR W !,?2,"Patient Name"
126 I FOR W !,?4,"Health Factors",?41,"Value",?47,"Date",!
127 I 'FOR W !,"Category^Patient^SSN^Health Factor^Value^Date",!
128 F I=1:1:78 W "="
129 ;==
130 S PAGE=1
131 S CAT="" F S CAT=$O(^TMP("PXRMGEC",$J,"HFCD",CAT)) Q:CAT="" D
132 .S DFN1=0
133 .I FOR W !,$P(CAT," ",3,6) D PAGE^PXRMGECZ
134 .S DFN=0 F S DFN=$O(^TMP("PXRMGEC",$J,"HFCD",CAT,DFN)) Q:DFN="" D
135 ..S HF="" F S HF=$O(^TMP("PXRMGEC",$J,"HFCD",CAT,DFN,HF)) Q:HF="" D
136 ...S DATE=0 F S DATE=$O(^TMP("PXRMGEC",$J,"HFCD",CAT,DFN,HF,DATE)) Q:DATE="" D
137 ....I FOR I DFN'=DFN1 W ! D PAGE^PXRMGECZ
138 ....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
139 ....S HFN=$$HFNAME(0,HF)
140 ....S HFDA=$O(^TMP("PXRMGEC",$J,"HFCD",CAT,DFN,HF,DATE,0))
141 ....I FOR W !,?4,$P(HFN,"^",1),?41,$P(HFN,"^",2),?47,$P($$FMTE^XLFDT(DATE,"5ZM"),"@",1) D PAGE^PXRMGECZ
142 ....S COMMENT=$G(^AUPNVHF(HFDA,811))
143 ....I FOR I COMMENT'="" D COMQ^PXRMGECZ
144 ....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
145 K ^TMP("PXRMGEC",$J)
146 S ZTREQ="@"
147 D ^%ZISC
148 Q
149DFN2 ;By Provider Report
150 N DFN,DOCT,DIADA,DATEV,FLAG,REF,DFN1,PAGE,I
151 S REF="^TMP(""PXRMGEC"",$J)",DFN1=0
152 I FORMAT="D" S FOR=0
153 I FORMAT="F" S FOR=1
154 W @IOF
155 F I=1:1:78 W "="
156 ;==
157 W !,"GEC Provider"
158 W !,"From: "_$$FMTE^XLFDT(BDT,"5ZM")_" To: "_$$FMTE^XLFDT(EDT,"5ZM")
159 W !,"Report Displays Counts of Complete Referrals Only"
160 I FOR W !,"Provider"
161 I FOR W !," Patient",?17,"Completion Date",?41,"Dialog",!
162 I 'FOR W !,"Provider^IEN^Patient^SSN^Dialog^Completion Date",!
163 F I=1:1:78 W "="
164 ;==
165 S PAGE=1
166 D E^PXRMGECV("DFN",1,BDT,EDT,"F",0)
167 S DOCT=0 F S DOCT=$O(@REF@("DFN",DOCT)),FLAG=1 Q:DOCT="" D
168 .I PROV>0&('$D(PROVARY(DOCT))) Q
169 .I FOR W:FLAG=1 !!,$$GET1^DIQ(200,DOCT,.01)_" ("_DOCT_")" D PAGE^PXRMGECZ
170 .S DFN=0 F S DFN=$O(@REF@("DFN",DOCT,DFN)) Q:DFN="" D
171 ..S DATEV=0 F S DATEV=$O(@REF@("DFN",DOCT,DFN,DATEV)) Q:DATEV="" D
172 ...S DIADA=0 F S DIADA=$O(@REF@("DFN",DOCT,DFN,DATEV,DIADA)) Q:DIADA="" D
173 ....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
174 ....I FOR I DFN'=DFN1!(FLAG=1) W ! D PAGE^PXRMGECZ
175 ....S FLAG=0
176 ....W ?17,$P($$FMTE^XLFDT(DATEV,"5ZM"),"@",1,2),?41,$P($P($G(^PXRMD(801.41,DIADA,0)),"^",1)," ",3,6)
177 ....S DFN1=DFN
178 ....I 'FOR W !,$$GET1^DIQ(200,DOCT,.01),"^",DOCT,"^",$P($G(^DPT(DFN,0)),"^",1),"^",$P($G(^DPT(DFN,0)),"^",9)
179 ....I 'FOR W "^",$P($P($G(^PXRMD(801.41,DIADA,0)),"^",1)," ",3,6),"^",$P($$FMTE^XLFDT(DATEV,"5ZM"),"@",1) D PAGE^PXRMGECZ
180 K ^TMP("PXRMGEC",$J)
181 S ZTREQ="@"
182 Q
183 ;
184LOCCNT ;Count Locations of Referrals
185 N LOC,VDT
186 S LOC="" F S LOC=$O(^TMP("PXRMGEC",$J,"LOCB",LOC)) Q:LOC="" D
187 .S VDT="" F S VDT=$O(^TMP("PXRMGEC",$J,"LOCB",LOC,VDT)) Q:VDT="" D
188 ..I $D(^TMP("PXRMGEC",$J,"LOCBB",LOC)) S ^TMP("PXRMGEC",$J,"LOCBB",LOC)=$G(^TMP("PXRMGEC",$J,"LOCBB",LOC))+1
189 ..E S ^TMP("PXRMGEC",$J,"LOCBB",LOC)=1
190 Q
191 ;
192HFNAME(DA,NAME) ;Decide to split name into columns
193 N WHOLE,FIRST,SECOND,REF,REF2,RESULT
194 I DA>0 D
195 .S WHOLE=$P($G(^AUTTHF($P($G(^AUPNVHF(DA,0)),"^",1),0)),"^",1)
196 E S WHOLE=NAME
197 S RESULT="^"
198 S REF="YESNOSTAGE 1STAGE 2STAGE 3STAGE4"
199 S REF2="12"
200 S FIRST=$P(WHOLE,"-",1,$L(WHOLE,"-")-1)
201 S SECOND=$P(WHOLE,"-",$L(WHOLE,"-"))
202 I REF[SECOND S RESULT=FIRST_"^"_SECOND
203 E S RESULT=WHOLE_"^"
204 I REF2[SECOND S RESULT=WHOLE_"^"
205 Q RESULT
206 ;
Note: See TracBrowser for help on using the repository browser.