> Don't know if I could get my head around what's going on here

:worried: well that's never a good sign. It might help to look at `config/clinic_exporter_formats.yml` to see what the data looks like. The general case (patients for example) always hit the `else` clause and outputs an array of `["Column Name", "Column Data for the given record"]`

The `if` clause just recurses down into an association. So for `procedures` it calls `PatientProcedure#procedure` which returns a `Procedure` object, then it sends that to `ClinicExporter#column` with the key / value pairs nested underneath in from `config/clinic_exporter_formats.yml`. Does that make sense? I tried explaining that in my comments above the method but perhaps I need to elaborate a bit more.

> Why are we using `try` instead of plain `public_send`? `try` would be needed only if we think there could be an error (a typo, for instance) in the config file, is that right?

I'm using `try` here so the export doesn't fail when an association is missing. For example with `PatientProcedure` records it's possible, but highly unlikely, that the associated `Procedure` record is missing. Rather than having the export script fail, I've opted to export a nil for those columns. This is probably not the best behavior. If there is a missing association that means something has gone wrong and I should investigate. However because of the nature of these clinics I'd rather get most of the data exported, and deal with the exceptions later.

> Isn't `is_a?` more readable than `===`?

"Readable" is very subjective, but I have a feeling most people would agree with you. Personally I prefer the `===` operator, but am not opposed to changing it.

> Maybe we could use something such as `column_name`? `key` seems a little cryptic for me in this context (but maybe it's just me not getting what's going on!)

The variable / method names in this class really suck. I was having a really, really hard time making it context specific. I kept key / value just because it was easier for me to keep things straight in my head :stuck_out_tongue_winking_eye: But I totally agree there is room for improvement here.