Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: ORB3F1

ORB3F1.m

Go to the documentation of this file.
ORB3F1 ; slc/CLA - Extrinsic functions to support OE/RR 3 notifications ;08/17/16  07:57
 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**9,74,139,190,220,423**;Dec 17, 1997;Build 19
 ;
FIREFLOI(ORNUM,ORLOC,ORDT,IOPT) ;
 ;get all flagged OIs from order
 N OILST,ORI,ORFLST
 S ORI=""
 S IOPT=$$ISCLORIP(ORNUM,IOPT)
 D OIM^ORQOR2(.OILST,ORNUM)
 Q:+$G(OILST)<1
 F  S ORI=$O(OILST(ORI)) Q:'ORI  D
 . N ORBLST,ORBERR,ORBI,ORBFLAG,ORBE
 . S ORBE=""
 . I IOPT="I" D
 . . D ENVAL^XPAR(.ORBLST,"ORB OI ORDERED - INPT","`"_$G(OILST(ORI)),.ORBERR)
 . . Q:$G(ORBLST)>0
 . . D ENVAL^XPAR(.ORBLST,"ORB OI ORDERED - INPT PR","`"_$G(OILST(ORI)),.ORBERR)
 . I IOPT="O" D
 . . D ENVAL^XPAR(.ORBLST,"ORB OI ORDERED - OUTPT","`"_$G(OILST(ORI)),.ORBERR)
 . . Q:$G(ORBLST)>0
 . . D ENVAL^XPAR(.ORBLST,"ORB OI ORDERED - OUTPT PR","`"_$G(OILST(ORI)),.ORBERR)
 . I 'ORBERR,$G(ORBLST)>0 D
 . . F ORBI=1:1:ORBLST D
 . . . S ORBE=$O(ORBLST(ORBE))
 . . . I $D(ORBLST(ORBE,$G(OILST(ORI)))) S ORFLST(OILST(ORI))=""
 ;foreach flagged OI in order fire alert
 N ORANUM,ORDFN
 S ORDFN=+$P($G(^OR(100,+ORNUM,0)),U,2)
 S ORANUM=41 I IOPT="O" S ORANUM=61
 S ORI="" F  S ORI=$O(ORFLST(ORI)) Q:'ORI  D
 . N ORMSG
 . S ORMSG="Order placed: "_$P($G(^ORD(101.43,ORI,0)),U,1)_" "_ORDT
 . I $L(ORLOC)>0 S ORMSG="["_ORLOC_"] "_ORMSG
 . I '$D(^TMP("ORB3 FIREFLOI",$J,ORDFN,+ORNUM,ORANUM,ORI,ORDT)) D
 . . D EN^ORB3(ORANUM,ORDFN,+ORNUM,"",ORMSG,ORI)
 . . S ^TMP("ORB3 FIREFLOI",$J,ORDFN,+ORNUM,ORANUM,ORI,ORDT)=$$NOW^XLFDT
 Q
XQAKILL(ORN) ;extrinsic function to return the delete mechanism for the notification based on definition in PARAM DEF file
 N ORBKILL S ORBKILL=1
 Q:$G(ORN)="" ORBKILL
 S ORBKILL=$$GET^XPAR("DIV^SYS^PKG","ORB DELETE MECHANISM",ORN,"I")
 I ORBKILL="A" S ORBKILL=0  ;delete for all recipients
 E  S ORBKILL=1  ;default for delete mechanism is 1 (delete only for this recipient)
 Q ORBKILL
SITEORD(ORNUM,IOPT) ;Extrinsic function returns 1 (Yes) if the site has flagged the
 ; orderable item (determined from the order number ORNUM) to trigger a
 ; notification when ordered
 S IOPT=$$ISCLORIP(ORNUM,IOPT)
 N ORBFLAG,ORI,ORBLST,ORBERR,ORBI,ORBE,OILST
 S ORBFLAG=0,ORI="",ORBE="",ORBERR=""
 Q:+$G(ORNUM)<1 ORBFLAG
 D OIM^ORQOR2(.OILST,ORNUM)
 Q:+$G(OILST)<1 ORBFLAG
 F  S ORI=$O(OILST(ORI)) Q:'ORI!ORBFLAG  D
 . I IOPT="I" D
 . . D ENVAL^XPAR(.ORBLST,"ORB OI ORDERED - INPT","`"_$G(OILST(ORI)),.ORBERR)
 . . Q:$G(ORBLST)>0
 . . D ENVAL^XPAR(.ORBLST,"ORB OI ORDERED - INPT PR","`"_$G(OILST(ORI)),.ORBERR)
 . I IOPT="O" D
 . . D ENVAL^XPAR(.ORBLST,"ORB OI ORDERED - OUTPT","`"_$G(OILST(ORI)),.ORBERR)
 . . Q:$G(ORBLST)>0
 . . D ENVAL^XPAR(.ORBLST,"ORB OI ORDERED - OUTPT PR","`"_$G(OILST(ORI)),.ORBERR)
 . I 'ORBERR,$G(ORBLST)>0 D
 . . F ORBI=1:1:ORBLST Q:ORBFLAG=1  D
 . . . S ORBE=$O(ORBLST(ORBE))
 . . . I $D(ORBLST(ORBE,$G(OILST(ORI)))) S ORBFLAG=1
 Q ORBFLAG
