source: Scheduling/trunk/m/BSDXUT.m@ 1462

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

Done refactoring BSDX31 plus all Unit Tests

File size: 17.8 KB
Line 
1BSDXUT ; VEN/SMH - Unit Tests for Scheduling GUI ; 6/27/12 4:18pm
2 ;;1.7T1;BSDX;;Aug 31, 2011;Build 18
3 ; Licensed under LGPL
4 ;
5 ; Change Log:
6 ; June 21 2012: Initial Version
7 ;
8UT07 ; Unit Tests for BSDX07 - Assumes you have Patients with DFNs 1,2,3,4,5
9 ; HLs/Resources are created as part of the UT
10 ; Set-up - Create Clinics
11 N RESNAM S RESNAM="UTCLINIC"
12 N HLRESIENS ; holds output of UTCR^BSDXUT - HL IEN^Resource IEN
13 D
14 . N $ET S $ET="D ^%ZTER B"
15 . S HLRESIENS=$$UTCR^BSDXUT(RESNAM)
16 . I HLRESIENS<0 S $EC=",U1," ; not supposed to happen - hard crash if so
17 ;
18 N HLIEN,RESIEN
19 S HLIEN=$P(HLRESIENS,U)
20 S RESIEN=$P(HLRESIENS,U,2)
21 ;
22 ; Get start and end times
23 N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
24 N APPTTIME S APPTTIME=$P(TIMES,U)
25 N ENDTIME S ENDTIME=$P(TIMES,U,2)
26 ;
27 N ZZZ,DFN
28 ; Test for normality:
29 S DFN=3
30 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
31 ; Does Appt exist?
32 N APPID S APPID=+$P(^BSDXTMP($J,1),U)
33 I 'APPID W "Error Making Appt-1" QUIT
34 I +^BSDXAPPT(APPID,0)'=APPTTIME W "Error Making Appt-2"
35 I '$D(^DPT(DFN,"S",APPTTIME)) W "Error Making Appt-3"
36 I '$$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error Making Appt-4"
37 ;
38 ; Do it again for a different patient
39 S DFN=2
40 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
41 N APPID S APPID=+$P(^BSDXTMP($J,1),U)
42 I 'APPID W "Error Making Appt-5" QUIT
43 I +^BSDXAPPT(APPID,0)'=APPTTIME W "Error Making Appt-6"
44 I '$D(^DPT(DFN,"S",APPTTIME)) W "Error Making Appt-7"
45 I '$$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error Making Appt-8"
46 ;
47 ; Again for a different patient (4)
48 S DFN=4
49 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
50 N APPID S APPID=+$P(^BSDXTMP($J,1),U)
51 I 'APPID W "Error Making Appt-9" QUIT
52 I +^BSDXAPPT(APPID,0)'=APPTTIME W "Error Making Appt-10"
53 I '$D(^DPT(DFN,"S",APPTTIME)) W "Error Making Appt-11"
54 I '$$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error Making Appt-12"
55 ;
56 ; Delete appointment set for Patient 4 (made above)
57 N BSDX,DFN
58 S DFN=4
59 S BSDX("PAT")=DFN
60 S BSDX("CLN")=HLIEN
61 S BSDX("ADT")=APPTTIME
62 D ROLLBACK^BSDX07(APPID,.BSDX)
63 I +$G(^BSDXAPPT(APPID,0)) W "Error in deleting appointment-1",!
64 I $D(^DPT(DFN,"S",APPTTIME)) W "Error in deleting appointment-2",!
65 I $$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error in deleting appointment-3",!
66 ;
67 ; Again for a different patient (5)
68 S DFN=5
69 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
70 N APPID S APPID=+$P(^BSDXTMP($J,1),U)
71 I 'APPID W "Error Making Appt-13" QUIT
72 I +^BSDXAPPT(APPID,0)'=APPTTIME W "Error Making Appt-14"
73 I '$D(^DPT(DFN,"S",APPTTIME)) W "Error Making Appt-15"
74 I '$$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error Making Appt-16"
75 ; Now cancel that appointment
76 D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Sam's Cancel Note")
77 ; Now make it again
78 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
79 N APPID S APPID=+$P(^BSDXTMP($J,1),U)
80 I 'APPID W "Error Making Appt-17" QUIT
81 I +^BSDXAPPT(APPID,0)'=APPTTIME W "Error Making Appt-18"
82 I '$D(^DPT(DFN,"S",APPTTIME)) W "Error Making Appt-19"
83 I '$$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error Making Appt-20"
84 ;
85 ; Delete appointment set for Patient 1 (not made)... needs to not crash
86 D
87 . N $ET S $ET="D ^%ZTER S $EC="""" W ""Failure to del non-existent appt"",!"
88 . N BSDX
89 . S BSDX("PAT")=1
90 . S BSDX("CLN")=HLIEN
91 . S BSDX("ADT")=APPTTIME
92 . D ROLLBACK^BSDX07(APPID,.BSDX)
93 ;
94 ; Test for bad start date
95 D APPADD^BSDX07(.ZZZ,2100123,3100123.3,2,RESNAM,30,"Sam's Note",1)
96 I +$P(^BSDXTMP($J,1),U,2)'=-2 W "Error in -2",!
97 ; Test for bad end date
98 D APPADD^BSDX07(.ZZZ,3100123,2100123.3,2,RESNAM,30,"Sam's Note",1)
99 I +$P(^BSDXTMP($J,1),U,2)'=-3 W "Error in -3",!
100 ; Test for end date without time - obsolete
101 ; Test for mumps error
102 N BSDXDIE S BSDXDIE=1
103 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,1,RESNAM,30,"Sam's Note",1)
104 I +$P(^BSDXTMP($J,1),U,2)'=-100 W "Error in -100: M Error",!
105 K BSDXDIE
106 ; Test for TRESTART -- retired in v 1.7
107 ; Test for non-numeric patient
108 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,"CAT,DOG",RESNAM,30,"Sam's Note",1)
109 I +$P(^BSDXTMP($J,1),U,2)'=-5 W "Error in -5",!
110 ; Test for a non-existent patient
111 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,8989898989,RESNAM,30,"Sam's Note",1)
112 I +$P(^BSDXTMP($J,1),U,2)'=-6 W "Error in -6",!
113 ; Test for a non-existent resource name
114 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,3,"lkajsflkjsadf",30,"Sam's Note",1)
115 I +$P(^BSDXTMP($J,1),U,2)'=-7 W "Error in -7",!
116 ; Test for corrupted resource
117 ; Can't test for -8 since it requires DB corruption
118 ; Test for inability to add appointment to BSDX Appointment (-9)
119 ; Also requires something wrong in the DB
120 ; Test for inability to add appointment to 2,44
121 ; Test by creating a duplicate appointment
122 ; Get start and end times
123 N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
124 N APPTTIME S APPTTIME=$P(TIMES,U)
125 N ENDTIME S ENDTIME=$P(TIMES,U,2)
126 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,3,RESNAM,30,"Sam's Note",1)
127 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,3,RESNAM,30,"Sam's Note",1)
128 I +$P(^BSDXTMP($J,1),U,2)'=-10 W "Error in -10",!
129 ;
130 ; Test that ROLLBACK^BSDX07 occurs properly in various places
131 N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
132 N APPTTIME S APPTTIME=$P(TIMES,U)
133 N ENDTIME S ENDTIME=$P(TIMES,U,2)
134 S DFN=4
135 N BSDXSIMERR1 S BSDXSIMERR1=1
136 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
137 N APPID S APPID=$O(^BSDXAPPT("B",APPTTIME,""))
138 I +APPID W "Error in deleting appointment-4",!
139 I $D(^DPT(DFN,"S",APPTTIME)) W "Error in deleting appointment-5",!
140 I $$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error in deleting appointment-6",!
141 ;
142 K BSDXSIMERR1
143 N BSDXSIMERR2 S BSDXSIMERR2=1
144 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
145 N APPID S APPID=$O(^BSDXAPPT("B",APPTTIME,""))
146 I +APPID W "Error in deleting appointment-7",!
147 I $D(^DPT(DFN,"S",APPTTIME)) W "Error in deleting appointment-8",!
148 I $$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error in deleting appointment-9",!
149 ;
150 K BSDXSIMERR2
151 N BSDXSIMERR4 S BSDXSIMERR4=1
152 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
153 N APPID S APPID=$O(^BSDXAPPT("B",APPTTIME,""))
154 I +APPID W "Error in deleting appointment-16",!
155 I $D(^DPT(DFN,"S",APPTTIME)) W "Error in deleting appointment-17",!
156 I $$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error in deleting appointment-18",!
157 ;
158 K BSDXSIMERR4
159 N BSDXSIMERR5 S BSDXSIMERR5=1
160 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
161 N APPID S APPID=$O(^BSDXAPPT("B",APPTTIME,""))
162 I +APPID W "Error in deleting appointment-19",!
163 I $D(^DPT(DFN,"S",APPTTIME)) W "Error in deleting appointment-20",!
164 I $$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error in deleting appointment-21",!
165 ;
166 ; Okay now we do UTs for an unlinked resource (not linked to PIMS)
167 N RESNAM S RESNAM="UTCLINICUL" ; Unlinked Clinic
168 N RESIEN
169 D
170 . N $ET S $ET="D ^%ZTER B"
171 . S RESIEN=$$UTCRRES^BSDXUT(RESNAM)
172 . I RESIEN<0 S $EC=",U1," ; not supposed to happen - hard crash if so
173 ;
174 ; Get start and end times
175 N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
176 N APPTTIME S APPTTIME=$P(TIMES,U)
177 N ENDTIME S ENDTIME=$P(TIMES,U,2)
178 ;
179 N ZZZ,DFN
180 ; Test for normality:
181 S DFN=3
182 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
183 ; Does Appt exist?
184 N APPID S APPID=+$P(^BSDXTMP($J,1),U)
185 I 'APPID W "Error Making Appt-101" QUIT
186 I +^BSDXAPPT(APPID,0)'=APPTTIME W "Error Making Appt-102"
187 I $D(^DPT(DFN,"S",APPTTIME)) W "Error Making Appt-103"
188 ;
189 ; Again for a different patient (4)
190 S DFN=4
191 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
192 N APPID S APPID=+$P(^BSDXTMP($J,1),U)
193 I 'APPID W "Error Making Appt-104" QUIT
194 I +^BSDXAPPT(APPID,0)'=APPTTIME W "Error Making Appt-105"
195 I $D(^DPT(DFN,"S",APPTTIME)) W "Error Making Appt-106"
196 ;
197 ; Delete appointment set for Patient 4 (made above)
198 N BSDX,DFN
199 S DFN=4
200 D ROLLBACK^BSDX07(APPID)
201 I +$G(^BSDXAPPT(APPID,0)) W "Error in deleting appointment-1",!
202 ;
203 ; Duplicate appointments... This is SUPPOSED to fail for now (v1.7)
204 N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
205 N APPTTIME S APPTTIME=$P(TIMES,U)
206 N ENDTIME S ENDTIME=$P(TIMES,U,2)
207 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,3,RESNAM,30,"Sam's Note",1)
208 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,3,RESNAM,30,"Sam's Note",1)
209 I +$P(^BSDXTMP($J,1),U,2)'=-10 W "Error in -10 in Unlinked Section (existing bug)",!
210 ;
211 ; Test that ROLLBACK^BSDX07 occurs properly in various places
212 N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
213 N APPTTIME S APPTTIME=$P(TIMES,U)
214 N ENDTIME S ENDTIME=$P(TIMES,U,2)
215 S DFN=4
216 N BSDXSIMERR1 S BSDXSIMERR1=1
217 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
218 N APPID S APPID=$O(^BSDXAPPT("B",APPTTIME,""))
219 I +APPID W "Error in deleting appointment-101",!
220 ;
221 ; These are never triggered, so we should still have an appointment
222 K BSDXSIMERR1
223 N BSDXSIMERR2 S BSDXSIMERR2=1
224 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
225 N APPID S APPID=$O(^BSDXAPPT("B",APPTTIME,""))
226 I '+APPID W "Error in deleting appointment-102",!
227 ;
228 K BSDXSIMERR2
229 N BSDXSIMERR4 S BSDXSIMERR4=1
230 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
231 N APPID S APPID=$O(^BSDXAPPT("B",APPTTIME,""))
232 I '+APPID W "Error in deleting appointment-103",!
233 ;
234 K BSDXSIMERR4
235 N BSDXSIMERR5 S BSDXSIMERR5=1
236 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
237 N APPID S APPID=$O(^BSDXAPPT("B",APPTTIME,""))
238 I '+APPID W "Error in deleting appointment-104",!
239 QUIT
240 ;
241UT08 ; Unit Tests for BSDX08; Must have patients 1,2,3,4,5 defined in system
242 N RESNAM S RESNAM="UTCLINIC"
243 N HLRESIENS ; holds output of UTCR^BSDXUT - HL IEN^Resource IEN
244 D
245 . N $ET S $ET="D ^%ZTER B"
246 . S HLRESIENS=$$UTCR^BSDXUT(RESNAM)
247 . I HLRESIENS<0 S $EC=",U1," ; not supposed to happen - hard crash if so
248 ;
249 N HLIEN,RESIEN
250 S HLIEN=$P(HLRESIENS,U)
251 S RESIEN=$P(HLRESIENS,U,2)
252 ;
253 ; Get start and end times
254 N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
255 N APPTTIME S APPTTIME=$P(TIMES,U)
256 N ENDTIME S ENDTIME=$P(TIMES,U,2)
257 ;
258 ; Test 1: Make normal appointment and cancel it. See if every thing works
259 N ZZZ,DFN
260 S DFN=3
261 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
262 S APPID=+$P(^BSDXTMP($J,1),U)
263 D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Sam's Cancel Note")
264 I $P(^BSDXAPPT(APPID,0),U,12)'>0 W "Error in Cancellation-1",!
265 I $O(^SC(HLIEN,"S",APPTTIME,1,0))]"" W "Error in Cancellation-2",!
266 I $P(^DPT(DFN,"S",APPTTIME,0),U,2)'="PC" W "Error in Cancellation-3",!
267 I ^DPT(DFN,"S",APPTTIME,"R")'="Sam's Cancel Note" W "Error in Cancellation-4",!
268 ;
269 ; Test 2: Check for -1 -- TODO: Fix later... Can't do right now automatically
270 ; Make appt
271 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
272 ; Lock the node in another job
273 S APPID=+$P(^BSDXTMP($J,1),U)
274 ; W "Lock ^BSDXAPPT("_APPID_") in another session. You have 10 seconds." H 10
275 D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Sam's Cancel Note")
276 ;
277 ; Test 3: Check for -100
278 N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
279 N APPTTIME S APPTTIME=$P(TIMES,U)
280 N ENDTIME S ENDTIME=$P(TIMES,U,2)
281 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
282 S APPID=+$P(^BSDXTMP($J,1),U)
283 N BSDXDIE1 S BSDXDIE1=1
284 D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Reasons")
285 I $P(^BSDXTMP($J,1),"~")'=-100 W "Error in -100",!
286 K BSDXDIE1
287 ;
288 ; Test 3.5: Check for -100 with an appointment to rollback.
289 N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
290 N APPTTIME S APPTTIME=$P(TIMES,U)
291 N ENDTIME S ENDTIME=$P(TIMES,U,2)
292 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
293 S APPID=+$P(^BSDXTMP($J,1),U)
294 N BSDXDIE2 S BSDXDIE2=1
295 D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Reasons")
296 I $P(^BSDXTMP($J,1),"~")'=-100 W "Error in -100-1",!
297 I $P(^BSDXAPPT(APPID,0),U,12)'="" W "Error in -100-2",!
298 K BSDXDIE2
299 ; Test 4: Restartable transaction -- retired in V 1.7
300 ; Test 5: for invalid Appointment ID (-2 and -3)
301 D APPDEL^BSDX08(.ZZZ,0,"PC",1,"Reasons")
302 I $P(^BSDXTMP($J,1),"~")'=-2 W "Error in -2",!
303 D APPDEL^BSDX08(.ZZZ,999999,"PC",1,"Reasons")
304 I $P(^BSDXTMP($J,1),"~")'=-3 W "Error in -3",!
305 ; More unit Tests
306 ;
307 ; Test 6: for Cancelling walkin and checked-in appointments
308 N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
309 N APPTTIME S APPTTIME=$P(TIMES,U)
310 N ENDTIME S ENDTIME=$P(TIMES,U,2)
311 S DFN=4
312 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,10,"Sam's Note",1) ; Add appt
313 S APPID=+$P(^BSDXTMP($J,1),U)
314 I APPID=0 W "Error in test 6",!
315 D CHECKIN^BSDX25(.ZZZ,APPID,$$NOW^XLFDT) ; check-in
316 D APPDEL^BSDX08(.ZZZ,APPID,"PC",10,"Cancel Note") ; Delete appt
317 I $P(^BSDXTMP($J,1),$C(30))'="" W "Error in test 6",!
318 ;
319 ; Test 7: for cancelling walkin and checked-in appointments
320 N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
321 N APPTTIME S APPTTIME=$P(TIMES,U)
322 N ENDTIME S ENDTIME=$P(TIMES,U,2)
323 S DFN=4
324 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,10,"Sam's Note",1) ; Add appt
325 S APPID=+$P(^BSDXTMP($J,1),U)
326 I APPID=0 W "Error in test 6",!
327 D CHECKIN^BSDX25(.ZZZ,APPID,$$NOW^XLFDT) ; Checkin
328 S BSDXRESULT=$$RMCI^BSDXAPI(DFN,HLIEN,APPTTIME) ; remove checkin
329 D APPDEL^BSDX08(.ZZZ,APPID,"PC",10,"Cancel Note") ; delete appt
330 I $P(^BSDXTMP($J,1),$C(30))'="" W "Error in test 6",!
331 ;
332 ; Unlinked Clinic Tests
333 N RESNAM S RESNAM="UTCLINICUL" ; Unlinked Clinic
334 N RESIEN
335 D
336 . N $ET S $ET="D ^%ZTER B"
337 . S RESIEN=$$UTCRRES^BSDXUT(RESNAM)
338 . I RESIEN<0 S $EC=",U1," ; not supposed to happen - hard crash if so
339 ;
340 ; Get start and end times
341 N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
342 N APPTTIME S APPTTIME=$P(TIMES,U)
343 N ENDTIME S ENDTIME=$P(TIMES,U,2)
344 ;
345 ; Test 1: Make normal appointment and cancel it. See if every thing works
346 N ZZZ,DFN
347 S DFN=3
348 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
349 S APPID=+$P(^BSDXTMP($J,1),U)
350 D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Sam's Cancel Note")
351 I $P(^BSDXAPPT(APPID,0),U,12)'>0 W "Error in Cancellation-1"
352 ;
353 ; Test 6: for Cancelling walkin and checked-in appointments
354 N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
355 N APPTTIME S APPTTIME=$P(TIMES,U)
356 N ENDTIME S ENDTIME=$P(TIMES,U,2)
357 S DFN=4
358 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,10,"Sam's Note",1) ; Add appt
359 S APPID=+$P(^BSDXTMP($J,1),U)
360 I APPID=0 W "Error in test 6",!
361 D CHECKIN^BSDX25(.ZZZ,APPID,$$NOW^XLFDT) ; check-in
362 D APPDEL^BSDX08(.ZZZ,APPID,"PC",10,"Cancel Note") ; Delete appt
363 I $P(^BSDXTMP($J,1),$C(30))'="" W "Error in test 6",!
364 ;
365 ; Test 7: for cancelling walkin and checked-in appointments
366 N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
367 N APPTTIME S APPTTIME=$P(TIMES,U)
368 N ENDTIME S ENDTIME=$P(TIMES,U,2)
369 S DFN=5
370 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,10,"Sam's Note",1) ; Add appt
371 S APPID=+$P(^BSDXTMP($J,1),U)
372 I APPID=0 W "Error in test 6",!
373 D CHECKIN^BSDX25(.ZZZ,APPID,$$NOW^XLFDT) ; Checkin
374 S BSDXRESULT=$$RMCI^BSDXAPI(DFN,HLIEN,APPTTIME) ; remove checkin
375 D APPDEL^BSDX08(.ZZZ,APPID,"PC",10,"Cancel Note") ; delete appt
376 I $P(^BSDXTMP($J,1),$C(30))'="" W "Error in test 6",!
377 QUIT
378 ;
379UTCR(RESNAM) ; $$ - Create Unit Test Clinic and Resource Pair ; Private
380 ; Input: Resource Name By Value
381 ; Output: -1^Error or HLIEN^RESIEN for Success (file 44 IEN^file 9002018.1 IEN)
382 ; DO NOT USE IN A PRODUCTION ENVIRONTMENT. INTENDED FOR TESTING ONLY
383 N HLIEN S HLIEN=$$UTCR44(RESNAM)
384 I +HLIEN=-1 QUIT HLIEN
385 ;
386 N RESIEN S RESIEN=$$UTCRRES(RESNAM,HLIEN)
387 I +RESIEN=-1 QUIT RESIEN
388 E QUIT HLIEN_U_RESIEN
389 ;
390UTCR44(HLNAME) ; $$ - Create Unit Test Clinic in File 44; Private ; TESTING ONLY CODE
391 ; Output: -1^Error or IEN for Success
392 ; Input: Hosp Location Name by Value
393 ; DO NOT USE IN A PRODUCTION ENVIRONTMENT. INTENDED FOR TESTING ONLY
394 ;
395 I $D(^SC("B",HLNAME)) Q $O(^(HLNAME,""))
396 ;
397 N SAM
398 S SAM(44,"?+1,",.01)=HLNAME ; Name
399 S SAM(44,"?+1,",2)="C" ; Type = Clinic
400 S SAM(44,"?+1,",2.1)=1 ; Type Extension (not used)
401 S SAM(44,"?+1,",3.5)=$O(^DG(40.8,0)) ; Division (not yet used)
402 S SAM(44,"?+1,",8)=295 ; Stop Code Number (not used)
403 S SAM(44,"?+1,",9)="M" ; Service (not used)
404 S SAM(44,"?+1,",1912)=15 ; Length of Appt (not used)
405 S SAM(44,"?+1,",1917)=4 ; Display increments per hour (not used)
406 S SAM(44,"?+1,",1918)=8 ; Overbooks/day max (not used)
407 S SAM(44,"?+1,",2000.5)=0 ; Require Action Profiles: Yes (not used)
408 S SAM(44,"?+1,",2001)=999 ; Allowable consecutive no-shows (not used)
409 S SAM(44,"?+1,",2002)=999 ; Max # days for Future Booking (not used)
410 S SAM(44,"?+1,",2005)=365 ; Max # days for Auto Rebook (not used)
411 S SAM(44,"?+1,",2502)="N" ; Non-Count Clinic (not used)
412 S SAM(44,"?+1,",2504)="Y" ; Clinic meets at this Facility? (not used)
413 S SAM(44,"?+1,",2507)=9 ; Appointment Type (not used)
414 ;
415 N BSDXERR,BSDXIEN
416 D UPDATE^DIE("",$NA(SAM),$NA(BSDXIEN),$NA(BSDXERR))
417 Q $S($D(BSDXERR):-1_U_BSDXERR("DIERR",1,"TEXT",1),1:BSDXIEN(1))
418 ;
419UTCRRES(NAME,HLIEN) ; $$ - Create Unit Test Resource in 9002018.1 (BSDX RESOURCE); Private
420 ; Input: Hospital Location IEN
421 ; Output: -1^Error or IEN for Success
422 ; DO NOT USE IN A PRODUCTION ENVIRONTMENT. INTENDED FOR TESTING ONLY
423 I $D(^BSDXRES("B",NAME)) Q $O(^(NAME,""))
424 S HLIEN=$G(HLIEN) ; If we don't send one in
425 N RES ; garbage variable
426 D RSRC^BSDX16(.RES,"|"_NAME_"||"_HLIEN)
427 N RTN S RTN=@$Q(^BSDXTMP($J,0)) ; return array next value
428 Q $S(RTN=0:-1_U_RTN,1:+RTN) ; 0 means an error has occurred; 1 means IEN returned
429 ;
430TIMES() ; $$ - Create a next available appointment time^ending time; Private
431 ; Output: appttime^endtime
432 N NOW S NOW=$$NOW^XLFDT() ; Now time
433 N LAST S LAST=$O(^BSDXAPPT("B"," "),-1) ; highest time in file
434 N TIME2USE S TIME2USE=$S(NOW>LAST:NOW,1:LAST) ; Which time to use?
435 S TIME2USE=$E(TIME2USE,1,12) ; Strip away seconds
436 N APPTIME S APPTIME=$$FMADD^XLFDT(TIME2USE,0,0,15,0) ; Add 15 min
437 N ENDTIME S ENDTIME=$$FMADD^XLFDT(APPTIME,0,0,15,0) ; Add 15 more min
438 Q APPTIME_U_ENDTIME ; quit with apptime^endtime
439 ;
440TIMEHL(HLIEN) ; $$ - Create a next available appointment time^ending time by HL; Private
441 ; Input: HLIEN
442 ; Output: Next available appointment time for the HLIEN
443 N LAST S LAST=$O(^SC(HLIEN,"S",""),-1)
444 Q $$FMADD^XLFDT(LAST,1,0,15,0) ; Add 1 day and 15 minutes
Note: See TracBrowser for help on using the repository browser.