@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); 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: assertThat(VistaDataChunk.NEW_OR_UPDATE, is(vistaDataChunk.getType())); Map<String,Object> jsonMap = vistaDataChunk.getJsonMap(); PatientAppointments testPatientAppointment = testDataList.get(i); 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()); } }
@Override public List<VistaDataChunk> fetchDodPatientAppointments(JMeadowsQuery query, PatientIds patientIds) throws JMeadowsException_Exception { LOG.debug("JMeadowsAppointmentService.fetchDodPatientAppointments - Entering method..."); validateParams(query, patientIds, USER, PATIENT); List<VistaDataChunk> oaAppointmentChunk = new ArrayList<VistaDataChunk>(); List<PatientAppointments> oaPatientAppointment = jMeadowsClient.getPatientAppointments(query); LOG.debug("JMeadowsAppointmentService.fetchDodPatientAppointments: " + ((oaPatientAppointment == null) ? "NO" : "" + oaPatientAppointment.size()) + " results retrieved from JMeadows."); if ((oaPatientAppointment != null) && (oaPatientAppointment.size() > 0)) { oaPatientAppointment = (List<PatientAppointments>) filterOnSourceProtocol(oaPatientAppointment, SOURCE_PROTOCOL_DODADAPTER); int iNumAppointments = calculateNumAppointments(oaPatientAppointment); int iCurAppointmentIdx = 1; for (PatientAppointments oPatientAppointment : oaPatientAppointment) { LOG.debug("JMeadowsAppointmentService.fetchDodPatientAppointments: Found DoD Appointment - Processing it... idx: " + iCurAppointmentIdx); VistaDataChunk oAppointmentChunk = transformPatientAppointmentChunk(oPatientAppointment, patientIds, iNumAppointments, iCurAppointmentIdx); if (oAppointmentChunk != null) { oaAppointmentChunk.add(oAppointmentChunk); iCurAppointmentIdx++; } } } return oaAppointmentChunk; }
JMeadowsAppointmentService implements IJMeadowsAppointmentService { @Override public List<VistaDataChunk> fetchDodPatientAppointments(JMeadowsQuery query, PatientIds patientIds) throws JMeadowsException_Exception { LOG.debug("JMeadowsAppointmentService.fetchDodPatientAppointments - Entering method..."); validateParams(query, patientIds, USER, PATIENT); List<VistaDataChunk> oaAppointmentChunk = new ArrayList<VistaDataChunk>(); List<PatientAppointments> oaPatientAppointment = jMeadowsClient.getPatientAppointments(query); LOG.debug("JMeadowsAppointmentService.fetchDodPatientAppointments: " + ((oaPatientAppointment == null) ? "NO" : "" + oaPatientAppointment.size()) + " results retrieved from JMeadows."); if ((oaPatientAppointment != null) && (oaPatientAppointment.size() > 0)) { oaPatientAppointment = (List<PatientAppointments>) filterOnSourceProtocol(oaPatientAppointment, SOURCE_PROTOCOL_DODADAPTER); int iNumAppointments = calculateNumAppointments(oaPatientAppointment); int iCurAppointmentIdx = 1; for (PatientAppointments oPatientAppointment : oaPatientAppointment) { LOG.debug("JMeadowsAppointmentService.fetchDodPatientAppointments: Found DoD Appointment - Processing it... idx: " + iCurAppointmentIdx); VistaDataChunk oAppointmentChunk = transformPatientAppointmentChunk(oPatientAppointment, patientIds, iNumAppointments, iCurAppointmentIdx); if (oAppointmentChunk != null) { oaAppointmentChunk.add(oAppointmentChunk); iCurAppointmentIdx++; } } } return oaAppointmentChunk; } }
JMeadowsAppointmentService implements IJMeadowsAppointmentService { @Override public List<VistaDataChunk> fetchDodPatientAppointments(JMeadowsQuery query, PatientIds patientIds) throws JMeadowsException_Exception { LOG.debug("JMeadowsAppointmentService.fetchDodPatientAppointments - Entering method..."); validateParams(query, patientIds, USER, PATIENT); List<VistaDataChunk> oaAppointmentChunk = new ArrayList<VistaDataChunk>(); List<PatientAppointments> oaPatientAppointment = jMeadowsClient.getPatientAppointments(query); LOG.debug("JMeadowsAppointmentService.fetchDodPatientAppointments: " + ((oaPatientAppointment == null) ? "NO" : "" + oaPatientAppointment.size()) + " results retrieved from JMeadows."); if ((oaPatientAppointment != null) && (oaPatientAppointment.size() > 0)) { oaPatientAppointment = (List<PatientAppointments>) filterOnSourceProtocol(oaPatientAppointment, SOURCE_PROTOCOL_DODADAPTER); int iNumAppointments = calculateNumAppointments(oaPatientAppointment); int iCurAppointmentIdx = 1; for (PatientAppointments oPatientAppointment : oaPatientAppointment) { LOG.debug("JMeadowsAppointmentService.fetchDodPatientAppointments: Found DoD Appointment - Processing it... idx: " + iCurAppointmentIdx); VistaDataChunk oAppointmentChunk = transformPatientAppointmentChunk(oPatientAppointment, patientIds, iNumAppointments, iCurAppointmentIdx); if (oAppointmentChunk != null) { oaAppointmentChunk.add(oAppointmentChunk); iCurAppointmentIdx++; } } } return oaAppointmentChunk; } @Autowired  JMeadowsAppointmentService(JMeadowsConfiguration jMeadowsConfiguration); }
JMeadowsAppointmentService implements IJMeadowsAppointmentService { @Override public List<VistaDataChunk> fetchDodPatientAppointments(JMeadowsQuery query, PatientIds patientIds) throws JMeadowsException_Exception { LOG.debug("JMeadowsAppointmentService.fetchDodPatientAppointments - Entering method..."); validateParams(query, patientIds, USER, PATIENT); List<VistaDataChunk> oaAppointmentChunk = new ArrayList<VistaDataChunk>(); List<PatientAppointments> oaPatientAppointment = jMeadowsClient.getPatientAppointments(query); LOG.debug("JMeadowsAppointmentService.fetchDodPatientAppointments: " + ((oaPatientAppointment == null) ? "NO" : "" + oaPatientAppointment.size()) + " results retrieved from JMeadows."); if ((oaPatientAppointment != null) && (oaPatientAppointment.size() > 0)) { oaPatientAppointment = (List<PatientAppointments>) filterOnSourceProtocol(oaPatientAppointment, SOURCE_PROTOCOL_DODADAPTER); int iNumAppointments = calculateNumAppointments(oaPatientAppointment); int iCurAppointmentIdx = 1; for (PatientAppointments oPatientAppointment : oaPatientAppointment) { LOG.debug("JMeadowsAppointmentService.fetchDodPatientAppointments: Found DoD Appointment - Processing it... idx: " + iCurAppointmentIdx); VistaDataChunk oAppointmentChunk = transformPatientAppointmentChunk(oPatientAppointment, patientIds, iNumAppointments, iCurAppointmentIdx); if (oAppointmentChunk != null) { oaAppointmentChunk.add(oAppointmentChunk); iCurAppointmentIdx++; } } } return oaAppointmentChunk; } @Autowired  JMeadowsAppointmentService(JMeadowsConfiguration jMeadowsConfiguration); void setJMeadowsClient(JMeadowsData jMeadowsClient); @Override List<VistaDataChunk> fetchDodPatientAppointments(JMeadowsQuery query,
                                                          PatientIds patientIds); }
