-
Notifications
You must be signed in to change notification settings - Fork 4
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
Commits on Dec 4, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 3a8fd28 - Browse repository at this point
Copy the full SHA 3a8fd28View commit details -
Configuration menu - View commit details
-
Copy full SHA for 38f07b3 - Browse repository at this point
Copy the full SHA 38f07b3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 72b6a2a - Browse repository at this point
Copy the full SHA 72b6a2aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 29f9fc9 - Browse repository at this point
Copy the full SHA 29f9fc9View commit details -
initial RTI equipment added. updated confusing naming of consumables …
…as equipment in MNH modules
Configuration menu - View commit details
-
Copy full SHA for 30d760e - Browse repository at this point
Copy the full SHA 30d760eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 0f16f59 - Browse repository at this point
Copy the full SHA 0f16f59View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5354899 - Browse repository at this point
Copy the full SHA 5354899View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7adde5f - Browse repository at this point
Copy the full SHA 7adde5fView commit details -
Configuration menu - View commit details
-
Copy full SHA for b7ad900 - Browse repository at this point
Copy the full SHA b7ad900View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7295d1a - Browse repository at this point
Copy the full SHA 7295d1aView commit details -
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:
Configuration menu - View commit details
-
Copy full SHA for ae05be9 - Browse repository at this point
Copy the full SHA ae05be9View commit details -
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"""
Configuration menu - View commit details
-
Copy full SHA for f9cca95 - Browse repository at this point
Copy the full SHA f9cca95View commit details
Commits on Dec 6, 2023
-
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
Configuration menu - View commit details
-
Copy full SHA for 287a80b - Browse repository at this point
Copy the full SHA 287a80bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 312aaa3 - Browse repository at this point
Copy the full SHA 312aaa3View commit details -
Configuration menu - View commit details
-
Copy full SHA for f1d4ee0 - Browse repository at this point
Copy the full SHA f1d4ee0View commit details -
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
Configuration menu - View commit details
-
Copy full SHA for 4325c78 - Browse repository at this point
Copy the full SHA 4325c78View commit details -
Configuration menu - View commit details
-
Copy full SHA for b42c15b - Browse repository at this point
Copy the full SHA b42c15bView commit details -
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
Configuration menu - View commit details
-
Copy full SHA for 6ff025c - Browse repository at this point
Copy the full SHA 6ff025cView commit details -
Configuration menu - View commit details
-
Copy full SHA for bf83c61 - Browse repository at this point
Copy the full SHA bf83c61View commit details -
Merge branch 'EvaJ/equipment/structure_ToRunSim' into equipment/integ…
…ration_in_modules # Conflicts: # src/scripts/healthsystem/equipment/equipment_catalogue.py
Configuration menu - View commit details
-
Copy full SHA for 0216daa - Browse repository at this point
Copy the full SHA 0216daaView commit details -
Configuration menu - View commit details
-
Copy full SHA for 0a5d8e7 - Browse repository at this point
Copy the full SHA 0a5d8e7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8fb6496 - Browse repository at this point
Copy the full SHA 8fb6496View commit details
Commits on Dec 11, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 51595fa - Browse repository at this point
Copy the full SHA 51595faView commit details -
Configuration menu - View commit details
-
Copy full SHA for 77a0926 - Browse repository at this point
Copy the full SHA 77a0926View commit details
Commits on Jan 2, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 7cd4fc3 - Browse repository at this point
Copy the full SHA 7cd4fc3View commit details
Commits on Jan 12, 2024
-
adding consumables for the cancer modules. consumables are defined in…
… cancer_consumables.py to prevent repeating code blocks
Configuration menu - View commit details
-
Copy full SHA for bc726c2 - Browse repository at this point
Copy the full SHA bc726c2View commit details -
adding equipment (first pass) to cancer modules. In addition have upd…
…ated spelling of cystoscopy within bladder_cancer.py and the associated resource file.
Configuration menu - View commit details
-
Copy full SHA for 9889da9 - Browse repository at this point
Copy the full SHA 9889da9View commit details -
Configuration menu - View commit details
-
Copy full SHA for a057c40 - Browse repository at this point
Copy the full SHA a057c40View commit details -
Configuration menu - View commit details
-
Copy full SHA for bfaef67 - Browse repository at this point
Copy the full SHA bfaef67View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7b4e331 - Browse repository at this point
Copy the full SHA 7b4e331View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7cb9f2a - Browse repository at this point
Copy the full SHA 7cb9f2aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 9b173d7 - Browse repository at this point
Copy the full SHA 9b173d7View commit details -
Configuration menu - View commit details
-
Copy full SHA for c53dc8c - Browse repository at this point
Copy the full SHA c53dc8cView commit details -
Configuration menu - View commit details
-
Copy full SHA for ab105e8 - Browse repository at this point
Copy the full SHA ab105e8View commit details
Commits on Jan 13, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 451f262 - Browse repository at this point
Copy the full SHA 451f262View commit details -
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(
Configuration menu - View commit details
-
Copy full SHA for b8da673 - Browse repository at this point
Copy the full SHA b8da673View commit details -
Configuration menu - View commit details
-
Copy full SHA for d685c69 - Browse repository at this point
Copy the full SHA d685c69View commit details -
Configuration menu - View commit details
-
Copy full SHA for a00d25a - Browse repository at this point
Copy the full SHA a00d25aView commit details -
Configuration menu - View commit details
-
Copy full SHA for b7cc852 - Browse repository at this point
Copy the full SHA b7cc852View commit details -
equipment_catalogue & utils: new script + a change in utils.py - to c…
…reate equip. catalogue
Configuration menu - View commit details
-
Copy full SHA for 7f5c575 - Browse repository at this point
Copy the full SHA 7f5c575View commit details -
Configuration menu - View commit details
-
Copy full SHA for c4b316b - Browse repository at this point
Copy the full SHA c4b316bView commit details -
healthsystem: sort equipment for log
Co-authored-by: Tim Hallett <39991060+tbhallett@users.noreply.github.com>
Configuration menu - View commit details
-
Copy full SHA for 79ba1c1 - Browse repository at this point
Copy the full SHA 79ba1c1View commit details -
Configuration menu - View commit details
-
Copy full SHA for 328bb78 - Browse repository at this point
Copy the full SHA 328bb78View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8fae9b3 - Browse repository at this point
Copy the full SHA 8fae9b3View commit details -
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(
Configuration menu - View commit details
-
Copy full SHA for c4615da - Browse repository at this point
Copy the full SHA c4615daView commit details -
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
Configuration menu - View commit details
-
Copy full SHA for 0d9e216 - Browse repository at this point
Copy the full SHA 0d9e216View commit details -
Configuration menu - View commit details
-
Copy full SHA for ecc5981 - Browse repository at this point
Copy the full SHA ecc5981View commit details -
Configuration menu - View commit details
-
Copy full SHA for a3d726e - Browse repository at this point
Copy the full SHA a3d726eView commit details -
Configuration menu - View commit details
-
Copy full SHA for d8a53b2 - Browse repository at this point
Copy the full SHA d8a53b2View commit details -
Configuration menu - View commit details
-
Copy full SHA for e7a8e56 - Browse repository at this point
Copy the full SHA e7a8e56View commit details -
Configuration menu - View commit details
-
Copy full SHA for bd55b0d - Browse repository at this point
Copy the full SHA bd55b0dView commit details -
Configuration menu - View commit details
-
Copy full SHA for ed50338 - Browse repository at this point
Copy the full SHA ed50338View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5576de9 - Browse repository at this point
Copy the full SHA 5576de9View commit details -
Configuration menu - View commit details
-
Copy full SHA for ba97098 - Browse repository at this point
Copy the full SHA ba97098View commit details -
Configuration menu - View commit details
-
Copy full SHA for d114b2d - Browse repository at this point
Copy the full SHA d114b2dView commit details -
Configuration menu - View commit details
-
Copy full SHA for e88babe - Browse repository at this point
Copy the full SHA e88babeView commit details -
Configuration menu - View commit details
-
Copy full SHA for 13af328 - Browse repository at this point
Copy the full SHA 13af328View commit details -
Configuration menu - View commit details
-
Copy full SHA for ac22da6 - Browse repository at this point
Copy the full SHA ac22da6View commit details -
Configuration menu - View commit details
-
Copy full SHA for 178e996 - Browse repository at this point
Copy the full SHA 178e996View commit details -
Configuration menu - View commit details
-
Copy full SHA for b7c4e86 - Browse repository at this point
Copy the full SHA b7c4e86View commit details -
equip_catalogue: make catalogues from new logging (equip included in …
…hsi_event_details, counts logged in hsi_event_counts)
Configuration menu - View commit details
-
Copy full SHA for c9f9da7 - Browse repository at this point
Copy the full SHA c9f9da7View commit details -
Configuration menu - View commit details
-
Copy full SHA for c311825 - Browse repository at this point
Copy the full SHA c311825View commit details -
Configuration menu - View commit details
-
Copy full SHA for 811da1f - Browse repository at this point
Copy the full SHA 811da1fView commit details -
[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()
Configuration menu - View commit details
-
Copy full SHA for 5c90ad4 - Browse repository at this point
Copy the full SHA 5c90ad4View commit details -
Configuration menu - View commit details
-
Copy full SHA for e970814 - Browse repository at this point
Copy the full SHA e970814View commit details -
Configuration menu - View commit details
-
Copy full SHA for f4a91fb - Browse repository at this point
Copy the full SHA f4a91fbView commit details -
Configuration menu - View commit details
-
Copy full SHA for 81a6eff - Browse repository at this point
Copy the full SHA 81a6effView commit details -
Configuration menu - View commit details
-
Copy full SHA for d6fa91d - Browse repository at this point
Copy the full SHA d6fa91dView commit details -
equip_catalogue: verify inputs as expected & set output file names in…
… 'create_equipment_catalogues' fnc
Configuration menu - View commit details
-
Copy full SHA for 903adcc - Browse repository at this point
Copy the full SHA 903adccView commit details -
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
Configuration menu - View commit details
-
Copy full SHA for 1d9c594 - Browse repository at this point
Copy the full SHA 1d9c594View commit details -
Configuration menu - View commit details
-
Copy full SHA for df7479e - Browse repository at this point
Copy the full SHA df7479eView commit details -
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
Configuration menu - View commit details
-
Copy full SHA for c67618c - Browse repository at this point
Copy the full SHA c67618cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 422bfbf - Browse repository at this point
Copy the full SHA 422bfbfView commit details -
Configuration menu - View commit details
-
Copy full SHA for 0eaacc3 - Browse repository at this point
Copy the full SHA 0eaacc3View commit details -
Configuration menu - View commit details
-
Copy full SHA for d99310a - Browse repository at this point
Copy the full SHA d99310aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 9d31842 - Browse repository at this point
Copy the full SHA 9d31842View commit details -
Configuration menu - View commit details
-
Copy full SHA for 2c5a436 - Browse repository at this point
Copy the full SHA 2c5a436View commit details -
Configuration menu - View commit details
-
Copy full SHA for 14f426a - Browse repository at this point
Copy the full SHA 14f426aView commit details -
Configuration menu - View commit details
-
Copy full SHA for e9c09ec - Browse repository at this point
Copy the full SHA e9c09ecView commit details -
Configuration menu - View commit details
-
Copy full SHA for b88f251 - Browse repository at this point
Copy the full SHA b88f251View commit details
Commits on Jan 15, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 507eb4e - Browse repository at this point
Copy the full SHA 507eb4eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 68ae9b0 - Browse repository at this point
Copy the full SHA 68ae9b0View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7fb9ee8 - Browse repository at this point
Copy the full SHA 7fb9ee8View commit details -
Configuration menu - View commit details
-
Copy full SHA for c49dce0 - Browse repository at this point
Copy the full SHA c49dce0View commit details -
Configuration menu - View commit details
-
Copy full SHA for a82704e - Browse repository at this point
Copy the full SHA a82704eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 3d9a2c3 - Browse repository at this point
Copy the full SHA 3d9a2c3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 92d11cb - Browse repository at this point
Copy the full SHA 92d11cbView commit details -
me: within HSI_Me_Treatment equip for me. with pneumonia updated only…
… if essen. consumbales avail.
Configuration menu - View commit details
-
Copy full SHA for de2a7c3 - Browse repository at this point
Copy the full SHA de2a7c3View commit details
Commits on Jan 16, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 0111625 - Browse repository at this point
Copy the full SHA 0111625View commit details
Commits on Jan 17, 2024
-
Configuration menu - View commit details
-
Copy full SHA for dc21979 - Browse repository at this point
Copy the full SHA dc21979View commit details -
Configuration menu - View commit details
-
Copy full SHA for cdaa44a - Browse repository at this point
Copy the full SHA cdaa44aView commit details
Commits on Jan 19, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 287ee67 - Browse repository at this point
Copy the full SHA 287ee67View commit details -
Configuration menu - View commit details
-
Copy full SHA for 812a9e2 - Browse repository at this point
Copy the full SHA 812a9e2View commit details -
Configuration menu - View commit details
-
Copy full SHA for b70b2e4 - Browse repository at this point
Copy the full SHA b70b2e4View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8cd81d0 - Browse repository at this point
Copy the full SHA 8cd81d0View commit details
Commits on Jan 21, 2024
-
Configuration menu - View commit details
-
Copy full SHA for a7426b1 - Browse repository at this point
Copy the full SHA a7426b1View commit details -
Configuration menu - View commit details
-
Copy full SHA for fc6bea2 - Browse repository at this point
Copy the full SHA fc6bea2View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1c987c3 - Browse repository at this point
Copy the full SHA 1c987c3View commit details
Commits on Jan 24, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 38ff44c - Browse repository at this point
Copy the full SHA 38ff44cView commit details
Commits on Jan 30, 2024
-
hs: ESS_EQUIP as HSI_Event's attribute; if settings of ESS_EQUIP forg…
…otten -> set to empty & warn
Configuration menu - View commit details
-
Copy full SHA for e0132f8 - Browse repository at this point
Copy the full SHA e0132f8View commit details -
Configuration menu - View commit details
-
Copy full SHA for 2859530 - Browse repository at this point
Copy the full SHA 2859530View commit details -
Configuration menu - View commit details
-
Copy full SHA for e5df950 - Browse repository at this point
Copy the full SHA e5df950View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5c66328 - Browse repository at this point
Copy the full SHA 5c66328View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8daa621 - Browse repository at this point
Copy the full SHA 8daa621View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1a69dca - Browse repository at this point
Copy the full SHA 1a69dcaView commit details -
Configuration menu - View commit details
-
Copy full SHA for 42492fa - Browse repository at this point
Copy the full SHA 42492faView commit details -
Configuration menu - View commit details
-
Copy full SHA for d0d2828 - Browse repository at this point
Copy the full SHA d0d2828View commit details -
Configuration menu - View commit details
-
Copy full SHA for d1c7523 - Browse repository at this point
Copy the full SHA d1c7523View commit details
Commits on Feb 1, 2024
-
Configuration menu - View commit details
-
Copy full SHA for c317540 - Browse repository at this point
Copy the full SHA c317540View commit details -
Configuration menu - View commit details
-
Copy full SHA for e8bb6b7 - Browse repository at this point
Copy the full SHA e8bb6b7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 32bb66b - Browse repository at this point
Copy the full SHA 32bb66bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 6ace152 - Browse repository at this point
Copy the full SHA 6ace152View commit details -
Configuration menu - View commit details
-
Copy full SHA for 14ab62f - Browse repository at this point
Copy the full SHA 14ab62fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 41646c8 - Browse repository at this point
Copy the full SHA 41646c8View commit details
Commits on Feb 5, 2024
-
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
Configuration menu - View commit details
-
Copy full SHA for eac9f36 - Browse repository at this point
Copy the full SHA eac9f36View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5806bde - Browse repository at this point
Copy the full SHA 5806bdeView commit details -
Configuration menu - View commit details
-
Copy full SHA for f1f759e - Browse repository at this point
Copy the full SHA f1f759eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 3093082 - Browse repository at this point
Copy the full SHA 3093082View commit details
Commits on Feb 14, 2024
-
Configuration menu - View commit details
-
Copy full SHA for caa3545 - Browse repository at this point
Copy the full SHA caa3545View commit details
Commits on Feb 15, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 09b97cf - Browse repository at this point
Copy the full SHA 09b97cfView commit details -
Configuration menu - View commit details
-
Copy full SHA for 8993a5a - Browse repository at this point
Copy the full SHA 8993a5aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 0b32685 - Browse repository at this point
Copy the full SHA 0b32685View commit details
Commits on Feb 22, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 3b1f8e5 - Browse repository at this point
Copy the full SHA 3b1f8e5View commit details
Commits on Mar 5, 2024
-
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 committedMar 5, 2024 Configuration menu - View commit details
-
Copy full SHA for ff4d072 - Browse repository at this point
Copy the full SHA ff4d072View commit details -
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 committedMar 5, 2024 Configuration menu - View commit details
-
Copy full SHA for 4d8712f - Browse repository at this point
Copy the full SHA 4d8712fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 5209b33 - Browse repository at this point
Copy the full SHA 5209b33View commit details -
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(
Configuration menu - View commit details
-
Copy full SHA for 5158aa2 - Browse repository at this point
Copy the full SHA 5158aa2View commit details -
Configuration menu - View commit details
-
Copy full SHA for e554dd7 - Browse repository at this point
Copy the full SHA e554dd7View commit details -
Configuration menu - View commit details
-
Copy full SHA for e4935e3 - Browse repository at this point
Copy the full SHA e4935e3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8b455bd - Browse repository at this point
Copy the full SHA 8b455bdView commit details -
equipment_catalogue & utils: new script + a change in utils.py - to c…
…reate equip. catalogue
Configuration menu - View commit details
-
Copy full SHA for 9f44e85 - Browse repository at this point
Copy the full SHA 9f44e85View commit details -
Configuration menu - View commit details
-
Copy full SHA for 0ff003b - Browse repository at this point
Copy the full SHA 0ff003bView commit details -
healthsystem: sort equipment for log
Co-authored-by: Tim Hallett <39991060+tbhallett@users.noreply.github.com>
Configuration menu - View commit details
-
Copy full SHA for f736939 - Browse repository at this point
Copy the full SHA f736939View commit details -
Configuration menu - View commit details
-
Copy full SHA for 745d4ab - Browse repository at this point
Copy the full SHA 745d4abView commit details -
Configuration menu - View commit details
-
Copy full SHA for e7c52d8 - Browse repository at this point
Copy the full SHA e7c52d8View commit details -
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(
Configuration menu - View commit details
-
Copy full SHA for b523d58 - Browse repository at this point
Copy the full SHA b523d58View commit details -
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
Configuration menu - View commit details
-
Copy full SHA for 5396269 - Browse repository at this point
Copy the full SHA 5396269View commit details -
Configuration menu - View commit details
-
Copy full SHA for 2791c18 - Browse repository at this point
Copy the full SHA 2791c18View commit details -
Configuration menu - View commit details
-
Copy full SHA for 07e1ae9 - Browse repository at this point
Copy the full SHA 07e1ae9View commit details -
Configuration menu - View commit details
-
Copy full SHA for 00270c1 - Browse repository at this point
Copy the full SHA 00270c1View commit details -
Configuration menu - View commit details
-
Copy full SHA for d486c4d - Browse repository at this point
Copy the full SHA d486c4dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 860d952 - Browse repository at this point
Copy the full SHA 860d952View commit details -
Configuration menu - View commit details
-
Copy full SHA for c573fc8 - Browse repository at this point
Copy the full SHA c573fc8View commit details -
Configuration menu - View commit details
-
Copy full SHA for 373018c - Browse repository at this point
Copy the full SHA 373018cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 307efab - Browse repository at this point
Copy the full SHA 307efabView commit details -
Configuration menu - View commit details
-
Copy full SHA for 4f2ce6c - Browse repository at this point
Copy the full SHA 4f2ce6cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 10b9dde - Browse repository at this point
Copy the full SHA 10b9ddeView commit details -
Configuration menu - View commit details
-
Copy full SHA for 1f2ff79 - Browse repository at this point
Copy the full SHA 1f2ff79View commit details -
Configuration menu - View commit details
-
Copy full SHA for adde374 - Browse repository at this point
Copy the full SHA adde374View commit details -
Configuration menu - View commit details
-
Copy full SHA for e6013d9 - Browse repository at this point
Copy the full SHA e6013d9View commit details -
Configuration menu - View commit details
-
Copy full SHA for a214a88 - Browse repository at this point
Copy the full SHA a214a88View commit details -
equip_catalogue: make catalogues from new logging (equip included in …
…hsi_event_details, counts logged in hsi_event_counts)
Configuration menu - View commit details
-
Copy full SHA for 32145b6 - Browse repository at this point
Copy the full SHA 32145b6View commit details -
Configuration menu - View commit details
-
Copy full SHA for d8e299f - Browse repository at this point
Copy the full SHA d8e299fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 598368d - Browse repository at this point
Copy the full SHA 598368dView commit details -
[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()
Configuration menu - View commit details
-
Copy full SHA for e2fdafb - Browse repository at this point
Copy the full SHA e2fdafbView commit details -
Configuration menu - View commit details
-
Copy full SHA for acf3a63 - Browse repository at this point
Copy the full SHA acf3a63View commit details -
Configuration menu - View commit details
-
Copy full SHA for 97f0f3f - Browse repository at this point
Copy the full SHA 97f0f3fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 1435d22 - Browse repository at this point
Copy the full SHA 1435d22View commit details -
Configuration menu - View commit details
-
Copy full SHA for 14a11a7 - Browse repository at this point
Copy the full SHA 14a11a7View commit details -
equip_catalogue: verify inputs as expected & set output file names in…
… 'create_equipment_catalogues' fnc
Configuration menu - View commit details
-
Copy full SHA for 6d85fe1 - Browse repository at this point
Copy the full SHA 6d85fe1View commit details -
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
Configuration menu - View commit details
-
Copy full SHA for 934e52d - Browse repository at this point
Copy the full SHA 934e52dView commit details -
Configuration menu - View commit details
-
Copy full SHA for bdbd8f7 - Browse repository at this point
Copy the full SHA bdbd8f7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 070454c - Browse repository at this point
Copy the full SHA 070454cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 99be34a - Browse repository at this point
Copy the full SHA 99be34aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 5076e3b - Browse repository at this point
Copy the full SHA 5076e3bView commit details -
Configuration menu - View commit details
-
Copy full SHA for d47b53e - Browse repository at this point
Copy the full SHA d47b53eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 057fb44 - Browse repository at this point
Copy the full SHA 057fb44View commit details -
Configuration menu - View commit details
-
Copy full SHA for 2bf3e8a - Browse repository at this point
Copy the full SHA 2bf3e8aView commit details -
Configuration menu - View commit details
-
Copy full SHA for fa3380f - Browse repository at this point
Copy the full SHA fa3380fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 4b7904a - Browse repository at this point
Copy the full SHA 4b7904aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 8c8bcc5 - Browse repository at this point
Copy the full SHA 8c8bcc5View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6b03edd - Browse repository at this point
Copy the full SHA 6b03eddView commit details -
Configuration menu - View commit details
-
Copy full SHA for c37e1de - Browse repository at this point
Copy the full SHA c37e1deView commit details -
Configuration menu - View commit details
-
Copy full SHA for 99ad138 - Browse repository at this point
Copy the full SHA 99ad138View commit details -
Configuration menu - View commit details
-
Copy full SHA for a281e56 - Browse repository at this point
Copy the full SHA a281e56View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1787ffe - Browse repository at this point
Copy the full SHA 1787ffeView commit details -
Configuration menu - View commit details
-
Copy full SHA for f961640 - Browse repository at this point
Copy the full SHA f961640View commit details -
Configuration menu - View commit details
-
Copy full SHA for 12142b0 - Browse repository at this point
Copy the full SHA 12142b0View commit details -
Configuration menu - View commit details
-
Copy full SHA for 36f0523 - Browse repository at this point
Copy the full SHA 36f0523View commit details -
Configuration menu - View commit details
-
Copy full SHA for b40f955 - Browse repository at this point
Copy the full SHA b40f955View commit details -
Configuration menu - View commit details
-
Copy full SHA for 9c8b6ad - Browse repository at this point
Copy the full SHA 9c8b6adView commit details -
Configuration menu - View commit details
-
Copy full SHA for 0552e48 - Browse repository at this point
Copy the full SHA 0552e48View commit details -
hs: ESS_EQUIP as HSI_Event's attribute; if settings of ESS_EQUIP forg…
…otten -> set to empty & warn
Configuration menu - View commit details
-
Copy full SHA for 0106e20 - Browse repository at this point
Copy the full SHA 0106e20View commit details -
Configuration menu - View commit details
-
Copy full SHA for 455f4e0 - Browse repository at this point
Copy the full SHA 455f4e0View commit details -
Configuration menu - View commit details
-
Copy full SHA for 503036d - Browse repository at this point
Copy the full SHA 503036dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 8ea0b27 - Browse repository at this point
Copy the full SHA 8ea0b27View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7ad13cc - Browse repository at this point
Copy the full SHA 7ad13ccView commit details -
Configuration menu - View commit details
-
Copy full SHA for 39a5d21 - Browse repository at this point
Copy the full SHA 39a5d21View commit details -
Configuration menu - View commit details
-
Copy full SHA for 9dcf46b - Browse repository at this point
Copy the full SHA 9dcf46bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 0bda4d0 - Browse repository at this point
Copy the full SHA 0bda4d0View commit details -
Configuration menu - View commit details
-
Copy full SHA for fc273a0 - Browse repository at this point
Copy the full SHA fc273a0View commit details -
RF_Cons_Items_and_Pkgs: reverted changes from script; Cystoscope, End…
…oscope, PSA test added manually
Configuration menu - View commit details
-
Copy full SHA for 0289af3 - Browse repository at this point
Copy the full SHA 0289af3View commit details
Commits on Mar 6, 2024
-
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
Configuration menu - View commit details
-
Copy full SHA for f844535 - Browse repository at this point
Copy the full SHA f844535View commit details -
Configuration menu - View commit details
-
Copy full SHA for bdb755c - Browse repository at this point
Copy the full SHA bdb755cView commit details
Commits on Mar 7, 2024
-
Configuration menu - View commit details
-
Copy full SHA for bed404d - Browse repository at this point
Copy the full SHA bed404dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 7c69972 - Browse repository at this point
Copy the full SHA 7c69972View commit details
Commits on Mar 21, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 0d387a4 - Browse repository at this point
Copy the full SHA 0d387a4View commit details -
Configuration menu - View commit details
-
Copy full SHA for b87781e - Browse repository at this point
Copy the full SHA b87781eView commit details -
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
Configuration menu - View commit details
-
Copy full SHA for 88632f6 - Browse repository at this point
Copy the full SHA 88632f6View commit details -
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
Configuration menu - View commit details
-
Copy full SHA for d71107a - Browse repository at this point
Copy the full SHA d71107aView commit details
Commits on Mar 25, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 2518c49 - Browse repository at this point
Copy the full SHA 2518c49View commit details -
Configuration menu - View commit details
-
Copy full SHA for a6fffc9 - Browse repository at this point
Copy the full SHA a6fffc9View commit details -
Configuration menu - View commit details
-
Copy full SHA for 8428d8a - Browse repository at this point
Copy the full SHA 8428d8aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 2a3c8f8 - Browse repository at this point
Copy the full SHA 2a3c8f8View commit details -
[no_ci] RF_Equip: availabilities changed from probs to True/False val…
…ues (all True for now)
Configuration menu - View commit details
-
Copy full SHA for b1aa9ae - Browse repository at this point
Copy the full SHA b1aa9aeView commit details
Commits on Mar 26, 2024
-
Co-authored-by: Tim Hallett <39991060+tbhallett@users.noreply.github.com>
Configuration menu - View commit details
-
Copy full SHA for ffd5178 - Browse repository at this point
Copy the full SHA ffd5178View commit details -
hs: rm equip_availability before sim default
Co-authored-by: Tim Hallett <39991060+tbhallett@users.noreply.github.com>
Configuration menu - View commit details
-
Copy full SHA for 7c8ea54 - Browse repository at this point
Copy the full SHA 7c8ea54View commit details -
Co-authored-by: Tim Hallett <39991060+tbhallett@users.noreply.github.com>
Configuration menu - View commit details
-
Copy full SHA for 6ddd11e - Browse repository at this point
Copy the full SHA 6ddd11eView commit details
Commits on Apr 16, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 4f4d858 - Browse repository at this point
Copy the full SHA 4f4d858View commit details -
Configuration menu - View commit details
-
Copy full SHA for f8b0ac1 - Browse repository at this point
Copy the full SHA f8b0ac1View commit details
Commits on May 9, 2024
-
Merge branch 'refs/heads/master' into EvaJ/equipment/structure_ToRunSim
# Conflicts: # resources/healthsystem/ResourceFile_HealthSystem_parameters.csv # src/tlo/methods/healthsystem.py
Configuration menu - View commit details
-
Copy full SHA for 55772ed - Browse repository at this point
Copy the full SHA 55772edView commit details -
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.
Configuration menu - View commit details
-
Copy full SHA for 16752ae - Browse repository at this point
Copy the full SHA 16752aeView commit details -
Configuration menu - View commit details
-
Copy full SHA for cd2774e - Browse repository at this point
Copy the full SHA cd2774eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 7a5d991 - Browse repository at this point
Copy the full SHA 7a5d991View commit details -
Configuration menu - View commit details
-
Copy full SHA for 4781555 - Browse repository at this point
Copy the full SHA 4781555View commit details
Commits on May 10, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 27779e6 - Browse repository at this point
Copy the full SHA 27779e6View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1988ae2 - Browse repository at this point
Copy the full SHA 1988ae2View commit details -
Configuration menu - View commit details
-
Copy full SHA for 13d5a3c - Browse repository at this point
Copy the full SHA 13d5a3cView commit details
Commits on May 12, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 3d4b80d - Browse repository at this point
Copy the full SHA 3d4b80dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 3bb2581 - Browse repository at this point
Copy the full SHA 3bb2581View commit details
Commits on May 13, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 3c16898 - Browse repository at this point
Copy the full SHA 3c16898View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5bcdb38 - Browse repository at this point
Copy the full SHA 5bcdb38View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3bea20f - Browse repository at this point
Copy the full SHA 3bea20fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 3a8d3da - Browse repository at this point
Copy the full SHA 3a8d3daView commit details -
Configuration menu - View commit details
-
Copy full SHA for dc9d9b9 - Browse repository at this point
Copy the full SHA dc9d9b9View commit details -
Configuration menu - View commit details
-
Copy full SHA for ea4027b - Browse repository at this point
Copy the full SHA ea4027bView commit details -
Merge branch 'refs/heads/master' into equipment/integration_in_modules
# Conflicts: # src/tlo/methods/healthsystem.py # src/tlo/methods/hsi_generic_first_appts.py
Configuration menu - View commit details
-
Copy full SHA for b31b93f - Browse repository at this point
Copy the full SHA b31b93fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 2dd360a - Browse repository at this point
Copy the full SHA 2dd360aView commit details -
Configuration menu - View commit details
-
Copy full SHA for a306e24 - Browse repository at this point
Copy the full SHA a306e24View commit details -
Configuration menu - View commit details
-
Copy full SHA for faf2fa8 - Browse repository at this point
Copy the full SHA faf2fa8View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3be6e70 - Browse repository at this point
Copy the full SHA 3be6e70View commit details -
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
Configuration menu - View commit details
-
Copy full SHA for 68c4da2 - Browse repository at this point
Copy the full SHA 68c4da2View commit details -
temporarily make simulation shorter, smaller and with fewer draws to …
…create a test run.
Configuration menu - View commit details
-
Copy full SHA for 8bcda48 - Browse repository at this point
Copy the full SHA 8bcda48View commit details -
Revert "temporarily make simulation shorter, smaller and with fewer d…
…raws to create a test run." This reverts commit 8bcda48.
Configuration menu - View commit details
-
Copy full SHA for 0dd00c4 - Browse repository at this point
Copy the full SHA 0dd00c4View commit details
Commits on May 16, 2024
-
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
Configuration menu - View commit details
-
Copy full SHA for ce6a2d8 - Browse repository at this point
Copy the full SHA ce6a2d8View commit details -
Configuration menu - View commit details
-
Copy full SHA for d1c8699 - Browse repository at this point
Copy the full SHA d1c8699View commit details
Commits on May 24, 2024
-
Configuration menu - View commit details
-
Copy full SHA for f566709 - Browse repository at this point
Copy the full SHA f566709View commit details
Commits on May 28, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 3bf93ac - Browse repository at this point
Copy the full SHA 3bf93acView commit details
Commits on May 31, 2024
-
Merge branch 'refs/heads/master' into hallett/equipment_changes_and_s…
…tructure # Conflicts: # src/tlo/methods/tb.py
Configuration menu - View commit details
-
Copy full SHA for 56056d2 - Browse repository at this point
Copy the full SHA 56056d2View commit details -
* 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>
Configuration menu - View commit details
-
Copy full SHA for 135fc2e - Browse repository at this point
Copy the full SHA 135fc2eView commit details
Commits on Jun 6, 2024
-
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
Configuration menu - View commit details
-
Copy full SHA for 0d6fd8d - Browse repository at this point
Copy the full SHA 0d6fd8dView commit details -
cancer_cons: joined screening cons for biopsy, cystoscopy and endosco…
…py; bc: biopsy replaced with cystoscopy; oc biopsy replaced with endoscopy
Configuration menu - View commit details
-
Copy full SHA for b7c27c8 - Browse repository at this point
Copy the full SHA b7c27c8View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1f1d94b - Browse repository at this point
Copy the full SHA 1f1d94bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 6c8c33d - Browse repository at this point
Copy the full SHA 6c8c33dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 694da75 - Browse repository at this point
Copy the full SHA 694da75View commit details
Commits on Jun 10, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 7a27a1f - Browse repository at this point
Copy the full SHA 7a27a1fView commit details
Commits on Jun 20, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 310f6b4 - Browse repository at this point
Copy the full SHA 310f6b4View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3bd3487 - Browse repository at this point
Copy the full SHA 3bd3487View commit details -
Configuration menu - View commit details
-
Copy full SHA for f4aabca - Browse repository at this point
Copy the full SHA f4aabcaView commit details -
allow spaces in Pkg_Names (don't remove all spaces, but instead strip…
… out trailing/leading spaces)
Configuration menu - View commit details
-
Copy full SHA for 88b6f59 - Browse repository at this point
Copy the full SHA 88b6f59View commit details