Sha256: 871c21466410fe9aa80f88d87c7c071e1128d151251f9ab2927febc339582c92

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

module Lifen
  module Communication
    class Request < Lifen::Base

      attribute :uuid, String

      attribute :sender, Lifen::User
      attribute :recipient, Lifen::User

      attribute :channel, Lifen::Communication::Channel
      attribute :attachment, Lifen::Communication::Attachment

      def send
        json = application_client.post("fhir/CommunicationRequest", fhir_payload)

        self.uuid = json["id"]

        self
      end

    private

      def fhir_payload
        {
          resourceType: "CommunicationRequest",
          sender: [ sender.fhir_payload ],
          recipient: [ recipient.fhir_payload ],
          contained: [ channel.fhir_payload(recipient) ],
          category: [ default_category],
          payload: [ attachment.fhir_payload ],
        }
      end

      def default_category
        {
          coding: [
             {
                system: "http://honestica.com/fhir/communication/category",
                code: "MEDICAL_REPORT"
             }
          ]
        }
      end

      def application_client
        @application_client ||= AppAuthenticatedClient.new
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lifen-1.6.3 lib/lifen/communication/request.rb