Sha256: 9db7049d96cb28aba5e784cd8b50e649522c7dbb5d5efd5b7ca9553204ed719f

Contents?: true

Size: 666 Bytes

Versions: 2

Compression:

Stored size: 666 Bytes

Contents

module LifenFhir
  class Category < Base

    CODES = ["MEDICAL_REPORT", "MESSAGE", "MEDICATION_ORDER", "REFERRAL_REQUEST", "OTHER"]

    attribute :code, String, default: "MEDICAL_REPORT"

    def fhir_payload
      raise Error.new(message: "Invalid category: code must be in the authorized values") if !valid?

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

    def attributes_from_json(json)
      self.code = Array(json["coding"]).first.fetch "code"

      self
    end

    def valid?
      CODES.include? code
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lifen_fhir-0.7.1 lib/lifen_fhir/category.rb
lifen_fhir-0.7.0 lib/lifen_fhir/category.rb