Blog

    Feature Stores in Healthcare: Reusable Clinical Features from FHIR Data

    By GauravAugust 21, 20269 mins read
    On this page

    Feature stores in healthcare hold reusable clinical features that more than one model can read: last HbA1c, last eGFR, days since discharge. Each feature is computed from FHIR data, has a name and a version, and records the path it came from. A feature store is not a FHIR persistence store or a cloud FHIR database.

    Written for digital health founders and hospital CTOs whose teams build more than one clinical model, it covers definitions, timestamps, status and corrections, units, versioning, access and tests.

    What is a feature store for reusable clinical features from FHIR data?

    A feature store for reusable clinical features holds named, versioned values computed from FHIR data, such as the last HbA1c from Observation, that several models read the same way. Agnotic Technologies stores the derived value and its definition, not the whole Patient graph. Where FHIR resources themselves persist is a separate system.

    Sharing last lab values across models?

    We version each feature against a FHIR path. This is not a FHIR persistence store.

    • Name: last_hba1c, last_egfr, days_since_discharge. One idea each.
    • Version: the definition, including the LOINC or local code, and the window.
    • Source: the Observation or Encounter path. If the path is missing, the feature is missing, not guessed.
    • Not: a FHIR server or a table of raw resources. Those hold the source data the feature reads.

    FHIR servers and data lakes persist the source resources. The feature store sits one step later: it holds the named value that several models read, computed from those resources.

    What must a feature not do?

    A feature must not invent a value when the Observation is absent, and it must not write back into the chart. Agnotic returns missing and leaves Patient alone.

    • Missing Observation: feature is null, with the version that says so.
    • No write-back: features are derived. They are not new clinical assertions.
    • Same version on train and serve, or the model is on the wrong definition.

    Which fields make up a feature definition?

    A feature definition names the source resource, the code, the time rule, the status rule, the unit and the null rule, and gives that combination a version. Agnotic treats the definition as code: reviewed, stored and referenced by its version id.

    LOINC 4548-4 is the code for Hemoglobin A1c/Hemoglobin.total in Blood.

    • Source: Observation, filtered by code system and code, such as LOINC 4548-4 for last_hba1c.
    • Time rule: which timestamp counts, and how far back the lookback window reaches.
    • Status rule: which Observation statuses are accepted.
    • Unit: the unit the value is returned in, and the conversions allowed to reach it.
    • Null rule: what the feature returns when no qualifying Observation exists.
    • Owner: the person who approves a new version.

    A definition without a named owner tends to collect quiet edits. One owner turns every change into a decision someone signed.

    Which Observation timestamp should a last value use?

    A last value should be ordered by the clinically relevant time and filtered by when the result became available. Using only one of the two either reorders results or leaks future data into training rows.

    In FHIR R4, Observation.effective[x] is the clinically relevant time or time period for the observation, and Observation.issued is the date and time that version was made available.

    • Order by effective time: the HbA1c drawn most recently is the last one, even if an older draw was issued later.
    • Filter by issued time: for a training row at a given prediction time, ignore results issued after that moment.
    • Missing issued time: the definition states the rule, usually excluding that result from point-in-time training rows.

    The issued filter is the rule teams skip. A model trained on results nobody had yet looks better offline than it ever will at the bedside.

    How should Observation status and corrections change a feature?

    Status decides whether a result counts at all, and a correction should change the served value the next time it is computed. Agnotic writes the accepted statuses into each definition rather than assuming final.

    The FHIR R4 ObservationStatus value set includes preliminary, final, amended, cancelled and entered-in-error. Entered-in-error means the observation was withdrawn following a previous final release.

    • final and amended: usually accepted.
    • preliminary: accepted only if the definition says so, and that choice is part of the version.
    • cancelled and entered-in-error: never accepted. A result withdrawn after release must drop out.

    When an amended or withdrawn result arrives, the serving value recomputes. Training rows already built are not rewritten in place; the next training cut picks up the change.

    How do units and local codes affect a feature?

    Units and local codes are where one feature quietly turns into two. A result in a different unit, or under a local code nobody mapped, either corrupts the value or disappears.

    • Units: the definition fixes one output unit. A result in an unlisted unit is excluded and counted, not guessed.
    • Local codes: each site's lab codes map to the definition's LOINC code before the feature reads them.
    • Unmapped codes: reported per site, because a new analyser or test name usually appears at one site first.

    HbA1c shows why: laboratories may report it as a percentage or in mmol/mol. The definition decides which one the model receives.

    How do you serve one definition to training and to a live model?

    You serve it from one piece of code that computes the value two ways: as of a past moment for training rows, and as of now for live requests. Two separate implementations of the same feature will drift apart.

    • Offline: for each training row, compute the value from data issued before that row's prediction time.
    • Online: for a live request, compute or look up the current value for that patient.
    • Both paths return the value, the definition version and the effective time of the source Observation.

    Returning the source time lets the calling model, or a person reviewing its output, see that the last HbA1c is months old rather than from this morning.

    When should a feature get a new version instead of an edit?

    Any change that could alter a returned value gets a new version, including a bug fix. Editing a definition in place means a model validated on one behaviour is now reading another.

    • New version: a change to the code list, window, status rule, unit, null rule or timestamp rule.
    • Same version: performance work that provably returns identical values on a fixed test set.
    • Old versions stay readable until no registered model reads them.
    • The owner approves each new version and names which models will move to it.

    Who may read feature values, and are they PHI?

    Feature values tied to a patient are PHI, and only the model services that need a feature should read it. A last HbA1c with a patient id attached is a lab result stored in a new place.

    The minimum necessary standard applies to model services as it does to people: each service reads only the features its model uses.

    • Grant access per model service and per feature, not to the whole store.
    • Log reads by service identity and feature name, without the values.
    • Keep feature storage inside the same protections as the clinical data it came from.

    What are the common mistakes with healthcare feature stores?

    Reusable features go wrong when two consumers assume different things about the same name. Most of these failures look like model problems until someone inspects the feature itself.

    • Leakage: training rows read results issued after the prediction time.
    • Mixed versions: training used one version while serving still returns the previous one.
    • Silent imputation: serving fills nulls with a default that training never saw.
    • Site mapping gaps: one site's local code is unmapped, so its patients look as if they were never tested.
    • Time zones: effective times compared without offsets shift results across a day boundary.

    Each of these is cheaper to catch in the definition review than in a model that has already shipped.

    A worked example: last HbA1c shared by two models

    A worked example: a diabetes outreach model and a readmission risk model both want the most recent HbA1c. Instead of two separate queries, the team publishes last_hba1c as one definition.

    The definition reads Observation coded LOINC 4548-4 plus mapped local codes, accepts final and amended, orders by effective time, filters by issued time for training, returns a percentage, and is null when no result falls in the lookback window.

    Later, one site adds an analyser with a new local code. The unmapped-code report flags it and the mapping is added. Because values change for that site, the owner publishes a new version, and each model owner decides when to move.

    How do you test a feature before a second model reads it?

    You test it against hand-checked patients and against every edge case its definition claims to handle. A feature with a second consumer needs tests the first consumer never wrote.

    • Synthetic patients with no result, one result, a withdrawn result and a late-issued result.
    • A point-in-time test proving a training row never sees a result issued after its prediction time.
    • A parity test: offline and online paths return the same value for the same patient and moment.
    • A unit test for every allowed conversion and every excluded unit.

    Keep those synthetic patients next to the definition in the repository, so the tests travel with each new version and run before it is published.

    How does Agnotic publish a feature?

    Agnotic writes each definition with its owner, builds the offline and online paths from one piece of code, adds the point-in-time and parity tests, and publishes each version for the client's models to adopt.

    Named, versioned, computed, not stored as the chart

    Last Observation of a code. Null when absent. Not a FHIR database.

    Related reading on Agnotic

    The extract pipeline, the training snapshot, the model registry and FHIR basics.

    Sources

    Frequently Asked Questions

    Yes, if each names the version. Mixing versions on one endpoint is a defect.

    Talk to an engineer about your project

    Name the features and the FHIR paths. We will version each definition, return null when the Observation is absent, and we will not treat this as a FHIR database.

    Go deeper

    Services and solutions on this topic