Skip to main content

Exposing the Decision Support Values table in ehrQL

30 January 2025

We have made the TPP DecisionSupportValues table available in ehrQL.

This table is used by TPP to store the precalculated results of any decision support algorithms. At the time of writing, the only algorithm available is v1 of the electronic frailty index (EFI), but this could be extended in the future.

Full documentation is here, but here is an example of how to get the latest EFI for each patient.

from ehrql import create_dataset
from ehrql.tables.tpp import decision_support_values

dataset = create_dataset()

latest_efi_record = (
  decision_support_values
    .electronic_frailty_index()
    .sort_by(decision_support_values.calculation_date)
    .last_for_patient()
)

dataset.latest_efi = latest_efi_record.numeric_value
dataset.latest_efi_date = latest_efi_record.calculation_date