source: Scheduling/trunk/m/BSDX27.m@ 1082

Last change on this file since 1082 was 1041, checked in by Sam Habiel, 14 years ago

Updated routines version to 1.42

File size: 11.4 KB
RevLine 
[1041]1BSDX27 ; IHS/OIT/HMW - WINDOWS SCHEDULING RPCS ; 12/6/10 4:52pm
2 ;;1.42;BSDX;;Dec 07, 2010
[888]3 ;
4 ; Change Log: July 15, 2010
[1041]5 ; UJO/SMH - i18n: FM Dates passed into routine for Clinic Letters - CLDISP ta
6 ; v 1.42 - 3101208 - SMH
7 ; - Added check to skip cancelled appointments. Check was forgotten
8 ; in original code.
9 ; . N BSDXFLAGS S BSDXFLAGS=$P(BSDXNOD,U,2) ; No show and Cancel Flags
10 ; . Q:BSDXFLAGS["C" ; if appt is cancelled, quit
11 ;
12 Q
13 ;
14PADISPD(BSDXY,BSDXPAT) ;EP
15 ;Entry point for debugging
16 ;
17 ;D DEBUG^%Serenji("PADISP^BSDX27(.BSDXY,BSDXPAT)")
18 Q
19 ;
20PADISP(BSDXY,BSDXPAT) ;EP
21 ;Return recordset of patient appointments used in listing
22 ;a patient's appointments and generating patient letters.
23 ;Called by rpc BSDX PATIENT APPT DISPLAY
24 ;
25 ; Sam's Notes:
26 ; Relatively complex algorithm.
27 ; 1. First, loop through ^DPT(DA,"S", and get all appointments.
28 ; Exclude cancelled appts. Store in BSDXDPT array.
29 ; 2. Go through ^BSDXAPPT("CPAT", (patient index) .
30 ; Get the info from there and compar with BSDXDPT array. If
31 ; they are the same, get all info, and rm entry from BSDXDPT array.
32 ; 3. If there are any remaining entries in BSDXDPT (PIMS leftovers),
33 ; Get the data from file 2 and 44.
34 ;
35 N BSDXI,BSDXIEN,BSDXNOD,BSDXNAM,BSDXDOB,BSDXHRN,BSDXSEX,BSDXCNID,BSDXCNOD,BSDXMADE,BSDXCLRK,BSDXNOT,BSDXQ
36 N BSDXSTRT
37 N BSDXSTRE,BSDXCITY,BSDXST,BSDXZIP,BSDXPHON
38 S BSDXY="^BSDXTMP("_$J_")"
39 S BSDXI=0
40 S ^BSDXTMP($J,BSDXI)="T00030Name^D00020DOB^T00030Sex^T00030HRN^D00030ApptDate^T00030Clinic^T00030TypeStatus"
41 S ^BSDXTMP($J,BSDXI)=^(BSDXI)_"^I00010RESOURCEID^T00030APPT_MADE_BY^D00020DATE_APPT_MADE^T00250NOTE^T00030STREET^T00030CITY^T00030STATE^T00030ZIP^T00030HOMEPHONE"_$C(30)
42 S X="ERROR^BSDX27",@^%ZOSF("TRAP")
43 ;Get patient info
44 ;
45 I '+BSDXPAT S ^BSDXTMP($J,1)=$C(31) Q
46 I '$D(^DPT(+BSDXPAT,0)) S ^BSDXTMP($J,1)=$C(31) Q
47 S BSDXNOD=$$PATINFO(BSDXPAT)
48 S BSDXNAM=$P(BSDXNOD,U) ;NAME
49 S BSDXSEX=$P(BSDXNOD,U,2) ;SEX
50 S BSDXDOB=$P(BSDXNOD,U,3) ;DOB
51 S BSDXHRN=$P(BSDXNOD,U,4) ;Health Record Number for location DUZ(2)
52 S BSDXSTRE=$P(BSDXNOD,U,5) ;Street
53 S BSDXCITY=$P(BSDXNOD,U,6) ;City
54 S BSDXST=$P(BSDXNOD,U,7) ;State
55 S BSDXZIP=$P(BSDXNOD,U,8) ;zip
56 S BSDXPHON=$P(BSDXNOD,U,9) ;homephone
57 ;
58 ;Organize ^DPT(BSDXPAT,"S," nodes
59 ; into BSDXDPT(CLINIC,DATE)
60 ;
61 I $D(^DPT(BSDXPAT,"S")) S BSDXDT=0 F S BSDXDT=$O(^DPT(BSDXPAT,"S",BSDXDT)) Q:'+BSDXDT D
62 . S BSDXNOD=$G(^DPT(BSDXPAT,"S",BSDXDT,0))
63 . S BSDXCID=$P(BSDXNOD,U)
64 . Q:'+BSDXCID
65 . Q:'$D(^SC(BSDXCID,0))
66 . N BSDXFLAGS S BSDXFLAGS=$P(BSDXNOD,U,2) ; No show and Cancel Flags
67 . Q:BSDXFLAGS["C" ; if appt is cancelled, quit
68 . S BSDXDPT(BSDXCID,BSDXDT)=BSDXNOD
69 ;
70 ;$O Through ^BSDX("CPAT",
71 S BSDXIEN=0
72 I $D(^BSDXAPPT("CPAT",BSDXPAT)) F S BSDXIEN=$O(^BSDXAPPT("CPAT",BSDXPAT,BSDXIEN)) Q:'BSDXIEN D
73 . N BSDXNOD,BSDXAPT,BSDXCID,BSDXCNOD,BSDXCLN,BSDX44,BSDXDNOD,BSDXSTAT,BSDX,BSDXTYPE,BSDXLIN
74 . S BSDXNOD=$G(^BSDXAPPT(BSDXIEN,0))
75 . Q:BSDXNOD=""
76 . Q:$P(BSDXNOD,U,12)]"" ;CANCELLED
77 . S Y=$P(BSDXNOD,U)
78 . Q:'+Y
79 . X ^DD("DD") S Y=$TR(Y,"@"," ")
80 . S BSDXAPT=Y ;Appointment date time
81 . S BSDXCLRK=$P(BSDXNOD,U,8) ;Appointment made by
82 . S:+BSDXCLRK BSDXCLRK=$G(^VA(200,BSDXCLRK,0)),BSDXCLRK=$P(BSDXCLRK,U)
83 . S Y=$P(BSDXNOD,U,9) ;Date Appointment Made
84 . I +Y X ^DD("DD") S Y=$TR(Y,"@"," ")
85 . S BSDXMADE=Y
86 . ;NOTE
87 . S BSDXNOT=""
88 . I $D(^BSDXAPPT(BSDXIEN,1,0)) S BSDXNOT="",BSDXQ=0 F S BSDXQ=$O(^BSDXAPPT(BSDXIEN,1,BSDXQ)) Q:'+BSDXQ D
89 . . S BSDXLIN=$G(^BSDXAPPT(BSDXIEN,1,BSDXQ,0))
90 . . S:(BSDXLIN'="")&($E(BSDXLIN,$L(BSDXLIN)-1,$L(BSDXLIN))'=" ") BSDXLIN=BSDXLIN_" "
91 . . S BSDXNOT=BSDXNOT_BSDXLIN
92 . ;Resource
93 . S BSDXCID=$P(BSDXNOD,U,7) ;IEN of BSDX RESOURCE
94 . Q:'+BSDXCID
95 . Q:'$D(^BSDXRES(BSDXCID,0))
96 . S BSDXCNOD=$G(^BSDXRES(BSDXCID,0)) ;BSDX RESOURCE node
97 . Q:BSDXCNOD=""
98 . S BSDXCLN=$P(BSDXCNOD,U) ;Text name of BSDX Resource
99 . S BSDX44=$P(BSDXCNOD,U,4) ;File 44 pointer
100 . ;If appt entry in ^DPT(PAT,"S" exists for this clinic, get the TYPE/STATUS info from
101 . ;the BSDXDPT array and delete the BSDXDPT node
102 . S BSDXTYPE=""
103 . I +BSDX44,$D(BSDXDPT(BSDX44,$P(BSDXNOD,U))) D ;BSDXNOD is the BSDX APPOINTMENT node
104 . . S BSDXDNOD=BSDXDPT(BSDX44,$P(BSDXNOD,U)) ;BSDXDNOD is a copy of the ^DPT(PAT,"S" node
105 . . S BSDXTYPE=$$STATUS(BSDXPAT,$P(BSDXNOD,U),BSDXDNOD) ;IHS/OIT/HMW 20050208 Added
106 . . K BSDXDPT(BSDX44,$P(BSDXNOD,U))
107 . S BSDXI=BSDXI+1
108 . S ^BSDXTMP($J,BSDXI)=BSDXNAM_"^"_BSDXDOB_"^"_BSDXSEX_"^"_BSDXHRN_"^"_BSDXAPT_"^"_BSDXCLN_"^"_BSDXTYPE_"^"_BSDXCID_"^"_BSDXCLRK_"^"_BSDXMADE_"^"_BSDXNOT_"^"_BSDXSTRE_"^"_BSDXCITY_"^"_BSDXST_"^"_BSDXZIP_"^"_BSDXPHON_$C(30)
109 . Q
110 ;
111 ;Go through remaining BSDXDPT( entries
112 I $D(BSDXDPT) S BSDX44=0 D
113 . F S BSDX44=$O(BSDXDPT(BSDX44)) Q:'+BSDX44 S BSDXDT=0 D
114 . . F S BSDXDT=$O(BSDXDPT(BSDX44,BSDXDT)) Q:'+BSDXDT D
115 . . . S BSDXDNOD=BSDXDPT(BSDX44,BSDXDT)
116 . . . S Y=BSDXDT
117 . . . Q:'+Y
118 . . . X ^DD("DD") S Y=$TR(Y,"@"," ")
119 . . . S BSDXAPT=Y
120 . . . S BSDXTYPE=$$STATUS(BSDXPAT,BSDXDT,BSDXDNOD) ;IHS/OIT/HMW 20050208 Added
121 . . . S BSDXCLN=$P($G(^SC(BSDX44,0)),U)
122 . . . S BSDXCLRK=$P(BSDXDNOD,U,18)
123 . . . S:+BSDXCLRK BSDXCLRK=$G(^VA(200,BSDXCLRK,0)),BSDXCLRK=$P(BSDXCLRK,U)
124 . . . S Y=$P(BSDXDNOD,U,19)
125 . . . I +Y X ^DD("DD") S Y=$TR(Y,"@"," ")
126 . . . S BSDXMADE=Y
127 . . . S BSDXNOT=""
128 . . . S BSDXI=BSDXI+1
129 . . . S ^BSDXTMP($J,BSDXI)=BSDXNAM_"^"_BSDXDOB_"^"_BSDXSEX_"^"_BSDXHRN_"^"_BSDXAPT_"^"_BSDXCLN_"^"_BSDXTYPE_"^"_"^"_BSDXCLRK_"^"_BSDXMADE_"^"_BSDXNOT_"^"_BSDXSTRE_"^"_BSDXCITY_"^"_BSDXST_"^"_BSDXZIP_"^"_BSDXPHON_$C(30)
130 . . . K BSDXDPT(BSDX44,BSDXDT)
131 ;
132 S BSDXI=BSDXI+1
133 S ^BSDXTMP($J,BSDXI)=$C(31)
134 Q
135 ;
136STATUS(PAT,DATE,NODE) ; returns appt status
137 ;IHS/OIT/HMW 20050208 Added from BSDDPA
138 NEW TYP
139 S TYP=$$APPTYP^BSDXAPI(PAT,DATE) ;sched vs. walkin
140 I $P(NODE,U,2)["C" Q TYP_" - CANCELLED"
141 I $P(NODE,U,2)'="NT",$P(NODE,U,2)["N" Q TYP_" - NO SHOW"
142 I $$CO^BSDXAPI(PAT,+NODE,DATE) Q TYP_" - CHECKED OUT"
143 I $$CI^BSDXAPI(PAT,+NODE,DATE) Q TYP_" - CHECKED IN"
144 Q TYP
145 ;
146ERROR ;
147 D ERR(BSDXI,"RPMS Error")
148 Q
149 ;
150ERR(BSDXI,ERRNO,MSG) ;Error processing
151 S:'$D(BSDXI) BSDXI=999
152 I +ERRNO S BSDXERR=ERRNO+134234112 ;vbObjectError
153 E S BSDXERR=ERRNO
154 S BSDXI=BSDXI+1
155 S ^BSDXTMP($J,BSDXI)=MSG_"^^^^^^^^^^^^^^^"_$C(30)
156 S BSDXI=BSDXI+1
157 S ^BSDXTMP($J,BSDXI)=$C(31)
158 Q
159PATINFO(BSDXPAT) ;EP
160 ;Intrisic Function returns NAME^SEX^DOB^HRN^STREET^CITY^STATE^ZIP^PHONE for patient ien BSDXPAT
161 ;DOB is in external format
162 ;HRN depends on existence of DUZ(2)
163 ;
164 N BSDXNOD,BSDXNAM,BSDXSEX,BSDXDOB,BSDXHRN,BSDXSTRT,BSDXCITY,BSDXST,BSDXZIP,BSDXPHON
165 S BSDXNOD=^DPT(+BSDXPAT,0)
166 S BSDXNAM=$P(BSDXNOD,U) ;NAME
167 S BSDXSEX=$P(BSDXNOD,U,2)
168 S BSDXSEX=$S(BSDXSEX="F":"FEMALE",BSDXSEX="M":"MALE",1:"")
169 S Y=$P(BSDXNOD,U,3) I Y]"" X ^DD("DD") S Y=$TR(Y,"@"," ")
170 S BSDXDOB=Y ;DOB
171 S BSDXHRN=""
172 I $D(DUZ(2)) I DUZ(2)>0 S BSDXHRN=$P($G(^AUPNPAT(BSDXPAT,41,DUZ(2),0)),U,2) ;HRN
173 ;
174 S BSDXNOD=$G(^DPT(+BSDXPAT,.11))
175 S (BSDXSTRT,BSDXCITY,BSDXST,BSDXZIP)=""
176 I BSDXNOD]"" D
177 . S BSDXSTRT=$E($P(BSDXNOD,U),1,50) ;STREET
178 . S BSDXCITY=$P(BSDXNOD,U,4) ;CITY
179 . S BSDXST=$P(BSDXNOD,U,5) ;STATE
180 . I +BSDXST,$D(^DIC(5,+BSDXST,0)) S BSDXST=$P(^DIC(5,+BSDXST,0),U,2)
181 . S BSDXZIP=$P(BSDXNOD,U,6) ;ZIP
182 ;
183 S BSDXNOD=$G(^DPT(+BSDXPAT,.13)) ;PHONE
184 S BSDXPHON=$P(BSDXNOD,U)
185 ;
186 Q BSDXNAM_U_BSDXSEX_U_BSDXDOB_U_BSDXHRN_U_BSDXSTRT_U_BSDXCITY_U_BSDXST_U_BSDXZIP_U_BSDXPHON
187 ;
[614]188CLDISPD(BSDXY,BSDXCLST,BSDXBEG,BSDXEND) ;EP
[1041]189 ;Entry point for debugging
190 ;
191 ;D DEBUG^%Serenji("CLDISP^BSDX27(.BSDXY,BSDXCLST,BSDXBEG,BSDXEND)")
192 Q
193 ;
194CLDISP(BSDXY,BSDXCLST,BSDXBEG,BSDXEND) ;EP
195 ;
196 ;Return recordset of patient appointments
197 ;between dates BSDXBEG and BSDXEND for each clinic in BSDXCLST.
198 ;Used in listing a patient's appointments and generating patient letters.
199 ;BSDXCLST is a |-delimited list of BSDX RESOURCE iens. (The last |-piece is null, so discard it.)
200 ;BSDXBEG and BSDXEND are in external date form.
201 ;Called by BSDX CLINIC LETTERS
202 ;
203 ; July 10, 2010 -- to support i18n, we pass dates from client in
204 ; locale-neutral Fileman format. No need to convert it.
205 N BSDXI,BSDXNOD,BSDXNAM,BSDXDOB,BSDXHRN,BSDXSEX,BSDXCID,BSDXCNOD,BSDXDT
206 N BSDXJ,BSDXAID,BSDXPAT,BSDXPNOD,BSDXCLN,BSDXCLRK,BSDXMADE,BSDXNOT,BSDXLIN
207 N BSDXSTRT
208 N BSDXSTRE,BSDXCITY,BSDXST,BSDXZIP,BSDXPHON
209 S BSDXY="^BSDXTMP("_$J_")"
210 K ^BSDXTMP($J)
211 S BSDXI=0
212 S ^BSDXTMP($J,BSDXI)="T00030Name^D00020DOB^T00030Sex^T00030HRN^D00030ApptDate^T00030Clinic^T00030TypeStatus"
213 S ^BSDXTMP($J,BSDXI)=^(BSDXI)_"^I00010RESOURCEID^T00030APPT_MADE_BY^D00020DATE_APPT_MADE^T00250NOTE^T00030STREET^T00030CITY^T00030STATE^T00030ZIP^T00030HOMEPHONE"_$C(30)
214 S X="ERROR^BSDX27",@^%ZOSF("TRAP")
215 ;
216 ;Convert beginning and ending dates
217 ;
218 S BSDXBEG=BSDXBEG-1,BSDXBEG=BSDXBEG_".9999"
219 S BSDXEND=BSDXEND_".9999"
220 I BSDXCLST="" D ERR(BSDXI,0,"Routine: BSDX27, Error: Null clinic list") Q
221 ;
222 ;For each clinic in BSDXCLST $O through ^BSDXAPPT("ARSRC",ResourceIEN,FMDate,ApptIEN)
223 ;
224 F BSDXJ=1:1:$L(BSDXCLST,"|")-1 S BSDXCID=$P(BSDXCLST,"|",BSDXJ) D
225 . S BSDXCLN=$G(^BSDXRES(BSDXCID,0)) S BSDXCLN=$P(BSDXCLN,U) Q:BSDXCLN=""
226 . S BSDXSTRT=BSDXBEG F S BSDXSTRT=$O(^BSDXAPPT("ARSRC",BSDXCID,BSDXSTRT)) Q:'+BSDXSTRT Q:BSDXSTRT>BSDXEND D
227 . . S BSDXAID=0 F S BSDXAID=$O(^BSDXAPPT("ARSRC",BSDXCID,BSDXSTRT,BSDXAID)) Q:'+BSDXAID D
228 . . . S BSDXNOD=$G(^BSDXAPPT(BSDXAID,0))
229 . . . Q:BSDXNOD=""
230 . . . Q:$P(BSDXNOD,U,12)]"" ;CANCELLED
231 . . . Q:$P(BSDXNOD,U,13)="y" ;WALKIN
232 . . . S Y=$P(BSDXNOD,U)
233 . . . Q:'+Y
234 . . . X ^DD("DD") S Y=$TR(Y,"@"," ")
235 . . . S BSDXAPT=Y ;Appointment date time
236 . . . ;
237 . . . ;NOTE
238 . . . S BSDXNOT=""
239 . . . I $D(^BSDXAPPT(BSDXAID,1,0)) S BSDXQ=0 F S BSDXQ=$O(^BSDXAPPT(BSDXAID,1,BSDXQ)) Q:'+BSDXQ D
240 . . . . S BSDXLIN=$G(^BSDXAPPT(BSDXAID,1,BSDXQ,0))
241 . . . . S:(BSDXLIN'="")&($E(BSDXLIN,$L(BSDXLIN)-1,$L(BSDXLIN))'=" ") BSDXLIN=BSDXLIN_" "
242 . . . . S BSDXNOT=BSDXNOT_BSDXLIN
243 . . . ;
244 . . . S BSDXPAT=$P(BSDXNOD,U,5)
245 . . . S BSDXPNOD=$$PATINFO(BSDXPAT)
246 . . . S BSDXNAM=$P(BSDXPNOD,U) ;NAME
247 . . . S BSDXSEX=$P(BSDXPNOD,U,2) ;SEX
248 . . . S BSDXDOB=$P(BSDXPNOD,U,3) ;DOB
249 . . . S BSDXHRN=$P(BSDXPNOD,U,4) ;Health Record Number for location DUZ(2)
250 . . . S BSDXSTRE=$P(BSDXPNOD,U,5) ;Street
251 . . . S BSDXCITY=$P(BSDXPNOD,U,6) ;City
252 . . . S BSDXST=$P(BSDXPNOD,U,7) ;State
253 . . . S BSDXZIP=$P(BSDXPNOD,U,8) ;zip
254 . . . S BSDXPHON=$P(BSDXPNOD,U,9) ;homephone
255 . . . S BSDXTYPE="" ;Type/status doesn't exist for BSDX APPT clinics and it's not needed for clinic letters
256 . . . S BSDXCLRK=$P(BSDXNOD,U,8)
257 . . . S:+BSDXCLRK BSDXCLRK=$G(^VA(200,BSDXCLRK,0)),BSDXCLRK=$P(BSDXCLRK,U)
258 . . . S Y=$P(BSDXNOD,U,9)
259 . . . I +Y X ^DD("DD") S Y=$TR(Y,"@"," ")
260 . . . S BSDXMADE=Y
261 . . . S BSDXI=BSDXI+1
262 . . . S ^BSDXTMP($J,BSDXI)=BSDXNAM_"^"_BSDXDOB_"^"_BSDXSEX_"^"_BSDXHRN_"^"_BSDXAPT_"^"_BSDXCLN_"^"_BSDXTYPE_"^"_BSDXCID_"^"_BSDXCLRK_"^"_BSDXMADE_"^"_BSDXNOT_"^"_BSDXSTRE_"^"_BSDXCITY_"^"_BSDXST_"^"_BSDXZIP_"^"_BSDXPHON_$C(30)
263 ;
264 S BSDXI=BSDXI+1
265 S ^BSDXTMP($J,BSDXI)=$C(31)
266 Q
Note: See TracBrowser for help on using the repository browser.