Sha256: c17897936ae4e50fb4db1421d2148f6a5e5b25de4e6d273214d69c1bcc1f6c24

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

require 'mustache'
class QdmPatient < Mustache
  include Qrda::Export::Helper::PatientViewHelper

  self.template_path = __dir__

  def initialize(patient, include_style)
    @include_style = include_style
    @patient = patient
    @qdmPatient = patient.qdmPatient
  end

  def include_style?
    @include_style
  end

  def data_elements
    de_hash = {}
    @qdmPatient.dataElements.each do |data_element|
      de_hash[data_element._type] ? de_hash[data_element._type].element_list << data_element : de_hash[data_element._type] = { title: data_element._type, element_list: [data_element] }
    end
    JSON.parse(de_hash.values.to_json)
  end

  def unit_string
    "#{self['value']} #{self['unit']}"
  end

  def code_code_system_string
    "#{self['code']} (#{self['codeSystem']})"
  end

  def result_string
    return unit_string if self['unit']
    return code_code_system_string if self['code']

    ''
  end

  def facility_string
    "#{self['code']['code']} (#{self['code']['codeSystem']})"
  end

  def end_time?
    self['high'] && DateTime.parse(self['high']).year < 3000
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cqm-reports-1.0.0.0 lib/html-export/qdm-patient/qdm_patient.rb