JMeadowsOrderService implements IJMeadowsOrderService { @Override public List<VistaDataChunk> fetchDodPatientOrders(JMeadowsQuery query, PatientIds patientIds) throws JMeadowsException_Exception { LOG.debug("JMeadowsOrderService.fetchDodPatientOrders - Entering method..."); validateParams(query, patientIds, USER, PATIENT); List<VistaDataChunk> oaOrderChunk = new ArrayList<VistaDataChunk>(); List<Order> oaOrder = jMeadowsClient.getPatientOrders(query); LOG.debug("JMeadowsOrderService.fetchDodPatientOrders: " + ((oaOrder == null)? "NO" : ""+oaOrder.size()) + " results retrieved from JMeadows."); if (CollectionUtils.isNotEmpty(oaOrder)) { oaOrder = (List<Order>) filterOnSourceProtocol(oaOrder, SOURCE_PROTOCOL_DODADAPTER); int iNumOrders = calculateNumOrders(oaOrder); int iCurOrderIdx = 1; for (Order oOrder : oaOrder) { LOG.debug("JMeadowsOrderService.fetchDodPatientOrders: Found DoD Order - Processing it... idx: " + iCurOrderIdx); if (StringUtils.isBlank(oOrder.getType()) || StringUtils.isBlank(oOrder.getDescription())) { LOG.debug("skip not enough order chunk data"); }else { VistaDataChunk oOrderChunk = transformOrderChunk(oOrder, patientIds, iNumOrders, iCurOrderIdx); if (oOrderChunk != null) { oaOrderChunk.add(oOrderChunk); iCurOrderIdx++; } } } } return oaOrderChunk; } @Autowired  JMeadowsOrderService(JMeadowsConfiguration jMeadowsConfiguration); void setJMeadowsClient(JMeadowsData jMeadowsClient); @Override List<VistaDataChunk> fetchDodPatientOrders(JMeadowsQuery query, PatientIds patientIds); static final String DOMAIN_ORDER; static final String TYPE_CONSULT; static final String TYPE_LAB; static final String TYPE_MEDICATION; static final String TYPE_RADIOLOGY; static final String SERVICE_CODE_CONSULT; static final String SERVICE_CODE_LAB; static final String SERVICE_CODE_NON_VA_MEDICATION; static final String SERVICE_CODE_RADIOLOGY; }
@Test public void testFetchPatientOrders() { try { when(this.mockJMeadowsClient.getPatientOrders(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 = mockJMeadowsOrderService.fetchDodPatientOrders(query, patientIds); assertNotNull(vistaDataChunkList); assertThat(vistaDataChunkList.size(), is(2)); List<Order> testDataList = createTestData(); for(int i = 0; i < vistaDataChunkList.size(); i++) { VistaDataChunk vistaDataChunk = vistaDataChunkList.get(i); assertThat(JMeadowsOrderService.DOMAIN_ORDER, 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(); Order testOrder = testDataList.get(i); assertThat("DOD", is(jsonMap.get("facilityCode"))); assertThat("DOD", is(jsonMap.get("facilityName"))); assertThat("urn:va:order:DOD:"+edipi+":"+testOrder.getCdrEventId(), is(jsonMap.get("uid"))); assertThat(((String) jsonMap.get("kind")).toUpperCase(), containsString(testOrder.getType().toUpperCase())); assertThat(testOrder.getDescription(), is(jsonMap.get("name"))); assertThat(testOrder.getOrderingProvider(), is(jsonMap.get("providerName"))); List<Map<String, Object>> codes = (List<Map<String, Object>>)jsonMap.get("codes"); assertThat(JLVTerminologySystem.LOINC.getUrn(), is(codes.get(0).get("system"))); } } catch (JMeadowsException_Exception e) { fail(e.getMessage()); } }
@Test public void testNullAndEmptyOrderList() { try { when(this.mockJMeadowsClient.getPatientOrders(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 = mockJMeadowsOrderService.fetchDodPatientOrders(query, patientIds); assertNotNull(vistaDataChunkList); assertThat(vistaDataChunkList.size(), is(0)); when(this.mockJMeadowsClient.getPatientOrders(any(JMeadowsQuery.class))).thenReturn(new ArrayList<Order>()); assertNotNull(vistaDataChunkList); assertThat(vistaDataChunkList.size(), is(0)); } catch (JMeadowsException_Exception e) { fail(e.getMessage()); } }