Skip to content

Commit

Permalink
overlooked baseline post-withdrawn possibility with new timeline resu…
Browse files Browse the repository at this point in the history
…lts.
  • Loading branch information
pbugni committed Feb 22, 2024
1 parent 1dc4b2f commit 1a74538
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
4 changes: 4 additions & 0 deletions portal/models/adherence_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,12 @@ def sort_by_visit_key(d):
def sort_key(key):
if key == 'Baseline':
return 0, 0
elif key == f"Baseline{withdrawn}":
return 0, 1
elif key == 'Indefinite':
return 2, 0
elif key == f'Indefinite{withdrawn}':
return 2, 1
else:
match = pattern.match(key)
if not match.groups():
Expand Down
27 changes: 23 additions & 4 deletions tests/test_reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,26 @@ def test_adherence_sort(self):
"Month 12": {
"qb": "CRV Baseline v2",
"site": "CRV",
"visit": "Month 12",
"status": "Withdrawn",
"completion_date ": "22 - Jun - 2023 00:00:00 ",
"consent": "20 - May - 2023 07: 42:46 ",
"country ": None,
"user_id ": 3,
"study_id": "study user 3",
"site_code": ""},
"Baseline post-withdrawn": {
"qb": "CRV Baseline v2",
"site": "CRV",
"visit": "Baseline",
"status": "Completed",
"completion_date ": "22 - Jun - 2023 00:00:00 ",
"consent": "19 - Jun - 2023 07: 42:46",
"country ": None,
"user_id ": 2,
"study_id": "study user 2",
"site_code": ""
},
"Baseline": {
"qb": "CRV Baseline v2",
"site": "CRV",
Expand All @@ -185,11 +198,17 @@ def test_adherence_sort(self):
},
}
results = sort_by_visit_key(sort_me)
assert len(results) == 4
assert len(results) == 5
assert results[0]["visit"] == "Baseline"
assert results[1]["visit"] == "Month 3"
assert results[2]["status"] == "Withdrawn"
assert results[3]["status"] == "Completed"
assert results[0]["status"] == "Due"
assert results[1]["visit"] == "Baseline"
assert results[1]["status"] == "Completed"
assert results[2]["visit"] == "Month 3"
assert results[2]["status"] == "Completed"
assert results[3]["visit"] == "Month 12"
assert results[3]["status"] == "Withdrawn"
assert results[4]["visit"] == "Month 12"
assert results[4]["status"] == "Completed"

def populate_adherence_cache(self, test_users):
"""helper method to bring current test user state into adherence cache"""
Expand Down

0 comments on commit 1a74538

Please sign in to comment.