SITERES(ORNUM,IOPT) ;Extrinsic function returns 1 (Yes) if the site has flagged the
 ; orderable item (determined from the order number ORNUM) to trigger a
 ; notification when resulted
 N ORBFLAG,OI,ORBLST,ORBERR,ORBI,ORBE
 S ORBFLAG=0,OI="",ORBE="",ORBERR=""
 Q:+$G(ORNUM)<1 ORBFLAG
 S OI=$$OI^ORQOR2(ORNUM)
 Q:+$G(OI)<1 ORBFLAG
 I IOPT="I" D ENVAL^XPAR(.ORBLST,"ORB OI RESULTS - INPT","`"_OI,.ORBERR)
 I IOPT="O" D ENVAL^XPAR(.ORBLST,"ORB OI RESULTS - OUTPT","`"_OI,.ORBERR)
 I 'ORBERR,$G(ORBLST)>0 D
 .F ORBI=1:1:ORBLST Q:ORBFLAG=1  D
 ..S ORBE=$O(ORBLST(ORBE))
 ..I $D(ORBLST(ORBE,OI)) S ORBFLAG=1
 Q ORBFLAG
LRRAD(OI) ;Extrinsic function returns 1 (true) if Orderable Item is a
 ;Chemistry Lab ("S.CH") or Imaging ("S.XRAY") proc or Consult ("S.CSLT")
 N OITEXT,ORBFLAG
 S ORBFLAG=""
 Q:+$G(OI)<1 ORBFLAG
 Q:'$L($G(^ORD(101.43,OI,0))) ORBFLAG
 S OITEXT=$P(^ORD(101.43,OI,0),U)
 S OITEXT=$$UP^XLFSTR(OITEXT)
 Q:$D(^ORD(101.43,"S.CH",OITEXT)) 1
 Q:$D(^ORD(101.43,"S.XRAY",OITEXT)) 1
 Q:$D(^ORD(101.43,"S.CSLT",OITEXT)) 1
 Q ORBFLAG
 ;
EXP(ORDT,ORNUM) ;set up ^XTMP("ORAE" to store expired orders
 N ORNOW,X0
 S ORNOW=$$NOW^XLFDT
 S ^XTMP("ORAE",0)=$$FMADD^XLFDT(ORNOW,30,"","","")_U_ORNOW
 S X0=^OR(100,ORNUM,0)
 S ^XTMP("ORAE",$P(X0,U,2),$P(X0,U,11),ORDT,ORNUM)=""
 Q
 ;
DELEXP ; delete ^XTMP("ORAE" entries older than param value + 48 hours
 ; or have been replaced by another order
 N ORNOW,OREXDT,OREXPAR,ORDELDT,ORPT,ORDG,ORN,ORREP
 S ORNOW=$$NOW^XLFDT
 S OREXPAR=$$GET^XPAR("ALL","ORWOR EXPIRED ORDERS",1,"I")
 S OREXPAR=$S($G(OREXPAR):OREXPAR,1:72)
 S ORDELDT=$$FMADD^XLFDT(ORNOW,"",-(OREXPAR+48),"","")
 S ORPT=0 F  S ORPT=$O(^XTMP("ORAE",ORPT)) Q:'ORPT  D
 .S ORDG=0 F  S ORDG=$O(^XTMP("ORAE",ORPT,ORDG)) Q:'ORDG  D
 ..S OREXDT=0 F  S OREXDT=$O(^XTMP("ORAE",ORPT,ORDG,OREXDT)) Q:'OREXDT  D
 ...I OREXDT<ORDELDT K ^XTMP("ORAE",ORPT,ORDG,OREXDT) Q
 ...S ORN=0 F  S ORN=$O(^XTMP("ORAE",ORPT,ORDG,OREXDT,ORN)) Q:'ORN  D
 ....Q:'$D(^OR(100,ORN,3))
 ....S ORREP=$P(^OR(100,ORN,3),U,6)
 ....I +$G(ORREP)>0 K ^XTMP("ORAE",ORPT,ORDG,OREXDT,ORN)
 Q
ISCLORIP(ORNUM,ORTYPE) ; returns 1 if the order is an inpatient med or a clinic med/inf
 N ORRET,ORCLMED,ORCLINF,ORIPMED,ORIPMED2,ORTO
 S ORNUM=+ORNUM
 S ORRET=ORTYPE
 Q:'$D(^OR(100,ORNUM)) ORRET
 S ORTO=$P(^OR(100,ORNUM,0),U,11)
 I ORTO=$O(^ORD(100.98,"B","CLINIC MEDICATIONS",0)) S ORRET="I"
 I ORTO=$O(^ORD(100.98,"B","CLINIC INFUSIONS",0)) S ORRET="I"
 I ORTO=$O(^ORD(100.98,"B","UNIT DOSE MEDICATIONS",0)) S ORRET="I"
 I ORTO=$O(^ORD(100.98,"B","INPATIENT MEDICATIONS",0)) S ORRET="I"
 I ORTO=$O(^ORD(100.98,"B","OUTPATIENT MEDICATIONS",0)) S ORRET="O"
 I ORTO=$O(^ORD(100.98,"B","SPLY",0)) S ORRET="O"
 Q ORRET