Produced by Araxis Merge on 10/2/2017 7:00:08 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 | cds.zip\cds\product\production\cdsinvocation\cds-invocation\src\test\java\com\cognitive\cds\invocation\fhir | FhirDataRetrieverIT.java | Wed Jul 12 18:43:52 2017 UTC |
| 2 | cds.zip\cds\product\production\cdsinvocation\cds-invocation\src\test\java\com\cognitive\cds\invocation\fhir | FhirDataRetrieverIT.java | Wed Sep 27 16:01:30 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 1068 |
| 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 | /* | |
| 2 | * COPYRIG HT STATUS: © 2015, 2 016. This work, aut hored by C ognitive M edical Sys tems | |
| 3 | * employe es, was fu nded in wh ole or in part by Th e Departme nt of Vete rans | |
| 4 | * Affairs under U.S . Governme nt contrac t VA118-11 -D-1011 / VA118-1011 -0013. | |
| 5 | * The cop yright hol der agrees to post o r allow th e Governme nt to post all or | |
| 6 | * part of this work in open-s ource repo sitories s ubject to the Apache License, | |
| 7 | * Version 2.0, date d January 2004. All other righ ts are res erved by t he | |
| 8 | * copyrig ht owner. | |
| 9 | * | |
| 10 | * For use outside t he Governm ent, the f ollowing n otice appl ies: | |
| 11 | * | |
| 12 | * Cop yright 201 5 © Cognit ive Medica l Systems | |
| 13 | * | |
| 14 | * Lic ensed unde r the Apac he License , Version 2.0 (the " License"); you may | |
| 15 | * not use this file excep t in compl iance with the Licen se. You ma y obtain | |
| 16 | * a c opy of the License a t http://w ww.apache. org/licens es/LICENSE -2.0 | |
| 17 | * | |
| 18 | * Unl ess requir ed by appl icable law or agreed to in wri ting, soft ware | |
| 19 | * dis tributed u nder the L icense is distribute d on an "A S IS" BASI S, | |
| 20 | * WIT HOUT WARRA NTIES OR C ONDITIONS OF ANY KIN D, either express or implied. | |
| 21 | * See the Licen se for the specific language g overning p ermissions and | |
| 22 | * lim itations u nder the L icense. | |
| 23 | * | |
| 24 | */ | |
| 25 | package co m.cognitiv e.cds.invo cation.fhi r; | |
| 26 | ||
| 27 | import sta tic org.ju nit.Assert .assertNot Null; | |
| 28 | import sta tic org.ju nit.Assert .assertTru e; | |
| 29 | ||
| 30 | import jav a.io.IOExc eption; | |
| 31 | import jav a.io.Input Stream; | |
| 32 | import jav a.nio.file .Files; | |
| 33 | import jav a.nio.file .Paths; | |
| 34 | import jav a.util.Arr ayList; | |
| 35 | import jav a.util.Lis t; | |
| 36 | import jav a.util.con current.Ca llable; | |
| 37 | import jav a.util.con current.Ex ecutorServ ice; | |
| 38 | import jav a.util.con current.Ex ecutors; | |
| 39 | ||
| 40 | import jav ax.ws.rs.c ore.Respon se; | |
| 41 | ||
| 42 | import org .apache.cx f.helpers. IOUtils; | |
| 43 | import org .apache.cx f.jaxrs.cl ient.WebCl ient; | |
| 44 | import org .junit.Aft er; | |
| 45 | import org .junit.Aft erClass; | |
| 46 | import org .junit.Bef ore; | |
| 47 | import org .junit.Bef oreClass; | |
| 48 | import org .junit.Ign ore; | |
| 49 | import org .junit.Tes t; | |
| 50 | import org .junit.run ner.RunWit h; | |
| 51 | import org .springfra mework.bea ns.factory .annotatio n.Autowire d; | |
| 52 | import org .springfra mework.bea ns.factory .annotatio n.Qualifie r; | |
| 53 | import org .springfra mework.tes t.context. ContextCon figuration ; | |
| 54 | import org .springfra mework.tes t.context. junit4.Spr ingJUnit4C lassRunner ; | |
| 55 | ||
| 56 | import com .cognitive .cds.invoc ation.exce ptions.Dat aRetrieval Exception; | |
| 57 | import com .cognitive .cds.invoc ation.util .FhirUtils ; | |
| 58 | ||
| 59 | import ca. uhn.fhir.m odel.base. resource.B aseOperati onOutcome. BaseIssue; | |
| 60 | import ca. uhn.fhir.m odel.dstu2 .resource. Bundle; | |
| 61 | import ca. uhn.fhir.p arser.IPar ser; | |
| 62 | import ca. uhn.fhir.v alidation. FhirValida tor; | |
| 63 | import ca. uhn.fhir.v alidation. Validation Result; | |
| 64 | ||
| 65 | /** | |
| 66 | * | |
| 67 | * @author tnguyen | |
| 68 | */ | |
| 69 | @RunWith(S pringJUnit 4ClassRunn er.class) | |
| 70 | @ContextCo nfiguratio n(location s = { "cla sspath:fhi rcontext-t est.xml" } ) | |
| 71 | public cla ss FhirDat aRetriever IT { | |
| 72 | ||
| 73 | privat e static f inal org.s lf4j.Logge r log = or g.slf4j.Lo ggerFactor y.getLogge r(FhirData RetrieverI T.class); | |
| 74 | ||
| 75 | @Autow ired | |
| 76 | @Quali fier("retr ieveFhirDa ta") | |
| 77 | FhirDa taRetrieve r instance ; | |
| 78 | ||
| 79 | public FhirDataR etrieverIT () { | |
| 80 | } | |
| 81 | ||
| 82 | @Befor eClass | |
| 83 | public static vo id setUpCl ass() { | |
| 84 | } | |
| 85 | ||
| 86 | @After Class | |
| 87 | public static vo id tearDow nClass() { | |
| 88 | } | |
| 89 | ||
| 90 | @Befor e | |
| 91 | public void setU p() throws Exception { | |
| 92 | } | |
| 93 | ||
| 94 | @After | |
| 95 | public void tear Down() { | |
| 96 | } | |
| 97 | ||
| 98 | /** | |
| 99 | * NOT E: DEVELOP MENT TESTI NG ONLY | |
| 100 | * | |
| 101 | * Int egration T est of Fhi rDataRetri ever.getFh irData met hod. (with attempted | |
| 102 | * liv e retrieva l from RDK FHir serv er) | |
| 103 | * | |
| 104 | * @th rows DataR etrievalEx ception | |
| 105 | */ | |
| 106 | ||
| 107 | @Ignor e("This is really a service le vel integr ation test ") | |
| 108 | @Test | |
| 109 | public void test GetPatient () throws DataRetrie valExcepti on, Interr uptedExcep tion, IOEx ception { | |
| 110 | ||
| 111 | lo g.info("\n \n======== ========== ===> TESTI NG: testGe tPatient < ========== ========== = "); | |
| 112 | ||
| 113 | Li st<String> queries = new Array List<Strin g>(); | |
| 114 | Bu ndle b = n ew Bundle( ); | |
| 115 | ||
| 116 | qu eries.add( "patient/9 E7A;239"); | |
| 117 | ||
| 118 | th is.getFhir Data(queri es); | |
| 119 | } | |
| 120 | ||
| 121 | @Ignor e("This is really a service le vel integr ation test ") | |
| 122 | @Test | |
| 123 | public void test GetVitals( ) throws D ataRetriev alExceptio n, Interru ptedExcept ion, IOExc eption { | |
| 124 | ||
| 125 | lo g.info("\n \n======== ========== ===> TESTI NG: testGe tVitals (n ow vital-s igns) <=== ========== ======== " ); | |
| 126 | ||
| 127 | Li st<String> queries = new Array List<Strin g>(); | |
| 128 | Bu ndle b = n ew Bundle( ); | |
| 129 | ||
| 130 | qu eries.add( "patient/9 E7A;140/ob servation? _tag=vital -signs"); | |
| 131 | ||
| 132 | th is.getFhir Data(queri es); | |
| 133 | } | |
| 134 | ||
| 135 | @Ignor e("This is really a service le vel integr ation test ") | |
| 136 | @Test | |
| 137 | public void test GetDiagnos ticWithDat eParam() t hrows Data RetrievalE xception, Interrupte dException , IOExcept ion { | |
| 138 | Li st<String> queries = new Array List<Strin g>(); | |
| 139 | St ringBuffer query = n ew StringB uffer("pat ient/9E7A; 3/diagnost icreport?d omain=lab& amp;date=# #dateGreat erThanOrEq ual-360d## "); | |
| 140 | FH IRJSONData ModelHandl er modelHa nder = new FHIRJSOND ataModelHa ndler() { | |
| 141 | @Overr ide | |
| 142 | public IFhirData Retriever createFhir DataRetrie ver() { | |
| 143 | return i nstance; | |
| 144 | } | |
| 145 | }; | |
| 146 | Stri ng resolve dQuery = m odelHander .resolveDa teParams(q uery).toSt ring(); | |
| 147 | qu eries.add( resolvedQu ery); | |
| 148 | th is.getFhir Data(queri es); | |
| 149 | } | |
| 150 | ||
| 151 | @Ignor e("This is really a service le vel integr ation test ") | |
| 152 | @Test | |
| 153 | public void test GetPatient AndVitals( ) throws D ataRetriev alExceptio n, Interru ptedExcept ion, IOExc eption { | |
| 154 | ||
| 155 | lo g.info("\n \n======== ========== ===> TESTI NG: testGe tPatientAn dVitals (n ow vital-s igns) <=== ========== ======== " ); | |
| 156 | ||
| 157 | Li st<String> queries = new Array List<Strin g>(); | |
| 158 | Bu ndle b = n ew Bundle( ); | |
| 159 | ||
| 160 | qu eries.add( "patient/9 E7A;140"); | |
| 161 | th is.getFhir Data(queri es); | |
| 162 | ||
| 163 | // ---------- ---------- ---------- ---------- ---------- ---------- ---------- | |
| 164 | // To test n ew re-Auth code afte r an RDK A uth timeou t, | |
| 165 | // we need t o delete t he current RDK sessi on (simula ting sessi on time ou t), | |
| 166 | // then call getFhirDa ta() again . | |
| 167 | // Result sh ould be su ccessful s ince a re- Auth will be automat ically don e. | |
| 168 | // ---------- ---------- ---------- ---------- ---------- ---------- ---------- | |
| 169 | We bClient my Client = i nstance.ge tClient(); | |
| 170 | lo g.info("DE LETING RDK session") ; | |
| 171 | my Client.pat h("/authen tication/s ystems").d elete(); | |
| 172 | ||
| 173 | ||
| 174 | qu eries.clea r(); | |
| 175 | qu eries.add( "patient/9 E7A;140/ob servation? profile=CD S&_tag=vit al-signs") ; | |
| 176 | ||
| 177 | th is.getFhir Data(queri es); | |
| 178 | } | |
| 179 | ||
| 180 | @Ignor e("This is really a service le vel integr ation test ") | |
| 181 | @Test | |
| 182 | public void test GetConditi on() throw s Interrup tedExcepti on, IOExce ption, Dat aRetrieval Exception { | |
| 183 | ||
| 184 | lo g.info("\n \n======== ========== ===> TESTI NG: testGe tCondition <======== ========== === "); | |
| 185 | ||
| 186 | Li st<String> queries = new Array List<Strin g>(); | |
| 187 | Bu ndle b = n ew Bundle( ); | |
| 188 | ||
| 189 | qu eries.add( "patient/9 E7A;140/co ndition"); | |
| 190 | th is.getFhir Data(queri es); | |
| 191 | } | |
| 192 | ||
| 193 | @Ignor e("This is really a service le vel integr ation test ") | |
| 194 | @Test | |
| 195 | public void test GetObserva tion() thr ows Interr uptedExcep tion, IOEx ception, D ataRetriev alExceptio n { | |
| 196 | ||
| 197 | lo g.info("\n \n======== ========== ===> TESTI NG: testGe tObservati on <====== ========== ===== "); | |
| 198 | ||
| 199 | Li st<String> queries = new Array List<Strin g>(); | |
| 200 | Bu ndle b = n ew Bundle( ); | |
| 201 | qu eries.add( "patient/9 E7A;140/ob servation" ); | |
| 202 | ||
| 203 | th is.getFhir Data(queri es); | |
| 204 | } | |
| 205 | ||
| 206 | @Ignor e("This is really a service le vel integr ation test ") | |
| 207 | @Test | |
| 208 | public void test GetEducati ons() thro ws Interru ptedExcept ion, IOExc eption, Da taRetrieva lException { | |
| 209 | ||
| 210 | lo g.info("\n \n======== ========== ===> TESTI NG: testGe tEducation s <======= ========== ==== "); | |
| 211 | ||
| 212 | Li st<String> queries = new Array List<Strin g>(); | |
| 213 | Bu ndle b = n ew Bundle( ); | |
| 214 | ||
| 215 | qu eries.add( "patient/9 E7A;253/pr ocedure?_t ag=educati ons"); | |
| 216 | ||
| 217 | th is.getFhir Data(queri es); | |
| 218 | } | |
| 219 | ||
| 220 | @Ignor e("This is really a service le vel integr ation test ") | |
| 221 | @Test | |
| 222 | public void test GetAllProc edure() th rows Inter ruptedExce ption, IOE xception, DataRetrie valExcepti on { | |
| 223 | ||
| 224 | lo g.info("\n \n======== ========== ===> TESTI NG: testGe tAllProced ure <===== ========== ====== "); | |
| 225 | ||
| 226 | Li st<String> queries = new Array List<Strin g>(); | |
| 227 | Bu ndle b = n ew Bundle( ); | |
| 228 | ||
| 229 | qu eries.add( "patient/C 877;227/pr ocedure"); | |
| 230 | ||
| 231 | th is.getFhir Data(queri es); | |
| 232 | } | |
| 233 | ||
| 234 | @Ignor e("This is really a service le vel integr ation test ") | |
| 235 | @Test | |
| 236 | public void test GetHealthF actors() t hrows Inte rruptedExc eption, IO Exception, DataRetri evalExcept ion { | |
| 237 | ||
| 238 | lo g.info("\n \n======== ========== ===> TESTI NG: testGe tHealthFac tors (now social-his tory) <=== ========== ======== " ); | |
| 239 | ||
| 240 | Li st<String> queries = new Array List<Strin g>(); | |
| 241 | Bu ndle b = n ew Bundle( ); | |
| 242 | // TODO healt h factors fhir query is disabl ed from RD K side. En able this query in t he future when it's enabled fr om RDK sid e | |
| 243 | // queries.ad d("patient /9E7A;140/ observatio n?_tag=soc ial-histor y"); | |
| 244 | ||
| 245 | th is.getFhir Data(queri es); | |
| 246 | } | |
| 247 | ||
| 248 | @Ignor e("This is really a service le vel integr ation test ") | |
| 249 | @Test | |
| 250 | public void test GetMedicat ionDispens e() throws Interrupt edExceptio n, IOExcep tion, Data RetrievalE xception { | |
| 251 | ||
| 252 | lo g.info("\n \n======== ========== ===> TESTI NG: testGe tMedicatio nDispense <========= ========== == "); | |
| 253 | ||
| 254 | Li st<String> queries = new Array List<Strin g>(); | |
| 255 | Bu ndle b = n ew Bundle( ); | |
| 256 | ||
| 257 | qu eries.add( "medicatio ndispense? subject.id entifier=9 E7A;140"); | |
| 258 | ||
| 259 | th is.getFhir Data(queri es); | |
| 260 | } | |
| 261 | ||
| 262 | @Ignor e("This is really a service le vel integr ation test ") | |
| 263 | @Test | |
| 264 | public void test GetMedicat ionPrescri ption() th rows Inter ruptedExce ption, IOE xception, DataRetrie valExcepti on { | |
| 265 | ||
| 266 | lo g.info("\n \n======== ========== ===> TESTI NG: testGe tMedicatio nPrescript ion <===== ========== ====== "); | |
| 267 | ||
| 268 | Li st<String> queries = new Array List<Strin g>(); | |
| 269 | Bu ndle b = n ew Bundle( ); | |
| 270 | ||
| 271 | // This has i ssues due to a chang e in fhir spec - thi s was from a period | |
| 272 | // when we we re transit ioning ver sions. | |
| 273 | qu eries.add( "patient/9 E7A;301/me dicationpr escription "); | |
| 274 | ||
| 275 | th is.getFhir Data(queri es); | |
| 276 | } | |
| 277 | ||
| 278 | @Ignor e("This is really a service le vel integr ation test ") | |
| 279 | @Test | |
| 280 | public void test GetMedicat ionAdminis tration() throws Int erruptedEx ception, I OException , DataRetr ievalExcep tion { | |
| 281 | ||
| 282 | lo g.info("\n \n======== ========== ===> TESTI NG: testGe tMedicatio nAdministr ation <=== ========== ======== " ); | |
| 283 | ||
| 284 | Li st<String> queries = new Array List<Strin g>(); | |
| 285 | Bu ndle b = n ew Bundle( ); | |
| 286 | ||
| 287 | qu eries.add( "medicatio nadministr ation?subj ect.identi fier=9E7A; 140"); | |
| 288 | ||
| 289 | th is.getFhir Data(queri es); | |
| 290 | } | |
| 291 | ||
| 292 | @Ignor e("This is really a service le vel integr ation test ") | |
| 293 | @Test | |
| 294 | public void test GetAllergy Intoleranc e() throws Interrupt edExceptio n, IOExcep tion, Data RetrievalE xception { | |
| 295 | ||
| 296 | lo g.info("\n \n======== ========== ===> TESTI NG: testGe tAllergyIn tolerance <========= ========== == "); | |
| 297 | ||
| 298 | Li st<String> queries = new Array List<Strin g>(); | |
| 299 | Bu ndle b = n ew Bundle( ); | |
| 300 | ||
| 301 | qu eries.add( "allergyin tolerance? subject.id entifier=9 E7A;140"); | |
| 302 | ||
| 303 | th is.getFhir Data(queri es); | |
| 304 | } | |
| 305 | ||
| 306 | @Ignor e("This is really a service le vel integr ation test ") | |
| 307 | @Test | |
| 308 | public void test GetLabs() throws Int erruptedEx ception, I OException , DataRetr ievalExcep tion { | |
| 309 | ||
| 310 | lo g.info("\n \n======== ========== ===> TESTI NG: testGe tLabs <=== ========== ======== " ); | |
| 311 | ||
| 312 | Li st<String> queries = new Array List<Strin g>(); | |
| 313 | ||
| 314 | FH IRJSONData ModelHandl er modelHa nder = new FHIRJSOND ataModelHa ndler() { | |
| 315 | @Overrid e | |
| 316 | public I FhirDataRe triever cr eateFhirDa taRetrieve r() { | |
| 317 | return instance; | |
| 318 | } | |
| 319 | }; | |
| 320 | StringBuff er query = new Strin gBuffer("/ patient/9E 7A;253/dia gnosticrep ort?domain =lab&date= ##dateLess ThanOrEqua l-180d##") ; | |
| 321 | String res olvedQuery = modelHa nder.resol veDatePara ms(query). toString() ; | |
| 322 | queries.ad d(resolved Query); | |
| 323 | this.getFh irData(que ries); | |
| 324 | } | |
| 325 | ||
| 326 | @Ignor e("This is really a service le vel integr ation test ") | |
| 327 | @Test | |
| 328 | public void test GetImmuniz ation() th rows Inter ruptedExce ption, IOE xception, DataRetrie valExcepti on { | |
| 329 | ||
| 330 | lo g.info("\n \n======== ========== ===> TESTI NG: testGe tImmunizat ion <===== ========== ====== "); | |
| 331 | ||
| 332 | Li st<String> queries = new Array List<Strin g>(); | |
| 333 | Bu ndle b = n ew Bundle( ); | |
| 334 | ||
| 335 | qu eries.add( "immunizat ion?subjec t.identifi er=9E7A;14 0"); | |
| 336 | ||
| 337 | th is.getFhir Data(queri es); | |
| 338 | } | |
| 339 | ||
| 340 | @Ignor e("This is really a service le vel integr ation test ") | |
| 341 | @Test | |
| 342 | public void test GetComposi tion() thr ows Interr uptedExcep tion, IOEx ception, D ataRetriev alExceptio n { | |
| 343 | ||
| 344 | lo g.info("\n \n======== ========== ===> TESTI NG: testGe tCompositi on <====== ========== ===== "); | |
| 345 | ||
| 346 | Li st<String> queries = new Array List<Strin g>(); | |
| 347 | Bu ndle b = n ew Bundle( ); | |
| 348 | ||
| 349 | qu eries.add( "compositi on?subject .identifie r=9E7A;140 &limit=1") ; | |
| 350 | ||
| 351 | th is.getFhir Data(queri es); | |
| 352 | } | |
| 353 | ||
| 354 | @Ignor e("This is really a service le vel integr ation test ") | |
| 355 | @Test | |
| 356 | public void test GetReferra lRequest() throws In terruptedE xception, IOExceptio n, DataRet rievalExce ption { | |
| 357 | ||
| 358 | lo g.info("\n \n======== ========== ===> TESTI NG: testGe tReferralR equest <== ========== ========= "); | |
| 359 | ||
| 360 | Li st<String> queries = new Array List<Strin g>(); | |
| 361 | Bu ndle b = n ew Bundle( ); | |
| 362 | ||
| 363 | qu eries.add( "referralr equest?sub ject.ident ifier=9E7A ;140"); | |
| 364 | ||
| 365 | th is.getFhir Data(queri es); | |
| 366 | } | |
| 367 | ||
| 368 | @Ignor e("This is really a service le vel integr ation test ") | |
| 369 | @Test | |
| 370 | public void test GetOrderDi agnosticOr der() thro ws Interru ptedExcept ion, IOExc eption, Da taRetrieva lException { | |
| 371 | ||
| 372 | lo g.info("\n \n======== ========== ===> TESTI NG: testGe tOrderDiag nosticOrde r <======= ========== ==== "); | |
| 373 | ||
| 374 | Li st<String> queries = new Array List<Strin g>(); | |
| 375 | Bu ndle b = n ew Bundle( ); | |
| 376 | ||
| 377 | qu eries.add( "order?sub ject.ident ifier=9E7A ;8&detail. display=Di agnosticOr der"); | |
| 378 | ||
| 379 | th is.getFhir Data(queri es, "testG etOrderDia gnosticOrd er.json"); | |
| 380 | } | |
| 381 | ||
| 382 | @Ignor e("This is really a service le vel integr ation test ") | |
| 383 | @Test | |
| 384 | public void test Diagnostic Order() th rows Inter ruptedExce ption, IOE xception, DataRetrie valExcepti on { | |
| 385 | ||
| 386 | lo g.info("\n \n======== ========== ===> TESTI NG: testDi agnosticOr der <===== ========== ====== "); | |
| 387 | ||
| 388 | Li st<String> queries = new Array List<Strin g>(); | |
| 389 | Bu ndle b = n ew Bundle( ); | |
| 390 | ||
| 391 | qu eries.add( "patient/9 E7A;8/diag nosticorde r"); | |
| 392 | ||
| 393 | th is.getFhir Data(queri es); | |
| 394 | } | |
| 395 | ||
| 396 | @Ignor e("This is really a service le vel integr ation test ") | |
| 397 | @Test | |
| 398 | public void test Procedure( ) throws I nterrupted Exception, IOExcepti on, DataRe trievalExc eption { | |
| 399 | ||
| 400 | lo g.info("\n \n======== ========== ===> TESTI NG: testPr ocedure <= ========== ========== "); | |
| 401 | ||
| 402 | Li st<String> queries = new Array List<Strin g>(); | |
| 403 | Bu ndle b = n ew Bundle( ); | |
| 404 | ||
| 405 | qu eries.add( "patient/9 E7A;239/pr ocedure?_t ag=procedu re"); | |
| 406 | ||
| 407 | th is.getFhir Data(queri es); | |
| 408 | } | |
| 409 | ||
| 410 | /** | |
| 411 | * | |
| 412 | * @pa ram querie s | |
| 413 | * @th rows DataR etrievalEx ception | |
| 414 | * @th rows Inter ruptedExce ption | |
| 415 | * @th rows IOExc eption | |
| 416 | */ | |
| 417 | public void getF hirData(Li st<String> queries) throws Dat aRetrieval Exception, Interrupt edExceptio n, IOExcep tion { | |
| 418 | th is.getFhir Data(queri es, null); | |
| 419 | } | |
| 420 | ||
| 421 | public void getF hirData(Li st<String> queries, String res ultOutputF ileName) t hrows Data RetrievalE xception, Interrupte dException , IOExcept ion { | |
| 422 | ||
| 423 | // log.info(" ===> getFh irData: " + instance .getBaseUR L()); | |
| 424 | ||
| 425 | Bu ndle bundl eOut = ins tance.getF hirData(qu eries); | |
| 426 | ||
| 427 | // PARSE AND CHECK FIN AL BUNDLE | |
| 428 | IP arser pars er = FhirU tils.newJs onParser() .setPretty Print(true ); | |
| 429 | ||
| 430 | St ring outst r = parser .encodeRes ourceToStr ing(bundle Out); | |
| 431 | // log.info( "\n\nNEW B UNDLE AFTE R BUNDLE(2 ):\n" + ou tstr); | |
| 432 | if (resultOu tputFileNa me != null ) { | |
| 433 | log.info ("\n===> R ESULTING j son WRITTE N TO: " + resultOutp utFileName + "\n"); | |
| 434 | Files.wr ite(Paths. get("./" + resultOut putFileNam e), outstr .getBytes( )); | |
| 435 | } | |
| 436 | ||
| 437 | // --------- ---------- ------- | |
| 438 | // Setup the schema fo r validati ng | |
| 439 | // --------- ---------- ------- | |
| 440 | Fh irValidato r val = Fh irUtils.ge tContext() .newValida tor(); | |
| 441 | va l.setValid ateAgainst StandardSc hema(true) ; | |
| 442 | va l.setValid ateAgainst StandardSc hematron(t rue); | |
| 443 | ||
| 444 | // --------- ---------- ---------- ------ | |
| 445 | // Parsing & Validatin g a Bundle json | |
| 446 | // --------- ---------- ---------- ------ | |
| 447 | Bu ndle bundl e = (Bundl e) parser. parseResou rce(outstr ); | |
| 448 | as sertNotNul l("Bundle should not be null", bundle); | |
| 449 | ||
| 450 | Va lidationRe sult valid ationResul t = val.va lidateWith Result(bun dleOut); | |
| 451 | ||
| 452 | lo g.info(".. ..... VALI DATING: To tal Issues = " + val idationRes ult.getOpe rationOutc ome().getI ssue().siz e() + "... .......... ....\n"); | |
| 453 | fo r (BaseIss ue issue : validatio nResult.ge tOperation Outcome(). getIssue() ) { | |
| 454 | log.erro r(issue.ge tDetailsEl ement().ge tValueAsSt ring()); | |
| 455 | } | |
| 456 | lo g.info(".. .......... .......... .......... .......... .......... .\n"); | |
| 457 | // TODO enabl e validati on when DE 6920 is fi xed | |
| 458 | // assertTrue ("Parsed & Validated : ", valid ationResul t.isSucces sful()); | |
| 459 | } | |
| 460 | ||
| 461 | ||
| 462 | /***** ********** ********** ********* | |
| 463 | * MUL TITHREAD T ESTS | |
| 464 | */ | |
| 465 | /* | |
| 466 | * Thi s test use s FhirData Retriever. getClient( ) to get t he WebClie nt from Fh irClient | |
| 467 | * Eac h each cal l passes a unique pa tient uid and the re turned res ult should contain t he passed uid as exp ectedResul t | |
| 468 | * The test may fail the f irst time with timeo ut due to sync issue s. | |
| 469 | */ | |
| 470 | @Ignor e("This is really a service le vel integr ation test ") | |
| 471 | @Test | |
| 472 | public void mult iThreadPat ients() { | |
| 473 | lo g.info("\n \n======== ========== ===> TESTI NG: Multi- Thread tes tGetPatien t <======= ========== ==== "); | |
| 474 | ||
| 475 | Li st<Callabl e<String>> threadWor kers = new ArrayList <>(); | |
| 476 | tr y{ | |
| 477 | //Be sure to check t his list b eforehand - http:// IP /vpr/all/i ndex/pid/p id | |
| 478 | //Th is may fai l the firs t time wit h timeout due to syn c issues. | |
| 479 | thre adWorkers. add(new We bClientWor ker(instan ce.getClie nt(),1,"pa tient/9E7A ;3","urn:v a:patient: 9E7A:3:3") ); | |
| 480 | thre adWorkers. add(new We bClientWor ker(instan ce.getClie nt(),2,"pa tient/9E7A ;100817"," urn:va:pat ient:9E7A: 100817:100 817")); | |
| 481 | thre adWorkers. add(new We bClientWor ker(instan ce.getClie nt(),3,"pa tient/9E7A ;71","urn: va:patient :9E7A:71:7 1")); | |
| 482 | thre adWorkers. add(new We bClientWor ker(instan ce.getClie nt(),4,"pa tient/9E7A ;239","urn :va:patien t:9E7A:239 :239")); | |
| 483 | thre adWorkers. add(new We bClientWor ker(instan ce.getClie nt(),5,"pa tient/9E7A ;149","urn :va:patien t:9E7A:149 :149")); | |
| 484 | thre adWorkers. add(new We bClientWor ker(instan ce.getClie nt(),6,"pa tient/9E7A ;227","urn :va:patien t:9E7A:227 :227")); | |
| 485 | thre adWorkers. add(new We bClientWor ker(instan ce.getClie nt(),7,"pa tient/9E7A ;167","urn :va:patien t:9E7A:149 :167")); | |
| 486 | thre adWorkers. add(new We bClientWor ker(instan ce.getClie nt(),8,"pa tient/9E7A ;100599"," urn:va:pat ient:9E7A: 100599:100 599")); | |
| 487 | thre adWorkers. add(new We bClientWor ker(instan ce.getClie nt(),9,"pa tient/9E7A ;230","urn :va:patien t:9E7A:230 :230")); | |
| 488 | ||
| 489 | Executor Service ex ecutor = E xecutors.n ewFixedThr eadPool(th readWorker s.size()); | |
| 490 | exec utor.invok eAll(threa dWorkers); | |
| 491 | } | |
| 492 | ca tch(Except ion e) { | |
| 493 | log. error("Fai lure to ex ecute", e) ; | |
| 494 | } | |
| 495 | } | |
| 496 | ||
| 497 | ||
| 498 | class WebClientW orker impl ements Cal lable<Stri ng> { | |
| 499 | pr ivate fina l String q uery; | |
| 500 | pr ivate fina l String e xpectedRes ults; | |
| 501 | pr ivate fina l WebClien t client; | |
| 502 | pr ivate fina l int clie ntNumber; | |
| 503 | ||
| 504 | pu blic WebCl ientWorker (WebClient client, i nt clientN umber, Str ing query, String ex pectedResu lts) { | |
| 505 | this .client = client; | |
| 506 | this .clientNum ber = clie ntNumber; | |
| 507 | this .query = q uery; | |
| 508 | this .expectedR esults = e xpectedRes ults; | |
| 509 | } | |
| 510 | ||
| 511 | @Ove rride | |
| 512 | publ ic String call() { | |
| 513 | try { | |
| 514 | Resp onse respo nse = inst ance.getFh irData(cli ent, query ); | |
| 515 | Inpu tStream in = (InputS tream) res ponse.getE ntity(); | |
| 516 | Stri ng text = IOUtils.to String(in, "UTF-8"); | |
| 517 | // l og.info(cl ientNumber +" : "+tex t); | |
| 518 | if(t ext.indexO f(expected Results) ! = -1) { | |
| 519 | log.in fo(clientN umber+" su ccess : \t " + expect edResults) ; | |
| 520 | // The result sh ould conta in the uni que patien t id of th e call | |
| 521 | assert True(text. contains(e xpectedRes ults)); | |
| 522 | } | |
| 523 | else { | |
| 524 | log.in fo(clientN umber+" fa ilure : \t "+expected Results); | |
| 525 | } | |
| 526 | } catch (Exception e) { | |
| 527 | log. error("Fai lure for W ebClientWo rker : "+e xpectedRes ults, e); | |
| 528 | } | |
| 529 | //Don't need this but we can 't use Run nable when submittin g a collec tion to Ex ecutorServ ice. | |
| 530 | return c lientNumbe r + " fins ihed"; | |
| 531 | } | |
| 532 | ||
| 533 | ||
| 534 | } | |
| 535 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.