Produced by Araxis Merge on 4/5/2017 4:21:45 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 | C:\working_scrub\Unredacted\eHX Code Base\eHX_Bld2_Source Code_CIF_2017-02-14\NHIN_adapter\AdapterEJB\src\test\java\gov\va\med\nhin\adapter\adaptergateway\patientannounce | AnnouncePatientTest.java | Fri Feb 10 15:41:44 2017 UTC |
| 2 | eHX-CIF.zip\eHX-CIF\eHX Code Base\eHX_Bld2_Source Code_CIF_2017-02-14\NHIN_adapter\AdapterEJB\src\test\java\gov\va\med\nhin\adapter\adaptergateway\patientannounce | AnnouncePatientTest.java | Mon Apr 3 14:23:38 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 1886 |
| 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 | * To chan ge this te mplate, ch oose Tools | Templat es | |
| 3 | * and ope n the temp late in th e editor. | |
| 4 | */ | |
| 5 | package go v.va.med.n hin.adapte r.adapterg ateway.pat ientannoun ce; | |
| 6 | ||
| 7 | import jav a.util.*; | |
| 8 | ||
| 9 | import org .junit.*; | |
| 10 | import org .junit.run ner.*; | |
| 11 | import sta tic org.ju nit.Assert .*; | |
| 12 | ||
| 13 | import gov .hhs.fha.n hinc.entit ypatientdi scovery.*; | |
| 14 | import org .jmock.*; | |
| 15 | import org .jmock.int egration.j unit4.*; | |
| 16 | import org .hl7.v3.*; | |
| 17 | ||
| 18 | import gov .va.med.nh in.adapter .announcep atient.*; | |
| 19 | import gov .va.med.nh in.adapter .audit.*; | |
| 20 | import gov .va.med.nh in.adapter .datamanag er.*; | |
| 21 | import gov .va.med.nh in.adapter .facilitym anager.*; | |
| 22 | import gov .va.med.nh in.adapter .permissio n.*; | |
| 23 | import gov .va.med.nh in.adapter .propertyl ookup.*; | |
| 24 | ||
| 25 | ||
| 26 | /** | |
| 27 | * | |
| 28 | * @author DN S VAZQUD | |
| 29 | */ | |
| 30 | @RunWith(J Mock.class ) | |
| 31 | public cla ss Announc ePatientTe st | |
| 32 | { | |
| 33 | privat e Mockery context = new JUnit4 Mockery(); | |
| 34 | ||
| 35 | public AnnounceP atientTest () | |
| 36 | { | |
| 37 | } | |
| 38 | ||
| 39 | /** | |
| 40 | * Tes t of annou ncePatient method, o f class An nouncePati ent. | |
| 41 | */ | |
| 42 | @Test | |
| 43 | public void test AnnouncePa tientNullR equest() | |
| 44 | { | |
| 45 | Sy stem.out.p rintln("an nouncePati entNullReq uest"); | |
| 46 | An nouncePati entType bo dy = null; | |
| 47 | An nouncePati ent instan ce = new A nnouncePat ient(); | |
| 48 | An nouncePati entRespons eType expR esult = ne w Announce PatientRes ponseType( ); | |
| 49 | ex pResult.se tReturn(-1 ); | |
| 50 | An nouncePati entRespons eType resu lt = insta nce.announ cePatient( body); | |
| 51 | as sertEquals (expResult .getReturn (), result .getReturn ()); | |
| 52 | } | |
| 53 | ||
| 54 | @Test | |
| 55 | public void test AnnouncePa tientNoPat ientId() | |
| 56 | { | |
| 57 | Sy stem.out.p rintln("an nouncePati entNoPatie ntId"); | |
| 58 | An nouncePati entType bo dy = new A nnouncePat ientType() ; | |
| 59 | An nouncePati ent instan ce = new A nnouncePat ient(); | |
| 60 | An nouncePati entRespons eType expR esult = ne w Announce PatientRes ponseType( ); | |
| 61 | ex pResult.se tReturn(-1 ); | |
| 62 | An nouncePati entRespons eType resu lt = insta nce.announ cePatient( body); | |
| 63 | as sertEquals (expResult .getReturn (), result .getReturn ()); | |
| 64 | } | |
| 65 | ||
| 66 | @Test | |
| 67 | public void test AnnouncePa tientInval idPatientI d() | |
| 68 | { | |
| 69 | Sy stem.out.p rintln("an nouncePati entInvalid PatientId" ); | |
| 70 | ||
| 71 | fi nal String patientId = "1234"; | |
| 72 | An nouncePati entType bo dy = new A nnouncePat ientType() ; | |
| 73 | bo dy.setPati entId(pati entId); | |
| 74 | ||
| 75 | An nouncePati ent instan ce = new A nnouncePat ient(); | |
| 76 | fi nal DataMa nager data Manager = context.mo ck(DataMan ager.class ); | |
| 77 | fi nal DataQu ery dataQu ery = cont ext.mock(D ataQuery.c lass); | |
| 78 | ||
| 79 | in stance.set DataManage r(dataMana ger); | |
| 80 | ||
| 81 | co ntext.chec king(new E xpectation s() { | |
| 82 | { | |
| 83 | oneOf(da taManager) .getQuery( "Composite .findDemog raphics"); | |
| 84 | will(ret urnValue(d ataQuery)) ; | |
| 85 | oneOf(da taQuery).s etParamete r("icn", p atientId); | |
| 86 | oneOf(da taQuery).g etResults( ); | |
| 87 | will(ret urnValue(n ew ArrayLi st())); | |
| 88 | }} ); | |
| 89 | ||
| 90 | An nouncePati entRespons eType expR esult = ne w Announce PatientRes ponseType( ); | |
| 91 | ex pResult.se tReturn(0) ; | |
| 92 | ||
| 93 | An nouncePati entRespons eType resu lt = insta nce.announ cePatient( body); | |
| 94 | as sertEquals (expResult .getReturn (), result .getReturn ()); | |
| 95 | } | |
| 96 | ||
| 97 | @Test | |
| 98 | public void test AnnouncePa tientPatie ntNotFound () | |
| 99 | { | |
| 100 | Sy stem.out.p rintln("te stAnnounce PatientPat ientNotFou nd"); | |
| 101 | ||
| 102 | fi nal String patientId = "123456 789V123456 "; | |
| 103 | An nouncePati entType bo dy = new A nnouncePat ientType() ; | |
| 104 | bo dy.setPati entId(pati entId); | |
| 105 | ||
| 106 | An nouncePati ent instan ce = new A nnouncePat ient(); | |
| 107 | fi nal DataMa nager data Manager = context.mo ck(DataMan ager.class ); | |
| 108 | fi nal DataQu ery dataQu ery = cont ext.mock(D ataQuery.c lass); | |
| 109 | ||
| 110 | in stance.set DataManage r(dataMana ger); | |
| 111 | ||
| 112 | co ntext.chec king(new E xpectation s() { | |
| 113 | { | |
| 114 | List pat ients = ne w ArrayLis t(); | |
| 115 | ||
| 116 | oneOf(da taManager) .getQuery( "Composite .findDemog raphics"); | |
| 117 | will(ret urnValue(d ataQuery)) ; | |
| 118 | oneOf(da taQuery).s etParamete r("icn", p atientId); | |
| 119 | oneOf(da taQuery).g etResults( ); | |
| 120 | will(ret urnValue(p atients)); | |
| 121 | }} ); | |
| 122 | ||
| 123 | An nouncePati entRespons eType expR esult = ne w Announce PatientRes ponseType( ); | |
| 124 | ex pResult.se tReturn(0) ; | |
| 125 | ||
| 126 | An nouncePati entRespons eType resu lt = insta nce.announ cePatient( body); | |
| 127 | as sertEquals (expResult .getReturn (), result .getReturn ()); | |
| 128 | } | |
| 129 | ||
| 130 | @Test | |
| 131 | public void test AnnouncePa tientNotEn oughInfo() | |
| 132 | { | |
| 133 | Sy stem.out.p rintln("te stAnnounce PatientNot EnoughInfo "); | |
| 134 | ||
| 135 | fi nal String patientId = "123456 789V123456 "; | |
| 136 | An nouncePati entType bo dy = new A nnouncePat ientType() ; | |
| 137 | bo dy.setPati entId(pati entId); | |
| 138 | ||
| 139 | An nouncePati ent instan ce = new A nnouncePat ient(); | |
| 140 | fi nal DataMa nager data Manager = context.mo ck(DataMan ager.class ); | |
| 141 | fi nal DataQu ery dataQu ery = cont ext.mock(D ataQuery.c lass); | |
| 142 | ||
| 143 | in stance.set DataManage r(dataMana ger); | |
| 144 | ||
| 145 | co ntext.chec king(new E xpectation s() { | |
| 146 | { | |
| 147 | Map pati ent = new HashMap(); | |
| 148 | List pat ients = ne w ArrayLis t<Map>(); | |
| 149 | patients .add(patie nt); | |
| 150 | ||
| 151 | oneOf(da taManager) .getQuery( "Composite .findDemog raphics"); | |
| 152 | will(ret urnValue(d ataQuery)) ; | |
| 153 | oneOf(da taQuery).s etParamete r("icn", p atientId); | |
| 154 | oneOf(da taQuery).g etResults( ); | |
| 155 | will(ret urnValue(p atients)); | |
| 156 | }} ); | |
| 157 | ||
| 158 | ||
| 159 | An nouncePati entRespons eType expR esult = ne w Announce PatientRes ponseType( ); | |
| 160 | ex pResult.se tReturn(0) ; | |
| 161 | ||
| 162 | An nouncePati entRespons eType resu lt = insta nce.announ cePatient( body); | |
| 163 | as sertEquals (expResult .getReturn (), result .getReturn ()); | |
| 164 | } | |
| 165 | ||
| 166 | @Test | |
| 167 | public void test AnnouncePa tient() | |
| 168 | { | |
| 169 | Sy stem.out.p rintln("te stAnnounce Patient"); | |
| 170 | ||
| 171 | fi nal String patientId = "123456 7890V12345 6"; | |
| 172 | ||
| 173 | fi nal Map de mographics = new Has hMap() {{ | |
| 174 | put("nam eGiven", n ew ArrayLi st() {{ | |
| 175 | add( "First"); | |
| 176 | add( "Middle"); | |
| 177 | }}); | |
| 178 | put("nam ePrefix", "Prefix"); | |
| 179 | put("nam eSuffix", "Suffix"); | |
| 180 | put("nam eFamily", "Family"); | |
| 181 | put("gen derCode", "gender"); | |
| 182 | put("bir thDate", " 20121022") ; | |
| 183 | put("SSN ", "666668 888"); | |
| 184 | put("MRN ", "123456 7890V12345 6"); | |
| 185 | }} ; | |
| 186 | ||
| 187 | fi nal Map de mographics Ext = new HashMap() {{ | |
| 188 | put("hom eAddressSt reet", new ArrayList () {{ | |
| 189 | add( "1234 Test Lane"); | |
| 190 | add( "Apt 37"); | |
| 191 | }}); | |
| 192 | put("hom eAddressCi ty", "Test City"); | |
| 193 | put("hom eAddressSt ate", "LA" ); | |
| 194 | put("hom eAddressPo stal", "70 124"); | |
| 195 | put("pho neHome", " tel:+1-333 -777-8888" ); | |
| 196 | put("mar italStatus Cod", "S") ; | |
| 197 | put("mul tipleBirth Code", "N" ); | |
| 198 | }} ; | |
| 199 | ||
| 200 | fi nal Map pa tient = ne w HashMap( ) {{ | |
| 201 | put("dem ographics" , demograp hics); | |
| 202 | put("dem ographicsE xt", demog raphicsExt ); | |
| 203 | put("pat ientPrefer redFacilit yNumber", "TEST"); | |
| 204 | put("pat ientPrefer redFacilit yName", "T est Facili ty"); | |
| 205 | }} ; | |
| 206 | ||
| 207 | fi nal List p atients = new ArrayL ist() {{ | |
| 208 | add(pati ent); | |
| 209 | }} ; | |
| 210 | ||
| 211 | fi nal Announ cePatientT ype body = new Annou ncePatient Type(); | |
| 212 | bo dy.setPati entId(pati entId); | |
| 213 | Us erInfoType userInfo = new User InfoType() ; | |
| 214 | us erInfo.set FullName(" Test User" ); | |
| 215 | us erInfo.set UserId("vh aisbtest") ; | |
| 216 | us erInfo.set Authentica tionMethod ("password "); | |
| 217 | us erInfo.set Role("test Role"); | |
| 218 | bo dy.setUser Info(userI nfo); | |
| 219 | ||
| 220 | fi nal Facili ty facilit y = new Fa cility(); | |
| 221 | fa cility.set FacilityNu mber("TEST "); | |
| 222 | fa cility.set FacilityNa me("Test F acility"); | |
| 223 | fa cility.set HomeCommun ityId("1.2 .3.4.5"); | |
| 224 | fa cility.set FullHomeCo mmunityId( "urn:oid:1 .2.3.4.5") ; | |
| 225 | ||
| 226 | fi nal Audit expAudit = new Audit (); | |
| 227 | ex pAudit.set Action("An nounce"); | |
| 228 | ex pAudit.set Details( | |
| 229 | "ssn=" + demograph ics.get("S SN") | |
| 230 | + ", las tName=" + demographi cs.get("na meFamily") | |
| 231 | + ", mid dleName=" + ((List)d emographic s.get("nam eGiven")). get(1) | |
| 232 | + ", giv enName=" + ((List)de mographics .get("name Given")).g et(0) | |
| 233 | + ", pre fix=" + de mographics .get("name Prefix") | |
| 234 | + ", suf fix=" + de mographics .get("name Suffix") | |
| 235 | + ", dob =" + demog raphics.ge t("birthDa te") | |
| 236 | + ", add ress[0]=" + ((List)d emographic sExt.get(" homeAddres sStreet")) .get(0) | |
| 237 | + ", add ress[1]=" + ((List)d emographic sExt.get(" homeAddres sStreet")) .get(1) | |
| 238 | + ", cit y=" + demo graphicsEx t.get("hom eAddressCi ty") | |
| 239 | + ", sta te=" + dem ographicsE xt.get("ho meAddressS tate") | |
| 240 | + ", zip =" + demog raphicsExt .get("home AddressPos tal") | |
| 241 | + ", pho ne=" + dem ographicsE xt.get("ph oneHome") | |
| 242 | + ", gen der=" + de mographics .get("gend erCode") | |
| 243 | + ", mul tiBirth=" + demograp hicsExt.ge t("multipl eBirthCode ") | |
| 244 | + ", mar italStatus =" + demog raphicsExt .get("mari talStatusC ode") | |
| 245 | + ", pat ientId=" + demograph ics.get("M RN") | |
| 246 | + ", hom eCommunity Id=1.2.3.4 .5" | |
| 247 | ); | |
| 248 | ex pAudit.set Organizati onId("urn: oid:1.2.3. 4.5"); | |
| 249 | ex pAudit.set PatientFac ilityName( "Test Faci lity"); | |
| 250 | ex pAudit.set PatientFac ilityNumbe r("TEST"); | |
| 251 | ex pAudit.set PatientGiv enName(((L ist<String >)demograp hics.get(" nameGiven" )).get(0)) ; | |
| 252 | ex pAudit.set PatientId( (String)de mographics .get("MRN" )); | |
| 253 | ex pAudit.set PatientLas tName((Str ing)demogr aphics.get ("nameFami ly")); | |
| 254 | ex pAudit.set PatientSSN ((String)d emographic s.get("SSN ")); | |
| 255 | ex pAudit.set PurposeFor Use("TREAT MENT"); | |
| 256 | ex pAudit.set UserFacili tyName(fac ility.getF acilityNam e()); | |
| 257 | ex pAudit.set UserFacili tyNumber(f acility.ge tFullHomeC ommunityId ()); | |
| 258 | ex pAudit.set UserId(bod y.getUserI nfo().getU serId() + ", CN=" + body.getUs erInfo().g etFullName () + ", O= " + facili ty.getFaci lityName() ); | |
| 259 | ex pAudit.set UserName(b ody.getUse rInfo().ge tFullName( )); | |
| 260 | ex pAudit.set UserRole(" 224608005" ); | |
| 261 | ||
| 262 | fi nal List<M ap> roles = new Arra yList<Map> (); | |
| 263 | Ma p role = n ew HashMap (); | |
| 264 | ro le.put("na me", "ROLE "); | |
| 265 | ro les.add(ro le); | |
| 266 | ||
| 267 | fi nal Respon dingGatewa yPRPAIN201 306UV02Res ponseType response = new Respo ndingGatew ayPRPAIN20 1306UV02Re sponseType (); | |
| 268 | re sponse.get CommunityR esponse(). add(new Co mmunityPRP AIN201306U V02Respons eType()); | |
| 269 | ||
| 270 | An nouncePati ent instan ce = new A nnouncePat ient(); | |
| 271 | ||
| 272 | fi nal DataMa nager data Manager = context.mo ck(DataMan ager.class ); | |
| 273 | fi nal DataQu ery dataQu ery = cont ext.mock(D ataQuery.c lass); | |
| 274 | fi nal Proper tyLookup p ropertyLoo kup = cont ext.mock(P ropertyLoo kup.class) ; | |
| 275 | fi nal AuditM anager aud itManager = context. mock(Audit Manager.cl ass); | |
| 276 | fi nal Facili tyManager facilityMa nager = co ntext.mock (FacilityM anager.cla ss); | |
| 277 | fi nal Entity PatientDis coveryPort Type entit yPatientDi scovery = context.mo ck(EntityP atientDisc overyPortT ype.class) ; | |
| 278 | ||
| 279 | in stance.set DataManage r(dataMana ger); | |
| 280 | in stance.set PropertyLo okup(prope rtyLookup) ; | |
| 281 | in stance.set AuditManag er(auditMa nager); | |
| 282 | in stance.set FacilityMa nager(faci lityManage r); | |
| 283 | in stance.set EntityPati entDiscove ry(entityP atientDisc overy); | |
| 284 | ||
| 285 | co ntext.chec king(new E xpectation s() { | |
| 286 | { | |
| 287 | oneOf(da taManager) .getQuery( "Composite .findDemog raphics"); | |
| 288 | will(ret urnValue(d ataQuery)) ; | |
| 289 | oneOf(da taQuery).s etParamete r("icn", p atientId); | |
| 290 | oneOf(da taQuery).g etResults( ); | |
| 291 | will(ret urnValue(p atients)); | |
| 292 | ||
| 293 | oneOf(da taManager) .getQuery( "STS.looku pSNOMED"); | |
| 294 | will(ret urnValue(d ataQuery)) ; | |
| 295 | oneOf(da taQuery).s etParamete r("code", "224608005 "); | |
| 296 | oneOf(da taQuery).g etResults( ); | |
| 297 | will(ret urnValue(r oles)); | |
| 298 | ||
| 299 | oneOf(au ditManager ).storeAud it(with(eq ual(expAud it))); | |
| 300 | ||
| 301 | oneOf(en tityPatien tDiscovery ).respondi ngGatewayP RPAIN20130 5UV02(with (any(Respo ndingGatew ayPRPAIN20 1305UV02Re questType. class))); | |
| 302 | will(ret urnValue(r esponse)); | |
| 303 | ||
| 304 | allowing (propertyL ookup).get Property(w ith(any(St ring.class ))); | |
| 305 | will(ret urnValue(" property") ); | |
| 306 | ||
| 307 | allowing (facilityM anager).ge tFacilityB yFacilityN umber("VA" ); | |
| 308 | will(ret urnValue(f acility)); | |
| 309 | }} ); | |
| 310 | ||
| 311 | An nouncePati entRespons eType expR esult = ne w Announce PatientRes ponseType( ); | |
| 312 | ex pResult.se tReturn(1) ; | |
| 313 | ||
| 314 | An nouncePati entRespons eType resu lt = insta nce.announ cePatient( body); | |
| 315 | as sertEquals (expResult .getReturn (), result .getReturn ()); | |
| 316 | } | |
| 317 | ||
| 318 | @Test | |
| 319 | public void test AnnouncePa tientNoMid dleName() | |
| 320 | { | |
| 321 | Sy stem.out.p rintln("te stAnnounce PatientNoM iddleName" ); | |
| 322 | ||
| 323 | fi nal String patientId = "123456 7890V12345 6"; | |
| 324 | ||
| 325 | fi nal Map de mographics = new Has hMap() {{ | |
| 326 | put("nam eGiven", n ew ArrayLi st() {{ | |
| 327 | add( "First"); | |
| 328 | }}); | |
| 329 | put("nam ePrefix", "Prefix"); | |
| 330 | put("nam eSuffix", "Suffix"); | |
| 331 | put("nam eFamily", "Family"); | |
| 332 | put("gen derCode", "gender"); | |
| 333 | put("bir thDate", " 20121022") ; | |
| 334 | put("SSN ", "666668 888"); | |
| 335 | put("MRN ", "123456 7890V12345 6"); | |
| 336 | }} ; | |
| 337 | ||
| 338 | fi nal Map de mographics Ext = new HashMap() {{ | |
| 339 | put("hom eAddressSt reet", new ArrayList () {{ | |
| 340 | add( "1234 Test Lane"); | |
| 341 | add( "Apt 37"); | |
| 342 | }}); | |
| 343 | put("hom eAddressCi ty", "Test City"); | |
| 344 | put("hom eAddressSt ate", "LA" ); | |
| 345 | put("hom eAddressPo stal", "70 124"); | |
| 346 | put("pho neHome", " tel:+1-333 -777-8888" ); | |
| 347 | put("mar italStatus Cod", "S") ; | |
| 348 | put("mul tipleBirth Code", "N" ); | |
| 349 | }} ; | |
| 350 | ||
| 351 | fi nal Map pa tient = ne w HashMap( ) {{ | |
| 352 | put("dem ographics" , demograp hics); | |
| 353 | put("dem ographicsE xt", demog raphicsExt ); | |
| 354 | put("pat ientPrefer redFacilit yNumber", "TEST"); | |
| 355 | put("pat ientPrefer redFacilit yName", "T est Facili ty"); | |
| 356 | }} ; | |
| 357 | ||
| 358 | fi nal List p atients = new ArrayL ist() {{ | |
| 359 | add(pati ent); | |
| 360 | }} ; | |
| 361 | ||
| 362 | fi nal Announ cePatientT ype body = new Annou ncePatient Type(); | |
| 363 | bo dy.setPati entId(pati entId); | |
| 364 | Us erInfoType userInfo = new User InfoType() ; | |
| 365 | us erInfo.set FullName(" Test User" ); | |
| 366 | us erInfo.set UserId("vh aisbtest") ; | |
| 367 | us erInfo.set Authentica tionMethod ("password "); | |
| 368 | us erInfo.set Role("test Role"); | |
| 369 | bo dy.setUser Info(userI nfo); | |
| 370 | ||
| 371 | fi nal Facili ty facilit y = new Fa cility(); | |
| 372 | fa cility.set FacilityNu mber("TEST "); | |
| 373 | fa cility.set FacilityNa me("Test F acility"); | |
| 374 | fa cility.set HomeCommun ityId("1.2 .3.4.5"); | |
| 375 | fa cility.set FullHomeCo mmunityId( "urn:oid:1 .2.3.4.5") ; | |
| 376 | ||
| 377 | fi nal Audit expAudit = new Audit (); | |
| 378 | ex pAudit.set Action("An nounce"); | |
| 379 | ex pAudit.set Details( | |
| 380 | "ssn=" + demograph ics.get("S SN") | |
| 381 | + ", las tName=" + demographi cs.get("na meFamily") | |
| 382 | + ", mid dleName=" | |
| 383 | + ", giv enName=" + ((List)de mographics .get("name Given")).g et(0) | |
| 384 | + ", pre fix=" + de mographics .get("name Prefix") | |
| 385 | + ", suf fix=" + de mographics .get("name Suffix") | |
| 386 | + ", dob =" + demog raphics.ge t("birthDa te") | |
| 387 | + ", add ress[0]=" + ((List)d emographic sExt.get(" homeAddres sStreet")) .get(0) | |
| 388 | + ", add ress[1]=" + ((List)d emographic sExt.get(" homeAddres sStreet")) .get(1) | |
| 389 | + ", cit y=" + demo graphicsEx t.get("hom eAddressCi ty") | |
| 390 | + ", sta te=" + dem ographicsE xt.get("ho meAddressS tate") | |
| 391 | + ", zip =" + demog raphicsExt .get("home AddressPos tal") | |
| 392 | + ", pho ne=" + dem ographicsE xt.get("ph oneHome") | |
| 393 | + ", gen der=" + de mographics .get("gend erCode") | |
| 394 | + ", mul tiBirth=" + demograp hicsExt.ge t("multipl eBirthCode ") | |
| 395 | + ", mar italStatus =" + demog raphicsExt .get("mari talStatusC ode") | |
| 396 | + ", pat ientId=" + demograph ics.get("M RN") | |
| 397 | + ", hom eCommunity Id=1.2.3.4 .5" | |
| 398 | ); | |
| 399 | ex pAudit.set Organizati onId("urn: oid:1.2.3. 4.5"); | |
| 400 | ex pAudit.set PatientFac ilityName( "Test Faci lity"); | |
| 401 | ex pAudit.set PatientFac ilityNumbe r("TEST"); | |
| 402 | ex pAudit.set PatientGiv enName(((L ist<String >)demograp hics.get(" nameGiven" )).get(0)) ; | |
| 403 | ex pAudit.set PatientId( (String)de mographics .get("MRN" )); | |
| 404 | ex pAudit.set PatientLas tName((Str ing)demogr aphics.get ("nameFami ly")); | |
| 405 | ex pAudit.set PatientSSN ((String)d emographic s.get("SSN ")); | |
| 406 | ex pAudit.set PurposeFor Use("TREAT MENT"); | |
| 407 | ex pAudit.set UserFacili tyName(fac ility.getF acilityNam e()); | |
| 408 | ex pAudit.set UserFacili tyNumber(f acility.ge tFullHomeC ommunityId ()); | |
| 409 | ex pAudit.set UserId(bod y.getUserI nfo().getU serId() + ", CN=" + body.getUs erInfo().g etFullName () + ", O= " + facili ty.getFaci lityName() ); | |
| 410 | ex pAudit.set UserName(b ody.getUse rInfo().ge tFullName( )); | |
| 411 | ex pAudit.set UserRole(" 224608005" ); | |
| 412 | ||
| 413 | fi nal List<M ap> roles = new Arra yList<Map> (); | |
| 414 | Ma p role = n ew HashMap (); | |
| 415 | ro le.put("na me", "ROLE "); | |
| 416 | ro les.add(ro le); | |
| 417 | ||
| 418 | fi nal Respon dingGatewa yPRPAIN201 306UV02Res ponseType response = new Respo ndingGatew ayPRPAIN20 1306UV02Re sponseType (); | |
| 419 | re sponse.get CommunityR esponse(). add(new Co mmunityPRP AIN201306U V02Respons eType()); | |
| 420 | ||
| 421 | An nouncePati ent instan ce = new A nnouncePat ient(); | |
| 422 | ||
| 423 | fi nal DataMa nager data Manager = context.mo ck(DataMan ager.class ); | |
| 424 | fi nal DataQu ery dataQu ery = cont ext.mock(D ataQuery.c lass); | |
| 425 | fi nal Proper tyLookup p ropertyLoo kup = cont ext.mock(P ropertyLoo kup.class) ; | |
| 426 | fi nal AuditM anager aud itManager = context. mock(Audit Manager.cl ass); | |
| 427 | fi nal Facili tyManager facilityMa nager = co ntext.mock (FacilityM anager.cla ss); | |
| 428 | fi nal Entity PatientDis coveryPort Type entit yPatientDi scovery = context.mo ck(EntityP atientDisc overyPortT ype.class) ; | |
| 429 | ||
| 430 | in stance.set DataManage r(dataMana ger); | |
| 431 | in stance.set PropertyLo okup(prope rtyLookup) ; | |
| 432 | in stance.set AuditManag er(auditMa nager); | |
| 433 | in stance.set FacilityMa nager(faci lityManage r); | |
| 434 | in stance.set EntityPati entDiscove ry(entityP atientDisc overy); | |
| 435 | ||
| 436 | co ntext.chec king(new E xpectation s() { | |
| 437 | { | |
| 438 | oneOf(da taManager) .getQuery( "Composite .findDemog raphics"); | |
| 439 | will(ret urnValue(d ataQuery)) ; | |
| 440 | oneOf(da taQuery).s etParamete r("icn", p atientId); | |
| 441 | oneOf(da taQuery).g etResults( ); | |
| 442 | will(ret urnValue(p atients)); | |
| 443 | ||
| 444 | oneOf(da taManager) .getQuery( "STS.looku pSNOMED"); | |
| 445 | will(ret urnValue(d ataQuery)) ; | |
| 446 | oneOf(da taQuery).s etParamete r("code", "224608005 "); | |
| 447 | oneOf(da taQuery).g etResults( ); | |
| 448 | will(ret urnValue(r oles)); | |
| 449 | ||
| 450 | oneOf(au ditManager ).storeAud it(with(eq ual(expAud it))); | |
| 451 | ||
| 452 | oneOf(en tityPatien tDiscovery ).respondi ngGatewayP RPAIN20130 5UV02(with (any(Respo ndingGatew ayPRPAIN20 1305UV02Re questType. class))); | |
| 453 | will(ret urnValue(r esponse)); | |
| 454 | ||
| 455 | allowing (propertyL ookup).get Property(w ith(any(St ring.class ))); | |
| 456 | will(ret urnValue(" property") ); | |
| 457 | ||
| 458 | allowing (facilityM anager).ge tFacilityB yFacilityN umber("VA" ); | |
| 459 | will(ret urnValue(f acility)); | |
| 460 | }} ); | |
| 461 | ||
| 462 | An nouncePati entRespons eType expR esult = ne w Announce PatientRes ponseType( ); | |
| 463 | ex pResult.se tReturn(1) ; | |
| 464 | ||
| 465 | An nouncePati entRespons eType resu lt = insta nce.announ cePatient( body); | |
| 466 | as sertEquals (expResult .getReturn (), result .getReturn ()); | |
| 467 | } | |
| 468 | ||
| 469 | @Test | |
| 470 | public void test AnnouncePa tientTarge ted() | |
| 471 | { | |
| 472 | Sy stem.out.p rintln("te stAnnounce PatientTar geted"); | |
| 473 | ||
| 474 | fi nal String patientId = "123456 7890V12345 6"; | |
| 475 | ||
| 476 | fi nal Map de mographics = new Has hMap() {{ | |
| 477 | put("nam eGiven", n ew ArrayLi st() {{ | |
| 478 | add( "First"); | |
| 479 | add( "Middle"); | |
| 480 | }}); | |
| 481 | put("nam ePrefix", "Prefix"); | |
| 482 | put("nam eSuffix", "Suffix"); | |
| 483 | put("nam eFamily", "Family"); | |
| 484 | put("gen derCode", "gender"); | |
| 485 | put("bir thDate", " 20121022") ; | |
| 486 | put("SSN ", "666668 888"); | |
| 487 | put("MRN ", "123456 7890V12345 6"); | |
| 488 | }} ; | |
| 489 | ||
| 490 | fi nal Map de mographics Ext = new HashMap() {{ | |
| 491 | put("hom eAddressSt reet", new ArrayList () {{ | |
| 492 | add( "1234 Test Lane"); | |
| 493 | add( "Apt 37"); | |
| 494 | }}); | |
| 495 | put("hom eAddressCi ty", "Test City"); | |
| 496 | put("hom eAddressSt ate", "LA" ); | |
| 497 | put("hom eAddressPo stal", "70 124"); | |
| 498 | put("pho neHome", " tel:+1-333 -777-8888" ); | |
| 499 | put("mar italStatus Cod", "S") ; | |
| 500 | put("mul tipleBirth Code", "N" ); | |
| 501 | }} ; | |
| 502 | ||
| 503 | fi nal Map pa tient = ne w HashMap( ) {{ | |
| 504 | put("dem ographics" , demograp hics); | |
| 505 | put("dem ographicsE xt", demog raphicsExt ); | |
| 506 | put("pat ientPrefer redFacilit yNumber", "TEST"); | |
| 507 | put("pat ientPrefer redFacilit yName", "T est Facili ty"); | |
| 508 | }} ; | |
| 509 | ||
| 510 | fi nal List p atients = new ArrayL ist() {{ | |
| 511 | add(pati ent); | |
| 512 | }} ; | |
| 513 | ||
| 514 | fi nal Announ cePatientT ype body = new Annou ncePatient Type(); | |
| 515 | bo dy.setPati entId(pati entId); | |
| 516 | Us erInfoType userInfo = new User InfoType() ; | |
| 517 | us erInfo.set FullName(" Test User" ); | |
| 518 | us erInfo.set UserId("vh aisbtest") ; | |
| 519 | us erInfo.set Authentica tionMethod ("password "); | |
| 520 | us erInfo.set Role("test Role"); | |
| 521 | bo dy.setUser Info(userI nfo); | |
| 522 | An nouncePati entType.Fa cilities f acilities = new Anno uncePatien tType.Faci lities(); | |
| 523 | bo dy.setFaci lities(fac ilities); | |
| 524 | fi nal String testFacil ity = "200 TEST"; | |
| 525 | fa cilities.g etFacility ().add(tes tFacility) ; | |
| 526 | ||
| 527 | fi nal Facili ty facilit y = new Fa cility(); | |
| 528 | fa cility.set FacilityNu mber("TEST "); | |
| 529 | fa cility.set FacilityNa me("Test F acility"); | |
| 530 | fa cility.set HomeCommun ityId("1.2 .3.4.5"); | |
| 531 | fa cility.set FullHomeCo mmunityId( "urn:oid:1 .2.3.4.5") ; | |
| 532 | ||
| 533 | fi nal Audit expAudit = new Audit (); | |
| 534 | ex pAudit.set Action("An nounce"); | |
| 535 | ex pAudit.set Details( | |
| 536 | "ssn=" + demograph ics.get("S SN") | |
| 537 | + ", las tName=" + demographi cs.get("na meFamily") | |
| 538 | + ", mid dleName=" + ((List)d emographic s.get("nam eGiven")). get(1) | |
| 539 | + ", giv enName=" + ((List)de mographics .get("name Given")).g et(0) | |
| 540 | + ", pre fix=" + de mographics .get("name Prefix") | |
| 541 | + ", suf fix=" + de mographics .get("name Suffix") | |
| 542 | + ", dob =" + demog raphics.ge t("birthDa te") | |
| 543 | + ", add ress[0]=" + ((List)d emographic sExt.get(" homeAddres sStreet")) .get(0) | |
| 544 | + ", add ress[1]=" + ((List)d emographic sExt.get(" homeAddres sStreet")) .get(1) | |
| 545 | + ", cit y=" + demo graphicsEx t.get("hom eAddressCi ty") | |
| 546 | + ", sta te=" + dem ographicsE xt.get("ho meAddressS tate") | |
| 547 | + ", zip =" + demog raphicsExt .get("home AddressPos tal") | |
| 548 | + ", pho ne=" + dem ographicsE xt.get("ph oneHome") | |
| 549 | + ", gen der=" + de mographics .get("gend erCode") | |
| 550 | + ", mul tiBirth=" + demograp hicsExt.ge t("multipl eBirthCode ") | |
| 551 | + ", mar italStatus =" + demog raphicsExt .get("mari talStatusC ode") | |
| 552 | + ", pat ientId=" + demograph ics.get("M RN") | |
| 553 | + ", hom eCommunity Id=1.2.3.4 .5" | |
| 554 | ); | |
| 555 | ex pAudit.set Organizati onId("urn: oid:1.2.3. 4.5"); | |
| 556 | ex pAudit.set PatientFac ilityName( "Test Faci lity"); | |
| 557 | ex pAudit.set PatientFac ilityNumbe r("TEST"); | |
| 558 | ex pAudit.set PatientGiv enName(((L ist<String >)demograp hics.get(" nameGiven" )).get(0)) ; | |
| 559 | ex pAudit.set PatientId( (String)de mographics .get("MRN" )); | |
| 560 | ex pAudit.set PatientLas tName((Str ing)demogr aphics.get ("nameFami ly")); | |
| 561 | ex pAudit.set PatientSSN ((String)d emographic s.get("SSN ")); | |
| 562 | ex pAudit.set PurposeFor Use("TREAT MENT"); | |
| 563 | ex pAudit.set UserFacili tyName(fac ility.getF acilityNam e()); | |
| 564 | ex pAudit.set UserFacili tyNumber(f acility.ge tFullHomeC ommunityId ()); | |
| 565 | ex pAudit.set UserId(bod y.getUserI nfo().getU serId() + ", CN=" + body.getUs erInfo().g etFullName () + ", O= " + facili ty.getFaci lityName() ); | |
| 566 | ex pAudit.set UserName(b ody.getUse rInfo().ge tFullName( )); | |
| 567 | ex pAudit.set UserRole(" 224608005" ); | |
| 568 | ||
| 569 | fi nal List<M ap> roles = new Arra yList<Map> (); | |
| 570 | Ma p role = n ew HashMap (); | |
| 571 | ro le.put("na me", "ROLE "); | |
| 572 | ro les.add(ro le); | |
| 573 | ||
| 574 | fi nal Respon dingGatewa yPRPAIN201 306UV02Res ponseType response = new Respo ndingGatew ayPRPAIN20 1306UV02Re sponseType (); | |
| 575 | re sponse.get CommunityR esponse(). add(new Co mmunityPRP AIN201306U V02Respons eType()); | |
| 576 | ||
| 577 | An nouncePati ent instan ce = new A nnouncePat ient(); | |
| 578 | ||
| 579 | fi nal DataMa nager data Manager = context.mo ck(DataMan ager.class ); | |
| 580 | fi nal DataQu ery dataQu ery = cont ext.mock(D ataQuery.c lass); | |
| 581 | fi nal Proper tyLookup p ropertyLoo kup = cont ext.mock(P ropertyLoo kup.class) ; | |
| 582 | fi nal AuditM anager aud itManager = context. mock(Audit Manager.cl ass); | |
| 583 | fi nal Facili tyManager facilityMa nager = co ntext.mock (FacilityM anager.cla ss); | |
| 584 | fi nal Entity PatientDis coveryPort Type entit yPatientDi scovery = context.mo ck(EntityP atientDisc overyPortT ype.class) ; | |
| 585 | ||
| 586 | in stance.set DataManage r(dataMana ger); | |
| 587 | in stance.set PropertyLo okup(prope rtyLookup) ; | |
| 588 | in stance.set AuditManag er(auditMa nager); | |
| 589 | in stance.set FacilityMa nager(faci lityManage r); | |
| 590 | in stance.set EntityPati entDiscove ry(entityP atientDisc overy); | |
| 591 | ||
| 592 | co ntext.chec king(new E xpectation s() { | |
| 593 | { | |
| 594 | oneOf(da taManager) .getQuery( "Composite .findDemog raphics"); | |
| 595 | will(ret urnValue(d ataQuery)) ; | |
| 596 | oneOf(da taQuery).s etParamete r("icn", p atientId); | |
| 597 | oneOf(da taQuery).g etResults( ); | |
| 598 | will(ret urnValue(p atients)); | |
| 599 | ||
| 600 | oneOf(da taManager) .getQuery( "STS.looku pSNOMED"); | |
| 601 | will(ret urnValue(d ataQuery)) ; | |
| 602 | oneOf(da taQuery).s etParamete r("code", "224608005 "); | |
| 603 | oneOf(da taQuery).g etResults( ); | |
| 604 | will(ret urnValue(r oles)); | |
| 605 | ||
| 606 | oneOf(au ditManager ).storeAud it(with(eq ual(expAud it))); | |
| 607 | ||
| 608 | oneOf(en tityPatien tDiscovery ).respondi ngGatewayP RPAIN20130 5UV02(with (any(Respo ndingGatew ayPRPAIN20 1305UV02Re questType. class))); | |
| 609 | will(ret urnValue(r esponse)); | |
| 610 | ||
| 611 | allowing (propertyL ookup).get Property(w ith(any(St ring.class ))); | |
| 612 | will(ret urnValue(" property") ); | |
| 613 | ||
| 614 | oneOf(fa cilityMana ger).getFa cilityByFa cilityNumb er(testFac ility); | |
| 615 | will(ret urnValue(f acility)); | |
| 616 | ||
| 617 | allowing (facilityM anager).ge tFacilityB yFacilityN umber("VA" ); | |
| 618 | will(ret urnValue(f acility)); | |
| 619 | }} ); | |
| 620 | ||
| 621 | An nouncePati entRespons eType expR esult = ne w Announce PatientRes ponseType( ); | |
| 622 | ex pResult.se tReturn(1) ; | |
| 623 | ||
| 624 | An nouncePati entRespons eType resu lt = insta nce.announ cePatient( body); | |
| 625 | as sertEquals (expResult .getReturn (), result .getReturn ()); | |
| 626 | } | |
| 627 | ||
| 628 | @Test | |
| 629 | public void test AnnouncePa tientTarge tedInvalid FacilityNu mber() | |
| 630 | { | |
| 631 | Sy stem.out.p rintln("te stAnnounce PatientTar getedInval idFacility Number"); | |
| 632 | ||
| 633 | fi nal String patientId = "123456 7890V12345 6"; | |
| 634 | ||
| 635 | fi nal Map de mographics = new Has hMap() {{ | |
| 636 | put("nam eGiven", n ew ArrayLi st() {{ | |
| 637 | add( "First"); | |
| 638 | add( "Middle"); | |
| 639 | }}); | |
| 640 | put("nam ePrefix", "Prefix"); | |
| 641 | put("nam eSuffix", "Suffix"); | |
| 642 | put("nam eFamily", "Family"); | |
| 643 | put("gen derCode", "gender"); | |
| 644 | put("bir thDate", " 20121022") ; | |
| 645 | put("SSN ", "666668 888"); | |
| 646 | put("MRN ", "123456 7890V12345 6"); | |
| 647 | }} ; | |
| 648 | ||
| 649 | fi nal Map de mographics Ext = new HashMap() {{ | |
| 650 | put("hom eAddressSt reet", new ArrayList () {{ | |
| 651 | add( "1234 Test Lane"); | |
| 652 | add( "Apt 37"); | |
| 653 | }}); | |
| 654 | put("hom eAddressCi ty", "Test City"); | |
| 655 | put("hom eAddressSt ate", "LA" ); | |
| 656 | put("hom eAddressPo stal", "70 124"); | |
| 657 | put("pho neHome", " tel:+1-333 -777-8888" ); | |
| 658 | put("mar italStatus Cod", "S") ; | |
| 659 | put("mul tipleBirth Code", "N" ); | |
| 660 | }} ; | |
| 661 | ||
| 662 | fi nal Map pa tient = ne w HashMap( ) {{ | |
| 663 | put("dem ographics" , demograp hics); | |
| 664 | put("dem ographicsE xt", demog raphicsExt ); | |
| 665 | put("pat ientPrefer redFacilit yNumber", "TEST"); | |
| 666 | put("pat ientPrefer redFacilit yName", "T est Facili ty"); | |
| 667 | }} ; | |
| 668 | ||
| 669 | fi nal List p atients = new ArrayL ist() {{ | |
| 670 | add(pati ent); | |
| 671 | }} ; | |
| 672 | ||
| 673 | fi nal Announ cePatientT ype body = new Annou ncePatient Type(); | |
| 674 | bo dy.setPati entId(pati entId); | |
| 675 | Us erInfoType userInfo = new User InfoType() ; | |
| 676 | us erInfo.set FullName(" Test User" ); | |
| 677 | us erInfo.set UserId("vh aisbtest") ; | |
| 678 | us erInfo.set Authentica tionMethod ("password "); | |
| 679 | us erInfo.set Role("test Role"); | |
| 680 | bo dy.setUser Info(userI nfo); | |
| 681 | An nouncePati entType.Fa cilities f acilities = new Anno uncePatien tType.Faci lities(); | |
| 682 | bo dy.setFaci lities(fac ilities); | |
| 683 | fi nal String testFacil ity = "200 TEST"; | |
| 684 | fa cilities.g etFacility ().add(tes tFacility) ; | |
| 685 | ||
| 686 | fi nal Facili ty facilit y = new Fa cility(); | |
| 687 | fa cility.set FacilityNu mber("TEST "); | |
| 688 | fa cility.set FacilityNa me("Test F acility"); | |
| 689 | fa cility.set HomeCommun ityId("1.2 .3.4.5"); | |
| 690 | fa cility.set FullHomeCo mmunityId( "urn:oid:1 .2.3.4.5") ; | |
| 691 | ||
| 692 | fi nal Audit expAudit = new Audit (); | |
| 693 | ex pAudit.set Action("An nounce"); | |
| 694 | ex pAudit.set Details( | |
| 695 | "ssn=" + demograph ics.get("S SN") | |
| 696 | + ", las tName=" + demographi cs.get("na meFamily") | |
| 697 | + ", mid dleName=" + ((List)d emographic s.get("nam eGiven")). get(1) | |
| 698 | + ", giv enName=" + ((List)de mographics .get("name Given")).g et(0) | |
| 699 | + ", pre fix=" + de mographics .get("name Prefix") | |
| 700 | + ", suf fix=" + de mographics .get("name Suffix") | |
| 701 | + ", dob =" + demog raphics.ge t("birthDa te") | |
| 702 | + ", add ress[0]=" + ((List)d emographic sExt.get(" homeAddres sStreet")) .get(0) | |
| 703 | + ", add ress[1]=" + ((List)d emographic sExt.get(" homeAddres sStreet")) .get(1) | |
| 704 | + ", cit y=" + demo graphicsEx t.get("hom eAddressCi ty") | |
| 705 | + ", sta te=" + dem ographicsE xt.get("ho meAddressS tate") | |
| 706 | + ", zip =" + demog raphicsExt .get("home AddressPos tal") | |
| 707 | + ", pho ne=" + dem ographicsE xt.get("ph oneHome") | |
| 708 | + ", gen der=" + de mographics .get("gend erCode") | |
| 709 | + ", mul tiBirth=" + demograp hicsExt.ge t("multipl eBirthCode ") | |
| 710 | + ", mar italStatus =" + demog raphicsExt .get("mari talStatusC ode") | |
| 711 | + ", pat ientId=" + demograph ics.get("M RN") | |
| 712 | + ", hom eCommunity Id=1.2.3.4 .5" | |
| 713 | ); | |
| 714 | ex pAudit.set Organizati onId("urn: oid:1.2.3. 4.5"); | |
| 715 | ex pAudit.set PatientFac ilityName( "Test Faci lity"); | |
| 716 | ex pAudit.set PatientFac ilityNumbe r("TEST"); | |
| 717 | ex pAudit.set PatientGiv enName(((L ist<String >)demograp hics.get(" nameGiven" )).get(0)) ; | |
| 718 | ex pAudit.set PatientId( (String)de mographics .get("MRN" )); | |
| 719 | ex pAudit.set PatientLas tName((Str ing)demogr aphics.get ("nameFami ly")); | |
| 720 | ex pAudit.set PatientSSN ((String)d emographic s.get("SSN ")); | |
| 721 | ex pAudit.set PurposeFor Use("TREAT MENT"); | |
| 722 | ex pAudit.set UserFacili tyName(fac ility.getF acilityNam e()); | |
| 723 | ex pAudit.set UserFacili tyNumber(f acility.ge tFullHomeC ommunityId ()); | |
| 724 | ex pAudit.set UserId(bod y.getUserI nfo().getU serId() + ", CN=" + body.getUs erInfo().g etFullName () + ", O= " + facili ty.getFaci lityName() ); | |
| 725 | ex pAudit.set UserName(b ody.getUse rInfo().ge tFullName( )); | |
| 726 | ex pAudit.set UserRole(" 224608005" ); | |
| 727 | ||
| 728 | fi nal List<M ap> roles = new Arra yList<Map> (); | |
| 729 | Ma p role = n ew HashMap (); | |
| 730 | ro le.put("na me", "ROLE "); | |
| 731 | ro les.add(ro le); | |
| 732 | ||
| 733 | fi nal Respon dingGatewa yPRPAIN201 306UV02Res ponseType response = new Respo ndingGatew ayPRPAIN20 1306UV02Re sponseType (); | |
| 734 | re sponse.get CommunityR esponse(). add(new Co mmunityPRP AIN201306U V02Respons eType()); | |
| 735 | ||
| 736 | An nouncePati ent instan ce = new A nnouncePat ient(); | |
| 737 | ||
| 738 | fi nal DataMa nager data Manager = context.mo ck(DataMan ager.class ); | |
| 739 | fi nal DataQu ery dataQu ery = cont ext.mock(D ataQuery.c lass); | |
| 740 | fi nal Proper tyLookup p ropertyLoo kup = cont ext.mock(P ropertyLoo kup.class) ; | |
| 741 | fi nal AuditM anager aud itManager = context. mock(Audit Manager.cl ass); | |
| 742 | fi nal Facili tyManager facilityMa nager = co ntext.mock (FacilityM anager.cla ss); | |
| 743 | fi nal Entity PatientDis coveryPort Type entit yPatientDi scovery = context.mo ck(EntityP atientDisc overyPortT ype.class) ; | |
| 744 | ||
| 745 | in stance.set DataManage r(dataMana ger); | |
| 746 | in stance.set PropertyLo okup(prope rtyLookup) ; | |
| 747 | in stance.set AuditManag er(auditMa nager); | |
| 748 | in stance.set FacilityMa nager(faci lityManage r); | |
| 749 | in stance.set EntityPati entDiscove ry(entityP atientDisc overy); | |
| 750 | ||
| 751 | co ntext.chec king(new E xpectation s() { | |
| 752 | { | |
| 753 | oneOf(da taManager) .getQuery( "Composite .findDemog raphics"); | |
| 754 | will(ret urnValue(d ataQuery)) ; | |
| 755 | oneOf(da taQuery).s etParamete r("icn", p atientId); | |
| 756 | oneOf(da taQuery).g etResults( ); | |
| 757 | will(ret urnValue(p atients)); | |
| 758 | ||
| 759 | oneOf(da taManager) .getQuery( "STS.looku pSNOMED"); | |
| 760 | will(ret urnValue(d ataQuery)) ; | |
| 761 | oneOf(da taQuery).s etParamete r("code", "224608005 "); | |
| 762 | oneOf(da taQuery).g etResults( ); | |
| 763 | will(ret urnValue(r oles)); | |
| 764 | ||
| 765 | oneOf(au ditManager ).storeAud it(with(eq ual(expAud it))); | |
| 766 | ||
| 767 | never(en tityPatien tDiscovery ).respondi ngGatewayP RPAIN20130 5UV02(with (any(Respo ndingGatew ayPRPAIN20 1305UV02Re questType. class))); | |
| 768 | ||
| 769 | allowing (propertyL ookup).get Property(w ith(any(St ring.class ))); | |
| 770 | will(ret urnValue(" property") ); | |
| 771 | ||
| 772 | oneOf(fa cilityMana ger).getFa cilityByFa cilityNumb er(testFac ility); | |
| 773 | will(ret urnValue(n ull)); | |
| 774 | ||
| 775 | allowing (facilityM anager).ge tFacilityB yFacilityN umber("VA" ); | |
| 776 | will(ret urnValue(f acility)); | |
| 777 | }} ); | |
| 778 | ||
| 779 | An nouncePati entRespons eType expR esult = ne w Announce PatientRes ponseType( ); | |
| 780 | ex pResult.se tReturn(0) ; | |
| 781 | ||
| 782 | An nouncePati entRespons eType resu lt = insta nce.announ cePatient( body); | |
| 783 | as sertEquals (expResult .getReturn (), result .getReturn ()); | |
| 784 | } | |
| 785 | ||
| 786 | @Test | |
| 787 | public void test AnnouncePa tientTarge tedEntityP DThrowsExc eption() | |
| 788 | { | |
| 789 | Sy stem.out.p rintln("te stAnnounce PatientTar getedEntit yPDThrowsE xception") ; | |
| 790 | ||
| 791 | fi nal String patientId = "123456 7890V12345 6"; | |
| 792 | ||
| 793 | fi nal Map de mographics = new Has hMap() {{ | |
| 794 | put("nam eGiven", n ew ArrayLi st() {{ | |
| 795 | add( "First"); | |
| 796 | add( "Middle"); | |
| 797 | }}); | |
| 798 | put("nam ePrefix", "Prefix"); | |
| 799 | put("nam eSuffix", "Suffix"); | |
| 800 | put("nam eFamily", "Family"); | |
| 801 | put("gen derCode", "gender"); | |
| 802 | put("bir thDate", " 20121022") ; | |
| 803 | put("SSN ", "666668 888"); | |
| 804 | put("MRN ", "123456 7890V12345 6"); | |
| 805 | }} ; | |
| 806 | ||
| 807 | fi nal Map de mographics Ext = new HashMap() {{ | |
| 808 | put("hom eAddressSt reet", new ArrayList () {{ | |
| 809 | add( "1234 Test Lane"); | |
| 810 | add( "Apt 37"); | |
| 811 | }}); | |
| 812 | put("hom eAddressCi ty", "Test City"); | |
| 813 | put("hom eAddressSt ate", "LA" ); | |
| 814 | put("hom eAddressPo stal", "70 124"); | |
| 815 | put("pho neHome", " tel:+1-333 -777-8888" ); | |
| 816 | put("mar italStatus Cod", "S") ; | |
| 817 | put("mul tipleBirth Code", "N" ); | |
| 818 | }} ; | |
| 819 | ||
| 820 | fi nal Map pa tient = ne w HashMap( ) {{ | |
| 821 | put("dem ographics" , demograp hics); | |
| 822 | put("dem ographicsE xt", demog raphicsExt ); | |
| 823 | put("pat ientPrefer redFacilit yNumber", "TEST"); | |
| 824 | put("pat ientPrefer redFacilit yName", "T est Facili ty"); | |
| 825 | }} ; | |
| 826 | ||
| 827 | fi nal List p atients = new ArrayL ist() {{ | |
| 828 | add(pati ent); | |
| 829 | }} ; | |
| 830 | ||
| 831 | fi nal Announ cePatientT ype body = new Annou ncePatient Type(); | |
| 832 | bo dy.setPati entId(pati entId); | |
| 833 | Us erInfoType userInfo = new User InfoType() ; | |
| 834 | us erInfo.set FullName(" Test User" ); | |
| 835 | us erInfo.set UserId("vh aisbtest") ; | |
| 836 | us erInfo.set Authentica tionMethod ("password "); | |
| 837 | us erInfo.set Role("test Role"); | |
| 838 | bo dy.setUser Info(userI nfo); | |
| 839 | An nouncePati entType.Fa cilities f acilities = new Anno uncePatien tType.Faci lities(); | |
| 840 | bo dy.setFaci lities(fac ilities); | |
| 841 | fi nal String testFacil ity = "200 TEST"; | |
| 842 | fa cilities.g etFacility ().add(tes tFacility) ; | |
| 843 | ||
| 844 | fi nal Facili ty facilit y = new Fa cility(); | |
| 845 | fa cility.set FacilityNu mber("TEST "); | |
| 846 | fa cility.set FacilityNa me("Test F acility"); | |
| 847 | fa cility.set HomeCommun ityId("1.2 .3.4.5"); | |
| 848 | fa cility.set FullHomeCo mmunityId( "urn:oid:1 .2.3.4.5") ; | |
| 849 | ||
| 850 | fi nal Audit expAudit = new Audit (); | |
| 851 | ex pAudit.set Action("An nounce"); | |
| 852 | ex pAudit.set Details( | |
| 853 | "ssn=" + demograph ics.get("S SN") | |
| 854 | + ", las tName=" + demographi cs.get("na meFamily") | |
| 855 | + ", mid dleName=" + ((List)d emographic s.get("nam eGiven")). get(1) | |
| 856 | + ", giv enName=" + ((List)de mographics .get("name Given")).g et(0) | |
| 857 | + ", pre fix=" + de mographics .get("name Prefix") | |
| 858 | + ", suf fix=" + de mographics .get("name Suffix") | |
| 859 | + ", dob =" + demog raphics.ge t("birthDa te") | |
| 860 | + ", add ress[0]=" + ((List)d emographic sExt.get(" homeAddres sStreet")) .get(0) | |
| 861 | + ", add ress[1]=" + ((List)d emographic sExt.get(" homeAddres sStreet")) .get(1) | |
| 862 | + ", cit y=" + demo graphicsEx t.get("hom eAddressCi ty") | |
| 863 | + ", sta te=" + dem ographicsE xt.get("ho meAddressS tate") | |
| 864 | + ", zip =" + demog raphicsExt .get("home AddressPos tal") | |
| 865 | + ", pho ne=" + dem ographicsE xt.get("ph oneHome") | |
| 866 | + ", gen der=" + de mographics .get("gend erCode") | |
| 867 | + ", mul tiBirth=" + demograp hicsExt.ge t("multipl eBirthCode ") | |
| 868 | + ", mar italStatus =" + demog raphicsExt .get("mari talStatusC ode") | |
| 869 | + ", pat ientId=" + demograph ics.get("M RN") | |
| 870 | + ", hom eCommunity Id=1.2.3.4 .5" | |
| 871 | ); | |
| 872 | ex pAudit.set Organizati onId("urn: oid:1.2.3. 4.5"); | |
| 873 | ex pAudit.set PatientFac ilityName( "Test Faci lity"); | |
| 874 | ex pAudit.set PatientFac ilityNumbe r("TEST"); | |
| 875 | ex pAudit.set PatientGiv enName(((L ist<String >)demograp hics.get(" nameGiven" )).get(0)) ; | |
| 876 | ex pAudit.set PatientId( (String)de mographics .get("MRN" )); | |
| 877 | ex pAudit.set PatientLas tName((Str ing)demogr aphics.get ("nameFami ly")); | |
| 878 | ex pAudit.set PatientSSN ((String)d emographic s.get("SSN ")); | |
| 879 | ex pAudit.set PurposeFor Use("TREAT MENT"); | |
| 880 | ex pAudit.set UserFacili tyName(fac ility.getF acilityNam e()); | |
| 881 | ex pAudit.set UserFacili tyNumber(f acility.ge tFullHomeC ommunityId ()); | |
| 882 | ex pAudit.set UserId(bod y.getUserI nfo().getU serId() + ", CN=" + body.getUs erInfo().g etFullName () + ", O= " + facili ty.getFaci lityName() ); | |
| 883 | ex pAudit.set UserName(b ody.getUse rInfo().ge tFullName( )); | |
| 884 | ex pAudit.set UserRole(" 224608005" ); | |
| 885 | ||
| 886 | fi nal List<M ap> roles = new Arra yList<Map> (); | |
| 887 | Ma p role = n ew HashMap (); | |
| 888 | ro le.put("na me", "ROLE "); | |
| 889 | ro les.add(ro le); | |
| 890 | ||
| 891 | fi nal Respon dingGatewa yPRPAIN201 306UV02Res ponseType response = new Respo ndingGatew ayPRPAIN20 1306UV02Re sponseType (); | |
| 892 | re sponse.get CommunityR esponse(). add(new Co mmunityPRP AIN201306U V02Respons eType()); | |
| 893 | ||
| 894 | An nouncePati ent instan ce = new A nnouncePat ient(); | |
| 895 | ||
| 896 | fi nal DataMa nager data Manager = context.mo ck(DataMan ager.class ); | |
| 897 | fi nal DataQu ery dataQu ery = cont ext.mock(D ataQuery.c lass); | |
| 898 | fi nal Proper tyLookup p ropertyLoo kup = cont ext.mock(P ropertyLoo kup.class) ; | |
| 899 | fi nal AuditM anager aud itManager = context. mock(Audit Manager.cl ass); | |
| 900 | fi nal Facili tyManager facilityMa nager = co ntext.mock (FacilityM anager.cla ss); | |
| 901 | fi nal Entity PatientDis coveryPort Type entit yPatientDi scovery = context.mo ck(EntityP atientDisc overyPortT ype.class) ; | |
| 902 | ||
| 903 | in stance.set DataManage r(dataMana ger); | |
| 904 | in stance.set PropertyLo okup(prope rtyLookup) ; | |
| 905 | in stance.set AuditManag er(auditMa nager); | |
| 906 | in stance.set FacilityMa nager(faci lityManage r); | |
| 907 | in stance.set EntityPati entDiscove ry(entityP atientDisc overy); | |
| 908 | ||
| 909 | co ntext.chec king(new E xpectation s() { | |
| 910 | { | |
| 911 | oneOf(da taManager) .getQuery( "Composite .findDemog raphics"); | |
| 912 | will(ret urnValue(d ataQuery)) ; | |
| 913 | oneOf(da taQuery).s etParamete r("icn", p atientId); | |
| 914 | oneOf(da taQuery).g etResults( ); | |
| 915 | will(ret urnValue(p atients)); | |
| 916 | ||
| 917 | oneOf(da taManager) .getQuery( "STS.looku pSNOMED"); | |
| 918 | will(ret urnValue(d ataQuery)) ; | |
| 919 | oneOf(da taQuery).s etParamete r("code", "224608005 "); | |
| 920 | oneOf(da taQuery).g etResults( ); | |
| 921 | will(ret urnValue(r oles)); | |
| 922 | ||
| 923 | oneOf(au ditManager ).storeAud it(with(eq ual(expAud it))); | |
| 924 | ||
| 925 | oneOf(en tityPatien tDiscovery ).respondi ngGatewayP RPAIN20130 5UV02(with (any(Respo ndingGatew ayPRPAIN20 1305UV02Re questType. class))); | |
| 926 | will(thr owExceptio n(new Runt imeExcepti on())); | |
| 927 | ||
| 928 | allowing (propertyL ookup).get Property(w ith(any(St ring.class ))); | |
| 929 | will(ret urnValue(" property") ); | |
| 930 | ||
| 931 | oneOf(fa cilityMana ger).getFa cilityByFa cilityNumb er(testFac ility); | |
| 932 | will(ret urnValue(f acility)); | |
| 933 | ||
| 934 | allowing (facilityM anager).ge tFacilityB yFacilityN umber("VA" ); | |
| 935 | will(ret urnValue(f acility)); | |
| 936 | }} ); | |
| 937 | ||
| 938 | An nouncePati entRespons eType expR esult = ne w Announce PatientRes ponseType( ); | |
| 939 | ex pResult.se tReturn(-1 ); | |
| 940 | ||
| 941 | An nouncePati entRespons eType resu lt = insta nce.announ cePatient( body); | |
| 942 | as sertEquals (expResult .getReturn (), result .getReturn ()); | |
| 943 | } | |
| 944 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.