PSOBKDED ;BIR/SAB - Edit backdoor Rx Order entry ;04/17/95
;;7.0;OUTPATIENT PHARMACY;**11,46,91,78,99,117,133,143,268**;DEC 1997;Build 9
;Ref PS(50.607 IA 2221
;Ref PS(50.7 IA 2223
;Ref PS(51.2 IA 2226
;Ref PSDRUG( IA 221
;Ref DOSE^PSSORPH IA 3234
;Ref PS(55 IA 2228
1 S %DT="AEX",%DT(0)=-PSONEW("FILL DATE"),Y=PSONEW("ISSUE DATE") X ^DD("DD") S %DT("A")="ISSUE DATE: ",%DT("B")=Y D ^%DT
I "^"[$E(X) D KX K %DT Q
G:Y=-1 1 S (PSOID,PSONEW("ISSUE DATE"))=Y D KX K %DT
Q
2 S PSONEW("FLD")=2 D FILLDT^PSODIR2(.PSONEW) ;Fdt
Q
3 S:$G(POERR) PSONEW("ISSUE DATE")=PSOID
S PSONEW("FLD")=3 D PTSTAT^PSODIR1(.PSONEW) ;Sta
Q
4 S PSONEW("FLD")=4 D PROV^PSODIR(.PSONEW) ;Pro
Q
5 S PSONEW("FLD")=5 D CLINIC^PSODIR2(.PSONEW) ;Cli
Q
6 S PSONEW("FLD")=6 D ^PSODRG,EN^PSODIAG ;Drg/ICD
D 6^PSODRGN
Q
7 S PSONEW("FLD")=7 D QTY^PSODIR1(.PSONEW) ;Qty
Q
8 S PSONEW("FLD")=8 D DAYS^PSODIR1(.PSONEW) ;Day
K PSMAX,PSTMAX D REF^PSOORNEW S PSONEW("N# REF")=PSONEW("# OF REFILLS")
Q
9 S PSONEW("FLD")=9 D REFILL^PSODIR1(.PSONEW) ;Ref
K PSMAX,PSTMAX
Q
10 S PSONEW("FLD")="3A" D DOSE^PSODIR(.PSONEW) ;Dose
Q
;
Q I $G(COPY),$G(SIGOK) S PSOFDR=1 K PSONEW("SIG")
S PSONEW("FLD")=10 D SIG^PSODIR1(.PSONEW) ;Sig
I $G(COPY) K PSOFDR
S DIR(0)="E",DIR("A")="Press Return to Continue" D ^DIR D KV
Q
INS S PSONEW("FLD")="3B" D INS^PSODIR(.PSONEW) ;Ins
Q
11 S PSONEW("FLD")=11 D COPIES^PSODIR1(.PSONEW) ;Cop
Q
12 S PSONEW("FLD")=12 D MW^PSODIR2(.PSONEW) ;M/W
Q
13 S PSONEW("FLD")=13 D RMK^PSODIR2(.PSONEW) ;Rem
Q
DOSE ;backdoor
I '$G(PSONEW("ENT")) S IEN=IEN+1,^TMP("PSOPO",$J,IEN,0)=" (5) Dosage Ordered: " G INS1
S SD=1 F I=1:1:PSONEW("ENT") D
.I '$G(PSONEW("DOSE ORDERED",I)),$G(PSONEW("VERB",I))]"" S IEN=IEN+1,^TMP("PSOPO",$J,IEN,0)=" Verb: "_$G(PSONEW("VERB",I))
.S:$G(SD)=1 IEN=IEN+1,^TMP("PSOPO",$J,IEN,0)=" (5)",DS=1 K SD
.D DOSE1
INS1 S IEN=IEN+1,^TMP("PSOPO",$J,IEN,0)=" (6)Pat Instruction:"
INS2 I $O(PSONEW("SIG",0)) F D=0:0 S D=$O(PSONEW("SIG",D)) Q:'D D
.F SG=1:1:$L(PSONEW("SIG",D)) S:$L(^TMP("PSOPO",$J,IEN,0)_" "_$P(PSONEW("SIG",D)," ",SG))>80 IEN=IEN+1,$P(^TMP("PSOPO",$J,IEN,0)," ",21)=" " D
..S:$P(PSONEW("SIG",D)," ",SG)'="" ^TMP("PSOPO",$J,IEN,0)=$G(^TMP("PSOPO",$J,IEN,0))_" "_$P(PSONEW("SIG",D)," ",SG)
I $P($G(^PS(55,PSODFN,"LAN")),"^") D Q
.S IEN=IEN+1,^TMP("PSOPO",$J,IEN,0)=" Other Patient Inst.: "
.I $G(^PSRX(+$G(PSONEW("OIRXN")),"INSS"))]"" S PSONEW("SINS")=^PSRX(PSONEW("OIRXN"),"INSS")
.S ^TMP("PSOPO",$J,IEN,0)=^TMP("PSOPO",$J,IEN,0)_$G(PSONEW("SINS"))
Q
;
DOSE1 I $G(DS)=1 D K DS G DU
.S ^TMP("PSOPO",$J,IEN,0)=^TMP("PSOPO",$J,IEN,0)_" Dosage Ordered: "_$S($E(PSONEW("DOSE",I),1)="."&($G(PSONEW("DOSE ORDERED",I))):"0",1:"")_PSONEW("DOSE",I)_$S($G(PSONEW("UNITS",I))'="":" ("_$P(^PS(50.607,PSONEW("UNITS",I),0),"^")_")",1:"")
S IEN=IEN+1,^TMP("PSOPO",$J,IEN,0)=" Dosage Ordered: "_$S($E(PSONEW("DOSE",I),1)="."&($G(PSONEW("DOSE ORDERED",I))):"0",1:"")_PSONEW("DOSE",I)_$S($G(PSONEW("UNITS",I))'="":" ("_$P(^PS(50.607,PSONEW("UNITS",I),0),"^")_")",1:"")
DU I '$G(PSONEW("DOSE ORDERED",I)),$P($G(^PS(55,PSODFN,"LAN")),"^") S IEN=IEN+1,^TMP("PSOPO",$J,IEN,0)=" Oth. Lang. Dosage: "_$G(PSONEW("ODOSE",I))
I $G(PSONEW("DOSE ORDERED",I)),$G(PSONEW("VERB",I))]"" S IEN=IEN+1,^TMP("PSOPO",$J,IEN,0)=" Verb: "_$G(PSONEW("VERB",I))
S:$G(PSONEW("DOSE ORDERED",I)) IEN=IEN+1,^TMP("PSOPO",$J,IEN,0)=" Dispense Units: "_$S($E($G(PSONEW("DOSE ORDERED",I)),1)=".":"0",1:"")_$G(PSONEW("DOSE ORDERED",I))
I $G(PSONEW("DOSE ORDERED",I)),$G(PSONEW("NOUN",I))]"" S IEN=IEN+1,^TMP("PSOPO",$J,IEN,0)=" Noun: "_PSONEW("NOUN",I)
I $G(PSONEW("ROUTE",I)) S IEN=IEN+1,^TMP("PSOPO",$J,IEN,0)=" Route: "_$P(^PS(51.2,PSONEW("ROUTE",I),0),"^")
S IEN=IEN+1,^TMP("PSOPO",$J,IEN,0)=" Schedule: "_PSONEW("SCHEDULE",I)
I $G(PSONEW("DURATION",I))]"" D
.S IEN=IEN+1
.S ^TMP("PSOPO",$J,IEN,0)=" *Duration: "_PSONEW("DURATION",I)_" ("_$S(PSONEW("DURATION",I)["M":"MINUTES",PSONEW("DURATION",I)["W":"WEEKS",PSONEW("DURATION",I)["L":"MONTHS",PSONEW("DURATION",I)["H":"HOURS",1:"DAYS")_")"
I $G(PSONEW("CONJUNCTION",I))]"" S IEN=IEN+1,^TMP("PSOPO",$J,IEN,0)=" Conjunction: "_$S($G(PSONEW("CONJUNCTION",I))="A":"AND",$G(PSONEW("CONJUNCTION",I))="T":"THEN",$G(PSONEW("CONJUNCTION",I))="X":"EXCEPT",1:"")
Q
RTE I $G(DRET) S PSORXED("ROUTE",ENT)=""
I $G(RTE) K RTE
K DIR,DIRUT S DIR(0)="FO^2:45",DIR("A")="ROUTE",DIR("?")="^D HLP^PSOORED4"
S DIR("B")=$S($G(PSORXED("ROUTE",ENT)):$P(^PS(51.2,PSORXED("ROUTE",ENT),0),"^"),$G(RTE)]"":RTE,$G(DRET):"",1:"PO") K:DIR("B")="" DIR("B")
;I '$G(PSORXED("ROUTE",ENT)),$G(PSOREEDT) K DIR("B")
D ^DIR I X[U,$L(X)>1 S FIELD="RTE",JUMP=1 K DIRUT,DTOUT Q
Q:$D(DTOUT)!($D(DUOUT))
I X="@"!(X="") K RTE,ERTE S DRET=1,PSORXED("ROUTE",ENT)="" Q
K DRET I X=$P($G(^PS(51.2,+$G(PSORXED("ROUTE",ENT)),0)),"^") S RTE=$P(^PS(51.2,PSORXED("ROUTE",ENT),0),"^") W X_" "_$G(ERTE) Q
S DIC=51.2,DIC(0)="QEZM",DIC("S")="I $P(^(0),""^"",4)" D ^DIC Q:X[U G:Y=-1 RTE W " "_$P(Y(0),"^",2)
S:X'="" PSORXED("ROUTE",ENT)=+Y,RTE=Y(0,0),ERTE=$P(Y(0),"^",2)
Q
ASK K JUMP,UNITN,DOSE D KV D DOSE^PSSORPH(.DOSE,PSODRUG("IEN"),"O",PSODFN)
I $D(DOSE("DD")) I $G(PSOFROM)="PENDING"!($G(PSOREEDQ)) D LST2^PSOBKDE1 G ASK1
D:$G(PSOFROM)="NEW"&($G(PSORX("EDIT"))']"")!($G(PSOFROM1))!($G(COPY)) LST^PSOBKDE1:$O(DOSE(0))
ASK1 S STRE=$P($G(DOSE("DD",PSODRUG("IEN"))),"^",5),UNITN=$P($G(DOSE("DD",PSODRUG("IEN"))),"^",6),DOSE("LD")=$P($G(DOSE("DD",PSODRUG("IEN"))),"^",11)
W ! S DIR(0)="F^1:60",DIR("A",1)="Select from list of Available Dosages, Enter Free Text Dose",DIR("?")="^D LST1^PSOBKDE1",DIR("A")="or Enter a Question Mark (?) to view list"
I $G(PSORXED("DOSE",ENT))]"" S DIR("B")=PSORXED("DOSE",ENT) D
.I $G(PSORXED("UNITS",ENT))]"",DIR("B")'[($P($G(^PS(50.607,PSORXED("UNITS",ENT),0)),"^")) S DIR("B")=DIR("B")_$P($G(^PS(50.607,PSORXED("UNITS",ENT),0)),"^")
K:$G(PSOREEDQ)!($G(PSOBDRG)) DIR("B")
D ^DIR
I X[U,$L(X)>1 S FIELD="ASK",JUMP=1 K DIRUT,DTOUT Q
I $D(DIRUT) S:$G(ORD) PSODSPL=1 Q
I X=$G(PSORXED("DOSE",ENT)),$D(DOSE(Y)) G GD1
I X=$G(PSORXED("DOSE",ENT)) D G DOS
.S DOSE=X,UNITS=$G(PSORXED("UNITS",ENT))
.I DOSE'?.N&(DOSE'?.N1".".N)!'DOSE("LD") S (UNITN,UNITS,PSORXED("UNITS",ENT))="" K PSORXED("DOSE ORDERED",ENT),DUPD,PSORXED("NOUN",ENT)
GD1 N PSORXTE
I $D(DOSE(Y)) D G DOS ;from list
.S DOSE=$S($P(DOSE(Y),"^"):$P(DOSE(Y),"^"),$P(DOSE(Y),"^",3)]"":$P(DOSE(Y),"^",3),1:1),DOLST=Y
.I $P(DOSE(Y),"^") S UNITS=$P(DOSE(Y),"^",2),DUPD=$P(DOSE(Y),"^",3),UNITN=$P(DOSE("DD",PSODRUG("IEN")),"^",6),PSORXTE("DOSE ORDERED",ENT)=DUPD
.S PSORXTE("NOUN",ENT)=$P(DOSE(Y),"^",6),PSORXTE("VERB",ENT)=$P(DOSE(Y),"^",8)
.I DOSE'?.N&(DOSE'?.N1".".N)!'DOSE("LD") D Q
..S (UNITN,UNITS,PSORXED("UNITS",ENT))="" K PSORXED("DOSE ORDERED",ENT),DUPD,PSORXED("NOUN",ENT)
..I $P($G(^PS(55,PSODFN,"LAN")),"^"),$G(PSOFROM)="PENDING" D LAN^PSOORED5 Q
..I $P($G(^PS(55,PSODFN,"LAN")),"^"),$G(PSOFROM)="NEW" D LAN^PSOORED5
.S PSORXTE("UNITS",ENT)=$G(UNITS)
S DOSE=Y,DOLST=0 ;non-numeric and numeric not in list
I DOSE("LD") D
.F I=1:1:$L(DOSE) I $E(DOSE,I)'?.N&($E(DOSE,I)'?1" ")&($E(DOSE,I)'?1".") S DCHK=$G(DCHK)_$E(DOSE,I)
.I $G(DCHK)]"" D
..S DCHK=$TR(DCHK,"qwertyuioplkjhgfdsazxcvbnm","QWERTYUIOPLKJHGFDSAZXCVBNM")
..I DCHK=UNITN S DOSE=+DOSE
K I,DCHK
S PSOINDT=$$GET1^DIQ(50,PSODRUG("IEN"),100,"I") I PSOINDT,DT>PSOINDT G DOS
S PSORXTE("NOUN",ENT)=$P(DOSE("DD",PSODRUG("IEN")),"^",9),PSORXTE("VERB",ENT)=$P(DOSE("DD",PSODRUG("IEN")),"^",10)
I DOSE'?.N&(DOSE'?.N1".".N)!'DOSE("LD") S (UNITN,UNITS,PSORXED("UNITS",ENT))="" K PSORXED("NOUN",ENT),PSORXED("ODOSE",ENT) G DOS
S:$P(DOSE("DD",PSODRUG("IEN")),"^",6)]"" (PSORXTE("UNITS",ENT),UNITS)=$O(^PS(50.607,"B",$P(DOSE("DD",PSODRUG("IEN")),"^",6),0)),UNITN=$P(DOSE("DD",PSODRUG("IEN")),"^",6)
S:$P(DOSE("DD",PSODRUG("IEN")),"^",5) DUPD=DOSE/$P(DOSE("DD",PSODRUG("IEN")),"^",5),PSORXTE("DOSE ORDERED",ENT)=DUPD
DOS W " "_$S($E(DOSE,1)="."&($G(UNITN)'=""):"0",1:"")_DOSE W:$G(UNITN)'="" UNITN
W ! K DIR,DIRUT S DIR(0)="Y",DIR("A")="You entered "_$S($E(DOSE,1)="."&($G(UNITN)'=""):"0",1:"")_DOSE_$S($G(UNITN)'="":UNITN,1:"")_" is this correct",DIR("B")="Yes"
D ^DIR I 'Y D KX K DOSE,UNITS,PSORXTE,PSOINDT G ASK
S PSORXED("DOSE",ENT)=DOSE
S:$G(PSORXTE("DOSE ORDERED",ENT))]"" PSORXED("DOSE ORDERED",ENT)=PSORXTE("DOSE ORDERED",ENT)
S:$G(PSORXTE("NOUN",ENT))]"" PSORXED("NOUN",ENT)=PSORXTE("NOUN",ENT)
S:$G(PSORXTE("VERB",ENT))]"" PSORXED("VERB",ENT)=PSORXTE("VERB",ENT)
S:$G(PSORXTE("UNITS",ENT))]"" PSORXED("UNITS",ENT)=PSORXTE("UNITS",ENT)
I $G(PSORXED("DOSE",ENT))'?.N&($G(PSORXED("DOSE",ENT))'?.N1".".N)!'DOSE("LD"),$P($G(^PS(55,PSODFN,"LAN")),"^") D
.K OTHDOS(ENT) D KX S DIR(0)="52.0113,9"
.I '$G(OTHDOS(ENT)),$G(PSORXED("ODOSE",ENT))']"" D LAN^PSOORED5
.I $G(PSORXED("ODOSE",ENT))]"" S DIR("B")=PSORXED("ODOSE",ENT) K:DIR("B")="" DIR("B")
.K DTOUT,DUOUT,DIRUT,Y,X D ^DIR K DIR K:$G(X)="@"!($G(X)="") DIRUT I $D(DIRUT) Q
.I X="@" S OTHDOS(ENT)=1 D KX K PSORXED("ODOSE",ENT) Q
.S:X'="" PSORXED("ODOSE",ENT)=X
Q
;
SCH D KX
S DIR("?")="^D SCHLP^PSOORED4",DIR("A")="Schedule: ",DIR(0)="FA^1:20^I X[""""""""!(X?.E1C.E)!($A(X)=45)!($L(X,"" "")>3)!($L(X)>20)!($L(X)<1) K X"
I '$D(PSOSCH),'$D(PSORXED("SCHEDULE",ENT)),$P(^PS(50.7,PSODRUG("OI"),0),"^",8)]"" S PSOSCH=$P(^PS(50.7,PSODRUG("OI"),0),"^",8)
S DIR("B")=$S($D(PSOSCH)&('$D(PSORXED("SCHEDULE",ENT))):PSOSCH,$G(PSORXED("SCHEDULE",ENT))]"":PSORXED("SCHEDULE",ENT),1:"") K:DIR("B")="" DIR("B")
I $G(PSORXED("SCHEDULE",ENT))']"",$G(PSOREEDT) K DIR("B")
D ^DIR
Q
KX K X,Y
KV K DTOUT,DUOUT,DIR,DIRUT
Q
PSOBKDED ;BIR/SAB - Edit backdoor Rx Order entry ;04/17/95
+1 ;;7.0;OUTPATIENT PHARMACY;**11,46,91,78,99,117,133,143,268**;DEC 1997;Build 9
+2 ;Ref PS(50.607 IA 2221
+3 ;Ref PS(50.7 IA 2223
+4 ;Ref PS(51.2 IA 2226
+5 ;Ref PSDRUG( IA 221
+6 ;Ref DOSE^PSSORPH IA 3234
+7 ;Ref PS(55 IA 2228
1 SET %DT="AEX"
SET %DT(0)=-PSONEW("FILL DATE")
SET Y=PSONEW("ISSUE DATE")
XECUTE ^DD("DD")
SET %DT("A")="ISSUE DATE: "
SET %DT("B")=Y
DO ^%DT
+1 IF "^"[$EXTRACT(X)
DO KX
KILL %DT
QUIT
+2 IF Y=-1
GOTO 1
SET (PSOID,PSONEW("ISSUE DATE"))=Y
DO KX
KILL %DT
+3 QUIT
2 ;Fdt
SET PSONEW("FLD")=2
DO FILLDT^PSODIR2(.PSONEW)
+1 QUIT
3 IF $GET(POERR)
SET PSONEW("ISSUE DATE")=PSOID
+1 ;Sta
SET PSONEW("FLD")=3
DO PTSTAT^PSODIR1(.PSONEW)
+2 QUIT
4 ;Pro
SET PSONEW("FLD")=4
DO PROV^PSODIR(.PSONEW)
+1 QUIT
5 ;Cli
SET PSONEW("FLD")=5
DO CLINIC^PSODIR2(.PSONEW)
+1 QUIT
6 ;Drg/ICD
SET PSONEW("FLD")=6
DO ^PSODRG
DO EN^PSODIAG
+1 DO 6^PSODRGN
+2 QUIT
7 ;Qty
SET PSONEW("FLD")=7
DO QTY^PSODIR1(.PSONEW)
+1 QUIT
8 ;Day
SET PSONEW("FLD")=8
DO DAYS^PSODIR1(.PSONEW)
+1 KILL PSMAX,PSTMAX
DO REF^PSOORNEW
SET PSONEW("N# REF")=PSONEW("# OF REFILLS")
+2 QUIT
9 ;Ref
SET PSONEW("FLD")=9
DO REFILL^PSODIR1(.PSONEW)
+1 KILL PSMAX,PSTMAX
+2 QUIT
10 ;Dose
SET PSONEW("FLD")="3A"
DO DOSE^PSODIR(.PSONEW)
+1 QUIT
+2 ;
+3 QUIT
IF $GET(COPY)
IF $GET(SIGOK)
SET PSOFDR=1
KILL PSONEW("SIG")
+4 ;Sig
SET PSONEW("FLD")=10
DO SIG^PSODIR1(.PSONEW)
+5 IF $GET(COPY)
KILL PSOFDR
+6 SET DIR(0)="E"
SET DIR("A")="Press Return to Continue"
DO ^DIR
DO KV
+7 QUIT
INS ;Ins
SET PSONEW("FLD")="3B"
DO INS^PSODIR(.PSONEW)
+1 QUIT
11 ;Cop
SET PSONEW("FLD")=11
DO COPIES^PSODIR1(.PSONEW)
+1 QUIT
12 ;M/W
SET PSONEW("FLD")=12
DO MW^PSODIR2(.PSONEW)
+1 QUIT
13 ;Rem
SET PSONEW("FLD")=13
DO RMK^PSODIR2(.PSONEW)
+1 QUIT
DOSE ;backdoor
+1 IF '$GET(PSONEW("ENT"))
SET IEN=IEN+1
SET ^TMP("PSOPO",$JOB,IEN,0)=" (5) Dosage Ordered: "
GOTO INS1
+2 SET SD=1
FOR I=1:1:PSONEW("ENT")
Begin DoDot:1
+3 IF '$GET(PSONEW("DOSE ORDERED",I))
IF $GET(PSONEW("VERB",I))]""
SET IEN=IEN+1
SET ^TMP("PSOPO",$JOB,IEN,0)=" Verb: "_$GET(PSONEW("VERB",I))
+4 IF $GET(SD)=1
SET IEN=IEN+1
SET ^TMP("PSOPO",$JOB,IEN,0)=" (5)"
SET DS=1
KILL SD
+5 DO DOSE1
End DoDot:1
INS1 SET IEN=IEN+1
SET ^TMP("PSOPO",$JOB,IEN,0)=" (6)Pat Instruction:"
INS2 IF $ORDER(PSONEW("SIG",0))
FOR D=0:0
SET D=$ORDER(PSONEW("SIG",D))
IF 'D
QUIT
Begin DoDot:1
+1 FOR SG=1:1:$LENGTH(PSONEW("SIG",D))
IF $LENGTH(^TMP("PSOPO",$JOB,IEN,0)_" "_$PIECE(PSONEW("SIG",D)," ",SG))>80
SET IEN=IEN+1
SET $PIECE(^TMP("PSOPO",$JOB,IEN,0)," ",21)=" "
Begin DoDot:2
+2 IF $PIECE(PSONEW("SIG",D)," ",SG)'=""
SET ^TMP("PSOPO",$JOB,IEN,0)=$GET(^TMP("PSOPO",$JOB,IEN,0))_" "_$PIECE(PSONEW("SIG",D)," ",SG)
End DoDot:2
End DoDot:1
+3 IF $PIECE($GET(^PS(55,PSODFN,"LAN")),"^")
Begin DoDot:1
+4 SET IEN=IEN+1
SET ^TMP("PSOPO",$JOB,IEN,0)=" Other Patient Inst.: "
+5 IF $GET(^PSRX(+$GET(PSONEW("OIRXN")),"INSS"))]""
SET PSONEW("SINS")=^PSRX(PSONEW("OIRXN"),"INSS")
+6 SET ^TMP("PSOPO",$JOB,IEN,0)=^TMP("PSOPO",$JOB,IEN,0)_$GET(PSONEW("SINS"))
End DoDot:1
QUIT
+7 QUIT
+8 ;
DOSE1 IF $GET(DS)=1
Begin DoDot:1
+1 SET ^TMP("PSOPO",$JOB,IEN,0)=^TMP("PSOPO",$JOB,IEN,0)_" Dosage Ordered: "_$SELECT(...
... $EXTRACT(PSONEW("DOSE",I),1)="."&($GET(PSONEW("DOSE ORDERED",I))):"0",1:"")_PSONEW("DOSE",I)_$SELECT($GET(PSONEW("UNITS",I))'="":" ("_$PIECE(^PS(50.607,PSONEW("UNITS",I),0),"^")_")",1:"")
End DoDot:1
KILL DS
GOTO DU
+2 SET IEN=IEN+1
SET ^TMP("PSOPO",$JOB,IEN,0)=" Dosage Ordered: "_$SELECT($EXTRACT(PSONEW("DOSE",I),1)="."&($GET(PSONEW("DOSE ORDERED",I))):"0",1:"")_PSONEW("DOSE",I)_$SELECT($GET(PSONEW("UNITS",I))'="":" ("_$PIECE(^PS(50.607,PSONEW("UNITS",I),0),"^")_")",
1:"")
DU IF '$GET(PSONEW("DOSE ORDERED",I))
IF $PIECE($GET(^PS(55,PSODFN,"LAN")),"^")
SET IEN=IEN+1
SET ^TMP("PSOPO",$JOB,IEN,0)=" Oth. Lang. Dosage: "_$GET(PSONEW("ODOSE",I))
+1 IF $GET(PSONEW("DOSE ORDERED",I))
IF $GET(PSONEW("VERB",I))]""
SET IEN=IEN+1
SET ^TMP("PSOPO",$JOB,IEN,0)=" Verb: "_$GET(PSONEW("VERB",I))
+2 IF $GET(PSONEW("DOSE ORDERED",I))
SET IEN=IEN+1
SET ^TMP("PSOPO",$JOB,IEN,0)=" Dispense Units: "_$SELECT($EXTRACT($GET(PSONEW("DOSE ORDERED",I)),1)=".":"0",1:"")_$GET(PSONEW("DOSE ORDERED",I))
+3 IF $GET(PSONEW("DOSE ORDERED",I))
IF $GET(PSONEW("NOUN",I))]""
SET IEN=IEN+1
SET ^TMP("PSOPO",$JOB,IEN,0)=" Noun: "_PSONEW("NOUN",I)
+4 IF $GET(PSONEW("ROUTE",I))
SET IEN=IEN+1
SET ^TMP("PSOPO",$JOB,IEN,0)=" Route: "_$PIECE(^PS(51.2,PSONEW("ROUTE",I),0),"^")
+5 SET IEN=IEN+1
SET ^TMP("PSOPO",$JOB,IEN,0)=" Schedule: "_PSONEW("SCHEDULE",I)
+6 IF $GET(PSONEW("DURATION",I))]""
Begin DoDot:1
+7 SET IEN=IEN+1
+8 SET ^TMP("PSOPO",$JOB,IEN,0)=" *Duration: "_PSONEW("DURATION",I)_" ("_$SELECT(PSONEW("DURATION",I)["M":"MINUTES",PSONEW("DURATION",I)["W":"WEEKS",PSONEW("DURATION",I)["L":"MONTHS",PSONEW("DURATION",I)["H":"HOURS",1:"DAYS")_")"
End DoDot:1
+9 IF $GET(PSONEW("CONJUNCTION",I))]""
SET IEN=IEN+1
SET ^TMP("PSOPO",$JOB,IEN,0)=" Conjunction: "_$SELECT($GET(PSONEW("CONJUNCTION",I))="A":"AND",$GET(PSONEW("CONJUNCTION",I))="T":"THEN",$GET(PSONEW("CONJUNCTION",I))="X":"EXCEPT",1:"")
+10 QUIT
RTE IF $GET(DRET)
SET PSORXED("ROUTE",ENT)=""
+1 IF $GET(RTE)
KILL RTE
+2 KILL DIR,DIRUT
SET DIR(0)="FO^2:45"
SET DIR("A")="ROUTE"
SET DIR("?")="^D HLP^PSOORED4"
+3 SET DIR("B")=$SELECT($GET(PSORXED("ROUTE",ENT)):$PIECE(^PS(51.2,PSORXED("ROUTE",ENT),0),"^"),$GET(RTE)]"":RTE,$GET(DRET):"",1:"PO")
IF DIR("B")=""
KILL DIR("B")
+4 ;I '$G(PSORXED("ROUTE",ENT)),$G(PSOREEDT) K DIR("B")
+5 DO ^DIR
IF X[U
IF $LENGTH(X)>1
SET FIELD="RTE"
SET JUMP=1
KILL DIRUT,DTOUT
QUIT
+6 IF $DATA(DTOUT)!($DATA(DUOUT))
QUIT
+7 IF X="@"!(X="")
KILL RTE,ERTE
SET DRET=1
SET PSORXED("ROUTE",ENT)=""
QUIT
+8 KILL DRET
IF X=$PIECE($GET(^PS(51.2,+$GET(PSORXED("ROUTE",ENT)),0)),"^")
SET RTE=$PIECE(^PS(51.2,PSORXED("ROUTE",ENT),0),"^")
WRITE X_" "_$GET(ERTE)
QUIT
+9 SET DIC=51.2
SET DIC(0)="QEZM"
SET DIC("S")="I $P(^(0),""^"",4)"
DO ^DIC
IF X[U
QUIT
IF Y=-1
GOTO RTE
WRITE " "_$PIECE(Y(0),"^",2)
+10 IF X'=""
SET PSORXED("ROUTE",ENT)=+Y
SET RTE=Y(0,0)
SET ERTE=$PIECE(Y(0),"^",2)
+11 QUIT
ASK KILL JUMP,UNITN,DOSE
DO KV
DO DOSE^PSSORPH(.DOSE,PSODRUG("IEN"),"O",PSODFN)
+1 IF $DATA(DOSE("DD"))
IF $GET(PSOFROM)="PENDING"!($GET(PSOREEDQ))
DO LST2^PSOBKDE1
GOTO ASK1
+2 IF $GET(PSOFROM)="NEW"&($GET(PSORX("EDIT"))']"")!($GET(PSOFROM1))!($GET(COPY))
IF $ORDER(DOSE(0))
DO LST^PSOBKDE1
ASK1 SET STRE=$PIECE($GET(DOSE("DD",PSODRUG("IEN"))),"^",5)
SET UNITN=$PIECE($GET(DOSE("DD",PSODRUG("IEN"))),"^",6)
SET DOSE("LD")=$PIECE($GET(DOSE("DD",PSODRUG("IEN"))),"^",11)
+1 WRITE !
SET DIR(0)="F^1:60"
SET DIR("A",1)="Select from list of Available Dosages, Enter Free Text Dose"
SET DIR("?")="^D LST1^PSOBKDE1"
SET DIR("A")="or Enter a Question Mark (?) to view list"
+2 IF $GET(PSORXED("DOSE",ENT))]""
SET DIR("B")=PSORXED("DOSE",ENT)
Begin DoDot:1
+3 IF $GET(PSORXED("UNITS",ENT))]""
IF DIR("B")'[($PIECE($GET(^PS(50.607,PSORXED("UNITS",ENT),0)),"^"))
SET DIR("B")=DIR("B")_$PIECE($GET(^PS(50.607,PSORXED("UNITS",ENT),0)),"^")
End DoDot:1
+4 IF $GET(PSOREEDQ)!($GET(PSOBDRG))
KILL DIR("B")
+5 DO ^DIR
+6 IF X[U
IF $LENGTH(X)>1
SET FIELD="ASK"
SET JUMP=1
KILL DIRUT,DTOUT
QUIT
+7 IF $DATA(DIRUT)
IF $GET(ORD)
SET PSODSPL=1
QUIT
+8 IF X=$GET(PSORXED("DOSE",ENT))
IF $DATA(DOSE(Y))
GOTO GD1
+9 IF X=$GET(PSORXED("DOSE",ENT))
Begin DoDot:1
+10 SET DOSE=X
SET UNITS=$GET(PSORXED("UNITS",ENT))
+11 IF DOSE'?.N&(DOSE'?.N1".".N)!'DOSE("LD")
SET (UNITN,UNITS,PSORXED("UNITS",ENT))=""
KILL PSORXED("DOSE ORDERED",ENT),DUPD,PSORXED("NOUN",ENT)
End DoDot:1
GOTO DOS
GD1 NEW PSORXTE
+1 ;from list
IF $DATA(DOSE(Y))
Begin DoDot:1
+2 SET DOSE=$SELECT($PIECE(DOSE(Y),"^"):$PIECE(DOSE(Y),"^"),$PIECE(DOSE(Y),"^",3)]"":$PIECE(DOSE(Y),"^",3),1:1)
SET DOLST=Y
+3 IF $PIECE(DOSE(Y),"^")
SET UNITS=$PIECE(DOSE(Y),"^",2)
SET DUPD=$PIECE(DOSE(Y),"^",3)
SET UNITN=$PIECE(DOSE("DD",PSODRUG("IEN")),"^",6)
SET PSORXTE("DOSE ORDERED",ENT)=DUPD
+4 SET PSORXTE("NOUN",ENT)=$PIECE(DOSE(Y),"^",6)
SET PSORXTE("VERB",ENT)=$PIECE(DOSE(Y),"^",8)
+5 IF DOSE'?.N&(DOSE'?.N1".".N)!'DOSE("LD")
Begin DoDot:2
+6 SET (UNITN,UNITS,PSORXED("UNITS",ENT))=""
KILL PSORXED("DOSE ORDERED",ENT),DUPD,PSORXED("NOUN",ENT)
+7 IF $PIECE($GET(^PS(55,PSODFN,"LAN")),"^")
IF $GET(PSOFROM)="PENDING"
DO LAN^PSOORED5
QUIT
+8 IF $PIECE($GET(^PS(55,PSODFN,"LAN")),"^")
IF $GET(PSOFROM)="NEW"
DO LAN^PSOORED5
End DoDot:2
QUIT
+9 SET PSORXTE("UNITS",ENT)=$GET(UNITS)
End DoDot:1
GOTO DOS
+10 ;non-numeric and numeric not in list
SET DOSE=Y
SET DOLST=0
+11 IF DOSE("LD")
Begin DoDot:1
+12 FOR I=1:1:$LENGTH(DOSE)
IF $EXTRACT(DOSE,I)'?.N&($EXTRACT(DOSE,I)'?1" ")&($EXTRACT(DOSE,I)'?1".")
SET DCHK=$GET(DCHK)_$EXTRACT(DOSE,I)
+13 IF $GET(DCHK)]""
Begin DoDot:2
+14 SET DCHK=$TRANSLATE(DCHK,"qwertyuioplkjhgfdsazxcvbnm","QWERTYUIOPLKJHGFDSAZXCVBNM")
+15 IF DCHK=UNITN
SET DOSE=+DOSE
End DoDot:2
End DoDot:1
+16 KILL I,DCHK
+17 SET PSOINDT=$$GET1^DIQ(50,PSODRUG("IEN"),100,"I")
IF PSOINDT
IF DT>PSOINDT
GOTO DOS
+18 SET PSORXTE("NOUN",ENT)=$PIECE(DOSE("DD",PSODRUG("IEN")),"^",9)
SET PSORXTE("VERB",ENT)=$PIECE(DOSE("DD",PSODRUG("IEN")),"^",10)
+19 IF DOSE'?.N&(DOSE'?.N1".".N)!'DOSE("LD")
SET (UNITN,UNITS,PSORXED("UNITS",ENT))=""
KILL PSORXED("NOUN",ENT),PSORXED("ODOSE",ENT)
GOTO DOS
+20 IF $PIECE(DOSE("DD",PSODRUG("IEN")),"^",6)]""
SET (PSORXTE("UNITS",ENT),UNITS)=$ORDER(^PS(50.607,"B",$PIECE(DOSE("DD",PSODRUG("IEN")),"^",6),0))
SET UNITN=$PIECE(DOSE("DD",PSODRUG("IEN")),"^",6)
+21 IF $PIECE(DOSE("DD",PSODRUG("IEN")),"^",5)
SET DUPD=DOSE/$PIECE(DOSE("DD",PSODRUG("IEN")),"^",5)
SET PSORXTE("DOSE ORDERED",ENT)=DUPD
DOS WRITE " "_$SELECT($EXTRACT(DOSE,1)="."&($GET(UNITN)'=""):"0",1:"")_DOSE
IF $GET(UNITN)'=""
WRITE UNITN
+1 WRITE !
KILL DIR,DIRUT
SET DIR(0)="Y"
SET DIR("A")="You entered "_$SELECT($EXTRACT(DOSE,1)="."&($GET(UNITN)'=""):"0",1:"")_DOSE_$SELECT($GET(UNITN)'="":UNITN,1:"")_" is this correct"
SET DIR("B")="Yes"
+2 DO ^DIR
IF 'Y
DO KX
KILL DOSE,UNITS,PSORXTE,PSOINDT
GOTO ASK
+3 SET PSORXED("DOSE",ENT)=DOSE
+4 IF $GET(PSORXTE("DOSE ORDERED",ENT))]""
SET PSORXED("DOSE ORDERED",ENT)=PSORXTE("DOSE ORDERED",ENT)
+5 IF $GET(PSORXTE("NOUN",ENT))]""
SET PSORXED("NOUN",ENT)=PSORXTE("NOUN",ENT)
+6 IF $GET(PSORXTE("VERB",ENT))]""
SET PSORXED("VERB",ENT)=PSORXTE("VERB",ENT)
+7 IF $GET(PSORXTE("UNITS",ENT))]""
SET PSORXED("UNITS",ENT)=PSORXTE("UNITS",ENT)
+8 IF $GET(PSORXED("DOSE",ENT))'?.N&($GET(PSORXED("DOSE",ENT))'?.N1".".N)!'DOSE("LD")
IF $PIECE($GET(^PS(55,PSODFN,"LAN")),"^")
Begin DoDot:1
+9 KILL OTHDOS(ENT)
DO KX
SET DIR(0)="52.0113,9"
+10 IF '$GET(OTHDOS(ENT))
IF $GET(PSORXED("ODOSE",ENT))']""
DO LAN^PSOORED5
+11 IF $GET(PSORXED("ODOSE",ENT))]""
SET DIR("B")=PSORXED("ODOSE",ENT)
IF DIR("B")=""
KILL DIR("B")
+12 KILL DTOUT,DUOUT,DIRUT,Y,X
DO ^DIR
KILL DIR
IF $GET(X)="@"!($GET(X)="")
KILL DIRUT
IF $DATA(DIRUT)
QUIT
+13 IF X="@"
SET OTHDOS(ENT)=1
DO KX
KILL PSORXED("ODOSE",ENT)
QUIT
+14 IF X'=""
SET PSORXED("ODOSE",ENT)=X
End DoDot:1
+15 QUIT
+16 ;
SCH DO KX
+1 SET DIR("?")="^D SCHLP^PSOORED4"
SET DIR("A")="Schedule: "
SET DIR(0)="FA^1:20^I X[""""""""!(X?.E1C.E)!($A(X)=45)!($L(X,"" "")>3)!($L(X)>20)!($L(X)<1) K X"
+2 IF '$DATA(PSOSCH)
IF '$DATA(PSORXED("SCHEDULE",ENT))
IF $PIECE(^PS(50.7,PSODRUG("OI"),0),"^",8)]""
SET PSOSCH=$PIECE(^PS(50.7,PSODRUG("OI"),0),"^",8)
+3 SET DIR("B")=$SELECT($DATA(PSOSCH)&('$DATA(PSORXED("SCHEDULE",ENT))):PSOSCH,$GET(PSORXED("SCHEDULE",ENT))]"":PSORXED("SCHEDULE",ENT),1:"")
IF DIR("B")=""
KILL DIR("B")
+4 IF $GET(PSORXED("SCHEDULE",ENT))']""
IF $GET(PSOREEDT)
KILL DIR("B")
+5 DO ^DIR
+6 QUIT
KX KILL X,Y
KV KILL DTOUT,DUOUT,DIR,DIRUT
+1 QUIT