1 | PXRMETX ; SLC/PJH - Run Extract for QUERI ;11:42 AM 17 Dec 2008
|
---|
2 | ;;2.0;CLINICAL REMINDERS;**4,6,7**;Feb 04, 2005;Build 1
|
---|
3 | ; Modified from FOIA VISTA,
|
---|
4 | ; Copyright (C) 2007 WorldVistA
|
---|
5 | ;
|
---|
6 | ; This program is free software; you can redistribute it and/or modify
|
---|
7 | ; it under the terms of the GNU General Public License as published by
|
---|
8 | ; the Free Software Foundation; either version 2 of the License, or
|
---|
9 | ; (at your option) any later version.
|
---|
10 | ;
|
---|
11 | ; This program is distributed in the hope that it will be useful,
|
---|
12 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | ; GNU General Public License for more details.
|
---|
15 | ;
|
---|
16 | ; You should have received a copy of the GNU General Public License
|
---|
17 | ; along with this program; if not, write to the Free Software
|
---|
18 | ; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
---|
19 | ;
|
---|
20 | ;
|
---|
21 | AUTO(ID,PURGE) ;Called from option scheduling (#19.2)
|
---|
22 | N IEN,LIST,LUVALUE,MODE,NEXT
|
---|
23 | S LUVALUE(1)=ID
|
---|
24 | D FIND^DIC(810.2,"","","U",.LUVALUE,"","","","","LIST")
|
---|
25 | ;Get ien of extract parameter
|
---|
26 | S IEN=$P(LIST("DILIST",2,1),U,1) Q:'IEN
|
---|
27 | ;Get next extract period
|
---|
28 | S NEXT=$P($G(^PXRM(810.2,IEN,0)),U,6) Q:NEXT=""
|
---|
29 | ;Node is Extract and Transmit
|
---|
30 | S MODE=$S($P($G(^PXRM(810.2,IEN,100)),U)="N":0,1:1)
|
---|
31 | ;Run extract
|
---|
32 | D RUN^PXRMETX(IEN,NEXT,MODE,PURGE)
|
---|
33 | ;Purge Extract Summary
|
---|
34 | D PRGES^PXRMETXU
|
---|
35 | ;Purge Patient Lists
|
---|
36 | D PRGPL^PXRMETXU
|
---|
37 | Q
|
---|
38 | ;
|
---|
39 | GETNAME(NAME,CLASS) ;Get the extract name.
|
---|
40 | I '$D(^PXRMXT(810.3,"B",NAME)) Q NAME
|
---|
41 | N CNT,NEW
|
---|
42 | S (CNT,NEW)=0
|
---|
43 | ;If name exists concatenate count
|
---|
44 | F D Q:NEW
|
---|
45 | .I '$D(^PXRMXT(810.3,"B",NAME)) S NEW=1 Q
|
---|
46 | .S CNT=CNT+1,NAME=$P(NAME,"/")_"/"_$$RJ^XLFSTR(CNT,2,0)
|
---|
47 | Q NAME
|
---|
48 | ;
|
---|
49 | IHD ;Monthly IHD Extract, called from option PXRM EXTRACT VA-IHD QUERI.
|
---|
50 | D AUTO("VA-IHD QUERI","Y")
|
---|
51 | Q
|
---|
52 | ;
|
---|
53 | MAIL(NAME,NEXT,MODE) ;Completion mail message
|
---|
54 | N FREQ,TEXT
|
---|
55 | S FREQ="year"
|
---|
56 | I $E(NEXT)="M" S FREQ="month"
|
---|
57 | I $E(NEXT)="Q" S FREQ="quarter"
|
---|
58 | ;
|
---|
59 | I MODE=0 S TEXT="Extract and Transmission"
|
---|
60 | I MODE=1 S TEXT="Extract (No Transmission)"
|
---|
61 | I MODE=2 S TEXT="Manual Extract and Transmission"
|
---|
62 | I MODE=3 S TEXT="Manual Extract (No Transmission)"
|
---|
63 | ;
|
---|
64 | S TEXT=NAME_" "_TEXT_" completed for "_FREQ_" "_NEXT
|
---|
65 | D MES^PXRMEUT(TEXT)
|
---|
66 | Q
|
---|
67 | ;
|
---|
68 | MH ;Monthly MH Extract, called from option PXRM EXTRACT VA-MH QUERI.
|
---|
69 | D AUTO("VA-MH QUERI","Y")
|
---|
70 | Q
|
---|
71 | ;
|
---|
72 | ;Begin WV change wv/so 12/17/2008
|
---|
73 | ;
|
---|
74 | ACAD ;Auto CAD entry point
|
---|
75 | D AUTO("VOE DOQ-IT CAD EXTRACTION")
|
---|
76 | Q
|
---|
77 | ;
|
---|
78 | ADM ;Auto DM entry point
|
---|
79 | D AUTO("VOE DOQ-IT DM EXTRACTION")
|
---|
80 | Q
|
---|
81 | ;
|
---|
82 | AHF ;Auto HF entry point
|
---|
83 | D AUTO("VOE DOQ-IT HF EXTRACTION")
|
---|
84 | Q
|
---|
85 | ;
|
---|
86 | AHTN ;Auto HTN entry point
|
---|
87 | D AUTO("VOE DOQ-IT HTN EXTRACTION")
|
---|
88 | Q
|
---|
89 | ;
|
---|
90 | APC ;Auto PC entry point
|
---|
91 | D AUTO("VOE DOQ-IT PC EXTRACTION")
|
---|
92 | Q
|
---|
93 | ;End WV change
|
---|
94 | ;
|
---|
95 | RUN(IEN,NEXT,MODE,PURGE) ;Process extract parameter
|
---|
96 | ; IEN is ien of Extract Parameter
|
---|
97 | ; NEXT is period to extract
|
---|
98 | ; MODE = 0 is extract and transmission
|
---|
99 | ; MODE = 1 is extract only
|
---|
100 | ; MODE = 2 is manual extract and transmission (doesn't update 810.2)
|
---|
101 | ; MODE = 3 is manual extract only (doesn't update 810.2)
|
---|
102 | ;
|
---|
103 | N CLASS,FDA,FDAIEN,MSG
|
---|
104 | N PXRMIDOD,PXRMLIST,PXRMNODE,PXRMRULE,PXRMSTRT,PXRMXIEN,PATCREAT,XNAME
|
---|
105 | N ITER
|
---|
106 | ;Initialise
|
---|
107 | K ^TMP("PXRMETX",$J),^TMP("PXRMETX1",$J)
|
---|
108 | ;Workfile node for ^TMP
|
---|
109 | S PXRMNODE="PXRMRULE"
|
---|
110 | ;Get details from parameter file
|
---|
111 | N DATA,INDP,INTP,LIST,NAME,PARTYPE,PERIOD,SNAME,TEXT,YEAR
|
---|
112 | ;Get class from extract parameter
|
---|
113 | S CLASS=$P($G(^PXRM(810.2,IEN,100)),U)
|
---|
114 | ;Otherwise default to local
|
---|
115 | I $G(CLASS)="" S CLASS="L"
|
---|
116 | ;
|
---|
117 | S DATA=$G(^PXRM(810.2,IEN,0))
|
---|
118 | ;Determine Extract Name and period
|
---|
119 | S NAME=$P(DATA,U),PARTYPE=$P(DATA,U,2)
|
---|
120 | S YEAR=$P(NEXT,"/",2),PERIOD=$P(NEXT,"/")
|
---|
121 | ;Calculate report period start and end dates
|
---|
122 | D CALC^PXRMEUT(NEXT,.PXRMSTRT,.PXRMSTOP)
|
---|
123 | ;Determine output name for patient list and extract summary
|
---|
124 | S XNAME=NAME_" "_YEAR_" "_PERIOD
|
---|
125 | S NAME=$$GETNAME(XNAME)
|
---|
126 | S ITER=$P(NAME,"/",2)
|
---|
127 | ;Process (single) Denominator rule into patient list
|
---|
128 | N SEQ,SUB
|
---|
129 | S SEQ=""
|
---|
130 | F S SEQ=$O(^PXRM(810.2,IEN,10,"B",SEQ)) Q:'SEQ D
|
---|
131 | .S SUB=$O(^PXRM(810.2,IEN,10,"B",SEQ,"")) Q:'SUB
|
---|
132 | .S DATA=$G(^PXRM(810.2,IEN,10,SUB,0)) Q:DATA=""
|
---|
133 | .S PXRMRULE=$P(DATA,U,2) Q:'PXRMRULE
|
---|
134 | .S LIST=$P(DATA,U,3) Q:LIST=""
|
---|
135 | .I LIST["yyyy" S LIST=$P(LIST,"yyyy")_YEAR_$P(LIST,"yyyy",2)
|
---|
136 | .I LIST["nn" S LIST=$P(LIST,"nn")_$E(PERIOD,2,10)_$P(LIST,"nn",2)
|
---|
137 | .S INDP=+$P(DATA,U,4)
|
---|
138 | .S INTP=+$P(DATA,U,5)
|
---|
139 | .;Create new patient list
|
---|
140 | .I ITER'="" S LIST=LIST_"/"_ITER
|
---|
141 | .S PATCREAT="Y",PXRMLIST=$$CRLST^PXRMRUL1(LIST,CLASS) Q:'PXRMLIST
|
---|
142 | .;
|
---|
143 | .D START^PXRMRULE(PXRMRULE,PXRMLIST,PXRMNODE,PXRMSTRT,PXRMSTOP,IEN,YEAR,PERIOD,INDP,INTP,ITER)
|
---|
144 | .;Clear ^TMP lists created for rule
|
---|
145 | .D CLEAR^PXRMRULE(PXRMRULE,PXRMNODE)
|
---|
146 | .;Process reminders and finding rules
|
---|
147 | .;If include deceased patients is true then set the flag so reminders
|
---|
148 | .;will be evaluated for deceased patients.
|
---|
149 | .S PXRMIDOD=$S(INDP:1,1:0)
|
---|
150 | .D REM^PXRMETXR(SUB,PXRMLIST,PXRMSTRT,PXRMSTOP,PARTYPE)
|
---|
151 | ;
|
---|
152 | ;Get the name
|
---|
153 | ;S NAME=$$GETNAME(XNAME)
|
---|
154 | ;Create extract summary entry
|
---|
155 | S FDA(810.3,"+1,",.01)=NAME
|
---|
156 | S FDA(810.3,"+1,",.02)=PXRMSTRT
|
---|
157 | S FDA(810.3,"+1,",.03)=PXRMSTOP
|
---|
158 | S FDA(810.3,"+1,",.06)=$$NOW^XLFDT
|
---|
159 | S FDA(810.3,"+1,",1)=IEN
|
---|
160 | S FDA(810.3,"+1,",2)=PARTYPE
|
---|
161 | S FDA(810.3,"+1,",3)=$E(PERIOD,2,99)
|
---|
162 | S FDA(810.3,"+1,",4)=YEAR
|
---|
163 | S FDA(810.3,"+1,",5)=$S(MODE<2:"A",1:"M")
|
---|
164 | S FDA(810.3,"+1,",7)=$E(PERIOD)
|
---|
165 | I PURGE="Y" S FDA(810.3,"+1,",50)=1
|
---|
166 | S FDA(810.3,"+1,",100)=CLASS
|
---|
167 | D UPDATE^DIE("","FDA","FDAIEN","MSG")
|
---|
168 | I $D(MSG) D AWRITE^PXRMUTIL("MSG") G EXIT
|
---|
169 | ;
|
---|
170 | ;Update extract summary from ^TMP
|
---|
171 | D UPDEX(FDAIEN(1))
|
---|
172 | ;
|
---|
173 | ;Transmit results
|
---|
174 | I (MODE=0)!(MODE=2) D TRANS(FDAIEN(1))
|
---|
175 | ;
|
---|
176 | ;Update extract parameters
|
---|
177 | I MODE<2 D UPDPAR
|
---|
178 | ;
|
---|
179 | ;Mail message that extract completed
|
---|
180 | D MAIL(NAME,NEXT,MODE)
|
---|
181 | ;
|
---|
182 | EXIT ;Clear workfile
|
---|
183 | K ^TMP("PXRMETX",$J),^TMP("PXRMETX1",$J)
|
---|
184 | Q
|
---|
185 | ;
|
---|
186 | TRANS(PXRMXIEN) ;Transmit HL7 messages
|
---|
187 | N HL7ID,NAME,NEXT
|
---|
188 | S HL7ID=""
|
---|
189 | D HL7^PXRM7API(PXRMXIEN,1,.HL7ID)
|
---|
190 | H 2
|
---|
191 | ;Lock extract summary
|
---|
192 | D LOCK(PXRMXIEN) Q:$D(DUOUT)
|
---|
193 | ;Update run information
|
---|
194 | S NAME=$P($G(^PXRMXT(810.3,PXRMXIEN,0)),U)
|
---|
195 | S NEXT=$P($G(^PXRMXT(810.3,PXRMXIEN,4)),U,3)
|
---|
196 | S FDA(810.3,"?1,",.01)=NAME
|
---|
197 | S FDA(810.36,"?+2,?1,",.01)=HL7ID
|
---|
198 | S FDA(810.36,"?+2,?1,",.02)=$$NOW^XLFDT
|
---|
199 | D UPDATE^DIE("","FDA","","MSG")
|
---|
200 | ;Unlock extract summary
|
---|
201 | D UNLOCK(PXRMXIEN)
|
---|
202 | Q
|
---|
203 | ;
|
---|
204 | UPDEX(IEN) ;Update extract summary
|
---|
205 | N DUOUT
|
---|
206 | ;Lock extract summary
|
---|
207 | D LOCK(IEN) Q:$D(DUOUT)
|
---|
208 | ;
|
---|
209 | ;Update totals section
|
---|
210 | N APPL,CNT,DFN,DUE,DATA,ETYP,EVAL
|
---|
211 | N FAPPL,FCNT,FDATA,FDUE,FEVAL,FGNAM,FGSTA,FIND,FNAPPL,FNDUE,FSEQ
|
---|
212 | N GDATA,GSEQ,INST,NAPPL,NDUE,PCNT,PXRMLIST,RCNT,RIEN,RSEQ,SEQ,TEMP
|
---|
213 | S SEQ="",CNT=1,RSEQ=0
|
---|
214 | F S SEQ=$O(^TMP("PXRMETX",$J,SEQ)) Q:SEQ="" D
|
---|
215 | .S INST=0
|
---|
216 | .F S INST=$O(^TMP("PXRMETX",$J,SEQ,INST)) Q:'INST D
|
---|
217 | ..S RCNT=""
|
---|
218 | ..F S RCNT=$O(^TMP("PXRMETX",$J,SEQ,INST,RCNT)) Q:RCNT="" D
|
---|
219 | ...S DATA=$G(^TMP("PXRMETX",$J,SEQ,INST,RCNT)) Q:'DATA
|
---|
220 | ...S RIEN=$P(DATA,U,1),EVAL=$P(DATA,U,2),APPL=$P(DATA,U,3)
|
---|
221 | ...S NAPPL=$P(DATA,U,4),DUE=$P(DATA,U,5),NDUE=$P(DATA,U,6)
|
---|
222 | ...S PXRMLIST=$P(DATA,U,7)
|
---|
223 | ...S CNT=CNT+1,RSEQ=RSEQ+1
|
---|
224 | ...S TEMP=$$RJ^XLFSTR(RSEQ,3,0)_U_RIEN_U_INST_U_PXRMLIST_U_EVAL_U_APPL_U_NAPPL_U_DUE_U_NDUE
|
---|
225 | ...S ^PXRMXT(810.3,IEN,3,RSEQ,0)=TEMP
|
---|
226 | ...S ^PXRMXT(810.3,IEN,3,"B",$P(TEMP,U,1),RSEQ)=""
|
---|
227 | ...;For each count type
|
---|
228 | ...S GSEQ="",FCNT=0
|
---|
229 | ...F S GSEQ=$O(^TMP("PXRMETX1",$J,SEQ,RCNT,GSEQ)) Q:GSEQ="" D
|
---|
230 | ....S GDATA=$G(^TMP("PXRMETX1",$J,SEQ,RCNT,GSEQ))
|
---|
231 | ....S FGNAM=$P(GDATA,U),ETYP=$P(GDATA,U,2),FGSTA=$P(GDATA,U,3)
|
---|
232 | ....;For each term
|
---|
233 | ....S FSEQ=0
|
---|
234 | ....F S FSEQ=$O(^TMP("PXRMETX1",$J,SEQ,RCNT,GSEQ,FSEQ)) Q:FSEQ="" D
|
---|
235 | .....;Get the term ien
|
---|
236 | .....S FIND=$P($G(^TMP("PXRMETX1",$J,SEQ,RCNT,GSEQ,FSEQ)),U),FCNT=FCNT+1
|
---|
237 | .....;Update finding totals
|
---|
238 | .....S FDATA=$G(^TMP("PXRMETX",$J,SEQ,INST,RCNT,GSEQ,FSEQ))
|
---|
239 | .....S FEVAL=$P(FDATA,U,2),FAPPL=$P(FDATA,U,3),FNAPPL=$P(FDATA,U,4)
|
---|
240 | .....S FDUE=$P(FDATA,U,5),FNDUE=$P(FDATA,U,6)
|
---|
241 | .....S TEMP=FSEQ_U_$P(FIND,";")_U_ETYP_U_FEVAL_U_FAPPL_U_FNAPPL_U_FDUE_U_FNDUE_U_FGNAM_U_FGSTA
|
---|
242 | .....S ^PXRMXT(810.3,IEN,3,RSEQ,1,FCNT,0)=TEMP
|
---|
243 | .....;
|
---|
244 | .....;AGP REMOVE UNTIL A DECISION CAN BE MADE
|
---|
245 | .....;S DFN=0,PCNT=0
|
---|
246 | .....;F S DFN=$O(^TMP("PXRMETX",$J,SEQ,INST,RCNT,GSEQ,FSEQ,DFN)) Q:DFN'>0 D
|
---|
247 | .....;.S PCNT=PCNT+1,^PXRMXT(810.3,IEN,3,RSEQ,1,FCNT,1,PCNT,0)=DFN
|
---|
248 | .....;I PCNT>0 S ^PXRMXT(810.3,IEN,3,RSEQ,1,FCNT,1,0)="^810.3316PA"_U_PCNT_U_PCNT
|
---|
249 | ....I FCNT>0 S ^PXRMXT(810.3,IEN,3,RSEQ,1,0)="^810.331I"_U_FCNT_U_FCNT
|
---|
250 | .I RSEQ>0 S ^PXRMXT(810.3,IEN,3,0)="^810.33I"_U_RSEQ_U_RSEQ
|
---|
251 | ;Unlock extract summary
|
---|
252 | D UNLOCK(IEN)
|
---|
253 | Q
|
---|
254 | ;
|
---|
255 | ;File locking
|
---|
256 | LOCK(PXRMXIEN) L +^PXRMXT(810.3,PXRMXIEN):0
|
---|
257 | I '$T W !!?5,"Another user is using this extract summary" S DUOUT=1
|
---|
258 | Q
|
---|
259 | ;
|
---|
260 | UNLOCK(PXRMXIEN) L -^PXRMXT(810.3,PXRMXIEN) Q
|
---|
261 | ;
|
---|
262 | UPDPAR ;Update parameters when run complete
|
---|
263 | N DATA,LAST,NEXT,PERIOD,TYPE,YEAR
|
---|
264 | S DATA=$G(^PXRM(810.2,IEN,0)),NEXT=$P(DATA,U,6),TYPE=$P(DATA,U,3)
|
---|
265 | ;Last run updated
|
---|
266 | S LAST=NEXT
|
---|
267 | ;Calculate next run
|
---|
268 | I TYPE="Y" S NEXT=NEXT+1
|
---|
269 | I "QM"[TYPE D
|
---|
270 | .N NUM
|
---|
271 | .S PERIOD=$P(NEXT,"/",1),YEAR=$P(NEXT,"/",2)
|
---|
272 | .S NUM=$P(PERIOD,TYPE,2)+1
|
---|
273 | .I TYPE="Q",NUM>4 S NUM=1,YEAR=YEAR+1
|
---|
274 | .I TYPE="M",NUM>12 S NUM=1,YEAR=YEAR+1
|
---|
275 | .S NEXT=TYPE_NUM_"/"_YEAR
|
---|
276 | ;Update last and next run fields
|
---|
277 | S $P(^PXRM(810.2,IEN,0),U,4,6)=LAST_U_$$NOW^XLFDT_U_NEXT
|
---|
278 | Q
|
---|
279 | ;
|
---|