RAUTODC ;HISC/GJC discontinue expired rad orders ;30 Jan 2018 9:01 AM
;;5.0;Radiology/Nuclear Medicine;**135**;Mar 16, 1998;Build 7
;
; *** WORKING: INTERNAL ONLY ***
;
EN1 ;entry point for initial mass discontinue action
;check for all imaging types no bulletins/alerts
;EN^RABUL is the bulletin routine.
;
;Routine IA Type
;-------------------------------------
; $$EC^%ZOSV 10097 (S)
; ^%ZTER 1621 (S)
; $$S^%ZTLOAD 10063 (S)
; $$*^XLFDT 10103 (S)
; ^XMD 10070 (S)
; EN^XPAR 2263 (S)
; ENVAL^XPAR 2263 (S)
; $$KSP^XUPARAM 2541 (S)
; OUT^XPDMENU(p1,p2) 1157 (S)
; ENALL^DIK 10013 (S)
;
;
; *************************************************************
; *** now that we've disabled all the notifications we need ***
; *** to restore them if we run into an error. so we set ***
; *** the error trap code ***
S X="ERROR^RAUTODC",@^%ZOSF("TRAP")
; *************************************************************
;
;OE/RR NOTIFICATIONS IEN/NAME: 26/IMAGING REQUEST CANCEL/HELD
;
; *** variable list ***
;RA135TIME: flag that mass DC is running (see RABUL)
;RAIEN : IEN of 'IMAGING REQUEST CANCEL/HELD' notification
;RADD21 : DATE DESIRED (Not guaranteed) value from "BDD" xref
;RADUZ : the user performing these action on file 75.1 (POSTMASTER)
;RAEDTM : end date for mass DC process (no bulletins; no notifications)
;RAENT : entity USR-DUZ, DIV-DUZ(2), SYS-domain, PKG-package
;RAIEN : IEN of IMAGING REQUEST CANCEL/HELD notification (26)
;RANOTE : array of the 'IMAGING REQUEST CANCEL/HELD' notification setting
;RAOIFN : IEN of the record in RAD/NUC MED ORDERS file 75.1
;RAOREQST : the REQUEST STATUS of each order record hit in file 75.1
;RAOSTS : internal FM variable for DISCONTINUED (1) req'd for ^RAORDU
;RAQUIT : indicates if the mass dc has been stopped or ran past time
;RAREQSTS : hold (3)/pending (5)/scheduled (8) - the REQUEST STATUS static string
; used to compare against each record's REQUEST STATUS value against
;RASAV : carbon copy of RANOTE, the original notification values (enabled/disabled)
; : used to reset notifications to their original settings when the process
; has finished, has errored or has stopped.
;
;w/o the reason we cannot go forward.
S RAOREA(1)=$$GETREA()
I RAOREA(1)'>0 D K RAOREA Q
.N RAX S RAX(1)="'OBSOLETE ORDER-P135 (automated)' not found in file 75.2"
.D EMAIL(.RAX)
.Q
;
; check notifications against: OR PARAM COORDINATOR MENU
;
N RAERR
;
;prevents bulletins from firing (RABUL in DD 75.1, fld: 5)
S RA135TIME=1
;
S RAQUIT=0,RAREQSTS="^3^5^8^"
;
;--- get notifications ---
K RANOTE S RAPAR="ORB PROCESSING FLAG"
S RAINT="IMAGING REQUEST CANCEL/HELD"
D GETNOTE(.RANOTE,RAPAR,RAINT)
;
;RAERR is returned: RAERR=0 if no error, else error
I RAERR'=0 D Q
.N RAX S RAX(1)="GETNOTE^RAUTODC failed."
.D EMAIL(.RAX)
.Q
;--- end get notifications ---
;
;save off the original definition of the notification values in RASAV
K RASAV M RASAV=RANOTE
;
;must save off the original IMAGING REQUEST CANCEL/HELD notification definitions
;in XTMP to ensure resetting them to their correct values in case of error.
S RADESC="RA5_0P135: save off the original value of the IMAGING REQUEST CANCEL/HELD notification per parameter"
K ^XTMP("RA5_0P135",0) S ^XTMP("RA5_0P135",0)=$$FMADD^XLFDT($$DT^XLFDT(),30,0,0,0)_"^"_$$DT^XLFDT()_"^"_RADESC
K RADESC M ^XTMP("RA5_0P135")=RANOTE
;
; RASAV save the original values of at each notification value @ each
; level: user, team, service, location, division, system & package.
; disable notifications if set to enabled. Use RANOTE as the reference.
; Place options 'Cancel a Request' & 'Hold a Request' out of order
D DISABLE,OOO(1)
;
K RAERR
;
N RADD21,RADUZ S RADD21=0
S RADUZ=.5 ;POSTMASTER
;
;turn off notifications and bulletins for all events up to May 31st 2015@23:59
S RAEDTM=3150531.2359
;
; set to 'Discontinue' request status internal value
; used when calling ^RAORDU (fixed value)
S RAOSTS=1
;
;track statistics: how many records, how long did it take?
S RAQST=$$NOW^XLFDT() ;start time w/seconds
S RAQDC=0 ;count the # of orders DC'd.
;
;"BDD" cross reference on the added w/RA*5.0*135
F S RADD21=$O(^RAO(75.1,"BDD",RADD21)) Q:RADD21=""!(RADD21>RAEDTM) D Q:RAQUIT
.;
.S RAOIFN=0 F S RAOIFN=$O(^RAO(75.1,"BDD",RADD21,RAOIFN)) Q:RAOIFN="" D Q:RAQUIT
..S RAOIFN(0)=$G(^RAO(75.1,RAOIFN,0)) Q:RAOIFN(0)=""
..;
..;only hold (3)/pending (5)/scheduled (8) orders are DC'd
..;RAREQSTS="^3^5^8^"
..S RAOREQST=$P(RAOIFN(0),U,5)
..Q:RAREQSTS'[(U_RAOREQST_U)
..;
..;
..; Request Status='Scheduled' check the 'SCHEDULED DATE/TIME'
..; 'DATE DESIRED (not Guaranteed)' fields
..; if 'SCHEDULED DATE/TIME' > 05/31/2015@2359 -OR-
..; 'DATE DESIRED (not Guaranteed)' > 06/01/2015
..; quit
..I RAOREQST=8,(($$8()>RAEDTM)) Q
..;
..;
..; RAOIFN & RAOREA(n) are defined above. RAOSTS
..; is set above (to a value of one) outside the
..; RADD21 FOR loop above RAOIFN, RAOREA(n) & RADD21
..; are required when calling ^RAORDU
..D ^RAORDU
..S RAQDC=RAQDC+1 ;increment the DC'd order total
..Q
.;
.I $$S^%ZTLOAD() S (ZTSTOP,RAQUIT)=1 D Q
..;re-enable the notifications, place options back in order
..D ENABLE,OOO(0)
..S RATXT(1)="RA*5.0*135 mass DC process stopped: "_$$NOW^XLFDT()
..D EMAIL(.RATXT) K RATXT
..Q
.Q
;
;only remove the task from the task log if not stopped (ZTSTOP=0)
S:$D(ZTQUEUED)&($G(ZTSTOP,0)=0) ZTREQ="@"
;
; the process completed successfully: no error; not stopped
; re-enable the notifications, place options back in order
D:RAQUIT=0 ENABLE,OOO(0)
;
D STATS ;track DC'd statistics, email results to proper audience
;
KILL ; Kill variables
K RA135TIME,RADD21,RADUZ,RAEDTM,RAENT,RAIEN,RANOTE,RAOIFN
K RAOREA,RAOREQST,RAQDC,RAQFIN,RAQST,RAQUIT,RAREQSTS,RASAV
Q
;
; *** utilities ***
;
GETREA() ;get the generic discontinue reason IEN
;the record has a .01 of 'OBSOLETE ORDER-P135 (automated)'
;the "B" xref stores 'OBSOLETE ORDER-P135 (automated' thirty chars
Q $O(^RA(75.2,"B","OBSOLETE ORDER-P135 (automated",0))
;
DISABLE ;disable the notifications that were enabled
S RAENT="" F S RAENT=$O(RANOTE(RAENT)) Q:RAENT="" D
.S RAIEN=$O(RANOTE(RAENT,0)) Q:RAIEN=0
.;RAIEN=IEN of the value 'IMAGING REQUEST CANCEL/HELD' `26
.D:$G(RANOTE(RAENT,RAIEN))'="D" NOTEVT(RAENT,1) ;disable
.;note: if not 'D'isabled then the notification
.; is either 'E'nabled or 'M'andatory
.Q
Q
;
ENABLE ;enable the notifications that were disabled
N RAIEN,RAENT
S RAENT="" F S RAENT=$O(RASAV(RAENT)) Q:RAENT="" D
.S RAIEN=$O(RANOTE(RAENT,0)) Q:RAIEN=0
.;RAIEN should be the IEN of the value "IMAGING REQUEST CANCEL/HELD" `26
.;RASAV is the array of notifications defnitions before our total disable action
.D:$G(RASAV(RAENT,RAIEN))'="D" NOTEVT(RAENT,0) ;enable
.;note: if not 'E'nabled or 'M'andatory then the
.; notification was 'D'isabled.
.Q
Q
;
8() ;get SCHEDULED DATE (TIME optional) fld: #23
Q $P(RAOIFN(0),U,23)
;
GETNOTE(ARY,PAR,INST) ; gets both enabled & disabled
D ENVAL^XPAR(.ARY,PAR,INST,.RAERR)
;RAERR is returned: RAERR=0 if no error, else error
I RAERR'=0 D
.N RATXT S RATXT(1)="RAERR = "_$G(RAERR),RATXT(2)="INST = "_INST
.S RATXT(3)="RANOTE = "_$G(RANOTE),RATXT(4)="PAR = "_PAR
.S RATXT(5)="Error @ GETNOTE^RAUTODC"
.D EMAIL(.RATXT)
Q
;
NOTEVT(RAENT,Y) ;
;RAENT = array value of notification (#100.9) values
; for "IMAGING REQUEST CANCEL/HELD"
;Y = 1 disable, 0 enable
;
;RAIEN is global in scope RAIEN should be 26
N RAPAR,RAY S RAPAR="48"
I Y=1 S RAY="D"
E S RAY=$G(RASAV(RAENT,RAIEN))
S RAY(0)=$S(RAY="D":"Disabled",RAY="E":"Enabled",1:"Mandatory")
D EN^XPAR(RAENT,RAPAR,RAIEN,.RAY,.ERR)
;
Q
;
OOO(Y) ;place options 'Cancel a Request' & 'Hold a Request' in/out of order
;input: Y = 1 to set options out of order (OOO)
; Y = 0 to set options back in order
S RAX=$S(Y=1:"<<< RA*5.0*135 >>>",1:"@")
F RAI="RA ORDERCANCEL","RA ORDERHOLD" D OUT^XPDMENU(RAI,RAX)
K RAI,RAX
Q
;
ERROR ;come here on error
N RAERR,RATXT
S RAERR=$$EC^%ZOSV ;get error code
;record error
D ^%ZTER
;restore notifications, place options back in order
D ENABLE,OOO(0)
;build email
s RATXT(1)=$G(ZTDESC,"RA*5.0*135 part one")_" has encountered an error."
S RATXT(2)="$ZE: "_RAERR
;send email
D EMAIL(.RATXT)
Q
;
EMAIL(RAX) ;email error to us
;RAX = error text array
N D0,D1,DIC,XMDUN,XMDUZ,XMSUB,XMY
S XMY("greg.cebelinski@domain.ext")=""
S XMY("kerry.milligan@domain.ext")=""
S XMSUB="RA*5.0*135@"_$$KSP^XUPARAM("WHERE")
S XMDUZ=.5,XMTEXT="RAX("
D ^XMD S RAMSGNUM=XMZ
Q
;
;
EN2 ; re-index the new 'DATE DESIRED (Not guaranteed)' (#21) "BDD" xref
;
K DA,DIC,DIK S DIK="^RAO(75.1,",DIK(1)="21^BDD" D ENALL^DIK
K DA,DIC,DIK
Q
;
EN3 ; re-index the existing 'REQUEST STATUS' (#5) "AS" xref.
;
K DA,DIC,DIK K ^RAO(75.1,"AS") ;kill the corrupted "AS" xref
S DIK="^RAO(75.1,",DIK(1)="5^AS" D ENALL^DIK
K DA,DIC,DIK
Q
;
STATS ;track DC'd statistics: how many records, how long did it take.
; email to RA REQUEST CANCELLED & POSTMASTER.
;
N I,RAQFIN,RATEXT,RAX,XMDUZ,XMMG,XMSUB,XMTEXT,XMY,XMZ
S RAX="DC'd order process ",XMDUZ=.5 ;postmaster
S RAQFIN=$$NOW^XLFDT() ;w/seconds
S XMSUB="RA135: # of DC'd orders over time statistics"
S RATEXT(1)=RAX_"started: "_$$FMTE^XLFDT(RAQST,"1P") ;RAQST is global
S RATEXT(2)=RAX_"finished: "_$$FMTE^XLFDT(RAQFIN,"1P")
S RATEXT(3)="Total # of orders DC'd: "_RAQDC,RATXT(4)=""
S RATEXT(5)="DC'd process duration: "_$$FMDIFF^XLFDT(RAQFIN,RAQST,3)
F I="G.RA REQUEST CANCELLED","POSTMASTER" S XMY(I)=""
S XMTEXT="RATEXT("
D ^XMD
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRAUTODC 10184 printed Nov 22, 2024@17:50:32 Page 2
RAUTODC ;HISC/GJC discontinue expired rad orders ;30 Jan 2018 9:01 AM
+1 ;;5.0;Radiology/Nuclear Medicine;**135**;Mar 16, 1998;Build 7
+2 ;
+3 ; *** WORKING: INTERNAL ONLY ***
+4 ;
EN1 ;entry point for initial mass discontinue action
+1 ;check for all imaging types no bulletins/alerts
+2 ;EN^RABUL is the bulletin routine.
+3 ;
+4 ;Routine IA Type
+5 ;-------------------------------------
+6 ; $$EC^%ZOSV 10097 (S)
+7 ; ^%ZTER 1621 (S)
+8 ; $$S^%ZTLOAD 10063 (S)
+9 ; $$*^XLFDT 10103 (S)
+10 ; ^XMD 10070 (S)
+11 ; EN^XPAR 2263 (S)
+12 ; ENVAL^XPAR 2263 (S)
+13 ; $$KSP^XUPARAM 2541 (S)
+14 ; OUT^XPDMENU(p1,p2) 1157 (S)
+15 ; ENALL^DIK 10013 (S)
+16 ;
+17 ;
+18 ; *************************************************************
+19 ; *** now that we've disabled all the notifications we need ***
+20 ; *** to restore them if we run into an error. so we set ***
+21 ; *** the error trap code ***
+22 SET X="ERROR^RAUTODC"
SET @^%ZOSF("TRAP")
+23 ; *************************************************************
+24 ;
+25 ;OE/RR NOTIFICATIONS IEN/NAME: 26/IMAGING REQUEST CANCEL/HELD
+26 ;
+27 ; *** variable list ***
+28 ;RA135TIME: flag that mass DC is running (see RABUL)
+29 ;RAIEN : IEN of 'IMAGING REQUEST CANCEL/HELD' notification
+30 ;RADD21 : DATE DESIRED (Not guaranteed) value from "BDD" xref
+31 ;RADUZ : the user performing these action on file 75.1 (POSTMASTER)
+32 ;RAEDTM : end date for mass DC process (no bulletins; no notifications)
+33 ;RAENT : entity USR-DUZ, DIV-DUZ(2), SYS-domain, PKG-package
+34 ;RAIEN : IEN of IMAGING REQUEST CANCEL/HELD notification (26)
+35 ;RANOTE : array of the 'IMAGING REQUEST CANCEL/HELD' notification setting
+36 ;RAOIFN : IEN of the record in RAD/NUC MED ORDERS file 75.1
+37 ;RAOREQST : the REQUEST STATUS of each order record hit in file 75.1
+38 ;RAOSTS : internal FM variable for DISCONTINUED (1) req'd for ^RAORDU
+39 ;RAQUIT : indicates if the mass dc has been stopped or ran past time
+40 ;RAREQSTS : hold (3)/pending (5)/scheduled (8) - the REQUEST STATUS static string
+41 ; used to compare against each record's REQUEST STATUS value against
+42 ;RASAV : carbon copy of RANOTE, the original notification values (enabled/disabled)
+43 ; : used to reset notifications to their original settings when the process
+44 ; has finished, has errored or has stopped.
+45 ;
+46 ;w/o the reason we cannot go forward.
+47 SET RAOREA(1)=$$GETREA()
+48 IF RAOREA(1)'>0
Begin DoDot:1
+49 NEW RAX
SET RAX(1)="'OBSOLETE ORDER-P135 (automated)' not found in file 75.2"
+50 DO EMAIL(.RAX)
+51 QUIT
End DoDot:1
KILL RAOREA
QUIT
+52 ;
+53 ; check notifications against: OR PARAM COORDINATOR MENU
+54 ;
+55 NEW RAERR
+56 ;
+57 ;prevents bulletins from firing (RABUL in DD 75.1, fld: 5)
+58 SET RA135TIME=1
+59 ;
+60 SET RAQUIT=0
SET RAREQSTS="^3^5^8^"
+61 ;
+62 ;--- get notifications ---
+63 KILL RANOTE
SET RAPAR="ORB PROCESSING FLAG"
+64 SET RAINT="IMAGING REQUEST CANCEL/HELD"
+65 DO GETNOTE(.RANOTE,RAPAR,RAINT)
+66 ;
+67 ;RAERR is returned: RAERR=0 if no error, else error
+68 IF RAERR'=0
Begin DoDot:1
+69 NEW RAX
SET RAX(1)="GETNOTE^RAUTODC failed."
+70 DO EMAIL(.RAX)
+71 QUIT
End DoDot:1
QUIT
+72 ;--- end get notifications ---
+73 ;
+74 ;save off the original definition of the notification values in RASAV
+75 KILL RASAV
MERGE RASAV=RANOTE
+76 ;
+77 ;must save off the original IMAGING REQUEST CANCEL/HELD notification definitions
+78 ;in XTMP to ensure resetting them to their correct values in case of error.
+79 SET RADESC="RA5_0P135: save off the original value of the IMAGING REQUEST CANCEL/HELD notification per parameter"
+80 KILL ^XTMP("RA5_0P135",0)
SET ^XTMP("RA5_0P135",0)=$$FMADD^XLFDT($$DT^XLFDT(),30,0,0,0)_"^"_$$DT^XLFDT()_"^"_RADESC
+81 KILL RADESC
MERGE ^XTMP("RA5_0P135")=RANOTE
+82 ;
+83 ; RASAV save the original values of at each notification value @ each
+84 ; level: user, team, service, location, division, system & package.
+85 ; disable notifications if set to enabled. Use RANOTE as the reference.
+86 ; Place options 'Cancel a Request' & 'Hold a Request' out of order
+87 DO DISABLE
DO OOO(1)
+88 ;
+89 KILL RAERR
+90 ;
+91 NEW RADD21,RADUZ
SET RADD21=0
+92 ;POSTMASTER
SET RADUZ=.5
+93 ;
+94 ;turn off notifications and bulletins for all events up to May 31st 2015@23:59
+95 SET RAEDTM=3150531.2359
+96 ;
+97 ; set to 'Discontinue' request status internal value
+98 ; used when calling ^RAORDU (fixed value)
+99 SET RAOSTS=1
+100 ;
+101 ;track statistics: how many records, how long did it take?
+102 ;start time w/seconds
SET RAQST=$$NOW^XLFDT()
+103 ;count the # of orders DC'd.
SET RAQDC=0
+104 ;
+105 ;"BDD" cross reference on the added w/RA*5.0*135
+106 FOR
SET RADD21=$ORDER(^RAO(75.1,"BDD",RADD21))
if RADD21=""!(RADD21>RAEDTM)
QUIT
Begin DoDot:1
+107 ;
+108 SET RAOIFN=0
FOR
SET RAOIFN=$ORDER(^RAO(75.1,"BDD",RADD21,RAOIFN))
if RAOIFN=""
QUIT
Begin DoDot:2
+109 SET RAOIFN(0)=$GET(^RAO(75.1,RAOIFN,0))
if RAOIFN(0)=""
QUIT
+110 ;
+111 ;only hold (3)/pending (5)/scheduled (8) orders are DC'd
+112 ;RAREQSTS="^3^5^8^"
+113 SET RAOREQST=$PIECE(RAOIFN(0),U,5)
+114 if RAREQSTS'[(U_RAOREQST_U)
QUIT
+115 ;
+116 ;
+117 ; Request Status='Scheduled' check the 'SCHEDULED DATE/TIME'
+118 ; 'DATE DESIRED (not Guaranteed)' fields
+119 ; if 'SCHEDULED DATE/TIME' > 05/31/2015@2359 -OR-
+120 ; 'DATE DESIRED (not Guaranteed)' > 06/01/2015
+121 ; quit
+122 IF RAOREQST=8
IF (($$8()>RAEDTM))
QUIT
+123 ;
+124 ;
+125 ; RAOIFN & RAOREA(n) are defined above. RAOSTS
+126 ; is set above (to a value of one) outside the
+127 ; RADD21 FOR loop above RAOIFN, RAOREA(n) & RADD21
+128 ; are required when calling ^RAORDU
+129 DO ^RAORDU
+130 ;increment the DC'd order total
SET RAQDC=RAQDC+1
+131 QUIT
End DoDot:2
if RAQUIT
QUIT
+132 ;
+133 IF $$S^%ZTLOAD()
SET (ZTSTOP,RAQUIT)=1
Begin DoDot:2
+134 ;re-enable the notifications, place options back in order
+135 DO ENABLE
DO OOO(0)
+136 SET RATXT(1)="RA*5.0*135 mass DC process stopped: "_$$NOW^XLFDT()
+137 DO EMAIL(.RATXT)
KILL RATXT
+138 QUIT
End DoDot:2
QUIT
+139 QUIT
End DoDot:1
if RAQUIT
QUIT
+140 ;
+141 ;only remove the task from the task log if not stopped (ZTSTOP=0)
+142 if $DATA(ZTQUEUED)&($GET(ZTSTOP,0)=0)
SET ZTREQ="@"
+143 ;
+144 ; the process completed successfully: no error; not stopped
+145 ; re-enable the notifications, place options back in order
+146 if RAQUIT=0
DO ENABLE
DO OOO(0)
+147 ;
+148 ;track DC'd statistics, email results to proper audience
DO STATS
+149 ;
KILL ; Kill variables
+1 KILL RA135TIME,RADD21,RADUZ,RAEDTM,RAENT,RAIEN,RANOTE,RAOIFN
+2 KILL RAOREA,RAOREQST,RAQDC,RAQFIN,RAQST,RAQUIT,RAREQSTS,RASAV
+3 QUIT
+4 ;
+5 ; *** utilities ***
+6 ;
GETREA() ;get the generic discontinue reason IEN
+1 ;the record has a .01 of 'OBSOLETE ORDER-P135 (automated)'
+2 ;the "B" xref stores 'OBSOLETE ORDER-P135 (automated' thirty chars
+3 QUIT $ORDER(^RA(75.2,"B","OBSOLETE ORDER-P135 (automated",0))
+4 ;
DISABLE ;disable the notifications that were enabled
+1 SET RAENT=""
FOR
SET RAENT=$ORDER(RANOTE(RAENT))
if RAENT=""
QUIT
Begin DoDot:1
+2 SET RAIEN=$ORDER(RANOTE(RAENT,0))
if RAIEN=0
QUIT
+3 ;RAIEN=IEN of the value 'IMAGING REQUEST CANCEL/HELD' `26
+4 ;disable
if $GET(RANOTE(RAENT,RAIEN))'="D"
DO NOTEVT(RAENT,1)
+5 ;note: if not 'D'isabled then the notification
+6 ; is either 'E'nabled or 'M'andatory
+7 QUIT
End DoDot:1
+8 QUIT
+9 ;
ENABLE ;enable the notifications that were disabled
+1 NEW RAIEN,RAENT
+2 SET RAENT=""
FOR
SET RAENT=$ORDER(RASAV(RAENT))
if RAENT=""
QUIT
Begin DoDot:1
+3 SET RAIEN=$ORDER(RANOTE(RAENT,0))
if RAIEN=0
QUIT
+4 ;RAIEN should be the IEN of the value "IMAGING REQUEST CANCEL/HELD" `26
+5 ;RASAV is the array of notifications defnitions before our total disable action
+6 ;enable
if $GET(RASAV(RAENT,RAIEN))'="D"
DO NOTEVT(RAENT,0)
+7 ;note: if not 'E'nabled or 'M'andatory then the
+8 ; notification was 'D'isabled.
+9 QUIT
End DoDot:1
+10 QUIT
+11 ;
8() ;get SCHEDULED DATE (TIME optional) fld: #23
+1 QUIT $PIECE(RAOIFN(0),U,23)
+2 ;
GETNOTE(ARY,PAR,INST) ; gets both enabled & disabled
+1 DO ENVAL^XPAR(.ARY,PAR,INST,.RAERR)
+2 ;RAERR is returned: RAERR=0 if no error, else error
+3 IF RAERR'=0
Begin DoDot:1
+4 NEW RATXT
SET RATXT(1)="RAERR = "_$GET(RAERR)
SET RATXT(2)="INST = "_INST
+5 SET RATXT(3)="RANOTE = "_$GET(RANOTE)
SET RATXT(4)="PAR = "_PAR
+6 SET RATXT(5)="Error @ GETNOTE^RAUTODC"
+7 DO EMAIL(.RATXT)
End DoDot:1
+8 QUIT
+9 ;
NOTEVT(RAENT,Y) ;
+1 ;RAENT = array value of notification (#100.9) values
+2 ; for "IMAGING REQUEST CANCEL/HELD"
+3 ;Y = 1 disable, 0 enable
+4 ;
+5 ;RAIEN is global in scope RAIEN should be 26
+6 NEW RAPAR,RAY
SET RAPAR="48"
+7 IF Y=1
SET RAY="D"
+8 IF '$TEST
SET RAY=$GET(RASAV(RAENT,RAIEN))
+9 SET RAY(0)=$SELECT(RAY="D":"Disabled",RAY="E":"Enabled",1:"Mandatory")
+10 DO EN^XPAR(RAENT,RAPAR,RAIEN,.RAY,.ERR)
+11 ;
+12 QUIT
+13 ;
OOO(Y) ;place options 'Cancel a Request' & 'Hold a Request' in/out of order
+1 ;input: Y = 1 to set options out of order (OOO)
+2 ; Y = 0 to set options back in order
+3 SET RAX=$SELECT(Y=1:"<<< RA*5.0*135 >>>",1:"@")
+4 FOR RAI="RA ORDERCANCEL","RA ORDERHOLD"
DO OUT^XPDMENU(RAI,RAX)
+5 KILL RAI,RAX
+6 QUIT
+7 ;
ERROR ;come here on error
+1 NEW RAERR,RATXT
+2 ;get error code
SET RAERR=$$EC^%ZOSV
+3 ;record error
+4 DO ^%ZTER
+5 ;restore notifications, place options back in order
+6 DO ENABLE
DO OOO(0)
+7 ;build email
+8 SET RATXT(1)=$GET(ZTDESC,"RA*5.0*135 part one")_" has encountered an error."
+9 SET RATXT(2)="$ZE: "_RAERR
+10 ;send email
+11 DO EMAIL(.RATXT)
+12 QUIT
+13 ;
EMAIL(RAX) ;email error to us
+1 ;RAX = error text array
+2 NEW D0,D1,DIC,XMDUN,XMDUZ,XMSUB,XMY
+3 SET XMY("greg.cebelinski@domain.ext")=""
+4 SET XMY("kerry.milligan@domain.ext")=""
+5 SET XMSUB="RA*5.0*135@"_$$KSP^XUPARAM("WHERE")
+6 SET XMDUZ=.5
SET XMTEXT="RAX("
+7 DO ^XMD
SET RAMSGNUM=XMZ
+8 QUIT
+9 ;
+10 ;
EN2 ; re-index the new 'DATE DESIRED (Not guaranteed)' (#21) "BDD" xref
+1 ;
+2 KILL DA,DIC,DIK
SET DIK="^RAO(75.1,"
SET DIK(1)="21^BDD"
DO ENALL^DIK
+3 KILL DA,DIC,DIK
+4 QUIT
+5 ;
EN3 ; re-index the existing 'REQUEST STATUS' (#5) "AS" xref.
+1 ;
+2 ;kill the corrupted "AS" xref
KILL DA,DIC,DIK
KILL ^RAO(75.1,"AS")
+3 SET DIK="^RAO(75.1,"
SET DIK(1)="5^AS"
DO ENALL^DIK
+4 KILL DA,DIC,DIK
+5 QUIT
+6 ;
STATS ;track DC'd statistics: how many records, how long did it take.
+1 ; email to RA REQUEST CANCELLED & POSTMASTER.
+2 ;
+3 NEW I,RAQFIN,RATEXT,RAX,XMDUZ,XMMG,XMSUB,XMTEXT,XMY,XMZ
+4 ;postmaster
SET RAX="DC'd order process "
SET XMDUZ=.5
+5 ;w/seconds
SET RAQFIN=$$NOW^XLFDT()
+6 SET XMSUB="RA135: # of DC'd orders over time statistics"
+7 ;RAQST is global
SET RATEXT(1)=RAX_"started: "_$$FMTE^XLFDT(RAQST,"1P")
+8 SET RATEXT(2)=RAX_"finished: "_$$FMTE^XLFDT(RAQFIN,"1P")
+9 SET RATEXT(3)="Total # of orders DC'd: "_RAQDC
SET RATXT(4)=""
+10 SET RATEXT(5)="DC'd process duration: "_$$FMDIFF^XLFDT(RAQFIN,RAQST,3)
+11 FOR I="G.RA REQUEST CANCELLED","POSTMASTER"
SET XMY(I)=""
+12 SET XMTEXT="RATEXT("
+13 DO ^XMD
+14 QUIT
+15 ;