-
Notifications
You must be signed in to change notification settings - Fork 16
Description
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
pis currently scheduled to occupybed_type1on2010-01-01and2010-01-02. - On
2010-01-01,pis scheduled another appointment that imposes a footprint ofbed_type1for 1 day, andbed_type2for 6 days.
"Combining" the existing footprint with the incoming one, as is what is currently done, results in:
poccupiesbed_type1on2010-01-01and2010-01-02,poccupiesbed_type2on2010-01-03through to2010-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;
pwould occupybed_type1on2010-01-01and2010-01-02.poccupiesbed_type2from2010-01-03through to2010-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.