Skip to content

Commit

Permalink
Updated eligibility criteria correctness for starting and restarting …
Browse files Browse the repository at this point in the history
…PrEP.
  • Loading branch information
pineapple-cat committed Nov 11, 2024
1 parent 09f8538 commit f461a44
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/hivpy/prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,8 @@ def continue_prep(self, pop: Population, time_step):
Update PrEP usage for people continuing PrEP.
"""
# people who have used prep before but not yet started this time step
eligible = pop.get_sub_pop(AND(COND(col.EVER_PREP, op.eq, True),
eligible = pop.get_sub_pop(AND(COND(col.PREP_ELIGIBLE, op.eq, True),
COND(col.EVER_PREP, op.eq, True),
COND(col.PREP_JUST_STARTED, op.eq, False),
COND(col.LAST_PREP_STOP_DATE, op.eq, None),
OR(COND(col.LAST_TEST_DATE, op.ne, pop.date),
Expand Down Expand Up @@ -724,8 +725,10 @@ def restart_prep(self, pop: Population, time_step):
Update PrEP usage for people restarting PrEP.
"""
# people who have used prep before and previously stopped using it
eligible = pop.get_sub_pop(AND(COND(col.EVER_PREP, op.eq, True),
COND(col.LAST_PREP_STOP_DATE, op.lt, pop.date),
eligible = pop.get_sub_pop(AND(COND(col.HIV_DIAGNOSED, op.eq, False),
COND(col.PREP_ELIGIBLE, op.eq, True),
COND(col.EVER_PREP, op.eq, True),
COND(col.LAST_PREP_STOP_DATE, op.lt, pop.date), # FIXME: is this right?
COND(col.LAST_TEST_DATE, op.eq, pop.date)))

if len(eligible) > 0:
Expand Down
4 changes: 4 additions & 0 deletions src/tests/test_prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,8 @@ def test_continuing_prep():
time_step = timedelta(months=1)
pop = Population(size=N, start_date=date(5000, 1, 1))
pop.prep.date_prep_intro = [date(2000), date(3000), date(4000), date(5000)]
pop.data[col.HIV_DIAGNOSED] = False
pop.data[col.PREP_ELIGIBLE] = True
pop.data[col.EVER_PREP] = True
pop.data[col.LAST_PREP_STOP_DATE] = None
pop.data[col.PREP_JUST_STARTED] = False
Expand Down Expand Up @@ -840,6 +842,8 @@ def test_restarting_prep():
time_step = timedelta(months=1)
pop = Population(size=N, start_date=date(5000, 1, 1))
pop.prep.date_prep_intro = [date(2000), date(3000), date(4000), date(5000)]
pop.data[col.HIV_DIAGNOSED] = False
pop.data[col.PREP_ELIGIBLE] = True
pop.data[col.EVER_PREP] = True
pop.data[col.LAST_PREP_STOP_DATE] = pop.date - time_step
pop.data[col.PREP_JUST_STARTED] = False
Expand Down

0 comments on commit f461a44

Please sign in to comment.