resourceGroups and filters. For when to use them, with worked examples, see Filter FHIR resources.
resourceGroups
A list of the resource groups to produce. Each entry names one group, and can narrow it to some of its categories.
Rules:
- Omit the field to produce every group with every category. A group you leave out of the list is not produced.
- An empty list returns a 422. Omit the field instead.
- Listing the same group twice returns a 400.
- The response always contains one Patient and one Encounter. Listing them has no effect, and you cannot turn them off.
Categories per resource group
Not every group has categories, and categories work differently per group. The values come from the R4 value sets for Observation category, Condition category, and AllergyIntolerance category. The Procedure values are SNOMED CT concepts, in line with the R4 procedure category example set.
FHIR also defines the Observation categories
therapy and activity. The endpoint does not produce them, and returns a 400 if you select them.
What the Observation categories hold:
filters
A list of code filters. Each filter applies to one coding system.
The allowed codes are the
include set minus the exclude set, within the built-in scope of each field.
Condition groups
A condition group combines one or more conditions:73211009) or a subtype of it, and that are SNOMED CT disorders.
Conditions
Each condition has aproperty, an op, and a value:
The properties you can filter on:
Scope
Ascope narrows a filter to one resource group, one category, or one field:
Rules:
- A filter without
fieldapplies to thecodefield only. To filter body sites, setfieldtobodySite. - A category scope on Observation restricts the whole category. On Condition, AllergyIntolerance, and Procedure, a category scope only applies to resources that have that category.
How filters combine
When several filters apply to the same field, they combine:- Includes intersect. A code must match every
includethat applies. - Excludes add up. The endpoint removes a code that matches any
excludethat applies. - The built-in scope always applies. An
includenarrows the built-in scope of a field. It cannot widen it.
Filterable fields
Ascope must point to a field that the endpoint actually codes. This table lists every valid combination. Any other combination returns a 400.
Three Observation categories use two coding systems for
code: LOINC for measurements, such as “20 pack-years”, and SNOMED CT for findings, such as “never smoked”. A LOINC filter on these categories only affects the measurements. See Measurements and findings.
valueCodeableConcept is only filterable on imaging, where it holds a qualifier such as Present, Absent, or Severe. The other finding categories use a fixed Present or Absent pair.
The FHIR R4 AllergyIntolerance and FamilyMemberHistory resources have no bodySite field, so you cannot filter one.
Validation rules
The endpoint checks every filter before it starts. A filter that would have no effect is an error, so you never get a silently ignored filter. The request returns a 400 when:systemIdnames a coding system the endpoint does not use. The error message lists the valid ones.scope.categoryis set withoutscope.resourceGroup.- A category does not belong to its group, or the group has no categories.
- The combination of
resourceGroup,field, andsystemIdis not in the filterable fields table, for examplebodySitein LOINC. - The filter applies to a group or category that
resourceGroupsturns off. - A condition is invalid: an unknown property or
op,is-aordescendent-ofon a property other thancode, a code that does not exist, or an unknownsemantic_tag. resourceGroupslists the same group twice, or listscategoriesfor FamilyMemberHistory, Patient, or Encounter.
resourceGroups,categories, or a group’sconditionsis an empty list.- A condition’s
valuedoes not fit itsop:inneeds a list,existsneedstrueorfalse, andis-aanddescendent-ofneed a code or a list of codes. - A group has more than one condition and no
match. - Condition groups nest more than three levels deep.
Next steps
Filter FHIR resources
See worked examples for each kind of filter.
Observation resource group
See how each Observation category looks in the response.