ORMFN ; SLC/MKB - MFN msg router ;11/21/2006
;;3.0;ORDER ENTRY/RESULTS REPORTING;**26,97,94,176,215,243**;Dec 17, 1997;Build 242
EN(MSG) ; -- main entry point for OR ITEM RECEIVE
N ORMSG,ORNMSP,ORDG,MSH,MFI,MFE,ZPKG,ZSY,NTE,ORMFE,ORDITEM,ORACTION,ORDIFN,ORFIEN,ORFLD,ORFDA,NUM,VALUE,X,Y,DA,DIC,DIK,SYS,ZLC,LAST,NAME,ID,INACTIVE,I,ORY,NEXT,DD,DO
S ORMSG=$G(MSG,"MSG") Q:'$O(@ORMSG@(0)) ; msg array root
N ORNOW S ORNOW=$$NOW^XLFDT ;M ^XTMP("OR ITEM RECEIVE",ORNOW)=@ORMSG
MSH S MSH=0 F S MSH=$O(@ORMSG@(MSH)) Q:MSH'>0 Q:$E(@ORMSG@(MSH),1,3)="MSH"
Q:'MSH S MSH=MSH_U_@ORMSG@(MSH)
S X=$P(MSH,"|",3) S:X="RADIOLOGY" X="IMAGING"
S ORDG=$O(^ORD(100.98,"B",X,0)),ORNMSP=$$NMSP(X) Q:'$L(ORNMSP)
S MFI=$O(@ORMSG@(+MSH)) Q:$E(@ORMSG@(MFI),1,3)'="MFI" ; error
MFE S MFE=+MFI ; ** loop through each MFE segment
F S MFE=$O(@ORMSG@(+MFE)) Q:MFE'>0 I $E(@ORMSG@(MFE),1,3)="MFE" D
. K ORFLD,ORFDA
. S MFE=MFE_U_@ORMSG@(MFE),ORMFE=$P(MFE,"|",2),INACTIVE=$P(MFE,"|",4)
. S ORDITEM=$P(MFE,"|",5),NAME=$TR($P(ORDITEM,U,5),"~"," ")
. S ID=$P(ORDITEM,U,4)_";"_$P(ORDITEM,U,6)
. S ORDIFN=+$O(^ORD(101.43,"ID",ID,0)),ORFIEN=ORDIFN_","
. S ORACTION=$S(ORMFE="MAD":1,(ORMFE="MAC")&('ORDIFN):1,(ORMFE="MUP")&('ORDIFN):1,'ORDIFN:0,ORMFE="MAC":2,ORMFE="MUP":2,ORMFE="MDC":3,ORMFE="MDL":3,1:0) ; 1=add, 2=change, 3=delete (inactivate)
. Q:'ORACTION ; 0=error
. I ORACTION=3 S ORFDA(101.43,ORFIEN,.1)=$S(INACTIVE:$$HL7TFM^XLFDT(INACTIVE),1:$$NOW^XLFDT) D FILE^DIE("K","ORFDA") Q
ADD . I ORACTION=1,'ORDIFN D Q:'ORDIFN ;create item if it doesn't exist
. . S ORDIFN=$$CREATE(NAME),ORFIEN=ORDIFN_","
. . S ORFDA(101.43,ORFIEN,5)=+ORDG
. S ORFLD(.01)=NAME,ORFLD(1.1)=NAME,ORFLD(2)=ID,ORFLD(3)=$P(ORDITEM,U)
. S SYS=$P(ORDITEM,U,3),ORFLD(4)=$S(+SYS=99:$E(SYS,3,99),1:SYS)
. S ORFLD(.1)=$S(ORMFE="MAC":"@",(ORMFE="MUP")&('INACTIVE):"@",INACTIVE:$$HL7TFM^XLFDT(INACTIVE),1:"")
. F NUM=.01,.1,1.1,2,3,4 S VALUE=$S(ORFLD(NUM)="":"@",1:ORFLD(NUM)) D VAL^DIE(101.43,ORFIEN,NUM,"F",VALUE,.ORY,"ORFDA")
ZPKG . S LAST=+MFE,ZPKG=$O(@ORMSG@(+MFE))
. I ZPKG,$E(@ORMSG@(ZPKG),1,3)=("Z"_ORNMSP) S ZPKG=ZPKG_U_@ORMSG@(ZPKG),LAST=+ZPKG D @ORNMSP ; ZXX segment
. D FILE^DIE("K","ORFDA") ; file data
ZLC . S NEXT=$O(@ORMSG@(LAST)) I NEXT,$E(@ORMSG@(NEXT),1,3)="ZLC" D
. . N COMP,CID,CODE,CSYS
. . K DA,^ORD(101.43,ORDIFN,10) ;S DIC("P")=$P(^DD(101.43,10,0),U,2)
. . S DA(1)=ORDIFN,DIC="^ORD(101.43,"_DA(1)_",10,",DIC(0)="L",ZLC=LAST
. . F S ZLC=$O(@ORMSG@(ZLC)) Q:ZLC'>0 Q:$E(@ORMSG@(ZLC),1,3)'="ZLC" D
. . . S COMP=$P(@ORMSG@(ZLC),"|",5),X=$P(COMP,U,5) I X="" S LAST=ZLC Q
. . . S CID=$P(COMP,U,4)_";"_$P(COMP,U,6) K DIC("DR"),DO,DD
. . . S CODE=$P(COMP,U),CSYS=$P(COMP,U,3) S:+CSYS=99 CSYS=$E(CSYS,3,99)
. . . S DIC("DR")="2///^S X=CID;3///^S X=CODE;4///^S X=CSYS"
. . . D FILE^DICN S LAST=ZLC
ZSY . I $D(^ORD(101.43,ORDIFN,2)) D ; kill old ones first
. . S DA(1)=ORDIFN,DIK="^ORD(101.43,"_DA(1)_",2,"
. . S DA=0 F S DA=$O(^ORD(101.43,DA(1),2,DA)) Q:DA'>0 D ^DIK
. . K ^ORD(101.43,ORDIFN,2),DIK,DA
. S NEXT=$O(@ORMSG@(LAST)) I NEXT,$E(@ORMSG@(NEXT),1,3)="ZSY" D
. . K DA,DIC S DA(1)=ORDIFN,DIC="^ORD(101.43,"_DA(1)_",2,"
. . S DIC(0)="L",ZSY=LAST ;,DIC("P")=$P(^DD(101.43,1,0),U,2)
. . F S ZSY=$O(@ORMSG@(+ZSY)) Q:ZSY'>0 Q:$E(@ORMSG@(ZSY),1,3)'="ZSY" D
. . . S X=$P(@ORMSG@(ZSY),"|",3),LAST=ZSY
. . . K DD,DO D:$L(X) FILE^DICN
NTE . K ^ORD(101.43,ORDIFN,8) ; replace text
. S NEXT=$O(@ORMSG@(LAST)) I NEXT,$E(@ORMSG@(NEXT),1,3)="NTE" D
. . S NTE=LAST,DA=0
. . F S NTE=$O(@ORMSG@(NTE)) Q:NTE'>0 Q:$E(@ORMSG@(NTE),1,3)'="NTE" S DA=DA+1,^ORD(101.43,ORDIFN,8,DA,0)=$P(@ORMSG@(NTE),"|",4) I $O(@ORMSG@(NTE,0)) D
. . . S I=0 F S I=$O(@ORMSG@(NTE,I)) Q:I'>0 S DA=DA+1,^ORD(101.43,ORDIFN,8,DA,0)=@ORMSG@(NTE,I)
. . S ^ORD(101.43,ORDIFN,8,0)="^^"_DA_U_DA_U_DT_U
Q
;
NMSP(NAME) ; -- returns namespace for package
I NAME="RADIOLOGY" Q "RA"
I NAME="IMAGING" Q "RA"
I NAME="LABORATORY" Q "LR"
I NAME="DIETETICS" Q "FH"
I NAME="PHARMACY" Q "PS"
I NAME="CONSULTS" Q "CS"
I NAME="PROCEDURES" Q "CS"
Q ""
;
CREATE(X) ; -- Create new item in #101.43
Q:'$L($G(X)) 0 N HDR,LAST,TOTAL,I
L +^ORD(101.43,0):1 Q:'$T 0
S HDR=$G(^ORD(101.43,0)) Q:HDR="" 0
S LAST=$P(HDR,U,3),TOTAL=$P(HDR,U,4)
F I=(LAST+1):1 Q:'$D(^ORD(101.43,I,0))
S ^ORD(101.43,I,0)=X,X=$E(X,1,30),^ORD(101.43,"B",$$UP^XLFSTR(X),I)=""
S $P(^ORD(101.43,0),U,3,4)=I_U_(TOTAL+1)
L -^ORD(101.43,0)
Q I
;
FH ; -- Dietetics
S X=$P(ZPKG,"|",2),ORFLD(111.1)=$S(X="":"@",1:X)
S X=$P(ZPKG,"|",3),ORFLD(111.2)=$S(X="":"@",1:X)
S X=$P(ZPKG,"|",5),ORFLD(111.3)=$S(X="":"@",1:X)
F NUM=111.1,111.2,111.3 D VAL^DIE(101.43,ORFIEN,NUM,"F",ORFLD(NUM),.ORY,"ORFDA")
K ^ORD(101.43,ORDIFN,8) S X=$P(ZPKG,"|",4)
I $L(X) S ^ORD(101.43,ORDIFN,8,0)="^^1^1^"_DT_U,^(1,0)=X
Q
;
LR ; -- Laboratory
S X=$P(ZPKG,"|",2),ORFLD(60.1)=$S(X="":"@",1:X)
S X=$P(ZPKG,"|",3),ORFLD(60.2)=$S(X="":"@",1:X)
;S X=$P(ZPKG,"|",4),ORFLD(60.3)=$S(X="":"@",1:X)
S X=$P(ZPKG,"|",5),ORFLD(60.6)=$S(X="":"@",1:X)
S X=$P(ZPKG,"|",6),ORFLD(60.4)=$S(X="":"@",1:X)
S X=$P(ZPKG,"|",7),ORFLD(60.5)=$S(X="":"@",1:X)
S X=$P(ZPKG,"|",8),ORFLD(6)=$S(X="":"@",1:X)
S X=$P(ZPKG,"|",9),ORFLD(60.7)=$S(X="":"@",1:X)
F NUM=6,60.1,60.2,60.4,60.5,60.6,60.7 D VAL^DIE(101.43,ORFIEN,NUM,"F",ORFLD(NUM),.ORY,"ORFDA")
Q
;
PS ; -- Pharmacy
N ROUTE
S X=$P(ZPKG,"|",2)
;S ORFDA(101.43,ORFIEN,50.1)=$S(X'["I":0,$L($P($P(ORDITEM,U,5),"~",3)):2,1:1)
S ORFDA(101.43,ORFIEN,50.1)=$S(X["V":2,X["I":1,1:0) ;inpt or iv med
S ORFDA(101.43,ORFIEN,50.2)=(X["O") ;outpt med
S ORFDA(101.43,ORFIEN,50.3)=(X["B") ;fluid base/soln
S ORFDA(101.43,ORFIEN,50.4)=(X["A") ;fluid additive
S ORFDA(101.43,ORFIEN,50.5)=(X["S") ;supply item
S ORFDA(101.43,ORFIEN,50.7)=(X["N") ;non-VA med
S X=$P(ZPKG,"|",3),ORFDA(101.43,ORFIEN,50.6)=$S(X:1,1:0)
;Check for default med route
;S ROUTE=$$MEDROUTE
;I ROUTE>0 S ORFDA(101.43,ORFIEN,50.8)=ROUTE
Q
;
MEDROUTE() ;
N CNT,ROUTE
S CNT=0,ROUTE=0
F S CNT=$O(@ORMSG@(CNT)) Q:CNT'>0 D
.I $P($G(@ORMSG@(CNT)),"|")'="ZPB" Q
.S ROUTE=+$P($G(@ORMSG@(CNT)),"|",4)
Q ROUTE
;
RA ; -- Radiology/Nuc Medicine
S X=$P(ZPKG,"|",4),ORFLD(6)=$S(X="":"@",1:X)
S X=$P(ZPKG,"|",5),ORFLD(71.1)=$S(X="":"@",1:X)
S X=$P(ZPKG,"|",7),ORFLD(71.2)=$S(X="":"@",1:X)
S X=$P(ZPKG,"|",2),ORFLD(71.3)=$S(X="":"@",1:X)
S ORFLD(71.4)=$S($P(ZPKG,"|",6)="Y":1,1:0)
S ORFLD(7)=$S($P(ZPKG,"|",3)="Y":2,1:1)
F NUM=6,7,71.1,71.2,71.3,71.4 D VAL^DIE(101.43,ORFIEN,NUM,"F",ORFLD(NUM),.ORY,"ORFDA")
Q
;
CS ; -- Consults/Requests
S X=$P(ZPKG,"|",2),ORFLD(123.1)=$S(X="":"@",1:X)
D VAL^DIE(101.43,ORFIEN,123.1,"F",ORFLD(123.1),.ORY,"ORFDA")
Q
ORMFN ; SLC/MKB - MFN msg router ;11/21/2006
+1 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**26,97,94,176,215,243**;Dec 17, 1997;Build 242
EN(MSG) ; -- main entry point for OR ITEM RECEIVE
+1 NEW ORMSG,ORNMSP,ORDG,MSH,MFI,MFE,ZPKG,ZSY,NTE,ORMFE,ORDITEM,ORACTION,ORDIFN,ORFIEN,ORFLD,ORFDA,NUM,VALUE,X,Y,DA,DIC,DIK,SYS,ZLC,LAST,NAME,ID,INACTIVE,I,ORY,NEXT,DD,DO
+2 ; msg array root
SET ORMSG=$GET(MSG,"MSG")
IF '$ORDER(@ORMSG@(0))
QUIT
+3 ;M ^XTMP("OR ITEM RECEIVE",ORNOW)=@ORMSG
NEW ORNOW
SET ORNOW=$$NOW^XLFDT
MSH SET MSH=0
FOR
SET MSH=$ORDER(@ORMSG@(MSH))
IF MSH'>0
QUIT
IF $EXTRACT(@ORMSG@(MSH),1,3)="MSH"
QUIT
+1 IF 'MSH
QUIT
SET MSH=MSH_U_@ORMSG@(MSH)
+2 SET X=$PIECE(MSH,"|",3)
IF X="RADIOLOGY"
SET X="IMAGING"
+3 SET ORDG=$ORDER(^ORD(100.98,"B",X,0))
SET ORNMSP=$$NMSP(X)
IF '$LENGTH(ORNMSP)
QUIT
+4 ; error
SET MFI=$ORDER(@ORMSG@(+MSH))
IF $EXTRACT(@ORMSG@(MFI),1,3)'="MFI"
QUIT
MFE ; ** loop through each MFE segment
SET MFE=+MFI
+1 FOR
SET MFE=$ORDER(@ORMSG@(+MFE))
IF MFE'>0
QUIT
IF $EXTRACT(@ORMSG@(MFE),1,3)="MFE"
Begin DoDot:1
+2 KILL ORFLD,ORFDA
+3 SET MFE=MFE_U_@ORMSG@(MFE)
SET ORMFE=$PIECE(MFE,"|",2)
SET INACTIVE=$PIECE(MFE,"|",4)
+4 SET ORDITEM=$PIECE(MFE,"|",5)
SET NAME=$TRANSLATE($PIECE(ORDITEM,U,5),"~"," ")
+5 SET ID=$PIECE(ORDITEM,U,4)_";"_$PIECE(ORDITEM,U,6)
+6 SET ORDIFN=+$ORDER(^ORD(101.43,"ID",ID,0))
SET ORFIEN=ORDIFN_","
+7 ; 1=add, 2=change, 3=delete (inactivate)
SET ORACTION=$SELECT(ORMFE="MAD":1,(ORMFE="MAC")&('ORDIFN):1,(ORMFE="MUP")&('ORDIFN):1,'ORDIFN:0,ORMFE="MAC":2,ORMFE="MUP":2,ORMFE="MDC":3,ORMFE="MDL":3,1:0)
+8 ; 0=error
IF 'ORACTION
QUIT
+9 IF ORACTION=3
SET ORFDA(101.43,ORFIEN,.1)=$SELECT(INACTIVE:$$HL7TFM^XLFDT(INACTIVE),1:$$NOW^XLFDT)
DO FILE^DIE("K","ORFDA")
QUIT
ADD ;create item if it doesn't exist
IF ORACTION=1
IF 'ORDIFN
Begin DoDot:2
+1 SET ORDIFN=$$CREATE(NAME)
SET ORFIEN=ORDIFN_","
+2 SET ORFDA(101.43,ORFIEN,5)=+ORDG
End DoDot:2
IF 'ORDIFN
QUIT
+3 SET ORFLD(.01)=NAME
SET ORFLD(1.1)=NAME
SET ORFLD(2)=ID
SET ORFLD(3)=$PIECE(ORDITEM,U)
+4 SET SYS=$PIECE(ORDITEM,U,3)
SET ORFLD(4)=$SELECT(+SYS=99:$EXTRACT(SYS,3,99),1:SYS)
+5 SET ORFLD(.1)=$SELECT(ORMFE="MAC":"@",(ORMFE="MUP")&('INACTIVE):"@",INACTIVE:$$HL7TFM^XLFDT(INACTIVE),1:"")
+6 FOR NUM=.01,.1,1.1,2,3,4
SET VALUE=$SELECT(ORFLD(NUM)="":"@",1:ORFLD(NUM))
DO VAL^DIE(101.43,ORFIEN,NUM,"F",VALUE,.ORY,"ORFDA")
ZPKG SET LAST=+MFE
SET ZPKG=$ORDER(@ORMSG@(+MFE))
+1 ; ZXX segment
IF ZPKG
IF $EXTRACT(@ORMSG@(ZPKG),1,3)=("Z"_ORNMSP)
SET ZPKG=ZPKG_U_@ORMSG@(ZPKG)
SET LAST=+ZPKG
DO @ORNMSP
+2 ; file data
DO FILE^DIE("K","ORFDA")
ZLC SET NEXT=$ORDER(@ORMSG@(LAST))
IF NEXT
IF $EXTRACT(@ORMSG@(NEXT),1,3)="ZLC"
Begin DoDot:2
+1 NEW COMP,CID,CODE,CSYS
+2 ;S DIC("P")=$P(^DD(101.43,10,0),U,2)
KILL DA,^ORD(101.43,ORDIFN,10)
+3 SET DA(1)=ORDIFN
SET DIC="^ORD(101.43,"_DA(1)_",10,"
SET DIC(0)="L"
SET ZLC=LAST
+4 FOR
SET ZLC=$ORDER(@ORMSG@(ZLC))
IF ZLC'>0
QUIT
IF $EXTRACT(@ORMSG@(ZLC),1,3)'="ZLC"
QUIT
Begin DoDot:3
+5 SET COMP=$PIECE(@ORMSG@(ZLC),"|",5)
SET X=$PIECE(COMP,U,5)
IF X=""
SET LAST=ZLC
QUIT
+6 SET CID=$PIECE(COMP,U,4)_";"_$PIECE(COMP,U,6)
KILL DIC("DR"),DO,DD
+7 SET CODE=$PIECE(COMP,U)
SET CSYS=$PIECE(COMP,U,3)
IF +CSYS=99
SET CSYS=$EXTRACT(CSYS,3,99)
+8 SET DIC("DR")="2///^S X=CID;3///^S X=CODE;4///^S X=CSYS"
+9 DO FILE^DICN
SET LAST=ZLC
End DoDot:3
End DoDot:2
ZSY ; kill old ones first
IF $DATA(^ORD(101.43,ORDIFN,2))
Begin DoDot:2
+1 SET DA(1)=ORDIFN
SET DIK="^ORD(101.43,"_DA(1)_",2,"
+2 SET DA=0
FOR
SET DA=$ORDER(^ORD(101.43,DA(1),2,DA))
IF DA'>0
QUIT
DO ^DIK
+3 KILL ^ORD(101.43,ORDIFN,2),DIK,DA
End DoDot:2
+4 SET NEXT=$ORDER(@ORMSG@(LAST))
IF NEXT
IF $EXTRACT(@ORMSG@(NEXT),1,3)="ZSY"
Begin DoDot:2
+5 KILL DA,DIC
SET DA(1)=ORDIFN
SET DIC="^ORD(101.43,"_DA(1)_",2,"
+6 ;,DIC("P")=$P(^DD(101.43,1,0),U,2)
SET DIC(0)="L"
SET ZSY=LAST
+7 FOR
SET ZSY=$ORDER(@ORMSG@(+ZSY))
IF ZSY'>0
QUIT
IF $EXTRACT(@ORMSG@(ZSY),1,3)'="ZSY"
QUIT
Begin DoDot:3
+8 SET X=$PIECE(@ORMSG@(ZSY),"|",3)
SET LAST=ZSY
+9 KILL DD,DO
IF $LENGTH(X)
DO FILE^DICN
End DoDot:3
End DoDot:2
NTE ; replace text
KILL ^ORD(101.43,ORDIFN,8)
+1 SET NEXT=$ORDER(@ORMSG@(LAST))
IF NEXT
IF $EXTRACT(@ORMSG@(NEXT),1,3)="NTE"
Begin DoDot:2
+2 SET NTE=LAST
SET DA=0
+3 FOR
SET NTE=$ORDER(@ORMSG@(NTE))
IF NTE'>0
QUIT
IF $EXTRACT(@ORMSG@(NTE),1,3)'="NTE"
QUIT
SET DA=DA+1
SET ^ORD(101.43,ORDIFN,8,DA,0)=$PIECE(@ORMSG@(NTE),"|",4)
IF $ORDER(@ORMSG@(NTE,0))
Begin DoDot:3
+4 SET I=0
FOR
SET I=$ORDER(@ORMSG@(NTE,I))
IF I'>0
QUIT
SET DA=DA+1
SET ^ORD(101.43,ORDIFN,8,DA,0)=@ORMSG@(NTE,I)
End DoDot:3
+5 SET ^ORD(101.43,ORDIFN,8,0)="^^"_DA_U_DA_U_DT_U
End DoDot:2
End DoDot:1
+6 QUIT
+7 ;
NMSP(NAME) ; -- returns namespace for package
+1 IF NAME="RADIOLOGY"
QUIT "RA"
+2 IF NAME="IMAGING"
QUIT "RA"
+3 IF NAME="LABORATORY"
QUIT "LR"
+4 IF NAME="DIETETICS"
QUIT "FH"
+5 IF NAME="PHARMACY"
QUIT "PS"
+6 IF NAME="CONSULTS"
QUIT "CS"
+7 IF NAME="PROCEDURES"
QUIT "CS"
+8 QUIT ""
+9 ;
CREATE(X) ; -- Create new item in #101.43
+1 IF '$LENGTH($GET(X))
QUIT 0
NEW HDR,LAST,TOTAL,I
+2 LOCK +^ORD(101.43,0):1
IF '$TEST
QUIT 0
+3 SET HDR=$GET(^ORD(101.43,0))
IF HDR=""
QUIT 0
+4 SET LAST=$PIECE(HDR,U,3)
SET TOTAL=$PIECE(HDR,U,4)
+5 FOR I=(LAST+1):1
IF '$DATA(^ORD(101.43,I,0))
QUIT
+6 SET ^ORD(101.43,I,0)=X
SET X=$EXTRACT(X,1,30)
SET ^ORD(101.43,"B",$$UP^XLFSTR(X),I)=""
+7 SET $PIECE(^ORD(101.43,0),U,3,4)=I_U_(TOTAL+1)
+8 LOCK -^ORD(101.43,0)
+9 QUIT I
+10 ;
FH ; -- Dietetics
+1 SET X=$PIECE(ZPKG,"|",2)
SET ORFLD(111.1)=$SELECT(X="":"@",1:X)
+2 SET X=$PIECE(ZPKG,"|",3)
SET ORFLD(111.2)=$SELECT(X="":"@",1:X)
+3 SET X=$PIECE(ZPKG,"|",5)
SET ORFLD(111.3)=$SELECT(X="":"@",1:X)
+4 FOR NUM=111.1,111.2,111.3
DO VAL^DIE(101.43,ORFIEN,NUM,"F",ORFLD(NUM),.ORY,"ORFDA")
+5 KILL ^ORD(101.43,ORDIFN,8)
SET X=$PIECE(ZPKG,"|",4)
+6 IF $LENGTH(X)
SET ^ORD(101.43,ORDIFN,8,0)="^^1^1^"_DT_U
SET ^(1,0)=X
+7 QUIT
+8 ;
LR ; -- Laboratory
+1 SET X=$PIECE(ZPKG,"|",2)
SET ORFLD(60.1)=$SELECT(X="":"@",1:X)
+2 SET X=$PIECE(ZPKG,"|",3)
SET ORFLD(60.2)=$SELECT(X="":"@",1:X)
+3 ;S X=$P(ZPKG,"|",4),ORFLD(60.3)=$S(X="":"@",1:X)
+4 SET X=$PIECE(ZPKG,"|",5)
SET ORFLD(60.6)=$SELECT(X="":"@",1:X)
+5 SET X=$PIECE(ZPKG,"|",6)
SET ORFLD(60.4)=$SELECT(X="":"@",1:X)
+6 SET X=$PIECE(ZPKG,"|",7)
SET ORFLD(60.5)=$SELECT(X="":"@",1:X)
+7 SET X=$PIECE(ZPKG,"|",8)
SET ORFLD(6)=$SELECT(X="":"@",1:X)
+8 SET X=$PIECE(ZPKG,"|",9)
SET ORFLD(60.7)=$SELECT(X="":"@",1:X)
+9 FOR NUM=6,60.1,60.2,60.4,60.5,60.6,60.7
DO VAL^DIE(101.43,ORFIEN,NUM,"F",ORFLD(NUM),.ORY,"ORFDA")
+10 QUIT
+11 ;
PS ; -- Pharmacy
+1 NEW ROUTE
+2 SET X=$PIECE(ZPKG,"|",2)
+3 ;S ORFDA(101.43,ORFIEN,50.1)=$S(X'["I":0,$L($P($P(ORDITEM,U,5),"~",3)):2,1:1)
+4 ;inpt or iv med
SET ORFDA(101.43,ORFIEN,50.1)=$SELECT(X["V":2,X["I":1,1:0)
+5 ;outpt med
SET ORFDA(101.43,ORFIEN,50.2)=(X["O")
+6 ;fluid base/soln
SET ORFDA(101.43,ORFIEN,50.3)=(X["B")
+7 ;fluid additive
SET ORFDA(101.43,ORFIEN,50.4)=(X["A")
+8 ;supply item
SET ORFDA(101.43,ORFIEN,50.5)=(X["S")
+9 ;non-VA med
SET ORFDA(101.43,ORFIEN,50.7)=(X["N")
+10 SET X=$PIECE(ZPKG,"|",3)
SET ORFDA(101.43,ORFIEN,50.6)=$SELECT(X:1,1:0)
+11 ;Check for default med route
+12 ;S ROUTE=$$MEDROUTE
+13 ;I ROUTE>0 S ORFDA(101.43,ORFIEN,50.8)=ROUTE
+14 QUIT
+15 ;
MEDROUTE() ;
+1 NEW CNT,ROUTE
+2 SET CNT=0
SET ROUTE=0
+3 FOR
SET CNT=$ORDER(@ORMSG@(CNT))
IF CNT'>0
QUIT
Begin DoDot:1
+4 IF $PIECE($GET(@ORMSG@(CNT)),"|")'="ZPB"
QUIT
+5 SET ROUTE=+$PIECE($GET(@ORMSG@(CNT)),"|",4)
End DoDot:1
+6 QUIT ROUTE
+7 ;
RA ; -- Radiology/Nuc Medicine
+1 SET X=$PIECE(ZPKG,"|",4)
SET ORFLD(6)=$SELECT(X="":"@",1:X)
+2 SET X=$PIECE(ZPKG,"|",5)
SET ORFLD(71.1)=$SELECT(X="":"@",1:X)
+3 SET X=$PIECE(ZPKG,"|",7)
SET ORFLD(71.2)=$SELECT(X="":"@",1:X)
+4 SET X=$PIECE(ZPKG,"|",2)
SET ORFLD(71.3)=$SELECT(X="":"@",1:X)
+5 SET ORFLD(71.4)=$SELECT($PIECE(ZPKG,"|",6)="Y":1,1:0)
+6 SET ORFLD(7)=$SELECT($PIECE(ZPKG,"|",3)="Y":2,1:1)
+7 FOR NUM=6,7,71.1,71.2,71.3,71.4
DO VAL^DIE(101.43,ORFIEN,NUM,"F",ORFLD(NUM),.ORY,"ORFDA")
+8 QUIT
+9 ;
CS ; -- Consults/Requests
+1 SET X=$PIECE(ZPKG,"|",2)
SET ORFLD(123.1)=$SELECT(X="":"@",1:X)
+2 DO VAL^DIE(101.43,ORFIEN,123.1,"F",ORFLD(123.1),.ORY,"ORFDA")
+3 QUIT