source: Scheduling/trunk/m/BSDXUT1.m@ 1455

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

Refactored BSDX08 and BSDX29 routines; plus new UT routine BSDXUT1

File size: 3.1 KB
Line 
1BSDXUT1 ; VEN/SMH - Unit Tests for Scheduling GUI - cont. ; 6/22/12 1:44pm
2 ;;1.7T1;BSDX;;Aug 31, 2011;Build 18
3 ;
4 ;
5UT29 ; Unit Test for BSDX29
6 ; HLs/Resources are created as part of the UT
7 ; Patients 1,2,3,4,5 must exist
8 ;
9 I '$$TM^%ZTLOAD() W "Cannot test. Taskman is not running!" QUIT
10 ;
11 ; Set-up - Create Clinics
12 N RESNAM S RESNAM="UTCLINIC"
13 N HLRESIENS ; holds output of UTCR^BSDXUT - HL IEN^Resource IEN
14 D
15 . N $ET S $ET="D ^%ZTER B"
16 . S HLRESIENS=$$UTCR^BSDXUT(RESNAM)
17 . I HLRESIENS<0 S $EC=",U1," ; not supposed to happen - hard crash if so
18 ;
19 N HLIEN,RESIEN
20 S HLIEN=$P(HLRESIENS,U)
21 S RESIEN=$P(HLRESIENS,U,2)
22 ;
23 ; Turn off SDAM APPT PROTOCOL BSDX Entries
24 N BSDXNOEV
25 S BSDXNOEV=1 ;Don't execute BSDX ADD APPOINTMENT protocol
26 ;
27 ; Create a bunch of appointments in PIMS (25 actually)
28 N DFN
29 N BSDXAPPT,BSDXDATE
30 N BSDXI
31 F BSDXI=1:1:5 D
32 . N APPTTIME S APPTTIME=$$TIMEHL^BSDXUT(HLIEN) ; appt time
33 . F DFN=1,2,3,4,5 D
34 . . N % S %=$$MAKE1^BSDXAPI(DFN,HLIEN,3,APPTTIME,15,"Sam Test Appt"_DFN)
35 . . I % W "Error in $$MAKE1^BSDXAPI for TIME "_APPTTIME_" for DFN "_DFN,!,%,!
36 . . E S BSDXAPPT(DFN,APPTTIME)="",BSDXDATE(APPTTIME)=""
37 ;
38 ; Check that appointments are not in ^BSDXAPPT
39 N DFN,APPTTIME S (DFN,APPTTIME)=""
40 F S DFN=$O(BSDXAPPT(DFN)) Q:'DFN D
41 . F S APPTTIME=$O(BSDXAPPT(DFN,APPTTIME)) Q:'APPTTIME D
42 . . I $D(^BSDXAPPT("APAT",DFN,APPTTIME)) W "Appt for "_DFN_" @ "_APPTTIME_" present",!
43 ;
44 ; Now, copy those appointments using BSDX29 to ^BSDXAPPT
45 N FIRSTDATE S FIRSTDATE=$O(BSDXDATE(""))
46 N LASTDATE S LASTDATE=$O(BSDXDATE(""),-1)
47 N ZZZ ; garbage
48 D BSDXCP^BSDX29(.ZZZ,RESIEN,HLIEN,FIRSTDATE,LASTDATE)
49 I +^BSDXTMP($J,1)=0 W "Error... task not created",! QUIT
50 ;
51 W "Waiting for 5 seconds for it to finish",! HANG 5
52 N DFN,APPTTIME S (DFN,APPTTIME)=""
53 F S DFN=$O(BSDXAPPT(DFN)) Q:'DFN D
54 . F S APPTTIME=$O(BSDXAPPT(DFN,APPTTIME)) Q:'APPTTIME D
55 . . I '$D(^BSDXAPPT("APAT",DFN,APPTTIME)) W "Appt for "_DFN_" @ "_APPTTIME_" missing",!
56 ;
57 ; Do all of this again making sure that events execute.
58 K BSDXNOEV
59 ;
60 ; Create a bunch of appointments in PIMS (25 actually)
61 N DFN
62 N BSDXAPPT,BSDXDATE
63 N BSDXI
64 F BSDXI=1:1:5 D
65 . N APPTTIME S APPTTIME=$$TIMEHL^BSDXUT(HLIEN) ; appt time
66 . F DFN=1,2,3,4,5 D
67 . . N % S %=$$MAKE1^BSDXAPI(DFN,HLIEN,3,APPTTIME,15,"Sam Test Appt"_DFN)
68 . . I % W "Error in $$MAKE1^BSDXAPI for TIME "_APPTTIME_" for DFN "_DFN,!,%,!
69 . . E S BSDXAPPT(DFN,APPTTIME)="",BSDXDATE(APPTTIME)=""
70 ;
71 ; Check that appointments are in ^BSDXAPPT (different from last time)
72 N DFN,APPTTIME S (DFN,APPTTIME)=""
73 F S DFN=$O(BSDXAPPT(DFN)) Q:'DFN D
74 . F S APPTTIME=$O(BSDXAPPT(DFN,APPTTIME)) Q:'APPTTIME D
75 . . I '$D(^BSDXAPPT("APAT",DFN,APPTTIME)) W "Appt for "_DFN_" @ "_APPTTIME_" present",!
76 ;
77 ; Now, copy those appointments using BSDX29 to ^BSDXAPPT
78 N FIRSTDATE S FIRSTDATE=$O(BSDXDATE(""))
79 N LASTDATE S LASTDATE=$O(BSDXDATE(""),-1)
80 N ZZZ ; garbage
81 D BSDXCP^BSDX29(.ZZZ,RESIEN,HLIEN,FIRSTDATE,LASTDATE)
82 I +^BSDXTMP($J,1)=0 W "Error... task not created",! QUIT
83 ;
84 W "Waiting for 5 seconds for it to finish",! HANG 5
85 W ^BSDXTMP("BSDXCOPY",+^BSDXTMP($J,1)),!
86 W "Last line should say 0",!
87 QUIT
Note: See TracBrowser for help on using the repository browser.