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

PR to record the prevalence of disease/condition, still births, neonatal death, maternal mortality #1455

Open
wants to merge 190 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
190 commits
Select commit Hold shift + click to select a range
5b712f9
Initial file for recording the prevalence of all diseases
RachelMurray-Watson Jul 24, 2024
9a0ea19
Tidied
RachelMurray-Watson Jul 24, 2024
354a45c
Just realized that I can't access the folders
RachelMurray-Watson Jul 25, 2024
9bddac8
Added function to report back prevalence
RachelMurray-Watson Jul 26, 2024
6bdb972
Added function to request get_current_prevalence from each registered…
RachelMurray-Watson Jul 26, 2024
1725b54
typo
RachelMurray-Watson Jul 26, 2024
ec8881d
Added logging of prevalences
RachelMurray-Watson Jul 26, 2024
3bdcb61
Added function that reports the prevalence of any TB infection in any…
RachelMurray-Watson Jul 26, 2024
ce5bd89
Added column names so that they would not overwrite
RachelMurray-Watson Jul 26, 2024
2692bc8
Check to see if recording the prevalence is working.
RachelMurray-Watson Jul 26, 2024
8205850
Now redundant, was to source from logs
RachelMurray-Watson Jul 26, 2024
ce89c7c
Added function to return the prevalence of malaria infections.
RachelMurray-Watson Jul 26, 2024
f0a9e12
added docstring
RachelMurray-Watson Jul 26, 2024
4c07c7d
Added function calculating the prevalence of prostate cancer over all…
RachelMurray-Watson Jul 26, 2024
c22e1b2
Added function calculating the prevalence of measles over all individ…
RachelMurray-Watson Jul 26, 2024
19ffc46
Added function calculating the prevalence of other adult cancers over…
RachelMurray-Watson Jul 26, 2024
023c563
Added function calculating the prevalence of RTIs over all individuals
RachelMurray-Watson Jul 26, 2024
99d021c
Added missing return statement
RachelMurray-Watson Jul 26, 2024
48a5b5d
Added function reporting prevalence of COPD across all individuals
RachelMurray-Watson Jul 26, 2024
af7a596
Added logging of prevalence
RachelMurray-Watson Jul 26, 2024
d286b0d
Added function reporting prevalence of ARLI across all individuals
RachelMurray-Watson Jul 26, 2024
88a8b27
Added function reporting prevalence of ALRI across all individuals
RachelMurray-Watson Jul 26, 2024
a9b8754
Added function reporting prevalence of breast cancer across all indiv…
RachelMurray-Watson Jul 26, 2024
c1815e5
Added function reporting prevalence of epilepsy across all individuals
RachelMurray-Watson Jul 26, 2024
0965522
Added function reporting prevalence of epilepsy across all individuals
RachelMurray-Watson Jul 26, 2024
156646c
Added function reporting prevalence of oesophageal cancer across all …
RachelMurray-Watson Jul 26, 2024
3d854ef
Added function reporting prevalence of schisto cancer across all indi…
RachelMurray-Watson Jul 26, 2024
9287c8b
Added function reporting prevalence of newborn outcomes across all in…
RachelMurray-Watson Jul 29, 2024
47ca667
Added function reporting prevalence of maternal outcomes across all i…
RachelMurray-Watson Jul 29, 2024
415b38d
Updated to include new modules
RachelMurray-Watson Jul 29, 2024
533dbb9
changed years of interest as test
RachelMurray-Watson Jul 31, 2024
f927ec3
removed unnecessary logs
RachelMurray-Watson Jul 31, 2024
17425a3
removed prevalence function
RachelMurray-Watson Aug 1, 2024
69455bc
Changed the naming of columns so the prevalence from the labour modul…
RachelMurray-Watson Aug 1, 2024
1474923
Added a function to record the prevalence of intrapartum stillbirths
RachelMurray-Watson Aug 1, 2024
78665a8
updated doc string
RachelMurray-Watson Aug 1, 2024
20c0a9c
Added a function to record the prevalence of antenatal stillbirths
RachelMurray-Watson Aug 1, 2024
366c939
Updated naming of columns
RachelMurray-Watson Aug 1, 2024
cf2a2b5
removed prevalence calculations
RachelMurray-Watson Aug 1, 2024
0c1d924
Added function calculating neonatal and maternal mortality. Neonatal …
RachelMurray-Watson Aug 1, 2024
6c2125c
fixed errors in recording
RachelMurray-Watson Aug 1, 2024
d42a609
Fixed titles of columns
RachelMurray-Watson Aug 1, 2024
06053fe
Fixed titles of columns
RachelMurray-Watson Aug 1, 2024
c272e82
corrected function name
RachelMurray-Watson Aug 1, 2024
e6908d8
corrected function
RachelMurray-Watson Aug 1, 2024
273e68d
corrected function
RachelMurray-Watson Aug 1, 2024
fc2fcc7
added function to report the prevalence of bladder cancer across all …
RachelMurray-Watson Aug 1, 2024
cdd490c
added function to report the prevalence of depression for that month …
RachelMurray-Watson Aug 1, 2024
ac9c3e1
removed some modules from checks on prevalence as either (a) forgot t…
RachelMurray-Watson Aug 1, 2024
a756059
changed how infections are calculated (based on number reporting symp…
RachelMurray-Watson Aug 1, 2024
0ce8fec
tidied
RachelMurray-Watson Aug 1, 2024
a714f24
added function to calculate monthly prevalence of bladder cancer acro…
RachelMurray-Watson Aug 1, 2024
701a177
added function to calculate monthly prevalence of diarrhoea across al…
RachelMurray-Watson Aug 1, 2024
e1cb143
added function to calculate monthly prevalence of different ncds. Cal…
RachelMurray-Watson Aug 1, 2024
1c91fae
added function to calculate monthly prevalence of different ncds. Cal…
RachelMurray-Watson Aug 1, 2024
a047e20
Fixed to allow for dataframes to pass through
RachelMurray-Watson Aug 2, 2024
1b5f16b
Fixed from None to False
RachelMurray-Watson Aug 2, 2024
25575dd
Fixed from 0 to '0'
RachelMurray-Watson Aug 2, 2024
28f0a87
Fixed calculation of depression in last month
RachelMurray-Watson Aug 2, 2024
3eacfe1
Removed checks
RachelMurray-Watson Aug 2, 2024
17758f6
Added debugging
RachelMurray-Watson Aug 2, 2024
b4f5434
Removed print checks
RachelMurray-Watson Aug 12, 2024
9f663fd
NOT WORKING but tried to simplify the collection process as was being…
RachelMurray-Watson Aug 13, 2024
24e7279
Now logging properly
RachelMurray-Watson Aug 13, 2024
145dada
Included code for if HIV module isn't loaded
RachelMurray-Watson Aug 14, 2024
64ca957
Added/removed check
RachelMurray-Watson Aug 14, 2024
d1fd3f2
Added function to record number of antenatal stillbirthds
RachelMurray-Watson Aug 14, 2024
9edb85c
renamed newborn to neonatal
RachelMurray-Watson Aug 14, 2024
07987d3
Accessed all possible data from logs, but it's not matching
RachelMurray-Watson Aug 15, 2024
c3490db
not needed
RachelMurray-Watson Aug 15, 2024
211f6c0
removed prints
RachelMurray-Watson Aug 15, 2024
8c6291b
changed date to see if things match up more
RachelMurray-Watson Aug 15, 2024
a5d9e65
removed "isn't false"
RachelMurray-Watson Aug 15, 2024
e6797d5
removed "is true"
RachelMurray-Watson Aug 15, 2024
d2b2d26
replaced == false with not
RachelMurray-Watson Aug 15, 2024
487ee5a
Now matching up more. Have to use the second key from the function I …
RachelMurray-Watson Aug 15, 2024
c841092
Edited so no dividing by zero
RachelMurray-Watson Aug 15, 2024
24c4bd2
changed to does not equal to avoid assertion error
RachelMurray-Watson Aug 15, 2024
ec67dbf
removed unused imports
RachelMurray-Watson Aug 15, 2024
d6ba6a5
removed == False
RachelMurray-Watson Aug 15, 2024
8bf5d85
Intrapartum stillbirth not working
RachelMurray-Watson Aug 16, 2024
f318ca5
added export
RachelMurray-Watson Aug 16, 2024
da9f40a
added export
RachelMurray-Watson Aug 16, 2024
17cb6b5
Better readability
RachelMurray-Watson Aug 16, 2024
0aabe37
removed pandas
RachelMurray-Watson Aug 16, 2024
1831049
isort
RachelMurray-Watson Aug 16, 2024
74981c1
changed definition of COPDS
RachelMurray-Watson Aug 16, 2024
fb4e7e4
changed definition of COPDS
RachelMurray-Watson Aug 16, 2024
7cc8d02
removed calculations of maternal and newborn mortality pending help
RachelMurray-Watson Aug 16, 2024
35f15c5
changed years to see if things log differentlu
RachelMurray-Watson Aug 16, 2024
3720335
stopped logging stillbirths until fixed
RachelMurray-Watson Aug 16, 2024
01e0525
CHecked what was registered
RachelMurray-Watson Aug 16, 2024
83b695d
Skip Mockitis
RachelMurray-Watson Aug 17, 2024
597f055
Skip Mockitis, ChronicSyndrome, DiseaseThatCausedA
RachelMurray-Watson Aug 17, 2024
b21ecdf
Removed unused
RachelMurray-Watson Aug 18, 2024
3962fa6
Added check of "must have died in the last month"
RachelMurray-Watson Aug 19, 2024
7dacc6d
Added check of "must have died in the last month"
RachelMurray-Watson Aug 19, 2024
fa0e532
Removed denominators
RachelMurray-Watson Aug 19, 2024
7cb70be
Removed brackets and unneeded bracket
RachelMurray-Watson Aug 19, 2024
dbd87ff
Changed back to a rate
RachelMurray-Watson Aug 20, 2024
c01362b
Added in dataframes to track stillbirths
RachelMurray-Watson Aug 20, 2024
f2e067b
Renamed columns
RachelMurray-Watson Aug 20, 2024
cbec6ea
skip some columns
RachelMurray-Watson Aug 20, 2024
54b8e7f
skip some columns
RachelMurray-Watson Aug 20, 2024
24fd8fd
Aded skip over dates that go beyond when the prevalence is logged by …
RachelMurray-Watson Aug 21, 2024
a942bfd
Fixed up tests for all diseases WITH log stored
RachelMurray-Watson Aug 21, 2024
0576bcb
Include keeping track of population to go from prevalence to cases
RachelMurray-Watson Aug 21, 2024
23c5106
Returned to running simulation
RachelMurray-Watson Aug 21, 2024
7437f04
removed unnecessary prints
RachelMurray-Watson Aug 21, 2024
854dde5
added record of live birthds
RachelMurray-Watson Aug 21, 2024
5ac533a
added record of live birthds
RachelMurray-Watson Aug 21, 2024
66abb64
added record of live births
RachelMurray-Watson Aug 21, 2024
b35e81f
redid name of column
RachelMurray-Watson Aug 21, 2024
0659162
Added in test of neonatal deaths, maternal deaths, stillbirths
RachelMurray-Watson Aug 21, 2024
08dbc81
remove unused variable
RachelMurray-Watson Aug 21, 2024
e458bda
isort
RachelMurray-Watson Aug 21, 2024
de3c6b1
isort
RachelMurray-Watson Aug 21, 2024
f38533b
TB recording isn't working...
RachelMurray-Watson Aug 21, 2024
f7cf21b
changed to allow for simplified births logging
RachelMurray-Watson Aug 21, 2024
847bee0
removed loading
RachelMurray-Watson Aug 21, 2024
93d8d02
removed unused imports
RachelMurray-Watson Aug 21, 2024
bbd036b
isort
RachelMurray-Watson Aug 21, 2024
8895865
removed incorrect assignation
RachelMurray-Watson Aug 22, 2024
b9a0b43
Merge branch 'master' into rmw/log_prevalence_all_disease
RachelMurray-Watson Aug 22, 2024
39a2b82
Changed calculation of prevalence on simple whether or not person was…
RachelMurray-Watson Aug 29, 2024
0bb4062
Changed calculation of prevalence to be the number of people who are …
RachelMurray-Watson Aug 29, 2024
442d7e6
Get_Current_Prevalence have test variable that is true/false and chan…
RachelMurray-Watson Aug 29, 2024
f613679
Made test a parameter that is default set to False and can be modifie…
RachelMurray-Watson Aug 29, 2024
64f10d2
Ensured indenting was correct. Removed tolerance buffer for days and …
RachelMurray-Watson Aug 29, 2024
b14e4b0
Attempted to make the prevalence logging daily, for the purpose of th…
RachelMurray-Watson Aug 30, 2024
d2d1726
Tidied and used function to calculate prevalences.
RachelMurray-Watson Aug 30, 2024
7163299
Tried to make the log daily by introducing more conditions.
RachelMurray-Watson Aug 30, 2024
8bb1cc7
Monthly call from functions
RachelMurray-Watson Aug 30, 2024
35a806b
removed unused variable for checks
RachelMurray-Watson Aug 30, 2024
0a49ae2
removed unused variable for checks
RachelMurray-Watson Aug 30, 2024
ea79fe8
removed unused variable for checks
RachelMurray-Watson Aug 30, 2024
3d8c01a
isort
RachelMurray-Watson Aug 30, 2024
d271418
new write to log function just for prevalence calculations
RachelMurray-Watson Sep 3, 2024
2e34873
new write to log function just for prevalence calculations. Now logs …
RachelMurray-Watson Sep 3, 2024
6681800
new write to log function just for prevalence calculations. Now logs …
RachelMurray-Watson Sep 3, 2024
b88995d
Allow mockitis to be read in the GetPrevalence Class.
RachelMurray-Watson Sep 4, 2024
792734c
Set p(infection) of Mockitis to 1 and checked logging
RachelMurray-Watson Sep 4, 2024
9b28149
In demography, fixed labels for direct/indirect/hiv/non hiv deaths
RachelMurray-Watson Sep 4, 2024
066f172
Changed malaria prevalence calculator to clinical and severe malaria …
RachelMurray-Watson Sep 4, 2024
295acf4
Changed schisto prevalence calculation to check for Low-infection or …
RachelMurray-Watson Sep 4, 2024
d1ddcc2
Changed TB prevalence logging to only include active cases. "I think …
RachelMurray-Watson Sep 4, 2024
3332382
Now using (df['rt_inj_severity'] != 'none') again to record RTI injuries
RachelMurray-Watson Sep 4, 2024
05e8777
Updated description of logger to show what is being saved where
RachelMurray-Watson Sep 4, 2024
2c34870
Added report_prevalence to the skeleton module so that it's formally …
RachelMurray-Watson Sep 4, 2024
ea55f1a
Added option between daily, monthly, and yearly logging
RachelMurray-Watson Sep 4, 2024
8f78528
Tidied test to have mockitis test (to check logging structures etc) a…
RachelMurray-Watson Sep 4, 2024
ac84e8c
isort
RachelMurray-Watson Sep 4, 2024
5b60013
- Corrected logging_frequency_prevalence from BOOL to STRING
RachelMurray-Watson Sep 5, 2024
8d986e5
- Remove log_line_by_line for prevalence as is contained in write_to_…
RachelMurray-Watson Sep 5, 2024
334f047
Removed seed argument
RachelMurray-Watson Sep 5, 2024
4bc8d1d
Added report_prevalence, which returns None
RachelMurray-Watson Sep 5, 2024
a4f4b57
CardioMetabolic no longer a special case. Instead, checks to see if t…
RachelMurray-Watson Sep 5, 2024
de3f95e
Changing the labelling of the Intrapartum and Antenatal Stillbirths t…
RachelMurray-Watson Sep 5, 2024
7ff62bf
Changing the labelling of the Intrapartum and Antenatal Stillbirths t…
RachelMurray-Watson Sep 5, 2024
4c7d818
Changing the labelling of the Intrapartum and Antenatal Stillbirths t…
RachelMurray-Watson Sep 5, 2024
ff400be
Changed the indexing of self.prevalence_of_diseases to be flexible in…
RachelMurray-Watson Sep 5, 2024
a102db5
Update src/tlo/methods/healthburden.py
RachelMurray-Watson Sep 5, 2024
97327bf
Merge remote-tracking branch 'origin/rmw/log_prevalence_all_disease' …
RachelMurray-Watson Sep 5, 2024
5ef54f3
In healthburden module, removed checks on what the prevalence logging…
RachelMurray-Watson Sep 5, 2024
f3e09bc
Updated the docstring to remove references to the necessity of one da…
RachelMurray-Watson Sep 5, 2024
c9ca5f4
Refactored the function log_df_line_by_line to be a function on this …
RachelMurray-Watson Sep 5, 2024
5cf9961
Added report_prevalence to baseclass. Returns None if not overwritten
RachelMurray-Watson Sep 5, 2024
837be30
- Refactored the function log_df_line_by_line to be a function on thi…
RachelMurray-Watson Sep 5, 2024
b8408da
Fixed typo in recording the prevalence as a dataframe issue.
RachelMurray-Watson Sep 5, 2024
333975f
- Removed report_prevalence from baseclass
RachelMurray-Watson Sep 11, 2024
54fe152
- fixed docstring
RachelMurray-Watson Sep 11, 2024
4909def
Merge branch 'refs/heads/master' into rmw/log_prevalence_all_disease
RachelMurray-Watson Sep 11, 2024
a89c0b4
- disease modules now return dictionaries
RachelMurray-Watson Sep 11, 2024
edede44
- disease modules now return dictionaries
RachelMurray-Watson Sep 11, 2024
ff12b09
- disease modules now return dictionaries
RachelMurray-Watson Sep 11, 2024
2ba29bc
testing
RachelMurray-Watson Sep 12, 2024
e76136f
Added even simpler dummy disease. Only allows infections, no recovery…
RachelMurray-Watson Sep 12, 2024
1a817dc
Now collects dictionaries
RachelMurray-Watson Sep 12, 2024
65d1d7c
Fixed up dummy disease
RachelMurray-Watson Sep 12, 2024
a9040dc
Added dummy disease module to Mockitis
RachelMurray-Watson Sep 12, 2024
1ef4436
isort
RachelMurray-Watson Sep 12, 2024
306f778
isort
RachelMurray-Watson Sep 12, 2024
b108a10
replaced explicit boolean logic
RachelMurray-Watson Sep 12, 2024
0b40a06
Removed reference to dataframe
RachelMurray-Watson Sep 12, 2024
453ae74
isort
RachelMurray-Watson Sep 12, 2024
f558eef
fix errors
RachelMurray-Watson Sep 12, 2024
2953043
Edited so that the DiseaseThatCausesA/B etc modules from the test_hea…
RachelMurray-Watson Sep 12, 2024
0901eb3
Removed print statements
RachelMurray-Watson Sep 30, 2024
0023c25
Changed prevalence calculation for RTI to ensure accident happened in…
RachelMurray-Watson Oct 1, 2024
9aa4520
Changed prevalence calculation for RTI to ensure accident happened in…
RachelMurray-Watson Oct 1, 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
43 changes: 43 additions & 0 deletions src/scripts/longterm_projections/longterm_projections_draws.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"scenario_script_path": "/Users/rem76/PycharmProjects/TLOmodel/src/scripts/longterm_projections/longterm_projections.py",
"scenario_seed": 0,
"arguments": [],
"runs_per_draw": 1,
"draws": [
{
"draw_number": 0,
"parameters": {
"SymptomManager": {
"spurious_symptoms": true
},
"HealthSystem": {
"Service_Availability": [
"*"
],
"use_funded_or_actual_staffing": "funded_plus",
"mode_appt_constraints": 1,
"cons_availability": "default",
"beds_availability": "all",
"equip_availability": "default",
"cons_availability_postSwitch": "all",
"year_cons_availability_switch": 2020,
"equip_availability_postSwitch": "all",
"year_equip_availability_switch": 2020
},
"ImprovedHealthSystemAndCareSeekingScenarioSwitcher": {
"max_healthsystem_function": [
false,
true
],
"max_healthcare_seeking": [
false,
true
],
"year_of_switch": 2020
}
}
}
],
"commit": "7ea3f5ae200444bf4a4688dbc2e40961fef84fd8",
"github": "https://github.com/UCL/TLOmodel/tree/7ea3f5ae200444bf4a4688dbc2e40961fef84fd8"
}
32 changes: 22 additions & 10 deletions src/tlo/methods/alri.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
to_odds = lambda pr: pr / (1.0 - pr) # noqa: E731
to_prob = lambda odds: odds / (1.0 + odds) # noqa: E731


