1 | ORTSKLPS ;SLC/JMH-nightly task to lapse old unsigned orders ; 4/9/08 10:00am
|
---|
2 | ;;3.0;ORDER ENTRY/RESULTS REPORTING;**243**;Dec 17, 1997;Build 242
|
---|
3 | ;
|
---|
4 | TASK ;
|
---|
5 | ;only run between Midnight and 1:59:59 AM
|
---|
6 | I $E($P($$NOW^XLFDT,".",2),1,2)>1 Q
|
---|
7 | ;don't run if run recently (within 4 hours)
|
---|
8 | ;I $$FMDIFF^XLFDT($$NOW^XLFDT,$G(^XTMP("OR LAPSE ORDERS","LAST TIME")),2)<14400 Q
|
---|
9 | ;set timestamp of last run
|
---|
10 | S ^XTMP("OR LAPSE ORDERS",0)=$$FMADD^XLFDT($$NOW^XLFDT,2)_U_$$NOW^XLFDT
|
---|
11 | S ^XTMP("OR LAPSE ORDERS","LAST TIME")=$$NOW^XLFDT
|
---|
12 | ;loop through unsigned orders
|
---|
13 | N ORVP,ORDT,ORN,ORACT,ORINVDT,ORPARAM,ORDIAL,ORDISP
|
---|
14 | S ORVP="" F S ORVP=$O(^OR(100,"AS",ORVP)) Q:'$L(ORVP) D
|
---|
15 | .S ORINVDT=0 F S ORINVDT=$O(^OR(100,"AS",ORVP,ORINVDT)) Q:'ORINVDT D
|
---|
16 | ..S ORDT=9999999-ORINVDT
|
---|
17 | ..S ORN=0 F S ORN=$O(^OR(100,"AS",ORVP,ORINVDT,ORN)) Q:'ORN D
|
---|
18 | ...;don't lapse if order does not have a status of unreleased (11)
|
---|
19 | ...Q:$P($G(^OR(100,ORN,3)),U,3)'=11
|
---|
20 | ...;get order action
|
---|
21 | ...S ORACT=$O(^OR(100,"AS",ORVP,ORINVDT,ORN,""))
|
---|
22 | ...;get order dialog
|
---|
23 | ...S ORDIAL=$P($G(^OR(100,ORN,0)),U,5)
|
---|
24 | ...I $P(ORDIAL,";",2)='"ORD(101.41," Q
|
---|
25 | ...;using order dialog get display group
|
---|
26 | ...S ORDISP=$P($G(^ORD(101.41,+ORDIAL,0)),U,5)
|
---|
27 | ...I +ORDISP S ORDISP=$P($G(^ORD(100.98,+ORDISP,0)),U)
|
---|
28 | ...;get lapse parameter for display group
|
---|
29 | ...I $L(ORDISP) S ORPARAM=$$GET^XPAR("ALL","OR LAPSE ORDERS",ORDISP)
|
---|
30 | ...;get default lapse parameter if one for display group not set
|
---|
31 | ...I '$G(ORPARAM) S ORPARAM=$$GET^XPAR("ALL","OR LAPSE ORDERS DFLT")
|
---|
32 | ...;quit if ORPARAM isn't even set
|
---|
33 | ...Q:'$L(ORPARAM)
|
---|
34 | ...;quit if order is not older than T-(days for lapse)
|
---|
35 | ...I $$FMDIFF^XLFDT($$NOW^XLFDT,ORDT,1)<ORPARAM Q
|
---|
36 | ...;if old then lapse
|
---|
37 | ...D LAPSE^ORCSAVE2(ORN_";"_ORACT)
|
---|
38 | ;loop through pending events
|
---|
39 | N ORPT,OREVT,ORPTR,Y
|
---|
40 | S ORPT="" F S ORPT=$O(^ORE(100.2,"AE",ORPT)) Q:'ORPT D
|
---|
41 | .S OREVT="" F S OREVT=$O(^ORE(100.2,"AE",ORPT,OREVT)) Q:'OREVT D
|
---|
42 | ..S ORPTR="" F S ORPTR=$O(^ORE(100.2,"AE",ORPT,OREVT,ORPTR)) Q:'ORPTR S Y=$$LAPSED^OREVNTX(ORPTR)
|
---|
43 | Q
|
---|