Refactoring and txn restart fix to routines 26,29,31
This commit is contained in:
parent
882f7bad40
commit
2f21f07db7
|
@ -1,4 +1,4 @@
|
||||||
BSDX26 ; IHS/OIT/HMW - WINDOWS SCHEDULING RPCS ; 11/18/10 5:36pm
|
BSDX26 ; IHS/OIT/HMW - WINDOWS SCHEDULING RPCS ; 12/6/10 3:08am
|
||||||
;;1.42;BSDX;;Sep 29, 2010
|
;;1.42;BSDX;;Sep 29, 2010
|
||||||
; Change History:
|
; Change History:
|
||||||
; 3101023 - UJO/SMH - Addition of restartable transaction; relocation of tx.
|
; 3101023 - UJO/SMH - Addition of restartable transaction; relocation of tx.
|
||||||
|
@ -33,17 +33,19 @@ UT ; Unit Tests
|
||||||
N bsdxdie S bsdxdie=1
|
N bsdxdie S bsdxdie=1
|
||||||
D EDITAPT(.ZZZ,188,NOTE)
|
D EDITAPT(.ZZZ,188,NOTE)
|
||||||
I +^BSDXTMP($J,1)'=-100 W "ERROR IN -100",! B
|
I +^BSDXTMP($J,1)'=-100 W "ERROR IN -100",! B
|
||||||
|
k bsdxdie
|
||||||
; Test 5: Trestart
|
; Test 5: Trestart
|
||||||
N bsdxrestart S bsdxrestart=1
|
N bsdxrestart S bsdxrestart=1
|
||||||
N %H S %H=$H
|
N %H S %H=$H
|
||||||
N NOTE S NOTE="New Note "_%H
|
N NOTE S NOTE="New Note "_%H
|
||||||
D EDITAPT(.ZZZ,188,NOTE)
|
D EDITAPT(.ZZZ,188,NOTE)
|
||||||
I ^BSDXAPPT(188,1,1,0)'=NOTE W "ERROR in TRESTART",! B
|
I ^BSDXAPPT(188,1,1,0)'=NOTE W "ERROR in TRESTART",! B
|
||||||
; Test for Hosp Location Update
|
; Test 6: for Hosp Location Update
|
||||||
N DATE S DATE=$$NOW^XLFDT()
|
N DATE S DATE=$$NOW^XLFDT()
|
||||||
|
S DATE=$E(DATE,1,12) ; Just get minutes b/c of HL file input transform
|
||||||
D APPADD^BSDX07(.ZZZ,DATE,DATE+.001,3,"Dr Office",30,"Old Note",1)
|
D APPADD^BSDX07(.ZZZ,DATE,DATE+.001,3,"Dr Office",30,"Old Note",1)
|
||||||
N APPID S APPID=+$P(^BSDXTMP($J,1),U)
|
N APPID S APPID=+$P(^BSDXTMP($J,1),U)
|
||||||
D EDITAPT(.ZZZ,APTID,"New Note")
|
D EDITAPT(.ZZZ,APPID,"New Note")
|
||||||
I ^BSDXAPPT(APTID,1,1,0)'="New Note" W "Error in HL Section",! B
|
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
|
I $P(^SC(2,"S",DATE,1,1,0),U,4)'="New Note" W "Error in HL Section",! B
|
||||||
QUIT
|
QUIT
|
||||||
|
|
135
m/BSDX29.m
135
m/BSDX29.m
|
@ -1,79 +1,92 @@
|
||||||
BSDX29 ; IHS/OIT/HMW - WINDOWS SCHEDULING RPCS ; 7/18/10 2:03pm
|
BSDX29 ; IHS/OIT/HMW - WINDOWS SCHEDULING RPCS ; 12/6/10 6:05am
|
||||||
;;1.41;BSDX;;Sep 29, 2010
|
;;1.42;BSDX;;Sep 29, 2010
|
||||||
;
|
;
|
||||||
; Change Log:
|
; Change Log:
|
||||||
; v1.3 by WV/SMH on 3100713
|
; v1.3 by WV/SMH on 3100713
|
||||||
; - Beginning and Ending dates passed as FM Dates
|
; - Beginning and Ending dates passed as FM Dates
|
||||||
|
; v1.42 by WV/SMH on 3101023
|
||||||
|
; - Transaction moved; now restartable too.
|
||||||
|
; --> Thanks to Zach Gonzalez and Rick Marshall.
|
||||||
|
; - Refactoring of major portions of routine
|
||||||
;
|
;
|
||||||
BSDXCPD(BSDXY,BSDXRES,BSDX44,BSDXBEG,BSDXEND) ;EP
|
BSDXCPD(BSDXY,BSDXRES,BSDX44,BSDXBEG,BSDXEND) ;EP
|
||||||
;Entry point for debugging
|
;Entry point for debugging
|
||||||
;
|
;
|
||||||
;D DEBUG^%Serenji("BSDXCP^BSDX29(.BSDXY,BSDXRES,BSDX44,BSDXBEG,BSDXEND)")
|
D DEBUG^%Serenji("BSDXCP^BSDX29(.BSDXY,BSDXRES,BSDX44,BSDXBEG,BSDXEND)")
|
||||||
Q
|
Q
|
||||||
;
|
;
|
||||||
BSDXCP(BSDXY,BSDXRES,BSDX44,BSDXBEG,BSDXEND) ;EP
|
BSDXCP(BSDXY,BSDXRES,BSDX44,BSDXBEG,BSDXEND) ;EP
|
||||||
;Copy appointments from HOSPITAL LOCATION entry BSDX44 to BSDX RESOURCE entry BSDXRES
|
;Copy appointments from HOSPITAL LOCATION entry BSDX44 to BSDX RESOURCE entry BSDXRES
|
||||||
;Beginning with appointments on day BSDXBEG and ending on BSDXEND, inclusive
|
;Beginning with appointments on day BSDXBEG and ending on BSDXEND, inclusive
|
||||||
|
;Called by RPC: BSDX COPY APPOINTMENTS
|
||||||
;
|
;
|
||||||
;Returns ADO Recordset formatted fields containing count of records copied and error message:
|
; Parameters:
|
||||||
;
|
; - BSDXY: Global Return
|
||||||
; July 13 2010: D dates (BEG and END) from US format to FM Dates for i18n
|
; - BSDXRES: BSDX RESOURCE to copy appointments to
|
||||||
|
; - BSDX44: Hospital Location IEN to copy appointments from
|
||||||
|
; - BSDXBEG: Beginning Date in FM Format
|
||||||
|
; - BSDXEND: End Date in FM Format
|
||||||
|
;
|
||||||
|
;Returns ADO Recordset containing TASK_NUMBER and ERRORID
|
||||||
;
|
;
|
||||||
;
|
; Return Array
|
||||||
S BSDXY="^BSDXTMP("_$J_")"
|
S BSDXY=$NA(^BSDXTMP($J))
|
||||||
N BSDXI,BSDXST,ZTSK
|
K ^BSDXTMP($J)
|
||||||
S BSDXI=0
|
; $ET
|
||||||
S X="ETRAP^BSDX29",@^%ZOSF("TRAP")
|
N $ET S $ET="G ETRAP^BSDX29"
|
||||||
|
; Counter
|
||||||
|
N BSDXI S BSDXI=0
|
||||||
|
; Header Node
|
||||||
S ^BSDXTMP($J,0)="T00010TASK_NUMBER^T00020ERRORID"_$C(30)
|
S ^BSDXTMP($J,0)="T00010TASK_NUMBER^T00020ERRORID"_$C(30)
|
||||||
;
|
;
|
||||||
;Convert beginning and ending dates
|
; Make dates inclusive; add 1 to FM dates
|
||||||
;
|
S BSDXBEG=BSDXBEG-1
|
||||||
;TODO:Validate FM Dates coming through
|
|
||||||
;
|
|
||||||
S BSDXBEG=BSDXBEG-1
|
|
||||||
S BSDXEND=BSDXEND+1
|
S BSDXEND=BSDXEND+1
|
||||||
;
|
;
|
||||||
|
; Taskman variables
|
||||||
|
N ZTSK,ZTRTN,ZTDTH,ZTDESC,ZTSAVE
|
||||||
|
; Task Load
|
||||||
S ZTRTN="ZTM^BSDX29",ZTDTH=$H,ZTDESC="COPY PATIENT APPTS"
|
S ZTRTN="ZTM^BSDX29",ZTDTH=$H,ZTDESC="COPY PATIENT APPTS"
|
||||||
S ZTSAVE("BSDXBEG")="",ZTSAVE("BSDXEND")="",ZTSAVE("BSDX44")="",ZTSAVE("BSDXRES")=""
|
S ZTSAVE("BSDXBEG")="",ZTSAVE("BSDXEND")="",ZTSAVE("BSDX44")="",ZTSAVE("BSDXRES")=""
|
||||||
D ^%ZTLOAD
|
D ^%ZTLOAD
|
||||||
;
|
; Set up return ADO.net dataset
|
||||||
|
N BSDXST S BSDXST=$S($G(ZTSK)>0:"OK",1:"Unable to create task.")
|
||||||
S BSDXI=BSDXI+1
|
S BSDXI=BSDXI+1
|
||||||
S BSDXST=$S($G(ZTSK)>0:"OK",1:"Unable to create task.")
|
|
||||||
S ^BSDXTMP($J,BSDXI)=$G(ZTSK)_"^"_BSDXST_$C(30)_$C(31)
|
S ^BSDXTMP($J,BSDXI)=$G(ZTSK)_"^"_BSDXST_$C(30)_$C(31)
|
||||||
Q
|
QUIT
|
||||||
;
|
|
||||||
ZTMTST ;
|
|
||||||
;
|
|
||||||
S %DT="AE" D ^%DT S BSDXBEG=Y
|
|
||||||
S %DT="AE" D ^%DT S BSDXEND=Y
|
|
||||||
S BSDX44=3,BSDXSRES=1,ZTSK=3380
|
|
||||||
D ZTM
|
|
||||||
Q
|
|
||||||
;
|
;
|
||||||
ZTMD ;EP - Debug entry point
|
ZTMD ;EP - Debug entry point
|
||||||
;D DEBUG^%Serenji("ZTM^BSDX29")
|
;D DEBUG^%Serenji("ZTM^BSDX29")
|
||||||
Q
|
Q
|
||||||
;
|
;
|
||||||
ZTM ;EP
|
ZTM ;EP - Taskman entry point
|
||||||
;Taskman entry point
|
; Variables set up in ZTSAVE above
|
||||||
S X="ZTMERR^BSDX29",@^%ZOSF("TRAP")
|
;
|
||||||
;$O through ^SC(BSDX44,"S",
|
|
||||||
Q:'$D(ZTSK)
|
Q:'$D(ZTSK)
|
||||||
N BSDXCNT,BSDXIEN,BSDXNOD,BSDXNOTE,BSDXCAN,BSDXPAT,BSDXLEN,BSDXMADE,BSDXCLRK,BSDXPAT,BSDXQUIT
|
; $ET
|
||||||
S BSDXCNT=0,BSDXQUIT=0
|
N $ET S $ET="G ZTMERR^BSDX29"
|
||||||
S ^BSDXTMP("BSDXCOPY",ZTSK)=BSDXCNT
|
; Txn
|
||||||
TSTART
|
TSTART (BSDXBEG,BSDXEND,BSDX44,BSDXRES):T="BSDX COPY APPOINTMENT^BSDX29"
|
||||||
F S BSDXBEG=$O(^SC(BSDX44,"S",BSDXBEG)) Q:'+BSDXBEG Q:BSDXBEG>BSDXEND Q:BSDXQUIT D
|
;$O through ^SC(BSDX44,"S",
|
||||||
. S BSDXIEN=0 F S BSDXIEN=$O(^SC(BSDX44,"S",BSDXBEG,1,BSDXIEN)) Q:'+BSDXIEN Q:BSDXQUIT D
|
N BSDXCNT S BSDXCNT=0 ; Count of Copied Appointments
|
||||||
. . S BSDXNOD=$G(^SC(BSDX44,"S",BSDXBEG,1,BSDXIEN,0))
|
N BSDXQUIT S BSDXQUIT=0 ; Quit Flag to be retrieved from an external proc
|
||||||
. . Q:'+BSDXNOD
|
; Set Count
|
||||||
. . S BSDXCAN=$P(BSDXNOD,U,9)
|
S ^BSDXTMP("BSDXCOPY",ZTSK)=BSDXCNT
|
||||||
. . Q:BSDXCAN="C"
|
; Loop through dates here.
|
||||||
. . S BSDXPAT=$P(BSDXNOD,U)
|
F S BSDXBEG=$O(^SC(BSDX44,"S",BSDXBEG)) Q:'+BSDXBEG Q:BSDXBEG>BSDXEND Q:BSDXQUIT D
|
||||||
. . S BSDXLEN=$P(BSDXNOD,U,2) ;duration in minutes
|
. ; Loop through Entries in each date in the subsubfile.
|
||||||
. . S BSDXCLRK=$P(BSDXNOD,U,6) ;appt made by (clerk)
|
. ; Quit if we are at the end or if a remote process requests a quit.
|
||||||
. . S BSDXMADE=$P(BSDXNOD,U,7) ;date appt made
|
. N BSDXIEN S BSDXIEN=0
|
||||||
. . S BSDXNOTE=$P(BSDXNOD,U,4) ;'OTHER' field contains note
|
. F S BSDXIEN=$O(^SC(BSDX44,"S",BSDXBEG,1,BSDXIEN)) Q:'+BSDXIEN Q:BSDXQUIT D
|
||||||
|
. . N BSDXNOD S BSDXNOD=$G(^SC(BSDX44,"S",BSDXBEG,1,BSDXIEN,0)) ; Node
|
||||||
|
. . Q:'+BSDXNOD ; Quit if no node
|
||||||
|
. . N BSDXCAN S BSDXCAN=$P(BSDXNOD,U,9) ; Cancel flag
|
||||||
|
. . Q:BSDXCAN="C" ; Quit if appt cancelled
|
||||||
|
. . N BSDXPAT S BSDXPAT=$P(BSDXNOD,U) ; Patient
|
||||||
|
. . N BSDXLEN S BSDXLEN=$P(BSDXNOD,U,2) ;duration in minutes
|
||||||
|
. . N BSDXCLRK S BSDXCLRK=$P(BSDXNOD,U,6) ;appt made by (clerk)
|
||||||
|
. . N BSDXMADE S BSDXMADE=$P(BSDXNOD,U,7) ;date appt made
|
||||||
|
. . N BSDXNOTE S BSDXNOTE=$P(BSDXNOD,U,4) ;'OTHER' field contains note
|
||||||
. . S BSDXCNT=BSDXCNT+$$XFER(BSDXRES,BSDXBEG,BSDXPAT,BSDXLEN,BSDXCLRK,BSDXMADE,BSDXNOTE)
|
. . S BSDXCNT=BSDXCNT+$$XFER(BSDXRES,BSDXBEG,BSDXPAT,BSDXLEN,BSDXCLRK,BSDXMADE,BSDXNOTE)
|
||||||
. . I +BSDXCNT,BSDXCNT#10=0 S ^BSDXTMP("BSDXCOPY",ZTSK)=BSDXCNT_" records copied." ;every 10th record
|
. . I +BSDXCNT,BSDXCNT#10=0 S ^BSDXTMP("BSDXCOPY",ZTSK)=BSDXCNT_" records copied." ;every 10th record
|
||||||
. . I $D(^BSDXTMP("BSDXCOPY",ZTSK,"CANCEL")) S BSDXQUIT=1 ;Check for cancel flag
|
. . I $D(^BSDXTMP("BSDXCOPY",ZTSK,"CANCEL")) S BSDXQUIT=1 ;Check for cancel flag
|
||||||
|
@ -84,10 +97,13 @@ ZTM ;EP
|
||||||
S ^BSDXTMP("BSDXCOPY",ZTSK)=$S(BSDXQUIT:"Cancelled. No records copied.",1:"Finished. "_BSDXCNT_" records copied.")
|
S ^BSDXTMP("BSDXCOPY",ZTSK)=$S(BSDXQUIT:"Cancelled. No records copied.",1:"Finished. "_BSDXCNT_" records copied.")
|
||||||
Q
|
Q
|
||||||
;
|
;
|
||||||
ZTMERR ;
|
ZTMERR ; For now, error from TM is only in trap; not returned to client.
|
||||||
TROLLBACK
|
N $ET S $ET="D ^%ZTER HALT" ; Emergency Error Trap
|
||||||
|
; Rollback before logging the error
|
||||||
|
I $TL>0 TROLLBACK
|
||||||
D ^%ZTER
|
D ^%ZTER
|
||||||
Q
|
S $EC="" ; Clear Error
|
||||||
|
QUIT
|
||||||
;
|
;
|
||||||
XFER(BSDXRES,BSDXBEG,BSDXPAT,BSDXLEN,BSDXCLRK,BSDXMADE,BSDXNOTE) ;EP
|
XFER(BSDXRES,BSDXBEG,BSDXPAT,BSDXLEN,BSDXCLRK,BSDXMADE,BSDXNOTE) ;EP
|
||||||
;
|
;
|
||||||
|
@ -131,19 +147,22 @@ XFER(BSDXRES,BSDXBEG,BSDXPAT,BSDXLEN,BSDXCLRK,BSDXMADE,BSDXNOTE) ;EP
|
||||||
;
|
;
|
||||||
ERR(BSDXI,BSDXCNT,BSDXERR) ;Error processing
|
ERR(BSDXI,BSDXCNT,BSDXERR) ;Error processing
|
||||||
S BSDXI=BSDXI+1
|
S BSDXI=BSDXI+1
|
||||||
|
S BSDXERR=$TR(BSDXERR,"^","~")
|
||||||
S ^BSDXTMP($J,BSDXI)=BSDXCNT_"^"_BSDXERR_$C(30)
|
S ^BSDXTMP($J,BSDXI)=BSDXCNT_"^"_BSDXERR_$C(30)
|
||||||
S BSDXI=BSDXI+1
|
S BSDXI=BSDXI+1
|
||||||
S ^BSDXTMP($J,BSDXI)=$C(31)
|
S ^BSDXTMP($J,BSDXI)=$C(31)
|
||||||
Q
|
Q
|
||||||
;
|
;
|
||||||
ETRAP ;EP Error trap entry
|
ETRAP ;EP Error trap entry
|
||||||
D ^%ZTER
|
; No Txn here. So don't rollback anything
|
||||||
I '$D(BSDXI) N BSDXI S BSDXI=999
|
N $ET S $ET="D ^%ZTER HALT" ; Emergency Error Trap
|
||||||
S BSDXI=BSDXI+1
|
D ^%ZTER
|
||||||
D ERR(BSDXI,$G(BSDXCNT),"Routine: BSDX29, Error: "_$G(%ZTERROR))
|
S $EC="" ; Clear error
|
||||||
|
I '$D(BSDXI) N BSDXI S BSDXI=0
|
||||||
|
D ERR(BSDXI,$G(BSDXCNT),"~100~BSDX29, Error: "_$G(%ZTERZE))
|
||||||
Q
|
Q
|
||||||
;
|
;
|
||||||
CPSTAT(BSDXY,BSDXTSK) ;EP
|
CPSTAT(BSDXY,BSDXTSK) ;EP - Note: As of Dec 6 2010: Inactive Code
|
||||||
;Return status (copied record count) of tasked job having ZTSK=BSDXTSK
|
;Return status (copied record count) of tasked job having ZTSK=BSDXTSK
|
||||||
;
|
;
|
||||||
S BSDXY="^BSDXTMP("_$J_")"
|
S BSDXY="^BSDXTMP("_$J_")"
|
||||||
|
@ -159,7 +178,7 @@ CPSTAT(BSDXY,BSDXTSK) ;EP
|
||||||
S ^BSDXTMP($J,BSDXI)=BSDXCNT_"^"_"OK"_$C(30)_$C(31)
|
S ^BSDXTMP($J,BSDXI)=BSDXCNT_"^"_"OK"_$C(30)_$C(31)
|
||||||
Q
|
Q
|
||||||
;
|
;
|
||||||
CPCANC(BSDXY,BSDXTSK) ;EP
|
CPCANC(BSDXY,BSDXTSK) ;EP Note: As of Dec 6 2010: Inactive code.
|
||||||
;Signal tasked job having ZTSK=BSDXTSK to cancel
|
;Signal tasked job having ZTSK=BSDXTSK to cancel
|
||||||
;Returns current record count of copy process
|
;Returns current record count of copy process
|
||||||
;
|
;
|
||||||
|
|
345
m/BSDX31.m
345
m/BSDX31.m
|
@ -1,151 +1,194 @@
|
||||||
BSDX31 ; IHS/OIT/HMW - WINDOWS SCHEDULING RPCS ;
|
BSDX31 ; IHS/OIT/HMW - WINDOWS SCHEDULING RPCS ; 12/6/10 8:25am
|
||||||
;;1.41;BSDX;;Sep 29, 2010
|
;;1.42;BSDX;;Sep 29, 2010
|
||||||
;
|
; Change Log:
|
||||||
;
|
; v1.42 Oct 23 2010 WV/SMH
|
||||||
NOSHOWD(BSDXY,BSDXAPTID,BSDXNS) ;EP
|
; - Change transaction to restartable. Thanks to Zach Gonzalez
|
||||||
;Entry point for debugging
|
; --> and Rick Marshall for their help.
|
||||||
;
|
; v1.42 Dec 6 2010: Extensive refactoring
|
||||||
;D DEBUG^%Serenji("NOSHOW^BSDX31(.BSDXY,BSDXAPTID,BSDXNS)")
|
;
|
||||||
Q
|
; Error Reference:
|
||||||
;
|
; -1: zero or null Appt ID
|
||||||
NOSHOW(BSDXY,BSDXAPTID,BSDXNS) ;EP
|
; -2: Invalid APPT ID (doesn't exist in ^BSDXAPPT)
|
||||||
;Called by BSDX NOSHOW
|
; -3: No-show flag is invalid
|
||||||
;Sets appointment noshow flag in BSDX APPOINTMENT file
|
; -100: M Error
|
||||||
;BSDXAPTID is entry number in BSDX APPOINTMENT file
|
;
|
||||||
;BSDXNS = 1: NOSHOW, 0: CANCEL NOSHO
|
;
|
||||||
;Calls CANCEL^BSDAPI to set noshow data in ^DPT
|
NOSHOWD(BSDXY,BSDXAPTID,BSDXNS) ;EP
|
||||||
;Returns error code in recordset field ERRORID
|
;Entry point for debugging
|
||||||
;
|
;
|
||||||
N BSDXNOD,BSDXPATID,BSDXSTART,BSDXID,BSDXI,BSDXZ,BSDXERR,BSDXMSG,BSDXFDA,BSDXIENS
|
D DEBUG^%Serenji("NOSHOW^BSDX31(.BSDXY,BSDXAPTID,BSDXNS)")
|
||||||
N BSDXNOEV
|
Q
|
||||||
S BSDXNOEV=1 ;Don't execute protocol
|
;
|
||||||
;
|
UT ; Unit Tests
|
||||||
D ^XBKVAR S X="ETRAP^BSDX31",@^%ZOSF("TRAP")
|
; Test 1: Sanity Check
|
||||||
S BSDXI=0
|
N ZZZ ; Garbage return variable
|
||||||
K ^BSDXTMP($J)
|
N DATE S DATE=$$NOW^XLFDT()
|
||||||
S BSDXY="^BSDXTMP("_$J_")"
|
S DATE=$E(DATE,1,12) ; Just get minutes b/c of HL file input transform
|
||||||
S ^BSDXTMP($J,BSDXI)="I00020ERRORID^T00030ERRORTEXT"_$C(30)
|
D APPADD^BSDX07(.ZZZ,DATE,DATE+.0001,3,"Dr Office",30,"Old Note",1)
|
||||||
S BSDXI=BSDXI+1
|
N APPID S APPID=+$P(^BSDXTMP($J,1),U)
|
||||||
TSTART
|
D NOSHOW(.ZZZ,APPID,1)
|
||||||
I '+BSDXAPTID D ERR(0,"BSDX31: Invalid Appointment ID") Q
|
I $P(^BSDXAPPT(APPID,0),U,10)'=1 W "ERROR T1",! B
|
||||||
I '$D(^BSDXAPPT(BSDXAPTID,0)) D ERR(0,"BSDX31: Invalid Appointment ID") Q
|
I $P(^DPT(3,"S",DATE,0),U,2)'="N" W "ERROR T1",! B
|
||||||
S BSDXNS=+BSDXNS
|
; Test 2: Undo noshow
|
||||||
I BSDXNS'=1&(BSDXNS'=0) D ERR(0,"BSDX31: Invalid No Show value") Q
|
D NOSHOW(.ZZZ,APPID,0)
|
||||||
;
|
I $P(^BSDXAPPT(APPID,0),U,10)'="0" W "ERROR T2",! B
|
||||||
;Edit BSDX APPOINTMENT entry NOSHOW field
|
I $P(^DPT(3,"S",DATE,0),U,2)'="" W "ERROR T2",! B
|
||||||
S BSDXNOD=^BSDXAPPT(BSDXAPTID,0)
|
; Test 3: -1
|
||||||
I BSDXNOD="" D ERR(0,"BSDX31: Invalid Appointment ID") Q
|
D NOSHOW(.ZZZ,"",0)
|
||||||
S BSDXPATID=$P(BSDXNOD,U,5)
|
I $P(^BSDXTMP($J,1),U)'=-1 W "ERROR T3",! B
|
||||||
S BSDXSTART=$P(BSDXNOD,U)
|
; Test 4: -2
|
||||||
;
|
D NOSHOW(.ZZZ,2938748233,0)
|
||||||
D BSDXNOS(BSDXAPTID,BSDXNS)
|
I $P(^BSDXTMP($J,1),U)'=-2 W "ERROR T4",! B
|
||||||
I $D(BSDXMSG("DIERR")) S BSDXMSG=$G(BSDXMSG("DIERR",1,"TEXT",1)) D ERR(0,"BSDX31: "_BSDXMSG) Q
|
QUIT
|
||||||
;
|
NOSHOW(BSDXY,BSDXAPTID,BSDXNS) ;EP - No show a patient
|
||||||
S BSDXSC1=$P(BSDXNOD,U,7) ;RESOURCEID
|
; Called by RPC: BSDX NOSHOW
|
||||||
I BSDXSC1]"",$D(^BSDXRES(BSDXSC1,0)) D I $G(BSDXZ)]"" S BSDXERR="BSDX31: APNOSHO Returned: "_BSDXZ D ERR(0,BSDXERR) Q
|
; Sets appointment noshow flag in BSDX APPOINTMENT file and "S" node in File 2
|
||||||
. S BSDXNOD=^BSDXRES(BSDXSC1,0)
|
;
|
||||||
. S BSDXSC1=$P(BSDXNOD,U,4) ;HOSPITAL LOCATION
|
; Parameters:
|
||||||
. I BSDXSC1]"",$D(^SC(BSDXSC1,0)) D APNOSHO(.BSDXZ,BSDXSC1,BSDXPATID,BSDXSTART,BSDXNS)
|
; BSDXY: Global Return
|
||||||
;
|
; BSDXAPTID is entry number in BSDX APPOINTMENT file
|
||||||
TCOMMIT
|
; BSDXNS = 1: NOSHOW, 0: CANCEL NOSHO
|
||||||
S BSDXI=BSDXI+1
|
;
|
||||||
S ^BSDXTMP($J,BSDXI)="1^"_$C(30)
|
; Returns ADO.net record set with fields
|
||||||
S BSDXI=BSDXI+1
|
; - ERRORID; ERRORTEXT
|
||||||
S ^BSDXTMP($J,BSDXI)=$C(31)
|
; ERRORID of 1 is okay
|
||||||
Q
|
; Anything else is an error.
|
||||||
;
|
;
|
||||||
APNOSHO(BSDXZ,BSDXSC1,BSDXDFN,BSDXSD,BSDXNS) ;
|
; Return Array; set and clear
|
||||||
; update file 2 info
|
S BSDXY=$NA(^BSDXTMP($J))
|
||||||
;Set noshow for patient BSDXDFN in clinic BSDXSC1
|
K ^BSDXTMP($J)
|
||||||
;at time BSDXSD
|
; $ET
|
||||||
N BSDXC,%H,BSDXCDT,BSDXIEN
|
N $ET S $ET="G ETRAP^BSDX31"
|
||||||
N BSDXIENS,BSDXFDA,BSDXMSG
|
; Basline vars
|
||||||
S %H=$H D YMD^%DTC
|
D ^XBKVAR ; Set up baseline variables (DUZ, DUZ(2)) if they don't exist
|
||||||
S BSDXCDT=X+%
|
; Counter
|
||||||
;
|
N BSDXI S BSDXI=0
|
||||||
S BSDXIENS=BSDXSD_","_BSDXDFN_","
|
; Header Node
|
||||||
I +BSDXNS D
|
S ^BSDXTMP($J,BSDXI)="I00020ERRORID^T00030ERRORTEXT"_$C(30)
|
||||||
. S BSDXFDA(2.98,BSDXIENS,3)="N"
|
; Begin transaction
|
||||||
. S BSDXFDA(2.98,BSDXIENS,14)=DUZ
|
TSTART (BSDXI,BSDXY,BSDXAPTID,BSDXNS):T="BSDX NOSHOW CANCEL^BSDX29"
|
||||||
. S BSDXFDA(2.98,BSDXIENS,15)=BSDXCDT
|
; Turn off SDAM APPT PROTOCOL BSDX Entries
|
||||||
E D
|
N BSDXNOEV S BSDXNOEV=1 ;Don't execute protocol
|
||||||
. S BSDXFDA(2.98,BSDXIENS,3)=""
|
; Appointment ID check
|
||||||
. S BSDXFDA(2.98,BSDXIENS,14)=""
|
I '+BSDXAPTID D ERR(-1,"BSDX31: Invalid Appointment ID") Q
|
||||||
. S BSDXFDA(2.98,BSDXIENS,15)=""
|
I '$D(^BSDXAPPT(BSDXAPTID,0)) D ERR(-2,"BSDX31: Invalid Appointment ID") Q
|
||||||
K BSDXIEN
|
; Noshow value check - Must be 1 or 0
|
||||||
D UPDATE^DIE("","BSDXFDA","BSDXIEN","BSDXMSG")
|
S BSDXNS=+BSDXNS
|
||||||
S BSDXZ=$G(BSDXMSG("DIERR",1,"TEXT",1))
|
I BSDXNS'=1&(BSDXNS'=0) D ERR(-3,"BSDX31: Invalid No Show value") Q
|
||||||
Q
|
; Get Some data
|
||||||
;
|
N BSDXNOD S BSDXNOD=^BSDXAPPT(BSDXAPTID,0) ; Node
|
||||||
BSDXNOS(BSDXAPTID,BSDXNS) ;
|
N BSDXPATID S BSDXPATID=$P(BSDXNOD,U,5) ; DFN
|
||||||
;
|
N BSDXSTART S BSDXSTART=$P(BSDXNOD,U) ; Start Date/Time
|
||||||
N BSDXFDA,BSDXIENS
|
; Edit BSDX APPOINTMENT entry
|
||||||
S BSDXIENS=BSDXAPTID_","
|
N BSDXMSG ;
|
||||||
S BSDXFDA(9002018.4,BSDXIENS,.1)=BSDXNS ;NOSHOW
|
D BSDXNOS(BSDXAPTID,BSDXNS,.BSDXMSG) ;Edit BSDX APPOINTMENT entry NOSHOW field
|
||||||
D FILE^DIE("","BSDXFDA","BSDXMSG")
|
I $D(BSDXMSG("DIERR")) S BSDXMSG=$G(BSDXMSG("DIERR",1,"TEXT",1)) D ERR(-4,"BSDX31: "_BSDXMSG) Q
|
||||||
;
|
; Edit File 2 "S" node entry
|
||||||
Q
|
N BSDXZ,BSDXERR ; Error variables to control looping
|
||||||
;
|
S BSDXSC1=$P(BSDXNOD,U,7) ;RESOURCEID
|
||||||
NOSEVT(BSDXPAT,BSDXSTART,BSDXSC) ;EP Called by BSDX NOSHOW APPOINTMENT event
|
; If Resource ID exists, and HL exists (means that Resource is linked), No show in File 2
|
||||||
;when appointments NOSHOW via PIMS interface.
|
I BSDXSC1]"",$D(^BSDXRES(BSDXSC1,0)) D I $G(BSDXZ)]"" S BSDXERR="BSDX31: APNOSHO Returned: "_BSDXZ D ERR(-5,BSDXERR) Q
|
||||||
;Propagates NOSHOW to BSDXAPPT and raises refresh event to running GUI clients
|
. S BSDXNOD=^BSDXRES(BSDXSC1,0)
|
||||||
;
|
. S BSDXSC1=$P(BSDXNOD,U,4) ;HOSPITAL LOCATION
|
||||||
Q:+$G(BSDXNOEV)
|
. I BSDXSC1]"",$D(^SC(BSDXSC1,0)) D APNOSHO(.BSDXZ,BSDXSC1,BSDXPATID,BSDXSTART,BSDXNS)
|
||||||
Q:'+$G(BSDXSC)
|
;
|
||||||
Q:$G(SDATA("AFTER","STATUS"))["AUTO RE-BOOK"
|
TCOMMIT
|
||||||
N BSDXSTAT,BSDXFOUND,BSDXRES
|
S BSDXI=BSDXI+1
|
||||||
S BSDXSTAT=1
|
S ^BSDXTMP($J,BSDXI)="1^"_$C(30) ; 1 means everything okay
|
||||||
S:$G(SDATA("BEFORE","STATUS"))["NO-SHOW" BSDXSTAT=0
|
S BSDXI=BSDXI+1
|
||||||
S BSDXFOUND=0
|
S ^BSDXTMP($J,BSDXI)=$C(31)
|
||||||
I $D(^BSDXRES("ALOC",BSDXSC)) S BSDXRES=$O(^BSDXRES("ALOC",BSDXSC,0)) S BSDXFOUND=$$NOSEVT1(BSDXRES,BSDXSTART,BSDXPAT,BSDXSTAT)
|
QUIT
|
||||||
I BSDXFOUND D NOSEVT3(BSDXRES) Q
|
;
|
||||||
I $D(^BXDXRES("ASSOC",BSDXSC)) S BSDXRES=$O(^BSDXRES("ASSOC",BSDXSC,0)) S BSDXFOUND=$$NOSEVT1(BSDXRES,BSDXSTART,BSDXPAT,BSDXSTAT)
|
APNOSHO(BSDXZ,BSDXSC1,BSDXDFN,BSDXSD,BSDXNS) ;
|
||||||
I BSDXFOUND D NOSEVT3(BSDXRES)
|
; update file 2 info
|
||||||
Q
|
;Set noshow for patient BSDXDFN in clinic BSDXSC1
|
||||||
;
|
;at time BSDXSD
|
||||||
NOSEVT1(BSDXRES,BSDXSTART,BSDXPAT,BSDXSTAT) ;
|
N BSDXC,%H,BSDXCDT,BSDXIEN
|
||||||
;Get appointment id in BSDXAPT
|
N BSDXIENS,BSDXFDA,BSDXMSG
|
||||||
;If found, call BSDXNOS(BSDXAPPT) and return 1
|
S %H=$H D YMD^%DTC
|
||||||
;else return 0
|
S BSDXCDT=X+%
|
||||||
N BSDXFOUND,BSDXAPPT
|
;
|
||||||
S BSDXFOUND=0
|
S BSDXIENS=BSDXSD_","_BSDXDFN_","
|
||||||
Q:'+$G(BSDXRES) BSDXFOUND
|
I +BSDXNS D
|
||||||
Q:'$D(^BSDXAPPT("ARSRC",BSDXRES,BSDXSTART)) BSDXFOUND
|
. S BSDXFDA(2.98,BSDXIENS,3)="N"
|
||||||
S BSDXAPPT=0 F S BSDXAPPT=$O(^BSDXAPPT("ARSRC",BSDXRES,BSDXSTART,BSDXAPPT)) Q:'+BSDXAPPT D Q:BSDXFOUND
|
. S BSDXFDA(2.98,BSDXIENS,14)=DUZ
|
||||||
. S BSDXNOD=$G(^BSDXAPPT(BSDXAPPT,0)) Q:BSDXNOD=""
|
. S BSDXFDA(2.98,BSDXIENS,15)=BSDXCDT
|
||||||
. I $P(BSDXNOD,U,5)=BSDXPAT,$P(BSDXNOD,U,12)="" S BSDXFOUND=1 Q
|
E D
|
||||||
I BSDXFOUND,+$G(BSDXAPPT) D BSDXNOS(BSDXAPPT,BSDXSTAT)
|
. S BSDXFDA(2.98,BSDXIENS,3)=""
|
||||||
Q BSDXFOUND
|
. S BSDXFDA(2.98,BSDXIENS,14)=""
|
||||||
;
|
. S BSDXFDA(2.98,BSDXIENS,15)=""
|
||||||
NOSEVT3(BSDXRES) ;
|
K BSDXIEN
|
||||||
;Call RaiseEvent to notify GUI clients
|
D UPDATE^DIE("","BSDXFDA","BSDXIEN","BSDXMSG")
|
||||||
;
|
S BSDXZ=$G(BSDXMSG("DIERR",1,"TEXT",1))
|
||||||
N BSDXRESN
|
Q
|
||||||
S BSDXRESN=$G(^BSDXRES(BSDXRES,0))
|
;
|
||||||
Q:BSDXRESN=""
|
BSDXNOS(BSDXAPTID,BSDXNS,BSDXMSG) ;
|
||||||
S BSDXRESN=$P(BSDXRESN,"^")
|
;
|
||||||
D EVENT^BMXMEVN("BSDX SCHEDULE",BSDXRESN)
|
N BSDXFDA,BSDXIENS
|
||||||
Q
|
S BSDXIENS=BSDXAPTID_","
|
||||||
;
|
S BSDXFDA(9002018.4,BSDXIENS,.1)=BSDXNS ;NOSHOW
|
||||||
;
|
D FILE^DIE("","BSDXFDA","BSDXMSG")
|
||||||
ERR(BSDXERID,ERRTXT) ;Error processing
|
QUIT
|
||||||
S:'+$G(BSDXI) BSDXI=999999
|
;
|
||||||
S BSDXI=BSDXI+1
|
NOSEVT(BSDXPAT,BSDXSTART,BSDXSC) ;EP Called by BSDX NOSHOW APPOINTMENT event
|
||||||
TROLLBACK
|
;when appointments NOSHOW via PIMS interface.
|
||||||
S ^BSDXTMP($J,BSDXI)=BSDXERID_"^"_ERRTXT_$C(30)
|
;Propagates NOSHOW to BSDXAPPT and raises refresh event to running GUI clients
|
||||||
S BSDXI=BSDXI+1
|
;
|
||||||
S ^BSDXTMP($J,BSDXI)=$C(31)
|
Q:+$G(BSDXNOEV)
|
||||||
Q
|
Q:'+$G(BSDXSC)
|
||||||
;
|
Q:$G(SDATA("AFTER","STATUS"))["AUTO RE-BOOK"
|
||||||
ETRAP ;EP Error trap entry
|
N BSDXSTAT,BSDXFOUND,BSDXRES
|
||||||
D ^%ZTER
|
S BSDXSTAT=1
|
||||||
I '$D(BSDXI) N BSDXI S BSDXI=999999
|
S:$G(SDATA("BEFORE","STATUS"))["NO-SHOW" BSDXSTAT=0
|
||||||
S BSDXI=BSDXI+1
|
S BSDXFOUND=0
|
||||||
D ERR(0,"BSDX31 Error: "_$G(%ZTERROR))
|
I $D(^BSDXRES("ALOC",BSDXSC)) S BSDXRES=$O(^BSDXRES("ALOC",BSDXSC,0)) S BSDXFOUND=$$NOSEVT1(BSDXRES,BSDXSTART,BSDXPAT,BSDXSTAT)
|
||||||
Q
|
I BSDXFOUND D NOSEVT3(BSDXRES) Q
|
||||||
;
|
I $D(^BXDXRES("ASSOC",BSDXSC)) S BSDXRES=$O(^BSDXRES("ASSOC",BSDXSC,0)) S BSDXFOUND=$$NOSEVT1(BSDXRES,BSDXSTART,BSDXPAT,BSDXSTAT)
|
||||||
IMHERE(BSDXRES) ;EP
|
I BSDXFOUND D NOSEVT3(BSDXRES)
|
||||||
;Entry point for BSDX IM HERE remote procedure
|
Q
|
||||||
S BSDXRES=1
|
;
|
||||||
Q
|
NOSEVT1(BSDXRES,BSDXSTART,BSDXPAT,BSDXSTAT) ;
|
||||||
;
|
;Get appointment id in BSDXAPT
|
||||||
|
;If found, call BSDXNOS(BSDXAPPT) and return 1
|
||||||
|
;else return 0
|
||||||
|
N BSDXFOUND,BSDXAPPT
|
||||||
|
S BSDXFOUND=0
|
||||||
|
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=""
|
||||||
|
. I $P(BSDXNOD,U,5)=BSDXPAT,$P(BSDXNOD,U,12)="" S BSDXFOUND=1 Q
|
||||||
|
I BSDXFOUND,+$G(BSDXAPPT) D BSDXNOS(BSDXAPPT,BSDXSTAT)
|
||||||
|
Q BSDXFOUND
|
||||||
|
;
|
||||||
|
NOSEVT3(BSDXRES) ;
|
||||||
|
;Call RaiseEvent to notify GUI clients
|
||||||
|
;
|
||||||
|
N BSDXRESN
|
||||||
|
S BSDXRESN=$G(^BSDXRES(BSDXRES,0))
|
||||||
|
Q:BSDXRESN=""
|
||||||
|
S BSDXRESN=$P(BSDXRESN,"^")
|
||||||
|
D EVENT^BMXMEVN("BSDX SCHEDULE",BSDXRESN)
|
||||||
|
Q
|
||||||
|
;
|
||||||
|
;
|
||||||
|
ERR(BSDXERID,ERRTXT) ;Error processing
|
||||||
|
S BSDXI=BSDXI+1
|
||||||
|
TROLLBACK
|
||||||
|
S ^BSDXTMP($J,BSDXI)=BSDXERID_"^"_ERRTXT_$C(30)
|
||||||
|
S BSDXI=BSDXI+1
|
||||||
|
S ^BSDXTMP($J,BSDXI)=$C(31)
|
||||||
|
Q
|
||||||
|
;
|
||||||
|
ETRAP ;EP Error trap entry
|
||||||
|
D ^%ZTER
|
||||||
|
I '$D(BSDXI) N BSDXI S BSDXI=999999
|
||||||
|
S BSDXI=BSDXI+1
|
||||||
|
D ERR(0,"BSDX31 Error: "_$G(%ZTERROR))
|
||||||
|
Q
|
||||||
|
;
|
||||||
|
IMHERE(BSDXRES) ;EP
|
||||||
|
;Entry point for BSDX IM HERE remote procedure
|
||||||
|
S BSDXRES=1
|
||||||
|
Q
|
||||||
|
;
|
||||||
|
|
Loading…
Reference in New Issue