You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All of the tests first start with setting eligibility criteria which are then passed into PatientFactory to create eligible patients.
E.g. in test_kpis_33_40.py:
@pytest.mark.django_db
def test_kpi_calculation_33(AUDIT_START_DATE):
...
# Create Patients and Visits that should be eligible (KPI5)
eligible_criteria = {
# KPI5 base criteria
"visit__visit_date": AUDIT_START_DATE + relativedelta(days=2),
"date_of_birth": AUDIT_START_DATE - relativedelta(days=365 * 10),
# KPI 5 specific eligibility are any of the following:
# Date of diagnosis NOT within the audit period
"diagnosis_date": AUDIT_START_DATE - relativedelta(days=2),
# Date of leaving service NOT within the audit period
# transfer date only not None if they have left
"transfer__date_leaving_service": None,
# Date of death NOT within the audit period"
"death_date": None,
}
Often, these eligibility criteria are based on the same measures, usually KPI 1, 5, 6 so far. I think the eligibility criteria may require tweaking so rather than defining them individually in each test as this will be a nightmare to tweak, refactor all universal ones into conftest.py (so all tests can globally access them) as fixtures. An example already exists in conftest.py with AUDIT_START_DATE:
@pytest.fixture
def AUDIT_START_DATE():
"""AUDIT_START_DATE is Day 2 of the first audit period"""
return date(year=2024, month=4, day=1)
Which can then be used in any test (passing into the test function as an argument) without import e.g in test_kpis_33_40.py:
@pytest.mark.django_db
def test_kpi_calculation_33(AUDIT_START_DATE):
"""Tests that KPI33 is calculated correctly.
Calculates KPI 32: HbA1c 4+ (%)
Numerator: Number of eligible patients with at least four entries for HbA1c value (item 17) with an observation date (item 19) within the audit period
Denominator: Number of patients with Type 1 diabetes with a complete year of care in the audit period (measure 5)
"""
# Ensure starting with clean pts in test db
Patient.objects.all().delete()
# Create Patients and Visits that should be eligible (KPI5)
eligible_criteria = {
# KPI5 base criteria
"visit__visit_date": AUDIT_START_DATE + relativedelta(days=2),
The text was updated successfully, but these errors were encountered:
All of the tests first start with setting eligibility criteria which are then passed into
PatientFactory
to create eligible patients.E.g. in
test_kpis_33_40.py
:Often, these eligibility criteria are based on the same measures, usually KPI 1, 5, 6 so far. I think the eligibility criteria may require tweaking so rather than defining them individually in each test as this will be a nightmare to tweak, refactor all universal ones into
conftest.py
(so all tests can globally access them) as fixtures. An example already exists inconftest.py
withAUDIT_START_DATE
:Which can then be used in any test (passing into the test function as an argument) without import e.g in
test_kpis_33_40.py
:The text was updated successfully, but these errors were encountered: