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

ORY216.m

Go to the documentation of this file.
  1. ORY216 ;SLC/MKB - Clean-up existing Allergy orders ;3/16/04 14:28
  1. ;;3.0;ORDER ENTRY/RESULTS REPORTING;**216**;Dec 17, 1997
  1. ;
  1. POST ; -- postinit
  1. N ORDG,ORX S ORDG=+$O(^ORD(100.98,"B","ALG",0)) Q:ORDG'>0
  1. S $P(^ORD(100.98,ORDG,0),U,4)="" ;clear Default Dialog
  1. S ORX("GMRAOR ALLERGY ENTER/EDIT")="" D EN^ORYDLG(216,.ORX)
  1. D TASK
  1. Q
  1. ;
  1. TASK ; -- queue job to complete ART orders
  1. Q:$G(^XTMP("ORGMRA","PAT"))<0 ;already done
  1. N ZTDESC,ZTRTN,ZTIO,ZTSAVE,ZTDTH,ZTSK,ORMSG
  1. S ORMSG(1)="A background job has been queued to complete any currently active"
  1. S ORMSG(2)="Allergy/Adverse Reaction orders." D MES^XPDUTL(.ORMSG)
  1. S ZTDESC="Mark ART orders as complete",ZTRTN="EN^ORY216"
  1. S ZTIO="",ZTDTH=$H,ZTSAVE("DUZ")="" D ^%ZTLOAD K ORMSG
  1. S ORMSG="Task "_$S($G(ZTSK):"#"_ZTSK,1:"not")_" started."
  1. D MES^XPDUTL(ORMSG)
  1. I '$G(ZTSK) D BMES^XPDUTL("Use TASK^ORY216 to queue this job to complete ART orders as soon as possible!")
  1. Q
  1. ;
  1. EN ; -- main loop to complete ART orders on:
  1. ; ^OR(100,"ACT",ORVP,invORLOG,ORDG,ORIFN)
  1. ;
  1. N ORDG,ORNOW,ORVP,ORLOG,ORIFN
  1. S ORDG=+$O(^ORD(100.98,"B","ALG",0)) Q:ORDG'>0
  1. S ORNOW=+$E($$NOW^XLFDT,1,12),ORVP=$G(^XTMP("ORGMRA","PAT")) I '$D(^(0)) D
  1. . S ^XTMP("ORGMRA",0)=$$FMADD^XLFDT(ORNOW,90)_U_ORNOW_"^ART orders completion"
  1. F S ORVP=$O(^OR(100,"ACT",ORVP)) Q:ORVP="" D Q:$G(ZTSTOP)
  1. . S ORLOG=0 F S ORLOG=$O(^OR(100,"ACT",ORVP,ORLOG)) Q:ORLOG'>0 D
  1. .. S ORIFN=0 F S ORIFN=+$O(^OR(100,"ACT",ORVP,ORLOG,ORDG,ORIFN)) Q:ORIFN'>0 D
  1. ... Q:$P($G(^OR(100,ORIFN,3)),U,3)=2 ;already completed
  1. ... D STATUS^ORCSAVE2(ORIFN,2) S $P(^OR(100,ORIFN,6),U,6)=ORNOW
  1. . S ^XTMP("ORGMRA","PAT")=ORVP
  1. . I $D(ZTQUEUED) S:$$S^%ZTLOAD ZTSTOP=1 Q:$G(ZTSTOP)
  1. I '$G(ZTSTOP) S ^XTMP("ORGMRA","PAT")=-1 D MAIL ;done
  1. Q
  1. ;
  1. MAIL ; -- Send completion message to user who initiated conversion
  1. N XMSUB,XMTEXT,XMDUZ,XMY,XMZ,XMMG,ORTXT,DIFROM
  1. S XMDUZ="PATCH OR*3*216 ART ORDERS COMPLETION",XMY(.5)="" S:$G(DUZ) XMY(DUZ)=""
  1. S ORTXT(1)="The task triggered by patch OR*3*216"_$S($G(ZTSK):" (Task #"_ZTSK_")",1:"")_" to complete ART orders"
  1. S ORTXT(2)="finished at "_$$FMTE^XLFDT($$NOW^XLFDT)_"."
  1. S XMTEXT="ORTXT(",XMSUB="PATCH OR*3*216 ART ORDERS COMPLETED"
  1. D ^XMD
  1. Q