JMeadowsAppointmentService implements IJMeadowsAppointmentService { @Override public List<VistaDataChunk> fetchDodPatientAppointments(JMeadowsQuery query, PatientIds patientIds) throws JMeadowsException_Exception { LOG.debug("JMeadowsAppointmentService.fetchDodPatientAppointments - Entering method..."); validateParams(query, patientIds, USER, PATIENT); List<VistaDataChunk> oaAppointmentChunk = new ArrayList<VistaDataChunk>(); List<PatientAppointments> oaPatientAppointment = jMeadowsClient.getPatientAppointments(query); LOG.debug("JMeadowsAppointmentService.fetchDodPatientAppointments: " + ((oaPatientAppointment == null) ? "NO" : "" + oaPatientAppointment.size()) + " results retrieved from JMeadows."); if ((oaPatientAppointment != null) && (oaPatientAppointment.size() > 0)) { oaPatientAppointment = (List<PatientAppointments>) filterOnSourceProtocol(oaPatientAppointment, SOURCE_PROTOCOL_DODADAPTER); int iNumAppointments = calculateNumAppointments(oaPatientAppointment); int iCurAppointmentIdx = 1; for (PatientAppointments oPatientAppointment : oaPatientAppointment) { LOG.debug("JMeadowsAppointmentService.fetchDodPatientAppointments: Found DoD Appointment - Processing it... idx: " + iCurAppointmentIdx); VistaDataChunk oAppointmentChunk = transformPatientAppointmentChunk(oPatientAppointment, patientIds, iNumAppointments, iCurAppointmentIdx); if (oAppointmentChunk != null) { oaAppointmentChunk.add(oAppointmentChunk); iCurAppointmentIdx++; } } } return oaAppointmentChunk; } @Autowired  JMeadowsAppointmentService(JMeadowsConfiguration jMeadowsConfiguration); void setJMeadowsClient(JMeadowsData jMeadowsClient); @Override List<VistaDataChunk> fetchDodPatientAppointments(JMeadowsQuery query,
                                                          PatientIds patientIds); static final String DOMAIN_APPOINTMENT_VISIT; }