source: WorldVistAEHR/trunk/r/OUTPATIENT_PHARMACY-PSO-APSP-HUIP/PSOORED3.m@ 846

Last change on this file since 846 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 7.4 KB
Line 
1PSOORED3 ;BIR/SAB-edit finished orders through backdoor ; 10/20/06 11:09am
2 ;;7.0;OUTPATIENT PHARMACY;**46,78,99,117,133,148,249**;DEC 1997;Build 9
3 ;External reference to PS(51.2 supported by DBIA 2226
4 ;called from psoored2
5 D DOLST
6 ;
7DOSE ;adds dosing info
8 I '$G(PSORXED("ENT")) F S I=$O(PSORXED("DOSE",I)) Q:'I S PSORXED("ENT")=$G(PSORXED("ENT"))+1
9 K ROU,UNITN,STRE,PSODOSE,RTE,NOUN,VERB M PSODOSE=PSORXED
10 D KV K FIELD,DOSEOR,DOOR,X,Y,UNITS S ENT=1
11ASK S ROU="PSOORED3" D ASK^PSOBKDED K ROU I $G(JUMP) K JUMP G JUMP
12 G:$D(DIRUT) EXQ
13 I $G(QUIT)]"" K QUIT,ROU Q
14 ;
15 I $G(VERB)]"" S PSORXED("VERB",ENT)=VERB G DUPD
16VER D VER^PSOOREDX I X[U,$L(X)>1 S FIELD="VER" G JUMP
17 G:$D(DTOUT)!($D(DUOUT)) EXQ
18 I X="@" K PSORXED("VERB",ENT),VERB G DUPD
19 S:X'="" (PSORXED("VERB",ENT),VERB)=X
20DUPD ;
21 I $G(PSORXED("DOSE",ENT))'?.N&($G(PSORXED("DOSE",ENT))'?.N1".".N)!'DOSE("LD") K PSORXED("DOSE ORDERED",ENT),DUPD G NOU1
22 D DUPD^PSOOREDX
23 S DIR("B")=$S($G(PSORXED("DOSE ORDERED",ENT))]"":PSORXED("DOSE ORDERED",ENT),1:"") S:$E($G(DIR("B")),1)="." DIR("B")="0"_$G(DIR("B")) K:DIR("B")="" DIR("B")
24 D ^DIR I X[U,$L(X)>1 S FIELD="DUPD" G JUMP
25 G:$D(DTOUT)!($D(DUOUT)) EXQ
26 I X="@"!(X=0) W !,"Dispense Units Per Dose is Required!!",! G DUPD
27 D STR^PSOOREDX
28NOU1 G:'$G(PSORXED("DOSE ORDERED",ENT)) RTE
29 D CNON
30 N PSONDEF
31 I $G(NOUN)]"" S PSORXED("NOUN",ENT)=NOUN
32NOU D NOU^PSOOREDX I X[U,$L(X)>1 S FIELD="NOU" G JUMP
33 G:$D(DTOUT)!($D(DUOUT)) EXQ
34 I X="@" K PSORXED("NOUN",ENT),NOUN G RTE
35 I X'="",$G(PSONDEF)="" S NOUN=X
36 I X'="",$G(PSONDEF)'=X S NOUN=X
37 S:X'="" PSORXED("NOUN",ENT)=X
38RTE S:$G(PSORXED("ROUTE",ENT))']"" DRET=1
39 K JUMP S ROU="PSOORED3" D RTE^PSOBKDED K ROU
40 I $G(JUMP) K JUMP G JUMP
41 G:$D(DTOUT)!($D(DUOUT)) EXQ
42 I $G(QUIT) K QUIT,ROU Q
43 ;
44SCH D SCH^PSOBKDED I X[U,$L(X)>1 S FIELD="SCH" G JUMP
45 G:$D(DTOUT)!($D(DUOUT)) EXQ
46 S SCH=Y D SCH^PSOSIG I $G(SCH)']"" G SCH
47 S PSORXED("SCHEDULE",ENT)=SCH W " ("_SCHEX_")" K SCH,SCHEX,X,Y,PSOSCH
48 S:PSORXED("ENT")<ENT PSORXED("ENT")=ENT
49 ;
50DUR D KV K EXP S DIR(0)="52.0113,4",DIR("A")="LIMITED DURATION (IN MONTHS, WEEKS, DAYS, HOURS OR MINUTES)"
51 S DIR("B")=$S($G(DUR)]"":DUR,$G(PSORXED("DURATION",ENT))]"":PSORXED("DURATION",ENT),1:"") K:DIR("B")="" DIR("B")
52 D ^DIR I X[U,$L(X)>1 S FIELD="DUR" G JUMP
53 G:$D(DTOUT)!($D(DUOUT)) EXQ
54 D DUR1^PSOOREDX
55 ;
56CON D CON^PSOOREDX I X[U,$L(X)>1 S FIELD="CON" G JUMP
57 G:$D(DTOUT)!($D(DUOUT)) EXQ
58 I X="@",$G(PSORXED("CONJUNCTION",ENT))="" W !,?10,"Invalid Entry - nothing to delete!!" G CON
59 S:X'=""&(X'="@") PSORXED("CONJUNCTION",ENT)=Y
60 I X="@" D CON1^PSOOREDX G:$D(DIRUT) EXQ G:'Y CON N CKX S CKX=1 D UPD^PSOOREDX G CON
61 I $G(PSORXED("CONJUNCTION",ENT))]"" S ENT=ENT+1 K DIR G ASK
62 S DENT=$O(PSORXED("DOSE",ENT)) I DENT,(ENT+1)'=DENT D
63 .K PSORXED("DOSE",DENT),PSORXED("NOUN",DENT),PSORXED("VERB",DENT),PSORXED("DOSE ORDERED",DENT),PSORXED("ROUTE",DENT),PSORXED("ODOSE",DENT)
64 .K PSORXED("SCHEDULE",DENT),PSORXED("DURATION",DENT),PSORXED("CONJUNCTION",DENT),DENT
65 I $G(FIELD)]"" K FIELD S QUIT=1
66 I $O(^PSRX(PSORXED("IRXN"),"INS1",0)) D
67 .F D=0:0 S D=$O(^PSRX(PSORXED("IRXN"),"INS1",D)) Q:'D S PSORXED("SIG",D)=^PSRX(PSORXED("IRXN"),"INS1",D,0)
68 D EN^PSOFSIG(.PSORXED) D VER^PSOORED7:'$G(PSOVER) I $G(CKX),'$G(PSOSIGFL) D M1 K CKX
69 I $G(PSOSIGFL)=1 S PSORXED("ENT")=ENT,SIGOK=1 G EX1
70 K QTY,QTYHLD S:$G(PSORXED("QTY")) QTYHLD=PSORXED("QTY") D QTY^PSOSIG(.PSORXED) I $G(PSORXED("QTY")) S QTY=1
71 I $G(QTYHLD),'$G(PSORXED("QTY")) S PSORXED("QTY")=QTYHLD
72 K QTYHLD Q:$G(PSOVER)!($G(PSOREEDQ))
73UDSIG I $O(SIG(0)) D
74 .S D=0 F S D=$O(SIG(D)) Q:'D S ^PSRX(PSORXED("IRXN"),"SIG1",D,0)=SIG(D),$P(^PSRX(PSORXED("IRXN"),"SIG1",0),"^",3)=+$P($G(^PSRX(PSORXED("IRXN"),"SIG1",0)),"^",3)+1,$P(^(0),"^",4)=+$P($G(^(0)),"^",4)+1 Q:'$O(SIG(D))
75 .S (A,I)=0 F S I=$O(^PSRX(PSORXED("IRXN"),"A",I)) Q:'I S A=A+1
76 .D NOW^%DTC I $G(QTY) S A=A+1,^PSRX(PSORXED("IRXN"),"A",A,0)=%_"^E^"_DUZ_"^0^Quantity Updated "_"("_$P(^PSRX(PSORXED("IRXN"),0),"^",7)_")",$P(^PSRX(PSORXED("IRXN"),0),"^",7)=$G(PSORXED("QTY")) K QTY
77 .S A=A+1,^PSRX(PSORXED("IRXN"),"A",A,0)=%_"^E^"_DUZ_"^0^New Dosing Instructions Added",^PSRX(PSORXED("IRXN"),"A",A,1)="ORIGINAL SIG^" D
78 ..I '$P($G(^PSRX(PSORXED("IRXN"),"SIG")),"^",2) S $P(^PSRX(PSORXED("IRXN"),"A",A,1),"^",2)=$P($G(^PSRX(PSORXED("IRXN"),"SIG")),"^") Q
79 ..F I=0:0 S I=$O(^PSRX(PSORXED("IRXN"),"SIG1",I)) Q:'I S ^PSRX(PSORXED("IRXN"),"A",A,2,I,0)=^PSRX(PSORXED("IRXN"),"SIG1",I,0),^PSRX(PSORXED("IRXN"),"A",A,2,0)="^52.34A^"_I_"^"_I
80 .S ^PSRX(PSORXED("IRXN"),"SIG")="^1"
81 .K SIG,A,I
82 S ^PSRX(PSORXED("IRXN"),6,0)="^52.0113^"_ENT_"^"_ENT
83 F I=1:1:ENT S ^PSRX(PSORXED("IRXN"),6,I,0)=PSORXED("DOSE",I)_"^"_$G(PSORXED("DOSE ORDERED",I))_"^"_$G(PSORXED("UNITS",I))_"^"_$G(PSORXED("NOUN",I))_"^" D
84 .S ^PSRX(PSORXED("IRXN"),6,I,0)=^PSRX(PSORXED("IRXN"),6,I,0)_$G(PSORXED("DURATION",I))_"^"_$G(PSORXED("CONJUNCTION",I))_"^"_$G(PSORXED("ROUTE",I))_"^"_$G(PSORXED("SCHEDULE",I))_"^"_$G(PSORXED("VERB",I))
85 .S ^PSRX(PSORXED("IRXN"),6,I,1)=$G(PSORXED("ODOSE",I))
86 S ^PSRX(PSORXED("IRXN"),"POE")=1
87 G EX
88 Q
89EX ;
90 K PSORXED("DOSE"),DOSE,DUPD,SCH,PSORXED("NOUN"),PSORXED("VERB"),VERB,NOUN,PSORXED("DOSE ORDERED"),DOSEOR,PSORXED("ROUTE"),ENT,PSORTE,SIG,PSODOSE
91 K PSORXED("SCHEDULE"),PSORXED("DURATION"),PSORXED("CONJUNCTION"),DURA,X,Y,PSORXED("ODOSE")
92EX1 K STRE,UNITN,DOSE,DUPD,SCH,VERB,NOUN,DOSEOR,RTE,DUR,X,Y,ENTS,PSOSCH,ERTE,ROU
93KV K DIR,DIRUT,DUOUT,DTOUT
94 Q
95EXQ K PSORXED,PSOSIGFL M PSORXED=PSODOSE D EN^PSOFSIG(.PSORXED) S PSORXED("DFLG")=1 D M1 G EX
96 Q
97M1 D M1^PSOOREDX
98 Q
99DOLST1(PSORXED) ;
100 ;
101DOLST F I=0:0 S I=$O(^PSRX(PSORXED("IRXN"),6,I)) Q:'I S INST=^(I,0) D
102 .S PSORXED("DOSE",I)=$P(INST,"^"),PSORXED("DOSE ORDERED",I)=$P(INST,"^",2),PSORXED("UNITS",I)=$P(INST,"^",3),PSORXED("NOUN",I)=$P(INST,"^",4)
103 .I $P(INST,"^",5)]"" D
104 ..S PSORXED("DURATION",I)=$S($E($P(INST,"^",5),1)'?.N:$E($P(INST,"^",5),2,99)_$E($P(INST,"^",5),1),1:$P(INST,"^",5))
105 .S PSORXED("ROUTE",I)=$P(INST,"^",7),PSORXED("SCHEDULE",I)=$P(INST,"^",8)
106 .S PSORXED("CONJUNCTION",I)=$P(INST,"^",6),PSORXED("VERB",I)=$P(INST,"^",9),OLENT=I
107 .S PSORXED("ODOSE",I)=$G(^PSRX(PSORXED("IRXN"),6,I,1))
108 K:'$O(PSORXED("DOSE",0)) PSORXED("ENT"),OLENT
109 S PSORXED("INS")=$G(^PSRX(PSORXED("IRXN"),"INS"))
110 Q
111UPDSIG ;updates sig
112 K ^PSRX(PSORXED("IRXN"),"SIG1") S ^PSRX(PSORXED("IRXN"),"SIG1",0)="^52.04A^^"
113 S D=0 F S D=$O(SIG(D)) Q:'D S ^PSRX(PSORXED("IRXN"),"SIG1",D,0)=SIG(D),$P(^PSRX(PSORXED("IRXN"),"SIG1",0),"^",3)=+$P($G(^PSRX(PSORXED("IRXN"),"SIG1",0)),"^",3)+1,$P(^(0),"^",4)=+$P($G(^(0)),"^",4)+1
114 S ^PSRX(PSORXED("IRXN"),"SIG")="^1"
115 Q
116JUMP ;jump to fields
117 I $L($E(X,2,99))<3 W !,"Field Name Must Be At Least 3 Characters in Length",! G @FIELD
118 D FNM^PSOOREDX
119 I FLDNM']"" K X,NM,FLDNM W !,"INVALID FIELD NAME. PLEASE TRY AGAIN!",! G @FIELD
120 F AR=1:1:PSORXED("ENT") W !,AR_". "_$P(FLDNM,"^",2)_": "_$S(NM="ROU"&($G(PSORXED($P(FLDNM,"^"),AR))):$P(^PS(51.2,PSORXED($P(FLDNM,"^"),AR),0),"^"),1:$G(PSORXED($P(FLDNM,"^"),AR))) S AR1=AR
121 D KV S DIR("A",1)="* Indicates which fields will create a New Order",DIR("A")="Select Field to Edit by number",DIR(0)="NO^1:"_AR1 D ^DIR G:$D(DIRUT) @FIELD
122 D JFN^PSOOREDX G:FLDNM="" @FIELD G @FLDNM
123 G EX
124 Q
125 ;
126CNON ;
127 I $G(NOUN)'="" Q
128 I '$G(PSORXED("DOSE ORDERED",ENT)) Q
129 N PSONLT,PSONLL,PSONLG
130 S PSONLL=$P($G(DOSE("DD",+$G(PSODRUG("IEN")))),"^",9) I PSONLL="" Q
131 S PSONLG=$L(PSONLL)
132 I PSONLG'>3 Q
133 S PSONLT=$E(PSONLL,(PSONLG-2),PSONLG)
134 I PSONLT'="(S)",PSONLT'="(s)" Q
135 ;test noun of (S)
136 K NOUN ; NOT SURE ABOUT THIS???
137 I $G(PSORXED("DOSE ORDERED",ENT))>1 S PSORXED("NOUN",ENT)=$E(PSONLL,1,(PSONLG-3))_$E(PSONLT,2) Q
138 S PSORXED("NOUN",ENT)=$E(PSONLL,1,(PSONLG-3))
139 Q
Note: See TracBrowser for help on using the repository browser.