- ORWORB ; slc/dee/REV/CLA,WAT - RPC functions which return user alert ;10:12 am JAN 31, 2001
- ;;3.0;ORDER ENTRY/RESULTS REPORTING;**10,85,116,148,173,190,215,243,296**;Dec 17, 1997;Build 19
- ;
- ;This routine invokes to following ICR(s):
- ;ICR 4156 ;REGISTRATION, COMBAT VETERAN STATUS
- ;
- URGENLST(ORY) ;return array of the urgency for the notification
- N ORSRV,ORERROR
- S ORSRV=$G(^VA(200,DUZ,5)) I +ORSRV>0 S ORSRV=$P(ORSRV,U)
- D GETLST^XPAR(.ORY,"USR^SRV.`"_$G(ORSRV)_"^DIV^SYS^PKG","ORB URGENCY","I",.ORERROR)
- Q
- ;
- FASTUSER(ORY) ;return current user's notifications across all patients
- N STRTDATE,STOPDATE,ORTOT,I,ORURG,URG,ORN,SORT,ORN0,URGLIST,REMLIST,REM,NONORLST,NONOR
- N ALRT,ALRTDT,ALRTPT,ALRTMSG,ALRTI,ALRTLOC,ALRTXQA,J,FWDBY,PRE,ALRTDFN
- K ^TMP("ORBG",$J)
- S STRTDATE="",STOPDATE="",FWDBY="Forwarded by: "
- D GETUSER1^XQALDATA("^TMP(""ORB"",$J)",DUZ,STRTDATE,STOPDATE)
- S ORTOT=^TMP("ORB",$J)
- D URGLIST^ORQORB(.URGLIST)
- D REMLIST^ORQORB(.REMLIST)
- D REMNONOR^ORQORB(.NONORLST)
- S J=0
- F I=1:1:ORTOT D
- .S ALRTDFN=""
- .S ALRT=^TMP("ORB",$J,I)
- .S PRE=$E(ALRT,1,1)
- .S ALRTXQA=$P(ALRT,U,2) ;XQAID
- .S NONOR="" F S NONOR=$O(NONORLST(NONOR)) Q:NONOR="" D
- ..I ALRTXQA[NONOR S REM=1 ;allow this type of alert to be Removed
- .S ALRTMSG=$P($P(ALRT,U),PRE_" ",2)
- .I $E(ALRT,4,8)'="-----" D ;not forwarded alert info/comment
- ..S ORURG="n/a"
- ..S ALRTI=$P(ALRT," ")
- ..S ALRTPT=""
- ..S ALRTLOC=""
- ..I $E($P(ALRTXQA,";"),1,3)="TIU" S ORURG="Moderate"
- ..I $P(ALRTXQA,",")="OR" D
- ...S ORN=$P($P(ALRTXQA,";"),",",3)
- ...S URG=$G(URGLIST(ORN))
- ...S ORURG=$S(URG=1:"HIGH",URG=2:"Moderate",1:"low")
- ...S REM=$G(REMLIST(ORN))
- ...S ORN0=^ORD(100.9,ORN,0)
- ...S ALRTI=$S($P(ORN0,U,6)="INFODEL":"I",1:"")
- ...S ALRTDFN=$P(ALRTXQA,",",2)
- ...S ALRTLOC=$G(^DPT(+$G(ALRTDFN),.1))
- ..S ALRTI=$S(ALRTI="I":"I",1:"")
- ..I (ALRT["): ")!($G(ORN)=27&(ALRT[") CV")) D ;WAT
- ...S ALRTPT=$P(ALRT,": ")
- ...S ALRTPT=$E(ALRTPT,4,$L(ALRTPT))
- ...I $G(ORN)=27&(ALRT[") CV") S ALRTMSG=$P($P(ALRT,U),": ",2) ;WAT
- ...E S ALRTMSG=$P($P(ALRT,U),"): ",2) ;WAT
- ...I $E(ALRTMSG,1,1)="[" D
- ....S:'$L(ALRTLOC) ALRTLOC=$P($P(ALRTMSG,"]"),"[",2)
- ....S ALRTMSG=$P(ALRTMSG,"] ",2)
- ..I '$L($G(ALRTPT)) S ALRTPT="no patient"
- ..S ALRTDT=$P(ALRTXQA,";",3)
- ..S ALRTDT=$P(ALRTDT,".")_"."_$E($P(ALRTDT,".",2)_"0000",1,4)
- ..S ALRTDT=$E(ALRTDT,4,5)_"/"_$E(ALRTDT,6,7)_"/"_($E(ALRTDT,1,3)+1700)_"@"_$E($P(ALRTDT,".",2),1,2)_":"_$E($P(ALRTDT,".",2),3,4)
- ..;S ALRTDT=($E(ALRTDT,1,3)+1700)_"/"_$E(ALRTDT,4,5)_"/"_$E(ALRTDT,6,7)_"@"_$E($P(ALRTDT,".",2),1,2)_":"_$E($P(ALRTDT,".",2),3,4)
- ..S J=J+1,^TMP("ORBG",$J,J)=ALRTI_U_ALRTPT_U_ALRTLOC_U_ORURG_U_ALRTDT_U
- ..S ^TMP("ORBG",$J,J)=^TMP("ORBG",$J,J)_ALRTMSG_U_U_ALRTXQA_U_$G(REM)_U
- .;
- .;if alert forward info/comment:
- .I $E(ALRTMSG,1,5)="-----" D
- ..S ALRTMSG=$P(ALRTMSG,"-----",2)
- ..I $E(ALRTMSG,1,14)=FWDBY D
- ...S J=J+1,^TMP("ORBG",$J,J)=FWDBY_U_$P($P(ALRTMSG,FWDBY,2),"Generated: ")_$P($P(ALRTMSG,FWDBY,2),"Generated: ",2)
- ..E S ^TMP("ORBG",$J,J)=^TMP("ORBG",$J,J)_U_""""_ALRTMSG_""""
- S ^TMP("ORBG",$J)=""
- S ORY=$NA(^TMP("ORBG",$J))
- Q
- ;
- GETDATA(ORY,XQAID) ; return XQADATA for an alert
- N SHOWADD
- S ORY=""
- Q:$G(XQAID)=""!('$D(^XTV(8992,"AXQA",XQAID)))
- D GETACT^XQALERT(XQAID)
- S ORY=XQADATA
- I ($E(XQAID,1,3)="TIU"),(+ORY>0) D
- . S SHOWADD=1
- . S ORY=ORY_$$RESOLVE^TIUSRVLO(+ORY)
- K XQAID,XQADATA,XQAOPT,XQAROU
- Q
- ;
- KILUNSNO(Y,ORVP) ; Delete unsigned order alerts if no unsigned orders remaining
- S ORVP=ORVP_";DPT("
- D UNOTIF^ORCSIGN
- Q
- ;
- UNFLORD(ORY,DFN,XQAID) ; -- auto-unflag orders?/delete alert
- Q:'$L(DFN)!('$L(XQAID))
- N ORI,ORIFN,ORA,XQAKILL,ORN,ORBY,ORAUTO,ORUNF
- S ORN=+$O(^ORD(100.9,"B","FLAGGED ORDERS",0))
- S XQAKILL=$$XQAKILL^ORB3F1(ORN)
- D LIST^ORQOR1(.ORBY,DFN,"ALL",12,"","")
- S ORAUTO=+$$GET^XPAR("ALL","ORPF AUTO UNFLAG")
- S ORI=0 F S ORI=$O(ORBY(ORI)) Q:ORI'>0 D
- . I ORAUTO D ; unflag
- . . S ORUNF=+$E($$NOW^XLFDT,1,12)_U_DUZ_"^Auto-Unflagged"
- . . S ORIFN=$P(ORBY(ORI),U),ORA=+$P(ORIFN,";",2)
- . . I ORIFN,$D(^OR(100,+ORIFN,0)) S $P(^(8,ORA,3),U)=0,$P(^(3),U,6,8)=ORUNF D MSG^ORCFLAG(ORIFN) ; unflag
- I ORAUTO!(+$G(ORBY(1))=0) D DELETE^XQALERT
- Q
- KILEXMED(Y,ORDFN) ; -- Delete expiring meds notification if no expiring meds remaining
- N ORDG,ORLST S ORDG=$$DG^ORQOR1("RX")
- D AGET^ORWORR(.ORLST,ORDFN,5,ORDG)
- Q:+(@ORLST@(.1)) ;more left
- N XQAKILL,ORNIFN,ORVP,ORIO S OROI=""
- F OROI="INPT","OUTPT" D
- .S ORNIFN=$O(^ORD(100.9,"B","MEDICATIONS EXPIRING - "_OROI,0)),ORVP=ORDFN_";DPT("
- .Q:'$L($G(ORNIFN))
- .S XQAKILL=$$XQAKILL^ORB3F1(ORNIFN) ; expiring meds notif
- .I $D(XQAID) D DELETE^XQALERT
- .I '$D(XQAID) S XQAID=$P($G(^ORD(100.9,ORNIFN,0)),U,2)_","_+ORVP_","_ORNIFN D DELETEA^XQALERT K XQAID
- Q
- KILEXOI(Y,ORDFN,ORNIFN) ; -- Delete expiring flagged OI notification if no flagged expiring OI remaining
- N ORDG,ORLST S ORDG=$$DG^ORQOR1("ALL")
- D AGET^ORWORR(.ORLST,ORDFN,5,ORDG)
- Q:+(@ORLST@(.1)) ;more left
- N XQAKILL,ORVP
- S ORVP=ORDFN_";DPT("
- S XQAKILL=$$XQAKILL^ORB3F1(ORNIFN) ; flagged expiring OI notifications
- I $D(XQAID) D DELETE^XQALERT
- I '$D(XQAID) S XQAID=$P($G(^ORD(100.9,ORNIFN,0)),U,2)_","_+ORVP_","_ORNIFN D DELETEA^XQALERT K XQAID
- Q
- KILUNVOR(Y,ORDFN) ; -- Delete UNVERIFIED ORDER notification if none remaining within current admission/30 days
- N DFN,ORDG,ORLST,ORBDT,OREDT,ORDDT S ORDG=$$DG^ORQOR1("ALL")
- S OREDT=$$NOW^XLFDT
- S ORDDT=$$FMADD^XLFDT(OREDT,"-90")
- ;get current admission date/time:
- S DFN=ORDFN,VA200="" D INP^VADPT
- S ORBDT=$P($G(VAIN(7)),U)
- S ORBDT=$S('$L($G(ORBDT)):$$FMADD^XLFDT(OREDT,"-30"),1:ORBDT) ;<= if no admission use past 30 days
- S ORBDT=$S(ORDDT>ORBDT:ORDDT,1:ORBDT) ;max past days to use is 90 days
- D AGET^ORWORR(.ORLST,ORDFN,9,ORDG,ORBDT,OREDT)
- Q:+(@ORLST@(.1)) ;more left
- N XQAKILL,ORVP,ORNIFN
- S ORNIFN=$O(^ORD(100.9,"B","UNVERIFIED ORDER",0)),ORVP=ORDFN_";DPT("
- S XQAKILL=$$XQAKILL^ORB3F1(ORNIFN)
- I $D(XQAID) D DELETE^XQALERT
- I '$D(XQAID) S XQAID=$P($G(^ORD(100.9,ORNIFN,0)),U,2)_","_+ORVP_","_ORNIFN D DELETEA^XQALERT K XQAID
- Q
- KILUNVMD(Y,ORDFN) ; -- Delete UNVERIFIED MEDS notification if none remaining within current admission/30 days
- N DFN,ORDG,ORLST,ORBDT,OREDT,ORDDT S ORDG=$$DG^ORQOR1("RX")
- S OREDT=$$NOW^XLFDT
- S ORDDT=$$FMADD^XLFDT(OREDT,"-90")
- ;get current admission date/time:
- S DFN=ORDFN,VA200="" D INP^VADPT
- S ORBDT=$P($G(VAIN(7)),U)
- S ORBDT=$S('$L($G(ORBDT)):$$FMADD^XLFDT(OREDT,"-30"),1:ORBDT) ;<= if no admission use past 30 days
- S ORBDT=$S(ORDDT>ORBDT:ORDDT,1:ORBDT) ;max past days to use is 90 days
- D AGET^ORWORR(.ORLST,ORDFN,9,ORDG,ORBDT,OREDT)
- Q:+(@ORLST@(.1)) ;more left
- N XQAKILL,ORVP,ORNIFN
- S ORNIFN=$O(^ORD(100.9,"B","UNVERIFIED MEDICATION ORDER",0)),ORVP=ORDFN_";DPT("
- S XQAKILL=$$XQAKILL^ORB3F1(ORNIFN)
- I $D(XQAID) D DELETE^XQALERT
- I '$D(XQAID) S XQAID=$P($G(^ORD(100.9,ORNIFN,0)),U,2)_","_+ORVP_","_ORNIFN D DELETEA^XQALERT K XQAID
- Q
- ESORD(ORY,XQAID) ;order(s) requiring electronic signature follow-up
- K XQAKILL
- N ORPT,ORDG,ORBXQAID,ORY,ORX,ORZ,ORDERS,ORDNUM,ORQUIT,ORBLMDEL
- S ORBXQAID=XQAID,ORDERS=0,ORQUIT=0
- S ORPT=$P($P(XQAID,";"),",",2) ;get pt dfn from xqaid
- S ORDG=$$DG^ORQOR1("ALL")
- ;the FLG code for UNSIGNED orders in ORQ1 is '11'
- ;get unsigned orders - if none exist, delete alert then quit:
- D EN^ORQ1(ORPT_";DPT(",ORDG,11,"","","",0,0)
- S ORX="",ORX=$O(^TMP("ORR",$J,ORX)) Q:ORX="" I +$G(^TMP("ORR",$J,ORX,"TOT"))<1 D DEL^ORB3FUP1(.ORY,ORBXQAID) K ^TMP("ORR",$J) Q
- ;
- ;user does not have ORES key, delete user's alert:
- I '$D(^XUSEC("ORES",DUZ)) S XQAKILL=1 D DEL^ORB3FUP1(.ORY,ORBXQAID) K ^TMP("ORR",$J) Q
- ;
- ;if prov is NOT linked to pt via attending, primary or teams:
- I $$PPLINK^ORQPTQ1(DUZ,ORPT)=0 D
- .S ORX="" F S ORX=$O(^TMP("ORR",$J,ORX)) Q:ORX=""!(ORDERS=1) D
- ..S ORZ="" F S ORZ=$O(^TMP("ORR",$J,ORX,ORZ)) Q:+ORZ=0!(ORDERS=1) D
- ...S ORDNUM=^TMP("ORR",$J,ORX,ORZ)
- ...;quit if this unsigned order's last action was made by the user
- ...I DUZ=+$$UNSIGNOR^ORQOR2(ORDNUM) S ORDERS=1
- .I ORDERS'=1 D ;provider has no outstanding unsigned orders for pt
- ..S XQAKILL=1 D DEL^ORB3FUP1(.ORY,ORBXQAID) ;delete alert for this user
- K ^TMP("ORR",$J)
- Q
- ;
- TXTFUP(ROOT,DFN,NOTIF,XQADATA) ; Follow-up for text messages
- ;
- I NOTIF=67 D CHGRAD
- Q
- ;
- CHGRAD ;GUI follow-up for Imaging Request Changed (#67)
- S ROOT=$NA(^TMP($J,"RAE4"))
- K @ROOT
- D SET1^RAO7PC4 ;DBIA #3563
- Q
- ;
- GETSORT(ORY) ;return notification sort method^direction for user/division/system/pkg
- S ORY=$$GET^XPAR("ALL","ORB SORT METHOD",1,"I")_U_$$GET^XPAR("ALL","ORB SORT DIRECTION",1,"I")
- Q
- ;
- SETSORT(ORERR,SORT,DIR) ;set notification sort method^direction for user
- D EN^XPAR(DUZ_";VA(200,","ORB SORT METHOD",1,SORT,.ORERR)
- I $L($G(DIR)) D EN^XPAR(DUZ_";VA(200,","ORB SORT DIRECTION",1,DIR,.ORERR)
- Q
- ORWORB ; slc/dee/REV/CLA,WAT - RPC functions which return user alert ;10:12 am JAN 31, 2001
- +1 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**10,85,116,148,173,190,215,243,296**;Dec 17, 1997;Build 19
- +2 ;
- +3 ;This routine invokes to following ICR(s):
- +4 ;ICR 4156 ;REGISTRATION, COMBAT VETERAN STATUS
- +5 ;
- URGENLST(ORY) ;return array of the urgency for the notification
- +1 NEW ORSRV,ORERROR
- +2 SET ORSRV=$GET(^VA(200,DUZ,5))
- IF +ORSRV>0
- SET ORSRV=$PIECE(ORSRV,U)
- +3 DO GETLST^XPAR(.ORY,"USR^SRV.`"_$GET(ORSRV)_"^DIV^SYS^PKG","ORB URGENCY","I",.ORERROR)
- +4 QUIT
- +5 ;
- FASTUSER(ORY) ;return current user's notifications across all patients
- +1 NEW STRTDATE,STOPDATE,ORTOT,I,ORURG,URG,ORN,SORT,ORN0,URGLIST,REMLIST,REM,NONORLST,NONOR
- +2 NEW ALRT,ALRTDT,ALRTPT,ALRTMSG,ALRTI,ALRTLOC,ALRTXQA,J,FWDBY,PRE,ALRTDFN
- +3 KILL ^TMP("ORBG",$JOB)
- +4 SET STRTDATE=""
- SET STOPDATE=""
- SET FWDBY="Forwarded by: "
- +5 DO GETUSER1^XQALDATA("^TMP(""ORB"",$J)",DUZ,STRTDATE,STOPDATE)
- +6 SET ORTOT=^TMP("ORB",$JOB)
- +7 DO URGLIST^ORQORB(.URGLIST)
- +8 DO REMLIST^ORQORB(.REMLIST)
- +9 DO REMNONOR^ORQORB(.NONORLST)
- +10 SET J=0
- +11 FOR I=1:1:ORTOT
- Begin DoDot:1
- +12 SET ALRTDFN=""
- +13 SET ALRT=^TMP("ORB",$JOB,I)
- +14 SET PRE=$EXTRACT(ALRT,1,1)
- +15 ;XQAID
- SET ALRTXQA=$PIECE(ALRT,U,2)
- +16 SET NONOR=""
- FOR
- SET NONOR=$ORDER(NONORLST(NONOR))
- IF NONOR=""
- QUIT
- Begin DoDot:2
- +17 ;allow this type of alert to be Removed
- IF ALRTXQA[NONOR
- SET REM=1
- End DoDot:2
- +18 SET ALRTMSG=$PIECE($PIECE(ALRT,U),PRE_" ",2)
- +19 ;not forwarded alert info/comment
- IF $EXTRACT(ALRT,4,8)'="-----"
- Begin DoDot:2
- +20 SET ORURG="n/a"
- +21 SET ALRTI=$PIECE(ALRT," ")
- +22 SET ALRTPT=""
- +23 SET ALRTLOC=""
- +24 IF $EXTRACT($PIECE(ALRTXQA,";"),1,3)="TIU"
- SET ORURG="Moderate"
- +25 IF $PIECE(ALRTXQA,",")="OR"
- Begin DoDot:3
- +26 SET ORN=$PIECE($PIECE(ALRTXQA,";"),",",3)
- +27 SET URG=$GET(URGLIST(ORN))
- +28 SET ORURG=$SELECT(URG=1:"HIGH",URG=2:"Moderate",1:"low")
- +29 SET REM=$GET(REMLIST(ORN))
- +30 SET ORN0=^ORD(100.9,ORN,0)
- +31 SET ALRTI=$SELECT($PIECE(ORN0,U,6)="INFODEL":"I",1:"")
- +32 SET ALRTDFN=$PIECE(ALRTXQA,",",2)
- +33 SET ALRTLOC=$GET(^DPT(+$GET(ALRTDFN),.1))
- End DoDot:3
- +34 SET ALRTI=$SELECT(ALRTI="I":"I",1:"")
- +35 ;WAT
- IF (ALRT["): ")!($GET(ORN)=27&(ALRT[") CV"))
- Begin DoDot:3
- +36 SET ALRTPT=$PIECE(ALRT,": ")
- +37 SET ALRTPT=$EXTRACT(ALRTPT,4,$LENGTH(ALRTPT))
- +38 ;WAT
- IF $GET(ORN)=27&(ALRT[") CV")
- SET ALRTMSG=$PIECE($PIECE(ALRT,U),": ",2)
- +39 ;WAT
- IF '$TEST
- SET ALRTMSG=$PIECE($PIECE(ALRT,U),"): ",2)
- +40 IF $EXTRACT(ALRTMSG,1,1)="["
- Begin DoDot:4
- +41 IF '$LENGTH(ALRTLOC)
- SET ALRTLOC=$PIECE($PIECE(ALRTMSG,"]"),"[",2)
- +42 SET ALRTMSG=$PIECE(ALRTMSG,"] ",2)
- End DoDot:4
- End DoDot:3
- +43 IF '$LENGTH($GET(ALRTPT))
- SET ALRTPT="no patient"
- +44 SET ALRTDT=$PIECE(ALRTXQA,";",3)
- +45 SET ALRTDT=$PIECE(ALRTDT,".")_"."_$EXTRACT($PIECE(ALRTDT,".",2)_"0000",1,4)
- +46 SET ALRTDT=$EXTRACT(ALRTDT,4,5)_"/"_$EXTRACT(ALRTDT,6,7)_"/"_($EXTRACT(ALRTDT,1,3)+1700)_"@"_$EXTRACT($PIECE(ALRTDT,".",2),1,2)_":"_$EXTRACT($PIECE(ALRTDT,".",2),3,4)
- +47 ;S ALRTDT=($E(ALRTDT,1,3)+1700)_"/"_$E(ALRTDT,4,5)_"/"_$E(ALRTDT,6,7)_"@"_$E($P(ALRTDT,".",2),1,2)_":"_$E($P(ALRTDT,".",2),3,4)
- +48 SET J=J+1
- SET ^TMP("ORBG",$JOB,J)=ALRTI_U_ALRTPT_U_ALRTLOC_U_ORURG_U_ALRTDT_U
- +49 SET ^TMP("ORBG",$JOB,J)=^TMP("ORBG",$JOB,J)_ALRTMSG_U_U_ALRTXQA_U_$GET(REM)_U
- End DoDot:2
- +50 ;
- +51 ;if alert forward info/comment:
- +52 IF $EXTRACT(ALRTMSG,1,5)="-----"
- Begin DoDot:2
- +53 SET ALRTMSG=$PIECE(ALRTMSG,"-----",2)
- +54 IF $EXTRACT(ALRTMSG,1,14)=FWDBY
- Begin DoDot:3
- +55 SET J=J+1
- SET ^TMP("ORBG",$JOB,J)=FWDBY_U_$PIECE($PIECE(ALRTMSG,FWDBY,2),"Generated: ")_$PIECE($PIECE(ALRTMSG,FWDBY,2),"Generated: ",2)
- End DoDot:3
- +56 IF '$TEST
- SET ^TMP("ORBG",$JOB,J)=^TMP("ORBG",$JOB,J)_U_""""_ALRTMSG_""""
- End DoDot:2
- End DoDot:1
- +57 SET ^TMP("ORBG",$JOB)=""
- +58 SET ORY=$NAME(^TMP("ORBG",$JOB))
- +59 QUIT
- +60 ;
- GETDATA(ORY,XQAID) ; return XQADATA for an alert
- +1 NEW SHOWADD
- +2 SET ORY=""
- +3 IF $GET(XQAID)=""!('$DATA(^XTV(8992,"AXQA",XQAID)))
- QUIT
- +4 DO GETACT^XQALERT(XQAID)
- +5 SET ORY=XQADATA
- +6 IF ($EXTRACT(XQAID,1,3)="TIU")
- IF (+ORY>0)
- Begin DoDot:1
- +7 SET SHOWADD=1
- +8 SET ORY=ORY_$$RESOLVE^TIUSRVLO(+ORY)
- End DoDot:1
- +9 KILL XQAID,XQADATA,XQAOPT,XQAROU
- +10 QUIT
- +11 ;
- KILUNSNO(Y,ORVP) ; Delete unsigned order alerts if no unsigned orders remaining
- +1 SET ORVP=ORVP_";DPT("
- +2 DO UNOTIF^ORCSIGN
- +3 QUIT
- +4 ;
- UNFLORD(ORY,DFN,XQAID) ; -- auto-unflag orders?/delete alert
- +1 IF '$LENGTH(DFN)!('$LENGTH(XQAID))
- QUIT
- +2 NEW ORI,ORIFN,ORA,XQAKILL,ORN,ORBY,ORAUTO,ORUNF
- +3 SET ORN=+$ORDER(^ORD(100.9,"B","FLAGGED ORDERS",0))
- +4 SET XQAKILL=$$XQAKILL^ORB3F1(ORN)
- +5 DO LIST^ORQOR1(.ORBY,DFN,"ALL",12,"","")
- +6 SET ORAUTO=+$$GET^XPAR("ALL","ORPF AUTO UNFLAG")
- +7 SET ORI=0
- FOR
- SET ORI=$ORDER(ORBY(ORI))
- IF ORI'>0
- QUIT
- Begin DoDot:1
- +8 ; unflag
- IF ORAUTO
- Begin DoDot:2
- +9 SET ORUNF=+$EXTRACT($$NOW^XLFDT,1,12)_U_DUZ_"^Auto-Unflagged"
- +10 SET ORIFN=$PIECE(ORBY(ORI),U)
- SET ORA=+$PIECE(ORIFN,";",2)
- +11 ; unflag
- IF ORIFN
- IF $DATA(^OR(100,+ORIFN,0))
- SET $PIECE(^(8,ORA,3),U)=0
- SET $PIECE(^(3),U,6,8)=ORUNF
- DO MSG^ORCFLAG(ORIFN)
- End DoDot:2
- End DoDot:1
- +12 IF ORAUTO!(+$GET(ORBY(1))=0)
- DO DELETE^XQALERT
- +13 QUIT
- KILEXMED(Y,ORDFN) ; -- Delete expiring meds notification if no expiring meds remaining
- +1 NEW ORDG,ORLST
- SET ORDG=$$DG^ORQOR1("RX")
- +2 DO AGET^ORWORR(.ORLST,ORDFN,5,ORDG)
- +3 ;more left
- IF +(@ORLST@(.1))
- QUIT
- +4 NEW XQAKILL,ORNIFN,ORVP,ORIO
- SET OROI=""
- +5 FOR OROI="INPT","OUTPT"
- Begin DoDot:1
- +6 SET ORNIFN=$ORDER(^ORD(100.9,"B","MEDICATIONS EXPIRING - "_OROI,0))
- SET ORVP=ORDFN_";DPT("
- +7 IF '$LENGTH($GET(ORNIFN))
- QUIT
- +8 ; expiring meds notif
- SET XQAKILL=$$XQAKILL^ORB3F1(ORNIFN)
- +9 IF $DATA(XQAID)
- DO DELETE^XQALERT
- +10 IF '$DATA(XQAID)
- SET XQAID=$PIECE($GET(^ORD(100.9,ORNIFN,0)),U,2)_","_+ORVP_","_ORNIFN
- DO DELETEA^XQALERT
- KILL XQAID
- End DoDot:1
- +11 QUIT
- KILEXOI(Y,ORDFN,ORNIFN) ; -- Delete expiring flagged OI notification if no flagged expiring OI remaining
- +1 NEW ORDG,ORLST
- SET ORDG=$$DG^ORQOR1("ALL")
- +2 DO AGET^ORWORR(.ORLST,ORDFN,5,ORDG)
- +3 ;more left
- IF +(@ORLST@(.1))
- QUIT
- +4 NEW XQAKILL,ORVP
- +5 SET ORVP=ORDFN_";DPT("
- +6 ; flagged expiring OI notifications
- SET XQAKILL=$$XQAKILL^ORB3F1(ORNIFN)
- +7 IF $DATA(XQAID)
- DO DELETE^XQALERT
- +8 IF '$DATA(XQAID)
- SET XQAID=$PIECE($GET(^ORD(100.9,ORNIFN,0)),U,2)_","_+ORVP_","_ORNIFN
- DO DELETEA^XQALERT
- KILL XQAID
- +9 QUIT
- KILUNVOR(Y,ORDFN) ; -- Delete UNVERIFIED ORDER notification if none remaining within current admission/30 days
- +1 NEW DFN,ORDG,ORLST,ORBDT,OREDT,ORDDT
- SET ORDG=$$DG^ORQOR1("ALL")
- +2 SET OREDT=$$NOW^XLFDT
- +3 SET ORDDT=$$FMADD^XLFDT(OREDT,"-90")
- +4 ;get current admission date/time:
- +5 SET DFN=ORDFN
- SET VA200=""
- DO INP^VADPT
- +6 SET ORBDT=$PIECE($GET(VAIN(7)),U)
- +7 ;<= if no admission use past 30 days
- SET ORBDT=$SELECT('$LENGTH($GET(ORBDT)):$$FMADD^XLFDT(OREDT,"-30"),1:ORBDT)
- +8 ;max past days to use is 90 days
- SET ORBDT=$SELECT(ORDDT>ORBDT:ORDDT,1:ORBDT)
- +9 DO AGET^ORWORR(.ORLST,ORDFN,9,ORDG,ORBDT,OREDT)
- +10 ;more left
- IF +(@ORLST@(.1))
- QUIT
- +11 NEW XQAKILL,ORVP,ORNIFN
- +12 SET ORNIFN=$ORDER(^ORD(100.9,"B","UNVERIFIED ORDER",0))
- SET ORVP=ORDFN_";DPT("
- +13 SET XQAKILL=$$XQAKILL^ORB3F1(ORNIFN)
- +14 IF $DATA(XQAID)
- DO DELETE^XQALERT
- +15 IF '$DATA(XQAID)
- SET XQAID=$PIECE($GET(^ORD(100.9,ORNIFN,0)),U,2)_","_+ORVP_","_ORNIFN
- DO DELETEA^XQALERT
- KILL XQAID
- +16 QUIT
- KILUNVMD(Y,ORDFN) ; -- Delete UNVERIFIED MEDS notification if none remaining within current admission/30 days
- +1 NEW DFN,ORDG,ORLST,ORBDT,OREDT,ORDDT
- SET ORDG=$$DG^ORQOR1("RX")
- +2 SET OREDT=$$NOW^XLFDT
- +3 SET ORDDT=$$FMADD^XLFDT(OREDT,"-90")
- +4 ;get current admission date/time:
- +5 SET DFN=ORDFN
- SET VA200=""
- DO INP^VADPT
- +6 SET ORBDT=$PIECE($GET(VAIN(7)),U)
- +7 ;<= if no admission use past 30 days
- SET ORBDT=$SELECT('$LENGTH($GET(ORBDT)):$$FMADD^XLFDT(OREDT,"-30"),1:ORBDT)
- +8 ;max past days to use is 90 days
- SET ORBDT=$SELECT(ORDDT>ORBDT:ORDDT,1:ORBDT)
- +9 DO AGET^ORWORR(.ORLST,ORDFN,9,ORDG,ORBDT,OREDT)
- +10 ;more left
- IF +(@ORLST@(.1))
- QUIT
- +11 NEW XQAKILL,ORVP,ORNIFN
- +12 SET ORNIFN=$ORDER(^ORD(100.9,"B","UNVERIFIED MEDICATION ORDER",0))
- SET ORVP=ORDFN_";DPT("
- +13 SET XQAKILL=$$XQAKILL^ORB3F1(ORNIFN)
- +14 IF $DATA(XQAID)
- DO DELETE^XQALERT
- +15 IF '$DATA(XQAID)
- SET XQAID=$PIECE($GET(^ORD(100.9,ORNIFN,0)),U,2)_","_+ORVP_","_ORNIFN
- DO DELETEA^XQALERT
- KILL XQAID
- +16 QUIT
- ESORD(ORY,XQAID) ;order(s) requiring electronic signature follow-up
- +1 KILL XQAKILL
- +2 NEW ORPT,ORDG,ORBXQAID,ORY,ORX,ORZ,ORDERS,ORDNUM,ORQUIT,ORBLMDEL
- +3 SET ORBXQAID=XQAID
- SET ORDERS=0
- SET ORQUIT=0
- +4 ;get pt dfn from xqaid
- SET ORPT=$PIECE($PIECE(XQAID,";"),",",2)
- +5 SET ORDG=$$DG^ORQOR1("ALL")
- +6 ;the FLG code for UNSIGNED orders in ORQ1 is '11'
- +7 ;get unsigned orders - if none exist, delete alert then quit:
- +8 DO EN^ORQ1(ORPT_";DPT(",ORDG,11,"","","",0,0)
- +9 SET ORX=""
- SET ORX=$ORDER(^TMP("ORR",$JOB,ORX))
- IF ORX=""
- QUIT
- IF +$GET(^TMP("ORR",$JOB,ORX,"TOT"))<1
- DO DEL^ORB3FUP1(.ORY,ORBXQAID)
- KILL ^TMP("ORR",$JOB)
- QUIT
- +10 ;
- +11 ;user does not have ORES key, delete user's alert:
- +12 IF '$DATA(^XUSEC("ORES",DUZ))
- SET XQAKILL=1
- DO DEL^ORB3FUP1(.ORY,ORBXQAID)
- KILL ^TMP("ORR",$JOB)
- QUIT
- +13 ;
- +14 ;if prov is NOT linked to pt via attending, primary or teams:
- +15 IF $$PPLINK^ORQPTQ1(DUZ,ORPT)=0
- Begin DoDot:1
- +16 SET ORX=""
- FOR
- SET ORX=$ORDER(^TMP("ORR",$JOB,ORX))
- IF ORX=""!(ORDERS=1)
- QUIT
- Begin DoDot:2
- +17 SET ORZ=""
- FOR
- SET ORZ=$ORDER(^TMP("ORR",$JOB,ORX,ORZ))
- IF +ORZ=0!(ORDERS=1)
- QUIT
- Begin DoDot:3
- +18 SET ORDNUM=^TMP("ORR",$JOB,ORX,ORZ)
- +19 ;quit if this unsigned order's last action was made by the user
- +20 IF DUZ=+$$UNSIGNOR^ORQOR2(ORDNUM)
- SET ORDERS=1
- End DoDot:3
- End DoDot:2
- +21 ;provider has no outstanding unsigned orders for pt
- IF ORDERS'=1
- Begin DoDot:2
- +22 ;delete alert for this user
- SET XQAKILL=1
- DO DEL^ORB3FUP1(.ORY,ORBXQAID)
- End DoDot:2
- End DoDot:1
- +23 KILL ^TMP("ORR",$JOB)
- +24 QUIT
- +25 ;
- TXTFUP(ROOT,DFN,NOTIF,XQADATA) ; Follow-up for text messages
- +1 ;
- +2 IF NOTIF=67
- DO CHGRAD
- +3 QUIT
- +4 ;
- CHGRAD ;GUI follow-up for Imaging Request Changed (#67)
- +1 SET ROOT=$NAME(^TMP($JOB,"RAE4"))
- +2 KILL @ROOT
- +3 ;DBIA #3563
- DO SET1^RAO7PC4
- +4 QUIT
- +5 ;
- GETSORT(ORY) ;return notification sort method^direction for user/division/system/pkg
- +1 SET ORY=$$GET^XPAR("ALL","ORB SORT METHOD",1,"I")_U_$$GET^XPAR("ALL","ORB SORT DIRECTION",1,"I")
- +2 QUIT
- +3 ;
- SETSORT(ORERR,SORT,DIR) ;set notification sort method^direction for user
- +1 DO EN^XPAR(DUZ_";VA(200,","ORB SORT METHOD",1,SORT,.ORERR)
- +2 IF $LENGTH($GET(DIR))
- DO EN^XPAR(DUZ_";VA(200,","ORB SORT DIRECTION",1,DIR,.ORERR)
- +3 QUIT