BSDX25 refactoring, continued

This commit is contained in:
sam 2012-06-29 23:09:55 +00:00
parent 494017259d
commit 86db419104
6 changed files with 153 additions and 65 deletions

View File

@ -1,71 +1,88 @@
BSDX25 ; VW/UJO/SMH - WINDOWS SCHEDULING RPCS ; 6/28/12 11:45am
;;1.6;BSDX;;Aug 31, 2011;Build 18
BSDX25 ; VEN/SMH - WINDOWS SCHEDULING RPCS ; 6/29/12 12:04pm
;;1.7T1;BSDX;;Aug 31, 2011;Build 18
; Licensed under LGPL
;
; Change Log:
; 3110106: SMH -> Changed Check-in EP - Removed unused paramters. Will change C#
;
;
CHECKIND(BSDXY,BSDXAPTID,BSDXCDT,BSDXCC,BSDXPRV,BSDXROU,BSDXVCL,BSDXVFM,BSDXOG) ;EP
CHECKIND(BSDXY,BSDXAPPTID,BSDXCDT,BSDXCC,BSDXPRV,BSDXROU,BSDXVCL,BSDXVFM,BSDXOG) ;EP
;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,BSDXAPPTID,BSDXCDT,BSDXCC,BSDXPRV,BSDXROU,BSDXVCL,BSDXVFM,BSDXOG)",$P(^BSDXDBUG("BREAK"),U,2))
Q
;
CHECKIN(BSDXY,BSDXAPTID,BSDXCDT) ;Private EP Check in appointment
CHECKIN(BSDXY,BSDXAPPTID,BSDXCDT) ;Private EP Check in appointment
; Old additional vars: ,BSDXCC,BSDXPRV,BSDXROU,BSDXVCL,BSDXVFM,BSDXOG)
; Called by RPC: BSDX CHECKIN APPOINTMENT
;
; Private to GUI; use BSDXAPI for general API to checkin patients
; Parameters:
; BSDXY: Global Out
; BSDXAPTID: Appointment ID in ^BSDXAPPT
; BSDXAPPTID: Appointment ID in ^BSDXAPPT
; BSDXCDT: Checkin Date --> Changed
; BSDXCC: Clinic Stop IEN (not used)
; BSDXPRV: Provider IEN (not used)
; BSDXROU: Print Routing Slip? (not used)
; BSDXVCL: PCC+ Clinic IEN (not used)
; BSDXVFM: PCC+ Form IEN (not used)
; BSDXOG: PCC+ Outguide (true or false)
; BSDXOG: PCC+ Outguide (true or false) (not used)
;
; Output:
; ADO.net table with 1 column ErrorID, 1 row result
; - 0 if all okay
; - Another number or text if not
;
N BSDXNOD,BSDXPATID,BSDXSTART,DIK,DA,BSDXID,BSDXZ,BSDXIENS,BSDXVEN
;
; Turn off SDAM Appointment Events BSDX Protocol Processing
N BSDXNOEV
S BSDXNOEV=1 ;Don't execute protocol
;
; Set min DUZ vars
D ^XBKVAR
D ^XBKVAR
;
; $ET
N $ET S $ET="G ERROR^BSDX25"
;
N BSDXI S BSDXI=0
K ^BSDXTMP($J)
S BSDXY="^BSDXTMP("_$J_")"
;
S BSDXY=$NAME(^BSDXTMP($J))
K @BSDXY
;
S ^BSDXTMP($J,0)="T00020ERRORID"_$C(30)
I '+BSDXAPTID D ERR("BSDX25: Invalid Appointment ID") Q
I '$D(^BSDXAPPT(BSDXAPTID,0)) D ERR("BSDX08: Invalid Appointment ID") Q
;
I '+BSDXAPPTID D ERR("Invalid Appointment ID") QUIT
I '$D(^BSDXAPPT(BSDXAPPTID,0)) D ERR("Invalid Appointment ID") QUIT
;
; Lock the node for synchronizing access to appointment
LOCK +^BSDXAPPT(BSDXAPPTID):1
ELSE DO ERR("-7~Lock not acquired") QUIT
;
; Remove Date formatting v.1.5. Client will send date as FM Date.
;S:BSDXCDT["@0000" BSDXCDT=$P(BSDXCDT,"@")
;S %DT="T",X=BSDXCDT D ^%DT S BSDXCDT=Y
S BSDXCDT=+BSDXCDT ; Strip off zeros if C# sends them
I BSDXCDT=-1 D ERR(70) Q
I BSDXCDT>$$NOW^XLFDT S BSDXCDT=$$NOW^XLFDT
;Checkin BSDX APPOINTMENT entry
D BSDXCHK(BSDXAPTID,BSDXCDT)
S BSDXNOD=^BSDXAPPT(BSDXAPTID,0)
S BSDXPATID=$P(BSDXNOD,U,5)
S BSDXSTART=$P(BSDXNOD,U)
;
S BSDXSC1=$P(BSDXNOD,U,7) ;RESOURCEID
I BSDXSC1]"",$D(^BSDXRES(BSDXSC1,0)) D I +$G(BSDXZ) D ERR($P(BSDXZ,U,2)) Q
. S BSDXNOD=^BSDXRES(BSDXSC1,0)
. S BSDXSC1=$P(BSDXNOD,U,4) ;HOSPITAL LOCATION
. I BSDXSC1]"",$D(^SC(BSDXSC1,0)) D APCHK(.BSDXZ,BSDXSC1,BSDXPATID,BSDXCDT,BSDXSTART)
;Checkin BSDX APPOINTMENT entry
N BSDXERR S BSDXERR=$$BSDXCHK(BSDXAPPTID,BSDXCDT)
I BSDXERR D ERR("BSDX08: Fileman Filer failed to check-in appt") QUIT
;
N BSDXNOD S BSDXNOD=^BSDXAPPT(BSDXAPPTID,0)
N BSDXPATID S BSDXPATID=$P(BSDXNOD,U,5)
N BSDXSTART S BSDXSTART=$P(BSDXNOD,U)
;
; Get Hospital Location IEN from BSDXAPPT to BSDXRES (RESOUCE:HOSPITAL LOCATION)
N BSDXSC1 S BSDXSC1=$$GET1^DIQ(9002018.4,BSDXAPPTID_",",".07:.04","I")
I BSDXSC1,'$D(^SC(BSDXSC1,0)) S BSDXSC1="" ; Null it off if it doesn't exist
;
; File check-in using BSDXAPI
N BSDXERR S BSDXERR=0
I BSDXSC1 S BSDXERR=$$CHECKIN1^BSDXAPI(BSDXPATID,BSDXSC1,BSDXSTART)
I BSDXERR D ERR($P(BSDXZ,U,2)) QUIT
;
; Unlock
LOCK -^BSDXAPPT(BSDXAPPTID)
;
S BSDXI=BSDXI+1
S ^BSDXTMP($J,BSDXI)="0"_$C(30)
@ -73,21 +90,23 @@ CHECKIN(BSDXY,BSDXAPTID,BSDXCDT) ;Private EP Check in appointment
S ^BSDXTMP($J,BSDXI)=$C(31)
Q
;
BSDXCHK(BSDXAPTID,BSDXCDT) ;
BSDXCHK(BSDXAPPTID,BSDXCDT) ; $$ Private Entry Point. File or delete check-in to
; BSDX Appointment
; Input: BSDXAPPTID -> Appointment ID
; BSDXCDT -> Check-in date, or "@" to remove check-in.
;
S BSDXIENS=BSDXAPTID_","
; Output: 1^Error for error
; 0 for success
;
N BSDXIENS,BSDXMSG,BSDXFDA ; Filer variables
S BSDXIENS=BSDXAPPTID_","
S BSDXFDA(9002018.4,BSDXIENS,.03)=BSDXCDT
D FILE^DIE("","BSDXFDA","BSDXMSG")
Q
;
APCHK(BSDXZ,BSDXSC1,BSDXDFN,BSDXCDT,BSDXSTART) ;
;Checkin appointment for patient BSDXDFN in clinic BSDXSC1
;at time BSDXSTART
S BSDXZ=$$CHECKIN1^BSDXAPI(BSDXDFN,BSDXSC1,BSDXSTART)
Q
Q:$D(BSDXMSG) 1_U_BSDXMSG("DIERR",1,"TEXT",1)
Q 0
;
RMCI(BSDXY,BSDXAPPTID) ; EP - Remove Check-in from BSDX APPT and 2/44
; Called by RPC [Fill in later]
; Called by RPC BSDX REMOVE CHECK-IN
;
; Parameters to pass:
; APPTID: IEN in file BSDX APPOINTMENT
@ -102,6 +121,8 @@ 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)
; -4~DB has corruption. Call Tech Support. (Resource ID in BSDXAPPT doesnt exist in BSDXRES)
; -5~BSDXAPI Error. Message depends on error.
; -6~Data Filing Error in BSDXCHK
; -7~Lock not acquired
; -100~Mumps Error
;
N BSDXNOEV S BSDXNOEV=1 ;Don't execute protocol
@ -116,20 +137,20 @@ RMCI(BSDXY,BSDXAPPTID) ; EP - Remove Check-in from BSDX APPT and 2/44
;
S ^BSDXTMP($J,BSDXI)="T00020ERRORID"_$C(30) ; Header of ADO recordset
;
TSTART (BSDXI):SERIAL ; Perform Autolocking
;
;;;test
I $g(bsdxdie) S X=8/0
;;;
I $g(bsdxrestart) k bsdxrestart TRESTART
;;;test
I $G(BSDXDIE) N X S X=8/0
;
; Check for Appointment ID (passed and exists in file)
I '+$G(BSDXAPPTID) D ERR("-1~Invalid Appointment ID") QUIT
I '$D(^BSDXAPPT(BSDXAPPTID,0)) D ERR("-2~Invalid Appointment ID") QUIT
;
; Lock the node for synchronizing access to appointment
LOCK +^BSDXAPPT(BSDXAPPTID):1
ELSE DO ERR("-7~Lock not acquired") QUIT
;
; Remove checkin from BSDX APPOINTMENT entry
D BSDXCHK(BSDXAPPTID,"@")
N BSDXERR S BSDXERR=$$BSDXCHK(BSDXAPPTID,"@")
I BSDXERR D ERR("-6~Cannot file data in $$BSDXCHK") QUIT
;
; Now, remove checkin from PIMS files 2/44
N BSDXNOD S BSDXNOD=^BSDXAPPT(BSDXAPPTID,0)
@ -148,7 +169,8 @@ RMCI(BSDXY,BSDXAPPTID) ; EP - Remove Check-in from BSDX APPT and 2/44
I BSDXSC1]"",$D(^SC(BSDXSC1,0)) S BSDXZ=$$RMCI^BSDXAPI(BSDXPATID,BSDXSC1,BSDXSTART)
I +$G(BSDXZ) D ERR("-5~"_$P(BSDXZ,U,2)) QUIT
;
TCOMMIT ; Save Data into Globals
; Unlock
LOCK -^BSDXAPPT(BSDXAPPTID)
;
; Return ADO recordset
S BSDXI=BSDXI+1
@ -182,9 +204,11 @@ CHKEVT1(BSDXRES,BSDXSTART,BSDXPAT,BSDXSTAT) ;
Q:'+$G(BSDXRES) BSDXFOUND
Q:'$D(^BSDXAPPT("ARSRC",BSDXRES,BSDXSTART)) BSDXFOUND
S BSDXAPPT=0 F S BSDXAPPT=$O(^BSDXAPPT("ARSRC",BSDXRES,BSDXSTART,BSDXAPPT)) Q:'+BSDXAPPT D Q:BSDXFOUND
. S BSDXNOD=$G(^BSDXAPPT(BSDXAPPT,0)) Q:BSDXNOD=""
. N BSDXNOD S BSDXNOD=$G(^BSDXAPPT(BSDXAPPT,0)) Q:BSDXNOD=""
. I $P(BSDXNOD,U,5)=BSDXPAT,$P(BSDXNOD,U,12)="" S BSDXFOUND=1 Q
I BSDXFOUND,+$G(BSDXAPPT) D BSDXCHK(BSDXAPPT,BSDXSTAT)
I BSDXFOUND,+$G(BSDXAPPT) D
. N BSDXERR S BSDXERR=$$BSDXCHK(BSDXAPPT,BSDXSTAT)
. I BSDXERR D ^%ZTER ; VEN/SMH - This is silent. This is a last resort
Q BSDXFOUND
;
CHKEVT3(BSDXRES) ;
@ -199,8 +223,6 @@ CHKEVT3(BSDXRES) ;
;
ERROR ;
S $ETRAP="D ^%ZTER HALT" ; Emergency Error Trap for the wise
; Rollback, otherwise ^XTER will be empty from future rollback
I $TL>0 TROLLBACK
D ^%ZTER
S $EC="" ; Clear Error
; Log error message and send to client
@ -208,7 +230,7 @@ ERROR ;
Q
;
ERR(BSDXERR) ;Error processing
I $TLEVEL>0 TROLLBACK
I $G(BSDXAPPTID) LOCK -^BSDXAPPT(BSDXAPPTID)
S BSDXERR=$G(BSDXERR)
S BSDXERR=$P(BSDXERR,"~")_"~"_$TEXT(+0)_":"_$P(BSDXERR,"~",2) ; Append Routine Name
S BSDXI=$G(BSDXI)+1

