1 | PSBVDLUD ;BIRMINGHAM/EFC-BCMA UNIT DOSE VIRTUAL DUE LIST FUNCTIONS ;Mar 2004
|
---|
2 | ;;3.0;BAR CODE MED ADMIN;**11,13,38,32**;Mar 2004;Build 32
|
---|
3 | ;Per VHA Directive 2004-038 (or future revisions regarding same), this routine should not be modified.
|
---|
4 | ;
|
---|
5 | ; Reference/IA
|
---|
6 | ; EN^PSJBCMA/2828
|
---|
7 | ; $$GET^XPAR/2263
|
---|
8 | ;
|
---|
9 | EN(DFN,PSBDT) ;
|
---|
10 | ;
|
---|
11 | ;
|
---|
12 | ; Description:
|
---|
13 | ; Returns the current unit dose order set for today to display
|
---|
14 | ; on the client VDL
|
---|
15 | ;
|
---|
16 | N PSBDATA,PSBTBOUT
|
---|
17 | S PSBTBOUT=0
|
---|
18 | ;
|
---|
19 | ;This routine now re-uses the ^TMP("PSJ",$J global built in PSBVDLTB
|
---|
20 | ;
|
---|
21 | G:$G(^TMP("PSJ",$J,1,0))=-1 1
|
---|
22 | F PSBX=0:0 S PSBX=$O(^TMP("PSJ",$J,PSBX)) Q:('PSBX)!(PSBTBOUT) D
|
---|
23 | .S:(PSBTAB'="UDTAB")&($G(^TMP("PSB",$J,"UDTAB",2))>0) PSBTBOUT=1
|
---|
24 | .D CLEAN^PSBVT,PSJ^PSBVT(PSBX)
|
---|
25 | .;
|
---|
26 | .; << Standard checks for ALL orders >>
|
---|
27 | .;
|
---|
28 | .Q:PSBONX["V" ;No IVs on UD tab
|
---|
29 | .Q:PSBONX["P" ; No Pending Orders
|
---|
30 | .Q:PSBOST>PSBWADM ; Order Start Date/Time > admin window
|
---|
31 | .Q:PSBOSP<PSBWBEG ; For Non one-times Order Stop Date/Time < vdl window
|
---|
32 | .Q:PSBOSTS["D" ; Is it DC'd
|
---|
33 | .Q:PSBNGF ; Is it marked DO NOT GIVE!
|
---|
34 | .Q:PSBIVPSH
|
---|
35 | .;
|
---|
36 | .; Non One-Times with stop date/time < now
|
---|
37 | .;
|
---|
38 | .D NOW^%DTC
|
---|
39 | .Q:PSBOSP<%
|
---|
40 | .;
|
---|
41 | .; include Active, Renewed, ReInstated and On Call
|
---|
42 | .; (Is it not one time)&(Is it not active or renewed or On Call)
|
---|
43 | .I PSBSCHT'="O",PSBOSTS'="A",PSBOSTS'="H",PSBOSTS'="R",PSBOSTS'="RE",PSBOSTS'="O" Q
|
---|
44 | .;
|
---|
45 | .; Is One Time Given
|
---|
46 | .;
|
---|
47 | .I PSBSCHT="O" D Q:PSBGVN
|
---|
48 | ..S (PSBGVN,X,Y)=""
|
---|
49 | ..F S X=$O(^PSB(53.79,"AOIP",DFN,PSBOIT,X),-1) Q:'X D
|
---|
50 | ...F S Y=$O(^PSB(53.79,"AOIP",DFN,PSBOIT,X,Y),-1) Q:'Y D
|
---|
51 | ....I $P(^PSB(53.79,Y,.1),U)=PSBONX,$P(^PSB(53.79,Y,0),U,9)="G" S PSBGVN=1,(X,Y)=0
|
---|
52 | .;
|
---|
53 | .; How long does One Time remain on VDL ??
|
---|
54 | .S PSBRMN=1
|
---|
55 | .I PSBSCHT="O",PSBOSP'=PSBOST&(%>PSBOSP) S PSBRMN=0
|
---|
56 | .Q:'PSBRMN
|
---|
57 | .; Is On-Call Given, Can it be given more than once
|
---|
58 | .;
|
---|
59 | .I PSBSCHT="OC" D Q:PSBGVN&('$$GET^XPAR("DIV","PSB ADMIN MULTIPLE ONCALL"))
|
---|
60 | ..S (PSBGVN,X,Y)=""
|
---|
61 | ..F S X=$O(^PSB(53.79,"AOIP",DFN,PSBOIT,X),-1) Q:'X D
|
---|
62 | ...F S Y=$O(^PSB(53.79,"AOIP",DFN,PSBOIT,X,Y),-1) Q:'Y D
|
---|
63 | ....I $P(^PSB(53.79,Y,.1),U)=PSBONX,$P(^PSB(53.79,Y,0),U,9)="G" S PSBGVN=1,(X,Y)=0
|
---|
64 | .;
|
---|
65 | .S PSBREC=""
|
---|
66 | .S $P(PSBREC,U,1)=DFN ; dfn
|
---|
67 | .S $P(PSBREC,U,2)=PSBONX ; order
|
---|
68 | .S $P(PSBREC,U,3)=PSBON ; order ien
|
---|
69 | .S $P(PSBREC,U,4)=PSBOTYP ; iv/ud/pending
|
---|
70 | .S $P(PSBREC,U,5)=PSBSCHT ; schedule type
|
---|
71 | .S $P(PSBREC,U,6)=PSBSCH ; schedule
|
---|
72 | .S $P(PSBREC,U,7)=$S(PSBHSM:"HSM",PSBSM:"SM",1:"") ; self med
|
---|
73 | .S $P(PSBREC,U,8)=PSBOITX ; drugname
|
---|
74 | .S $P(PSBREC,U,9)=PSBDOSE_" "_PSBIFR ; dosage
|
---|
75 | .S $P(PSBREC,U,10)=PSBMR ; med route
|
---|
76 | .; Last Given from the AOIP X-Ref - not given status not excepted
|
---|
77 | .S (PSBCNT,PSBFLAG)=0,(YZ,PSBSTUS,PSBADMER)="" K PSBHSTA,PSBHSTAX
|
---|
78 | .F XZ=1:1:20 S YZ=$O(^PSB(53.79,"AOIP",DFN,PSBOIT,YZ),-1),(PSBCNT,PSBFLAG)=0 Q:YZ="" D
|
---|
79 | ..S:YZ>0 $P(PSBREC,U,11)=YZ
|
---|
80 | ..S X="" F S X=$O(^PSB(53.79,"AOIP",DFN,PSBOIT,YZ,X),-1) Q:X="" D
|
---|
81 | ...K PSBLCK L +^PSB(53.79,X):1 I L -^PSB(53.79,X) S PSBLCK=1
|
---|
82 | ...S PSBSTUS=$P(^PSB(53.79,X,0),U,9)
|
---|
83 | ...I $G(PSBSTUS)="" S:'$G(PSBLCK) PSBSTUS="X" I $G(PSBLCK) S PSBADMER=1 D
|
---|
84 | ....K PSBPARM3,PSBPARM5,PSBPARM6,PSBPARM7
|
---|
85 | ....S PSBPARM6=X,Y=$P(^PSB(53.79,X,.1),U,3) D DD^%DT S PSBPARM3=Y,Y=$P(^PSB(53.79,X,0),U,6) D DD^%DT S PSBPARM5=Y
|
---|
86 | ....S PSBPARM7=$P(^PSB(53.79,X,0),U,7) S PSBPARM7="( # "_PSBPARM7_" ) "_$$GET1^DIQ(200,PSBPARM7_",",.01)
|
---|
87 | ....K PSBXTMP S PSBXTMP=PSBONX
|
---|
88 | ....D CLEAN^PSBVT,PSJ1^PSBVT(DFN,$$GET1^DIQ(53.79,PSBPARM6_",",.11))
|
---|
89 | ....D ERROR^PSBMLU(PSBONX,PSBOITX,DFN,PSBPARM3_" admin's ACTION STATUS is ""UNKNOWN"".",PSBSCH,PSBPARM5,PSBPARM6,PSBPARM7) ; SEND AN E-MAIL
|
---|
90 | ....D CLEAN^PSBVT,PSJ1^PSBVT(DFN,PSBXTMP) ;Reset Variables
|
---|
91 | ....S X=PSBPARM6 K PSBPARM3,PSBPARM5,PSBPARM6,PSBPARM7
|
---|
92 | ...K PSBLCK S:(PSBSTUS']"") PSBSTUS="U" I PSBSTUS'="N",($G(PSBSTUS)'="X") S PSBFLAG=1,PSBHSTA(YZ,$G(PSBSTUS))="ORIG"_U_X
|
---|
93 | ...D:PSBSTUS="N"
|
---|
94 | ....S $P(PSBREC,U,11)=""
|
---|
95 | ....S Z="" F S Z=$O(^PSB(53.79,X,.9,Z),-1) Q:'Z Q:PSBFLAG=1 S PSBDATA=$G(^(Z,0)) D
|
---|
96 | .....I (PSBDATA["Set to 'NOT GIVEN'")!(PSBDATA["Set to 'GIVEN'")!(PSBDATA["Set to 'REFUSED'")!(PSBDATA["Set to 'HELD'")!(PSBDATA["Set to 'MISSING DOSE'")!(PSBDATA["Set to 'REMOVED'") S PSBCNT=PSBCNT+1
|
---|
97 | .....I (PSBDATA["STATUS 'HELD'")!(PSBDATA["STATUS 'GIVEN'")!(PSBDATA["STATUS 'REFUSED'")!(PSBDATA["STATUS 'MISSING DOSE'")!(PSBDATA["STATUS 'REMOVED'") S PSBCNT=PSBCNT+1
|
---|
98 | .....I PSBCNT#2=0,PSBDATA["'REFUSED'" S PSBSTUS="R" D LAST^PSBVDLU1
|
---|
99 | .....I PSBCNT#2=0,PSBDATA["'HELD'" S PSBSTUS="H" D LAST^PSBVDLU1
|
---|
100 | .....I PSBCNT#2=0,PSBDATA["'MISSING DOSE'" S PSBSTUS="M" D LAST^PSBVDLU1
|
---|
101 | .....I PSBCNT#2=0,PSBDATA["'REMOVED'" S PSBSTUS="RM" D LAST^PSBVDLU1
|
---|
102 | .....I PSBFLAG=1,'$D(PSBHSTA($P(PSBREC,U,11),$G(PSBSTUS))) S PSBHSTA($P(PSBREC,U,11),$G(PSBSTUS))=Z_U_X
|
---|
103 | .I $D(PSBHSTA) S $P(PSBREC,U,11)=$O(PSBHSTA(""),-1),PSBSTUS=$O(PSBHSTA($P(PSBREC,U,11),""),-1) M PSBHSTAX(PSBOIT)=PSBHSTA K PSBHSTA ;last action date/time
|
---|
104 | .S $P(PSBREC,U,12)="" ;med log ien inserted below for actual date
|
---|
105 | .S $P(PSBREC,U,13)="" ;med log status inserted below for actual date
|
---|
106 | .S $P(PSBREC,U,14)="" ; admin date inserted below
|
---|
107 | .S $P(PSBREC,U,15)=PSBOIT ; OI Pointer
|
---|
108 | .S $P(PSBREC,U,16)=PSBNJECT ;med route injectable flag
|
---|
109 | .; Variable dosage entered as ####-####?
|
---|
110 | .I $P(PSBREC,U,9)?1.4N1"-"1.4N.E S $P(PSBREC,U,17)=1
|
---|
111 | .E S $P(PSBREC,U,17)=0
|
---|
112 | .S:PSBDOSEF?1"CAP".E!(PSBDOSEF?1"TAB".E)!(PSBDOSEF="PATCH") $P(PSBREC,U,18)=PSBDOSEF ; dosage form
|
---|
113 | .S $P(PSBREC,U,20)=$S((PSBSTUS="X")!(PSBSTUS="N"):"",1:PSBSTUS) ; last action status
|
---|
114 | .S $P(PSBREC,U,21)=PSBOST
|
---|
115 | .S $P(PSBREC,U,22)=PSBOSTS
|
---|
116 | .S $P(PSBREC,U,26)=PSBOSP
|
---|
117 | .S $P(PSBREC,U,27)=$$LASTG^PSBCSUTL(DFN,PSBOIT)
|
---|
118 | .;
|
---|
119 | .; Gather Dispense Drugs
|
---|
120 | .D NOW^%DTC
|
---|
121 | .S (PSBDDS,PSBSOLS,PSBADDS,PSBFLAG)="0"
|
---|
122 | .F Y=0:0 S Y=$O(PSBDDA(Y)) Q:'Y D
|
---|
123 | ..I $P(PSBDDA(Y),U,5)=$P(%,".") S PSBFLAG=1 ;If drug was inactivated
|
---|
124 | ..Q:$P(PSBDDA(Y),U,5)&($P(PSBDDA(Y),U,5)<%) ; Inactive
|
---|
125 | ..S:$P(PSBDDA(Y),U,4)="" $P(PSBDDA(Y),U,4)=1
|
---|
126 | ..S PSBDDS=PSBDDS_U_$P(PSBDDA(Y),U,1,4)
|
---|
127 | ..S $P(PSBDDS,U,1)=PSBDDS+1
|
---|
128 | .;
|
---|
129 | .; On-Call One Time PRN orders
|
---|
130 | .S PSBQRR=0
|
---|
131 | .I "^O^OC^P^"[(U_PSBSCHT_U) D ADD^PSBVDLU1(PSBREC,PSBOTXT,PSBNOW\1,PSBDDS,PSBSOLS,PSBADDS,"UDTAB") Q
|
---|
132 | .;
|
---|
133 | .; Now we deal with only continuous
|
---|
134 | .; process admintimes
|
---|
135 | .; Display an order on the VDL based on the frequency received from IPM **PSB*2.0*3
|
---|
136 | .S (PSBYES,PSBODD,PSBYTF)=0
|
---|
137 | .I PSBSCH="" D ERROR^PSBMLU(PSBONX,PSBOITX,DFN,"No Schedule on this order")
|
---|
138 | .S:$$PSBDCHK1^PSBVT1(PSBSCH) PSBYES=1
|
---|
139 | .I PSBYES,PSBADST="" D ERROR^PSBMLU(PSBONX,PSBOITX,DFN,"Admin times required",PSBSCH) Q
|
---|
140 | .F I=1:1 Q:$P(PSBSCH,"-",I)="" I $P(PSBSCH,"-",I)?2N!($P(PSBSCH,"-",I)?4N) S PSBYES=1,PSBYTF=1
|
---|
141 | .I PSBSCHT="C",PSBYTF="1",PSBADST="" D ERROR^PSBMLU(PSBONX,PSBOITX,DFN,"Admin times required",PSBSCH) Q
|
---|
142 | .S PSBFREQ=$$GETFREQ^PSBVDLU1(DFN,PSBONX)
|
---|
143 | .I PSBFREQ="O" S PSBFREQ=1440
|
---|
144 | .I PSBFREQ="D" S PSBFREQ=""
|
---|
145 | .I 'PSBYES,PSBFREQ<1 D ERROR^PSBMLU(PSBONX,PSBOITX,DFN,"Invalid frequency received from order",PSBSCH) Q
|
---|
146 | .I (PSBADST="")&(+PSBFREQ>0) D ODDSCH^PSBVDLU1("UDTAB") Q ;calculate admin times based on frequency
|
---|
147 | .; No admin times, MAYDAY MAYDAY!!
|
---|
148 | .I +PSBFREQ>0 I (PSBFREQ#1440'=0),(1440#PSBFREQ'=0) S PSBODD=1
|
---|
149 | .I PSBODD,PSBADST'="" D ERROR^PSBMLU(PSBONX,PSBOITX,DFN,"Administration Times on ODD SCHEDULE",PSBSCH) Q
|
---|
150 | .; process admin times against beginning and ending date
|
---|
151 | .; build all orders for both days.
|
---|
152 | .F PSBY=1:1 Q:$P(PSBADST,"-",PSBY)="" D
|
---|
153 | ..;For invalid admin times
|
---|
154 | ..I ($P(PSBADST,"-",PSBY)'?2N)&($P(PSBADST,"-",PSBY)'?4N) D ERROR^PSBMLU(PSBONX,PSBOITX,DFN,"Invalid Admin times",PSBSCH)
|
---|
155 | ..; apply this time to the beginning window date
|
---|
156 | ..S PSB=+(PSBWBEG\1_"."_$P(PSBADST,"-",PSBY))
|
---|
157 | ..D:(PSB'<PSBWBEG)&(PSB'>PSBWEND) ; Make sure it is in the window
|
---|
158 | ...D:(PSB'<PSBOST)&(PSB<PSBOSP) ; Make sure this time is active
|
---|
159 | ....D:$$OKAY^PSBVDLU1(PSBOST,PSB,PSBSCH,PSBONX,PSBOITX,PSBFREQ,PSBOSTS) ; Okay on this date?
|
---|
160 | .....D ADD^PSBVDLU1(PSBREC,PSBOTXT,PSB,PSBDDS,PSBSOLS,PSBADDS,"UDTAB")
|
---|
161 | ..;
|
---|
162 | ..Q:(PSBWBEG\1)=(PSBWEND\1) ; Window only has one day rare but possible
|
---|
163 | ..;
|
---|
164 | ..; apply this time to the ending window date
|
---|
165 | ..S PSB=+(PSBWEND\1_"."_$P(PSBADST,"-",PSBY))
|
---|
166 | ..D:(PSB'<PSBWBEG)&(PSB'>PSBWEND) ; Make sure it is in the window
|
---|
167 | ...D:(PSB'<PSBOST)&(PSB<PSBOSP) ; Make sure this time is active
|
---|
168 | ....D:$$OKAY^PSBVDLU1(PSBOST,PSB,PSBSCH,PSBONX,PSBOITX,PSBFREQ,PSBOSTS) ; Okay on this date?
|
---|
169 | .....D ADD^PSBVDLU1(PSBREC,PSBOTXT,PSB,PSBDDS,PSBSOLS,PSBADDS,"UDTAB")
|
---|
170 | .K PSBSTUS
|
---|
171 | 1 K PSBREC D EN^PSBVDLPA
|
---|
172 | ;add initials of verifying pharmacist/verifying nurse
|
---|
173 | D:PSBTAB="UDTAB" VNURSE^PSBVDLU1("UDTAB")
|
---|
174 | D CLEAN^PSBVT
|
---|
175 | Q
|
---|
176 | ;
|
---|