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

This commit is contained in:
sam 2012-06-28 22:54:30 +00:00
parent f2c57b4774
commit 494017259d
4 changed files with 288 additions and 190 deletions

View File

@ -1,51 +1,19 @@
BSDX25 ; VW/UJO/SMH - WINDOWS SCHEDULING RPCS ; 4/28/11 10:24am BSDX25 ; VW/UJO/SMH - WINDOWS SCHEDULING RPCS ; 6/28/12 11:45am
;;1.6T2;BSDX;;May 16, 2011 ;;1.6;BSDX;;Aug 31, 2011;Build 18
; Licensed under LGPL ; Licensed under LGPL
; ;
; Change Log: ; Change Log:
; 3110106: SMH -> Changed Check-in EP - Removed unused paramters. Will change C# ; 3110106: SMH -> Changed Check-in EP - Removed unused paramters. Will change C#
; ;
; ;
UT ; Unit Tests
; Make appointment, checkin, then uncheckin
N ZZZ
N APPTTIME S APPTTIME=$E($$NOW^XLFDT(),1,12)
D APPADD^BSDX07(.ZZZ,APPTTIME,APPTTIME+.0001,3,"Dr Office",30,"Sam's Note",1)
N APPTID S APPTID=+^BSDXTMP($J,1)
N HL S HL=$$GET1^DIQ(9002018.4,APPTID,".07:.04","I")
D CHECKIN^BSDX25(.ZZZ,APPTID,$$NOW^XLFDT())
IF '$P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN CHECKIN 1",!
IF '+$G(^SC(HL,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN CHECKIN 2",!
D RMCI^BSDX25(.ZZZ,APPTID)
IF $P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN UNCHECKIN 1",!
IF $G(^SC(HL,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN UNCHECKIN 2",!
D RMCI^BSDX25(.ZZZ,APPTID) ; again, test sanity in repeat
IF $P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN UNCHECKIN 1",!
IF $G(^SC(HL,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN UNCHECKIN 2",!
; now test various error conditions
; Test Error 1
D RMCI^BSDX25(.ZZZ,)
IF +^BSDXTMP($J,1)'=-1 WRITE "ERROR IN ETest 1",!
; Test Error 2
D RMCI^BSDX25(.ZZZ,234987234398)
IF +^BSDXTMP($J,1)'=-2 WRITE "ERROR IN Etest 2",!
; Tests for 3 to 5 difficult to produce
; Error tests follow: Mumps error test; Transaction restartability
N bsdxdie S bsdxdie=1
D RMCI^BSDX25(.ZZZ,APPTID)
IF +^BSDXTMP($J,1)'=-20 WRITE "ERROR IN Etest 3",!
K bsdxdie
N bsdxrestart S bsdxrestart=1
D RMCI^BSDX25(.ZZZ,APPTID)
IF +^BSDXTMP($J,1)'=0 WRITE "Error in Etest 4",!
QUIT
CHECKIND(BSDXY,BSDXAPTID,BSDXCDT,BSDXCC,BSDXPRV,BSDXROU,BSDXVCL,BSDXVFM,BSDXOG) ;EP CHECKIND(BSDXY,BSDXAPTID,BSDXCDT,BSDXCC,BSDXPRV,BSDXROU,BSDXVCL,BSDXVFM,BSDXOG) ;EP
;Entry point for debugging ;Entry point for debugging
; ;
;I +$G(^BSDXDBUG("BREAK","CHECKIN")),+$G(^BSDXDBUG("BREAK"))=DUZ D DEBUG^%Serenji("CHECKIN^BSDX25(.BSDXY,BSDXAPTID,BSDXCDT,BSDXCC,BSDXPRV,BSDXROU,BSDXVCL,BSDXVFM,BSDXOG)",$P(^BSDXDBUG("BREAK"),U,2)) ;I +$G(^BSDXDBUG("BREAK","CHECKIN")),+$G(^BSDXDBUG("BREAK"))=DUZ D DEBUG^%Serenji("CHECKIN^BSDX25(.BSDXY,BSDXAPTID,BSDXCDT,BSDXCC,BSDXPRV,BSDXROU,BSDXVCL,BSDXVFM,BSDXOG)",$P(^BSDXDBUG("BREAK"),U,2))
Q Q
; ;
CHECKIN(BSDXY,BSDXAPTID,BSDXCDT) ; ,BSDXCC,BSDXPRV,BSDXROU,BSDXVCL,BSDXVFM,BSDXOG) ;EP Check in appointment CHECKIN(BSDXY,BSDXAPTID,BSDXCDT) ;Private EP Check in appointment
; Old additional vars: ,BSDXCC,BSDXPRV,BSDXROU,BSDXVCL,BSDXVFM,BSDXOG)
; Private to GUI; use BSDXAPI for general API to checkin patients ; Private to GUI; use BSDXAPI for general API to checkin patients
; Parameters: ; Parameters:
; BSDXY: Global Out ; BSDXY: Global Out
@ -62,13 +30,20 @@ CHECKIN(BSDXY,BSDXAPTID,BSDXCDT) ; ,BSDXCC,BSDXPRV,BSDXROU,BSDXVCL,BSDXVFM,BSDXO
; ADO.net table with 1 column ErrorID, 1 row result ; ADO.net table with 1 column ErrorID, 1 row result
; - 0 if all okay ; - 0 if all okay
; - Another number or text if not ; - Another number or text if not
;
N BSDXNOD,BSDXPATID,BSDXSTART,DIK,DA,BSDXID,BSDXI,BSDXZ,BSDXIENS,BSDXVEN N BSDXNOD,BSDXPATID,BSDXSTART,DIK,DA,BSDXID,BSDXZ,BSDXIENS,BSDXVEN
;
; Turn off SDAM Appointment Events BSDX Protocol Processing
N BSDXNOEV N BSDXNOEV
S BSDXNOEV=1 ;Don't execute protocol S BSDXNOEV=1 ;Don't execute protocol
; ;
D ^XBKVAR S X="ERROR^BSDX25",@^%ZOSF("TRAP") ; Set min DUZ vars
S BSDXI=0 D ^XBKVAR
;
; $ET
N $ET S $ET="G ERROR^BSDX25"
;
N BSDXI S BSDXI=0
K ^BSDXTMP($J) K ^BSDXTMP($J)
S BSDXY="^BSDXTMP("_$J_")" S BSDXY="^BSDXTMP("_$J_")"
S ^BSDXTMP($J,0)="T00020ERRORID"_$C(30) S ^BSDXTMP($J,0)="T00020ERRORID"_$C(30)
@ -77,7 +52,7 @@ CHECKIN(BSDXY,BSDXAPTID,BSDXCDT) ; ,BSDXCC,BSDXPRV,BSDXROU,BSDXVCL,BSDXVFM,BSDXO
; Remove Date formatting v.1.5. Client will send date as FM Date. ; Remove Date formatting v.1.5. Client will send date as FM Date.
;S:BSDXCDT["@0000" BSDXCDT=$P(BSDXCDT,"@") ;S:BSDXCDT["@0000" BSDXCDT=$P(BSDXCDT,"@")
;S %DT="T",X=BSDXCDT D ^%DT S BSDXCDT=Y ;S %DT="T",X=BSDXCDT D ^%DT S BSDXCDT=Y
S BSDXCDT=+BSDXCDT ; Strip off zeros if C# sends them S BSDXCDT=+BSDXCDT ; Strip off zeros if C# sends them
I BSDXCDT=-1 D ERR(70) Q I BSDXCDT=-1 D ERR(70) Q
I BSDXCDT>$$NOW^XLFDT S BSDXCDT=$$NOW^XLFDT I BSDXCDT>$$NOW^XLFDT S BSDXCDT=$$NOW^XLFDT
;Checkin BSDX APPOINTMENT entry ;Checkin BSDX APPOINTMENT entry
@ -127,7 +102,7 @@ RMCI(BSDXY,BSDXAPPTID) ; EP - Remove Check-in from BSDX APPT and 2/44
; -3~DB has corruption. Call Tech Support. (Resource ID doesn't exist in BSDXAPPT) ; -3~DB has corruption. Call Tech Support. (Resource ID doesn't exist in BSDXAPPT)
; -4~DB has corruption. Call Tech Support. (Resource ID in BSDXAPPT doesnt exist in BSDXRES) ; -4~DB has corruption. Call Tech Support. (Resource ID in BSDXAPPT doesnt exist in BSDXRES)
; -5~BSDXAPI Error. Message depends on error. ; -5~BSDXAPI Error. Message depends on error.
; -20~Mumps Error ; -100~Mumps Error
; ;
N BSDXNOEV S BSDXNOEV=1 ;Don't execute protocol N BSDXNOEV S BSDXNOEV=1 ;Don't execute protocol
; ;
@ -158,8 +133,8 @@ RMCI(BSDXY,BSDXAPPTID) ; EP - Remove Check-in from BSDX APPT and 2/44
; ;
; Now, remove checkin from PIMS files 2/44 ; Now, remove checkin from PIMS files 2/44
N BSDXNOD S BSDXNOD=^BSDXAPPT(BSDXAPPTID,0) N BSDXNOD S BSDXNOD=^BSDXAPPT(BSDXAPPTID,0)
N BSDXPATID S BSDXPATID=$P(BSDXNOD,U,5) ; DFN N BSDXPATID S BSDXPATID=$P(BSDXNOD,U,5) ; DFN
N BSDXSTART S BSDXSTART=$P(BSDXNOD,U) ; Start Date N BSDXSTART S BSDXSTART=$P(BSDXNOD,U) ; Start Date
N BSDXSC1 S BSDXSC1=$P(BSDXNOD,U,7) ; Resource ID N BSDXSC1 S BSDXSC1=$P(BSDXNOD,U,7) ; Resource ID
; ;
; If the resource doesn't exist, error out. DB is corrupt. ; If the resource doesn't exist, error out. DB is corrupt.
@ -224,12 +199,12 @@ CHKEVT3(BSDXRES) ;
; ;
ERROR ; ERROR ;
S $ETRAP="D ^%ZTER HALT" ; Emergency Error Trap for the wise S $ETRAP="D ^%ZTER HALT" ; Emergency Error Trap for the wise
; Rollback, otherwise ^XTER will be empty from future rollback ; Rollback, otherwise ^XTER will be empty from future rollback
I $TL>0 TROLLBACK I $TL>0 TROLLBACK
D ^%ZTER D ^%ZTER
S $EC="" ; Clear Error S $EC="" ; Clear Error
; Log error message and send to client ; Log error message and send to client
D ERR("-20~Mumps Error") D ERR("-100~Mumps Error")
Q Q
; ;
ERR(BSDXERR) ;Error processing ERR(BSDXERR) ;Error processing

View File

@ -1,4 +1,4 @@
BSDXUT ; VEN/SMH - Unit Tests for Scheduling GUI ; 6/27/12 4:18pm BSDXUT ; VEN/SMH - Unit Tests for Scheduling GUI ; 6/28/12 10:14am
;;1.7T1;BSDX;;Aug 31, 2011;Build 18 ;;1.7T1;BSDX;;Aug 31, 2011;Build 18
; Licensed under LGPL ; Licensed under LGPL
; ;
@ -238,144 +238,6 @@ UT07 ; Unit Tests for BSDX07 - Assumes you have Patients with DFNs 1,2,3,4,5
I '+APPID W "Error in deleting appointment-104",! I '+APPID W "Error in deleting appointment-104",!
QUIT QUIT
; ;
UT08 ; Unit Tests for BSDX08; Must have patients 1,2,3,4,5 defined in system
N RESNAM S RESNAM="UTCLINIC"
N HLRESIENS ; holds output of UTCR^BSDXUT - HL IEN^Resource IEN
D
. N $ET S $ET="D ^%ZTER B"
. S HLRESIENS=$$UTCR^BSDXUT(RESNAM)
. I HLRESIENS<0 S $EC=",U1," ; not supposed to happen - hard crash if so
;
N HLIEN,RESIEN
S HLIEN=$P(HLRESIENS,U)
S RESIEN=$P(HLRESIENS,U,2)
;
; Get start and end times
N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
N APPTTIME S APPTTIME=$P(TIMES,U)
N ENDTIME S ENDTIME=$P(TIMES,U,2)
;
; Test 1: Make normal appointment and cancel it. See if every thing works
N ZZZ,DFN
S DFN=3
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
S APPID=+$P(^BSDXTMP($J,1),U)
D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Sam's Cancel Note")
I $P(^BSDXAPPT(APPID,0),U,12)'>0 W "Error in Cancellation-1",!
I $O(^SC(HLIEN,"S",APPTTIME,1,0))]"" W "Error in Cancellation-2",!
I $P(^DPT(DFN,"S",APPTTIME,0),U,2)'="PC" W "Error in Cancellation-3",!
I ^DPT(DFN,"S",APPTTIME,"R")'="Sam's Cancel Note" W "Error in Cancellation-4",!
;
; Test 2: Check for -1 -- TODO: Fix later... Can't do right now automatically
; Make appt
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
; Lock the node in another job
S APPID=+$P(^BSDXTMP($J,1),U)
; W "Lock ^BSDXAPPT("_APPID_") in another session. You have 10 seconds." H 10
D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Sam's Cancel Note")
;
; Test 3: Check for -100
N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
N APPTTIME S APPTTIME=$P(TIMES,U)
N ENDTIME S ENDTIME=$P(TIMES,U,2)
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
S APPID=+$P(^BSDXTMP($J,1),U)
N BSDXDIE1 S BSDXDIE1=1
D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Reasons")
I $P(^BSDXTMP($J,1),"~")'=-100 W "Error in -100",!
K BSDXDIE1
;
; Test 3.5: Check for -100 with an appointment to rollback.
N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
N APPTTIME S APPTTIME=$P(TIMES,U)
N ENDTIME S ENDTIME=$P(TIMES,U,2)
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
S APPID=+$P(^BSDXTMP($J,1),U)
N BSDXDIE2 S BSDXDIE2=1
D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Reasons")
I $P(^BSDXTMP($J,1),"~")'=-100 W "Error in -100-1",!
I $P(^BSDXAPPT(APPID,0),U,12)'="" W "Error in -100-2",!
K BSDXDIE2
; Test 4: Restartable transaction -- retired in V 1.7
; Test 5: for invalid Appointment ID (-2 and -3)
D APPDEL^BSDX08(.ZZZ,0,"PC",1,"Reasons")
I $P(^BSDXTMP($J,1),"~")'=-2 W "Error in -2",!
D APPDEL^BSDX08(.ZZZ,999999,"PC",1,"Reasons")
I $P(^BSDXTMP($J,1),"~")'=-3 W "Error in -3",!
; More unit Tests
;
; Test 6: for Cancelling walkin and checked-in appointments
N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
N APPTTIME S APPTTIME=$P(TIMES,U)
N ENDTIME S ENDTIME=$P(TIMES,U,2)
S DFN=4
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,10,"Sam's Note",1) ; Add appt
S APPID=+$P(^BSDXTMP($J,1),U)
I APPID=0 W "Error in test 6",!
D CHECKIN^BSDX25(.ZZZ,APPID,$$NOW^XLFDT) ; check-in
D APPDEL^BSDX08(.ZZZ,APPID,"PC",10,"Cancel Note") ; Delete appt
I $P(^BSDXTMP($J,1),$C(30))'="" W "Error in test 6",!
;
; Test 7: for cancelling walkin and checked-in appointments
N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
N APPTTIME S APPTTIME=$P(TIMES,U)
N ENDTIME S ENDTIME=$P(TIMES,U,2)
S DFN=4
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,10,"Sam's Note",1) ; Add appt
S APPID=+$P(^BSDXTMP($J,1),U)
I APPID=0 W "Error in test 6",!
D CHECKIN^BSDX25(.ZZZ,APPID,$$NOW^XLFDT) ; Checkin
S BSDXRESULT=$$RMCI^BSDXAPI(DFN,HLIEN,APPTTIME) ; remove checkin
D APPDEL^BSDX08(.ZZZ,APPID,"PC",10,"Cancel Note") ; delete appt
I $P(^BSDXTMP($J,1),$C(30))'="" W "Error in test 6",!
;
; Unlinked Clinic Tests
N RESNAM S RESNAM="UTCLINICUL" ; Unlinked Clinic
N RESIEN
D
. N $ET S $ET="D ^%ZTER B"
. S RESIEN=$$UTCRRES^BSDXUT(RESNAM)
. I RESIEN<0 S $EC=",U1," ; not supposed to happen - hard crash if so
;
; Get start and end times
N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
N APPTTIME S APPTTIME=$P(TIMES,U)
N ENDTIME S ENDTIME=$P(TIMES,U,2)
;
; Test 1: Make normal appointment and cancel it. See if every thing works
N ZZZ,DFN
S DFN=3
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
S APPID=+$P(^BSDXTMP($J,1),U)
D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Sam's Cancel Note")
I $P(^BSDXAPPT(APPID,0),U,12)'>0 W "Error in Cancellation-1"
;
; Test 6: for Cancelling walkin and checked-in appointments
N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
N APPTTIME S APPTTIME=$P(TIMES,U)
N ENDTIME S ENDTIME=$P(TIMES,U,2)
S DFN=4
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,10,"Sam's Note",1) ; Add appt
S APPID=+$P(^BSDXTMP($J,1),U)
I APPID=0 W "Error in test 6",!
D CHECKIN^BSDX25(.ZZZ,APPID,$$NOW^XLFDT) ; check-in
D APPDEL^BSDX08(.ZZZ,APPID,"PC",10,"Cancel Note") ; Delete appt
I $P(^BSDXTMP($J,1),$C(30))'="" W "Error in test 6",!
;
; Test 7: for cancelling walkin and checked-in appointments
N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
N APPTTIME S APPTTIME=$P(TIMES,U)
N ENDTIME S ENDTIME=$P(TIMES,U,2)
S DFN=5
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,10,"Sam's Note",1) ; Add appt
S APPID=+$P(^BSDXTMP($J,1),U)
I APPID=0 W "Error in test 6",!
D CHECKIN^BSDX25(.ZZZ,APPID,$$NOW^XLFDT) ; Checkin
S BSDXRESULT=$$RMCI^BSDXAPI(DFN,HLIEN,APPTTIME) ; remove checkin
D APPDEL^BSDX08(.ZZZ,APPID,"PC",10,"Cancel Note") ; delete appt
I $P(^BSDXTMP($J,1),$C(30))'="" W "Error in test 6",!
QUIT
;
UTCR(RESNAM) ; $$ - Create Unit Test Clinic and Resource Pair ; Private UTCR(RESNAM) ; $$ - Create Unit Test Clinic and Resource Pair ; Private
; Input: Resource Name By Value ; Input: Resource Name By Value
; Output: -1^Error or HLIEN^RESIEN for Success (file 44 IEN^file 9002018.1 IEN) ; Output: -1^Error or HLIEN^RESIEN for Success (file 44 IEN^file 9002018.1 IEN)

