VistA-WorldVistAEHR/r/REMOTE_ORDER_ENTRY_SYSTEM-R.../RMPFDE4.m

40 lines
1.5 KiB
Mathematica

RMPFDE4 ;DDC/PJU - SENDS ALERTS WHEN ELIG REQESTS NOT ACTED ON ;11/01/02
;;3.0;REMOTE ORDER ENTRY SYSTEM;;02/18/03
;SET RMPFDE4 IN OPTION FILE & REPETITIVE QUE WITH A PARAM OF X DAYS
START ;;RMPFDY ;time frame
Q:'$D(^RMPF(791814,"C",2))
N IEN,RMPFST,RMPFDIFF ;START DATE
S IEN=0 S:'$G(RMPFDY) RMPFDY=7 ;Defaults to 7 if RMPFDY not set in Rep QUE
LOOP S IEN=$O(^RMPF(791814,"C",2,IEN)) G:'IEN EXIT ;records in wait status
;LOOK FOR END OF GLOBAL RECORDS
S S0=$G(^RMPF(791814,IEN,0)),S1=$G(^(1)),S2=$G(^(2))
G:$P(S2,U,2)'=2 LOOP ;acted on already
G:$P(S0,U,4)>DT LOOP ;expired
S RMPFST=$P(S0,U,2) ;date input
G:'RMPFST LOOP ;missing input date
S RMPFDIFF=$$FMDIFF^XLFDT(DT,RMPFST) ;days since input
I RMPFDIFF>RMPFDY D SEND(IEN,RMPFDIFF) ;SEND ALERT IF NEC
G LOOP
EXIT K RMPFDY D KILL^XM Q
;
SEND(ENT,RMPFDIFF) ;
;INPUT ENTRY IN FORM IEN, DIFFERENCE IN DAYS SINCE ENTERED
N SSN,DFN,NM,MS,RMPFTXT,RMUSER
S DFN=$P(S0,U,1)
Q:'DFN D DEM^VADPT Q:VAERR
S NM=VADM(1) Q:NM=""
S SSN=$P(VADM(2),U,1)
S MS=$P(S1,U,2),RMUSER=$P(S0,U,3) ;email# & requesting user
;SETUP ALERT
S RMPFTXT="Action req'd on Elig Req [msg #"_MS_"] for: "_$P(NM,",",1)_"-"_$E(SSN,6,10)_" from "_RMPFDIFF_" days ago."
S XQA("G.RMPF ROES UPDATES (PSAS)")=""
S:$L(RMUSER) XQA(RMUSER)=""
S XQAMSG=RMPFTXT
S XQAID="RMPF_ELIG_ALERT"
D SETUP^XQALERT ;SEND
END Q
;sample entry in file after completed
;^RMPF(791814,1,0)=733928^3030212^988^3050212
;^(1)=NSC^2673145
;^(2)=NSC^NSC^1^988^3030218