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

Equipment: Integration into modules #1341

Merged
merged 461 commits into from
Jun 20, 2024
This pull request is big! We’re only showing the most recent 250 commits.

Commits on Dec 4, 2023

  1. Configuration menu
    Copy the full SHA
    3a8fd28 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    38f07b3 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    72b6a2a View commit details
    Browse the repository at this point in the history
  4. diarrhoea equipment added

    joehcollins authored and EvaJanouskova committed Dec 4, 2023
    Configuration menu
    Copy the full SHA
    29f9fc9 View commit details
    Browse the repository at this point in the history
  5. initial RTI equipment added. updated confusing naming of consumables …

    …as equipment in MNH modules
    joehcollins authored and EvaJanouskova committed Dec 4, 2023
    Configuration menu
    Copy the full SHA
    30d760e View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    0f16f59 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    5354899 View commit details
    Browse the repository at this point in the history
  8. nb: rm finished TODO

    EvaJanouskova committed Dec 4, 2023
    Configuration menu
    Copy the full SHA
    7adde5f View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    b7ad900 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    7295d1a View commit details
    Browse the repository at this point in the history
  11. brc & co: add TODOs to replace dummy examples by real equip items

    diff --git src/tlo/methods/breast_cancer.py src/tlo/methods/breast_cancer.py
    index 402266516..57e842119 100644
    --- src/tlo/methods/breast_cancer.py
    +++ src/tlo/methods/breast_cancer.py
    @@ -646,8 +646,9 @@ 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.
    -        # TODO: but the appt footprints suggests mammography to be provided
    -        self.EQUIPMENT = {'Slice Master sample processing Unit', 'Paraffin Dispense', 'Whatever used with biopsy'}
    +
    +        # TODO: Eva's dummy equipment example (not sure if it actually needs to be added and if it is in the RF)
    +        #  {'Slice Master sample processing Unit', 'Paraffin Dispense', 'Whatever used with biopsy'}
    
             # ap_oct23 - Eva, I cannot locate a biopsy needle in the equipment - perhaps it is in consumables
             # the other equipment need is for histology in the lab - there is a whole long list of items needed
    @@ -771,8 +772,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"]
    
    +        # TODO: Eva's dummy equipment example - it needs to be replaced by real items from the RF
             # Update equipment
    -        self.EQUIPMENT.update({'Anything used for mastectomy'})
    +        # self.EQUIPMENT.update({'Anything used for mastectomy'})
    
             # 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 6f9e4254b..8c9821b0c 100644
    --- src/tlo/methods/contraception.py
    +++ src/tlo/methods/contraception.py
    @@ -1284,8 +1284,10 @@ class HSI_Contraception_FamilyPlanningAppt(HSI_Event, IndividualScopeEventMixin)
    
                 # Update equipment
                 if _new_contraceptive == 'female_sterilization':
    +                # TODO: Eva's dummy example - needs to be replaced by real item(s)
                     self.EQUIPMENT.update({'Smt used to sterilize a woman'})
                 elif _new_contraceptive == 'IUD':
    +                # TODO: Eva's dummy example - needs to be replaced by real item(s)
                     self.EQUIPMENT.update({'Equipment used when performing IUD'})
    
             else:
    EvaJanouskova committed Dec 4, 2023
    Configuration menu
    Copy the full SHA
    ae05be9 View commit details
    Browse the repository at this point in the history
  12. fix mistakes from the rebase

    diff --git src/tlo/methods/care_of_women_during_pregnancy.py src/tlo/methods/care_of_women_during_pregnancy.py
    index 2944ee41f..96a4b6975 100644
    --- src/tlo/methods/care_of_women_during_pregnancy.py
    +++ src/tlo/methods/care_of_women_during_pregnancy.py
    @@ -572,7 +572,7 @@ class CareOfWomenDuringPregnancy(Module):
    
         def antenatal_care_scheduler(self, individual_id, visit_to_be_scheduled, recommended_gestation_next_anc):
             """
    -        This function is responsible for scheduling a womans next ANC contact in the schedule if she chooses to seek
    +        This function is responsible for scheduling a woman's next ANC contact in the schedule if she chooses to seek
             care again.  It is called by each of the ANC HSIs.
             :param individual_id: individual_id
             :param visit_to_be_scheduled: Number if next visit in the schedule (2-8)
    @@ -1572,8 +1572,8 @@ class HSI_CareOfWomenDuringPregnancy_SecondAntenatalCareContact(HSI_Event, Indiv
                     self.module.antenatal_care_scheduler(person_id, visit_to_be_scheduled=3,
                                                          recommended_gestation_next_anc=gest_age_next_contact)
    
    -            # Then we administer interventions that are due to be delivered at this womans gestational age, which may be
    -            # in addition to intervention delivered in ANC2
    +            # Then we administer interventions that are due to be delivered at this woman's gestational age, which may
    +            # be in addition to intervention delivered in ANC2
                 if mother.ps_gestational_age_in_weeks < 26:
                     self.module.albendazole_administration(hsi_event=self)
                     self.module.iptp_administration(hsi_event=self)
    @@ -1621,7 +1621,7 @@ class HSI_CareOfWomenDuringPregnancy_ThirdAntenatalCareContact(HSI_Event, Indivi
         antenatal care contact (ANC3). It is scheduled by the HSI_CareOfWomenDuringPregnancy_SecondAntenatalCareContact for
         women who choose to seek additional ANC after their previous visit. It is recommended that this visit occur at 26
         weeks gestation. This event delivers the interventions to women which are part of ANC3. Additionally interventions
    -    that should be delivered according to a womans gestational age and position in her ANC schedule are delivered.
    +    that should be delivered according to a woman's gestational age and position in her ANC schedule are delivered.
         Finally scheduling the next ANC contact in the occurs during this HSI along with admission to antenatal inpatient
         ward in the case of complications"""
    EvaJanouskova committed Dec 4, 2023
    Configuration menu
    Copy the full SHA
    f9cca95 View commit details
    Browse the repository at this point in the history

