Skip to content

Enable switching service availability in healthsystem module#1802

Open
sangeetabhatia03 wants to merge 18 commits intomasterfrom
sb/lcoa-inputs-from-tlo
Open

Enable switching service availability in healthsystem module#1802
sangeetabhatia03 wants to merge 18 commits intomasterfrom
sb/lcoa-inputs-from-tlo

Conversation

@sangeetabhatia03
Copy link
Collaborator

This pull request enables switching of service availability in the healthsystem module. Key changes include the addition of new parameters for service availability switching.

I have also created a scenario file for our initial analysis; would be great to get your feedback on this.

@@ -0,0 +1,45 @@
"""The file contains all the definitions of scenarios for the TLO-LCOA project."""
Copy link
Collaborator

Choose a reason for hiding this comment

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

just a quick look at this -- why not put this into your main scenario file?

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.

Nice logic and nice test.

Personal taste but I would suggest simplifying the scenario file so that we have everything in one file. (The style of having it split across multiple files is useful when we have lots of scenario file drawing from the same 'base', but it feel a bit confusing here).

Comment on lines +2125 to +2126
if (self.sim.date.year == self.parameters['year_service_availability_switch'] - 1):
self._compute_factors_for_effective_capabilities()
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is fine. but its different to the pattern we have for other changes - which is to schedule an event to occur on the date we we want the switch to happen, and then let the event do this work. Don't feel strongly about this!

# Don't increment the counter; log and return.
if not self.is_treatment_id_allowed(hsi_event.TREATMENT_ID, self.service_availability):
self.call_and_record_never_ran_hsi_event(hsi_event=hsi_event, priority=priority, clinic=clinic)
return
Copy link
Collaborator

Choose a reason for hiding this comment

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

we don't need this 'return'

Comment on lines +1266 to +1277
def _compute_factors_for_effective_capabilities(self):
"""Compute factor to rescale capabilities to capture effective capability.
Computation of these factors is split from the actual rescaling to facilitate
capturing them even when running the model in mode 1."""
self._rescaling_factors = defaultdict(dict)
for clinic, clinic_cl in self._daily_capabilities.items():
for facID_and_officer in clinic_cl.keys():
self._rescaling_factors[clinic][facID_and_officer] = self._summary_counter.frac_time_used_by_facID_and_officer(
facID_and_officer=facID_and_officer, clinic=clinic
)
self._summary_counter._rescaling_factors = self._rescaling_factors

Copy link
Collaborator

Choose a reason for hiding this comment

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

is this intended to be on this PR?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, so that we can log rescaling factors.

Copy link
Collaborator

@marghe-molaro marghe-molaro left a comment

Choose a reason for hiding this comment

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

Hi @sangeetabhatia03, this is looking great, I've just added a few comments!
Summary:

  • I agree with Tim about having a single scenario file
  • I've suggested tightening the test just a little bit, it shouldn't take too long!

# First check that the service the HSI needs is available. If not, don't add to queue.
# Don't increment the counter; log and return.
if not self.is_treatment_id_allowed(hsi_event.TREATMENT_ID, self.service_availability):
self.call_and_record_never_ran_hsi_event(hsi_event=hsi_event, priority=priority, clinic=clinic)
Copy link
Collaborator

Choose a reason for hiding this comment

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

To be consistent with how HSIs are removed from the queue when the HSI is no longer available in the health system, I think here too never_ran should be scheduled for topen

super().__init__()
self.seed = 0
self.start_date = Date(2010, 1, 1)
self.end_date = Date(2040, 1, 1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think to have full 15 years from the 1st of Jan 2026 you want to end this on the 1st of Jan 2041

self.seed = 0
self.start_date = Date(2010, 1, 1)
self.end_date = Date(2040, 1, 1)
self.pop_size = 100
Copy link
Collaborator

Choose a reason for hiding this comment

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

Assuming this is a relic from local tests, but just to remind ourselves I think we said we were going to go up to 250k?

'yearly_HR_scaling_mode': 'historical_scaling',
},

"ImprovedHealthSystemAndCareSeekingScenarioSwitcher": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just checking - did you check that these are compatible with the suspend/resume on Azure?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As discussed with @marghe-molaro parking this check for now because switching to max_healthsystem_function and max_healthcare_seeking is the same across all draws for our current analysis.

'year_of_switch': self.YEAR_OF_SERVICE_AVAILABILITY_SWITCH,
},

"ImprovedHealthSystemAndCareSeekingScenarioSwitcher": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

As above, would be good to double check that this is compatible

scenario_definitions.baseline(),
{
'HealthSystem': {
'service_availability_postSwitch': list(self._scenarios.values())[draw_number],
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess you've tested locally that the conversion into a list here makes the different service_availability configurations accessible via draw_number? Just struggling to wrap my head around it without running it

level="0",
treatment_id="ThisEventShouldNotRunPostSwitch",
)
## These events open after service availability switch
Copy link
Collaborator

Choose a reason for hiding this comment

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

To tighten this test a little bit, it would be good to schedule say 60% of these treatment_IDs before the switch, and 40% after. You then want to double check that 60% did go ahead (and all with dates < switch), and that 40% were never ran.

The "risk" of treatment_IDs "slipping" into the post-switch period and affecting the health outcome is I think higher than treatment_IDs being scheduled in that period at all!

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.

3 participants