# ---------------------------------------------------------------------------------------------------------
# MODULE DEFINITION
# ---------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -995,6 +996,15 @@ def report_daly_values(self):
daly_values_by_pathogen = daly_values_by_pathogen.add_prefix('ALRI_')
return daly_values_by_pathogen

def report_prevalence(self):
# This returns dataframe that reports on the prevalence of ALRI for all individuals
df = self.sim.population.props
total_prev = len(
df[(df['is_alive']) & (df['ri_current_infection_status'])]
) / len(df[df['is_alive']])

return {'ALRI': total_prev}

def over_ride_availability_of_certain_consumables(self):
"""Over-ride the availability of certain consumables, according the parameter values provided."""
p = self.parameters
Expand Down Expand Up @@ -1121,7 +1131,6 @@ def look_up_consumables(self):
get_item_code(item='Salbutamol sulphate 1mg/ml, 5ml_each_CMST'): 2
}


def end_episode(self, person_id):
"""End the episode infection for a person (i.e. reset all properties to show no current infection or
complications).
Expand Down Expand Up @@ -1336,7 +1345,7 @@ def _ultimate_treatment_indicated_for_patient(classification_for_treatment_decis
elif classification_for_treatment_decision == 'chest_indrawing_pneumonia':
return {
'antibiotic_indicated': (
'Amoxicillin_tablet_or_suspension_5days', # <-- # <-- First choice antibiotic
'Amoxicillin_tablet_or_suspension_5days', # <-- # <-- First choice antibiotic
),
'oxygen_indicated': False
}
Expand Down Expand Up @@ -1441,11 +1450,11 @@ def make_linear_model(age_effects=None):
'age_years',
conditions_are_mutually_exclusive=True,
conditions_are_exhaustive=True).when(0, age_effects[0])
.when(1, age_effects[1])
.when(2, age_effects[2])
.when(3, age_effects[3])
.when(4, age_effects[4])
.when('>= 5', 0.0),
.when(1, age_effects[1])
.when(2, age_effects[2])
.when(3, age_effects[3])
.when(4, age_effects[4])
.when('>= 5', 0.0),
Predictor('li_wood_burn_stove').when(False, p['rr_ALRI_indoor_air_pollution']),
Predictor().when('(va_measles_all_doses == False) & (age_years >= 1)',
p['rr_ALRI_incomplete_measles_immunisation']),
Expand Down Expand Up @@ -1675,13 +1684,14 @@ def prob_die_of_alri(self,

def get_odds_of_death(age_in_whole_months):
"""Returns odds of death given age in whole months."""

def get_odds_of_death_for_under_two_month_old(age_in_whole_months):
return p[f'base_odds_death_ALRI_{_age_}'] * \
(p[f'or_death_ALRI_{_age_}_by_month_increase_in_age'] ** age_in_whole_months)
(p[f'or_death_ALRI_{_age_}_by_month_increase_in_age'] ** age_in_whole_months)

def get_odds_of_death_for_over_two_month_old(age_in_whole_months):
return p[f'base_odds_death_ALRI_{_age_}'] * \
(p[f'or_death_ALRI_{_age_}_by_month_increase_in_age'] ** (age_in_whole_months - 2))
(p[f'or_death_ALRI_{_age_}_by_month_increase_in_age'] ** (age_in_whole_months - 2))

return get_odds_of_death_for_under_two_month_old(age_in_whole_months=age_in_whole_months) \
if age_in_whole_months < 2 \
Expand Down Expand Up @@ -1887,6 +1897,7 @@ def _prob_treatment_fails_when_cough_or_cold():
else:
raise ValueError('Unrecognised imci_symptom_based_classification.')


# ---------------------------------------------------------------------------------------------------------
# DISEASE MODULE EVENTS
# ---------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -3040,7 +3051,8 @@ def apply(self, person_id):

assert 'fast_breathing_pneumonia' == \
self.module.get_imci_classification_based_on_symptoms(
child_is_younger_than_2_months=False, symptoms=self.sim.modules['SymptomManager'].has_what(person_id=person_id)
child_is_younger_than_2_months=False,
symptoms=self.sim.modules['SymptomManager'].has_what(person_id=person_id)
)


Expand Down
9 changes: 9 additions & 0 deletions src/tlo/methods/bladder_cancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,15 @@ def report_daly_values(self):

return disability_series_for_alive_persons

def report_prevalence(self):
# This reports on the prevalence of bladder cancer for all individuals

df = self.sim.population.props
total_prev = len(
df[(df.bc_status != 'none') & (df.is_alive)]
) / len(df[df.is_alive])
return {'Bladder Cancer': total_prev}

def do_at_generic_first_appt(
self,
person_id: int,
Expand Down
8 changes: 8 additions & 0 deletions src/tlo/methods/breast_cancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,14 @@ def report_daly_values(self):

return disability_series_for_alive_persons

def report_prevalence(self):
# This returns dataframe that reports on the prevalence of breast cancer for all individuals
df = self.sim.population.props
total_prev = len(
df[(df['is_alive']) & (df['brc_status'] != 'none')]
) / len(df[df['is_alive']])

return {'Breast Cancer': total_prev}
def do_at_generic_first_appt(
self,
person_id: int,
Expand Down
12 changes: 12 additions & 0 deletions src/tlo/methods/cardio_metabolic_disorders.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,18 @@ def left_censor(obs, window_open):

return dw

def report_prevalence(self):
"""Report prevalence of disease to the HealthBurden module"""
df = self.sim.population.props
prevalence_dict = {}

for condition in self.conditions:
prevalence = df[f'nc_{condition}'].sum() / len(df)
prevalence_dict[condition] = prevalence

# Create a DataFrame from the prevalence dictionary
return prevalence_dict

def on_hsi_alert(self, person_id, treatment_id):
"""
This is called whenever there is an HSI event commissioned by one of the other disease modules.
Expand Down
2 changes: 2 additions & 0 deletions src/tlo/methods/chronicsyndrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ def report_daly_values(self):

