class HL7::Exporter::Csv

Attributes

template[RW]

Public Instance Methods

export() click to toggle source
# File lib/hl7/exporter/csv.rb, line 5
def export
  template % data
end

Private Instance Methods

data() click to toggle source
# File lib/hl7/exporter/csv.rb, line 54
def data
  {
    sending_facility: sending_facility,
    patient_name: patient.name,
    patient_dob:  getDate(patient.dob),
    nick_name:  patient.nick_name,
    sex: patient.sex,
    test_results: test_results,
  }
end
default_template() click to toggle source
# File lib/hl7/exporter/csv.rb, line 14
    def default_template
%[Sending Facility: %{sending_facility}
Name: %{patient_name}
DOB: %{patient_dob}
Nick: %{nick_name}
Sex: %{sex}
test, result, flag, units, reference interval
%{test_results}
]
    end
getDate(date) click to toggle source
# File lib/hl7/exporter/csv.rb, line 30
def getDate(date)
  Date.parse(date).strftime("%Y/%m/%d")
end
obr_row_template(observation) click to toggle source
# File lib/hl7/exporter/csv.rb, line 25
def obr_row_template(observation)
  "#{observation.name}, #{observation.result}, #{observation.flags}, " +
  "#{observation.units}, #{observation.reference_range}"
end
observation_row(obr) click to toggle source
# File lib/hl7/exporter/csv.rb, line 45
def observation_row(obr)
  observation = HL7::Exporter::Observation.new(obr)
  obr_row_template(observation)
end
patient() click to toggle source
# File lib/hl7/exporter/csv.rb, line 50
def patient
  @patient ||= HL7::Exporter::Patient.new(message[:PID])
end
sending_facility() click to toggle source
# File lib/hl7/exporter/csv.rb, line 34
def sending_facility
  return '' unless message[:MSH]
  message[:MSH].sending_facility || ''
end
test_results() click to toggle source
# File lib/hl7/exporter/csv.rb, line 39
def test_results
  message[:OBR].children.map{ |obr|
    observation_row(obr)
  }.join("\n")
end