Skip to main content

Module fhir_format

Module fhir_format 

Source
Expand description

Shared fhir-format output and FHIR-representation content negotiation for the SQL-on-FHIR run operations (SoF v2 Common Operation Behavior).

Two independent negotiation axes are implemented here so sof-server and the HFS REST handlers apply identical rules:

  • Axis 1 — format selection: _format=fhir (or Accept: application/fhir+json when _format is absent) selects the fhir output format: a Parameters resource with one repeating row parameter per result row (format_view_fhir_parameters).
  • Axis 2 — representation: when a flat format is selected and the client sends Accept: application/fhir+json, the raw payload is wrapped in a serialized Binary resource envelope with base64 data (wrap_in_binary_envelope). The XML envelope form (application/fhir+xml) is not supported and callers should reject it with 406 Not Acceptable (see accept_requires_unsupported_fhir_xml).

Constants§

FHIR_JSON_MIME
Native media type of the fhir output format.
FHIR_XML_MIME
The FHIR XML media type — recognised only to reject it explicitly.

Functions§

accept_has_mime
True when the given Accept header value lists mime (parameters such as ;q= are ignored; matching is case-insensitive).
accept_requires_unsupported_fhir_xml
True when the client asked for a FHIR XML representation without also accepting FHIR JSON. Per the spec, a server that does not support the envelope form requested via Accept SHALL respond 406 Not Acceptable rather than silently returning raw bytes under a FHIR media type; this server does not produce XML.
format_view_fhir_parameters
Renders a ProcessedResult as a FHIR Parameters resource per the SoF v2 spec’s fhir output format: one top-level row parameter per result row, with one part per non-NULL column carrying the appropriate value[x].
wrap_in_binary_envelope
Wraps raw payload bytes in a serialized FHIR Binary resource envelope (contentType = the payload’s native media type, data = base64). The caller serves the result under application/fhir+json.