ORUTL3 ;SLC/JLC - OE/RR Utilities ;Oct 12, 2021@10:42:54
;;3.0;ORDER ENTRY/RESULTS REPORTING;**111,397,405**;Dec 17, 1997;Build 211
;
;
;
NATURE(ORIFN) ;find nature of order
;ORIFN is the order;action being requested
;if no action is present, the API will find the most recent action that has
;a nature of order
N OR8,ORACT,ORNAT,ORNATURE
S ORACT=$P(ORIFN,";",2),ORIFN=$P(ORIFN,";")
I '$D(^OR(100,ORIFN,0)) Q 0 ; not a valid order
I ORACT="" D
. N S1,A
. S S1=0
. F S S1=$O(^OR(100,ORIFN,8,S1)) Q:'S1 S A=$P($G(^(S1,0)),"^",12) I A]"" S ORACT=S1
I ORACT="" Q 0 ;not a valid order action
I '$D(^OR(100,ORIFN,8,ORACT)) Q 0 ;not a valid order action
S OR8=$G(^OR(100,ORIFN,8,ORACT,0)) S ORNATURE=$P(OR8,"^",12),ORNAT=$$TEXT(ORNATURE)
Q ORNATURE_"^"_ORNAT
TEXT(X) ; -- Returns 3 ^-piece identifier for nature X
N ORN,Y S ORN=$G(^ORD(100.02,+$G(X),0))
S Y=$P(ORN,U,2)_U_$P(ORN,U)_"^99ORN"
Q Y
ISSUPPLY(ORDDIEN) ;IS THIS DISPENSE DRUG A SUPPLY ORDER
;INPUT: ORDDIEN - DISPENSE DRUG TO BE CHECKED
D ZERO^PSS50(ORDDIEN,,,,,"ORDRUG")
I ^TMP($J,"ORDRUG",0)<1 Q
I "^XA^XX^"[("^"_$E(^TMP($J,"ORDRUG",ORDDIEN,2),1,2)_"^") Q 1
I ^TMP($J,"ORDRUG",ORDDIEN,2)="DX900",$G(^TMP($J,"ORDRUG",ORDDIEN,3))["S" Q 1
Q 0
;
ISOISPLY(OROIIEN) ;is this orderable item a supply order
; Input: OROIIEN - Orderable Item IEN (#101.43) to be checked
N ORDRUG,ORLST,ORSPLY
;
S ORSPLY=1
;
D OI2DD^ORKCHK5(.ORLST,OROIIEN,"O")
I '$O(ORLST(0)) S ORSPLY=0
S ORDRUG=""
F S ORDRUG=$O(ORLST(ORDRUG)) Q:ORDRUG=""!('ORSPLY) D
. I '$$ISSUPPLY(+ORDRUG) S ORSPLY=0
;
Q ORSPLY
;
ISTITR(ORIFN) ; Is this a titration order?
;
; ORIFN is the Order (#100) IEN
;
N OR0,ORDG,ORTITR,ORTITRVAL
;
S OR0=$G(^OR(100,+ORIFN,0))
S ORDG=$P($G(^ORD(100.98,+$P(OR0,U,11),0)),U,3)
I ORDG'="O RX" Q 0
;
S ORTITR=+$O(^OR(100,+ORIFN,4.5,"ID","TITR",0))
I ORTITR D Q $G(ORTITRVAL)
. S ORTITRVAL=+$G(^OR(100,+ORIFN,4.5,ORTITR,1))
;
; also check backdoor pharmacy (in case of orders marked
; in backdoor pharmacy as titrating pre-v32/p405)
S PSIFN=$G(^OR(100,+ORIFN,4))
I PSIFN["S" Q 0
I $$TITRX^PSOUTL(PSIFN)="t" Q 1
;
Q 0
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HORUTL3 2185 printed Dec 13, 2024@02:34:39 Page 2
ORUTL3 ;SLC/JLC - OE/RR Utilities ;Oct 12, 2021@10:42:54
+1 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**111,397,405**;Dec 17, 1997;Build 211
+2 ;
+3 ;
+4 ;
NATURE(ORIFN) ;find nature of order
+1 ;ORIFN is the order;action being requested
+2 ;if no action is present, the API will find the most recent action that has
+3 ;a nature of order
+4 NEW OR8,ORACT,ORNAT,ORNATURE
+5 SET ORACT=$PIECE(ORIFN,";",2)
SET ORIFN=$PIECE(ORIFN,";")
+6 ; not a valid order
IF '$DATA(^OR(100,ORIFN,0))
QUIT 0
+7 IF ORACT=""
Begin DoDot:1
+8 NEW S1,A
+9 SET S1=0
+10 FOR
SET S1=$ORDER(^OR(100,ORIFN,8,S1))
if 'S1
QUIT
SET A=$PIECE($GET(^(S1,0)),"^",12)
IF A]""
SET ORACT=S1
End DoDot:1
+11 ;not a valid order action
IF ORACT=""
QUIT 0
+12 ;not a valid order action
IF '$DATA(^OR(100,ORIFN,8,ORACT))
QUIT 0
+13 SET OR8=$GET(^OR(100,ORIFN,8,ORACT,0))
SET ORNATURE=$PIECE(OR8,"^",12)
SET ORNAT=$$TEXT(ORNATURE)
+14 QUIT ORNATURE_"^"_ORNAT
TEXT(X) ; -- Returns 3 ^-piece identifier for nature X
+1 NEW ORN,Y
SET ORN=$GET(^ORD(100.02,+$GET(X),0))
+2 SET Y=$PIECE(ORN,U,2)_U_$PIECE(ORN,U)_"^99ORN"
+3 QUIT Y
ISSUPPLY(ORDDIEN) ;IS THIS DISPENSE DRUG A SUPPLY ORDER
+1 ;INPUT: ORDDIEN - DISPENSE DRUG TO BE CHECKED
+2 DO ZERO^PSS50(ORDDIEN,,,,,"ORDRUG")
+3 IF ^TMP($JOB,"ORDRUG",0)<1
QUIT
+4 IF "^XA^XX^"[("^"_$EXTRACT(^TMP($JOB,"ORDRUG",ORDDIEN,2),1,2)_"^")
QUIT 1
+5 IF ^TMP($JOB,"ORDRUG",ORDDIEN,2)="DX900"
IF $GET(^TMP($JOB,"ORDRUG",ORDDIEN,3))["S"
QUIT 1
+6 QUIT 0
+7 ;
ISOISPLY(OROIIEN) ;is this orderable item a supply order
+1 ; Input: OROIIEN - Orderable Item IEN (#101.43) to be checked
+2 NEW ORDRUG,ORLST,ORSPLY
+3 ;
+4 SET ORSPLY=1
+5 ;
+6 DO OI2DD^ORKCHK5(.ORLST,OROIIEN,"O")
+7 IF '$ORDER(ORLST(0))
SET ORSPLY=0
+8 SET ORDRUG=""
+9 FOR
SET ORDRUG=$ORDER(ORLST(ORDRUG))
if ORDRUG=""!('ORSPLY)
QUIT
Begin DoDot:1
+10 IF '$$ISSUPPLY(+ORDRUG)
SET ORSPLY=0
End DoDot:1
+11 ;
+12 QUIT ORSPLY
+13 ;
ISTITR(ORIFN) ; Is this a titration order?
+1 ;
+2 ; ORIFN is the Order (#100) IEN
+3 ;
+4 NEW OR0,ORDG,ORTITR,ORTITRVAL
+5 ;
+6 SET OR0=$GET(^OR(100,+ORIFN,0))
+7 SET ORDG=$PIECE($GET(^ORD(100.98,+$PIECE(OR0,U,11),0)),U,3)
+8 IF ORDG'="O RX"
QUIT 0
+9 ;
+10 SET ORTITR=+$ORDER(^OR(100,+ORIFN,4.5,"ID","TITR",0))
+11 IF ORTITR
Begin DoDot:1
+12 SET ORTITRVAL=+$GET(^OR(100,+ORIFN,4.5,ORTITR,1))
End DoDot:1
QUIT $GET(ORTITRVAL)
+13 ;
+14 ; also check backdoor pharmacy (in case of orders marked
+15 ; in backdoor pharmacy as titrating pre-v32/p405)
+16 SET PSIFN=$GET(^OR(100,+ORIFN,4))
+17 IF PSIFN["S"
QUIT 0
+18 IF $$TITRX^PSOUTL(PSIFN)="t"
QUIT 1
+19 ;
+20 QUIT 0