source: Scheduling/trunk/m/BSDXUT2.m@ 1763

Last change on this file since 1763 was 1625, checked in by Tariq Hamkari, 11 years ago

Ayman Ghaith : adding the correct routines which not has the transactions.

File size: 9.9 KB
Line 
1BSDXUT2 ; VEN/SMH - Unit Tests for Scheduling GUI - cont. ; 7/9/12 3:18pm
2 ;;1.7;BSDX;;Jun 01, 2013;Build 24
3 ;
4EN ; Run all unit tests in this routine
5 D UT25,PIMS
6 QUIT
7 ;
8UT25 ; Unit Tests for BSDX25
9 ; Make appointment, checkin, then uncheckin
10 N $ET S $ET="W ""An Error Occured. Breaking."",! BREAK"
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 ; Test 1: Make normal appointment and cancel it. See if every thing works
28 N ZZZ,DFN
29 S DFN=5
30 N ZZZ
31 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
32 N APPTID S APPTID=+^BSDXTMP($J,1)
33 N HL S HL=$$GET1^DIQ(9002018.4,APPTID,".07:.04","I")
34 D CHECKIN^BSDX25(.ZZZ,APPTID,$$NOW^XLFDT())
35 IF '$P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN CHECKIN 1",!
36 IF '+$G(^SC(HL,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN CHECKIN 2",!
37 D RMCI^BSDX25(.ZZZ,APPTID)
38 IF $P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN UNCHECKIN 1",!
39 IF $G(^SC(HL,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN UNCHECKIN 2",!
40 D RMCI^BSDX25(.ZZZ,APPTID) ; again, test sanity in repeat
41 IF $P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN UNCHECKIN 1",!
42 IF $G(^SC(HL,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN UNCHECKIN 2",!
43 ; now test various error conditions
44 ; Test Error 1
45 D RMCI^BSDX25(.ZZZ,)
46 IF +^BSDXTMP($J,1)'=-1 WRITE "ERROR IN ETest 1",!
47 ; Test Error 2
48 D RMCI^BSDX25(.ZZZ,234987234398)
49 IF +^BSDXTMP($J,1)'=-2 WRITE "ERROR IN Etest 2",!
50 ; Tests for 3 to 5 difficult to produce
51 ; Error tests follow: Mumps error test;
52 ; Error in RMCI
53 N BSDXDIE S BSDXDIE=1
54 D RMCI^BSDX25(.ZZZ,APPTID)
55 IF +^BSDXTMP($J,1)'=-100 WRITE "ERROR IN Etest 3",!
56 K BSDXDIE
57 ; M Error in CHECKIN
58 N BSDXDIE S BSDXDIE=1
59 D CHECKIN^BSDX25(.ZZZ,APPTID,$$NOW^XLFDT())
60 IF +^BSDXTMP($J,1)'=-100 WRITE "ERROR IN Etest 8",!
61 K BSDXDIE
62 ; M Error in $$CHECKIN^BSDXAPI
63 N BSDXDIE2 S BSDXDIE2=1
64 D CHECKIN^BSDX25(.ZZZ,APPTID,$$NOW^XLFDT())
65 IF +^BSDXTMP($J,1)'=-100 WRITE "ERROR IN Etest 9",!
66 K BSDXDIE2
67 ; M Error in $$RMCI^BSDXAPI1
68 N BSDXDIE2 S BSDXDIE2=1
69 D RMCI^BSDX25(.ZZZ,APPTID)
70 IF +^BSDXTMP($J,1)'=-100 WRITE "ERROR IN Etest 13",!
71 K BSDXDIE2
72 ;
73 ; Get start and end times
74 N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
75 N APPTTIME S APPTTIME=$P(TIMES,U)
76 N ENDTIME S ENDTIME=$P(TIMES,U,2)
77 ;
78 N ZZZ,DFN
79 S DFN=5
80 N ZZZ
81 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
82 N APPTID S APPTID=+^BSDXTMP($J,1)
83 N HL S HL=$$GET1^DIQ(9002018.4,APPTID,".07:.04","I")
84 ;
85 ; Simulated Error in $$BSDXCHK^BSDX25
86 N BSDXSIMERR1 S BSDXSIMERR1=1
87 D CHECKIN^BSDX25(.ZZZ,APPTID,$$NOW^XLFDT())
88 IF +^BSDXTMP($J,1)'=-3 WRITE "ERROR in Etest 10",!
89 IF $P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN CHECKIN 111",!
90 IF +$G(^SC(HL,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN CHECKIN 112",!
91 K BSDXSIMERR1
92 ;
93 ; Simulated Error in $$CHECKICK^BSDXAPI
94 N BSDXSIMERR2 S BSDXSIMERR2=1
95 D CHECKIN^BSDX25(.ZZZ,APPTID,$$NOW^XLFDT())
96 IF +^BSDXTMP($J,1)'=-10 WRITE "ERROR in Etest 11",!
97 IF $P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN CHECKIN 113",!
98 IF +$G(^SC(HL,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN CHECKIN 114",!
99 K BSDXSIMERR2
100 ;
101 ; Simulated Error in $$CHECKIN^BSDXAPI
102 N BSDXSIMERR3 S BSDXSIMERR3=1
103 D CHECKIN^BSDX25(.ZZZ,APPTID,$$NOW^XLFDT())
104 IF +^BSDXTMP($J,1)'=-10 WRITE "ERROR in Etest 11",!
105 IF $P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN CHECKIN 115",!
106 IF +$G(^SC(HL,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN CHECKIN 116",!
107 K BSDXSIMERR3
108 ;
109 ; Check-in for real for the subsequent tests
110 D CHECKIN^BSDX25(.ZZZ,APPTID,$$NOW^XLFDT()) ; Check-in first!
111 IF '$P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN CHECKIN 1110",!
112 IF '+$G(^SC(HL,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN RMCI 1120",!
113 ;
114 ; Simulated Error in $$BSDXCHK^BSDX25; This time for remove check-in
115 N BSDXSIMERR1 S BSDXSIMERR1=1
116 D RMCI^BSDX25(.ZZZ,APPTID)
117 IF +^BSDXTMP($J,1)'=-6 WRITE "ERROR in Etest 14",!
118 IF '$P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN RMCI 111",!
119 IF '+$G(^SC(HL,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN RMCI 112",!
120 K BSDXSIMERR1
121 ;
122 ; Simulated Error in $$RMCICK^BSDXAPI1
123 N BSDXSIMERR2 S BSDXSIMERR2=1
124 D RMCI^BSDX25(.ZZZ,APPTID)
125 IF +^BSDXTMP($J,1)'=-5 WRITE "ERROR in Etest 15",!
126 IF '$P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN RMCI 113",!
127 IF '+$G(^SC(HL,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN RMCI 114",!
128 K BSDXSIMERR2
129 ;
130 ; Simulated Error in $$RMCI^BSDXAPI1
131 N BSDXSIMERR3 S BSDXSIMERR3=1
132 D RMCI^BSDX25(.ZZZ,APPTID)
133 IF +^BSDXTMP($J,1)'=-5 WRITE "ERROR in Etest 16",!
134 IF '$P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN RMCI 115",!
135 IF '+$G(^SC(HL,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN RMCI 116",!
136 K BSDXSIMERR3
137 ;
138 ; Unlinked Clinic Tests
139 N RESNAM S RESNAM="UTCLINICUL" ; Unlinked Clinic
140 N RESIEN
141 D
142 . N $ET S $ET="D ^%ZTER B"
143 . S RESIEN=$$UTCRRES^BSDXUT(RESNAM)
144 . I RESIEN<0 S $EC=",U1," ; not supposed to happen - hard crash if so
145 ;
146 ; Get start and end times
147 N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
148 N APPTTIME S APPTTIME=$P(TIMES,U)
149 N ENDTIME S ENDTIME=$P(TIMES,U,2)
150 ;
151 N ZZZ,DFN
152 S DFN=4
153 N ZZZ
154 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
155 N APPTID S APPTID=+^BSDXTMP($J,1)
156 N HL S HL=$$GET1^DIQ(9002018.4,APPTID,".07:.04","I")
157 I HL'="" W "Error. Hospital Location Exists",!
158 ;
159 D CHECKIN^BSDX25(.ZZZ,APPTID,$$NOW^XLFDT())
160 IF '$P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN CHECKIN 3",!
161 ;test
162 D RMCI^BSDX25(.ZZZ,APPTID)
163 IF $P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN UNCHECKIN 3",!
164 D RMCI^BSDX25(.ZZZ,APPTID) ; again, test sanity in repeat
165 IF $P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN UNCHECKIN 3",!
166 ; now test various error conditions
167 ; Test Error 1
168 D RMCI^BSDX25(.ZZZ,)
169 IF +^BSDXTMP($J,1)'=-1 WRITE "ERROR IN ETest 5",!
170 ; Test Error 2
171 D RMCI^BSDX25(.ZZZ,234987234398)
172 IF +^BSDXTMP($J,1)'=-2 WRITE "ERROR IN Etest 6",!
173 ; Tests for 3 to 5 difficult to produce
174 ; Error tests follow: Mumps error test; Transaction restartability
175 N BSDXDIE S BSDXDIE=1
176 D RMCI^BSDX25(.ZZZ,APPTID)
177 IF +^BSDXTMP($J,1)'=-100 WRITE "ERROR IN Etest 7",!
178 K BSDXDIE
179 QUIT
180 ;
181PIMS ; Tests for running PIMS by itself.
182 N $ET S $ET="W ""An Error Occured. Breaking."",! BREAK"
183 N RESNAM S RESNAM="UTCLINIC"
184 N HLRESIENS ; holds output of UTCR^BSDXUT - HL IEN^Resource IEN
185 D
186 . N $ET S $ET="D ^%ZTER B"
187 . S HLRESIENS=$$UTCR^BSDXUT(RESNAM)
188 . I HLRESIENS<0 S $EC=",U1," ; not supposed to happen - hard crash if so
189 ;
190 N HLIEN,RESIEN
191 S HLIEN=$P(HLRESIENS,U)
192 S RESIEN=$P(HLRESIENS,U,2)
193 ;
194 ;
195 N APPTTIME S APPTTIME=$$TIMEHL^BSDXUT(HLIEN) ; appt time
196 N DFN S DFN=2
197 ;
198 ; TEST $$MAKE1^BSDXAPI
199 N % S %=$$MAKE1^BSDXAPI(DFN,HLIEN,3,APPTTIME,15,"Sam Test Appt"_DFN)
200 I % W "Error in $$MAKE1^BSDXAPI for TIME "_APPTTIME_" for DFN "_DFN,!,%,!
201 I '$D(^BSDXAPPT("APAT",DFN,APPTTIME)) W "No BSDX Appointment Created",!
202 N RESID S RESID=$O(^(APPTTIME,""))
203 N APPTID S APPTID=$O(^(RESID,""))
204 I 'APPTID W "Can't get appointment",!
205 IF $P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN CHECKIN 3",!
206 ;
207 ; TEST CHECKIN1 AND RMCI ^BSDXAPI[1]
208 N % S %=$$CHECKIN1^BSDXAPI(DFN,HLIEN,APPTTIME) ; Checkin via PIMS
209 I % W "Error in Checking in via BSDXAPI",!
210 IF '+$G(^SC(HLIEN,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN CHECKIN 10",!
211 IF '$P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN CHECKIN 11",!
212 N % S %=$$RMCI^BSDXAPI1(DFN,HLIEN,APPTTIME)
213 I % W "Error removing Check-in via PIMS",!
214 I +$G(^SC(HLIEN,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN UNCHECKIN 12",!
215 IF $P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN CHECKIN 13",!
216 N % S %=$$CHECKIN1^BSDXAPI(DFN,HLIEN,APPTTIME) ; Checkin via PIMS again
217 I % W "Error in Checking in via BSDXAPI",!
218 IF '+$G(^SC(HLIEN,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN CHECKIN 14",!
219 IF '$P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN CHECKIN 15",!
220 ;
221 ; TEST CANCEL1^BSDXAPI
222 N APPTTIME S APPTTIME=$$TIMEHL^BSDXUT(HLIEN) ; appt time
223 N DFN S DFN=2
224 N % S %=$$MAKE1^BSDXAPI(DFN,HLIEN,3,APPTTIME,15,"Sam Test Appt"_DFN)
225 I % W "Error in $$MAKE1^BSDXAPI for TIME "_APPTTIME_" for DFN "_DFN,!,%,!
226 I '$D(^BSDXAPPT("APAT",DFN,APPTTIME)) W "No BSDX Appointment Created",!
227 N RESID S RESID=$O(^(APPTTIME,""))
228 N APPTID S APPTID=$O(^(RESID,""))
229 I 'APPTID W "Can't get appointment",!
230 N % S %=$$CANCEL1^BSDXAPI(DFN,HLIEN,"PC",APPTTIME,1,"Afraid of Baby Foxes")
231 I % W "Error cancelling via $$CANCEL1^BSDXAPI",!
232 I ^BSDXAPPT(APPTID,0) ; Change $R
233 I '$P(^(0),U,12) W "No cancel date found in BSDXAPPT",!
234 ; Make same appointment again!
235 ; NB: Index APAT will have two identical entries, one for the cancelled
236 ; appointment, and one for the new one. I won't check it for that reason.
237 N % S %=$$MAKE1^BSDXAPI(DFN,HLIEN,3,APPTTIME,15,"Sam Test Appt"_DFN)
238 I % W "Error in $$MAKE1^BSDXAPI for TIME "_APPTTIME_" for DFN "_DFN,!,%,!
239 ;
240 ; TEST NOSHOW^BSDXAPI1
241 N APPTTIME S APPTTIME=$$TIMEHL^BSDXUT(HLIEN) ; appt time
242 N DFN S DFN=3
243 N % S %=$$MAKE1^BSDXAPI(DFN,HLIEN,3,APPTTIME,15,"Sam Test Appt"_DFN)
244 I % W "Error in $$MAKE1^BSDXAPI for TIME "_APPTTIME_" for DFN "_DFN,!,%,!
245 I '$D(^BSDXAPPT("APAT",DFN,APPTTIME)) W "No BSDX Appointment Created",!
246 N RESID S RESID=$O(^(APPTTIME,""))
247 N APPTID S APPTID=$O(^(RESID,""))
248 I 'APPTID W "Can't get appointment",!
249 ; No show via PIMS
250 N % S %=$$NOSHOW^BSDXAPI1(DFN,HLIEN,APPTTIME,1)
251 I % W "Error no-showing via $$NOSHOW^BSDXAPI1",!
252 I ^BSDXAPPT(APPTID,0) ; Change $R
253 I '$P(^(0),U,10) W "No-show not present in ^BSDXAPPT",!
254 ; un-noshow via PIMS
255 N % S %=$$NOSHOW^BSDXAPI1(DFN,HLIEN,APPTTIME,0)
256 I % W "Error no-showing via $$NOSHOW^BSDXAPI1",!
257 I ^BSDXAPPT(APPTID,0) ; Change $R
258 I $P(^(0),U,10) W "No-show present in ^BSDXAPPT when it shouldn't",!
259 ;
260 ; NB: UPDATENT^BSDXAPI is updates the note. Right now, we don't have any
261 ; way to update the note from BSDXAPI back to ^BSDXAPPT as the protocol
262 ; file is currently not involved. Right now I can't even find the code
263 ; that lets you change an appointment note in PIMS.
264 ;
265 QUIT
Note: See TracBrowser for help on using the repository browser.