PSJORRE ;BIR/MV - RETURN INPATIENT ACTIVE MEDS (CONDENSED) ;Jun 24, 2020@10:05:20
;;5.0;INPATIENT MEDICATIONS;**22,51,50,58,81,110,111,112,134,225,275,315,399**;16 DEC 97;Build 64
;;Per VHA Directive 2004-038, this routine should not be modified.
;Reference to ^PS(52.6 is supported by DBIA 1231.
;Reference to ^PS(52.7 is supported by DBIA 2173.
;Reference to ^PS(55 is supported by DBIA 2191.
;Reference to ^TMP("PS" is documented in DBIA #2383.
;
OCL(DFN,BDT,EDT,TFN,MVIEW) ; return condensed list of inpat meds
; MVIEW=0 - This returns the 'unsorted' list as it was returned prior to GUI 27
; MVIEW=1 - This returns the old sort view of the list, pre-sorted for GUI 27
; MVIEW=2 - This returns new sort view #1 of the order profile for GUI 27
; MVIEW=3 - This returns new sort view #2 of the order profile for GUI 27
D @$S($G(MVIEW)=3:"OCL^PSJORRN1(DFN,BDT,EDT,.TFN)",$G(MVIEW)=2:"OCL^PSJORRN(DFN,BDT,EDT,.TFN)",$G(MVIEW)=1:"OCL^PSJORRO(DFN,BDT,EDT,.TFN)",1:"OCL1(DFN,BDT,EDT,TFN)")
Q
OCL1(DFN,BDT,EDT,TFN,MVIEW) ; Execute this section if MVIEW=0
N ADM,CNT,DN,DO,F,FON,INFUS,INST,MR,ND,ND0,ND2,ND2P1,ND6,ON,PON,PST,SCH,SIO,STAT,TYPE,UNITS,WBDT,X,Y,PSJCLIN,A ;*315
; PON=placer order number (oerr), FON=filler order number
S:BDT="" BDT=DT S WBDT=BDT_".000001"
S:EDT="" EDT=9999999
S:EDT'["." EDT=EDT_".999999"
S F="^PS(55,DFN,5," F S WBDT=$O(^PS(55,DFN,5,"AUS",WBDT)) Q:'WBDT F ON=0:0 S ON=$O(^PS(55,DFN,5,"AUS",WBDT,ON)) Q:'ON D UDTMP
S F="^PS(53.1," F PST="P","N" F ON=0:0 S ON=$O(^PS(53.1,"AS",PST,DFN,ON)) Q:'ON S X=$P($G(^PS(53.1,+ON,0)),U,4) D @$S(X="U":"UDTMP",1:"IVTMP")
S F="^PS(55,"_DFN_",""IV"",",WBDT=BDT F S WBDT=$O(^PS(55,DFN,"IV","AIS",WBDT)) Q:'WBDT F ON=0:0 S ON=$O(^PS(55,DFN,"IV","AIS",WBDT,ON)) Q:'ON D IVTMP
Q
;
UDTMP ;*** Set ^TMP for Unit dose orders.
N PROVIDER,RNWDT,EDTCMPLX,NDP2 S (MR,SCH,INST,PON)="",FON=+ON_$S(F["53.1":"P",1:"U")
D TYPE
S RNWDT=$$LASTREN^PSJLMPRI(DFN,FON) I RNWDT S RNWDT=+RNWDT
S NDP2=$G(@(F_ON_",.2)")) S EDTCMPLX=$P(NDP2,"^",8)
S ND2=$G(@(F_ON_",2)")) I 'EDTCMPLX I F'["53.1",($P(ND2,U,2)>EDT) Q
;*315 drp
S ND2P1=$G(@(F_ON_",2.1)")) I 'EDTCMPLX I F'["53.1",($P(ND2P1,U,2.1)>EDT) Q
S ND0=$G(@(F_ON_",0)")) I 'EDTCMPLX I F["53.1",($P(ND0,U,16)>EDT) Q
S STAT=$$CODES^PSIVUTL($P(ND0,U,9),$S(FON["P":53.1,1:55.06),28)
S ND6=$P($G(@(F_ON_",6)")),"^"),INST=$G(@(F_+ON_",.3)"))
S:ND6["Instructions too long. See Order View or BCMA for full text" ND6="Instructions too long. See order details for full text."
S FON=+ON_$S(F["53.1":"P",1:"U"),DO=$P($G(@(F_ON_",.2)")),"^",2)
D DRGDISP^PSJLMUT1(DFN,FON,40,0,.DN,1)
;*225 Don't allow 0 Units
S UNITS="" I '$O(@(F_+ON_",1,1)")) S UNITS=$P($G(@(F_+ON_",1,1,0)")),U,2) S:(FON["U")&(+UNITS=0) UNITS=1
S:+$P(ND0,U,3) MR=$$MR^PSJORRE1(+$P(ND0,U,3))
N NOTGIVEN S NOTGIVEN=$S(FON["U":$P($G(^PS(55,DFN,5,+ON,0)),"^",22),1:"")
S TFN=TFN+1
S ^TMP("PS",$J,TFN,0)=FON_";I"_U_DN(1)_"^^"_$P(ND2,U,4)_"^^"_DO_U_UNITS_U_$P(ND0,U,21)_U_STAT_U_U_U_U_NOTGIVEN_U_($P(ND0,U,9)="P"&($P(ND0,U,24)="R"))_U_$P(ND2,U,2)_U_$G(RNWDT)
K ^TMP("PS",$J,TFN,"CLINIC",0) I PSJCLIN]"" S ^TMP("PS",$J,TFN,"CLINIC",0)=PSJCLIN
S PROVIDER=$P($G(@(F_+ON_",0)")),"^",2)
I PROVIDER S ^TMP("PS",$J,TFN,"P",0)=PROVIDER_"^"_$P($G(^VA(200,PROVIDER,0)),"^")
S ^TMP("PS",$J,TFN,"MDR",0)=MR]"" S:MR]"" ^TMP("PS",$J,TFN,"MDR",1,0)=MR
S ^TMP("PS",$J,TFN,"SCH",0)=$P(ND2,U)]"" S:$P(ND2,U)]"" ^TMP("PS",$J,TFN,"SCH",1,0)=$P(ND2,U)
S ^TMP("PS",$J,TFN,"SIG",0)=INST]"" S:INST]"" ^TMP("PS",$J,TFN,"SIG",1,0)=INST
S ^TMP("PS",$J,TFN,"ADM",0)=$P(ND2,U,5)]"" S:$P(ND2,U,5)]"" ^TMP("PS",$J,TFN,"ADM",1,0)=$P(ND2,U,5)
S ^TMP("PS",$J,TFN,"RMV",0)=$P(ND2P1,U,2)]"" S:$P(ND2P1,U,2)]"" ^TMP("PS",$J,TFN,"RMV",1,0)=$P(ND2P1,U,2) ;*315
S ^TMP("PS",$J,TFN,"SIO",0)=ND6]"" S:ND6]"" ^TMP("PS",$J,TFN,"SIO",1,0)=ND6
S:$P($G(@(F_ON_",18)")),U)]"" ^TMP("PS",$J,TFN,"IND",0)=$P($G(@(F_ON_",18)")),U) ;*399-IND
Q
;
IVTMP ;*** Set ^TMP for IV orders.
N PROVIDER,START,STOP,EDTCMPLX,NDP2,IVLIM
S NDP2=$G(@(F_ON_",.2)")) S EDTCMPLX=$P(NDP2,"^",8)
S ND0=$G(@(F_ON_",0)")) I 'EDTCMPLX I F'["53.1",($P(ND0,U,2)>EDT) Q
D TYPE
S FON=+ON_$S(F["53.1":"P",1:"V"),TFN=TFN+1,CNT=0
S RNWDT=$$LASTREN^PSJLMPRI(DFN,FON) I RNWDT S RNWDT=+RNWDT
F X=0:0 S X=$O(@(F_ON_",""AD"","_X_")")) Q:'X S ND=$G(@(F_ON_",""AD"","_X_",0)")),DN=$P($G(^PS(52.6,+ND,0)),U),Y=DN_U_$P(ND,U,2) S:$P(ND,U,3) Y=Y_U_$P(ND,U,3) S CNT=CNT+1,^TMP("PS",$J,TFN,"A",CNT,0)=Y
S ^TMP("PS",$J,TFN,"A",0)=CNT,CNT=0
F X=0:0 S X=$O(@(F_ON_",""SOL"","_X_")")) Q:'X S ND=$G(@(F_ON_",""SOL"","_X_",0)")),DN=$G(^PS(52.7,+ND,0)),CNT=CNT+1,^TMP("PS",$J,TFN,"B",CNT,0)=$P(DN,U)_U_$P(ND,U,2)_U_$P(DN,U,4)
S ^TMP("PS",$J,TFN,"B",0)=CNT
S TYPE=$P(ND0,U,4),(MR,SCH,INST,INFUS)=""
I FON["P" S ND2=$G(^PS(53.1,+ON,2)),SCH=$P(ND2,U),START=$P(ND2,U,2),STOP=$P(ND2,U,4),MR=$P(ND0,U,3),INFUS=$P($G(^PS(53.1,+ON,8)),U,5),STAT=$$CODES^PSIVUTL($P(ND0,U,9),53.1,28),ADM=$P(ND2,U,5),SIO=$P($G(@(F_+ON_",6)")),"^")
I FON'["P" S START=$P(ND0,U,2),STOP=$P(ND0,U,3),SCH=$P(ND0,U,9),INFUS=$P(ND0,U,8),MR=$P($G(^PS(55,DFN,"IV",+ON,.2)),U,3),STAT=$$CODES^PSIVUTL($P(ND0,U,17),55.01,100),ADM=$P(ND0,U,11),SIO=$P($G(@(F_+ON_",3)")),"^")
S:($G(SIO)["Instructions too long. See Order View or BCMA for full text") SIO="Instructions too long. See order details for full text."
S DN=$G(@(F_+ON_",.2)")),DO=$P(DN,U,2)
S DN=$S(+$P(DN,U):$$OIDF^PSJLMUT1($P(DN,U)),1:"")
S:MR MR=$$MR^PSJORRE1(+MR),INST=$G(@(F_+ON_",.3)"))
S ^TMP("PS",$J,TFN,0)=FON_";I"_U_DN_U_INFUS_U_STOP_"^^"_DO_"^^"_$P(ND0,"^",21)_U_STAT_U_U_U_U_U_($P(ND0,U,9)="P"&($P(ND0,U,24)="R"))_U_START_U_$G(RNWDT)
K ^TMP("PS",$J,TFN,"CLINIC",0) I PSJCLIN]"" S ^TMP("PS",$J,TFN,"CLINIC",0)=PSJCLIN
S PROVIDER=$P($G(@(F_+ON_",0)")),"^",6)
I PROVIDER S ^TMP("PS",$J,TFN,"P",0)=PROVIDER_"^"_$P($G(^VA(200,PROVIDER,0)),"^")
S ND2P5=$G(@(F_+ON_",2.5)")) S IVLIM=$P(ND2P5,U,4) I $E(IVLIM)="a" S IVLIM="doses"_$P(IVLIM,"a",2)
I IVLIM="" S IVLIM=$P(ND2P5,U,2) S:(IVLIM'["d")&(IVLIM'["h") IVLIM=""
S ^TMP("PS",$J,TFN,"MDR",0)=MR]"" S:MR]"" ^TMP("PS",$J,TFN,"MDR",1,0)=MR
S ^TMP("PS",$J,TFN,"SIG",0)=INST]"" S:INST]"" ^TMP("PS",$J,TFN,"SIG",1,0)=INST
S ^TMP("PS",$J,TFN,"SCH",0)=SCH]"" S:SCH]"" ^TMP("PS",$J,TFN,"SCH",1,0)=SCH
S ^TMP("PS",$J,TFN,"ADM",0)=ADM]"" S:ADM]"" ^TMP("PS",$J,TFN,"ADM",1,0)=ADM
S ^TMP("PS",$J,TFN,"SIO",0)=SIO]"" S:SIO]"" ^TMP("PS",$J,TFN,"SIO",1,0)=SIO
I $G(IVLIM)]"" S ^TMP("PS",$J,TFN,"IVLIM",0)=IVLIM
S:$P($G(@(F_ON_",18)")),U)]"" ^TMP("PS",$J,TFN,"IND",0)=$P($G(@(F_ON_",18)")),U) ;*399-IND
Q
STAT(Y,X) ;* Return the full status instead of just the code for U/D.
S X=$P($P(";"_$P(Y,U,3),";"_X_":",2),";")
Q X
TYPE ;determine if this is an IMO order or not
S (A,PSJCLIN)="" I F["PS(53.1" S A=$G(^PS(53.1,ON,"DSS"))
I F["PS(55" S A=$S(F["IV":$G(^PS(55,DFN,"IV",ON,"DSS")),1:$G(^PS(55,DFN,5,ON,8)))
I $P(A,"^",2)'="" S PSJCLIN=+A
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSJORRE 6953 printed Dec 13, 2024@02:08:22 Page 2
PSJORRE ;BIR/MV - RETURN INPATIENT ACTIVE MEDS (CONDENSED) ;Jun 24, 2020@10:05:20
+1 ;;5.0;INPATIENT MEDICATIONS;**22,51,50,58,81,110,111,112,134,225,275,315,399**;16 DEC 97;Build 64
+2 ;;Per VHA Directive 2004-038, this routine should not be modified.
+3 ;Reference to ^PS(52.6 is supported by DBIA 1231.
+4 ;Reference to ^PS(52.7 is supported by DBIA 2173.
+5 ;Reference to ^PS(55 is supported by DBIA 2191.
+6 ;Reference to ^TMP("PS" is documented in DBIA #2383.
+7 ;
OCL(DFN,BDT,EDT,TFN,MVIEW) ; return condensed list of inpat meds
+1 ; MVIEW=0 - This returns the 'unsorted' list as it was returned prior to GUI 27
+2 ; MVIEW=1 - This returns the old sort view of the list, pre-sorted for GUI 27
+3 ; MVIEW=2 - This returns new sort view #1 of the order profile for GUI 27
+4 ; MVIEW=3 - This returns new sort view #2 of the order profile for GUI 27
+5 DO @$SELECT($GET(MVIEW)=3:"OCL^PSJORRN1(DFN,BDT,EDT,.TFN)",$GET(MVIEW)=2:"OCL^PSJORRN(DFN,BDT,EDT,.TFN)",$GET(MVIEW)=1:"OCL^PSJORRO(DFN,BDT,EDT,.TFN)",1:"OCL1(DFN,BDT,EDT,TFN)")
+6 QUIT
OCL1(DFN,BDT,EDT,TFN,MVIEW) ; Execute this section if MVIEW=0
+1 ;*315
NEW ADM,CNT,DN,DO,F,FON,INFUS,INST,MR,ND,ND0,ND2,ND2P1,ND6,ON,PON,PST,SCH,SIO,STAT,TYPE,UNITS,WBDT,X,Y,PSJCLIN,A
+2 ; PON=placer order number (oerr), FON=filler order number
+3 if BDT=""
SET BDT=DT
SET WBDT=BDT_".000001"
+4 if EDT=""
SET EDT=9999999
+5 if EDT'["."
SET EDT=EDT_".999999"
+6 SET F="^PS(55,DFN,5,"
FOR
SET WBDT=$ORDER(^PS(55,DFN,5,"AUS",WBDT))
if 'WBDT
QUIT
FOR ON=0:0
SET ON=$ORDER(^PS(55,DFN,5,"AUS",WBDT,ON))
if 'ON
QUIT
DO UDTMP
+7 SET F="^PS(53.1,"
FOR PST="P","N"
FOR ON=0:0
SET ON=$ORDER(^PS(53.1,"AS",PST,DFN,ON))
if 'ON
QUIT
SET X=$PIECE($GET(^PS(53.1,+ON,0)),U,4)
DO @$SELECT(X="U":"UDTMP",1:"IVTMP")
+8 SET F="^PS(55,"_DFN_",""IV"","
SET WBDT=BDT
FOR
SET WBDT=$ORDER(^PS(55,DFN,"IV","AIS",WBDT))
if 'WBDT
QUIT
FOR ON=0:0
SET ON=$ORDER(^PS(55,DFN,"IV","AIS",WBDT,ON))
if 'ON
QUIT
DO IVTMP
+9 QUIT
+10 ;
UDTMP ;*** Set ^TMP for Unit dose orders.
+1 NEW PROVIDER,RNWDT,EDTCMPLX,NDP2
SET (MR,SCH,INST,PON)=""
SET FON=+ON_$SELECT(F["53.1":"P",1:"U")
+2 DO TYPE
+3 SET RNWDT=$$LASTREN^PSJLMPRI(DFN,FON)
IF RNWDT
SET RNWDT=+RNWDT
+4 SET NDP2=$GET(@(F_ON_",.2)"))
SET EDTCMPLX=$PIECE(NDP2,"^",8)
+5 SET ND2=$GET(@(F_ON_",2)"))
IF 'EDTCMPLX
IF F'["53.1"
IF ($PIECE(ND2,U,2)>EDT)
QUIT
+6 ;*315 drp
+7 SET ND2P1=$GET(@(F_ON_",2.1)"))
IF 'EDTCMPLX
IF F'["53.1"
IF ($PIECE(ND2P1,U,2.1)>EDT)
QUIT
+8 SET ND0=$GET(@(F_ON_",0)"))
IF 'EDTCMPLX
IF F["53.1"
IF ($PIECE(ND0,U,16)>EDT)
QUIT
+9 SET STAT=$$CODES^PSIVUTL($PIECE(ND0,U,9),$SELECT(FON["P":53.1,1:55.06),28)
+10 SET ND6=$PIECE($GET(@(F_ON_",6)")),"^")
SET INST=$GET(@(F_+ON_",.3)"))
+11 if ND6["Instructions too long. See Order View or BCMA for full text"
SET ND6="Instructions too long. See order details for full text."
+12 SET FON=+ON_$SELECT(F["53.1":"P",1:"U")
SET DO=$PIECE($GET(@(F_ON_",.2)")),"^",2)
+13 DO DRGDISP^PSJLMUT1(DFN,FON,40,0,.DN,1)
+14 ;*225 Don't allow 0 Units
+15 SET UNITS=""
IF '$ORDER(@(F_+ON_",1,1)"))
SET UNITS=$PIECE($GET(@(F_+ON_",1,1,0)")),U,2)
if (FON["U")&(+UNITS=0)
SET UNITS=1
+16 if +$PIECE(ND0,U,3)
SET MR=$$MR^PSJORRE1(+$PIECE(ND0,U,3))
+17 NEW NOTGIVEN
SET NOTGIVEN=$SELECT(FON["U":$PIECE($GET(^PS(55,DFN,5,+ON,0)),"^",22),1:"")
+18 SET TFN=TFN+1
+19 SET ^TMP("PS",$JOB,TFN,0)=FON_";I"_U_DN(1)_"^^"_$PIECE(ND2,U,4)_"^^"_DO_U_UNITS_U_$PIECE(ND0,U,21)_U_STAT_U_U_U_U_NOTGIVEN_U_($PIECE(ND0,U,9)="P"&($PIECE(ND0,U,24)="R"))_U_$PIECE(ND2,U,2)_U_$GET(RNWDT)
+20 KILL ^TMP("PS",$JOB,TFN,"CLINIC",0)
IF PSJCLIN]""
SET ^TMP("PS",$JOB,TFN,"CLINIC",0)=PSJCLIN
+21 SET PROVIDER=$PIECE($GET(@(F_+ON_",0)")),"^",2)
+22 IF PROVIDER
SET ^TMP("PS",$JOB,TFN,"P",0)=PROVIDER_"^"_$PIECE($GET(^VA(200,PROVIDER,0)),"^")
+23 SET ^TMP("PS",$JOB,TFN,"MDR",0)=MR]""
if MR]""
SET ^TMP("PS",$JOB,TFN,"MDR",1,0)=MR
+24 SET ^TMP("PS",$JOB,TFN,"SCH",0)=$PIECE(ND2,U)]""
if $PIECE(ND2,U)]""
SET ^TMP("PS",$JOB,TFN,"SCH",1,0)=$PIECE(ND2,U)
+25 SET ^TMP("PS",$JOB,TFN,"SIG",0)=INST]""
if INST]""
SET ^TMP("PS",$JOB,TFN,"SIG",1,0)=INST
+26 SET ^TMP("PS",$JOB,TFN,"ADM",0)=$PIECE(ND2,U,5)]""
if $PIECE(ND2,U,5)]""
SET ^TMP("PS",$JOB,TFN,"ADM",1,0)=$PIECE(ND2,U,5)
+27 ;*315
SET ^TMP("PS",$JOB,TFN,"RMV",0)=$PIECE(ND2P1,U,2)]""
if $PIECE(ND2P1,U,2)]""
SET ^TMP("PS",$JOB,TFN,"RMV",1,0)=$PIECE(ND2P1,U,2)
+28 SET ^TMP("PS",$JOB,TFN,"SIO",0)=ND6]""
if ND6]""
SET ^TMP("PS",$JOB,TFN,"SIO",1,0)=ND6
+29 ;*399-IND
if $PIECE($GET(@(F_ON_",18)")),U)]""
SET ^TMP("PS",$JOB,TFN,"IND",0)=$PIECE($GET(@(F_ON_",18)")),U)
+30 QUIT
+31 ;
IVTMP ;*** Set ^TMP for IV orders.
+1 NEW PROVIDER,START,STOP,EDTCMPLX,NDP2,IVLIM
+2 SET NDP2=$GET(@(F_ON_",.2)"))
SET EDTCMPLX=$PIECE(NDP2,"^",8)
+3 SET ND0=$GET(@(F_ON_",0)"))
IF 'EDTCMPLX
IF F'["53.1"
IF ($PIECE(ND0,U,2)>EDT)
QUIT
+4 DO TYPE
+5 SET FON=+ON_$SELECT(F["53.1":"P",1:"V")
SET TFN=TFN+1
SET CNT=0
+6 SET RNWDT=$$LASTREN^PSJLMPRI(DFN,FON)
IF RNWDT
SET RNWDT=+RNWDT
+7 FOR X=0:0
SET X=$ORDER(@(F_ON_",""AD"","_X_")"))
if 'X
QUIT
SET ND=$GET(@(F_ON_",""AD"","_X_",0)"))
SET DN=$PIECE($GET(^PS(52.6,+ND,0)),U)
SET Y=DN_U_$PIECE(ND,U,2)
if $PIECE(ND,U,3)
SET Y=Y_U_$PIECE(ND,U,3)
SET CNT=CNT+1
SET ^TMP("PS",$JOB,TFN,"A",CNT,0)=Y
+8 SET ^TMP("PS",$JOB,TFN,"A",0)=CNT
SET CNT=0
+9 FOR X=0:0
SET X=$ORDER(@(F_ON_",""SOL"","_X_")"))
if 'X
QUIT
SET ND=$GET(@(F_ON_",""SOL"","_X_",0)"))
SET DN=$GET(^PS(52.7,+ND,0))
SET CNT=CNT+1
SET ^TMP("PS",$JOB,TFN,"B",CNT,0)=$PIECE(DN,U)_U_$PIECE(ND,U,2)_U_$PIECE(DN,U,4)
+10 SET ^TMP("PS",$JOB,TFN,"B",0)=CNT
+11 SET TYPE=$PIECE(ND0,U,4)
SET (MR,SCH,INST,INFUS)=""
+12 IF FON["P"
SET ND2=$GET(^PS(53.1,+ON,2))
SET SCH=$PIECE(ND2,U)
SET START=$PIECE(ND2,U,2)
SET STOP=$PIECE(ND2,U,4)
SET MR=$PIECE(ND0,U,3)
SET INFUS=$PIECE($GET(^PS(53.1,+ON,8)),U,5)
SET STAT=$$CODES^PSIVUTL($PIECE(ND0,U,9),53.1,28)
SET ADM=$PIECE(ND2,U,5)
SET SIO=$PIECE($GET(@(F_+ON_",6)")),"^")
+13 IF FON'["P"
SET START=$PIECE(ND0,U,2)
SET STOP=$PIECE(ND0,U,3)
SET SCH=$PIECE(ND0,U,9)
SET INFUS=$PIECE(ND0,U,8)
SET MR=$PIECE($GET(^PS(55,DFN,"IV",+ON,.2)),U,3)
SET STAT=$$CODES^PSIVUTL($PIECE(ND0,U,17),55.01,100)
SET ADM=$PIECE(ND0,U,11)
SET SIO=$PIECE($GET(@(F_+ON_",3)")),"^")
+14 if ($GET(SIO)["Instructions too long. See Order View or BCMA for full text")
SET SIO="Instructions too long. See order details for full text."
+15 SET DN=$GET(@(F_+ON_",.2)"))
SET DO=$PIECE(DN,U,2)
+16 SET DN=$SELECT(+$PIECE(DN,U):$$OIDF^PSJLMUT1($PIECE(DN,U)),1:"")
+17 if MR
SET MR=$$MR^PSJORRE1(+MR)
SET INST=$GET(@(F_+ON_",.3)"))
+18 SET ^TMP("PS",$JOB,TFN,0)=FON_";I"_U_DN_U_INFUS_U_STOP_"^^"_DO_"^^"_$PIECE(ND0,"^",21)_U_STAT_U_U_U_U_U_($PIECE(ND0,U,9)="P"&($PIECE(ND0,U,24)="R"))_U_START_U_$GET(RNWDT)
+19 KILL ^TMP("PS",$JOB,TFN,"CLINIC",0)
IF PSJCLIN]""
SET ^TMP("PS",$JOB,TFN,"CLINIC",0)=PSJCLIN
+20 SET PROVIDER=$PIECE($GET(@(F_+ON_",0)")),"^",6)
+21 IF PROVIDER
SET ^TMP("PS",$JOB,TFN,"P",0)=PROVIDER_"^"_$PIECE($GET(^VA(200,PROVIDER,0)),"^")
+22 SET ND2P5=$GET(@(F_+ON_",2.5)"))
SET IVLIM=$PIECE(ND2P5,U,4)
IF $EXTRACT(IVLIM)="a"
SET IVLIM="doses"_$PIECE(IVLIM,"a",2)
+23 IF IVLIM=""
SET IVLIM=$PIECE(ND2P5,U,2)
if (IVLIM'["d")&(IVLIM'["h")
SET IVLIM=""
+24 SET ^TMP("PS",$JOB,TFN,"MDR",0)=MR]""
if MR]""
SET ^TMP("PS",$JOB,TFN,"MDR",1,0)=MR
+25 SET ^TMP("PS",$JOB,TFN,"SIG",0)=INST]""
if INST]""
SET ^TMP("PS",$JOB,TFN,"SIG",1,0)=INST
+26 SET ^TMP("PS",$JOB,TFN,"SCH",0)=SCH]""
if SCH]""
SET ^TMP("PS",$JOB,TFN,"SCH",1,0)=SCH
+27 SET ^TMP("PS",$JOB,TFN,"ADM",0)=ADM]""
if ADM]""
SET ^TMP("PS",$JOB,TFN,"ADM",1,0)=ADM
+28 SET ^TMP("PS",$JOB,TFN,"SIO",0)=SIO]""
if SIO]""
SET ^TMP("PS",$JOB,TFN,"SIO",1,0)=SIO
+29 IF $GET(IVLIM)]""
SET ^TMP("PS",$JOB,TFN,"IVLIM",0)=IVLIM
+30 ;*399-IND
if $PIECE($GET(@(F_ON_",18)")),U)]""
SET ^TMP("PS",$JOB,TFN,"IND",0)=$PIECE($GET(@(F_ON_",18)")),U)
+31 QUIT
STAT(Y,X) ;* Return the full status instead of just the code for U/D.
+1 SET X=$PIECE($PIECE(";"_$PIECE(Y,U,3),";"_X_":",2),";")
+2 QUIT X
TYPE ;determine if this is an IMO order or not
+1 SET (A,PSJCLIN)=""
IF F["PS(53.1"
SET A=$GET(^PS(53.1,ON,"DSS"))
+2 IF F["PS(55"
SET A=$SELECT(F["IV":$GET(^PS(55,DFN,"IV",ON,"DSS")),1:$GET(^PS(55,DFN,5,ON,8)))
+3 IF $PIECE(A,"^",2)'=""
SET PSJCLIN=+A
+4 QUIT