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

ORY134.m

Go to the documentation of this file.
  1. ORY134 ;SLC/DAN ;3/28/02 12:35
  1. ;;3.0;ORDER ENTRY/RESULTS REPORTING;**134**;Dec 17, 1997
  1. ;
  1. ;Finds current orders with incorrect fractional dose entries containing two decimal places.
  1. ;
  1. N ORMSG,ZTSK
  1. S ORMSG(1)=""
  1. S ORMSG(2)="This patch contains a post-init. This post-init will"
  1. S ORMSG(3)="run in the background and will identify potential fractional dose problems."
  1. S ORMSG(4)="It will then send a mail message to the iniator and holders of the PSNMGR key"
  1. S ORMSG(5)="indicating which orders need to be reviewed."
  1. S ORMSG(6)=""
  1. D MES^XPDUTL(.ORMSG)
  1. S ZTRTN="DQ^ORY134",ZTDESC="Patch OR*3*134 database review",ZTIO="",ZTSAVE("DUZ")="",ZTDTH=$H
  1. D ^%ZTLOAD
  1. I $G(ZTSK) D MES^XPDUTL("Post-init queued to background as task number "_ZTSK_".")
  1. Q
  1. ;
  1. DQ ;Enter here for queued task
  1. K ^TMP("ORFIX",$J)
  1. D FIX,MAIL
  1. K ^TMP("ORFIX",$J),^TMP("ORTXT",$J)
  1. Q
  1. ;
  1. FIX ;This section will identify active orders with fractional dose problems
  1. N PAT,DATE,IEN,PTID
  1. S PAT=""
  1. F S PAT=$O(^OR(100,"AC",PAT)) Q:PAT="" D
  1. .S DATE=0 F S DATE=$O(^OR(100,"AC",PAT,DATE)) Q:'+DATE D
  1. ..S IEN=0 F S IEN=$O(^OR(100,"AC",PAT,DATE,IEN)) Q:'+IEN D
  1. ...Q:$$NMSP^ORCD($P($G(^OR(100,IEN,0)),U,14))'="PS" ;quit if not pharmacy
  1. ...S PTID=$$PTID(PAT) Q:PTID=-1 ;get patient ID quit if referral or couldn't determine name
  1. ...I $$VALUE^ORX8(IEN,"INSTR")["0.." I '$$UPDT S ^TMP("ORFIX",$J,$P($$STATUS^ORQOR2(IEN),U,2),PTID,IEN)=$$DRUG
  1. Q
  1. ;
  1. MAIL ;Send results of review in a mail message to initiator
  1. N I,XMSUB,XMTEXT,XMDUZ,XMY,STA,IEN,PAT
  1. S XMSUB="Patch OR*3*134 review completed"
  1. S XMDUZ="Patch OR*3*134 Post-Init"
  1. S XMY(.5)="" S:$G(DUZ) XMY(DUZ)="" D PSNMGR(.XMY)
  1. S XMTEXT="^TMP(""ORTXT"",$J,"
  1. K ^TMP("ORTXT",$J)
  1. S I=1
  1. S ^TMP("ORTXT",$J,I)="The database review for patch OR*3*134 has completed.",I=I+1
  1. S ^TMP("ORTXT",$J,I)="Below is a listing of patients that need to have",I=I+1
  1. S ^TMP("ORTXT",$J,I)="their prescriptions reviewed and possibly updated.",I=I+1
  1. S ^TMP("ORTXT",$J,I)="",I=I+1
  1. S ^TMP("ORTXT",$J,I)="For orders in an active (active, pending, hold, etc) state it is",I=I+1
  1. S ^TMP("ORTXT",$J,I)="recommended that the order be evaluated and updated according to",I=I+1
  1. S ^TMP("ORTXT",$J,I)="the following guidelines.",I=I+1
  1. S ^TMP("ORTXT",$J,I)="",I=I+1
  1. S ^TMP("ORTXT",$J,I)="If the order has refills remaining or if the order can",I=I+1
  1. S ^TMP("ORTXT",$J,I)="potentially be renewed, edit the invalid dosage which will",I=I+1
  1. S ^TMP("ORTXT",$J,I)="create a new order with a valid SIG. The appropriate number",I=I+1
  1. S ^TMP("ORTXT",$J,I)="of remaining refills must then be added to the new order.",I=I+1
  1. S ^TMP("ORTXT",$J,I)="",I=I+1
  1. S ^TMP("ORTXT",$J,I)="If the order has no refills remaining and the order will not",I=I+1
  1. S ^TMP("ORTXT",$J,I)="be renewed then the order should be discontinued.",I=I+1
  1. S ^TMP("ORTXT",$J,I)="",I=I+1
  1. S ^TMP("ORTXT",$J,I)="Depending on the status of the order the DRUG listed in the report",I=I+1
  1. S ^TMP("ORTXT",$J,I)="will either be a dispense drug or an orderable item.",I=I+1
  1. S ^TMP("ORTXT",$J,I)="",I=I+1
  1. I '$D(^TMP("ORFIX",$J)) S ^TMP("ORTXT",$J,I)="No problems were found. No manual intervention is required.",I=I+1
  1. S ^TMP("ORTXT",$J,I)="",I=I+1
  1. S STA="" F S STA=$O(^TMP("ORFIX",$J,STA)) Q:STA="" D
  1. .S ^TMP("ORTXT",$J,I)="Order Status - "_STA,I=I+1,^TMP("ORTXT",$J,I)="",I=I+1
  1. .S PAT=0 F S PAT=$O(^TMP("ORFIX",$J,STA,PAT)) Q:PAT="" D
  1. ..S IEN=0 F S IEN=$O(^TMP("ORFIX",$J,STA,PAT,IEN)) Q:'+IEN D
  1. ...S ^TMP("ORTXT",$J,I)=PAT_$$REPEAT^XLFSTR(" ",(40-$L(PAT)))_"DRUG = "_^TMP("ORFIX",$J,STA,PAT,IEN),I=I+1
  1. .S ^TMP("ORTXT",$J,I)="",I=I+1
  1. D ^XMD ;send results
  1. Q
  1. ;
  1. PTID(IEN) ;Return pt name and 1A4U identifiers or -1 if unable to determine
  1. N DFN,VADM
  1. I +IEN=0!(IEN'["DPT") Q -1
  1. S DFN=+IEN
  1. D ^VADPT
  1. I $G(VADM(1))="" Q -1
  1. Q $E(VADM(1),1)_$E(VADM(2),6,9)_" "_VADM(1)
  1. ;
  1. UPDT() ;Function to determine if order has been updated yet.
  1. N TXT,I,UPDT
  1. S UPDT=1
  1. D TEXT^ORQ12(.TXT,IEN_";"_$P($G(^OR(100,IEN,3)),U,7),80) ;get current order text
  1. F I=1:1:TXT I TXT(I)["0.." S UPDT=0 Q
  1. Q UPDT
  1. ;
  1. DRUG() ;Get dispense drug or orderable item
  1. N VALUE
  1. S VALUE=$$VALUE^ORX8(IEN,"DRUG",,"E")
  1. I VALUE="" S VALUE=$$VALUE^ORX8(IEN,"ORDERABLE",,"E")
  1. Q VALUE
  1. ;
  1. PSNMGR(XMY) ;Add PSNMGR key holders to XMY array
  1. ;DBIA 10076 allows direct read of XUSEC
  1. N USER
  1. S USER=0 F S USER=$O(^XUSEC("PSNMGR",USER)) Q:'USER S XMY(USER)=""
  1. Q