Sha256: cc95139fded7904d7bffb1e5f970929ec44d056402c09ea36cb9db7269362260

Contents?: true

Size: 1.81 KB

Versions: 5

Compression:

Stored size: 1.81 KB

Contents

module FHIR
  module STU3
    class StructureDefinitionFinding
      # This is not an official FHIR Resource type. It is a data structure used for reporting.
      attr_accessor :resourceType
      attr_accessor :profileIdA
      attr_accessor :profileIdB
      attr_accessor :status
      attr_accessor :path
      attr_accessor :attribute
      attr_accessor :message
      attr_accessor :valueA
      attr_accessor :valueB

      def to_s
        "#{resourceType},#{profileIdA},#{profileIdB},#{path},#{attribute},#{status},#{message},#{valueA},#{valueB}"
      end

      def to_json
        JSON.pretty_unparse(as_json)
      end

      def from_json(json)
        obj = FHIR::STU3::StructureDefinitionFinding.new
        if json.is_a? String
          begin
            if json.encoding.names.include? 'UTF-8'
              json.gsub!("\xEF\xBB\xBF".force_encoding('UTF-8'), '') # remove UTF-8 BOM
            end
            hash = JSON.parse(json)
            hash.each do |key, value|
              obj.send("#{key}=".to_sym, value) if value
            end
          rescue => e
            FHIR.logger.error "Failed to parse JSON: #{e.message}"
            return nil
          end
        end
        obj
      end

      def clone
        from_json(to_json)
      end

      def warning(path, attribute, message, value_a, value_b)
        obj = clone
        obj.status = 'WARNING'
        obj.path = path
        obj.attribute = attribute
        obj.message = message
        obj.valueA = value_a
        obj.valueB = value_b
        obj
      end

      def error(path, attribute, message, value_a, value_b)
        obj = clone
        obj.status = 'ERROR'
        obj.path = path
        obj.attribute = attribute
        obj.message = message
        obj.valueA = value_a
        obj.valueB = value_b
        obj
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fhir_stu3_models-3.1.1 lib/fhir_stu3_models/fhir_ext/structure_definition_finding.rb
fhir_stu3_models-3.1.0 lib/fhir_stu3_models/fhir_ext/structure_definition_finding.rb
fhir_stu3_models-3.0.2 lib/fhir_stu3_models/fhir_ext/structure_definition_finding.rb
fhir_stu3_models-3.0.1 lib/fhir_stu3_models/fhir_ext/structure_definition_finding.rb
fhir_stu3_models-3.0.0 lib/fhir_stu3_models/fhir_ext/structure_definition_finding.rb