diff --git a/frontend/src/components/addOrder/Index.js b/frontend/src/components/addOrder/Index.js index 9470b91650..dfaafb2df4 100755 --- a/frontend/src/components/addOrder/Index.js +++ b/frontend/src/components/addOrder/Index.js @@ -169,13 +169,15 @@ const Index = () => { crossSampleTypeMap = {}; crossSampleTypeOrderMap = {}; - parseSampletypes( - newOrderFormValues, - order.sampleTypes instanceof Array - ? order.sampleTypes - : [{ sampleType: order.sampleTypes.sampleType }], - SampleTypes, - ); + if (order.sampleTypes != "") { + parseSampletypes( + newOrderFormValues, + order.sampleTypes instanceof Array + ? order.sampleTypes + : [{ sampleType: order.sampleTypes.sampleType }], + SampleTypes, + ); + } const urlParams = new URLSearchParams(window.location.search); const externalId = urlParams.get("ID"); diff --git a/frontend/src/components/eOrder/EOrder.js b/frontend/src/components/eOrder/EOrder.js index ef758c5130..54f02c2b82 100644 --- a/frontend/src/components/eOrder/EOrder.js +++ b/frontend/src/components/eOrder/EOrder.js @@ -54,7 +54,12 @@ const EOrder = ({ eOrders, setEOrders, eOrderRef }) => { } function editOrder(externalOrderId, labNumber) { - window.open("SamplePatientEntry?ID=" + externalOrderId + "&labNumber=" + (labNumber || "")); + window.open( + "SamplePatientEntry?ID=" + + externalOrderId + + "&labNumber=" + + (labNumber || ""), + ); } const handleLabNoGeneration = (e, index) => { diff --git a/pom.xml b/pom.xml index 64aa3f557d..577de72a55 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ 8 1 - 37 + 38 UTF-8 ${project.basedir}/liquibase/liquibase.properties 1.4.1 diff --git a/src/main/java/org/openelisglobal/common/provider/query/LabOrderSearchProvider.java b/src/main/java/org/openelisglobal/common/provider/query/LabOrderSearchProvider.java index 256ba89003..31097a167a 100644 --- a/src/main/java/org/openelisglobal/common/provider/query/LabOrderSearchProvider.java +++ b/src/main/java/org/openelisglobal/common/provider/query/LabOrderSearchProvider.java @@ -467,12 +467,18 @@ private void addToTestOrPanel(List tests, String loinc, String sampleTy } } if (test == null) { - test = testService.getActiveTestsByLoinc(loinc).get(0); + List alltests = testService.getActiveTestsByLoinc(loinc); + if (alltests != null && alltests.size() > 0) { + test = alltests.get(0); + } } - if (typeOfSample == null) { - typeOfSample = typeOfSampleService.getTypeOfSampleForTest(test.getId()).get(0); + if (test != null) { + if (typeOfSample == null) { + typeOfSample = typeOfSampleService.getTypeOfSampleForTest(test.getId()).get(0); + } + tests.add(new Request(test.getName(), loinc, typeOfSample.getLocalizedName())); } - tests.add(new Request(test.getName(), loinc, typeOfSample.getLocalizedName())); + } private void createMaps(List testRequests, List panelNames) { diff --git a/src/main/java/org/openelisglobal/common/rest/provider/PatientDashBoardProvider.java b/src/main/java/org/openelisglobal/common/rest/provider/PatientDashBoardProvider.java index 1df9033dc3..662de10c67 100644 --- a/src/main/java/org/openelisglobal/common/rest/provider/PatientDashBoardProvider.java +++ b/src/main/java/org/openelisglobal/common/rest/provider/PatientDashBoardProvider.java @@ -347,8 +347,10 @@ public DashBoardMetrics getDasBoardTiles() { metrics.setUnPritendResults(unprintedResults().size()); break; case INCOMING_ORDERS: - metrics.setIncomigOrders(electronicOrderService.getCountOfElectronicOrdersByTimestampAndStatus( - startTimestamp, endTimestamp, iStatusService.getStatusID(ExternalOrderStatus.Entered))); + List estausIds = new ArrayList<>(); + estausIds.add(Integer.parseInt(iStatusService.getStatusID(ExternalOrderStatus.Entered))); + estausIds.add(Integer.parseInt(iStatusService.getStatusID(ExternalOrderStatus.NonConforming))); + metrics.setIncomigOrders(electronicOrderService.getCountOfElectronicOrdersByStatusList(estausIds)); break; case AVERAGE_TURN_AROUND_TIME: metrics.setAverageTurnAroudTime(calculateAverageReceptionToValidationTime()); @@ -436,8 +438,10 @@ private List retreiveOrders(DashBoardTile.TileType listType, S case UN_PRINTED_RESULTS: return convertAnalysesToOrderBean(unprintedResults()); case INCOMING_ORDERS: - List eOrders = electronicOrderService.getAllElectronicOrdersByTimestampAndStatus( - startTimestamp, endTimestamp, iStatusService.getStatusID(ExternalOrderStatus.Entered), + List estausIds = new ArrayList<>(); + estausIds.add(Integer.parseInt(iStatusService.getStatusID(ExternalOrderStatus.Entered))); + estausIds.add(Integer.parseInt(iStatusService.getStatusID(ExternalOrderStatus.NonConforming))); + List eOrders = electronicOrderService.getAllElectronicOrdersByStatusList(estausIds, ElectronicOrder.SortOrder.STATUS_ID); return convertElectronicToOrderBean(eOrders); case AVERAGE_TURN_AROUND_TIME: diff --git a/src/main/java/org/openelisglobal/dataexchange/order/dao/ElectronicOrderDAO.java b/src/main/java/org/openelisglobal/dataexchange/order/dao/ElectronicOrderDAO.java index 7b26cced15..179157b4ad 100644 --- a/src/main/java/org/openelisglobal/dataexchange/order/dao/ElectronicOrderDAO.java +++ b/src/main/java/org/openelisglobal/dataexchange/order/dao/ElectronicOrderDAO.java @@ -55,4 +55,8 @@ public List getAllElectronicOrdersMatchingAnyValue(List String patientValue, SortOrder order); int getCountOfAllElectronicOrdersByDateAndStatus(Date startDate, Date endDate, String statusId); + + int getCountOfElectronicOrdersByStatusList(List statusIds); + + List getAllElectronicOrdersByStatusList(List statusIds, SortOrder sortOrder); } diff --git a/src/main/java/org/openelisglobal/dataexchange/order/daoimpl/ElectronicOrderDAOImpl.java b/src/main/java/org/openelisglobal/dataexchange/order/daoimpl/ElectronicOrderDAOImpl.java index 5cb2d14c5d..472fd49d15 100644 --- a/src/main/java/org/openelisglobal/dataexchange/order/daoimpl/ElectronicOrderDAOImpl.java +++ b/src/main/java/org/openelisglobal/dataexchange/order/daoimpl/ElectronicOrderDAOImpl.java @@ -458,4 +458,64 @@ public int getCountOfAllElectronicOrdersByDateAndStatus(Date startDate, Date end } return 0; } + + @Override + public int getCountOfElectronicOrdersByStatusList(List statusIds) { + String hql = "SELECT COUNT(*) From ElectronicOrder eo WHERE 1 = 1 "; + + if (statusIds != null) { + hql += "AND eo.statusId IN (:statusIds)"; + } + + try { + Query query = entityManager.unwrap(Session.class).createQuery(hql, Long.class); + if (statusIds != null) { + query.setParameter("statusIds", statusIds); + } + Long count = query.uniqueResult(); + return count.intValue(); + } catch (HibernateException e) { + handleException(e, "getCountOfElectronicOrdersByStatusList"); + } + return 0; + } + + @Override + public List getAllElectronicOrdersByStatusList(List statusIds, SortOrder sortOrder) { + String hql = "From ElectronicOrder eo WHERE 1 = 1 "; + + if (statusIds != null) { + hql += "AND eo.statusId IN (:statusIds)"; + } + + switch (sortOrder) { + case STATUS_ID: + hql += "ORDER BY eo.statusId asc "; + break; + case LAST_UPDATED_ASC: + hql += "ORDER BY eo.lastUpdated asc "; + break; + case LAST_UPDATED_DESC: + hql += "ORDER BY eo.lastUpdated desc "; + break; + case EXTERNAL_ID: + hql += "ORDER BY eo.externalId asc "; + break; + default: + // + break; + } + + try { + Query query = entityManager.unwrap(Session.class).createQuery(hql, ElectronicOrder.class); + + if (statusIds != null) { + query.setParameter("statusIds", statusIds); + } + return query.list(); + } catch (HibernateException e) { + handleException(e, "getAllElectronicOrdersByStatusList"); + } + return new ArrayList<>(); + } } diff --git a/src/main/java/org/openelisglobal/dataexchange/service/order/ElectronicOrderService.java b/src/main/java/org/openelisglobal/dataexchange/service/order/ElectronicOrderService.java index 2dd6e5778b..4094580a72 100644 --- a/src/main/java/org/openelisglobal/dataexchange/service/order/ElectronicOrderService.java +++ b/src/main/java/org/openelisglobal/dataexchange/service/order/ElectronicOrderService.java @@ -29,11 +29,15 @@ List getAllElectronicOrdersByDateAndStatus(Date startDate, Date int getCountOfAllElectronicOrdersByDateAndStatus(Date startDate, Date endDate, String statusId); List getAllElectronicOrdersByTimestampAndStatus(Timestamp startTimestamp, Timestamp endTimestamp, - String statusId, SortOrder statusId2); + String statusId, SortOrder sortOrder); int getCountOfElectronicOrdersByTimestampAndStatus(Timestamp startTimestamp, Timestamp endTimestamp, String statusId); + int getCountOfElectronicOrdersByStatusList(List statusIds); + + List getAllElectronicOrdersByStatusList(List statusIds, SortOrder sortOrder); + List searchForElectronicOrders(ElectronicOrderViewForm form); List searchForStudyElectronicOrders(ElectronicOrderViewForm form); diff --git a/src/main/java/org/openelisglobal/dataexchange/service/order/ElectronicOrderServiceImpl.java b/src/main/java/org/openelisglobal/dataexchange/service/order/ElectronicOrderServiceImpl.java index 7b8280b84a..a2a57bd0bd 100644 --- a/src/main/java/org/openelisglobal/dataexchange/service/order/ElectronicOrderServiceImpl.java +++ b/src/main/java/org/openelisglobal/dataexchange/service/order/ElectronicOrderServiceImpl.java @@ -214,4 +214,14 @@ public List searchForStudyElectronicOrders(ElectronicOrderViewF public int getCountOfAllElectronicOrdersByDateAndStatus(Date startDate, Date endDate, String statusId) { return getBaseObjectDAO().getCountOfAllElectronicOrdersByDateAndStatus(startDate, endDate, statusId); } + + @Override + public List getAllElectronicOrdersByStatusList(List statusIds, SortOrder sortOrder) { + return getBaseObjectDAO().getAllElectronicOrdersByStatusList(statusIds, sortOrder); + } + + @Override + public int getCountOfElectronicOrdersByStatusList(List statusIds) { + return getBaseObjectDAO().getCountOfElectronicOrdersByStatusList(statusIds); + } }