return health_values

def report_prevalence(self):
return {'ChronicSyndrome':None}
def do_at_generic_first_appt_emergency(
self,
person_id: int,
Expand Down
9 changes: 9 additions & 0 deletions src/tlo/methods/copd.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,15 @@ def report_daly_values(self):
df = self.sim.population.props
return df.loc[df.is_alive, 'ch_lungfunction'].map(self.models.disability_weight_given_lungfunction)

def report_prevalence(self):
# This returns dataframe that reports on the prevalence of COPD for all individuals
df = self.sim.population.props
total_prev = len(
df[(df['is_alive']) & (df['ch_lungfunction'] > 3)] # 3 is mild COPD
) / len(df[df['is_alive']])

return {'COPD': total_prev}

def define_symptoms(self):
"""Define and register Symptoms"""
self.sim.modules['SymptomManager'].register_symptom(
Expand Down
50 changes: 49 additions & 1 deletion src/tlo/methods/demography.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def __init__(self, name=None, resourcefilepath=None, equal_allocation_by_distric
),

'district_num_of_residence': Property(
Types.CATEGORICAL,
Types.CATEGORICAL,
'The district number in which the person is resident',
categories=['SET_AT_RUNTIME']
),
Expand Down Expand Up @@ -383,6 +383,54 @@ def on_birth(self, mother_id, child_id):
'mother_age_at_pregnancy': _mother_age_at_pregnancy}
)

