Produced by Araxis Merge on 3/25/2019 8:58:06 AM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
# | Location | File | Last Modified |
---|---|---|---|
1 | C:\AraxisMergeCompare\Pri_un\IMAG_Source\VISA\Java\VistaImagingDataSourceProvider\main\src\java\gov\va\med\imaging\protocol\vista | VistaImagingTranslator.java | Mon Mar 18 20:39:11 2019 UTC |
2 | C:\AraxisMergeCompare\Pri_re\IMAG_Source\VISA\Java\VistaImagingDataSourceProvider\main\src\java\gov\va\med\imaging\protocol\vista | VistaImagingTranslator.java | Tue Mar 19 15:13:34 2019 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 2 | 6402 |
Changed | 1 | 2 |
Inserted | 0 | 0 |
Removed | 0 | 0 |
Whitespace | |
---|---|
Character case | Differences in character case are significant |
Line endings | Differences in line endings (CR and LF characters) are ignored |
CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
1 | package go v.va.med.i maging.pro tocol.vist a; | |
2 | ||
3 | import jav a.text.Par seExceptio n; | |
4 | import jav a.text.Sim pleDateFor mat; | |
5 | import jav a.util.Arr ayList; | |
6 | import jav a.util.Col lection; | |
7 | import jav a.util.Dat e; | |
8 | import jav a.util.Enu meration; | |
9 | import jav a.util.Has hMap; | |
10 | import jav a.util.Has hSet; | |
11 | import jav a.util.Ite rator; | |
12 | import jav a.util.Lin kedList; | |
13 | import jav a.util.Lis t; | |
14 | import jav a.util.Loc ale; | |
15 | import jav a.util.Map ; | |
16 | import jav a.util.Set ; | |
17 | import jav a.util.Sor tedSet; | |
18 | import jav a.util.Tre eSet; | |
19 | ||
20 | import org .apache.lo gging.log4 j.LogManag er; | |
21 | import org .apache.lo gging.log4 j.Logger; | |
22 | ||
23 | import gov .va.med.He althSummar yURN; | |
24 | import gov .va.med.Pa tientIdent ifier; | |
25 | import gov .va.med.Ro utingToken ; | |
26 | import gov .va.med.im aging.Stor edStudyFil terURN; | |
27 | import gov .va.med.im aging.Stri ngUtil; | |
28 | import gov .va.med.im aging.Stud yURN; | |
29 | import gov .va.med.im aging.core .interface s.exceptio ns.MethodE xception; | |
30 | import gov .va.med.im aging.exce ptions.URN FormatExce ption; | |
31 | import gov .va.med.im aging.exch ange.busin ess.Applic ationTimeo utParamete rs; | |
32 | import gov .va.med.im aging.exch ange.busin ess.Divisi on; | |
33 | import gov .va.med.im aging.exch ange.busin ess.Electr onicSignat ureResult; | |
34 | import gov .va.med.im aging.exch ange.busin ess.Health SummaryTyp e; | |
35 | import gov .va.med.im aging.exch ange.busin ess.Image; | |
36 | import gov .va.med.im aging.exch ange.busin ess.ImageA ccessReaso n; | |
37 | import gov .va.med.im aging.exch ange.busin ess.Patien t; | |
38 | import gov .va.med.im aging.exch ange.busin ess.Patien t.PatientS ex; | |
39 | import gov .va.med.im aging.exch ange.busin ess.Patien tSensitive Value; | |
40 | import gov .va.med.im aging.exch ange.busin ess.Series ; | |
41 | import gov .va.med.im aging.exch ange.busin ess.Site; | |
42 | import gov .va.med.im aging.exch ange.busin ess.Stored StudyFilte r; | |
43 | import gov .va.med.im aging.exch ange.busin ess.Study; | |
44 | import gov .va.med.im aging.exch ange.busin ess.StudyF ilter; | |
45 | import gov .va.med.im aging.exch ange.busin ess.User; | |
46 | import gov .va.med.im aging.exch ange.busin ess.storag e.Artifact Instance; | |
47 | import gov .va.med.im aging.exch ange.busin ess.util.E xchangeUti l; | |
48 | import gov .va.med.im aging.exch ange.enums .ImageAcce ssReasonTy pe; | |
49 | import gov .va.med.im aging.exch ange.enums .ObjectOri gin; | |
50 | import gov .va.med.im aging.exch ange.enums .PatientSe nsitivityL evel; | |
51 | import gov .va.med.im aging.exch ange.enums .StudyDele tedImageSt ate; | |
52 | import gov .va.med.im aging.exch ange.enums .StudyLoad Level; | |
53 | import gov .va.med.im aging.exch ange.trans lation.exc eptions.Tr anslationE xception; | |
54 | import gov .va.med.im aging.prot ocol.vista .exception s.Artifact ParsingExc eption; | |
55 | import gov .va.med.im aging.prot ocol.vista .exception s.ImagePar singExcept ion; | |
56 | import gov .va.med.im aging.prot ocol.vista .exception s.SeriesPa rsingExcep tion; | |
57 | import gov .va.med.im aging.prot ocol.vista .exception s.StudyPar singExcept ion; | |
58 | import gov .va.med.im aging.prot ocol.vista .exception s.VistaPar singExcept ion; | |
59 | import gov .va.med.im aging.tran sactioncon text.Trans actionCont extFactory ; | |
60 | import gov .va.med.im aging.url. vista.Encr yptionUtil s; | |
61 | import gov .va.med.im aging.url. vista.Stri ngUtils; | |
62 | import gov .va.med.im aging.url. vista.exce ptions.Vis taMethodEx ception; | |
63 | import gov .va.med.im aging.url. vista.imag e.NetworkL ocation; | |
64 | import gov .va.med.im aging.url. vista.imag e.SitePara meterCrede ntials; | |
65 | import gov .va.med.im aging.vist aimagingda tasource.c ommon.Vist aImagingCo mmonUtilit ies; | |
66 | import gov .va.med.im aging.vist aobjects.C prsIdentif ierImages; | |
67 | import gov .va.med.im aging.vist aobjects.V istaGroup; | |
68 | import gov .va.med.im aging.vist aobjects.V istaImage; | |
69 | import gov .va.med.im aging.vist aobjects.V istaPatien t; | |
70 | import gov .va.med.im aging.vist aobjects.V istaPatien tPhotoIDIn formation; | |
71 | ||
72 | /** | |
73 | * | |
74 | * @author DNS werfej | |
75 | * | |
76 | */ | |
77 | public cla ss VistaIm agingTrans lator | |
78 | { | |
79 | pr ivate stat ic Logger logger = L ogManager. getLogger( VistaImagi ngTranslat or.class); | |
80 | ||
81 | pr ivate stat ic final S tring unkn ownPatient = "00000V 000000"; | |
82 | ||
83 | /* * | |
84 | * Convert t he returne d String v alue from an RPC cal l to a Pat ientSensit iveValue. | |
85 | * | |
86 | * @param rt n | |
87 | * @param pa tientDfn | |
88 | * @return | |
89 | * @throws V istaMethod Exception | |
90 | * / | |
91 | pu blic stati c PatientS ensitiveVa lue conver tStringToP atientSens itiveValue (String rt n, String patientDfn ) | |
92 | th rows Vista MethodExce ption | |
93 | { | |
94 | if( (rtn == nu ll) || (rt n.equals(" -1")) ) | |
95 | { | |
96 | String msg = "Er ror respon se while c hecking pa tient sens itivity fo r patient; DFN=" + p atientDfn; | |
97 | logger .error(msg ); | |
98 | throw new VistaM ethodExcep tion(msg); | |
99 | } | |
100 | Stri ng [] line s = rtn.sp lit(String Utils.NEW_ LINE); | |
101 | if(l ines.lengt h <= 0) | |
102 | { | |
103 | String msg = "Er ror parsin g response from chec king patie nt sensiti ve; DFN=" + patientD fn; | |
104 | logger .error(msg ); | |
105 | logger .error("Vi stA Respon se [" + rt n + "]"); | |
106 | throw new VistaM ethodExcep tion(msg); | |
107 | } | |
108 | int code = Int eger.parse Int(lines[ 0].trim()) ; | |
109 | logg er.info("P atient Sen sitive lev el for pat ient (DFN) : '" + pat ientDfn + "' is '" + code + "' "); | |
110 | Pati entSensiti vityLevel sensitiveL evel = Pat ientSensit ivityLevel .getPatien tSensitivi tyLevel(co de); | |
111 | Stri ngBuilder sb = new S tringBuild er(); | |
112 | for( int i = 1; i < lines .length; i ++) | |
113 | { | |
114 | sb.app end(lines[ i]); | |
115 | if(i ! = (lines.l ength - 1) ) | |
116 | sb.appen d("\n"); | |
117 | } | |
118 | ||
119 | retu rn new Pat ientSensit iveValue(s ensitiveLe vel, sb.to String()); | |
120 | } | |
121 | ||
122 | /* * | |
123 | * Extract t he name of a server share from a complet e UNC path . | |
124 | * | |
125 | * @param un cPath | |
126 | * @return | |
127 | * / | |
128 | pu blic stati c String e xtractServ erShare(St ring uncPa th) | |
129 | { | |
130 | Stri ng imgPath = uncPath ; | |
131 | if(i mgPath.sta rtsWith("\ \\\")) | |
132 | imgPat h = imgPat h.substrin g(2); | |
133 | ||
134 | Stri ng server = StringUt ils.Piece( imgPath, " \\", 1); | |
135 | Stri ng share = StringUti ls.Piece(i mgPath, "\ \", 2); | |
136 | Stri ng serverS hare = "\\ \\" + serv er + "\\" + share; | |
137 | ||
138 | retu rn serverS hare; | |
139 | } | |
140 | ||
141 | /* * | |
142 | * Get the s erver shar e from an Image inst ance. | |
143 | * The serve r share is the serve r share of one of (i n preferre d order) | |
144 | * 1.) the i mage Full filename | |
145 | * 2.) the i mage Abs f ilename | |
146 | * 3.) the i mage Big f ilename | |
147 | * 4.) a zer o length s tring | |
148 | * | |
149 | * @param im age | |
150 | * @return | |
151 | * / | |
152 | pu blic stati c String e xtractServ erShare(Im age image) | |
153 | { | |
154 | if(i mage == nu ll) | |
155 | { | |
156 | logger .info("Ima ge is null , returnin g empty se rver share "); | |
157 | return ""; | |
158 | } | |
159 | ||
160 | if( image.getF ullFilenam e() != nul l && image .getFullFi lename().l ength() > 0 ) | |
161 | { | |
162 | logger .info("Usi ng FULL fi le path [" + image.g etFullFile name() + " ] for imag e [" + ima ge.getIen( ) + "] for server sh are."); | |
163 | return extractSe rverShare( image.get FullFilena me().toLow erCase() ) ; | |
164 | } | |
165 | ||
166 | if( image.getA bsFilename () != null && image. getAbsFile name().len gth() > 0 ) | |
167 | { | |
168 | logger .info("Usi ng ABS fil e path [" + image.ge tAbsFilena me() + "] for image [" + image .getIen() + "] for s erver shar e."); | |
169 | return extractSe rverShare( image.get AbsFilenam e().toLowe rCase() ); | |
170 | } | |
171 | ||
172 | if( image.getB igFilename () != null && image. getBigFile name().len gth() > 0 ) | |
173 | { | |
174 | logger .info("Usi ng BIG fil e path [" + image.ge tBigFilena me() + "] for image [" + image .getIen() + "] for s erver shar e."); | |
175 | return extractSe rverShare( image.get BigFilenam e().toLowe rCase() ); | |
176 | } | |
177 | ||
178 | logg er.info("N o file pat hs specifi ed in imag e [" + ima ge.getIen( ) + "]."); | |
179 | retu rn ""; | |
180 | } | |
181 | ||
182 | /* * | |
183 | * | |
184 | * @param rt n | |
185 | * @return | |
186 | * @throws E xception | |
187 | * / | |
188 | pu blic stati c String p arseOption Number(Str ing rtn) | |
189 | th rows Excep tion | |
190 | { | |
191 | Stri ng[] lines = StringU tils.Split (rtn, Stri ngUtils.CR LF); | |
192 | if ( !lines[0]. equals("[D ata]")) { | |
193 | throw new Except ion("Inval id return format (" + rtn + ") "); | |
194 | } | |
195 | if ( lines[1].s tartsWith( "[BEGIN_di ERRORS]")) { | |
196 | throw new Except ion(rtn.su bstring(8) ); | |
197 | } | |
198 | if ( lines.leng th == 1) | |
199 | throw new Except ion("No op tion numbe r data"); | |
200 | ||
201 | int p = lines[ 1].indexOf (",^"); | |
202 | Stri ng optNum = lines[1] .substring (p + 2); | |
203 | if( !StringUti ls.isNumer ic(optNum) ) | |
204 | throw new Except ion("Non-n umeric opt ion number "); | |
205 | ||
206 | retu rn optNum; | |
207 | } | |
208 | ||
209 | /* * | |
210 | * Takes a V ista respo nse like: | |
211 | * 1^Class: CLIN - | |
212 | * Item~S2^S ite^Note T itle~~W0^P roc DT~S1^ Procedure^ # Img~S2^S hort Desc^ Pkg^Class^ Type^Speci alty^Event ^Origin^Ca p Dt~S1~W0 ^Cap by~~W 0^Image ID ~S2~W0 | |
213 | * 1^WAS^NUR SING NOTE^ 09/28/2001 00:01^NOT E^2^CONSUL T NURSE ME DICAL WOUN D SPEC INP T^NOTE^CLI N^CONSULT^ NURSING^WO UND ASSESS MENT^VA^09 /28/2001 0 1:35^IMAGP ROVIDERONE TWOSIX,ONE TWOSIX^175 2|1752^\\I SW-IMGGOLD BACK\image 1$\DM\00\1 7\DM001753 .JPG^\\ISW -IMGGOLDBA CK\image1$ \DM\00\17\ DM001753.A BS^CONSULT NURSE MED ICAL WOUND SPEC INPT ^3010928^1 1^NOTE^09/ 28/2001^36 ^M^A^^^2^1 ^WAS^^^711 ^IMAGPATIE NT1055,105 5^CLIN^^^ | |
214 | * 2^WAS^OPH THALMOLOGY ^08/20/200 1 00:01^OP H^10^Ophth almology^N OTE^CLIN^I MAGE^EYE C ARE^^VA^08 /20/2001 2 2:32^IMAGP ROVIDERONE TWOSIX,ONE TWOSIX^178 3|1783^\\I SW-IMGGOLD BACK\image 1$\DM\00\1 7\DM001784 .DCM^\\ISW -IMGGOLDBA CK\image1$ \DM\00\17\ DM001784.A BS^Ophthal mology^301 0820^11^OP H^08/20/20 01^41^M^A^ ^^10^1^WAS ^^^711^IMA GPATIENT10 55,1055^CL IN^^^^ | |
215 | * | |
216 | * and creat e a sorted set of Vi staGroup i nstances. | |
217 | * | |
218 | * @param gr oupList | |
219 | * @return | |
220 | * / | |
221 | public static So rtedSet<Vi staGroup> createGrou psFromGrou pLines( | |
222 | Si te site, | |
223 | St ring group List, | |
224 | Pa tientIdent ifier pati entIdentif ier, | |
225 | St udyDeleted ImageState studyDele tedImageSt ate) | |
226 | throws VistaPars ingExcepti on | |
227 | { | |
228 | So rtedSet<Vi staGroup> groups = n ew TreeSet <VistaGrou p>(); | |
229 | St ring heade rLine = "" ; | |
230 | if (groupList .charAt(0) == '1') | |
231 | { | |
232 | String [] lines = StringUti ls.Split(g roupList, StringUtil s.NEW_LINE ); | |
233 | // the first two lines of the respon se contain the respo nse status and the m etadata, r espectivel y | |
234 | if(lin es.length <= 0) | |
235 | throw ne w VistaPar singExcept ion("Study list cont ains no st atus, meta -data or d ata."); | |
236 | if(lin es.length == 1) | |
237 | throw ne w VistaPar singExcept ion("Study list cont ains no me ta-data or data."); | |
238 | if(lin es.length == 2) | |
239 | { | |
240 | logger.i nfo("Study list cont ains no da ta."); | |
241 | return g roups; | |
242 | } | |
243 | logger .info("Fou nd and par sing [" + lines.leng th + "] li nes of gro up data fo r patient '" + patie ntIdentifi er + "'"); | |
244 | // par se the res ponse stat us line an d retain t he ??? | |
245 | String rpcRespon seLine = l ines[0].tr im(); | |
246 | String response = StringUt ils.MagPie ce(rpcResp onseLine, StringUtil s.CARET, 2 ); | |
247 | ||
248 | // the headerLin e is the m etadata, d escribes t he format of the stu dy results | |
249 | // sav e it and p ass to the method th at actuall y parses t he study l ines | |
250 | header Line = lin es[1]; | |
251 | ||
252 | // for each rema ining line in the re sponse, pa rse a Stud y instance and add i t | |
253 | // to our list | |
254 | for(in t j = 2; j < lines.l ength; j++ ) | |
255 | { | |
256 | VistaGro up group; | |
257 | try | |
258 | { | |
259 | group = cr eateGroupF romGroupLi ne(site, h eaderLine, lines[j], patientId entifier, | |
260 | stud yDeletedIm ageState); | |
261 | if(group ! = null) | |
262 | { | |
263 | gr oup.setRpc ResponseMs g(response ); | |
264 | if ( ! groups .add(group ) ) | |
265 | logg er.warn("D uplicate g roup, IEN= '" + group .getIen() + "' is no t being ad ded to res ult set.") ; | |
266 | } | |
267 | } | |
268 | catch (U RNFormatEx ception x) | |
269 | { | |
270 | throw new VistaParsi ngExceptio n(x); | |
271 | } | |
272 | } | |
273 | } | |
274 | ||
275 | // p ut the pat ient ICN f ield into the groups | |
276 | for( VistaGroup group : g roups) | |
277 | group. setPatient Identifier (patientId entifier); | |
278 | ||
279 | ||
280 | re turn group s; | |
281 | } | |
282 | ||
283 | /** | |
284 | * THI S SHOULD O NLY BE USE D IF NOT U SING GET P ATIENT STU DY GRAPH R PC - This is for old (non patc h 83) site s | |
285 | * | |
286 | * Takes a V ista respo nse like: | |
287 | * 1^Class: CLIN - | |
288 | * Item~S2^S ite^Note T itle~~W0^P roc DT~S1^ Procedure^ # Img~S2^S hort Desc^ Pkg^Class^ Type^Speci alty^Event ^Origin^Ca p Dt~S1~W0 ^Cap by~~W 0^Image ID ~S2~W0 | |
289 | * 1^WAS^NUR SING NOTE^ 09/28/2001 00:01^NOT E^2^CONSUL T NURSE ME DICAL WOUN D SPEC INP T^NOTE^CLI N^CONSULT^ NURSING^WO UND ASSESS MENT^VA^09 /28/2001 0 1:35^IMAGP ROVIDERONE TWOSIX,ONE TWOSIX^175 2|1752^\\I SW-IMGGOLD BACK\image 1$\DM\00\1 7\DM001753 .JPG^\\ISW -IMGGOLDBA CK\image1$ \DM\00\17\ DM001753.A BS^CONSULT NURSE MED ICAL WOUND SPEC INPT ^3010928^1 1^NOTE^09/ 28/2001^36 ^M^A^^^2^1 ^WAS^^^711 ^IMAGPATIE NT1055,105 5^CLIN^^^ | |
290 | * 2^WAS^OPH THALMOLOGY ^08/20/200 1 00:01^OP H^10^Ophth almology^N OTE^CLIN^I MAGE^EYE C ARE^^VA^08 /20/2001 2 2:32^IMAGP ROVIDERONE TWOSIX,ONE TWOSIX^178 3|1783^\\I SW-IMGGOLD BACK\image 1$\DM\00\1 7\DM001784 .DCM^\\ISW -IMGGOLDBA CK\image1$ \DM\00\17\ DM001784.A BS^Ophthal mology^301 0820^11^OP H^08/20/20 01^41^M^A^ ^^10^1^WAS ^^^711^IMA GPATIENT10 55,1055^CL IN^^^^ | |
291 | * | |
292 | * | |
293 | * @param st udyList | |
294 | * @return | |
295 | * / | |
296 | public static So rtedSet<Vi staGroup> createGrou psFromGrou pLinesHand leSingleIm ageGroup( | |
297 | Si te site, | |
298 | St ring study List, | |
299 | Pa tientIdent ifier pati entIdentif ier, | |
300 | St udyLoadLev el studyLo adLevel, | |
301 | St udyDeleted ImageState studyDele tedImageSt ate) | |
302 | throws VistaPars ingExcepti on | |
303 | { | |
304 | So rtedSet<Vi staGroup> studies = new TreeSe t<VistaGro up>(); | |
305 | St ring heade rLine = "" ; | |
306 | if (studyList .charAt(0) == '1') | |
307 | { | |
308 | String [] lines = StringUti ls.Split(s tudyList, StringUtil s.NEW_LINE ); | |
309 | // the first two lines of the respon se contain the respo nse status and the m etadata, r espectivel y | |
310 | if(lin es.length <= 0) | |
311 | throw ne w VistaPar singExcept ion("Study list cont ains no st atus, meta -data or d ata."); | |
312 | if(lin es.length == 1) | |
313 | throw ne w VistaPar singExcept ion("Study list cont ains no me ta-data or data."); | |
314 | if(lin es.length == 2) | |
315 | { | |
316 | logger.i nfo("Study list cont ains no da ta."); | |
317 | return s tudies; | |
318 | } | |
319 | ||
320 | // par se the res ponse stat us line an d retain t he ??? | |
321 | String rpcRespon seLine = l ines[0].tr im(); | |
322 | String response = StringUt ils.MagPie ce(rpcResp onseLine, StringUtil s.CARET, 2 ); | |
323 | ||
324 | // the headerLin e is the m etadata, d escribes t he format of the stu dy results | |
325 | // sav e it and p ass to the method th at actuall y parses t he study l ines | |
326 | header Line = lin es[1]; | |
327 | ||
328 | // for each rema ining line in the re sponse, pa rse a Stud y instance and add i t | |
329 | // to our list | |
330 | for(in t j = 2; j < lines.l ength; j++ ) | |
331 | { | |
332 | VistaGro up study = createGro upFromGrou pLineHandl eSingleIma geGroup( | |
333 | site, head erLine, li nes[j], pa tientIdent ifier, stu dyLoadLeve l, | |
334 | studyDelet edImageSta te); | |
335 | if(study != null) | |
336 | { | |
337 | study.setR pcResponse Msg(respon se); | |
338 | studies.ad d(study); | |
339 | } | |
340 | } | |
341 | } | |
342 | ||
343 | re turn studi es; | |
344 | } | |
345 | ||
346 | /** | |
347 | * tak e one line from a Vi stA respon se and mak e a Study instance f rom it. | |
348 | * The study hea der descri bes the co ntent of t he Study s tring and looks some thing like : | |
349 | * Ite m~S2^Site^ Note Title ~~W0^Proc DT~S1^Proc edure^# Im g~S2^Short Desc^Pkg^ Class^Type ^Specialty ^Event^Ori gin^Cap Dt ~S1~W0^Cap by~~W0^Im age ID~S2~ W0 | |
350 | * | |
351 | * A s tudy line looks some thing like this: | |
352 | * 1^WAS^NUR SING NOTE^ 09/28/2001 00:01^NOT E^2^CONSUL T NURSE ME DICAL WOUN D SPEC INP T^NOTE^CLI N^CONSULT^ NURSING^WO UND ASSESS MENT^VA^09 /28/2001 0 1:35^IMAGP ROVIDERONE TWOSIX,ONE TWOSIX^175 2|1752^\\I SW-IMGGOLD BACK\image 1$\DM\00\1 7\DM001753 .JPG^\\ISW -IMGGOLDBA CK\image1$ \DM\00\17\ DM001753.A BS^CONSULT NURSE MED ICAL WOUND SPEC INPT ^3010928^1 1^NOTE^09/ 28/2001^36 ^M^A^^^2^1 ^WAS^^^711 ^IMAGPATIE NT1055,105 5^CLIN^^^ | |
353 | * | |
354 | * NOT E: the stu dy line in cludes the data for the first image in t he study, which cont ains much of what | |
355 | * we would cons ider Study data | |
356 | * | |
357 | * @pa ram studyH eader | |
358 | * @pa ram studyS tring | |
359 | * @re turn | |
360 | * @th rows URNFo rmatExcept ion | |
361 | * @th rows Vista ParsingExc eption | |
362 | */ | |
363 | privat e static V istaGroup createGrou pFromGroup Line( | |
364 | Si te site, | |
365 | St ring study Header, | |
366 | St ring study String, | |
367 | Pa tientIdent ifier pati entIdentif ier, | |
368 | St udyDeleted ImageState studyDele tedImageSt ate) | |
369 | throws URNFormat Exception, VistaPars ingExcepti on | |
370 | { | |
371 | if ((studyHea der == nul l) || (stu dyHeader.e quals("")) ) | |
372 | retu rn null; | |
373 | ||
374 | if ((studyStr ing == nul l) || (stu dyString.e quals("")) ) | |
375 | retu rn null; | |
376 | ||
377 | St ring[] par ts = Strin gUtils.Spl it(studySt ring, Stri ngUtils.ST ICK); | |
378 | ||
379 | // do study part | |
380 | St ring [] pi eces = Str ingUtils.S plit(parts [0], Strin gUtils.CAR ET); | |
381 | St ring [] ke ys = Strin gUtils.Spl it(studyHe ader, Stri ngUtils.CA RET); | |
382 | ||
383 | // clean up the keys ( remove any ~ values) | |
384 | fo r(int i = 0; i < key s.length; i++) | |
385 | keys [i] = Stri ngUtils.Ma gPiece(key s[i], Stri ngUtils.TI LDE, 1); | |
386 | ||
387 | in t maxLengt h = pieces .length; | |
388 | if (maxLength > keys.le ngth) | |
389 | maxL ength = ke ys.length; | |
390 | ||
391 | // create a VistaImage instance to hold th e data tem porarily | |
392 | Vi staImage v istaImage = VistaIma ge.create( "^" + part s[1]); | |
393 | ||
394 | Vi staGroup g roup = new VistaGrou p(StudyLoa dLevel.STU DY_ONLY, s tudyDelete dImageStat e); | |
395 | ||
396 | fo r(int i = 0; i < max Length; i+ +) | |
397 | grou p.setValue ( keys[i], pieces[i] ); | |
398 | ||
399 | if ((group.ge tProcedure DateString () != null ) && (grou p.getProce dureDateSt ring().len gth() > 0) ) | |
400 | grou p.setProce dureDate(V istaTransl atorUtilit y.convertV istaDateto Date(group .getProced ureDateStr ing())); | |
401 | ||
402 | // set this here in ca se the set Value() ca lls overwr ite it | |
403 | gr oup.setPat ientIdenti fier(patie ntIdentifi er); | |
404 | gr oup.setPat ientName(v istaImage. getPatient Name()); | |
405 | gr oup.setIen (vistaImag e.getIen() ); | |
406 | // JMW 4/26/ 2011 P104T 4 - set th e group si te abbrevi ation from the image value | |
407 | gr oup.setSit eAbbr(vist aImage.get SiteAbbr() ); | |
408 | ||
409 | // setting t he first i mage, if p opulating for shallo w this wil l be neede d, if full it will | |
410 | // be trashe d | |
411 | gr oup.setFir stVistaIma ge(vistaIm age); | |
412 | gr oup.setFir stImageIen (vistaImag e.getIen() ); | |
413 | ||
414 | // new field s availabl e from Pat ch 93 | |
415 | gr oup.setDoc umentDate( vistaImage .getDocume ntDate()); | |
416 | gr oup.setSen sitive(vis taImage.is Sensitive( )); | |
417 | gr oup.setStu dyStatus(v istaImage. getImageSt atus()); | |
418 | gr oup.setStu dyViewStat us(vistaIm age.getIma geViewStat us()); | |
419 | gr oup.setStu dyImagesHa veAnnotati ons(vistaI mage.isIma geHasAnnot ations()); | |
420 | ||
421 | re turn group ; | |
422 | } | |
423 | ||
424 | /** | |
425 | * Tra nsform a V istaImage instance i nto an Ima ge instanc e, adding the study properties . | |
426 | * | |
427 | * @pa ram vistaI mage | |
428 | * @re turn | |
429 | * @th rows URNFo rmatExcept ion | |
430 | */ | |
431 | public static Im age transf orm(String originati ngSiteId, String stu dyId, Pati entIdentif ier patien tIdentifie r, | |
432 | Vist aImage vis taImage) | |
433 | throws URNFormat Exception | |
434 | { | |
435 | Im age image = Image.cr eate(origi natingSite Id, vistaI mage.getIe n(), study Id, | |
436 | patien tIdentifie r, vistaIm age.getIma geModality ()); | |
437 | ||
438 | im age.setFul lFilename( vistaImage .getFullFi lename()); | |
439 | im age.setAbs Filename(v istaImage. getAbsFile name()); | |
440 | im age.setDes cription(v istaImage. getDescrip tion()); | |
441 | im age.setImg Type(vista Image.getI mgType()); | |
442 | im age.setPro cedure(vis taImage.ge tProcedure ()); | |
443 | im age.setPro cedureDate (vistaImag e.getProce dureDate() ); | |
444 | im age.setAbs Location(v istaImage. getAbsLoca tion()); | |
445 | im age.setFul lLocation( vistaImage .getFullLo cation()); | |
446 | im age.setDic omSequence NumberForD isplay(vis taImage.ge tDicomSequ enceNumber ForDisplay ()); | |
447 | im age.setDic omImageNum berForDisp lay(vistaI mage.getDi comImageNu mberForDis play()); | |
448 | im age.setSit eAbbr(vist aImage.get SiteAbbr() ); | |
449 | im age.setQaM essage(vis taImage.ge tQaMessage ()); | |
450 | im age.setBig Filename(v istaImage. getBigFile name()); | |
451 | im age.setPat ientDFN(vi staImage.g etPatientD FN()); | |
452 | im age.setPat ientName(v istaImage. getPatient Name()); | |
453 | im age.setIma geClass(vi staImage.g etImageCla ss()); | |
454 | im age.setDoc umentDate( vistaImage .getDocume ntDate()); | |
455 | imag e.setCaptu reDate(vis taImage.ge tCaptureDa te()); | |
456 | imag e.setSensi tive(vista Image.isSe nsitive()) ; | |
457 | imag e.setImage Status(vis taImage.ge tImageStat us()); | |
458 | imag e.setImage ViewStatus (vistaImag e.getImage ViewStatus ()); | |
459 | imag e.setAssoc iatedNoteR esulted(vi staImage.g etAssociat edNoteResu lted()); | |
460 | imag e.setImage Package(vi staImage.g etImagePac kage()); | |
461 | imag e.setImage HasAnnotat ions(vista Image.isIm ageHasAnno tations()) ; | |
462 | imag e.setImage Annotation Status(vis taImage.ge tImageAnno tationStat us()); | |
463 | im age.setIma geAnnotati onStatusDe scription( vistaImage .getImageA nnotationS tatusDescr iption()); | |
464 | ||
465 | re turn image ; | |
466 | } | |
467 | ||
468 | /** | |
469 | * Tra nsform a C ollection of VistaIm age instan ces into a SortedSet of Image instances, | |
470 | * add ing the st udy and pa tient key data. | |
471 | * | |
472 | * @pa ram origin atingSiteI d | |
473 | * @pa ram studyI d | |
474 | * @pa ram patien tIcn | |
475 | * @pa ram vistaI mages | |
476 | * @re turn | |
477 | * @th rows URNFo rmatExcept ion | |
478 | */ | |
479 | public static So rtedSet<Im age> trans form( | |
480 | St ring origi natingSite Id, | |
481 | St ring study Id, | |
482 | Pa tientIdent ifier pati entIdentif ier, | |
483 | Co llection<V istaImage> vistaImag es) | |
484 | throws URNFormat Exception | |
485 | { | |
486 | So rtedSet<Im age> resul t = new Tr eeSet<Imag e>(); | |
487 | ||
488 | fo r(VistaIma ge vistaIm age : vist aImages) | |
489 | if( !result.ad d(transfor m(originat ingSiteId, studyId, patientIde ntifier, v istaImage) ) ) | |
490 | logger .warn("Dup licate ima ge, IEN='" + vistaIm age.getIen () + "' is not being added dur ing transf orm."); | |
491 | ||
492 | re turn resul t; | |
493 | } | |
494 | /** | |
495 | * THI S SHOULD O NLY BE USE D IF NOT U SING GET P ATIENT STU DY GRAPH R PC - This is for old (non patc h 83) site s | |
496 | * | |
497 | * tak e one line from a Vi stA respon se and mak e a Study instance f rom it. | |
498 | * The study hea der descri bes the co ntent of t he Study s tring and looks some thing like : | |
499 | * Ite m~S2^Site^ Note Title ~~W0^Proc DT~S1^Proc edure^# Im g~S2^Short Desc^Pkg^ Class^Type ^Specialty ^Event^Ori gin^Cap Dt ~S1~W0^Cap by~~W0^Im age ID~S2~ W0 | |
500 | * | |
501 | * A s tudy line looks some thing like this: | |
502 | * 1^WAS^NUR SING NOTE^ 09/28/2001 00:01^NOT E^2^CONSUL T NURSE ME DICAL WOUN D SPEC INP T^NOTE^CLI N^CONSULT^ NURSING^WO UND ASSESS MENT^VA^09 /28/2001 0 1:35^IMAGP ROVIDERONE TWOSIX,ONE TWOSIX^175 2|1752^\\I SW-IMGGOLD BACK\image 1$\DM\00\1 7\DM001753 .JPG^\\ISW -IMGGOLDBA CK\image1$ \DM\00\17\ DM001753.A BS^CONSULT NURSE MED ICAL WOUND SPEC INPT ^3010928^1 1^NOTE^09/ 28/2001^36 ^M^A^^^2^1 ^WAS^^^711 ^IMAGPATIE NT1055,105 5^CLIN^^^ | |
503 | * | |
504 | * NOT E: the stu dy line in cludes the data for the first image in t he study, which cont ains much of what | |
505 | * we would cons ider Study data | |
506 | * | |
507 | * @pa ram studyH eader | |
508 | * @pa ram studyS tring | |
509 | * @re turn | |
510 | * @th rows Vista ParsingExc eption | |
511 | */ | |
512 | public static Vi staGroup c reateGroup FromGroupL ineHandleS ingleImage Group( | |
513 | Si te site, | |
514 | St ring study Header, | |
515 | St ring study String, | |
516 | Pa tientIdent ifier pati entIdentif ier, | |
517 | St udyLoadLev el studyLo adLevel, | |
518 | St udyDeleted ImageState studyDele tedImageSt ate) | |
519 | throws VistaPars ingExcepti on | |
520 | { | |
521 | if ((studyHea der == nul l) || (stu dyHeader.e quals("")) ) | |
522 | retu rn null; | |
523 | ||
524 | if ((studyStr ing == nul l) || (stu dyString.e quals("")) ) | |
525 | retu rn null; | |
526 | ||
527 | logg er.debug(" studyStrin g: " + stu dyString); | |
528 | St ring[] par ts = Strin gUtils.Spl it(studySt ring, Stri ngUtils.ST ICK); | |
529 | ||
530 | // do study part | |
531 | St ring [] pi eces = Str ingUtils.S plit(parts [0], Strin gUtils.CAR ET); | |
532 | St ring [] ke ys = Strin gUtils.Spl it(studyHe ader, Stri ngUtils.CA RET); | |
533 | ||
534 | // clean up the keys ( remove any ~ values) | |
535 | fo r(int i = 0; i < key s.length; i++) | |
536 | keys [i] = Stri ngUtils.Ma gPiece(key s[i], Stri ngUtils.TI LDE, 1); | |
537 | ||
538 | in t maxLengt h = pieces .length; | |
539 | if (maxLength > keys.le ngth) | |
540 | maxL ength = ke ys.length; | |
541 | ||
542 | St ring image String = " ^" + parts [1]; | |
543 | logg er.debug(" imageStrin g: " + ima geString); | |
544 | ||
545 | Vi staGroup s tudy = new VistaGrou p( studyLo adLevel, s tudyDelete dImageStat e ); | |
546 | ||
547 | fo r(int i = 0; i < max Length; i+ +) | |
548 | { | |
549 | stud y.setValue ( keys[i], pieces[i] ); | |
550 | } | |
551 | ||
552 | if ((study.ge tProcedure DateString () != null ) && (stud y.getProce dureDateSt ring().len gth() > 0) ) | |
553 | { | |
554 | stud y.setProce dureDate(V istaTransl atorUtilit y.convertV istaDateto Date(study .getProced ureDateStr ing())); | |
555 | } | |
556 | ||
557 | // set patie nt Icn sin ce not get ting from these Vist A RPC call s | |
558 | st udy.setPat ientIdenti fier(patie ntIdentifi er); | |
559 | ||
560 | Vist aImage vis taImage = VistaImage .create(im ageString) ; | |
561 | stud y.setIen(v istaImage. getIen()); | |
562 | ||
563 | // if the st udy is a s ingle imag e study, t hen set th e first im age | |
564 | if ((vistaIma ge.getImgT ype() != 11) || (!s tudyLoadLe vel.isIncl udeImages( ))) | |
565 | { | |
566 | stud y.setFirst VistaImage (vistaImag e); | |
567 | stud y.setFirst ImageIen(v istaImage. getIen()); | |
568 | stud y.setPatie ntName(vis taImage.ge tPatientNa me()); | |
569 | } | |
570 | st udy.setStu dyImagesHa veAnnotati ons(vistaI mage.isIma geHasAnnot ations()); | |
571 | ||
572 | if (parts.le ngth == 3) { | |
573 | Stri ng altExam Nbr = Stri ngUtils.Pi ece(parts[ 2], String Utils.CRST RING, 1); | |
574 | stud y.setAlter nateExamNu mber(altEx amNbr); | |
575 | } | |
576 | ||
577 | re turn study ; | |
578 | } | |
579 | ||
580 | /** | |
581 | * Tra nsform a c ollection of VistaGr oup instan ces into a sorted se t of Study instances . | |
582 | * | |
583 | * @pa ram object Origin | |
584 | * @pa ram site | |
585 | * @pa ram groups | |
586 | * @re turn | |
587 | * @th rows URNFo rmatExcept ion | |
588 | */ | |
589 | public static So rtedSet<St udy> trans form(Objec tOrigin ob jectOrigin , Site sit e, Collect ion<VistaG roup> grou ps) | |
590 | throws URNFormat Exception | |
591 | { | |
592 | So rtedSet<St udy> resul t = new Tr eeSet<Stud y>(); | |
593 | ||
594 | fo r(VistaGro up group : groups) | |
595 | resu lt.add(tra nsform(obj ectOrigin, site, gro up)); | |
596 | ||
597 | re turn resul t; | |
598 | } | |
599 | ||
600 | /** | |
601 | * Tra nsform a s ingle Vist aGroup ins tance into a Study i nstance. | |
602 | * | |
603 | * @pa ram group | |
604 | * @re turn | |
605 | * @th rows URNFo rmatExcept ion | |
606 | */ | |
607 | public static St udy transf orm(Object Origin obj ectOrigin, Site site , VistaGro up group) | |
608 | throws URNFormat Exception | |
609 | { | |
610 | St udy result = Study.c reate(obje ctOrigin, site.getSi teNumber() , group.ge tIen(), | |
611 | group. getPatient Identifier (), group. getStudyLo adLevel(), group.get StudyDelet edImageSta te()); | |
612 | ||
613 | // copy the "dynamic" properties first and then copy the named propertie s | |
614 | // some of t he named p roperties may overwr ite the "d ynamic" pr operties | |
615 | fo r( Enumera tion<Strin g> propert yKeyEnumer ator = gro up.getKeys (); proper tyKeyEnume rator.hasM oreElement s(); ) | |
616 | { | |
617 | Stri ng propert yKey = pro pertyKeyEn umerator.n extElement (); | |
618 | resu lt.setValu e(property Key, group .getValue( propertyKe y)); | |
619 | } | |
620 | ||
621 | re sult.setAl ienSiteNum ber(group. getAlienSi teNumber() ); | |
622 | re sult.setCa ptureBy(gr oup.getCap tureBy()); | |
623 | re sult.setCa ptureDate( group.getC aptureDate ()); | |
624 | re sult.setDe scription( group.getD escription ()); | |
625 | re sult.setEr rorMessage (group.get ErrorMessa ge()); | |
626 | re sult.setEv ent(group. getEvent() ); | |
627 | if (group.get FirstVista Image() != null) | |
628 | { | |
629 | Imag e firstIma ge = trans form(site. getSiteNum ber(), gro up.getIen( ), group.g etPatientI dentifier( ), group.g etFirstVis taImage()) ; | |
630 | resu lt.setFirs tImage(fir stImage); | |
631 | } | |
632 | re sult.setFi rstImageIe n(group.ge tFirstImag eIen()); | |
633 | re sult.setIm ageCount(g roup.getIm ageCount() ); | |
634 | re sult.setIm agePackage (group.get ImagePacka ge()); | |
635 | re sult.setIm ageType(gr oup.getIma geType()); | |
636 | re sult.setNo teTitle(gr oup.getNot eTitle()); | |
637 | re sult.setOr igin(group .getOrigin ()); | |
638 | re sult.setPa tientName( group.getP atientName ()); | |
639 | re sult.setPr ocedure(gr oup.getPro cedure()); | |
640 | re sult.setPr ocedureDat e(group.ge tProcedure Date()); | |
641 | re sult.setPr ocedureDat eString(gr oup.getPro cedureDate String()); | |
642 | re sult.setRa diologyRep ort(group. getRadiolo gyReport() ); | |
643 | re sult.setRp cResponseM sg(group.g etRpcRespo nseMsg()); | |
644 | re sult.setSi teAbbr(sit e.getSiteA bbr()); | |
645 | re sult.setSi teName(sit e.getSiteN ame()); | |
646 | re sult.setSp ecialty(gr oup.getSpe cialty()); | |
647 | re sult.setSt udyClass(g roup.getSt udyClass() ); | |
648 | re sult.setSt udyUid(gro up.getStud yUid()); | |
649 | re sult.setGr oupIen(gro up.getIen( )); | |
650 | if (group.ge tAlternate ExamNumber () != null ) | |
651 | { | |
652 | resu lt.setAlte rnateExamN umber(grou p.getAlter nateExamNu mber()); | |
653 | } | |
654 | ||
655 | re turn resul t; | |
656 | } | |
657 | ||
658 | pr ivate fina l static S tring STUD Y_UID_KEY = "STUDY_U ID"; | |
659 | pr ivate fina l static S tring STUD Y_PAT_KEY = "STUDY_P AT"; | |
660 | pr ivate fina l static S tring STUD Y_IEN_KEY = "STUDY_I EN"; | |
661 | pr ivate fina l static S tring STUD Y_INFO_KEY = "STUDY_ INFO"; | |
662 | pr ivate fina l static S tring SERI ES_UID_KEY = "SERIES _UID"; | |
663 | pr ivate fina l static S tring SERI ES_IEN_KEY = "SERIES _IEN"; | |
664 | pr ivate fina l static S tring SERI ES_NUMBER_ KEY = "SER IES_NUMBER "; | |
665 | pr ivate fina l static S tring SERI ES_CLASS_I NDEX_KEY = "SERIES_C LASS_INDEX "; | |
666 | pr ivate fina l static S tring SERI ES_PROCEVE NT_INDEX_K EY = "SERI ES_PROC/EV ENT_INDEX" ; | |
667 | pr ivate fina l static S tring SERI ES_SPECSUB SPEC_INDEX _KEY = "SE RIES_SPEC/ SUBSPEC_IN DEX"; | |
668 | pr ivate fina l static S tring IMAG E_UID_KEY = "IMAGE_U ID"; | |
669 | pr ivate fina l static S tring IMAG E_IEN_KEY = "IMAGE_I EN"; | |
670 | pr ivate fina l static S tring IMAG E_NUMBER_K EY = "IMAG E_NUMBER"; | |
671 | pr ivate fina l static S tring IMAG E_ABSTRACT _KEY = "IM AGE_ABSTRA CT"; | |
672 | pr ivate fina l static S tring IMAG E_FULL_KEY = "IMAGE_ FULL"; | |
673 | pr ivate fina l static S tring IMAG E_TEXT_KEY = "IMAGE_ TEXT"; | |
674 | pr ivate fina l static S tring IMAG E_INFO_KEY = "IMAGE_ INFO"; | |
675 | pr ivate fina l static S tring CONT EXT_NEXT = "NEXT_CON TEXTID"; | |
676 | pr ivate fina l static S tring STUD Y_NEXT = " NEXT_STUDY "; | |
677 | pr ivate fina l static S tring SERI ES_NEXT = "NEXT_SERI ES"; | |
678 | pr ivate fina l static S tring IMAG E_NEXT = " NEXT_IMAGE "; | |
679 | pr ivate fina l static S tring ARTI FACTINSTAN CE_NEXT = "NEXT_ARTI FACTINSTAN CE"; | |
680 | pr ivate fina l static S tring GROU P_IEN_KEY = "GROUP_I EN"; | |
681 | pr ivate fina l static S tring STUD Y_MODALITY = "STUDY_ MODALITY"; | |
682 | pr ivate fina l static S tring SERI ES_MODALIT Y = "SERIE S_MODALITY "; | |
683 | pr ivate fina l static S tring ARTI FACTINSTAN CE_PK_KEY = "ARTIFAC TINSTANCE_ PK"; | |
684 | pr ivate fina l static S tring ARTI FACTINSTAN CE_ARTIFAC T_KEY = "A RTIFACTINS TANCE_ARTI FACT"; | |
685 | pr ivate fina l static S tring ARTI FACTINSTAN CE_ARTIFAC TFORMAT_KE Y = "ARTIF ACTINSTANC E_ARTIFACT FORMAT"; | |
686 | pr ivate fina l static S tring ARTI FACTINSTAN CE_STORAGE PROVIDER_K EY = "ARTI FACTINSTAN CE_STORAGE PROVIDER"; | |
687 | pr ivate fina l static S tring ARTI FACTINSTAN CE_STORAGE PROVIDERTY PE_KEY = " ARTIFACTIN STANCE_STO RAGEPROVID ERTYPE"; | |
688 | pr ivate fina l static S tring ARTI FACTINSTAN CE_CREATED ATETIME_KE Y = "ARTIF ACTINSTANC E_CREATEDA TETIME"; | |
689 | pr ivate fina l static S tring ARTI FACTINSTAN CE_LASTACC ESSDATETIM E_KEY = "A RTIFACTINS TANCE_LAST ACCESSDATE TIME"; | |
690 | pr ivate fina l static S tring ARTI FACTINSTAN CE_FILEREF _KEY = "A RTIFACTINS TANCE_FILE REF"; | |
691 | pr ivate fina l static S tring ARTI FACTINSTAN CE_DISKVOL UME_KEY = "ARTIFACTI NSTANCE_DI SKVOLUME"; | |
692 | pr ivate fina l static S tring ARTIFACTIN STANCE_PHY SICALREFER ENCE_KEY = "ARTIFACT INSTANCE_P HYSICALREF ERENCE"; | |
693 | pr ivate fina l static S tring ARTI FACTINSTAN CE_FILEPAT H_KEY = "A RTIFACTINS TANCE_FILE PATH"; | |
694 | pr ivate fina l static S tring STUD Y_ERROR = "STUDY_ERR "; | |
695 | pr ivate fina l static S tring IMAG E_ERROR = "IMAGE_ERR "; | |
696 | ||
697 | /* * | |
698 | * Convert a String, a s returned from Vist A Imaging, into a so rted set o f Study in stances. | |
699 | * | |
700 | * @param si te | |
701 | * @param vi staRespons e | |
702 | * @param st udyLoadLev el | |
703 | * @return | |
704 | * / | |
705 | pu blic stati c SortedSe t<Study> c reateStudi esFromGrap h(Site sit e, String vistaRespo nse, | |
706 | StudyL oadLevel s tudyLoadLe vel, Study DeletedIma geState st udyDeleted ImageState ) | |
707 | { | |
708 | Stri ng details [] = Strin gUtils.Spl it(vistaRe sponse, St ringUtils. NEW_LINE); | |
709 | Sort edSet<Stud y> studies = createS tudiesFrom Graph(site , details, studyLoad Level, | |
710 | studyDel etedImageS tate); | |
711 | retu rn studies ; | |
712 | } | |
713 | ||
714 | ||
715 | // the defin ition of t he levels in teh hie rarchy of data retur ned from t he Vista R PC call | |
716 | pr ivate stat ic VistaIm agingParse r.Ontology DelimiterK ey[] study OntologyDe limiterKey s = | |
717 | ne w VistaIma gingParser .OntologyD elimiterKe y[] | |
718 | { | |
719 | new VistaImagi ngParser.O ntologyDel imiterKey( STUDY_NEXT , new Stri ng[] {STUD Y_MODALITY }), | |
720 | new VistaImagi ngParser.O ntologyDel imiterKey( SERIES_NEX T), | |
721 | new VistaImagi ngParser.O ntologyDel imiterKey( IMAGE_NEXT ), | |
722 | new VistaImagi ngParser.O ntologyDel imiterKey( ARTIFACTIN STANCE_NEX T) | |
723 | }; | |
724 | ||
725 | /* * | |
726 | * | |
727 | * @param si te | |
728 | * @param st udyLines - a String array orig inally fro m Vista in a form th at defies simple des cription. | |
729 | * "l ines" are CR delimit ed lines o f text | |
730 | * "p arts" are delimited by the ver tical bar '|' charac ter | |
731 | * "p ieces" are delimited by the ca ret '^' ch aracter | |
732 | * Ea ch line co nsists of 1..n parts . The fir st part (i ndex=0) is a key. | |
733 | * Ea ch part co nsists of 1..n piece s. | |
734 | * Pr ior to cal ling this method, th e parts ha ve been pa rsed into a String a rray. | |
735 | * Example of a singl e image st udy: | |
736 | * 11 | |
737 | * NE XT_STUDY|| 712 | |
738 | * ST UDY_IEN|71 2 | |
739 | * ST UDY_PAT|10 11|9217103 663V710366 |IMAGPATIE NT1011,101 1 | |
740 | * NE XT_SERIES | |
741 | * SE RIES_IEN|7 12 | |
742 | * NE XT_IMAGE | |
743 | * IM AGE_IEN|71 3 | |
744 | * IM AGE_INFO|B 2^713^\\is w-werfelj- lt\image1$ \DM\00\07\ DM000713.T GA^\\isw-w erfelj-lt\ image1$\DM \00\07\DM0 00713.ABS^ 040600-28 CHEST SIN GLE VIEW^3 000406.134 9^3^CR^04/ 06/2000^^M ^A^^^1^1^S LC^^^1011^ IMAGPATIEN T1011,1011 ^CLIN^^^^ | |
745 | * IM AGE_ABSTRA CT|\\isw-w erfelj-lt\ image1$\DM \00\07\DM0 00713.ABS | |
746 | * IM AGE_FULL|\ \isw-werfe lj-lt\imag e1$\DM\00\ 07\DM00071 3.TGA | |
747 | * IM AGE_TEXT|\ \isw-werfe lj-lt\imag e1$\DM\00\ 07\DM00071 3.TXT | |
748 | * The firs t line is the number of lines in the res ponse. | |
749 | * | |
750 | * The keys "NEXT_STU DY", "NEXT _SERIES", and "NEXT_ IMAGE" mak e up the " study onto logy" defi nition, re ally | |
751 | * just the demarcati on of the levels of the hierar chy. The VistaImagi ngParser w ill use th ose keys a s delimite rs | |
752 | * when par sing the S tring retu rned from Vista into a hierarc hy of line s. | |
753 | * | |
754 | * @return | |
755 | * / | |
756 | pu blic stati c SortedSe t<Study> c reateStudi esFromGrap h(Site sit e, String[ ] studyLin es, | |
757 | StudyL oadLevel s tudyLoadLe vel, Study DeletedIma geState st udyDeleted ImageState ) | |
758 | { | |
759 | Sort edSet<Stud y> studyLi st = new T reeSet<Stu dy>(); | |
760 | if( studyLines == null | | studyLin es.length <= 1 ) | |
761 | return studyList ; // i .e. return an empty Set | |
762 | ||
763 | Stri ng studyCo untLine = studyLines [0].trim() ; | |
764 | ||
765 | try | |
766 | { | |
767 | int expectedLi neCount = Integer.pa rseInt( st udyCountLi ne ); | |
768 | if( expectedLi neCount != studyLine s.length ) | |
769 | logger.w arn("The e xpected nu mber of li nes (" + e xpectedLin eCount + | |
770 | ") does not match the actual num ber (" + ( studyLines .length) + | |
771 | ") , continui ng."); | |
772 | } | |
773 | catc h (NumberF ormatExcep tion e) | |
774 | { | |
775 | logger .warn("Una ble to par se the fir st line (c ontaining number of lines) in the VistA response. Line was '" + | |
776 | studyCount Line + "', continuin g."); | |
777 | } | |
778 | ||
779 | // d rop the fi rst line | |
780 | Stri ng[] realL ines = new String[st udyLines.l ength-1]; | |
781 | Syst em.arrayco py(studyLi nes, 1, re alLines, 0 , realLine s.length); | |
782 | ||
783 | // c reate a Vi sta Parser using the hierarchy levels de fined by t he ontolog y delimite r keys | |
784 | Vist aImagingPa rser parse r = new Vi staImaging Parser(stu dyOntology DelimiterK eys); | |
785 | ||
786 | List <VistaImag ingParser. ParsedVist aLine> par sedStudyLi nes = pars er.parse(r ealLines, true); | |
787 | ||
788 | // i f there ar e any pars ed lines t hat have t he root ke y | |
789 | if(p arsedStudy Lines != n ull && par sedStudyLi nes.size() > 0) | |
790 | for(Vi staImaging Parser.Par sedVistaLi ne studyLi ne : parse dStudyLine s) | |
791 | { | |
792 | Study st udy; | |
793 | try | |
794 | { | |
795 | study = cr eateStudy( site, stud yLine, stu dyLoadLeve l, studyDe letedImage State); | |
796 | if(study ! = null) | |
797 | st udyList.ad d(study); | |
798 | } | |
799 | catch (U RNFormatEx ception ur nfX) | |
800 | { | |
801 | logger.err or("Except ion creati ng a study . " + urn fX.getMess age(), urn fX); | |
802 | } | |
803 | catch (S tudyParsin gException spX) | |
804 | { | |
805 | logger.err or("Except ion creati ng a study . " + spX .getMessag e(), spX); | |
806 | } | |
807 | catch (E xception X ) | |
808 | { | |
809 | logger.err or("Except ion creati ng a study . " + X.g etMessage( ), X); | |
810 | } | |
811 | } | |
812 | // add the compl ete Study with Serie s and Imag e instance s attached | |
813 | // to the list o f Study | |
814 | ||
815 | retu rn studyLi st; | |
816 | } | |
817 | ||
818 | /* * | |
819 | * | |
820 | * @param si te | |
821 | * @param st udyLine | |
822 | * @return | |
823 | * @throws U RNFormatEx ception | |
824 | * / | |
825 | pr ivate stat ic Study c reateStudy (Site site , VistaIma gingParser .ParsedVis taLine stu dyLine, | |
826 | StudyL oadLevel s tudyLoadLe vel, Study DeletedIma geState st udyDeleted ImageState ) | |
827 | th rows URNFo rmatExcept ion, Study ParsingExc eption | |
828 | { | |
829 | if(s tudyLine = = null){ | |
830 | throw new StudyP arsingExce ption("stu dyLine is null."); | |
831 | } | |
832 | ||
833 | VistaIma gingParser .ParsedVis taLine err orProperty = studyLi ne.getProp erty(STUDY _ERROR); | |
834 | if(error Property ! = null) | |
835 | { | |
836 | //st udyUid = e rrorProper ty.getValu eAtIndex(0 ); | |
837 | Stri ng badIEN = null; | |
838 | if(stu dyLine.isV alueAtInde xExists(1) ){ | |
839 | badIEN = studyLine .getValueA tIndex(1); | |
840 | } | |
841 | Stri ng errorMs g = ""; | |
842 | if(e rrorProper ty.isValue AtIndexExi sts(1)){ | |
843 | errorM sg = error Property.g etValueAtI ndex(1); | |
844 | } | |
845 | ||
846 | Pati entIdentif ier unknow n = Patien tIdentifie r.icnPatie ntIdentifi er(unknown Patient); | |
847 | ||
848 | Study stud y = Study. create(Obj ectOrigin. VA, site.g etSiteNumb er(), badI EN, | |
849 | unknown, studyLoad Level, stu dyDeletedI mageState) ; | |
850 | ||
851 | logg er.warn("S TUDY Error for study Ien [" + badIEN + " ], '" + er rorMsg + " '." ); | |
852 | stud y.setError Message(er rorMsg); | |
853 | // J MW 7/17/08 - we now return the study but keep the error mess age to use later | |
854 | retu rn study; | |
855 | } | |
856 | ||
857 | //Vi staImaging Parser.Par sedVistaLi ne nextStu dyProperty = studyLi ne.getProp erty(STUDY _NEXT); | |
858 | Stri ng dataStr ucture = n ull; | |
859 | bool ean isStud yInNewData Structure = false; | |
860 | if(s tudyLine.i sValueAtIn dexExists( 1)){ | |
861 | dataSt ructure = studyLine. getValueAt Index(1); | |
862 | if((da taStructur e != null) && (dataS tructure.l ength() > 0)){ | |
863 | if(dataS tructure.e quals("NEW ")){ | |
864 | isStudyInN ewDataStru cture = tr ue; | |
865 | } | |
866 | } | |
867 | } | |
868 | Vist aImagingPa rser.Parse dVistaLine ienProper ty = study Line.getPr operty(STU DY_IEN_KEY ); | |
869 | ||
870 | String i en = null; | |
871 | ||
872 | // we mu st have th e IEN to c reate a St udy | |
873 | if(ienPr operty != null) | |
874 | ien = ienPrope rty.getVal ueAtIndex( 0); // e ither the first valu e of the S TUDY_IEN l ine | |
875 | else | |
876 | ien = studyLin e.getValue AtIndex(1) ; // or the second value fro m the NEXT _STUDY lin e | |
877 | ||
878 | logger.d ebug("IEN from parse d line: " + ien); | |
879 | ||
880 | int imag eCount = 0 ; | |
881 | String f irstImageI en = ""; | |
882 | String c ptCode = " "; | |
883 | String c onsolidate dSiteNumbe r = ""; | |
884 | int numb erOfDicomI mages = -1 ; | |
885 | ||
886 | if(ienPr operty.isV alueAtInde xExists(1) ) | |
887 | { | |
888 | Stri ng imageCo untString = ienPrope rty.getVal ueAtIndex( 1); | |
889 | logger.deb ug("ImageC ountString : " + imag eCountStri ng); | |
890 | if(( imageCount String != null) && ( imageCount String.len gth() > 0) ) | |
891 | { | |
892 | imageC ount = Int eger.parse Int(imageC ountString ); | |
893 | } | |
894 | } | |
895 | ||
896 | logger.d ebug("Imag eCount: " + imageCou nt); | |
897 | ||
898 | if(ienPr operty.isV alueAtInde xExists(2) ) | |
899 | { | |
900 | firs tImageIen = ienPrope rty.getVal ueAtIndex( 2); | |
901 | } | |
902 | // JMW 1 0/6/2010 P 104 - the CPT code i s present in the 3rd piece of the STUDY_ IEN field | |
903 | if(ienPr operty.isV alueAtInde xExists(3) ) | |
904 | { | |
905 | cptC ode = ienP roperty.ge tValueAtIn dex(3); | |
906 | } | |
907 | // JMW 1 0/29/2010 P104 - if site the i mage is ph ysically s tored at i s in the 4 th piece o f the STUD Y_IEN fiel d | |
908 | if(ienPr operty.isV alueAtInde xExists(4) ) | |
909 | { | |
910 | cons olidatedSi teNumber = ienProper ty.getValu eAtIndex(4 ); | |
911 | } | |
912 | else{ | |
913 | cons olidatedSi teNumber = site.getS iteNumber( ); | |
914 | } | |
915 | // JMW 7 /21/2018 - if there is a 6th p iece of th e STUDY_IE N line it is the num ber of ima ges in the study whi ch are DIC OM images (or potent ially) | |
916 | // get t hat value | |
917 | if(ienPr operty.isV alueAtInde xExists(5) ) | |
918 | { | |
919 | Stri ng numberO fDicomImag esString = ienProper ty.getValu eAtIndex(5 ); | |
920 | if(( numberOfDi comImagesS tring != n ull) && (n umberOfDic omImagesSt ring.lengt h()> 0)) | |
921 | number OfDicomIma ges = Inte ger.parseI nt(numberO fDicomImag esString); | |
922 | } | |
923 | ||
924 | String s tudyUid = null; | |
925 | VistaIma gingParser .ParsedVis taLine uid Property = studyLine .getProper ty(STUDY_U ID_KEY); | |
926 | if(uidPr operty != null) | |
927 | stud yUid = uid Property.g etValueAtI ndex(0); | |
928 | ||
929 | String p atientIcn = null; | |
930 | String p atientName = null; | |
931 | String p atientDfn = null; | |
932 | VistaIma gingParser .ParsedVis taLine pat ientProper ty = study Line.getPr operty(STU DY_PAT_KEY ); | |
933 | if(patie ntProperty != null) | |
934 | { | |
935 | pati entIcn = p atientProp erty.getVa lueAtIndex (1); | |
936 | pati entName = patientPro perty.getV alueAtInde x(2); | |
937 | } | |
938 | ||
939 | PatientI dentifier patientIde ntifier = null; | |
940 | if(patie ntIcn != n ull && pat ientIcn.le ngth() > 0 && !patie ntIcn.star tsWith("-1 ")) | |
941 | pati entIdentif ier = Pati entIdentif ier.icnPat ientIdenti fier(patie ntIcn); | |
942 | else | |
943 | pati entIdentif ier = Pati entIdentif ier.dfnPat ientIdenti fier(patie ntDfn); | |
944 | ||
945 | Study st udy = Stud y.create(O bjectOrigi n.VA, site .getSiteNu mber(), ie n, | |
946 | patien tIdentifie r, studyLo adLevel, s tudyDelete dImageStat e, isStudy InNewDataS tructure, false); | |
947 | ||
948 | study.se tSiteName( site.getSi teName()); | |
949 | study.se tSiteAbbr( site.getSi teAbbr()); | |
950 | ||
951 | study.se tStudyUid( studyUid); | |
952 | ||
953 | st udy.setPat ientName(p atientName ); | |
954 | st udy.setCpt Code(cptCo de); | |
955 | st udy.setCon solidatedS iteNumber( consolidat edSiteNumb er); | |
956 | st udy.setNum berOfDicom Images(num berOfDicom Images); | |
957 | ||
958 | if(!stud yLoadLevel .isInclude Images()) | |
959 | { | |
960 | logg er.info("S tudy is no t loaded w ith images , setting image coun t to '" + imageCount + | |
961 | "' and first ima ge IEN to '" + first ImageIen + "'."); | |
962 | stud y.setFirst ImageIen(f irstImageI en); | |
963 | } | |
964 | ||
965 | //Viewer requires image coun t | |
966 | study.se tImageCoun t(imageCou nt); | |
967 | ||
968 | VistaIma gingParser .ParsedVis taLine mod alityPrope rty = stud yLine.getP roperty(ST UDY_MODALI TY); | |
969 | if(modal ityPropert y != null) | |
970 | { | |
971 | Stri ng[] modal ities = mo dalityProp erty.getVa lueAtIndex (0).split( ",", -1); | |
972 | for( String mod ality : mo dalities) | |
973 | study. addModalit y(modality ); | |
974 | } | |
975 | ||
976 | VistaIma gingParser .ParsedVis taLine stu dyInfoProp erty = stu dyLine.get Property(S TUDY_INFO_ KEY); | |
977 | if(study InfoProper ty != null ) { | |
978 | String [] studyIn fo = Strin gUtils.Spl it(studyIn foProperty .getValueA tIndex(0), StringUti ls.CARET); | |
979 | stud y.setNoteT itle(study Info[2]); | |
980 | stud y.setProce dureDateSt ring(study Info[3]); | |
981 | if(( study.getP rocedureDa teString() != null) && (study. getProcedu reDateStri ng().lengt h() > 0)) | |
982 | { | |
983 | study. setProcedu reDate(Vis taTranslat orUtility. convertVis taDatetoDa te(study.g etProcedur eDateStrin g())); | |
984 | } | |
985 | stud y.setProce dure(study Info[4]); | |
986 | stud y.setDescr iption(stu dyInfo[6]) ; | |
987 | stud y.setImage Package(st udyInfo[7] ); | |
988 | stud y.setStudy Class(stud yInfo[8]); | |
989 | stud y.setImage Type(study Info[9]); | |
990 | stud y.setSpeci alty(study Info[10]); | |
991 | stud y.setEvent (studyInfo [11]); | |
992 | stud y.setOrigi n(studyInf o[12]); | |
993 | stud y.setCaptu reDate(stu dyInfo[13] ); | |
994 | stud y.setCaptu reBy(study Info[14]); | |
995 | //if (studyInfo .length >= 20){ | |
996 | // study. setAccessi onNumber(s tudyInfo[1 9]); | |
997 | //} | |
998 | stud y.setAlter nateExamNu mber(study InfoProper ty.getValu eAtIndex(1 )); | |
999 | Stri ng studyCp rsIdentifi er = null; | |
1000 | if(s tudyInfoPr operty.isV alueAtInde xExists(2) ){ | |
1001 | studyC prsIdentif ier = stud yInfoPrope rty.getVal ueAtIndex( 2); | |
1002 | } | |
1003 | logg er.debug(" study CPRS Identifie r: " + stu dyCprsIden tifier); | |
1004 | if(s tudyCprsId entifier ! = null){ | |
1005 | study. setContext Id(studyCp rsIdentifi er); | |
1006 | } | |
1007 | else { | |
1008 | StudyU RN artifac tIdentifie r = (Study URN)study. getGlobalA rtifactIde ntifier(); | |
1009 | study. setContext Id(artifac tIdentifie r.toString ()); | |
1010 | } | |
1011 | } | |
1012 | ||
1013 | String a ltFirstIma geIen = "" ; | |
1014 | for( Ite rator<Vist aImagingPa rser.Parse dVistaLine > seriesIt er = study Line.child Iterator() ; seriesIt er.hasNext (); ) | |
1015 | { | |
1016 | Vist aImagingPa rser.Parse dVistaLine seriesLin e = series Iter.next( ); | |
1017 | try { | |
1018 | Series s eries = cr eateSeries (site, stu dy, series Line, altF irstImageI en, isStud yInNewData Structure) ; | |
1019 | if (studyLoad Level.IsIn cludeSerie s()) | |
1020 | study.ad dSeries(se ries); | |
1021 | } | |
1022 | catch (URNFormat Exception urnfX){ | |
1023 | logger.err or("URNFor matExcepti on creatin g a serie for study IEN " + st udy.getStu dyIen() + ". " + ur nfX.getMes sage(), ur nfX); | |
1024 | } | |
1025 | catch (SeriesPar singExcept ion spX) { | |
1026 | logger .error("Se riesParsin gException creating a serie fo r study IE N " + stud y.getStudy Ien() + ". " + spX. getMessage (), spX); | |
1027 | } | |
1028 | catch (Exception X){ | |
1029 | logger.e rror("Exce ption crea ting a ser ie for stu dy IEN " + study.get StudyIen() + ". " + X.getMess age(), X); | |
1030 | } | |
1031 | } | |
1032 | ||
1033 | if(first ImageIen = = null || firstImage Ien.length () == 0){ | |
1034 | firs tImageIen = altFirst ImageIen; | |
1035 | } | |
1036 | if(!stud yLoadLevel .isInclude Images()) | |
1037 | { | |
1038 | // this is a special case, if the load l evel was n ot full | |
1039 | // i f the stud y is a sin gle image study, the n older st udies may not have a n image no de, | |
1040 | // i t might ju st be the parent nod e and it r epresents the image node. in t his case | |
1041 | // t he imageCo unt and fi rstImageIe n will not have been provided in the RPC call, | |
1042 | // t he firstIm ageIen is the same a s the grou p ien and the imageC ount is 1 | |
1043 | if(i mageCount == 0) | |
1044 | { | |
1045 | logger .debug("St udyLoadLev el was not full and image coun t was 0, s etting ima ge count t o 1 indica ting singl e image gr oup with n o child no de"); | |
1046 | imageC ount = 1; | |
1047 | } | |
1048 | if(f irstImageI en.length( ) == 0) | |
1049 | { | |
1050 | logger .debug("St udyLoadLev el was not full and first Imag e Ien is m issing, se tting valu e to '" + ien + "', indicating single im age group with no ch ild node") ; | |
1051 | firstI mageIen = ien; | |
1052 | } | |
1053 | } | |
1054 | ||
1055 | return s tudy; | |
1056 | } | |
1057 | ||
1058 | /* * | |
1059 | * | |
1060 | * @param si te | |
1061 | * @param pa rentStudy | |
1062 | * @param se riesLine | |
1063 | * @return | |
1064 | * @throws U RNFormatEx ception | |
1065 | * / | |
1066 | pr ivate stat ic Series createSeri es(Site si te, Study parentStud y, VistaIm agingParse r.ParsedVi staLine se riesLine, | |
1067 | String altFirstI mageIen, b oolean isS eriesInNew DataStruct ure) | |
1068 | th rows URNFo rmatExcept ion, Serie sParsingEx ception | |
1069 | { | |
1070 | if(s eriesLine == null){ | |
1071 | throw new Series ParsingExc eption("se riesLine i s null."); | |
1072 | } | |
1073 | ||
1074 | Seri es series = new Seri es(); | |
1075 | ||
1076 | Vist aImagingPa rser.Parse dVistaLine uidProper ty = serie sLine.getP roperty(SE RIES_UID_K EY); | |
1077 | if(uidPr operty != null) | |
1078 | { | |
1079 | Stri ng uid = u idProperty .getValueA tIndex(0); | |
1080 | seri es.setSeri esUid(uid) ; | |
1081 | } | |
1082 | ||
1083 | VistaIma gingParser .ParsedVis taLine ien Property = seriesLin e.getPrope rty(SERIES _IEN_KEY); | |
1084 | if(ienPr operty != null) | |
1085 | { | |
1086 | Stri ng ien = i enProperty .getValueA tIndex(0); | |
1087 | seri es.setSeri esIen(ien) ; | |
1088 | } | |
1089 | ||
1090 | VistaIma gingParser .ParsedVis taLine num berPropert y = series Line.getPr operty(SER IES_NUMBER _KEY); | |
1091 | if(numbe rProperty != null) | |
1092 | { | |
1093 | Stri ng number = numberPr operty.get ValueAtInd ex(0); | |
1094 | seri es.setSeri esNumber(n umber); | |
1095 | } | |
1096 | ||
1097 | VistaIma gingParser .ParsedVis taLine mod alityPrope rty = seri esLine.get Property(S ERIES_MODA LITY); | |
1098 | if(modal ityPropert y != null) | |
1099 | { | |
1100 | Stri ng modalit y = modali tyProperty .getValueA tIndex(0); | |
1101 | if(! "*".equals (modality) ) | |
1102 | seri es.setModa lity(modal ity); | |
1103 | } | |
1104 | ||
1105 | if(paren tStudy.isS tudyInNewD ataStructu re()){ | |
1106 | VistaI magingPars er.ParsedV istaLine c lassIndexP roperty = seriesLine .getProper ty(SERIES_ CLASS_INDE X_KEY); | |
1107 | if(classIn dexPropert y != null) | |
1108 | { | |
1109 | String classInde x = classI ndexProper ty.getValu eAtIndex(0 ); | |
1110 | parent Study.setS tudyClass( classIndex ); | |
1111 | } | |
1112 | ||
1113 | VistaI magingPars er.ParsedV istaLine p rocEventPr operty = s eriesLine. getPropert y(SERIES_P ROCEVENT_I NDEX_KEY); | |
1114 | if(procEve ntProperty != null) | |
1115 | { | |
1116 | String procEvent = procEve ntProperty .getValueA tIndex(0); | |
1117 | parent Study.setE vent(procE vent); | |
1118 | } | |
1119 | ||
1120 | VistaI magingPars er.ParsedV istaLine s pecPropert y = series Line.getPr operty(SER IES_SPECSU BSPEC_INDE X_KEY); | |
1121 | if(specPro perty != n ull) | |
1122 | { | |
1123 | String spec = sp ecProperty .getValueA tIndex(0); | |
1124 | parent Study.setS pecialty(s pec); | |
1125 | } | |
1126 | } | |
1127 | ||
1128 | series.s etSeriesIn NewDataStr ucture(par entStudy.i sStudyInNe wDataStruc ture()); | |
1129 | ||
1130 | for( Ite rator<Vist aImagingPa rser.Parse dVistaLine > imageIte r = series Line.child Iterator() ; imageIte r.hasNext( ); ) | |
1131 | { | |
1132 | Vist aImagingPa rser.Parse dVistaLine imageLine = imageIt er.next(); | |
1133 | try{ | |
1134 | Image image = cr eateImage( site, pare ntStudy, s eries, ima geLine, al tFirstImag eIen, isSe riesInNewD ataStructu re); | |
1135 | if(ima ge != null ) | |
1136 | series.a ddImage(im age); | |
1137 | } | |
1138 | catch (URNFormat Exception urnfX){ | |
1139 | logger.e rror("URNF ormatExcep tion creat ing an ima ge for ser ies IEN " + series.g etSeriesIe n() + ". " + urnfX. getMessage (), urnfX) ; | |
1140 | } | |
1141 | catc h(ImagePar singExcept ion ipX){ | |
1142 | logger .error("Im ageParsing Exception creating a n image fo r series I EN " + ser ies.getSer iesIen() + ". " + i pX.getMess age(), ipX ); | |
1143 | } | |
1144 | catch (Exception X){ | |
1145 | logger.e rror("Exce ption crea ting an im age for se ries IEN " + series. getSeriesI en() + ". " + X.get Message(), X); | |
1146 | } | |
1147 | } | |
1148 | ||
1149 | retu rn series; | |
1150 | } | |
1151 | ||
1152 | /* * | |
1153 | * | |
1154 | * @param si te | |
1155 | * @param pa rentStudy | |
1156 | * @param pa rentSeries | |
1157 | * @param se riesLine | |
1158 | * @return | |
1159 | * @throws U RNFormatEx ception | |
1160 | * / | |
1161 | pr ivate stat ic Image c reateImage ( | |
1162 | Site site, | |
1163 | Stud y parentSt udy, | |
1164 | Seri es parentS eries, | |
1165 | Vist aImagingPa rser.Parse dVistaLine imageLine , | |
1166 | Stri ng altFirs tImageIen, | |
1167 | bool ean isImag eInNewData Structure) | |
1168 | th rows URNFo rmatExcept ion, Image ParsingExc eption | |
1169 | { | |
1170 | if(i mageLine = = null){ | |
1171 | throw new ImageP arsingExce ption("ima geLine is null."); | |
1172 | } | |
1173 | ||
1174 | Stri ng imageIe n = null; | |
1175 | Stri ng consoli datedSiteN umber = "" ; | |
1176 | Vist aImagingPa rser.Parse dVistaLine ienProper ty = image Line.getPr operty(IMA GE_IEN_KEY ); | |
1177 | if(ienPr operty != null) | |
1178 | { | |
1179 | imag eIen = ien Property.g etValueAtI ndex(0); | |
1180 | } | |
1181 | ||
1182 | if(altFi rstImageIe n.length() == 0){ | |
1183 | altF irstImageI en = image Ien; | |
1184 | } | |
1185 | ||
1186 | String i mageUid = ""; | |
1187 | Vi staImaging Parser.Par sedVistaLi ne uidProp erty = ima geLine.get Property(I MAGE_UID_K EY); | |
1188 | if(uidPr operty != null) | |
1189 | { | |
1190 | Stri ng uid = u idProperty .getValueA tIndex(0); | |
1191 | imag eUid = uid ; | |
1192 | } | |
1193 | ||
1194 | String i mageNumber = ""; | |
1195 | VistaIma gingParser .ParsedVis taLine num berPropert y = imageL ine.getPro perty(IMAG E_NUMBER_K EY); | |
1196 | if(numbe rProperty != null) | |
1197 | { | |
1198 | Stri ng number = numberPr operty.get ValueAtInd ex(0); | |
1199 | imag eNumber = number; | |
1200 | } | |
1201 | ||
1202 | String i mageInfoLi ne = null; | |
1203 | VistaIma gingParser .ParsedVis taLine inf oProperty = imageLin e.getPrope rty(IMAGE_ INFO_KEY); | |
1204 | if(infoP roperty != null) | |
1205 | { | |
1206 | Stri ng infoLin e = infoPr operty.get ValueAtInd ex(0); | |
1207 | imag eInfoLine = infoLine ; | |
1208 | if(i nfoPropert y.isValueA tIndexExis ts(1)) | |
1209 | { | |
1210 | consol idatedSite Number = i nfoPropert y.getValue AtIndex(1) ; | |
1211 | } | |
1212 | else { | |
1213 | consol idatedSite Number = s ite.getSit eNumber(); | |
1214 | } | |
1215 | } | |
1216 | ||
1217 | if(image InfoLine = = null) | |
1218 | { | |
1219 | logg er.warn("N o IMAGE_IN FO details for image [" + imag eIen + "], indicates this imag e was dele ted, exclu ding from result"); | |
1220 | retu rn null; | |
1221 | } | |
1222 | ||
1223 | String g roupIen = null; | |
1224 | VistaIma gingParser .ParsedVis taLine gro upIenPrope rty = imag eLine.getP roperty(GR OUP_IEN_KE Y); | |
1225 | if(group IenPropert y != null) | |
1226 | { | |
1227 | grou pIen = gro upIenPrope rty.getVal ueAtIndex( 0); | |
1228 | pare ntStudy.se tGroupIen( groupIen); | |
1229 | } | |
1230 | else | |
1231 | { | |
1232 | // i f the GROU P_IEN key is missing that mean s this is a single i mage | |
1233 | // s tudy with no child n ode, in th is case th e group IE N, image I EN, and ST UDY IEN ar e all the same | |
1234 | //im age.setGro upIen(pare ntStudy.ge tStudyIen( )); | |
1235 | } | |
1236 | VistaIma gingParser .ParsedVis taLine ima geErrorPro perty = im ageLine.ge tProperty( IMAGE_ERRO R); | |
1237 | String e rrorMessag e = null; | |
1238 | if(image ErrorPrope rty != nul l) | |
1239 | { | |
1240 | Stri ng errorMs g = imageE rrorProper ty.getValu eAtIndex(0 ); | |
1241 | erro rMessage = errorMsg; | |
1242 | } | |
1243 | // JMW 2 /6/08 - No longer ge tting thes e values f rom the gr aph, getti ng them fr om the inf o key | |
1244 | // JMW 3 /7/08 - se tting thes e values a t the end so that th ey overwri te the val ues we got | |
1245 | // from VistA - no t entirely sure abou t this but sometimes VistA doe sn't have the right | |
1246 | // abbre viation (i f the site has not s et it prop erly) | |
1247 | // JMW 1 /21/10 - w ant to use site abbr eviation f rom VistA for consol idated sit es so they have the actual val ue - this could | |
1248 | // cause problems if site do esn't set value prop erly, but should not have func tional imp act - only visual im pact. | |
1249 | //image. setSiteAbb r(site.get SiteAbbr() ); | |
1250 | // JMW 4 /9/10 - no t sure why setSiteNu mber is co mmented ou t... | |
1251 | //im age.setSit eNumber(si te.getSite Number()); | |
1252 | ||
1253 | Image im age = Imag e.create( | |
1254 | site.get SiteNumber (), | |
1255 | imageIen , | |
1256 | groupI en == null ? parentS tudy.getSt udyIen() : groupIen, | |
1257 | parent Study.getP atientIden tifier(), | |
1258 | parentSe ries.getMo dality(), | |
1259 | isImageI nNewDataSt ructure); | |
1260 | ||
1261 | image.se tImageUid( imageUid); | |
1262 | image.se tImageNumb er(imageNu mber); | |
1263 | image.se tConsolida tedSiteNum ber(consol idatedSite Number); | |
1264 | updateIm ageWithIma geLine(ima ge, imageI nfoLine); | |
1265 | if(error Message != null) | |
1266 | { | |
1267 | imag e.setError Message(er rorMessage ); | |
1268 | } | |
1269 | if(paren tStudy.get FirstImage () == null ) | |
1270 | { | |
1271 | pare ntStudy.se tFirstImag e(image); | |
1272 | pare ntStudy.se tFirstImag eIen(image .getIen()) ; | |
1273 | } | |
1274 | ||
1275 | if(isIma geInNewDat aStructure ){ | |
1276 | Map<String ,ArtifactI nstance> f ullProvide rMap = new HashMap<S tring,Arti factInstan ce>(); | |
1277 | Map<String ,ArtifactI nstance> t humbnailPr oviderMap = new Hash Map<String ,ArtifactI nstance>() ; | |
1278 | ||
1279 | for( Itera tor<VistaI magingPars er.ParsedV istaLine> instanceIt er = image Line.child Iterator() ; instance Iter.hasNe xt(); ) | |
1280 | { | |
1281 | VistaI magingPars er.ParsedV istaLine i nstanceLin e = instan ceIter.nex t(); | |
1282 | try{ | |
1283 | createAr tifactInst anceForIma ge(site, p arentStudy , parentSe ries, imag e, fullPro viderMap, thumbnailP roviderMap , instance Line); | |
1284 | } | |
1285 | catch (U RNFormatEx ception ur nfX){ | |
1286 | logger.err or("URNFor matExcepti on creatin g an artif act for im age IEN " + image.ge tIen() + " . " + urn fX.getMess age(), urn fX); | |
1287 | } | |
1288 | catch( ArtifactPa rsingExcep tion apX){ | |
1289 | logger.e rror("Arti factParsin gException creating an artifac t for imag e IEN " + image.getI en() + ". " + apX.g etMessage( ), apX); | |
1290 | } | |
1291 | catch( Exception X){ | |
1292 | logger.e rror("Exce ption crea ting an ar tifact for image IEN " + image .getIen() + ". " + X.getMessa ge(), X); | |
1293 | } | |
1294 | } | |
1295 | //WFP-add code later to identi fy other t han Magnet ic for abs Location a nd fullLoc ation | |
1296 | ArtifactIn stance ful lImageInfo = getBest ProviderIm ageUNC(ful lProviderM ap); | |
1297 | ArtifactIn stance thu mbnailImag eInfo = ge tBestProvi derImageUN C(thumbnai lProviderM ap); | |
1298 | ||
1299 | if(fullIma geInfo == null){ | |
1300 | throw new ImageP arsingExce ption("Ful l Resoluti on artifac t instance is null f or image " + image.g etIen() + "."); | |
1301 | } | |
1302 | if(thumbna ilImageInf o == null) { | |
1303 | throw new ImageP arsingExce ption("Thu mbnail art ifact inst ance is nu ll for ima ge " + ima ge.getIen( ) + "."); | |
1304 | } | |
1305 | ||
1306 | if(image ! = null){ | |
1307 | im age.setFul lFilename( fullImageI nfo.getAbs oluteFiles pec()); | |
1308 | image.se tFullLocat ion("M"); | |
1309 | image.se tFullDiskV olumeIen(S tring.valu eOf(fullIm ageInfo.ge tDiskVolum e())); | |
1310 | image.se tFullFilep ath(fullIm ageInfo.ge tFilePath( )); | |
1311 | image.se tFullFiles pec(fullIm ageInfo.ge tFileRef() ); | |
1312 | image.se tFullArtif actIen(Str ing.valueO f(fullImag eInfo.getA rtifactId( ))); | |
1313 | image.se tAbsFilena me(thumbna ilImageInf o.getAbsol uteFilespe c()); | |
1314 | image.se tAbsLocati on("M"); | |
1315 | image.se tAbsDiskVo lumeIen(St ring.value Of(thumbna ilImageInf o.getDiskV olume())); | |
1316 | image.se tAbsFilepa th(thumbna ilImageInf o.getFileP ath()); | |
1317 | image.se tAbsFilesp ec(thumbna ilImageInf o.getFileR ef()); | |
1318 | image.se tAbsArtifa ctIen(Stri ng.valueOf (thumbnail ImageInfo. getArtifac tId())); | |
1319 | } | |
1320 | } | |
1321 | //Di scovered w e were doi ng the col lection ad d() twice. | |
1322 | //if(ima ge != null ){ | |
1323 | // parent Series.add Image(imag e); | |
1324 | //} | |
1325 | retu rn image; | |
1326 | } | |
1327 | ||
1328 | /* * | |
1329 | * | |
1330 | * @param si te | |
1331 | * @param pa rentStudy | |
1332 | * @param pa rentSeries | |
1333 | * @param pa rentImage | |
1334 | * @param se riesLine | |
1335 | * @param is StudyInNew DataStruct ure | |
1336 | * @return | |
1337 | * @throws U RNFormatEx ception | |
1338 | * / | |
1339 | pr ivate stat ic void cr eateArtifa ctInstance ForImage( | |
1340 | Site site, | |
1341 | Stud y parentSt udy, | |
1342 | Seri es parentS eries, | |
1343 | Imag e image, | |
1344 | Map< String,Art ifactInsta nce> dicom ProviderMa p, | |
1345 | Map< String,Art ifactInsta nce> jpegP roviderMap , | |
1346 | Vist aImagingPa rser.Parse dVistaLine artifactI nstanceLin e) | |
1347 | th rows URNFo rmatExcept ion, Artif actParsing Exception | |
1348 | { | |
1349 | if(a rtifactIns tanceLine == null){ | |
1350 | throw new Artifa ctParsingE xception(" artifactIn stanceLine is null." ); | |
1351 | } | |
1352 | ||
1353 | Stri ng artifac tInstanceI en = null; | |
1354 | Vist aImagingPa rser.Parse dVistaLine artifactI nstanceIen Property = artifactI nstanceLin e.getPrope rty(ARTIFA CTINSTANCE _PK_KEY); | |
1355 | if(artif actInstanc eIenProper ty != null ) | |
1356 | { | |
1357 | arti factInstan ceIen = ar tifactInst anceIenPro perty.getV alueAtInde x(0); | |
1358 | } | |
1359 | ||
1360 | Stri ng imageFo rmat = nul l; | |
1361 | Vist aImagingPa rser.Parse dVistaLine imageForm atProperty = artifac tInstanceL ine.getPro perty(ARTI FACTINSTAN CE_ARTIFAC TFORMAT_KE Y); | |
1362 | if(image FormatProp erty != nu ll) | |
1363 | { | |
1364 | imag eFormat = imageForma tProperty. getValueAt Index(0); | |
1365 | } | |
1366 | ||
1367 | Stri ng artifac tIen = nul l; | |
1368 | Vist aImagingPa rser.Parse dVistaLine artifactI enProperty = artifac tInstanceL ine.getPro perty(ARTI FACTINSTAN CE_ARTIFAC T_KEY); | |
1369 | if(artif actIenProp erty != nu ll) | |
1370 | { | |
1371 | arti factIen = artifactIe nProperty. getValueAt Index(0); | |
1372 | } | |
1373 | ||
1374 | //String storagePr ovider = n ull; | |
1375 | // VistaImagi ngParser.P arsedVista Line stora geProvider Property = artifactI nstanceLin e.getPrope rty(ARTIFA CTINSTANCE _STORAGEPR OVIDER_KEY ); | |
1376 | //if(sto rageProvid erProperty != null) | |
1377 | //{ | |
1378 | // stor ageProvide r = storag eProviderP roperty.ge tValueAtIn dex(0); | |
1379 | //} | |
1380 | ||
1381 | String s torageProv iderType = null; | |
1382 | Vi staImaging Parser.Par sedVistaLi ne storage ProviderTy peProperty = artifac tInstanceL ine.getPro perty(ARTI FACTINSTAN CE_STORAGE PROVIDERTY PE_KEY); | |
1383 | if(stora geProvider TypeProper ty != null ) | |
1384 | { | |
1385 | stor ageProvide rType = st orageProvi derTypePro perty.getV alueAtInde x(0); | |
1386 | } | |
1387 | ||
1388 | String c reationDat e = null; | |
1389 | Date cre ationDateS tamp = nul l; | |
1390 | VistaIma gingParser .ParsedVis taLine cre ationDateP roperty = artifactIn stanceLine .getProper ty(ARTIFAC TINSTANCE_ CREATEDATE TIME_KEY); | |
1391 | if(creat ionDatePro perty != n ull) | |
1392 | { | |
1393 | crea tionDate = creationD atePropert y.getValue AtIndex(0) ; | |
1394 | if(( creationDa te != null ) && (crea tionDate.l ength() > 0)) | |
1395 | { | |
1396 | creati onDateStam p = VistaT ranslatorU tility.con vertVistaD atetoDate( creationDa te); | |
1397 | image. setCapture Date(creat ionDateSta mp); | |
1398 | } | |
1399 | ||
1400 | } | |
1401 | ||
1402 | //String lastAcces sDate = nu ll; | |
1403 | //VistaI magingPars er.ParsedV istaLine l astAccessD atePropert y = artifa ctInstance Line.getPr operty(ART IFACTINSTA NCE_LASTAC CESSDATETI ME_KEY); | |
1404 | //if(las tAccessDat eProperty != null) | |
1405 | //{ | |
1406 | // last AccessDate = lastAcc essDatePro perty.getV alueAtInde x(0); | |
1407 | //} | |
1408 | ||
1409 | String f ileRef = n ull; | |
1410 | VistaIma gingParser .ParsedVis taLine fil eRefProper ty = artif actInstanc eLine.getP roperty(AR TIFACTINST ANCE_FILER EF_KEY); | |
1411 | if(fileR efProperty != null) | |
1412 | { | |
1413 | file Ref = file RefPropert y.getValue AtIndex(0) ; | |
1414 | } | |
1415 | ||
1416 | String d iskVolumeI en = null; | |
1417 | VistaIma gingParser .ParsedVis taLine dis kVolumePro perty = ar tifactInst anceLine.g etProperty (ARTIFACTI NSTANCE_DI SKVOLUME_K EY); | |
1418 | if(diskV olumePrope rty != nul l) | |
1419 | { | |
1420 | disk VolumeIen = diskVolu meProperty .getValueA tIndex(0); | |
1421 | } | |
1422 | ||
1423 | String d iskPhysica lRef = nul l; | |
1424 | VistaIma gingParser .ParsedVis taLine dis kPhysicalR efProperty = artifac tInstanceL ine.getPro perty(ARTI FACTINSTAN CE_PHYSICA LREFERENCE _KEY); | |
1425 | if(diskP hysicalRef Property ! = null) | |
1426 | { | |
1427 | disk PhysicalRe f = diskPh ysicalRefP roperty.ge tValueAtIn dex(0); | |
1428 | } | |
1429 | ||
1430 | String f ilePath = null; | |
1431 | VistaIma gingParser .ParsedVis taLine fil ePathPrope rty = arti factInstan ceLine.get Property(A RTIFACTINS TANCE_FILE PATH_KEY); | |
1432 | if(fileP athPropert y != null) | |
1433 | { | |
1434 | file Path = fil ePathPrope rty.getVal ueAtIndex( 0); | |
1435 | } | |
1436 | ||
1437 | String a rtifactUNC = createU NCForImage InNewDataS tructure(d iskPhysica lRef, file Ref, fileP ath); | |
1438 | ||
1439 | Artifact Instance i nfo = new ArtifactIn stance(); | |
1440 | info.set AbsoluteFi lespec(art ifactUNC); | |
1441 | info.set DiskVolume (new Integ er(diskVol umeIen)); | |
1442 | info.set FileRef(fi leRef); | |
1443 | info.set FilePath(f ilePath); | |
1444 | info.set Id(new Int eger(artif actInstanc eIen)); | |
1445 | info.set ArtifactId (new Integ er(artifac tIen)); | |
1446 | ||
1447 | if(dicom ProviderMa p == null || jpegPro viderMap = = null){ | |
1448 | thro w new Arti factParsin gException ("DICOM Ma p or JPEG Map is nul l."); | |
1449 | } | |
1450 | ||
1451 | if (imag eFormat.eq uals("DICO M")){ | |
1452 | dico mProviderM ap.put(sto rageProvid erType, in fo); | |
1453 | } | |
1454 | else if( imageForma t.endsWith ("JPEG")){ | |
1455 | ||
1456 | jpeg ProviderMa p.put(stor ageProvide rType, inf o); | |
1457 | } | |
1458 | } | |
1459 | ||
1460 | ||
1461 | pr ivate stat ic void up dateImageW ithImageLi ne(Image i mage, Stri ng imageLi ne) | |
1462 | th rows Image ParsingExc eption | |
1463 | { | |
1464 | try{ | |
1465 | if((im age != nul l) && (ima geLine != null)) | |
1466 | { | |
1467 | VistaIma ge vistaIm age = Vist aImage.cre ate(imageL ine); | |
1468 | image.se tFullFilen ame(vistaI mage.getFu llFilename ()); | |
1469 | image.se tAbsFilena me(vistaIm age.getAbs Filename() ); | |
1470 | image.se tDescripti on(vistaIm age.getDes cription() ); | |
1471 | image.se tImgType(v istaImage. getImgType ()); | |
1472 | image.se tProcedure (vistaImag e.getProce dure()); | |
1473 | image.se tProcedure Date(vista Image.getP rocedureDa te()); | |
1474 | image.se tAbsLocati on(vistaIm age.getAbs Location() ); | |
1475 | image.se tFullLocat ion(vistaI mage.getFu llLocation ()); | |
1476 | image.se tDicomSequ enceNumber ForDisplay (vistaImag e.getDicom SequenceNu mberForDis play()); | |
1477 | image.se tDicomImag eNumberFor Display(vi staImage.g etDicomIma geNumberFo rDisplay() ); | |
1478 | image.se tSiteAbbr( vistaImage .getSiteAb br()); | |
1479 | image.se tBigFilena me(vistaIm age.getBig Filename() ); | |
1480 | image.se tPatientDF N(vistaIma ge.getPati entDFN()); | |
1481 | image.se tPatientNa me(vistaIm age.getPat ientName() ); | |
1482 | image.se tImageClas s(vistaIma ge.getImag eClass()); | |
1483 | image.se tDocumentD ate(vistaI mage.getDo cumentDate ()); | |
1484 | image.se tCaptureDa te(vistaIm age.getCap tureDate() ); | |
1485 | image.se tSensitive (vistaImag e.isSensit ive()); | |
1486 | image.se tImageStat us(vistaIm age.getIma geStatus() ); | |
1487 | image.se tImageView Status(vis taImage.ge tImageView Status()); | |
1488 | image.se tAssociate dNoteResul ted(vistaI mage.getAs sociatedNo teResulted ()); | |
1489 | image.se tImagePack age(vistaI mage.getIm agePackage ()); | |
1490 | image.se tImageHasA nnotations (vistaImag e.isImageH asAnnotati ons()); | |
1491 | image.se tImageAnno tationStat us(vistaIm age.getIma geAnnotati onStatus() ); | |
1492 | image.se tImageAnno tationStat usDescript ion(vistaI mage.getIm ageAnnotat ionStatusD escription ()); | |
1493 | ||
1494 | } | |
1495 | else{ | |
1496 | throw ne w ImagePar singExcept ion("image Line or im age object is null." ); | |
1497 | } | |
1498 | } | |
1499 | catc h(VistaPar singExcept ion vpX){ | |
1500 | throw new ImageP arsingExce ption(vpX. getMessage (), vpX); | |
1501 | } | |
1502 | } | |
1503 | ||
1504 | /* * | |
1505 | * Convert a String, a s returned from Vist A Imaging, into a so rted set o f Study in stances. | |
1506 | * | |
1507 | * @param si te | |
1508 | * @param vi staRespons e | |
1509 | * @param st udyLoadLev el | |
1510 | * @return | |
1511 | * / | |
1512 | pu blic stati c SortedSe t<Study> c reateFilte redStudies FromGraph( Site site, String vi staRespons e, | |
1513 | StudyL oadLevel s tudyLoadLe vel, Study Filter stu dyFilter, StudyDelet edImageSta te studyDe letedImage State) | |
1514 | { | |
1515 | Stri ng details [] = Strin gUtils.Spl it(vistaRe sponse, St ringUtils. NEW_LINE); | |
1516 | Sort edSet<Stud y> studies = createF ilteredStu diesFromGr aph(site, details, s tudyLoadLe vel, study Filter, | |
1517 | studyDel etedImageS tate); | |
1518 | retu rn studies ; | |
1519 | } | |
1520 | ||
1521 | /* * | |
1522 | * | |
1523 | * @param si te | |
1524 | * @param st udyLines - a String array orig inally fro m Vista in a form th at defies simple des cription. | |
1525 | * "l ines" are CR delimit ed lines o f text | |
1526 | * "p arts" are delimited by the ver tical bar '|' charac ter | |
1527 | * "p ieces" are delimited by the ca ret '^' ch aracter | |
1528 | * Ea ch line co nsists of 1..n parts . The fir st part (i ndex=0) is a key. | |
1529 | * Ea ch part co nsists of 1..n piece s. | |
1530 | * Pr ior to cal ling this method, th e parts ha ve been pa rsed into a String a rray. | |
1531 | * Example of a singl e image st udy: | |
1532 | * 11 | |
1533 | * NE XT_STUDY|| 712 | |
1534 | * ST UDY_IEN|71 2 | |
1535 | * ST UDY_PAT|10 11|9217103 663V710366 |IMAGPATIE NT1011,101 1 | |
1536 | * NE XT_SERIES | |
1537 | * SE RIES_IEN|7 12 | |
1538 | * NE XT_IMAGE | |
1539 | * IM AGE_IEN|71 3 | |
1540 | * IM AGE_INFO|B 2^713^\\is w-werfelj- lt\image1$ \DM\00\07\ DM000713.T GA^\\isw-w erfelj-lt\ image1$\DM \00\07\DM0 00713.ABS^ 040600-28 CHEST SIN GLE VIEW^3 000406.134 9^3^CR^04/ 06/2000^^M ^A^^^1^1^S LC^^^1011^ IMAGPATIEN T1011,1011 ^CLIN^^^^ | |
1541 | * IM AGE_ABSTRA CT|\\isw-w erfelj-lt\ image1$\DM \00\07\DM0 00713.ABS | |
1542 | * IM AGE_FULL|\ \isw-werfe lj-lt\imag e1$\DM\00\ 07\DM00071 3.TGA | |
1543 | * IM AGE_TEXT|\ \isw-werfe lj-lt\imag e1$\DM\00\ 07\DM00071 3.TXT | |
1544 | * The firs t line is the number of lines in the res ponse. | |
1545 | * | |
1546 | * The keys "NEXT_STU DY", "NEXT _SERIES", and "NEXT_ IMAGE" mak e up the " study onto logy" defi nition, re ally | |
1547 | * just the demarcati on of the levels of the hierar chy. The VistaImagi ngParser w ill use th ose keys a s delimite rs | |
1548 | * when par sing the S tring retu rned from Vista into a hierarc hy of line s. | |
1549 | * | |
1550 | * @return | |
1551 | * / | |
1552 | pu blic stati c SortedSe t<Study> c reateFilte redStudies FromGraph( Site site, String[] studyLines , | |
1553 | StudyL oadLevel s tudyLoadLe vel, Study Filter stu dyFilter, StudyDelet edImageSta te studyDe letedImage State) | |
1554 | { | |
1555 | Sort edSet<Stud y> studyLi st = new T reeSet<Stu dy>(); | |
1556 | if( studyLines == null | | studyLin es.length <= 1 ) | |
1557 | return studyList ; // i .e. return an empty Set | |
1558 | ||
1559 | Stri ng studyCo untLine = studyLines [0].trim() ; | |
1560 | try | |
1561 | { | |
1562 | int expectedLi neCount = Integer.pa rseInt( st udyCountLi ne ); | |
1563 | if( expectedLi neCount != studyLine s.length ) | |
1564 | logger.w arn("The e xpected nu mber of li nes (" + e xpectedLin eCount + | |
1565 | ") does not match the actual num ber (" + ( studyLines .length) + | |
1566 | ") , continui ng."); | |
1567 | } | |
1568 | catc h (NumberF ormatExcep tion e) | |
1569 | { | |
1570 | logger .warn("Una ble to par se the fir st line (c ontaining number of lines) in the VistA response. Line was '" + | |
1571 | studyCount Line + "', continuin g."); | |
1572 | } | |
1573 | ||
1574 | // d rop the fi rst line | |
1575 | Stri ng[] realL ines = new String[st udyLines.l ength-1]; | |
1576 | Syst em.arrayco py(studyLi nes, 1, re alLines, 0 , realLine s.length); | |
1577 | ||
1578 | // c reate a Vi sta Parser using the hierarchy levels de fined by t he ontolog y delimite r keys | |
1579 | Vist aImagingPa rser parse r = new Vi staImaging Parser(stu dyOntology DelimiterK eys); | |
1580 | ||
1581 | List <VistaImag ingParser. ParsedVist aLine> par sedStudyLi nes = pars er.parse(r ealLines, true); | |
1582 | ||
1583 | // i f there ar e any pars ed lines t hat have t he root ke y | |
1584 | if(p arsedStudy Lines != n ull && par sedStudyLi nes.size() > 0) | |
1585 | for(Vi staImaging Parser.Par sedVistaLi ne studyLi ne : parse dStudyLine s) | |
1586 | { | |
1587 | Study st udy; | |
1588 | try | |
1589 | { | |
1590 | study = cr eateFilter edStudy(si te, studyL ine, study LoadLevel, studyFilt er, studyD eletedImag eState); | |
1591 | if(study ! = null) | |
1592 | st udyList.ad d(study); | |
1593 | } | |
1594 | catch (U RNFormatEx ception ur nfX) | |
1595 | { | |
1596 | logger.err or("Except ion creati ng a study . " + urn fX.getMess age(), urn fX); | |
1597 | } | |
1598 | catch (S tudyParsin gException spX) | |
1599 | { | |
1600 | logger.err or("Except ion creati ng a study . " + spX .getMessag e(), spX); | |
1601 | } | |
1602 | catch (E xception X ) | |
1603 | { | |
1604 | logger.err or("Except ion creati ng a study . " + X.g etMessage( ), X); | |
1605 | } | |
1606 | } | |
1607 | // add the compl ete Study with Serie s and Imag e instance s attached | |
1608 | // to the list o f Study | |
1609 | ||
1610 | retu rn studyLi st; | |
1611 | } | |
1612 | ||
1613 | ||
1614 | /* * | |
1615 | * | |
1616 | * @param si te | |
1617 | * @param st udyLine | |
1618 | * @return | |
1619 | * @throws U RNFormatEx ception | |
1620 | * / | |
1621 | pr ivate stat ic Study c reateFilte redStudy(S ite site, VistaImagi ngParser.P arsedVista Line study Line, | |
1622 | StudyL oadLevel s tudyLoadLe vel, Study Filter stu dyFilter, StudyDelet edImageSta te studyDe letedImage State) | |
1623 | th rows URNFo rmatExcept ion, Study ParsingExc eption | |
1624 | { | |
1625 | ||
1626 | VistaIma gingParser .ParsedVis taLine err orProperty = studyLi ne.getProp erty(STUDY _ERROR); | |
1627 | if(error Property ! = null) | |
1628 | { | |
1629 | //st udyUid = e rrorProper ty.getValu eAtIndex(0 ); | |
1630 | Stri ng badIEN = null; | |
1631 | if(stu dyLine.isV alueAtInde xExists(1) ){ | |
1632 | badIEN = studyLine .getValueA tIndex(1); | |
1633 | } | |
1634 | Stri ng errorMs g = ""; | |
1635 | if(e rrorProper ty.isValue AtIndexExi sts(1)){ | |
1636 | errorM sg = error Property.g etValueAtI ndex(1); | |
1637 | } | |
1638 | ||
1639 | Pati entIdentif ier unknow n = Patien tIdentifie r.icnPatie ntIdentifi er(unknown Patient); | |
1640 | ||
1641 | Study stud y = Study. create(Obj ectOrigin. VA, site.g etSiteNumb er(), badI EN, | |
1642 | unknown, studyLoad Level, stu dyDeletedI mageState) ; | |
1643 | ||
1644 | logg er.warn("S TUDY Error for study Ien [" + badIEN + " ], '" + er rorMsg + " '." ); | |
1645 | stud y.setError Message(er rorMsg); | |
1646 | // J MW 7/17/08 - we now return the study but keep the error mess age to use later | |
1647 | retu rn study; | |
1648 | } | |
1649 | ||
1650 | //Vi staImaging Parser.Par sedVistaLi ne nextStu dyProperty = studyLi ne.getProp erty(STUDY _NEXT); | |
1651 | Stri ng dataStr ucture = n ull; | |
1652 | bool ean isStud yInNewData Structure = false; | |
1653 | if(s tudyLine.i sValueAtIn dexExists( 1)){ | |
1654 | dataSt ructure = studyLine. getValueAt Index(1); | |
1655 | if((da taStructur e != null) && (dataS tructure.l ength() > 0)){ | |
1656 | if(dataS tructure.e quals("NEW ")){ | |
1657 | isStudyInN ewDataStru cture = tr ue; | |
1658 | } | |
1659 | } | |
1660 | } | |
1661 | Vist aImagingPa rser.Parse dVistaLine ienProper ty = study Line.getPr operty(STU DY_IEN_KEY ); | |
1662 | String i en = null; | |
1663 | ||
1664 | // we mu st have th e IEN to c reate a St udy | |
1665 | if(ienPr operty != null) | |
1666 | ien = ienPrope rty.getVal ueAtIndex( 0); // e ither the first valu e of the S TUDY_IEN l ine | |
1667 | else | |
1668 | ien = studyLin e.getValue AtIndex(1) ; // or the second value fro m the NEXT _STUDY lin e | |
1669 | ||
1670 | logger.d ebug("IEN from parse d line: " + ien); | |
1671 | int imag eCount = 0 ; | |
1672 | String f irstImageI en = ""; | |
1673 | String c ptCode = " "; | |
1674 | String c onsolidate dSiteNumbe r = ""; | |
1675 | if(ienPr operty.isV alueAtInde xExists(1) ) | |
1676 | { | |
1677 | Stri ng imageCo untString = ienPrope rty.getVal ueAtIndex( 1); | |
1678 | if(( imageCount String != null) && ( imageCount String.len gth() > 0) ) | |
1679 | { | |
1680 | imageC ount = Int eger.parse Int(imageC ountString ); | |
1681 | } | |
1682 | } | |
1683 | if(ienPr operty.isV alueAtInde xExists(2) ) | |
1684 | { | |
1685 | firs tImageIen = ienPrope rty.getVal ueAtIndex( 2); | |
1686 | } | |
1687 | // JMW 1 0/6/2010 P 104 - the CPT code i s present in the 3rd piece of the STUDY_ IEN field | |
1688 | if(ienPr operty.isV alueAtInde xExists(3) ) | |
1689 | { | |
1690 | cptC ode = ienP roperty.ge tValueAtIn dex(3); | |
1691 | } | |
1692 | // JMW 1 0/29/2010 P104 - if site the i mage is ph ysically s tored at i s in the 4 th piece o f the STUD Y_IEN fiel d | |
1693 | if(ienPr operty.isV alueAtInde xExists(4) ) | |
1694 | { | |
1695 | cons olidatedSi teNumber = ienProper ty.getValu eAtIndex(4 ); | |
1696 | } | |
1697 | else{ | |
1698 | cons olidatedSi teNumber = site.getS iteNumber( ); | |
1699 | } | |
1700 | ||
1701 | ||
1702 | String s tudyUid = null; | |
1703 | VistaIma gingParser .ParsedVis taLine uid Property = studyLine .getProper ty(STUDY_U ID_KEY); | |
1704 | if(uidPr operty != null) | |
1705 | stud yUid = uid Property.g etValueAtI ndex(0); | |
1706 | ||
1707 | String p atientIcn = null; | |
1708 | String p atientName = null; | |
1709 | String p atientDfn = null; | |
1710 | VistaIma gingParser .ParsedVis taLine pat ientProper ty = study Line.getPr operty(STU DY_PAT_KEY ); | |
1711 | if(patie ntProperty != null) | |
1712 | { | |
1713 | pati entIcn = p atientProp erty.getVa lueAtIndex (1); | |
1714 | pati entName = patientPro perty.getV alueAtInde x(2); | |
1715 | } | |
1716 | ||
1717 | PatientI dentifier patientIde ntifier = null; | |
1718 | if(patie ntIcn != n ull && pat ientIcn.le ngth() > 0 && !patie ntIcn.star tsWith("-1 ")) | |
1719 | pati entIdentif ier = Pati entIdentif ier.icnPat ientIdenti fier(patie ntIcn); | |
1720 | else | |
1721 | pati entIdentif ier = Pati entIdentif ier.dfnPat ientIdenti fier(patie ntDfn); | |
1722 | ||
1723 | Study st udy = Stud y.create(O bjectOrigi n.VA, site .getSiteNu mber(), ie n, | |
1724 | patien tIdentifie r, studyLo adLevel, s tudyDelete dImageStat e, isStudy InNewDataS tructure, false); | |
1725 | study.se tSiteName( site.getSi teName()); | |
1726 | study.se tSiteAbbr( site.getSi teAbbr()); | |
1727 | ||
1728 | study.se tStudyUid( studyUid); | |
1729 | ||
1730 | st udy.setPat ientName(p atientName ); | |
1731 | st udy.setCpt Code(cptCo de); | |
1732 | st udy.setCon solidatedS iteNumber( consolidat edSiteNumb er); | |
1733 | ||
1734 | if(!stud yLoadLevel .isInclude Images()) | |
1735 | { | |
1736 | logg er.info("S tudy is no t loaded w ith images , setting image coun t to '" + imageCount + | |
1737 | "' and first ima ge IEN to '" + first ImageIen + "'."); | |
1738 | stud y.setImage Count(imag eCount); | |
1739 | stud y.setFirst ImageIen(f irstImageI en); | |
1740 | } | |
1741 | ||
1742 | VistaIma gingParser .ParsedVis taLine mod alityPrope rty = stud yLine.getP roperty(ST UDY_MODALI TY); | |
1743 | if(modal ityPropert y != null) | |
1744 | { | |
1745 | Stri ng[] modal ities = mo dalityProp erty.getVa lueAtIndex (0).split( ",", -1); | |
1746 | for( String mod ality : mo dalities) | |
1747 | study. addModalit y(modality ); | |
1748 | } | |
1749 | ||
1750 | VistaIma gingParser .ParsedVis taLine stu dyInfoProp erty = stu dyLine.get Property(S TUDY_INFO_ KEY); | |
1751 | if(study InfoProper ty != null ) { | |
1752 | String [] studyIn fo = Strin gUtils.Spl it(studyIn foProperty .getValueA tIndex(0), StringUti ls.CARET); | |
1753 | stud y.setNoteT itle(study Info[2]); | |
1754 | stud y.setProce dureDateSt ring(study Info[3]); | |
1755 | if(( study.getP rocedureDa teString() != null) && (study. getProcedu reDateStri ng().lengt h() > 0)) | |
1756 | { | |
1757 | study. setProcedu reDate(Vis taTranslat orUtility. convertVis taDatetoDa te(study.g etProcedur eDateStrin g())); | |
1758 | } | |
1759 | stud y.setProce dure(study Info[4]); | |
1760 | stud y.setDescr iption(stu dyInfo[6]) ; | |
1761 | stud y.setImage Package(st udyInfo[7] ); | |
1762 | stud y.setStudy Class(stud yInfo[8]); | |
1763 | stud y.setImage Type(study Info[9]); | |
1764 | stud y.setSpeci alty(study Info[10]); | |
1765 | stud y.setEvent (studyInfo [11]); | |
1766 | stud y.setOrigi n(studyInf o[12]); | |
1767 | stud y.setCaptu reDate(stu dyInfo[13] ); | |
1768 | stud y.setCaptu reBy(study Info[14]); | |
1769 | //if (studyInfo .length >= 20){ | |
1770 | // study. setAccessi onNumber(s tudyInfo[1 9]); | |
1771 | //} | |
1772 | stud y.setAlter nateExamNu mber(study InfoProper ty.getValu eAtIndex(1 )); | |
1773 | Stri ng studyCp rsIdentifi er = null; | |
1774 | if(s tudyInfoPr operty.isV alueAtInde xExists(2) ){ | |
1775 | studyC prsIdentif ier = stud yInfoPrope rty.getVal ueAtIndex( 2); | |
1776 | } | |
1777 | logg er.debug(" study CPRS Identifie r: " + stu dyCprsIden tifier); | |
1778 | if(( studyFilte r.isInclud eEncounter Orders() & & studyCpr sIdentifie r != null) || | |
1779 | (studyFi lter.isInc ludePatien tOrders() && (studyC prsIdentif ier == nul l || | |
1780 | studyCpr sIdentifie r.length() == 0))){ | |
1781 | logger .debug("Co llecting s tudy [" + study.getS tudyIen() +"]"); | |
1782 | } | |
1783 | else { | |
1784 | logger .debug("No t collecti ng study [ " + study. getStudyIe n() + "]") ; | |
1785 | return null; | |
1786 | } | |
1787 | ||
1788 | if(s tudyCprsId entifier ! = null){ | |
1789 | study. setContext Id(studyCp rsIdentifi er); | |
1790 | } | |
1791 | else { | |
1792 | StudyU RN artifac tIdentifie r = (Study URN)study. getGlobalA rtifactIde ntifier(); | |
1793 | study. setContext Id(artifac tIdentifie r.toString ()); | |
1794 | } | |
1795 | } | |
1796 | ||
1797 | String a ltFirstIma geIen = "" ; | |
1798 | for( Ite rator<Vist aImagingPa rser.Parse dVistaLine > seriesIt er = study Line.child Iterator() ; seriesIt er.hasNext (); ) | |
1799 | { | |
1800 | Vist aImagingPa rser.Parse dVistaLine seriesLin e = series Iter.next( ); | |
1801 | try{ | |
1802 | Series series = createSeri es(site, s tudy, seri esLine, al tFirstImag eIen, isSt udyInNewDa taStructur e); | |
1803 | if(stu dyLoadLeve l.IsInclud eSeries()) | |
1804 | study.ad dSeries(se ries); | |
1805 | } | |
1806 | catch (URNFormat Exception urnfX){ | |
1807 | logger.e rror("URNF ormatExcep tion creat ing a seri e for stud y IEN " + study.getS tudyIen() + ". Seri es Line: [ " + series Line + "]. " + urnf X.getMessa ge(), urnf X); | |
1808 | } | |
1809 | catch (SeriesPar singExcept ion spX) { | |
1810 | logger .error("Se riesParsin gException creating a serie fo r study IE N " + stud y.getStudy Ien() + ". Series L ine: [" + seriesLine + "]. " + spX.getM essage(), spX); | |
1811 | } | |
1812 | catch (Exception X){ | |
1813 | logger.e rror("Exce ption crea ting a ser ie for stu dy IEN " + study.get StudyIen() + ". Ser ies Line: [" + serie sLine + "] . " + X.g etMessage( ), X); | |
1814 | } | |
1815 | } | |
1816 | ||
1817 | if(first ImageIen = = null || firstImage Ien.length () == 0){ | |
1818 | firs tImageIen = altFirst ImageIen; | |
1819 | } | |
1820 | if(!stud yLoadLevel .isInclude Images()) | |
1821 | { | |
1822 | // this is a special case, if the load l evel was n ot full | |
1823 | // i f the stud y is a sin gle image study, the n older st udies may not have a n image no de, | |
1824 | // i t might ju st be the parent nod e and it r epresents the image node. in t his case | |
1825 | // t he imageCo unt and fi rstImageIe n will not have been provided in the RPC call, | |
1826 | // t he firstIm ageIen is the same a s the grou p ien and the imageC ount is 1 | |
1827 | if(i mageCount == 0) | |
1828 | { | |
1829 | logger .debug("St udyLoadLev el was not full and image coun t was 0, s etting ima ge count t o 1 indica ting singl e image gr oup with n o child no de"); | |
1830 | imageC ount = 1; | |
1831 | } | |
1832 | if(f irstImageI en.length( ) == 0) | |
1833 | { | |
1834 | logger .debug("St udyLoadLev el was not full and first Imag e Ien is m issing, se tting valu e to '" + ien + "', indicating single im age group with no ch ild node") ; | |
1835 | firstI mageIen = ien; | |
1836 | } | |
1837 | } | |
1838 | ||
1839 | return s tudy; | |
1840 | } | |
1841 | ||
1842 | ||
1843 | ||
1844 | /* * | |
1845 | * Con verts rpc data from VistA into Image obj ect | |
1846 | * | |
1847 | * @pa ram imageS tring | |
1848 | * @re turn Image object re presenting VistA str ing data o r null if the String cannot be used to | |
1849 | * build a valid Im age instan ce | |
1850 | * @throws U RNFormatEx ception | |
1851 | * @throws V istaParsin gException | |
1852 | */ | |
1853 | privat e static I mage vista ImageStrin gToImage(S tring imag eString, S tring orig inatingSit eId, | |
1854 | Stri ng studyId , PatientI dentifier patientIde ntifier) | |
1855 | throws URNFormat Exception, VistaPars ingExcepti on | |
1856 | { | |
1857 | if (imageStri ng == null || imageS tring.leng th() == 0) | |
1858 | retu rn null; | |
1859 | ||
1860 | Vi staImage v istaImage = VistaIma ge.create( imageStrin g); | |
1861 | re turn trans form(origi natingSite Id, studyI d, patient Identifier , vistaIma ge); | |
1862 | } | |
1863 | ||
1864 | /** | |
1865 | * @pa ram imageL ist | |
1866 | * @re turn List of image o bjects bas ed on imag eList info rmation | |
1867 | * @th rows URNFo rmatExcept ion | |
1868 | * @th rows Vista ParsingExc eption | |
1869 | */ | |
1870 | public static Li st<Image> VistaImage StringList ToImageLis t(String i mageList, String ori ginatingSi teId, | |
1871 | Stri ng studyId , PatientI dentifier patientIde ntifier) | |
1872 | throws URNFormat Exception | |
1873 | { | |
1874 | Li st<Image> images = n ew LinkedL ist<Image> (); | |
1875 | if ((imageLis t == null) || (image List.equal s(""))) { | |
1876 | retu rn images; | |
1877 | } | |
1878 | St ring []lin es = Strin gUtils.Spl it(imageLi st, String Utils.NEW_ LINE); | |
1879 | fo r(int i = 1; i < lin es.length; i++) | |
1880 | { | |
1881 | try | |
1882 | { | |
1883 | Image image = vi staImageSt ringToImag e(lines[i] , originat ingSiteId, studyId, patientIde ntifier); | |
1884 | images .add(image ); | |
1885 | } | |
1886 | catc h(VistaPar singExcept ion vpX) | |
1887 | { | |
1888 | // if there is a parsing e xception, just throw away this image, no t the enti re list | |
1889 | logger .error("Vi stParsingE xception p arsing ima ge line '" + lines[i ] + "'.", vpX); | |
1890 | } | |
1891 | } | |
1892 | re turn image s; | |
1893 | } | |
1894 | ||
1895 | /** | |
1896 | * | |
1897 | * @pa ram networ kLocationS tring | |
1898 | * @pa ram site | |
1899 | * @re turn | |
1900 | */ | |
1901 | public static Li st<Network Location> VistaNetwo rkLocation sToNetwork LocationsL ist(String networkLo cationStri ng, | |
1902 | Site site, Sit eParameter Credential s sitePara meterCrede ntials) | |
1903 | { | |
1904 | Li st<Network Location> networkLoc ations = n ew ArrayLi st<Network Location>( ); | |
1905 | ||
1906 | St ring[] sha res = Stri ngUtils.Sp lit(networ kLocationS tring, Str ingUtils.N EW_LINE); | |
1907 | ||
1908 | // s kip first element (r esponse me ssage) | |
1909 | for( int i = 1; i < share s.length; i++) { | |
1910 | Networ kLocation netLoc = V istaNetwor kLocationS tringToNet workLocati on(shares[ i], site, | |
1911 | siteParame terCredent ials); | |
1912 | networ kLocations .add(netLo c); | |
1913 | } | |
1914 | retu rn network Locations; | |
1915 | } | |
1916 | ||
1917 | /** | |
1918 | * | |
1919 | * @pa ram networ kLocationS tring | |
1920 | * @pa ram site | |
1921 | * @re turn | |
1922 | */ | |
1923 | public static Ne tworkLocat ion VistaN etworkLoca tionString ToNetworkL ocation(St ring netwo rkLocation String, | |
1924 | Site site, Sit eParameter Credential s sitePara meterCrede ntials) | |
1925 | { | |
1926 | // 5^\\ delphidevm \image2$^M AG^1^^^^^E HR^1^1|100 | |
1927 | // 1) 5^ | |
1928 | // 2) \\delphide vm\image2$ ^ | |
1929 | // 3) MAG^ | |
1930 | // 4) 1^ | |
1931 | // 5) ^ | |
1932 | // 6) ^ | |
1933 | // 7) ^ | |
1934 | // 8) ^ | |
1935 | // 9) EHR^ | |
1936 | // 10 )1^ | |
1937 | // 11 )1|100 | |
1938 | ||
1939 | St ring ien = StringUti ls.Piece(n etworkLoca tionString , StringUt ils.CARET, 1); | |
1940 | St ring path = StringU tils.Piece (networkLo cationStri ng, String Utils.CARE T, 2); | |
1941 | Stri ng user = StringUtil s.Piece(ne tworkLocat ionString, StringUti ls.CARET, 5); | |
1942 | if(u ser == nul l) | |
1943 | user = ""; | |
1944 | Stri ng pass = StringUtil s.Piece(ne tworkLocat ionString, StringUti ls.CARET, 6); | |
1945 | if(p ass == nul l) | |
1946 | { | |
1947 | pass = ""; | |
1948 | } | |
1949 | else if(pass.l ength() > 0) | |
1950 | { | |
1951 | try | |
1952 | { | |
1953 | pass = E ncryptionU tils.decry pt(pass); | |
1954 | } | |
1955 | catch( Exception ex) | |
1956 | { | |
1957 | System.o ut.println ("Exceptio n decrypti ng passwor d for shar e [" + pat h + "], pa ssword is [" + pass + "]"); | |
1958 | ex.print StackTrace (); | |
1959 | } | |
1960 | } | |
1961 | if(s iteParamet erCredenti als != nul l) | |
1962 | { | |
1963 | if(pas s.equals(" ")) { | |
1964 | pass = s iteParamet erCredenti als.getPas sword(); | |
1965 | } | |
1966 | if(use r.equals(" ")) { | |
1967 | user = s iteParamet erCredenti als.getUse rname(); | |
1968 | } | |
1969 | } | |
1970 | re turn new N etworkLoca tion(path, user, pas s, site.ge tSiteNumbe r()); | |
1971 | } | |
1972 | ||
1973 | public static Si teParamete rCredentia ls VistaIm agingSiteP arametersS tringToSit eCredentia ls(String imagingSit eParameter sString) | |
1974 | { | |
1975 | Stri ng[] param eters = St ringUtils. Split(imag ingSitePar ametersStr ing, Strin gUtils.NEW _LINE); | |
1976 | Stri ng usernam e = String Utils.Piec e(paramete rs[2], Str ingUtils.C ARET, 1); | |
1977 | Stri ng pass = parameters [2]; | |
1978 | pass = pass.su bstring(us ername.len gth() + 1) ; | |
1979 | pass = pass.su bstring(0, pass.leng th() - 1); // remove trailing \n charact er | |
1980 | if(( pass != nu ll) && (pa ss.length( ) > 0)) | |
1981 | { | |
1982 | pass = Encryptio nUtils.dec rypt(pass) ; | |
1983 | } | |
1984 | retu rn new Sit eParameter Credential s(username , pass); | |
1985 | } | |
1986 | ||
1987 | public static Li st<String> convertVi staVersion sToVersion Numbers(St ring magVe rsions) | |
1988 | { | |
1989 | St ring [] ve rsions = S tringUtils .Split(mag Versions, StringUtil s.NEW_LINE ); | |
1990 | Li st<String> magVersio nList = ne w ArrayLis t<String>( versions.l ength); | |
1991 | for( int i = 0; i < versi ons.length ; i++) { | |
1992 | String [] versio nDetails = StringUti ls.Split(v ersions[i] , StringUt ils.CARET) ; | |
1993 | if(ver sionDetail s[0] != nu ll) | |
1994 | { | |
1995 | String [ ]versionPi eces = Str ingUtils.S plit(versi onDetails[ 0], String Utils.SPAC E); | |
1996 | if(versi onPieces[0 ] != null) | |
1997 | magVersion List.add(v ersionPiec es[0]); | |
1998 | } | |
1999 | } | |
2000 | retu rn magVers ionList; | |
2001 | } | |
2002 | ||
2003 | /** | |
2004 | * Con verts data received from a HIS update Vi stA query into a key -value has hmap. | |
2005 | * Inp ut data lo oks like: | |
2006 | * | |
2007 | * 21 data fiel ds returne d. | |
2008 | 0008,0018^ 1.2.840.11 3754.660.2 0080219103 530278.1 | |
2009 | 0008,0020^ 20030509 | |
2010 | 0008,0050^ 050903-170 | |
2011 | 0008,0090^ IMAGPROVID ERONETWOEI GHT,ONETWO EIGHT\1A | |
2012 | 0008,1030^ NM | |
2013 | 0008,1050^ IMAGPROVID ERONETWOEI GHT,ONETWO EIGHT | |
2014 | 0010,0010^ IMAGPATIEN T720,720 | |
2015 | 0010,0020^ 000000720 | |
2016 | 0010,0030^ 19320000 | |
2017 | 0010,0032^ 000000 | |
2018 | 0010,0040^ M | |
2019 | 0010,1000^ 1006170580 V294705 | |
2020 | 0010,1040^ 430 GRISWO LD DR^^^SA LT LAKE CI TY^UTAH^33 461 | |
2021 | 0020,000D^ 1.3.46.670 589.8.2021 400214009. 2001.1.170 .8 | |
2022 | 0020,000E^ 1.2.840.11 4234.1.21. 1.21555949 79.2003020 6.1545.2 | |
2023 | 0032,1020^ 660 | |
2024 | 0032,1032^ IMAGPROVID ERONETWOSI X,ONETWOSI X | |
2025 | 0032,1060^ RADIOGRAPH IC PROCEDU RE | |
2026 | 0032,1064 0008,0100^ 76499 | |
2027 | 0032,1064 0008,0102^ C4 | |
2028 | 0032,1064 0008,0104^ RADIOGRAPH IC PROCEDU RE | |
2029 | * | |
2030 | * @pa ram vistaH isUpdate | |
2031 | * @re turn | |
2032 | */ | |
2033 | public static Ha shMap<Stri ng, String > convertV istaHisUpd ateToHashm ap(String vistaHisUp date) | |
2034 | { | |
2035 | Ha shMap<Stri ng, String > hisUpdat e = new Ha shMap<Stri ng, String >(); | |
2036 | St ring [] fi elds = Str ingUtils.S plit(vista HisUpdate, StringUti ls.NEW_LIN E); | |
2037 | for( int i = 1; i < field s.length; i++) { | |
2038 | String fullField = fields[ i].trim(); | |
2039 | String tagkey = StringUtil s.MagPiece (fullField , StringUt ils.CARET, 1); | |
2040 | String tagval = StringUtil s.MagPiece Count(full Field, Str ingUtils.C ARET, 1, 0 ); | |
2041 | hisUpd ate.put(ta gkey, tagv al); | |
2042 | } | |
2043 | re turn hisUp date; | |
2044 | } | |
2045 | ||
2046 | /** | |
2047 | * | |
2048 | * @pa ram vistaR esponse | |
2049 | * @pa ram study | |
2050 | * @re turn | |
2051 | * @th rows Vista ParsingExc eption | |
2052 | */ | |
2053 | public static So rtedSet<Vi staImage> createImag eGroupFrom ImageLines (String vi staRespons e, Study s tudy) | |
2054 | throws VistaPars ingExcepti on | |
2055 | { | |
2056 | So rtedSet<Vi staImage> images = n ew TreeSet <VistaImag e>(); | |
2057 | St ring[] lin es = Strin gUtils.Spl it(vistaRe sponse, St ringUtils. NEW_LINE); | |
2058 | fo r(int i = 1; i < lin es.length; i++) | |
2059 | { | |
2060 | Stri ng imageLi ne = lines [i]; | |
2061 | Vist aImage ima ge = Vista Image.crea te(imageLi ne); | |
2062 | imag es.add(ima ge); | |
2063 | } | |
2064 | re turn image s; | |
2065 | } | |
2066 | ||
2067 | ||
2068 | ||
2069 | /** | |
2070 | * | |
2071 | * @pa ram studyL ist | |
2072 | * @pa ram patien tIcn | |
2073 | * @pa ram siteNu mber | |
2074 | * @re turn | |
2075 | * @th rows Vista ParsingExc eption | |
2076 | */ | |
2077 | public static Li st<Image> createImag esForFirst ImagesFrom VistaGroup List( | |
2078 | St ring study List, | |
2079 | Pa tientIdent ifier pati entIdentif ier, | |
2080 | St ring siteN umber) | |
2081 | throws VistaPars ingExcepti on | |
2082 | { | |
2083 | Li st<Image> images = n ew ArrayLi st<Image>( ); | |
2084 | ||
2085 | St ring heade rLine = "" ; | |
2086 | if (studyList .charAt(0) == '1') | |
2087 | { | |
2088 | String [] lines = StringUti ls.Split(s tudyList, StringUtil s.NEW_LINE ); | |
2089 | // the first two lines of the respon se contain the respo nse status and the m etadata, r espectivel y | |
2090 | if(lin es.length <= 0) | |
2091 | throw ne w VistaPar singExcept ion("Study list cont ains no st atus, meta -data or d ata."); | |
2092 | if(lin es.length == 1) | |
2093 | throw ne w VistaPar singExcept ion("Study list cont ains no me ta-data or data."); | |
2094 | if(lin es.length == 2) | |
2095 | { | |
2096 | logger.i nfo("Study list cont ains no da ta."); | |
2097 | return i mages; | |
2098 | } | |
2099 | ||
2100 | // par se the res ponse stat us line an d retain t he ??? | |
2101 | String rpcRespon seLine = l ines[0].tr im(); | |
2102 | String response = StringUt ils.MagPie ce(rpcResp onseLine, StringUtil s.CARET, 2 ); | |
2103 | ||
2104 | // the headerLin e is the m etadata, d escribes t he format of the stu dy results | |
2105 | // sav e it and p ass to the method th at actuall y parses t he study l ines | |
2106 | header Line = lin es[1]; | |
2107 | ||
2108 | // for each rema ining line in the re sponse, pa rse a Stud y instance and add i t | |
2109 | // to our list | |
2110 | String studyIen = null; | |
2111 | for(in t j = 2; j < lines.l ength; j++ ) | |
2112 | { | |
2113 | String i magePiece = StringUt ils.MagPie ce(lines[j ], StringU tils.STICK , 2); | |
2114 | // this next test will deal with trail ing blank lines | |
2115 | if(image Piece != n ull && ima gePiece.le ngth() > 0 ) | |
2116 | { | |
2117 | String ima geLine = " B1^" + ima gePiece; | |
2118 | VistaImage vistaImag e = VistaI mage.creat e(imageLin e); | |
2119 | studyIen = studyIen == null ? vistaImage .getIen() : studyIen ; | |
2120 | ||
2121 | Image imag e; | |
2122 | try | |
2123 | { | |
2124 | im age = tran sform(site Number, st udyIen, pa tientIdent ifier, vis taImage); | |
2125 | im ages.add(i mage); | |
2126 | } | |
2127 | catch (URN FormatExce ption x) | |
2128 | { | |
2129 | lo gger.error ("URNForma tException parsing l ine '" + i mageLine + "'.", x); | |
2130 | } | |
2131 | } | |
2132 | } | |
2133 | } | |
2134 | re turn image s; | |
2135 | } | |
2136 | ||
2137 | /** | |
2138 | * Ext ract the i mage IEN f rom a Vist A Imaging result ima ge string. | |
2139 | * The image IEN is needed to build an ImageUR N, which i s required to create | |
2140 | * an Image inst ance. Thi s method p rovides a way to get the image IEN befor e parsing the | |
2141 | * ent ire String . | |
2142 | * | |
2143 | * @pa ram imageS tring | |
2144 | * @re turn | |
2145 | */ | |
2146 | privat e static S tring extr actImageIe nFromVista ImageStrin g(String i mageString ) | |
2147 | { | |
2148 | if ( imageStr ing == nul l || image String.equ als("") ) | |
2149 | retu rn null; | |
2150 | ||
2151 | St ring[] pie ces = Stri ngUtils.Sp lit(imageS tring, Str ingUtils.C ARET); | |
2152 | St ring image Ien = piec es[1]; | |
2153 | ||
2154 | re turn image Ien; | |
2155 | } | |
2156 | ||
2157 | /** | |
2158 | * Con verts the RPC respon se into a list of pa tient obje cts | |
2159 | * @pa ram findPa tientResul ts | |
2160 | * @re turn | |
2161 | */ | |
2162 | public static Li st<VistaPa tient> con vertFindPa tientResul tsToVistaP atient(Str ing findPa tientResul ts) | |
2163 | { | |
2164 | Li st<VistaPa tient> vis taPatients = new Arr ayList<Vis taPatient> (); | |
2165 | St ring[] lin es = Strin gUtils.Spl it(findPat ientResult s, StringU tils.NEW_L INE); | |
2166 | if (lines.len gth == 1) | |
2167 | { | |
2168 | logg er.error(" Error find ing patien ts, '" + f indPatient Results + "'"); | |
2169 | } | |
2170 | el se | |
2171 | { | |
2172 | for( int i = 1; i < lines .length; i ++) | |
2173 | { | |
2174 | String [] patient Pieces = S tringUtils .Split(lin es[i], Str ingUtils.C ARET); | |
2175 | String rawPatien tInfo = pa tientPiece s[0]; | |
2176 | boolea n sensitiv e = false; | |
2177 | if(raw PatientInf o != null && rawPati entInfo.co ntains(" * SENSITIVE* ")) | |
2178 | { | |
2179 | sensitiv e = true; | |
2180 | } | |
2181 | String dfn = pat ientPieces [1]; | |
2182 | if(dfn != null) | |
2183 | dfn = df n.trim(); | |
2184 | vistaP atients.ad d(new Vist aPatient(d fn, sensit ive)); | |
2185 | } | |
2186 | } | |
2187 | re turn vista Patients; | |
2188 | } | |
2189 | ||
2190 | /** | |
2191 | * Con verts a da te string from a pat ient info query into a Date ob ject | |
2192 | * @pa ram dateSt ring | |
2193 | * @re turn | |
2194 | * @th rows Parse Exception | |
2195 | */ | |
2196 | public static Da te convert PatientDet ailsDateSt ringToDate (String da teString) | |
2197 | throws ParseExce ption | |
2198 | { | |
2199 | if (dateStri ng.length( )==10) | |
2200 | { | |
2201 | // W e have a 4 -digit yea r. | |
2202 | Simp leDateForm at sdf = n ew SimpleD ateFormat( "MM/dd/yyy y", Locale .US); | |
2203 | retu rn sdf.par se(dateStr ing); | |
2204 | } | |
2205 | el se | |
2206 | { | |
2207 | // M ust be a 2 -digit yea r | |
2208 | Simp leDateForm at sdf = n ew SimpleD ateFormat( "MM/dd/yy" , Locale.U S); | |
2209 | retu rn sdf.par se(dateStr ing); | |
2210 | } | |
2211 | } | |
2212 | ||
2213 | /** | |
2214 | * Con verts a pa tient Info response from VistA into a Pa tient obje ct | |
2215 | * @pa ram patien tInfoResul ts | |
2216 | * @re turn | |
2217 | * @th rows Parse Exception | |
2218 | */ | |
2219 | public static Pa tient conv ertPatient InfoResult sToPatient (String pa tientInfoR esults, bo olean sens itive) | |
2220 | throws ParseExce ption | |
2221 | { | |
2222 | St ring [] pi eces = Str ingUtils.S plit(patie ntInfoResu lts, Strin gUtils.CAR ET); | |
2223 | St ring dfn = pieces[1] ; | |
2224 | St ring patie ntName = p ieces[2]; | |
2225 | St ring patie ntSex = pi eces[3]; | |
2226 | St ring patie ntDob = pi eces[4]; | |
2227 | St ring ssn = formatSsn (pieces[5] ); | |
2228 | St ring veter anStatus = pieces[7] ; | |
2229 | St ring patie ntIcn = pi eces[10]; | |
2230 | ||
2231 | re turn new P atient(pat ientName,p atientIcn, veteranSt atus, | |
2232 | Patien tSex.value OfPatientS ex(patient Sex), | |
2233 | conver tPatientDe tailsDateS tringToDat e(patientD ob), | |
2234 | ssn, d fn, sensit ive); | |
2235 | } | |
2236 | ||
2237 | privat e static S tring form atSsn(Stri ng ssn) | |
2238 | { | |
2239 | ss n += ""; | |
2240 | if (ssn.leng th() >= 9) | |
2241 | { | |
2242 | Stri ng part1 = ssn.subst ring(0, 3) ; | |
2243 | Stri ng part2 = ssn.subst ring(3,5); | |
2244 | Stri ng part3 = ssn.subst ring(5); | |
2245 | ||
2246 | ssn = part1 + "-" + part 2 + "-" + part3; | |
2247 | } | |
2248 | ||
2249 | re turn ssn; | |
2250 | } | |
2251 | ||
2252 | /* * | |
2253 | * Ext racts the first phot o Id filen ame from t he RPC res ponse from VistA | |
2254 | * @pa ram vistaR esult | |
2255 | * @re turn | |
2256 | */ | |
2257 | public static St ring extra ctPatientP hotoIdFile nameFromVi staResult( String vis taResult) | |
2258 | { | |
2259 | if (vistaResu lt == null ) | |
2260 | retu rn null; | |
2261 | St ring [] li nes = Stri ngUtils.Sp lit(vistaR esult, Str ingUtils.N EW_LINE); | |
2262 | if (lines.len gth < 2) | |
2263 | retu rn null; | |
2264 | ||
2265 | St ring photo Line = lin es[1]; | |
2266 | St ring [] li nePieces = StringUti ls.Split(p hotoLine, StringUtil s.CARET); | |
2267 | re turn lineP ieces[2]; | |
2268 | } | |
2269 | ||
2270 | /** | |
2271 | * Cre ates a lis t of image s from an RPC respon se from Vi stA for a list of im ages assoc iated with a TIU not e | |
2272 | * @pa ram vistaR esult | |
2273 | * @pa ram patien tIcn | |
2274 | * @pa ram site | |
2275 | * @re turn | |
2276 | * @th rows Vista ParsingExc eption | |
2277 | */ | |
2278 | public static Li st<Image> createImag eListFromT iuNoteResp onse( | |
2279 | St ring vista Result, | |
2280 | St ring study Id, | |
2281 | Pa tientIdent ifier pati entIdentif ier, | |
2282 | Si te site) | |
2283 | throws VistaPars ingExcepti on | |
2284 | { | |
2285 | re turn extra ctImageLis tFromVista Result(vis taResult, studyId, p atientIden tifier, si te); | |
2286 | } | |
2287 | ||
2288 | /** | |
2289 | * Cre ates a lis t of image s from an RPC respon se from Vi stA for a list of im ages assoc iated with a Radiolo gy consult | |
2290 | * @pa ram vistaR esult | |
2291 | * @pa ram patien tIcn | |
2292 | * @pa ram site | |
2293 | * @re turn | |
2294 | * @th rows Vista ParsingExc eption | |
2295 | */ | |
2296 | public static Li st<Image> createImag eListFromR adExamResp onse( | |
2297 | St ring vista Result, | |
2298 | St ring study Id, | |
2299 | Pa tientIdent ifier pati entIdentif ier, | |
2300 | Si te site) | |
2301 | throws VistaPars ingExcepti on | |
2302 | { | |
2303 | re turn extra ctImageLis tFromVista Result(vis taResult, studyId, p atientIden tifier, si te); | |
2304 | } | |
2305 | ||
2306 | /** | |
2307 | * | |
2308 | * @pa ram vistaR esult | |
2309 | * @pa ram patien tIcn | |
2310 | * @pa ram site | |
2311 | * @re turn | |
2312 | * @th rows Vista ParsingExc eption | |
2313 | */ | |
2314 | pr ivate stat ic List<Im age> extra ctImageLis tFromVista Result( | |
2315 | Stri ng vistaRe sult, | |
2316 | Stri ng studyId , | |
2317 | Pati entIdentif ier patien tIdentifie r, | |
2318 | Site site) | |
2319 | th rows Vista ParsingExc eption | |
2320 | { | |
2321 | if(v istaResult == null) | |
2322 | retu rn null; | |
2323 | ||
2324 | List <Image> im ages = new ArrayList <Image>(); | |
2325 | ||
2326 | List <VistaImag e> vistaIm ages = ext ractVistaI mageListFr omVistaRes ult(vistaR esult); | |
2327 | for( VistaImage vistaImag e : vistaI mages) | |
2328 | { | |
2329 | Image image; | |
2330 | try | |
2331 | { | |
2332 | image = transform( site.getSi teNumber() , studyId, patientId entifier, vistaImage ); | |
2333 | images .add(image ); | |
2334 | } | |
2335 | catch (URNFormat Exception x) | |
2336 | { | |
2337 | logger.e rror("Exce ption pars ing VistaI mage '" + vistaImage .toString( ) + "'.", x); | |
2338 | } | |
2339 | } | |
2340 | ||
2341 | re turn image s; | |
2342 | } | |
2343 | ||
2344 | /** | |
2345 | * | |
2346 | * @pa ram vistaR esult | |
2347 | * @pa ram patien tIcn | |
2348 | * @pa ram site | |
2349 | * @re turn | |
2350 | * @th rows Vista ParsingExc eption | |
2351 | */ | |
2352 | pu blic stati c List<Vis taImage> e xtractVist aImageList FromVistaR esult(Stri ng vistaRe sult) | |
2353 | th rows Vista ParsingExc eption | |
2354 | { | |
2355 | if(v istaResult == null) | |
2356 | retu rn null; | |
2357 | Li st<VistaIm age> image s = new Ar rayList<Vi staImage>( ); | |
2358 | ||
2359 | St ring [] li nes = Stri ngUtils.Sp lit(vistaR esult, Str ingUtils.N EW_LINE); | |
2360 | fo r(int i = 1; i < lin es.length; i++) | |
2361 | { | |
2362 | Vist aImage ima ge = Vista Image.crea te(lines[i ]); | |
2363 | if(i mage != nu ll) | |
2364 | images .add( imag e ); | |
2365 | } | |
2366 | ||
2367 | re turn image s; | |
2368 | } | |
2369 | ||
2370 | ||
2371 | pu blic stati c CprsIden tifierImag es extract CprsImageL istFromVis taResult( | |
2372 | Site s ite, | |
2373 | Patien tIdentifie r patientI dentifier, | |
2374 | String vistaResu lt, | |
2375 | StudyF ilter filt er) | |
2376 | th rows Vista ParsingExc eption, Tr anslationE xception, URNFormatE xception | |
2377 | { | |
2378 | if(v istaResult == null) | |
2379 | retu rn null; | |
2380 | ||
2381 | Cp rsIdentifi erImages c prsIdentif ierImages = new Cprs Identifier Images(); | |
2382 | St ring [] cp rsIdentifi erLines = StringUtil s.Split(vi staResult, CONTEXT_NE XT); | |
2383 | logg er.debug(" extractCp rsImageLis tFromVista Result - c prsIdentif ierLines.l ength = " + cprsIden tifierLine s.length); | |
2384 | ||
2385 | fo r(int i = 1; i < cpr sIdentifie rLines.len gth; i++) | |
2386 | { | |
2387 | Stri ng cprsIde ntifierLin e = cprsId entifierLi nes[i]; | |
2388 | Stri ng [] line s = String Utils.Spli t(cprsIden tifierLine , StringUt ils.NEW_LI NE); | |
2389 | Stri ng cprsIde ntifier = StringUtil .Piece(lin es[0], Str ingUtil.ST ICK, 2); | |
2390 | logg er.debug(" cprsIdenti fier = " + cprsIdent ifier); | |
2391 | Bool ean err = StringUtil .Piece(lin es[0], Str ingUtil.ST ICK, 3).eq uals("0"); | |
2392 | ||
2393 | if ( err) { | |
2394 | String errMsg = StringUtil .Piece(lin es[0], Str ingUtil.ST ICK, 4); | |
2395 | logg er.debug(" cprsIdenti fier error = " + err Msg); | |
2396 | cprsIden tifierImag es.getErro rVistaImag es().put(c prsIdentif ier, errMs g); | |
2397 | } | |
2398 | else | |
2399 | { | |
2400 | List<S tudy> stud yList = ne w ArrayLis t<Study>() ; | |
2401 | Boolea n isTIU = StringUtil .Piece(cpr sIdentifie r, StringU til.CARET, 4).equals ("TIU"); | |
2402 | Boolea n isRA = S tringUtil. Piece(cprs Identifier , StringUt il.CARET, 4).equals( "RA"); | |
2403 | ||
2404 | logger.d ebug("Patc h 185 and beyond: " + filter.i sIncludeAl lObjects() ); | |
2405 | ||
2406 | //P185 + up | |
2407 | if (fi lter.isInc ludeAllObj ects()) | |
2408 | { | |
2409 | if (isRA | | isTIU) | |
2410 | { | |
2411 | st udyList = TranslateR adAndTIUSt udies( | |
2412 | site, patientIde ntifier, c prsIdentif ierImages, | |
2413 | cprsId entifier, lines, fil ter, isRA, isTIU); | |
2414 | } | |
2415 | else | |
2416 | { | |
2417 | String e rrMsg = "P ackage unk nown for C PRS Identi fier."; | |
2418 | logger.d ebug("CPRS Identifie r: "+cprsI dentifier+ ", error: " + errMsg ); | |
2419 | cprsIdenti fierImages .getErrorV istaImages ().put(cpr sIdentifie r, errMsg) ; | |
2420 | } | |
2421 | } | |
2422 | //pre 185 | |
2423 | else | |
2424 | { | |
2425 | if (isTI U) | |
2426 | { | |
2427 | studyList = Translat eTiuStudie s( | |
2428 | site , patientI dentifier, cprsIdent ifierImage s, | |
2429 | cprs Identifier , lines); | |
2430 | } | |
2431 | else if( isRA) | |
2432 | { | |
2433 | st udyList = TranslateR adAndTIUSt udies( | |
2434 | site, patientIde ntifier, c prsIdentif ierImages, | |
2435 | cprsId entifier, lines, fil ter, isRA, isTIU); | |
2436 | } | |
2437 | else | |
2438 | { | |
2439 | String e rrMsg = "P ackage unk nown for C PRS Identi fier."; | |
2440 | logger .debug("CP RS Identif ier: "+cpr sIdentifie r+", error : " + errM sg); | |
2441 | cprsIdenti fierImages .getErrorV istaImages ().put(cpr sIdentifie r, errMsg) ; | |
2442 | } | |
2443 | } | |
2444 | ||
2445 | cprsIden tifierImag es.getVist aStudies() .put(cprsI dentifier, studyList ); | |
2446 | } | |
2447 | } | |
2448 | Ad dStudiesWi thErrors(s ite, patie ntIdentifi er, cprsId entifierIm ages); | |
2449 | ||
2450 | re turn cprsI dentifierI mages; | |
2451 | } | |
2452 | ||
2453 | ||
2454 | ||
2455 | pu blic stati c List<Stu dy> Transl ateRadStud ies( | |
2456 | Site s ite, | |
2457 | Patien tIdentifie r patientI dentifier, | |
2458 | CprsId entifierIm ages cprsI dentifierI mages, | |
2459 | String cprsIdent ifier, | |
2460 | String [] lines){ | |
2461 | Stud yDeletedIm ageState s tudyDelete dImageStat e = Study DeletedIma geState.ca nnotInclud eDeletedIm ages; | |
2462 | ||
2463 | Stri ng lineCou nt = Strin gUtil.Piec e(lines[0] , "|", 4); | |
2464 | Stri ng studyLi nes = line Count + St ringUtils. NEW_LINE; | |
2465 | stud yLines += AddStudyLi nes(lines) ; | |
2466 | logg er.debug(" studyLines = " + stu dyLines); | |
2467 | ||
2468 | Sort edSet<Stud y> studies = VistaIm agingTrans lator.crea teStudiesF romGraph( | |
2469 | site, st udyLines, StudyLoadL evel.STUDY _ONLY_NOSE RIES, stud yDeletedIm ageState); | |
2470 | ||
2471 | List <Study> st udyList = cprsIdenti fierImages .getVistaS tudies().g et(cprsIde ntifier); | |
2472 | if ( studyList == null) { | |
2473 | studyL ist = new ArrayList< Study>(); | |
2474 | } | |
2475 | ||
2476 | for( Study stud y: studies ) | |
2477 | { | |
2478 | study. setContext Id(cprsIde ntifier); | |
2479 | studyL ist.add(st udy); | |
2480 | if (In teger.pars eInt(study .getStudyI en()) >= c prsIdentif ierImages. getLastStu dyIen()) { | |
2481 | cprsIden tifierImag es.setLast StudyIen(I nteger.par seInt(stud y.getStudy Ien())); | |
2482 | } | |
2483 | } | |
2484 | ||
2485 | retu rn studyLi st; | |
2486 | } | |
2487 | ||
2488 | ||
2489 | /** | |
2490 | * | |
2491 | * @pa ram vistaR esult | |
2492 | * @pa ram patien tIcn | |
2493 | * @pa ram site | |
2494 | * @re turn | |
2495 | * @th rows Vista ParsingExc eption | |
2496 | */ | |
2497 | pu blic stati c CprsIden tifierImag es extract CprsImageL istFromVis taResult(S tring vist aResult) | |
2498 | th rows Vista ParsingExc eption | |
2499 | { | |
2500 | if (vistaResu lt == null ) | |
2501 | retu rn null; | |
2502 | ||
2503 | Cp rsIdentifi erImages c prsIdentif ierImages = new Cprs Identifier Images(); | |
2504 | ||
2505 | St ring [] li nes = Stri ngUtils.Sp lit(vistaR esult, Str ingUtils.N EW_LINE); | |
2506 | lo gger.debug ("vistaRes ult (" + 0 + ") = " + lines[0] ); | |
2507 | if (StringUt il.Piece(l ines[0], " ^", 1).equ als("0")) { | |
2508 | logg er.info("R PC [MAGN C PRS IMAGE LIST] erro r: " + Str ingUtil.Pi ece(lines[ 0], "^", 1 )); | |
2509 | retu rn null; | |
2510 | } | |
2511 | ||
2512 | fo r(int i = 1; i < lin es.length; i++) | |
2513 | { | |
2514 | logger .debug("vi staResult (" + i + " ) = " + li nes[i]); | |
2515 | ||
2516 | Stri ng cprsIde ntifier = StringUtil .Piece(lin es[i], "|" , 1); | |
2517 | bool ean isErro rRecord = StringUtil .Piece(lin es[i], "|" , 2).equal s("0"); | |
2518 | Stri ng imageIn fo = Strin gUtil.Piec e(lines[i] , "|", 3); | |
2519 | Stri ng groupIe n = String Util.Piece (imageInfo , "^", 25) ; | |
2520 | ||
2521 | if ( isErrorRec ord) { | |
2522 | cprsId entifierIm ages.getEr rorVistaIm ages().put (cprsIdent ifier, ima geInfo); | |
2523 | } | |
2524 | else | |
2525 | { | |
2526 | List<V istaImage> images = cprsIdenti fierImages .getVistaI mages().ge t(cprsIden tifier); | |
2527 | if (im ages == nu ll) { | |
2528 | images = new Arr ayList<Vis taImage>() ; | |
2529 | cprsId entifierIm ages.getVi staImages( ).put(cprs Identifier , images); | |
2530 | } | |
2531 | VistaI mage image = VistaIm age.create (imageInfo ); | |
2532 | if(ima ge != null ) { | |
2533 | images.a dd( image ); | |
2534 | } | |
2535 | ||
2536 | String group = c prsIdentif ierImages. getVistaIm ageGroups( ).get(cprs Identifier ); | |
2537 | if (gr oup == nul l) { | |
2538 | cprsIden tifierImag es.getVist aImageGrou ps().put(c prsIdentif ier, group Ien); | |
2539 | } | |
2540 | ||
2541 | } | |
2542 | } | |
2543 | ||
2544 | re turn cprsI dentifierI mages; | |
2545 | } | |
2546 | ||
2547 | pu blic stati c void Add StudiesWit hErrors( | |
2548 | Site s ite, | |
2549 | Patien tIdentifie r patientI dentifier, | |
2550 | CprsId entifierIm ages cprsI dentifierI mages) | |
2551 | th rows Vista ParsingExc eption, Tr anslationE xception{ | |
2552 | Stud yDeletedIm ageState s tudyDelete dImageStat e = Study DeletedIma geState.ca nnotInclud eDeletedIm ages; | |
2553 | ||
2554 | Set set = cprs Identifier Images.get ErrorVista Images().e ntrySet(); | |
2555 | Iterator iterator = set.iter ator(); | |
2556 | in t maxStudy Ien = cprs Identifier Images.get LastStudyI en(); | |
2557 | ||
2558 | while(it erator.has Next()) { | |
2559 | try | |
2560 | { | |
2561 | maxStudy Ien++; | |
2562 | Study st udy = Stud y.create(O bjectOrigi n.UNKNOWN, site.getS iteNumber( ), | |
2563 | ma xStudyIen + "", pati entIdentif ier, Study LoadLevel. STUDY_AND_ IMAGES, | |
2564 | st udyDeleted ImageState ); | |
2565 | Map.Entr y mentry = (Map.Entr y)iterator .next(); | |
2566 | String c prsIdentif ier = ment ry.getKey( ).toString (); | |
2567 | String e rrmsg = me ntry.getVa lue().toSt ring(); | |
2568 | study.se tErrorMess age(errmsg ); //add e rror messa ge | |
2569 | study.se tContextId (cprsIdent ifier); | |
2570 | List<Stu dy> studyL ist = cprs Identifier Images.get VistaStudi es().get(c prsIdentif ier); | |
2571 | if (st udyList == null) { | |
2572 | studyList = new Arra yList<Stud y>(); | |
2573 | } | |
2574 | studyLis t.add(stud y); | |
2575 | cprsIden tifierImag es.getVist aStudies() .put(cprsI dentifier, studyList ); | |
2576 | } | |
2577 | catch (URNFormat Exception x) | |
2578 | { | |
2579 | logger.e rror("Unab le to crea te a Study from the given key elements") ; | |
2580 | throw ne w Translat ionExcepti on("Unable to create a Study f rom the gi ven key el ements"); | |
2581 | } | |
2582 | } | |
2583 | } | |
2584 | ||
2585 | pu blic stati c String A ddStudyLin es(String[ ] lines) | |
2586 | { | |
2587 | List <String> l st = new A rrayList<S tring>(); | |
2588 | ||
2589 | //Re move empty lines | |
2590 | for( int i = 1; i < lines .length; i ++) | |
2591 | { | |
2592 | String line = li nes[i]; | |
2593 | line = StringUti l.Piece(li ne, String Util.CRCHA R, 1); | |
2594 | line = StringUti l.Piece(li ne, String Util.NEW_L INECHAR, 1 ); | |
2595 | if (!l ine.trim() .isEmpty() ) | |
2596 | lst.add( line); | |
2597 | } | |
2598 | ||
2599 | Stri ng result = ""; | |
2600 | for (int i = 0 ; i < lst. size(); i+ +) | |
2601 | { | |
2602 | result += lst.ge t(i); | |
2603 | if (i < lst.size ()-1) | |
2604 | result + = StringUt ils.NEW_LI NE; | |
2605 | } | |
2606 | ||
2607 | retu rn result; | |
2608 | } | |
2609 | ||
2610 | pu blic stati c List<Stu dy> Transl ateTiuStud ies( | |
2611 | Site s ite, | |
2612 | Patien tIdentifie r patientI dentifier, | |
2613 | CprsId entifierIm ages cprsI dentifierI mages, | |
2614 | String cprsIdent ifier, | |
2615 | String [] lines) | |
2616 | th rows Vista ParsingExc eption, UR NFormatExc eption{ | |
2617 | Stri ng headerL ine = "Ite m~S2^Site^ Note Title ~~W0^Proc DT~S1^Proc edure^# Im g~S2^Short Desc^Pkg^ Class^Type ^Specialty ^Event^Ori gin^Cap Dt ~S1~W0^Cap by~~W0^Im age ID~S2~ W0"; | |
2618 | ||
2619 | Stri ng studyLi nes = "1" + StringUt ils.NEW_LI NE + heade rLine + St ringUtils. NEW_LINE; | |
2620 | stud yLines += AddStudyLi nes(lines) ; | |
2621 | logg er.debug(" TIU studyL ines = " + studyLine s); | |
2622 | ||
2623 | Sort edSet<Vist aGroup> gr oups = Vis taImagingT ranslator. createGrou psFromGrou pLinesHand leSingleIm ageGroup( | |
2624 | site, st udyLines, patientIde ntifier, S tudyLoadLe vel.FULL, | |
2625 | StudyDel etedImageS tate.canno tIncludeDe letedImage s); | |
2626 | Sort edSet<Stud y> studies = VistaIm agingTrans lator.tran sform(Obje ctOrigin.V A, site, g roups); | |
2627 | ||
2628 | List <Study> st udyList = cprsIdenti fierImages .getVistaS tudies().g et(cprsIde ntifier); | |
2629 | if ( studyList == null) { | |
2630 | studyL ist = new ArrayList< Study>(); | |
2631 | } | |
2632 | ||
2633 | for( Study stud y: studies ) | |
2634 | { | |
2635 | study. setContext Id(cprsIde ntifier); | |
2636 | studyL ist.add(st udy); | |
2637 | ||
2638 | Sorted Set<Image> images = new TreeSe t<Image>() ; | |
2639 | ||
2640 | Image img = stud y.getFirst Image(); | |
2641 | if (im g != null) | |
2642 | { | |
2643 | images.a dd(img); | |
2644 | VistaIma gingCommon Utilities. addImagesT oStudyAsSe ries(study , images); | |
2645 | } | |
2646 | ||
2647 | if (In teger.pars eInt(study .getStudyI en()) >= c prsIdentif ierImages. getLastStu dyIen()) { | |
2648 | cprsIden tifierImag es.setLast StudyIen(I nteger.par seInt(stud y.getStudy Ien())); | |
2649 | } | |
2650 | } | |
2651 | ||
2652 | retu rn studyLi st; | |
2653 | ||
2654 | } | |
2655 | ||
2656 | pu blic stati c List<Stu dy> Transl ateRadAndT IUStudies( | |
2657 | Site s ite, | |
2658 | Patien tIdentifie r patientI dentifier, | |
2659 | CprsId entifierIm ages cprsI dentifierI mages, | |
2660 | String cprsIdent ifier, | |
2661 | String [] lines, | |
2662 | StudyF ilter filt er, | |
2663 | boolea n isRA, | |
2664 | boolea n isTIU){ | |
2665 | Stud yDeletedIm ageState s tudyDelete dImageStat e = Study DeletedIma geState.ca nnotInclud eDeletedIm ages; | |
2666 | ||
2667 | logg er.debug(" RAD/TIU st udy: " + l ines); | |
2668 | Stri ng lineCou nt = Strin gUtil.Piec e(lines[0] , "|", 4); | |
2669 | Stri ng studyLi nes = line Count + St ringUtils. NEW_LINE; | |
2670 | stud yLines += AddStudyLi nes(lines) ; | |
2671 | logg er.debug(" RAD/TIU st udy to tra nslate: " + studyLin es); | |
2672 | ||
2673 | Stud yLoadLevel metaDataL evel; | |
2674 | if(f ilter != n ull){ | |
2675 | if(fil ter.isIncl udeImages( )){ | |
2676 | metaData Level = St udyLoadLev el.STUDY_A ND_IMAGES; | |
2677 | } | |
2678 | else{ | |
2679 | metaData Level = St udyLoadLev el.STUDY_O NLY_NOSERI ES; | |
2680 | } | |
2681 | } | |
2682 | else { | |
2683 | metaDa taLevel = StudyLoadL evel.STUDY _ONLY_NOSE RIES; | |
2684 | } | |
2685 | ||
2686 | logg er.debug(" RAD/TIU st udyloadlev el: " + me taDataLeve l.getDescr iption()); | |
2687 | ||
2688 | Sort edSet<Stud y> studies = VistaIm agingTrans lator.crea teStudiesF romGraph( | |
2689 | site, st udyLines, metaDataLe vel, study DeletedIma geState); | |
2690 | ||
2691 | List <Study> st udyList = cprsIdenti fierImages .getVistaS tudies().g et(cprsIde ntifier); | |
2692 | if ( studyList == null) { | |
2693 | studyL ist = new ArrayList< Study>(); | |
2694 | } | |
2695 | ||
2696 | for( Study stud y: studies ) | |
2697 | { | |
2698 | study. setContext Id(cprsIde ntifier); | |
2699 | studyL ist.add(st udy); | |
2700 | if (In teger.pars eInt(study .getStudyI en()) >= c prsIdentif ierImages. getLastStu dyIen()) { | |
2701 | cprsIden tifierImag es.setLast StudyIen(I nteger.par seInt(stud y.getStudy Ien())); | |
2702 | } | |
2703 | } | |
2704 | ||
2705 | retu rn studyLi st; | |
2706 | } | |
2707 | ||
2708 | ||
2709 | /* * | |
2710 | * Ext ract the g roup paren t IEN from an RPC re sponse for the 0 nod e of an im age | |
2711 | * @pa ram vistaR esult | |
2712 | * @re turn The I EN of the parent gro up image o r null if this image represent s a group image | |
2713 | */ | |
2714 | public static St ring extra ctGroupIen FromNode0R esponse(St ring vista Result) | |
2715 | { | |
2716 | St ring [] pi eces = Str ingUtils.S plit(vista Result, St ringUtils. CARET); | |
2717 | // if there is no 10th piece the n this is a group im age and do es not hav e a parent | |
2718 | if (pieces.le ngth < 10) | |
2719 | retu rn null; | |
2720 | re turn piece s[9]; // 1 0th piece of result is group I EN if pass ed image d ata | |
2721 | // return Str ingUtils.M agPiece(vi staResult, StringUti ls.CARET, 10); | |
2722 | } | |
2723 | ||
2724 | public static Li st<String> translate UserKeys(S tring vist aResult) | |
2725 | { | |
2726 | Li st<String> result = new ArrayL ist<String >(); | |
2727 | St ring[] key s = String Utils.Spli t(vistaRes ult, Strin gUtils.NEW _LINE); | |
2728 | ||
2729 | // t rim whites pace, incl uding CR a nd/or LF c haracters | |
2730 | if(k eys != nul l) | |
2731 | { | |
2732 | for(in t index=0; index<key s.length; ++index) | |
2733 | { | |
2734 | result.a dd(keys[in dex].trim( )); | |
2735 | } | |
2736 | } | |
2737 | ||
2738 | retu rn result; | |
2739 | } | |
2740 | ||
2741 | pu blic stati c List<Div ision> tra nslateDivi sions(Stri ng vistaRe sult) | |
2742 | { | |
2743 | Li st<Divisio n> result = new Arra yList<Divi sion>(); | |
2744 | St ring[] div isions = S tringUtils .Split(vis taResult, StringUtil s.NEW_LINE ); | |
2745 | ||
2746 | // t rim whites pace, incl uding CR a nd/or LF c haracters | |
2747 | if(d ivisions ! = null) | |
2748 | { | |
2749 | for(in t i=1; i<d ivisions.l ength; i++ ) | |
2750 | { | |
2751 | String[] fields = StringUtil s.Split(di visions[i] , StringUt ils.CARET) ; | |
2752 | result.a dd(new Div ision(fiel ds[0].trim (), fields [1].trim() , fields[2 ].trim())) ; | |
2753 | } | |
2754 | } | |
2755 | ||
2756 | retu rn result; | |
2757 | } | |
2758 | ||
2759 | pu blic stati c User tra nslateUser (String vi staResult) | |
2760 | { | |
2761 | Stri ng [] line s = String Utils.Spli t(vistaRes ult, Strin gUtils.NEW _LINE); | |
2762 | Stri ng duz = l ines[0].tr im(); | |
2763 | Stri ng name = lines[1].t rim(); | |
2764 | Stri ng title = lines[4]. trim(); | |
2765 | Stri ng service = lines[5 ].trim(); | |
2766 | retu rn new Vis taUser(duz , name, ti tle, servi ce); | |
2767 | ||
2768 | } | |
2769 | ||
2770 | pu blic stati c List<Str ing> conve rtTreating SiteListTo SiteNumber s(String v istaResult , | |
2771 | boolea n includeT railingCha ractersFor Site200) | |
2772 | { | |
2773 | List <String> r esult = ne w ArrayLis t<String>( ); | |
2774 | Stri ngBuilder initialSit eList = ne w StringBu ilder(); | |
2775 | Stri ngBuilder convertedS iteList = new String Builder(); | |
2776 | Stri ng prefix = ""; | |
2777 | if(v istaResult != null) | |
2778 | { | |
2779 | String [] lines = StringUt ils.Split( vistaResul t.trim(), StringUtil s.NEW_LINE ); | |
2780 | if(lin es.length <= 0) | |
2781 | { | |
2782 | logger.w arn("Got e mpty strin g results from VistA for treat ing sites, this shou ldn't happ en!"); | |
2783 | } | |
2784 | else i f(lines.le ngth > 0) | |
2785 | { | |
2786 | String h eaderLine = lines[0] .trim(); | |
2787 | if(heade rLine.star tsWith("0" )) | |
2788 | { | |
2789 | logger.inf o("Patient has no tr eating sit es, " + vi staResult) ; | |
2790 | } | |
2791 | else | |
2792 | { | |
2793 | logger.deb ug("Treati ng sites h eader line , " + head erLine); | |
2794 | for(int i = 1; i < l ines.lengt h; i++) | |
2795 | { | |
2796 | St ring [] pi eces = Str ingUtils.S plit(lines [i], Strin gUtils.CAR ET); | |
2797 | ||
2798 | St ring initi alSiteNumb er = piece s[0].trim( ); | |
2799 | St ring conve rtedSiteNu mber = ext ractUnnece ssarySiteN umberChara cters(init ialSiteNum ber, | |
2800 | includ eTrailingC haractersF orSite200) ; | |
2801 | in itialSiteL ist.append (prefix); | |
2802 | in itialSiteL ist.append (initialSi teNumber); | |
2803 | co nvertedSit eList.appe nd(prefix) ; | |
2804 | co nvertedSit eList.appe nd(convert edSiteNumb er); | |
2805 | re sult.add(c onvertedSi teNumber); | |
2806 | pr efix = ", "; | |
2807 | } | |
2808 | } | |
2809 | } | |
2810 | } | |
2811 | logg er.info("C onverted s ite list ' " + initia lSiteList. toString() + "' to ' " + conver tedSiteLis t.toString () + "'.") ; | |
2812 | // p ut into a hashset to exclude d uplicate e ntries | |
2813 | retu rn new Arr ayList<Str ing>(new H ashSet<Str ing>(resul t)); | |
2814 | } | |
2815 | ||
2816 | /* * | |
2817 | * This meth od looks a t the site number an d extracts unnecessa ry charact ers. If th e site | |
2818 | * number st arts with letters, t hey are ex cluded. A ny letters after num bers are e xcluded an d | |
2819 | * any numbe rs followi ng that ar e also exc luded. | |
2820 | * | |
2821 | * ex: ABC20 0T1 transl ates to 20 0 | |
2822 | * @param ra wSiteNumbe r | |
2823 | * @return | |
2824 | * / | |
2825 | pr ivate stat ic String extractUnn ecessarySi teNumberCh aracters(S tring rawS iteNumber, | |
2826 | boolea n includeT railingCha ractersFor Site200) | |
2827 | { | |
2828 | Stri ngBuilder result = n ull; | |
2829 | for( int i = 0; i < rawSi teNumber.l ength(); i ++) | |
2830 | { | |
2831 | char c h = rawSit eNumber.ch arAt(i); | |
2832 | int c = (int)ch; | |
2833 | // che ck if the character is a lette r | |
2834 | if((c < 48) || ( c > 57)) | |
2835 | { | |
2836 | if(resul t != null) | |
2837 | { | |
2838 | // we have already a dded some numbers to the resul t so we ar e looking at trailin g characte rs | |
2839 | String sNu mber = res ult.toStri ng(); | |
2840 | // if the current si te number is 200 | |
2841 | if(sNumber .startsWit h(Exchange Util.getDo dSiteNumbe r())) | |
2842 | { | |
2843 | // if we wan t to inclu de trailin g characte rs for 200 | |
2844 | if (includeTr ailingChar actersForS ite200) | |
2845 | resu lt.append( ch); // add the character | |
2846 | el se | |
2847 | retu rn result. toString() ; // retur n the valu e | |
2848 | } | |
2849 | else | |
2850 | { | |
2851 | // not site 200 so jus t return t he value | |
2852 | re turn resul t.toString (); | |
2853 | } | |
2854 | ||
2855 | } | |
2856 | } | |
2857 | else | |
2858 | { | |
2859 | if(resul t == null) | |
2860 | { | |
2861 | result = n ew StringB uilder(); | |
2862 | } | |
2863 | result.a ppend(ch); | |
2864 | } | |
2865 | } | |
2866 | if(r esult == n ull) | |
2867 | return ""; | |
2868 | retu rn result. toString() ; | |
2869 | ||
2870 | } | |
2871 | ||
2872 | /* * | |
2873 | * | |
2874 | 1^Ok | |
2875 | 13^All images we re removed from the group^D^^1 3 | |
2876 | 6^Auth orized rel ease of me dical reco rds or hea lth inform ation (ROI )^CP^^6 | |
2877 | 2^Clin ical care for other VA patient s^CP^^2 | |
2878 | 1^Clin ical care for the pa tient whos e images a re being d ownloaded^ CP^^1 | |
2879 | 7^Corr upt image^ D^^7 | |
2880 | 4^For approved t eaching pu rposes by VA staff^C P^^4 | |
2881 | 5^For use in app roved VA p ublication s^CP^^5 | |
2882 | 3^For use in app roved rese arch by VA staff^CP^ ^3 | |
2883 | 14^HIM S document correctio n^DS^^14 | |
2884 | 12^Ima ge is inco rrectly in cluded in an image g roup^S^^12 | |
2885 | 8^Low quality im age^DS^^8 | |
2886 | 9^Wron g case/exa m/accessio n number^D S^^9 | |
2887 | 10^Wro ng note ti tle^D^^10 | |
2888 | 11^Wro ng patient ^D^^11 | |
2889 | * | |
2890 | * @param si te | |
2891 | * @param rt n | |
2892 | * @return | |
2893 | * @throws M ethodExcep tion | |
2894 | * / | |
2895 | pu blic stati c List<Ima geAccessRe ason> tran slateImage AccessReas ons(Site s ite, Strin g rtn) | |
2896 | th rows Metho dException | |
2897 | { | |
2898 | if(r tn.startsW ith("0")) | |
2899 | { | |
2900 | throw new Method Exception( "Exception retrievin g the imag e access r eason list , " + rtn) ; | |
2901 | } | |
2902 | ||
2903 | Rout ingToken r outingToke n = site.c reateRouti ngToken(); | |
2904 | ||
2905 | List <ImageAcce ssReason> reasons = new ArrayL ist<ImageA ccessReaso n>(); | |
2906 | Stri ng [] line s = String Utils.Spli t(rtn, Str ingUtils.N EW_LINE); | |
2907 | for( int i = 1; i < lines .length; i ++) | |
2908 | { | |
2909 | String [] pieces = StringU tils.Split (lines[i]. trim(), St ringUtils. CARET); | |
2910 | int re asonCode = Integer.p arseInt(pi eces[0]); | |
2911 | String descripti on = piece s[1]; | |
2912 | String types = p ieces[2]; | |
2913 | String globalCod e = pieces [4]; | |
2914 | ||
2915 | reason s.add(new ImageAcces sReason(ro utingToken , reasonCo de, descri ption, | |
2916 | translateR easons(typ es), globa lCode)); | |
2917 | ||
2918 | } | |
2919 | retu rn reasons ; | |
2920 | } | |
2921 | ||
2922 | pr ivate stat ic List<Im ageAccessR easonType> translate Reasons(St ring types ) | |
2923 | { | |
2924 | List <ImageAcce ssReasonTy pe> result = new Arr ayList<Ima geAccessRe asonType>( ); | |
2925 | if(t ypes != nu ll) | |
2926 | { | |
2927 | char [ ] charArra y = types. toCharArra y(); | |
2928 | ||
2929 | for(in t i = 0; i < charArr ay.length; i++) | |
2930 | { | |
2931 | String r easonCode = String.v alueOf(cha rArray[i]) ; | |
2932 | ImageAcc essReasonT ype reason Type = | |
2933 | ImageAcces sReasonTyp e.getFromC ode(reason Code); | |
2934 | if(reaso nType == n ull) | |
2935 | { | |
2936 | logger.war n("Could n ot find an ImageAcce ssReasonTy pe for cod e '" + rea sonCode + "'."); | |
2937 | } | |
2938 | else | |
2939 | { | |
2940 | result.add (reasonTyp e); | |
2941 | } | |
2942 | } | |
2943 | } | |
2944 | ||
2945 | ||
2946 | retu rn result; | |
2947 | } | |
2948 | ||
2949 | pu blic stati c Electron icSignatur eResult tr anslateEle ctronicSig nature(Str ing rtn) | |
2950 | { | |
2951 | Stri ng [] piec es = Strin gUtils.Spl it(rtn.tri m(), Strin gUtils.CAR ET); | |
2952 | if(" 0".equals( pieces[0]) ) | |
2953 | { | |
2954 | Transa ctionConte xtFactory. get().addD ebugInform ation("ver ifyElectro nicSignatu re() faile d, " + rtn ); | |
2955 | logger .error("Er ror verify ing e-sign ature, " + rtn); | |
2956 | return new Elect ronicSigna tureResult (false, pi eces[1]); | |
2957 | } | |
2958 | else | |
2959 | { | |
2960 | return new Elect ronicSigna tureResult (true, pie ces[1]); | |
2961 | } | |
2962 | } | |
2963 | ||
2964 | pu blic stati c List<Hea lthSummary Type> tran slateHealt hSummaries (String vi staResult, Site site ) | |
2965 | th rows Metho dException | |
2966 | { | |
2967 | List <HealthSum maryType> result = n ew ArrayLi st<HealthS ummaryType >(); | |
2968 | Stri ng [] line s = String Utils.Spli t(vistaRes ult, Strin gUtils.NEW _LINE); | |
2969 | for( int i = 1; i < lines .length; i ++) | |
2970 | { | |
2971 | String [] pieces = StringU tils.Split (lines[i]. trim(), St ringUtils. CARET); | |
2972 | String name = pi eces[0]; | |
2973 | String ien = pie ces[1]; | |
2974 | try | |
2975 | { | |
2976 | HealthSu mmaryURN h ealthSumma ryUrn = He althSummar yURN.creat e(site.get SiteNumber (), ien); | |
2977 | result.a dd(new Hea lthSummary Type(healt hSummaryUr n, name)); | |
2978 | } | |
2979 | catch( URNFormatE xception u rnfX) | |
2980 | { | |
2981 | throw ne w MethodEx ception(ur nfX); | |
2982 | } | |
2983 | } | |
2984 | retu rn result; | |
2985 | } | |
2986 | ||
2987 | pu blic stati c String t ranslateHe althSummar y(String v istaResult ) | |
2988 | th rows Metho dException | |
2989 | { | |
2990 | if(! vistaResul t.startsWi th("1")) | |
2991 | { | |
2992 | throw new Method Exception( vistaResul t); | |
2993 | } | |
2994 | Stri ng [] line s = String Utils.Spli t(vistaRes ult, Strin gUtils.NEW _LINE); | |
2995 | Stri ngBuilder result = n ew StringB uilder(); | |
2996 | for( int i = 1; i < lines .length; i ++) | |
2997 | { | |
2998 | result .append(li nes[i].tri m() + Stri ngUtils.NE W_LINE); | |
2999 | } | |
3000 | retu rn result. toString() ; | |
3001 | } | |
3002 | ||
3003 | pu blic stati c Applicat ionTimeout Parameters translate Applicatio nTimeoutPa rameters(S tring vist aResult) | |
3004 | th rows Metho dException | |
3005 | { | |
3006 | // I nitialize the timeou t to 0 | |
3007 | int timeoutInS econds = 0 ; | |
3008 | ||
3009 | // t ry to pars e the retu rned value into an i nteger. If successfu l, | |
3010 | // u pdate the timeoutInS econds var iable | |
3011 | try | |
3012 | { | |
3013 | int ti meoutInMin utes = Int eger.parse Int(vistaR esult); | |
3014 | timeou tInSeconds = timeout InMinutes * 60; | |
3015 | } ca tch (Excep tion e) { | |
3016 | // Log the excep tion | |
3017 | logger .info("Una ble to par se importe r applicat ion timeou t value fr om RPC res ult: " + v istaResult , e); | |
3018 | } | |
3019 | ||
3020 | // R eturn the instance. The timeou t value wi ll either be what wa s | |
3021 | // r eturned fr om VistA, or 0 | |
3022 | retu rn new App licationTi meoutParam eters(time outInSecon ds); | |
3023 | } | |
3024 | ||
3025 | /* * | |
3026 | * Ext racts the first phot o Id filen ame from t he RPC res ponse from VistA | |
3027 | * @pa ram vistaR esult | |
3028 | * @re turn | |
3029 | */ | |
3030 | public static Vi staPatient PhotoIDInf ormation e xtractPati entPhotoId Informatio nFromVista Result(Str ing vistaR esult) | |
3031 | { | |
3032 | /* * | |
3033 | 1 ^1 | |
3034 | B2^1 2539^\\del phidevm\im age1$\ECG0 \00\00\01\ 25\ECG0000 0012539.JP G^\\delphi devm\image 1$\ECG0\00 \00\01\25\ ECG0000001 2539.ABS^P HOTO ID^31 31219.094^ 18^PHOTO I D^12/19/20 13 09:40^^ M^A^^^1^1^ EHR^^^3^ZZ PATIENT,T EST THREE^ ADMIN/CLIN ^12/19/201 3 09:41:24 ^12/19/201 3^0^0:0^^^ 0^0^0^ | |
3035 | * / | |
3036 | ||
3037 | ||
3038 | if (vistaResu lt == null ) | |
3039 | retu rn null; | |
3040 | St ring [] li nes = Stri ngUtils.Sp lit(vistaR esult, Str ingUtils.N EW_LINE); | |
3041 | if (lines.len gth < 2) | |
3042 | retu rn null; | |
3043 | ||
3044 | St ring photo Line = lin es[1]; | |
3045 | St ring [] li nePieces = StringUti ls.Split(p hotoLine, StringUtil s.CARET); | |
3046 | ||
3047 | St ring ien = linePiece s[1]; | |
3048 | St ring filen ame = line Pieces[2]; | |
3049 | St ring dateS tring = li nePieces[8 ]; | |
3050 | St ring patie ntName = l inePieces[ 20]; | |
3051 | ||
3052 | // 12/19/201 3 09:40 | |
3053 | Si mpleDateFo rmat forma t = new Si mpleDateFo rmat("MM/d d/yyyy HH: mm"); | |
3054 | Da te date = null; | |
3055 | tr y | |
3056 | { | |
3057 | date = format. parse(date String); | |
3058 | } | |
3059 | ca tch(ParseE xception p X) | |
3060 | { | |
3061 | logg er.warn("E rror parsi ng patient photo ID date, " + pX.getMess age()); | |
3062 | } | |
3063 | ||
3064 | re turn new V istaPatien tPhotoIDIn formation( patientNam e, filenam e, date, i en); | |
3065 | } | |
3066 | ||
3067 | privat e static S tring crea teUNCForIm ageInNewDa taStructur e(String n etworkLoca tion, Stri ng fileRef , String f ilePath){ | |
3068 | ||
3069 | String Buffer buf fer = new StringBuff er(); | |
3070 | buffer .append(ne tworkLocat ion); | |
3071 | buffer .append(fi lePath); | |
3072 | buffer .append(fi leRef); | |
3073 | ||
3074 | return buffer.to String(); | |
3075 | } | |
3076 | ||
3077 | privat e static A rtifactIns tance getB estProvide rImageUNC( Map<String ,ArtifactI nstance> i mageProvid erMap){ | |
3078 | ||
3079 | if (imageProv iderMap.co ntainsKey( "RAID")){ | |
3080 | retu rn imagePr oviderMap. get("RAID" ); | |
3081 | } | |
3082 | el se{ | |
3083 | retu rn imagePr oviderMap. get("JUKEB OX"); | |
3084 | } | |
3085 | } | |
3086 | ||
3087 | pu blic stati c List<Stu dy> Conver tVistaResu ltToStudyL ist( | |
3088 | Site s ite, | |
3089 | String vistaResp onse, | |
3090 | StudyF ilter filt er) | |
3091 | { | |
3092 | Stud yDeletedIm ageState s tudyDelete dImageStat e = Study DeletedIma geState.in cludesDele tedImages; | |
3093 | Stud yLoadLevel studyLoad Level = St udyLoadLev el.STUDY_O NLY_NOSERI ES; | |
3094 | ||
3095 | Stri ng details [] = Strin gUtils.Spl it(vistaRe sponse, St ringUtils. NEW_LINE); | |
3096 | ||
3097 | Sort edSet<Stud y> studies = createS tudiesFrom Graph( | |
3098 | site, | |
3099 | details, | |
3100 | studyLoa dLevel, | |
3101 | studyDel etedImageS tate); | |
3102 | ||
3103 | List <Study> st udyList = new ArrayL ist<Study> (); | |
3104 | ||
3105 | for( Study stud y: studies ) | |
3106 | { | |
3107 | studyL ist.add(st udy); | |
3108 | } | |
3109 | ||
3110 | retu rn studyLi st; | |
3111 | } | |
3112 | ||
3113 | public static So rtedSet<Vi staGroup> createGrou psFromGrou pLines( | |
3114 | Site site, | |
3115 | Stri ng groupLi st, | |
3116 | Stud yDeletedIm ageState s tudyDelete dImageStat e) | |
3117 | throws VistaPars ingExcepti on | |
3118 | { | |
3119 | So rtedSet<Vi staGroup> groups = n ew TreeSet <VistaGrou p>(); | |
3120 | St ring heade rLine = "" ; | |
3121 | if (groupList .charAt(0) == '1') | |
3122 | { | |
3123 | String [] lines = StringUti ls.Split(g roupList, StringUtil s.NEW_LINE ); | |
3124 | // the first two lines of the respon se contain the respo nse status and the m etadata, r espectivel y | |
3125 | if(lin es.length <= 0) | |
3126 | throw ne w VistaPar singExcept ion("Study list cont ains no st atus, meta -data or d ata."); | |
3127 | if(lin es.length == 1) | |
3128 | throw ne w VistaPar singExcept ion("Study list cont ains no me ta-data or data."); | |
3129 | if(lin es.length == 2) | |
3130 | { | |
3131 | logger.i nfo("Study list cont ains no da ta."); | |
3132 | return g roups; | |
3133 | } | |
3134 | logger .info("Fou nd and par sing [" + lines.leng th + "] li nes of gro up data"); | |
3135 | // par se the res ponse stat us line an d retain t he ??? | |
3136 | String rpcRespon seLine = l ines[0].tr im(); | |
3137 | String response = StringUt ils.MagPie ce(rpcResp onseLine, StringUtil s.CARET, 2 ); | |
3138 | ||
3139 | // the headerLin e is the m etadata, d escribes t he format of the stu dy results | |
3140 | // sav e it and p ass to the method th at actuall y parses t he study l ines | |
3141 | header Line = lin es[1]; | |
3142 | ||
3143 | // for each rema ining line in the re sponse, pa rse a Stud y instance and add i t | |
3144 | // to our list | |
3145 | for(in t j = 2; j < lines.l ength; j++ ) | |
3146 | { | |
3147 | VistaGro up group; | |
3148 | try | |
3149 | { | |
3150 | String dfn = StringU tils.Piece (lines[j], "^", 35); | |
3151 | logger.deb ug("Parsin g line for patient d fn: " + df n); | |
3152 | PatientIde ntifier pa tientIdent ifier = Pa tientIdent ifier.dfnP atientIden tifier(dfn ); | |
3153 | group = cr eateGroupF romGroupLi ne(site, h eaderLine, lines[j], patientId entifier, | |
3154 | stud yDeletedIm ageState); | |
3155 | if(group ! = null) | |
3156 | { | |
3157 | gr oup.setRpc ResponseMs g(response ); | |
3158 | if ( ! groups .add(group ) ) | |
3159 | logg er.warn("D uplicate g roup, IEN= '" + group .getIen() + "' is no t being ad ded to res ult set.") ; | |
3160 | } | |
3161 | } | |
3162 | catch (U RNFormatEx ception x) | |
3163 | { | |
3164 | throw new VistaParsi ngExceptio n(x); | |
3165 | } | |
3166 | } | |
3167 | } | |
3168 | ||
3169 | re turn group s; | |
3170 | } | |
3171 | ||
3172 | public static Li st<StoredS tudyFilter > translat eFilters(S tring vist aResult, R outingToke n routingT oken) | |
3173 | throws URNFormat Exception | |
3174 | { | |
3175 | /* | |
3176 | 15 | |
3177 | 16^NST ORIGIN^20 095 | |
3178 | 15^Cli nical All^ 20095 | |
3179 | 14^Adm in All^200 95 | |
3180 | * / | |
3181 | if (vistaResu lt == null ) | |
3182 | retu rn null; | |
3183 | St ring [] li nes = Stri ngUtils.Sp lit(vistaR esult, Str ingUtils.N EW_LINE); | |
3184 | Li st<StoredS tudyFilter > result = new Array List<Store dStudyFilt er>(); | |
3185 | fo r(int i = 1; i < lin es.length; i++) | |
3186 | { | |
3187 | Stri ng line = lines[i]; | |
3188 | Stri ng [] piec es = Strin gUtils.Spl it(line, S tringUtils .CARET); | |
3189 | Stri ng id = pi eces[0]; | |
3190 | Stri ng name = pieces[1]; | |
3191 | Stor edStudyFil ter stored StudyFilte r = new St oredStudyF ilter(); | |
3192 | ||
3193 | Stor edStudyFil terURN urn = StoredS tudyFilter URN.create (routingTo ken.getRep ositoryUni queId(), i d); | |
3194 | stor edStudyFil ter.setSto redStudyFi lterUrn(ur n); | |
3195 | stor edStudyFil ter.setNam e(name); | |
3196 | resu lt.add(sto redStudyFi lter); | |
3197 | } | |
3198 | re turn resul t; | |
3199 | } | |
3200 | ||
3201 | ||
3202 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.