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

add TB culture HSI #1453

Merged
merged 23 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
cca6604
modification to scenarios to get it running fast
tbhallett Jul 29, 2024
209a222
define mode1 baseline properly
tbhallett Aug 2, 2024
71aa918
define mode1 baseline properly
tbhallett Aug 2, 2024
0a138e5
add culture test for tb dx
tdm32 Aug 5, 2024
b39cdf6
remove unneeded todo statement
tdm32 Aug 5, 2024
6c2d22a
remove ref to life expectancy in script
tdm32 Aug 5, 2024
5dcca8c
remove unused imports
tdm32 Aug 5, 2024
22c6bcf
update priority policies
tdm32 Aug 6, 2024
0941c3e
add scenario version with consumables always available
tbhallett Aug 6, 2024
c734124
update plots
tdm32 Aug 9, 2024
5ce3b75
Merge remote-tracking branch 'origin/hallett/test_run_htm_scale_up' i…
tdm32 Aug 13, 2024
9a01a98
add outputs to test plot file
tdm32 Aug 14, 2024
0f7cd50
Merge branch 'master' into hallett/test_run_htm_scale_up
tdm32 Dec 10, 2024
20dd65f
Merge remote-tracking branch 'origin/hallett/test_run_htm_scale_up' i…
tdm32 Dec 10, 2024
66fd198
revert analysis scripts
tdm32 Dec 10, 2024
792ee4b
Merge branch 'master' into hallett/test_run_htm_scale_up
tdm32 Dec 11, 2024
61496c9
Merge branch 'master' into hallett/test_run_htm_scale_up
tbhallett Dec 13, 2024
9d071c1
Merge branch 'master' into hallett/test_run_htm_scale_up
tbhallett Dec 13, 2024
836cfbf
remove suppress_footprint from HSI_Tb_Culture
tdm32 Dec 16, 2024
5ef261b
Merge remote-tracking branch 'origin/hallett/test_run_htm_scale_up' i…
tdm32 Dec 16, 2024
f85dc9f
remove unused statement ACTUAL_APPT_FOOTPRINT = self.EXPECTED_APPT_FO…
tdm32 Dec 16, 2024
78b0e2a
Merge branch 'refs/heads/master' into hallett/test_run_htm_scale_up
tbhallett Dec 17, 2024
9fe9cb8
roll back other files
tbhallett Dec 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Git LFS file not shown
113 changes: 113 additions & 0 deletions src/tlo/methods/tb.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,21 @@ def get_consumables_for_dx_and_tx(self):
)
)

# TB Culture
self.item_codes_for_consumables_required['culture_test'] = \
hs.get_item_code_from_item_name("MGIT960 Culture and DST")

# sensitivity/specificity set for smear status of cases
self.sim.modules["HealthSystem"].dx_manager.register_dx_test(
tb_culture_test=DxTest(
property="tb_inf",
target_categories=["active"],
sensitivity=1.0,
specificity=1.0,
item_codes=self.item_codes_for_consumables_required['culture_test']
)
)

# 4) -------- Define the treatment options --------
# treatment supplied as full kits for duration of treatment
# adult treatment - primary
Expand Down Expand Up @@ -1458,6 +1473,7 @@ def __init__(self, module):
def apply(self, population):

self.module.update_parameters_for_program_scaleup()
# note also culture test used in target/max scale-up in place of clinical dx


class TbActiveEvent(RegularEvent, PopulationScopeEventMixin):
Expand Down Expand Up @@ -1729,6 +1745,8 @@ def apply(self, person_id, squeeze_factor):
# check if patient has: cough, fever, night sweat, weight loss
# if none of the above conditions are present, no further action
persons_symptoms = self.sim.modules["SymptomManager"].has_what(person_id=person_id)
person_has_tb_symptoms = all(symptom in persons_symptoms for symptom in self.module.symptom_list)

if not any(x in self.module.symptom_list for x in persons_symptoms):
return self.make_appt_footprint({})

Expand Down Expand Up @@ -1944,6 +1962,27 @@ def apply(self, person_id, squeeze_factor):
tclose=None,
)

# ------------------------- Culture testing if program scale-up ------------------------- #
# under program scale-up, if a person tests negative but still has symptoms
# indicative of TB, they are referred for culture test which has perfect sensitivity
# this has the effect to reduce false negatives
if not test_result and person_has_tb_symptoms:
if p['type_of_scaleup'] != 'none' and self.sim.date.year >= p['scaleup_start_year']:
logger.debug(
key="message",
data=f"HSI_Tb_ScreeningAndRefer: scheduling culture for person {person_id}",
)

culture_event = HSI_Tb_Culture(
self.module, person_id=person_id
)
self.sim.modules["HealthSystem"].schedule_hsi_event(
culture_event,
priority=0,
topen=now,
tclose=None,
)

# Return the footprint. If it should be suppressed, return a blank footprint.
if self.suppress_footprint:
return self.make_appt_footprint({})
Expand Down Expand Up @@ -1979,6 +2018,7 @@ def apply(self, person_id, squeeze_factor):
df = self.sim.population.props
now = self.sim.date
person = df.loc[person_id]
p = self.module.parameters
test_result = None

# If the person is dead or already diagnosed, do nothing do not occupy any resources
Expand Down Expand Up @@ -2021,6 +2061,79 @@ def apply(self, person_id, squeeze_factor):
tclose=None,
priority=0,
)
# ------------------------- Culture testing if program scale-up ------------------------- #
# under program scale-up, if a person tests negative but still has all symptoms
# indicative of TB, they are referred for culture test which has perfect sensitivity
# this has the effect to reduce false negatives
person_has_tb_symptoms = all(symptom in persons_symptoms for symptom in self.module.symptom_list)

if not test_result and person_has_tb_symptoms:
if p['type_of_scaleup'] != 'none' and self.sim.date.year >= p['scaleup_start_year']:

logger.debug(
key="message",
data=f"HSI_Tb_ClinicalDiagnosis: scheduling culture for person {person_id}",
)

culture_event = HSI_Tb_Culture(
self.module, person_id=person_id
)
self.sim.modules["HealthSystem"].schedule_hsi_event(
culture_event,
priority=0,
topen=now,
tclose=None,
)


class HSI_Tb_Culture(HSI_Event, IndividualScopeEventMixin):
"""
This the TB culture HSI used for microbiological diagnosis of TB
results (MGIT) are available after 2-6 weeks
will return drug-susceptibility
100% sensitivity in smear-positive
80-90% sensitivity in smear-negative
if this test is not available, not further action as this is
already preceded by a sequence of tests
"""

def __init__(self, module, person_id):
super().__init__(module, person_id=person_id)
assert isinstance(module, Tb)

self.TREATMENT_ID = "Tb_Test_Culture"
self.EXPECTED_APPT_FOOTPRINT = self.make_appt_footprint({"LabTBMicro": 1})
self.ACCEPTED_FACILITY_LEVEL = '1b'

def apply(self, person_id, squeeze_factor):

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()

test_result = self.sim.modules["HealthSystem"].dx_manager.run_dx_test(
dx_tests_to_run="tb_culture_test", hsi_event=self)

# 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'})

# 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

self.sim.modules["HealthSystem"].schedule_hsi_event(
HSI_Tb_StartTreatment(
person_id=person_id, module=self.module, facility_level="1a"
),
topen=self.sim.date,
tclose=None,
priority=0,
)


class HSI_Tb_Xray_level1b(HSI_Event, IndividualScopeEventMixin):
Expand Down
Loading