@Test public void testFetchPatientEncounters() { try { when(this.mockJMeadowsClient.getPatientEncounters(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 = jMeadowsEncounterService.fetchDodPatientEncounters(query, patientIds); assertNotNull(vistaDataChunkList); assertThat(vistaDataChunkList.size(), is(2)); List<PatientEncounter> testDataList = createTestData(); for(int i = 0; i < vistaDataChunkList.size(); i++) { VistaDataChunk vistaDataChunk = vistaDataChunkList.get(i); assertThat(JMeadowsEncounterService.DOMAIN_ENCOUNTER_VISIST, 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: assertThat(VistaDataChunk.NEW_OR_UPDATE, is(vistaDataChunk.getType())); Map<String,Object> jsonMap = vistaDataChunk.getJsonMap(); PatientEncounter testPatientEncounter = testDataList.get(i); assertThat("DOD", is(jsonMap.get("facilityCode"))); assertThat("DOD", is(jsonMap.get("facilityName"))); assertThat("urn:va:visit:DOD:"+edipi+":"+testPatientEncounter.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(testPatientEncounter.getProvider(), is(provider.get("name"))); } } catch (JMeadowsException_Exception e) { fail(e.getMessage()); } }
@Override public List<VistaDataChunk> fetchDodPatientEncounters(JMeadowsQuery query, PatientIds patientIds) throws JMeadowsException_Exception { LOG.debug("JMeadowsEncounterService.fetchDodPatientEncounters - Entering method..."); validateParams(query, patientIds, USER, PATIENT); List<VistaDataChunk> oaEncounterChunk = new ArrayList<VistaDataChunk>(); List<PatientEncounter> oaPatientEncounter = jMeadowsClient.getPatientEncounters(query); LOG.debug("JMeadowsEncounterService.fetchDodPatientEncounters: " + ((oaPatientEncounter == null) ? "NO" : "" + oaPatientEncounter.size()) + " results retrieved from JMeadows."); if ((oaPatientEncounter != null) && (oaPatientEncounter.size() > 0)) { oaPatientEncounter = (List<PatientEncounter>) filterOnSourceProtocol(oaPatientEncounter, SOURCE_PROTOCOL_DODADAPTER); int iNumEncounters = calculateNumEncounters(oaPatientEncounter); int iCurEncounterIdx = 1; for (PatientEncounter oPatientEncounter : oaPatientEncounter) { LOG.debug("JMeadowsEncounterService.fetchDodPatientEncounters: Found DoD Encounter - Processing it... idx: " + iCurEncounterIdx); VistaDataChunk oEncounterChunk = transformPatientEncounterChunk(oPatientEncounter, patientIds, iNumEncounters, iCurEncounterIdx); if (oEncounterChunk != null) { oaEncounterChunk.add(oEncounterChunk); iCurEncounterIdx++; } } } return oaEncounterChunk; }
JMeadowsEncounterService implements IJMeadowsEncounterService { @Override public List<VistaDataChunk> fetchDodPatientEncounters(JMeadowsQuery query, PatientIds patientIds) throws JMeadowsException_Exception { LOG.debug("JMeadowsEncounterService.fetchDodPatientEncounters - Entering method..."); validateParams(query, patientIds, USER, PATIENT); List<VistaDataChunk> oaEncounterChunk = new ArrayList<VistaDataChunk>(); List<PatientEncounter> oaPatientEncounter = jMeadowsClient.getPatientEncounters(query); LOG.debug("JMeadowsEncounterService.fetchDodPatientEncounters: " + ((oaPatientEncounter == null) ? "NO" : "" + oaPatientEncounter.size()) + " results retrieved from JMeadows."); if ((oaPatientEncounter != null) && (oaPatientEncounter.size() > 0)) { oaPatientEncounter = (List<PatientEncounter>) filterOnSourceProtocol(oaPatientEncounter, SOURCE_PROTOCOL_DODADAPTER); int iNumEncounters = calculateNumEncounters(oaPatientEncounter); int iCurEncounterIdx = 1; for (PatientEncounter oPatientEncounter : oaPatientEncounter) { LOG.debug("JMeadowsEncounterService.fetchDodPatientEncounters: Found DoD Encounter - Processing it... idx: " + iCurEncounterIdx); VistaDataChunk oEncounterChunk = transformPatientEncounterChunk(oPatientEncounter, patientIds, iNumEncounters, iCurEncounterIdx); if (oEncounterChunk != null) { oaEncounterChunk.add(oEncounterChunk); iCurEncounterIdx++; } } } return oaEncounterChunk; } }
JMeadowsEncounterService implements IJMeadowsEncounterService { @Override public List<VistaDataChunk> fetchDodPatientEncounters(JMeadowsQuery query, PatientIds patientIds) throws JMeadowsException_Exception { LOG.debug("JMeadowsEncounterService.fetchDodPatientEncounters - Entering method..."); validateParams(query, patientIds, USER, PATIENT); List<VistaDataChunk> oaEncounterChunk = new ArrayList<VistaDataChunk>(); List<PatientEncounter> oaPatientEncounter = jMeadowsClient.getPatientEncounters(query); LOG.debug("JMeadowsEncounterService.fetchDodPatientEncounters: " + ((oaPatientEncounter == null) ? "NO" : "" + oaPatientEncounter.size()) + " results retrieved from JMeadows."); if ((oaPatientEncounter != null) && (oaPatientEncounter.size() > 0)) { oaPatientEncounter = (List<PatientEncounter>) filterOnSourceProtocol(oaPatientEncounter, SOURCE_PROTOCOL_DODADAPTER); int iNumEncounters = calculateNumEncounters(oaPatientEncounter); int iCurEncounterIdx = 1; for (PatientEncounter oPatientEncounter : oaPatientEncounter) { LOG.debug("JMeadowsEncounterService.fetchDodPatientEncounters: Found DoD Encounter - Processing it... idx: " + iCurEncounterIdx); VistaDataChunk oEncounterChunk = transformPatientEncounterChunk(oPatientEncounter, patientIds, iNumEncounters, iCurEncounterIdx); if (oEncounterChunk != null) { oaEncounterChunk.add(oEncounterChunk); iCurEncounterIdx++; } } } return oaEncounterChunk; } @Autowired  JMeadowsEncounterService(JMeadowsConfiguration jMeadowsConfiguration); }
JMeadowsEncounterService implements IJMeadowsEncounterService { @Override public List<VistaDataChunk> fetchDodPatientEncounters(JMeadowsQuery query, PatientIds patientIds) throws JMeadowsException_Exception { LOG.debug("JMeadowsEncounterService.fetchDodPatientEncounters - Entering method..."); validateParams(query, patientIds, USER, PATIENT); List<VistaDataChunk> oaEncounterChunk = new ArrayList<VistaDataChunk>(); List<PatientEncounter> oaPatientEncounter = jMeadowsClient.getPatientEncounters(query); LOG.debug("JMeadowsEncounterService.fetchDodPatientEncounters: " + ((oaPatientEncounter == null) ? "NO" : "" + oaPatientEncounter.size()) + " results retrieved from JMeadows."); if ((oaPatientEncounter != null) && (oaPatientEncounter.size() > 0)) { oaPatientEncounter = (List<PatientEncounter>) filterOnSourceProtocol(oaPatientEncounter, SOURCE_PROTOCOL_DODADAPTER); int iNumEncounters = calculateNumEncounters(oaPatientEncounter); int iCurEncounterIdx = 1; for (PatientEncounter oPatientEncounter : oaPatientEncounter) { LOG.debug("JMeadowsEncounterService.fetchDodPatientEncounters: Found DoD Encounter - Processing it... idx: " + iCurEncounterIdx); VistaDataChunk oEncounterChunk = transformPatientEncounterChunk(oPatientEncounter, patientIds, iNumEncounters, iCurEncounterIdx); if (oEncounterChunk != null) { oaEncounterChunk.add(oEncounterChunk); iCurEncounterIdx++; } } } return oaEncounterChunk; } @Autowired  JMeadowsEncounterService(JMeadowsConfiguration jMeadowsConfiguration); void setJMeadowsClient(JMeadowsData jMeadowsClient); @Override List<VistaDataChunk> fetchDodPatientEncounters(JMeadowsQuery query,
			PatientIds patientIds); }
JMeadowsEncounterService implements IJMeadowsEncounterService { @Override public List<VistaDataChunk> fetchDodPatientEncounters(JMeadowsQuery query, PatientIds patientIds) throws JMeadowsException_Exception { LOG.debug("JMeadowsEncounterService.fetchDodPatientEncounters - Entering method..."); validateParams(query, patientIds, USER, PATIENT); List<VistaDataChunk> oaEncounterChunk = new ArrayList<VistaDataChunk>(); List<PatientEncounter> oaPatientEncounter = jMeadowsClient.getPatientEncounters(query); LOG.debug("JMeadowsEncounterService.fetchDodPatientEncounters: " + ((oaPatientEncounter == null) ? "NO" : "" + oaPatientEncounter.size()) + " results retrieved from JMeadows."); if ((oaPatientEncounter != null) && (oaPatientEncounter.size() > 0)) { oaPatientEncounter = (List<PatientEncounter>) filterOnSourceProtocol(oaPatientEncounter, SOURCE_PROTOCOL_DODADAPTER); int iNumEncounters = calculateNumEncounters(oaPatientEncounter); int iCurEncounterIdx = 1; for (PatientEncounter oPatientEncounter : oaPatientEncounter) { LOG.debug("JMeadowsEncounterService.fetchDodPatientEncounters: Found DoD Encounter - Processing it... idx: " + iCurEncounterIdx); VistaDataChunk oEncounterChunk = transformPatientEncounterChunk(oPatientEncounter, patientIds, iNumEncounters, iCurEncounterIdx); if (oEncounterChunk != null) { oaEncounterChunk.add(oEncounterChunk); iCurEncounterIdx++; } } } return oaEncounterChunk; } @Autowired  JMeadowsEncounterService(JMeadowsConfiguration jMeadowsConfiguration); void setJMeadowsClient(JMeadowsData jMeadowsClient); @Override List<VistaDataChunk> fetchDodPatientEncounters(JMeadowsQuery query,
			PatientIds patientIds); static final String DOMAIN_ENCOUNTER_VISIST; }