Repository navigation
Description
Summary
Date search parameters match date, dateTime, instant and Period values but not Timing values. R4 lists Timing as a type that date parameters search, so a resource whose searched element is a Timing should be found. Today it is silently left out.
This is a documented limitation, not a defect. #2950 (Search each alternative of a choice element) fixed #2914 (Date search on Observation fails: cannot determine FHIR type of Observation.effective) by searching each alternative of a choice element that the parameter type allows. The date type allows date, dateTime, instant and Period (SearchParameterType), so a Timing alternative is skipped. The library search docs say that Observation?date=2020 does not match an Observation "whose effective is a Timing". #2914 noted this as a gap.
Current behaviour (observed)
On 11.0.0-SNAPSHOT, built from release/11.0.0 at 4de8ad6 (Python 3.11.13, Java 21.0.3, Spark 4.0.5, FHIR R4):
import json
from pathling import PathlingContext
pc = PathlingContext.create(enable_terminology=False)
def observation(id, effective):
return dict({"resourceType": "Observation", "id": id, "status": "final", "code": {"text": "x"}}, **effective)
resources = [
observation("datetime", {"effectiveDateTime": "2020-04-01"}),
observation("timing-event", {"effectiveTiming": {"event": ["2020-04-01T10:00:00Z"]}}),
observation("timing-bounds", {"effectiveTiming": {"repeat": {
"boundsPeriod": {"start": "2020-01-01", "end": "2020-12-31"},
"frequency": 1, "period": 1, "periodUnit": "d"}}}),
]
observations = pc.encode(pc.spark.createDataFrame([(json.dumps(r),) for r in resources], ["value"]), "Observation")
for query in ["date=2020", "date=2020-04-01"]:
ids = sorted(r.id for r in observations.filter(pc.search_to_column("Observation", query)).select("id").collect())
print(f"{query} -> {ids}")Output:
date=2020 -> ['datetime']
date=2020-04-01 -> ['datetime']
Neither Timing Observation is returned, and no error is raised. The same happens for a Timing event in 2020 with ServiceRequest?occurrence=2020, ChargeItem?occurrence=2020 and CarePlan?activity-date=2020.
Requested behaviour (from the specification, not verified end to end)
R4 lists Timing as a type that date parameters search (the cross-map of search parameter types and data types on the R4 search page). It treats a Timing target as an explicit range (prefixes: "If the target value is a Range, a Period, or a Timing, then the target is explicitly a range"), and says how that range is taken (date):
the specified scheduling details are ignored and only the outer limits matter. For instance, a schedule that specifies every second day between 31-Jan 2013 and 24-Mar 2013 includes 1-Feb 2013, even though that is on an odd day that is not specified by the period.
So a Timing should be searched as the range from its earliest to its latest limit, with the same prefix rules as a Period. For the snippet above:
| Query | Expected |
|---|---|
date=2020 |
datetime, timing-event, timing-bounds |
date=2020-04-01 |
datetime, timing-event (the year-long bounds are not contained in one day) |
Notes
- Open questions for the design: what the outer limits of a Timing are when it has several
events, onlyrepeat.bounds[x], both, or neither; how to handleboundsDurationandboundsRange, which are not dates; and whether a Timing with no limits matches nothing. - Scope: in the bundled R4 registry, the date parameters that reach a Timing are those over
Observation.effective[x](date, also through the sharedclinical-date),ServiceRequest.occurrence[x](occurrence),ChargeItem.occurrence[x](occurrence) andCarePlan.activity.detail.scheduled[x](activity-date). All four were run. Some parameters over an element that allows a Timing, such as DeviceRequestevent-date, already exclude it in their expression withas(dateTime) | as(Period), so they are not affected. Custom search parameters over a Timing would need the same support. - When this is implemented, the sentence about
Timingin the library search docs needs to be removed.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsBacklog
Activity