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

ORTSKLPS.m

Go to the documentation of this file.
  1. ORTSKLPS ;SLC/JMH - NIGHTLY TASK TO LAPSE OLD UNSIGNED ORDERS;03/27/2015 11:45
  1. ;;3.0;ORDER ENTRY/RESULTS REPORTING;**243,280,350**;Dec 17, 1997;Build 77
  1. ;
  1. TASK ;
  1. ;only run between Midnight and 1:59:59 AM
  1. ;I $E($P($$NOW^XLFDT,".",2),1,2)>1 Q
  1. ;don't run if run recently (within 4 hours)
  1. ;I $$FMDIFF^XLFDT($$NOW^XLFDT,$G(^XTMP("OR LAPSE ORDERS","LAST TIME")),2)<14400 Q
  1. ;set timestamp of last run
  1. S ^XTMP("OR LAPSE ORDERS",0)=$$FMADD^XLFDT($$NOW^XLFDT,2)_U_$$NOW^XLFDT
  1. S ^XTMP("OR LAPSE ORDERS","LAST TIME")=$$NOW^XLFDT
  1. ;loop through unsigned orders
  1. N ORVP,ORDT,ORN,ORACT,ORINVDT,ORPARAM,ORDIAL,ORDISP
  1. S ORVP="" F S ORVP=$O(^OR(100,"AS",ORVP)) Q:'$L(ORVP) D
  1. .N ORDATA,ORDERERS
  1. .S ORINVDT=0 F S ORINVDT=$O(^OR(100,"AS",ORVP,ORINVDT)) Q:'ORINVDT D
  1. ..S ORDT=9999999-ORINVDT
  1. ..S ORN=0 F S ORN=$O(^OR(100,"AS",ORVP,ORINVDT,ORN)) Q:'ORN D
  1. ...;don't lapse if order does not have a status of unreleased (11)
  1. ...Q:$P($G(^OR(100,ORN,3)),U,3)'=11
  1. ...;get order action
  1. ...S ORACT=$O(^OR(100,"AS",ORVP,ORINVDT,ORN,""))
  1. ...;get order dialog
  1. ...S ORDIAL=$P($G(^OR(100,ORN,0)),U,5)
  1. ...I $P(ORDIAL,";",2)='"ORD(101.41," Q
  1. ...;using order dialog get display group
  1. ...S ORDISP=$P($G(^ORD(101.41,+ORDIAL,0)),U,5)
  1. ...I +ORDISP S ORDISP=$P($G(^ORD(100.98,+ORDISP,0)),U)
  1. ...;get lapse parameter for display group
  1. ...I $L(ORDISP) S ORPARAM=$$GET^XPAR($$ENT(ORN),"OR LAPSE ORDERS",ORDISP)
  1. ...;get default lapse parameter if one for display group not set
  1. ...I '$G(ORPARAM) S ORPARAM=$$GET^XPAR($$ENT(ORN),"OR LAPSE ORDERS DFLT")
  1. ...;quit if ORPARAM isn't even set
  1. ...Q:'$L(ORPARAM)
  1. ...;quit if order is not older than T-(days for lapse)
  1. ...I $$FMDIFF^XLFDT($$NOW^XLFDT,ORDT,2)<(ORPARAM*24*60*60) Q
  1. ...;if old then lapse
  1. ...D LAPSE^ORCSAVE2(ORN_";"_ORACT)
  1. ...S ORDATA=$S($G(ORDATA)'="":ORDATA_U,1:"")_ORN
  1. ...;Since one alert covers many orders (not passing order number to EN^ORB3), collect the orderer
  1. ...S ORDERERS($$ORDERER^ORQOR2(ORN))=""
  1. .;send notification, one per patient
  1. .D:$D(ORDATA) EN^ORB3(78,+ORVP,"",.ORDERERS,"Lapsed Unsigned Order(s)","NEW;"_ORDATA)
  1. ;loop through pending events
  1. N ORPT,OREVT,ORPTR,Y
  1. S ORPT="" F S ORPT=$O(^ORE(100.2,"AE",ORPT)) Q:'ORPT D
  1. .S OREVT="" F S OREVT=$O(^ORE(100.2,"AE",ORPT,OREVT)) Q:'OREVT D
  1. ..S ORPTR="" F S ORPTR=$O(^ORE(100.2,"AE",ORPT,OREVT,ORPTR)) Q:'ORPTR S Y=$$LAPSED^OREVNTX(ORPTR)
  1. Q
  1. ENT(ORN) ;get the proper entity for an order
  1. N ORRET,ORHS,ORDIV
  1. S ORRET="ALL"
  1. S ORHS=$P(^OR(100,ORN,0),U,10)
  1. I $G(ORHS)>0 S ORDIV=$P(^SC(+ORHS,0),U,4)
  1. I $G(ORDIV)>0 S ORRET=ORDIV_";DIC(4,^SYS^PKG"
  1. Q ORRET