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

HIV testing for the symptomatic #182

Merged
merged 55 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
ceb4d8f
Added symptomatic test probabilities.
pineapple-cat Apr 15, 2024
9c5134f
Updated relevant symptomatic testing columns.
pineapple-cat Apr 15, 2024
05492ef
Added calculations for symptomatic test probabilities and outcomes.
pineapple-cat Apr 15, 2024
c290e21
Fixed typo.
pineapple-cat Apr 15, 2024
08031e5
Added function to mark symptomatic people for testing.
pineapple-cat Apr 15, 2024
bdb02ff
Added function to mark non-HIV symptomatic people for testing.
pineapple-cat May 7, 2024
8188652
Extracted general population test marking into its own function.
pineapple-cat May 7, 2024
4a845c8
Updated main HIV testing function to make use of test marks.
pineapple-cat May 8, 2024
9c59325
Added probability of testing with non-HIV symptoms.
pineapple-cat May 8, 2024
b4a639f
Bugfixes for unit tests (transform_group issue left unsolved; awaitin…
pineapple-cat May 8, 2024
0e33c59
Fixed transform_group column name issues for past time steps.
pineapple-cat May 9, 2024
e6b23ab
Function reordering for better clarity.
pineapple-cat May 9, 2024
6de1d5d
Added unit test for HIV symptomatic testing.
pineapple-cat May 16, 2024
10e098b
Added unit test for non-HIV symptomatic testing.
pineapple-cat May 16, 2024
5666ccb
Updated general HIV testing unit test.
pineapple-cat May 16, 2024
207550e
Fixed ADC risk unit test.
pineapple-cat May 17, 2024
6b579c4
Moved post-test VMMC update function to circumcision module.
pineapple-cat May 17, 2024
7a089dc
Updated post-VMMC HIV test marks.
pineapple-cat May 17, 2024
71208f9
Updated unit tests to account for post-VMMC testing.
pineapple-cat May 17, 2024
d124395
Updated call ordering of ANC HIV test marks.
pineapple-cat May 20, 2024
48a1c22
Updated unit tests to account for new ANC testing.
pineapple-cat May 20, 2024
7109ddf
Moved timing of ANC removal from people giving birth this time step.
pineapple-cat May 20, 2024
a401850
Updated ANC test mark code for brevity.
pineapple-cat May 20, 2024
fb807d9
Updated VMMC test marking to work with time step.
pineapple-cat May 22, 2024
3b1df5c
Added HIV testing tutorial.
pineapple-cat May 30, 2024
5d55145
Added new tutorial to general and updated other tutorials for better …
pineapple-cat May 30, 2024
ec54452
Added some notes and documented a warning about testing HIV symptomat…
pineapple-cat May 30, 2024
180e907
Comment style fix.
pineapple-cat May 30, 2024
be5ed07
Fixed testing population selection criteria + updated unit tests.
pineapple-cat May 30, 2024
a95d5ac
Added regular sex worker testing to general population testing.
pineapple-cat May 31, 2024
0d2c7ae
Added regular sex worker testing unit test + minor adjustments to oth…
pineapple-cat May 31, 2024
964f2b4
Adding suggested ANC-related changes.
pineapple-cat Jun 10, 2024
4d310ce
Updated testing date variables for better clarity.
pineapple-cat Jun 10, 2024
be212d8
Use "targeted" instead of "specific"
mmcleod89 Jun 13, 2024
11e8e76
Fix pregnancy test for want no children
mmcleod89 Jun 13, 2024
76496a0
Merge branch 'development' into symptomatic-testing
pineapple-cat Jun 19, 2024
4df6658
Updated symptomatic testing outcomes to use TB infection date.
pineapple-cat Jun 19, 2024
f6a06d8
Updated HIV testing unit tests to account for use of TB infection date.
pineapple-cat Jun 19, 2024
5e8bc51
Fixed HIV symptomatic test marking with new TB primary infection column.
pineapple-cat Jun 20, 2024
a45a8b2
Update disease status before testing
mmcleod89 Jun 24, 2024
21c9bd1
Change name to TB_INITIAL_INFECTION
mmcleod89 Jun 24, 2024
7d6ad09
Update src/hivpy/hiv_testing.py
mmcleod89 Jun 25, 2024
c9493e1
Update src/tests/test_sexual_behaviour.py
mmcleod89 Jun 25, 2024
3eb1d78
Update src/tests/test_sexual_behaviour.py
mmcleod89 Jun 25, 2024
9b32d42
Added negative unit test to ensure nobody was being tested before the…
pineapple-cat Jun 25, 2024
cd90a9b
Added more date-related checks to unit tests.
pineapple-cat Jul 1, 2024
895aa54
Remove floating point dates
mmcleod89 Jul 8, 2024
305b1ba
Merge branch 'symptomatic-testing' of github.com:UCL/hivpy into sympt…
mmcleod89 Jul 8, 2024
d45b894
Fix newer tests; use months for testing periods
mmcleod89 Jul 8, 2024
1aa5357
style fixes
mmcleod89 Jul 8, 2024
ac3bd53
Don't have last date date > current date
mmcleod89 Jul 8, 2024
99516ed
Evertested should be false if date test is none
mmcleod89 Jul 8, 2024
7c53bd3
Oops camelCase
mmcleod89 Jul 8, 2024
c17035b
Comment made redundant
mmcleod89 Jul 8, 2024
fc445b5
Fix import
mmcleod89 Jul 8, 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
42 changes: 30 additions & 12 deletions src/hivpy/circumcision.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,24 @@ def update_vmmc(self, pop, time_step):
pop.data.loc[uncirc_male_population, col.VMMC] = circumcision

# chance to get vmmc after a negative HIV test
pop.hiv_testing.update_vmmc_after_test(pop, time_step)
self.update_vmmc_after_test(pop, time_step)

# newly circumcised males get the current date set as their circumcision date
new_circ_males = pop.get_sub_pop([(col.CIRCUMCISED, op.eq, True),
(col.CIRCUMCISION_DATE, op.eq, None)])
pop.data.loc[new_circ_males, col.CIRCUMCISION_DATE] = self.date

# standard HIV testing after circumcision
pop.hiv_testing.update_post_vmmc_testing(pop)
def calc_circ_outcomes(self, age_group, size):
"""
Uses the circumcision probability for a given
age group to return VMMC outcomes.
"""
prob_circ = self.calc_prob_circ(age_group)
# outcomes
r = rng.uniform(size=size)
circumcision = r < prob_circ

return circumcision

def calc_prob_circ(self, age_group):
"""
Expand Down Expand Up @@ -207,14 +216,23 @@ def calc_prob_circ(self, age_group):

return min(prob_circ, 1)

def calc_circ_outcomes(self, age_group, size):
def update_vmmc_after_test(self, pop, time_step):
"""
Uses the circumcision probability for a given
age group to return VMMC outcomes.
Update VMMC in individuals that tested HIV negative last time step.
"""
prob_circ = self.calc_prob_circ(age_group)
# outcomes
r = rng.uniform(size=size)
circumcision = r < prob_circ

return circumcision
if self.circ_after_test:
# select uncircumcised men tested last timestep
tested_uncirc_male_pop = pop.get_sub_pop([(col.SEX, op.eq, SexType.Male),
(col.CIRCUMCISED, op.eq, False),
(col.HIV_DIAGNOSED, op.eq, False),
(col.LAST_TEST_DATE, op.eq, pop.date - time_step),
(col.HARD_REACH, op.eq, False),
(col.AGE, op.le, self.max_vmmc_age)])
# continue if eligible men are present this timestep
if len(tested_uncirc_male_pop) > 0:
# calculate post-test vmmc outcomes
r = rng.uniform(size=len(tested_uncirc_male_pop))
circumcision = r < self.prob_circ_after_test
# assign outcomes
pop.set_present_variable(col.CIRCUMCISED, circumcision, tested_uncirc_male_pop)
pop.set_present_variable(col.VMMC, circumcision, tested_uncirc_male_pop)
1 change: 1 addition & 0 deletions src/hivpy/column_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
STI = "sti" # bool: True if has sexually transmitted infection (non HIV), false o/w (TODO: DUMMIED)

HARD_REACH = "hard_reach" # bool: True if person is reluctant to test for HIV (also affects PrEP and VMMC), but will still test if symptomatic or in antenatal care
TEST_MARK = "test_mark" # bool: True if a person has been marked for testing this time step
EVER_TESTED = "ever_tested" # bool: True if person has ever been tested for HIV
LAST_TEST_DATE = "last_test_date" # None | datetime.date: date of last HIV test
NSTP_LAST_TEST = "nstp_last_test" # int: number of short term condomless sex partners since last test (DUMMY)
Expand Down
22 changes: 17 additions & 5 deletions src/hivpy/data/hiv_testing.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# years during which HIV testing begins
date_start_anc_testing: 2003.5
date_start_testing: 2009
# year during which HIV testing begins
date_start_testing: 2003.5
# year after which rate of testing starts increasing
date_rate_testing_incr: 2009

# starting probability for first tests
init_rate_first_test: 0
Expand All @@ -24,17 +25,28 @@ prob_anc_test_trim3: 0.1
# probability of being tested after delivery
prob_test_postdel: 0.95

# probability of being tested based on symptoms
prob_test_non_hiv_symptoms: 0.01
prob_test_who4: 0.1
prob_test_tb: 0.1
prob_test_non_tb_who3: 0.05

# affects testing probability based on number of partners
test_targeting:
Value: [1, 1.25, 1.5]
Probability: [0.2, 0.6, 0.2]

# year during which testing probability plateaus
date_test_rate_plateau:
# years during which testing probability plateaus
date_general_testing_plateau:
Value: [2011.5, 2013.5, 2015.5, 2017.5, 2019.5]
Probability: [0.1, 0.1, 0.2, 0.3, 0.3]
date_targeted_testing_plateau: 2015

# multiplier for testing probability
an_lin_incr_test:
Value: [0.0001, 0.0005, 0.003, 0.01, 0.02, 0.03]
Probability: [0.2, 0.25, 0.35, 0.1, 0.05, 0.05]

# multiplier for symptomatic testing probability
incr_test_rate_sympt:
Value: [1.05, 1.10, 1.15, 1.20, 1.25]
Loading