FhirEx.Resources.Subscription (fhir_ex v0.3.0)

Copy Markdown View Source

FHIR R5 Subscription resource.

Describes a push-based subscription to receive notifications when data matching a given SubscriptionTopic changes on the server.

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

Status codes: requested | active | error | off | entered-in-error

Channel types (from http://terminology.hl7.org/CodeSystem/subscription-channel-type): rest-hook | websocket | email | message

Content codes: empty | id-only | full-resource

Filters

filter_by narrows which events trigger the subscription. Each filter names a parameter defined by the SubscriptionTopic:

%{
  resource_type: "Observation",
  filter_parameter: "category",
  comparator: "eq",
  value: "laboratory"
}

Channel parameters

parameter passes channel-specific key/value pairs (e.g. HTTP headers for a rest-hook):

%{name: "Authorization", value: "Bearer secret"}

Example

alias FhirEx.Resources.Subscription
alias FhirEx.Types.{Coding, ContactPoint}

subscription = %Subscription{
  id: "sub-001",
  status: "requested",
  topic: "http://example.org/SubscriptionTopic/lab-result",
  channel_type: %Coding{
    system: "http://terminology.hl7.org/CodeSystem/subscription-channel-type",
    code: "rest-hook"
  },
  endpoint: "https://receiver.example.org/fhir/notification",
  content: "full-resource",
  content_type: "application/fhir+json",
  filter_by: [
    %{
      resource_type: "Observation",
      filter_parameter: "category",
      comparator: "eq",
      value: "laboratory"
    }
  ],
  parameter: [
    %{name: "Authorization", value: "Bearer secret-token"}
  ],
  reason: "Receive lab results for downstream processing"
}

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.

Returns the FHIR resource type name string.

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

Types

filter_by()

@type filter_by() :: %{
  resource_type: String.t() | nil,
  filter_parameter: String.t(),
  comparator: String.t() | nil,
  modifier: String.t() | nil,
  value: String.t()
}

parameter()

@type parameter() :: %{name: String.t(), value: String.t()}

t()

@type t() :: %FhirEx.Resources.Subscription{
  channel_type: FhirEx.Types.Coding.t(),
  contact: [FhirEx.Types.ContactPoint.t()] | nil,
  content: String.t() | nil,
  content_type: String.t() | nil,
  end: String.t() | nil,
  endpoint: String.t() | nil,
  extension: [FhirEx.Types.Extension.t()] | nil,
  filter_by: [filter_by()] | nil,
  heartbeat_period: non_neg_integer() | nil,
  id: String.t() | nil,
  identifier: [FhirEx.Types.Identifier.t()] | nil,
  managing_entity: FhirEx.Types.Reference.t() | nil,
  max_count: pos_integer() | nil,
  meta: FhirEx.Types.Meta.t() | nil,
  name: String.t() | nil,
  parameter: [parameter()] | nil,
  reason: String.t() | nil,
  status: String.t(),
  text: FhirEx.Types.Narrative.t() | nil,
  timeout: non_neg_integer() | nil,
  topic: String.t()
}

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.

resource_type()

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

Returns the FHIR resource type name string.

to_map(s)

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

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