source: qrda/C0Q/trunk/p/C0QMU121.m@ 1508

Last change on this file since 1508 was 1501, checked in by Sam Habiel, 12 years ago

Latest routines; T11 copy

File size: 16.7 KB
Line 
1C0QMU121 ;VEN/SMH - Patient Reminder List, cont. ; 7/31/12 12:33pm
2 ;;1.0;C0Q;;May 21, 2012;Build 63
3 ;
4 ; Licensed under package license.
5 ;
6SMOKING ; Smoking data collection
7 ; WANT TO CHANGE SMOKING STATUS CHECKING FOR 2012 TO A SIMPLE SET OF
8 ; HEALTH FACTORS. GPL
9 I $$INLIST^C0QMU12(ZYR_"HasSmokingStatus",DFN) D Q ; ALREADY HAS SMOKING STAT CHECK
10 . S C0QLIST(ZYR_"HasSmokingStatus",DFN)=""
11 . S C0QLIST(ZYR_"Over12",DFN)=""
12 I $$INLIST^C0QMU12(ZYR_"NoSmokingStatus",DFN) D Q ; ALREADY HAS SMOKING STATUS CHECK
13 . S C0QLIST(ZYR_"NoSmokingStatus",DFN)=""
14 . S C0QLIST(ZYR_"Over12",DFN)=""
15 N C0QSMOKE,C0QSYN
16 S C0QSYN=0
17 I $$AGE^C0QUTIL(DFN)<13 Q ; DON'T CHECK UNDER AGE 13
18 D HFCAT^C0QHF(.C0QSMOKE,DFN,"TOBACCO") ; GET ALL HEALTH FACTORS FOR THE
19 ; PATIENT IN THE CATEGORY OF TOBACCO
20 I $D(C0QSMOKE) S C0QSYN=1
21 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Quit Smokeless Tobacco <1 Yr Ago")
22 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Quit Smokeless Tobacco > 20 Yrs Ago")
23 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Quit Smokeless Tobacco: 1-5 Yrs Ago")
24 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Quit Smokeless Tobacco: 10-20 Yrs Ago")
25 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Quit Smokeless Tobacco: 5-10 Yrs Ago")
26 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Quit Smoking")
27 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Quit Smoking < 1 Yr Ago")
28 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Quit Smoking > 20 Yrs Ago")
29 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Quit Smoking: 1-5 Yrs Ago")
30 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Quit Smoking: 10-20 Yrs Ago")
31 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Quit Smoking: 5-10 Yrs Ago")
32 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"PREVIOUS SMOKELESS TOBACCO USER")
33 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"PREVIOUS SMOKELESS: 1-5 YRS AGO")
34 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"PREVIOUS SMOKELESS: 10-20 YRS AGO")
35 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"PREVIOUS SMOKELESS: 5-10 YRS AGO")
36 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"PREVIOUS SMOKELESS: < 1 YR AGO")
37 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"PREVIOUS SMOKELESS: > 20 YRS AGO")
38 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"PREVIOUS SMOKER")
39 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"PREVIOUS SMOKER 10-20 YRS")
40 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"PREVIOUS SMOKER 20+ YRS")
41 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"PREVIOUS SMOKER < 1 YR")
42 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"PREVIOUS SMOKER < 1 YR AGO")
43 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"PREVIOUS SMOKER > 20 YRS AGO")
44 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"PREVIOUS SMOKER: 1-5 YRS")
45 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"PREVIOUS SMOKER: 1-5 YRS AGO")
46 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"PREVIOUS SMOKER: 10-20 YRS AGO")
47 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"PREVIOUS SMOKER: 5-10 YRS")
48 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"PREVIOUS SMOKER: 5-10 YRS AGO")
49 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"PREVIOUS SMOKELESS TOBACCO USER")
50 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"LIFETIME NON-SMOKER")
51 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Former Smokeless Tobacco User")
52 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Former Smoker")
53 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Former Smoker (PMH)")
54 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoke Exposure/2nd Hand Exposure")
55 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoked For 1-5 Yrs")
56 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoked For 10-20 Yrs")
57 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoked For 5-10 Yrs")
58 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoked For < 1 Yr")
59 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoked For > 20 Yrs")
60 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smokeless Tobacco User")
61 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smokeless Used for 1-5 Yrs")
62 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smokeless Used for 10-20 Yrs")
63 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smokeless Used for 5-10 Yrs")
64 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smokeless Used for < 1 Yr")
65 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smokeless Used for > 20 Yrs")
66 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoker (HPI)")
67 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoking (FMH)")
68 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoking (PMH)")
69 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoking Cessation (OPH)")
70 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"LIFETIME NON-SMOKER")
71 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Former Smokeless Tobacco User")
72 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Former Smoker")
73 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Former Smoker (PMH)")
74 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoke Exposure/2nd Hand Exposure")
75 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoked For 1-5 Yrs")
76 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoked For 10-20 Yrs")
77 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoked For 5-10 Yrs")
78 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoked For < 1 Yr")
79 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoked For > 20 Yrs")
80 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smokeless Tobacco User")
81 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smokeless Used for 1-5 Yrs")
82 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smokeless Used for 10-20 Yrs")
83 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smokeless Used for 5-10 Yrs")
84 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smokeless Used for < 1 Yr")
85 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smokeless Used for > 20 Yrs")
86 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoker (HPI)")
87 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoking (FMH)")
88 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoking (PMH)")
89 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Non-Smoker")
90 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"LIFETIME NON-SMOKER")
91 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Former Smokeless Tobacco User")
92 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Former Smoker")
93 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Former Smoker (PMH)")
94 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoke Exposure/2nd Hand Exposure")
95 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoked For 1-5 Yrs")
96 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoked For 10-20 Yrs")
97 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoked For 5-10 Yrs")
98 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoked For < 1 Yr")
99 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoked For > 20 Yrs")
100 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smokeless Tobacco User")
101 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smokeless Used for 1-5 Yrs")
102 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smokeless Used for 10-20 Yrs")
103 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smokeless Used for 5-10 Yrs")
104 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smokeless Used for < 1 Yr")
105 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smokeless Used for > 20 Yrs")
106 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoker (HPI)")
107 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoking (FMH)")
108 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoking (PMH)")
109 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"LIFETIME NON-SMOKER")
110 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Former Smokeless Tobacco User")
111 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Former Smoker")
112 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Former Smoker (PMH)")
113 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoke Exposure/2nd Hand Exposure")
114 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoked For 1-5 Yrs")
115 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoked For 10-20 Yrs")
116 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoked For 5-10 Yrs")
117 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoked For < 1 Yr")
118 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoked For > 20 Yrs")
119 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smokeless Tobacco User")
120 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smokeless Used for 1-5 Yrs")
121 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smokeless Used for 10-20 Yrs")
122 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smokeless Used for 5-10 Yrs")
123 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smokeless Used for < 1 Yr")
124 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smokeless Used for > 20 Yrs")
125 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoker (HPI)")
126 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoking (FMH)")
127 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoking (PMH)")
128 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Non-Smoker")
129 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"LIFETIME NON-SMOKER")
130 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Former Smokeless Tobacco User")
131 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Former Smoker")
132 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Former Smoker (PMH)")
133 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoke Exposure/2nd Hand Exposure")
134 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoked For 1-5 Yrs")
135 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoked For 10-20 Yrs")
136 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoked For 5-10 Yrs")
137 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoked For < 1 Yr")
138 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoked For > 20 Yrs")
139 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smokeless Tobacco User")
140 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smokeless Used for 1-5 Yrs")
141 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smokeless Used for 10-20 Yrs")
142 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smokeless Used for 5-10 Yrs")
143 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smokeless Used for < 1 Yr")
144 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smokeless Used for > 20 Yrs")
145 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoker (HPI)")
146 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoking (FMH)")
147 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Smoking (PMH)")
148 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Non-Smoker")
149 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Non-Smoker (PMH)")
150 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Non-Tobacco User")
151 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Current Smoker - No")
152 S:'C0QSYN C0QSYN=$$HFYN^C0QHF(DFN,"Current Smoker - Yes")
153 S C0QLIST(ZYR_"Over12",DFN)=""
154 ;N GT
155 ;S GT(1,"HasSmokingStatus","SMOK")=""
156 ;S GT(2,"HasSmokingStatus","Smok")=""
157 ;S GT(3,"HasSmokingStatus","smok")=""
158 ;I 'C0QSYN D ;
159 ;. N G
160 ;. S OK=$$TXTALL^C0QNOTES(.G,.GT,DFN)
161 ;. I $D(G) S C0QSYN=1
162 I C0QSYN S C0QLIST(ZYR_"HasSmokingStatus",DFN)=""
163 E S C0QLIST(ZYR_"NoSmokingStatus",DFN)=""
164 Q
165 ;
166DOTIME(ZHF) ; COMPUTE THE MEAN TIME IN THE ED FROM ARRIVAL TO DEPARTURE
167 ; THIS IS A QUALITY MEASURE ED-1 FOR MEANINGFUL USE
168 ; IT PRINTS A REPORT OF EACH PATIENT WITH THE ED TIMES RECORDED
169 ; AND THEIR TIME. AT THE END IT PRINTS THE MEAN TIME
170 N ZP
171 S ZP=$$PATLN^C0QMU12(ZYR_"HasEDtime") ; patient list name for patients to process
172 S ZHFN=9000010.23 ; FILE NUMBER FOR V HEALTH FACTORS
173 S ZVFN=9000010 ; VISIT FILE NUMBER
174 K ZARY1,ZARY2
175 N ZI S ZI=""
176 S COUNT=0
177 F S ZI=$O(@ZP@(ZI)) Q:ZI="" D ; FOR EACH PATIENT
178 . S COUNT=COUNT+1
179 . N ZA,ZD
180 . S ZA=$$VHFIEN^C0QHF(ZI,"ED ARRIVAL TIME") ; IEN OF ARRIVAL HEALTH FACTOR
181 . S ZD=$$VHFIEN^C0QHF(ZI,ZHF) ; IEN OF DEPART HEALTH FACTOR
182 . N ZAD,ZDD ; ARRIVAL DATE, DEPARTURE DATE
183 . N ZAC,ZDC ; ARRIVAL COMMENT, DEPARTURE COMMENT
184 . ; THE COMMENT IS THE TIME XXYY
185 . N OK,TMP
186 . S TMP=$$GET1^DIQ(ZHFN,ZA_",",.03,"I") ; VISIT POINTER
187 . S ZAD=$$GET1^DIQ(ZVFN,TMP_",",.01,"I") ; VISIT DATE
188 . ;S ZAD=$P(^AUPNVHF(ZA,0),U,3) ; DATE IS PIECE 3
189 . S TMP=$$GET1^DIQ(ZHFN,ZD_",",.03,"I") ; VISIT POINTER
190 . S ZDD=$$GET1^DIQ(ZVFN,TMP_",",.01,"I") ; VISIT DATE
191 . ;S ZDD=$$GET1^DIQ(ZHFN,ZD_",",1201,"I") ; EVENT DATE FIELD
192 . ;S ZDD=$P(^AUPNVHF(ZD,0),U,3) ; DATE IS PIECE 3
193 . ;S OK=$$GET1^DIQ(ZHFN,ZA_",",81101,"","ZAC") ; ARRIVAL TIME
194 . S ZAC=$G(^AUPNVHF(ZA,811)) ; THE TIME
195 . ;S OK=$$GET1^DIQ(ZHFN,ZD_",",81101,"","ZDC") ; DEPARTURE TIME
196 . S ZDC=$G(^AUPNVHF(ZD,811)) ; DEPARTURE TIME
197 . N ZT ; THE TIME DIFFERENCE BETWEEN THE DATES
198 . W !,!,"PATIENT: ",ZI," ",$P(^DPT(ZI,0),U,1)
199 . W !,"IN: ",$$FMTE^XLFDT(ZAD_"."_ZAC)," OUT: ",$$FMTE^XLFDT(ZDD_"."_ZDC)
200 . S G1=($E(ZDC,1,2)*60)+($E(ZDC,3,4))
201 . S G2=($E(ZAC,1,2)*60)+($E(ZAC,3,4))
202 . I (ZDD-ZAD)>0 S G1=G1+(((ZDD-ZAD)*24)*60)
203 . S GTOT=G1-G2
204 . W !,"TIME: ",GTOT," ESTIMATED"
205 . S ZT=$$DTDIFF^C0QUTIL(ZDD,ZDC,ZAD,ZAC) ; COMPUTE THE DIFFERENCE IN MINUTES
206 . W !,"COMPUTED MINUTES: ",ZT
207 . ;I ZT'=GTOT B ; LET'S FIND OUT WHAT'S WRONG
208 . I ZT<0 D Q ; SKIP PATIENTS WITH NEGATIVE TIMES
209 . . W !,"****EXCLUDED****"
210 . I ZT>400000 D Q ; THESE ARE ERRORS
211 . . W !,"****EXCLUDED****"
212 . S ZARY1(ZT,ZI)="" ; ARRAY ORDERED BY MINUTES OF PATIENTS
213 N ZY,ZZ S ZY="" S ZZ=""
214 N ZCOUNT S ZCOUNT=0
215 F S ZY=$O(ZARY1(ZY)) Q:ZY="" D ; FOR EACH TIME
216 . F S ZZ=$O(ZARY1(ZY,ZZ)) Q:ZZ="" D ; FOR EACH PATIENT WITH THIS TIME
217 . . S ZCOUNT=ZCOUNT+1
218 . . S ZARY2(ZCOUNT,ZY,ZZ)=""
219 . . ;W !,ZCOUNT," PATIENT: ",ZZ," MINUTES: ",ZY
220 N ZMID
221 S ZMID=$P(ZCOUNT/2,".")
222 W !,"NUMBER OF PATIENTS IN REPORT: ",ZCOUNT
223 W !,"ED ARRIVAL TIME UNTIL ",ZHF
224 W !,"MEDIAN TIME: ",$O(ZARY2(ZMID,""))
225 Q
226 ;
227DOTIME2(ZHF) ; COMPUTE THE MEAN TIME IN THE ED FROM ARRIVAL TO DEPARTURE
228 ; THIS IS A QUALITY MEASURE ED-1 FOR MEANINGFUL USE
229 ; IT PRINTS A REPORT OF EACH PATIENT WITH THE ED TIMES RECORDED
230 ; AND THEIR TIME. AT THE END IT PRINTS THE MEAN TIME
231 N ZP
232 S ZP=$$PATLN^C0QMU12(ZYR_"HasEDtime") ; patient list name for patients to process
233 S ZHFN=9000010.23 ; FILE NUMBER FOR V HEALTH FACTORS
234 S ZVFN=9000010 ; VISIT FILE NUMBER
235 K ZARY1,ZARY2
236 N ZI S ZI=""
237 S COUNT=0
238 F S ZI=$O(@ZP@(ZI)) Q:ZI="" D ; FOR EACH PATIENT
239 . S COUNT=COUNT+1
240 . N ZA,ZD
241 . ;S ZA=$$VHFIEN^C0QHF(ZI,"ED ARRIVAL TIME") ; IEN OF ARRIVAL HEALTH FACTOR
242 . ;S ZD=$$VHFIEN^C0QHF(ZI,ZHF) ; IEN OF DEPART HEALTH FACTOR
243 . S ZA=$$VHFIEN^C0QHF(ZI,ZHF) ; IEN OF DEPART HEALTH FACTOR
244 . S ZD=$$VHFIEN^C0QHF(ZI,"ED DEPARTURE TIME") ; IEN OF ARRIVAL HEALTH FACTOR
245 . N ZAD,ZDD ; ARRIVAL DATE, DEPARTURE DATE
246 . N ZAC,ZDC ; ARRIVAL COMMENT, DEPARTURE COMMENT
247 . ; THE COMMENT IS THE TIME XXYY
248 . N OK,TMP
249 . S TMP=$$GET1^DIQ(ZHFN,ZA_",",.03,"I") ; VISIT POINTER
250 . S ZAD=$$GET1^DIQ(ZVFN,TMP_",",.01,"I") ; VISIT DATE
251 . ;S ZAD=$P(^AUPNVHF(ZA,0),U,3) ; DATE IS PIECE 3
252 . S TMP=$$GET1^DIQ(ZHFN,ZD_",",.03,"I") ; VISIT POINTER
253 . S ZDD=$$GET1^DIQ(ZVFN,TMP_",",.01,"I") ; VISIT DATE
254 . ;S ZDD=$$GET1^DIQ(ZHFN,ZD_",",1201,"I") ; EVENT DATE FIELD
255 . ;S ZDD=$P(^AUPNVHF(ZD,0),U,3) ; DATE IS PIECE 3
256 . ;S OK=$$GET1^DIQ(ZHFN,ZA_",",81101,"","ZAC") ; ARRIVAL TIME
257 . S ZAC=$G(^AUPNVHF(ZA,811)) ; THE TIME
258 . ;S OK=$$GET1^DIQ(ZHFN,ZD_",",81101,"","ZDC") ; DEPARTURE TIME
259 . S ZDC=$G(^AUPNVHF(ZD,811)) ; DEPARTURE TIME
260 . N ZT ; THE TIME DIFFERENCE BETWEEN THE DATES
261 . W !,!,"PATIENT: ",ZI," ",$P(^DPT(ZI,0),U,1)
262 . W !,"IN: ",$$FMTE^XLFDT(ZAD_"."_ZAC)," OUT: ",$$FMTE^XLFDT(ZDD_"."_ZDC)
263 . S G1=($E(ZDC,1,2)*60)+($E(ZDC,3,4))
264 . S G2=($E(ZAC,1,2)*60)+($E(ZAC,3,4))
265 . I (ZDD-ZAD)>0 S G1=G1+(((ZDD-ZAD)*24)*60)
266 . S GTOT=G1-G2
267 . W !,"TIME: ",GTOT," ESTIMATED"
268 . S ZT=$$DTDIFF^C0QUTIL(ZDD,ZDC,ZAD,ZAC) ; COMPUTE THE DIFFERENCE IN MINUTES
269 . W !,"COMPUTED MINUTES: ",ZT
270 . ;I ZT'=GTOT B ; LET'S FIND OUT WHAT'S WRONG
271 . I ZT<0 D Q ; SKIP PATIENTS WITH NEGATIVE TIMES
272 . . W !,"****EXCLUDED****"
273 . I ZT>400000 D Q ; THESE ARE ERRORS
274 . . W !,"****EXCLUDED****"
275 . S ZARY1(ZT,ZI)="" ; ARRAY ORDERED BY MINUTES OF PATIENTS
276 N ZY,ZZ S ZY="" S ZZ=""
277 N ZCOUNT S ZCOUNT=0
278 F S ZY=$O(ZARY1(ZY)) Q:ZY="" D ; FOR EACH TIME
279 . F S ZZ=$O(ZARY1(ZY,ZZ)) Q:ZZ="" D ; FOR EACH PATIENT WITH THIS TIME
280 . . S ZCOUNT=ZCOUNT+1
281 . . S ZARY2(ZCOUNT,ZY,ZZ)=""
282 . . ;W !,ZCOUNT," PATIENT: ",ZZ," MINUTES: ",ZY
283 N ZMID
284 S ZMID=$P(ZCOUNT/2,".")
285 W !,"NUMBER OF PATIENTS IN REPORT: ",ZCOUNT
286 W !,"ED ARRIVAL TIME UNTIL ",ZHF
287 W !,"MEDIAN TIME: ",$O(ZARY2(ZMID,""))
288 Q
289 ;
290 ; LOOK AT GETTING RID OF PRINT AND SS AS THEY ARE NOT BEING USED. GPL
291 ; VEN/SMH - Call is used in C0QMU12, perhaps not called.
292 ;
293PRINT ; PRINT TO SCREEN
294 I $D(WARD) W !!,WARD_"-"_WARDNAME_" "_RB_": "_PTNAME_"("_PTSEX_") "
295 I $D(EXDTE) D ;
296 . W !,"Discharge Date: ",EXDTE
297 . W !,DFN," ",PTNAME
298 W !,"DOB: ",PTDOB," HRN: ",PTHRN
299 W !,"Language Spoken: ",$G(PTLANG)
300 W !,"Race: ",RACEDSC
301 W !,"Ethnicity: ",$G(ETHNDSC)
302 W !,"Problems: "
303 W !,PBDESC
304 W !,"Allergies: "
305 W !,ALDESC
306 W !,"Medications: "
307 W !
308 Q
309 ;
310SS ; CREATE SPREADSHEET ARRAY
311 S G1("Patient")=DFN
312 I $D(WARD) D ;
313 . S G1("WardName")=WARDNAME
314 . S G1("RoomAndBed")=RB
315 I $D(EXDTE) D ;
316 . S G1("DischargeDate")=EXDTE
317 S G1("PatientName")=PTNAME
318 S G1("Gender")=PTSEX
319 S G1("DateOfBirth")=PTDOB
320 S G1("HealthRecordNumber")=PTHRN
321 S G1("LanguageSpoken")=$G(PTLANG)
322 S G1("Race")=RACEDSC
323 S G1("Ehtnicity")=$G(ETHNDSC)
324 S G1("Problem")=PBDESC
325 I PBDESC["No problems found" S G1("HasProblem")=0
326 E S G1("HasProblem")=1
327 S G1("Allergies")=ALDESC
328 I ALDESC["No Allergy" S G1("HasAllergy")=0
329 E S G1("HasAllergy")=1
330 I $D(MDITEM) D ;
331 . S G1("HasMed")=1
332 E S G1("HasMed")=0
333 S G1("MedDescription")=$G(MDDESC)
334 I $D(MDITEM) W !,"("_MDITEM_")"_MDDESC E W !,MDDESC
335 D RNF1TO2B^C0CRNF("GRSLT","G1")
336 K G1
337 Q ; DON'T WANT TO DO THE NHIN STUFF NOW
338 ;
339PATLIST ; CREATE PATIENT LISTS
340 ; WANT TO GET RID OF PATLIST AND MOVE FUNCTION TO OTHER ROUTINES. GPL
341 ; VEN/SMH - Call is moved here. Seems to be used in C0QMU12.
342 ; Think about removing at another time.
343 S C0QLIST(ZYR_"Patient",DFN)="" ; THE PATIENT LIST
344 N DEMOYN S DEMOYN=1
345 I $G(PTSEX)="" S DEMOYN=0
346 I $G(PTDOB)="" S DEMOYN=0
347 I $G(PTHRN)="" S DEMOYN=0
348 I $G(PTLANG)="" S DEMOYN=0
349 I $G(RACEDSC)="" S DEMOYN=0
350 I $G(ETHNDSC)="" S DEMOYN=0
351 ;I DEMOYN S C0QLIST("HasDemographics",DFN)=""
352 ;E S C0QLIST("FailedDemographics",DFN)=""
353 ;S G1("Gender")=PTSEX
354 ;S G1("DateOfBirth")=PTDOB
355 ;S G1("HealthRecordNumber")=PTHRN
356 ;S G1("LanguageSpoken")=$G(PTLANG)
357 ;S G1("Race")=RACEDSC
358 ;S G1("Ehtnicity")=$G(ETHNDSC)
359 S G1("Problem")=PBDESC
360 I PBDESC["No problems found" S C0QLIST(ZYR_"NoProblem",DFN)=""
361 E S C0QLIST(ZYR_"HasProblem",DFN)=""
362 ;S G1("Allergies")=ALDESC
363 I ALDESC["No Allergy" S C0QLIST(ZYR_"NoAllergy",DFN)=""
364 E S C0QLIST(ZYR_"HasAllergy",DFN)=""
365 ;I $D(MDITEM) D ;
366 ;. S C0QLIST("HasMed",DFN)=""
367 ;E S G1("NoMed",DFN)=""
368 ;S G1("MedDescription")=$G(MDDESC)
369 Q
370 ;
371NHIN ; SHOW THE NHIN ARRAY FOR THIS PATIENT
372 Q:DFN=137!(DFN=14)
373 D EN^C0CNHIN(.G,DFN,"")
374 D ZWRITE^C0QUTIL("G")
375 K G
376 ;
377 QUIT ;end of WARD
378 ;
Note: See TracBrowser for help on using the repository browser.