Healthcare and life sciences
Predict readmissions, estimate length of stay, and monitor follow-up compliance.
Data mapping
- Entity
- patient (pseudonymised identifier)
- Group
- hospital or clinic
- Profile
- generic; configure time windows with verticals.register
Supported analyses
- Will this patient be readmitted within 30 days?
predict_event(target="admission", window_days=30) - What is the expected length of the next stay?
predict_value(target="admission", window_days=120)
Reference implementation
from datetime import datetime, timedelta
from vertiq import plugins, rules
from vertiq.mapping import Mapping, apply, repair
from vertiq.tasks import predict_event, predict_value
# rows: the source export as a list of dicts, e.g. list(csv.DictReader(open("export.csv")))
mapping = Mapping.parse({"entity": "Patienten Nr", "time": "Admit Date", "type": "Encounter Type", "value": "LOS Days", "group": "Klinik", "attrs": ["Diagnosis Code", "Ward", "Follow-up Due", "Follow-up Done"], "date_format": "%d/%m/%Y"})
m, notes = repair(mapping, rows) # validates column names, value types and date format against the rows
ds, problems = apply(m, rows) # rows that fail to load are reported, not imputed
@plugins.feature("clinic")
def chronic_codes(entity, before, cut): # receives only events recorded before the cutoff
chronic = {"E11", "I50", "J44"}
return {"chronic": float(any(e.attrs.get("Diagnosis Code") in chronic for e in before))}
task = predict_event(ds, target="admission", window_days=30, pack="clinic")
print(task.status, task.report()) # "trained" only if the model outperformed the baseline on held-out entities
if task.status == "trained":
print(task.score("P29999")) # probability with contributing factors
size = predict_value(ds, target="admission", window_days=120, pack="clinic")
print(size.status, size.report())
flags = rules.run(ds, [
rules.repeat(30, type="admission"), # readmission within 30 days
rules.overdue("Follow-up Due", "Follow-up Done", tolerance_days=3), # follow-up completed more than 3 days late
])
print(flags["summary"])
This code is executed by the test suite (tests/test_guides.py) against generated records with these column names.
Recommended plugin
chronic_codes: Clinician-defined lists of chronic diagnosis codes add information that encounter data does not state.
Validation rules
rules.repeat(30, type="admission"): readmission within 30 daysrules.overdue("Follow-up Due", "Follow-up Done", tolerance_days=3): follow-up completed more than 3 days late
Related modules
tasks.predict_uplift: the effect of a follow-up programme on readmissions, against patients not calledcausal.matched_att: an effect estimate when a protocol was introduced without a control group
Implementation notes
- Outputs support prioritisation and do not replace clinical judgement.
- Use pseudonymised identifiers and exclude direct identifiers from mapped data.
- Comply with applicable health-data regulation, such as DPDP in India or HIPAA in the United States.
Validation
- Length of stay: mean absolute error 1.61 days against 2.18 for the previous-value baseline, 5 runs
- Healthcare tables in the Vertiq LM mapping evaluation
- Every deployment: the evaluation gate measures each model on the organisation's own held-out records before promotion.