View File

@ -1,4 +1,4 @@
BSDXAPI ; IHS/ANMC/LJF & VW/SMH - SCHEDULING APIs ; 6/26/12 4:55pm
BSDXAPI ; IHS/ANMC/LJF & VW/SMH - SCHEDULING APIs ; 6/29/12 12:19pm
;;1.7T1;BSDX;;Aug 31, 2011;Build 18
; Licensed under LGPL
;

View File

@ -1,4 +1,4 @@
BSDXAPI1 ; VEN/SMH - SCHEDULING APIs - Continued!!! ; 6/27/12 4:45pm
BSDXAPI1 ; VEN/SMH - SCHEDULING APIs - Continued!!! ; 6/29/12 11:52am
;;1.7T1;BSDX;;Aug 31, 2011;Build 18
; Licensed under LGPL
;
@ -55,3 +55,65 @@ NOSHOWCK(PAT,CLINIC,DATE,NSFLAG) ; $$ PEP; No-show Check
; 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
;
RMCI(PAT,CLINIC,DATE) ;PEP; -- Remove Check-in; $$
; PAT = DFN
; CLINIC = SC IEN
; DATE = FM Date/Time of Appointment
;
; Returns:
; 0 if okay
; -1 if failure
;
; Call like this: $$RMCI(233,33,3110102.1130)
;
; Move my variables into the ones used by SDAPIs (just a convenience)
NEW SDATA,DFN,SDT,SDCL,SDDA,SDCIHDL,SDMODE
S DFN=PAT,SDT=DATE,SDCL=CLINIC,SDMODE=2,SDDA=$$SCIEN^BSDXAPI(DFN,SDCL,SDT)
;
I SDDA<1 QUIT 0 ; Appt cancelled; cancelled appts rm'ed from file 44
;
; remember before status
S SDCIHDL=$$HANDLE^SDAMEVT(1),SDATA=SDDA_U_DFN_U_SDT_U_SDCL
D BEFORE^SDAMEVT(.SDATA,DFN,SDT,SDCL,SDDA,SDCIHDL)
;
; remove check-in using filer.
N BSDXIENS S BSDXIENS=SDDA_","_DATE_","_CLINIC_","
N BSDXFDA
S BSDXFDA(44.003,BSDXIENS,309)="@" ; CHECKED-IN
S BSDXFDA(44.003,BSDXIENS,302)="@" ; CHECK IN USER
S BSDXFDA(44.003,BSDXIENS,305)="@" ; CHECK IN ENTERED
N BSDXERR
D FILE^DIE("","BSDXFDA","BSDXERR")
I $D(BSDXERR) QUIT "-1~Can't file for Pat "_PAT_" in Clinic "_CLINIC_" at "_DATE_". Fileman reported an error: "_BSDXERR("DIERR",1,"TEXT",1)
;
; set after status
; S SDDA=$$SCIEN(DFN,SDCL,SDT) ;smh -why is this here? SDDA won't change.
S SDCIHDL=$$HANDLE^SDAMEVT(1),SDATA=SDDA_U_DFN_U_SDT_U_SDCL
D AFTER^SDAMEVT(.SDATA,DFN,SDT,SDCL,SDDA,SDCIHDL)
;
; call event driver
D EVT^SDAMEVT(.SDATA,4,SDMODE,SDCIHDL)
QUIT 0
;
UPDATENT(PAT,CLINIC,DATE,NOTE) ; PEP; Update Note in ^SC for patient's appointment @ DATE
; PAT = DFN
; CLINIC = SC IEN
; DATE = FM Date/Time of Appointment
;
; Returns:
; 0 if okay
; -1 if failure
;
; ERROR SIMULATION
I $G(BSDXSIMERR1) QUIT "-1~Simulated Error"
;
N SCIEN S SCIEN=$$SCIEN^BSDXAPI(PAT,CLINIC,DATE) ; ien of appt in ^SC
I SCIEN<1 QUIT 0 ; Appt cancelled; cancelled appts rm'ed from file 44
N BSDXIENS S BSDXIENS=SCIEN_","_DATE_","_CLINIC_","
N BSDXFDA S BSDXFDA(44.003,BSDXIENS,3)=$E(NOTE,1,150)
N BSDXERR
D FILE^DIE("","BSDXFDA","BSDXERR")
I $D(BSDXERR) QUIT "-1~Can't file for Pat "_PAT_" in Clinic "_CLINIC_" at "_DATE_". Fileman reported an error: "_BSDXERR("DIERR",1,"TEXT",1)
QUIT 0
;

