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

ORY124.m

Go to the documentation of this file.
  1. ORY124 ;SLC/DAN--Find potentially erroneous complex orders ;10/25/01 14:36
  1. ;;3.0;ORDER ENTRY/RESULTS REPORTING;**124**;Dec 17, 1997
  1. ;
  1. N DIC,X,Y,ORMSG,QUE,ORIOPTR,ORION,OREND,%ZIS
  1. I '$G(XPDENV)!($G(^XTMP("ORY124",0))) Q ;Don't process if just loading distribution
  1. D CHECK Q:Y=-1
  1. S ORMSG(1)="A check will now be made to identify any complex pharmacy orders that have",ORMSG(2)="exactly 4 lines associated with them. You should review each entry",ORMSG(3)="for accuracy."
  1. S ORMSG(4)="",ORMSG(5)="This report will be automatically queued to run in the background.",ORMSG(6)="Please select a printer.",ORMSG(7)=""
  1. D MES^XPDUTL(.ORMSG)
  1. S QUE=1
  1. TASK ;
  1. S %ZIS="Q",%ZIS("B")="" S:$G(QUE) %ZIS("S")="I $G(^(""TYPE""))'=""VTRM""" D ^%ZIS I POP D EXIT Q
  1. I $G(QUE)!($D(IO("Q"))) S ZTRTN="DQ^ORY124",ZTDESC="Complex orders search",ZTSAVE("*")="" D ^%ZTLOAD D:'$D(ZTSK) EXIT Q
  1. DQ ;Come here to start
  1. N ORID,ORIEN,DIC,X,Y
  1. K ^TMP($J,"FC")
  1. D CHECK Q:Y=-1
  1. U IO W:$E(IOST,1,2)="C-" !,"Searching..."
  1. S ORID=Y ;Install completion date
  1. S ORID=$$FMADD^XLFDT(ORID\1,-1,,,-1) ;Set start date to install date - 1 day and 1 second
  1. S ORIEN=$O(^OR(100,"AF",+$O(^OR(100,"AF",ORID)),0)) I ORIEN="" D PRINT Q ;Get first order number associated with date of install
  1. F S ORIEN=$O(^OR(100,ORIEN)) Q:'+ORIEN D
  1. .Q:$$NMSP^ORCD($P($G(^OR(100,ORIEN,0)),"^",14))'="PS" ;Quit if not a pharmacy order
  1. .Q:$$DOSE'=4 ;Quit if not 4 doses
  1. .S ^TMP($J,"FC",ORIEN)="" ;Save if pharmacy order with 4 doses
  1. D PRINT,^%ZISC
  1. S ^XTMP("ORY124",0)=$$FMADD^XLFDT(DT,60) ;Set automatic removal to 60 days.
  1. Q
  1. ;
  1. DOSE() ;Returns number of doses associated with order
  1. N DOSE,I
  1. F I=0:0 S I=$O(^OR(100,ORIEN,4.5,"ID","DOSE",I)) Q:'+I S DOSE=$G(DOSE)+1
  1. Q +$G(DOSE)
  1. ;
  1. PRINT ;Print out info associated with order
  1. N PAGE,DATE,J
  1. S PAGE=1,DATE=$$FMTE^XLFDT(DT,"2D")
  1. D HDR
  1. I '$D(^TMP($J,"FC")) W "NO DATA TO REPORT." Q
  1. S J=0 F S J=$O(^TMP($J,"FC",J)) Q:'+J D
  1. .W !,J
  1. .W ?12,$$FMTE^XLFDT($P($G(^OR(100,J,8,1,0)),"^"),"2D")
  1. .W ?25,$$PNM(J)
  1. .W ?58,$P($$STATUS^ORQOR2(J),"^",2)
  1. .D:$Y>(IOSL-4) HDR
  1. Q
  1. ;
  1. HDR ;
  1. N DASH
  1. K DASH
  1. W @IOF,!
  1. W "Complex Orders Search",?35,DATE,?70,"PAGE: ",PAGE,!
  1. W "ORDER #",?12,"ORDER DATE",?25,"PATIENT NAME",?58,"ORDER STATUS"
  1. S $P(DASH,"-",IOM)="" W !,DASH,!
  1. S PAGE=PAGE+1
  1. Q
  1. ;
  1. PNM(ORIEN) ;Returns patient name
  1. N OBJ,FILE,NAME
  1. S OBJ=$P($G(^OR(100,ORIEN,0)),"^",2)
  1. I OBJ="" Q ""
  1. S FILE="^"_$P(OBJ,";",2)
  1. S NAME=$P($G(@(FILE_$P(OBJ,";")_",0)")),"^")
  1. Q NAME
  1. ;
  1. EXIT ;
  1. D BMES^XPDUTL("Report not queued. Please run TASK^ORY124 at a later time to see the report.") Q
  1. ;
  1. CHECK ;Check for patch 94 existence
  1. N IEN
  1. S Y=-1,IEN=0 F S IEN=$O(^XPD(9.7,"B","OR*3.0*94",IEN)) Q:'+IEN I $P($G(^XPD(9.7,IEN,1)),"^",3)'="" S Y=$P(^(1),"^",3) Q ;Get install date from earliest entry
  1. I Y=-1 D BMES^XPDUTL("Patch 94 not installed, complex orders report does not need to run.") Q