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

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

Updated version number on all routines to be 1.7T1.
Minor fixes here and there for XINDEX errors.

File size: 7.4 KB
Line 
1BSDXUT2 ; VEN/SMH - Unit Tests for Scheduling GUI - cont. ; 7/5/12 11:39am
2 ;;1.7T1;BSDX;;Jul 06, 2012;Build 18
3 ;
4EN ; Run all unit tests in this routine
5 D UT25
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 ;
180 ; Tests for running PIMS by itself.
181 N APPTTIME S APPTTIME=$$TIMEHL^BSDXUT(HLIEN) ; appt time
182 N DFN S DFN=2
183 N % S %=$$MAKE1^BSDXAPI(DFN,HLIEN,3,APPTTIME,15,"Sam Test Appt"_DFN)
184 I % W "Error in $$MAKE1^BSDXAPI for TIME "_APPTTIME_" for DFN "_DFN,!,%,!
185 I '$D(^BSDXAPPT("APAT",DFN,APPTTIME)) W "No BSDX Appointment Created",!
186 ;TODO: Index doesn't include resource.
187 N APPTID S APPTID=$O(^(APPTTIME,""))
188 I 'APPTID W "Can't get appointment",!
189 IF $P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN CHECKIN 3",!
190 N % S %=$$CHECKIN1^BSDXAPI(DFN,HLIEN,APPTTIME) ; Checkin via PIMS
191 I % W "Error in Checking in via BSDXAPI",!
192 IF '+$G(^SC(HLIEN,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN CHECKIN 10",!
193 IF '$P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN CHECKIN 11",!
194 N % S %=$$RMCI^BSDXAPI1(DFN,HLIEN,APPTTIME)
195 I % W "Error removing Check-in via PIMS",!
196 I +$G(^SC(HLIEN,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN UNCHECKIN 12",!
197 IF $P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN CHECKIN 13",!
198 N % S %=$$CHECKIN1^BSDXAPI(DFN,HLIEN,APPTTIME) ; Checkin via PIMS again
199 I % W "Error in Checking in via BSDXAPI",!
200 IF '+$G(^SC(HLIEN,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN CHECKIN 14",!
201 IF '$P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN CHECKIN 15",!
202 QUIT
Note: See TracBrowser for help on using the repository browser.