Refactoring of BSDX26; BSDXAPI has new ep to update note in file 44
This commit is contained in:
parent
3d51d124f2
commit
4c83603835
119
m/BSDX26.m
119
m/BSDX26.m
|
@ -1,55 +1,130 @@
|
||||||
BSDX26 ; IHS/OIT/HMW - WINDOWS SCHEDULING RPCS ;
|
BSDX26 ; IHS/OIT/HMW - WINDOWS SCHEDULING RPCS ; 11/18/10 5:36pm
|
||||||
;;1.41;BSDX;;Sep 29, 2010
|
;;1.42;BSDX;;Sep 29, 2010
|
||||||
|
; Change History:
|
||||||
|
; 3101023 - UJO/SMH - Addition of restartable transaction; relocation of tx.
|
||||||
|
; --> Thanks to Zach Gonzalez and Rick Marshall
|
||||||
|
; 3101205 - UJO/SMH - Extensive refactoring.
|
||||||
;
|
;
|
||||||
|
; Error Reference:
|
||||||
|
; -1: Appt ID is not a number
|
||||||
|
; -2: Appt IEN is not in ^BSDXAPPT
|
||||||
|
; -3: FM Failure to file WP field in ^BSDXAPPT
|
||||||
;
|
;
|
||||||
EDITAPTD(BSDXY,BSDXAPTID,BSDXNOTE) ;EP
|
EDITAPTD(BSDXY,BSDXAPTID,BSDXNOTE) ;EP
|
||||||
;Entry point for debugging
|
;Entry point for debugging
|
||||||
;
|
;
|
||||||
;D DEBUG^%Serenji("EDITAPT^BSDX26(.BSDXY,BSDXAPTID,BSDXNOTE)")
|
D DEBUG^%Serenji("EDITAPT^BSDX26(.BSDXY,BSDXAPTID,BSDXNOTE)")
|
||||||
Q
|
Q
|
||||||
|
UT ; Unit Tests
|
||||||
|
; Test 1: Make sure this damn thing works
|
||||||
|
N ZZZ
|
||||||
|
N %H S %H=$H
|
||||||
|
N NOTE S NOTE="New Note "_%H
|
||||||
|
D EDITAPT(.ZZZ,188,NOTE)
|
||||||
|
I ^BSDXAPPT(188,1,1,0)'=NOTE W "ERROR",! B
|
||||||
|
; Test 2: Test Errors -1 and -2
|
||||||
|
N ZZZ
|
||||||
|
N NOTE S NOTE="Nothing important"
|
||||||
|
D EDITAPT(.ZZZ,"BLAHBLAH",NOTE)
|
||||||
|
I +^BSDXTMP($J,1)'=-1 W "ERROR IN -1",! B
|
||||||
|
D EDITAPT(.ZZZ,298734322,NOTE)
|
||||||
|
I +^BSDXTMP($J,1)'=-2 W "ERROR IN -2",! B
|
||||||
|
; Test 4: M Error
|
||||||
|
N bsdxdie S bsdxdie=1
|
||||||
|
D EDITAPT(.ZZZ,188,NOTE)
|
||||||
|
I +^BSDXTMP($J,1)'=-100 W "ERROR IN -100",! B
|
||||||
|
; Test 5: Trestart
|
||||||
|
N bsdxrestart S bsdxrestart=1
|
||||||
|
N %H S %H=$H
|
||||||
|
N NOTE S NOTE="New Note "_%H
|
||||||
|
D EDITAPT(.ZZZ,188,NOTE)
|
||||||
|
I ^BSDXAPPT(188,1,1,0)'=NOTE W "ERROR in TRESTART",! B
|
||||||
|
; Test for Hosp Location Update
|
||||||
|
N DATE S DATE=$$NOW^XLFDT()
|
||||||
|
D APPADD^BSDX07(.ZZZ,DATE,DATE+.001,3,"Dr Office",30,"Old Note",1)
|
||||||
|
N APPID S APPID=+$P(^BSDXTMP($J,1),U)
|
||||||
|
D EDITAPT(.ZZZ,APTID,"New Note")
|
||||||
|
I ^BSDXAPPT(APTID,1,1,0)'="New Note" W "Error in HL Section",! B
|
||||||
|
I $P(^SC(2,"S",DATE,1,1,0),U,4)'="New Note" W "Error in HL Section",! B
|
||||||
|
QUIT
|
||||||
;
|
;
|
||||||
EDITAPT(BSDXY,BSDXAPTID,BSDXNOTE) ;EP Edit appointment (only note text can be edited)
|
EDITAPT(BSDXY,BSDXAPTID,BSDXNOTE) ;EP Edit appointment (only note text can be edited)
|
||||||
|
; Called by RPC: BSDX EDIT APPOINTMENT
|
||||||
;
|
;
|
||||||
N BSDXNOD,BSDXPATID,BSDXSTART,DIK,DA,BSDXID,BSDXI,BSDXZ,BSDXIENS
|
; Edits Appointment Text in BSDX APPOINTMENT file & Hosp Location (44) file
|
||||||
;
|
;
|
||||||
D ^XBKVAR
|
; Parameters:
|
||||||
S X="ETRAP^BSDX26",@^%ZOSF("TRAP")
|
; - BSDXY: Global Return (RPC must be set to Global Array)
|
||||||
S BSDXI=0
|
; - BSDXAPTID: Appointment IEN in BSDX APPOINTMENT
|
||||||
|
; - BSDXNOTE: New note
|
||||||
|
;
|
||||||
|
; Return:
|
||||||
|
; ADO.net Recordset having 1 field: ERRORID
|
||||||
|
; If Okay: -1; otherwise, positive integer with message
|
||||||
|
;
|
||||||
|
; Return Array; set Return and clear array
|
||||||
|
S BSDXY=$NA(^BSDXTMP($J))
|
||||||
K ^BSDXTMP($J)
|
K ^BSDXTMP($J)
|
||||||
S BSDXY="^BSDXTMP("_$J_")"
|
; ET
|
||||||
|
N $ET S $ET="G ETRAP^BSDX26"
|
||||||
|
; Set up basic DUZ variables
|
||||||
|
D ^XBKVAR
|
||||||
|
; Counter
|
||||||
|
N BSDXI S BSDXI=0
|
||||||
|
; Header Node
|
||||||
S ^BSDXTMP($J,BSDXI)="T00020ERRORID"_$C(30)
|
S ^BSDXTMP($J,BSDXI)="T00020ERRORID"_$C(30)
|
||||||
S BSDXI=BSDXI+1
|
; Restartable txn for GT.M. Restored vars are Params + BSDXI.
|
||||||
TSTART
|
TSTART (BSDXY,BSDXAPTID,BSDXNOTE,BSDXI):T="BSDX EDIT APPOINTMENT^BSDX26"
|
||||||
I '+BSDXAPTID D ERR(BSDXI,"BSDX26: Invalid Appointment ID") Q
|
;
|
||||||
I '$D(^BSDXAPPT(BSDXAPTID,0)) D ERR(BSDXI,"BSDX26: Invalid Appointment ID") Q
|
;;;test for error inside transaction. See if %ZTER works
|
||||||
;Add WP field
|
I $G(bsdxdie) S X=1/0
|
||||||
;I BSDXNOTE]"" S BSDXNOTE(.5)=BSDXNOTE,BSDXNOTE=""
|
;;;test
|
||||||
|
;;;test for TRESTART
|
||||||
|
I $G(bsdxrestart) K bsdxrestart TRESTART
|
||||||
|
;;;test
|
||||||
|
;
|
||||||
|
; Validate Appointment ID
|
||||||
|
I '+BSDXAPTID D ERR(BSDXI,"-1~BSDX26: Invalid Appointment ID") QUIT
|
||||||
|
I '$D(^BSDXAPPT(BSDXAPTID,0)) D ERR(BSDXI,"-2~BSDX26: Invalid Appointment ID") QUIT
|
||||||
|
; Put the WP in decendant fields from the root to file as a WP field
|
||||||
S BSDXNOTE(.5)=BSDXNOTE,BSDXNOTE=""
|
S BSDXNOTE(.5)=BSDXNOTE,BSDXNOTE=""
|
||||||
I $D(BSDXNOTE(0)) S BSDXNOTE(.5)=BSDXNOTE(0) K BSDXNOTE(0)
|
I $D(BSDXNOTE(0)) S BSDXNOTE(.5)=BSDXNOTE(0) K BSDXNOTE(0)
|
||||||
|
N BSDXMSG ; Message in case of error in filing.
|
||||||
I $D(BSDXNOTE(.5)) D
|
I $D(BSDXNOTE(.5)) D
|
||||||
. D WP^DIE(9002018.4,BSDXAPTID_",",1,"","BSDXNOTE","BSDXMSG")
|
. D WP^DIE(9002018.4,BSDXAPTID_",",1,"","BSDXNOTE","BSDXMSG")
|
||||||
|
I $D(BSDXMSG) D ERR(BSDXI,"-3~BSDX26: Fileman failure to file data into 9002018.4") QUIT
|
||||||
;
|
;
|
||||||
|
; Now file in file 44:
|
||||||
|
N PTIEN S PTIEN=$$GET1^DIQ(9002018.4,BSDXAPTID,".05","I") ; Patient IEN
|
||||||
|
N HLIEN S HLIEN=$$GET1^DIQ(9002018.4,BSDXAPTID,".07:.04","I") ; HL Location IEN pointed to by Resource ID
|
||||||
|
N DATE S DATE=+^BSDXAPPT(BSDXAPTID,0) ; Date of APPT
|
||||||
|
N BSDXRES S BSDXRES=0 ; Result
|
||||||
|
; Update Note only if we have a linked hospital location.
|
||||||
|
I HLIEN S BSDXRES=$$UPDATENOTE^BSDXAPI(PTIEN,HLIEN,DATE,BSDXNOTE(.5))
|
||||||
|
; If we get an error (denoted by -1 in BSDXRES), return error to client
|
||||||
|
I BSDXRES<0 D ERR(BSDXI,"-4~BSDX26: BSDXAPI reports an error: "_BSDXRES) QUIT
|
||||||
;Return Recordset
|
;Return Recordset
|
||||||
TCOMMIT
|
TCOMMIT
|
||||||
S BSDXI=BSDXI+1
|
S BSDXI=BSDXI+1
|
||||||
S ^BSDXTMP($J,BSDXI)="-1"_$C(30)
|
S ^BSDXTMP($J,BSDXI)="-1"_$C(30)
|
||||||
S BSDXI=BSDXI+1
|
S BSDXI=BSDXI+1
|
||||||
S ^BSDXTMP($J,BSDXI)=$C(31)
|
S ^BSDXTMP($J,BSDXI)=$C(31)
|
||||||
Q
|
QUIT
|
||||||
;
|
|
||||||
;
|
;
|
||||||
ERR(BSDXI,BSDXERR) ;Error processing
|
ERR(BSDXI,BSDXERR) ;Error processing
|
||||||
S BSDXI=BSDXI+1
|
S BSDXI=BSDXI+1
|
||||||
TROLLBACK
|
S BSDXERR=$TR(BSDXERR,"^","~")
|
||||||
|
I $TL>0 TROLLBACK
|
||||||
S ^BSDXTMP($J,BSDXI)=BSDXERR_$C(30)
|
S ^BSDXTMP($J,BSDXI)=BSDXERR_$C(30)
|
||||||
S BSDXI=BSDXI+1
|
S BSDXI=BSDXI+1
|
||||||
S ^BSDXTMP($J,BSDXI)=$C(31)
|
S ^BSDXTMP($J,BSDXI)=$C(31)
|
||||||
Q
|
QUIT
|
||||||
;
|
;
|
||||||
ETRAP ;EP Error trap entry
|
ETRAP ;EP Error trap entry
|
||||||
TROLLBACK
|
N $ET S $ET="D ^%ZTER HALT" ; Emergency Error Trap
|
||||||
|
I $TL>0 TROLLBACK
|
||||||
D ^%ZTER
|
D ^%ZTER
|
||||||
I '$D(BSDXI) N BSDXI S BSDXI=999999
|
S $EC=""
|
||||||
S BSDXI=BSDXI+1
|
I '$D(BSDXI) N BSDXI S BSDXI=0
|
||||||
D ERR(BSDXI,"BSDX26 Error: "_$G(%ZTERROR))
|
D ERR(BSDXI,"-100~BSDX26 Error: "_$G(%ZTERZE))
|
||||||
Q
|
Q
|
||||||
|
|
20
m/BSDXAPI.m
20
m/BSDXAPI.m
|
@ -1,4 +1,4 @@
|
||||||
BSDXAPI ; IHS/ANMC/LJF - SCHEDULING APIs ; 11/2/10 4:36pm
|
BSDXAPI ; IHS/ANMC/LJF - SCHEDULING APIs ; 11/18/10 5:34pm
|
||||||
;;1.42;BSDX;;Sep 29, 2010;Build 7
|
;;1.42;BSDX;;Sep 29, 2010;Build 7
|
||||||
;Orignal routine is BSDAPI by IHS/LJF, HMW, and MAW
|
;Orignal routine is BSDAPI by IHS/LJF, HMW, and MAW
|
||||||
;local mods (many) by WV/SMH
|
;local mods (many) by WV/SMH
|
||||||
|
@ -8,6 +8,8 @@ BSDXAPI ; IHS/ANMC/LJF - SCHEDULING APIs ; 11/2/10 4:36pm
|
||||||
; - Use new style Fileman API for storing appointments in file 44 in $$MAKE due to problems with legacy API.
|
; - Use new style Fileman API for storing appointments in file 44 in $$MAKE due to problems with legacy API.
|
||||||
; 2010-11-12:
|
; 2010-11-12:
|
||||||
; - Changed ="C" to ["C" in SCIEN. Cancelled appointments can be "PC" as well.
|
; - Changed ="C" to ["C" in SCIEN. Cancelled appointments can be "PC" as well.
|
||||||
|
; 2010-12-5
|
||||||
|
; Added an entry point to update the patient note in file 44.
|
||||||
;
|
;
|
||||||
MAKE1(DFN,CLIN,TYP,DATE,LEN,INFO) ; Simplified PEP w/ parameters for $$MAKE - making appointment
|
MAKE1(DFN,CLIN,TYP,DATE,LEN,INFO) ; Simplified PEP w/ parameters for $$MAKE - making appointment
|
||||||
; Call like this for DFN 23435 having an appointment at Hospital Location 33
|
; Call like this for DFN 23435 having an appointment at Hospital Location 33
|
||||||
|
@ -275,3 +277,19 @@ CO(PAT,CLINIC,DATE,SDIEN) ;PEP; -- returns 1 if appt already checked-out
|
||||||
S X=$P($G(^SC(CLINIC,"S",DATE,1,X,"C")),U,3)
|
S X=$P($G(^SC(CLINIC,"S",DATE,1,X,"C")),U,3)
|
||||||
Q $S(X:1,1:0)
|
Q $S(X:1,1:0)
|
||||||
;
|
;
|
||||||
|
UPDATENOTE(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
|
||||||
|
N SCIEN S SCIEN=$$SCIEN(PAT,CLINIC,DATE) ; ien of appt in ^SC
|
||||||
|
I SCIEN<1 QUIT "-1~No Appt can be found in file 44 for Patient "_PAT_" on "_DATE_" in clinic "_CLINIC
|
||||||
|
N BSDXIENS S BSDXIENS=SCIEN_","_DATE_","_CLINIC_","
|
||||||
|
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
|
||||||
|
|
Loading…
Reference in New Issue