Skip to content

Commit

Permalink
Merge pull request #1212 from mozzy11/develop
Browse files Browse the repository at this point in the history
fix Electronic Oders in New UI
  • Loading branch information
mozzy11 authored Jul 31, 2024
2 parents 04ce7a1 + b693dd2 commit 6d674c4
Show file tree
Hide file tree
Showing 12 changed files with 204 additions and 103 deletions.
5 changes: 3 additions & 2 deletions frontend/src/components/addOrder/PatientInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ const PatientInfo = (props) => {
"guid=" +
orderFormValues.patientProperties.guid;
getFromOpenElisServer(searchEndPoint, (searchPatients) => {
if (searchPatients.length > 0) {
if (searchPatients.patientSearchResults.length > 0) {
const searchEndPoint =
"/rest/patient-details?patientID=" + searchPatients[0].patientID;
"/rest/patient-details?patientID=" +
searchPatients.patientSearchResults[0].patientID;
getFromOpenElisServer(searchEndPoint, (patientDetails) => {
getSelectedPatient(patientDetails);
handleNewPatientTab();
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/eOrder/EOrder.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const EOrder = ({ eOrders, setEOrders, eOrderRef }) => {
}

function editOrder(externalOrderId, labNumber) {
window.open("AddOrder?ID=" + externalOrderId + "&labNumber=" + labNumber);
window.open("SamplePatientEntry?ID=" + externalOrderId + "&labNumber=" + (labNumber || ""));
}

const handleLabNoGeneration = (e, index) => {
Expand Down
205 changes: 117 additions & 88 deletions frontend/src/components/eOrder/EOrderSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,25 @@ const EOrderSearch = ({
const [statusId, setStatusId] = useState("");
const [statusOptions, setStatusOptions] = useState([]);
const [allInfo, setAllInfo] = useState(false);
const [allInfo2, setAllInfo2] = useState(false);
const [searchCompleted, setSearchCompleted] = useState(false);

useEffect(() => {
getFromOpenElisServer("/rest/ElectronicOrders", handleElectronicOrders);
getFromOpenElisServer(
"/rest/displayList/ELECTRONIC_ORDER_STATUSES",
handleOrderStatus,
);
}, []);

const handleElectronicOrders = (response) => {
console.log(response);
};

const handleOrderStatus = (response) => {
setStatusOptions(response);
};

function searchByIdentifier() {
const params = new URLSearchParams({
searchType: "IDENTIFIER",
Expand All @@ -62,7 +71,7 @@ const EOrderSearch = ({
startDate: startDate,
endDate: endDate,
statusId: statusId,
useAllInfo: allInfo,
useAllInfo: allInfo2,
});
getFromOpenElisServer(
"/rest/ElectronicOrders?" + params.toString(),
Expand Down Expand Up @@ -105,101 +114,121 @@ const EOrderSearch = ({
</Grid>
<br></br>
<div className="orderLegendBody">
<FormattedMessage id="eorder.search1.text" />
<br></br>
<div className="formInlineDiv">
<TextInput
id="searchValue"
labelText={intl.formatMessage({ id: "eorder.searchValue" })}
value={searchValue}
onChange={(e) => {
setSearchValue(e.target.value);
}}
onKeyDown={(e) => {
if (e.key === "Enter") {
searchByIdentifier();
}
}}
/>
<div className="formInlineDiv bottomAlign">
<Checkbox
id="allInfo1"
labelText={intl.formatMessage({ id: "eorder.allInfo" })}
checked={allInfo}
<Grid fullWidth={true}>
<Column lg={16}>
<FormattedMessage id="eorder.search1.text" />
</Column>
<Column lg={16}>
<br></br>
</Column>
<Column lg={8}>
<TextInput
id="searchValue"
labelText={intl.formatMessage({ id: "eorder.searchValue" })}
value={searchValue}
onChange={(e) => {
setAllInfo(e.currentTarget.checked);
setSearchValue(e.target.value);
}}
onKeyDown={(e) => {
if (e.key === "Enter") {
searchByIdentifier();
}
}}
/>
<div className="formInlineDiv">
<div></div>
<Button onClick={searchByIdentifier}>
<FormattedMessage id="label.button.search" />
</Button>
</Column>
<Column lg={2}>
<div className="bottomAlign">
<Checkbox
id="allInfo1"
labelText={intl.formatMessage({ id: "eorder.allInfo" })}
checked={allInfo}
onChange={(e) => {
setAllInfo(e.currentTarget.checked);
}}
/>
</div>
</div>
</div>
<hr></hr>
<FormattedMessage id="eorder.search2.text" />
<br></br>
<div className="formInlineDiv">
<CustomDatePicker
id={"eOrder_startDate"}
labelText={intl.formatMessage({ id: "eorder.date.start" })}
value={startDate}
className="inputDate"
onChange={(date) => setStartDate(date)}
/>
</div>
<div className="formInlineDiv">
<CustomDatePicker
id={"eOrder_startDate"}
labelText={intl.formatMessage({ id: "eorder.date.end" })}
value={startDate}
className="inputDate"
onChange={(date) => setEndDate(date)}
/>
</div>
<div className="formInlineDiv">
<Select
id="statusId"
labelText={intl.formatMessage({ id: "eorder.status" })}
value={statusId}
onChange={(e) => {
setStatusId(e.target.value);
}}
>
<SelectItem value="" text="All Statuses" />
{statusOptions.map((statusOption, index) => {
return (
<SelectItem
key={index}
value={statusOption.id}
text={statusOption.value}
/>
);
})}
</Select>
<div className="formInlineDiv bottomAlign">
<Checkbox
id="allInfo2"
labelText={intl.formatMessage({ id: "eorder.allInfo" })}
checked={allInfo}
</Column>
<Column lg={2}></Column>
<Column lg={4}>
<Button onClick={searchByIdentifier}>
<FormattedMessage id="label.button.search" />
</Button>
</Column>

<Column lg={16}>
<hr></hr>
</Column>
<Column lg={16}>
<FormattedMessage id="eorder.search2.text" />
</Column>
<Column lg={16}>
<br></br>
</Column>
<Column lg={2}>
<CustomDatePicker
id={"eOrder_startDate"}
labelText={intl.formatMessage({ id: "eorder.date.start" })}
value={startDate}
className="inputDate"
onChange={(date) => setStartDate(date)}
/>
</Column>
<Column lg={2}>
<CustomDatePicker
id={"eOrder_startDate"}
labelText={intl.formatMessage({ id: "eorder.date.end" })}
value={startDate}
className="inputDate"
onChange={(date) => setEndDate(date)}
/>
</Column>
<Column lg={4}>
<Select
id="statusId"
labelText={intl.formatMessage({ id: "eorder.status" })}
value={statusId}
onChange={(e) => {
setAllInfo(e.currentTarget.checked);
setStatusId(e.target.value);
}}
/>
<div className="formInlineDiv">
<div></div>
<Button onClick={searchByDateAndStatus}>
<FormattedMessage id="label.button.search" />
</Button>
>
<SelectItem value="" text="All Statuses" />
{statusOptions.map((statusOption, index) => {
return (
<SelectItem
key={index}
value={statusOption.id}
text={statusOption.value}
/>
);
})}
</Select>
</Column>
<Column lg={2}>
<div className="bottomAlign">
<Checkbox
id="allInfo2"
labelText={intl.formatMessage({ id: "eorder.allInfo" })}
checked={allInfo2}
onChange={(e) => {
setAllInfo2(e.currentTarget.checked);
}}
/>
</div>
</div>
</div>
</Column>
<Column lg={2}></Column>
<Column lg={4}>
<Button onClick={searchByDateAndStatus}>
<FormattedMessage id="label.button.search" />
</Button>
</Column>

{searchCompleted && !hasEOrders && (
<Column lg={16} md={8} sm={4}>
<FormattedMessage id="eorder.search.noresults" />
</Column>
)}
</Grid>
</div>
{searchCompleted && !hasEOrders && (
<FormattedMessage id="eorder.search.noresults" />
)}
</>
);
};
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/components/layout/search/searchBar.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
border: 2px solid #110f74;
}


.patients {
overflow-y: auto;
width: 700px;
Expand Down Expand Up @@ -62,8 +61,6 @@
.search-input {
width: 100%;
}


}

@media (min-width: 769px) and (max-width: 1024px) {
Expand Down
1 change: 0 additions & 1 deletion frontend/src/components/layout/search/searchBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ const SearchBar = (props) => {
}
};


return (
<Layer className="main">
<Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ private List<OrderDisplayBean> convertElectronicToOrderBean(List<ElectronicOrder
List<OrderDisplayBean> orderBeanList = new ArrayList<>();
eOrders.forEach(eOrder -> {
OrderDisplayBean orderBean = new OrderDisplayBean();
orderBean.setId(eOrder.getId());
orderBean.setPriority(eOrder.getPriority().toString());
orderBean.setOrderDate(DateUtil.convertTimestampToStringDate(eOrder.getOrderTimestamp()));
Sample sample = sampleService.getSampleByReferringId(eOrder.getExternalId());
Expand Down Expand Up @@ -298,6 +299,10 @@ private List<OrderDisplayBean> convertElectronicToOrderBean(List<ElectronicOrder
public DashBoardMetrics getDasBoardTiles() {

DashBoardMetrics metrics = new DashBoardMetrics();
java.sql.Timestamp startTimestamp = DateUtil
.convertStringDateStringTimeToTimestamp(DateUtil.getCurrentDateAsText(), "00:00:00.0");
java.sql.Timestamp endTimestamp = DateUtil
.convertStringDateStringTimeToTimestamp(DateUtil.getCurrentDateAsText(), "23:59:59");
DashBoardTile.TileType.stream().forEach(type -> {
List<Integer> statusIdList;
Set<Integer> statusIdSet;
Expand Down Expand Up @@ -342,8 +347,8 @@ public DashBoardMetrics getDasBoardTiles() {
metrics.setUnPritendResults(unprintedResults().size());
break;
case INCOMING_ORDERS:
metrics.setIncomigOrders(electronicOrderService.getCountOfAllElectronicOrdersByDateAndStatus(null, null,
iStatusService.getStatusID(ExternalOrderStatus.Entered)));
metrics.setIncomigOrders(electronicOrderService.getCountOfElectronicOrdersByTimestampAndStatus(
startTimestamp, endTimestamp, iStatusService.getStatusID(ExternalOrderStatus.Entered)));
break;
case AVERAGE_TURN_AROUND_TIME:
metrics.setAverageTurnAroudTime(calculateAverageReceptionToValidationTime());
Expand Down Expand Up @@ -397,7 +402,10 @@ public PatientDashBoardForm getDashBoardDisplayList(HttpServletRequest request,
private List<OrderDisplayBean> retreiveOrders(DashBoardTile.TileType listType, String systemUserId) {
Set<Integer> statusIdSet;
List<Analysis> analyses;

java.sql.Timestamp startTimestamp = DateUtil
.convertStringDateStringTimeToTimestamp(DateUtil.getCurrentDateAsText(), "00:00:00.0");
java.sql.Timestamp endTimestamp = DateUtil
.convertStringDateStringTimeToTimestamp(DateUtil.getCurrentDateAsText(), "23:59:59");
switch (listType) {
case ORDERS_IN_PROGRESS:
analyses = analysisService.getAnalysesForStatusId(iStatusService.getStatusID(AnalysisStatus.NotStarted));
Expand Down Expand Up @@ -428,8 +436,9 @@ private List<OrderDisplayBean> retreiveOrders(DashBoardTile.TileType listType, S
case UN_PRINTED_RESULTS:
return convertAnalysesToOrderBean(unprintedResults());
case INCOMING_ORDERS:
List<ElectronicOrder> eOrders = electronicOrderService.getAllElectronicOrdersByDateAndStatus(null, null,
iStatusService.getStatusID(ExternalOrderStatus.Entered), ElectronicOrder.SortOrder.EXTERNAL_ID);
List<ElectronicOrder> eOrders = electronicOrderService.getAllElectronicOrdersByTimestampAndStatus(
startTimestamp, endTimestamp, iStatusService.getStatusID(ExternalOrderStatus.Entered),
ElectronicOrder.SortOrder.STATUS_ID);
return convertElectronicToOrderBean(eOrders);
case AVERAGE_TURN_AROUND_TIME:
return new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ List<ElectronicOrder> getAllElectronicOrdersByDateAndStatus(Date startDate, Date
List<ElectronicOrder> getAllElectronicOrdersByTimestampAndStatus(Timestamp startTimestamp, Timestamp endTimestamp,
String statusId, SortOrder sortOrder);

int getCountOfElectronicOrdersByTimestampAndStatus(Timestamp startTimestamp, Timestamp endTimestamp,
String statusId);

public List<ElectronicOrder> getAllElectronicOrdersMatchingAnyValue(List<String> identifierValues,
String patientValue, SortOrder order);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,34 @@ public List<ElectronicOrder> getAllElectronicOrdersByTimestampAndStatus(java.sql
return null;
}

@Override
public int getCountOfElectronicOrdersByTimestampAndStatus(java.sql.Timestamp startTimestamp,
java.sql.Timestamp endTimestamp, String statusId) {
String hql = "SELECT COUNT(*) From ElectronicOrder eo WHERE 1 = 1 ";
if (startTimestamp != null) {
hql += "AND eo.orderTimestamp BETWEEN :startDate AND :endDate ";
}
if (!GenericValidator.isBlankOrNull(statusId)) {
hql += "AND eo.statusId = :statusId ";
}

try {
Query<Long> query = entityManager.unwrap(Session.class).createQuery(hql, Long.class);
if (startTimestamp != null) {
query.setParameter("startDate", startTimestamp);
query.setParameter("endDate", endTimestamp);
}
if (!GenericValidator.isBlankOrNull(statusId)) {
query.setParameter("statusId", Integer.parseInt(statusId));
}
Long count = query.uniqueResult();
return count.intValue();
} catch (HibernateException e) {
handleException(e, "getAllElectronicOrdersByDateAndStatus");
}
return 0;
}

@Override
public int getCountOfAllElectronicOrdersByDateAndStatus(Date startDate, Date endDate, String statusId) {
String hql = "SELECT COUNT(*) From ElectronicOrder eo WHERE 1 = 1 ";
Expand All @@ -424,7 +452,7 @@ public int getCountOfAllElectronicOrdersByDateAndStatus(Date startDate, Date end
query.setParameter("statusId", Integer.parseInt(statusId));
}
Long count = query.uniqueResult();
count.intValue();
return count.intValue();
} catch (HibernateException e) {
handleException(e, "getCountOfAllElectronicOrdersByDateAndStatus");
}
Expand Down
Loading

0 comments on commit 6d674c4

Please sign in to comment.