Sha256: 457dd2e1a561f45defcae9b06494abc1aa7a3f8253e034e6866cf2a9cd2128d4

Contents?: true

Size: 1.27 KB

Versions: 27

Compression:

Stored size: 1.27 KB

Contents

require_dependency "renalware/hd/base_controller"

module Renalware
  module HD
    class ProtocolsController < BaseController
      before_action :load_patient

      def show
        respond_to do |format|
          format.pdf {
            disposition = params.fetch("disposition", "inline")
            render_pdf(disposition)
          }
        end
      end

      private

      def render_pdf(disposition)
        render(
          pdf_options.merge(
            pdf: pdf_filename,
            disposition: disposition,
            print_media_type: true,
            locals: {
              protocol: ProtocolPresenter.new(patient, view_context)
            }
          )
        )
      end

      # Other options to consider:
      #  viewport_size: '1280x1024'
      #  disable_smart_shrinking: true
      def pdf_options
        {
          page_size: "A4",
          orientation: "Landscape",
          layout: "renalware/layouts/pdf",
          margin: { top: 10, bottom: 10, left: 10, right: 10 },
          footer: {
            font_size: 8
          },
          show_as_html: Rails.env.development? && params.key?("debug")
        }
      end

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

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
renalware-core-2.0.16 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.15 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.14 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.13 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.12 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.11 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.9 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.8 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.7 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.5 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.4 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.3 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.2 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.1 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.0 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.0.pre.rc13 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.0.pre.rc11 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.0.pre.rc10 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.0.pre.rc9 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.0.pre.rc8 app/controllers/renalware/hd/protocols_controller.rb