Moved Unit Tests and UT Set-up to BSDXUT, started refactoring BSDX08.
This commit is contained in:
parent
bce0324b63
commit
03d9bfeec4
170
m/BSDX07.m
170
m/BSDX07.m
|
@ -1,4 +1,4 @@
|
|||
BSDX07 ; VW/UJO/SMH - WINDOWS SCHEDULING RPCS ; 6/20/12 3:28pm
|
||||
BSDX07 ; VW/UJO/SMH - WINDOWS SCHEDULING RPCS ; 6/21/12 3:54pm
|
||||
;;1.7T1;BSDX;;Aug 31, 2011;Build 18
|
||||
; Licensed under LGPL
|
||||
;
|
||||
|
@ -6,7 +6,6 @@ BSDX07 ; VW/UJO/SMH - WINDOWS SCHEDULING RPCS ; 6/20/12 3:28pm
|
|||
; UJO/SMH
|
||||
; v1.3 July 13 2010 - Add support i18n - Dates input as FM dates, not US.
|
||||
; v1.42 Oct 22 2010 - Transaction now restartable by providing arguments
|
||||
; thanks to Rick Marshall and Zach Gonzalez at Oroville.
|
||||
; v1.42 Oct 30 2010 - Extensive refactoring.
|
||||
; v1.5 Mar 15 2011 - End time does not have to have time anymore.
|
||||
; It could be midnight of the next day
|
||||
|
@ -31,170 +30,6 @@ APPADDD(BSDXY,BSDXSTART,BSDXEND,BSDXPATID,BSDXRES,BSDXLEN,BSDXNOTE,BSDXATID)
|
|||
; D DEBUG^%Serenji("APPADD^BSDX07(.BSDXY,BSDXSTART,BSDXEND,BSDXPATID,BSDXRES,BSDXLEN,BSDXNOTE,BSDXATID)")
|
||||
Q
|
||||
;
|
||||
UT ; Unit Tests - Assumes you have Patients with DFNs 1,2 and 3
|
||||
; Set-up - Create Clinics
|
||||
N RESNAM S RESNAM="UTCLINIC"
|
||||
N HLRESIENS ; holds output of UTCR^BSDX35 - HL IEN^Resource IEN
|
||||
D
|
||||
. N $ET S $ET="D ^%ZTER B"
|
||||
. S HLRESIENS=$$UTCR^BSDX35(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^BSDX35 ; appt time^end time
|
||||
N APPTTIME S APPTTIME=$P(TIMES,U)
|
||||
N ENDTIME S ENDTIME=$P(TIMES,U,2)
|
||||
;
|
||||
N ZZZ,DFN
|
||||
; Test for normality:
|
||||
S DFN=3
|
||||
D APPADD(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
|
||||
; Does Appt exist?
|
||||
N APPID S APPID=+$P(^BSDXTMP($J,1),U)
|
||||
I 'APPID W "Error Making Appt-1" QUIT
|
||||
I +^BSDXAPPT(APPID,0)'=APPTTIME W "Error Making Appt-2"
|
||||
I '$D(^DPT(DFN,"S",APPTTIME)) W "Error Making Appt-3"
|
||||
I '$$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error Making Appt-4"
|
||||
;
|
||||
; Do it again for a different patient
|
||||
S DFN=2
|
||||
D APPADD(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
|
||||
N APPID S APPID=+$P(^BSDXTMP($J,1),U)
|
||||
I 'APPID W "Error Making Appt-5" QUIT
|
||||
I +^BSDXAPPT(APPID,0)'=APPTTIME W "Error Making Appt-6"
|
||||
I '$D(^DPT(DFN,"S",APPTTIME)) W "Error Making Appt-7"
|
||||
I '$$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error Making Appt-8"
|
||||
;
|
||||
; Again for a different patient (4)
|
||||
S DFN=4
|
||||
D APPADD(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
|
||||
N APPID S APPID=+$P(^BSDXTMP($J,1),U)
|
||||
I 'APPID W "Error Making Appt-9" QUIT
|
||||
I +^BSDXAPPT(APPID,0)'=APPTTIME W "Error Making Appt-10"
|
||||
I '$D(^DPT(DFN,"S",APPTTIME)) W "Error Making Appt-11"
|
||||
I '$$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error Making Appt-12"
|
||||
;
|
||||
; Delete appointment set for Patient 4 (made above)
|
||||
N BSDX,DFN
|
||||
S DFN=4
|
||||
S BSDX("PAT")=DFN
|
||||
S BSDX("CLN")=HLIEN
|
||||
S BSDX("ADT")=APPTTIME
|
||||
D ROLLBACK(APPID,.BSDX)
|
||||
I +$G(^BSDXAPPT(APPID,0)) W "Error in deleting appointment-1",!
|
||||
I $D(^DPT(DFN,"S",APPTTIME)) W "Error in deleting appointment-2",!
|
||||
I $$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error in deleting appointment-3",!
|
||||
;
|
||||
; Again for a different patient (5)
|
||||
S DFN=5
|
||||
D APPADD(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
|
||||
N APPID S APPID=+$P(^BSDXTMP($J,1),U)
|
||||
I 'APPID W "Error Making Appt-13" QUIT
|
||||
I +^BSDXAPPT(APPID,0)'=APPTTIME W "Error Making Appt-14"
|
||||
I '$D(^DPT(DFN,"S",APPTTIME)) W "Error Making Appt-15"
|
||||
I '$$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error Making Appt-16"
|
||||
; Now cancel that appointment
|
||||
D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Sam's Cancel Note")
|
||||
; Now make it again
|
||||
D APPADD(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
|
||||
N APPID S APPID=+$P(^BSDXTMP($J,1),U)
|
||||
I 'APPID W "Error Making Appt-17" QUIT
|
||||
I +^BSDXAPPT(APPID,0)'=APPTTIME W "Error Making Appt-18"
|
||||
I '$D(^DPT(DFN,"S",APPTTIME)) W "Error Making Appt-19"
|
||||
I '$$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error Making Appt-20"
|
||||
;
|
||||
; Delete appointment set for Patient 1 (not made)... needs to not crash
|
||||
D
|
||||
. N $ET S $ET="D ^%ZTER S $EC="""" W ""Failure to del non-existent appt"",!"
|
||||
. N BSDX
|
||||
. S BSDX("PAT")=1
|
||||
. S BSDX("CLN")=HLIEN
|
||||
. S BSDX("ADT")=APPTTIME
|
||||
. D ROLLBACK(APPID,.BSDX)
|
||||
;
|
||||
; Test for bad start date
|
||||
D APPADD(.ZZZ,2100123,3100123.3,2,RESNAM,30,"Sam's Note",1)
|
||||
I +$P(^BSDXTMP($J,1),U,2)'=-2 W "Error in -2",!
|
||||
; Test for bad end date
|
||||
D APPADD(.ZZZ,3100123,2100123.3,2,RESNAM,30,"Sam's Note",1)
|
||||
I +$P(^BSDXTMP($J,1),U,2)'=-3 W "Error in -3",!
|
||||
; Test for end date without time - obsolete
|
||||
; D APPADD(.ZZZ,3100123.1,3100123,2,RESNAM,30,"Sam's Note",1)
|
||||
; I +$P(^BSDXTMP($J,1),U,2)'=-4 W "Error in -4",!
|
||||
; Test for mumps error
|
||||
S BSDXDIE=1
|
||||
D APPADD(.ZZZ,APPTTIME,ENDTIME,1,RESNAM,30,"Sam's Note",1)
|
||||
I +$P(^BSDXTMP($J,1),U,2)'=-100 W "Error in -100: M Error",!
|
||||
K BSDXDIE
|
||||
; Test for TRESTART -- retired in v 1.7
|
||||
; S BSDXRESTART=1
|
||||
; D APPADD(.ZZZ,APPTTIME,ENDTIME,3,RESNAM,30,"Sam's Note",1)
|
||||
; I +$P(^BSDXTMP($J,1),U,2)'=0&(+$P(^BSDXTMP($J,1),U,2)'=-10) W "Error in TRESTART",!
|
||||
; K BSDXRESTART
|
||||
; Test for non-numeric patient
|
||||
D APPADD(.ZZZ,APPTTIME,ENDTIME,"CAT,DOG",RESNAM,30,"Sam's Note",1)
|
||||
I +$P(^BSDXTMP($J,1),U,2)'=-5 W "Error in -5",!
|
||||
; Test for a non-existent patient
|
||||
D APPADD(.ZZZ,APPTTIME,ENDTIME,8989898989,RESNAM,30,"Sam's Note",1)
|
||||
I +$P(^BSDXTMP($J,1),U,2)'=-6 W "Error in -6",!
|
||||
; Test for a non-existent resource name
|
||||
D APPADD(.ZZZ,APPTTIME,ENDTIME,3,"lkajsflkjsadf",30,"Sam's Note",1)
|
||||
I +$P(^BSDXTMP($J,1),U,2)'=-7 W "Error in -7",!
|
||||
; Test for corrupted resource
|
||||
; Can't test for -8 since it requires DB corruption
|
||||
; Test for inability to add appointment to BSDX Appointment (-9)
|
||||
; Also requires something wrong in the DB
|
||||
; Test for inability to add appointment to 2,44
|
||||
; Test by creating a duplicate appointment
|
||||
; Get start and end times
|
||||
N TIMES S TIMES=$$TIMES^BSDX35 ; appt time^end time
|
||||
N APPTTIME S APPTTIME=$P(TIMES,U)
|
||||
N ENDTIME S ENDTIME=$P(TIMES,U,2)
|
||||
D APPADD(.ZZZ,APPTTIME,ENDTIME,3,RESNAM,30,"Sam's Note",1)
|
||||
D APPADD(.ZZZ,APPTTIME,ENDTIME,3,RESNAM,30,"Sam's Note",1)
|
||||
I +$P(^BSDXTMP($J,1),U,2)'=-10 W "Error in -10",!
|
||||
;
|
||||
; Test that rollback occurs properly in various places
|
||||
N TIMES S TIMES=$$TIMES^BSDX35 ; appt time^end time
|
||||
N APPTTIME S APPTTIME=$P(TIMES,U)
|
||||
N ENDTIME S ENDTIME=$P(TIMES,U,2)
|
||||
S DFN=4
|
||||
N BSDXSIMERR1 S BSDXSIMERR1=1
|
||||
D APPADD(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
|
||||
N APPID S APPID=$O(^BSDXAPPT("B",APPTTIME,""))
|
||||
I +APPID W "Error in deleting appointment-4",!
|
||||
I $D(^DPT(DFN,"S",APPTTIME)) W "Error in deleting appointment-5",!
|
||||
I $$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error in deleting appointment-6",!
|
||||
;
|
||||
K BSDXSIMERR1
|
||||
N BSDXSIMERR2 S BSDXSIMERR2=1
|
||||
D APPADD(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
|
||||
N APPID S APPID=$O(^BSDXAPPT("B",APPTTIME,""))
|
||||
I +APPID W "Error in deleting appointment-7",!
|
||||
I $D(^DPT(DFN,"S",APPTTIME)) W "Error in deleting appointment-8",!
|
||||
I $$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error in deleting appointment-9",!
|
||||
;
|
||||
K BSDXSIMERR2
|
||||
N BSDXSIMERR4 S BSDXSIMERR4=1
|
||||
D APPADD(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
|
||||
N APPID S APPID=$O(^BSDXAPPT("B",APPTTIME,""))
|
||||
I +APPID W "Error in deleting appointment-16",!
|
||||
I $D(^DPT(DFN,"S",APPTTIME)) W "Error in deleting appointment-17",!
|
||||
I $$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error in deleting appointment-18",!
|
||||
;
|
||||
K BSDXSIMERR4
|
||||
N BSDXSIMERR5 S BSDXSIMERR5=1
|
||||
D APPADD(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
|
||||
N APPID S APPID=$O(^BSDXAPPT("B",APPTTIME,""))
|
||||
I +APPID W "Error in deleting appointment-19",!
|
||||
I $D(^DPT(DFN,"S",APPTTIME)) W "Error in deleting appointment-20",!
|
||||
I $$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error in deleting appointment-21",!
|
||||
QUIT
|
||||
;
|
||||
APPADD(BSDXY,BSDXSTART,BSDXEND,BSDXPATID,BSDXRES,BSDXLEN,BSDXNOTE,BSDXATID,BSDXRADEXAM) ;EP
|
||||
;
|
||||
;Called by RPC: BSDX ADD NEW APPOINTMENT
|
||||
|
@ -298,7 +133,7 @@ APPADD(BSDXY,BSDXSTART,BSDXEND,BSDXPATID,BSDXRES,BSDXLEN,BSDXNOTE,BSDXATID,BSDXR
|
|||
N BSDXERR ; Variable to hold value of $$MAKE and $$MAKECK
|
||||
N BSDXC ; Array to send to MAKE and MAKECK APIs
|
||||
; Only if we have a valid Hosp Location
|
||||
I +BSDXSCD,$D(^SC(BSDXSCD,0)) D
|
||||
I +BSDXSCD,$D(^SC(BSDXSCD,0)) D I +BSDXERR D ERR(BSDXI,"-10~BSDX07 Error: MAKECK^BSDXAPI returned error code: "_BSDXERR) Q ; no need for roll back
|
||||
. S BSDXC("PAT")=BSDXPATID
|
||||
. S BSDXC("CLN")=BSDXSCD
|
||||
. S BSDXC("TYP")=3 ;3 for scheduled appts, 4 for walkins
|
||||
|
@ -310,7 +145,6 @@ APPADD(BSDXY,BSDXSTART,BSDXEND,BSDXPATID,BSDXRES,BSDXLEN,BSDXNOTE,BSDXATID,BSDXR
|
|||
. S BSDXC("OI")=$$STRIP(BSDXC("OI")) ;Strip control characters from note
|
||||
. S BSDXC("USR")=DUZ
|
||||
. S BSDXERR=$$MAKECK^BSDXAPI(.BSDXC)
|
||||
I +BSDXERR D ERR(BSDXI,"-10~BSDX07 Error: MAKECK^BSDXAPI returned error code: "_BSDXERR) Q ; no need for roll back
|
||||
;
|
||||
; Done with all checks, let's make appointment in BSDX APPOINTMENT
|
||||
N BSDXAPPTID
|
||||
|
|
96
m/BSDX08.m
96
m/BSDX08.m
|
@ -1,4 +1,4 @@
|
|||
BSDX08 ; VW/UJO/SMH - WINDOWS SCHEDULING RPCS ; 6/20/12 3:52pm
|
||||
BSDX08 ; VW/UJO/SMH - WINDOWS SCHEDULING RPCS ; 6/21/12 4:49pm
|
||||
;;1.6;BSDX;;Aug 31, 2011;Build 18
|
||||
;
|
||||
; Original by HMW. New Written by Sam Habiel. Licensed under LGPL.
|
||||
|
@ -37,85 +37,6 @@ APPDELD(BSDXY,BSDXAPTID,BSDXTYP,BSDXCR,BSDXNOT) ;EP
|
|||
;D DEBUG^%Serenji("APPDEL^BSDX08(.BSDXY,BSDXAPTID,BSDXTYP,BSDXCR,BSDXNOT)")
|
||||
Q
|
||||
;
|
||||
UT ; Unit Tests
|
||||
N RESNAM S RESNAM="UTCLINIC"
|
||||
N HLRESIENS ; holds output of UTCR^BSDX35 - HL IEN^Resource IEN
|
||||
D
|
||||
. N $ET S $ET="D ^%ZTER B"
|
||||
. S HLRESIENS=$$UTCR^BSDX35(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^BSDX35 ; 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(2,"S",APPTTIME,1,0))]"" W "Error in Cancellation-2"
|
||||
I $P(^DPT(4,"S",APPTTIME,0),U,2)'="PC" W "Error in Cancellation-3"
|
||||
I ^DPT(4,"S",3110123.2,"R")'="Sam's Cancel Note" W "Error in Cancellation-4"
|
||||
;
|
||||
; Test 2: Check for -1
|
||||
; Make appt
|
||||
D APPADD^BSDX07(.ZZZ,3110125.2,3110125.3,4,"Dr Office",10,"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
|
||||
S bsdxdie=1
|
||||
D APPADD^BSDX07(.ZZZ,3110126.2,3110126.3,4,"Dr Office",10,"Sam's Note",1)
|
||||
S APPID=+$P(^BSDXTMP($J,1),U)
|
||||
D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Reasons")
|
||||
I $P(^BSDXTMP($J,1),"~")'=-100 W "Error in -100",!
|
||||
K bsdxdie
|
||||
;
|
||||
; Test 4: Restartable transaction
|
||||
S bsdxrestart=1
|
||||
D APPADD^BSDX07(.ZZZ,3110128.2,3110128.3,4,"Dr Office",10,"Sam's Note",1)
|
||||
S APPID=+$P(^BSDXTMP($J,1),U)
|
||||
D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Reasons")
|
||||
I $P(^DPT(4,"S",3110128.2,0),U,2)'="PC" W "Error in Restartable Transaction",!
|
||||
;
|
||||
; 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",!
|
||||
UT2 ; More unit Tests
|
||||
;
|
||||
; Test 6: for Cancelling walkin and checked-in appointments
|
||||
S BSDXSTART=$E($$NOW^XLFDT,1,12),BSDXEND=BSDXSTART+.0001
|
||||
D APPADD^BSDX07(.ZZZ,BSDXSTART,BSDXEND,4,"Dr Office",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
|
||||
S BSDXSTART=$E($$NOW^XLFDT,1,12)+.0001,BSDXEND=BSDXSTART+.0001
|
||||
D APPADD^BSDX07(.ZZZ,BSDXSTART,BSDXEND,4,"Dr Office",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 BSDXRES=$O(^BSDXRES("B","Dr Office",""))
|
||||
S BSDXCLN=$P(^BSDXRES(BSDXRES,0),U,4)
|
||||
S BSDXRESULT=$$RMCI^BSDXAPI(4,BSDXCLN,BSDXSTART) ; 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
|
||||
APPDEL(BSDXY,BSDXAPTID,BSDXTYP,BSDXCR,BSDXNOT) ;EP
|
||||
;Called by RPC: BSDX CANCEL APPOINTMENT
|
||||
;Cancels existing appointment in BSDX APPOINTMENT and 44/2 subfiles
|
||||
|
@ -140,6 +61,7 @@ APPDEL(BSDXY,BSDXAPTID,BSDXTYP,BSDXCR,BSDXNOT) ;EP
|
|||
;
|
||||
; Counter
|
||||
N BSDXI S BSDXI=0
|
||||
;
|
||||
; Header Node
|
||||
S ^BSDXTMP($J,BSDXI)="T00100ERRORID"_$C(30)
|
||||
;
|
||||
|
@ -157,10 +79,10 @@ APPDEL(BSDXY,BSDXAPTID,BSDXTYP,BSDXCR,BSDXNOT) ;EP
|
|||
S BSDXNOEV=1 ;Don't execute BSDX CANCEL APPOINTMENT protocol
|
||||
;
|
||||
;;;test for error inside transaction. See if %ZTER works
|
||||
I $G(bsdxdie) S X=1/0
|
||||
I $G(BSDXDIE) S X=1/0
|
||||
;;;test
|
||||
;;;test for TRESTART
|
||||
I $G(bsdxrestart) K bsdxrestart TRESTART
|
||||
I $G(BSDXRESTART) K BSDXRESTART tRESTART
|
||||
;;;test
|
||||
;
|
||||
; Check appointment ID and whether it exists
|
||||
|
@ -186,7 +108,7 @@ APPDEL(BSDXY,BSDXAPTID,BSDXTYP,BSDXCR,BSDXNOT) ;EP
|
|||
; Error indicator for Hosp Location filing for getting out of routine
|
||||
N BSDXERR S BSDXERR=0
|
||||
; Only file in 2/44 if there is an associated hospital location
|
||||
I BSDXLOC D QUIT:BSDXERR
|
||||
I BSDXLOC D QUIT:BSDXERR
|
||||
. I '$D(^SC(BSDXLOC,0)) S BSDXERR=1 D ERR(BSDXI,"-6~BSDX08: Invalid Hosp Location stored in Database") QUIT
|
||||
. ; Get the IEN of the appointment in the "S" node of ^SC
|
||||
. N BSDXSCIEN
|
||||
|
@ -214,7 +136,7 @@ APPDEL(BSDXY,BSDXAPTID,BSDXTYP,BSDXCR,BSDXNOT) ;EP
|
|||
AVUPDT(BSDXSCD,BSDXSTART,BSDXLEN) ;Update Legacy PIMS Clinic availability
|
||||
;See SDCNP0
|
||||
N SD,S ; Start Date
|
||||
S (SD,S)=BSDXSTART
|
||||
S (SD,S)=BSDXSTART
|
||||
N I ; Clinic IEN in 44
|
||||
S I=BSDXSCD
|
||||
; if day has no schedule in legacy PIMS, forget about this update.
|
||||
|
@ -243,16 +165,16 @@ AVUPDT(BSDXSCD,BSDXSTART,BSDXLEN) ;Update Legacy PIMS Clinic availability
|
|||
N ST ; ??
|
||||
; Y#1 -> Minutes; *SI -> * Slots per hour; \.6 trunc min to hour
|
||||
; Y\1 -> Hours since start of day; * SI: * slots
|
||||
S ST=Y#1*SI\.6+(Y\1*SI)
|
||||
S ST=Y#1*SI\.6+(Y\1*SI)
|
||||
N SS ; how many slots are supposed to be taken by appointment
|
||||
S SS=SL*HSI/60 ; (nb: try SL: 30 min; HSI: 4 slots)
|
||||
N I
|
||||
I Y'<1 D ; If Hours since start of Date is greater than 1
|
||||
. ; loop through pattern. Tired of documenting.
|
||||
. F I=ST+ST:SDDIF D Q:Y="" Q:SS'>0
|
||||
. . S Y=$E(STR,$F(STR,$E(S,I+1))) Q:Y=""
|
||||
. . S Y=$E(STR,$F(STR,$E(S,I+1))) Q:Y=""
|
||||
. . S S=$E(S,1,I)_Y_$E(S,I+2,999)
|
||||
. . S SS=SS-1
|
||||
. . S SS=SS-1
|
||||
. . Q:SS'>0
|
||||
S ^SC(BSDXSCD,"ST",SD\1,1)=S ; new pattern; global set
|
||||
Q
|
||||
|
|
59
m/BSDX35.m
59
m/BSDX35.m
|
@ -1,4 +1,4 @@
|
|||
BSDX35 ; IHS/OIT/HMW - WINDOWS SCHEDULING RPCS ; 6/18/12 2:27pm
|
||||
BSDX35 ; IHS/OIT/HMW - WINDOWS SCHEDULING RPCS ; 6/21/12 3:57pm
|
||||
;;1.7T1;BSDX;;Aug 31, 2011;Build 18
|
||||
; Licensed under LGPL
|
||||
;
|
||||
|
@ -73,60 +73,3 @@ ERR(ERRNO) ;Error processing
|
|||
S BSDXI=BSDXI+1
|
||||
S ^BSDXTMP($J,BSDXI)=$C(31)
|
||||
Q
|
||||
UTCR(RESNAM) ; $$ - Create Unit Test Clinic and Resource Pair ; Private
|
||||
; Input: Resource Name By Value
|
||||
; Output: -1^Error or HLIEN^RESIEN for Success (file 44 IEN^file 9002018.1 IEN)
|
||||
; DO NOT USE IN A PRODUCTION ENVIRONTMENT. INTENDED FOR TESTING ONLY
|
||||
N HLIEN S HLIEN=$$UTCR44(RESNAM)
|
||||
I +HLIEN=-1 QUIT HLIEN
|
||||
;
|
||||
N RESIEN S RESIEN=$$UTCRRES(RESNAM,HLIEN)
|
||||
I +RESIEN=-1 QUIT RESIEN
|
||||
E QUIT HLIEN_U_RESIEN
|
||||
;
|
||||
UTCR44(HLNAME) ; $$ - Create Unit Test Clinic in File 44; Private ; TESTING ONLY CODE
|
||||
; Output: -1^Error or IEN for Success
|
||||
; Input: Hosp Location Name by Value
|
||||
; DO NOT USE IN A PRODUCTION ENVIRONTMENT. INTENDED FOR TESTING ONLY
|
||||
;
|
||||
I $D(^SC("B",HLNAME)) Q $O(^(HLNAME,""))
|
||||
;
|
||||
N SAM
|
||||
S SAM(44,"?+1,",.01)=HLNAME ; Name
|
||||
S SAM(44,"?+1,",2)="C" ; Type = Clinic
|
||||
S SAM(44,"?+1,",2.1)=1 ; Type Extension (not used)
|
||||
S SAM(44,"?+1,",3.5)=$O(^DG(40.8,0)) ; Division (not yet used)
|
||||
S SAM(44,"?+1,",8)=295 ; Stop Code Number (not used)
|
||||
S SAM(44,"?+1,",9)="M" ; Service (not used)
|
||||
S SAM(44,"?+1,",1912)=15 ; Length of Appt (not used)
|
||||
S SAM(44,"?+1,",1917)=4 ; Display increments per hour (not used)
|
||||
S SAM(44,"?+1,",1918)=8 ; Overbooks/day max (not used)
|
||||
S SAM(44,"?+1,",2000.5)=0 ; Require Action Profiles: Yes (not used)
|
||||
S SAM(44,"?+1,",2001)=999 ; Allowable consecutive no-shows (not used)
|
||||
S SAM(44,"?+1,",2002)=999 ; Max # days for Future Booking (not used)
|
||||
S SAM(44,"?+1,",2005)=365 ; Max # days for Auto Rebook (not used)
|
||||
S SAM(44,"?+1,",2502)="N" ; Non-Count Clinic (not used)
|
||||
S SAM(44,"?+1,",2504)="Y" ; Clinic meets at this Facility? (not used)
|
||||
S SAM(44,"?+1,",2507)=9 ; Appointment Type (not used)
|
||||
;
|
||||
N BSDXERR,BSDXIEN
|
||||
D UPDATE^DIE("",$NA(SAM),$NA(BSDXIEN),$NA(BSDXERR))
|
||||
Q $S($D(BSDXERR):-1_U_BSDXERR("DIERR",1,"TEXT",1),1:BSDXIEN(1))
|
||||
;
|
||||
UTCRRES(NAME,HLIEN) ; $$ - Create Unit Test Resource in 9002018.1 (BSDX RESOURCE); Private
|
||||
; Input: Hospital Location IEN
|
||||
; Output: -1^Error or IEN for Success
|
||||
; DO NOT USE IN A PRODUCTION ENVIRONTMENT. INTENDED FOR TESTING ONLY
|
||||
I $D(^BSDXRES("B",NAME)) Q $O(^(NAME,""))
|
||||
D RSRC^BSDX16(.RES,"|"_NAME_"||"_HLIEN)
|
||||
N RTN S RTN=@$Q(^BSDXTMP($J,0)) ; return array next value
|
||||
Q $S(RTN=0:-1_U_RTN,1:+RTN) ; 0 means an error has occurred; 1 means IEN returned
|
||||
;
|
||||
TIMES() ; $$ - Create a next available appointment time^ending time; Private
|
||||
N NOW S NOW=$$NOW^XLFDT() ; Now time
|
||||
N LAST S LAST=$O(^BSDXAPPT("B"," "),-1) ; highest time in file
|
||||
N TIME2USE S TIME2USE=$S(NOW>LAST:NOW,1:LAST) ; Which time to use?
|
||||
S TIME2USE=$E(TIME2USE,1,12) ; Strip away seconds
|
||||
N APPTIME S APPTIME=$$FMADD^XLFDT(TIME2USE,0,0,15,0) ; Add 15 min
|
||||
N ENDTIME S ENDTIME=$$FMADD^XLFDT(APPTIME,0,0,15,0) ; Add 15 more min
|
||||
Q APPTIME_U_ENDTIME ; quit with apptime^endtime
|
||||
|
|
|
@ -0,0 +1,423 @@
|
|||
BSDXUT ; VEN/SMH - Unit Tests for Scheduling GUI ; 6/21/12 4:42pm
|
||||
;;1.7T1;BSDX;;Aug 31, 2011;Build 18
|
||||
; Licensed under LGPL
|
||||
;
|
||||
; Change Log:
|
||||
; June 21 2012: Initial Version
|
||||
;
|
||||
UT07 ; Unit Tests for BSDX07 - Assumes you have Patients with DFNs 1,2,3,4,5
|
||||
; HLs/Resources are created as part of the UT
|
||||
; Set-up - Create Clinics
|
||||
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)
|
||||
;
|
||||
N ZZZ,DFN
|
||||
; Test for normality:
|
||||
S DFN=3
|
||||
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
|
||||
; Does Appt exist?
|
||||
N APPID S APPID=+$P(^BSDXTMP($J,1),U)
|
||||
I 'APPID W "Error Making Appt-1" QUIT
|
||||
I +^BSDXAPPT(APPID,0)'=APPTTIME W "Error Making Appt-2"
|
||||
I '$D(^DPT(DFN,"S",APPTTIME)) W "Error Making Appt-3"
|
||||
I '$$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error Making Appt-4"
|
||||
;
|
||||
; Do it again for a different patient
|
||||
S DFN=2
|
||||
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
|
||||
N APPID S APPID=+$P(^BSDXTMP($J,1),U)
|
||||
I 'APPID W "Error Making Appt-5" QUIT
|
||||
I +^BSDXAPPT(APPID,0)'=APPTTIME W "Error Making Appt-6"
|
||||
I '$D(^DPT(DFN,"S",APPTTIME)) W "Error Making Appt-7"
|
||||
I '$$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error Making Appt-8"
|
||||
;
|
||||
; Again for a different patient (4)
|
||||
S DFN=4
|
||||
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
|
||||
N APPID S APPID=+$P(^BSDXTMP($J,1),U)
|
||||
I 'APPID W "Error Making Appt-9" QUIT
|
||||
I +^BSDXAPPT(APPID,0)'=APPTTIME W "Error Making Appt-10"
|
||||
I '$D(^DPT(DFN,"S",APPTTIME)) W "Error Making Appt-11"
|
||||
I '$$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error Making Appt-12"
|
||||
;
|
||||
; Delete appointment set for Patient 4 (made above)
|
||||
N BSDX,DFN
|
||||
S DFN=4
|
||||
S BSDX("PAT")=DFN
|
||||
S BSDX("CLN")=HLIEN
|
||||
S BSDX("ADT")=APPTTIME
|
||||
D ROLLBACK^BSDX07(APPID,.BSDX)
|
||||
I +$G(^BSDXAPPT(APPID,0)) W "Error in deleting appointment-1",!
|
||||
I $D(^DPT(DFN,"S",APPTTIME)) W "Error in deleting appointment-2",!
|
||||
I $$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error in deleting appointment-3",!
|
||||
;
|
||||
; Again for a different patient (5)
|
||||
S DFN=5
|
||||
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
|
||||
N APPID S APPID=+$P(^BSDXTMP($J,1),U)
|
||||
I 'APPID W "Error Making Appt-13" QUIT
|
||||
I +^BSDXAPPT(APPID,0)'=APPTTIME W "Error Making Appt-14"
|
||||
I '$D(^DPT(DFN,"S",APPTTIME)) W "Error Making Appt-15"
|
||||
I '$$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error Making Appt-16"
|
||||
; Now cancel that appointment
|
||||
D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Sam's Cancel Note")
|
||||
; Now make it again
|
||||
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
|
||||
N APPID S APPID=+$P(^BSDXTMP($J,1),U)
|
||||
I 'APPID W "Error Making Appt-17" QUIT
|
||||
I +^BSDXAPPT(APPID,0)'=APPTTIME W "Error Making Appt-18"
|
||||
I '$D(^DPT(DFN,"S",APPTTIME)) W "Error Making Appt-19"
|
||||
I '$$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error Making Appt-20"
|
||||
;
|
||||
; Delete appointment set for Patient 1 (not made)... needs to not crash
|
||||
D
|
||||
. N $ET S $ET="D ^%ZTER S $EC="""" W ""Failure to del non-existent appt"",!"
|
||||
. N BSDX
|
||||
. S BSDX("PAT")=1
|
||||
. S BSDX("CLN")=HLIEN
|
||||
. S BSDX("ADT")=APPTTIME
|
||||
. D ROLLBACK^BSDX07(APPID,.BSDX)
|
||||
;
|
||||
; Test for bad start date
|
||||
D APPADD^BSDX07(.ZZZ,2100123,3100123.3,2,RESNAM,30,"Sam's Note",1)
|
||||
I +$P(^BSDXTMP($J,1),U,2)'=-2 W "Error in -2",!
|
||||
; Test for bad end date
|
||||
D APPADD^BSDX07(.ZZZ,3100123,2100123.3,2,RESNAM,30,"Sam's Note",1)
|
||||
I +$P(^BSDXTMP($J,1),U,2)'=-3 W "Error in -3",!
|
||||
; Test for end date without time - obsolete
|
||||
; Test for mumps error
|
||||
N BSDXDIE S BSDXDIE=1
|
||||
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,1,RESNAM,30,"Sam's Note",1)
|
||||
I +$P(^BSDXTMP($J,1),U,2)'=-100 W "Error in -100: M Error",!
|
||||
K BSDXDIE
|
||||
; Test for TRESTART -- retired in v 1.7
|
||||
; Test for non-numeric patient
|
||||
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,"CAT,DOG",RESNAM,30,"Sam's Note",1)
|
||||
I +$P(^BSDXTMP($J,1),U,2)'=-5 W "Error in -5",!
|
||||
; Test for a non-existent patient
|
||||
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,8989898989,RESNAM,30,"Sam's Note",1)
|
||||
I +$P(^BSDXTMP($J,1),U,2)'=-6 W "Error in -6",!
|
||||
; Test for a non-existent resource name
|
||||
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,3,"lkajsflkjsadf",30,"Sam's Note",1)
|
||||
I +$P(^BSDXTMP($J,1),U,2)'=-7 W "Error in -7",!
|
||||
; Test for corrupted resource
|
||||
; Can't test for -8 since it requires DB corruption
|
||||
; Test for inability to add appointment to BSDX Appointment (-9)
|
||||
; Also requires something wrong in the DB
|
||||
; Test for inability to add appointment to 2,44
|
||||
; Test by creating a duplicate appointment
|
||||
; 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)
|
||||
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,3,RESNAM,30,"Sam's Note",1)
|
||||
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,3,RESNAM,30,"Sam's Note",1)
|
||||
I +$P(^BSDXTMP($J,1),U,2)'=-10 W "Error in -10",!
|
||||
;
|
||||
; Test that ROLLBACK^BSDX07 occurs properly in various places
|
||||
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
|
||||
N BSDXSIMERR1 S BSDXSIMERR1=1
|
||||
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
|
||||
N APPID S APPID=$O(^BSDXAPPT("B",APPTTIME,""))
|
||||
I +APPID W "Error in deleting appointment-4",!
|
||||
I $D(^DPT(DFN,"S",APPTTIME)) W "Error in deleting appointment-5",!
|
||||
I $$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error in deleting appointment-6",!
|
||||
;
|
||||
K BSDXSIMERR1
|
||||
N BSDXSIMERR2 S BSDXSIMERR2=1
|
||||
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
|
||||
N APPID S APPID=$O(^BSDXAPPT("B",APPTTIME,""))
|
||||
I +APPID W "Error in deleting appointment-7",!
|
||||
I $D(^DPT(DFN,"S",APPTTIME)) W "Error in deleting appointment-8",!
|
||||
I $$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error in deleting appointment-9",!
|
||||
;
|
||||
K BSDXSIMERR2
|
||||
N BSDXSIMERR4 S BSDXSIMERR4=1
|
||||
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
|
||||
N APPID S APPID=$O(^BSDXAPPT("B",APPTTIME,""))
|
||||
I +APPID W "Error in deleting appointment-16",!
|
||||
I $D(^DPT(DFN,"S",APPTTIME)) W "Error in deleting appointment-17",!
|
||||
I $$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error in deleting appointment-18",!
|
||||
;
|
||||
K BSDXSIMERR4
|
||||
N BSDXSIMERR5 S BSDXSIMERR5=1
|
||||
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
|
||||
N APPID S APPID=$O(^BSDXAPPT("B",APPTTIME,""))
|
||||
I +APPID W "Error in deleting appointment-19",!
|
||||
I $D(^DPT(DFN,"S",APPTTIME)) W "Error in deleting appointment-20",!
|
||||
I $$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error in deleting appointment-21",!
|
||||
;
|
||||
; Okay now we do UTs for an unlinked resource (not linked to PIMS)
|
||||
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
|
||||
; Test for normality:
|
||||
S DFN=3
|
||||
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
|
||||
; Does Appt exist?
|
||||
N APPID S APPID=+$P(^BSDXTMP($J,1),U)
|
||||
I 'APPID W "Error Making Appt-101" QUIT
|
||||
I +^BSDXAPPT(APPID,0)'=APPTTIME W "Error Making Appt-102"
|
||||
I $D(^DPT(DFN,"S",APPTTIME)) W "Error Making Appt-103"
|
||||
;
|
||||
; Again for a different patient (4)
|
||||
S DFN=4
|
||||
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
|
||||
N APPID S APPID=+$P(^BSDXTMP($J,1),U)
|
||||
I 'APPID W "Error Making Appt-104" QUIT
|
||||
I +^BSDXAPPT(APPID,0)'=APPTTIME W "Error Making Appt-105"
|
||||
I $D(^DPT(DFN,"S",APPTTIME)) W "Error Making Appt-106"
|
||||
;
|
||||
; Delete appointment set for Patient 4 (made above)
|
||||
N BSDX,DFN
|
||||
S DFN=4
|
||||
D ROLLBACK^BSDX07(APPID)
|
||||
I +$G(^BSDXAPPT(APPID,0)) W "Error in deleting appointment-1",!
|
||||
;
|
||||
; Duplicate appointments... This is SUPPOSED to fail for now (v1.7)
|
||||
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,3,RESNAM,30,"Sam's Note",1)
|
||||
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,3,RESNAM,30,"Sam's Note",1)
|
||||
I +$P(^BSDXTMP($J,1),U,2)'=-10 W "Error in -10 in Unlinked Section",!
|
||||
;
|
||||
; Test that ROLLBACK^BSDX07 occurs properly in various places
|
||||
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
|
||||
N BSDXSIMERR1 S BSDXSIMERR1=1
|
||||
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
|
||||
N APPID S APPID=$O(^BSDXAPPT("B",APPTTIME,""))
|
||||
I +APPID W "Error in deleting appointment-101",!
|
||||
;
|
||||
; These are never triggered, so we should still have an appointment
|
||||
K BSDXSIMERR1
|
||||
N BSDXSIMERR2 S BSDXSIMERR2=1
|
||||
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
|
||||
N APPID S APPID=$O(^BSDXAPPT("B",APPTTIME,""))
|
||||
I '+APPID W "Error in deleting appointment-102",!
|
||||
;
|
||||
K BSDXSIMERR2
|
||||
N BSDXSIMERR4 S BSDXSIMERR4=1
|
||||
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
|
||||
N APPID S APPID=$O(^BSDXAPPT("B",APPTTIME,""))
|
||||
I '+APPID W "Error in deleting appointment-103",!
|
||||
;
|
||||
K BSDXSIMERR4
|
||||
N BSDXSIMERR5 S BSDXSIMERR5=1
|
||||
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
|
||||
N APPID S APPID=$O(^BSDXAPPT("B",APPTTIME,""))
|
||||
I '+APPID W "Error in deleting appointment-104",!
|
||||
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 BSDXDIE S BSDXDIE=1
|
||||
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,"Reasons")
|
||||
I $P(^BSDXTMP($J,1),"~")'=-100 W "Error in -100",!
|
||||
K BSDXDIE
|
||||
;
|
||||
; 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,BSDXSTART) ; 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,BSDXSTART) ; 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
|
||||
; Input: Resource Name By Value
|
||||
; Output: -1^Error or HLIEN^RESIEN for Success (file 44 IEN^file 9002018.1 IEN)
|
||||
; DO NOT USE IN A PRODUCTION ENVIRONTMENT. INTENDED FOR TESTING ONLY
|
||||
N HLIEN S HLIEN=$$UTCR44(RESNAM)
|
||||
I +HLIEN=-1 QUIT HLIEN
|
||||
;
|
||||
N RESIEN S RESIEN=$$UTCRRES(RESNAM,HLIEN)
|
||||
I +RESIEN=-1 QUIT RESIEN
|
||||
E QUIT HLIEN_U_RESIEN
|
||||
;
|
||||
UTCR44(HLNAME) ; $$ - Create Unit Test Clinic in File 44; Private ; TESTING ONLY CODE
|
||||
; Output: -1^Error or IEN for Success
|
||||
; Input: Hosp Location Name by Value
|
||||
; DO NOT USE IN A PRODUCTION ENVIRONTMENT. INTENDED FOR TESTING ONLY
|
||||
;
|
||||
I $D(^SC("B",HLNAME)) Q $O(^(HLNAME,""))
|
||||
;
|
||||
N SAM
|
||||
S SAM(44,"?+1,",.01)=HLNAME ; Name
|
||||
S SAM(44,"?+1,",2)="C" ; Type = Clinic
|
||||
S SAM(44,"?+1,",2.1)=1 ; Type Extension (not used)
|
||||
S SAM(44,"?+1,",3.5)=$O(^DG(40.8,0)) ; Division (not yet used)
|
||||
S SAM(44,"?+1,",8)=295 ; Stop Code Number (not used)
|
||||
S SAM(44,"?+1,",9)="M" ; Service (not used)
|
||||
S SAM(44,"?+1,",1912)=15 ; Length of Appt (not used)
|
||||
S SAM(44,"?+1,",1917)=4 ; Display increments per hour (not used)
|
||||
S SAM(44,"?+1,",1918)=8 ; Overbooks/day max (not used)
|
||||
S SAM(44,"?+1,",2000.5)=0 ; Require Action Profiles: Yes (not used)
|
||||
S SAM(44,"?+1,",2001)=999 ; Allowable consecutive no-shows (not used)
|
||||
S SAM(44,"?+1,",2002)=999 ; Max # days for Future Booking (not used)
|
||||
S SAM(44,"?+1,",2005)=365 ; Max # days for Auto Rebook (not used)
|
||||
S SAM(44,"?+1,",2502)="N" ; Non-Count Clinic (not used)
|
||||
S SAM(44,"?+1,",2504)="Y" ; Clinic meets at this Facility? (not used)
|
||||
S SAM(44,"?+1,",2507)=9 ; Appointment Type (not used)
|
||||
;
|
||||
N BSDXERR,BSDXIEN
|
||||
D UPDATE^DIE("",$NA(SAM),$NA(BSDXIEN),$NA(BSDXERR))
|
||||
Q $S($D(BSDXERR):-1_U_BSDXERR("DIERR",1,"TEXT",1),1:BSDXIEN(1))
|
||||
;
|
||||
UTCRRES(NAME,HLIEN) ; $$ - Create Unit Test Resource in 9002018.1 (BSDX RESOURCE); Private
|
||||
; Input: Hospital Location IEN
|
||||
; Output: -1^Error or IEN for Success
|
||||
; DO NOT USE IN A PRODUCTION ENVIRONTMENT. INTENDED FOR TESTING ONLY
|
||||
I $D(^BSDXRES("B",NAME)) Q $O(^(NAME,""))
|
||||
S HLIEN=$G(HLIEN) ; If we don't send one in
|
||||
N RES ; garbage variable
|
||||
D RSRC^BSDX16(.RES,"|"_NAME_"||"_HLIEN)
|
||||
N RTN S RTN=@$Q(^BSDXTMP($J,0)) ; return array next value
|
||||
Q $S(RTN=0:-1_U_RTN,1:+RTN) ; 0 means an error has occurred; 1 means IEN returned
|
||||
;
|
||||
TIMES() ; $$ - Create a next available appointment time^ending time; Private
|
||||
N NOW S NOW=$$NOW^XLFDT() ; Now time
|
||||
N LAST S LAST=$O(^BSDXAPPT("B"," "),-1) ; highest time in file
|
||||
N TIME2USE S TIME2USE=$S(NOW>LAST:NOW,1:LAST) ; Which time to use?
|
||||
S TIME2USE=$E(TIME2USE,1,12) ; Strip away seconds
|
||||
N APPTIME S APPTIME=$$FMADD^XLFDT(TIME2USE,0,0,15,0) ; Add 15 min
|
||||
N ENDTIME S ENDTIME=$$FMADD^XLFDT(APPTIME,0,0,15,0) ; Add 15 more min
|
||||
Q APPTIME_U_ENDTIME ; quit with apptime^endtime
|
Loading…
Reference in New Issue