source: WorldVistAEHR/trunk/r/OUTPATIENT_PHARMACY-PSO-APSP-HUIP/PSOLLL1.m@ 1270

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

initial load of WorldVistAEHR

File size: 9.3 KB
Line 
1PSOLLL1 ;BIR/BHW - LASER LABELS ;10/24/2002
2 ;;7.0;OUTPATIENT PHARMACY;**120,141,135,162,161,233,200,264**;DEC 1997;Build 19
3 ;
4 ;Reference to ^PSDRUG supported by DBIA 221
5 ;Reference ^VA(200,D0,"PS" supported by DBIA 224
6 ;External reference to ^PS(55 supported by DBIA 2228
7 ;
8ST I $P($G(^PSRX(RX,3)),"^",3) S PSOPROV=+$P(^(0),"^",4),PSOPROV=$S($G(RXP):+$P($G(RXP),"^",17),$G(RXF):+$P($G(^PSRX(RX,1,RXF,0)),"^",17),1:PSOPROV) S:'$G(PSOPROV) PSOPROV=+$P(^PSRX(RX,0),"^",4) D
9 . I +$P($G(^VA(200,PSOPROV,"PS")),"^",7) S:'$P($G(PHYS),"/",2) PHYS=$G(PHYS)_"/"_+$P($G(^PSRX(RX,3)),"^",3)
10 S $P(ULN,"_",34)="",PSOTRAIL=1
11 S (Y,X1)=EXPDT X ^DD("DD") S EXPDT=Y,Y=$P(^PSRX(RX,0),"^",13) X ^DD("DD") S ISD=Y,X2=DT D ^%DTC S DIFF=X
12 S Y=DATE X ^DD("DD") S DATE=Y
13 S TECH="("_$S($P($G(^PSRX(+$G(RX),"OR1")),"^",5):$P($G(^PSRX(+$G(RX),"OR1")),"^",5),1:$P(RXY,"^",16))_"/"_$S($G(VRPH)&($P(PSOPAR,"^",32)):VRPH,1:" ")_")"
14 S PSZIP=$P(PS,"^",5),PSOHZIP=$S(PSZIP["-":PSZIP,1:$E(PSZIP,1,5)_$S($E(PSZIP,6,9)]"":"-"_$E(PSZIP,6,9),1:""))
15L1 I $G(PSOIO("BLH"))]"" X PSOIO("BLH")
16 I 'SIGF,'SIGM,'PMIM K PSOSTLK,ZTKDRUG I $L($T(PSOSTALK^PSOTALK1)) D PSOSTALK^PSOTALK1 D S PSOSTLK=1 ; PRINT ONE SCRIPTALK LABEL IF APPLICABLE
17 .D 6^VADPT,PID^VADPT6 S SSNPN=$G(VA("BID"))
18 S T="VAMC "_$P(PS,"^",7)_", "_STATE_" "_$G(PSOHZIP) S:SIGF!($G(FILLCONT)) T=" " D PRINT(T)
19 S T=$P(PS2,"^",2)_" "_TECH_" Ph: "_$P(PS,"^",3)_"-"_$P(PS,"^",4) S:SIGF!($G(FILLCONT)) T=" " D PRINT(T)
20 S PSDU=$P($G(^PSDRUG($P($G(^PSRX(RX,0)),"^",6),660)),"^",8)
21 I $G(PSOIO("BLB"))]"" X PSOIO("BLB")
22 S XFONT=$E(PSOFONT,2,99)
23 S T="Rx# "_RXN_" " S:SIGF!($G(FILLCONT)) T=" " D PRINT(T,1)
24 D STRT^PSOLLU1("RX#",T,.L) S PSOY=PSOY-PSOYI,OPSOX=PSOX,PSOX=L(XFONT)*300+PSOX
25 S DR=$G(SIGF("DR"))
26 S T=" "_DATE_" "_$S('SIGF:"Fill "_(RXF+1)_" of "_(1+$P(RXY,"^",9)),1:"(label continued)") S:SIGF!($G(FILLCONT)) T=" " D PRINT(T)
27 S PSOX=OPSOX,T=PNM S:SIGF!($G(FILLCONT)) T=" " I T'=" " D PRINT(T,1)
28 I DR>1 S PSOX=OPSOX,T="Rx# "_RXN_" (label continued)" D PRINT(T)
29 D STRT^PSOLLU1("SIG",T,.L)
30 S OPSOX=PSOX,PSOX=L(XFONT)*300+PSOX,PSOY=PSOY-PSOYI,T=" "_$G(SSNPN) S:SIGF!($G(FILLCONT)) T=" " D PRINT(T)
31 S PSOX=OPSOX,LENGTH=0,PTEXT="",SIGF=0,XFONT=$E(PSOFONT,2,99)
32 N DP,TEXTP,TEXTL,MORE
33 I 'SIGM,'$G(FILLCONT) D COUNTSG^PSOLLLW
34 S DR=SIGF("DR")
35 I DR>1,'$D(NSGY(DR,4)) D
36 .F I=4:-1:1 Q:$D(NSGY(DR,I)) S T=" " D PRINT(T) ; BOTTOM-JUSTIFY CONTINUED BOTTLE SIG JUST ABOVE 'DISCARD' LINE
37 F I=1:1 Q:'$D(NSGY(DR,I)) S TEXT=NSGY(DR,I) D PRINT(TEXT)
38 I I>4,$D(NSGY(DR,5)) S SIGF=1,SIGF("DR")=DR+1
39 I $G(PSOIO("BLF"))]"" X PSOIO("BLF")
40 S PSOY=PSODY-PSOYI,PSOFONT=PSODFONT
41 I SIGF G WARN:'SIGM&('$G(FILLCONT)),CONT
42 I '$D(NSGY) G CONT
43 K NSGY,^TMP($J,"PSOSIG",RX)
44 D NOW^%DTC S X1=X,X2=365 D C^%DTC S Y=X X ^DD("DD")
45 S DEA=$P($G(^PSDRUG($P(RXY,"^",6),0)),"^",3),T=""
46 I DEA'["S" S T="Discard after "_$S(DEA[0!(DEA["M"):"_________",1:Y)_"__________ "
47 S T=T_"Mfr_________" D PRINT(T)
48 S PSOY=PSOY-5
49 D S PSOFONT="F8" D PRINT(T)
50 . S NOR=$P(RXY,"^",9)-RXF
51 . I $P(RXY,"^",9)=0 S T="NO REFILL" Q
52 . I NOR=0 S T="NO REFILLS LEFT" Q
53 . S T="May refill "_NOR_"X by "_EXPDT
54 S PPHYS=$G(PHYS)
55 S XFONT=$E(PSOQFONT,2,99)
56 S TEXT="Qty: " D STRT^PSOLLU1("SIG",TEXT,.L) S Q(1)=L(XFONT)
57 S TEXT=" "_PSDU D STRT^PSOLLU1("SIG",TEXT,.L) S Q(2)=L(XFONT)
58 S TEXT=" "_$G(PHYS) D STRT^PSOLLU1("SIG",TEXT,.L) S Q(3)=L(XFONT)
59 S TEXT=$G(QTY) D STRT^PSOLLU1("SIG",TEXT,.L) S LENGTH=Q(1)+Q(2)+Q(3)+L(XFONT+2),Q(4)=L(XFONT+2)
60 I LENGTH>3 F I=$L(PHYS)-1:-1:1 S PPHYS=$E(PHYS,1,I),TEXT=" "_PPHYS D STRT^PSOLLU1("SIG",TEXT,.L) I Q(1)+Q(2)+Q(4)+L(XFONT)<3.3 Q
61 S PSOFONT=PSOTFONT,OPSOX=PSOX,PSOX=PSOX+(Q(1)*300),PSOY=PSOQY-PSOYI,T=$G(QTY) D PRINT(T)
62 S PSOX=OPSOX,PSOFONT=PSOQFONT,PSOY=PSOY-PSOYI,T="Qty: " D PRINT(T)
63 S PSOX=PSOX+(Q(1)+Q(4)*300),PSOY=PSOY-PSOYI,T=" "_$G(PSDU)_" "_$G(PPHYS) D PRINT(T)
64 S PSOFONT=PSOTFONT,PSOX=OPSOX,PSOY=PSOTY-PSOYI,T=DRUG D STRT^PSOLLU1("SIG",T,.L)
65 I L($E(PSOFONT,2,99))>3 S PSOFONT=$S(PSOFONT="F12":"F10",PSOFONT="F10":"F9",PSOFONT="F9":F8,PSOFONT="F8":"F6")
66 S ZTKDRUG="XXXXXX SCRIPTALK RX XXXXXX"
67 I $G(PSOSTLK) S T=$S($G(PSOSTALK):ZTKDRUG,1:DRUG)
68 D PRINT(T,1)
69 I SIGM G CONT
70 S ^PSRX(RX,"TYPE")=0
71WARN ;PRINT WARNING LABELS
72 I $G(PSOIO("WLI"))]"" X PSOIO("WLI")
73 ; IF <5 WARNINGS, PRINT LABELS BOTTOM-JUSTIFIED
74 S PSOLAN=$P($G(^PS(55,DFN,"LAN")),"^",2)
75 S WARN5=WARN F Q:$L(WARN5,",")>4 S WARN5=" ,"_WARN5
76 F WWW=1:1:5 S PSOWARN=$P(WARN5,",",WWW) I PSOWARN'="" D
77 . I PSOWARN["N" D NEWWARN^PSOLLLW Q
78 . D WARN54^PSOLLLW
79 ;RETURN MAIL
80 S PS=$S($D(^PS(59,PSOSITE,0)):^(0),1:"") I $P(PSOSYS,"^",4),$D(^PS(59,+$P($G(PSOSYS),"^",4),0)) S PS=^PS(59,$P($G(PSOSYS),"^",4),0)
81 S VAADDR1=$P(PS,"^"),VASTREET=$P(PS,"^",2),STATE=$S($D(^DIC(5,+$P(PS,"^",8),0)):$P(^(0),"^",2),1:"UNKNOWN")
82 S PSZIP=$P(PS,"^",5),PSOHZIP=$S(PSZIP["-":PSZIP,1:$E(PSZIP,1,5)_$S($E(PSZIP,6,9)]"":"-"_$E(PSZIP,6,9),1:""))
83 I $G(PSOIO("RMI"))]"" X PSOIO("RMI")
84 S PSOYI=$G(PSOHYI,40),OFONT=PSOFONT,PSOFONT=$G(PSOHFONT)
85 S BLNKLIN="",$P(BLNKLIN," ",40)=" "
86 S T="Attn: (119)"_BLNKLIN_$$FMTE^XLFDT(DT) D PRINT(T,0)
87 S T=$G(VASTREET) D PRINT(T,0)
88 S T=$P(PS,"^",7)_", "_$G(STATE)_" "_$G(PSOHZIP) D PRINT(T,0)
89 S PSOY=PSOY+PSOYI,T=$S(PS55=2:"***DO NOT MAIL***",1:"") I T'="" D PRINT(T,0)
90 I T'="***DO NOT MAIL***" S T=$S(PS55[0!(PS55[3)!(PS55=""):"REGULAR MAIL",1:"CERTIFIED MAIL") S T=T_"-"_$G(MAILCOM) S:$L(T)>25 PSOFONT="F8" D PRINT(T,0)
91 S PSOFONT=OFONT
92 S T=PNM
93 S PSOY=PSOY+PSOYI,PSOYI=PSORYI D PRINT(T,0)
94 I $G(VAPA(1))=""!(PS55=2) G W
95 ; ADD CHECK FOR BAD ADDRESS INDICATOR OR FOREIGN ADDRESS
96 N PSOBADR,PSOTEMP,PSOFORGN,I
97 S PSOBADR=0,PSOTEMP=0
98 S PSOFORGN=$P($G(VAPA(25)),"^",2) I PSOFORGN'="",PSOFORGN'["UNITED STATES" S PSOFORGN=1
99 I 'PSOFORGN S PSOBADR=$$BADADR^DGUTL3(DFN)
100 I 'PSOFORGN,PSOBADR S PSOTEMP=$$CHKTEMP^PSOBAI(DFN)
101 F I=1:1:3 I $G(VAPA(I))]"" D
102 . S T="" I I=1,'PSOFORGN,PSOBADR,'$G(PSOTEMP) S T="** BAD ADDRESS INDICATED **"
103 . I I=1,T="",PSOFORGN S T="*** FOREIGN ADDRESS ***"
104 . I T="" I 'PSOFORGN I 'PSOBADR!$G(PSOTEMP) S T=$G(VAPA(I))
105 . D STRT^PSOLLU1("ML",T,.L) I L($E(PSOFONT,2,99))<2.37 D PRINT(T,0) Q
106 . F F=12,10,9,8,6 I L(F)<2.37 S OFONT=PSOFONT,PSOFONT="F"_F D PRINT(T,0) S PSOFONT=OFONT Q
107 S A=+$G(VAPA(5)) I A S A=$S($D(^DIC(5,A,0)):$P(^(0),"^",2),1:"UNKNOWN")
108 S T="" I 'PSOFORGN I 'PSOBADR!$G(PSOTEMP) S T=$G(VAPA(4))_", "_A_" "_$S($G(VAPA(11)):$P(VAPA(11),"^",2),1:$G(VAPA(6)))
109 D PRINT(T,0)
110W ;
111 S T=$S(MW="WINDOW":"WINDOW -",1:"MAIL -")
112 N XFONT
113 S OFONT=PSOFONT,PSOYI=$G(PSOTYI,40),PSOFONT=PSOTFONT,XFONT=$E(PSOFONT,2,99),PSOY=PSOTY
114 I T["WINDOW" D
115 . I $G(^PSRX(RX,"MP"))'="" S PSOY=PSOY-PSOYI ; START 1 LINE HIGHER IF METHOD OF PICK-UP
116 . S OPSOX=PSOX D PRINT(T,1) S PSOX=PSOX+200,PSOY=PSOY-PSOYI
117 . S T=$G(^PSRX(RX,"MP")) I T="" S PSOFONT=OFONT,PSOX=OPSOX Q
118 . N FIRST
119 . S FIRST=1
120 . D STRT^PSOLLU1("ML",T,.L)
121 . I L(XFONT)<1.75 D PRINT(T,0) S PSOFONT=OFONT,PSOX=OPSOX Q
122 . F F=10,9,8,6 I L(F)<4.5 Q
123 . S XFONT=F,PSOFONT="F"_F,PSOYI=$S(PSOFONT="F12":40,PSOFONT="F10":35,PSOFONT="F9":30,PSOFONT="F8":25,1:20)
124 . F J=$L(T," "):-1:1 S PTEXT=$P(T," ",1,J) D STRT^PSOLLU1("ML",PTEXT,.L) D Q:T=""
125 .. I FIRST I L(XFONT)<1.75 D PRINT(PTEXT,0) S T=$P(T," ",J+1,512),J=$L(T," ")+1,PTEXT="",FIRST=0,PSOX=OPSOX,PSOY=PSOY+20 Q
126 .. I 'FIRST I L(XFONT)<2.3 D PRINT(PTEXT,0) S T=$P(T," ",J+1,512),J=$L(T," ")+1,PTEXT=""
127 . D:PTEXT]"" PRINT(PTEXT,0)
128 I T="MAIL -" D PRINT(T,1)
129 S PSOFONT=OFONT
130CONT I $G(SIDE) G BARC:'L5,CONT2
131 I $G(COPIES)>1 G BARC
132 I 'L2!PFM D ^PSOLLL2 S L2=1
133 I 'L3 D ^PSOLLL3 S L3=1
134 I 'L4!PMIM S PIMI=0 D ^PSOLLL4 S L4=1
135 I L5 W @IOF G CONT2
136BARC I $G(BOTTLBL) G BARCE ; ONLY PRINT BARCODE ON 1ST BOTTLE LABEL
137 S BOTTLBL=1
138 I $G(PSOIO("BLBC"))]"" X PSOIO("BLBC") I $G(NOBARC) G BARCE
139 S X2=PSOINST_"-"_RX W X2
140 I $G(PSOIO("EBLBC"))]"" X PSOIO("EBLBC")
141BARCE W @IOF
142COPY I SIGF S SIGM=1 G L1 ; NEED TO FINISH PRINTING CONTINUED BOTTLE LABEL
143 S FILLCONT=0 I PFM!PMIM S FILLCONT=1 G L1
144 I $G(COPIES)>1 D G L1
145 . S COPIES=COPIES-1
146 . S (SIGM,PFM,PMIM,L2,L3,L4,L5,BOTTLBL)=0
147 . K SIGF,PFF,PMIF S (SIGF,PFF,PMIF)=0 F I="DR","T" S (SIGF(I),PFF(I))=1
148 . F I="A","B","I" S PMIF(I)=1
149 S IR=0 F FDA=0:0 S FDA=$O(^PSRX(RX,"L",FDA)) Q:'FDA S IR=FDA
150 S IR=IR+1,^PSRX(RX,"L",0)="^52.032DA^"_IR_"^"_IR
151 S ^PSRX(RX,"L",IR,0)=PSOFNOW_"^"_$S($G(RXP):99-RXPI,1:RXF)_"^"_$S($G(PCOMX)]"":$G(PCOMX),$G(PCOMH(RX))]"":PCOMH(RX),1:"From RX number "_$P(^PSRX(RX,0),"^"))_$S($G(RXP):" (Partial)",1:"")_$S($D(REPRINT):" (Reprint)",1:"")_"^"_PDUZ
152 N PSOBADR,PSOTEMP
153 S PSOBADR=$$CHKRX^PSOBAI(RX)
154 I $G(PSOBADR) S PSOTEMP=$P(PSOBADR,"^",2),PSOBADR=$P(PSOBADR,"^")
155 I $G(PSOBADR),'$G(PSOTEMP) D
156 .S IR=IR+1,^PSRX(RX,"L",0)="^52.032DA^"_IR_"^"_IR
157 .S ^PSRX(RX,"L",IR,0)=PSOFNOW_"^"_$S($G(RXP):99-RXPI,1:RXF)_"^"_"ROUTING="_$G(MW)_" (BAD ADDRESS)"_"^"_PDUZ
158 S L5=1
159CONT2 I SIGF S SIGM=1 G L1 ; MORE BOTTLE LABEL SIG TO PRINT
160 I PMIM G CONT ; MORE PMI INFO TO PRINT
161 I $G(PSOBLALL)=1,$P(PPL,",",PI+1)="" D TRAIL
162 Q
163PRINT(T,B) ;
164 S BOLD=$G(B)
165 I 'BOLD,$G(PSOIO(PSOFONT))]"" X PSOIO(PSOFONT)
166 I BOLD,$G(PSOIO(PSOFONT_"B"))]"" X PSOIO(PSOFONT_"B")
167 I $G(PSOIO("ST"))]"" X PSOIO("ST")
168 W T,!
169 I $G(PSOIO("ET"))]"" X PSOIO("ET")
170 I BOLD,$G(PSOIO(PSOFONT))]"" X PSOIO(PSOFONT) ;TURN OFF BOLDING
171 Q
172TRAIL I $G(SIDE) G END
173 D ^PSOLLL5
174 D ^PSOLLLH
175 D ^PSOLLL6
176 I '$P($G(^PS(59,PSOSITE,1)),"^",18) Q
177 I '$G(REPRINT) D ^PSOLLL7
178END I '$P(PSOPAR,"^",31) Q
179 W @IOF
180 I $G(PSOIO("PMII"))]"" X PSOIO("PMII")
181 I $G(PSOIO(PSOFONT))]"" X PSOIO(PSOFONT)
182 S T="NEXT PATIENT"
183 S PSOX=1100-(L($E(PSOFONT,2,99))*300/2)
184 I $G(PSOIO("ST"))]"" X PSOIO("ST")
185 W T,!
186 I $G(PSOIO("ET"))]"" X PSOIO("ET")
187 Q
188 ;
Note: See TracBrowser for help on using the repository browser.