View File

@ -1,7 +1,145 @@
BSDXUT1 ; VEN/SMH - Unit Tests for Scheduling GUI - cont. ; 6/27/12 4:59pm BSDXUT1 ; VEN/SMH - Unit Tests for Scheduling GUI - cont. ; 6/28/12 10:17am
;;1.7T1;BSDX;;Aug 31, 2011;Build 18 ;;1.7T1;BSDX;;Aug 31, 2011;Build 18
; ;
; ;
UT08 ; Unit Tests for BSDX08; Must have patients 1,2,3,4,5 defined in system
N RESNAM S RESNAM="UTCLINIC"
N HLRESIENS ; holds output of UTCR^BSDXUT - HL IEN^Resource IEN
D
. N $ET S $ET="D ^%ZTER B"
. S HLRESIENS=$$UTCR^BSDXUT(RESNAM)
. I HLRESIENS<0 S $EC=",U1," ; not supposed to happen - hard crash if so
;
N HLIEN,RESIEN
S HLIEN=$P(HLRESIENS,U)
S RESIEN=$P(HLRESIENS,U,2)
;
; Get start and end times
N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
N APPTTIME S APPTTIME=$P(TIMES,U)
N ENDTIME S ENDTIME=$P(TIMES,U,2)
;
; Test 1: Make normal appointment and cancel it. See if every thing works
N ZZZ,DFN
S DFN=3
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
S APPID=+$P(^BSDXTMP($J,1),U)
D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Sam's Cancel Note")
I $P(^BSDXAPPT(APPID,0),U,12)'>0 W "Error in Cancellation-1",!
I $O(^SC(HLIEN,"S",APPTTIME,1,0))]"" W "Error in Cancellation-2",!
I $P(^DPT(DFN,"S",APPTTIME,0),U,2)'="PC" W "Error in Cancellation-3",!
I ^DPT(DFN,"S",APPTTIME,"R")'="Sam's Cancel Note" W "Error in Cancellation-4",!
;
; Test 2: Check for -1 -- TODO: Fix later... Can't do right now automatically
; Make appt
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
; Lock the node in another job
S APPID=+$P(^BSDXTMP($J,1),U)
; W "Lock ^BSDXAPPT("_APPID_") in another session. You have 10 seconds." H 10
D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Sam's Cancel Note")
;
; Test 3: Check for -100
N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
N APPTTIME S APPTTIME=$P(TIMES,U)
N ENDTIME S ENDTIME=$P(TIMES,U,2)
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
S APPID=+$P(^BSDXTMP($J,1),U)
N BSDXDIE1 S BSDXDIE1=1
D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Reasons")
I $P(^BSDXTMP($J,1),"~")'=-100 W "Error in -100",!
K BSDXDIE1
;
; Test 3.5: Check for -100 with an appointment to rollback.
N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
N APPTTIME S APPTTIME=$P(TIMES,U)
N ENDTIME S ENDTIME=$P(TIMES,U,2)
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
S APPID=+$P(^BSDXTMP($J,1),U)
N BSDXDIE2 S BSDXDIE2=1
D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Reasons")
I $P(^BSDXTMP($J,1),"~")'=-100 W "Error in -100-1",!
I $P(^BSDXAPPT(APPID,0),U,12)'="" W "Error in -100-2",!
K BSDXDIE2
; Test 4: Restartable transaction -- retired in V 1.7
; Test 5: for invalid Appointment ID (-2 and -3)
D APPDEL^BSDX08(.ZZZ,0,"PC",1,"Reasons")
I $P(^BSDXTMP($J,1),"~")'=-2 W "Error in -2",!
D APPDEL^BSDX08(.ZZZ,999999,"PC",1,"Reasons")
I $P(^BSDXTMP($J,1),"~")'=-3 W "Error in -3",!
; More unit Tests
;
; Test 6: for Cancelling walkin and checked-in appointments
N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
N APPTTIME S APPTTIME=$P(TIMES,U)
N ENDTIME S ENDTIME=$P(TIMES,U,2)
S DFN=4
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,10,"Sam's Note",1) ; Add appt
S APPID=+$P(^BSDXTMP($J,1),U)
I APPID=0 W "Error in test 6",!
D CHECKIN^BSDX25(.ZZZ,APPID,$$NOW^XLFDT) ; check-in
D APPDEL^BSDX08(.ZZZ,APPID,"PC",10,"Cancel Note") ; Delete appt
I $P(^BSDXTMP($J,1),$C(30))'="" W "Error in test 6",!
;
; Test 7: for cancelling walkin and checked-in appointments
N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
N APPTTIME S APPTTIME=$P(TIMES,U)
N ENDTIME S ENDTIME=$P(TIMES,U,2)
S DFN=4
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,10,"Sam's Note",1) ; Add appt
S APPID=+$P(^BSDXTMP($J,1),U)
I APPID=0 W "Error in test 6",!
D CHECKIN^BSDX25(.ZZZ,APPID,$$NOW^XLFDT) ; Checkin
S BSDXRESULT=$$RMCI^BSDXAPI(DFN,HLIEN,APPTTIME) ; remove checkin
D APPDEL^BSDX08(.ZZZ,APPID,"PC",10,"Cancel Note") ; delete appt
I $P(^BSDXTMP($J,1),$C(30))'="" W "Error in test 6",!
;
; Unlinked Clinic Tests
N RESNAM S RESNAM="UTCLINICUL" ; Unlinked Clinic
N RESIEN
D
. N $ET S $ET="D ^%ZTER B"
. S RESIEN=$$UTCRRES^BSDXUT(RESNAM)
. I RESIEN<0 S $EC=",U1," ; not supposed to happen - hard crash if so
;
; Get start and end times
N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
N APPTTIME S APPTTIME=$P(TIMES,U)
N ENDTIME S ENDTIME=$P(TIMES,U,2)
;
; Test 1: Make normal appointment and cancel it. See if every thing works
N ZZZ,DFN
S DFN=3
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
S APPID=+$P(^BSDXTMP($J,1),U)
D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Sam's Cancel Note")
I $P(^BSDXAPPT(APPID,0),U,12)'>0 W "Error in Cancellation-1"
;
; Test 6: for Cancelling walkin and checked-in appointments
N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
N APPTTIME S APPTTIME=$P(TIMES,U)
N ENDTIME S ENDTIME=$P(TIMES,U,2)
S DFN=4
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,10,"Sam's Note",1) ; Add appt
S APPID=+$P(^BSDXTMP($J,1),U)
I APPID=0 W "Error in test 6",!
D CHECKIN^BSDX25(.ZZZ,APPID,$$NOW^XLFDT) ; check-in
D APPDEL^BSDX08(.ZZZ,APPID,"PC",10,"Cancel Note") ; Delete appt
I $P(^BSDXTMP($J,1),$C(30))'="" W "Error in test 6",!
;
; Test 7: for cancelling walkin and checked-in appointments
N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
N APPTTIME S APPTTIME=$P(TIMES,U)
N ENDTIME S ENDTIME=$P(TIMES,U,2)
S DFN=5
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,10,"Sam's Note",1) ; Add appt
S APPID=+$P(^BSDXTMP($J,1),U)
I APPID=0 W "Error in test 6",!
D CHECKIN^BSDX25(.ZZZ,APPID,$$NOW^XLFDT) ; Checkin
S BSDXRESULT=$$RMCI^BSDXAPI(DFN,HLIEN,APPTTIME) ; remove checkin
D APPDEL^BSDX08(.ZZZ,APPID,"PC",10,"Cancel Note") ; delete appt
I $P(^BSDXTMP($J,1),$C(30))'="" W "Error in test 6",!
QUIT
;
UT29 ; Unit Test for BSDX29 UT29 ; Unit Test for BSDX29
; HLs/Resources are created as part of the UT ; HLs/Resources are created as part of the UT
; Patients 1,2,3,4,5 must exist ; Patients 1,2,3,4,5 must exist

