Module: HealthDataStandards::Export::CommaSV
Instance Method Summary collapse
-
#export(patient, header) ⇒ Object
Builds a CSV row representing the patient.
- #extract_patient_data(patient) ⇒ Object
- #generate_header ⇒ Object
Instance Method Details
#export(patient, header) ⇒ Object
Builds a CSV row representing the patient.
7 8 9 10 11 12 13 |
# File 'lib/health-data-standards/export/csv.rb', line 7 def export(patient,header) csv = header ? [generate_header,extract_patient_data(patient)] : extract_patient_data(patient) end |
#extract_patient_data(patient) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/health-data-standards/export/csv.rb', line 19 def extract_patient_data(patient) race = '' ethnicity = '' race = patient.race['name'] || patient.race if !patient.race.nil? ethnicity = patient.ethnicity['name'] || patient.ethnicity if !patient.ethnicity.nil? [patient.patient_id, patient.first, patient.last, patient.gender, race, ethnicity, Time.at(patient.birthdate).strftime('%m/%d/%Y')] end |
#generate_header ⇒ Object
15 16 17 |
# File 'lib/health-data-standards/export/csv.rb', line 15 def generate_header ["patient_id", "first name", "last name", "gender","race","ethnicity","birthdate"] end |