[OT] Issues with surgical block created across multiple days

If the surgical block is spread across multiple days then the surgical block is not shown in OT module UI in day view. If the surgical block is spread across multiple days in different weeks then it will not be shown in week view as well. Thus, surgical blocks across multiple days are not visible on UI making them useless.

Analysis: This is happening because openmrs surgicalBlock get API calls take startDateTime and endDateTime as parameters. For day view API calls will send startDateTime as date 00:00 and endDateTime as date 23:59. So, only surgical blocks that start and end on the same day will be returned by API. Similarly for week view API calls only return results which will start and end in the same week.

Suggested Fix: Implement a new optional API parameter(ActiveBlocks=true/false) for sugricalBlocks openmrs API end point. By default, ActiveBlocks parameter is treated as false. If ActiveBlocks is passed as true then API will return active surgical blocks within the given date range. (i.e) If start and end date time of the same day/week are passed as api parameters then any surgical block which is active for some period in between that given range should be returned.

CC: @angshuonline @gsluthra @buvaneswariarun @binduak @vmalini @swedhan @pradiptakundu

1 Like

I feel there will quite likely be use cases in some hospitals where OT blocks might spill over across day boundaries / week boundaries.

  1. What should the intended user experience for this feature be?
  2. Can you please provide pointers to specific code where you think changes would be needed (maybe provide Github links) to support spill-overs?
  1. 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.

  2. 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.

1 Like

What usecases do you see for a block to span across day (more than 24 hrs) and across weeks? If such is the case, why can’t be it broken into multiple blocks?

@angshuonline - Isn’t is possible that someone wishes to book at 10PM-2AM slot for surgery? I think it doesn’t happen usually in hospitals - but I feel in some sites – during war/conflict – some organisations might run OTs at cross-day boundaries. They can definitely make two slots from 10PM-12AM and 12AM-2AM, but then they will be entering the same data in both blocks twice.

We might not be seeing such a requirement from existing deployments, but it could come by. Either Bahmni should not allow crossing day boundaries while creating a block, since it breaks the UI in a way – or if it allows creating such blocks, then it should also gracefully handle it by showing them up in UI. But allowing creation and then silently hiding them seems to be unexpected behavior.

Yeah, I want to make sure i understand the use case context. I have seen too many cases, where flexibility in Bahmni/OpenMRS allowing people to hack around things that should not be done.

I can understand blocks spanning 10pm-2am - but that would be extreme cases (war/conflict). but if its about creating a block across 2 days where effectively surgeries are done between 8am-2pm each day, then I don’t think we should cater for that. It allows for incorrect setup for convenience.

Similarly, I don’t understand why across weeks! If its about Sunday → Tuesday … I would like to know does that mean a surgery block will continue for 72 hours continuously having back to back surgeries? Every such busy setup will definitely maintain a surgery roster, and I don’t think the system will help if caters to convenience instead of correctness or ground scenarios.

@tarunshettygari can you elaborate your use cases?

@angshuonline Currently, in Bahmni there is no restriction from UI for creating surgical blocks across multiple days. But OT scheduling screen is not showing such surgical blocks which are created across day/week.

In our prod systems, people are creating surgical blocks across days for multiple reason.

  1. We have certain working hours for example 9-5 and people create surgical block for whole day(9-5) and schedule multiple surgeries for same surgeon. And if same surgeon needs OT lab for two day from 9-5 they tend to create surgical block like today date 9 AM - tomorrow date 5 PM. (Blocking OT lab for two days)
  2. Giving wrong end date by mistake.

Once surgical blocks are created across multiple days, there is no way to find the block anywhere in UI. And user is not even able to create new surgical block again in that period as it throws overlap error.

The above issue has occurred multiple times in our prod systems. And we have to manually run an sql query to fix the surgical block by modifying end date to fall on same day as start date.

Expected Fix:

  1. Add a validation in create surgical block page to restrict the user from creating surgical blocks across multiple days. (As mentioned in above comment there can be some extreme cases where user wants to create surgical block across days. So, we don’t recommend adding restriction from UI).
  2. Show the surgical blocks created across day/week on OT scheduling screen.
1 Like

I think it would be a good idea to raise a JIRA ticket for this. My recommendation would be:

  1. UI should provide a confirmation dialog to inform user they are creating a surgical block that cross days – and if they say Yes, then continue - else abandon. That way if someone has done this by mistake, they would get a chance to correct.
  2. As you said: UI should show all blocks created in the system, regardless of wether they are intra-day or inter-day – and should be editable by user.
1 Like

Created card on Bahmni Jira - [BAH-1170] [OT] Issues with surgical block created across multiple days - Bahmni - JIRA

1 Like