From 9d898879b7c5c1f8078ecdf7b5c3e9773bb06e26 Mon Sep 17 00:00:00 2001 From: fbraza Date: Sat, 19 Jul 2025 16:20:33 +0200 Subject: [PATCH 1/2] feat: implement SCORE2-Diabetes cardiovascular risk algorithm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add new score2_diabetes module following existing patterns - Create Score2DiabetesUnits and Score2DiabetesMarkers schemas - Implement full algorithm with Belgium (Low Risk) calibration - Add test structure with placeholder values for MDCalc validation - Update helpers to support new unit types The implementation includes all coefficients, transformations, and interaction terms from the SCORE2-Diabetes specification. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../test__input__patient_01.json | 51 ++++ .../test__input__patient_02.json | 51 ++++ .../test__input__patient_03.json | 51 ++++ .../test__input__patient_04.json | 51 ++++ .../test__input__patient_05.json | 51 ++++ .../test__input__patient_06.json | 51 ++++ tests/test_score2_diabetes.py | 41 +++ vitals/biomarkers/helpers.py | 2 +- vitals/biomarkers/schemas.py | 33 +++ vitals/score2_diabetes/__init__.py | 5 + vitals/score2_diabetes/compute.py | 239 ++++++++++++++++++ 11 files changed, 625 insertions(+), 1 deletion(-) create mode 100644 tests/inputs/score2_diabetes/test__input__patient_01.json create mode 100644 tests/inputs/score2_diabetes/test__input__patient_02.json create mode 100644 tests/inputs/score2_diabetes/test__input__patient_03.json create mode 100644 tests/inputs/score2_diabetes/test__input__patient_04.json create mode 100644 tests/inputs/score2_diabetes/test__input__patient_05.json create mode 100644 tests/inputs/score2_diabetes/test__input__patient_06.json create mode 100644 tests/test_score2_diabetes.py create mode 100644 vitals/score2_diabetes/__init__.py create mode 100644 vitals/score2_diabetes/compute.py diff --git a/tests/inputs/score2_diabetes/test__input__patient_01.json b/tests/inputs/score2_diabetes/test__input__patient_01.json new file mode 100644 index 0000000..c5b14b6 --- /dev/null +++ b/tests/inputs/score2_diabetes/test__input__patient_01.json @@ -0,0 +1,51 @@ +{ + "metadata": { + "patient_id": "P001-2024-001", + "sex": "male", + "timestamp": "2024-11-04T10:00:00Z", + "test_date": "2024-11-04", + "laboratory": "SCORE2-Diabetes Labs" + }, + "raw_biomarkers": { + "age_years": { + "value": 45, + "unit": "years" + }, + "smoking_yes_no": { + "value": false, + "unit": "yes/no" + }, + "systolic_blood_pressure_mmhg": { + "value": 130, + "unit": "mmHg" + }, + "total_cholesterol_mmol_l": { + "value": 5.5, + "unit": "mmol/L" + }, + "hdl_cholesterol_mmol_l": { + "value": 1.2, + "unit": "mmol/L" + }, + "is_male_yes_no": { + "value": true, + "unit": "yes/no" + }, + "diabetes_yes_no": { + "value": true, + "unit": "yes/no" + }, + "age_at_diabetes_diagnosis_years": { + "value": 40, + "unit": "years" + }, + "hba1c_mmol_mol": { + "value": 48, + "unit": "mmol/mol" + }, + "egfr_ml_min_1_73m2": { + "value": 90, + "unit": "mL/min/1.73m\u00b2" + } + } +} diff --git a/tests/inputs/score2_diabetes/test__input__patient_02.json b/tests/inputs/score2_diabetes/test__input__patient_02.json new file mode 100644 index 0000000..73b780d --- /dev/null +++ b/tests/inputs/score2_diabetes/test__input__patient_02.json @@ -0,0 +1,51 @@ +{ + "metadata": { + "patient_id": "P002-2024-002", + "sex": "female", + "timestamp": "2024-11-04T10:30:00Z", + "test_date": "2024-11-04", + "laboratory": "SCORE2-Diabetes Labs" + }, + "raw_biomarkers": { + "age_years": { + "value": 55, + "unit": "years" + }, + "smoking_yes_no": { + "value": true, + "unit": "yes/no" + }, + "systolic_blood_pressure_mmhg": { + "value": 145, + "unit": "mmHg" + }, + "total_cholesterol_mmol_l": { + "value": 6.8, + "unit": "mmol/L" + }, + "hdl_cholesterol_mmol_l": { + "value": 1.1, + "unit": "mmol/L" + }, + "is_male_yes_no": { + "value": false, + "unit": "yes/no" + }, + "diabetes_yes_no": { + "value": true, + "unit": "yes/no" + }, + "age_at_diabetes_diagnosis_years": { + "value": 50, + "unit": "years" + }, + "hba1c_mmol_mol": { + "value": 58, + "unit": "mmol/mol" + }, + "egfr_ml_min_1_73m2": { + "value": 75, + "unit": "mL/min/1.73m\u00b2" + } + } +} diff --git a/tests/inputs/score2_diabetes/test__input__patient_03.json b/tests/inputs/score2_diabetes/test__input__patient_03.json new file mode 100644 index 0000000..44d6161 --- /dev/null +++ b/tests/inputs/score2_diabetes/test__input__patient_03.json @@ -0,0 +1,51 @@ +{ + "metadata": { + "patient_id": "P003-2024-003", + "sex": "male", + "timestamp": "2024-11-04T11:00:00Z", + "test_date": "2024-11-04", + "laboratory": "SCORE2-Diabetes Labs" + }, + "raw_biomarkers": { + "age_years": { + "value": 65, + "unit": "years" + }, + "smoking_yes_no": { + "value": false, + "unit": "yes/no" + }, + "systolic_blood_pressure_mmhg": { + "value": 155, + "unit": "mmHg" + }, + "total_cholesterol_mmol_l": { + "value": 7.2, + "unit": "mmol/L" + }, + "hdl_cholesterol_mmol_l": { + "value": 0.9, + "unit": "mmol/L" + }, + "is_male_yes_no": { + "value": true, + "unit": "yes/no" + }, + "diabetes_yes_no": { + "value": true, + "unit": "yes/no" + }, + "age_at_diabetes_diagnosis_years": { + "value": 55, + "unit": "years" + }, + "hba1c_mmol_mol": { + "value": 68, + "unit": "mmol/mol" + }, + "egfr_ml_min_1_73m2": { + "value": 60, + "unit": "mL/min/1.73m\u00b2" + } + } +} diff --git a/tests/inputs/score2_diabetes/test__input__patient_04.json b/tests/inputs/score2_diabetes/test__input__patient_04.json new file mode 100644 index 0000000..a7d5e88 --- /dev/null +++ b/tests/inputs/score2_diabetes/test__input__patient_04.json @@ -0,0 +1,51 @@ +{ + "metadata": { + "patient_id": "P004-2024-004", + "sex": "female", + "timestamp": "2024-11-04T11:30:00Z", + "test_date": "2024-11-04", + "laboratory": "SCORE2-Diabetes Labs" + }, + "raw_biomarkers": { + "age_years": { + "value": 48, + "unit": "years" + }, + "smoking_yes_no": { + "value": false, + "unit": "yes/no" + }, + "systolic_blood_pressure_mmhg": { + "value": 120, + "unit": "mmHg" + }, + "total_cholesterol_mmol_l": { + "value": 4.8, + "unit": "mmol/L" + }, + "hdl_cholesterol_mmol_l": { + "value": 1.5, + "unit": "mmol/L" + }, + "is_male_yes_no": { + "value": false, + "unit": "yes/no" + }, + "diabetes_yes_no": { + "value": true, + "unit": "yes/no" + }, + "age_at_diabetes_diagnosis_years": { + "value": 45, + "unit": "years" + }, + "hba1c_mmol_mol": { + "value": 42, + "unit": "mmol/mol" + }, + "egfr_ml_min_1_73m2": { + "value": 100, + "unit": "mL/min/1.73m\u00b2" + } + } +} diff --git a/tests/inputs/score2_diabetes/test__input__patient_05.json b/tests/inputs/score2_diabetes/test__input__patient_05.json new file mode 100644 index 0000000..82614f4 --- /dev/null +++ b/tests/inputs/score2_diabetes/test__input__patient_05.json @@ -0,0 +1,51 @@ +{ + "metadata": { + "patient_id": "P005-2024-005", + "sex": "male", + "timestamp": "2024-11-04T12:00:00Z", + "test_date": "2024-11-04", + "laboratory": "SCORE2-Diabetes Labs" + }, + "raw_biomarkers": { + "age_years": { + "value": 60, + "unit": "years" + }, + "smoking_yes_no": { + "value": true, + "unit": "yes/no" + }, + "systolic_blood_pressure_mmhg": { + "value": 150, + "unit": "mmHg" + }, + "total_cholesterol_mmol_l": { + "value": 6.5, + "unit": "mmol/L" + }, + "hdl_cholesterol_mmol_l": { + "value": 1.0, + "unit": "mmol/L" + }, + "is_male_yes_no": { + "value": true, + "unit": "yes/no" + }, + "diabetes_yes_no": { + "value": true, + "unit": "yes/no" + }, + "age_at_diabetes_diagnosis_years": { + "value": 48, + "unit": "years" + }, + "hba1c_mmol_mol": { + "value": 75, + "unit": "mmol/mol" + }, + "egfr_ml_min_1_73m2": { + "value": 50, + "unit": "mL/min/1.73m\u00b2" + } + } +} diff --git a/tests/inputs/score2_diabetes/test__input__patient_06.json b/tests/inputs/score2_diabetes/test__input__patient_06.json new file mode 100644 index 0000000..07694a3 --- /dev/null +++ b/tests/inputs/score2_diabetes/test__input__patient_06.json @@ -0,0 +1,51 @@ +{ + "metadata": { + "patient_id": "P006-2024-006", + "sex": "female", + "timestamp": "2024-11-04T12:30:00Z", + "test_date": "2024-11-04", + "laboratory": "SCORE2-Diabetes Labs" + }, + "raw_biomarkers": { + "age_years": { + "value": 42, + "unit": "years" + }, + "smoking_yes_no": { + "value": true, + "unit": "yes/no" + }, + "systolic_blood_pressure_mmhg": { + "value": 135, + "unit": "mmHg" + }, + "total_cholesterol_mmol_l": { + "value": 6.0, + "unit": "mmol/L" + }, + "hdl_cholesterol_mmol_l": { + "value": 1.3, + "unit": "mmol/L" + }, + "is_male_yes_no": { + "value": false, + "unit": "yes/no" + }, + "diabetes_yes_no": { + "value": true, + "unit": "yes/no" + }, + "age_at_diabetes_diagnosis_years": { + "value": 38, + "unit": "years" + }, + "hba1c_mmol_mol": { + "value": 53, + "unit": "mmol/mol" + }, + "egfr_ml_min_1_73m2": { + "value": 85, + "unit": "mL/min/1.73m\u00b2" + } + } +} diff --git a/tests/test_score2_diabetes.py b/tests/test_score2_diabetes.py new file mode 100644 index 0000000..5403df3 --- /dev/null +++ b/tests/test_score2_diabetes.py @@ -0,0 +1,41 @@ +from pathlib import Path + +import pytest + +from vitals.score2_diabetes import compute + +OUT_FILEPATH = Path(__file__).parent / "inputs" / "score2_diabetes" + + +@pytest.mark.parametrize( + "filename,expected", + [ + ("test__input__patient_01.json", (45.00, 0.00, "PLACEHOLDER")), + ("test__input__patient_02.json", (55.00, 0.00, "PLACEHOLDER")), + ("test__input__patient_03.json", (65.00, 0.00, "PLACEHOLDER")), + ("test__input__patient_04.json", (48.00, 0.00, "PLACEHOLDER")), + ("test__input__patient_05.json", (60.00, 0.00, "PLACEHOLDER")), + ("test__input__patient_06.json", (42.00, 0.00, "PLACEHOLDER")), + ], +) +def test_score2_diabetes(filename, expected): + """ + Test SCORE2-Diabetes cardiovascular risk calculation. + + NOTE: The expected risk values and categories are placeholders. + They need to be calculated using MDCalc and updated before running tests. + """ + # Get the actual fixture value + age, pred_risk, pred_risk_category = compute.cardiovascular_risk( + OUT_FILEPATH / filename + ) + expected_age, expected_risk, expected_category = expected + + assert age == expected_age + # TODO: Update these assertions once actual values are calculated + # assert pred_risk_category == expected_category + # assert pytest.approx(pred_risk, abs=0.1) == expected_risk + + +if __name__ == "__main__": + pytest.main([__file__]) diff --git a/vitals/biomarkers/helpers.py b/vitals/biomarkers/helpers.py index a112320..ca1d8d7 100755 --- a/vitals/biomarkers/helpers.py +++ b/vitals/biomarkers/helpers.py @@ -7,7 +7,7 @@ from vitals.biomarkers import schemas Biomarkers = TypeVar("Biomarkers", bound=BaseModel) -Units = schemas.PhenoageUnits | schemas.Score2Units +Units = schemas.PhenoageUnits | schemas.Score2Units | schemas.Score2DiabetesUnits class ConversionInfo(TypedDict): diff --git a/vitals/biomarkers/schemas.py b/vitals/biomarkers/schemas.py index 4e49f54..e93e7d4 100755 --- a/vitals/biomarkers/schemas.py +++ b/vitals/biomarkers/schemas.py @@ -57,3 +57,36 @@ class Score2Markers(BaseModel): hdl_cholesterol: float smoking: bool is_male: bool + + +# ------ SCORE2-Diabetes Schemas +class Score2DiabetesUnits(BaseModel): + """ + The expected unit to be used for Score2-Diabetes computation + """ + + age: str = "years" + systolic_blood_pressure: str = "mmHg" + total_cholesterol: str = "mmol/L" + hdl_cholesterol: str = "mmol/L" + smoking: str = "yes/no" + is_male: str = "yes/no" + diabetes: str = "yes/no" + age_at_diabetes_diagnosis: str = "years" + hba1c: str = "mmol/mol" + egfr: str = "mL/min/1.73m²" + + +class Score2DiabetesMarkers(BaseModel): + """Processed Score2-Diabetes biomarkers with standardized units.""" + + age: float + systolic_blood_pressure: float + total_cholesterol: float + hdl_cholesterol: float + smoking: bool + is_male: bool + diabetes: bool + age_at_diabetes_diagnosis: float + hba1c: float + egfr: float diff --git a/vitals/score2_diabetes/__init__.py b/vitals/score2_diabetes/__init__.py new file mode 100644 index 0000000..c1e1944 --- /dev/null +++ b/vitals/score2_diabetes/__init__.py @@ -0,0 +1,5 @@ +"""SCORE2-Diabetes cardiovascular risk assessment algorithm.""" + +from .compute import cardiovascular_risk + +__all__ = ["cardiovascular_risk"] diff --git a/vitals/score2_diabetes/compute.py b/vitals/score2_diabetes/compute.py new file mode 100644 index 0000000..a628f50 --- /dev/null +++ b/vitals/score2_diabetes/compute.py @@ -0,0 +1,239 @@ +""" +Module for computing the SCORE2-Diabetes cardiovascular risk assessment. + +This module implements the SCORE2-Diabetes algorithm for 10-year cardiovascular disease +risk estimation in patients with diabetes. +""" + +import math +from pathlib import Path +from typing import Literal, TypeAlias + +import numpy as np +from pydantic import BaseModel + +from vitals.biomarkers import helpers, schemas + +RiskCategory: TypeAlias = Literal["Low to moderate", "High", "Very high"] + + +class ModelCoefficients(BaseModel): + """ + Sex-specific coefficients for the SCORE2-Diabetes Cox proportional hazards model. + + These coefficients are used to calculate the 10-year risk of cardiovascular disease + based on transformed risk factors and their age interactions. + """ + + # Male main effect coefficients + male_age: float = 0.5368 + male_smoking: float = 0.4774 + male_sbp: float = 0.1322 + male_diabetes: float = 0.6457 + male_total_cholesterol: float = 0.1102 + male_hdl_cholesterol: float = -0.1087 + male_age_at_diabetes_diagnosis: float = -0.0998 + male_hba1c: float = 0.0955 + male_egfr: float = -0.0591 + male_egfr_squared: float = 0.0058 + + # Male interaction term coefficients + male_smoking_age: float = -0.0672 + male_sbp_age: float = -0.0268 + male_diabetes_age: float = -0.0983 + male_tchol_age: float = -0.0181 + male_hdl_age: float = 0.0095 + male_hba1c_age: float = -0.0134 + male_egfr_age: float = 0.0115 + + # Female main effect coefficients + female_age: float = 0.6624 + female_smoking: float = 0.6139 + female_sbp: float = 0.1421 + female_diabetes: float = 0.8096 + female_total_cholesterol: float = 0.1127 + female_hdl_cholesterol: float = -0.1568 + female_age_at_diabetes_diagnosis: float = -0.1180 + female_hba1c: float = 0.1173 + female_egfr: float = -0.0640 + female_egfr_squared: float = 0.0062 + + # Female interaction term coefficients + female_smoking_age: float = -0.1122 + female_sbp_age: float = -0.0167 + female_diabetes_age: float = -0.1272 + female_tchol_age: float = -0.0200 + female_hdl_age: float = 0.0186 + female_hba1c_age: float = -0.0196 + female_egfr_age: float = 0.0169 + + +class BaselineSurvival(BaseModel): + """ + Sex-specific baseline survival probabilities for the SCORE2-Diabetes model. + + These values represent the 10-year survival probability for individuals + with all risk factors at their reference values. + """ + + male: float = 0.9605 + female: float = 0.9776 + + +class CalibrationScales(BaseModel): + """ + Region and sex-specific calibration scales for Belgium (Low Risk region). + + These scales are used to calibrate the uncalibrated risk estimate to match + the population-specific cardiovascular disease incidence rates. + """ + + # Male calibration scales + male_scale1: float = -0.5699 + male_scale2: float = 0.7476 + + # Female calibration scales + female_scale1: float = -0.7380 + female_scale2: float = 0.7019 + + +def cardiovascular_risk(filepath: str | Path) -> tuple[float, float, RiskCategory]: + """ + Calculate the 10-year cardiovascular disease risk using the SCORE2-Diabetes algorithm. + + This function implements the SCORE2-Diabetes risk assessment for patients with diabetes. + It uses sex-specific Cox proportional hazards model coefficients and applies regional + calibration for Belgium (Low Risk region). + + Args: + filepath: Path to JSON file containing biomarker data including age, sex, + systolic blood pressure, total cholesterol, HDL cholesterol, smoking status, + diabetes status, age at diabetes diagnosis, HbA1c, and eGFR. + + Returns: + A tuple containing: + - age: The patient's chronological age + - risk_percentage: The calibrated 10-year CVD risk as a percentage + - risk_category: Risk stratification category ("Low to moderate", "High", or "Very high") + + Raises: + ValueError: If invalid biomarker class is used + """ + # Extract biomarkers from JSON file + biomarkers = helpers.extract_biomarkers_from_json( + filepath=filepath, + biomarker_class=schemas.Score2DiabetesMarkers, + biomarker_units=schemas.Score2DiabetesUnits(), + ) + + if not isinstance(biomarkers, schemas.Score2DiabetesMarkers): + raise ValueError(f"Invalid biomarker class used: {biomarkers}") + + age: float = biomarkers.age + is_male: bool = biomarkers.is_male # True for male, False for female + + # Apply transformations to biomarkers + cage: float = (age - 60) / 5 + smoking: float = float(biomarkers.smoking) # Convert bool to float (1.0 or 0.0) + csbp: float = (biomarkers.systolic_blood_pressure - 120) / 20 + diabetes: float = float(biomarkers.diabetes) # Convert bool to float (1.0 or 0.0) + ctchol: float = biomarkers.total_cholesterol - 6 + chdl: float = (biomarkers.hdl_cholesterol - 1.3) / 0.5 + cagediab: float = diabetes * (biomarkers.age_at_diabetes_diagnosis - 50) / 5 + ca1c: float = (biomarkers.hba1c - 31) / 9.34 + cegfr: float = (math.log(biomarkers.egfr) - 4.5) / 0.15 + cegfr_squared: float = cegfr * cegfr + + # Calculate interaction terms + smoking_age: float = smoking * cage + sbp_age: float = csbp * cage + diabetes_age: float = diabetes * cage + tchol_age: float = ctchol * cage + hdl_age: float = chdl * cage + hba1c_age: float = ca1c * cage + egfr_age: float = cegfr * cage + + # Get model coefficients + coef: ModelCoefficients = ModelCoefficients() + + # Calculate linear predictor (x) based on sex + linear_pred: float + baseline_survival: float + scale1: float + scale2: float + + if is_male: + linear_pred = ( + coef.male_age * cage + + coef.male_smoking * smoking + + coef.male_sbp * csbp + + coef.male_diabetes * diabetes + + coef.male_total_cholesterol * ctchol + + coef.male_hdl_cholesterol * chdl + + coef.male_age_at_diabetes_diagnosis * cagediab + + coef.male_hba1c * ca1c + + coef.male_egfr * cegfr + + coef.male_egfr_squared * cegfr_squared + + coef.male_smoking_age * smoking_age + + coef.male_sbp_age * sbp_age + + coef.male_diabetes_age * diabetes_age + + coef.male_tchol_age * tchol_age + + coef.male_hdl_age * hdl_age + + coef.male_hba1c_age * hba1c_age + + coef.male_egfr_age * egfr_age + ) + baseline_survival = BaselineSurvival().male + scale1 = CalibrationScales().male_scale1 + scale2 = CalibrationScales().male_scale2 + else: + linear_pred = ( + coef.female_age * cage + + coef.female_smoking * smoking + + coef.female_sbp * csbp + + coef.female_diabetes * diabetes + + coef.female_total_cholesterol * ctchol + + coef.female_hdl_cholesterol * chdl + + coef.female_age_at_diabetes_diagnosis * cagediab + + coef.female_hba1c * ca1c + + coef.female_egfr * cegfr + + coef.female_egfr_squared * cegfr_squared + + coef.female_smoking_age * smoking_age + + coef.female_sbp_age * sbp_age + + coef.female_diabetes_age * diabetes_age + + coef.female_tchol_age * tchol_age + + coef.female_hdl_age * hdl_age + + coef.female_hba1c_age * hba1c_age + + coef.female_egfr_age * egfr_age + ) + baseline_survival = BaselineSurvival().female + scale1 = CalibrationScales().female_scale1 + scale2 = CalibrationScales().female_scale2 + + # Calculate uncalibrated risk + uncalibrated_risk: float = 1 - np.power(baseline_survival, np.exp(linear_pred)) + + # Apply calibration for Belgium (Low Risk region) + # Calibrated 10-year risk, % = [1 - exp(-exp(scale1 + scale2*ln(-ln(1 - 10-year risk))))] * 100 + calibrated_risk: float = float( + (1 - np.exp(-np.exp(scale1 + scale2 * np.log(-np.log(1 - uncalibrated_risk))))) + * 100 + ) + + # Determine risk category based on age + risk_category: RiskCategory + if age < 50: + if calibrated_risk < 2.5: + risk_category = "Low to moderate" + elif calibrated_risk < 7.5: + risk_category = "High" + else: + risk_category = "Very high" + else: # age 50-69 + if calibrated_risk < 5: + risk_category = "Low to moderate" + elif calibrated_risk < 10: + risk_category = "High" + else: + risk_category = "Very high" + + return (age, round(calibrated_risk, 2), risk_category) From f72aab44fc8c4a8f34d78095157a7d5e5c82ba98 Mon Sep 17 00:00:00 2001 From: fbraza Date: Sat, 19 Jul 2025 20:08:43 +0200 Subject: [PATCH 2/2] test: add values for unit test score2 diabetes --- .../test__input__patient_05.json | 2 +- tests/test_score2_diabetes.py | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/tests/inputs/score2_diabetes/test__input__patient_05.json b/tests/inputs/score2_diabetes/test__input__patient_05.json index 82614f4..c33969d 100644 --- a/tests/inputs/score2_diabetes/test__input__patient_05.json +++ b/tests/inputs/score2_diabetes/test__input__patient_05.json @@ -44,7 +44,7 @@ "unit": "mmol/mol" }, "egfr_ml_min_1_73m2": { - "value": 50, + "value": 60, "unit": "mL/min/1.73m\u00b2" } } diff --git a/tests/test_score2_diabetes.py b/tests/test_score2_diabetes.py index 5403df3..78401f5 100644 --- a/tests/test_score2_diabetes.py +++ b/tests/test_score2_diabetes.py @@ -10,12 +10,12 @@ @pytest.mark.parametrize( "filename,expected", [ - ("test__input__patient_01.json", (45.00, 0.00, "PLACEHOLDER")), - ("test__input__patient_02.json", (55.00, 0.00, "PLACEHOLDER")), - ("test__input__patient_03.json", (65.00, 0.00, "PLACEHOLDER")), - ("test__input__patient_04.json", (48.00, 0.00, "PLACEHOLDER")), - ("test__input__patient_05.json", (60.00, 0.00, "PLACEHOLDER")), - ("test__input__patient_06.json", (42.00, 0.00, "PLACEHOLDER")), + ("test__input__patient_01.json", (45.00, 4.40, "High")), + ("test__input__patient_02.json", (55.00, 11.80, "Very high")), + ("test__input__patient_03.json", (65.00, 18.60, "Very high")), + ("test__input__patient_04.json", (48.00, 2.30, "Low to moderate")), + ("test__input__patient_05.json", (60.00, 22.30, "Very high")), + ("test__input__patient_06.json", (42.00, 5.80, "High")), ], ) def test_score2_diabetes(filename, expected): @@ -32,9 +32,8 @@ def test_score2_diabetes(filename, expected): expected_age, expected_risk, expected_category = expected assert age == expected_age - # TODO: Update these assertions once actual values are calculated - # assert pred_risk_category == expected_category - # assert pytest.approx(pred_risk, abs=0.1) == expected_risk + assert pred_risk_category == expected_category + assert pytest.approx(pred_risk, abs=0.1) == expected_risk if __name__ == "__main__":