Skip to content

Add age validation for SCORE2 algorithm #5

@fbraza

Description

@fbraza

Issue Description

The SCORE2 and SCORE2-Diabetes algorithms are designed for patients aged 40-69 years, but the current implementations don't validate this age range.

Problem

  • No validation that age is within the 40-69 year range in both SCORE2 and SCORE2-Diabetes modules
  • Could lead to incorrect risk calculations for patients outside this range
  • SCORE2-Diabetes has additional concern: patients aged 70+ fall into the 50-69 logic without explicit upper bound validation

Suggested Implementation

For SCORE2 (vitals/score2/compute.py):

def cardiovascular_risk(filepath: str) -> tuple[float, float, str]:
    # Extract biomarkers...
    
    age = biomarkers.age
    
    # Add age validation
    if age < 40 or age > 69:
        raise ValueError(f"SCORE2 is only validated for ages 40-69. Patient age: {age}")
    
    # Continue with calculations...

For SCORE2-Diabetes (vitals/score2_diabetes/compute.py):

def cardiovascular_risk(filepath: str | Path) -> tuple[float, float, RiskCategory]:
    # Extract biomarkers...
    
    age: float = biomarkers.age
    
    # Add age validation
    if not 40 <= age <= 69:
        raise ValueError(f"SCORE2-Diabetes is validated for ages 40-69, got {age}")
    
    # Continue with calculations...

Impact

  • Ensures the algorithms are only used for their validated populations
  • Prevents misuse and incorrect risk assessments
  • Improves code robustness in both modules
  • Addresses edge case handling for age boundaries

Related

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions