File size: 869 Bytes
21c7db9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""Tabular feature extraction."""

from __future__ import annotations

from app.common.types import PatientProfile


def build_tabular_features(patient: PatientProfile) -> dict[str, float]:
    return {
        "age": float(patient.age),
        "med_count": float(len(patient.medications)),
        "frailty": float(patient.frailty_score),
        "adherence": float(patient.adherence_estimate),
        "egfr": float(patient.labs.egfr or 60.0),
        "ast": float(patient.labs.ast or 30.0),
        "alt": float(patient.labs.alt or 30.0),
        "inr": float(patient.labs.inr or 1.2),
        "glucose": float(patient.labs.glucose or 110.0),
        "specialist_conflict_count": float(len(patient.specialist_conflicts)),
        "ade_history_count": float(len(patient.prior_ade_history)),
        "monitoring_gap_count": float(len(patient.monitoring_gaps)),
    }