-
What should the intended user experience for this feature be?
The user should be allowed to create surgical block across day boundaries / week boundaries as allowed today and such block should appear on OT module UI. Currently, such blocks created across day/week boundaries are not shown in OT module UI as openmrs API is not returning such blocks.
-
Can you please provide pointers to specific code where you think changes would be needed (maybe provide Github links) to support spill-overs?
We wanted to add new api parameter(activeBlocks) to existing api end point (openmrs/ws/rest/v1/surgicalBlock) to fix this issue.
Required code changes in “getSurgicalBlocksFor” method in SurgicalBlockDAO.java file
public List<SurgicalBlock> getSurgicalBlocksFor(Date startDatetime, Date endDatetime, Provider provider, Location location, Boolean includeVoided, Boolean activeBlocks) {
Session session = sessionFactory.getCurrentSession();
Criteria criteria = session.createCriteria(SurgicalBlock.class, "surgicalBlock");
if (activeBlocks) {
criteria.add(Restrictions.ge("endDatetime", startDatetime));
criteria.add(Restrictions.le("startDatetime", endDatetime));
} else {
criteria.add(Restrictions.ge("startDatetime", startDatetime));
criteria.add(Restrictions.le("endDatetime", endDatetime));
}
if (!includeVoided) {
criteria.add(Restrictions.eq("voided", false));
}
if (provider != null) {
criteria.add(Restrictions.eq("provider", provider));
}
if (location != null) {
criteria.add(Restrictions.eq("location", location));
}
return criteria.list();
}
Note: You can see the startDateTime and endDateTime restrictions are added based on new api parameter(activeBlocks).
Example:
Surgical Block 1: OT1 - Mar 7th 9:00 - Mar 9th 16:00
Surgical Block 2: OT1 - Mar 6th 23:00 - Mar 7nd 4:00
Surgical Block 3: OT1 Mar 7th 5:00 - Mar 7th 7:00
Day View API for 7th Mar -
openmrs/ws/rest/v1/surgicalBlock?endDatetime=2021-03-07T23:59:59.999&includeVoided=false&startDatetime=2021-03-07T00:00:00.000
Expected Result: All three sugical blocks as they are active for sometime in given date range.
Actual Result: Only surgical block 3 is returned. Surgical blocks 1,2 are not returned as they are not starting after 7th Mar 00:00 or not ended before 7th Mar 23:59.
Week View API for 7th - 13th Mar -
openmrs/ws/rest/v1/surgicalBlock?endDatetime=2021-03-13T23:59:59.999&includeVoided=false&startDatetime=2021-03-07T00:00:00.000
Expected Result: All three sugical blocks as they are active for sometime in given date range.
Actual Result: Only surgical block 1,3 are returned. Surgical block 2 is not returned as it started before 7th Mar 00:00
Conclusion: If new api parameter(activeBlocks) is passed as true then all the three surgical blocks will be returned as they are active for sometime in given time range. And same can be displayed on OT module UI.