ORBCMA5 ; SLC/JDL - BCMA Order utility ;2/18/02 13:37
;;3.0;ORDER ENTRY/RESULTS REPORTING;**133**;Dec 17, 1997
;;BCMA ORDER UTITLITY;**133**;12/12/2001
;
GETUDID(Y,INFO) ; Get Unit/Dose Order Form ID
S Y=$O(^ORD(101.41,"B","PSJ OR PAT OE",0))
S:$L(Y)<1 Y=0
Q
GETIVID(Y,INFO) ; Get IV Order Form ID
S Y=$O(^ORD(101.41,"B","PSJI OR PAT FLUID OE",0))
S:$L(Y)<1 Y=0
Q
GETUD(Y,ODITM) ; get unit dose orderable item
; ODITM: Orderable item ien
N DGIDX,OIIEN,UDIEN
S DGIDX=0
S UDIEN=$O(^ORD(101.44,"B","ORWDSET UD RX",0))
F S DGIDX=$O(^ORD(101.44,UDIEN,20,DGIDX)) Q:'DGIDX D
. S OIIEN=$P(^ORD(101.44,UDIEN,20,DGIDX,0),U,1)
. I OIIEN=ODITM S Y=^ORD(101.44,UDIEN,20,DGIDX,0)
K DGIDX,OIIEN,UDIEN
Q
ODITMBC(Y,XREF,ODLST) ; --Return orderable items info based on ItemIen
N CNT,NUM,XRF
S CNT=0,NUM=0,XRF=""
S:$L(XREF) XRF=XREF
F S CNT=$O(ODLST(CNT)) Q:'CNT D FNDINFO(.Y,ODLST(CNT))
Q
FNDINFO(Y,ODIEN) ;
N ODI,CRTM,FRM,XX,FINDIT
S XX="",FINDIT=0
S FRM="",CRTM=$$NOW^XLFDT
F S FRM=$O(^ORD(101.43,XRF,FRM)) Q:FRM="" D
. S ODI=0 F S ODI=$O(^ORD(101.43,XRF,FRM,ODI)) Q:'ODI D
.. S XX=^ORD(101.43,XRF,FRM,ODI)
.. I +$P(XX,U,3),$P(XX,U,3)<CRTM Q
.. I ODI=+ODIEN D
... S NUM=NUM+1,FINDIT=1
... I 'XX S Y(NUM)=ODIEN_U_$P(XX,U,2)_U_$P(XX,U,2)
... E S Y(NUM)=ODIEN_U_$P(XX,U,2)_$C(9)_"<"_$P(XX,U,4)_">"_U_$P(XX,U,4)
I FINDIT=0 D
. S:$D(^ORD(101.43,+ODIEN,0)) XX=^ORD(101.43,+ODIEN,0)
. S NUM=NUM+1
. S:$L(XX) Y(NUM)=ODIEN_U_$P(XX,U)_U_$P(XX,U)_U_"NF"
Q
ORBCMA5 ; SLC/JDL - BCMA Order utility ;2/18/02 13:37
+1 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**133**;Dec 17, 1997
+2 ;;BCMA ORDER UTITLITY;**133**;12/12/2001
+3 ;
GETUDID(Y,INFO) ; Get Unit/Dose Order Form ID
+1 SET Y=$ORDER(^ORD(101.41,"B","PSJ OR PAT OE",0))
+2 IF $LENGTH(Y)<1
SET Y=0
+3 QUIT
GETIVID(Y,INFO) ; Get IV Order Form ID
+1 SET Y=$ORDER(^ORD(101.41,"B","PSJI OR PAT FLUID OE",0))
+2 IF $LENGTH(Y)<1
SET Y=0
+3 QUIT
GETUD(Y,ODITM) ; get unit dose orderable item
+1 ; ODITM: Orderable item ien
+2 NEW DGIDX,OIIEN,UDIEN
+3 SET DGIDX=0
+4 SET UDIEN=$ORDER(^ORD(101.44,"B","ORWDSET UD RX",0))
+5 FOR
SET DGIDX=$ORDER(^ORD(101.44,UDIEN,20,DGIDX))
IF 'DGIDX
QUIT
Begin DoDot:1
+6 SET OIIEN=$PIECE(^ORD(101.44,UDIEN,20,DGIDX,0),U,1)
+7 IF OIIEN=ODITM
SET Y=^ORD(101.44,UDIEN,20,DGIDX,0)
End DoDot:1
+8 KILL DGIDX,OIIEN,UDIEN
+9 QUIT
ODITMBC(Y,XREF,ODLST) ; --Return orderable items info based on ItemIen
+1 NEW CNT,NUM,XRF
+2 SET CNT=0
SET NUM=0
SET XRF=""
+3 IF $LENGTH(XREF)
SET XRF=XREF
+4 FOR
SET CNT=$ORDER(ODLST(CNT))
IF 'CNT
QUIT
DO FNDINFO(.Y,ODLST(CNT))
+5 QUIT
FNDINFO(Y,ODIEN) ;
+1 NEW ODI,CRTM,FRM,XX,FINDIT
+2 SET XX=""
SET FINDIT=0
+3 SET FRM=""
SET CRTM=$$NOW^XLFDT
+4 FOR
SET FRM=$ORDER(^ORD(101.43,XRF,FRM))
IF FRM=""
QUIT
Begin DoDot:1
+5 SET ODI=0
FOR
SET ODI=$ORDER(^ORD(101.43,XRF,FRM,ODI))
IF 'ODI
QUIT
Begin DoDot:2
+6 SET XX=^ORD(101.43,XRF,FRM,ODI)
+7 IF +$PIECE(XX,U,3)
IF $PIECE(XX,U,3)<CRTM
QUIT
+8 IF ODI=+ODIEN
Begin DoDot:3
+9 SET NUM=NUM+1
SET FINDIT=1
+10 IF 'XX
SET Y(NUM)=ODIEN_U_$PIECE(XX,U,2)_U_$PIECE(XX,U,2)
+11 IF '$TEST
SET Y(NUM)=ODIEN_U_$PIECE(XX,U,2)_$CHAR(9)_"<"_$PIECE(XX,U,4)_">"_U_$PIECE(XX,U,4)
End DoDot:3
End DoDot:2
End DoDot:1
+12 IF FINDIT=0
Begin DoDot:1
+13 IF $DATA(^ORD(101.43,+ODIEN,0))
SET XX=^ORD(101.43,+ODIEN,0)
+14 SET NUM=NUM+1
+15 IF $LENGTH(XX)
SET Y(NUM)=ODIEN_U_$PIECE(XX,U)_U_$PIECE(XX,U)_U_"NF"
End DoDot:1
+16 QUIT