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

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

Moved some unit tests around; Unit tests for BSDX25; minor refactoring for BSDX25

File size: 4.7 KB
Line 
1BSDXUT2 ; VEN/SMH - Unit Tests for Scheduling GUI - cont. ; 6/28/12 11:55am
2 ;;1.7T1;BSDX;;Aug 31, 2011;Build 18
3 ;
4UT25 ; Unit Tests for BSDX25
5 ; Make appointment, checkin, then uncheckin
6 N $ET S $ET="W ""An Error Occured. Breaking."",! BREAK"
7 N RESNAM S RESNAM="UTCLINIC"
8 N HLRESIENS ; holds output of UTCR^BSDXUT - HL IEN^Resource IEN
9 D
10 . N $ET S $ET="D ^%ZTER B"
11 . S HLRESIENS=$$UTCR^BSDXUT(RESNAM)
12 . I HLRESIENS<0 S $EC=",U1," ; not supposed to happen - hard crash if so
13 ;
14 N HLIEN,RESIEN
15 S HLIEN=$P(HLRESIENS,U)
16 S RESIEN=$P(HLRESIENS,U,2)
17 ;
18 ; Get start and end times
19 N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
20 N APPTTIME S APPTTIME=$P(TIMES,U)
21 N ENDTIME S ENDTIME=$P(TIMES,U,2)
22 ;
23 ; Test 1: Make normal appointment and cancel it. See if every thing works
24 N ZZZ,DFN
25 S DFN=5
26 N ZZZ
27 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
28 N APPTID S APPTID=+^BSDXTMP($J,1)
29 N HL S HL=$$GET1^DIQ(9002018.4,APPTID,".07:.04","I")
30 D CHECKIN^BSDX25(.ZZZ,APPTID,$$NOW^XLFDT())
31 IF '$P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN CHECKIN 1",!
32 IF '+$G(^SC(HL,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN CHECKIN 2",!
33 D RMCI^BSDX25(.ZZZ,APPTID)
34 IF $P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN UNCHECKIN 1",!
35 IF $G(^SC(HL,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN UNCHECKIN 2",!
36 D RMCI^BSDX25(.ZZZ,APPTID) ; again, test sanity in repeat
37 IF $P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN UNCHECKIN 1",!
38 IF $G(^SC(HL,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN UNCHECKIN 2",!
39 ; now test various error conditions
40 ; Test Error 1
41 D RMCI^BSDX25(.ZZZ,)
42 IF +^BSDXTMP($J,1)'=-1 WRITE "ERROR IN ETest 1",!
43 ; Test Error 2
44 D RMCI^BSDX25(.ZZZ,234987234398)
45 IF +^BSDXTMP($J,1)'=-2 WRITE "ERROR IN Etest 2",!
46 ; Tests for 3 to 5 difficult to produce
47 ; Error tests follow: Mumps error test; Transaction restartability
48 N bsdxdie S bsdxdie=1
49 D RMCI^BSDX25(.ZZZ,APPTID)
50 IF +^BSDXTMP($J,1)'=-100 WRITE "ERROR IN Etest 3",!
51 K bsdxdie
52 N bsdxrestart S bsdxrestart=1
53 D RMCI^BSDX25(.ZZZ,APPTID)
54 IF +^BSDXTMP($J,1)'=0 WRITE "Error in Etest 4",!
55 ;
56 ; Unlinked Clinic Tests
57 N RESNAM S RESNAM="UTCLINICUL" ; Unlinked Clinic
58 N RESIEN
59 D
60 . N $ET S $ET="D ^%ZTER B"
61 . S RESIEN=$$UTCRRES^BSDXUT(RESNAM)
62 . I RESIEN<0 S $EC=",U1," ; not supposed to happen - hard crash if so
63 ;
64 ; Get start and end times
65 N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
66 N APPTTIME S APPTTIME=$P(TIMES,U)
67 N ENDTIME S ENDTIME=$P(TIMES,U,2)
68 ;
69 N ZZZ,DFN
70 S DFN=4
71 N ZZZ
72 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
73 N APPTID S APPTID=+^BSDXTMP($J,1)
74 N HL S HL=$$GET1^DIQ(9002018.4,APPTID,".07:.04","I")
75 I HL'="" W "Error. Hospital Location Exists",!
76 ;
77 D CHECKIN^BSDX25(.ZZZ,APPTID,$$NOW^XLFDT())
78 IF '$P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN CHECKIN 3",!
79 ;test
80 D RMCI^BSDX25(.ZZZ,APPTID)
81 IF $P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN UNCHECKIN 3",!
82 D RMCI^BSDX25(.ZZZ,APPTID) ; again, test sanity in repeat
83 IF $P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN UNCHECKIN 3",!
84 ; now test various error conditions
85 ; Test Error 1
86 D RMCI^BSDX25(.ZZZ,)
87 IF +^BSDXTMP($J,1)'=-1 WRITE "ERROR IN ETest 5",!
88 ; Test Error 2
89 D RMCI^BSDX25(.ZZZ,234987234398)
90 IF +^BSDXTMP($J,1)'=-2 WRITE "ERROR IN Etest 6",!
91 ; Tests for 3 to 5 difficult to produce
92 ; Error tests follow: Mumps error test; Transaction restartability
93 N bsdxdie S bsdxdie=1
94 D RMCI^BSDX25(.ZZZ,APPTID)
95 IF +^BSDXTMP($J,1)'=-100 WRITE "ERROR IN Etest 7",!
96 K bsdxdie
97 N bsdxrestart S bsdxrestart=1
98 D RMCI^BSDX25(.ZZZ,APPTID)
99 IF +^BSDXTMP($J,1)'=0 WRITE "Error in Etest 8",!
100 ;
101 ; Tests for running PIMS by itself.
102 N APPTTIME S APPTTIME=$$TIMEHL^BSDXUT(HLIEN) ; appt time
103 N DFN S DFN=2
104 N % S %=$$MAKE1^BSDXAPI(DFN,HLIEN,3,APPTTIME,15,"Sam Test Appt"_DFN)
105 I % W "Error in $$MAKE1^BSDXAPI for TIME "_APPTTIME_" for DFN "_DFN,!,%,!
106 I '$D(^BSDXAPPT("APAT",DFN,APPTTIME)) W "No BSDX Appointment Created",!
107 ;TODO: Index doesn't include resource.
108 N APPTID S APPTID=$O(^(APPTTIME,""))
109 I 'APPTID W "Can't get appointment",!
110 IF $P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN CHECKIN 3",!
111 N % S %=$$CHECKIN1^BSDXAPI(DFN,HLIEN,APPTTIME) ; Checkin via PIMS
112 I % W "Error in Checking in via BSDXAPI",!
113 IF '+$G(^SC(HLIEN,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN CHECKIN 10",!
114 IF '$P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN CHECKIN 11",!
115 N % S %=$$RMCI^BSDXAPI(DFN,HLIEN,APPTTIME)
116 I % W "Error removing Check-in via PIMS",!
117 I +$G(^SC(HLIEN,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN UNCHECKIN 12",!
118 IF $P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN CHECKIN 13",!
119 N % S %=$$CHECKIN1^BSDXAPI(DFN,HLIEN,APPTTIME) ; Checkin via PIMS again
120 I % W "Error in Checking in via BSDXAPI",!
121 IF '+$G(^SC(HLIEN,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN CHECKIN 14",!
122 IF '$P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN CHECKIN 15",!
123 QUIT
Note: See TracBrowser for help on using the repository browser.