Done refactoring BSDX31 plus all Unit Tests
This commit is contained in:
parent
00c73491bd
commit
f2c57b4774
44
m/BSDX31.m
44
m/BSDX31.m
|
@ -1,4 +1,4 @@
|
|||
BSDX31 ; IHS/OIT/HMW - WINDOWS SCHEDULING RPCS ; 6/26/12 4:35pm
|
||||
BSDX31 ; IHS/OIT/HMW - WINDOWS SCHEDULING RPCS ; 6/27/12 4:57pm
|
||||
;;1.7T1;BSDX;;Aug 31, 2011;Build 18
|
||||
; Licensed under LGPL
|
||||
; Change Log:
|
||||
|
@ -9,6 +9,8 @@ BSDX31 ; IHS/OIT/HMW - WINDOWS SCHEDULING RPCS ; 6/26/12 4:35pm
|
|||
; as $$NOSHOW
|
||||
; - Made BSDXNOS extrinsic.
|
||||
; - Moved Unit Tests to BSDXUT1
|
||||
; - BSDXNOS deletes no-show rather than file 0 for
|
||||
; undoing a no show
|
||||
;
|
||||
; Error Reference:
|
||||
; -1: zero or null Appt ID
|
||||
|
@ -84,20 +86,34 @@ NOSHOW(BSDXY,BSDXAPTID,BSDXNS) ;EP - No show a patient
|
|||
; Get the Hospital Location
|
||||
N BSDXRESNOD S BSDXRESNOD=^BSDXRES(BSDXRES,0)
|
||||
N BSDXLOC S BSDXLOC=$P(BSDXRESNOD,U,4) ;HOSPITAL LOCATION
|
||||
I '$D(^SC(BSDXLOC,0)) S BSDXLOC="" ; Unlink it if it doesn't exist
|
||||
; I can go and then delete it from BSDXLOC like Mailman code which tries
|
||||
; to be too helpful... but I will postpone that until this is need it.
|
||||
I BSDXLOC,'$D(^SC(BSDXLOC,0)) S BSDXLOC="" ; Unlink it if it doesn't exist
|
||||
; I can go and then delete it from ^BSDXRES like Mailman code which tries
|
||||
; to be too helpful... but I will postpone that until this is a need.
|
||||
;
|
||||
; Edit BSDX APPOINTMENT entry
|
||||
N BSDXMSG S BSDXMSG=$$BSDXNOS(BSDXAPTID,BSDXNS) ;Edit BSDX APPOINTMENT entry NOSHOW field
|
||||
; Check if it's okay to no-show patient.
|
||||
N BSDXERR S BSDXERR=0 ; Error variable
|
||||
I BSDXLOC S BSDXERR=$$NOSHOWCK^BSDXAPI1(BSDXPATID,BSDXLOC,BSDXSTART,BSDXNS)
|
||||
I BSDXERR D ERR(-5,"BSDX31: "_$P(BSDXERR,U,2)) QUIT
|
||||
;
|
||||
; Simulated Error
|
||||
I $G(BSDXSIMERR1) D ERR(-4,"BSDX31: Simulated Error") QUIT
|
||||
; Edit BSDX APPOINTMENT entry No-show field
|
||||
; Failure Analysis: If we fail here, no rollback needed, as this is the 1st
|
||||
; call
|
||||
N BSDXMSG S BSDXMSG=$$BSDXNOS(BSDXAPTID,BSDXNS)
|
||||
I BSDXMSG D ERR(-4,"BSDX31: "_$P(BSDXMSG,U,2)) QUIT
|
||||
;
|
||||
; Edit File 2 "S" node entry
|
||||
N BSDXERR ; Error variable
|
||||
; Failure Analysis: If we fail here, we need to rollback the BSDX
|
||||
; Apptointment Entry
|
||||
N BSDXERR S BSDXERR=0 ; Error variable
|
||||
; If HL exist, (resource is linked to PIMS), file no show in File 2
|
||||
I BSDXLOC S BSDXERR=$$NOSHOW^BSDXAPI1(BSDXPATID,BSDXLOC,BSDXSTART,BSDXNS)
|
||||
I BSDXERR D ERR(-5,"BSDX31: "_$P(BSDXERR,U,2)) QUIT
|
||||
I BSDXERR D QUIT
|
||||
. D ERR(-5,"BSDX31: "_$P(BSDXERR,U,2))
|
||||
. N % S %=$$BSDXNOS(BSDXAPTID,'BSDXNS) ; no error checking for filer
|
||||
;
|
||||
; Return data in ADO.net table
|
||||
S BSDXI=BSDXI+1
|
||||
S ^BSDXTMP($J,BSDXI)="1^"_$C(30) ; 1 means everything okay
|
||||
S BSDXI=BSDXI+1
|
||||
|
@ -105,9 +121,13 @@ NOSHOW(BSDXY,BSDXAPTID,BSDXNS) ;EP - No show a patient
|
|||
QUIT
|
||||
;
|
||||
BSDXNOS(BSDXAPTID,BSDXNS) ; $$ Private; File/unfile noshow in ^BSDXAPPT
|
||||
; in v1.7 I delete the no-show value rather than file zero
|
||||
N BSDXFDA,BSDXIENS,BSDXMSG
|
||||
N BSDXVALUE ; What to file: 1 or delete it.
|
||||
I BSDXNS S BSDXVALUE=1
|
||||
E S BSDXVALUE="@"
|
||||
S BSDXIENS=BSDXAPTID_","
|
||||
S BSDXFDA(9002018.4,BSDXIENS,.1)=BSDXNS ;NOSHOW
|
||||
S BSDXFDA(9002018.4,BSDXIENS,.1)=BSDXVALUE ;NOSHOW 1 or 0
|
||||
D FILE^DIE("","BSDXFDA","BSDXMSG")
|
||||
QUIT:$D(BSDXMSG) -1_U_BSDXMSG("DIERR",1,"TEXT",1)
|
||||
QUIT 0
|
||||
|
@ -156,6 +176,8 @@ NOSEVT3(BSDXRES) ;
|
|||
;
|
||||
;
|
||||
ERR(BSDXERID,ERRTXT) ;Error processing
|
||||
; If last line is $C(31), we are done. No more errors to send to client.
|
||||
I ^BSDXTMP($J,$O(^BSDXTMP($J," "),-1))=$C(31) QUIT
|
||||
S BSDXI=BSDXI+1
|
||||
S ERRTXT=$TR(ERRTXT,"^","~")
|
||||
S ^BSDXTMP($J,BSDXI)=BSDXERID_"^"_ERRTXT_$C(30)
|
||||
|
@ -165,13 +187,13 @@ ERR(BSDXERID,ERRTXT) ;Error processing
|
|||
;
|
||||
ETRAP ;EP Error trap entry
|
||||
N $ET S $ET="D ^%ZTER HALT" ; Emergency Error Trap
|
||||
I $G(BSDXAPTID),$D(BSDXNS) N % S %=$$BSDXNOS(BSDXAPTID,'BSDXNS) ; Reverse No-Show status (whatever it was)
|
||||
D ^%ZTER
|
||||
S $EC="" ; Clear Error
|
||||
I $G(BSDXAPTID),$D(BSDXNS) N % S %=$$BSDXNOS(BSDXAPTID,'BSDXNS) ; Reverse No-Show status (whatever it was)
|
||||
; Send to client
|
||||
I '$D(BSDXI) N BSDXI S BSDXI=0
|
||||
D ERR(-100,"BSDX31 Error: "_$G(%ZTERZE))
|
||||
QUIT
|
||||
Q:$Q 100_U_"Mumps Error" Q
|
||||
;
|
||||
IMHERE(BSDXRES) ;EP
|
||||
;Entry point for BSDX IM HERE remote procedure
|
||||
|
|
32
m/BSDXAPI1.m
32
m/BSDXAPI1.m
|
@ -1,4 +1,4 @@
|
|||
BSDXAPI1 ; VEN/SMH - SCHEDULING APIs - Continued!!! ; 6/26/12 4:32pm
|
||||
BSDXAPI1 ; VEN/SMH - SCHEDULING APIs - Continued!!! ; 6/27/12 4:45pm
|
||||
;;1.7T1;BSDX;;Aug 31, 2011;Build 18
|
||||
; Licensed under LGPL
|
||||
;
|
||||
|
@ -6,15 +6,25 @@ NOSHOW(PAT,CLINIC,DATE,NSFLAG) ; $$ PEP; No-show Patient at appt date (new in v1
|
|||
; PAT = DFN
|
||||
; CLINIC = SC IEN
|
||||
; DATE = FM Date/Time of Appointment
|
||||
; NSFLAG = truthy value to add no-show, or falsy to remove
|
||||
; -1^error for failure, 0 for success
|
||||
; NSFLAG = truthy value to add no-show, or falsy to remove (use 1 or 0 pls!)
|
||||
; 1^error for failure, 0 for success
|
||||
; Code follows EN1^SDN
|
||||
;
|
||||
; Check for failure conditions first before doing this. No globals set here
|
||||
N NOSHOWCK S NOSHOWCK=$$NOSHOWCK(PAT,CLINIC,DATE,NSFLAG)
|
||||
I NOSHOWCK Q NOSHOWCK
|
||||
;
|
||||
; Set up Protocol Driver
|
||||
N SDNSHDL,SDDA S SDNSHDL=$$HANDLE^SDAMEVT(1) S SDDA=$$SCIEN^BSDXAPI(PAT,CLINIC,DATE)
|
||||
N SDATA
|
||||
D BEFORE^SDAMEVT(.SDATA,PAT,DATE,CLINIC,SDDA,SDNSHDL)
|
||||
D BEFORE^SDAMEVT(.SDATA,PAT,DATE,CLINIC,SDDA,SDNSHDL) ; Only ^TMP set here.
|
||||
;
|
||||
; Simulated Errors
|
||||
Q:$D(BSDXSIMERR2) 1_U_"Simulated Error"
|
||||
;
|
||||
; Edit the ^DPT( "S" node entry - Noshow or undo noshow
|
||||
; Failure analysis: if we fail here, we presume no change happened in
|
||||
; ^DPT(DA,"S", and so we just have to roll back ^BSDXAPPT
|
||||
N BSDXIENS S BSDXIENS=DATE_","_PAT_","
|
||||
N BSDXFDA
|
||||
I +NSFLAG D
|
||||
|
@ -28,8 +38,20 @@ NOSHOW(PAT,CLINIC,DATE,NSFLAG) ; $$ PEP; No-show Patient at appt date (new in v1
|
|||
N BSDXMSG
|
||||
D FILE^DIE("","BSDXFDA","BSDXMSG")
|
||||
Q:$D(BSDXMSG) 1_U_"Fileman edit to DPT error: Patient="_PAT_" Appt="_DATE_" Error="_BSDXMSG("DIERR",1,"TEXT",1)
|
||||
;
|
||||
; This M error trigger tests if ^BSDXAPPT rolls back.
|
||||
; I won't try to roll back ^DPT(,"S"
|
||||
; The M error is caused here, so if I try to rollback, I can cause another
|
||||
; error. Infinite Errors then.
|
||||
I $D(BSDXSIMERR3) N X S X=1/0
|
||||
;
|
||||
; Run the event driver
|
||||
D NOSHOW^SDAMEVT(.SDATA,PAT,DATE,CLINIC,SDDA,0,SDNSHDL)
|
||||
Q 0
|
||||
;
|
||||
NOSHOWCK(PAT,CLINIC,DATE,NSFLAG) ; $$ PEP; No-show Check
|
||||
; pars are the same as above
|
||||
; TODO: Not all appointments can be no showed.
|
||||
; Check the code in SDAMN
|
||||
; S SDSTB=$$STATUS^SDAM1(DFN,SDT,SDCL,$G(^DPT(DFN,"S",SDT,0))) ; before status
|
||||
; Q:'$$CHK ; Checks $D(^SD(409.63,"ANS",1,+SDSTB))
|
||||
QUIT 0
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
BSDXUT ; VEN/SMH - Unit Tests for Scheduling GUI ; 6/26/12 11:06am
|
||||
BSDXUT ; VEN/SMH - Unit Tests for Scheduling GUI ; 6/27/12 4:18pm
|
||||
;;1.7T1;BSDX;;Aug 31, 2011;Build 18
|
||||
; Licensed under LGPL
|
||||
;
|
||||
|
@ -206,7 +206,7 @@ UT07 ; Unit Tests for BSDX07 - Assumes you have Patients with DFNs 1,2,3,4,5
|
|||
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",!
|
||||
I +$P(^BSDXTMP($J,1),U,2)'=-10 W "Error in -10 in Unlinked Section (existing bug)",!
|
||||
;
|
||||
; Test that ROLLBACK^BSDX07 occurs properly in various places
|
||||
N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
|
||||
|
|
72
m/BSDXUT1.m
72
m/BSDXUT1.m
|
@ -1,4 +1,4 @@
|
|||
BSDXUT1 ; VEN/SMH - Unit Tests for Scheduling GUI - cont. ; 6/26/12 4:36pm
|
||||
BSDXUT1 ; VEN/SMH - Unit Tests for Scheduling GUI - cont. ; 6/27/12 4:59pm
|
||||
;;1.7T1;BSDX;;Aug 31, 2011;Build 18
|
||||
;
|
||||
;
|
||||
|
@ -226,7 +226,7 @@ UT31 ; Unit Tests for BSDX31
|
|||
I $P(^DPT(DFN,"S",APPTTIME,0),U,2)'="N" W "ERROR T1",!
|
||||
; Test 2: Undo NOSHOW
|
||||
D NOSHOW^BSDX31(.ZZZ,APPID,0)
|
||||
I $P(^BSDXAPPT(APPID,0),U,10)'="0" W "ERROR T2",!
|
||||
I $P(^BSDXAPPT(APPID,0),U,10)'="" W "ERROR T2",!
|
||||
I $P(^DPT(DFN,"S",APPTTIME,0),U,2)'="" W "ERROR T2",!
|
||||
; Test 3: -1
|
||||
D NOSHOW^BSDX31(.ZZZ,"",0)
|
||||
|
@ -242,8 +242,70 @@ UT31 ; Unit Tests for BSDX31
|
|||
D NOSHOW^BSDX31(.ZZZ,APPID,1)
|
||||
I $P(^BSDXTMP($J,1),U)'=-100 W "ERROR T6",!
|
||||
K BSDXDIE
|
||||
; Test 7: Restartable transaction
|
||||
N BSDXRESTART S BSDXRESTART=1
|
||||
;
|
||||
; Test 9
|
||||
; Error Simulations
|
||||
; 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)
|
||||
;
|
||||
; This tests if we fail without filing anything
|
||||
N ZZZ,DFN
|
||||
S DFN=3
|
||||
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
|
||||
N APPID S APPID=+$P(^BSDXTMP($J,1),U)
|
||||
N BSDXSIMERR1 S BSDXSIMERR1=1
|
||||
D NOSHOW^BSDX31(.ZZZ,APPID,1)
|
||||
I $P(^BSDXAPPT(APPID,0),U,10)'=1 W "ERROR T7",!
|
||||
I $P(^BSDXTMP($J,1),U)'=-4 W "ERROR T9.1",!
|
||||
I $P(^BSDXAPPT(APPID,0),U,10)'="" W "ERROR T9.2",!
|
||||
I $P(^DPT(DFN,"S",APPTTIME,0),U,2)'="" W "ERROR T9.3",!
|
||||
K BSDXSIMERR1
|
||||
;
|
||||
; This tests if we fail inside BSDXAPI and have to rollback ^BSDXAPPT
|
||||
N BSDXSIMERR2 S BSDXSIMERR2=1
|
||||
D NOSHOW^BSDX31(.ZZZ,APPID,1)
|
||||
I $P(^BSDXTMP($J,1),U)'=-5 W "ERROR T9.4",!
|
||||
I $P(^BSDXAPPT(APPID,0),U,10)'="" W "ERROR T9.5",!
|
||||
I $P(^DPT(DFN,"S",APPTTIME,0),U,2)'="" W "ERROR T9.6",!
|
||||
K BSDXSIMERR2
|
||||
;
|
||||
; This test a mumps error in BSDXAPI
|
||||
N BSDXSIMERR3 S BSDXSIMERR3=1
|
||||
D NOSHOW^BSDX31(.ZZZ,APPID,1)
|
||||
I +$P(^BSDXTMP($J,1),U)'=-100 W "ERROR T9.7",!
|
||||
I $P(^BSDXAPPT(APPID,0),U,10)'="" W "ERROR T9.8",!
|
||||
K BSDXSIMERR3
|
||||
;
|
||||
; Test 7: Restartable transaction ; Retired
|
||||
;
|
||||
; Test 8: 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)
|
||||
;
|
||||
; Make appt
|
||||
N ZZZ,DFN
|
||||
S DFN=3
|
||||
D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
|
||||
N APPID S APPID=+$P(^BSDXTMP($J,1),U)
|
||||
; Test 1: Sanity Check
|
||||
D NOSHOW^BSDX31(.ZZZ,APPID,1)
|
||||
I $P(^BSDXAPPT(APPID,0),U,10)'=1 W "ERROR T8.1",!
|
||||
; Test 2: Undo NOSHOW
|
||||
D NOSHOW^BSDX31(.ZZZ,APPID,0)
|
||||
I $P(^BSDXAPPT(APPID,0),U,10)'="" W "ERROR T8.2",!
|
||||
; Test 3: Put it back on...
|
||||
D NOSHOW^BSDX31(.ZZZ,APPID,1)
|
||||
I $P(^BSDXAPPT(APPID,0),U,10)'=1 W "ERROR T8.3",!
|
||||
;
|
||||
;
|
||||
QUIT
|
||||
|
|
Loading…
Reference in New Issue