Skip to main content

fhir_search

Helpers for building FHIR search parameter values.

Module​

Functions​

escape_fhir_search_value​

def escape_fhir_search_value(value: str) ‑> str:

Escape a value so a FHIR search reads it as one literal value.

Arguments

  • value: The raw value, such as an imaging patient ID.

Returns The value with each backslash, comma, pipe and dollar sign escaped.

fhir_identifier_token​

def fhir_identifier_token(identifier: str) ‑> str:

Build an identifier search token from an identifier a person typed.

An identifier containing exactly one | is read as system|value: each side is escaped but the separating | is kept, so servers that need a system-qualified token still work. Any other identifier (no |, or more than one) is escaped as a single literal value, | included.

The identifier must be unescaped: pipes are counted as they stand, so an already-escaped input is read with the wrong number of separators and is escaped a second time.

Arguments

  • identifier: The identifier as supplied, optionally system|value.

Returns The token to use as the value of an identifier search parameter.