FHIR R5 Observation resource.
Measurements and assertions made about a patient, device, or other subject. The primary resource for representing lab results.
https://www.hl7.org/fhir/R5/observation.html
Status codes: registered | preliminary | final | amended | corrected |
cancelled | entered-in-error | unknownPolymorphic value[x]
The result value is stored as a tagged tuple on the value field:
{:quantity, %Quantity{value: 14.5, unit: "g/dL", ...}}
{:codeable_concept, %CodeableConcept{...}}
{:string, "Positive"}
{:boolean, true}
{:integer, 42}
{:range, %Range{...}}
{:ratio, %Ratio{...}}
{:sampled_data, map()}
{:time, "09:30:00"}
{:date_time, "2024-01-15T09:30:00Z"}
{:period, %Period{...}}Reference ranges
The reference_range field holds normal ranges for the result.
Each entry can have low, high, normal_value, type, applies_to, age, and text.
Example
alias FhirEx.Resources.Observation
alias FhirEx.Types.{Reference, CodeableConcept, Coding, Quantity}
observation = %Observation{
id: "obs-001",
status: "final",
category: [
%CodeableConcept{
coding: [%Coding{
system: "http://terminology.hl7.org/CodeSystem/observation-category",
code: "laboratory"
}]
}
],
code: %CodeableConcept{
coding: [%Coding{system: "http://loinc.org", code: "718-7", display: "Hemoglobin [Mass/volume] in Blood"}],
text: "Hemoglobin"
},
subject: %Reference{reference: "Patient/patient-001"},
effective: {:date_time, "2024-01-15T09:30:00Z"},
issued: "2024-01-15T10:00:00Z",
value: {:quantity, %Quantity{value: 14.5, unit: "g/dL", system: "http://unitsofmeasure.org", code: "g/dL"}},
reference_range: [
%{
low: %Quantity{value: 12.0, unit: "g/dL", system: "http://unitsofmeasure.org", code: "g/dL"},
high: %Quantity{value: 17.5, unit: "g/dL", system: "http://unitsofmeasure.org", code: "g/dL"},
text: "12.0 - 17.5 g/dL"
}
]
}
Summary
Functions
Builds the struct from a string-keyed map (e.g., from decoded FHIR JSON). Polymorphic fields are decoded into tagged tuples.
Builds a new struct from a map or keyword list of field values.
Returns the FHIR resource type name string.
Converts the struct to a string-keyed map for use with FhirEx.JSON. Polymorphic fields (value[x], effective[x]) are serialised to their FHIR JSON keys.
Types
@type component() :: %{ code: FhirEx.Types.CodeableConcept.t(), value: value_type() | nil, data_absent_reason: FhirEx.Types.CodeableConcept.t() | nil, interpretation: [FhirEx.Types.CodeableConcept.t()] | nil, reference_range: [reference_range()] | nil }
@type effective_type() :: {:date_time, String.t()} | {:period, FhirEx.Types.Period.t()} | {:timing, map()} | {:instant, String.t()}
@type reference_range() :: %{ low: FhirEx.Types.Quantity.t() | nil, high: FhirEx.Types.Quantity.t() | nil, normal_value: FhirEx.Types.CodeableConcept.t() | nil, type: FhirEx.Types.CodeableConcept.t() | nil, applies_to: [FhirEx.Types.CodeableConcept.t()] | nil, age: map() | nil, text: String.t() | nil }
@type t() :: %FhirEx.Resources.Observation{ based_on: [FhirEx.Types.Reference.t()] | nil, body_site: FhirEx.Types.CodeableConcept.t() | nil, body_structure: FhirEx.Types.Reference.t() | nil, category: [FhirEx.Types.CodeableConcept.t()] | nil, code: FhirEx.Types.CodeableConcept.t(), component: [component()] | nil, data_absent_reason: FhirEx.Types.CodeableConcept.t() | nil, derived_from: [FhirEx.Types.Reference.t()] | nil, device: FhirEx.Types.Reference.t() | nil, effective: effective_type() | nil, encounter: FhirEx.Types.Reference.t() | nil, extension: [FhirEx.Types.Extension.t()] | nil, focus: [FhirEx.Types.Reference.t()] | nil, has_member: [FhirEx.Types.Reference.t()] | nil, id: String.t() | nil, identifier: [FhirEx.Types.Identifier.t()] | nil, instantiates_canonical: String.t() | nil, instantiates_reference: FhirEx.Types.Reference.t() | nil, interpretation: [FhirEx.Types.CodeableConcept.t()] | nil, issued: String.t() | nil, meta: FhirEx.Types.Meta.t() | nil, method: FhirEx.Types.CodeableConcept.t() | nil, note: [FhirEx.Types.Annotation.t()] | nil, part_of: [FhirEx.Types.Reference.t()] | nil, performer: [FhirEx.Types.Reference.t()] | nil, reference_range: [reference_range()] | nil, specimen: FhirEx.Types.Reference.t() | nil, status: String.t(), subject: FhirEx.Types.Reference.t() | nil, text: FhirEx.Types.Narrative.t() | nil, triggered_by: [map()] | nil, value: value_type() | nil }
@type value_type() :: {:quantity, FhirEx.Types.Quantity.t()} | {:codeable_concept, FhirEx.Types.CodeableConcept.t()} | {:string, String.t()} | {:boolean, boolean()} | {:integer, integer()} | {:range, FhirEx.Types.Range.t()} | {:ratio, FhirEx.Types.Ratio.t()} | {:sampled_data, map()} | {:time, String.t()} | {:date_time, String.t()} | {:period, FhirEx.Types.Period.t()}
Functions
Builds the struct from a string-keyed map (e.g., from decoded FHIR JSON). Polymorphic fields are decoded into tagged tuples.
Builds a new struct from a map or keyword list of field values.
@spec resource_type() :: String.t()
Returns the FHIR resource type name string.
Converts the struct to a string-keyed map for use with FhirEx.JSON. Polymorphic fields (value[x], effective[x]) are serialised to their FHIR JSON keys.