Sha256: 5dea04dc8ae5dd7e67cc51ae365186e3ed17fed0d2857c0f0274ed54f7f8ae69

Contents?: true

Size: 1.3 KB

Versions: 44

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

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

44 entries across 44 versions & 1 rubygems

Version Path
renalware-core-2.0.64 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.63 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.62 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.61 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.60 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.58 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.57 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.56 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.55 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.54 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.53 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.52 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.51 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.50 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.48 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.47 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.46 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.45 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.44 app/controllers/renalware/hd/protocols_controller.rb
renalware-core-2.0.43 app/controllers/renalware/hd/protocols_controller.rb