source: FOIAVistA/trunk/r/BAR_CODE_MED_ADMIN-ALPB-PSB/PSBOCP.m@ 1742

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

initial load of FOIAVistA 6/30/08 version

File size: 9.1 KB
Line 
1PSBOCP ;BIRMINGHAM/TEJ-COVERSHEET PRN 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 ; Entry Point
8 N PSBX1X,RESULTS,RESULT,PSBFUTR
9 S PSBFUTR=$TR(PSBRPT(1),"~","^")
10 S (PSBOCRIT,PSBXFLG,PSBCFLG)="" ; Order Status search criteria - "A"ctive, "D"C ed, "E"xpired"
11 S:$P(PSBFUTR,U,7) PSBOCRIT=PSBOCRIT_"D" S:$P(PSBFUTR,U,8) PSBOCRIT=PSBOCRIT_"E" S:$P(PSBFUTR,U,5) PSBOCRIT=PSBOCRIT_"A"
12 S:$P(PSBFUTR,U,4) PSBOCRIT=PSBOCRIT_"F"
13 S:$P(PSBFUTR,U,11) PSBXFLG=1
14 I $D(PSBRPT(.2)) I $P(PSBRPT(.2),U,8) S PSBCFLG=1
15 K PSBSRTBY,PSBCMT,PSBADM,PSBDATA,PSBOUTP,PSBLGD
16 S PSBSORT=1
17 D NOW^%DTC S (Y,PSBNOWX)=% D DD^%DT S PSBDTTM=Y
18 D GETPAR^PSBPAR("ALL","PSB ADMIN BEFORE")
19 S PSBB4=0 S:RESULTS(0)>0 PSBB4=+RESULTS(0)
20 D GETPAR^PSBPAR("ALL","PSB ADMIN AFTER")
21 S PSBAFT=0 S:RESULTS(0)>0 PSBAFT=+RESULTS(0)
22 K ^XTMP("PSBO",$J,"PSBLIST")
23 S (PSBPGNUM,PSBLNTOT,PSBTOT,PSBX1X)=""
24 K PSBLIST,PSBLIST2
25 S PSBXDFN=$P(PSBRPT(.1),U,2)
26 S PSBLIST(PSBXDFN)=""
27 S (PSBX1X,PSBTOT)=0
28 F S PSBX1X=$O(PSBLIST(PSBX1X)) Q:+PSBX1X=0 D
29 .D RPC^PSBCSUTL(.PSBAREA,PSBX1X)
30 .M PSBDATA=@PSBAREA
31 .S PSBX2X=1
32 .S (PSBLIST2("ACTIVE"),PSBLIST2("FUTURE"),PSBLIST2("EXPIRED/DC'd"),PSBLIST2(" * ERROR * "))=0
33 .F S PSBX2X=$O(PSBDATA(PSBX2X)) Q:+PSBX2X=0 D
34 ..S PSBDATA=PSBDATA(PSBX2X)
35 ..I ($P(PSBDATA,U)="ORD") I $P(PSBDATA,U,6)'="P" F S PSBX2X=$O(PSBDATA(PSBX2X)) S PSBDATA=PSBDATA(PSBX2X) Q:$P(PSBDATA,U)="END"
36 ..I ($P(PSBDATA,U)="ORD") K PSBORDN D Q
37 ...K PSBDRUGN
38 ...S PSBSCHTY="P"
39 ...S PSBORDN=$P(PSBDATA,U,3)
40 ...S PSBTB=$P(PSBDATA,U,29) S PSBTB=$S(PSBTB=1:"UD",PSBTB=2:"IVPB",PSBTB=3:"IV",1:" * ERROR * ")
41 ...S PSBTB(PSBORDN,PSBTB)=""
42 ...S PSBSTS1=$P(PSBDATA,U,23)
43 ...S PSBSTS=$S((PSBSTS1="A")&(($P(PSBDATA,U,27)>PSBNOWX)):"Active",PSBSTS1="H":"Hold",PSBSTS1="D":"Discontinued",PSBSTS1="DE":"Discontinued (Edit)",(PSBSTS1="E")!($P(PSBDATA,U,27)'>PSBNOWX):"Expired",1:" * ERROR * ")
44 ...S PSBSTS(PSBORDN,PSBSTS)=""
45 ...S V=$$FMADD^XLFDT(PSBNOWX,,,PSBB4)
46 ...S PSBSTSX=$S($P(PSBDATA,U,27)'>PSBNOWX:"EXPIRED/DC'd",$P(PSBDATA,U,22)'>V:"ACTIVE",V:"FUTURE",1:" * ERROR * ")
47 ...S PSBLIST2(PSBSTSX,$P(PSBDATA,U,9),PSBORDN)="" S PSBLIST2(PSBSTSX)=PSBLIST2(PSBSTSX)+1
48 ...S:PSBOCRIT[$E(PSBSTSX,1) PSBTOT=PSBTOT+1
49 ...S PSBSCHTY(PSBORDN,PSBSCHTY)=""
50 ...S PSBDOSR=$P(PSBDATA,U,10)_", "_$P(PSBDATA,U,11)
51 ...S PSBDOSR=$TR($E(PSBDOSR,1)," ")_$E(PSBDOSR,2,999)
52 ...S PSBDOSR(PSBORDN,PSBDOSR)=""
53 ...S PSBLSTG=$P(PSBDATA,U,28)
54 ...I PSBLSTG]"" S PSBLSTG(PSBORDN,$$FMTDT^PSBOCE1($E(PSBLSTG,1,12)))=""
55 ...S PSBLSTX=$S(PSBLSTG]"":$$LSTX(PSBLSTG,PSBNOWX),1:" ")
56 ...S PSBLSTX(PSBORDN,PSBLSTX)=""
57 ...; ** SPECIAL INSTRUCTIONS **
58 ...S PSBX2X=PSBX2X+1
59 ...S PSBSI=$P(PSBDATA(PSBX2X),U,2)
60 ...I PSBSI]" " S PSBSI(PSBORDN,PSBSI)=""
61 ...S PSBOSTDT=$P(PSBDATA,U,22)
62 ...S PSBOSTDT(PSBORDN,PSBOSTDT)=""
63 ...S PSBOSPDT=$P(PSBDATA,U,27)
64 ...S PSBOSPDT(PSBORDN,PSBOSPDT)=""
65 ..Q:'$D(PSBORDN)
66 ..I "^DD^ADD^SOL"[(U_$P(PSBDATA(PSBX2X),U)) D Q
67 ...F I=PSBX2X:1 S PSBDATA1=PSBDATA(I) D Q:$D(PSBOMDR(PSBORDN))
68 ....I "^DD^ADD^SOL"[(U_$P(PSBDATA1,U)) S PSBX2X=I S PSBDRUGN=$G(PSBDRUGN,"")_$P(PSBDATA1,U,3)_", " Q
69 ....S $E(PSBDRUGN,$L(PSBDRUGN)-1)="" S PSBDRUGN(PSBORDN,$E(PSBDRUGN,1,250))=PSBDRUGN
70 ....S PSBOMDR(PSBORDN,$E((PSBDRUGN_"; "_PSBDOSR),1,250))=PSBDRUGN_"; "_PSBDOSR
71 ..I $P(PSBDATA,U)="END" Q
72 ..Q:'$D(PSBORDN)
73 ..I $P(PSBDATA(PSBX2X),U)="ORF" D Q
74 ...S PSBDATA=PSBDATA(PSBX2X)
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)="ADM")&($P(PSBDATA,U,4)]"") D Q
78 ...S PSBXID=$P(PSBDATA,U,6)_U_$P(PSBDATA,U,4),PSBADM(PSBORDN,(-1*($P(PSBDATA,U,6))),PSBXID)=PSBDATA
79 ...I $O(PSBSCHTY(PSBORDN,""))="P" S PSBPRNR(PSBORDN,$P(PSBDATA,U,4))=$P(PSBDATA,U,9)
80 ...I $P(PSBDATA,U,3)]"" S PSBBID(PSBORDN,$P(PSBDATA,U,4))=$P(PSBDATA,U,3)
81 ...S:PSBXFLG PSBLGD(PSBORDN,"X","INITIALS",$P(PSBDATA,U,8))=""
82 ...I $P(PSBDATA(PSBX2X+1),U)="CMT" S PSBX2X=PSBX2X+1 F PSBX3X=PSBX2X:1 S PSBDATA=PSBDATA(PSBX3X) Q:($P(PSBDATA,U)'="CMT") D
83 ....S PSBX2X=PSBX3X
84 ....I $P(PSBDATA,U,3)]"" S PSBPRNEF(PSBORDN,$P(PSBXID,U,2))=$P(PSBDATA,U,3)
85 ....I PSBCFLG I $P(PSBDATA,U,2)'="" S PSBLGD(PSBORDN,"C","INITIALS",$P(PSBDATA,U,4))="",PSBCMT(PSBORDN,$P(PSBXID,U,2),(-1*$P(PSBDATA,U,6)))=PSBDATA
86 I +PSBTOT=0 K PSBLIST,^XTMP("PSBO",$J,"PSBLIST")
87 D CREATHDR^PSBOCP1
88 D SUBHDR^PSBOCE
89 D BLDRPT
90 D WRTRPT^PSBOCP1
91 Q
92BLDRPT ; Buld REPORT DATA
93 K PSBL2ULN
94 S PSBTOPHD=PSBLNTOT-2
95 I '$D(PSBLIST2) D Q
96 .S PSBOUTP(0,PSBLNTOT)="W !!,""<<<< NO ORDERS TO DISPLAY >>>>"",!!"
97 S PSBMORE=5 F PSBX1X="ACTIVE","FUTURE","EXPIRED/DC'd"," * ERROR * " D
98 .I PSBX1X'=" * ERROR * " S PSBSUM=PSBX1X_" ["_PSBLIST2(PSBX1X)_$S(PSBLIST2(PSBX1X)=1:" Order",1:" Orders")_"]" S PSBOUTP($$PGTOT,PSBLNTOT)="W !!,"""_PSBSUM_""""
99 .Q:PSBLIST2(PSBX1X)=0
100 .Q:PSBOCRIT'[$E(PSBX1X,1)
101 .S:$L(PSBSUM)>$G(PSBL2ULN,0) PSBL2ULN=$L(PSBSUM)
102 .S PSBOUTP($$PGTOT(2),PSBLNTOT)="W !,$TR($J("""",PSBL2ULN),"" "",""=""),!"
103 .S PSBOUTP($$PGTOT,PSBLNTOT)="W !"
104 .K PSBDATA
105 .S X0="",PSBTOT1=0
106 .F S X0=$O(PSBLIST2(PSBX1X,X0)) Q:X0="" S PSBX2X="" F S PSBX2X=$O(PSBLIST2(PSBX1X,X0,PSBX2X)) Q:PSBX2X="" D
107 ..M PSBLGD("INITIALS")=PSBLGD(PSBX2X,"X","INITIALS") M PSBLGD("INITIALS")=PSBLGD(PSBX2X,"C","INITIALS")
108 ..S PSBDATA(1,1)=$O(PSBTB(PSBX2X,""))
109 ..S PSBDATA(1,2)=$O(PSBSTS(PSBX2X,""))
110 ..S PSBDATA(1,3)=$O(PSBSCHTY(PSBX2X,""))
111 ..S Y0=$O(PSBOMDR(PSBX2X,"")) I Y0]"" S PSBDATA(1,4)="("_X0_")",PSBDATA(1,4,0)=PSBOMDR(PSBX2X,Y0)
112 ..S PSBDATA(1,5)=$O(PSBLSTG(PSBX2X,""))
113 ..S PSBDATA(1,6)=$O(PSBLSTX(PSBX2X,""))
114 ..S PSBDATA(1,7)=$$FMTDT^PSBOCE1($O(PSBOSTDT(PSBX2X,"")))
115 ..S PSBDATA(1,8)=$$FMTDT^PSBOCE1($E($O(PSBOSPDT(PSBX2X,"")),1,12))
116 ..S PSBSIDAT(1)=$O(PSBSI(PSBX2X,""))
117 ..S PSBTOT1=PSBTOT1+1
118 ..K PSBDATA(2),PSBDATA(3),PSBSILN
119 ..D BUILDLN,SIOPI^PSBOCM(.PSBSIDAT,PSBTAB8,$S(PSBX2X["V":"Other Print Info:",1:""))
120 ..I $D(PSBRPLN) S PSBMORE=$O(PSBRPLN(""),-1)+6 I $D(PSBSILN) S PSBMORE=PSBMORE+$O(PSBSILN(""),-1)
121 ..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
122 ..S PSBCNT=PSBTOT1_" "_$G(PSB1,"")
123 ..S PSBOUTP($$PGTOT,PSBLNTOT)="W """_PSBCNT_""""
124 ..S I="" F S I=$O(PSBRPLN(I)) Q:+I=0 D
125 ...S PSBOUTP($$PGTOT,PSBLNTOT)="W !,"""_PSBRPLN(I)_""""
126 ..S I="" F S I=$O(PSBSILN(I)) Q:+I=0 D
127 ...S PSBOUTP($$PGTOT,PSBLNTOT)="W !,"""_PSBSILN(I)_""""
128 ..S PSBOUTP($$PGTOT(2),PSBLNTOT)="W !,$TR($J("""",PSBTAB8),"" "",""-""),!"
129 ..K PSBRPLN,PSBDATA
130 D:+PSBTOT>0 LGD^PSBOCM
131 Q
132BUILDLN ; Constr recs
133 K J S J(0)="" F PSBFLD=1:1:8 S J=1 D FORMDAT(PSBFLD) S J($O(PSBRPLN(""),-1))=""
134 ; Write administration info...
135 Q:'PSBXFLG
136 S J=($O(J(""),-1)+1),PSBRPLN(J)=PSBBLANK,J(J)="",J=J+1
137 S (N,Y)=""
138 F S Y=$O(PSBADM(PSBX2X,Y)) Q:Y']"" D
139 .F S N=$O(PSBADM(PSBX2X,Y,N)) Q:N']"" D
140 ..I $D(PSBBID(PSBX2X,$P(N,U,2))) S PSBDATA(2,0)="BAG ID: "_PSBBID(PSBX2X,$P(N,U,2))
141 ..S $E(PSBDATA(2,0),25)="ACTION BY: "_$P(PSBADM(PSBX2X,Y,N),U,7)_" "_$$FMTDT^PSBOCE1($E($P(PSBADM(PSBX2X,Y,N),U,6),1,12))
142 ..S X=$P(PSBADM(PSBX2X,Y,N),U,5) S $E(PSBDATA(2,0),56)="ACTION: "_$S(X="G":"GIVEN",X="R":"REFUSED",X="RM":"REMOVED",X="H":"HELD",X="S":"STOPPED",X="I":"INFUSING",X="C":"COMPLETED",X="M":"MISSING DOSE",X=" ":"*UNKNOWN*",1:" ")
143 ..I $D(PSBPRNR(PSBX2X)) S $E(PSBDATA(2,0),72)="PRN REASON: "_PSBPRNR(PSBX2X,$P(N,U,2))
144 ..I $G(PSBDATA(2,0))]" " D WRAPPER(1,132-1,PSBDATA(2,0)) K PSBDATA(2) S J=J+1
145 ..I $D(PSBPRNEF(PSBX2X,$P(N,U,2))) S PSBDATA(2,0)="PRN EFFECTIVENESS: "_PSBPRNEF(PSBX2X,$P(N,U,2))
146 ..I $G(PSBDATA(2,0))]" " D WRAPPER(30,132-30,PSBDATA(2,0)) K PSBDATA(2) S J=J+1
147 ..I ('PSBCFLG)!('$D(PSBCMT(PSBX2X,$P(N,U,2)))) S PSBRPLN(J)=PSBBLANK,J(J)="",J=J+1 Q
148 ..S X="" F S X=$O(PSBCMT(PSBX2X,$P(N,U,2),X)) Q:X']"" D
149 ...S PSBDATA(2,0)="COMMENT BY: "_$S($P(PSBCMT(PSBX2X,$P(N,U,2),X),U,5)]"":$P(PSBCMT(PSBX2X,$P(N,U,2),X),U,5)_" "_$$FMTDT^PSBOCE1($E($P(PSBCMT(PSBX2X,$P(N,U,2),X),U,6),1,12)),1:" n/a ")
150 ...S PSBDATA(2,0)=PSBDATA(2,0)_" COMMENT: "_$S($P(PSBCMT(PSBX2X,$P(N,U,2),X),U,2)]"":$P(PSBCMT(PSBX2X,$P(N,U,2),X),U,2),1:" ")
151 ...I $G(PSBDATA(2,0))]" " D WRAPPER(30,132-30,PSBDATA(2,0)) K PSBDATA(2) S J=J+1
152 ..S PSBRPLN(J)=PSBBLANK,J(J)="",J=J+1
153 Q
154FORMDAT(FLD) ;
155 K PSBVAL
156 Q:'$D(PSBDATA(1,FLD))
157 S PSBVAL=PSBDATA(1,FLD)
158 D WRAPPER(@("PSBTAB"_(FLD-1))+1,((@("PSBTAB"_(FLD))-(@("PSBTAB"_(FLD-1))+1))),PSBVAL)
159 I FLD=4 S J=$O(J(""),-1)+1,PSBVAL=PSBDATA(1,4,0) D WRAPPER(@("PSBTAB"_(FLD-1))+1,((@("PSBTAB"_(FLD))-(@("PSBTAB"_(FLD-1))+1))),PSBVAL)
160 Q
161PGTOT(X) ;mnt PAGE Number
162 I (PSBLNTOT+PSBMORE)>(IOSL) D PGC^PSBOCE1
163 I $G(X,1) S PSBLNTOT=PSBLNTOT+$G(X,1),PSBMORE=PSBMORE-$G(X,1)
164 Q PSBPGNUM
165WRAPPER(X,Y,Z) ; Text WRAP
166 N PSB
167 I ($L(Z)>0),$F(Z,"""")>1 F Q:$F(Z,"""")'>1 S Z=$TR(Z,"""","^")
168 F Q:'$L(Z) D
169 .I $L(Z)<Y S $E(PSBRPLN(J),X)=Z S Z="" Q
170 .F PSB=Y:-1:0 Q:$E(Z,PSB)=" "
171 .S:PSB<1 PSB=Y
172 .S $E(PSBRPLN(J),X)=$E(Z,1,PSB)
173 .I $L(PSBRPLN(J),"^")>1 F X=1:1:$L(PSBRPLN(J),"^")-1 S $P(PSBRPLN(J),"^",X)=$P(PSBRPLN(J),"^",X)_""""
174 .S PSBRPLN(J)=$TR(PSBRPLN(J),"^","""")
175 .S Z=$E(Z,PSB+1,250),J=J+1,J(J)=""
176 Q ""
177LSTX(P,O) ;
178 S DT=$$FMDIFF^XLFDT(O,P,2)
179 I ((DT\60)<1) Q "0d 0h 1m"
180 S D=(DT\(60*60*24)) S DT=DT-(D*(60*60*24))
181 S H=(DT\(60*60)) S DT=DT-(H*(60*60))
182 S M=((DT+30)\(60)) S DT=DT-(M*(60))
183 Q D_"d "_H_"h "_M_"m"
Note: See TracBrowser for help on using the repository browser.