JMeadowsProblemService implements IJMeadowsProblemService { public List<VistaDataChunk> fetchDodPatientProblems(JMeadowsQuery query, PatientIds patientIds) throws JMeadowsException_Exception { LOG.debug("JMeadowsProblemService.fetchDodPatientProblems - Entering method..."); List<VistaDataChunk> oaProblemChunk = new ArrayList<VistaDataChunk>(); List<Problem> oaProblemResults = jMeadowsClient.getPatientProblemList(query); LOG.debug("JMeadowsProblemService.fetchPatientProblemList: " + ((oaProblemResults == null)? "NO" : "" + oaProblemResults.size()) + " Problems retrieved from JMeadows."); if ((oaProblemResults != null) && (oaProblemResults.size() > 0)) { oaProblemResults = (List<Problem>) filterOnSourceProtocol(oaProblemResults, SOURCE_PROTOCOL_DODADAPTER); int iNumProblems = calculateNumProblems(oaProblemResults); int oaProblemIdx = 1; for(Problem oProblem : oaProblemResults) { VistaDataChunk oProblemChunk = transformProblemChunk((ProblemDetail)oProblem, patientIds, iNumProblems, oaProblemIdx); if (oProblemChunk != null) { LOG.debug("JMeadowsProblemService.fetchPatientProblems: Found DoD Problem - Processing it... idx: " + oaProblemIdx); oaProblemChunk.add(oProblemChunk); oaProblemIdx++; } } } return oaProblemChunk; } @Autowired  JMeadowsProblemService(JMeadowsConfiguration jMeadowsConfiguration); void setJMeadowsClient(JMeadowsData jMeadowsClient); List<VistaDataChunk> fetchDodPatientProblems(JMeadowsQuery query, PatientIds patientIds); static final String DOMAIN_PROBLEM; }
@Test public void testFetchPatientProblems() { try { when(this.mockJMeadowsClient.getPatientProblemList(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 = jMeadowsProblemService.fetchDodPatientProblems(query, patientIds); assertNotNull(vistaDataChunkList); assertThat(vistaDataChunkList.size(), is(2)); List<Problem> testDataList = createTestData(); for(int i = 0; i < vistaDataChunkList.size(); i++) { VistaDataChunk vistaDataChunk = vistaDataChunkList.get(i); assertThat(JMeadowsProblemService.DOMAIN_PROBLEM, 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(); ProblemDetail testProblem = (ProblemDetail) testDataList.get(i); assertThat("DOD", is(jsonMap.get("facilityCode"))); assertThat(testProblem.getHospitalLocation(), is(jsonMap.get("locationName"))); assertThat("urn:va:problem:DOD:"+edipi+":"+testProblem.getCdrEventId(), is(jsonMap.get("uid"))); assertThat(testProblem.getDescription(), is(jsonMap.get("problemText"))); assertThat(testProblem.getEnteredBy(), is(jsonMap.get("providerName"))); assertThat(testProblem.getEnteredBy(), is(jsonMap.get("providerDisplayName"))); assertThat(testProblem.getIcdCode(), is(jsonMap.get("icdCode"))); assertThat(testProblem.getStatus(), is(jsonMap.get("statusName"))); assertThat(testProblem.getAcuity(), is(jsonMap.get("acuityName"))); assertThat(calendarToPointInTime(testProblem.getEnteredDate()).toString(), is(jsonMap.get("entered"))); assertThat(calendarToPointInTime(testProblem.getLastModifiedDate()).toString(), is(jsonMap.get("updated"))); assertThat(calendarToPointInTime(testProblem.getOnsetDate()).toString(), is(jsonMap.get("onset"))); List<ProblemNote> notes = testProblem.getNotes(); List<Map<String, Object>> comments = (List<Map<String, Object>>)jsonMap.get("comments"); assertThat(comments.size(), is(2)); int j = 0; for(ProblemNote note : notes) { Map<String, Object> comment = comments.get(j); assertThat(note.getNoteText(), is(comment.get("comment"))); j++; } } } catch (JMeadowsException_Exception e) { fail(e.getMessage()); } }
@Test public void testNullAndEmptyProblemList() { try { when(this.mockJMeadowsClient.getPatientProblemList(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 = jMeadowsProblemService.fetchDodPatientProblems(query, patientIds); assertNotNull(vistaDataChunkList); assertThat(vistaDataChunkList.size(), is(0)); when(this.mockJMeadowsClient.getPatientProblemList(any(JMeadowsQuery.class))).thenReturn(new ArrayList<Problem>()); assertNotNull(vistaDataChunkList); assertThat(vistaDataChunkList.size(), is(0)); } catch (JMeadowsException_Exception e) { fail(e.getMessage()); } }