-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Issue Description
The SCORE2 and SCORE2-Diabetes implementations don't validate that biomarker values are within reasonable physiological ranges, which could lead to incorrect risk calculations.
Suggested Validation Ranges
SCORE2 Biomarkers
SCORE2_RANGES = {
'systolic_blood_pressure': (70, 250), # mmHg
'total_cholesterol': (2.0, 15.0), # mmol/L
'hdl_cholesterol': (0.5, 5.0), # mmol/L
}SCORE2-Diabetes Additional Biomarkers
SCORE2_DIABETES_RANGES = {
# All SCORE2 ranges plus:
'age_at_diabetes_diagnosis': (0, 120), # years (cannot exceed current age)
'hba1c': (20, 200), # mmol/mol (normal: 42-47, diabetes: >47)
'egfr': (5, 150), # mL/min/1.73m² (very low to normal+)
}Implementation Suggestion
For SCORE2 (vitals/score2/compute.py):
def validate_score2_biomarkers(biomarkers: schemas.Score2Markers) -> None:
"""Validate that SCORE2 biomarker values are within reasonable ranges."""
# Validate SBP
if not (70 <= biomarkers.systolic_blood_pressure <= 250):
raise ValueError(
f"Systolic blood pressure {biomarkers.systolic_blood_pressure} mmHg "
f"is outside reasonable range (70-250 mmHg)"
)
# Validate total cholesterol
if not (2.0 <= biomarkers.total_cholesterol <= 15.0):
raise ValueError(
f"Total cholesterol {biomarkers.total_cholesterol} mmol/L "
f"is outside reasonable range (2.0-15.0 mmol/L)"
)
# Validate HDL cholesterol
if not (0.5 <= biomarkers.hdl_cholesterol <= 5.0):
raise ValueError(
f"HDL cholesterol {biomarkers.hdl_cholesterol} mmol/L "
f"is outside reasonable range (0.5-5.0 mmol/L)"
)
# HDL should not exceed total cholesterol
if biomarkers.hdl_cholesterol > biomarkers.total_cholesterol:
raise ValueError(
f"HDL cholesterol ({biomarkers.hdl_cholesterol}) cannot exceed "
f"total cholesterol ({biomarkers.total_cholesterol})"
)For SCORE2-Diabetes (vitals/score2_diabetes/compute.py):
def validate_score2_diabetes_biomarkers(biomarkers: schemas.Score2DiabetesMarkers) -> None:
"""Validate that SCORE2-Diabetes biomarker values are within reasonable ranges."""
# Validate all SCORE2 ranges (reuse logic)
# ... same SBP, cholesterol validations ...
# Validate diabetes-specific biomarkers
if not (0 <= biomarkers.age_at_diabetes_diagnosis <= biomarkers.age):
raise ValueError(
f"Age at diabetes diagnosis ({biomarkers.age_at_diabetes_diagnosis}) "
f"cannot exceed current age ({biomarkers.age})"
)
if not (20 <= biomarkers.hba1c <= 200):
raise ValueError(
f"HbA1c {biomarkers.hba1c} mmol/mol is outside reasonable range (20-200 mmol/mol)"
)
if not (5 <= biomarkers.egfr <= 150):
raise ValueError(
f"eGFR {biomarkers.egfr} mL/min/1.73m² is outside reasonable range (5-150)"
)Benefits
- Prevents calculation errors from data entry mistakes
- Provides clear error messages for debugging
- Ensures algorithms are used with realistic data
- Improves robustness in both modules
- Specifically addresses extreme biomarker values highlighted in PR feat: implement SCORE2-Diabetes cardiovascular risk algorithm #16 evaluation
Considerations
- Ranges should be reviewed by medical experts
- Consider whether to error or warn for edge cases
- May need different ranges for different populations
- eGFR lower bound (5) prevents logarithm calculation errors in SCORE2-Diabetes
Related
- PR feat: Implement SCORE2 cardiovascular risk assessment algorithm #2: feat: Implement SCORE2 cardiovascular risk assessment algorithm
- PR feat: implement SCORE2-Diabetes cardiovascular risk algorithm #16: feat: implement SCORE2-Diabetes cardiovascular risk algorithm
- Issue Add age validation for SCORE2 algorithm #5: Add age validation for algorithms
- Issue Add bounds checking for mathematical operations in SCORE2 #6: Add bounds checking for mathematical operations
- Evaluation feedback from PR feat: implement SCORE2-Diabetes cardiovascular risk algorithm #16 highlighting input validation needs
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request