FhirEx.Types.Reference (fhir_ex v0.2.0)

Copy Markdown View Source

FHIR R5 Reference data type.

A reference from one resource to another. The target may be a relative, absolute, or logical reference.

https://www.hl7.org/fhir/R5/references.html

Examples

# Relative reference (most common in a server context)
%Reference{reference: "Patient/patient-001"}

# Absolute reference
%Reference{reference: "https://fhir.example.org/Patient/patient-001"}

# With display text
%Reference{reference: "Patient/patient-001", display: "John Doe"}

# Logical reference (by identifier, no URL)
%Reference{
  type: "Patient",
  identifier: %Identifier{system: "http://hospital.org/mrn", value: "MRN-12345"},
  display: "John Doe"
}

Summary

Functions

Builds the struct from a string-keyed map (e.g., from decoded FHIR JSON).

Builds a new struct from a map or keyword list of field values.

Convenience constructor for a simple relative reference.

Converts the struct to a string-keyed map for use with FhirEx.JSON.

Types

t()

@type t() :: %FhirEx.Types.Reference{
  display: String.t() | nil,
  identifier: FhirEx.Types.Identifier.t() | nil,
  reference: String.t() | nil,
  type: String.t() | nil
}

Functions

from_map(map)

@spec from_map(map()) :: t()

Builds the struct from a string-keyed map (e.g., from decoded FHIR JSON).

new(attrs \\ %{})

@spec new(map() | keyword()) :: t()

Builds a new struct from a map or keyword list of field values.

to(resource_type, id)

@spec to(String.t(), String.t()) :: t()

Convenience constructor for a simple relative reference.

to_map(ref)

@spec to_map(t()) :: map()

Converts the struct to a string-keyed map for use with FhirEx.JSON.