@Test public void testFetchPatientAllergies() { try { when(this.mockJMeadowsClient.getPatientAllergies(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 = jMeadowsAllergyService.fetchDodPatientAllergies(query, patientIds); assertNotNull(vistaDataChunkList); assertThat(vistaDataChunkList.size(), is(2)); List<Allergy> testDataList = createTestData(); for(int i = 0; i < vistaDataChunkList.size(); i++) { VistaDataChunk vistaDataChunk = vistaDataChunkList.get(i); assertThat(JMeadowsAllergyService.DOMAIN_ALLERGY, 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("DOD;" + edipi, is(vistaDataChunk.getPatientId())); assertThat("vrpcb: assertThat(VistaDataChunk.NEW_OR_UPDATE, is(vistaDataChunk.getType())); Map<String,Object> jsonMap = vistaDataChunk.getJsonMap(); Allergy testAllergy = 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:allergy:DOD:"+edipi+":"+testAllergy.getCdrEventId(), is(jsonMap.get("uid"))); assertThat(testAllergy.getAllergyName(), is(jsonMap.get("summary"))); List<Map<String, Object>> products = (List<Map<String, Object>>)jsonMap.get("products"); Map<String, Object> product = products.get(0); assertThat(testAllergy.getAllergyName(), is(product.get("name"))); List<Map<String, Object>> comments = (List<Map<String, Object>>)jsonMap.get("comments"); Map<String, Object> comment = comments.get(0); assertThat(testAllergy.getComment(), is(comment.get("comment"))); List<Map<String, Object>> codes = (List<Map<String, Object>>)jsonMap.get("codes"); assertThat(JLVTerminologySystem.UMLS.getUrn(), is(codes.get(0).get("system"))); } } 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; }