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

ORTASK01.m

Go to the documentation of this file.
  1. ORTASK01 ; SLC/RJS - Look for orders to purge; [1/2/01 11:44am]
  1. ;;3.0;ORDER ENTRY/RESULTS REPORTING;**98**;Dec 17, 1997
  1. ;
  1. ; QUIT added below by PKS (SLC) on 11/27/2000 to prevent potential
  1. ; for any sites using unfinished ORTASK PURGE as scheduled option:
  1. ;
  1. Q
  1. ;
  1. S ;
  1. N ORCNT,ORT0,ORT3,ORTERR,ORTGRC,ORTNOW,ORTORD,ORTPDT,ORTRUN,X,%DT
  1. ;
  1. I '$G(ZTSK) D HELP S ORTRUN=$$READ("Y","Want to run the purge now ","NO") Q:(ORTRUN[U) Q:('ORTRUN)
  1. ;
  1. S ORTORD=$$GET^XPAR("ALL","ORPF LAST ORDER PURGED") S:(ORTORD<1) ORTORD=0
  1. S ORTGRC=$$GET^XPAR("ALL","ORPF GRACE DAYS BEFORE PURGE") S:(ORTGRC<1) ORTGRC=90
  1. S %DT="",X="T-"_ORTGRC D ^%DT S ORTPDT=+Y
  1. S %DT="",X="T" D ^%DT S ORTNOW=+Y
  1. ;
  1. S ORTERR=0 D F ORCNT=0:1 S ORTORD=$O(^OR(100,ORTORD)) Q:'ORTORD D Q:ORTERR
  1. .Q:'ORTORD Q:ORTERR
  1. .;
  1. .D EN^XPAR("SYS","ORPF LAST ORDER PURGED",1,"`"_ORTORD,.ORTERR) Q:ORTERR
  1. .;
  1. .S ORT0=$G(^OR(100,ORTORD,0))
  1. .S ORT3=$G(^OR(100,ORTORD,3))
  1. .;
  1. .Q:(ORTPDT<ORT3) ; DATE OF LAST ACTIVITY IS AFTER PURGE DATE
  1. .;
  1. .Q:(ORTNOW<$P(ORT0,U,8)) ; ORDER START DATE IS IN THE FUTURE
  1. .;
  1. .Q:'("^0^1^2^7^12^13^14^"[("^"_(+$P(ORT3,U,3))_"^")) ; LAST ACTIVITY STATUS IS NOT TERMINAL
  1. .;
  1. .Q:$P(ORT3,U,9) ; CHILD ORDER
  1. .;
  1. .D PURGE^ORMEVNT(ORTORD)
  1. .;
  1. ;
  1. D EN^XPAR("SYS","ORPF LAST ORDER PURGED",1,"",.ORTERR) Q:ORTERR
  1. D PUT^XPAR("SYS","ORPF LAST PURGE DATE",1,DT,.ORTERR) Q:ORTERR
  1. ;
  1. D:$G(ZTSK) KILL^%ZTLOAD
  1. ;
  1. Q
  1. ;
  1. HELP ;
  1. N LINE,TEXT
  1. W !!
  1. F LINE=1:1:999 S TEXT=$P($T(HELPTEXT+LINE),";",2,999) Q:TEXT W !,$P(TEXT,";",2,999)
  1. W !!
  1. Q
  1. ;
  1. HELPTEXT ;;
  1. ;; Option: ORTASK PURGE (Old Orders Batch Purge)
  1. ;;
  1. ;; This is a purge of all orders that have a 'Last Activity Date' of more
  1. ;; than the number of 'Grace days' ago. It also checks to make sure the
  1. ;; orders that are purged are 'Child' orders, have an order start date in
  1. ;; the past, and have a 'Terminal' status.
  1. ;;
  1. ;; As this option scans the entire Orders file, it should be sheduled to
  1. ;; run after hours.
  1. ;1;
  1. ;
  1. READ(OCXZ0,OCXZA,OCXZB,OCXZL) ;
  1. N OCXLINE,DIR,DTOUT,DUOUT,DIRUT,DIROUT
  1. Q:'$L($G(OCXZ0)) U
  1. S DIR(0)=OCXZ0
  1. S:$L($G(OCXZA)) DIR("A")=OCXZA
  1. S:$L($G(OCXZB)) DIR("B")=OCXZB
  1. F OCXLINE=1:1:($G(OCXZL)-1) W !
  1. D ^DIR
  1. I $D(DTOUT)!$D(DUOUT)!$D(DIRUT)!$D(DIROUT) Q U
  1. Q Y
  1. ;