View File

@ -1,10 +1,13 @@
BSDXUT ; VEN/SMH - Unit Tests for Scheduling GUI ; 6/28/12 10:14am
BSDXUT ; VEN/SMH - Unit Tests for Scheduling GUI ; 6/29/12 12:20pm
;;1.7T1;BSDX;;Aug 31, 2011;Build 18
; Licensed under LGPL
;
; Change Log:
; June 21 2012: Initial Version
;
EN ; Run all Unit Tests
D UT07
QUIT
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

View File

@ -1,7 +1,11 @@
BSDXUT1 ; VEN/SMH - Unit Tests for Scheduling GUI - cont. ; 6/28/12 10:17am
BSDXUT1 ; VEN/SMH - Unit Tests for Scheduling GUI - cont. ; 6/29/12 12:32pm
;;1.7T1;BSDX;;Aug 31, 2011;Build 18
;
;
EN ; Run All Unit Tests in this routine
D UT08,UT29,UT26,UT31
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
@ -220,8 +224,7 @@ UT29 ; Unit Test for BSDX29
I +^BSDXTMP($J,1)=0 W "Error... task not created",! QUIT
;
W "Waiting for 5 seconds for it to finish",! HANG 5
W ^BSDXTMP("BSDXCOPY",+^BSDXTMP($J,1)),!
W "Last line should say 0",!
W:^BSDXTMP("BSDXCOPY",+^BSDXTMP($J,1))'[" 0 records" "Copy failed",!
QUIT
;
UT26 ; Unit Tests - BSDX26

