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

test_equip rm to check all other tests will pass #1318

Closed

Conversation

EvaJanouskova
Copy link
Collaborator

No description provided.

EvaJanouskova and others added 30 commits March 5, 2024 16:50
diff --git src/tlo/methods/breast_cancer.py src/tlo/methods/breast_cancer.py
index 1ce9ad2bf..56c935fba 100644
--- src/tlo/methods/breast_cancer.py
+++ src/tlo/methods/breast_cancer.py
@@ -666,6 +666,8 @@ class HSI_BreastCancer_Investigation_Following_breast_lump_discernible(HSI_Event

         # Use a biopsy to diagnose whether the person has breast Cancer:
         # todo: request consumables needed for this
+        self.used_equipment = {'Slice Master sample processing Unit', 'Paraffin Dispense', 'Whatever used with biopsy',
+                               'Mammograph maybe?'}

         dx_result = hs.dx_manager.run_dx_test(
             dx_tests_to_run='biopsy_for_breast_cancer_given_breast_lump_discernible',
@@ -759,6 +761,9 @@ class HSI_BreastCancer_StartTreatment(HSI_Event, IndividualScopeEventMixin):
         df.at[person_id, "brc_date_treatment"] = self.sim.date
         df.at[person_id, "brc_stage_at_which_treatment_given"] = df.at[person_id, "brc_status"]

+        # Record used equipment
+        self.used_equipment = 'Anything used for mastectomy as I guess this is about'
+
         # Schedule a post-treatment check for 12 months:
         hs.schedule_hsi_event(
             hsi_event=HSI_BreastCancer_PostTreatmentCheck(
Co-authored-by: Tim Hallett <39991060+tbhallett@users.noreply.github.com>
…e for HSI - set in __init__, otherwise updated in apply

diff --git src/tlo/methods/breast_cancer.py src/tlo/methods/breast_cancer.py
index 5d8fabfcb..26155729a 100644
--- src/tlo/methods/breast_cancer.py
+++ src/tlo/methods/breast_cancer.py
@@ -646,6 +646,8 @@ class HSI_BreastCancer_Investigation_Following_breast_lump_discernible(HSI_Event
         self.TREATMENT_ID = "BreastCancer_Investigation"
         self.EXPECTED_APPT_FOOTPRINT = self.make_appt_footprint({"Over5OPD": 1, "Mammography": 1})
         self.ACCEPTED_FACILITY_LEVEL = '3'  # Biopsy only available at level 3 and above.
+        self.EQUIPMENT = {'Slice Master sample processing Unit', 'Paraffin Dispense', 'Whatever used with biopsy'}
+        # biopsy always performed with this HSI

     def apply(self, person_id, squeeze_factor):
         df = self.sim.population.props
@@ -666,8 +668,6 @@ class HSI_BreastCancer_Investigation_Following_breast_lump_discernible(HSI_Event

         # Use a biopsy to diagnose whether the person has breast Cancer:
         # todo: request consumables needed for this
-        self.used_equipment = {'Slice Master sample processing Unit', 'Paraffin Dispense', 'Whatever used with biopsy',
-                               'Mammograph maybe?'}

         dx_result = hs.dx_manager.run_dx_test(
             dx_tests_to_run='biopsy_for_breast_cancer_given_breast_lump_discernible',
@@ -761,8 +761,9 @@ class HSI_BreastCancer_StartTreatment(HSI_Event, IndividualScopeEventMixin):
         df.at[person_id, "brc_date_treatment"] = self.sim.date
         df.at[person_id, "brc_stage_at_which_treatment_given"] = df.at[person_id, "brc_status"]

-        # Record used equipment
-        self.used_equipment = {'Anything used for mastectomy as I guess this is about'}
+        # Update equipment used with treatment
+        # NB. read only with HSI run and healthsystem.summary logger set at the level INFO or higher
+        self.EQUIPMENT.update({'Anything used for mastectomy as I guess this is about'})

         # Schedule a post-treatment check for 12 months:
         hs.schedule_hsi_event(
diff --git src/tlo/methods/contraception.py src/tlo/methods/contraception.py
index 6ffb0ebc6..15851e1b7 100644
--- src/tlo/methods/contraception.py
+++ src/tlo/methods/contraception.py
@@ -1281,11 +1281,12 @@ class HSI_Contraception_FamilyPlanningAppt(HSI_Event, IndividualScopeEventMixin)

             _new_contraceptive = self.new_contraceptive

-            # Record used equipment when needed
+            # Update equipment when needed
+            # NB. read only with HSI run and healthsystem.summary logger set at the level of logger.INFO or higher
             if _new_contraceptive == 'female_sterilization':
-                self.used_equipment = {'Smt used to sterilize a woman'}
+                self.EQUIPMENT.update({'Smt used to sterilize a woman'})
             elif _new_contraceptive == 'IUD':
-                self.used_equipment = {'Equipment used when performing IUD'}
+                self.EQUIPMENT.update({'Equipment used when performing IUD'})

         else:
             _new_contraceptive = "not_using"
diff --git src/tlo/methods/healthsystem.py src/tlo/methods/healthsystem.py
index c19b0f433..3eb6b9940 100644
--- src/tlo/methods/healthsystem.py
+++ src/tlo/methods/healthsystem.py
@@ -182,7 +182,7 @@ class HSI_Event:
         self._received_info_about_bed_days = None
         self.expected_time_requests = {}
         self.facility_info = None
-        self.used_equipment = set()
+        self.EQUIPMENT = set()

     @Property
     def bed_days_allocated_to_this_event(self):
@@ -1741,7 +1741,7 @@ class HealthSystem(Module):
                 squeeze_factor=_squeeze_factor,
                 did_run=did_run,
                 priority=priority,
-                equipment=hsi_event.used_equipment,
+                equipment=hsi_event.EQUIPMENT,
             )

     def write_to_hsi_log(
diff --git src/tlo/methods/breast_cancer.py src/tlo/methods/breast_cancer.py
index 26155729a..aef476c87 100644
--- src/tlo/methods/breast_cancer.py
+++ src/tlo/methods/breast_cancer.py
@@ -647,7 +647,7 @@ class HSI_BreastCancer_Investigation_Following_breast_lump_discernible(HSI_Event
         self.EXPECTED_APPT_FOOTPRINT = self.make_appt_footprint({"Over5OPD": 1, "Mammography": 1})
         self.ACCEPTED_FACILITY_LEVEL = '3'  # Biopsy only available at level 3 and above.
         self.EQUIPMENT = {'Slice Master sample processing Unit', 'Paraffin Dispense', 'Whatever used with biopsy'}
-        # biopsy always performed with this HSI
+        # biopsy always performed with this HSI, hence always used the same set of equipment

     def apply(self, person_id, squeeze_factor):
         df = self.sim.population.props
…hsi_event_details, counts logged in hsi_event_counts)
diff --git src/tlo/methods/healthsystem.py src/tlo/methods/healthsystem.py
index d14f8f10a..5ecb43368 100644
--- src/tlo/methods/healthsystem.py
+++ src/tlo/methods/healthsystem.py
@@ -2611,7 +2611,7 @@ class HealthSystemScheduler(RegularEvent, PopulationScopeEventMixin):
                     squeeze_factor=0.0,
                     priority=-1,
                     did_run=True,
-                    equipment=set()  # TODO: explore more, should it be non-emtpy in some cases?
+                    equipment=set(),  # TODO: explore more, should it be non-empty in some cases?
                 )

         # Restart the total footprint of all calls today, beginning with those due to existing in-patients.
@@ -2666,7 +2666,6 @@ class HealthSystemSummaryCounter:
         self._appts = defaultdict(int)  # Running record of the Appointments of `HSI_Event`s that have run
         self._appts_by_level = {_level: defaultdict(int) for _level in ('0', '1a', '1b', '2', '3', '4')}
         # <--Same as `self._appts` but also split by facility_level
-        self._equip_by_level = {_level: set() for _level in ('0', '1a', '1b', '2', '3', '4')}

         # Log HSI_Events that never ran to monitor shortcoming of Health System
         self._never_ran_treatment_ids = defaultdict(int)  # As above, but for `HSI_Event`s that never ran
@@ -2683,8 +2682,7 @@ class HealthSystemSummaryCounter:
                          hsi_event_name: str,
                          squeeze_factor: float,
                          appt_footprint: Counter,
-                         level: str,
-                         equipment: set
+                         level: str
                          ) -> None:
         """Add information about an `HSI_Event` to the running summaries."""

@@ -2701,9 +2699,6 @@ class HealthSystemSummaryCounter:
             self._appts[appt_type] += number
             self._appts_by_level[level][appt_type] += number

-        # Update used equipment by level
-        self._equip_by_level[level].update(equipment)
-
     def record_never_ran_hsi_event(self,
                                    treatment_id: str,
                                    hsi_event_name: str,
@@ -2766,17 +2761,6 @@ class HealthSystemSummaryCounter:
             },
         )

-        # Sort equipment within levels, and log them
-        for key in self._equip_by_level:
-            self._equip_by_level[key] = sorted(self._equip_by_level[key])
-        logger_summary.info(
-            key="Equipment",
-            description="Sets of used equipment for each facility level in this calendar year.",
-            data={
-                "Equipment_By_Level": self._equip_by_level,
-            },
-        )
-
         self._reset_internal_stores()
EvaJanouskova and others added 25 commits March 5, 2024 16:52
… equip availability (before/within HSI); avail switcher; dummy probs by fac_level = 0.5; tests updated; TODOs added
# Conflicts:
#       resources/healthsystem/ResourceFile_HealthSystem_parameters.csv
#       src/tlo/methods/healthsystem.py
#       src/tlo/methods/hsi_event.py
@EvaJanouskova EvaJanouskova marked this pull request as draft April 13, 2024 10:07
Base automatically changed from EvaJ/equipment/structure_ToRunSim to master May 16, 2024 11:50
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.

None yet

2 participants