source: WorldVistAEHR/trunk/r/BAR_CODE_MED_ADMIN-ALPB-PSB/PSBOIV.m@ 1800

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

initial load of WorldVistAEHR

File size: 9.5 KB
Line 
1PSBOIV ;BIRMINGHAM/TEJ-IV BAG STATUS REPORT ;Mar 2004
2 ;;3.0;BAR CODE MED ADMIN;**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 ; File 52.6/436
7 ; File 52.7/437
8 ; File 4/10090
9 ; File 2/10035
10EN ; Entry
11 N PSB1,PSBFUTR
12 K PSBSRTBY,PSBOCRIT,PSBACRIT,NO S PSBCFLG=0
13 S PSBFUTR=$TR(PSBRPT(1),"~","^")
14 I $D(PSBRPT(.2)) I $P(PSBRPT(.2),U,8) S PSBCFLG=1
15 S PSBDTST=+$P(PSBRPT(.1),U,6)+$P(PSBRPT(.1),U,7)
16 S PSBDTSP=+$P(PSBRPT(.1),U,8)+$P(PSBRPT(.1),U,9)
17 S PSBOCRIT="" ; Ord Sttus "A"ctive, "D"C ed, "E"xprd"
18 S:$P(PSBFUTR,U,5) PSBOCRIT=PSBOCRIT_"A"
19 S:$P(PSBFUTR,U,7) PSBOCRIT=PSBOCRIT_"D"
20 S:$P(PSBFUTR,U,8) PSBOCRIT=PSBOCRIT_"E"
21 S PSBACRIT="" ; Actn Sttus "C"ompl, "I"nfusi, "M"issng, "S"tpped, "H"ld, "R"efsd", "N"o Actn
22 S:$P(PSBFUTR,U,12) PSBACRIT=PSBACRIT_"I"
23 S:$P(PSBFUTR,U,13) PSBACRIT=PSBACRIT_"S"
24 S:$P(PSBFUTR,U,14) PSBACRIT=PSBACRIT_"C"
25 S:$P(PSBFUTR,U,15) PSBACRIT=PSBACRIT_"N"
26 S:$P(PSBFUTR,U,16) PSBACRIT=PSBACRIT_"M"
27 S:$P(PSBFUTR,U,17) PSBACRIT=PSBACRIT_"H"
28 S:$P(PSBFUTR,U,18) PSBACRIT=PSBACRIT_"R"
29 D NOW^%DTC S (Y,PSBXNOW)=% D DD^%DT S:PSBDTSP=0 PSBDTSP=Y S PSBDTTM=Y
30 I +PSBDTST=0 S PSBDTST=X S PSBDTST=$$FMADD^XLFDT(PSBDTST,-3)_".0000"
31 S (PSBPGNUM,PSBLNTOT,PSBTOT,PSB1)=""
32 K PSBLIST,PSBLIST2,PSBBGS,PSBNOX
33 S PSBXDFN=$P(PSBRPT(.1),U,2)
34 S PSBLIST(PSBXDFN)=""
35 S PSB1=$O(PSBLIST("")) I +PSB1'=0 K ^TMP("PSJ",$J) D EN^PSJBCMA(PSB1,PSBDTST,PSBDTST)
36 I ^TMP("PSJ",$J,1,0)'=-1 D
37 .S PINX=0 F S PINX=$O(^TMP("PSJ",$J,PINX)) Q:+PINX'>0 D
38 ..S PSB2=$P(^TMP("PSJ",$J,PINX,0),U,3)
39 ..I PSB2["V" D Q
40 ...; flter critri
41 ...D CLEAN^PSBVT,PSJ1^PSBVT(PSB1,PSB2)
42 ...Q:$$IVPTAB^PSBVDLU3(PSBOTYP,PSBIVT,PSBISYR,PSBCHEMT,$G(PSBIVPSH,0))
43 ...Q:PSBOST>PSBDTSP
44 ...I "DE"'[PSBOSTS I PSBOSP'>PSBXNOW S PSBOSTS="E"
45 ...Q:PSBOCRIT'[PSBOSTS ;incl ord stat crit
46 ...Q:(PSBOSP<PSBXNOW)&(PSBOCRIT'["E")&(PSBOSTS'="D")
47 ...S PSBLIST2(PSB2,"OStart")=PSBOST
48 ...S PSBLIST2(PSB2,"OStop")=PSBOSP
49 ...S PSBLIST2(PSB2,"OStatus")=$S((PSBOSTS="D"):"Discontinued",(PSBOSTS="DE"):"Discontinued (Edit)",PSBXNOW>PSBOSP:"Expired",PSBOSTS="A":"Active",PSBOSTS="H":"On Hold",1:PSBOSTS)
50 ...S PSBLIST2(PSB2,"OPI")=PSBOTXT
51 ...M PSBLIST2(PSB2,"ADD")=PSBADA
52 ...M PSBLIST2(PSB2,"SOL")=PSBSOLA
53 ...D EN^PSBPOIV(PSB1,PSB2)
54 ...I +$O(^TMP("PSBAR",$J,""))>0 S X="" F S X=$O(^TMP("PSBAR",$J,X)) Q:+X=0 S PSBBGS(PSB2,X)=$P(^TMP("PSBAR",$J,X),U,2)
55 ...D:PSBACRIT["N"
56 ....S NO=1
57 ....I $D(PSBBGS(PSB2)) S X="" F S X=$O(PSBBGS(PSB2,X)) Q:+X=0 I PSBBGS(PSB2,X)'="" S NO=0 Q
58 ....I $D(^PSB(53.79,"AORDX",PSB1,PSB2)) S NO=0 Q
59 ...I $G(NO,0) I PSBOSTS="A" S PSBNOX(PSB2)="",PSBTOT=PSBTOT+1 Q
60 ...I $D(^PSB(53.79,"AUID",PSB1,PSB2)) M PSBBGS(PSB2)=^PSB(53.79,"AUID",PSB1,PSB2)
61 ...; Get X - "ASSOC BAGS"
62 ...S X="" F S X=$O(PSBBGS(PSB2,X)) Q:+X=0 I $G(PSBBGS(PSB2,X),"")'="" D
63 ....S Y="" F S Y=$O(^PSB(53.79,"AUID",PSB1,Y)) Q:Y="" D Q:Y="DONE"
64 .....I $D(^PSB(53.79,"AUID",PSB1,Y,X)) S PSBBGS(PSB2,X,$O(^PSB(53.79,"AUID",PSB1,Y,X,"")))="" S Y="DONE"
65 ...S X="" F S X=$O(PSBBGS(PSB2,X)) Q:+X=0 I $O(PSBBGS(PSB2,X,""))="" K PSBBGS(PSB2,X)
66 ...S PSB3="" F S PSB3=$O(PSBBGS(PSB2,PSB3)) Q:PSB3="" D
67 ....S PSB4="" F S PSB4=$O(PSBBGS(PSB2,PSB3,PSB4)) Q:+PSB4=0 D
68 .....I ($$GET1^DIQ(53.79,PSB4_",",.06,"I")'>PSBDTST)!($$GET1^DIQ(53.79,PSB4_",",.06,"I")'<PSBDTSP) K PSBBGS(PSB2,PSB3) Q
69 .....I PSBACRIT'[$$GET1^DIQ(53.79,PSB4_",",.09,"I") K PSBBGS(PSB2,PSB3) Q
70 .....S PSBBSTS(PSB2,PSB3,$$GET1^DIQ(53.79,PSB4_",",.09))=$$GET1^DIQ(53.79,PSB4_",",.06,"I"),PSBTOT=PSBTOT+1
71 .....I "SI"[$$GET1^DIQ(53.79,PSB4_",",.09,"I") I PSBXNOW>$$FMADD^XLFDT($$GET1^DIQ(53.79,PSB4_",",.06,"I"),,24) S PSB24HR(PSB2,PSB3)=""
72 .....I PSBCFLG S PSB5=0 F S PSB5=$O(^PSB(53.79,PSB4,.3,PSB5)) Q:+PSB5=0 D
73 ......I $P(^PSB(53.79,PSB4,.3,PSB5,0),U,3)=$$GET1^DIQ(53.79,PSB4_",",.06,"I") S PSBCMNT(PSB2,PSB3)="Comment: "_$P(^PSB(53.79,PSB4,.3,PSB5,0),U)
74 S INX="" F S INX=$O(PSBLIST2(INX)) Q:INX="" I '$D(PSBBGS(INX))&'$D(PSBNOX(INX)) K PSBLIST2(INX)
75 I +PSBTOT=0 K PSBLIST
76 S Y=PSBDTST D DD^%DT S Y1=Y S Y=PSBDTSP D DD^%DT S Y2=Y
77 D CREATHDR
78 D SUBHDR^PSBOIV1
79 D BLDRPT
80 D WRTRPT
81 K PSBSILN,PSBOUTP,PSBLIST2,PSBCMNT,PSBNOX
82 Q
83BLDRPT ; Buld Reprt
84 S (PSB2,PSB3,PSB4)=""
85 S PSBTOPHD=PSBLNTOT
86 I '$D(PSBLIST2) D Q
87 .S PSBOUTP(0,14)="W !!,""<<<< NO DATA TO DISPLAY >>>>"",!!"
88 S PSBTOT1=0
89 K PSBDATA
90 K J S J=1
91 F S PSB2=$O(PSBLIST2(PSB2)) Q:+PSB2=0 D
92 .S PSBORDX="" S PSBORDX=PSB2
93 .S PSBDATA(1)=$$FMTDT^PSBOIV1($E(PSBLIST2(PSB2,"OStart"),1,12))
94 .S PSBDATA(2)=$$FMTDT^PSBOIV1($E(PSBLIST2(PSB2,"OStop"),1,12))
95 .S PSBDATA(3)=PSBLIST2(PSB2,"OStatus")
96 .M PSBDATA(4,"ADD")=PSBLIST2(PSB2,"ADD") I $D(PSBDATA(4,"ADD",1)) S PSBDATA(4)="MED"
97 .M PSBDATA(4,"SOL")=PSBLIST2(PSB2,"SOL") I $D(PSBDATA(4,"SOL",1)) S PSBDATA(4)="MED"
98 .; Bag(s)
99 .I $D(PSBNOX(PSB2)) S PSBFLGD(PSB2," * No Action Taken On Order * ")=""
100 .I '$D(PSBNOX(PSB2))!(PSBACRIT["N") F S PSB3=$O(PSBBGS(PSB2,PSB3)) Q:+PSB3=0 D
101 ..S PSBDATA(5,PSB3)=PSB3
102 ..S PSBDATA(6,PSB3)=$O(PSBBSTS(PSB2,PSB3,""))
103 ..I $D(PSB24HR(PSB2,PSB3)) S PSBDATA(7,PSB3)=">24h"
104 ..I '$D(PSBNOX(PSB2)) S PSBDATA(8,PSB3)=$$FMTDT^PSBOIV1($E(PSBBSTS(PSB2,PSB3,PSBDATA(6,PSB3)),1,12))
105 ..E S PSBDATA(8,PSB3)="No Action On Order"
106 .K PSBOPDAT S PSBOPDAT(1)=$G(PSBLIST2(PSB2,"OPI"),"")
107 .S PSBTOT1=PSBTOT1+1
108 .K PSBRPLN,PSBSILN
109 .D BUILDLN,SIOPI^PSBOCM(.PSBOPDAT,PSBTAB8,"Other Print Info:")
110 .I $D(PSBRPLN) S PSBMORE=$O(PSBRPLN(""),-1)+4 I $D(PSBSILN) S PSBMORE=PSBMORE+$O(PSBSILN(""),-1)
111 .S (PSB1,PSB)="" I $D(PSBFLGD(PSB2)) F S PSB=$O(PSBFLGD(PSB2,PSB)) Q:PSB="" I ($P(PSB,":")'="STAT") S PSB1=$G(PSB1,"")_PSB
112 .S PSBCNT=PSBTOT1_" ("_PSB2_") "_PSB1,$E(PSBCNT,IOM)="|"
113 .S PSBOUTP($$PGTOT,PSBLNTOT)="W !,"""_PSBCNT_""""
114 .F N=$O(PSBRPLN("")):1:$O(PSBRPLN(""),-1) D
115 ..S PSB1X=0 S PSB1X=(($L(PSBRPLN(N),"""")-1)\2) I ($E(PSBRPLN(N),(PSBTAB8)+PSB1X)']" ") S $E(PSBRPLN(N),(PSBTAB8)+PSB1X)="|"
116 ..S PSBOUTP($$PGTOT,PSBLNTOT)="W !,"""_PSBRPLN(N)_""""
117 .K PSBRPLN,PSBDATA
118 .S I="" F S I=$O(PSBSILN(I)) Q:+I=0 D
119 ..S PSB1X=0 S PSB1X=(($L(PSBSILN(I),"""")-1)\2)
120 ..I ($E(PSBSILN(I),(PSBTAB8)+PSB1X)']" ") S $E(PSBSILN(I),(PSBTAB8)+PSB1X)="|"
121 ..S PSBOUTP($$PGTOT,PSBLNTOT)="W !,"""_PSBSILN(I)_""""
122 .S PSBOUTP($$PGTOT(2),PSBLNTOT)="W !,$TR($J("""",PSBTAB8),"" "",""-""),!"
123 Q
124BUILDLN ; Constr recs
125 K J,LN S J(0)="" F PSBFLD=1:1:3 I $G(PSBDATA(PSBFLD))]"" S J=1 D FORMDAT^PSBOIV1(PSBFLD) S J=1
126 F X=1:1 Q:'$D(PSBDATA(4,"ADD",X)) D
127 .S PSBDATA(4)=$P(PSBDATA(4,"ADD",X),U,3)
128 .D FORMDAT^PSBOIV1(4)
129 .S J=$O(J(""),-1)+1
130 F X=1:1 Q:'$D(PSBDATA(4,"SOL",X)) D
131 .S PSBDATA(4)=$P(PSBDATA(4,"SOL",X),U,3)
132 .D FORMDAT^PSBOIV1(4)
133 .S J=$O(J(""),-1)+1
134 F PSBFLD=5:1:8 I $D(PSBDATA(PSBFLD)) K J S J=1 D
135 .S X="" F S X=$O(PSBDATA(PSBFLD,X)) Q:+X=0 D
136 ..S PSBDATA(PSBFLD)=PSBDATA(PSBFLD,X)
137 ..I PSBFLD=5 S LN(X,J)=""
138 ..D:PSBFLD'=8 FORMDAT^PSBOIV1(PSBFLD)
139 ..S J=$O(J(""),-1)+1
140 ..I (PSBCFLG&(PSBFLD=5)),($D(PSBCMNT(PSB2,X))) D WRAPPER^PSBOIV1(PSBTAB4+1,(PSBTAB8-PSBTAB4)-1,PSBCMNT(PSB2,X)),WRAPPER^PSBOIV1(PSBTAB4+1,PSBTAB8-PSBTAB4," ")
141 .I PSBFLD=5 F J=1:1:$O(J(""),-1) S PREVLN(J)=$G(PSBRPLN(J),"")
142 .I PSBFLD'=5 I $D(PREVLN) S X="" F S X=$O(LN(X)) Q:X="" S J=$O(LN(X,"")) D:$D(PSBDATA(PSBFLD,X))
143 ..S $E(PREVLN(J),@("PSBTAB"_(PSBFLD-1))+1,@("PSBTAB"_(PSBFLD)))=PSBDATA(PSBFLD,X)
144 I $D(PREVLN) F J=1:1:$O(PREVLN(""),-1) S PSBRPLN(J)=PREVLN(J)
145 K PREVLN,LN
146 Q
147WRTRPT ;
148 I $O(PSBOUTP(""),-1)<1 D Q
149 .X PSBOUTP($O(PSBOUTP(""),-1),14)
150 .D FTR
151 S PSBPGNUM=1
152 S PSBZ="" F S PSBZ=$O(PSBOUTP(PSBZ)) Q:PSBZ="" D
153 .I PSBPGNUM'=PSBZ D FTR S PSBPGNUM=PSBZ D HDR,SUBHDR^PSBOIV1
154 .S PSB2="" F S PSB2=$O(PSBOUTP(PSBZ,PSB2)) Q:PSB2="" D
155 ..X PSBOUTP(PSBZ,PSB2)
156 D FTR
157 Q
158HDR ;
159 W:$Y>1 @IOF
160 W:$X>1 !
161 S PSBRPNM="BCMA IV BAG STATUS REPORT"
162 S LN=0
163 D:$P(PSBRPT(.1),U,1)="P"
164 .S LN=LN+1,PSBHDR(LN)=PSBRPNM_" for "_$$FMTE^XLFDT($P(PSBRPT(.1),U,6)+$P(PSBRPT(.1),U,7))_" to "_$$FMTE^XLFDT($P(PSBRPT(.1),U,8)+$P(PSBRPT(.1),U,9))
165 .S LN=LN+1,PSBHDR(LN)="Order Status(es): --"
166 .F Y=5,7,8 I $P(PSBFUTR,U,Y) S $P(PSBHDR(LN),": ",2)=$P(PSBHDR(LN),": ",2)_$S(PSBHDR(2)["--":"",1:"/ ")_$P("^^^^Active^^DC'd^Expired^^^^^^^^^^",U,Y)_" " S PSBHDR(LN)=$TR(PSBHDR(LN),"-","")
167 .S LN=LN+1,PSBHDR(LN)="Bag Status(es): --"
168 .F Y=12:1:18 I $P(PSBFUTR,U,Y) S $P(PSBHDR(LN),": ",2)=$P(PSBHDR(LN),": ",2)_$S(PSBHDR(LN)["--":"",1:"/ ")_$P("^^^^^^^^^^^Infusing^Stopped^Completed^No Action Taken^Missing Dose^Held^Refused",U,Y)_" " S PSBHDR(LN)=$TR(PSBHDR(LN),"-","")
169 .I PSBCFLG S LN=LN+1,PSBHDR(LN)="Include Comments/Reasons"
170 .D PT^PSBOHDR(PSBXDFN,.PSBHDR) W !
171 Q
172FTR ;
173 I (IOSL<100) F Q:$Y>(IOSL-5) W !,?(IOM-1),"|"
174 S PSBPG="Page: "_PSBPGNUM_" of "_$S($O(PSBOUTP(""),-1)=0:1,1:$O(PSBOUTP(""),-1))
175 S PSBPGRM=PSBTAB8-($L(PSBPG))
176 D PTFTR^PSBOHDR()
177 W !,PSBRPNM," ",?(PSBPGRM-($L(PSBDTTM)+3)),PSBDTTM_" "_PSBPG
178 Q
179PGTOT(X) ;mnt PAGE Number
180 I (PSBLNTOT+PSBMORE)>(IOSL) S PSBPGNUM=PSBPGNUM+1,PSBLNTOT=PSBTOPHD S PSBMORE=$S(PSBMORE>(IOSL-(PSBTOPHD)):(IOSL-(PSBTOPHD)),1:PSBMORE)
181 I $G(X,1) S PSBLNTOT=PSBLNTOT+$G(X,1),PSBMORE=PSBMORE-$G(X,1)
182 Q PSBPGNUM
183CREATHDR ;
184 K PSBHD1,PSBHD2
185 I IOM'<132 S PSBMORE=4,PSBHD1=$P($T(HD132A),";",2),PSBHD2=$P($T(HD132B),";",2),PSBBLANK=$P($T(H132BLK),";",2)
186 E S PSBHD1="THIS REPORT SUPPORTS >131 CHAR./LINE PRINT FORMATS ONLY" K PSBLIST2 Q
187 ; reset tabs
188 S PSBTAB0=1 F PSBI=0:1:($L(PSBHD1,"|")-1) S:PSBI>0 @("PSBTAB"_PSBI)=($F(PSBHD1,"|",@("PSBTAB"_(PSBI-1))+1))-1
189 S PSBPGNUM=1
190 D HDR
191 Q
192HD132A ; Order | Order | Order | Medication | Bag UID | Bag | | Action Date/Time |
193 Q
194HD132B ; Start Date | Stop Date | Status | | | Status | | |
195 Q
196H132BLK ;;
197 Q
Note: See TracBrowser for help on using the repository browser.