Skip to main content
This page lists every field and rule of the two filtering fields in a FHIR Extraction request: 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:
This group allows codes that are diabetes mellitus (73211009) or a subtype of it, and that are SNOMED CT disorders.

Conditions

Each condition has a property, an op, and a value: The properties you can filter on:

Scope

A scope narrows a filter to one resource group, one category, or one field: Rules:
  • A filter without field applies to the code field only. To filter body sites, set field to bodySite.
  • 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 include that applies.
  • Excludes add up. The endpoint removes a code that matches any exclude that applies.
  • The built-in scope always applies. An include narrows the built-in scope of a field. It cannot widen it.

Filterable fields

A scope 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:
  • systemId names a coding system the endpoint does not use. The error message lists the valid ones.
  • scope.category is set without scope.resourceGroup.
  • A category does not belong to its group, or the group has no categories.
  • The combination of resourceGroup, field, and systemId is not in the filterable fields table, for example bodySite in LOINC.
  • The filter applies to a group or category that resourceGroups turns off.
  • A condition is invalid: an unknown property or op, is-a or descendent-of on a property other than code, a code that does not exist, or an unknown semantic_tag.
  • resourceGroups lists the same group twice, or lists categories for FamilyMemberHistory, Patient, or Encounter.
The request returns a 422 when:
  • resourceGroups, categories, or a group’s conditions is an empty list.
  • A condition’s value does not fit its op: in needs a list, exists needs true or false, and is-a and descendent-of need 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.