@Test public void testNullAndEmptyAllergyList() { try { when(this.mockJMeadowsClient.getPatientAllergies(any(JMeadowsQuery.class))).thenReturn(null); 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 = jMeadowsAllergyService.fetchDodPatientAllergies(query, patientIds); assertNotNull(vistaDataChunkList); assertThat(vistaDataChunkList.size(), is(0)); when(this.mockJMeadowsClient.getPatientAllergies(any(JMeadowsQuery.class))).thenReturn(new ArrayList<Allergy>()); assertNotNull(vistaDataChunkList); assertThat(vistaDataChunkList.size(), is(0)); } catch (JMeadowsException_Exception e) { fail(e.getMessage()); } }
@Override public List<VistaDataChunk> fetchDodPatientAllergies(JMeadowsQuery query, PatientIds patientIds) throws JMeadowsException_Exception { LOG.debug("JMeadowsAllergyService.fetchDodPatientAllergies - Entering method..."); validateParams(query, patientIds, USER, PATIENT); List<VistaDataChunk> oaAllergyChunk = new ArrayList<VistaDataChunk>(); List<Allergy> oaAllergy = jMeadowsClient.getPatientAllergies(query); LOG.debug("JMeadowsAllergyService.fetchDodPatientAllergies: " + ((oaAllergy == null) ? "NO" : "" + oaAllergy.size()) + " results retrieved from JMeadows."); if ((oaAllergy != null) && (oaAllergy.size() > 0)) { oaAllergy = (List<Allergy>) filterOnSourceProtocol(oaAllergy, SOURCE_PROTOCOL_DODADAPTER); int iNumAllergies = calculateNumAllergies(oaAllergy); int iCurAllergyIdx = 1; for (Allergy oAllergy : oaAllergy) { LOG.debug("JMeadowsAllergyService.fetchDodPatientAllergies: Found DoD Allergy - Processing it... idx: " + iCurAllergyIdx); VistaDataChunk oAllergyChunk = transformAllergyChunk(oAllergy, patientIds, iNumAllergies, iCurAllergyIdx); if (oAllergyChunk != null) { oaAllergyChunk.add(oAllergyChunk); iCurAllergyIdx++; } } } return oaAllergyChunk; }
JMeadowsAllergyService implements IJMeadowsAllergyService { @Override public List<VistaDataChunk> fetchDodPatientAllergies(JMeadowsQuery query, PatientIds patientIds) throws JMeadowsException_Exception { LOG.debug("JMeadowsAllergyService.fetchDodPatientAllergies - Entering method..."); validateParams(query, patientIds, USER, PATIENT); List<VistaDataChunk> oaAllergyChunk = new ArrayList<VistaDataChunk>(); List<Allergy> oaAllergy = jMeadowsClient.getPatientAllergies(query); LOG.debug("JMeadowsAllergyService.fetchDodPatientAllergies: " + ((oaAllergy == null) ? "NO" : "" + oaAllergy.size()) + " results retrieved from JMeadows."); if ((oaAllergy != null) && (oaAllergy.size() > 0)) { oaAllergy = (List<Allergy>) filterOnSourceProtocol(oaAllergy, SOURCE_PROTOCOL_DODADAPTER); int iNumAllergies = calculateNumAllergies(oaAllergy); int iCurAllergyIdx = 1; for (Allergy oAllergy : oaAllergy) { LOG.debug("JMeadowsAllergyService.fetchDodPatientAllergies: Found DoD Allergy - Processing it... idx: " + iCurAllergyIdx); VistaDataChunk oAllergyChunk = transformAllergyChunk(oAllergy, patientIds, iNumAllergies, iCurAllergyIdx); if (oAllergyChunk != null) { oaAllergyChunk.add(oAllergyChunk); iCurAllergyIdx++; } } } return oaAllergyChunk; } }
JMeadowsAllergyService implements IJMeadowsAllergyService { @Override public List<VistaDataChunk> fetchDodPatientAllergies(JMeadowsQuery query, PatientIds patientIds) throws JMeadowsException_Exception { LOG.debug("JMeadowsAllergyService.fetchDodPatientAllergies - Entering method..."); validateParams(query, patientIds, USER, PATIENT); List<VistaDataChunk> oaAllergyChunk = new ArrayList<VistaDataChunk>(); List<Allergy> oaAllergy = jMeadowsClient.getPatientAllergies(query); LOG.debug("JMeadowsAllergyService.fetchDodPatientAllergies: " + ((oaAllergy == null) ? "NO" : "" + oaAllergy.size()) + " results retrieved from JMeadows."); if ((oaAllergy != null) && (oaAllergy.size() > 0)) { oaAllergy = (List<Allergy>) filterOnSourceProtocol(oaAllergy, SOURCE_PROTOCOL_DODADAPTER); int iNumAllergies = calculateNumAllergies(oaAllergy); int iCurAllergyIdx = 1; for (Allergy oAllergy : oaAllergy) { LOG.debug("JMeadowsAllergyService.fetchDodPatientAllergies: Found DoD Allergy - Processing it... idx: " + iCurAllergyIdx); VistaDataChunk oAllergyChunk = transformAllergyChunk(oAllergy, patientIds, iNumAllergies, iCurAllergyIdx); if (oAllergyChunk != null) { oaAllergyChunk.add(oAllergyChunk); iCurAllergyIdx++; } } } return oaAllergyChunk; } @Autowired  JMeadowsAllergyService(JMeadowsConfiguration jMeadowsConfiguration); }
JMeadowsAllergyService implements IJMeadowsAllergyService { @Override public List<VistaDataChunk> fetchDodPatientAllergies(JMeadowsQuery query, PatientIds patientIds) throws JMeadowsException_Exception { LOG.debug("JMeadowsAllergyService.fetchDodPatientAllergies - Entering method..."); validateParams(query, patientIds, USER, PATIENT); List<VistaDataChunk> oaAllergyChunk = new ArrayList<VistaDataChunk>(); List<Allergy> oaAllergy = jMeadowsClient.getPatientAllergies(query); LOG.debug("JMeadowsAllergyService.fetchDodPatientAllergies: " + ((oaAllergy == null) ? "NO" : "" + oaAllergy.size()) + " results retrieved from JMeadows."); if ((oaAllergy != null) && (oaAllergy.size() > 0)) { oaAllergy = (List<Allergy>) filterOnSourceProtocol(oaAllergy, SOURCE_PROTOCOL_DODADAPTER); int iNumAllergies = calculateNumAllergies(oaAllergy); int iCurAllergyIdx = 1; for (Allergy oAllergy : oaAllergy) { LOG.debug("JMeadowsAllergyService.fetchDodPatientAllergies: Found DoD Allergy - Processing it... idx: " + iCurAllergyIdx); VistaDataChunk oAllergyChunk = transformAllergyChunk(oAllergy, patientIds, iNumAllergies, iCurAllergyIdx); if (oAllergyChunk != null) { oaAllergyChunk.add(oAllergyChunk); iCurAllergyIdx++; } } } return oaAllergyChunk; } @Autowired  JMeadowsAllergyService(JMeadowsConfiguration jMeadowsConfiguration); void setJMeadowsClient(JMeadowsData jMeadowsClient); @Override List<VistaDataChunk> fetchDodPatientAllergies(JMeadowsQuery query, PatientIds patientIds); }
JMeadowsAllergyService implements IJMeadowsAllergyService { @Override public List<VistaDataChunk> fetchDodPatientAllergies(JMeadowsQuery query, PatientIds patientIds) throws JMeadowsException_Exception { LOG.debug("JMeadowsAllergyService.fetchDodPatientAllergies - Entering method..."); validateParams(query, patientIds, USER, PATIENT); List<VistaDataChunk> oaAllergyChunk = new ArrayList<VistaDataChunk>(); List<Allergy> oaAllergy = jMeadowsClient.getPatientAllergies(query); LOG.debug("JMeadowsAllergyService.fetchDodPatientAllergies: " + ((oaAllergy == null) ? "NO" : "" + oaAllergy.size()) + " results retrieved from JMeadows."); if ((oaAllergy != null) && (oaAllergy.size() > 0)) { oaAllergy = (List<Allergy>) filterOnSourceProtocol(oaAllergy, SOURCE_PROTOCOL_DODADAPTER); int iNumAllergies = calculateNumAllergies(oaAllergy); int iCurAllergyIdx = 1; for (Allergy oAllergy : oaAllergy) { LOG.debug("JMeadowsAllergyService.fetchDodPatientAllergies: Found DoD Allergy - Processing it... idx: " + iCurAllergyIdx); VistaDataChunk oAllergyChunk = transformAllergyChunk(oAllergy, patientIds, iNumAllergies, iCurAllergyIdx); if (oAllergyChunk != null) { oaAllergyChunk.add(oAllergyChunk); iCurAllergyIdx++; } } } return oaAllergyChunk; } @Autowired  JMeadowsAllergyService(JMeadowsConfiguration jMeadowsConfiguration); void setJMeadowsClient(JMeadowsData jMeadowsClient); @Override List<VistaDataChunk> fetchDodPatientAllergies(JMeadowsQuery query, PatientIds patientIds); static final String DOMAIN_ALLERGY; }