1 | PSBVDLU1 ;BIRMINGHAM/EFC-VIRTUAL DUE LIST (VDL) UTILITIES ;Mar 2004
|
---|
2 | ;;3.0;BAR CODE MED ADMIN;**13,32**;Mar 2004;Build 32
|
---|
3 | ;
|
---|
4 | ; Reference/IA
|
---|
5 | ; EN^PSJBCMA1/2829
|
---|
6 | ;
|
---|
7 | ODDSCH(PSBTABX) ;
|
---|
8 | I (PSBOST'<PSBWBEG)&(PSBOST'>PSBWEND) D ADD(PSBREC,PSBOTXT,PSBOST,PSBDDS,PSBSOLS,PSBADDS,PSBTABX) ;Include start date/time as admin
|
---|
9 | S PSBQUIT=0,PSBCDT=PSBOST F S PSBCDT=$$FMADD^XLFDT(PSBCDT,"","",PSBFREQ) Q:PSBQUIT=1 D
|
---|
10 | .I $P(PSBCDT,".",2)="" S PSBCDT=PSBCDT-1_".24"
|
---|
11 | .I PSBCDT>PSBWEND S PSBQUIT=1 Q
|
---|
12 | .I PSBCDT'<PSBWBEG,PSBCDT<PSBOSP D ADD(PSBREC,PSBOTXT,PSBCDT,PSBDDS,PSBSOLS,PSBADDS,PSBTABX) Q
|
---|
13 | Q
|
---|
14 | GETFREQ(PSBDFN,PSBORDN) ;
|
---|
15 | K ^TMP("PSJ1",$J)
|
---|
16 | D EN^PSJBCMA1(PSBDFN,PSBORDN,1)
|
---|
17 | S PSBFREQ=$P(^TMP("PSJ1",$J,4),U,11)
|
---|
18 | S PSBSCHBR=$P(^TMP("PSJ1",$J,2),"^",5)
|
---|
19 | I $$PSBDCHK1^PSBVT1(PSBSCHBR) S PSBFREQ=""
|
---|
20 | K ^TMP("PSJ1",$J)
|
---|
21 | Q PSBFREQ
|
---|
22 | ;
|
---|
23 | GETADMIN(PSBDFN,PSBORDN,PSBSTRT,PSBFREQ,PSBEVDT) ;
|
---|
24 | ;Determine administration times of an odd schedule for today
|
---|
25 | N PSBADMIN
|
---|
26 | K ^TMP("PSB",$J,"GETADMIN")
|
---|
27 | D EN^PSJBCMA1(PSBDFN,PSBORDN,1)
|
---|
28 | S PSBADMIN=$P(^TMP("PSJ1",$J,4),U,9),PSBFREQ=$P(^TMP("PSJ1",$J,4),U,11),^TMP("PSB",$J,"GETADMIN",0)=PSBADMIN
|
---|
29 | I $E(PSBFREQ)'?1N K ^TMP("PSJ1",$J) Q $G(^TMP("PSB",$J,"GETADMIN",0))
|
---|
30 | I PSBFREQ=0 K ^TMP("PSJ1",$J) Q $G(^TMP("PSB",$J,"GETADMIN",0))
|
---|
31 | I PSBSTRT'<PSBEVDT S PSBADMIN=$E($P(PSBSTRT,".",2)_"0000",1,4),^TMP("PSB",$J,"GETADMIN",0)=PSBADMIN
|
---|
32 | S PSBCDT=PSBSTRT,(PSBADTMX,PSBQUIT)=0 F S PSBCDT=$$FMADD^XLFDT(PSBCDT,"","",PSBFREQ) D Q:PSBQUIT=1
|
---|
33 | .I $P(PSBCDT,".",2)="" S PSBCDT=PSBCDT-1_".24"
|
---|
34 | .I (PSBCDT\1)>(PSBEVDT\1) S PSBQUIT=1 Q
|
---|
35 | .I (PSBCDT\1)=(PSBEVDT\1) S PSBADMIN=PSBADMIN_$S(PSBADMIN="":"",1:"-")_$E($P(PSBCDT,".",2)_"0000",1,4)
|
---|
36 | .S ^TMP("PSB",$J,"GETADMIN",PSBADTMX)=PSBADMIN
|
---|
37 | .S:($L(PSBADMIN)+5)>255 PSBADTMX=PSBADTMX+1,PSBADMIN=""
|
---|
38 | K ^TMP("PSJ1",$J),PSBADTMX
|
---|
39 | Q $G(^TMP("PSB",$J,"GETADMIN",0))
|
---|
40 | ;
|
---|
41 | ADD(PSBREC,PSBSI,PSBDT,PSBDD,PSBSOL,PSBADD,PSBTAB) ;
|
---|
42 | ;
|
---|
43 | ; Description: Add order to ^TMP("PSB",$J,PSBTAB,...) for RPC Return RESULTS
|
---|
44 | ;
|
---|
45 | ; PSBREC=order hdr from above
|
---|
46 | ; PSBSI=special instructions
|
---|
47 | ; PSBDT=admin date/time
|
---|
48 | ; PSBDD=Dispense Drugs
|
---|
49 | ; PSBSOL=Solutions
|
---|
50 | ; PSBADD=Additives
|
---|
51 | ;
|
---|
52 | N PSB
|
---|
53 | S PSBDT=$E(PSBDT,1,12),PSBQR=0
|
---|
54 | S PSB=$O(^TMP("PSB",$J,PSBTAB,""),-1) ; Get next node
|
---|
55 | S $P(PSBREC,U,14)=PSBDT ; Admin Time sits in ^14
|
---|
56 | I $P(PSBREC,U,5)'="O" S X=$O(^PSB(53.79,"AORD",DFN,PSBONX,PSBDT,0)) D:X
|
---|
57 | .S $P(PSBREC,U,12)=X
|
---|
58 | .K PSBLCK L +^PSB(53.79,X):1 I L -^PSB(53.79,X) S PSBLCK=1
|
---|
59 | .S PSBSTUS=$P(^PSB(53.79,X,0),U,9),$P(PSBREC,U,13)=$S(PSBSTUS="N":"",(PSBSTUS="")&$G(PSBLCK):"U",1:PSBSTUS),$P(PSBREC,U,23)=$P(^PSB(53.79,X,0),U,10),$P(PSBREC,U,24)=$P(^PSB(53.79,X,0),U,7)
|
---|
60 | .I $D(^PSB(53.79,X)) I PSBDOSEF="PATCH",PSBSTUS="G",PSBDT=$P(^PSB(53.79,X,.1),U,3),PSBQRR=0 S PSBQR=1
|
---|
61 | .I PSBSTUS="G",$G(PSBFLAG) D CHECK ;Get the correct dispense drug
|
---|
62 | I ($P(PSBREC,U,5)="O") D
|
---|
63 | .S X=$O(^PSB(53.79,"AORDX",DFN,PSBONX,"")) Q:X=""
|
---|
64 | .S Y=$O(^PSB(53.79,"AORDX",DFN,PSBONX,X,"")) Q:Y="" S $P(PSBREC,U,12)=Y
|
---|
65 | .K PSBLCK L +^PSB(53.79,Y):1 I L -^PSB(53.79,Y) S PSBLCK=1
|
---|
66 | .S PSBSTUS=$P(^PSB(53.79,Y,0),U,9),$P(PSBREC,U,13)=$S(PSBSTUS="N":"",(PSBSTUS="")&$G(PSBLCK):"U",1:PSBSTUS),$P(PSBREC,U,24)=$P(^PSB(53.79,Y,0),U,7)
|
---|
67 | .I $D(^PSB(53.79,Y)) I PSBDOSEF="PATCH",PSBSTUS="G",PSBDT=$P(^PSB(53.79,Y,.1),U,3),PSBQRR=0 S PSBQR=1
|
---|
68 | .I PSBSTUS="G",$G(PSBFLAG) D CHECK
|
---|
69 | Q:PSBQR=1
|
---|
70 | S $P(PSBREC,U,25)=0 I $G(PSBTRFL),$P(PSBREC,U,11)]"",$P(PSBREC,U,11)'<$G(PSBNTDT),$P(PSBREC,U,11)'>$G(PSBTRDT) S $P(PSBREC,U,25)=1
|
---|
71 | S PSB=PSB+1,^TMP("PSB",$J,PSBTAB,PSB)=PSBREC ; Order Hdr
|
---|
72 | I $P(PSBREC,U,12)]"" S PSBONVDL($P(PSBREC,U,12))=""
|
---|
73 | S PSB=PSB+1,^TMP("PSB",$J,PSBTAB,PSB)=PSBSI ; Special Instructions
|
---|
74 | ; add dispense drugs
|
---|
75 | I $D(PSBDDA) S X="" F S X=$O(PSBDDA(X)) Q:X="" S PSB=PSB+1,^TMP("PSB",$J,PSBTAB,PSB)=PSBDDA(X)
|
---|
76 | S PSBCHDT=0
|
---|
77 | I (PSBTAB'["CVRSHT"),(PSBONX["V"),(PSBOSTS="D"),($G(PSBFOR)="") D Q ;get infusing bag from DCed but not DEed orders
|
---|
78 | .D PSJ^PSBVT(PSBX)
|
---|
79 | .D INFUSING^PSBVDLU2 I PSBCOMP=0 Q
|
---|
80 | .I $D(PSBSOLA) S X="" F S X=$O(PSBSOLA(X)) Q:X="" S PSB=PSB+1,^TMP("PSB",$J,PSBTAB,PSB)=PSBSOLA(X)
|
---|
81 | .I $D(PSBADA) S X="" F S X=$O(PSBADA(X)) Q:X="" S PSB=PSB+1,^TMP("PSB",$J,PSBTAB,PSB)=PSBADA(X)
|
---|
82 | .S X="" F S X=$O(PSBPORA(PSBONX,X)) S PSBUID=$P(PSBPORA(PSBONX,X),U,1) Q:PSBUID]"" Q:X=""
|
---|
83 | .I PSBUID["P" Q
|
---|
84 | .I PSBUID["WS" D
|
---|
85 | ..S PSBNODE=$O(^PSB(53.79,"AUID",DFN,X,PSBUID,""))
|
---|
86 | ..S PSBUIDA(PSBUID)="ID"_U_PSBUID
|
---|
87 | ..S X=0 F S X=$O(^PSB(53.79,PSBNODE,.6,X)) Q:'X S PSBUIDA(PSBUID)=PSBUIDA(PSBUID)_U_"ADD;"_$P(^PSB(53.79,PSBNODE,.6,X,0),U,1)
|
---|
88 | ..S X=0 F S X=$O(^PSB(53.79,PSBNODE,.7,X)) Q:'X S PSBUIDA(PSBUID)=PSBUIDA(PSBUID)_U_"SOL;"_$P(^PSB(53.79,PSBNODE,.7,X,0),U,1)
|
---|
89 | .S PSBSONX=PSBONX
|
---|
90 | .I '$D(PSBUIDA(PSBUID)) S PSBCKOR="" F S PSBCKOR=$O(PSBPORA(PSBSONX,PSBCKOR)) Q:PSBCKOR="" D CLEAN^PSBVT,PSJ1^PSBVT(DFN,PSBCKOR) Q:$D(PSBUIDA(PSBUID))
|
---|
91 | .S PSBONX=PSBSONX
|
---|
92 | .S:$D(PSBUIDA(PSBUID)) PSB=PSB+2,^TMP("PSB",$J,PSBTAB,PSB-1)=PSBUIDA(PSBUID),^TMP("PSB",$J,PSBTAB,PSB)="END"
|
---|
93 | .D CLEAN^PSBVT,PSJ1^PSBVT(DFN,$O(PSBPORA("")))
|
---|
94 | ; add additives
|
---|
95 | I $D(PSBADA) S X="" F S X=$O(PSBADA(X)) Q:X="" S PSB=PSB+1,^TMP("PSB",$J,PSBTAB,PSB)=PSBADA(X)
|
---|
96 | ; add solutions
|
---|
97 | I $D(PSBSOLA) S X="" F S X=$O(PSBSOLA(X)) Q:X="" S $P(PSBSOLA(X),U,5)="",PSB=PSB+1,^TMP("PSB",$J,PSBTAB,PSB)=PSBSOLA(X)
|
---|
98 | I PSBONX["V" D EN^PSBPOIV(DFN,PSBONX) ; get bags
|
---|
99 | I $D(^TMP("PSBAR",$J)) S PSBUID=DFN_"V"_99999 F S PSBUID=$O(^TMP("PSBAR",$J,PSBUID),-1) Q:PSBUID="" D
|
---|
100 | .S PSBUIDS=^TMP("PSBAR",$J,PSBUID)
|
---|
101 | .I $P(PSBUIDS,U,1)="I",$P(PSBUIDS,U,2)'="I",$P(PSBUIDS,U,2)'="S" Q ; bag has invalid IV parameter, is not infusing or stopped
|
---|
102 | .I $P(PSBUIDS,U,2)'="I",$P(PSBUIDS,U,2)'="S",$P(PSBUIDS,U,8)'="" Q ; label is no longer valid, bag is not infusing or stopped
|
---|
103 | .I $P(PSBUIDS,U,2)="C" Q ; bag is completed
|
---|
104 | .I $P(PSBUIDS,U,2)="G" Q ; bag is given (PBTAB)
|
---|
105 | .S PSB=PSB+1,^TMP("PSB",$J,PSBTAB,PSB)=$P(PSBUIDS,U,10,999)
|
---|
106 | K ^TMP("PSBAR",$J)
|
---|
107 | S PSB=PSB+1,^TMP("PSB",$J,PSBTAB,PSB)="END"
|
---|
108 | S ^TMP("PSB",$J,PSBTAB,0)=PSB
|
---|
109 | Q
|
---|
110 | ;
|
---|
111 | CHECK S FILE=53.795,PSBNODE=.5,PSBIENS=X_","
|
---|
112 | F I=0:0 S I=$O(^PSB(53.79,X,PSBNODE,I)) Q:'I S $P(PSBDDS,U,3,4)=$$GET1^DIQ(FILE,I_","_PSBIENS,.01,"I")_U_$$GET1^DIQ(FILE,I_","_PSBIENS,.01)
|
---|
113 | Q
|
---|
114 | ;
|
---|
115 | VNURSE(PSBTAB) ;add initials of verifying pharmacist/verifying nurse
|
---|
116 | F PSBLP=1:1:$P(^TMP("PSB",$J,PSBTAB,0),U,1) S X=^TMP("PSB",$J,PSBTAB,PSBLP) I $P(X,U)=DFN D
|
---|
117 | .K ^TMP("PSJ1",$J)
|
---|
118 | .D PSJ1^PSBVT(DFN,$P(X,U,2))
|
---|
119 | .S $P(^TMP("PSB",$J,PSBTAB,PSBLP),U,19)=$S(PSBVNI]"":PSBVNI,1:"***")
|
---|
120 | K PSBLP,PSBTAB
|
---|
121 | Q
|
---|
122 | ;
|
---|
123 | OKAY(PSBSTRT,PSBADMIN,PSBSCH,PSBORDER,PSBDRUG,PSBFREQ,PSBOSTS) ;
|
---|
124 | ;
|
---|
125 | ; Description: Determines if an order schedule is valid for
|
---|
126 | ; the date in PSBADMIN (i.e. Q4D, is it valid today)
|
---|
127 | ;
|
---|
128 | ; PSBSTRT: Start Date of order (Time ignored)
|
---|
129 | ; PSBADMIN: Date of administration to check (Time ignored)
|
---|
130 | ; PSBSCH: Schedule (i.e. MO-WE-FR@0900 or Q48H...)
|
---|
131 | ; PSBORDER: Order reference
|
---|
132 | ; PSBDRUG: Drug ordered (Orderable Item)
|
---|
133 | ; PSBOSTS: The status of the order
|
---|
134 | ;
|
---|
135 | N PSBOKAY,PSBDAYS,PSBDOW
|
---|
136 | S PSBOSTS=$G(PSBOSTS)
|
---|
137 | ;
|
---|
138 | S PSBOKAY=0 ; Default Flag
|
---|
139 | I PSBFREQ'="",PSBFREQ'="D",PSBFREQ'>1440 Q 1
|
---|
140 | ;PRN and ONE TIMES show everyday
|
---|
141 | I (PSBSCHT="P")!(PSBSCHT="O") Q 1
|
---|
142 | S PSBDAYS=$$DAYS(PSBSCH)
|
---|
143 | ;
|
---|
144 | I PSBDAYS=1 S PSBOKAY=1 Q PSBOKAY ; Order is everyday
|
---|
145 | ;
|
---|
146 | ; find out if today is a good day for multi days
|
---|
147 | S PSBOKAY=0,PSBRDTE=PSBSTRT
|
---|
148 | S PSBADBR=PSBADMIN\1
|
---|
149 | S PSBENR=(PSBADMIN\1)+1
|
---|
150 | I PSBDAYS>1 D Q PSBOKAY
|
---|
151 | .I PSBADBR=(PSBSTRT\1) S PSBOKAY=1
|
---|
152 | .F S PSBRDTE=$$FMADD^XLFDT(PSBRDTE,"","",PSBFREQ) Q:PSBRDTE>PSBENR D
|
---|
153 | ..I $P(PSBRDTE,".",2)="" S PSBRDTE=PSBRDTE-1_".24"
|
---|
154 | ..I PSBRDTE\1=PSBADBR S PSBOKAY=1
|
---|
155 | ..I PSBOKAY="1" Q
|
---|
156 | ;
|
---|
157 | ; Try the MO-WE-FR@0800 thing as last resort
|
---|
158 | S X=PSBADMIN D H^%DTC I %Y=-1 D Q PSBOKAY ; Error
|
---|
159 | .S PSBOKAY=0
|
---|
160 | .Q:PSBOSTS="E"
|
---|
161 | .Q:$G(PSBMHND)="PSBOMH"
|
---|
162 | .D ERROR^PSBMLU($G(PSBORDER,"UNKNOWN"),$G(PSBDRUG,""),DFN,"Unable to determine schedule "_PSBSCH,PSBSCH)
|
---|
163 | S PSBDOW=$P("SU^MO^TU^WE^TH^FR^SA",U,%Y+1)
|
---|
164 | I $F(PSBSCH,PSBDOW)>0 S PSBOKAY=1 Q PSBOKAY
|
---|
165 | S PSBOKAY=0
|
---|
166 | Q PSBOKAY
|
---|
167 | ;
|
---|
168 | DAYS(PSB) ; Return days between doses (-1: error, 1:everyday 2: QOD...)
|
---|
169 | ;
|
---|
170 | ; Is it a PRN
|
---|
171 | I PSB?.E1"PRN".E Q 1 ; Straight PRN - As Needed
|
---|
172 | ;
|
---|
173 | S PSB=$TR(PSB," ","")
|
---|
174 | I PSB?2.4N.E Q 1
|
---|
175 | S X=PSBFREQ/1440 Q X
|
---|
176 | ;
|
---|
177 | Q
|
---|
178 | ;
|
---|
179 | LAST ;
|
---|
180 | S PSBCC=0
|
---|
181 | S ZZ="" F S ZZ=$O(^PSB(53.79,X,.3,ZZ),-1) Q:'ZZ Q:PSBFLAG=1 S PSBDATA2=$G(^(ZZ,0)) D
|
---|
182 | .S PSBCC=PSBCC+1
|
---|
183 | .I (PSBCC=2)!($P($P(PSBDATA2,U)," ")="Refused:")!($P($P(PSBDATA2,U)," ")="Held:") S $P(PSBREC,U,11)=$P(PSBDATA2,U,3),PSBFLAG=1
|
---|
184 | Q
|
---|
185 | ;
|
---|