- ORALWORD ; SLC/JMH - Utilities for Checking if an order can be ordered ;09-Oct-2013 08:56;PLS
- ;;3.0;ORDER ENTRY/RESULTS REPORTING;**243,1010,1012**;Dec 17, 1997;Build 242
- ;
- ; Modified - IHS/MSC/PLS - 06/17/13 - Added Q1 support for ALLWORD
- ; - 10/09/13 - Changed ALLWORD and ALLWRN to simply quit
- ALLWORD(ORY,DFN,ORX,ORTYPE,PROV) ;
- ;IHS/MSC/PLS - 10/09/2013
- S ORY=0 Q ; IHS doesn't use
- N OROI,ORYS,QOIEN,QPIEN,ORCLOZ,QOAA
- S OROI=0
- ;
- ;ORTYPE used to determine the type of data coming into the call
- ;ORYTPE="E" existing order, ORX equal the IEN from file 100 (used with
- ;copy,edit functionality)
- ;ORTYPE="Q" Quick Order, ORX equal the IEN from file 101.43
- ;ORTYPE="N" New order, ORX equal the IEN from file 101.41
- ;
- I ORTYPE="E" S OROI=$G(^OR(100,ORX,.1,1,0))
- I ORTYPE="Q" D
- .S QPIEN=$O(^ORD(101.41,"AB","OR GTX ORDERABLE ITEM","")) Q:QPIEN'>0
- .S QOIEN=$O(^ORD(101.41,ORX,6,"D",QPIEN,"")) Q:QOIEN'>0
- .S OROI=$G(^ORD(101.41,ORX,6,QOIEN,1))
- .S QOAA=$P($G(^ORD(101.41,ORX,5)),U,8)
- I ORTYPE="Q1" D ;Used when passing ORX as orderable item
- .S OROI=ORX,ORTYPE="Q"
- I ORTYPE="N" S OROI=ORX
- Q:OROI'>0
- S ORY=0
- ;checks if the orderable item (OROI) is a clozapine med
- ; if not returns ORY=0
- S ORCLOZ=$$ISCLOZ(OROI),ORY=ORY_U_ORCLOZ,ORY(0)=U_ORCLOZ
- Q:'ORCLOZ
- N ORQUIT
- S ORQUIT=0
- I '$G(PROV) S PROV=DUZ
- I $G(PROV) D
- .I '$L($$DEA^XUSER(,PROV)) D
- ..S ORQUIT=1,ORY=1
- ..S ORQUIT=1,ORY=1
- ..S ORY(1)="*** You are not authorized to place Clozapine orders."
- ..S ORY(2)="You must have a DEA#. Please contact your"
- ..S ORY(3)="CAC or IRM for more information. ***"
- .Q:ORQUIT
- .I '$D(^XUSEC("YSCL AUTHORIZED",PROV)) D
- ..S ORQUIT=1,ORY=1
- ..S ORY(1)="*** You are not authorized to place Clozapine orders."
- ..S ORY(2)="You must hold key YSCL AUTHORIZED. Please contact your"
- ..S ORY(3)="CAC or IRM for more information on this key. ***"
- Q:ORQUIT
- ; if is a cloz med , check if patient (DFN) can have a clozapine med
- S ORYS=$$CL^YSCLTST2(DFN)
- ; if yes returns ORY=0
- I +ORYS>0 D BEFQUIT Q
- ; if no
- ; returns
- ; ORY=1
- ; ORY(0)=CAPTION FOR DIALOG BOX
- ; ORY(1-N)=MESSAGE TO DISPLAY
- S ORY=1_U_ORCLOZ,ORY(0)="Problem Ordering Clozapine Related Medication"_U_ORCLOZ
- ;patient not in clozapine patient program
- I +ORYS<0 D Q
- .S ORY(1)="*** This patient is not registered in the clozapine treatment "
- .S ORY(2)="program or has been discontinued from the program and must "
- .S ORY(3)="have a new registration number assigned. Contact the NCCC to "
- .S ORY(4)="get this patient registered in the program. ***"
- ;problem with lab tests
- I +ORYS=0 D Q
- .I $$OVERRIDE^YSCLTST2(DFN) S ORY=0_U_ORCLOZ,ORY(0)=U_ORCLOZ D BEFQUIT Q ;override allowed
- .N COUNT S COUNT=0
- .S COUNT=COUNT+1,ORY(COUNT)="*** This clozapine drug may not be dispensed to the patient at this "
- .S COUNT=COUNT+1,ORY(COUNT)="time based on the available lab tests related to the clozapine "
- .S COUNT=COUNT+1,ORY(COUNT)="treatment program. Please contact the NCCC to request an override in"
- .S COUNT=COUNT+1,ORY(COUNT)="order to proceed with dispensing this drug. ***"
- .Q:'$L($P(ORYS,U,3))!('$L($P(ORYS,U,5)))
- .S COUNT=COUNT+1,ORY(COUNT)="Related Lab Test(s)"
- .S COUNT=COUNT+1,ORY(COUNT)="==================="
- .;the lab values returned by Mental Health are given in 4 digit numbers to be standard with
- .;reporting formats to the NCCC, we are dividing by 1000 to align it with the display of the
- .;labs on the lab tab
- .;S:$L($P(ORYS,U,3)) COUNT=COUNT+1,ORY(COUNT)=$P(ORYS,U,3)_": "_($P(ORYS,U,2)/1000)_" K/cmm"
- .;S:$L($P(ORYS,U,5)) COUNT=COUNT+1,ORY(COUNT)=$P(ORYS,U,5)_": "_($P(ORYS,U,4)/1000)_" K/cmm"
- .S:$L($P(ORYS,U,3)) COUNT=COUNT+1,ORY(COUNT)="WBC: "_($P(ORYS,U,2)/1000)_" K/cmm"
- .S:$L($P(ORYS,U,5)) COUNT=COUNT+1,ORY(COUNT)="ANC: "_($P(ORYS,U,4)/1000)_" K/cmm"
- .S COUNT=COUNT+1,ORY(COUNT)="Date/Time of last tests: "_$$DATE^ORU($P(ORYS,U,6))
- Q
- BEFQUIT ;
- Q:'$G(QOAA)
- N QODS,QORF,ORMAX,ORCLPAT
- S QODS=$O(^ORD(101.41,"AB","OR GTX DAYS SUPPLY","")) Q:QODS'>0
- S QODS=$O(^ORD(101.41,ORX,6,"D",QODS,"")) Q:QOIEN'>0
- S QODS=$G(^ORD(101.41,ORX,6,QODS,1))
- S QORF=$O(^ORD(101.41,"AB","OR GTX REFILLS","")) Q:QORF'>0
- S QORF=$O(^ORD(101.41,ORX,6,"D",QORF,"")) Q:QOIEN'>0
- S QORF=$G(^ORD(101.41,ORX,6,QORF,1))
- S QORF=QORF+1
- S ORCLPAT=$P(ORYS,U,7)
- S ORMAX=$S(ORYS="M":28,ORYS="B":14,ORYS="W":7,1:90)
- I QORF*QODS>ORMAX D
- .K ORY
- .S ORY=1_U_ORCLOZ,ORY(0)="Problem Ordering Clozapine Related Medication"_U_ORCLOZ
- .S ORY(1)="*** This patient is only allowed an order with a maximum Days Supply of "_ORMAX_"."
- .S ORY(2)="This includes the amounts added by any refills entered in with the order also."
- Q
- ISCLOZ(OROI) ;
- N ORPSOI,ORPSDRUG
- S ORPSOI=$P(^ORD(101.43,OROI,0),U,2)
- I $P(ORPSOI,";",2)'="99PSP" Q 0
- K ^TMP($J,"ORCLOZ")
- D ASP^PSS50(+ORPSOI,,,"ORCLOZ")
- S ORPSDRUG=$O(^TMP($J,"ORCLOZ",0))
- I 'ORPSDRUG K ^TMP($J,"ORCLOZ") Q 0
- K ^TMP($J,"ORCLOZ")
- D CLOZ^PSS50(ORPSDRUG,,,,,"ORCLOZ")
- I $G(^TMP($J,"ORCLOZ",ORPSDRUG,"CLOZ",0))>0 K ^TMP($J,"ORCLOZ") Q 1
- K ^TMP($J,"ORCLOZ")
- Q 0
- ALLWRN(ORY,ORN,REFILLS) ;allow order to be renewed
- ;ORN is the order number
- ;REFILLS is the number of refills to be included with the renewed order
- N ORDS,ORQT,ORUPD,ORSCH,ORDUR,ORDFN,ORDRG,OROI,ORMAXDS,ORMAXQT,ORCLOZ,ORREF,ORMAXREF
- ;default return 1 (ORY=1 means allow renew)
- S ORY=1
- ;IHS/MSC/PLS - 10/09/13
- Q ;IHS doesn't use
- ;get DFN (ORDFN)
- S ORDFN=+$P(^OR(100,ORN,0),U,2)
- Q:'ORDFN
- ;get if order is a clozapine order (ORCLOZ)
- S OROI=$G(^OR(100,ORN,.1,1,0)) Q:'OROI
- S ORCLOZ=$$ISCLOZ(OROI)
- ;quit if order is not clozapine
- I 'ORCLOZ Q
- ;get schedule from order (ORSCH)
- S ORSCH=$G(^OR(100,ORN,4.5,$O(^OR(100,ORN,4.5,"ID","SCHEDULE",0)),1))
- ;get units per dose from order (ORUPD)
- S ORSCH=$G(^OR(100,ORN,4.5,$O(^OR(100,ORN,4.5,"ID","DOSE",0)),1))
- S ORSCH=$P(ORSCH,"&",3)
- ;get duration from order (ORDUR)
- I '$O(^OR(100,ORN,4.5,"ID","DURATION",0)) S ORDUR="~^"
- E S ORSCH=$G(^OR(100,ORN,4.5,$O(^OR(100,ORN,4.5,"ID","DURATION",0)),1))
- ;get days supply from order (ORDS)
- S ORSCH=$G(^OR(100,ORN,4.5,$O(^OR(100,ORN,4.5,"ID","SUPPLY",0)),1))
- ;get drug (ptr50) from order (ORDRG)
- S ORSCH=$G(^OR(100,ORN,4.5,$O(^OR(100,ORN,4.5,"ID","DRUG",0)),1))
- ;get refills from order (ORREF)
- S ORSCH=$G(^OR(100,ORN,4.5,$O(^OR(100,ORN,4.5,"ID","REFILLS",0)),1))
- ;get quantity from order (ORQT)
- S ORSCH=$G(^OR(100,ORN,4.5,$O(^OR(100,ORN,4.5,"ID","QTY",0)),1))
- ;get max days supply for order (ORMAXDS)
- S ORMAXDS=$$DEFSPLY^ORWDPS1(ORDFN)
- ;if ds from order is > max ds return 0 (ORY=0)
- I ORDS>ORMAXDS D Q
- .S ORY=0
- .S ORY(0)="Problem Renewing Clozapine Related Medication"_U_ORCLOZ
- .S ORY(1)="The Days Supply set for this order is greater than the Max Days Supply"
- .S ORY(2)=" allowed for this patient."
- ;get max quantity for order (ORMAXQT)
- D DAY2QTY^ORWDPS2(.ORMAXQT,ORDS,ORUPD,ORSCH,ORDUR,ORDFN,ORDRG)
- ;if qt from order is > max qt return 0 (ORY=0)
- I ORQT>ORMAXQT D Q
- .S ORY=0
- .S ORY(0)="Problem Renewing Clozapine Related Medication"_U_ORCLOZ
- .S ORY(1)="The Quantity set for this order is greater than the Max Quantity"
- .S ORY(2)=" allowed for this patient."
- ;get max refills for order (ORMAXREF)
- D MAXREF^ORWDPS2(.ORMAXREF,ORDFN,ORDRG,ORDS,OROI,1)
- ;if refill from order is > max refills return 0 (ORY=0)
- I ORREF>ORMAXREF D Q
- .S ORY=0
- .S ORY(0)="Problem Renewing Clozapine Related Medication"_U_ORCLOZ
- .S ORY(1)="The Refills field set for this order is greater than the Refills"
- .S ORY(2)=" allowed for this patient with the order having a Days Supply "
- .S ORY(3)=" of "_ORDS_"."
- Q
- ORALWORD ; SLC/JMH - Utilities for Checking if an order can be ordered ;09-Oct-2013 08:56;PLS
- +1 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**243,1010,1012**;Dec 17, 1997;Build 242
- +2 ;
- +3 ; Modified - IHS/MSC/PLS - 06/17/13 - Added Q1 support for ALLWORD
- +4 ; - 10/09/13 - Changed ALLWORD and ALLWRN to simply quit
- ALLWORD(ORY,DFN,ORX,ORTYPE,PROV) ;
- +1 ;IHS/MSC/PLS - 10/09/2013
- +2 ; IHS doesn't use
- SET ORY=0
- QUIT
- +3 NEW OROI,ORYS,QOIEN,QPIEN,ORCLOZ,QOAA
- +4 SET OROI=0
- +5 ;
- +6 ;ORTYPE used to determine the type of data coming into the call
- +7 ;ORYTPE="E" existing order, ORX equal the IEN from file 100 (used with
- +8 ;copy,edit functionality)
- +9 ;ORTYPE="Q" Quick Order, ORX equal the IEN from file 101.43
- +10 ;ORTYPE="N" New order, ORX equal the IEN from file 101.41
- +11 ;
- +12 IF ORTYPE="E"
- SET OROI=$GET(^OR(100,ORX,.1,1,0))
- +13 IF ORTYPE="Q"
- Begin DoDot:1
- +14 SET QPIEN=$ORDER(^ORD(101.41,"AB","OR GTX ORDERABLE ITEM",""))
- IF QPIEN'>0
- QUIT
- +15 SET QOIEN=$ORDER(^ORD(101.41,ORX,6,"D",QPIEN,""))
- IF QOIEN'>0
- QUIT
- +16 SET OROI=$GET(^ORD(101.41,ORX,6,QOIEN,1))
- +17 SET QOAA=$PIECE($GET(^ORD(101.41,ORX,5)),U,8)
- End DoDot:1
- +18 ;Used when passing ORX as orderable item
- IF ORTYPE="Q1"
- Begin DoDot:1
- +19 SET OROI=ORX
- SET ORTYPE="Q"
- End DoDot:1
- +20 IF ORTYPE="N"
- SET OROI=ORX
- +21 IF OROI'>0
- QUIT
- +22 SET ORY=0
- +23 ;checks if the orderable item (OROI) is a clozapine med
- +24 ; if not returns ORY=0
- +25 SET ORCLOZ=$$ISCLOZ(OROI)
- SET ORY=ORY_U_ORCLOZ
- SET ORY(0)=U_ORCLOZ
- +26 IF 'ORCLOZ
- QUIT
- +27 NEW ORQUIT
- +28 SET ORQUIT=0
- +29 IF '$GET(PROV)
- SET PROV=DUZ
- +30 IF $GET(PROV)
- Begin DoDot:1
- +31 IF '$LENGTH($$DEA^XUSER(,PROV))
- Begin DoDot:2
- +32 SET ORQUIT=1
- SET ORY=1
- +33 SET ORQUIT=1
- SET ORY=1
- +34 SET ORY(1)="*** You are not authorized to place Clozapine orders."
- +35 SET ORY(2)="You must have a DEA#. Please contact your"
- +36 SET ORY(3)="CAC or IRM for more information. ***"
- End DoDot:2
- +37 IF ORQUIT
- QUIT
- +38 IF '$DATA(^XUSEC("YSCL AUTHORIZED",PROV))
- Begin DoDot:2
- +39 SET ORQUIT=1
- SET ORY=1
- +40 SET ORY(1)="*** You are not authorized to place Clozapine orders."
- +41 SET ORY(2)="You must hold key YSCL AUTHORIZED. Please contact your"
- +42 SET ORY(3)="CAC or IRM for more information on this key. ***"
- End DoDot:2
- End DoDot:1
- +43 IF ORQUIT
- QUIT
- +44 ; if is a cloz med , check if patient (DFN) can have a clozapine med
- +45 SET ORYS=$$CL^YSCLTST2(DFN)
- +46 ; if yes returns ORY=0
- +47 IF +ORYS>0
- DO BEFQUIT
- QUIT
- +48 ; if no
- +49 ; returns
- +50 ; ORY=1
- +51 ; ORY(0)=CAPTION FOR DIALOG BOX
- +52 ; ORY(1-N)=MESSAGE TO DISPLAY
- +53 SET ORY=1_U_ORCLOZ
- SET ORY(0)="Problem Ordering Clozapine Related Medication"_U_ORCLOZ
- +54 ;patient not in clozapine patient program
- +55 IF +ORYS<0
- Begin DoDot:1
- +56 SET ORY(1)="*** This patient is not registered in the clozapine treatment "
- +57 SET ORY(2)="program or has been discontinued from the program and must "
- +58 SET ORY(3)="have a new registration number assigned. Contact the NCCC to "
- +59 SET ORY(4)="get this patient registered in the program. ***"
- End DoDot:1
- QUIT
- +60 ;problem with lab tests
- +61 IF +ORYS=0
- Begin DoDot:1
- +62 ;override allowed
- IF $$OVERRIDE^YSCLTST2(DFN)
- SET ORY=0_U_ORCLOZ
- SET ORY(0)=U_ORCLOZ
- DO BEFQUIT
- QUIT
- +63 NEW COUNT
- SET COUNT=0
- +64 SET COUNT=COUNT+1
- SET ORY(COUNT)="*** This clozapine drug may not be dispensed to the patient at this "
- +65 SET COUNT=COUNT+1
- SET ORY(COUNT)="time based on the available lab tests related to the clozapine "
- +66 SET COUNT=COUNT+1
- SET ORY(COUNT)="treatment program. Please contact the NCCC to request an override in"
- +67 SET COUNT=COUNT+1
- SET ORY(COUNT)="order to proceed with dispensing this drug. ***"
- +68 IF '$LENGTH($PIECE(ORYS,U,3))!('$LENGTH($PIECE(ORYS,U,5)))
- QUIT
- +69 SET COUNT=COUNT+1
- SET ORY(COUNT)="Related Lab Test(s)"
- +70 SET COUNT=COUNT+1
- SET ORY(COUNT)="==================="
- +71 ;the lab values returned by Mental Health are given in 4 digit numbers to be standard with
- +72 ;reporting formats to the NCCC, we are dividing by 1000 to align it with the display of the
- +73 ;labs on the lab tab
- +74 ;S:$L($P(ORYS,U,3)) COUNT=COUNT+1,ORY(COUNT)=$P(ORYS,U,3)_": "_($P(ORYS,U,2)/1000)_" K/cmm"
- +75 ;S:$L($P(ORYS,U,5)) COUNT=COUNT+1,ORY(COUNT)=$P(ORYS,U,5)_": "_($P(ORYS,U,4)/1000)_" K/cmm"
- +76 IF $LENGTH($PIECE(ORYS,U,3))
- SET COUNT=COUNT+1
- SET ORY(COUNT)="WBC: "_($PIECE(ORYS,U,2)/1000)_" K/cmm"
- +77 IF $LENGTH($PIECE(ORYS,U,5))
- SET COUNT=COUNT+1
- SET ORY(COUNT)="ANC: "_($PIECE(ORYS,U,4)/1000)_" K/cmm"
- +78 SET COUNT=COUNT+1
- SET ORY(COUNT)="Date/Time of last tests: "_$$DATE^ORU($PIECE(ORYS,U,6))
- End DoDot:1
- QUIT
- +79 QUIT
- BEFQUIT ;
- +1 IF '$GET(QOAA)
- QUIT
- +2 NEW QODS,QORF,ORMAX,ORCLPAT
- +3 SET QODS=$ORDER(^ORD(101.41,"AB","OR GTX DAYS SUPPLY",""))
- IF QODS'>0
- QUIT
- +4 SET QODS=$ORDER(^ORD(101.41,ORX,6,"D",QODS,""))
- IF QOIEN'>0
- QUIT
- +5 SET QODS=$GET(^ORD(101.41,ORX,6,QODS,1))
- +6 SET QORF=$ORDER(^ORD(101.41,"AB","OR GTX REFILLS",""))
- IF QORF'>0
- QUIT
- +7 SET QORF=$ORDER(^ORD(101.41,ORX,6,"D",QORF,""))
- IF QOIEN'>0
- QUIT
- +8 SET QORF=$GET(^ORD(101.41,ORX,6,QORF,1))
- +9 SET QORF=QORF+1
- +10 SET ORCLPAT=$PIECE(ORYS,U,7)
- +11 SET ORMAX=$SELECT(ORYS="M":28,ORYS="B":14,ORYS="W":7,1:90)
- +12 IF QORF*QODS>ORMAX
- Begin DoDot:1
- +13 KILL ORY
- +14 SET ORY=1_U_ORCLOZ
- SET ORY(0)="Problem Ordering Clozapine Related Medication"_U_ORCLOZ
- +15 SET ORY(1)="*** This patient is only allowed an order with a maximum Days Supply of "_ORMAX_"."
- +16 SET ORY(2)="This includes the amounts added by any refills entered in with the order also."
- End DoDot:1
- +17 QUIT
- ISCLOZ(OROI) ;
- +1 NEW ORPSOI,ORPSDRUG
- +2 SET ORPSOI=$PIECE(^ORD(101.43,OROI,0),U,2)
- +3 IF $PIECE(ORPSOI,";",2)'="99PSP"
- QUIT 0
- +4 KILL ^TMP($JOB,"ORCLOZ")
- +5 DO ASP^PSS50(+ORPSOI,,,"ORCLOZ")
- +6 SET ORPSDRUG=$ORDER(^TMP($JOB,"ORCLOZ",0))
- +7 IF 'ORPSDRUG
- KILL ^TMP($JOB,"ORCLOZ")
- QUIT 0
- +8 KILL ^TMP($JOB,"ORCLOZ")
- +9 DO CLOZ^PSS50(ORPSDRUG,,,,,"ORCLOZ")
- +10 IF $GET(^TMP($JOB,"ORCLOZ",ORPSDRUG,"CLOZ",0))>0
- KILL ^TMP($JOB,"ORCLOZ")
- QUIT 1
- +11 KILL ^TMP($JOB,"ORCLOZ")
- +12 QUIT 0
- ALLWRN(ORY,ORN,REFILLS) ;allow order to be renewed
- +1 ;ORN is the order number
- +2 ;REFILLS is the number of refills to be included with the renewed order
- +3 NEW ORDS,ORQT,ORUPD,ORSCH,ORDUR,ORDFN,ORDRG,OROI,ORMAXDS,ORMAXQT,ORCLOZ,ORREF,ORMAXREF
- +4 ;default return 1 (ORY=1 means allow renew)
- +5 SET ORY=1
- +6 ;IHS/MSC/PLS - 10/09/13
- +7 ;IHS doesn't use
- QUIT
- +8 ;get DFN (ORDFN)
- +9 SET ORDFN=+$PIECE(^OR(100,ORN,0),U,2)
- +10 IF 'ORDFN
- QUIT
- +11 ;get if order is a clozapine order (ORCLOZ)
- +12 SET OROI=$GET(^OR(100,ORN,.1,1,0))
- IF 'OROI
- QUIT
- +13 SET ORCLOZ=$$ISCLOZ(OROI)
- +14 ;quit if order is not clozapine
- +15 IF 'ORCLOZ
- QUIT
- +16 ;get schedule from order (ORSCH)
- +17 SET ORSCH=$GET(^OR(100,ORN,4.5,$ORDER(^OR(100,ORN,4.5,"ID","SCHEDULE",0)),1))
- +18 ;get units per dose from order (ORUPD)
- +19 SET ORSCH=$GET(^OR(100,ORN,4.5,$ORDER(^OR(100,ORN,4.5,"ID","DOSE",0)),1))
- +20 SET ORSCH=$PIECE(ORSCH,"&",3)
- +21 ;get duration from order (ORDUR)
- +22 IF '$ORDER(^OR(100,ORN,4.5,"ID","DURATION",0))
- SET ORDUR="~^"
- +23 IF '$TEST
- SET ORSCH=$GET(^OR(100,ORN,4.5,$ORDER(^OR(100,ORN,4.5,"ID","DURATION",0)),1))
- +24 ;get days supply from order (ORDS)
- +25 SET ORSCH=$GET(^OR(100,ORN,4.5,$ORDER(^OR(100,ORN,4.5,"ID","SUPPLY",0)),1))
- +26 ;get drug (ptr50) from order (ORDRG)
- +27 SET ORSCH=$GET(^OR(100,ORN,4.5,$ORDER(^OR(100,ORN,4.5,"ID","DRUG",0)),1))
- +28 ;get refills from order (ORREF)
- +29 SET ORSCH=$GET(^OR(100,ORN,4.5,$ORDER(^OR(100,ORN,4.5,"ID","REFILLS",0)),1))
- +30 ;get quantity from order (ORQT)
- +31 SET ORSCH=$GET(^OR(100,ORN,4.5,$ORDER(^OR(100,ORN,4.5,"ID","QTY",0)),1))
- +32 ;get max days supply for order (ORMAXDS)
- +33 SET ORMAXDS=$$DEFSPLY^ORWDPS1(ORDFN)
- +34 ;if ds from order is > max ds return 0 (ORY=0)
- +35 IF ORDS>ORMAXDS
- Begin DoDot:1
- +36 SET ORY=0
- +37 SET ORY(0)="Problem Renewing Clozapine Related Medication"_U_ORCLOZ
- +38 SET ORY(1)="The Days Supply set for this order is greater than the Max Days Supply"
- +39 SET ORY(2)=" allowed for this patient."
- End DoDot:1
- QUIT
- +40 ;get max quantity for order (ORMAXQT)
- +41 DO DAY2QTY^ORWDPS2(.ORMAXQT,ORDS,ORUPD,ORSCH,ORDUR,ORDFN,ORDRG)
- +42 ;if qt from order is > max qt return 0 (ORY=0)
- +43 IF ORQT>ORMAXQT
- Begin DoDot:1
- +44 SET ORY=0
- +45 SET ORY(0)="Problem Renewing Clozapine Related Medication"_U_ORCLOZ
- +46 SET ORY(1)="The Quantity set for this order is greater than the Max Quantity"
- +47 SET ORY(2)=" allowed for this patient."
- End DoDot:1
- QUIT
- +48 ;get max refills for order (ORMAXREF)
- +49 DO MAXREF^ORWDPS2(.ORMAXREF,ORDFN,ORDRG,ORDS,OROI,1)
- +50 ;if refill from order is > max refills return 0 (ORY=0)
- +51 IF ORREF>ORMAXREF
- Begin DoDot:1
- +52 SET ORY=0
- +53 SET ORY(0)="Problem Renewing Clozapine Related Medication"_U_ORCLOZ
- +54 SET ORY(1)="The Refills field set for this order is greater than the Refills"
- +55 SET ORY(2)=" allowed for this patient with the order having a Days Supply "
- +56 SET ORY(3)=" of "_ORDS_"."
- End DoDot:1
- QUIT
- +57 QUIT