A lab result can have been measured before your model's cutoff and still have been unavailable at prediction time. A join on measurement date alone will silently let it in.

Consider a synthetic dataset for predictions made as of March 1. Person A has one result available in February and a newer result that only arrives in March. Person B also has a February measurement whose report arrives after the cutoff. The March 1 feature should use A's earlier result and mark B as missing.

from datetime import date cutoff = date.fromisoformat("2026-03-01") # The dates are synthetic. A result may be measured before it becomes available. rows = [ ("A", "2026-02-10", "2026-02-12", 11), ("A", "2026-02-20", "2026-03-03", 19), ("B", "2026-02-22", "2026-03-02", 23), ] latest = {} for person, measured, available, value in rows: if date.fromisoformat(available) > cutoff: continue if person not in latest or measured > latest[person][0]: latest[person] = (measured, value) features = {person: pair[1] for person, pair in latest.items()} assert features == {"A": 11}, features 

The assertion fails if you swap the availability check for a check on measurement date. A would incorrectly use 19, and B would gain a value of 23. In a real pipeline, left join this output to the prediction rows so B stays in the evaluation population. Decide what missing means with your reviewers before choosing an imputation method.

Keep the cutoff timestamp, its timezone, and the field that represents availability in the feature specification. Re-run this test for each new source. If the same measurement can be revised, keep a dated version history and test a correction that arrives after the cutoff. The example assumes a unique measurement date per person and date-granularity cutoffs. Use exact timestamps and an explicit tie-breaking rule when your source can provide them.

I work on RigorMed, an AI research workspace for developing research plans, checking evidence, and organizing work into reviewable tables, figures, and drafts. This code uses a synthetic fixture and was run locally. This article was drafted by an AI agent.