Commits on Dec 6, 2023

  1. Merge remote-tracking branch 'origin/equipment/integration_in_modules…

    …' into equipment/integration_in_modules
    
    # Conflicts:
    #	resources/healthsystem/infrastructure_and_equipment/ResourceFile_Equipment.csv
    #	src/scripts/healthsystem/equipment/equipment_catalogue.py
    #	src/tlo/methods/breast_cancer.py
    #	src/tlo/methods/care_of_women_during_pregnancy.py
    #	src/tlo/methods/contraception.py
    #	src/tlo/methods/healthsystem.py
    #	src/tlo/methods/newborn_outcomes.py
    joehcollins committed Dec 6, 2023
    Configuration menu
    Copy the full SHA
    287a80b View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    312aaa3 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    f1d4ee0 View commit details
    Browse the repository at this point in the history
  4. equip_catalogue: (1) detailed - equip set as string in one row, modul…

    …e_name before event_name, sorted by indexes; (2) added summary catal. (3) focused - only this cat. without empty equip rows and split by item per row
    EvaJanouskova committed Dec 6, 2023
    Configuration menu
    Copy the full SHA
    4325c78 View commit details
    Browse the repository at this point in the history
  5. co: equipment updated

    EvaJanouskova committed Dec 6, 2023
    Configuration menu
    Copy the full SHA
    b42c15b View commit details
    Browse the repository at this point in the history
  6. equip_catalogue: (1) detailed - equip set as string in one row, modul…

    …e_name before event_name, sorted by indexes; (2) added summary catal. (3) focused - only this cat. without empty equip rows and split by item per row
    EvaJanouskova committed Dec 6, 2023
    Configuration menu
    Copy the full SHA
    6ff025c View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    bf83c61 View commit details
    Browse the repository at this point in the history
  8. Merge branch 'EvaJ/equipment/structure_ToRunSim' into equipment/integ…

    …ration_in_modules
    
    # Conflicts:
    #	src/scripts/healthsystem/equipment/equipment_catalogue.py
    EvaJanouskova committed Dec 6, 2023
    Configuration menu
    Copy the full SHA
    0216daa View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    0a5d8e7 View commit details
    Browse the repository at this point in the history
  10. equip_catalogue: typo

    EvaJanouskova committed Dec 6, 2023
    Configuration menu
    Copy the full SHA
    8fb6496 View commit details
    Browse the repository at this point in the history

Commits on Dec 11, 2023

  1. Configuration menu
    Copy the full SHA
    51595fa View commit details
    Browse the repository at this point in the history
  2. RTI equipment first pass

    joehcollins committed Dec 11, 2023
    Configuration menu
    Copy the full SHA
    77a0926 View commit details
    Browse the repository at this point in the history

Commits on Jan 2, 2024

  1. Configuration menu
    Copy the full SHA
    7cd4fc3 View commit details
    Browse the repository at this point in the history

Commits on Jan 12, 2024

  1. adding consumables for the cancer modules. consumables are defined in…

    … cancer_consumables.py to prevent repeating code blocks
    joehcollins committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    bc726c2 View commit details
    Browse the repository at this point in the history
  2. adding equipment (first pass) to cancer modules. In addition have upd…

    …ated spelling of cystoscopy within bladder_cancer.py and the associated resource file.
    joehcollins committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    9889da9 View commit details
    Browse the repository at this point in the history
  3. formatting

    joehcollins committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    a057c40 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    bfaef67 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    7b4e331 View commit details
    Browse the repository at this point in the history
  6. formatting

    joehcollins committed Jan 12, 2024
    Configuration menu
    Copy the full SHA
    7cb9f2a View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    9b173d7 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    c53dc8c View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    ab105e8 View commit details
    Browse the repository at this point in the history

