Sha256: 14110f5f37f9e8a65c320aa3d8bec10c3d79dd72510a19bae7909f0eaf51e538

Contents?: true

Size: 663 Bytes

Versions: 4

Compression:

Stored size: 663 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 LifenFhir::Error, "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

4 entries across 4 versions & 1 rubygems

Version Path
lifen_fhir-0.6.1 lib/lifen_fhir/category.rb
lifen_fhir-0.6.0 lib/lifen_fhir/category.rb
lifen_fhir-0.5.0 lib/lifen_fhir/category.rb
lifen_fhir-0.4.2 lib/lifen_fhir/category.rb