Skip to content

BedDays can over-allocate facility beds when combining footprints #1399

@willGraham01

Description

@willGraham01

Whilst working on speedups & unit tests in #1392, I noticed the following behaviour in the model. Not sure if this is intended/accepted, but it struck me as odd so mentioning it here.

At present, when a person is already an inpatient and they are scheduled additional bed days at a facility, their remaining footprint is combined with the incoming footprint when allocating the total bed days they should be provided.

This can result in a facility being over-allocated in a particular type of bed. For example, consider the situation where (at some facility):

  • A person with ID p is currently scheduled to occupy bed_type1 on 2010-01-01 and 2010-01-02.
  • On 2010-01-01, p is scheduled another appointment that imposes a footprint of bed_type1 for 1 day, and bed_type2 for 6 days.

"Combining" the existing footprint with the incoming one, as is what is currently done, results in:

  • p occupies bed_type1 on 2010-01-01 and 2010-01-02,
  • p occupies bed_type2 on 2010-01-03 through to 2010-01-08.

However, there is no guarantee that bed_type2 is available on 2010-01-08 or 2010-01-07. The incoming footprint was allocated assuming the footprint would start on 2010-01-01, thus only reserving bed_type2 space until 2010-01-06. The existing footprint doesn't reserve any bed_type2s. As a result, the facility can be over-allocated for bed_type2 on 2010-01-08 and 2010-01-07. Since this logic applies to all HSI events, multiple patients can encounter the same issue, resulting in larger over-allocations on particular days.

Running the scale_run script for 1 year with an initial population of 10,000 will produce an example of this behaviour for patient 10107 on 2010-07-04. They occupy a general_bed on 2010-07-04 for the rest of that day. However on 2010-07-04 they are also given a new allocation for 7 non_bed_space days, to start immediately. The resulting combined footprint runs until 2010-07-11, however there is no guarantee that on 2010-07-11 there will be a bed for them.

Possible Solutions

If there is meant to be a "consistency check" for cases such as this, the impose_beddays_footprint function is too late to run it since bed days footprints are imposed after the HSI event has already run, so we cannot "undo" the HSI event that is in conflict. This check could be moved to happen earlier though, although I'm not sure on the exact location in the codebase as to where it should go.

Alternatively, it would be possible (at this stage in the code) to combine the two footprints by allocating the highest priority bed on any given day that they overlap, rather than extending the existing one. So in the case above;

  • p would occupy bed_type1 on 2010-01-01 and 2010-01-02.
  • p occupies bed_type2 from 2010-01-03 through to 2010-01-07.

Both the current and incoming footprints need bed_type1 on 2010-01-01. On 2010-01-02, the bed_type2 requirement from the incoming footprint can be satisfied by assigning the "higher-priority" occupation of bed_type1 from the current footprint.
Then from 2010-01-03 we allocate the remaining 5 days of bed_type2 from the incoming footprint.
This is guaranteed not to result in beds being over-allocated, since both footprints have checked for the availability of their respective beds, and we select the greatest of the two, rather than requesting both and allocating more bed-time without checking for it. However, it is a distinct behaviour from that which is currently implemented.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions