@Test public void testConvertInSet() throws Exception { VistaDataChunk fragment = MockVistaDataChunks.createFromJson( getObservationInSetResourceAsStream(), mockPatient, "observation"); fragment.setLocalPatientId("25"); Observation observation = (Observation) importer.convert(fragment); assertThat(observation.getPid(), is(MOCK_PID)); assertThat( observation.getUid(), is( UidUtils.getObservationUid( fragment.getSystemId(), fragment.getLocalPatientId(), observation.getLocalId()))); assertThat(observation.getEntered(), is(new PointInTime(2013, 2, 15, 14, 31, 50))); assertThat(observation.getFacilityCode(), is("500D")); assertThat(observation.getFacilityName(), is("SLC-FO HMP DEV")); assertThat(observation.getInterpretationCode(), is("urn:hl7:observation-interpretation:U")); assertThat(observation.getInterpretationName(), is("Unknown")); assertThat(observation.getLocalId(), is("{B14A750E-9849-4A50-9725-95EBD2289526}")); assertThat(observation.getLocationName(), is("GEN MED")); assertThat(observation.getLocationUid(), is("urn:va:location:F484:9")); assertThat(observation.getObserved(), is(new PointInTime(2013, 2, 15, 6, 53))); assertThat(observation.getResult(), is("TRIPLE")); assertThat(observation.getSetID(), is("{1BDC4488-C9CD-415E-BB93-F52C5945CB1A}")); assertThat(observation.getSetName(), is("triple lumen cath L Subclavian")); assertThat(observation.getSetStart(), is(new PointInTime(2013, 2, 14, 14, 27))); assertThat(observation.getSetType(), is("IV")); assertThat(observation.getStatusCode(), is("urn:va:observation-status:complete")); assertThat(observation.getStatusName(), is("complete")); assertThat( observation.getTypeCode(), is("urn:va:clioterminology:{E038D201-2840-B759-4D91-44A093768F8B}")); assertThat(observation.getTypeName(), is("CENTRAL LINE TYPE")); }
@Test public void testFetchPatientAppointments() { try { when(this.mockJMeadowsClient.getPatientAppointments(any(JMeadowsQuery.class))) .thenReturn(createTestData()); JMeadowsQuery query = new JMeadowsQueryBuilder().user(user).patient(patient).build(); PatientIds patientIds = new PatientIds.Builder().pid(pid).icn(icn).uid(uid).edipi(edipi).build(); List<VistaDataChunk> vistaDataChunkList = jMeadowsAppointmentService.fetchDodPatientAppointments(query, patientIds); assertNotNull(vistaDataChunkList); // dod status report should have been removed assertThat(vistaDataChunkList.size(), is(2)); List<PatientAppointments> testDataList = createTestData(); for (int i = 0; i < vistaDataChunkList.size(); i++) { VistaDataChunk vistaDataChunk = vistaDataChunkList.get(i); assertThat( JMeadowsAppointmentService.DOMAIN_APPOINTMENT_VISIT, is(vistaDataChunk.getDomain())); assertThat(2, is(vistaDataChunk.getItemCount())); assertThat(i + 1, is(vistaDataChunk.getItemIndex())); assertThat(vistaId, is(vistaDataChunk.getParams().get("vistaId"))); assertThat(dfn, is(vistaDataChunk.getParams().get("patientDfn"))); assertThat(vistaId, is(vistaDataChunk.getSystemId())); assertThat(dfn, is(vistaDataChunk.getLocalPatientId())); assertThat(icn, is(vistaDataChunk.getPatientIcn())); assertThat(pid, is(vistaDataChunk.getPatientId())); assertThat( "vrpcb://9E7A/HMP SYNCHRONIZATION CONTEXT/HMPDJFS API", is(vistaDataChunk.getRpcUri())); assertThat(VistaDataChunk.NEW_OR_UPDATE, is(vistaDataChunk.getType())); Map<String, Object> jsonMap = vistaDataChunk.getJsonMap(); PatientAppointments testPatientAppointment = testDataList.get(i); // assertThat("Allergy/Adverse Reaction", is(jsonMap.get("kind"))); assertThat("DOD", is(jsonMap.get("facilityCode"))); assertThat("DOD", is(jsonMap.get("facilityName"))); assertThat( "urn:va:appointment:DOD:" + edipi + ":" + testPatientAppointment.getCdrEventId(), is(jsonMap.get("uid"))); List<Map<String, Object>> providers = (List<Map<String, Object>>) jsonMap.get("providers"); Map<String, Object> provider = providers.get(0); assertThat(testPatientAppointment.getProviderName(), is(provider.get("name"))); } } catch (JMeadowsException_Exception e) { fail(e.getMessage()); } }
@Test public void testConvert() throws Exception { VistaDataChunk chunk = MockVistaDataChunks.createFromJson( PatientDemographicsImporterTest.class.getResourceAsStream("patient.json"), mockPatient, "patient"); PatientDemographicsImporter pi = new PatientDemographicsImporter(); PatientDemographics p = pi.convert(chunk); Assert.assertNotNull(p); Assert.assertEquals( p.getUid(), UidUtils.getPatientUid(chunk.getSystemId(), chunk.getLocalPatientId())); Assert.assertEquals("10104", p.getIcn()); Assert.assertEquals("AVIVAPATIENT", p.getFamilyName()); Assert.assertEquals("TWENTYFOUR", p.getGivenNames()); Assert.assertEquals("A0004", p.getBriefId()); Assert.assertEquals("666000004", p.getSsn()); Assert.assertTrue(p.isSensitive()); Assert.assertEquals(new PointInTime(1935, 4, 7), p.getBirthDate()); Assert.assertEquals("Male", p.getGenderName()); Assert.assertEquals("urn:va:pat-gender:M", p.getGenderCode()); // TODO: test for religion (needs code translation) Assert.assertTrue(p.isVeteran()); Assert.assertEquals("177", p.getLrdfn()); Assert.assertTrue(p.isServiceConnected()); Assert.assertEquals("10", p.getServiceConnectedPercent()); Assert.assertEquals(1, p.getAddress().size()); Address address = p.getAddress().iterator().next(); Assert.assertEquals("Any Street", address.getLine1()); Assert.assertEquals("Any Town", address.getCity()); Assert.assertEquals("WEST VIRGINIA", address.getState()); Assert.assertEquals("99998-0071", address.getZip()); Assert.assertEquals(1, p.getPatientRecordFlag().size()); PatientRecordFlag flag = p.getPatientRecordFlag().iterator().next(); Assert.assertEquals("WANDERER", flag.getName()); Assert.assertEquals("patient has a history of wandering off and getting lost", flag.getText()); Assert.assertNotNull(p.getMaritalStatusName()); Assert.assertEquals("urn:va:pat-maritalStatus:D", p.getMaritalStatusCode()); Assert.assertEquals("Divorced", p.getMaritalStatusName()); Assert.assertEquals(1, p.getAlias().size()); Alias alias = p.getAlias().iterator().next(); Assert.assertEquals("P4", alias.getFullName()); Assert.assertNull(alias.getFamilyName()); Assert.assertNull(alias.getGivenNames()); Assert.assertEquals(2, p.getTelecom().size()); Set<Telecom> telecoms = p.getTelecom(); for (Telecom telecom : telecoms) { if (telecom.getUse().equals("H")) { Assert.assertEquals("(222)555-8235", telecom.getValue()); } else if (telecom.getUse().equals("WP")) { Assert.assertEquals("(222)555-7720", telecom.getValue()); } else { Assert.fail(); } } Assert.assertEquals(1, p.getFacility().size()); // .facilities.size() SortedSet<PatientFacility> facilities = p.getFacility(); PatientFacility facility = facilities.first(); Assert.assertEquals("500", facility.getCode()); Assert.assertEquals("CAMP MASTER", facility.getName()); Assert.assertEquals(chunk.getSystemId(), facility.getSystemId()); Assert.assertEquals(chunk.getLocalPatientId(), facility.getLocalPatientId()); Assert.assertFalse(facility.isHomeSite()); Assert.assertEquals(6, p.getExposure().size()); // assertEquals("urn:va:N", p.getExposure().iterator().next().getUid()); Assert.assertEquals(1, p.getContact().size()); PatientContact support = p.getContact().iterator().next(); Assert.assertEquals("urn:va:pat-contact:NOK", support.getTypeCode()); Assert.assertEquals("Next of Kin", support.getTypeName()); Assert.assertEquals("VETERAN,BROTHER", support.getName()); }