1 | BSDXUT ; VEN/SMH - Unit Tests for Scheduling GUI ; 6/21/12 4:42pm
|
---|
2 | ;;1.7T1;BSDX;;Aug 31, 2011;Build 18
|
---|
3 | ; Licensed under LGPL
|
---|
4 | ;
|
---|
5 | ; Change Log:
|
---|
6 | ; June 21 2012: Initial Version
|
---|
7 | ;
|
---|
8 | UT07 ; 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",!
|
---|
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 | ;
|
---|
241 | UT08 ; 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 BSDXDIE S BSDXDIE=1
|
---|
279 | D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
|
---|
280 | S APPID=+$P(^BSDXTMP($J,1),U)
|
---|
281 | D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Reasons")
|
---|
282 | I $P(^BSDXTMP($J,1),"~")'=-100 W "Error in -100",!
|
---|
283 | K BSDXDIE
|
---|
284 | ;
|
---|
285 | ; Test 4: Restartable transaction -- retired in V 1.7
|
---|
286 | ; Test 5: for invalid Appointment ID (-2 and -3)
|
---|
287 | D APPDEL^BSDX08(.ZZZ,0,"PC",1,"Reasons")
|
---|
288 | I $P(^BSDXTMP($J,1),"~")'=-2 W "Error in -2",!
|
---|
289 | D APPDEL^BSDX08(.ZZZ,999999,"PC",1,"Reasons")
|
---|
290 | I $P(^BSDXTMP($J,1),"~")'=-3 W "Error in -3",!
|
---|
291 | ; More unit Tests
|
---|
292 | ;
|
---|
293 | ; Test 6: for Cancelling walkin and checked-in appointments
|
---|
294 | N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
|
---|
295 | N APPTTIME S APPTTIME=$P(TIMES,U)
|
---|
296 | N ENDTIME S ENDTIME=$P(TIMES,U,2)
|
---|
297 | S DFN=4
|
---|
298 | D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,10,"Sam's Note",1) ; Add appt
|
---|
299 | S APPID=+$P(^BSDXTMP($J,1),U)
|
---|
300 | I APPID=0 W "Error in test 6",!
|
---|
301 | D CHECKIN^BSDX25(.ZZZ,APPID,$$NOW^XLFDT) ; check-in
|
---|
302 | D APPDEL^BSDX08(.ZZZ,APPID,"PC",10,"Cancel Note") ; Delete appt
|
---|
303 | I $P(^BSDXTMP($J,1),$C(30))'="" W "Error in test 6",!
|
---|
304 | ;
|
---|
305 | ; Test 7: for cancelling walkin and checked-in appointments
|
---|
306 | N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
|
---|
307 | N APPTTIME S APPTTIME=$P(TIMES,U)
|
---|
308 | N ENDTIME S ENDTIME=$P(TIMES,U,2)
|
---|
309 | S DFN=4
|
---|
310 | D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,10,"Sam's Note",1) ; Add appt
|
---|
311 | S APPID=+$P(^BSDXTMP($J,1),U)
|
---|
312 | I APPID=0 W "Error in test 6",!
|
---|
313 | D CHECKIN^BSDX25(.ZZZ,APPID,$$NOW^XLFDT) ; Checkin
|
---|
314 | S BSDXRESULT=$$RMCI^BSDXAPI(DFN,HLIEN,BSDXSTART) ; remove checkin
|
---|
315 | D APPDEL^BSDX08(.ZZZ,APPID,"PC",10,"Cancel Note") ; delete appt
|
---|
316 | I $P(^BSDXTMP($J,1),$C(30))'="" W "Error in test 6",!
|
---|
317 | ;
|
---|
318 | ; Unlinked Clinic Tests
|
---|
319 | N RESNAM S RESNAM="UTCLINICUL" ; Unlinked Clinic
|
---|
320 | N RESIEN
|
---|
321 | D
|
---|
322 | . N $ET S $ET="D ^%ZTER B"
|
---|
323 | . S RESIEN=$$UTCRRES^BSDXUT(RESNAM)
|
---|
324 | . I RESIEN<0 S $EC=",U1," ; not supposed to happen - hard crash if so
|
---|
325 | ;
|
---|
326 | ; Get start and end times
|
---|
327 | N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
|
---|
328 | N APPTTIME S APPTTIME=$P(TIMES,U)
|
---|
329 | N ENDTIME S ENDTIME=$P(TIMES,U,2)
|
---|
330 | ;
|
---|
331 | ; Test 1: Make normal appointment and cancel it. See if every thing works
|
---|
332 | N ZZZ,DFN
|
---|
333 | S DFN=3
|
---|
334 | D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
|
---|
335 | S APPID=+$P(^BSDXTMP($J,1),U)
|
---|
336 | D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Sam's Cancel Note")
|
---|
337 | I $P(^BSDXAPPT(APPID,0),U,12)'>0 W "Error in Cancellation-1"
|
---|
338 | ;
|
---|
339 | ; Test 6: for Cancelling walkin and checked-in appointments
|
---|
340 | N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
|
---|
341 | N APPTTIME S APPTTIME=$P(TIMES,U)
|
---|
342 | N ENDTIME S ENDTIME=$P(TIMES,U,2)
|
---|
343 | S DFN=4
|
---|
344 | D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,10,"Sam's Note",1) ; Add appt
|
---|
345 | S APPID=+$P(^BSDXTMP($J,1),U)
|
---|
346 | I APPID=0 W "Error in test 6",!
|
---|
347 | D CHECKIN^BSDX25(.ZZZ,APPID,$$NOW^XLFDT) ; check-in
|
---|
348 | D APPDEL^BSDX08(.ZZZ,APPID,"PC",10,"Cancel Note") ; Delete appt
|
---|
349 | I $P(^BSDXTMP($J,1),$C(30))'="" W "Error in test 6",!
|
---|
350 | ;
|
---|
351 | ; Test 7: for cancelling walkin and checked-in appointments
|
---|
352 | N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
|
---|
353 | N APPTTIME S APPTTIME=$P(TIMES,U)
|
---|
354 | N ENDTIME S ENDTIME=$P(TIMES,U,2)
|
---|
355 | S DFN=5
|
---|
356 | D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,10,"Sam's Note",1) ; Add appt
|
---|
357 | S APPID=+$P(^BSDXTMP($J,1),U)
|
---|
358 | I APPID=0 W "Error in test 6",!
|
---|
359 | D CHECKIN^BSDX25(.ZZZ,APPID,$$NOW^XLFDT) ; Checkin
|
---|
360 | S BSDXRESULT=$$RMCI^BSDXAPI(DFN,HLIEN,BSDXSTART) ; remove checkin
|
---|
361 | D APPDEL^BSDX08(.ZZZ,APPID,"PC",10,"Cancel Note") ; delete appt
|
---|
362 | I $P(^BSDXTMP($J,1),$C(30))'="" W "Error in test 6",!
|
---|
363 | QUIT
|
---|
364 | ;
|
---|
365 | UTCR(RESNAM) ; $$ - Create Unit Test Clinic and Resource Pair ; Private
|
---|
366 | ; Input: Resource Name By Value
|
---|
367 | ; Output: -1^Error or HLIEN^RESIEN for Success (file 44 IEN^file 9002018.1 IEN)
|
---|
368 | ; DO NOT USE IN A PRODUCTION ENVIRONTMENT. INTENDED FOR TESTING ONLY
|
---|
369 | N HLIEN S HLIEN=$$UTCR44(RESNAM)
|
---|
370 | I +HLIEN=-1 QUIT HLIEN
|
---|
371 | ;
|
---|
372 | N RESIEN S RESIEN=$$UTCRRES(RESNAM,HLIEN)
|
---|
373 | I +RESIEN=-1 QUIT RESIEN
|
---|
374 | E QUIT HLIEN_U_RESIEN
|
---|
375 | ;
|
---|
376 | UTCR44(HLNAME) ; $$ - Create Unit Test Clinic in File 44; Private ; TESTING ONLY CODE
|
---|
377 | ; Output: -1^Error or IEN for Success
|
---|
378 | ; Input: Hosp Location Name by Value
|
---|
379 | ; DO NOT USE IN A PRODUCTION ENVIRONTMENT. INTENDED FOR TESTING ONLY
|
---|
380 | ;
|
---|
381 | I $D(^SC("B",HLNAME)) Q $O(^(HLNAME,""))
|
---|
382 | ;
|
---|
383 | N SAM
|
---|
384 | S SAM(44,"?+1,",.01)=HLNAME ; Name
|
---|
385 | S SAM(44,"?+1,",2)="C" ; Type = Clinic
|
---|
386 | S SAM(44,"?+1,",2.1)=1 ; Type Extension (not used)
|
---|
387 | S SAM(44,"?+1,",3.5)=$O(^DG(40.8,0)) ; Division (not yet used)
|
---|
388 | S SAM(44,"?+1,",8)=295 ; Stop Code Number (not used)
|
---|
389 | S SAM(44,"?+1,",9)="M" ; Service (not used)
|
---|
390 | S SAM(44,"?+1,",1912)=15 ; Length of Appt (not used)
|
---|
391 | S SAM(44,"?+1,",1917)=4 ; Display increments per hour (not used)
|
---|
392 | S SAM(44,"?+1,",1918)=8 ; Overbooks/day max (not used)
|
---|
393 | S SAM(44,"?+1,",2000.5)=0 ; Require Action Profiles: Yes (not used)
|
---|
394 | S SAM(44,"?+1,",2001)=999 ; Allowable consecutive no-shows (not used)
|
---|
395 | S SAM(44,"?+1,",2002)=999 ; Max # days for Future Booking (not used)
|
---|
396 | S SAM(44,"?+1,",2005)=365 ; Max # days for Auto Rebook (not used)
|
---|
397 | S SAM(44,"?+1,",2502)="N" ; Non-Count Clinic (not used)
|
---|
398 | S SAM(44,"?+1,",2504)="Y" ; Clinic meets at this Facility? (not used)
|
---|
399 | S SAM(44,"?+1,",2507)=9 ; Appointment Type (not used)
|
---|
400 | ;
|
---|
401 | N BSDXERR,BSDXIEN
|
---|
402 | D UPDATE^DIE("",$NA(SAM),$NA(BSDXIEN),$NA(BSDXERR))
|
---|
403 | Q $S($D(BSDXERR):-1_U_BSDXERR("DIERR",1,"TEXT",1),1:BSDXIEN(1))
|
---|
404 | ;
|
---|
405 | UTCRRES(NAME,HLIEN) ; $$ - Create Unit Test Resource in 9002018.1 (BSDX RESOURCE); Private
|
---|
406 | ; Input: Hospital Location IEN
|
---|
407 | ; Output: -1^Error or IEN for Success
|
---|
408 | ; DO NOT USE IN A PRODUCTION ENVIRONTMENT. INTENDED FOR TESTING ONLY
|
---|
409 | I $D(^BSDXRES("B",NAME)) Q $O(^(NAME,""))
|
---|
410 | S HLIEN=$G(HLIEN) ; If we don't send one in
|
---|
411 | N RES ; garbage variable
|
---|
412 | D RSRC^BSDX16(.RES,"|"_NAME_"||"_HLIEN)
|
---|
413 | N RTN S RTN=@$Q(^BSDXTMP($J,0)) ; return array next value
|
---|
414 | Q $S(RTN=0:-1_U_RTN,1:+RTN) ; 0 means an error has occurred; 1 means IEN returned
|
---|
415 | ;
|
---|
416 | TIMES() ; $$ - Create a next available appointment time^ending time; Private
|
---|
417 | N NOW S NOW=$$NOW^XLFDT() ; Now time
|
---|
418 | N LAST S LAST=$O(^BSDXAPPT("B"," "),-1) ; highest time in file
|
---|
419 | N TIME2USE S TIME2USE=$S(NOW>LAST:NOW,1:LAST) ; Which time to use?
|
---|
420 | S TIME2USE=$E(TIME2USE,1,12) ; Strip away seconds
|
---|
421 | N APPTIME S APPTIME=$$FMADD^XLFDT(TIME2USE,0,0,15,0) ; Add 15 min
|
---|
422 | N ENDTIME S ENDTIME=$$FMADD^XLFDT(APPTIME,0,0,15,0) ; Add 15 more min
|
---|
423 | Q APPTIME_U_ENDTIME ; quit with apptime^endtime
|
---|