source: WorldVistAEHR/trunk/r/BAR_CODE_MED_ADMIN-ALPB-PSB/PSBOMM.m@ 922

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

initial load of WorldVistAEHR

File size: 9.4 KB
Line 
1PSBOMM ;BIRMINGHAM/EFC-MISSED MEDS ;Mar 2004
2 ;;3.0;BAR CODE MED ADMIN;**26,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 ; ^DPT/10035
7 ; EN^PSJBCMA/2828
8 ; EN^PSJBCMA2/2830
9EN ;
10 N PSBSTRT,PSBSTOP,DFN,PSBODATE,PSBFLAG,PSBCNT,PSBEDIT,PSBFUTR
11 S PSBSTART=$P(PSBRPT(.1),U,6)+$P(PSBRPT(.1),U,7),PSBSTOP=$P(PSBRPT(.1),U,8)+$P(PSBRPT(.1),U,9)
12 D DEFLT^PSBOMM2
13 K PSBOCRIT,PSBACRIT,PSBS
14 S PSBOCRIT="^A^H"
15 S:$P(PSBFUTR,U,8) PSBOCRIT=PSBOCRIT_"^D^DE" S:$P(PSBFUTR,U,7) PSBOCRIT=PSBOCRIT_"^E"
16 S PSBACRIT="MG"
17 S:$P(PSBFUTR,U,17) PSBACRIT=PSBACRIT_"H" S:$P(PSBFUTR,U,18) PSBACRIT=PSBACRIT_"R"
18 S PSBINCC=0 S:$P(PSBRPT(.2),U,8) PSBINCC=1
19 K ^TMP("PSJ",$J),^TMP("PSB",$J),^TMP("PSB1",$J)
20 S PSBSTRT=$P(PSBRPT(.1),U,6)+$P(PSBRPT(.1),U,7)-.0000001
21 F DFN=0:0 S DFN=$O(^TMP("PSBO",$J,DFN)) Q:'DFN D EN1
22 D PRINT
23 K ^TMP("PSJ",$J),^TMP("PSB",$J),^TMP("PSBO",$J),PSBS
24 Q
25EN1 ;
26 N PSBGBL,PSBHDR,PSBX,PSBDFN,PSBDT,PSBEVDT,PSBH
27 K ^TMP("PSJ",$J) S PSBEVDT=PSBSTRT
28 D EN^PSJBCMA(DFN,PSBSTRT)
29 Q:^TMP("PSJ",$J,1,0)=-1
30 S PSBX=""
31 F S PSBX=$O(^TMP("PSJ",$J,PSBX)) Q:PSBX="" D
32 .Q:^TMP("PSJ",$J,PSBX,0)=-1
33 .D NOW^%DTC
34 .D CLEAN^PSBVT
35 .D PSJ^PSBVT(PSBX)
36 .Q:PSBIVT="A"
37 .Q:PSBIVT="H"
38 .I PSBIVT["S",PSBISYR'=1 Q
39 .I PSBIVT["C",PSBCHEMT'="P",PSBISYR'=1 Q
40 .I PSBIVT["C",PSBCHEMT="A" Q
41 .Q:PSBONX["P"
42 .Q:PSBOSP<PSBSTART
43 .I %>PSBOSP,PSBOSTS'="D",PSBOSTS'="DE",PSBOSTS'="H" S PSBOSTS="E"
44 .I PSBSCHT="C" D Q
45 ..S (PSBYES,PSBODD)=0
46 ..S PSBDOW="SU^MO^TU^WE^TH^FR^SA" F I=1:1:7 I $P(PSBDOW,"^",I)=$E(PSBSCH,1,2) S PSBYES=1
47 ..I PSBYES,PSBADST="" Q
48 ..F I=1:1 Q:$P(PSBSCH,"-",I)="" I $P(PSBSCH,"-",I)?2N!($P(PSBSCH,"-",I)?4N) S PSBYES=1
49 ..S PSBFREQ=$$GETFREQ^PSBVDLU1(DFN,PSBONX)
50 ..I PSBFREQ="O" S PSBYES=1,PSBFREQ=1440
51 ..I 'PSBYES,PSBADST="",PSBFREQ<1 Q
52 ..I (PSBFREQ#1440'=0),(1440#PSBFREQ'=0) S PSBODD=1
53 ..I PSBODD,PSBADST'="" Q
54 ..Q:PSBOCRIT'[PSBOSTS
55 ..Q:PSBNGF
56 ..Q:PSBOSTS="N"
57 ..Q:PSBSM
58 ..S PSBS(DFN,PSBONX,$S(PSBOSTS="A":"Active",PSBOSTS="H":"On Hold",PSBOSTS="D":"DC'd",PSBOSTS="DE":"DC'd (Edit)",PSBOSTS="E":"Expired",1:" *Unknown* "))=""
59 ..S PSBSTXP(PSBONX,$$DTFMT^PSBOMM2(PSBOSP))=""
60 ..S PSBCADM=0
61 ..I PSBADST="" D Q:$G(PSBADST)="" S PSBCADM=1
62 ...S X=PSBOST D H^%DTC S X1=((%H*24)*60)+(%T/60)
63 ...S X=PSBSTRT,X3=0 D H^%DTC S X2=((%H*24)*60)+(%T/60)
64 ...I X2'<X1 S X3=X2-X1 S PSBOST=$$FMADD^XLFDT(PSBSTRT,,,(-1*(X3#PSBFREQ)))
65 ...K PSBADST S PSBOST2=PSBOST,PSBDT2=PSBSTRT
66 ...F XZ=0:1 S PSBADST(XZ,PSBDT2)=$$GETADMIN^PSBVDLU1(DFN,PSBONX,PSBOST2,PSBFREQ,PSBDT2) D Q:PSBDT2>PSBSTOP
67 ....I ($L(PSBADST(XZ,PSBDT2),"-")>$L($G(PSBADST),"-"))!($G(PSBADST)="") S PSBADST=PSBADST(XZ,PSBDT2)
68 ....S Z=PSBDT2\1,J=$P(PSBADST(XZ,PSBDT2),"-",($L(PSBADST(XZ,PSBDT2),"-"))) S:J]"" PSBOST2=Z_"."_J
69 ....S PSBDT2=($$FMADD^XLFDT(Z,1))+.2400
70 ....S PSBDT2=$S($G(FLG):(PSBSTOP\1)+.2401,PSBDT2>PSBOSP:PSBOSP,1:PSBDT2) K FLG I PSBDT2=PSBOSP S FLG=1
71 ..S Z=PSBADST I Z]"" K ^TMP("PSB",$J,"GETADMIN") S ^TMP("PSB",$J,"GETADMIN",0)=Z
72 ..F Y=1:1:$L(Z,"-") D
73 ...Q:($P(Z,"-",Y)'?2N)&($P(Z,"-",Y)'?4N)
74 ..K PSBOACTL,^TMP("PSB1",$J) D EN^PSJBCMA2(DFN,PSBONX,1) I ^TMP("PSJ2",$J,0)'=1 M PSBOACTL=^TMP("PSJ2",$J) K ^TMP("PSJ2",$J)
75 ..I 'PSBODD F XX=0:1 Q:'$D(^TMP("PSB",$J,"GETADMIN",XX)) S (PSBADST,Z)=$G(^TMP("PSB",$J,"GETADMIN",XX)) D
76 ...D MISSED^PSBOMM2(Z,.PSBEDIT,PSBSTRT)
77 ..I PSBODD F XX=0:1 Q:'$D(PSBADST(XX)) S XXX=$O(PSBADST(XX,"")) S (PSBADST,Z)=PSBADST(XX,XXX) D
78 ...I Z]"" D MISSED^PSBOMM2(Z,.PSBEDIT,XXX)
79 .K PSBHDDT,PSBUNHD,^TMP("PSB1",$J)
80 .I PSBSCHT="O" D Q
81 ..Q:PSBOSTS="N"
82 ..Q:PSBNGF
83 ..Q:PSBSM
84 ..Q:(PSBOSP=PSBOST)&(PSBOCRIT'["E")
85 ..Q:PSBOST'<PSBSTOP
86 ..S PSBDT="*** ONE-TIME ***"
87 ..S (PSBSTXP(PSBONX,$$DTFMT^PSBOMM2(PSBOSP)),PSBSTXT(PSBONX,$$DTFMT^PSBOMM2(PSBOST)))=""
88 ..S (PSBG,X,Y,PSBXSTS)="" K PSBEXST
89 ..F S X=$O(^PSB(53.79,"AOIP",DFN,PSBOIT,X),-1) Q:'X D
90 ...F S Y=$O(^PSB(53.79,"AOIP",DFN,PSBOIT,X,Y),-1) Q:'Y D
91 ....S PSBXSTS=$P(^PSB(53.79,Y,0),U,9)
92 ....I $P(^PSB(53.79,Y,.1),U)=PSBONX,PSBXSTS'="N",PSBXSTS'="M" S PSBG=1,PSBG(PSBONX,Y)="",(X,Y)=0
93 ..I PSBG D PARTG1^PSBOMM2($O(PSBG(PSBONX,"")))
94 ..D NOW^%DTC
95 ..Q:(PSBOCRIT'[PSBOSTS)
96 ..S PSBS(DFN,PSBONX,$S(PSBOSTS="A":"Active",PSBOSTS="H":"On Hold",PSBOSTS="D":"DC'd",PSBOSTS="DE":"DC'd (Edit)",PSBOSTS="E":"Expired",1:" * ERROR * "))=""
97 ..D:'PSBG!(PSBACRIT[$G(PSBXSTS,1))
98 ...S VAR=""
99 ...K ^TMP("PSJ2",$J),^TMP("PSB1",$J),PSBOACTL D EN^PSJBCMA2(DFN,PSBONX,1) I ^TMP("PSJ2",$J,0)'=1 D
100 ....M PSBOACTL=^TMP("PSJ2",$J)
101 ....D UDONE^PSBOMM2
102 ....I PSBFLAG=1 S VAR="(On Hold) "_$$DTFMT^PSBOMM2(PSBHDDT)
103 ....I PSBFLAG=2 S VAR="(On Hold) "_$$DTFMT^PSBOMM2(PSBHDDT)_" (Off Hold) "_$$DTFMT^PSBOMM2(PSBUNHD)
104 ...I '$G(PSBEXST,0)!(PSBXSTS="M") S $P(^TMP("PSB",$J,DFN,"*** ONE-TIME ***",PSBOITX,PSBONX),U,1,4)=VAR
105 ...I $G(PSBEXST,0) D
106 ....S VAR1=$G(^TMP("PSB",$J,DFN,"*** ONE-TIME ***","* "_PSBOITX,PSBONX)) I VAR1]"" S $P(VAR1,U,1,4)=VAR_VAR1
107 ...K PSBHDDT,PSBUNHD,^TMP("PSB1",$J),PSBCNT
108 K PSBOACTL
109 Q
110PRINT ;
111 N PSBHDR,PSBDT,PSBOITX,PSBONX,DFN
112 K PSBNPG
113 S Y=$S($P(PSBRPT(.1),U,8)]"":$P(PSBRPT(.1),U,8),1:$P(PSBRPT(.1),U,6))
114 D:$P(PSBRPT(.1),U,1)="P"
115 .S PSBHDR(1)="MISSED MEDICATIONS REPORT for "_$$FMTE^XLFDT($P(PSBRPT(.1),U,6)+$P(PSBRPT(.1),U,7))_" to "_$$FMTE^XLFDT(Y+$P(PSBRPT(.1),U,9))
116 .S PSBHDR(2)="Order Status(es): --"
117 .F Y=5,8,7 I $P(PSBFUTR,U,Y) S $P(PSBHDR(2),": ",2)=$P(PSBHDR(2),": ",2)_$S(PSBHDR(2)["--":"",1:"/ ")_$P("^^^^Active^^Expired^DC'd^^^^^^^^^^",U,Y)_" " S PSBHDR(2)=$TR(PSBHDR(2),"-","")
118 .S PSBHDR(3)="Admin Status(es): --"
119 .F Y=16,17,18 I $P(PSBFUTR,U,Y) S $P(PSBHDR(3),": ",2)=$P(PSBHDR(3),": ",2)_$S(PSBHDR(3)["--":"",1:"/ ")_$P("^^^^^^^^^^^^^^^Missing Dose^Held^Refused",U,Y)_" " S PSBHDR(3)=$TR(PSBHDR(3),"-","")
120 .I PSBINCC S PSBHDR(4)="Include Comments/Reasons"
121 .S DFN=$P(PSBRPT(.1),U,2)
122 .W $$PTHDR()
123 .I $G(PSBEDIT) W !?7,"*Administration Times have been edited*"
124 .I $O(^TMP("PSB",$J,DFN,""))="" W !,"No Missed Medications Found",$$PTFTR^PSBOHDR() Q
125 .S PSBDT=""
126 .F S PSBDT=$O(^TMP("PSB",$J,DFN,PSBDT)) Q:PSBDT="" D
127 ..W !
128 ..S PSBOITX=""
129 ..F S PSBOITX=$O(^TMP("PSB",$J,DFN,PSBDT,PSBOITX)) Q:PSBOITX="" D
130 ...S PSBONX=""
131 ...F S PSBONX=$O(^TMP("PSB",$J,DFN,PSBDT,PSBOITX,PSBONX)) Q:PSBONX="" D
132 ....K VAR1,VAR2,VAR3,SP I $Y>(IOSL-9) W $$PTFTR^PSBOHDR(),$$PTHDR()
133 ....S VAR1=$G(^TMP("PSB",$J,DFN,PSBDT,PSBOITX,PSBONX))
134 ....S VAR2=$G(^TMP("PSB",$J,DFN,PSBDT,PSBOITX,PSBONX,"X"))
135 ....S VAR3=$G(^TMP("PSB",$J,DFN,PSBDT,PSBOITX,PSBONX,.3))
136 ....I PSBDT["ONE-TIME" D Q
137 .....W !
138 .....W !,$O(PSBS(DFN,PSBONX,"")),?15,PSBDT,?43,PSBOITX,!
139 .....I VAR1]"" W ?43,VAR1 S SP=1
140 .....I VAR2]"" W:$G(SP) ! W ?43,VAR2
141 .....I VAR3]"" W !,$$WRAP^PSBO(43,80,VAR3)
142 .....W !,"Start Date/Time: ",?18,$O(PSBSTXT(PSBONX,""))
143 .....W !,"Stop Date/Time: ",?18,$O(PSBSTXP(PSBONX,""))
144 ....W !,$O(PSBS(DFN,PSBONX,"")),?15,$S(+PSBDT>0:$$DTFMT^PSBOMM2(PSBDT),1:PSBDT),?43,PSBOITX,?95,$O(PSBSTXP(PSBONX,"")),!
145 ....I VAR1]"" W ?43,VAR1 S SP=1
146 ....I VAR2]"" W:$G(SP) ! W ?43,VAR2
147 ....I VAR3]"" W !,$$WRAP^PSBO(43,80,VAR3)
148 .W $$PTFTR^PSBOHDR()
149 .Q
150 D:$P(PSBRPT(.1),U,1)="W"
151 .S PSBHDR(1)="MISSED MEDICATIONS REPORT for "_$$FMTE^XLFDT($P(PSBRPT(.1),U,6)+$P(PSBRPT(.1),U,7))_" to "_$$FMTE^XLFDT(Y+$P(PSBRPT(.1),U,9))
152 .S PSBHDR(2)="Order Status(es): --"
153 .F Y=5,7,8 I $P(PSBFUTR,U,Y) S $P(PSBHDR(2),": ",2)=$P(PSBHDR(2),": ",2)_$S(PSBHDR(2)["--":"",1:"/ ")_$P("^^^^Active^^Expired^DC'd^^^^^^^^^^",U,Y)_" " S PSBHDR(2)=$TR(PSBHDR(2),"-","")
154 .S PSBHDR(3)="Admin Status(es): --"
155 .F Y=16,17,18 I $P(PSBFUTR,U,Y) S $P(PSBHDR(3),": ",2)=$P(PSBHDR(3),": ",2)_$S(PSBHDR(3)["--":"",1:"/ ")_$P("^^^^^^^^^^^^^^^Missing Dose^Held^Refused",U,Y)_" " S PSBHDR(3)=$TR(PSBHDR(3),"-","")
156 .I PSBINCC S PSBHDR(4)="Include Comments/Reasons"
157 .S PSBWARD=$P(PSBRPT(.1),U,3)
158 .W $$WRDHDR()
159 .I '$O(^TMP("PSB",$J,0)) W !,"No Missed Medications Found" Q
160 .S PSBSORT=$P(PSBRPT(.1),U,5)
161 .F DFN=0:0 S DFN=$O(^TMP("PSB",$J,DFN)) Q:'DFN D
162 ..S PSBDX=$S(PSBSORT="P":$P(^DPT(DFN,0),U),1:$G(^DPT(DFN,.1))_" "_$G(^(.101)))
163 ..S:PSBDX="" PSBDX=$P(^DPT(DFN,0),U)
164 ..S ^TMP("PSB",$J,"B",PSBDX,DFN)=""
165 .S PSBDX=""
166 .F S PSBDX=$O(^TMP("PSB",$J,"B",PSBDX)) Q:PSBDX="" D
167 ..F DFN=0:0 S DFN=$O(^TMP("PSB",$J,"B",PSBDX,DFN)) Q:'DFN D
168 ...W !
169 ...S PSBDT=""
170 ...F S PSBDT=$O(^TMP("PSB",$J,DFN,PSBDT)) Q:PSBDT="" D
171 ....W !
172 ....W:PSBDT["ONE-TIME" !
173 ....S PSBOITX=""
174 ....F S PSBOITX=$O(^TMP("PSB",$J,DFN,PSBDT,PSBOITX)) Q:PSBOITX="" D
175 .....S PSBONX=""
176 .....F S PSBONX=$O(^TMP("PSB",$J,DFN,PSBDT,PSBOITX,PSBONX)) Q:PSBONX="" D
177 ......K VAR1,VAR2,VAR3,SP I $Y>(IOSL-9) W $$WRDHDR()
178 ......W !,$O(PSBS(DFN,PSBONX,"")),?15,$G(^DPT(DFN,.101),"**"),?35,$P(^DPT(DFN,0),U)," (",$E($P(^(0),U,9),6,9),")"
179 ......S VAR1=$G(^TMP("PSB",$J,DFN,PSBDT,PSBOITX,PSBONX))
180 ......S VAR2=$G(^TMP("PSB",$J,DFN,PSBDT,PSBOITX,PSBONX,"X"))
181 ......S VAR3=$G(^TMP("PSB",$J,DFN,PSBDT,PSBOITX,PSBONX,.3))
182 ......I PSBDT["ONE-TIME" D Q
183 .......W !,PSBDT,?30,PSBOITX S SP=1
184 .......I VAR1]"" W !,?30,$P(VAR1,U,1) S SP=1
185 .......I VAR2]"" W:$G(SP) ! W ?30,VAR2
186 .......I VAR3]"" W !,$$WRAP^PSBO(30,95,VAR3)
187 .......W !,"Start Date/Time: ",?18,$O(PSBSTXT(PSBONX,""))
188 .......W !,"Stop Date/Time: ",?18,$O(PSBSTXP(PSBONX,""))
189 .......W !
190 ......W ?67,$S(+PSBDT>0:$$DTFMT^PSBOMM2(PSBDT),1:PSBDT),?85,PSBOITX S SP=1
191 ......I VAR1]"" W !,?50,VAR1 S SP=1
192 ......I VAR2]"" W:$G(SP) ! W ?50,VAR2
193 ......I VAR3]"" W !,$$WRAP^PSBO(50,75,VAR3)
194 Q
195WRDHDR() ;
196 D WARD^PSBOHDR(PSBWRD,.PSBHDR)
197 W !,"Order Status",?15,"Room-Bed",?35,"Patient",?67,"Admin Date/Time",?85,"Medication"
198 D LN1^PSBOMM2
199 Q ""
200PTHDR() ;
201 D PT^PSBOHDR(DFN,.PSBHDR)
202 W !,"Order Status",?15,"Administration Date/Time",?43,"Medication",?95,"Order Stop Date"
203 D LN1^PSBOMM2
204 Q ""
Note: See TracBrowser for help on using the repository browser.