Skip to content

Commit

Permalink
added return statements and footprints and as treatment_id for Xrays,…
Browse files Browse the repository at this point in the history
… culture, clinical diagnosis not printed
  • Loading branch information
nchagoma503 committed Jan 29, 2025
1 parent f48132c commit 3e3f987
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/scripts/hiv/DAH/analysis_tb_DAH10x.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

#outputfilepath = Path("./outputs")

results_folder = get_scenario_outputs('tb_DAH_scenarios10x-2025-01-29T090853Z', outputfilepath) [-1]
results_folder = get_scenario_outputs('tb_DAH_scenarios10x-2025-01-29T121043Z', outputfilepath) [-1]
log = load_pickled_dataframes(results_folder)
info = get_scenario_info(results_folder)
print(info)
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/hiv/DAH/tb_DAH_scenarios10x.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def __init__(self):
self.seed = 2134
#self.seed = random.randint(0, 50000),
self.start_date = Date(2010, 1, 1)
self.end_date = Date(2011, 12, 31)
self.pop_size = 600
self.end_date = Date(2012, 12, 31)
self.pop_size = 100
self._scenarios = self._get_scenarios()
self.number_of_draws = len(self._scenarios)
self.runs_per_draw = 2
Expand Down
34 changes: 25 additions & 9 deletions src/tlo/methods/tb.py
Original file line number Diff line number Diff line change
Expand Up @@ -2275,21 +2275,25 @@ def apply(self, person_id, squeeze_factor):
if not df.at[person_id, "is_alive"] or df.at[person_id, "tb_diagnosed"]:
return self.sim.modules["HealthSystem"].get_blank_appt_footprint()

#Run TB culture test
test_result = self.sim.modules["HealthSystem"].dx_manager.run_dx_test(
dx_tests_to_run="tb_culture_test", hsi_event=self)

#ACTUAL_APPT_FOOTPRINT = self.make_appt_footprint({})

# todo equipment required: MGIT instrument, MGIT tube, reagent kit included in consumables
if test_result is not None:
self.add_equipment({'Autoclave', 'Blood culture incubator', 'Vortex mixer',
'Dispensing pumps for culture media preparation', 'Biosafety Cabinet (Class II)',
'Centrifuge'})

ACTUAL_APPT_FOOTPRINT = self.make_appt_footprint({"LabTBMicro": 1})

# if test returns positive result, refer for appropriate treatment
if test_result:
df.at[person_id, "tb_diagnosed"] = True
df.at[person_id, "tb_date_diagnosed"] = self.sim.date

ACTUAL_APPT_FOOTPRINT = self.make_appt_footprint({"LabTBMicro": 1})

self.sim.modules["HealthSystem"].schedule_hsi_event(
HSI_Tb_StartTreatment(
Expand All @@ -2302,7 +2306,7 @@ def apply(self, person_id, squeeze_factor):

# Return the footprint. If it should be suppressed, return a blank footprint.
if self.suppress_footprint:
return self.make_appt_footprint({})
return
else:
return ACTUAL_APPT_FOOTPRINT

Expand All @@ -2326,13 +2330,17 @@ def __init__(self, module, person_id, suppress_footprint=False):
self.ACCEPTED_FACILITY_LEVEL = '1b'

def apply(self, person_id, squeeze_factor):
persons_symptoms = self.sim.modules["SymptomManager"].has_what(person_id)
if not any(x in self.module.symptom_list for x in persons_symptoms):
print(f"Facility CXR scheduled for person {person_id} due to TB symptoms.")
return self.sim.modules["HealthSystem"].get_blank_appt_footprint()

df = self.sim.population.props

if not df.at[person_id, "is_alive"] or df.at[person_id, "tb_diagnosed"]:
return self.sim.modules["HealthSystem"].get_blank_appt_footprint()

ACTUAL_APPT_FOOTPRINT = self.EXPECTED_APPT_FOOTPRINT
#ACTUAL_APPT_FOOTPRINT = self.EXPECTED_APPT_FOOTPRINT

smear_status = df.at[person_id, "tb_smear"]

Expand All @@ -2355,9 +2363,18 @@ def apply(self, person_id, squeeze_factor):
# return blank footprint as xray did not occur
if test_result is None:

ACTUAL_APPT_FOOTPRINT = self.make_appt_footprint({})
if smear_status:
test_result = self.sim.modules["HealthSystem"].dx_manager.run_dx_test(
dx_tests_to_run="tb_clinical", hsi_event=self
)

# add another clinic appointment
ACTUAL_APPT_FOOTPRINT = self.make_appt_footprint(
{"Under5OPD": 1, "DiagRadio": 1}
)

self.sim.modules["HealthSystem"].schedule_hsi_event(
else:
self.sim.modules["HealthSystem"].schedule_hsi_event(
HSI_Tb_Xray_level2(person_id=person_id, module=self.module),
topen=self.sim.date + pd.DateOffset(weeks=1),
tclose=None,
Expand Down Expand Up @@ -2429,6 +2446,7 @@ def apply(self, person_id, squeeze_factor):
test_result = self.sim.modules["HealthSystem"].dx_manager.run_dx_test(
dx_tests_to_run="tb_xray_smear_negative", hsi_event=self
)

if test_result is not None:
self.add_equipment(self.healthcare_system.equipment.from_pkg_names('X-ray'))

Expand All @@ -2438,7 +2456,7 @@ def apply(self, person_id, squeeze_factor):
# return blank footprint as xray was not available
if test_result is None:

ACTUAL_APPT_FOOTPRINT = self.make_appt_footprint({})
#ACTUAL_APPT_FOOTPRINT = self.make_appt_footprint({})

self.sim.modules["HealthSystem"].schedule_hsi_event(
HSI_Tb_ClinicalDiagnosis(person_id=person_id, module=self.module),
Expand All @@ -2452,8 +2470,6 @@ def apply(self, person_id, squeeze_factor):
df.at[person_id, "tb_diagnosed"] = True
df.at[person_id, "tb_date_diagnosed"] = self.sim.date



self.sim.modules["HealthSystem"].schedule_hsi_event(
HSI_Tb_StartTreatment(
person_id=person_id, module=self.module, facility_level="1a"
Expand Down Expand Up @@ -2984,7 +3000,7 @@ def apply(self, person_id, squeeze_factor):
dx_tests_to_run="tb_xray_smear_negative", hsi_event=self
)

ACTUAL_APPOINTMENT=self.make_appt_footprint({"ConWithDCSA": 1})
#ACTUAL_APPOINTMENT=self.make_appt_footprint({"ConWithDCSA": 1})

# If the test returns a positive result, refer for appropriate treatment
if test_result:
Expand Down

0 comments on commit 3e3f987

Please sign in to comment.