diff --git a/lib/cypress/expected_results_calculator.rb b/lib/cypress/expected_results_calculator.rb index 8e6eae7f..95e75da3 100644 --- a/lib/cypress/expected_results_calculator.rb +++ b/lib/cypress/expected_results_calculator.rb @@ -26,10 +26,27 @@ def initialize(patients, correlation_id, effective_date, start_date, sub_id = ni def add_patient_to_sup_map(ps_map, patient) patient_id = patient.id.to_s ps_map[patient_id] = {} - ps_map[patient_id]['SEX'] = patient.qdmPatient.get_data_elements('patient_characteristic', 'gender')[0].dataElementCodes[0].code - ps_map[patient_id]['RACE'] = patient.qdmPatient.get_data_elements('patient_characteristic', 'race')[0].dataElementCodes[0].code - ps_map[patient_id]['ETHNICITY'] = patient.qdmPatient.get_data_elements('patient_characteristic', 'ethnicity')[0].dataElementCodes[0].code - ps_map[patient_id]['PAYER'] = patient.qdmPatient.get_data_elements('patient_characteristic', 'payer')[0].dataElementCodes[0].code + + gender = patient.qdmPatient.get_data_elements('patient_characteristic', 'gender')[0] + if (gender != nil) + ps_map[patient_id]['SEX'] = gender.dataElementCodes[0].code + end + + race = patient.qdmPatient.get_data_elements('patient_characteristic', 'race')[0] + if (race != nil) + ps_map[patient_id]['RACE'] = race.dataElementCodes[0].code + end + + ethnicity = patient.qdmPatient.get_data_elements('patient_characteristic', 'ethnicity')[0] + if (ethnicity != nil) + ps_map[patient_id]['ETHNICITY'] = ethnicity.dataElementCodes[0].code + end + + payer = patient.qdmPatient.get_data_elements('patient_characteristic', 'payer')[0] + if (payer != nil) + ps_map[patient_id]['PAYER'] = payer.dataElementCodes[0].code + end + end def prepopulate_measure_result_hash(measure)