Sha256: fe199e9e05945364ac21987d5cbecc1a7501f54e4415072235758612f0e013e9

Contents?: true

Size: 1.31 KB

Versions: 54

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

require_dependency "renalware/hd/base_controller"

module Renalware
  module HD
    # Responsible for rendering an HD Session Form PDF (aka Protocol) which has the patients
    # past 3 sessions on it, and empty rows for their next three sessions.
    class ProtocolsController < BaseController
      # Note that although rendering an individual PDF for a patient here, we use PdfRender
      # which can handles multiple patients, and hence it uses the index.pdf.slim view.
      # The show view is not used.
      def show
        authorize Session, :show?
        respond_to do |format|
          format.html { render html: pdf_renderer.call }
          format.pdf { send_pdf_data_as_inline_file }
        end
      end

      private

      def send_pdf_data_as_inline_file
        send_data(
          pdf_renderer.call,
          filename: pdf_filename,
          type: "application/pdf",
          disposition: "inline"
        )
      end

      def pdf_renderer
        @pdf_renderer ||= begin
          SessionForms::PdfRenderer.new(
            patients: patient,
            output_html_for_debugging: params.key?(:debug)
          )
        end
      end

      def pdf_filename
        "#{patient.family_name}-#{patient.hospital_identifier.id}-protocol".upcase + ".pdf"
      end
    end
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
renalware-core-2.1.1 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.1.0 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.167 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.166 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.165 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.164 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.163 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.162 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.161 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.160 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.159 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.158 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.157 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.156 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.155 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.153 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.152 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.151 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.149 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.148 app/controllers/renalware/hd/protocols_controller.rb