source: FOIAVistA/trunk/r/OUTPATIENT_PHARMACY-PSO-APSP-HUIP/PSOVDF2.m@ 1384

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

initial load of FOIAVistA 6/30/08 version

File size: 9.3 KB
Line 
1PSOVDF2 ;BPOIFO/EL-OUTPATIENT PHARMACY (PRES, PREF, PPAR) HL7 MESSAGE ;10/04/04
2 ;;7.0;OUTPATIENT PHARMACY;**190,205,220,235,261**;DEC 1997;Build 9
3 ;
4 ; DBIAs:
5 ; 2226-PS(51.2
6 ; 221-PSDRUG
7 ; 4248-VDEFEL
8 ;
9 Q
10 ;
11 ; Creates one of three Outpatient HL7 messages:
12 ; RDE^O11^PRES, RDS^O13^PREF, or RDS^O13^PPAR
13 ;
14 ; Returns:
15 ; Piece ^ 1 - "LM"-Local Array
16 ; Piece ^ 2 - MSH segment, not set
17 ; OUT - OUTPUT array includes HL7 message for every segment except MSH
18 ;
19 ; Message Body "MSH,PID,ORC1,RXE1,RXR1,FT1,OBX1,NTE1,ORC2,ORC3"
20 ;
21 ;
22OUT ; Output
23 N WR K WR
24 S L=1
25OUT10 I $L(MSG)<247 S WR(L)=MSG
26 I $L(MSG)>246 S WR(L)=$E(MSG,1,246),L=L+1,MSG=$E(MSG,247,99999) G OUT10
27 ;
28OUT20 ; VISTA HL7
29 S X=""
30 F I=1:1 S X=$G(WR(I)) Q:X="" D
31 . I I=1 S OUT("HLS")=$G(OUT("HLS"))+1,OUT("HLS",OUT("HLS"))=X
32 . E I I>1 S OUT("HLS",OUT("HLS"),I-1)=X
33 Q
34 ;
35GET(GLOBAL,L,P) ; GET(GLOBAL,NODE,PIECE)
36 I $G(GLOBAL(L))="" Q ""
37 N RES
38 S RES=$P(GLOBAL(L),U,P)
39 Q RES
40 ;
41PUT(P) ; Put in MSG
42 I $G(VAL)="" Q
43 S $P(MSG,SEPF,P)=VAL
44 Q
45 ;
46PROCESS ;
47ORC1 ; ORC ORIGINAL FILL
48 S MSG="",CTR=0
49 S VAL=$$GET(.GL,"OR1",2) I $G(VAL)'="" S VAL=$$REPL^PSOVDF1(VAL),VAL=VAL_SEPC_SRC_"_39.3" D PUT(2)
50 S VAL=PSOVDFES_SEPC_SRC_"_.001" D PUT(3)
51 S VAL="CM" D PUT(5)
52 S (VAL,WR)="",WR=$$GET(.GL,2,2) I $G(WR)'="" D
53 .S WR=$$HLDATE^HLFNC(WR,"TS") I WR>0 S WR=$$REPL^PSOVDF1(WR),$P(VAL,SEPC,4)=WR,$P(VAL,SEPC,7)="FILL"
54 S WR=$$GET(.GL,2,6) I $G(WR)'="" D
55 .S WR=$$HLDATE^HLFNC(WR,"TS") I WR>0 S WR=$$REPL^PSOVDF1(WR),$P(VAL,SEPC,5)=WR,$P(VAL,SEPC,7)=$P(VAL,SEPC,7)_"/EXPIRATION"
56 I $G(VAL)'="" S CTR=CTR+1
57 S (TP)="",WR=$$GET(.GL,0,13) I $G(WR)'="" D
58 .S WR=$$HLDATE^HLFNC(WR,"TS") I WR>0 S WR=$$REPL^PSOVDF1(WR),$P(TP,SEPC,5)=WR,$P(TP,SEPC,7)="ISSUED" S CTR=CTR+1,$P(VAL,SEPR,CTR)=TP
59 S (TP)="",WR=$$GET(.GL,2,5) I $G(WR)'="" D
60 .S WR=$$HLDATE^HLFNC(WR,"TS") I WR>0 S WR=$$REPL^PSOVDF1(WR),$P(TP,SEPC,4)=WR,$P(TP,SEPC,7)="DISPENSED"
61 ; (7~5|3-101)
62 S WR=$$GET(.GL,3,1) I $G(WR)'="" D
63 .S WR=$$HLDATE^HLFNC(WR,"TS") I WR>0 S WR=$$REPL^PSOVDF1(WR),$P(TP,SEPC,5)=WR,$P(TP,SEPC,7)=$P(TP,SEPC,7)_"/LAST DISPENSED"
64 I $G(TP)'="" S CTR=CTR+1,$P(VAL,SEPR,CTR)=TP
65 ; (7~5|4-26.1)
66 S (TP)="",WR=$$GET(.GL,3,5) I $G(WR)'="" D
67 .S WR=$$HLDATE^HLFNC(WR,"TS") I WR>0 S WR=$$REPL^PSOVDF1(WR),$P(TP,SEPC,5)=WR,$P(TP,SEPC,7)="CANCEL" S CTR=CTR+1,$P(VAL,SEPR,CTR)=TP
68 I $G(VAL)'="" D PUT(7)
69 ; (9-21)
70 S VAL=$$GET(.GL,2,1),VAL=$$HLDATE^HLFNC(VAL,"TS") I VAL>0 S VAL=$$REPL^PSOVDF1(VAL) D PUT(9)
71 ; (10-16)
72 S VAL=$$GET(.GL,0,16) I $G(VAL)'="" S VAL=$$XCN200^VDEFEL(VAL) D PUT(10)
73 ; (12|1-4)
74 S WR="",VAL=$$GET(.GL,0,4) I $G(VAL)'="" D
75 . S WR=$$XCN200^VDEFEL(VAL,"RE")
76 ; (12|2-109)
77 S TP="",VAL=$$GET(.GL,3,3) I $G(VAL)'="" D
78 . S TP=$$XCN200^VDEFEL(VAL,"COSIGNER"),$P(WR,SEPR,2)=TP
79 I $G(WR)'="" S VAL=WR D PUT(12)
80 ; (13-5)
81 S VAL=$$GET(.GL,0,5)
82 I VAL'="" D ORC13^PSOVDF3,PUT(13)
83 S (VAL,PSOVD59)=$$GET(.GL,2,9) I $G(VAL)'="" D
84 .N PSONCOR,PSONCORP,PSOSINUM
85 .S X=$G(^PS(59,VAL,0)),PSONCORP=$P($G(^("SAND")),"^",3)
86 .S VAL=$P(X,U),(VAL,PSONCOR)=$$REPL^PSOVDF1(VAL) Q:VAL=""
87 .S PSOSINUM=$P(X,U,6),PSOSINUM=$$REPL^PSOVDF1(PSOSINUM)
88 .S VAL=PSOSINUM_SEPC_VAL_SEPC_SRC_"_20"
89 .I PSONCORP'="" S PSONCORP=$$REPL^PSOVDF1(PSONCORP),VAL=VAL_SEPC_PSONCORP_SEPC_PSONCOR_SEPC_"NCPDP"
90 .S PSOVDDIV(PSOVD59)=$G(VAL)
91 .D PUT(17)
92 S VAL=$G(PSOVDFIN) D PUT(21)
93 N PSOVLV,PSOVAR,PSOVEN,DIC,DR,DA,DIQ D
94 .I $D(GL(4)) D ORCCS^PSOVDF3
95 .S DIC=52,DR="100",(DA,PSOVEN)=PSOVDFD0,DIQ="PSOVAR",DIQ(0)="IE" D EN^DIQ1
96 .S VAL=$G(PSOVAR(52,PSOVEN,100,"I")) I VAL'="" D ORC25^PSOVDF3
97 .I VAL="",'$D(VCMP) Q
98 .S:VAL="" VAL=SEPC_SEPC
99 .S VAL=VAL_$S($D(VCMP(0)):SEPC_VCMP(0),1:"") D PUT(25)
100 I $G(MSG)="" G ORC1Q
101 S $P(MSG,U)="RE"
102 S MSG="ORC"_SEPF_MSG D OUT
103ORC1Q ; Q
104 ;
105RXE1 ; RXE ORIGINAL FILL
106 S MSG=""
107 ; (1~4-22)
108 S (VAL,WR)="",CTR=0 I $D(GL(6)) K TEMP M TEMP=GL(6) S WR=$$DOSE^PSOVDF3(.TEMP) I $G(WR)'="" S VAL=WR
109 D FINISH^PSOVDF3
110 D PUT(1)
111 N PSOV568,PSOVNAME,PSOVUIDN,PSOVLL,PSOVNND,PSOVNDF,PSONAM50,PSOVCMOP
112 S (GIVECODE,P,PSOVNDF,PSOVDRUG,VAL,PSOVNND,PSOV568,PSOVNAME,PSOVLL,PSOVUIDN,PSOVCMOP,PSONAM50)="",PSOVDRUG=$$GET(.GL,0,6)
113 I +$G(PSOVDRUG)'>0 G RXE1A
114 S PSOVNND=$G(^PSDRUG(PSOVDRUG,"ND")),PSOV568=0
115 I $P(PSOVNND,"^",10)'="" S PSOVCMOP=$$REPL^PSOVDF1($P(PSOVNND,"^",10))
116 S PSOVNDF=$P(PSOVNND,"^",3),PSOVLL=$P(PSOVNND,"^") I +PSOVNDF>0 D
117 .S PSOVUIDN=$$PROD0^PSNAPIS(+PSOVLL,+PSOVNDF),PSOVNAME=$P(PSOVUIDN,"^"),PSOVNAME=$$REPL^PSOVDF1(PSOVNAME) S PSOV568=$$GETVUID^XTID(50.68,,+PSOVNDF_",")
118 I $P($G(PSOV568),"^")'=0 S PSOV568=$$REPL^PSOVDF1(PSOV568) S VAL=$G(PSOV568)_SEPC_$G(PSOVNAME)_SEPC_"99VA_52_6",GIVECODE=VAL G RXE1A
119 S PSONAM50=$P($G(^PSDRUG(PSOVDRUG,0)),"^"),PSONAM50=$$REPL^PSOVDF1(PSONAM50) S VAL=SEPC_PSONAM50_SEPC_SRC_"_6",GIVECODE=VAL
120 ; (2~4-API or 52_27 or 50_31)
121RXE1A S WR=""
122 I $T(NDC^PSOHDR)]"" D
123 . S WR=$$NDC^PSOHDR(PSOVDFD0,0)
124 E S WR=$$GET(.GL,2,7) D
125 . I $G(WR)="",($G(PSOVDRUG)'="") S X=$G(^PSDRUG(PSOVDRUG,2)),WR=$P(X,U,4)
126 I $G(WR)'="" S WR=$$REPL^PSOVDF1(WR),$P(VAL,SEPC,4)=WR,$P(VAL,SEPC,6)="NDC",DRCODE=VAL
127 D PUT(2)
128 N PSOLUN,PSOLUNI
129 S (UNIT,VAL)="" I $G(PSOVNDF)'="" D
130 .S PSOLUN=$$DFSU^PSNAPIS(PSOVLL,PSOVNDF)
131 .I $G(PSOLUN)'="" N PSOUNTXT S PSOUNTXT=$P(PSOLUN,U,6),PSOUNTXT=$$REPL^PSOVDF1(PSOUNTXT),PSOLUNI=$P(PSOLUN,"^",5),PSOLUNI=$$REPL^PSOVDF1(PSOLUNI) S VAL=PSOLUNI_SEPC_PSOUNTXT_SEPC_SRC_"_6"
132 I $G(VAL)="" S VAL="UNK"
133 S UNIT=VAL D PUT(5)
134 S VAL=0 D PUT(3)
135 S VAL="" D RXE6^PSOVDF3 D PUT(6)
136 S CTR=0,(VAL,WR)=""
137 ; (7|3-113)
138 I $D(GL(6)) K TEMP M TEMP=GL(6) S WR=$$NSET^PSOVDF3(.TEMP) I $G(WR)'="" S VAL=WR
139 ;Don't piece out INS nodes, can possibly contain up-arrow from Provider Comments
140 S WR=$G(GL("INS")) I $G(WR)'="" S WR=$$REPL^PSOVDF1(WR),CTR=CTR+1,WR=SEPC_WR_SEPC_SRC_"_114",$P(VAL,SEPR,CTR)=WR
141 S WR=$$GET(.GL,"INSS",1) I $G(WR)'="" S WR=$$REPL^PSOVDF1(WR),CTR=CTR+1,WR=SEPC_WR_SEPC_SRC_"_114.1",$P(VAL,SEPR,CTR)=WR
142 I $D(GL("INS1")) K TEMP M TEMP=GL("INS1") S WR=$$SSETX^PSOVDF3(.TEMP,SRC_"_115"),VAL=VAL_SEPR_WR
143 D PUT(7)
144 ; (8~6-11)
145 S (WR,VAL)=""
146 S WR=$$GET1^DIQ(52,PSOVDFD0_",",11,"","","PSOVERR") K PSOVERR I $G(WR)'="" S WR=$$REPL^PSOVDF1(WR),$P(VAL,SEPC,6)=WR D PUT(8)
147 ; (10-7)
148 S VAL=$$GET(.GL,0,7),VAL=$$REPL^PSOVDF1(VAL) D PUT(10)
149 ; (12-9)
150 S VAL=$$GET(.GL,0,9),VAL=$$REPL^PSOVDF1(VAL) D PUT(12)
151 ; (14|1-23)
152 S WR="",VAL=$$GET(.GL,2,3) I $G(VAL)'="" D
153 . S WR=$$XCN200^VDEFEL(VAL,"PHARMACIST")
154 ; (14|2-104)
155 S TP="",VAL=$$GET(.GL,2,10) I $G(VAL)'="" D
156 . S TP=$$XCN200^VDEFEL(VAL,"VERIFIER PHARM"),$P(WR,SEPR,2)=TP
157 I $G(WR)'="" S VAL=WR D PUT(14)
158 ; (15-.01)
159 S VAL=$$GET(.GL,0,1),VAL=$$REPL^PSOVDF1(VAL) D PUT(15)
160 ; (18-31)
161 S VAL=$$GET(.GL,2,13) I $G(VAL)'="" S VAL=$$HLDATE^HLFNC(VAL,"TS") I VAL>0 S VAL=$$REPL^PSOVDF1(VAL) D PUT(18)
162 ; (21|1-10.2=1 or 10)
163 S VAL="" I '$D(GL("SIG")) G RXE1B
164 I $P(GL("SIG"),U,2)=1 D
165 . I $D(GL("SIG1")) K TEMP M TEMP=GL("SIG1") S VAL=$$SSETX^PSOVDF3(.TEMP,SRC_"_10.2")
166 E S VAL=$$GET(.GL,"SIG",1) I $G(VAL)'="" S VAL=$$REPL^PSOVDF1(VAL),VAL=VAL_SEPC_SEPC_SRC_"_10"
167 D PUT(21)
168RXE1B ; (22-8)
169 S VAL=$$GET(.GL,0,8) I $G(VAL)'="" S VAL="D"_VAL,VAL=$$REPL^PSOVDF1(VAL) D PUT(22)
170 S WR="",VAL=$$GET(.GL,"TN",1)
171 I $G(VAL)'="" S VAL=$$REPL^PSOVDF1(VAL),WR=VAL_SEPC_SEPC_SRC_"_6.5"
172 D RXE1OF31^PSOVDF3,PUT(31)
173 ;
174 I $G(MSG)="" G RXE1Q
175 S MSG="RXE"_SEPF_MSG D OUT
176RXE1Q ; Q
177 ;
178RXR1 ; RXR ORIGINAL FILL
179 S MSG=""
180 I '$D(GL(6)) G RXR1Q
181 N PSOVRTE,PSORTX
182 K TEMP M TEMP=GL(6)
183 S PSORTX="",PSOVDFD1=0
184RXR1A S PSOVDFD1=$O(TEMP(PSOVDFD1)) G RXR1B:'PSOVDFD1
185 S PSORTX=$P($G(TEMP(PSOVDFD1,0)),U,7)
186 I $G(PSORTX)="" G RXR1A
187 I '$D(^PS(51.2,PSORTX,0)) G RXR1A
188 S PSOVRTE=$P(^PS(51.2,PSORTX,0),U),PSOVRTE=$$REPL^PSOVDF1(PSOVRTE),PSORTX=$$REPL^PSOVDF1(PSORTX)
189 S VAL=PSORTX_SEPC_PSOVRTE_SEPC_HLINST_"_52.0113_6"
190 I $G(MSG)'="" S MSG=MSG_SEPR_VAL
191 E S MSG=VAL
192 G RXR1A
193RXR1B I $G(MSG)="" G RXR1Q
194 S MSG="RXR"_SEPF_MSG D OUT
195RXR1Q ; Q
196 ;
197FT1 ;FT1 ORIGINAL FILL
198 S (MSG)=""
199 ; (4-22)
200 S VAL=$$GET(.GL,2,2)
201 I $G(VAL)'="" S VAL=$$HLDATE^HLFNC(VAL,"TS") I VAL>0 S VAL=$$REPL^PSOVDF1(VAL) D PUT(4)
202 S VAL="CG" D PUT(6)
203 S (VAL,VFT7)="" D FT1A7^PSOVDF3,PUT(7)
204 ; (12-17)
205 S VAL=$$GET(.GL,0,17),VAL=$$REPL^PSOVDF1(VAL) D PUT(12)
206 ; (18-3)
207 S TP="",TP=$$GET(.GL,0,3)
208 I $G(TP)'="" S VAL=$P($G(^PS(53,TP,0)),U,2),VAL=$$REPL^PSOVDF1(VAL) D PUT(18)
209 S VAL=$$GET(.GL,"OR1",5)
210 I $G(VAL)'="" S VAL=$$XCN200^VDEFEL(VAL,SRC_"_38") D PUT(20)
211 I $G(MSG)="" G FT1Q
212 S (VAL,CTR)=1 D PUT(1)
213 S MSG="FT1"_SEPF_MSG D OUT
214FT1Q ;
215 ;patch 261 - new FT1 seg seq 2 for original
216 D FT1S2^PSOVDF3
217 ;
218OBX1 ; OBX ORIGINAL FILL
219 S CTR=0
220 F FIELD=41,42,116,117,118,119,120,121,201 D OBXLP
221 G OBX1B
222 ;
223OBXLP ;
224 S MSG=""
225 N DIC,DR,DA,DIQ,PSOOVAR,PSOOVEN
226 S DIC=52,DR=FIELD,(DA,PSOOVEN)=PSOVDFD0,DIQ="PSOOVAR",DIQ(0)="IE" D EN^DIQ1 S VAL=$G(PSOOVAR(52,PSOOVEN,FIELD,"I"))
227 I $G(VAL)="" Q
228 N PSOOVALE S PSOOVALE=$G(PSOOVAR(52,PSOOVEN,FIELD,"E")),PSOOVALE=$$REPL^PSOVDF1(PSOOVALE)
229 N PSOVLVU D
230 .S PSOVLVU=$$GETVUID^XTID(52,FIELD,VAL) I $P($G(PSOVLVU),"^")'=0 S VAL=$$REPL^PSOVDF1(PSOVLVU)_SEPC_$G(PSOOVALE)_SEPC_"99VA_52_"_FIELD D PUT(5) Q
231 .S VAL=$$REPL^PSOVDF1(VAL),VAL=VAL_SEPC_$G(PSOOVALE)_SEPC_SRC_"_"_FIELD D PUT(5)
232 S CTR=CTR+1,VAL=CTR D PUT(1)
233 S VAL="CE" D PUT(2)
234 N DD D FIELD^DID(52,FIELD,"","LABEL","DD","ERR")
235 S VAL=$G(DD("LABEL")),VAL=$$REPL^PSOVDF1(VAL) D PUT(3)
236 S VAL="F" D PUT(11)
237 S MSG="OBX"_SEPF_MSG D OUT
238 Q
239 ;
240OBX1B ;
241 S MSG=""
242 ; (5-301)
243 S VAL=$$GET(.GL,"SAND",1)
244 I $G(VAL)'="" D CLOZ^PSOVDF3
245 ;
246OBX1C ;
247 S MSG=""
248 ; (5-302)
249 S VAL=$$GET(.GL,"SAND",2)
250 I $G(VAL)'="" D WBC^PSOVDF3
251 ;
252NTE1 ;
253 D REM^PSOVDF3
254 ;
255NTE1B ;
256 D PRC^PSOVDF3
257 ;
258NTE1C ;
259 D DEL^PSOVDF3
260NTE1Q Q
Note: See TracBrowser for help on using the repository browser.