Sha256: 1c2b70e164c6df19cc712e604404d30f9209a68391e343aaa099dc17db207894
Contents?: true
Size: 1.21 KB
Versions: 15
Compression:
Stored size: 1.21 KB
Contents
require "renalware/letters/part" module Renalware module Letters class Part::ClinicalObservations < Part include Renalware::AttributeNameHelper OBSERVATION_ATTRS = %i(bp weight height bmi urine_blood urine_protein).freeze OBSERVATION_UNITS = { weight: :kg, height: :m }.freeze delegate(*OBSERVATION_ATTRS, to: :event) delegate :any?, to: :observations def each_observation observations.each do |arr| label, result, unit_of_measurement = arr yield(label, result, unit_of_measurement) end end def to_partial_path "renalware/letters/parts/clinical_observations" end private def observations OBSERVATION_ATTRS.each_with_object([]) do |observation, arr| value = send(observation) next if value.blank? arr << [ label_for(observation), enum_text_or_raw_value_for(value), OBSERVATION_UNITS[observation] ] end end def label_for(observation) attr_name(Renalware::Clinics::ClinicVisit, observation) end def enum_text_or_raw_value_for(value) value.try(:text) || value end end end end
Version data entries
15 entries across 15 versions & 1 rubygems