source: WorldVistAEHR/trunk/r/OUTPATIENT_PHARMACY-PSO-APSP-HUIP/PSOTALK.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.2 KB
Line 
1PSOTALK ;BIR/EJW - SCRIPTALK INTERFACE FROM VISTA ; 3/9/07 10:38am
2 ;;7.0;OUTPATIENT PHARMACY;**135,182,211,200,249**;DEC 1997;Build 9
3 ;External reference ^PS(55 supported by DBIA 2228
4 ;External reference to ^PSDRUG supported by DBIA 221
5 ;External reference to ^PS(59.7 controlled subscription by DBIA 694
6 ;ROB SILVERMAN-HINES DEVELOPED ORIGINAL VISTA CUSTOM SOFTWARE FOR SCRIPTALK
7EN Q:'$$PAT55 ; QUIT IF NOT A SCRIPTALK ELIGIBLE PATIENT
8 S PSOSTALK=1
9 N PHONE,RXNUM,RXALPHA,DATE,EDATE,RFILLS,PTNAME,SIG,SIGX,PROV,DRUG,WARN,LINE
10 D GATHER,TRANS,CLEAN
11 Q
12 ;
13CLEAN K PHONE,RXNUM,RXALPHA,DATE,EDATE,RFILLS,PTNAME,SIG,SIGX,PROV,DRUG,WARN,VADM
14 K PSOCTP,PSOCTV,XMIT,PSORCT,PSOTSSN,PSOEXPDT
15 K PSOLNE,PSOLEN,PSOLINE,PSOWORD,PSOWDS,LINE
16 K PSOSIG1,PSOLSIG,PSOSIG,PSOSTOP,PSOPMAP
17 Q
18BARE N RX
19 D CLEAN
20 W ! S DIC="^PSRX(",DIC(0)="AEQM" D ^DIC K DIC Q:Y<0 S RX=+Y
21 D:'$D(PSOPAR) ^PSOLSET
22 I '$$PAT55 W !,"Patient not enrolled in ScripTalk program." G BAREO
23 I $P(^PSRX(RX,"STA"),"^")'=0 W !,"Prescription not ACTIVE" G BAREO
24 D GATHER
25 W !!," Queuing ScripTalk label"
26 D TRANS
27BAREO D CLEAN
28 W !!
29 G BARE
30 Q
31BARI N RX
32 D CLEAN
33 S RX=$$READER^PSOTALK1("FO^1:12","Enter Barcode Rx#")
34 Q:RX']""
35 G:RX'["-" BARIO
36 S RX=$P(RX,"-",2)
37 I '$D(^PSRX(RX,0)) W !,"Prescription not on file" G BARIO
38 I '$$PAT55 W !,"Patient not enrolled in ScripTalk program." G BARIO
39 I $P(^PSRX(RX,"STA"),"^")'=0 W !,"Prescription not ACTIVE" G BARIO
40 D:'$D(PSOPAR) ^PSOLSET
41 D GATHER
42 W !!," Queuing ScripTalk label"
43 D TRANS
44BARIO D CLEAN
45 W !!
46 G BARI
47 Q
48GATHER ;
49 N DFN
50 S DFN=$P(^PSRX(RX,0),"^",2)
51 D DEM^VADPT
52 S PHONE=$$PHONE
53 S RXNUM=+$$RXNUM
54 S RXALPHA=$$RXALPHA
55 S DATE=$$DATE
56 S FILLS=$$RFILLS I $L(RFILLS)=1 S FILLS="0"_FILLS
57 S PTNAME=VADM(1) D
58 .N FNAM,MI
59 .S FNAM=$P(PTNAME,",",2) I FNAM[" " D
60 ..S MI=$P(FNAM," ",2,99) I MI[" " S MI=$P(MI," ")
61 ..S FNAM=$P(FNAM," ")
62 .S PTNAME=FNAM_$S($G(MI)'="":" "_MI,1:"")_" "_$P(PTNAME,",")
63 .S PTNAME=$$UP^XLFSTR(PTNAME)
64 .S PTNAME=$TR(PTNAME,"-"," ")
65 .S PTNAME=$TR(PTNAME,".","")
66 .S PTNAME=$TR(PTNAME,"'"," ")
67 S SIG=$TR($$UP^XLFSTR($$SIGPOE),"[\]^_`{|}~","(/) -'( ) ")
68 S SIGX=$TR($$UP^XLFSTR($$SIGPOEX),"[\]^_`{|}~","(/) -'( ) ")
69 S PROV=$E($$UP^XLFSTR($$PROV),1,30)
70 S DRUG=$TR($$UP^XLFSTR($$DRUG),"[\]^_`{|}~","(/) -'( ) ")
71 S WARN=$$WARN
72 D PSOEXP
73 S LINE(1)="VAMC "_$$CITY_", "_$$STATE_" "_$$ZIP
74 S LINE(2)=$$SITE_" ("_$$CLERK_"/"_$$VRPH_") "_$$ACODE_"-"_$$EPHON_" Exp: "_PSOEXPDT
75 S LINE(3)="Rx# "_$$RXNUM_" "_$$EDATE_" Fill "_$$FILNO_" of "_$$TFILLS
76 S LINE(4)=$$EPAT_" "_$$LAST6
77 D INST^PSOTALK1 S LINE(5)=$G(PSOLNE(1)),LINE(6)=$G(PSOLNE(2)),LINE(7)=$G(PSOLNE(3))
78 S LINE(8)=$$EPROV,LINE(10)=$$DRUG
79 S LINE(9)="Qty: "_$$QTY_" "_$$DF
80 Q
81TRANS ;If printer mapping defined use it; otherwise print by division 01/19/07
82 D PCHK:'$D(PSOPMAP) ;don't recheck for mapped printer if PSOPMAP equal 0 (not defined) or 1 (defined)
83 I '$D(^PS(59.7,1,47,"B",IOS))&('$G(PSOPMAP)) S ZTIO="`"_$P($G(^PS(59,PSOSITE,"STALK")),U)
84 Q:ZTIO="`"
85 S ZTRTN="GO^PSOTALK",ZTSAVE("*")="",ZTDTH=$$NOW^XLFDT,ZTDESC="Scriptalk Interface Transmission"
86 D ^%ZTLOAD
87 Q
88PCHK ;Check for printers that are mapped to a ScripTalk printer
89 N PSOLPRT,PSONIOS,PSOLBSEQ
90 S ZTIO="`",PSOLPRT=$S($D(PSOLAP):PSOLAP,$G(SUSPT):PSLION,$D(ION):ION,1:"") Q:PSOLPRT="" Q:'$D(^%ZIS(1,"B",PSOLPRT))
91 S PSONIOS="",PSOPMAP=0,PSONIOS=$O(^%ZIS(1,"B",PSOLPRT,PSONIOS))
92 I $D(^PS(59.7,1,47,"B",PSONIOS)) D
93 . S PSOLBSEQ="",PSOLBSEQ=$O(^PS(59.7,1,47,"B",PSONIOS,PSOLBSEQ))
94 . S ZTIO=ZTIO_$P(^PS(59.7,1,47,PSOLBSEQ,0),"^",2),PSOPMAP=1
95 Q
96 ;
97GO W !,"^XA",!,"^FO250,700^XGE:RX.GRF^FS" ;;1.2e 4-17-02 TO MOVE GRAPHIC
98 D OVERLAY,PICOTAG ;;FOR LARGER LABELS
99 W !,"^PQ1,0,1,Y",!,"^XZ" ;;FOR LARGER LABELS
100 S:$D(ZTQUEUED) ZTREQ="@"
101 Q
102 ;
103OVERLAY F PSOLINE=1:1:7 D DEFLINE((9+((20-PSOLINE)*28)),50,LINE(PSOLINE),PSOLINE,0)
104 F PSOLINE=8:1:10 D DEFLINE((9+((19-PSOLINE)*28)),50,LINE(PSOLINE),PSOLINE,0)
105 Q
106 ;
107DEFLINE(XCORD,YCORD,PRTOUT,FIELDNO,OFFSET) ;
108 W !,"^AFR,20,10^FO"_XCORD_","_YCORD_"^FR^CI0^FD"_PRTOUT_"^FS"
109 Q
110 ;
111PICOTAG S PSOCTP=1
112 S DRUG=$E(DRUG,1,39) ;1.2c*1 TEMPORARY FIX FOR DRUG TRUNCATE AT 39
113 F XMIT=PTNAME,DRUG,SIGX,DATE,FILLS,WARN,PROV,PHONE,RXNUM,RXALPHA D XMITP
114 Q
115 ;
116XMITP W !,"^RX"_$S(PSOCTP<10:"0",1:"")_PSOCTP_","_XMIT_"^FS"
117 S PSOCTP=PSOCTP+1
118 Q
119ID() I $$PAT55 Q "+SCRIPTALK"
120 E Q ""
121AUTO ;;v1.2c - LABEL REPRINTING FUNCTIONS 3-12-02
122 Q:$G(PSOTREP) ;NO AUTO-PRINT DURING REGULAR NON-VOIDED LABEL REPRINT
123 D PCHK
124 I $P($G(^PS(59,+PSOSITE,"STALK")),U,2)="A"!($G(PSOPMAP)) D EN
125 Q
126 ;
127PAT55() Q +$G(^PS(55,"ASTALK",$P(^PSRX(RX,0),"^",2))) ;IS PATIENT ENROLLED (NEW FIELD POSITION 2-12-02 RMS UPDATE v1.2b)
128PHONE() ;changes below 1.2c*1 to swap to site signed-on vs. site from Rx
129 Q $E($P(^PS(59,+PSOSITE,0),"^",3),1,3)_$E($TR($P(^PS(59,+PSOSITE,0),"^",4),"-,",""),1,7) ; RX DIVISION PHONE NUMBER
130CITY() Q $P(^PS(59,+PSOSITE,0),"^",7)
131STATE() Q $P(^DIC(5,$P(^PS(59,+PSOSITE,0),"^",8),0),"^",2)
132ZIP() Q $P(^PS(59,+PSOSITE,0),"^",5)
133SITE() Q $P(^PS(59,+PSOSITE,0),"^",6)
134ACODE() Q $P(^PS(59,+PSOSITE,0),"^",3)
135EPHON() Q $P(^PS(59,+PSOSITE,0),"^",4)
136CLERK() Q $P($G(^PSRX(RX,"OR1")),"^",5)
137PSOEXP ;
138 N X1,X2,X S X1=DT,X2=365 D C^%DTC S PSOEXPDT=X
139 S PSOEXPDT=$E(PSOEXPDT,4,5)_"/"_$E(PSOEXPDT,6,7)_"/"_$E(PSOEXPDT,2,3)
140 Q
141VRPH() Q $P($G(^PSRX(RX,2)),"^",10)
142RXNUM() Q $P(^PSRX(RX,0),"^",1) ;RETURN RX EXTERNAL NUMBER
143RXALPHA() ;RETURN RENEWAL LETTER OR SPACE CHARACTER
144 N RXALPHA
145 S RXALPHA=$E($P(^PSRX(RX,0),"^",1),$L($P(^PSRX(RX,0),"^",1)))
146 Q $S(RXALPHA?1A:RXALPHA,1:" ")
147DATE() ;CHANGED 7-30-01 TO USE EDATE FORMAT ALSO WHEN SPEAKING
148 S EDATE=$P(^PSRX(RX,3),"^")
149 Q $E(EDATE,4,5)_$E(EDATE,6,7)_$E(EDATE,2,3)
150EDATE() Q $$FMTE^XLFDT($P(^PSRX(RX,3),"^")) ; EXTERNAL DATE / LAST DISPENSED
151FILLS() Q $G(RXF)+1 ; FILL COUNT
152TFILLS() Q $P(^PSRX(RX,0),"^",9)+1 ; TOTAL FILLS
153RFILLS() ;NEW REFILLS REMAINING METHOD 9-21-00, BASED ON PTST+5^PSORXVW
154 S RFILLS=$P(^PSRX(RX,0),"^",9),PSORCT=0 F S PSORCT=$O(^PSRX(RX,1,PSORCT)) Q:'PSORCT S RFILLS=RFILLS-1
155 Q RFILLS
156FILNO() Q $$TFILLS-$$RFILLS
157EPAT() Q $P(^DPT($P(^PSRX(RX,0),"^",2),0),"^") ; EXTERNAL PATIENT NAME
158LAST6() S PSOTSSN=$P(^DPT($P(^PSRX(RX,0),"^",2),0),"^",9) ; LAST 6 OF SSN
159 Q $E(PSOTSSN,4,5)_"-"_$E(PSOTSSN,6,9)
160SIG() ;THIS SUBROUTINE WILL BE ABANDONED IF SIGPOE WORKS v1.2c 3-13-02
161 I $L($P(^PSRX(RX,"SIG"),"^",1))=0 Q $E($$LSIG^PSOTALK1($P(^PSRX(RX,"SIG1",1,0),"^",1)),1,196)
162 E Q $E($$LSIG^PSOTALK1($P(^PSRX(RX,"SIG"),"^",1)),1,196) ; SIG -- NEEDS TO BE EXPANDED
163SIGPOE() ;v1.2c - NEW SUBROUTINE TO GIVE MESSAGE FOR LONG SIGS FOR THE HUMAN READABLE PORTION
164 S PSOSIG=""
165 I $P($G(^PS(55,DFN,"LAN")),"^",1) D G SIGPOEE
166 .S PSOSIG=" " ; PUT SPACE ON FRONT OF SIG (GETS STRIPPED OFF LATER)
167 .D OTHL1^PSOLBL3(RX) I $O(SIG2(0))="" Q
168 .N XX,X
169 .;PSO*7*211;MODIFIED TO REPLACE SIG IF >138 INSTEAD OF 196
170 .S XX=0 F S XX=$O(SIG2(XX)) Q:'XX S X=SIG2(XX) I X'="" S PSOSIG=PSOSIG_X_" " I $L(PSOSIG)>138 D Q
171 ..S PSOSIG=" INDICACIONES MUY LARGAS. IMPRIMA UNA ETIQUETA DE VISTA VALIDA Y APLIQUELA SOBRE ESTA ETIQUETA DE SCRIPTALK EN LA BOTELLA."
172 E D ;
173 . N PSOSEQ
174 . S PSOSTOP=0,PSOSIG=""
175 . S PSOLSIG=" SIG IS TOO LONG. REPRINT A NON-VOIDED VISTA LABEL AND PLACE OVER THIS SCRIPTALK LABEL"
176 . S PSOSEQ=0 F S PSOSEQ=$O(^PSRX(RX,"SIG1",PSOSEQ)) Q:PSOSEQ'=+PSOSEQ!($G(PSOSTOP)) D ;
177 .. S PSOSIG1=$G(^PSRX(RX,"SIG1",PSOSEQ,0))
178 ..;PSO*7*211;MODIFIED TO REPLACE SIG IF >138 INSTEAD OF 196
179 .. I $L(PSOSIG)+$L($G(^PSRX(RX,"SIG1",PSOSEQ,0)))>138 S PSOSIG=PSOLSIG,PSOSTOP=1 Q ;
180 .. S PSOSIG=$G(PSOSIG)_" "_PSOSIG1
181SIGPOEE Q $E(PSOSIG,2,197)
182 ;
183SIGPOEX() ;v1.2c - NEW SUBROUTINE TO GIVE MESSAGE FOR LONG SIGS FOR THE READ ALOUD PORTION
184 S PSOSIG=""
185 I $P($G(^PS(55,DFN,"LAN")),"^",1) D G SIGPOEEX
186 .S PSOSIG=" " ; PUT SPACE ON FRONT OF SIG (GETS STRIPPED OFF LATER)
187 .D OTHL1^PSOLBL3(RX) I $O(SIG2(0))="" Q
188 .N XX,X
189 .S XX=0 F S XX=$O(SIG2(XX)) Q:'XX S X=SIG2(XX) I X'="" S PSOSIG=PSOSIG_X_" " I $L(PSOSIG)>196 D Q
190 ..S PSOSIG=" LAS INSTRUCCIONES DE ESTA RECETA SON MUY LARGAS. POR FAVOR SOLICITE A SU CUIDADOR QUE LE LEA LAS INSTRUCCIONES IMPRESAS EN EL ROTULO O COMUNIQUESE CON SU MEDICO PARA INSTRUCCIONES COMPLETAS."
191 I $L($P(^PSRX(RX,"SIG"),"^",1))'=0 Q $E($$LSIG^PSOTALK1($P(^PSRX(RX,"SIG"),"^",1)),1,196)
192 E D ;
193 . N PSOSEQ
194 . S PSOSTOP=0,PSOSIG=""
195 . S PSOLSIG=" THE INSTRUCTIONS FOR THIS PRESCRIPTION ARE TOO LONG. PLEASE HAVE A CAREGIVER READ THE PRINTED LABEL OR CONTACT YOUR PHYSICIAN FOR COMPLETE INSTRUCTIONS."
196 . S PSOSEQ=0 F S PSOSEQ=$O(^PSRX(RX,"SIG1",PSOSEQ)) Q:PSOSEQ'=+PSOSEQ!($G(PSOSTOP)) D ;
197 .. S PSOSIG1=$G(^PSRX(RX,"SIG1",PSOSEQ,0))
198 .. I $L(PSOSIG)+$L($G(^PSRX(RX,"SIG1",PSOSEQ,0)))>196 S PSOSIG=PSOLSIG,PSOSTOP=1 Q ;
199 .. S PSOSIG=$G(PSOSIG)_" "_PSOSIG1
200SIGPOEEX Q $E(PSOSIG,2,197)
201PROV() ;PROVIDER NAME
202 K DIC,X,Y S DIC="^VA(200,",DIC(0)="M",X="`"_+$P(^PSRX(RX,0),"^",4) D ^DIC S PSOPHYS=$S(+Y:$P(Y,"^",2),1:"UNKNOWN") K DIC,X,Y
203 Q $P($$NAMEFMT^XLFNAME(PSOPHYS)," MD")
204EPROV() ;
205 K DIC,X,Y S DIC="^VA(200,",DIC(0)="M",X="`"_+$P(^PSRX(RX,0),"^",4) D ^DIC S PSOPHYS=$S(+Y:$P(Y,"^",2),1:"UNKNOWN") K DIC,X,Y
206 Q PSOPHYS
207QTY() Q $S($G(RXP):$P(RXP,"^",4),1:$P(^PSRX(RX,0),"^",7))
208DF() Q $P($G(^PSDRUG($P(^PSRX(RX,0),"^",6),660)),"^",8)
209DRUG() Q $$ZZ^PSOSUTL(RX) ; DRUG NAME
210WARN() N WARN,NWARN,IWARN,XWARN ; 1-28-02 UPDATE v1.2a TO ELIMINATE LOCAL CODES
211 S WARN=$P(^PSDRUG($P(^PSRX(RX,0),"^",6),0),"^",8) ; WARNING LABEL CODES
212 F NWARN=1:1:3 S IWARN=$P(WARN,",",NWARN) S:IWARN>20 IWARN="" S:$L(IWARN)=1 IWARN="0"_IWARN S:$L(IWARN)=0 IWARN="00" S XWARN=$G(XWARN)_IWARN
213 Q XWARN
Note: See TracBrowser for help on using the repository browser.