PSIVORC2 ;BIR/MLM-PROCESS INCOMPLETE IV ORDER - CONT ;22 OCT 97 / 3:16 PM
;;5.0; INPATIENT MEDICATIONS ;**29,49,50,65,58,85,101,110,127,151**;16 DEC 97
;
; Reference to ^ORD(101 is supported by DBIA #872
; Reference to ^PS(51.2 is supported by DBIA #2178
; Reference to ^PS(55 is supported by DBIA #2191
; Reference to ^PS(52.6 is supported by DBIA #1231.
; Reference to ^PS(52.7 is supported by DBIA #2173.
; Reference to EN1^ORCFLAG is supported by DBIA #3620.
; Reference to ^PSSLOCK is supported by DBIA #2789
;
EDCHK ;Update or create new order in 55.
D CKORD D:'$G(PSJIVORF) ORPARM^PSIVOREN I 'PSJIVORF W !,"Either the Inpatient Medications or the IV Medications package is not on, please check the Order Parameters file" Q
I PSIVCHG,PSJIVORF D NATURE^PSIVOREN I '$D(P("NAT")) W $C(7),"Order unchanged" Q
;;S:PSIVCHG P(21)=""
S:PSIVCHG P("21FLG")=""
I $G(PSJCOM) D IV^PSJCOMV Q
Q:$$NONVF()
ACTIVE ;
S PSJCOM=P("PRNTON")
I PSJCOM D VFYIV^PSJCOMV Q
S P("RES")=$P($G(^PS(53.1,+ON,0)),U,24)
I P("RES")="R" S P("NEWON")=P("OLDON") S PSJOSTOP="" D RUPDATE^PSIVOREN(DFN,ON,P(2))
I P("RES")'="R" S PSJORD=ON,P(17)="A",ORSTS=6,PSJORNP=P(6) D SETNEW^PSIVORFB S P("NEWON")=ON55 D @$S(PSIVCHG:"NEWORD",1:"OLDORD")
S (ON55,ON)=P("NEWON"),OD=P(2) D EN^PSIVORE
D VF1^PSJLIACT("F","ORDER VERIFIED BY ",1)
D ENLBL^PSIVOPT(2,DUZ,DFN,3,+ON55,"N")
I $G(^PS(55,DFN,"IV",+ON55,4)) D EN1^PSJHL2(DFN,"ZV",ON55)
L -^PS(53.1,+$G(PSJORD)) L -^PS(55,DFN,"IV",+ON55)
Q
;
CKORD ;Check if new order is to be created.
I $G(PSIVCOPY) S PSIVCHG=0 Q
N ND S PSIVCHG=0,ND(0)=$G(^PS(53.1,+ON,0)),ND("PD")=$G(^PS(53.1,+ON,.2))_U_$P(ND(0),U,3)
N X S X=$P($G(^PS(53.1,+ON,8)),U,5),X=$S(P(8)["@":$P(X,"@"),1:X)
S ND=$S($E(P("OT"))="I":P(8)_U_$P($G(^PS(53.1,+ON,2)),U)_U_$P(ND(0),U,3)_U_+$P(ND("PD"),U),1:X_U_$P($G(^PS(53.1,+ON,2)),U)_U_+P("MR")_U_+P("PD"))
S ND=ND_U_$S($P(ND(0),U,2)=+P("CLRK"):+$P(ND(0),U,2),1:+P(6))
I ND'=($S($E(P("OT"))="I":P(8),P(8)["@":$P(P(8),"@"),1:P(8))_U_P(9)_U_+P("MR")_U_+P("PD")_U_+P(6)) S PSIVCHG=1 Q
Q:P(17)="P"
N DNE,ND,TDRG S (DRG("DRGC"),DNE)=0
Q:PSIVCHG F DRGT="AD","SOL" F DRGI=0:0 S DRGI=$O(DRG(DRGT,DRGI)) Q:'DRGI S TDRG(DRGT,+$P(DRG(DRGT,DRGI),U),DRGI)=$P(DRG(DRGT,DRGI),U,3) I $P(P("OT"),U)="F",'$P(DRG(DRGT,DRGI),U,5) S P("OT")="I"
F DRGT="AD","SOL" Q:DRGT="SOL"&(P("DTYP")=1) F DRGI=0:0 S DRGI=$O(^PS(53.1,+ON,DRGT,DRGI)) Q:'DRGI!DNE D
.S X=$G(^PS(53.1,+ON,DRGT,DRGI,0)),DRG("DRGC")=$G(DRG("DRGC"))+1
.I $D(TDRG(DRGT,+$P(X,U),DRGI)),$P(X,U,2)=$P(TDRG(DRGT,+$P(X,U),DRGI),U) Q
.S (PSIVCHG,DNE)=1
Q:PSIVCHG
I $G(DRG("AD",0))+$S(P("DTYP")=1:0,1:DRG("SOL",0))'=DRG("DRGC") S PSIVCHG=1 Q
CKPC ;
Q:PSIVCHG I $E(P("OT"))'="I" D
.;
.; Check IV drugs for changes.
.S DNE=0 F DRGT="AD","SOL" I $D(DRG(DRGT)) S FIL="52."_$S(DRGT="AD":6,1:7) D
..N ND,TDRG F DRGI=0:0 S DRGI=$O(DRG(DRGT,DRGI)) Q:'DRGI!DNE S TDRG(+$P(DRG(DRGT,DRGI),U),DRGI)=DRGI,TDRG("CNT")=+$G(TDRG("CNT"))+1
..F ON1=0:0 S ON1=$O(^PS(53.1,+ON,DRGT,ON1)) Q:'+ON1!DNE S ND=$G(^PS(53.1,+ON,DRGT,ON1,0)),ND("CNT")=$G(ND("CNT"))+1 D
...S DRG=+$P(ND,U) S:'$D(TDRG(+DRG)) (DNE,PSIVCHG)=1 F DRGI=0:0 S DRGI=$O(TDRG(+DRG,DRGI)) Q:'DRGI!DNE I $P($G(DRG(DRGT,DRGI)),U)_U_$P($G(DRG(DRGT,DRGI)),U,3)'=$P(ND,U,1,2) S (DNE,PSIVCHG)=1
..S:$G(ND("CNT"))'=$G(TDRG("CNT")) (DNE,PSIVCHG)=1 K ND,TDRG
Q
;
OLDORD ; Update old order, update order links.
Q:P("RES")="R"
S P("OLDON")=$P($G(^PS(53.1,+ON,0)),U,25) I P("OLDON")'=ON55 S $P(^PS(55,DFN,"IV",+ON55,2),U,8)=P("RES"),$P(^(2),U,5)=P("OLDON") I P("OLDON") D
.I P("OLDON")["V",$D(^PS(55,DFN,"IV",+P("OLDON"),0)) S $P(^(2),U,6)=ON55,$P(^(2),U,9)=P("RES")
.I P("OLDON")["A",$D(^PS(55,DFN,5,+P("OLDON"),0)) S $P(^(0),U,26,27)=ON55_U_P("RES")
.;I P("OLDON")["P",$D(^PS(53.1,+P("OLDON"),0)) S $P(^(0),U,26,27)=ON55_U_P("RES")
.I $S(P("OLDON")["P":1,P("OLDON")["N":1,1:0),$D(^PS(53.1,+P("OLDON"),0)) S $P(^(0),U,26,27)=ON55_U_P("RES")
D PUT531^PSIVORFA S $P(^PS(53.1,+ON,0),U,25,26)="^",ON=ON55 D UPD100^PSIVORFA
Q
;
NEWORD ; Create new order, update order links.
Q:P("RES")="R"
S $P(^PS(53.1,+ON,0),U,26,27)=P("NEWON")_U_"E",PSIVAC="CE",PSJORNAT=P("NAT") D DC^PSIVORA
S P("NEWON")=$P($G(^PS(53.1,+PSJORD,0)),U,26),$P(^PS(55,DFN,"IV",+P("NEWON"),2),U,5)=PSJORD,$P(^(2),U,8)="E",ON=ON55
;;I PSJIVORF D SET^PSIVORFE D EN1^PSJHL2(DFN,"SN",+ON55_"V","NEW ORDER CREATED")
I PSJIVORF D EN1^PSJHL2(DFN,"SN",+ON55_"V","NEW ORDER CREATED")
Q
;
GTIVDRG ; Try to find an IV drug from the Orderable Item.
; If there is only 1 match to OI then stuff in DRG otherwise prompt user to select which
; ad/sol matched to OI
K PSIVOI NEW FIL,ND,SCR,PSJNOW
D NOW^%DTC S PSJNOW=%
S SCR("S")="S ND=$P($G(^(""I"")),U) I ND=""""!(ND>PSJNOW)"
F FIL=52.6,52.7 D FIND^DIC(FIL,,"@;.01;2","QXP",+P("PD"),,"AOI",SCR("S"),,"PSIVOI") I +PSIVOI("DILIST",0)>0 D Q
. S DRGT=$S(FIL=52.6:"AD",1:"SOL"),PSIVOI=DRGT
. I PSIVOI="AD" D
.. N XX,XXX,QC S XX=0 F S XX=$O(PSIVOI("DILIST",XX)) Q:XX="" S XXX=+PSIVOI("DILIST",XX,0) D LIST^DIC(52.61,","_XXX_",","@;.01","PQ",,,,,,,"PSIVQC") D
... I +$G(PSIVQC("DILIST",0))>0 S QC=0 F S QC=$O(PSIVQC("DILIST",QC)) Q:QC="" S PSIVOI("DILIST",XX,QC,0)=PSIVQC("DILIST",QC,0)
... K PSIVQC("DILIST",0),PSIVQC("DILIST",0,"MAP")
.. D RESET
. I +PSIVOI("DILIST",0)=1 D
.. S DRG=+PSIVOI("DILIST",1,0)
.. S DNE=1,DRG(DRGT,0)=1,ND=$G(^PS(FIL,+DRG,0)),DRG(DRGT,1)=+DRG_U_$P(ND,U)_U_$S(FIL=52.7:$P(ND,U,3),1:"")_U_U_$P(ND,U,13)_U_$P(ND,U,11)
K:+PSIVOI("DILIST",0)<2 PSIVOI
Q
;
EDIT ; Edit incomplete order
S PSIVAC="CE"
I $E(P("OT"))="I",'$D(DRG("AD")),('$D(DRG("SOL"))) D GTIVDRG
I P(4)="" D 53^PSIVORC1 Q:P(4)="" D ^PSIVORV2
D GSTRING^PSIVORE1,GTFLDS^PSIVORFE ;S (PSIVOK,EDIT)="57^58^59^3"_$S(P("DTYP")=1:"^26^39",1:"")_"^63^64^"_$S($E(P("OT"))="I":"101^109^",1:"")_"10^25"_$S(+P(6)'=+P("CLRK"):"^1",1:"") D GTFLDS^PSIVORFE
Q:$G(DONE)
I $G(^ORD(101,+$P($G(VALM("PROTOCOL")),";"),0))["PSJ PC IV AC/EDIT ACTION" S PSIVENO=1
I '$G(PSIVENO) S PSIVENO=1 D EN^VALM("PSJ LM IV AC/EDIT") S VALMBCK="Q"
;;K ON55 D COMPLTE^PSIVORC1
Q
;
FINISH ; Ask only for missing data in incomplete IV order.
S P("OPI")=$$ENPC^PSJUTL("V",+PSIVUP,60,P("OPI")) I $E(P("OT"))="I",'$D(DRG("AD")),('$D(DRG("SOL"))) S DNE=0 D GTIVDRG
D:P(4)="" 53^PSIVORC1 Q:P(4)="" S P("DTYP")=$S(P(4)="":0,P(4)="P"!(P(23)="P")!(P(5)):1,P(4)="H":2,1:3)
I 'P(2) D ENT^PSIVCAL K %DT S X=P(2),%DT="RTX" D ^%DT S P(2)=+Y
I 'P(3) D ENSTOP^PSIVCAL K %DT S X=P(3),%DT="RTX" D ^%DT S P(3)=+Y
I 'P("MR") S P("MR")=$O(^PS(51.2,"B","INTRAVENOUS",0))_"^IV"
S PSIVOK="1^3^10^25^26^39^57^58^59^63^64" D CKFLDS^PSIVORC1 D:EDIT]"" EDIT^PSIVEDT G COMPLTE^PSIVORC1
Q
NONVF() ; Updated 53.1 status to non-verified after finish.
NEW PSGOEAV S PSGOEAV=+$P(PSJSYSP0,U,9)
I +PSJSYSU=3,PSGOEAV Q 0
I +PSJSYSU=1,PSGOEAV Q 0
I PSIVCHG D NWNONVF Q 1
S P(17)="N",P("REN")=0
D GTPD^PSIVORE2
W !,"...transcribing this non-verified order...."
S $P(^PS(53.1,+ON,.2),U)=""
D PUT531^PSIVORFA
D NEWNVAL^PSGAL5(ON,$S(+PSJSYSU=1:22000,+PSJSYSU=3:22005,1:22006),"","")
NEW PSIVORFA S PSIVORFA=1 D:ON["V" DEL55^PSIVORE2
D EN1^PSJHL2(DFN,"XX",ON,"UPDATED ORDER")
D VF
Q 1
NWNONVF ;Create non-verified due to edit
;D NATURE^PSIVOREN I '$D(P("NAT")) Q
K DA D ENGNN^PSGOETO S P("NEWON")=DA_"P",P(17)="N",P("REN")=0
S PSJORD=ON,$P(^PS(53.1,+ON,0),U,26,27)=P("NEWON")_U_"E",PSIVAC="CE",PSJORNAT=P("NAT") D DC^PSIVORA
S P("OLDON")=ON,ON=P("NEWON")
S P("RES")="E"
;D:P("DO")="" GTPD^PSIVORE2 ;Get dosage order if not defined for IPM IV
S P("DO")="" D GTPD^PSIVORE2 ;Get dosage order if not defined for IPM IV
D PUT531^PSIVORFA
S $P(^PS(53.1,+ON,0),U,25,26)=P("OLDON")_U_""
D NEWNVAL^PSGAL5(ON,$S(+PSJSYSU=1:22000,+PSJSYSU=3:22005,1:22006),"","")
D EN1^PSJHL2(DFN,"SN",ON,"SEND ORDER NUMBER")
S:$D(PSGP)#10 PSJNOL=$$LS^PSSLOCK(PSGP,ON)
D VF
Q
VF ; Display Verify screen
Q:ON'["P"
K PSJIVBD
D GT531^PSIVORFA(DFN,ON)
S PSGACT="EL"
I P(17)="N",(P("OLDON")=""),(+P("CLRK")=DUZ) S PSGACT="ELD"
I +PSJSYSU=3!(+PSJSYSU=1) S PSGACT="DELV"
I +PSJSYSU=3,$L($T(EN1^ORCFLAG)) S PSGACT=PSGACT_"G"
I P("OT")="I" S PSJSTAR="(1)^(5)^(7)^(9)^(10)"
I P("OT")'="I" S PSJSTAR="(1)^(2)^(3)^(5)^(7)^(9)"
D EN^VALM("PSJ LM IV INPT ACTIVE")
Q
;
RESET ;Reset PSIVOI("DILIST") for additives with quick codes
N XX,XXX,CNT S CNT=0
S XX=0 F S XX=$O(PSIVOI("DILIST",XX)) Q:XX="" S CNT=CNT+1,LYN(CNT)=PSIVOI("DILIST",XX,0) D
. S XXX=0 F S XXX=$O(PSIVOI("DILIST",XX,XXX)) Q:XXX="" S CNT=CNT+1,LYN(CNT)=$P(PSIVOI("DILIST",XX,0),"^")_"^"_$P(PSIVOI("DILIST",XX,XXX,0),"^",2)_"^"_$P(PSIVOI("DILIST",XX,XXX,0),"^")_"^"_"QC"
K PSIVOI("DILIST")
S PSIVOI("DILIST",0)=CNT_"^*^0^"
S XX=0 F S XX=$O(LYN(XX)) Q:'XX S PSIVOI("DILIST",XX,0)=LYN(XX)
K LYN
Q
PSIVORC2 ;BIR/MLM-PROCESS INCOMPLETE IV ORDER - CONT ;22 OCT 97 / 3:16 PM
+1 ;;5.0; INPATIENT MEDICATIONS ;**29,49,50,65,58,85,101,110,127,151**;16 DEC 97
+2 ;
+3 ; Reference to ^ORD(101 is supported by DBIA #872
+4 ; Reference to ^PS(51.2 is supported by DBIA #2178
+5 ; Reference to ^PS(55 is supported by DBIA #2191
+6 ; Reference to ^PS(52.6 is supported by DBIA #1231.
+7 ; Reference to ^PS(52.7 is supported by DBIA #2173.
+8 ; Reference to EN1^ORCFLAG is supported by DBIA #3620.
+9 ; Reference to ^PSSLOCK is supported by DBIA #2789
+10 ;
EDCHK ;Update or create new order in 55.
+1 DO CKORD
IF '$GET(PSJIVORF)
DO ORPARM^PSIVOREN
IF 'PSJIVORF
WRITE !,"Either the Inpatient Medications or the IV Medications package is not on, please check the Order Parameters file"
QUIT
+2 IF PSIVCHG
IF PSJIVORF
DO NATURE^PSIVOREN
IF '$DATA(P("NAT"))
WRITE $CHAR(7),"Order unchanged"
QUIT
+3 ;;S:PSIVCHG P(21)=""
+4 IF PSIVCHG
SET P("21FLG")=""
+5 IF $GET(PSJCOM)
DO IV^PSJCOMV
QUIT
+6 IF $$NONVF()
QUIT
ACTIVE ;
+1 SET PSJCOM=P("PRNTON")
+2 IF PSJCOM
DO VFYIV^PSJCOMV
QUIT
+3 SET P("RES")=$PIECE($GET(^PS(53.1,+ON,0)),U,24)
+4 IF P("RES")="R"
SET P("NEWON")=P("OLDON")
SET PSJOSTOP=""
DO RUPDATE^PSIVOREN(DFN,ON,P(2))
+5 IF P("RES")'="R"
SET PSJORD=ON
SET P(17)="A"
SET ORSTS=6
SET PSJORNP=P(6)
DO SETNEW^PSIVORFB
SET P("NEWON")=ON55
DO @$SELECT(PSIVCHG:"NEWORD",1:"OLDORD")
+6 SET (ON55,ON)=P("NEWON")
SET OD=P(2)
DO EN^PSIVORE
+7 DO VF1^PSJLIACT("F","ORDER VERIFIED BY ",1)
+8 DO ENLBL^PSIVOPT(2,DUZ,DFN,3,+ON55,"N")
+9 IF $GET(^PS(55,DFN,"IV",+ON55,4))
DO EN1^PSJHL2(DFN,"ZV",ON55)
+10 LOCK -^PS(53.1,+$GET(PSJORD))
LOCK -^PS(55,DFN,"IV",+ON55)
+11 QUIT
+12 ;
CKORD ;Check if new order is to be created.
+1 IF $GET(PSIVCOPY)
SET PSIVCHG=0
QUIT
+2 NEW ND
SET PSIVCHG=0
SET ND(0)=$GET(^PS(53.1,+ON,0))
SET ND("PD")=$GET(^PS(53.1,+ON,.2))_U_$PIECE(ND(0),U,3)
+3 NEW X
SET X=$PIECE($GET(^PS(53.1,+ON,8)),U,5)
SET X=$SELECT(P(8)["@":$PIECE(X,"@"),1:X)
+4 SET ND=$SELECT($EXTRACT(P("OT"))="I":P(8)_U_$PIECE($GET(^PS(53.1,+ON,2)),U)_U_$PIECE(ND(0),U,3)_U_+$PIECE(ND("PD"),U),1:X_U_$PIECE($GET(^PS(53.1,+ON,2)),U)_U_+P("MR")_U_+P("PD"))
+5 SET ND=ND_U_$SELECT($PIECE(ND(0),U,2)=+P("CLRK"):+$PIECE(ND(0),U,2),1:+P(6))
+6 IF ND'=($SELECT($EXTRACT(P("OT"))="I":P(8),P(8)["@":$PIECE(P(8),"@"),1:P(8))_U_P(9)_U_+P("MR")_U_+P("PD")_U_+P(6))
SET PSIVCHG=1
QUIT
+7 IF P(17)="P"
QUIT
+8 NEW DNE,ND,TDRG
SET (DRG("DRGC"),DNE)=0
+9 IF PSIVCHG
QUIT
FOR DRGT="AD","SOL"
FOR DRGI=0:0
SET DRGI=$ORDER(DRG(DRGT,DRGI))
IF 'DRGI
QUIT
SET TDRG(DRGT,+$PIECE(DRG(DRGT,DRGI),U),DRGI)=$PIECE(DRG(DRGT,DRGI),U,3)
IF $PIECE(P("OT"),U)="F"
IF '$PIECE(DRG(DRGT,DRGI),U,5)
SET P("OT")="I"
+10 FOR DRGT="AD","SOL"
IF DRGT="SOL"&(P("DTYP")=1)
QUIT
FOR DRGI=0:0
SET DRGI=$ORDER(^PS(53.1,+ON,DRGT,DRGI))
IF 'DRGI!DNE
QUIT
Begin DoDot:1
+11 SET X=$GET(^PS(53.1,+ON,DRGT,DRGI,0))
SET DRG("DRGC")=$GET(DRG("DRGC"))+1
+12 IF $DATA(TDRG(DRGT,+$PIECE(X,U),DRGI))
IF $PIECE(X,U,2)=$PIECE(TDRG(DRGT,+$PIECE(X,U),DRGI),U)
QUIT
+13 SET (PSIVCHG,DNE)=1
End DoDot:1
+14 IF PSIVCHG
QUIT
+15 IF $GET(DRG("AD",0))+$SELECT(P("DTYP")=1:0,1:DRG("SOL",0))'=DRG("DRGC")
SET PSIVCHG=1
QUIT
CKPC ;
+1 IF PSIVCHG
QUIT
IF $EXTRACT(P("OT"))'="I"
Begin DoDot:1
+2 ;
+3 ; Check IV drugs for changes.
+4 SET DNE=0
FOR DRGT="AD","SOL"
IF $DATA(DRG(DRGT))
SET FIL="52."_$SELECT(DRGT="AD":6,1:7)
Begin DoDot:2
+5 NEW ND,TDRG
FOR DRGI=0:0
SET DRGI=$ORDER(DRG(DRGT,DRGI))
IF 'DRGI!DNE
QUIT
SET TDRG(+$PIECE(DRG(DRGT,DRGI),U),DRGI)=DRGI
SET TDRG("CNT")=+$GET(TDRG("CNT"))+1
+6 FOR ON1=0:0
SET ON1=$ORDER(^PS(53.1,+ON,DRGT,ON1))
IF '+ON1!DNE
QUIT
SET ND=$GET(^PS(53.1,+ON,DRGT,ON1,0))
SET ND("CNT")=$GET(ND("CNT"))+1
Begin DoDot:3
+7 SET DRG=+$PIECE(ND,U)
IF '$DATA(TDRG(+DRG))
SET (DNE,PSIVCHG)=1
FOR DRGI=0:0
SET DRGI=$ORDER(TDRG(+DRG,DRGI))
IF 'DRGI!DNE
QUIT
IF $PIECE($GET(DRG(DRGT,DRGI)),U)_U_$PIECE($GET(DRG(DRGT,DRGI)),U,3)'=$PIECE(ND,U,1,2)
SET (DNE,PSIVCHG)=1
End DoDot:3
+8 IF $GET(ND("CNT"))'=$GET(TDRG("CNT"))
SET (DNE,PSIVCHG)=1
KILL ND,TDRG
End DoDot:2
End DoDot:1
+9 QUIT
+10 ;
OLDORD ; Update old order, update order links.
+1 IF P("RES")="R"
QUIT
+2 SET P("OLDON")=$PIECE($GET(^PS(53.1,+ON,0)),U,25)
IF P("OLDON")'=ON55
SET $PIECE(^PS(55,DFN,"IV",+ON55,2),U,8)=P("RES")
SET $PIECE(^(2),U,5)=P("OLDON")
IF P("OLDON")
Begin DoDot:1
+3 IF P("OLDON")["V"
IF $DATA(^PS(55,DFN,"IV",+P("OLDON"),0))
SET $PIECE(^(2),U,6)=ON55
SET $PIECE(^(2),U,9)=P("RES")
+4 IF P("OLDON")["A"
IF $DATA(^PS(55,DFN,5,+P("OLDON"),0))
SET $PIECE(^(0),U,26,27)=ON55_U_P("RES")
+5 ;I P("OLDON")["P",$D(^PS(53.1,+P("OLDON"),0)) S $P(^(0),U,26,27)=ON55_U_P("RES")
+6 IF $SELECT(P("OLDON")["P":1,P("OLDON")["N":1,1:0)
IF $DATA(^PS(53.1,+P("OLDON"),0))
SET $PIECE(^(0),U,26,27)=ON55_U_P("RES")
End DoDot:1
+7 DO PUT531^PSIVORFA
SET $PIECE(^PS(53.1,+ON,0),U,25,26)="^"
SET ON=ON55
DO UPD100^PSIVORFA
+8 QUIT
+9 ;
NEWORD ; Create new order, update order links.
+1 IF P("RES")="R"
QUIT
+2 SET $PIECE(^PS(53.1,+ON,0),U,26,27)=P("NEWON")_U_"E"
SET PSIVAC="CE"
SET PSJORNAT=P("NAT")
DO DC^PSIVORA
+3 SET P("NEWON")=$PIECE($GET(^PS(53.1,+PSJORD,0)),U,26)
SET $PIECE(^PS(55,DFN,"IV",+P("NEWON"),2),U,5)=PSJORD
SET $PIECE(^(2),U,8)="E"
SET ON=ON55
+4 ;;I PSJIVORF D SET^PSIVORFE D EN1^PSJHL2(DFN,"SN",+ON55_"V","NEW ORDER CREATED")
+5 IF PSJIVORF
DO EN1^PSJHL2(DFN,"SN",+ON55_"V","NEW ORDER CREATED")
+6 QUIT
+7 ;
GTIVDRG ; Try to find an IV drug from the Orderable Item.
+1 ; If there is only 1 match to OI then stuff in DRG otherwise prompt user to select which
+2 ; ad/sol matched to OI
+3 KILL PSIVOI
NEW FIL,ND,SCR,PSJNOW
+4 DO NOW^%DTC
SET PSJNOW=%
+5 SET SCR("S")="S ND=$P($G(^(""I"")),U) I ND=""""!(ND>PSJNOW)"
+6 FOR FIL=52.6,52.7
DO FIND^DIC(FIL,,"@;.01;2","QXP",+P("PD"),,"AOI",SCR("S"),,"PSIVOI")
IF +PSIVOI("DILIST",0)>0
Begin DoDot:1
+7 SET DRGT=$SELECT(FIL=52.6:"AD",1:"SOL")
SET PSIVOI=DRGT
+8 IF PSIVOI="AD"
Begin DoDot:2
+9 NEW XX,XXX,QC
SET XX=0
FOR
SET XX=$ORDER(PSIVOI("DILIST",XX))
IF XX=""
QUIT
SET XXX=+PSIVOI("DILIST",XX,0)
DO LIST^DIC(52.61,","_XXX_",","@;.01","PQ",,,,,,,"PSIVQC")
Begin DoDot:3
+10 IF +$GET(PSIVQC("DILIST",0))>0
SET QC=0
FOR
SET QC=$ORDER(PSIVQC("DILIST",QC))
IF QC=""
QUIT
SET PSIVOI("DILIST",XX,QC,0)=PSIVQC("DILIST",QC,0)
+11 KILL PSIVQC("DILIST",0),PSIVQC("DILIST",0,"MAP")
End DoDot:3
+12 DO RESET
End DoDot:2
+13 IF +PSIVOI("DILIST",0)=1
Begin DoDot:2
+14 SET DRG=+PSIVOI("DILIST",1,0)
+15 SET DNE=1
SET DRG(DRGT,0)=1
SET ND=$GET(^PS(FIL,+DRG,0))
SET DRG(DRGT,1)=+DRG_U_$PIECE(ND,U)_U_$SELECT(FIL=52.7:$PIECE(ND,U,3),1:"")_U_U_$PIECE(ND,U,13)_U_$PIECE(ND,U,11)
End DoDot:2
End DoDot:1
QUIT
+16 IF +PSIVOI("DILIST",0)<2
KILL PSIVOI
+17 QUIT
+18 ;
EDIT ; Edit incomplete order
+1 SET PSIVAC="CE"
+2 IF $EXTRACT(P("OT"))="I"
IF '$DATA(DRG("AD"))
IF ('$DATA(DRG("SOL")))
DO GTIVDRG
+3 IF P(4)=""
DO 53^PSIVORC1
IF P(4)=""
QUIT
DO ^PSIVORV2
+4 ;S (PSIVOK,EDIT)="57^58^59^3"_$S(P("DTYP")=1:"^26^39",1:"")_"^63^64^"_$S($E(P("OT"))="I":"101^109^",1:"")_"10^25"_$S(+P(6)'=+P("CLRK"):"^1",1:"") D GTFLDS^PSIVORFE
DO GSTRING^PSIVORE1
DO GTFLDS^PSIVORFE
+5 IF $GET(DONE)
QUIT
+6 IF $GET(^ORD(101,+$PIECE($GET(VALM("PROTOCOL")),";"),0))["PSJ PC IV AC/EDIT ACTION"
SET PSIVENO=1
+7 IF '$GET(PSIVENO)
SET PSIVENO=1
DO EN^VALM("PSJ LM IV AC/EDIT")
SET VALMBCK="Q"
+8 ;;K ON55 D COMPLTE^PSIVORC1
+9 QUIT
+10 ;
FINISH ; Ask only for missing data in incomplete IV order.
+1 SET P("OPI")=$$ENPC^PSJUTL("V",+PSIVUP,60,P("OPI"))
IF $EXTRACT(P("OT"))="I"
IF '$DATA(DRG("AD"))
IF ('$DATA(DRG("SOL")))
SET DNE=0
DO GTIVDRG
+2 IF P(4)=""
DO 53^PSIVORC1
IF P(4)=""
QUIT
SET P("DTYP")=$SELECT(P(4)="":0,P(4)="P"!(P(23)="P")!(P(5)):1,P(4)="H":2,1:3)
+3 IF 'P(2)
DO ENT^PSIVCAL
KILL %DT
SET X=P(2)
SET %DT="RTX"
DO ^%DT
SET P(2)=+Y
+4 IF 'P(3)
DO ENSTOP^PSIVCAL
KILL %DT
SET X=P(3)
SET %DT="RTX"
DO ^%DT
SET P(3)=+Y
+5 IF 'P("MR")
SET P("MR")=$ORDER(^PS(51.2,"B","INTRAVENOUS",0))_"^IV"
+6 SET PSIVOK="1^3^10^25^26^39^57^58^59^63^64"
DO CKFLDS^PSIVORC1
IF EDIT]""
DO EDIT^PSIVEDT
GOTO COMPLTE^PSIVORC1
+7 QUIT
NONVF() ; Updated 53.1 status to non-verified after finish.
+1 NEW PSGOEAV
SET PSGOEAV=+$PIECE(PSJSYSP0,U,9)
+2 IF +PSJSYSU=3
IF PSGOEAV
QUIT 0
+3 IF +PSJSYSU=1
IF PSGOEAV
QUIT 0
+4 IF PSIVCHG
DO NWNONVF
QUIT 1
+5 SET P(17)="N"
SET P("REN")=0
+6 DO GTPD^PSIVORE2
+7 WRITE !,"...transcribing this non-verified order...."
+8 SET $PIECE(^PS(53.1,+ON,.2),U)=""
+9 DO PUT531^PSIVORFA
+10 DO NEWNVAL^PSGAL5(ON,$SELECT(+PSJSYSU=1:22000,+PSJSYSU=3:22005,1:22006),"","")
+11 NEW PSIVORFA
SET PSIVORFA=1
IF ON["V"
DO DEL55^PSIVORE2
+12 DO EN1^PSJHL2(DFN,"XX",ON,"UPDATED ORDER")
+13 DO VF
+14 QUIT 1
NWNONVF ;Create non-verified due to edit
+1 ;D NATURE^PSIVOREN I '$D(P("NAT")) Q
+2 KILL DA
DO ENGNN^PSGOETO
SET P("NEWON")=DA_"P"
SET P(17)="N"
SET P("REN")=0
+3 SET PSJORD=ON
SET $PIECE(^PS(53.1,+ON,0),U,26,27)=P("NEWON")_U_"E"
SET PSIVAC="CE"
SET PSJORNAT=P("NAT")
DO DC^PSIVORA
+4 SET P("OLDON")=ON
SET ON=P("NEWON")
+5 SET P("RES")="E"
+6 ;D:P("DO")="" GTPD^PSIVORE2 ;Get dosage order if not defined for IPM IV
+7 ;Get dosage order if not defined for IPM IV
SET P("DO")=""
DO GTPD^PSIVORE2
+8 DO PUT531^PSIVORFA
+9 SET $PIECE(^PS(53.1,+ON,0),U,25,26)=P("OLDON")_U_""
+10 DO NEWNVAL^PSGAL5(ON,$SELECT(+PSJSYSU=1:22000,+PSJSYSU=3:22005,1:22006),"","")
+11 DO EN1^PSJHL2(DFN,"SN",ON,"SEND ORDER NUMBER")
+12 IF $DATA(PSGP)#10
SET PSJNOL=$$LS^PSSLOCK(PSGP,ON)
+13 DO VF
+14 QUIT
VF ; Display Verify screen
+1 IF ON'["P"
QUIT
+2 KILL PSJIVBD
+3 DO GT531^PSIVORFA(DFN,ON)
+4 SET PSGACT="EL"
+5 IF P(17)="N"
IF (P("OLDON")="")
IF (+P("CLRK")=DUZ)
SET PSGACT="ELD"
+6 IF +PSJSYSU=3!(+PSJSYSU=1)
SET PSGACT="DELV"
+7 IF +PSJSYSU=3
IF $LENGTH($TEXT(EN1^ORCFLAG))
SET PSGACT=PSGACT_"G"
+8 IF P("OT")="I"
SET PSJSTAR="(1)^(5)^(7)^(9)^(10)"
+9 IF P("OT")'="I"
SET PSJSTAR="(1)^(2)^(3)^(5)^(7)^(9)"
+10 DO EN^VALM("PSJ LM IV INPT ACTIVE")
+11 QUIT
+12 ;
RESET ;Reset PSIVOI("DILIST") for additives with quick codes
+1 NEW XX,XXX,CNT
SET CNT=0
+2 SET XX=0
FOR
SET XX=$ORDER(PSIVOI("DILIST",XX))
IF XX=""
QUIT
SET CNT=CNT+1
SET LYN(CNT)=PSIVOI("DILIST",XX,0)
Begin DoDot:1
+3 SET XXX=0
FOR
SET XXX=$ORDER(PSIVOI("DILIST",XX,XXX))
IF XXX=""
QUIT
SET CNT=CNT+1
SET LYN(CNT)=$PIECE(PSIVOI("DILIST",XX,0),"^")_"^"_$PIECE(PSIVOI("DILIST",XX,XXX,0),"^",2)_"^"_$PIECE(PSIVOI("DILIST",XX,XXX,0),"^")_"^"_"QC"
End DoDot:1
+4 KILL PSIVOI("DILIST")
+5 SET PSIVOI("DILIST",0)=CNT_"^*^0^"
+6 SET XX=0
FOR
SET XX=$ORDER(LYN(XX))
IF 'XX
QUIT
SET PSIVOI("DILIST",XX,0)=LYN(XX)
+7 KILL LYN
+8 QUIT