Class: Renalware::Admin::PlaygroundsController::Chart

Inherits:
Object
  • Object
show all
Defined in:
app/controllers/renalware/admin/playgrounds_controller.rb

Instance Method Summary collapse

Instance Method Details

#jsonObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'app/controllers/renalware/admin/playgrounds_controller.rb', line 49

def json
  return {} if form.patient_id.blank?

  ActiveRecord::Base.connection.execute(
    Arel.sql("      select\n        observed_on as x,\n        result as y\n        from renalware.pathology_chart_data(\#{form.patient_id},\n          '\#{form.obx_code}',\n          '\#{form.start_date}')\n    SQL\n  ).to_a.each_with_object({}) { |h, hash| hash[Date.parse(h[\"x\"])] = h[\"y\"] }\nend\n".squish)