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