123
m/BSDXUT2.m Normal file
View File

@ -0,0 +1,123 @@
BSDXUT2 ; VEN/SMH - Unit Tests for Scheduling GUI - cont. ; 6/28/12 11:55am
;;1.7T1;BSDX;;Aug 31, 2011;Build 18
;
UT25 ; Unit Tests for BSDX25
; Make appointment, checkin, then uncheckin
N $ET S $ET="W ""An Error Occured. Breaking."",! BREAK"
N RESNAM S RESNAM="UTCLINIC"
N HLRESIENS ; holds output of UTCR^BSDXUT - HL IEN^Resource IEN
D
. N $ET S $ET="D ^%ZTER B"
. S HLRESIENS=$$UTCR^BSDXUT(RESNAM)
. I HLRESIENS<0 S $EC=",U1," ; not supposed to happen - hard crash if so
;
N HLIEN,RESIEN
S HLIEN=$P(HLRESIENS,U)
S RESIEN=$P(HLRESIENS,U,2)
;
; Get start and end times
N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
N APPTTIME S APPTTIME=$P(TIMES,U)
N ENDTIME S ENDTIME=$P(TIMES,U,2)
;
; Test 1: Make normal appointment and cancel it. See if every thing works
N ZZZ,DFN
S DFN=5
N ZZZ
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
N APPTID S APPTID=+^BSDXTMP($J,1)
N HL S HL=$$GET1^DIQ(9002018.4,APPTID,".07:.04","I")
D CHECKIN^BSDX25(.ZZZ,APPTID,$$NOW^XLFDT())
IF '$P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN CHECKIN 1",!
IF '+$G(^SC(HL,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN CHECKIN 2",!
D RMCI^BSDX25(.ZZZ,APPTID)
IF $P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN UNCHECKIN 1",!
IF $G(^SC(HL,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN UNCHECKIN 2",!
D RMCI^BSDX25(.ZZZ,APPTID) ; again, test sanity in repeat
IF $P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN UNCHECKIN 1",!
IF $G(^SC(HL,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN UNCHECKIN 2",!
; now test various error conditions
; Test Error 1
D RMCI^BSDX25(.ZZZ,)
IF +^BSDXTMP($J,1)'=-1 WRITE "ERROR IN ETest 1",!
; Test Error 2
D RMCI^BSDX25(.ZZZ,234987234398)
IF +^BSDXTMP($J,1)'=-2 WRITE "ERROR IN Etest 2",!
; Tests for 3 to 5 difficult to produce
; Error tests follow: Mumps error test; Transaction restartability
N bsdxdie S bsdxdie=1
D RMCI^BSDX25(.ZZZ,APPTID)
IF +^BSDXTMP($J,1)'=-100 WRITE "ERROR IN Etest 3",!
K bsdxdie
N bsdxrestart S bsdxrestart=1
D RMCI^BSDX25(.ZZZ,APPTID)
IF +^BSDXTMP($J,1)'=0 WRITE "Error in Etest 4",!
;
; Unlinked Clinic Tests
N RESNAM S RESNAM="UTCLINICUL" ; Unlinked Clinic
N RESIEN
D
. N $ET S $ET="D ^%ZTER B"
. S RESIEN=$$UTCRRES^BSDXUT(RESNAM)
. I RESIEN<0 S $EC=",U1," ; not supposed to happen - hard crash if so
;
; Get start and end times
N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
N APPTTIME S APPTTIME=$P(TIMES,U)
N ENDTIME S ENDTIME=$P(TIMES,U,2)
;
N ZZZ,DFN
S DFN=4
N ZZZ
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
N APPTID S APPTID=+^BSDXTMP($J,1)
N HL S HL=$$GET1^DIQ(9002018.4,APPTID,".07:.04","I")
I HL'="" W "Error. Hospital Location Exists",!
;
D CHECKIN^BSDX25(.ZZZ,APPTID,$$NOW^XLFDT())
IF '$P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN CHECKIN 3",!
;test
D RMCI^BSDX25(.ZZZ,APPTID)
IF $P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN UNCHECKIN 3",!
D RMCI^BSDX25(.ZZZ,APPTID) ; again, test sanity in repeat
IF $P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN UNCHECKIN 3",!
; now test various error conditions
; Test Error 1
D RMCI^BSDX25(.ZZZ,)
IF +^BSDXTMP($J,1)'=-1 WRITE "ERROR IN ETest 5",!
; Test Error 2
D RMCI^BSDX25(.ZZZ,234987234398)
IF +^BSDXTMP($J,1)'=-2 WRITE "ERROR IN Etest 6",!
; Tests for 3 to 5 difficult to produce
; Error tests follow: Mumps error test; Transaction restartability
N bsdxdie S bsdxdie=1
D RMCI^BSDX25(.ZZZ,APPTID)
IF +^BSDXTMP($J,1)'=-100 WRITE "ERROR IN Etest 7",!
K bsdxdie
N bsdxrestart S bsdxrestart=1
D RMCI^BSDX25(.ZZZ,APPTID)
IF +^BSDXTMP($J,1)'=0 WRITE "Error in Etest 8",!
;
; Tests for running PIMS by itself.
N APPTTIME S APPTTIME=$$TIMEHL^BSDXUT(HLIEN) ; appt time
N DFN S DFN=2
N % S %=$$MAKE1^BSDXAPI(DFN,HLIEN,3,APPTTIME,15,"Sam Test Appt"_DFN)
I % W "Error in $$MAKE1^BSDXAPI for TIME "_APPTTIME_" for DFN "_DFN,!,%,!
I '$D(^BSDXAPPT("APAT",DFN,APPTTIME)) W "No BSDX Appointment Created",!
;TODO: Index doesn't include resource.
N APPTID S APPTID=$O(^(APPTTIME,""))
I 'APPTID W "Can't get appointment",!
IF $P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN CHECKIN 3",!
N % S %=$$CHECKIN1^BSDXAPI(DFN,HLIEN,APPTTIME) ; Checkin via PIMS
I % W "Error in Checking in via BSDXAPI",!
IF '+$G(^SC(HLIEN,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN CHECKIN 10",!
IF '$P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN CHECKIN 11",!
N % S %=$$RMCI^BSDXAPI(DFN,HLIEN,APPTTIME)
I % W "Error removing Check-in via PIMS",!
I +$G(^SC(HLIEN,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN UNCHECKIN 12",!
IF $P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN CHECKIN 13",!
N % S %=$$CHECKIN1^BSDXAPI(DFN,HLIEN,APPTTIME) ; Checkin via PIMS again
I % W "Error in Checking in via BSDXAPI",!
IF '+$G(^SC(HLIEN,"S",APPTTIME,1,1,"C")) WRITE "ERROR IN CHECKIN 14",!
IF '$P(^BSDXAPPT(APPTID,0),U,3) WRITE "ERROR IN CHECKIN 15",!
QUIT