PSIVEDRG ;BIR/MLM-ENTER/EDIT DRUGS FOR IV ORDER ;29-May-2012 14:32;PLS
;;5.0; INPATIENT MEDICATIONS ;**21,33,50,65,74,84,128,147,1015**;16 DEC 97;Build 62
;
; References to ^PS(52.6 supported by DBIA# 1231.
; References to ^PS(52.7 supported by DBIA# 2173.
; Reference to EN^PSOORDRG supported by DBIA# 2190.
;
; Modified - IHS/MSC/PB - 4/25/12 modified to add the new stability offset value to the DRG array
; this value is used to determine the iv expiration date
DRG ; Edit Additive/Solution data
NEW DRGOC,PSGORQF ;If PSGORQF=1 abort order after order check.
K PSIVOLD S DRG(2)="" I $D(DRG(DRGT)) S DRGI=+$O(DRG(DRGT,0)) I DRGI S PSIVOLD=1 D SETDRG
DRG1 ;
Q:$G(PSGORQF)
I $G(X)="?" K DUOUT
D FULL^VALM1
W !,"Select ",DRGTN,": "
I DRGT=$G(PSIVOI),($G(PSIVOI("DILIST",0))>1) D GTADSOL Q
W:DRG(2)]"" DRG(2),"//" R X:DTIME S:'$T X="^" S:X=U DONE=1 Q:X["^"!(X=""&(DRG(2)=""))
DRG1A I X="" W !,DRGTN,": ",DRG(2),"//" R X:DTIME S:'$T X="^" Q:X="^" I X="" S Y=1 D DRG3 G:DRGT="AD"!($G(P(4))="H") DRG1 Q
I X="@",DRG(2)]"" D DEL G:%'=1 DRG1A K DRG(DRGT,DRGI) S DRGI=+$O(DRG(DRGT,0)) S:'DRGI DRG(DRGT,0)=0 D SETDRG G DRG1
I X["???",($E(P("OT"))="M"),(PSIVAC["C") D ORFLDS^PSIVEDT1 G DRG1
I X'["?" S %=0 D:$D(DRG(DRGT)) CHK G:%=1 DRG1A D DRG2 Q:$G(Y)>0&($G(P(4))'="H"&(DRGT="SOL")) G DRG1
I $D(DRG(DRGT)) W !,"This order includes the following ",DRGTN,"S:",! F Y=0:0 S Y=$O(DRG(DRGT,Y)) Q:'Y W !,$P(DRG(DRGT,Y),U,2)
W !,"YOU MAY ENTER A NEW ",DRGTN,", IF YOU WISH",! D GTSCRN(X) S DIC(0)="EQM" D ^DIC K DIC G DRG1
Q
;
SETDRG ; Put Drug data into DRG(x).
F X=1:1:6 S DRG(X)=$P(DRG(DRGT,DRGI),U,X)
S X="" I DRG(2)="",DRG(1) S DRG(2)="*** Undefined ***"
Q
DRG2 ;
D GTSCRN(X) N PSIVX S PSIVX=X,DIC(0)="EQMZ" D ^DIC K DIC Q:Y<0
S PSJIVIEN=+Y
NEW PSJNF D NFIV^PSJDIN($S(DRGT="AD":52.6,1:52.7),+PSJIVIEN,.PSJNF)
W PSJNF("NF")
;IHS/MSC/PB - 4/25/12 line below modified to add the stability offset value to the DRG array as piece 7
S PSIVNEW=1,DRGTMP=+Y_U_$P(Y(0),U)_U_$S(DRGT="SOL":$P(Y(0),U,3),1:"")_U_U_$P(Y(0),U,13)_U_$P(Y(0),U,11)_U_$G(^PS($S(DRGT="AD":52.6,1:52.7),+Y,9999999))
I '$D(ON55) NEW ON55 S ON55=ON
D ORDERCHK(DFN,ON55,1) I $G(PSGORQF) S X=U,DONE=1 Q
D DINIV^PSJDIN($S(DRGT="AD":52.6,1:52.7),+DRGTMP)
S (DRG(DRGT,0),DRGI)=$G(DRG(DRGT,0))+1,DRG(DRGT,DRGI)=DRGTMP K PSIVOLD
I (PSIVAC="PN"!(PSIVAC="CF")),(DRGT="AD"),$D(^PS(52.6,"C",PSIVX,+DRGTMP)) D ^PSIVQUI Q:$G(PSIVSTR)="QUICK CODE"!$G(PSGORQF)
DRG3 ;
D:DRG(2)]"" DINIV^PSJDIN(FIL,+DRG(1))
D SETDRG
I DRGT="AD" S X=$P($G(^PS(FIL,+DRG(1),0)),U,3) W !!,"(The units of strength for this additive are in ",$$ENU^PSIVUTL(DRG(1)),")"
AMT ;
I DRGT="SOL",'$G(PSIVOLD),($G(P(4))_$G(P(23))'["S") G DRG4
1 ; Strength/Volume
W !,$S(DRGT="AD":"Strength: ",1:"Volume: ") W:+DRG(3) DRG(3),"//" R X:DTIME S:'$T X="^" Q:X="^" G:X=""&DRG(3) 2 I X="" W $C(7),$S(DRGT="AD":"Strength",1:"Volume")," is REQUIRED!" G 1
D:$D(X) IT G:'$D(X)!($G(X)["?") AMT S DRG(3)=X I X="" D FIELD^DID($S(DRGT="AD":53.157,1:53.158),1,"","XECUTABLE HELP","PSJEX") X PSJEX("XECUTABLE HELP") K PSJEX G AMT
2 I DRGT="AD",$G(P("DTYP"))>1,P(4)'="S",P(23)'="S" K DIR S DIR(0)="53.157,2" S:DRG(4)]"" DIR("B")=DRG(4) D ^DIR Q:$D(DTOUT)!$D(DUOUT) S:Y DRG(4)=Y
DRG4 ;
F X=1:1:6 S $P(DRG(DRGT,DRGI),U,X)=DRG(X)
S DRG(2)=""
Q
;
GTSCRN(PSIVX) ;Set DIC("S") if MD OE or matching drug has already been selected.
D:"?"[PSIVX HOLDHDR^PSJOE
S X=PSIVX
K DA,DIC S DIC=FIL,DIC("S")=$$IVDRGSC^PSIVUTL
I $E(PSIVAC)'="P",($P(P("OT"),U)="F") S X(1)=" I $P(X(1),U,13)",DIC("S")=$G(DIC("S"))_$S(DRGT="AD":X(1),$E(PSIVAC)="O":X(1),1:"")
Q
;
IT ; Input Transform for Strength/Volume.
I X?1.N,$L(X)>20 S X="?"
I X["?" W $C(7) S F1=53.15_$S(DRGT="AD":7,1:8),F2=1 D ENHLP^PSIVORC1 Q
I DRGT="AD" K:X'?.6N0.1".".8N!('X) X I $D(X) S:(X<1)&($P(X,".")'=0) X=0_X S X=X_" "_$$ENU^PSIVUTL(DRG(1)) W " ",X Q
I $D(X) K:X=""!(X'?.N0.1".".N)!(X>9999)!(X<.01) X I $D(X) S:(X<1)&($P(X,".")'=0) X=0_X S X=X_" ML" W " ",X
W:'$D(X) $C(7),"??"
Q
;
ORDERCHK(DFN,ON,X) ; Do order check
;* If X is define, include the DRG(X) to the order check
I X M:$D(DRG) DRGOC(ON)=DRG
NEW TMPDRG,X,XX,Y,PSIVNEW,PSGDRG,PSGDRGN,PSJDD,PSGP
D SAVEDRG(.TMPDRG,.DRG) ;Store DRG array in TMPDRG array
S PSIVNEW=1,PSGDRGN=$P($G(DRGTMP),U,2)
S (PSJDD,PSGDRG)=$P(^PS(FIL,+DRGTMP,0),U,2),PSGP=DFN
I FIL="52.6" D ENDDC^PSGSICHK(DFN,PSGDRG)
I FIL="52.7" D
. D EN^PSOORDRG(DFN,PSGDRG)
. N INTERVEN,PSJIREQ,PSJRXREQ S Y=1,(PSJIREQ,PSJRXREQ,INTERVEN,X)=""
. S DFN=PSGP K PSJPDRG
. D IVSOL^PSGSICHK
D SAVEDRG(.DRG,.TMPDRG) ;Restore DRG array from TMPDRG array
D ENSTOP^PSIVCAL
Q
SAVEDRG(NEW,OLD) ;Store/restore DRG array.
S:$G(OLD) NEW=OLD
F X=0:0 S X=$O(OLD(X)) Q:'X S NEW(X)=OLD(X)
F XX="AD","SOL" D
. I $D(OLD(XX,0))#10=1 S NEW(XX,0)=OLD(XX,0)
. F X=0:0 S X=$O(OLD(XX,X)) Q:'X S NEW(XX,X)=OLD(XX,X)
Q
;
CHK ; Check if drug is already part of order
N DDONE,I,TDRG,TDRGP F TDRG=0:0 S TDRG=$O(DRG(DRGT,TDRG)) Q:'TDRG!$G(DDONE) D
.I $$UPPER^VALM1($E($P(DRG(DRGT,+TDRG),U,2),1,$L(X)))=$$UPPER^VALM1(X) W $P($$UPPER^VALM1($P(DRG(DRGT,+TDRG),U,2)),$$UPPER^VALM1(X),2) D ASKCHK Q
.S TDRGP=$P(DRG(DRGT,TDRG),U) F J=0:0 S J=$O(^PS(FIL,TDRGP,3,J)) Q:'J!$G(DDONE) I $$UPPER^VALM1($E($P(^PS(FIL,TDRGP,3,J,0),U),1,$L(X)))=$$UPPER^VALM1(X) D D ASKCHK Q
..W $P($$UPPER^VALM1($P(^PS(FIL,TDRGP,3,J,0),U)),$$UPPER^VALM1(X),2)," ",$P(DRG(DRGT,TDRG),U,2)
Q
;
ASKCHK ; Do you want a drug that was previously selected.
S I=DRG(DRGT,TDRG) W " ",$P(I,U,3),$S($P(I,U,4):" ("_$P(I,U,4)_")",1:""),!,"...OK" S %=1 D YN^DICN
I %=1 S X="",DRGI=TDRG,(DDONE,PSIVOLD)=1 D SETDRG Q
W !,X
Q
;
DEL ;
W !?3,"SURE YOU WANT TO DELETE" S %=0 D YN^DICN S X="" I %'=1 W " <NOTHING DELETED>"
Q
GTADSOL ;If there're multiple ad/sol matched to an OI then display so user to select ad/sol
;PSIVOI array is defined in GTIVDRG^PSIVORC2
NEW DIR,ND,X,Y
S DIR(0)="LA^1:"_+PSIVOI("DILIST",0)
S DIR("?")="Please select "_$S(PSIVOI="AD":"an Additive or Quick Code",1:"a Solution")_" from the list"
F X=0:0 S X=$O(PSIVOI("DILIST",X)) Q:'X D
. S DIR("A",X)=" "_X_" "_$S($P(PSIVOI("DILIST",X,0),U,4)="QC":" - "_$P(PSIVOI("DILIST",X,0),U,2)_" -",1:$P(PSIVOI("DILIST",X,0),U,2))_$S(PSIVOI="SOL":" "_$P(PSIVOI("DILIST",X,0),U,3),1:"")
S DIR("A")="Select (1 - "_+PSIVOI("DILIST",0)_"): "
D ^DIR
I +Y D
. NEW PSIVOIND S PSIVOIND=PSIVOI("DILIST",+Y,0)
. W " "_$P(PSIVOIND,U,2)_$S(PSIVOI="SOL":" "_$P(PSIVOIND,U,3),1:"")
. S ND=$G(^PS($S(PSIVOI="AD":52.6,1:52.7),+PSIVOIND,0))
. S DRG(PSIVOI,0)=1
. S DRG(PSIVOI,1)=+PSIVOIND_U_$P(ND,U)_U_$S(PSIVOI="SOL":$P(ND,U,3),1:"")_U_U_$P(ND,U,13)_U_$P(ND,U,11)
. S DRGI=1 D SETDRG
. I $P(PSIVOI("DILIST",+Y,0),U,4)="QC",DRGT="AD",$D(^PS(52.6,"C",$P(PSIVOI("DILIST",+Y,0),U,2),+PSIVOI("DILIST",+Y,0))) D Q:$G(PSIVSTR)="QUICK CODE"!$G(PSGORQF)
.. S (X,PSIVX)=$P(PSIVOI("DILIST",+Y,0),U,2),(PSJIVIEN,Y)=+PSIVOI("DILIST",+Y,0) D
... N PSJNF D NFIV^PSJDIN(52.6,+PSJIVIEN,.PSJNF) W PSJNF("NF")
... S DRGTMP=DRG(DRGT,1)
... I '$D(ON55) N ON55 S ON55=ON
... D ORDERCHK(DFN,ON55,1) I $G(PSGORQF) S X=U,DONE=1 Q
... D DINIV^PSJDIN(52.6,+DRGTMP)
... D ^PSIVQUI
. I $P(PSIVOI("DILIST",+Y,0),U,4)'="QC" S DRGTMP=DRG(DRGT,1) D ORDERCHK(DFN,ON55,1) I $G(PSGORQF) S X=U,DONE=1 Q
. I PSIVOI="AD" D
.. N FIL S FIL=52.6 D DRG3
K PSIVOI
Q
PSIVEDRG ;BIR/MLM-ENTER/EDIT DRUGS FOR IV ORDER ;29-May-2012 14:32;PLS
+1 ;;5.0; INPATIENT MEDICATIONS ;**21,33,50,65,74,84,128,147,1015**;16 DEC 97;Build 62
+2 ;
+3 ; References to ^PS(52.6 supported by DBIA# 1231.
+4 ; References to ^PS(52.7 supported by DBIA# 2173.
+5 ; Reference to EN^PSOORDRG supported by DBIA# 2190.
+6 ;
+7 ; Modified - IHS/MSC/PB - 4/25/12 modified to add the new stability offset value to the DRG array
+8 ; this value is used to determine the iv expiration date
DRG ; Edit Additive/Solution data
+1 ;If PSGORQF=1 abort order after order check.
NEW DRGOC,PSGORQF
+2 KILL PSIVOLD
SET DRG(2)=""
IF $DATA(DRG(DRGT))
SET DRGI=+$ORDER(DRG(DRGT,0))
IF DRGI
SET PSIVOLD=1
DO SETDRG
DRG1 ;
+1 IF $GET(PSGORQF)
QUIT
+2 IF $GET(X)="?"
KILL DUOUT
+3 DO FULL^VALM1
+4 WRITE !,"Select ",DRGTN,": "
+5 IF DRGT=$GET(PSIVOI)
IF ($GET(PSIVOI("DILIST",0))>1)
DO GTADSOL
QUIT
+6 IF DRG(2)]""
WRITE DRG(2),"//"
READ X:DTIME
IF '$TEST
SET X="^"
IF X=U
SET DONE=1
IF X["^"!(X=""&(DRG(2)=""))
QUIT
DRG1A IF X=""
WRITE !,DRGTN,": ",DRG(2),"//"
READ X:DTIME
IF '$TEST
SET X="^"
IF X="^"
QUIT
IF X=""
SET Y=1
DO DRG3
IF DRGT="AD"!($GET(P(4))="H")
GOTO DRG1
QUIT
+1 IF X="@"
IF DRG(2)]""
DO DEL
IF %'=1
GOTO DRG1A
KILL DRG(DRGT,DRGI)
SET DRGI=+$ORDER(DRG(DRGT,0))
IF 'DRGI
SET DRG(DRGT,0)=0
DO SETDRG
GOTO DRG1
+2 IF X["???"
IF ($EXTRACT(P("OT"))="M")
IF (PSIVAC["C")
DO ORFLDS^PSIVEDT1
GOTO DRG1
+3 IF X'["?"
SET %=0
IF $DATA(DRG(DRGT))
DO CHK
IF %=1
GOTO DRG1A
DO DRG2
IF $GET(Y)>0&($GET(P(4))'="H"&(DRGT="SOL"))
QUIT
GOTO DRG1
+4 IF $DATA(DRG(DRGT))
WRITE !,"This order includes the following ",DRGTN,"S:",!
FOR Y=0:0
SET Y=$ORDER(DRG(DRGT,Y))
IF 'Y
QUIT
WRITE !,$PIECE(DRG(DRGT,Y),U,2)
+5 WRITE !,"YOU MAY ENTER A NEW ",DRGTN,", IF YOU WISH",!
DO GTSCRN(X)
SET DIC(0)="EQM"
DO ^DIC
KILL DIC
GOTO DRG1
+6 QUIT
+7 ;
SETDRG ; Put Drug data into DRG(x).
+1 FOR X=1:1:6
SET DRG(X)=$PIECE(DRG(DRGT,DRGI),U,X)
+2 SET X=""
IF DRG(2)=""
IF DRG(1)
SET DRG(2)="*** Undefined ***"
+3 QUIT
DRG2 ;
+1 DO GTSCRN(X)
NEW PSIVX
SET PSIVX=X
SET DIC(0)="EQMZ"
DO ^DIC
KILL DIC
IF Y<0
QUIT
+2 SET PSJIVIEN=+Y
+3 NEW PSJNF
DO NFIV^PSJDIN($SELECT(DRGT="AD":52.6,1:52.7),+PSJIVIEN,.PSJNF)
+4 WRITE PSJNF("NF")
+5 ;IHS/MSC/PB - 4/25/12 line below modified to add the stability offset value to the DRG array as piece 7
+6 SET PSIVNEW=1
SET DRGTMP=+Y_U_$PIECE(Y(0),U)_U_$SELECT(DRGT="SOL":$PIECE(Y(0),U,3),1:"")_U_U_$PIECE(Y(0),U,13)_U_$PIECE(Y(0),U,11)_U_$GET(^PS($SELECT(DRGT="AD":52.6,1:52.7),+Y,9999999))
+7 IF '$DATA(ON55)
NEW ON55
SET ON55=ON
+8 DO ORDERCHK(DFN,ON55,1)
IF $GET(PSGORQF)
SET X=U
SET DONE=1
QUIT
+9 DO DINIV^PSJDIN($SELECT(DRGT="AD":52.6,1:52.7),+DRGTMP)
+10 SET (DRG(DRGT,0),DRGI)=$GET(DRG(DRGT,0))+1
SET DRG(DRGT,DRGI)=DRGTMP
KILL PSIVOLD
+11 IF (PSIVAC="PN"!(PSIVAC="CF"))
IF (DRGT="AD")
IF $DATA(^PS(52.6,"C",PSIVX,+DRGTMP))
DO ^PSIVQUI
IF $GET(PSIVSTR)="QUICK CODE"!$GET(PSGORQF)
QUIT
DRG3 ;
+1 IF DRG(2)]""
DO DINIV^PSJDIN(FIL,+DRG(1))
+2 DO SETDRG
+3 IF DRGT="AD"
SET X=$PIECE($GET(^PS(FIL,+DRG(1),0)),U,3)
WRITE !!,"(The units of strength for this additive are in ",$$ENU^PSIVUTL(DRG(1)),")"
AMT ;
+1 IF DRGT="SOL"
IF '$GET(PSIVOLD)
IF ($GET(P(4))_$GET(P(23))'["S")
GOTO DRG4
1 ; Strength/Volume
+1 WRITE !,$SELECT(DRGT="AD":"Strength: ",1:"Volume: ")
IF +DRG(3)
WRITE DRG(3),"//"
READ X:DTIME
IF '$TEST
SET X="^"
IF X="^"
QUIT
IF X=""&DRG(3)
GOTO 2
IF X=""
WRITE $CHAR(7),$SELECT(DRGT="AD":"Strength",1:"Volume")," is REQUIRED!"
GOTO 1
+2 IF $DATA(X)
DO IT
IF '$DATA(X)!($GET(X)["?")
GOTO AMT
SET DRG(3)=X
IF X=""
DO FIELD^DID($SELECT(DRGT="AD":53.157,1:53.158),1,"","XECUTABLE HELP","PSJEX")
XECUTE PSJEX("XECUTABLE HELP")
KILL PSJEX
GOTO AMT
2 IF DRGT="AD"
IF $GET(P("DTYP"))>1
IF P(4)'="S"
IF P(23)'="S"
KILL DIR
SET DIR(0)="53.157,2"
IF DRG(4)]""
SET DIR("B")=DRG(4)
DO ^DIR
IF $DATA(DTOUT)!$DATA(DUOUT)
QUIT
IF Y
SET DRG(4)=Y
DRG4 ;
+1 FOR X=1:1:6
SET $PIECE(DRG(DRGT,DRGI),U,X)=DRG(X)
+2 SET DRG(2)=""
+3 QUIT
+4 ;
GTSCRN(PSIVX) ;Set DIC("S") if MD OE or matching drug has already been selected.
+1 IF "?"[PSIVX
DO HOLDHDR^PSJOE
+2 SET X=PSIVX
+3 KILL DA,DIC
SET DIC=FIL
SET DIC("S")=$$IVDRGSC^PSIVUTL
+4 IF $EXTRACT(PSIVAC)'="P"
IF ($PIECE(P("OT"),U)="F")
SET X(1)=" I $P(X(1),U,13)"
SET DIC("S")=$GET(DIC("S"))_$SELECT(DRGT="AD":X(1),$EXTRACT(PSIVAC)="O":X(1),1:"")
+5 QUIT
+6 ;
IT ; Input Transform for Strength/Volume.
+1 IF X?1.N
IF $LENGTH(X)>20
SET X="?"
+2 IF X["?"
WRITE $CHAR(7)
SET F1=53.15_$SELECT(DRGT="AD":7,1:8)
SET F2=1
DO ENHLP^PSIVORC1
QUIT
+3 IF DRGT="AD"
IF X'?.6N0.1".".8N!('X)
KILL X
IF $DATA(X)
IF (X<1)&($PIECE(X,".")'=0)
SET X=0_X
SET X=X_" "_$$ENU^PSIVUTL(DRG(1))
WRITE " ",X
QUIT
+4 IF $DATA(X)
IF X=""!(X'?.N0.1".".N)!(X>9999)!(X<.01)
KILL X
IF $DATA(X)
IF (X<1)&($PIECE(X,".")'=0)
SET X=0_X
SET X=X_" ML"
WRITE " ",X
+5 IF '$DATA(X)
WRITE $CHAR(7),"??"
+6 QUIT
+7 ;
ORDERCHK(DFN,ON,X) ; Do order check
+1 ;* If X is define, include the DRG(X) to the order check
+2 IF X
IF $DATA(DRG)
MERGE DRGOC(ON)=DRG
+3 NEW TMPDRG,X,XX,Y,PSIVNEW,PSGDRG,PSGDRGN,PSJDD,PSGP
+4 ;Store DRG array in TMPDRG array
DO SAVEDRG(.TMPDRG,.DRG)
+5 SET PSIVNEW=1
SET PSGDRGN=$PIECE($GET(DRGTMP),U,2)
+6 SET (PSJDD,PSGDRG)=$PIECE(^PS(FIL,+DRGTMP,0),U,2)
SET PSGP=DFN
+7 IF FIL="52.6"
DO ENDDC^PSGSICHK(DFN,PSGDRG)
+8 IF FIL="52.7"
Begin DoDot:1
+9 DO EN^PSOORDRG(DFN,PSGDRG)
+10 NEW INTERVEN,PSJIREQ,PSJRXREQ
SET Y=1
SET (PSJIREQ,PSJRXREQ,INTERVEN,X)=""
+11 SET DFN=PSGP
KILL PSJPDRG
+12 DO IVSOL^PSGSICHK
End DoDot:1
+13 ;Restore DRG array from TMPDRG array
DO SAVEDRG(.DRG,.TMPDRG)
+14 DO ENSTOP^PSIVCAL
+15 QUIT
SAVEDRG(NEW,OLD) ;Store/restore DRG array.
+1 IF $GET(OLD)
SET NEW=OLD
+2 FOR X=0:0
SET X=$ORDER(OLD(X))
IF 'X
QUIT
SET NEW(X)=OLD(X)
+3 FOR XX="AD","SOL"
Begin DoDot:1
+4 IF $DATA(OLD(XX,0))#10=1
SET NEW(XX,0)=OLD(XX,0)
+5 FOR X=0:0
SET X=$ORDER(OLD(XX,X))
IF 'X
QUIT
SET NEW(XX,X)=OLD(XX,X)
End DoDot:1
+6 QUIT
+7 ;
CHK ; Check if drug is already part of order
+1 NEW DDONE,I,TDRG,TDRGP
FOR TDRG=0:0
SET TDRG=$ORDER(DRG(DRGT,TDRG))
IF 'TDRG!$GET(DDONE)
QUIT
Begin DoDot:1
+2 IF $$UPPER^VALM1($EXTRACT($PIECE(DRG(DRGT,+TDRG),U,2),1,$LENGTH(X)))=$$UPPER^VALM1(X)
WRITE $PIECE($$UPPER^VALM1($PIECE(DRG(DRGT,+TDRG),U,2)),$$UPPER^VALM1(X),2)
DO ASKCHK
QUIT
+3 SET TDRGP=$PIECE(DRG(DRGT,TDRG),U)
FOR J=0:0
SET J=$ORDER(^PS(FIL,TDRGP,3,J))
IF 'J!$GET(DDONE)
QUIT
IF $$UPPER^VALM1($EXTRACT($PIECE(^PS(FIL,TDRGP,3,J,0),U),1,$LENGTH(X)))=$$UPPER^VALM1(X)
Begin DoDot:2
+4 WRITE $PIECE($$UPPER^VALM1($PIECE(^PS(FIL,TDRGP,3,J,0),U)),$$UPPER^VALM1(X),2)," ",$PIECE(DRG(DRGT,TDRG),U,2)
End DoDot:2
DO ASKCHK
QUIT
End DoDot:1
+5 QUIT
+6 ;
ASKCHK ; Do you want a drug that was previously selected.
+1 SET I=DRG(DRGT,TDRG)
WRITE " ",$PIECE(I,U,3),$SELECT($PIECE(I,U,4):" ("_$PIECE(I,U,4)_")",1:""),!,"...OK"
SET %=1
DO YN^DICN
+2 IF %=1
SET X=""
SET DRGI=TDRG
SET (DDONE,PSIVOLD)=1
DO SETDRG
QUIT
+3 WRITE !,X
+4 QUIT
+5 ;
DEL ;
+1 WRITE !?3,"SURE YOU WANT TO DELETE"
SET %=0
DO YN^DICN
SET X=""
IF %'=1
WRITE " <NOTHING DELETED>"
+2 QUIT
GTADSOL ;If there're multiple ad/sol matched to an OI then display so user to select ad/sol
+1 ;PSIVOI array is defined in GTIVDRG^PSIVORC2
+2 NEW DIR,ND,X,Y
+3 SET DIR(0)="LA^1:"_+PSIVOI("DILIST",0)
+4 SET DIR("?")="Please select "_$SELECT(PSIVOI="AD":"an Additive or Quick Code",1:"a Solution")_" from the list"
+5 FOR X=0:0
SET X=$ORDER(PSIVOI("DILIST",X))
IF 'X
QUIT
Begin DoDot:1
+6 SET DIR("A",X)=" "_X_" "_$SELECT($PIECE(PSIVOI("DILIST",X,0),U,4)="QC":" - "_$PIECE(PSIVOI("DILIST",X,0),U,2)_" -",1:$PIECE(PSIVOI("DILIST",X,0),U,2))_$SELECT(PSIVOI="SOL":" "_$PIECE(PSIVOI("DILIST",X,0),U,3),1:"")
End DoDot:1
+7 SET DIR("A")="Select (1 - "_+PSIVOI("DILIST",0)_"): "
+8 DO ^DIR
+9 IF +Y
Begin DoDot:1
+10 NEW PSIVOIND
SET PSIVOIND=PSIVOI("DILIST",+Y,0)
+11 WRITE " "_$PIECE(PSIVOIND,U,2)_$SELECT(PSIVOI="SOL":" "_$PIECE(PSIVOIND,U,3),1:"")
+12 SET ND=$GET(^PS($SELECT(PSIVOI="AD":52.6,1:52.7),+PSIVOIND,0))
+13 SET DRG(PSIVOI,0)=1
+14 SET DRG(PSIVOI,1)=+PSIVOIND_U_$PIECE(ND,U)_U_$SELECT(PSIVOI="SOL":$PIECE(ND,U,3),1:"")_U_U_$PIECE(ND,U,13)_U_$PIECE(ND,U,11)
+15 SET DRGI=1
DO SETDRG
+16 IF $PIECE(PSIVOI("DILIST",+Y,0),U,4)="QC"
IF DRGT="AD"
IF $DATA(^PS(52.6,"C",$PIECE(PSIVOI("DILIST",+Y,0),U,2),+PSIVOI("DILIST",+Y,0)))
Begin DoDot:2
+17 SET (X,PSIVX)=$PIECE(PSIVOI("DILIST",+Y,0),U,2)
SET (PSJIVIEN,Y)=+PSIVOI("DILIST",+Y,0)
Begin DoDot:3
+18 NEW PSJNF
DO NFIV^PSJDIN(52.6,+PSJIVIEN,.PSJNF)
WRITE PSJNF("NF")
+19 SET DRGTMP=DRG(DRGT,1)
+20 IF '$DATA(ON55)
NEW ON55
SET ON55=ON
+21 DO ORDERCHK(DFN,ON55,1)
IF $GET(PSGORQF)
SET X=U
SET DONE=1
QUIT
+22 DO DINIV^PSJDIN(52.6,+DRGTMP)
+23 DO ^PSIVQUI
End DoDot:3
End DoDot:2
IF $GET(PSIVSTR)="QUICK CODE"!$GET(PSGORQF)
QUIT
+24 IF $PIECE(PSIVOI("DILIST",+Y,0),U,4)'="QC"
SET DRGTMP=DRG(DRGT,1)
DO ORDERCHK(DFN,ON55,1)
IF $GET(PSGORQF)
SET X=U
SET DONE=1
QUIT
+25 IF PSIVOI="AD"
Begin DoDot:2
+26 NEW FIL
SET FIL=52.6
DO DRG3
End DoDot:2
End DoDot:1
+27 KILL PSIVOI
+28 QUIT