<commit_before>module HealthDataStandards
  module Export
    module CommaSV
      # Builds a CSV row representing the patient.
      #
      # @return csv representation of patient data
      def export(patient,header)
      
       
        csv = header ? [generate_header,extract_patient_data(patient)] : extract_patient_data(patient)           
      
       
      end
      
      def generate_header
        ["patient_id", "first name", "last name", "gender","race","ethnicity","birthdate"]
      end
      
      def extract_patient_data(patient)
       [patient.patient_id, patient.first, patient.last, patient.gender,patient.race,patient.ethnicity,Time.at(patient.birthdate).strftime('%m/%d/%Y')]
      end

      extend self
    
    end
  end
end<commit_msg>Fixing patient csv export to output race and ethnicity correctly<commit_after>module HealthDataStandards
  module Export
    module CommaSV
      # Builds a CSV row representing the patient.
      #
      # @return csv representation of patient data
      def export(patient,header)
      
       
        csv = header ? [generate_header,extract_patient_data(patient)] : extract_patient_data(patient)           
      
       
      end
      
      def generate_header
        ["patient_id", "first name", "last name", "gender","race","ethnicity","birthdate"]
      end
      
      def extract_patient_data(patient)
        race = patient.race['name'] || patient.race
        ethnicity = patient.ethnicity['name'] || patient.ethnicity
       [patient.patient_id, patient.first, patient.last, patient.gender, race, ethnicity, Time.at(patient.birthdate).strftime('%m/%d/%Y')]
      end

      extend self
    
    end
  end
end
{'fraction_non_alphanumeric': 0.09546258102533883, 'fraction_numerical': 0.0, 'mean_word_length': 2.5301455301455302, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1871840', 'n_tokens_mistral': 494, 'n_tokens_neox': 470, 'n_words': 111}