Commits on Jan 13, 2024

  1. Configuration menu
    Copy the full SHA
    451f262 View commit details
    Browse the repository at this point in the history
  2. breast_cancer: dummy used_equipment added where Andrew requested

    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(
    EvaJanouskova committed Jan 13, 2024
    Configuration menu
    Copy the full SHA
    b8da673 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    d685c69 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    a00d25a View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    b7cc852 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    7f5c575 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    c4b316b View commit details
    Browse the repository at this point in the history
  8. healthsystem: sort equipment for log

    Co-authored-by: Tim Hallett <39991060+tbhallett@users.noreply.github.com>
    EvaJanouskova and tbhallett committed Jan 13, 2024
    Configuration menu
    Copy the full SHA
    79ba1c1 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    328bb78 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    8fae9b3 View commit details
    Browse the repository at this point in the history
  11. hs, brc, co: used_equipment renamed to EQUIPMENT; if equip always sam…

    …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(
    EvaJanouskova committed Jan 13, 2024
    Configuration menu
    Copy the full SHA
    c4615da View commit details
    Browse the repository at this point in the history
  12. brc: comment updated

    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
    EvaJanouskova committed Jan 13, 2024
    Configuration menu
    Copy the full SHA
    0d9e216 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    ecc5981 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    a3d726e View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    d8a53b2 View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    e7a8e56 View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    bd55b0d View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    ed50338 View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    5576de9 View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    ba97098 View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    d114b2d View commit details
    Browse the repository at this point in the history
  22. Configuration menu
    Copy the full SHA
    e88babe View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    13af328 View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    ac22da6 View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    178e996 View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    b7c4e86 View commit details
    Browse the repository at this point in the history
  27. equip_catalogue: make catalogues from new logging (equip included in …

    …hsi_event_details, counts logged in hsi_event_counts)
    EvaJanouskova committed Jan 13, 2024
    Configuration menu
    Copy the full SHA
    c9f9da7 View commit details
    Browse the repository at this point in the history
  28. Configuration menu
    Copy the full SHA
    c311825 View commit details
    Browse the repository at this point in the history
  29. Configuration menu
    Copy the full SHA
    811da1f View commit details
    Browse the repository at this point in the history
  30. [no ci] hs: typo; Equipment logging removed

    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 committed Jan 13, 2024
    Configuration menu
    Copy the full SHA
    5c90ad4 View commit details
    Browse the repository at this point in the history
  31. Configuration menu
    Copy the full SHA
    e970814 View commit details
    Browse the repository at this point in the history
  32. Configuration menu
    Copy the full SHA
    f4a91fb View commit details
    Browse the repository at this point in the history
  33. Configuration menu
    Copy the full SHA
    81a6eff View commit details
    Browse the repository at this point in the history
  34. Configuration menu
    Copy the full SHA
    d6fa91d View commit details
    Browse the repository at this point in the history
  35. equip_catalogue: verify inputs as expected & set output file names in…

    … 'create_equipment_catalogues' fnc
    EvaJanouskova committed Jan 13, 2024
    Configuration menu
    Copy the full SHA
    903adcc View commit details
    Browse the repository at this point in the history
  36. equip_catalogue: (1) detailed - equip set as string in one row, modul…

    …e_name before event_name, sorted by indexes; (2) added summary catal. (3) focused - only this cat. without empty equip rows and split by item per row
    EvaJanouskova committed Jan 13, 2024
    Configuration menu
    Copy the full SHA
    1d9c594 View commit details
    Browse the repository at this point in the history
  37. Configuration menu
    Copy the full SHA
    df7479e View commit details
    Browse the repository at this point in the history
  38. hs: structure v2; alri+co: examples to test new structure

    diff --git src/tlo/methods/alri.py src/tlo/methods/alri.py
    index e4b0b46d1..c211e3317 100644
    --- src/tlo/methods/alri.py
    +++ src/tlo/methods/alri.py
    @@ -2290,6 +2290,8 @@ class HSI_Alri_Treatment(HSI_Event, IndividualScopeEventMixin):
             self._treatment_id_stub = 'Alri_Pneumonia_Treatment'
             self._facility_levels = ("0", "1a", "1b", "2")  # Health facility levels at which care may be provided
             assert facility_level in self._facility_levels
    +        self.set_essential_equipment({'Pulse oximeter'})
    +        # TODO: CORRECT --- an example with ess. equipm. set (which may or may not be used at the end)
             self.is_followup_following_treatment_failure = is_followup_following_treatment_failure
    
             if not inpatient:
    @@ -2596,6 +2598,8 @@ class HSI_Alri_Treatment(HSI_Event, IndividualScopeEventMixin):
                      'cough_or_cold'                    (symptoms-based assessment)
              }."""
    
    +        self.update_equipment({'Pulse oximeter'})
    +
             child_is_younger_than_2_months = age_exact_years < (2.0 / 12.0)
    
             imci_classification_based_on_symptoms = self._get_imci_classification_based_on_symptoms(
    diff --git src/tlo/methods/contraception.py src/tlo/methods/contraception.py
    index f86e342c8..d6786dd39 100644
    --- src/tlo/methods/contraception.py
    +++ src/tlo/methods/contraception.py
    @@ -353,7 +353,7 @@ class Contraception(Module):
                 # Increase prob of 'female_sterilization' in older women accordingly
                 probs_30plus = probs.copy()
                 probs_30plus['female_sterilization'] = (
    -                probs.loc['female_sterilization'] /
    +                probs.loc['female_sterilization'] /
                     self.ratio_n_females_30_49_to_15_49_in_2010
                 )
                 # Scale so that the probability of all outcomes sum to 1.0
    @@ -633,7 +633,7 @@ class Contraception(Module):
                 # Increase prob of 'female_sterilization' in older women accordingly
                 probs_30plus = probs.copy()
                 probs_30plus['female_sterilization'] = (
    -                probs.loc['female_sterilization'] /
    +                probs.loc['female_sterilization'] /
                     self.ratio_n_females_30_49_to_15_49_in_2010
                 )
                 # Scale so that the probability of all outcomes sum to 1.0
    @@ -1194,6 +1194,7 @@ class HSI_Contraception_FamilyPlanningAppt(HSI_Event, IndividualScopeEventMixin)
    
             self.TREATMENT_ID = "Contraception_Routine"
             self.ACCEPTED_FACILITY_LEVEL = _facility_level
    +        self.set_essential_equipment({''})
    
         @Property
         def EXPECTED_APPT_FOOTPRINT(self):
    @@ -1229,6 +1230,11 @@ class HSI_Contraception_FamilyPlanningAppt(HSI_Event, IndividualScopeEventMixin)
             # Record the date that Family Planning Appointment happened for this person
             self.sim.population.props.at[person_id, "co_date_of_last_fp_appt"] = self.sim.date
    
    +        # Measure weight, height and BP even if contraception not administrated
    +        self.update_equipment({
    +            'Weighing scale', 'Height Pole (Stadiometer)', 'Blood pressure machine'
    +        })
    +
             # Determine essential and optional items
             # TODO: we don't distinguish essential X optional for contraception methods yet, will need to update once we do
             items_essential = self.module.cons_codes[self.new_contraceptive]
    @@ -1255,7 +1261,8 @@ class HSI_Contraception_FamilyPlanningAppt(HSI_Event, IndividualScopeEventMixin)
             items_all = {**items_essential, **items_optional}
    
             # Determine whether the contraception is administrated (ie all essential items are available),
    -        # if so do log the availability of all items, if not set the contraception to "not_using":
    +        # if so do log the availability of all items and update used equipment if any, if not set the contraception to
    +        # "not_using":
             co_administrated = all(v for k, v in cons_available.items() if k in items_essential)
    
             if co_administrated:
    @@ -1280,6 +1287,16 @@ class HSI_Contraception_FamilyPlanningAppt(HSI_Event, IndividualScopeEventMixin)
    
                 _new_contraceptive = self.new_contraceptive
    
    +            # Update equipment if any needed for the method
    +            if _new_contraceptive == 'female_sterilization':
    +                self.update_equipment({
    +                    'Cusco’s/ bivalved Speculum (small, medium, large)', 'Lamp, Anglepoise'
    +                })
    +            elif _new_contraceptive == 'IUD':
    +                self.update_equipment({
    +                    'Cusco’s/ bivalved Speculum (small, medium, large)', 'Sponge Holding Forceps'
    +                })
    +
             else:
                 _new_contraceptive = "not_using"
    
    diff --git src/tlo/methods/healthsystem.py src/tlo/methods/healthsystem.py
    index 5ecb43368..1ad875f67 100644
    --- src/tlo/methods/healthsystem.py
    +++ src/tlo/methods/healthsystem.py
    @@ -183,6 +183,7 @@ class HSI_Event:
             self._received_info_about_bed_days = None
             self.expected_time_requests = {}
             self.facility_info = None
    +        # self.set_essential_equipment({''})  # HSI needs this attribute, but it is not defined in the Base class
             self.EQUIPMENT = set()
    
         @Property
    @@ -339,6 +340,37 @@ class HSI_Event:
                 "values"
             )
    
    +    def set_essential_equipment(self, set_of_equip):
    +        """Helper function to set essential equipment.
    +
    +        Should be passed a set of equipment items names (strings) or an empty set.
    +        """
    +        # Set EQUIPMENT if the given set_of_equip in correct format, ie a set of strings or an empty set
    +        if isinstance(set_of_equip, set) and all(isinstance(item, str) for item in set_of_equip):
    +            self.ESSENTIAL_EQUIPMENT  = set_of_equip
    +            return 0
    +
    +        raise ValueError(
    +            "Argument to set_essential_equipment should be an empty set or a set of strings of equipment item names "
    +            "from ResourceFile_Equipment.csv."
    +        )
    +
    +    def update_equipment(self, set_of_equip):
    +        """Helper function to update equipment.
    +
    +        Should be passed a set of equipment item names (strings).
    +        """
    +        # Update EQUIPMENT if the given set_of_equip in correct format, ie a non-empty set of strings
    +        if isinstance(set_of_equip, set) and (all(isinstance(item, str) for item in set_of_equip)) and \
    +           (set_of_equip not in [set(), None, {''}]):
    +            self.EQUIPMENT.update(set_of_equip)
    +            return self.EQUIPMENT.discard('')
    +
    +        raise ValueError(
    +            "Argument to update_equipment should be a non-empty set of strings of equipment item names "
    +            "from ResourceFile_Equipment.csv."
    +        )
    +
         def initialise(self):
             """Initialise the HSI:
             * Set the facility_info
    EvaJanouskova committed Jan 13, 2024
    Configuration menu
    Copy the full SHA
    c67618c View commit details
    Browse the repository at this point in the history
  39. Configuration menu
    Copy the full SHA
    422bfbf View commit details
    Browse the repository at this point in the history
  40. equip_catalogue: typo

    EvaJanouskova committed Jan 13, 2024
    Configuration menu
    Copy the full SHA
    0eaacc3 View commit details
    Browse the repository at this point in the history
  41. Configuration menu
    Copy the full SHA
    d99310a View commit details
    Browse the repository at this point in the history
  42. Configuration menu
    Copy the full SHA
    9d31842 View commit details
    Browse the repository at this point in the history
  43. brc: TODO added

    EvaJanouskova committed Jan 13, 2024
    Configuration menu
    Copy the full SHA
    2c5a436 View commit details
    Browse the repository at this point in the history
  44. hs: rm prints

    EvaJanouskova committed Jan 13, 2024
    Configuration menu
    Copy the full SHA
    14f426a View commit details
    Browse the repository at this point in the history
  45. hs: rm old code

    EvaJanouskova committed Jan 13, 2024
    Configuration menu
    Copy the full SHA
    e9c09ec View commit details
    Browse the repository at this point in the history
  46. Configuration menu
    Copy the full SHA
    b88f251 View commit details
    Browse the repository at this point in the history

Commits on Jan 15, 2024

  1. Configuration menu
    Copy the full SHA
    507eb4e View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    68ae9b0 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    7fb9ee8 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    c49dce0 View commit details
    Browse the repository at this point in the history
  5. bc: typos fixed

    EvaJanouskova committed Jan 15, 2024
    Configuration menu
    Copy the full SHA
    a82704e View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    3d9a2c3 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    92d11cb View commit details
    Browse the repository at this point in the history
  8. me: within HSI_Me_Treatment equip for me. with pneumonia updated only…

    … if essen. consumbales avail.
    EvaJanouskova committed Jan 15, 2024
    Configuration menu
    Copy the full SHA
    de2a7c3 View commit details
    Browse the repository at this point in the history

Commits on Jan 16, 2024

  1. Configuration menu
    Copy the full SHA
    0111625 View commit details
    Browse the repository at this point in the history

Commits on Jan 17, 2024

  1. Configuration menu
    Copy the full SHA
    dc21979 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    cdaa44a View commit details
    Browse the repository at this point in the history

Commits on Jan 19, 2024

  1. Configuration menu
    Copy the full SHA
    287ee67 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    812a9e2 View commit details
    Browse the repository at this point in the history
  3. hs: PEP8

    EvaJanouskova committed Jan 19, 2024
    Configuration menu
    Copy the full SHA
    b70b2e4 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    8cd81d0 View commit details
    Browse the repository at this point in the history

Commits on Jan 21, 2024

  1. Configuration menu
    Copy the full SHA
    a7426b1 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    fc6bea2 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    1c987c3 View commit details
    Browse the repository at this point in the history

Commits on Jan 24, 2024

  1. Configuration menu
    Copy the full SHA
    38ff44c View commit details
    Browse the repository at this point in the history

Commits on Jan 30, 2024

  1. hs: ESS_EQUIP as HSI_Event's attribute; if settings of ESS_EQUIP forg…

    …otten -> set to empty & warn
    EvaJanouskova committed Jan 30, 2024
    Configuration menu
    Copy the full SHA
    e0132f8 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    2859530 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    e5df950 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    5c66328 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    8daa621 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    1a69dca View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    42492fa View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    d0d2828 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    d1c7523 View commit details
    Browse the repository at this point in the history

Commits on Feb 1, 2024

  1. Configuration menu
    Copy the full SHA
    c317540 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    e8bb6b7 View commit details
    Browse the repository at this point in the history
  3. update comments in rti

    joehcollins committed Feb 1, 2024
    Configuration menu
    Copy the full SHA
    32bb66b View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    6ace152 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    14ab62f View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    41646c8 View commit details
    Browse the repository at this point in the history

Commits on Feb 5, 2024

  1. Merge remote-tracking branch 'origin/EvaJ/equipment/structure_ToRunSi…

    …m' into equipment/integration_in_modules
    
    # Conflicts:
    #	resources/healthsystem/infrastructure_and_equipment/ResourceFile_Equipment.csv
    #	src/scripts/healthsystem/equipment/equipment_catalogue.py
    #	src/tlo/analysis/utils.py
    #	src/tlo/methods/alri.py
    #	src/tlo/methods/breast_cancer.py
    #	src/tlo/methods/care_of_women_during_pregnancy.py
    #	src/tlo/methods/contraception.py
    #	src/tlo/methods/healthsystem.py
    #	src/tlo/methods/labour.py
    #	src/tlo/methods/newborn_outcomes.py
    EvaJanouskova committed Feb 5, 2024
    Configuration menu
    Copy the full SHA
    eac9f36 View commit details
    Browse the repository at this point in the history
  2. hs: update comment

    EvaJanouskova committed Feb 5, 2024
    Configuration menu
    Copy the full SHA
    5806bde View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    f1f759e View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    3093082 View commit details
    Browse the repository at this point in the history

Commits on Feb 14, 2024

  1. Configuration menu
    Copy the full SHA
    caa3545 View commit details
    Browse the repository at this point in the history

Commits on Feb 15, 2024

  1. cmd: TODO surgical pkg

    EvaJanouskova committed Feb 15, 2024
    Configuration menu
    Copy the full SHA
    09b97cf View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    8993a5a View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    0b32685 View commit details
    Browse the repository at this point in the history

Commits on Feb 22, 2024

  1. rti fixes

    joehcollins committed Feb 22, 2024
    Configuration menu
    Copy the full SHA
    3b1f8e5 View commit details
    Browse the repository at this point in the history

Commits on Mar 5, 2024

  1. Add cystoscope, endoscope and prostate specific antigen test to consu…

    …mable list
    
    - add three consumables to `ResourceFile_Consumables_Items_and_Packages.csv` using the `generate_consumables_item_codes_and_packages.py` script
    - correct the spelling of cystoscope (from cytoscope)
    sm2511 committed Mar 5, 2024
    Configuration menu
    Copy the full SHA
    ff4d072 View commit details
    Browse the repository at this point in the history
  2. Update the availability of Prostate specific antigen test

    to be the same as that of prostate biopsy. This is based on an assumption agreed with Andrew. All assumptions on availability of consumables not found in the OpenLMIS or HHFA datasets are in the `ResourceFile_hhfa_consumables.xlsx` file in Dropbox - `availability_assumptions` tab. This is all described  in the `Description of derivation of stockout rates from OpenLMIS data_Final.docx` file in Dropbox.
    sm2511 committed Mar 5, 2024
    Configuration menu
    Copy the full SHA
    4d8712f View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    5209b33 View commit details
    Browse the repository at this point in the history
  4. breast_cancer: dummy used_equipment added where Andrew requested

    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(
    EvaJanouskova committed Mar 5, 2024
    Configuration menu
    Copy the full SHA
    5158aa2 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    e554dd7 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    e4935e3 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    8b455bd View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    9f44e85 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    0ff003b View commit details
    Browse the repository at this point in the history
  10. healthsystem: sort equipment for log

    Co-authored-by: Tim Hallett <39991060+tbhallett@users.noreply.github.com>
    EvaJanouskova and tbhallett committed Mar 5, 2024
    Configuration menu
    Copy the full SHA
    f736939 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    745d4ab View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    e7c52d8 View commit details
    Browse the repository at this point in the history
  13. hs, brc, co: used_equipment renamed to EQUIPMENT; if equip always sam…

    …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(
    EvaJanouskova committed Mar 5, 2024
    Configuration menu
    Copy the full SHA
    b523d58 View commit details
    Browse the repository at this point in the history
  14. brc: comment updated

    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
    EvaJanouskova committed Mar 5, 2024
    Configuration menu
    Copy the full SHA
    5396269 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    2791c18 View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    07e1ae9 View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    00270c1 View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    d486c4d View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    860d952 View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    c573fc8 View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    373018c View commit details
    Browse the repository at this point in the history
  22. Configuration menu
    Copy the full SHA
    307efab View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    4f2ce6c View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    10b9dde View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    1f2ff79 View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    adde374 View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    e6013d9 View commit details
    Browse the repository at this point in the history
  28. Configuration menu
    Copy the full SHA
    a214a88 View commit details
    Browse the repository at this point in the history
  29. equip_catalogue: make catalogues from new logging (equip included in …

    …hsi_event_details, counts logged in hsi_event_counts)
    EvaJanouskova committed Mar 5, 2024
    Configuration menu
    Copy the full SHA
    32145b6 View commit details
    Browse the repository at this point in the history
  30. Configuration menu
    Copy the full SHA
    d8e299f View commit details
    Browse the repository at this point in the history
  31. Configuration menu
    Copy the full SHA
    598368d View commit details
    Browse the repository at this point in the history
  32. [no ci] hs: typo; Equipment logging removed

    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 committed Mar 5, 2024
    Configuration menu
    Copy the full SHA
    e2fdafb View commit details
    Browse the repository at this point in the history
  33. Configuration menu
    Copy the full SHA
    acf3a63 View commit details
    Browse the repository at this point in the history
  34. Configuration menu
    Copy the full SHA
    97f0f3f View commit details
    Browse the repository at this point in the history
  35. Configuration menu
    Copy the full SHA
    1435d22 View commit details
    Browse the repository at this point in the history
  36. Configuration menu
    Copy the full SHA
    14a11a7 View commit details
    Browse the repository at this point in the history
  37. equip_catalogue: verify inputs as expected & set output file names in…

    … 'create_equipment_catalogues' fnc
    EvaJanouskova committed Mar 5, 2024
    Configuration menu
    Copy the full SHA
    6d85fe1 View commit details
    Browse the repository at this point in the history
  38. equip_catalogue: (1) detailed - equip set as string in one row, modul…

    …e_name before event_name, sorted by indexes; (2) added summary catal. (3) focused - only this cat. without empty equip rows and split by item per row
    EvaJanouskova committed Mar 5, 2024
    Configuration menu
    Copy the full SHA
    934e52d View commit details
    Browse the repository at this point in the history
  39. Configuration menu
    Copy the full SHA
    bdbd8f7 View commit details
    Browse the repository at this point in the history
  40. Configuration menu
    Copy the full SHA
    070454c View commit details
    Browse the repository at this point in the history
  41. Configuration menu
    Copy the full SHA
    99be34a View commit details
    Browse the repository at this point in the history
  42. equip_catalogue: typo

    EvaJanouskova committed Mar 5, 2024
    Configuration menu
    Copy the full SHA
    5076e3b View commit details
    Browse the repository at this point in the history
  43. Configuration menu
    Copy the full SHA
    d47b53e View commit details
    Browse the repository at this point in the history
  44. Configuration menu
    Copy the full SHA
    057fb44 View commit details
    Browse the repository at this point in the history
  45. brc: TODO added

    EvaJanouskova committed Mar 5, 2024
    Configuration menu
    Copy the full SHA
    2bf3e8a View commit details
    Browse the repository at this point in the history
  46. hs: rm prints

    EvaJanouskova committed Mar 5, 2024
    Configuration menu
    Copy the full SHA
    fa3380f View commit details
    Browse the repository at this point in the history
  47. hs: rm old code

    EvaJanouskova committed Mar 5, 2024
    Configuration menu
    Copy the full SHA
    4b7904a View commit details
    Browse the repository at this point in the history
  48. Configuration menu
    Copy the full SHA
    8c8bcc5 View commit details
    Browse the repository at this point in the history
  49. Configuration menu
    Copy the full SHA
    6b03edd View commit details
    Browse the repository at this point in the history
  50. Configuration menu
    Copy the full SHA
    c37e1de View commit details
    Browse the repository at this point in the history
  51. Configuration menu
    Copy the full SHA
    99ad138 View commit details
    Browse the repository at this point in the history
  52. Configuration menu
    Copy the full SHA
    a281e56 View commit details
    Browse the repository at this point in the history
  53. Configuration menu
    Copy the full SHA
    1787ffe View commit details
    Browse the repository at this point in the history
  54. hs: PEP8

    EvaJanouskova committed Mar 5, 2024
    Configuration menu
    Copy the full SHA
    f961640 View commit details
    Browse the repository at this point in the history
  55. Configuration menu
    Copy the full SHA
    12142b0 View commit details
    Browse the repository at this point in the history
  56. Configuration menu
    Copy the full SHA
    36f0523 View commit details
    Browse the repository at this point in the history
  57. Configuration menu
    Copy the full SHA
    b40f955 View commit details
    Browse the repository at this point in the history
  58. Configuration menu
    Copy the full SHA
    9c8b6ad View commit details
    Browse the repository at this point in the history
  59. Configuration menu
    Copy the full SHA
    0552e48 View commit details
    Browse the repository at this point in the history
  60. hs: ESS_EQUIP as HSI_Event's attribute; if settings of ESS_EQUIP forg…

    …otten -> set to empty & warn
    EvaJanouskova committed Mar 5, 2024
    Configuration menu
    Copy the full SHA
    0106e20 View commit details
    Browse the repository at this point in the history
  61. Configuration menu
    Copy the full SHA
    455f4e0 View commit details
    Browse the repository at this point in the history
  62. Configuration menu
    Copy the full SHA
    503036d View commit details
    Browse the repository at this point in the history
  63. Configuration menu
    Copy the full SHA
    8ea0b27 View commit details
    Browse the repository at this point in the history
  64. Configuration menu
    Copy the full SHA
    7ad13cc View commit details
    Browse the repository at this point in the history
  65. Configuration menu
    Copy the full SHA
    39a5d21 View commit details
    Browse the repository at this point in the history
  66. Configuration menu
    Copy the full SHA
    9dcf46b View commit details
    Browse the repository at this point in the history
  67. Configuration menu
    Copy the full SHA
    0bda4d0 View commit details
    Browse the repository at this point in the history
  68. Configuration menu
    Copy the full SHA
    fc273a0 View commit details
    Browse the repository at this point in the history
  69. RF_Cons_Items_and_Pkgs: reverted changes from script; Cystoscope, End…

    …oscope, PSA test added manually
    EvaJanouskova committed Mar 5, 2024
    Configuration menu
    Copy the full SHA
    0289af3 View commit details
    Browse the repository at this point in the history

Commits on Mar 6, 2024

  1. Merge branch 'EvaJ/equipment/structure_ToRunSim' into equipment/integ…

    …ration_in_modules
    
    # Conflicts:
    #	resources/healthsystem/consumables/ResourceFile_Consumables_availability_small.csv
    #	resources/healthsystem/infrastructure_and_equipment/ResourceFile_Equipment.csv
    #	src/scripts/healthsystem/equipment/equipment_catalogue.py
    #	src/tlo/methods/alri.py
    #	src/tlo/methods/breast_cancer.py
    #	src/tlo/methods/care_of_women_during_pregnancy.py
    #	src/tlo/methods/contraception.py
    #	src/tlo/methods/healthsystem.py
    #	src/tlo/methods/labour.py
    #	src/tlo/methods/newborn_outcomes.py
    EvaJanouskova committed Mar 6, 2024
    Configuration menu
    Copy the full SHA
    f844535 View commit details
    Browse the repository at this point in the history
  2. modules: tidy up

    EvaJanouskova committed Mar 6, 2024
    Configuration menu
    Copy the full SHA
    bdb755c View commit details
    Browse the repository at this point in the history

Commits on Mar 7, 2024

  1. Configuration menu
    Copy the full SHA
    bed404d View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    7c69972 View commit details
    Browse the repository at this point in the history

Commits on Mar 21, 2024

  1. Configuration menu
    Copy the full SHA
    0d387a4 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    b87781e View commit details
    Browse the repository at this point in the history
  3. co, hs, RF_Equip, RF_HS_params, test_alri, test_co, test_hs: checking…

    … equip availability (before/within HSI); avail switcher; dummy probs by fac_level = 0.5; tests updated; TODOs added
    EvaJanouskova committed Mar 21, 2024
    Configuration menu
    Copy the full SHA
    88632f6 View commit details
    Browse the repository at this point in the history
  4. Merge branch 'master' into EvaJ/equipment/structure_ToRunSim

    # Conflicts:
    #       resources/healthsystem/ResourceFile_HealthSystem_parameters.csv
    #       src/tlo/methods/healthsystem.py
    #       src/tlo/methods/hsi_event.py
    EvaJanouskova committed Mar 21, 2024
    Configuration menu
    Copy the full SHA
    d71107a View commit details
    Browse the repository at this point in the history

Commits on Mar 25, 2024

  1. Configuration menu
    Copy the full SHA
    2518c49 View commit details
    Browse the repository at this point in the history
  2. example test suite

    tbhallett committed Mar 25, 2024
    Configuration menu
    Copy the full SHA
    a6fffc9 View commit details
    Browse the repository at this point in the history
  3. typo and add todo

    tbhallett committed Mar 25, 2024
    Configuration menu
    Copy the full SHA
    8428d8a View commit details
    Browse the repository at this point in the history
  4. further tests

    tbhallett committed Mar 25, 2024
    Configuration menu
    Copy the full SHA
    2a3c8f8 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    b1aa9ae View commit details
    Browse the repository at this point in the history

Commits on Mar 26, 2024

  1. ac: rm comments

    Co-authored-by: Tim Hallett <39991060+tbhallett@users.noreply.github.com>
    EvaJanouskova and tbhallett committed Mar 26, 2024
    Configuration menu
    Copy the full SHA
    ffd5178 View commit details
    Browse the repository at this point in the history
  2. hs: rm equip_availability before sim default

    Co-authored-by: Tim Hallett <39991060+tbhallett@users.noreply.github.com>
    EvaJanouskova and tbhallett committed Mar 26, 2024
    Configuration menu
    Copy the full SHA
    7c8ea54 View commit details
    Browse the repository at this point in the history
  3. labour: rm comments

    Co-authored-by: Tim Hallett <39991060+tbhallett@users.noreply.github.com>
    EvaJanouskova and tbhallett committed Mar 26, 2024
    Configuration menu
    Copy the full SHA
    6ddd11e View commit details
    Browse the repository at this point in the history

Commits on Apr 16, 2024

  1. hs: rm extra line

    EvaJanouskova committed Apr 16, 2024
    Configuration menu
    Copy the full SHA
    4f4d858 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f8b0ac1 View commit details
    Browse the repository at this point in the history

Commits on May 9, 2024

  1. Merge branch 'refs/heads/master' into EvaJ/equipment/structure_ToRunSim

    # Conflicts:
    #	resources/healthsystem/ResourceFile_HealthSystem_parameters.csv
    #	src/tlo/methods/healthsystem.py
    tbhallett committed May 9, 2024
    Configuration menu
    Copy the full SHA
    55772ed View commit details
    Browse the repository at this point in the history
  2. roll back incidental changes

    Note to @eva -- there were quite a ot of changes in `test_contraception.py` that seemed unrelated to this PR, but which she may like to cherry-pick and raise a PR for specifically.
    tbhallett committed May 9, 2024
    Configuration menu
    Copy the full SHA
    16752ae View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    cd2774e View commit details
    Browse the repository at this point in the history
  4. roll back parsing script

    tbhallett committed May 9, 2024
    Configuration menu
    Copy the full SHA
    7a5d991 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    4781555 View commit details
    Browse the repository at this point in the history

Commits on May 10, 2024

  1. Configuration menu
    Copy the full SHA
    27779e6 View commit details
    Browse the repository at this point in the history
  2. linting

    tbhallett committed May 10, 2024
    Configuration menu
    Copy the full SHA
    1988ae2 View commit details
    Browse the repository at this point in the history
  3. update call in bed-days

    tbhallett committed May 10, 2024
    Configuration menu
    Copy the full SHA
    13d5a3c View commit details
    Browse the repository at this point in the history

Commits on May 12, 2024

  1. Configuration menu
    Copy the full SHA
    3d4b80d View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    3bb2581 View commit details
    Browse the repository at this point in the history

Commits on May 13, 2024

  1. linting

    tbhallett committed May 13, 2024
    Configuration menu
    Copy the full SHA
    3c16898 View commit details
    Browse the repository at this point in the history
  2. linting

    tbhallett committed May 13, 2024
    Configuration menu
    Copy the full SHA
    5bcdb38 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    3bea20f View commit details
    Browse the repository at this point in the history
  4. linting

    tbhallett committed May 13, 2024
    Configuration menu
    Copy the full SHA
    3a8d3da View commit details
    Browse the repository at this point in the history
  5. linting

    tbhallett committed May 13, 2024
    Configuration menu
    Copy the full SHA
    dc9d9b9 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    ea4027b View commit details
    Browse the repository at this point in the history
  7. Merge branch 'refs/heads/master' into equipment/integration_in_modules

    # Conflicts:
    #	src/tlo/methods/healthsystem.py
    #	src/tlo/methods/hsi_generic_first_appts.py
    tbhallett committed May 13, 2024
    Configuration menu
    Copy the full SHA
    b31b93f View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    2dd360a View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    a306e24 View commit details
    Browse the repository at this point in the history
  10. tidy-up and tag todos

    tbhallett committed May 13, 2024
    Configuration menu
    Copy the full SHA
    faf2fa8 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    3be6e70 View commit details
    Browse the repository at this point in the history
  12. Merge branch 'refs/heads/EvaJ/equipment/structure_ToRunSim' into hall…

    …ett/equipment_changes_and_structure
    
    # Conflicts:
    #	src/scripts/data_file_processing/codes_to_items_list.py
    #	src/tlo/methods/alri.py
    #	src/tlo/methods/breast_cancer.py
    #	src/tlo/methods/care_of_women_during_pregnancy.py
    #	src/tlo/methods/contraception.py
    #	src/tlo/methods/healthsystem.py
    #	src/tlo/methods/labour.py
    #	src/tlo/methods/newborn_outcomes.py
    #	tests/test_healthsystem.py
    tbhallett committed May 13, 2024
    Configuration menu
    Copy the full SHA
    68c4da2 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    8bcda48 View commit details
    Browse the repository at this point in the history
  14. Revert "temporarily make simulation shorter, smaller and with fewer d…

    …raws to create a test run."
    
    This reverts commit 8bcda48.
    tbhallett committed May 13, 2024
    Configuration menu
    Copy the full SHA
    0dd00c4 View commit details
    Browse the repository at this point in the history

Commits on May 16, 2024

  1. Merge branch 'refs/heads/master' into hallett/equipment_changes_and_s…

    …tructure
    
    # Conflicts:
    #	src/tlo/methods/equipment.py
    #	src/tlo/methods/healthsystem.py
    #	src/tlo/methods/hsi_event.py
    #	tests/test_equipment.py
    #	tests/test_healthsystem.py
    tbhallett committed May 16, 2024
    Configuration menu
    Copy the full SHA
    ce6a2d8 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    d1c8699 View commit details
    Browse the repository at this point in the history

Commits on May 24, 2024

  1. Configuration menu
    Copy the full SHA
    f566709 View commit details
    Browse the repository at this point in the history

Commits on May 28, 2024

  1. Configuration menu
    Copy the full SHA
    3bf93ac View commit details
    Browse the repository at this point in the history

Commits on May 31, 2024

  1. Merge branch 'refs/heads/master' into hallett/equipment_changes_and_s…

    …tructure
    
    # Conflicts:
    #	src/tlo/methods/tb.py
    tbhallett committed May 31, 2024
    Configuration menu
    Copy the full SHA
    56056d2 View commit details
    Browse the repository at this point in the history
  2. equipment pkgs (#1378)

    * equip: update lookup pkg names to consider option of having one item within multiple pkgs
    
    * RF_EquipCatalogue: pkgs defined
    
    * modules: usages of equip pkgs included
    
    * RF_EquipCatalogue: Endoscope and ECG added
    
    * equip: warning messages clarified
    
    * equip & test_equip: fix lookup_item_codes_from_pkg_name() fnc and test its functionality
    
    diff --git src/tlo/methods/equipment.py src/tlo/methods/equipment.py
    index 1759a994f..099226748 100644
    --- src/tlo/methods/equipment.py
    +++ src/tlo/methods/equipment.py
    @@ -253,8 +253,17 @@ class Equipment:
             It is expected that this is used by the disease module once and then the resulting equipment item_codes are
             saved on the module."""
             df = self.catalogue
    +        item_codes = set()
    
    -        if pkg_name not in df['Pkg_Name'].unique().split(", "):
    +        item_codes.update(df.loc[df['Pkg_Name'] == pkg_name, 'Item_Code'].values)
    +
    +        all_pkg_names = set(df['Pkg_Name'].unique()[~pd.isnull(df['Pkg_Name'].unique())])
    +        all_multiple_pkg_names = [name for name in all_pkg_names if ", " in name]
    +        for multiple_pkg_name in all_multiple_pkg_names:
    +            if pkg_name in multiple_pkg_name.split(", "):
    +                item_codes.update(df.loc[df['Pkg_Name'] == multiple_pkg_name, 'Item_Code'].values)
    +
    +        if item_codes:
    +            return item_codes
    +        else:
                 raise ValueError(f'That Pkg_Name is not in the catalogue: {pkg_name=}')
    -
    -        return set(df.loc[df['Pkg_Name'] == pkg_name, 'Item_Code'].values)
    diff --git tests/test_equipment.py tests/test_equipment.py
    index a02ea282f..a39124454 100644
    --- tests/test_equipment.py
    +++ tests/test_equipment.py
    @@ -22,14 +22,18 @@ def test_core_functionality_of_equipment_class(seed):
    
         # Create toy data
         catalogue = pd.DataFrame(
    +        # PkgWith0+1 stands alone or as multiple pkgs for one item; PkgWith1 is only as multiple pkgs
    +        # for one item; PkgWith3 only stands alone
             [
                 {"Item_Description": "ItemZero", "Item_Code": 0, "Pkg_Name": 'PkgWith0+1'},
    -            {"Item_Description": "ItemOne", "Item_Code": 1, "Pkg_Name": 'PkgWith0+1'},
    +            {"Item_Description": "ItemOne", "Item_Code": 1, "Pkg_Name": 'PkgWith0+1, PkgWith1'},
                 {"Item_Description": "ItemTwo", "Item_Code": 2, "Pkg_Name": float('nan')},
    +            {"Item_Description": "ItemThree", "Item_Code": 3, "Pkg_Name": float('PkgWith3')},
             ]
         )
         data_availability = pd.DataFrame(
    -        # item 0 is not available anywhere; item 1 is available everywhere; item 2 is available only at facility_id=1
    +        # item 0 is not available anywhere; item 1 is available everywhere; item 2 is available only at facility_id=1;
    +        # availability not defined for item 3
             [
                 {"Item_Code": 0, "Facility_ID": 0, "Pr_Available": 0.0},
                 {"Item_Code": 0, "Facility_ID": 1, "Pr_Available": 0.0},
    @@ -134,17 +138,22 @@ def test_core_functionality_of_equipment_class(seed):
    
         # Lookup the item_codes that belong in a particular package.
         # - When package is recognised
    -    assert {0, 1} == eq_default.lookup_item_codes_from_pkg_name(pkg_name='PkgWith0+1')  # these items are in the same
    -    #                                                                                     package
    +    # if items are in the same package (once standing alone, once within multiple pkgs defined for item)
    +    assert {0, 1} == eq_default.lookup_item_codes_from_pkg_name(pkg_name='PkgWith0+1')
    +    # if the pkg within multiple pkgs defined for item
    +    assert {1} == eq_default.lookup_item_codes_from_pkg_name(pkg_name='PkgWith1')
    +    # if the pkg only stands alone
    +    assert {3} == eq_default.lookup_item_codes_from_pkg_name(pkg_name='PkgWith3')
    +
         # - Error thrown when package is not recognised
         with pytest.raises(ValueError):
             eq_default.lookup_item_codes_from_pkg_name(pkg_name='')
    
    -
     equipment_item_code_that_is_available = [0, 1, ]
     equipment_item_code_that_is_not_available = [2, 3,]
    
    +
     def run_simulation_and_return_log(
         seed, tmpdir, equipment_in_init, equipment_in_apply
     ) -> Dict:
    
    * equip & test_equip: update lookup for equipment from pkgs to less "expensive" version, lookup fnc renamed to from_pkg_names()
    
    diff --git src/tlo/methods/equipment.py src/tlo/methods/equipment.py
    index 099226748..3a4fb24ba 100644
    --- src/tlo/methods/equipment.py
    +++ src/tlo/methods/equipment.py
    @@ -1,6 +1,6 @@
     import warnings
     from collections import defaultdict
    -from typing import Counter, Iterable, Literal, Set, Union
    +from typing import Counter, Dict, Iterable, Literal, Set, Union
    
     import numpy as np
     import pandas as pd
    @@ -77,6 +77,7 @@ class Equipment:
    
             # - Data structures for quick look-ups for items and descriptors
             self._item_code_lookup = self.catalogue.set_index('Item_Description')['Item_Code'].to_dict()
    +        self._pkg_lookup = self._create_pkg_lookup()
             self._all_item_descriptors = set(self._item_code_lookup.keys())
             self._all_item_codes = set(self._item_code_lookup.values())
             self._all_fac_ids = self.master_facilities_list['Facility_ID'].unique()
    @@ -248,22 +249,37 @@ class Equipment:
                     data=row.to_dict(),
                 )
    
    -    def lookup_item_codes_from_pkg_name(self, pkg_name: str) -> Set[int]:
    -        """Convenience function to find the set of item_codes that are grouped under a package name in the catalogue.
    -        It is expected that this is used by the disease module once and then the resulting equipment item_codes are
    -        saved on the module."""
    -        df = self.catalogue
    -        item_codes = set()
    -
    -        item_codes.update(df.loc[df['Pkg_Name'] == pkg_name, 'Item_Code'].values)
    -
    -        all_pkg_names = set(df['Pkg_Name'].unique()[~pd.isnull(df['Pkg_Name'].unique())])
    -        all_multiple_pkg_names = [name for name in all_pkg_names if ", " in name]
    -        for multiple_pkg_name in all_multiple_pkg_names:
    -            if pkg_name in multiple_pkg_name.split(", "):
    -                item_codes.update(df.loc[df['Pkg_Name'] == multiple_pkg_name, 'Item_Code'].values)
    -
    -        if item_codes:
    -            return item_codes
    +    def from_pkg_names(self, pkg_names: Union[str, Iterable[str]]) -> Set[int]:
    +        """Convenience function to find the set of item_codes that are grouped under requested package name(s) in the
    +        catalogue."""
    +        # Make into a set if it is not one already
    +        if isinstance(pkg_names, (str, int)):
    +            pkg_names = set([pkg_names])
             else:
    -            raise ValueError(f'That Pkg_Name is not in the catalogue: {pkg_name=}')
    +            pkg_names = set(pkg_names)
    +
    +        item_codes = set()
    +        for pkg_name in pkg_names:
    +            if pkg_name in self._pkg_lookup.keys():
    +                item_codes.update(self._pkg_lookup[pkg_name])
    +            else:
    +                raise ValueError(f'That Pkg_Name is not in the catalogue: {pkg_name=}')
    +
    +        return item_codes
    +
    +    def _create_pkg_lookup(self) -> Dict[str, Set[int]]:
    +        df = self.catalogue
    +        pkg_lookup = dict()
    +
    +        pkg_names_raw = set(df['Pkg_Name'].unique()[~pd.isnull(df['Pkg_Name'].unique())])
    +        all_multiple_pkg_names = set(name for name in pkg_names_raw if ", " in name)
    +        all_pkg_names = pkg_names_raw - all_multiple_pkg_names
    +        for pkg_name in all_pkg_names:
    +            pkg_lookup[pkg_name] = set(df.loc[df['Pkg_Name'] == pkg_name, 'Item_Code'].values)
    +        for multiple_pkg_name in all_multiple_pkg_names:
    +            for pkg_name in multiple_pkg_name.split(", "):
    +                if pkg_name not in all_pkg_names:
    +                    pkg_lookup[pkg_name] = set()
    +                    all_pkg_names.update({pkg_name})
    +                pkg_lookup[pkg_name].update(set(df.loc[df['Pkg_Name'] == multiple_pkg_name, 'Item_Code'].values))
    +        return pkg_lookup
    diff --git tests/test_equipment.py tests/test_equipment.py
    index a39124454..0a462f08f 100644
    --- tests/test_equipment.py
    +++ tests/test_equipment.py
    @@ -139,15 +139,15 @@ def test_core_functionality_of_equipment_class(seed):
         # Lookup the item_codes that belong in a particular package.
         # - When package is recognised
         # if items are in the same package (once standing alone, once within multiple pkgs defined for item)
    -    assert {0, 1} == eq_default.lookup_item_codes_from_pkg_name(pkg_name='PkgWith0+1')
    +    assert {0, 1} == eq_default.from_pkg_names(pkg_name='PkgWith0+1')
         # if the pkg within multiple pkgs defined for item
    -    assert {1} == eq_default.lookup_item_codes_from_pkg_name(pkg_name='PkgWith1')
    +    assert {1} == eq_default.from_pkg_names(pkg_name='PkgWith1')
         # if the pkg only stands alone
    -    assert {3} == eq_default.lookup_item_codes_from_pkg_name(pkg_name='PkgWith3')
    +    assert {3} == eq_default.from_pkg_names(pkg_name='PkgWith3')
    
         # - Error thrown when package is not recognised
         with pytest.raises(ValueError):
    -        eq_default.lookup_item_codes_from_pkg_name(pkg_name='')
    +        eq_default.from_pkg_names(pkg_names='')
    
     equipment_item_code_that_is_available = [0, 1, ]
    
    * equip lookup fnc renamed to from_pkg_names()
    
    * test_equip: fixes from rebase
    
    * [no ci] test_equip: test correct item codes returned for multiple specified pkgs
    
    * add ANC packages
    
    * edit equipment_availability_estimation.py to manually add cost category
    
    * upate ResourceFile_Equipment_Availability_Estimates.csv running new script
    
    ---------
    
    Co-authored-by: joehcollins <joseph.h.collins@ucl.ac.uk>
    Co-authored-by: Tim Hallett <39991060+tbhallett@users.noreply.github.com>
    3 people committed May 31, 2024
    Configuration menu
    Copy the full SHA
    135fc2e View commit details
    Browse the repository at this point in the history

Commits on Jun 6, 2024

  1. Merge branch 'refs/heads/master' into hallett/equipment_changes_and_s…

    …tructure
    
    # Conflicts:
    #	src/tlo/methods/cancer_consumables.py
    #	src/tlo/methods/care_of_women_during_pregnancy.py
    #	src/tlo/methods/copd.py
    #	src/tlo/methods/labour.py
    #	src/tlo/methods/newborn_outcomes.py
    tbhallett committed Jun 6, 2024
    Configuration menu
    Copy the full SHA
    0d6fd8d View commit details
    Browse the repository at this point in the history
  2. cancer_cons: joined screening cons for biopsy, cystoscopy and endosco…

    …py; bc: biopsy replaced with cystoscopy; oc biopsy replaced with endoscopy
    EvaJanouskova committed Jun 6, 2024
    Configuration menu
    Copy the full SHA
    b7c27c8 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    1f1d94b View commit details
    Browse the repository at this point in the history
  4. pc: rm outdated todos

    EvaJanouskova committed Jun 6, 2024
    Configuration menu
    Copy the full SHA
    6c8c33d View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    694da75 View commit details
    Browse the repository at this point in the history

Commits on Jun 10, 2024

  1. Configuration menu
    Copy the full SHA
    7a27a1f View commit details
    Browse the repository at this point in the history

Commits on Jun 20, 2024

  1. Configuration menu
    Copy the full SHA
    310f6b4 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    3bd3487 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    f4aabca View commit details
    Browse the repository at this point in the history
  4. allow spaces in Pkg_Names (don't remove all spaces, but instead strip…

    … out trailing/leading spaces)
    tbhallett committed Jun 20, 2024
    Configuration menu
    Copy the full SHA
    88b6f59 View commit details
    Browse the repository at this point in the history