Produced by Araxis Merge on 3/25/2019 8:58:07 AM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
# | Location | File | Last Modified |
---|---|---|---|
1 | C:\AraxisMergeCompare\Pri_un\IMAG_Source\VISA\Java\VistaImagingDataSourceProvider\main\src\java\gov\va\med\imaging\vistaimagingdatasource\common | VistaImagingCommonUtilities.java | Mon Mar 18 20:39:11 2019 UTC |
2 | C:\AraxisMergeCompare\Pri_re\IMAG_Source\VISA\Java\VistaImagingDataSourceProvider\main\src\java\gov\va\med\imaging\vistaimagingdatasource\common | VistaImagingCommonUtilities.java | Tue Mar 19 12:04:28 2019 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 3 | 1596 |
Changed | 2 | 4 |
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 | /** | |
2 | * | |
3 | Package: MAG - Vis tA Imaging | |
4 | WARNING: Per VHA D irective 2 004-038, t his routin e should n ot be modi fied. | |
5 | Date Cre ated: Jan 28, 2009 | |
6 | Site Nam e: Washin gton OI Fi eld Office , Silver S pring, MD | |
7 | Developer: DNS werfej | |
8 | Descript ion: | |
9 | ||
10 | ;; +-------- ---------- ---------- ---------- ---------- ---------- ---------- + | |
11 | ;; Property of the US Government . | |
12 | ;; No permis sion to co py or redi stribute t his softwa re is give n. | |
13 | ;; Use of un released v ersions of this soft ware requi res the us er | |
14 | ;; to execu te a writt en test ag reement wi th the Vis tA Imaging | |
15 | ;; Developm ent Office of the De partment o f Veterans Affairs, | |
16 | ;; telephon e (301) 73 4-0100. | |
17 | ;; | |
18 | ;; The Food and Drug A dministrat ion classi fies this software a s | |
19 | ;; a Class I I medical device. A s such, it may not b e changed | |
20 | ;; in any wa y. Modifi cations to this soft ware may r esult in a n | |
21 | ;; adulterat ed medical device un der 21CFR8 20, the us e of which | |
22 | ;; is consid ered to be a violati on of US F ederal Sta tutes. | |
23 | ;; +-------- ---------- ---------- ---------- ---------- ---------- ---------- + | |
24 | ||
25 | */ | |
26 | package go v.va.med.i maging.vis taimagingd atasource. common; | |
27 | ||
28 | import gov .va.med.im aging.Stor edStudyFil terURN; | |
29 | import gov .va.med.im aging.core .interface s.exceptio ns.Connect ionExcepti on; | |
30 | import gov .va.med.im aging.core .interface s.exceptio ns.MethodE xception; | |
31 | import gov .va.med.im aging.data source.exc eptions.In validCrede ntialsExce ption; | |
32 | import gov .va.med.im aging.exce ptions.URN FormatExce ption; | |
33 | import gov .va.med.im aging.exch ange.busin ess.Image; | |
34 | import gov .va.med.im aging.exch ange.busin ess.Series ; | |
35 | import gov .va.med.im aging.exch ange.busin ess.Stored StudyFilte r; | |
36 | import gov .va.med.im aging.exch ange.busin ess.Study; | |
37 | import gov .va.med.im aging.exch ange.busin ess.StudyF ilter; | |
38 | import gov .va.med.im aging.exch ange.enums .StudyLoad Level; | |
39 | import gov .va.med.im aging.prot ocol.vista .VistaImag ingTransla tor; | |
40 | import gov .va.med.im aging.prot ocol.vista .VistaTran slatorUtil ity; | |
41 | import gov .va.med.im aging.core .interface s.exceptio ns.Patient NotFoundEx ception; | |
42 | import gov .va.med.im aging.tran sactioncon text.Trans actionCont extFactory ; | |
43 | import gov .va.med.im aging.url. vista.Stri ngUtils; | |
44 | import gov .va.med.im aging.url. vista.Vist aQuery; | |
45 | import gov .va.med.im aging.url. vista.exce ptions.Inv alidVistaC redentials Exception; | |
46 | import gov .va.med.im aging.url. vista.exce ptions.Vis taMethodEx ception; | |
47 | import gov .va.med.im aging.vist aimagingda tasource.V istaImagin gQueryFact ory; | |
48 | import gov .va.med.im aging.vist aimagingda tasource.c onfigurati on.VistaIm agingConfi guration; | |
49 | import gov .va.med.im aging.vist aobjects.V istaGroup; | |
50 | import gov .va.med.im aging.vist aobjects.V istaImage; | |
51 | import gov .va.med.im aging.vist aobjects.V istaStored StudyFilte r; | |
52 | import gov .va.med.im aging.vist adatasourc e.session. VistaSessi on; | |
53 | ||
54 | import jav a.io.IOExc eption; | |
55 | import jav a.net.Inet Address; | |
56 | import jav a.net.Unkn ownHostExc eption; | |
57 | import jav a.util.Has hMap; | |
58 | import jav a.util.Lis t; | |
59 | import jav a.util.Map ; | |
60 | import jav a.util.Sor tedSet; | |
61 | import jav a.util.Tre eSet; | |
62 | ||
63 | import org .apache.lo gging.log4 j.LogManag er; | |
64 | import org .apache.lo gging.log4 j.Logger; | |
65 | ||
66 | /** | |
67 | * Impleme ntations o f some com mon functi ons that a re used in multiple data sourc es. Put c ommon func tions here to | |
68 | * reduce copying of code. | |
69 | * | |
70 | * @author DNS werfej | |
71 | * | |
72 | */ | |
73 | public cla ss VistaIm agingCommo nUtilities | |
74 | { | |
75 | pr ivate stat ic Logger logger = L ogManager. getLogger( VistaImagi ngCommonUt ilities.cl ass); | |
76 | ||
77 | pu blic final static St ring DEFAU LT_SERIES_ NUMBER = " 1"; | |
78 | pr ivate fina l static S tring RPC_ MAG_IMAGE_ LIST = "MA G4 IMAGE L IST"; | |
79 | ||
80 | pr ivate fina l static R eplacement Characters [] report Replacemen tCharacter s = | |
81 | ne w Replacem entCharact ers [] | |
82 | { | |
83 | // r eplace FF (Form Feed ) characte r with new line | |
84 | new VistaImagi ngCommonUt ilities.Re placementC haracters( (char)12, (char)32) | |
85 | }; | |
86 | ||
87 | pu blic final static St ring DICOM _PATIENT_I D_KEY = "0 010,0020"; | |
88 | pu blic final static St ring DICOM _PATIENT_N AME_KEY = "0010,0010 "; | |
89 | pu blic final static St ring DICOM _ALT_PATIE NT_ID_KEY = "0010,10 00"; | |
90 | ||
91 | /* * | |
92 | * Checks to see if Vi stA has th e requred version of Imaging i nstalled. Requires a n open Vis taSession and for | |
93 | * the calli ng functio n to manag e (close) the connec tion | |
94 | * @param re quiredVist aImagingVe rsion The version of Imaging t hat is nec essary | |
95 | * @param vi staSession An open V ista Sessi on | |
96 | * @return | |
97 | * / | |
98 | pu blic stati c boolean isVersionC ompatible( String req uiredVista ImagingVer sion, Vist aSession v istaSessio n) | |
99 | { | |
100 | try | |
101 | { | |
102 | VistaQ uery magVe rsionsQuer y = VistaI magingQuer yFactory.c reateGetMa gInstalled VersionsQu ery(); | |
103 | String magVersio ns = vista Session.ca ll(magVers ionsQuery) ; | |
104 | logger .info(magV ersionsQue ry.getRpcN ame()+" RP C Results: "+StringUt ils.displa yEncodedCh ars(magVer sions)); | |
105 | ||
106 | ||
107 | List<S tring> mag VersionLis t = VistaI magingTran slator.con vertVistaV ersionsToV ersionNumb ers(magVer sions); | |
108 | for(in t i = 0; i < magVers ionList.si ze(); i++) | |
109 | { | |
110 | if(requi redVistaIm agingVersi on.equalsI gnoreCase( magVersion List.get(i ))) | |
111 | { | |
112 | logger.inf o("Vista d atabase ha s required imaging v ersion [" + required VistaImagi ngVersion + "] insta lled, ok t o continue "); | |
113 | return tru e; | |
114 | } | |
115 | } | |
116 | } | |
117 | catc h(VistaMet hodExcepti on vmX) | |
118 | { | |
119 | logger .error("Th ere was an error fin ding the i nstalled I maging ver sion from VistA", vm X); | |
120 | } | |
121 | catc h(InvalidV istaCreden tialsExcep tion icX) | |
122 | { | |
123 | logger .error("Th ere was an error fin ding the i nstalled I maging ver sion from VistA", ic X); | |
124 | } | |
125 | catc h(IOExcept ion ioX) | |
126 | { | |
127 | logger .error("Th ere was an error fin ding the i nstalled I maging ver sion from VistA", io X); | |
128 | } | |
129 | logg er.info("V ista datab ase does N OT have re quired ima ging versi on [" + re quiredVist aImagingVe rsion + "] , connecti on will no t continue "); | |
130 | retu rn false; | |
131 | } | |
132 | ||
133 | /* * | |
134 | * Converts the patien t ICN to a DFN. This function requires a n open Vis ta connect ion and re quires the calling | |
135 | * function to manage (Close) th e connecti on. The si te to whic h the quer y is made is based o n the vist a session | |
136 | * @param vi staSession | |
137 | * @param pa tientICN | |
138 | * @return | |
139 | * @throws M ethodExcep tion | |
140 | * @throws I OException | |
141 | * @throws C onnectionE xception | |
142 | * @throws P atientNotF oundExcept ion | |
143 | * / | |
144 | pu blic stati c String g etPatientD FN(VistaSe ssion vist aSession, String pat ientICN) | |
145 | th rows Metho dException , IOExcept ion, Conne ctionExcep tion, Pati entNotFoun dException | |
146 | { | |
147 | logg er.info("g etPatientD FN(" + pat ientICN + ") Transac tionContex t (" + Tra nsactionCo ntextFacto ry.get().g etDisplayI dentity() + ")."); | |
148 | ||
149 | Vist aQuery vm = VistaIma gingQueryF actory.cre ateGetPati entDFNVist aQuery(pat ientICN); | |
150 | ||
151 | St ring rtn = ""; | |
152 | tr y | |
153 | { | |
154 | rtn = vistaSes sion.call( vm); | |
155 | logger .info(vm.g etRpcName( )+" RPC Re sults:"+St ringUtils. displayEnc odedChars( rtn)); | |
156 | if( rtn.starts With("-1") ) | |
157 | { | |
158 | logger .warn("ICN [" + pati entICN + " ] not foun d in datab ase, respo nse [" + r tn + "]"); | |
159 | throw new Patien tNotFoundE xception(" Patient IC N [" + pat ientICN + "] not fou nd in the database") ; | |
160 | } | |
161 | } | |
162 | ca tch (Vista MethodExce ption e) | |
163 | { | |
164 | thro w new Meth odExceptio n(e.getMes sage()); | |
165 | } | |
166 | ca tch (Inval idVistaCre dentialsEx ception e) | |
167 | { | |
168 | thro w new Inva lidCredent ialsExcept ion(e.getM essage()); | |
169 | } | |
170 | re turn rtn; | |
171 | } | |
172 | ||
173 | pr ivate stat ic String workstatio nId = null ; | |
174 | /* * | |
175 | * Get the l ocal host name if av ailable, e lse get a default na me | |
176 | * | |
177 | * @return | |
178 | * / | |
179 | pu blic stati c synchron ized Strin g getWorks tationId() | |
180 | { | |
181 | if(w orkstation Id == null ) { | |
182 | try { | |
183 | InetAddr ess addr = InetAddre ss.getLoca lHost(); | |
184 | workstat ionId = ad dr.getHost Name(); | |
185 | } | |
186 | catch( UnknownHos tException uhX) { | |
187 | logger.w arn("Unabl e to get l ocal hostn ame, using default v alue"); | |
188 | workstat ionId = "V iX-DataSou rce"; | |
189 | } | |
190 | logger .info("Loc al host na me set to [" + works tationId + "]"); | |
191 | return workstati onId; | |
192 | } | |
193 | retu rn worksta tionId; | |
194 | } | |
195 | ||
196 | /* * | |
197 | * Maybe re- think this a bit, wa nt to merg e data but not do un necessary steps, | |
198 | * remove it ems from o ne list if already u sed that i tems data | |
199 | * | |
200 | * @param vi staSession | |
201 | * @param gr oups | |
202 | * @param st udyGraph | |
203 | * @param st udyLoadLev el Needed to determi ne if the report sho uld be loa ded | |
204 | * @return | |
205 | * / | |
206 | pu blic stati c SortedSe t<Study> m ergeStudyL ists( | |
207 | Vist aSession v istaSessio n, | |
208 | Sort edSet<Stud y> studyGr aph, | |
209 | Sort edSet<Vist aGroup> gr oups, | |
210 | Stud yLoadLevel studyLoad Level) | |
211 | { | |
212 | logg er.info("M erging stu dy lists, " + groups .size() + " groups a nd " + stu dyGraph.si ze() + " s tudies."); | |
213 | Sort edSet<Stud y> mergedS tudies = n ew TreeSet <Study>(); | |
214 | ||
215 | // i terate ove r the stud y graph an d add deta ils that w ere origin ally obtai ned | |
216 | // f rom the gr oups. | |
217 | for( Study stud y : studyG raph) | |
218 | { | |
219 | VistaG roup group = getMatc hingGroup( groups, st udy.getStu dyIen(), s tudy.getFi rstImageIe n()); | |
220 | if(gro up == null ) | |
221 | logger.e rror("Unab le to find matching study deta ils for st udy '" + s tudy.getSt udyIen() + "'."); | |
222 | else | |
223 | { | |
224 | mergedSt udies.add( mergeStud yWithGroup (vistaSess ion, study , group, s tudyLoadLe vel) ); | |
225 | logger.i nfo("Merge d study li sts, match ing study IEN " + st udy.getStu dyIen() + | |
226 | ", firstIm ageIEN-" + study.get FirstImage Ien() + ". " + | |
227 | " Group " + group.ge tIen() + " " + (grou ps.remove( group) ? " was" : "wa s not") + " removed from furth er matchin g."); | |
228 | // remov e the grou p, so we c an keep tr ack of whe ther they were all m atched or not | |
229 | } | |
230 | } | |
231 | ||
232 | // i f not all groups wer e matched then log a n informat ion messag e | |
233 | if(g roups.size () > 0) | |
234 | { | |
235 | logger .info(grou ps.size() + " remain ing group( s) not dir ectly matc hed to a s tudy"); | |
236 | for(Vi staGroup g roup : gro ups) | |
237 | // CTB 2 9Nov2009 | |
238 | //logger .info("\tS tudy [" + group.getI en() + "]= [" + Base3 2Conversio nUtility.b ase32Decod e(group.ge tIen()) + "]"); | |
239 | logger.i nfo("\tStu dy [" + gr oup.getIen () + "]=[" + group.g etIen() + "]"); | |
240 | ||
241 | } | |
242 | ||
243 | retu rn mergedS tudies; | |
244 | } | |
245 | ||
246 | pu blic stati c void set StudyRadio logyReport (VistaSess ion vistaS ession, St udy study) | |
247 | { | |
248 | try | |
249 | { | |
250 | logger .info("Get ting radio logy repor t for stud y '" + stu dy.getStud yIen() + " '"); | |
251 | study. setRadiolo gyReport(g etReport(v istaSessio n, study.g etStudyIen ())); | |
252 | } | |
253 | catc h(VistaMet hodExcepti on rpcX) | |
254 | { | |
255 | logger .warn("Exc eption ret rieving ra diology re port, " + rpcX.toStr ing()); | |
256 | study. setRadiolo gyReport(" "); | |
257 | } | |
258 | catc h (Connect ionExcepti on cX) | |
259 | { | |
260 | logger .warn("Exc eption ret rieving ra diology re port, " + cX.toStrin g()); | |
261 | study. setRadiolo gyReport(" "); | |
262 | } | |
263 | catc h (MethodE xception m X) | |
264 | { | |
265 | logger .warn("Exc eption ret rieving ra diology re port, " + mX.toStrin g()); | |
266 | study. setRadiolo gyReport(" "); | |
267 | } | |
268 | } | |
269 | ||
270 | /* * | |
271 | * | |
272 | * @param ie n Base32 e ncoded IEN of the im age to get the repor t for | |
273 | * @return | |
274 | * @throws M ethodExcep tion | |
275 | * @throws C onnectionE xception | |
276 | * @throws R pcExceptio n | |
277 | * / | |
278 | pu blic stati c String g etReport(V istaSessio n vistaSes sion, Stri ng ien) | |
279 | th rows Vista MethodExce ption, Con nectionExc eption, Me thodExcept ion | |
280 | { | |
281 | logg er.info("g etReport(" + ien + " ) Transact ionContext (" + Tran sactionCon textFactor y.get().ge tDisplayId entity() + ")."); | |
282 | // C TB 29Nov20 09 | |
283 | //ie n = Base32 Conversion Utility.ba se32Decode (ien); | |
284 | ien += "^"; | |
285 | Vist aQuery vm = VistaIma gingQueryF actory.cre ateGetRepo rtVistaQue ry(ien); | |
286 | Stri ng rtn = n ull; | |
287 | try | |
288 | { | |
289 | rtn = vistaSessi on.call(vm ); | |
290 | logger .info(vm.g etRpcName( )+" RPC Re sults:"+St ringUtils. displayEnc odedChars( rtn)); | |
291 | return VistaImag ingCommonU tilities.e xtractInva lidCharact ersFromRep ort(rtn); | |
292 | } | |
293 | catc h (Excepti on ex) | |
294 | { | |
295 | logger .error(ex) ; | |
296 | throw new VistaM ethodExcep tion(ex); | |
297 | } | |
298 | } | |
299 | ||
300 | /* * | |
301 | * Add the V istaImage instances from a sor ted set in to an exis ting Study instance | |
302 | * as a sing le Series. | |
303 | * | |
304 | * @param st udy | |
305 | * @param im ages | |
306 | * @throws U RNFormatEx ception | |
307 | * / | |
308 | pu blic stati c void add VistaImage sToStudyAs Series(Stu dy study, SortedSet< VistaImage > vistaIma ges) | |
309 | th rows URNFo rmatExcept ion | |
310 | { | |
311 | Seri es series = Series.c reate(stud y.getObjec tOrigin(), study.get StudyIen() , DEFAULT_ SERIES_NUM BER); | |
312 | ||
313 | Sort edSet<Imag e> images = | |
314 | VistaI magingTran slator.tra nsform(stu dy.getSite Number(), study.getS tudyIen(), study.get PatientIde ntifier(), | |
315 | vistaImage s); | |
316 | seri es.addImag es(images) ; | |
317 | stud y.addSerie s(series); | |
318 | } | |
319 | ||
320 | /* * | |
321 | * Add the I mage insta nces from a sorted s et into an existing Study inst ance | |
322 | * as a sing le Series. | |
323 | * | |
324 | * @param st udy | |
325 | * @param im ages | |
326 | * @throws U RNFormatEx ception | |
327 | * / | |
328 | pu blic stati c void add ImagesToSt udyAsSerie s(Study st udy, Sorte dSet<Image > images) | |
329 | { | |
330 | Seri es series = Series.c reate(stud y.getObjec tOrigin(), study.get StudyIen() , DEFAULT_ SERIES_NUM BER); | |
331 | ||
332 | seri es.addImag es(images) ; | |
333 | stud y.addSerie s(series); | |
334 | } | |
335 | ||
336 | /* * | |
337 | * | |
338 | * @param gr oups | |
339 | * @param gr aphStudyIe n | |
340 | * @param gr aphFirstIm ageIen | |
341 | * @return | |
342 | * / | |
343 | pr ivate stat ic VistaGr oup getMat chingGroup (SortedSet <VistaGrou p> groups, String gr aphStudyIe n, String graphFirst ImageIen) | |
344 | { | |
345 | logg er.debug(" getMatchin gGroup(" + groups.si ze() + " g roups," + graphStudy Ien + ") T ransaction Context (" + Transac tionContex tFactory.g et().getDi splayIdent ity() + ") ."); | |
346 | ||
347 | for( VistaGroup group : g roups) | |
348 | { | |
349 | String groupIen = group.ge tIen(); | |
350 | logger .debug("ge tMatchingG roup, eval uating gro up IEN '" + groupIen + | |
351 | "' to stud y IEN '" + graphStud yIen + | |
352 | "' and gra ph study f irst image IEN '" + graphFirst ImageIen + "'."); | |
353 | if( gr oupIen.equ alsIgnoreC ase(graphS tudyIen) | | groupIen .equalsIgn oreCase(gr aphFirstIm ageIen) ) | |
354 | return g roup; | |
355 | } | |
356 | logg er.warn("U nable to f ind group for study graph [" + graphStud yIen + "]" ); | |
357 | retu rn null; | |
358 | } | |
359 | ||
360 | /* * | |
361 | * This meth od is publ ic only fo r unit tes ting (grrr ) | |
362 | * @param re port | |
363 | * @return | |
364 | * / | |
365 | pu blic stati c String e xtractInva lidCharact ersFromRep ort(String report) | |
366 | { | |
367 | if(r eport == n ull) | |
368 | return null; | |
369 | for( Replacemen tCharacter s replacem entChar : reportRepl acementCha racters) | |
370 | { | |
371 | report = report. replace(re placementC har.oldCha r, replace mentChar.n ewChar); | |
372 | } | |
373 | retu rn report; | |
374 | } | |
375 | ||
376 | /* * | |
377 | * | |
378 | */ | |
379 | st atic class Replaceme ntCharacte rs | |
380 | { | |
381 | char oldChar; | |
382 | char newChar; | |
383 | ||
384 | Repl acementCha racters(ch ar oldChar , char new Char) | |
385 | { | |
386 | this.o ldChar = o ldChar; | |
387 | this.n ewChar = n ewChar; | |
388 | } | |
389 | } | |
390 | /* * | |
391 | * | |
392 | * @param vi staSession | |
393 | * @throws M ethodExcep tion | |
394 | * @throws I OException | |
395 | * @throws C onnectionE xception | |
396 | * / | |
397 | pu blic stati c void cre ateSession (VistaSess ion vistaS ession) | |
398 | th rows Metho dException , IOExcept ion, Conne ctionExcep tion | |
399 | { | |
400 | logg er.info("c reateSessi on() Trans actionCont ext (" + T ransaction ContextFac tory.get() .getDispla yIdentity( ) + ")."); | |
401 | ||
402 | Vist aQuery vm = VistaIma gingQueryF actory.cre ateSession Query(getW orkstation Id()); | |
403 | Stri ng rtn = n ull; | |
404 | try | |
405 | { | |
406 | rtn = vistaSessi on.call(vm ); | |
407 | logger .info(vm.g etRpcName( )+" RPC Re sults:"+St ringUtils. displayEnc odedChars( rtn)); | |
408 | if(rtn .startsWit h("0")) | |
409 | throw ne w MethodEx ception(rt n); | |
410 | ||
411 | logger .info("Cre ateSession result [" + rtn + " ]"); | |
412 | } | |
413 | catc h (VistaMe thodExcept ion e) | |
414 | { | |
415 | logger .error(e); | |
416 | thro w new Meth odExceptio n(e.getMes sage()); | |
417 | } | |
418 | ca tch (Inval idVistaCre dentialsEx ception e) | |
419 | { | |
420 | logg er.error(e ); | |
421 | thro w new Inva lidCredent ialsExcept ion(e.getM essage()); | |
422 | } | |
423 | } | |
424 | ||
425 | /* * | |
426 | * | |
427 | * @param vi staSession | |
428 | * @param st udy | |
429 | * @param gr oups | |
430 | * @param st udyLoadLev el | |
431 | * @return | |
432 | * / | |
433 | pu blic stati c Study me rgeStudyWi thMatching Group( | |
434 | Vist aSession v istaSessio n, | |
435 | Stud y study, | |
436 | Sort edSet<Vist aGroup> gr oups, | |
437 | Stud yLoadLevel studyLoad Level) | |
438 | { | |
439 | logg er.info("M erging stu dy '" + st udy.getStu dyIen() + "' with '" + groups. size() + " ' possible group(s)" ); | |
440 | Vist aGroup gro up = getMa tchingGrou p(groups, study.getS tudyIen(), study.get FirstImage Ien()); | |
441 | retu rn group = = null ? n ull : merg eStudyWith Group(vist aSession, study, gro up, studyL oadLevel); | |
442 | } | |
443 | ||
444 | /* * | |
445 | * Merge stu dy details into anot her Study instance. | |
446 | * The prima ry keys (s ite number and study IEN are n ot changed in the re ceiving in stance). | |
447 | * | |
448 | * @param vi staSession | |
449 | * @param st udy | |
450 | * @param gr oups | |
451 | * @param st udyLoadLev el | |
452 | * @return | |
453 | * / | |
454 | pu blic stati c Study me rgeStudyWi thGroup( | |
455 | Vist aSession v istaSessio n, | |
456 | Stud y study, | |
457 | Vist aGroup gro up, | |
458 | Stud yLoadLevel studyLoad Level) | |
459 | { | |
460 | if( group != n ull ) | |
461 | { | |
462 | study. setCapture By(group.g etCaptureB y()); | |
463 | study. setCapture Date(group .getCaptur eDate()); | |
464 | study. setDescrip tion(group .getDescri ption()); | |
465 | study. setEvent(g roup.getEv ent()); | |
466 | study. setImagePa ckage(grou p.getImage Package()) ; | |
467 | study. setImageTy pe(group.g etImageTyp e()); | |
468 | study. setNoteTit le(group.g etNoteTitl e()); | |
469 | study. setStudyCl ass(group. getStudyCl ass()); | |
470 | study. setOrigin( group.getO rigin()); | |
471 | study. setProcedu re(group.g etProcedur e()); | |
472 | study. setProcedu reDate(gro up.getProc edureDate( )); | |
473 | study. setSpecial ty(group.g etSpecialt y()); | |
474 | study. setGroupIe n(group.ge tIen()); | |
475 | // JMW 9/17/2010 if there is an actu al value h ere we don 't want to override it | |
476 | // the value fro m the grou p might on ly contain the group count whi ch is not correct if | |
477 | // the study con tains info rmation fr om multipl e groups | |
478 | if(stu dy.getImag eCount() < = 0) | |
479 | { | |
480 | study.se tImageCoun t(group.ge tImageCoun t()); | |
481 | } | |
482 | study. setProcedu reDateStri ng(group.g etProcedur eDateStrin g()); | |
483 | study. setAlienSi teNumber(g roup.getAl ienSiteNum ber()); | |
484 | study. setRpcResp onseMsg(gr oup.getRpc ResponseMs g()); | |
485 | // JMW 4/26/2011 P104T4 - did not ha ve this in here, cop ied below code (more or less) from depre cated merg e method i n Study ob ject | |
486 | study. setSiteAbb r(group.ge tSiteAbbr( )); // JMW - site ab br should come from RPC respon se, so ove rwrite val ue from si te object here | |
487 | ||
488 | // new fields fr om patch 9 3 | |
489 | study. setDocumen tDate(grou p.getDocum entDate()) ; | |
490 | study. setSensiti ve(group.i sSensitive ()); | |
491 | study. setStudyVi ewStatus(g roup.getSt udyViewSta tus()); | |
492 | study. setStudySt atus(group .getStudyS tatus()); | |
493 | study. setStudyIm agesHaveAn notations( group.isSt udyImagesH aveAnnotat ions()); | |
494 | ||
495 | if(! s tudy.getSt udyLoadLev el().isInc ludeImages ()) | |
496 | { | |
497 | // if th e study wa s not full y loaded, then its g etting the first ima ge from th e group RP C call | |
498 | // in th e case of a single i mage study , then the IEN from the group RPC for th e study is | |
499 | // actua lly the IE N of the i mage, not the group, so need t o set the first imag e study IE N | |
500 | // to be the actua l study IE N, not the image IEN . This is only impor tant for s hallow | |
501 | // reque sts that a re single image grou ps | |
502 | try | |
503 | { | |
504 | VistaImage vistaImag e = group. getFirstVi staImage() ; | |
505 | // JMW 7/2 1/2010 P10 4 | |
506 | // the IEN of the im age from g roup.getFi rstVistaIm age() is t he IEN of the study/ group beca use this | |
507 | // came fr om the MAG 4 PAT GET IMAGES rpc call | |
508 | // this is not the a ctual IEN of the fir st image, but the MA G DOD GET STUDIES IE N rpc incl udes the I EN | |
509 | // of the first imag e, so set the vistaI mage IEN t o that val ue, then a ssign the first imag e to | |
510 | // the stu dy | |
511 | vistaImage .setIen(st udy.getFir stImageIen ()); // th is value c omes from VistA so i t is corre ct, not th e group IE N but alwa ys the ima ge IEN | |
512 | Image firs tImage = V istaImagin gTranslato r.transfor m(study.ge tSiteNumbe r(), | |
513 | stud y.getStudy Ien(), stu dy.getPati entIdentif ier(), gro up.getFirs tVistaImag e()); | |
514 | // JMW 4/2 1/2011 P10 4 T4 | |
515 | // if the study has a consolid ated site number, th en it came from the first imag e in the g roup (this image) | |
516 | // so be s ure to ass ign that v alue to th e firstIma ge so it c an potenti ally updat e the imag e later | |
517 | firstImage .setConsol idatedSite Number(stu dy.getCons olidatedSi teNumber() ); | |
518 | ||
519 | //firstIma ge.setIen( studyGraph .getFirstI mageIen()) ; | |
520 | //firstIma ge.setGrou pIen(study .getStudyI en()); | |
521 | study.setF irstImage( firstImage ); | |
522 | study.setF irstImageI en(firstIm age.getIen ()); | |
523 | ||
524 | //studyDet ails.getFi rstImage() .setStudyI en(studyGr aph.getStu dyIen()); | |
525 | //studyDet ails.getFi rstImage() .setIen(st udyGraph.g etFirstIma geIen()); | |
526 | ||
527 | //studyGra ph.setFirs tImage(stu dyDetails. getFirstIm age()); | |
528 | //studyGra ph.setFirs tImageIen( studyDetai ls.getFirs tImage().g etIen()); | |
529 | } | |
530 | catch (U RNFormatEx ception x) | |
531 | { | |
532 | logger.err or("Error transformi ng VistaIm age instan ce into Im age instan ce", x); | |
533 | } | |
534 | } | |
535 | } | |
536 | ||
537 | if(s tudyLoadLe vel.isIncl udeReport( )) | |
538 | setStu dyRadiolog yReport(vi staSession , study); | |
539 | ||
540 | retu rn study; | |
541 | } | |
542 | ||
543 | /* * | |
544 | * Merge stu dy details into anot her Study instance. | |
545 | * The prima ry keys (s ite number and study IEN are n ot changed in the re ceiving in stance). | |
546 | * | |
547 | * @param vi staSession | |
548 | * @param ba seStudy | |
549 | * @param gr oups | |
550 | * @param st udyLoadLev el | |
551 | * @return | |
552 | * / | |
553 | pu blic stati c Study me rgeStudyWi thStudy( | |
554 | Vist aSession v istaSessio n, | |
555 | Stud y baseStud y, | |
556 | Stud y sourceSt udy, | |
557 | Stud yLoadLevel studyLoad Level) | |
558 | { | |
559 | if( sourceStud y != null ) | |
560 | { | |
561 | baseSt udy.setCap tureBy(sou rceStudy.g etCaptureB y()); | |
562 | baseSt udy.setCap tureDate(s ourceStudy .getCaptur eDate()); | |
563 | baseSt udy.setDes cription(s ourceStudy .getDescri ption()); | |
564 | baseSt udy.setEve nt(sourceS tudy.getEv ent()); | |
565 | baseSt udy.setIma gePackage( sourceStud y.getImage Package()) ; | |
566 | baseSt udy.setIma geType(sou rceStudy.g etImageTyp e()); | |
567 | baseSt udy.setNot eTitle(sou rceStudy.g etNoteTitl e()); | |
568 | baseSt udy.setStu dyClass(so urceStudy. getStudyCl ass()); | |
569 | baseSt udy.setOri gin(source Study.getO rigin()); | |
570 | baseSt udy.setPro cedure(sou rceStudy.g etProcedur e()); | |
571 | baseSt udy.setPro cedureDate (sourceStu dy.getProc edureDate( )); | |
572 | baseSt udy.setSpe cialty(sou rceStudy.g etSpecialt y()); | |
573 | // JMW 9/17/2010 if there is an actu al value h ere we don 't want to override it | |
574 | // the value fro m the grou p might on ly contain the group count whi ch is not correct if | |
575 | // the study con tains info rmation fr om multipl e groups | |
576 | if(bas eStudy.get ImageCount () <= 0) | |
577 | { | |
578 | baseStud y.setImage Count(sour ceStudy.ge tImageCoun t()); | |
579 | } | |
580 | baseSt udy.setPro cedureDate String(sou rceStudy.g etProcedur eDateStrin g()); | |
581 | baseSt udy.setAli enSiteNumb er(sourceS tudy.getAl ienSiteNum ber()); | |
582 | baseSt udy.setRpc ResponseMs g(sourceSt udy.getRpc ResponseMs g()); | |
583 | baseSt udy.setSen sitive(sou rceStudy.i sSensitive ()); | |
584 | baseSt udy.setDoc umentDate( sourceStud y.getDocum entDate()) ; | |
585 | baseSt udy.setStu dyViewStat us(sourceS tudy.getSt udyViewSta tus()); | |
586 | baseSt udy.setStu dyStatus(s ourceStudy .getStudyS tatus()); | |
587 | baseSt udy.setStu dyImagesHa veAnnotati ons(source Study.isSt udyImagesH aveAnnotat ions()); | |
588 | baseSt udy.setGro upIen(sour ceStudy.ge tGroupIen( )); | |
589 | baseSt udy.setAlt ernateExam Number(sou rceStudy.g etAlternat eExamNumbe r()); | |
590 | baseSt udy.setCon textId(sou rceStudy.g etContextI d()); | |
591 | ||
592 | if(! b aseStudy.g etStudyLoa dLevel().i sIncludeIm ages()) | |
593 | { | |
594 | // if th e study wa s not full y loaded, then its g etting the first ima ge from th e group RP C call | |
595 | // in th e case of a single i mage study , then the IEN from the group RPC for th e study is | |
596 | // actua lly the IE N of the i mage, not the group, so need t o set the first imag e study IE N | |
597 | // to be the actua l study IE N, not the image IEN . This is only impor tant for s hallow | |
598 | // reque sts that a re single image grou ps | |
599 | ||
600 | Image fi rstImage = baseStudy .getFirstI mage(); | |
601 | ||
602 | //System .out.print ln("Settin g first im age study Ien '" + B ase32Conve rsionUtili ty.base32D ecode(stud yGraph.get StudyIen() ) + "'"); | |
603 | ||
604 | //firstI mage.setIe n(studyGra ph.getFirs tImageIen( )); | |
605 | //firstI mage.setGr oupIen(bas eStudy.get StudyIen() ); | |
606 | baseStud y.setFirst Image(firs tImage); | |
607 | baseStud y.setFirst ImageIen(f irstImage. getIen()); | |
608 | ||
609 | //studyD etails.get FirstImage ().setStud yIen(study Graph.getS tudyIen()) ; | |
610 | //studyD etails.get FirstImage ().setIen( studyGraph .getFirstI mageIen()) ; | |
611 | ||
612 | //studyG raph.setFi rstImage(s tudyDetail s.getFirst Image()); | |
613 | //studyG raph.setFi rstImageIe n(studyDet ails.getFi rstImage() .getIen()) ; | |
614 | } | |
615 | } | |
616 | ||
617 | if(s tudyLoadLe vel.isIncl udeReport( )) | |
618 | setStu dyRadiolog yReport(vi staSession , baseStud y); | |
619 | ||
620 | retu rn baseStu dy; | |
621 | } | |
622 | ||
623 | /* * | |
624 | * Find the version re quired to run the da ta source from the c onfigurati on. If no version fo und then | |
625 | * defaultVe rsion is r eturned | |
626 | * | |
627 | * @param vi staConfigu ration | |
628 | * @param da taSourceCl ass | |
629 | * @param de faultVersi on | |
630 | * @return | |
631 | * / | |
632 | pu blic stati c String g etVistaDat aSourceIma gingVersio n(VistaIma gingConfig uration vi staConfigu ration, | |
633 | Class< ?> dataSou rceClass, String def aultVersio n) | |
634 | { | |
635 | Stri ng version = vistaCo nfiguratio n.getDataS ourceImagi ngVersion( dataSource Class); | |
636 | if(v ersion == null) | |
637 | return defaultVe rsion; | |
638 | retu rn version ; | |
639 | } | |
640 | ||
641 | pr ivate stat ic VistaSt oredStudyF ilter getS toredStudy FilterDeta ils(VistaS ession vis taSession, StoredStu dyFilterUR N storedSt udyFilterU RN) | |
642 | th rows IOExc eption, In validVista Credential sException , VistaMet hodExcepti on | |
643 | { | |
644 | Vist aQuery vis taQuery = new VistaQ uery("MAG4 FILTER DE TAILS"); | |
645 | vist aQuery.add Parameter( VistaQuery .LITERAL, storedStud yFilterURN .getFilter Id()); | |
646 | vist aQuery.add Parameter( VistaQuery .LITERAL, ""); | |
647 | vist aQuery.add Parameter( VistaQuery .LITERAL, ""); | |
648 | ||
649 | Stri ng rtn = v istaSessio n.call(vis taQuery); | |
650 | ||
651 | Vist aStoredStu dyFilter r esult = Vi staStoredS tudyFilter .create(rt n); | |
652 | ||
653 | retu rn result; | |
654 | } | |
655 | ||
656 | pu blic stati c VistaQue ry createM agImageLis tQuery(Vis taSession vistaSessi on, String patientDf n, StudyFi lter study Filter, | |
657 | boolea n allowDel etedImages ) | |
658 | th rows IOExc eption, In validVista Credential sException , VistaMet hodExcepti on | |
659 | { | |
660 | Vist aQuery msg = new Vis taQuery(RP C_MAG_IMAG E_LIST); | |
661 | Stri ng control Parameter = "E"; // existing i mages | |
662 | Stri ng fromDat e = ""; | |
663 | Stri ng toDate = ""; | |
664 | ||
665 | Stri ng studyPa ckage = "" ; | |
666 | Stri ng studyCl ass = ""; | |
667 | Stri ng studyTy pes = ""; | |
668 | Stri ng studyEv ent = ""; | |
669 | Stri ng studySp ecialty = ""; | |
670 | Stri ng studyOr igin = ""; | |
671 | int maximumRes ults = Int eger.MAX_V ALUE; | |
672 | List <String> c ptCodes = null; | |
673 | List <String> m odalityCod es = null; | |
674 | Stor edStudyFil terURN sto redStudyFi lterURN = null; | |
675 | ||
676 | if(s tudyFilter != null) | |
677 | { | |
678 | fromDa te = Vista Translator Utility.co nvertDateT oRpcFormat (studyFilt er.getFrom Date()); | |
679 | toDate = VistaTr anslatorUt ility.conv ertDateToR pcFormat(s tudyFilter .getToDate ()); | |
680 | studyP ackage = s tudyFilter .getStudy_ package(); | |
681 | studyC lass = stu dyFilter.g etStudy_cl ass(); | |
682 | studyT ypes = stu dyFilter.g etStudy_ty pe(); | |
683 | studyE vent = stu dyFilter.g etStudy_ev ent(); | |
684 | studyS pecialty = studyFilt er.getStud y_specialt y(); | |
685 | studyO rigin = st udyFilter. getOrigin( ); | |
686 | maximu mResults = studyFilt er.getMaxi mumResults (); | |
687 | cptCod es = study Filter.get CptCodes() ; | |
688 | modali tyCodes = studyFilte r.getModal ityCodes() ; | |
689 | stored StudyFilte rURN = stu dyFilter.g etStoredSt udyFilterU rn(); | |
690 | } | |
691 | ||
692 | ||
693 | if(( allowDelet edImages) && (studyF ilter != n ull) && (s tudyFilter .isInclude Deleted()) ) | |
694 | contro lParameter += "D"; / / deleted images | |
695 | msg. addParamet er(VistaQu ery.LITERA L, control Parameter) ; | |
696 | ||
697 | ||
698 | if(s toredStudy FilterURN != null) | |
699 | { | |
700 | VistaS toredStudy Filter vis taStoredSt udyFilter = getStore dStudyFilt erDetails( vistaSessi on, stored StudyFilte rURN); | |
701 | if(vis taStoredSt udyFilter != null) | |
702 | { | |
703 | logger.i nfo("Overr iding the included f ilter para meters wit h the valu es from th e filter [ " + stored StudyFilte rURN.toStr ing() + "] "); | |
704 | fromDate = vistaSt oredStudyF ilter.getF romDate(); | |
705 | toDate = vistaStor edStudyFil ter.getToD ate(); | |
706 | studyPac kage = vis taStoredSt udyFilter. getPackage s(); | |
707 | studyCla ss = vista StoredStud yFilter.ge tClasses() ; | |
708 | studyTyp es = vista StoredStud yFilter.ge tTypes(); | |
709 | studyEve nt = vista StoredStud yFilter.ge tProcEvent s(); | |
710 | studySpe cialty = v istaStored StudyFilte r.getSpecS ubSpec(); | |
711 | maximumR esults = v istaStored StudyFilte r.getMaxRe sults(); | |
712 | studyOri gin = vist aStoredStu dyFilter.g etOrigin() ; | |
713 | ||
714 | } | |
715 | else { | |
716 | logger.w arn("Could not find filter [" + storedSt udyFilterU RN.toStrin g() + "]") ; | |
717 | } | |
718 | } | |
719 | ||
720 | ||
721 | ||
722 | msg. addParamet er(VistaQu ery.LITERA L, fromDat e); | |
723 | msg. addParamet er(VistaQu ery.LITERA L, toDate) ; | |
724 | if(m aximumResu lts < Inte ger.MAX_VA LUE) | |
725 | { | |
726 | msg.ad dParameter (VistaQuer y.LITERAL, maximumRe sults + "" ); | |
727 | } | |
728 | else | |
729 | { | |
730 | msg.ad dParameter (VistaQuer y.LITERAL, ""); | |
731 | } | |
732 | Map< String, St ring> filt erParamete rs = new H ashMap<Str ing, Strin g>(); | |
733 | ||
734 | filt erParamete rs.put(fil terParamet ers.size() + "", "ID FN^^" + pa tientDfn); | |
735 | ||
736 | ||
737 | ||
738 | ||
739 | ||
740 | ||
741 | ||
742 | ||
743 | ||
744 | ||
745 | if(! "".equals( studyClass )) | |
746 | { | |
747 | studyC lass = stu dyClass.re place(',', '^'); // need to co nvert , to ^ | |
748 | filter Parameters .put(filte rParameter s.size() + "", "IXCL ASS^^" + s tudyClass) ; | |
749 | } | |
750 | if(! "".equals( studyPacka ge)) | |
751 | { | |
752 | studyP ackage = s tudyPackag e.replace( ',', '^'); // need t o convert , to ^ | |
753 | filter Parameters .put(filte rParameter s.size() + "", "IXPK G^^" + stu dyPackage) ; | |
754 | } | |
755 | if(! "".equals( studyTypes )) | |
756 | { | |
757 | studyT ypes = stu dyTypes.re place(',', '^'); // need to co nvert , to ^ | |
758 | filter Parameters .put(filte rParameter s.size() + "", "IXTY PE^^" + st udyTypes); | |
759 | } | |
760 | //TO DO: make s ure Event == Procedu re - i thi nk so? | |
761 | if(! "".equals( studyEvent )) | |
762 | { | |
763 | studyE vent = stu dyEvent.re place(',', '^'); // need to co nvert , to ^ | |
764 | filter Parameters .put(filte rParameter s.size() + "", "IXPR OC^^" + st udyEvent); | |
765 | } | |
766 | if(! "".equals( studySpeci alty)) | |
767 | { | |
768 | studyS pecialty = studySpec ialty.repl ace(',', ' ^'); // ne ed to conv ert , to ^ | |
769 | filter Parameters .put(filte rParameter s.size() + "", "IXSP EC^^" + st udySpecial ty); | |
770 | } | |
771 | if(! "".equals( studyOrigi n)) | |
772 | { | |
773 | studyO rigin = st udyOrigin. replace(', ', '^'); / / need to convert , to ^ | |
774 | filter Parameters .put(filte rParameter s.size() + "", "IXOR IGIN^^" + studyOrigi n); | |
775 | } | |
776 | if(c ptCodes != null && c ptCodes.si ze() > 0) | |
777 | { | |
778 | String cptCodeFi lter = "CP TCODE^^"; | |
779 | for(St ring cptCo de : cptCo des) | |
780 | { | |
781 | cptCodeF ilter += c ptCode + " ^"; | |
782 | } | |
783 | ||
784 | filter Parameters .put(filte rParameter s.size() + "", cptCo deFilter); | |
785 | } | |
786 | if(m odalityCod es != null && modali tyCodes.si ze() > 0) | |
787 | { | |
788 | String modalityC odeFilter = "MODALIT Y^^"; | |
789 | for(St ring modal ityCode : modalityCo des) | |
790 | { | |
791 | modality CodeFilter += modali tyCode + " ^"; | |
792 | } | |
793 | filter Parameters .put(filte rParameter s.size() + "", modal ityCodeFil ter); | |
794 | ||
795 | } | |
796 | msg. addParamet er(VistaQu ery.LIST, filterPara meters); | |
797 | Vist aImagingQu eryFactory .logVistaQ ueryReques t(msg); | |
798 | retu rn msg; | |
799 | } | |
800 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.