View File

@ -1,6 +1,10 @@
BSDXUT2 ; VEN/SMH - Unit Tests for Scheduling GUI - cont. ; 6/28/12 11:55am
BSDXUT2 ; VEN/SMH - Unit Tests for Scheduling GUI - cont. ; 6/29/12 12:23pm
;;1.7T1;BSDX;;Aug 31, 2011;Build 18
;
EN ; Run all unit tests in this routine
D UT25
QUIT
;
UT25 ; Unit Tests for BSDX25
; Make appointment, checkin, then uncheckin
N $ET S $ET="W ""An Error Occured. Breaking."",! BREAK"
@ -45,13 +49,10 @@ UT25 ; Unit Tests for BSDX25
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
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",!
K BSDXDIE
;
; Unlinked Clinic Tests
N RESNAM S RESNAM="UTCLINICUL" ; Unlinked Clinic
@ -90,13 +91,10 @@ UT25 ; Unit Tests for BSDX25
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
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",!
K BSDXDIE
;
; Tests for running PIMS by itself.
N APPTTIME S APPTTIME=$$TIMEHL^BSDXUT(HLIEN) ; appt time
@ -112,7 +110,7 @@ UT25 ; Unit Tests for BSDX25
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)
N % S %=$$RMCI^BSDXAPI1(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",!