source: WorldVistAEHR/trunk/r/BAR_CODE_MED_ADMIN-ALPB-PSB/PSBOCI.m@ 1211

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

initial load of WorldVistAEHR

File size: 9.3 KB
Line 
1PSBOCI ;BIRMINGHAM/TEJ-COVERSHEET IV OVERVIEW 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 4/10090
7EN ;
8 N PSBX1X,RESULTS,RESULT,PSBFUTR
9 S PSBFUTR=$TR(PSBRPT(1),"~","^")
10 S (PSBOCRIT,PSBXFLG,PSBCFLG,PSBBGX)="" ; srch crit - "A"ctive,"D"C ed,"E"xpired"
11 S PSBOCRIT="DEA"
12 S:$P(PSBFUTR,U,11) PSBXFLG=1
13 S:$P(PSBFUTR,U,12) PSBBGX=PSBBGX_"I"
14 S:$P(PSBFUTR,U,13) PSBBGX=PSBBGX_"S"
15 S:$P(PSBFUTR,U,14) PSBBGX=PSBBGX_"A"
16 I $D(PSBRPT(.2)) I $P(PSBRPT(.2),U,8) S PSBCFLG=1
17 K PSBSRTBY,PSBCMT,PSBADM,PSBDATA,PSBOUTP,PSBLGD
18 S PSBSORT=1
19 D NOW^%DTC S (Y,PSBNOWX)=% D DD^%DT S PSBDTTM=Y
20 D GETPAR^PSBPAR("ALL","PSB ADMIN BEFORE")
21 S PSBB4=0 S:RESULTS(0)>0 PSBB4=+RESULTS(0)
22 D GETPAR^PSBPAR("ALL","PSB ADMIN AFTER")
23 S PSBAFT=0 S:RESULTS(0)>0 PSBAFT=+RESULTS(0)
24 K ^XTMP("PSBO",$J,"PSBLIST")
25 S (PSBPGNUM,PSBLNTOT)=""
26 K PSBLIST,PSBLIST2
27 S PSBXDFN=$P(PSBRPT(.1),U,2)
28 S PSBLIST(PSBXDFN)=""
29 S (PSBX1X,PSBTOT)=0
30 F S PSBX1X=$O(PSBLIST(PSBX1X)) Q:+PSBX1X=0 D
31 .D RPC^PSBCSUTL(.PSBAREA,PSBX1X)
32 .M PSBDATA=@PSBAREA
33 .S PSBX2X=1
34 .S (PSBLIST2("All Other"),PSBLIST2("Infusing"),PSBLIST2("Stopped"),PSBLIST2(" * NO * "))=0
35 .K PSBBSO
36 .F S PSBX2X=$O(PSBDATA(PSBX2X)) Q:+PSBX2X=0 D
37 ..S PSBDATA=PSBDATA(PSBX2X)
38 ..I $P(PSBDATA,U)="ORD" K PSBORDN,PSBDRUGN D Q
39 ...S PSBEND=0
40 ...S PSBTB=$P(PSBDATA,U,29) S PSBTB=$S(PSBTB=1:"UD",PSBTB=2:"IVPB",PSBTB=3:"IV",1:" * ERROR * ")
41 ...I (PSBTB'="IV") F PSBX2X=PSBX2X:1 D Q:PSBEND>0
42 ....S PSBEND=0 I $P(PSBDATA(PSBX2X),U)="END" S PSBEND=PSBX2X
43 ...Q:PSBEND>0
44 ...S PSBSTS1=$P(PSBDATA,U,23)
45 ...S PSBSTS=$S((PSBSTS1="A")&(($P(PSBDATA,U,27)>PSBNOWX)):"Active",PSBSTS1="H":"On Hold",PSBSTS1="D":"Discontinued",PSBSTS1="DE":"Discontinued (Edit)",(PSBSTS1="E")!($P(PSBDATA,U,27)'>PSBNOWX):"Expired",1:" * ERROR * ")
46 ...S V=$$FMADD^XLFDT(PSBNOWX,,,PSBB4)
47 ...S PSBSTSX=$S($P(PSBDATA,U,27)'>PSBNOWX:"EXPIRED/DC'd",$P(PSBDATA,U,22)'>V:"ACTIVE",V:"FUTURE",1:" * ERROR * ")
48 ...I PSBSTSX=" * ERROR * " F PSBX2X=PSBX2X:1 D Q:PSBEND>0
49 ....S PSBEND=0 I $P(PSBDATA(PSBX2X),U)="END" S PSBEND=PSBX2X
50 ...Q:PSBEND>0
51 ...S PSBORDN=$P(PSBDATA,U,3)
52 ...S PSBORITX=$P(PSBDATA,U,9)
53 ...S PSBSTS(PSBORDN,PSBSTS)=""
54 ...S PSBOSTDT=$P(PSBDATA,U,22)
55 ...S PSBOSTDT(PSBORDN,PSBOSTDT)=""
56 ...S PSBOSPDT=$P(PSBDATA,U,27)
57 ...S PSBOSPDT(PSBORDN,PSBOSPDT)=""
58 ...S PSBDOSR=$P(PSBDATA,U,10)_", "_$P(PSBDATA,U,11)
59 ...S PSBDOSR=$TR($E(PSBDOSR,1)," ")_$E(PSBDOSR,2,999)
60 ...S PSBDOSR(PSBORDN,PSBDOSR)=""
61 ...S X2="A",PSBLIST2("All Other",PSBORITX,PSBORDN,"*NA*")=" "
62 ...S PSBBSO(PSBORDN)="" S:$G(PSBSTSX)="ACTIVE" PSBBSO(PSBORDN)="AVAILABLE"
63 ..Q:'$D(PSBORDN)
64 ..I $P(PSBDATA,U)="ORC" D Q
65 ...S PSBSI=$P(PSBDATA(PSBX2X),U,2)
66 ...I PSBSI]" " S PSBSI(PSBORDN,PSBSI)=""
67 ..Q:'$D(PSBORDN)
68 ..I "^DD^ADD^SOL"[(U_$P(PSBDATA(PSBX2X),U)) D Q
69 ...F I=PSBX2X:1 S PSBDATA1=PSBDATA(I) D Q:$D(PSBOMDR(PSBORDN))
70 ....I "^DD^ADD^SOL"[(U_$P(PSBDATA1,U)) S PSBX2X=I S PSBDRUGN=$G(PSBDRUGN,"")_$P(PSBDATA1,U,3)_", " Q
71 ....S $E(PSBDRUGN,$L(PSBDRUGN)-1)="" S PSBDRUGN(PSBORDN,$E(PSBDRUGN,1,250))=PSBDRUGN
72 ....S PSBOMDR(PSBORDN,$E((PSBDRUGN_"; "_PSBDOSR),1,250))=PSBDRUGN_"; "_PSBDOSR
73 ..Q:'$D(PSBORDN)
74 ..I $P(PSBDATA,U)="ORF" D Q
75 ...S:$P(PSBDATA,U,2)]"" PSBFLGD(PSBORDN,$P(PSBDATA,U,3)_" - "_$P(PSBDATA,U,4))=""
76 ..Q:'$D(PSBORDN)
77 ..I $P(PSBDATA,U)="ID" D Q
78 ...F PSBX3X=PSBX2X:1 S PSBDATA=PSBDATA(PSBX3X) Q:($P(PSBDATA,U)'="ID") D
79 ....S PSBX2X=PSBX3X
80 ....K X2
81 ....S X2="A",PSBLIST2("All Other",PSBORITX,PSBORDN,$P(PSBDATA,U,2))=PSBBSO(PSBORDN) I $D(PSBLIST2("All Other",PSBORITX,PSBORDN,"*NA*")) K PSBLIST2("All Other",PSBORITX,PSBORDN,"*NA*")
82 ..Q:'$D(PSBORDN)
83 ..I ($P(PSBDATA,U)="ADM")&($P(PSBDATA,U,4)]"") D Q
84 ...I $P(PSBDATA,U,3)]"" D
85 ....K X2
86 ....S PSBBID(PSBORDN,$P(PSBDATA,U,3))=""
87 ....I $P(^PSB(53.79,$P(PSBDATA,U,4),0),U,9)="I" S X2="I",PSBLIST2("Infusing")=PSBLIST2("Infusing")+1,PSBLIST2("Infusing",PSBORITX,PSBORDN,$P(PSBDATA,U,3))="INFUSING"
88 ....I $P(^PSB(53.79,$P(PSBDATA,U,4),0),U,9)="S" S X2="S",PSBLIST2("Stopped")=PSBLIST2("Stopped")+1,PSBLIST2("Stopped",PSBORITX,PSBORDN,$P(PSBDATA,U,3))="STOPPED"
89 ....I PSBBGX[$G(X2,"A") S:PSBXFLG PSBLGD(PSBORDN,"INITIALS",$P(PSBDATA,U,8))=""
90 ....S:'$D(X2) X2="A",PSBLIST2("All Other",PSBORITX,PSBORDN,$P(PSBDATA,U,3))=$$GET1^DIQ(53.79,$P(PSBDATA,U,4)_",","ACTION STATUS")
91 ....I $D(PSBLIST2("All Other",PSBORITX,PSBORDN,"*NA*")) K PSBLIST2("All Other",PSBORITX,PSBORDN,"*NA*")
92 ..Q:'$D(PSBORDN)
93 ..I $P(PSBDATA,U,1)="END" Q
94 F I="All Other","Infusing","Stopped" S X="",PSBLIST2(I)=0 F S X=$O(PSBLIST2(I,X)) Q:X="" S XI="" F S XI=$O(PSBLIST2(I,X,XI),-1) Q:XI="" D
95 .S PSBX2X="" F S PSBX2X=$O(PSBLIST2(I,X,XI,PSBX2X),-1) Q:PSBX2X="" S PSBLIST2(I)=PSBLIST2(I)+1 I (PSBBGX[$E(I,1)) S PSBTOT=PSBTOT+1
96 D CREATHDR
97 D SUBHDR
98 D BLDRPT
99 D WRTRPT
100 Q
101BLDRPT ; Bld RPT
102 K PSBL2ULN
103 S PSBTOPHD=PSBLNTOT-2
104 I '$D(PSBLIST2) D Q
105 .S PSBOUTP(0,PSBLNTOT)="W !!,""<<<< NO ORDERS TO DISPLAY >>>>"",!!"
106 S PSBMORE=5 F PSBX1X="Infusing","Stopped","All Other" D
107 .I PSBX1X'=" * ERROR * " S PSBSUM=PSBX1X_" ["_PSBLIST2(PSBX1X)_"]" S PSBOUTP($$PGTOT,PSBLNTOT)="W !!,"""_PSBSUM_""""
108 .Q:PSBLIST2(PSBX1X)=0
109 .Q:PSBBGX'[$E(PSBX1X,1)
110 .S:$L(PSBSUM)>$G(PSBL2ULN,0) PSBL2ULN=$L(PSBSUM)
111 .S PSBOUTP($$PGTOT(2),PSBLNTOT)="W !,$TR($J("""",PSBL2ULN),"" "",""=""),!"
112 .S PSBOUTP($$PGTOT,PSBLNTOT)="W !"
113 .K PSBDATA
114 .S X0="",PSBTOT1=0
115 .F S X0=$O(PSBLIST2(PSBX1X,X0)) Q:X0="" S PSBX2X="" F S PSBX2X=$O(PSBLIST2(PSBX1X,X0,PSBX2X)) Q:PSBX2X="" S XI="" F S XI=$O(PSBLIST2(PSBX1X,X0,PSBX2X,XI)) Q:XI="" D
116 ..K PSBDATA(1)
117 ..S PSBDATA(1,1)=XI
118 ..S PSBDATA(1,2)=$O(PSBSTS(PSBX2X,""))
119 ..S PSBDATA(1,3)=PSBLIST2(PSBX1X,X0,PSBX2X,XI)
120 ..S Y0=$O(PSBOMDR(PSBX2X,"")) I Y0]"" S PSBDATA(1,4)="("_X0_")",PSBDATA(1,4,0)=PSBOMDR(PSBX2X,Y0)
121 ..I "IS"[$E(PSBDATA(1,3),1) S (PSBCHG,PSBDATA(1,5))="",PSBORLST(0)=PSBX2X D RPC^PSBCHKIV(.PSBCHG,PSBXDFN,.PSBORLST)
122 ..I $D(PSBCHG(0)) I PSBCHG(0)>0 I ($P(PSBCHG(1),U)=PSBX2X)!($P(PSBCHG(1),U,5)=PSBX2X) F X2=0:1 Q:PSBCHG(X2)="END" I $P(PSBCHG(X2),U)="CD" S PSBDATA(1,5)="Changed Order" Q
123 ..S PSBDATA(1,6)=$$FMTDT^PSBOCE1($O(PSBOSTDT(PSBX2X,"")))
124 ..S PSBDATA(1,7)=$$FMTDT^PSBOCE1($E($O(PSBOSPDT(PSBX2X,"")),1,12))
125 ..S PSBSIDAT(1)=$O(PSBSI(PSBX2X,""))
126 ..S PSBTOT1=PSBTOT1+1
127 ..K PSBDATA(2),PSBSILN
128 ..D BUILDLN^PSBOCI1,SIOPI^PSBOCM(.PSBSIDAT,PSBTAB7,"Other Print Info:")
129 ..I $D(PSBRPLN) S PSBMORE=$O(PSBRPLN(""),-1)+6 I $D(PSBSILN) S PSBMORE=PSBMORE+$O(PSBSILN(""),-1)
130 ..K PSB1 I $D(PSBFLGD(PSBX2X)) S PSB="" F S PSB=$O(PSBFLGD(PSBX2X,PSB)) Q:PSB="" I ($P(PSB,":")'="NOX")&($P(PSB,":")'="STAT") S PSB1=$G(PSB1,"")_PSB
131 ..S PSBCNT=PSBTOT1_" "_$G(PSB1,"")
132 ..S PSBOUTP($$PGTOT,PSBLNTOT)="W """_PSBCNT_""""
133 ..S I="" F S I=$O(PSBRPLN(I)) Q:+I=0 D
134 ...S PSBOUTP($$PGTOT,PSBLNTOT)="W !,"""_PSBRPLN(I)_""""
135 ..S I="" F S I=$O(PSBSILN(I)) Q:+I=0 D
136 ...S PSBOUTP($$PGTOT,PSBLNTOT)="W !,"""_PSBSILN(I)_""""
137 ..S PSBOUTP($$PGTOT(2),PSBLNTOT)="W !,$TR($J("""",PSBTAB7),"" "",""-""),!"
138 ..K PSBRPLN,PSBDATA,PSBSILN
139 K PSBNO S PSBNO=1 D:+PSBTOT>0 LGD^PSBOCM K PSBNO
140 Q
141WRTRPT ; writ
142 I $O(PSBOUTP(""),-1)<1 D Q
143 .X PSBOUTP($O(PSBOUTP(""),-1),14)
144 .D PTFTR^PSBOCI1
145 S PSBPGNUM=1
146 S PSBZ="" F S PSBZ=$O(PSBOUTP(PSBZ)) Q:PSBZ="" D
147 .I PSBPGNUM'=PSBZ D PTFTR^PSBOCI1 S PSBPGNUM=PSBZ D HDR,SUBHDR
148 .S PSBX2X="" F S PSBX2X=$O(PSBOUTP(PSBZ,PSBX2X)) Q:PSBX2X="" D
149 ..X PSBOUTP(PSBZ,PSBX2X)
150 D PTFTR^PSBOCI1
151 K ^XTMP("PSBO",$J,"PSBLIST"),PSBOUTP
152 Q
153HDR ; Hder
154 W:$Y>1 @IOF
155 W:$X>1 !
156 S PSBRPNM="BCMA COVERSHEET IV OVERVIEW REPORT"
157 D:$P(PSBRPT(.1),U,1)="P"
158 .S PSBHDR(0)=PSBRPNM
159 .S PSBHDR(1)="Order Type(s): --"
160 .F Y=12,13,18 I $P(PSBFUTR,U,Y) S $P(PSBHDR(1),": ",2)=$P(PSBHDR(1),": ",2)_$S(PSBHDR(1)["--":"",1:"/ ")_$P("^^^^^^^^^^^Infusing Bags^Stopped Bags^^^^^All Others",U,Y)_" " S PSBHDR(1)=$TR(PSBHDR(1),"-","")
161 .I $P(PSBFUTR,U,11) S PSBHDR(2)="Include Action(s)"_$S(PSBCFLG:" & Comments/Reasons",1:"")
162 .D PT^PSBOHDR(PSBXDFN,.PSBHDR)
163 Q
164SUBHDR ;
165 N PSBAL S PSBAL=$O(PSBHDR("ALERGY",""),-1) S PSBAL=$S((PSBAL/12)>(PSBAL\12):(PSBAL\12)+1,1:(PSBAL\12))
166 N PSBRE S PSBRE=$O(PSBHDR("REAC",""),-1) S PSBRE=$S((PSBRE/12)>(PSBRE\12):(PSBRE\12)+1,1:(PSBRE\12))
167 S PSBLNTOT=$O(PSBHDR(""),-1)+9+PSBAL+PSBRE+1
168 I $G(PSBPGNUM,0)=1 W !,?(PSBTAB7-($L("Total Items reported: "_+PSBTOT))),"Total Items reported: "_+PSBTOT,! S PSBLNTOT=PSBLNTOT+2
169 W !,$TR($J("",PSBTAB7)," ","_") S PSBLNTOT=PSBLNTOT+1
170 W !,$G(PSBHD1,"") S PSBLNTOT=PSBLNTOT+1
171 W !,$G(PSBHD2,"") S PSBLNTOT=PSBLNTOT+1
172 W !,$TR($J("",PSBTAB7)," ","="),! S PSBLNTOT=PSBLNTOT+2
173 I $D(NOTE(PSBPGNUM)) W NOTE(PSBPGNUM),!! S PSBLNTOT=PSBLNTOT+2
174 Q
175PGTOT(X) ;PG Nmbr
176 I (PSBLNTOT+PSBMORE)>(IOSL) D PGC^PSBOCE1
177 I $G(X,1) S PSBLNTOT=PSBLNTOT+$G(X,1),PSBMORE=PSBMORE-$G(X,1)
178 Q PSBPGNUM
179CREATHDR ;
180 K PSBHD1,PSBHD2
181 I IOM'<132 S PSBHD1=$P($T(HD132A),"~",2),PSBHD2=$P($T(HD132B),";",2),PSBBLANK=$P($T(C132BLK),";",2)
182 E S PSBHD1="THIS REPORT SUPPORTS >131 CHAR./LINE PRINT FORMATS ONLY" K PSBLIST2 Q
183 ; tabs
184 S PSBTAB0=1 F PSBI=0:1:($L(PSBHD1,"|")-1) S:PSBI>0 @("PSBTAB"_PSBI)=($F(PSBHD1,"|",@("PSBTAB"_(PSBI-1))+1))-1
185 S PSBPGNUM=1
186 D HDR
187 Q
188HD132A ;~ Bag ID | Order | Bag | Medication; Infusion Rate, Route | Bag Info | Order Start | Order Stop |
189 Q
190HD132B ; | Status | Status | | | Date | Date |
191 Q
192C132BLK ;; | | | | | | |
193 Q
Note: See TracBrowser for help on using the repository browser.