FhirEx.Resources.OperationOutcome (fhir_ex v0.3.0)

Copy Markdown View Source

FHIR R5 OperationOutcome resource.

A collection of error, warning, or information messages that result from a FHIR system action (e.g., a server validation error, or the outcome of a batch/transaction request).

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

Issue severity

fatal | error | warning | information | success

Issue codes (common subset)

invalidstructurerequiredvalueinvariant
securityloginunknownexpiredforbidden
processingnot-supportedduplicatenot-foundconflict
too-longcode-invalidbusiness-ruletransienttimeout

throttled | informational | success

Example

alias FhirEx.Resources.OperationOutcome

outcome = %OperationOutcome{
  id: "oo-001",
  issue: [
    %{
      severity: "error",
      code: "required",
      details: %FhirEx.Types.CodeableConcept{text: "Patient.name is required"},
      expression: ["Patient.name"]
    }
  ]
}

# Build a quick error outcome
outcome = OperationOutcome.error("not-found", "Patient/999 was not found")
outcome = OperationOutcome.ok("Patient created successfully")

Summary

Functions

Builds a single-issue error OperationOutcome.

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.

Builds a single-issue informational / success OperationOutcome.

Returns the FHIR resource type name string.

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

Builds a single-issue warning OperationOutcome.

Types

issue()

@type issue() :: %{
  severity: String.t(),
  code: String.t(),
  details: FhirEx.Types.CodeableConcept.t() | nil,
  diagnostics: String.t() | nil,
  location: [String.t()] | nil,
  expression: [String.t()] | nil
}

t()

@type t() :: %FhirEx.Resources.OperationOutcome{
  extension: [FhirEx.Types.Extension.t()] | nil,
  id: String.t() | nil,
  issue: [issue()],
  meta: FhirEx.Types.Meta.t() | nil,
  text: FhirEx.Types.Narrative.t() | nil
}

Functions

error(code, diagnostics)

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

Builds a single-issue error OperationOutcome.

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.

ok(message)

@spec ok(String.t()) :: t()

Builds a single-issue informational / success OperationOutcome.

resource_type()

@spec resource_type() :: String.t()

Returns the FHIR resource type name string.

to_map(oo)

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

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

warning(code, diagnostics)

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

Builds a single-issue warning OperationOutcome.