@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()); } }
@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; }
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; } }
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); }
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); }
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; }