From 1a7453843942d578c2e2673f992eb085bafa9c29 Mon Sep 17 00:00:00 2001 From: Paul Bugni Date: Thu, 22 Feb 2024 11:57:34 -0800 Subject: [PATCH] overlooked baseline post-withdrawn possibility with new timeline results. --- portal/models/adherence_data.py | 4 ++++ tests/test_reporting.py | 27 +++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/portal/models/adherence_data.py b/portal/models/adherence_data.py index 5c99081a8..f70473656 100644 --- a/portal/models/adherence_data.py +++ b/portal/models/adherence_data.py @@ -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(): diff --git a/tests/test_reporting.py b/tests/test_reporting.py index fa5d3ff7d..0d1675272 100644 --- a/tests/test_reporting.py +++ b/tests/test_reporting.py @@ -165,6 +165,7 @@ 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 ", @@ -172,6 +173,18 @@ def test_adherence_sort(self): "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", @@ -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"""