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

ORALWORD.m

Go to the documentation of this file.
  1. ORALWORD ; SLC/JMH - Utilities for Checking if an order can be ordered ;Apr 21, 2021@10:02:50
  1. ;;3.0;ORDER ENTRY/RESULTS REPORTING;**243,427,405,499**;Dec 17, 1997;Build 165
  1. ;External reference $$CL^YSCLTST2 controlled by DBIA 4556
  1. ;External reference $$OVERRIDE^YSCLTST2 controlled by DBIA 4556
  1. ;Reference to ^DIQ supported by DBIA #2056
  1. ;Reference to ^PSS50 supported by DBIA #4533
  1. ;Reference to $$DEA^XUSER supported by DBIA #2343
  1. ;
  1. ALLWORD(ORY,DFN,ORX,ORTYPE,PROV) ;
  1. N OROI,ORYS,QOIEN,QPIEN,ORCLOZ,QOAA,DPKG
  1. S OROI=0
  1. ;
  1. ;ORTYPE used to determine the type of data coming into the call
  1. ;ORYTPE="E" existing order, ORX equal the IEN from file 100 (used with
  1. ;copy,edit functionality)
  1. ;ORTYPE="Q" Quick Order, ORX equal the IEN from file 101.41
  1. ;ORTYPE="N" New order, ORX equal the IEN from file 101.41
  1. ;
  1. I ORTYPE="E" S OROI=$G(^OR(100,ORX,.1,1,0)) N ORTXT D TEXT^ORQ12(.ORTXT,ORX) ; ajb added N and TEXT call
  1. I ORTYPE="Q" D
  1. .S QPIEN=$O(^ORD(101.41,"AB","OR GTX ORDERABLE ITEM","")) Q:QPIEN'>0
  1. .S QOIEN=$O(^ORD(101.41,ORX,6,"D",QPIEN,"")) Q:QOIEN'>0
  1. .S OROI=$G(^ORD(101.41,ORX,6,QOIEN,1))
  1. .S QOAA=$P($G(^ORD(101.41,ORX,5)),U,8)
  1. I ORTYPE="N" S OROI=ORX
  1. Q:OROI'>0
  1. ; patch 499
  1. N ORZIPOK S ORZIPOK=1 D I 'ORZIPOK Q
  1. . I $G(DLGIEN) S DPKG=$P($G(^ORD(101.41,+DLGIEN,0)),U) I $L(DPKG),(DPKG'["PSO") Q
  1. . D ZIP^ORWDPS11(.ORZIPOK,OROI,"PSO",DFN) I 'ORZIPOK D
  1. . . N COUNT,ORY0 S COUNT=+$O(ORY(""),-1)+1,ORY(COUNT)=$P(ORZIPOK,"^",2)
  1. . . S ORY0="Order Not Placed - Missing Patient Address"
  1. . . S ORY(0)=$S($L($G(ORY(0))):$G(ORY(0))_" | "_ORY0,1:ORY0)
  1. ;
  1. S ORY=0
  1. ;checks if the orderable item (OROI) is a clozapine med
  1. ; if not returns ORY=0
  1. S ORCLOZ=$$ISCLOZ(OROI),ORY=ORY_U_ORCLOZ,ORY(0)=U_ORCLOZ
  1. Q:'ORCLOZ
  1. N ORQUIT
  1. S ORQUIT=0
  1. I '$G(PROV) S PROV=DUZ
  1. I $G(PROV) D ; ajb v32 *405
  1. . N ORDEA,ORKEY S (ORDEA,ORKEY)=0
  1. . I '$L($$DEA^XUSER(,PROV)) S ORDEA=1
  1. . I '$D(^XUSEC("YSCL AUTHORIZED",PROV)) S ORKEY=1
  1. . I +ORDEA!+ORKEY D
  1. . . S ORQUIT=1,ORY=1
  1. . . S ORY(1)="Warning: This CLOZAPINE order will NOT be "_$S(ORTYPE="E":"transferred.",1:"placed.")
  1. . . S ORY(2)=""
  1. . . I +$D(ORTXT) S ORY(3)="" D
  1. . . . N X S X=0 F S X=$O(ORTXT(X)) Q:'+X S ORY(3)=ORY(3)_ORTXT(X)
  1. . . S:$G(ORY(3))'="" ORY(4)=""
  1. . . S ORY(5)="You are NOT authorized to place CLOZAPINE orders."
  1. . . S ORY(6)=""
  1. . . S ORY(7)="Reason: "_$S(+ORDEA&+ORKEY:"You do not have a DEA# and missing key YSCL AUTHORIZED.",+ORDEA:"You do not have a DEA#.",1:"You are missing key YSCL AUTHORIZED.")
  1. . . S ORY(8)=""
  1. . . S ORY(9)="Contact your Pharmacy for more information about the authorization requirements for ordering CLOZAPINE."
  1. . . N ORMSG D GETWP^XPAR(.ORMSG,"SYS","OR CPRS CLOZAPINE CUSTOM MSG")
  1. . . I +$D(ORMSG) S ORMSG=0 F S ORMSG=$O(ORMSG(ORMSG)) Q:'+ORMSG S ORY(8+ORMSG)=ORMSG(ORMSG,0) ; replace ORY(9) with custom message line(s)
  1. . . ;S ORY(1)="*** You are not authorized to place Clozapine orders."
  1. . . ;S ORY(2)="You must have a DEA#. Please contact your"
  1. . . ;S ORY(3)="CAC or IRM for more information. ***"
  1. . . ;S ORY(1)="*** You are not authorized to place Clozapine orders."
  1. . . ;S ORY(2)="You must hold key YSCL AUTHORIZED. Please contact your"
  1. . . ;S ORY(3)="CAC or IRM for more information on this key. ***"
  1. Q:ORQUIT
  1. ; if is a cloz med , check if patient (DFN) can have a clozapine med
  1. S ORYS=$$CL^YSCLTST2(DFN)
  1. ; if yes returns ORY=0
  1. I +ORYS>0 D BEFQUIT Q
  1. ; if no
  1. ; returns
  1. ; ORY=1
  1. ; ORY(0)=CAPTION FOR DIALOG BOX
  1. ; ORY(1-N)=MESSAGE TO DISPLAY
  1. S ORY=1_U_ORCLOZ,ORY(0)="Problem Ordering Clozapine Related Medication"_U_ORCLOZ
  1. ;patient not in clozapine patient program
  1. ;; START NCC REMEDIATION >> 427*RJS
  1. I +ORYS<0 D Q
  1. .S ORY(1)="*** This patient is not registered in the clozapine treatment "
  1. .S ORY(2)="program or has been discontinued from the program. A new"
  1. .S ORY(3)="registration number must be assigned. If this is not an emergency,"
  1. .S ORY(4)="contact the NCCC. For emergency registration during non-NCCC duty"
  1. .S ORY(5)="hours, a written order to the pharmacist can be used to process a"
  1. .S ORY(6)="registration override. ***"
  1. ;problem with lab tests
  1. I +ORYS=0 D Q
  1. .I $$OVERRIDE^YSCLTST2(DFN) S ORY=0_U_ORCLOZ,ORY(0)=U_ORCLOZ D BEFQUIT Q ;override allowed
  1. .I +$P(ORYS,"^",2),$P(ORYS,"^",4)<1000 D
  1. ..N COUNT S COUNT=0
  1. ..S COUNT=COUNT+1,ORY(COUNT)="*** This clozapine drug may not be dispensed to the patient at this "
  1. ..S COUNT=COUNT+1,ORY(COUNT)="time based on the available lab tests related to the clozapine "
  1. ..S COUNT=COUNT+1,ORY(COUNT)="treatment program. Please contact the NCCC to request an override in"
  1. ..S COUNT=COUNT+1,ORY(COUNT)="order to proceed with dispensing this drug. ***"
  1. ..D DISPRSLT
  1. .I '$P(ORYS,U,2),$P(ORYS,U,4) D
  1. ..N COUNT S COUNT=0
  1. ..S COUNT=COUNT+1,ORY(COUNT)="*** Permission to dispense clozapine has been denied based on the available"
  1. ..S COUNT=COUNT+1,ORY(COUNT)="lab tests related to the clozapine treatment program.***"
  1. ..S COUNT=COUNT+1,ORY(COUNT)=""
  1. ..S COUNT=COUNT+1,ORY(COUNT)="The latest lab test results drawn in the past 7 days have ANC results but no"
  1. ..S COUNT=COUNT+1,ORY(COUNT)="matching WBC. Redo the lab tests or contact the NCCC for a National Override"
  1. ..S COUNT=COUNT+1,ORY(COUNT)="to dispense clozapine with no matching WBC results."
  1. ..D DISPRSLT
  1. .I '+$P(ORYS,"^",4) D MSG
  1. Q
  1. MSG ;
  1. N COUNT S COUNT=0
  1. S COUNT=COUNT+1,ORY(COUNT)="*** Permission to dispense clozapine has been denied based on the"
  1. S COUNT=COUNT+1,ORY(COUNT)="available lab tests related to the clozapine treatment program. ***"
  1. S COUNT=COUNT+1,ORY(COUNT)=""
  1. I $P($G(X0),U)["PSJ" D DISPRSLT S COUNT=COUNT+1,ORY(COUNT)=""
  1. S COUNT=COUNT+1,ORY(COUNT)="For a National Override to dispense at the patient's normal"
  1. S COUNT=COUNT+1,ORY(COUNT)="frequency, contact the NCCC."
  1. S COUNT=COUNT+1,ORY(COUNT)=""
  1. D:$D(X0) ;; NCC REMEDIATION << 427 RTW Special Conditions selections for outpatient and inpatient RTW
  1. .I $P(X0,U,1)["PSO" D
  1. ..S COUNT=COUNT+1,ORY(COUNT)="A local emergency override for an Outpatient can be approved for:"
  1. ..S COUNT=COUNT+1,ORY(COUNT)="(1) weather-related conditions, (2) mail order delays of clozapine,"
  1. ..S COUNT=COUNT+1,ORY(COUNT)="or (3) inpatient going on leave."
  1. ..S COUNT=COUNT+1,ORY(COUNT)=""
  1. ..S COUNT=COUNT+1,ORY(COUNT)="For an Outpatient Special Conditions Local Override, a written prescription from"
  1. ..S COUNT=COUNT+1,ORY(COUNT)="the provider with documentation to the pharmacist is required to dispense"
  1. ..S COUNT=COUNT+1,ORY(COUNT)="a one-time emergency 4-day supply."
  1. .I $P(X0,U,1)["PSJ" D
  1. ..S COUNT=COUNT+1,ORY(COUNT)="A local emergency override for an Inpatient can be approved for:"
  1. ..S COUNT=COUNT+1,ORY(COUNT)="IP Order Override with Outside Lab Results"
  1. ..S COUNT=COUNT+1,ORY(COUNT)=""
  1. ..S COUNT=COUNT+1,ORY(COUNT)="For a Special Conditions Local Override, a written order from"
  1. ..S COUNT=COUNT+1,ORY(COUNT)="the provider with documentation to the pharmacist is required to"
  1. ..S COUNT=COUNT+1,ORY(COUNT)="dispense a one-time 4-day supply."
  1. ..S COUNT=COUNT+1,ORY(COUNT)=""
  1. ..S COUNT=COUNT+1,ORY(COUNT)="The provider must record the ANC from another facility including date/time in both the Provider Progress Note and Comment field in CPRS."
  1. Q
  1. DISPRSLT ; Display Lab Tests
  1. S COUNT=COUNT+1,ORY(COUNT)="Related Lab Test(s)"
  1. S COUNT=COUNT+1,ORY(COUNT)="==================="
  1. I $L($P(ORYS,U,3)) S COUNT=COUNT+1,ORY(COUNT)="WBC: "_($P(ORYS,U,2)/1000)_" K/cmm"
  1. E S COUNT=COUNT+1,ORY(COUNT)="WBC: NO TEST RESULTS FOUND"
  1. I $L($P(ORYS,U,5)) S COUNT=COUNT+1,ORY(COUNT)="ANC: "_($P(ORYS,U,4)/1000)_" K/cmm"
  1. E S COUNT=COUNT+1,ORY(COUNT)="ANC: NO TEST RESULTS FOUND"
  1. S COUNT=COUNT+1,ORY(COUNT)="Date/Time of last tests: "_$$DATE^ORU($P(ORYS,U,6))
  1. Q
  1. ;; END NCC REMEDIATION << 427*RTW
  1. BEFQUIT ;
  1. Q:'$G(QOAA)
  1. N QODS,QORF,ORMAX,ORCLPAT
  1. S QODS=$O(^ORD(101.41,"AB","OR GTX DAYS SUPPLY","")) Q:QODS'>0
  1. S QODS=$O(^ORD(101.41,ORX,6,"D",QODS,"")) Q:QOIEN'>0
  1. S QODS=$G(^ORD(101.41,ORX,6,QODS,1))
  1. S QORF=$O(^ORD(101.41,"AB","OR GTX REFILLS","")) Q:QORF'>0
  1. S QORF=$O(^ORD(101.41,ORX,6,"D",QORF,"")) Q:QOIEN'>0
  1. S QORF=$G(^ORD(101.41,ORX,6,QORF,1))
  1. S QORF=QORF+1
  1. S ORCLPAT=$P(ORYS,U,7)
  1. S ORMAX=$S(ORYS="M":28,ORYS="B":14,ORYS="W":7,1:90)
  1. I QORF*QODS>ORMAX D
  1. .K ORY
  1. .S ORY=1_U_ORCLOZ,ORY(0)="Problem Ordering Clozapine Related Medication"_U_ORCLOZ
  1. .S ORY(1)="*** This patient is only allowed an order with a maximum Days Supply of "_ORMAX_"."
  1. .S ORY(2)="This includes the amounts added by any refills entered in with the order also."
  1. Q
  1. ISCLOZ(OROI) ;
  1. N ORPSOI,ORPSDRUG,ISCLOZ
  1. S ORPSOI=$$GET1^DIQ(101.43,OROI,2)
  1. I $P(ORPSOI,";",2)'="99PSP" Q 0
  1. K ^TMP($J,"ORCLOZ")
  1. D ASP^PSS50(+ORPSOI,,,"ORCLOZ")
  1. S (ORPSDRUG,ISCLOZ)=0
  1. F S ORPSDRUG=$O(^TMP($J,"ORCLOZ",ORPSDRUG)) Q:'ORPSDRUG D Q:ISCLOZ
  1. .K ^TMP($J,"ORCLOZ2")
  1. .D CLOZ^PSS50(ORPSDRUG,,,,,"ORCLOZ2")
  1. .I $G(^TMP($J,"ORCLOZ2",ORPSDRUG,"CLOZ",0))>0 S ISCLOZ=1
  1. K ^TMP($J,"ORCLOZ"),^TMP($J,"ORCLOZ2")
  1. Q ISCLOZ
  1. ALLWRN(ORY,ORN,REFILLS) ;allow order to be renewed
  1. ;ORN is the order number
  1. ;REFILLS is the number of refills to be included with the renewed order
  1. N ORDS,ORQT,ORUPD,ORSCH,ORDUR,ORDFN,ORDRG,OROI,ORMAXDS,ORMAXQT,ORCLOZ,ORREF,ORMAXREF
  1. ;default return 1 (ORY=1 means allow renew)
  1. S ORY=1
  1. ;get DFN (ORDFN)
  1. S ORDFN=+$P(^OR(100,ORN,0),U,2)
  1. Q:'ORDFN
  1. ;get if order is a clozapine order (ORCLOZ)
  1. S OROI=$G(^OR(100,ORN,.1,1,0)) Q:'OROI
  1. S ORCLOZ=$$ISCLOZ(OROI)
  1. ;quit if order is not clozapine
  1. I 'ORCLOZ Q
  1. ;get schedule from order (ORSCH)
  1. S ORSCH=$G(^OR(100,ORN,4.5,$O(^OR(100,ORN,4.5,"ID","SCHEDULE",0)),1))
  1. ;get units per dose from order (ORUPD)
  1. S ORSCH=$G(^OR(100,ORN,4.5,$O(^OR(100,ORN,4.5,"ID","DOSE",0)),1))
  1. S ORSCH=$P(ORSCH,"&",3)
  1. ;get duration from order (ORDUR)
  1. I '$O(^OR(100,ORN,4.5,"ID","DURATION",0)) S ORDUR="~^"
  1. E S ORSCH=$G(^OR(100,ORN,4.5,$O(^OR(100,ORN,4.5,"ID","DURATION",0)),1))
  1. ;get days supply from order (ORDS)
  1. S ORSCH=$G(^OR(100,ORN,4.5,$O(^OR(100,ORN,4.5,"ID","SUPPLY",0)),1))
  1. ;get drug (ptr50) from order (ORDRG)
  1. S ORSCH=$G(^OR(100,ORN,4.5,$O(^OR(100,ORN,4.5,"ID","DRUG",0)),1))
  1. ;get refills from order (ORREF)
  1. S ORSCH=$G(^OR(100,ORN,4.5,$O(^OR(100,ORN,4.5,"ID","REFILLS",0)),1))
  1. ;get quantity from order (ORQT)
  1. S ORSCH=$G(^OR(100,ORN,4.5,$O(^OR(100,ORN,4.5,"ID","QTY",0)),1))
  1. ;get max days supply for order (ORMAXDS)
  1. S ORMAXDS=$$DEFSPLY^ORWDPS1(ORDFN)
  1. ;if ds from order is > max ds return 0 (ORY=0)
  1. I ORDS>ORMAXDS D Q
  1. .S ORY=0
  1. .S ORY(0)="Problem Renewing Clozapine Related Medication"_U_ORCLOZ
  1. .S ORY(1)="The Days Supply set for this order is greater than the Max Days Supply"
  1. .S ORY(2)=" allowed for this patient."
  1. ;get max quantity for order (ORMAXQT)
  1. D DAY2QTY^ORWDPS2(.ORMAXQT,ORDS,ORUPD,ORSCH,ORDUR,ORDFN,ORDRG)
  1. ;if qt from order is > max qt return 0 (ORY=0)
  1. I ORQT>ORMAXQT D Q
  1. .S ORY=0
  1. .S ORY(0)="Problem Renewing Clozapine Related Medication"_U_ORCLOZ
  1. .S ORY(1)="The Quantity set for this order is greater than the Max Quantity"
  1. .S ORY(2)=" allowed for this patient."
  1. ;get max refills for order (ORMAXREF)
  1. D MAXREF^ORWDPS2(.ORMAXREF,ORDFN,ORDRG,ORDS,OROI,1)
  1. ;if refill from order is > max refills return 0 (ORY=0)
  1. I ORREF>ORMAXREF D Q
  1. .S ORY=0
  1. .S ORY(0)="Problem Renewing Clozapine Related Medication"_U_ORCLOZ
  1. .S ORY(1)="The Refills field set for this order is greater than the Refills"
  1. .S ORY(2)=" allowed for this patient with the order having a Days Supply "
  1. .S ORY(3)=" of "_ORDS_"."
  1. Q