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

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

BSDX25 refactoring, continued

File size: 4.5 KB
Line 
1BSDXUT2 ; VEN/SMH - Unit Tests for Scheduling GUI - cont. ; 6/29/12 12:23pm
2 ;;1.7T1;BSDX;;Aug 31, 2011;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; Transaction restartability
52 N BSDXDIE S BSDXDIE=1
53 D RMCI^BSDX25(.ZZZ,APPTID)
54 IF +^BSDXTMP($J,1)'=-100 WRITE "ERROR IN Etest 3",!
55 K BSDXDIE
56 ;
57 ; Unlinked Clinic Tests
58 N RESNAM S RESNAM="UTCLINICUL" ; Unlinked Clinic
59 N RESIEN
60 D
61 . N $ET S $ET="D ^%ZTER B"
62 . S RESIEN=$$UTCRRES^BSDXUT(RESNAM)
63 . I RESIEN<0 S $EC=",U1," ; not supposed to happen - hard crash if so
64 ;
65 ; Get start and end times
66 N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
67 N APPTTIME S APPTTIME=$P(TIMES,U)
68 N ENDTIME S ENDTIME=$P(TIMES,U,2)
69 ;
70 N ZZZ,DFN
71 S DFN=4
72 N ZZZ
73 D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
74 N APPTID S APPTID=+^BSDXTMP($J,1)
75 N HL S HL=$$GET1^DIQ(9002018.4,APPTID,".07:.04","I")
76 I HL'="" W "Error. Hospital Location Exists",!
77 ;
78 D CHECKIN^BSDX25(.ZZZ,APPTID,$$NOW^XLFDT())
79 IF '$P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN CHECKIN 3",!
80 ;test
81 D RMCI^BSDX25(.ZZZ,APPTID)
82 IF $P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN UNCHECKIN 3",!
83 D RMCI^BSDX25(.ZZZ,APPTID) ; again, test sanity in repeat
84 IF $P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN UNCHECKIN 3",!
85 ; now test various error conditions
86 ; Test Error 1
87 D RMCI^BSDX25(.ZZZ,)
88 IF +^BSDXTMP($J,1)'=-1 WRITE "ERROR IN ETest 5",!
89 ; Test Error 2
90 D RMCI^BSDX25(.ZZZ,234987234398)
91 IF +^BSDXTMP($J,1)'=-2 WRITE "ERROR IN Etest 6",!
92 ; Tests for 3 to 5 difficult to produce
93 ; Error tests follow: Mumps error test; Transaction restartability
94 N BSDXDIE S BSDXDIE=1
95 D RMCI^BSDX25(.ZZZ,APPTID)
96 IF +^BSDXTMP($J,1)'=-100 WRITE "ERROR IN Etest 7",!
97 K BSDXDIE
98 ;
99 ; Tests for running PIMS by itself.
100 N APPTTIME S APPTTIME=$$TIMEHL^BSDXUT(HLIEN) ; appt time
101 N DFN S DFN=2
102 N % S %=$$MAKE1^BSDXAPI(DFN,HLIEN,3,APPTTIME,15,"Sam Test Appt"_DFN)
103 I % W "Error in $$MAKE1^BSDXAPI for TIME "_APPTTIME_" for DFN "_DFN,!,%,!
104 I '$D(^BSDXAPPT("APAT",DFN,APPTTIME)) W "No BSDX Appointment Created",!
105 ;TODO: Index doesn't include resource.
106 N APPTID S APPTID=$O(^(APPTTIME,""))
107 I 'APPTID W "Can't get appointment",!
108 IF $P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN CHECKIN 3",!
109 N % S %=$$CHECKIN1^BSDXAPI(DFN,HLIEN,APPTTIME) ; Checkin via PIMS
110 I % W "Error in Checking in via BSDXAPI",!
111 IF '+$G(^SC(HLIEN,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN CHECKIN 10",!
112 IF '$P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN CHECKIN 11",!
113 N % S %=$$RMCI^BSDXAPI1(DFN,HLIEN,APPTTIME)
114 I % W "Error removing Check-in via PIMS",!
115 I +$G(^SC(HLIEN,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN UNCHECKIN 12",!
116 IF $P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN CHECKIN 13",!
117 N % S %=$$CHECKIN1^BSDXAPI(DFN,HLIEN,APPTTIME) ; Checkin via PIMS again
118 I % W "Error in Checking in via BSDXAPI",!
119 IF '+$G(^SC(HLIEN,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN CHECKIN 14",!
120 IF '$P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN CHECKIN 15",!
121 QUIT
Note: See TracBrowser for help on using the repository browser.