Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BedDays availability switch now correctly updates capacities #1352

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

willGraham01
Copy link
Collaborator

@willGraham01 willGraham01 commented May 16, 2024

Fixes #1346

  • A new method, switch_beddays_availability has been created to handle all steps necessary when switching the availability of beds.
  • An appropriate test for this method has been added. There is scope to parametrise this test to check other possible inputs for availability, but this in itself should be covered if we are already testing the set_scaled_capacity method which the new method depends on.

@willGraham01 willGraham01 marked this pull request as ready for review May 16, 2024 10:18
Copy link
Collaborator

@tbhallett tbhallett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @willGraham01

def switch_beddays_availability(
self,
new_availability: Literal["all", "none", "default"],
effective_on_and_from: Date,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way in which we expect to use this (i.e., from HealthSystemChangeParameters) I think we can always assume that this is equal to today's date. This is the way in which other things (consumables, equipment) have their availability updated.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With regards to this and the below comment - I think exposing effective_on_and_from and model_to_data_popsize_ratio as arguments has an advantage in terms of making it easier to test (as we can pass in relevant values directly rather than having to manipulate the other objects they would be instead read from) and keeping it's implementation decoupled from implementation details of other classes, however we can possibly still achieve this by making the current switch_beddays_availability method instead _switch_beddays_availability to indicate for internal use only, and exposing a 'public' method

   def switch_beddays_availability(self, new_availability: Literal["all", "none", "default"]) -> None:
        """..."""
        self._switch_beddays_availability(
            new_availability=new_availability, 
            effective_on_and_from=self.sim.date,
            model_to_data_popsize_ratio=self.sim.modules["Demography"].initial_model_to_data_popsize_ratio
        )

This would still allow using the current _switch_beddays_availability implementation in tests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to make a public/private method like is suggested above, though I'd quite like to avoid spreading the self.sim.modules... cross-class-coupling into the bed-days class if possible. switch_beddays_availability is already called by classes that have this cross-class-coupling anyway, so it might as well stay isolated to there?

self,
new_availability: Literal["all", "none", "default"],
effective_on_and_from: Date,
model_to_data_popsize_ratio: float = 1.0,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be nicer (I think) if the user didn't need to pass this. It hasn't changed since the beginning of the simulation, so it seems awkward to pass it in just to instruct a change in availability to all/none/default.

Copy link
Collaborator

@matt-graham matt-graham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not super familiar with bed days system but this generally looks sensible from what I can tell. Added a couple of minor comments.

tests/test_beddays.py Outdated Show resolved Hide resolved
def switch_beddays_availability(
self,
new_availability: Literal["all", "none", "default"],
effective_on_and_from: Date,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With regards to this and the below comment - I think exposing effective_on_and_from and model_to_data_popsize_ratio as arguments has an advantage in terms of making it easier to test (as we can pass in relevant values directly rather than having to manipulate the other objects they would be instead read from) and keeping it's implementation decoupled from implementation details of other classes, however we can possibly still achieve this by making the current switch_beddays_availability method instead _switch_beddays_availability to indicate for internal use only, and exposing a 'public' method

   def switch_beddays_availability(self, new_availability: Literal["all", "none", "default"]) -> None:
        """..."""
        self._switch_beddays_availability(
            new_availability=new_availability, 
            effective_on_and_from=self.sim.date,
            model_to_data_popsize_ratio=self.sim.modules["Demography"].initial_model_to_data_popsize_ratio
        )

This would still allow using the current _switch_beddays_availability implementation in tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HealthSystemChangeParameters event has no effect when asked to update BedDays policy
3 participants