def report_prevalence(self):
"""
This function reports the prevalence of maternal death and neonatal deaths for this module generated in the previous month.
Returns a dataframe with these values.
"""
if 'SimplifiedBirths' in self.sim.modules:
neonatal_mortality_rate = None
maternal_mortality_rate = None
live_births = None
else:
df = self.sim.population.props
if len(df[(df['age_days'] < 29)]) == 0:
neonatal_mortality_rate = 0
maternal_mortality_rate = 0
live_births = 0
else:
neonatal_deaths = len(df[(df['age_days'] < 29) & (df['age_years'] == 0) & ~(df['is_alive']) & (
df['date_of_death'] >= (self.sim.date - DateOffset(months=1)))])
live_births = len(df[(df['age_days'] < 29)])
neonatal_mortality_rate = neonatal_deaths/live_births * 1000
maternal_direct_deaths = len(df.loc[
(df['cause_of_death'] == 'Maternal Disorders') &
(df['date_of_death'] >= (self.sim.date - DateOffset(months=1)))
])
indirect_deaths_non_hiv = len(df.loc[
(df['is_pregnant'] | df['la_is_postpartum']) &
(df['cause_of_death'].str.contains(
'Malaria|Suicide|ever_stroke|diabetes|chronic_ischemic_hd|ever_heart_attack|chronic_kidney_disease') |
(df['cause_of_death'] == 'TB')) &
(df['date_of_death'] >= (self.sim.date - DateOffset(months=1)))
])
indirect_deaths_hiv = len(df.loc[
(df['is_pregnant'] | df['la_is_postpartum']) &
df['cause_of_death'].str.contains('AIDS_non_TB|AIDS_TB') &
(df['date_of_death'] >= (self.sim.date - DateOffset(months=1)))
])
indirect_deaths_hiv = indirect_deaths_hiv * 0.3 # https://www.who.int/publications/i/item/9789240068759
maternal_deaths = maternal_direct_deaths + indirect_deaths_non_hiv + indirect_deaths_hiv
maternal_mortality_rate = maternal_deaths/live_births * 1000
print(live_births)

metrics_dict = {
'NMR': neonatal_mortality_rate,
'MMR': maternal_mortality_rate,
'live_births': live_births
}
return metrics_dict

def _edit_init_pop_to_prevent_persons_greater_than_max_age(self, df, max_age: int):
"""Return an edited version of the `pd.DataFrame` describing the probability of persons in the population being
created with certain characteristics to reflect the constraint the persons aged greater than `max_age_initial`
Expand Down
14 changes: 14 additions & 0 deletions src/tlo/methods/depression.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,20 @@ def right_censor(obs, window_close):

return av_daly_wt_last_month

def report_prevalence(self):
# This reports on the prevalence of depression for all individuals

df = self.sim.population.props
any_depr_in_the_last_month = df[((df['is_alive']) & (
~pd.isnull(df['de_date_init_most_rec_depr']) & (df['de_date_init_most_rec_depr'] <= self.sim.date)
) & (
pd.isnull(df['de_date_depr_resolved']) |
(df['de_date_depr_resolved'] >= (self.sim.date - DateOffset(months=1)))
))]
total_prev = len(
any_depr_in_the_last_month
) / len(df[df.is_alive])
return {'Depression': total_prev}
def _check_for_suspected_depression(
self, symptoms: List[str], treatment_id: str, has_even_been_diagnosed: bool
):
Expand Down
7 changes: 7 additions & 0 deletions src/tlo/methods/diarrhoea.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,13 @@ def report_daly_values(self):
average_daly_weight_in_last_month = pd.Series(values, idx) / days_last_month
return average_daly_weight_in_last_month.reindex(index=df.loc[df.is_alive].index, fill_value=0.0)

def report_prevalence(self):
df = self.sim.population.props
total_prev = len(
df[df.gi_has_diarrhoea & df.is_alive]
) / len(df[df.is_alive])
return {'Diarrhoea': total_prev}

def look_up_consumables(self):
"""Look up and store the consumables item codes used in each of the HSI."""
ic = self.sim.modules['HealthSystem'].get_item_code_from_item_name
Expand Down
10 changes: 10 additions & 0 deletions src/tlo/methods/epilepsy.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,16 @@ def report_daly_values(self):
df = self.sim.population.props # shortcut to population properties dataframe
return df.loc[df.is_alive, 'ep_disability']

def report_prevalence(self):
# This returns dataframe that reports on the prevalence of epilepsy for all individuals
df = self.sim.population.props
total_prev = len(
df[(df['is_alive']) & (df['ep_seiz_stat'] != '0')]
) / len(df[df['is_alive']])

return {'Epilepsy': total_prev}


def transition_seizure_stat(self):
"""
This function handles all transitions in epilepsy seizure status, for those on and off anti epileptics. The
Expand Down
Loading