Class: Renalware::Pathology::Requests::RequestsController

Inherits:
BaseController show all
Includes:
Concerns::Pageable
Defined in:
app/controllers/renalware/pathology/requests/requests_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#patient

Instance Method Details

#createObject

PDF POST Displays multiple PDFs



52
53
54
55
56
57
58
59
60
61
62
# File 'app/controllers/renalware/pathology/requests/requests_controller.rb', line 52

def create
  requests.each(&:print_form)

  render(
    pdf: "create",
    page_size: "A4",
    layout: "renalware/layouts/pdf",
    locals: local_vars,
    extra: "--no-print-media-type" # NOTE: Foundation CSS does not work well in print mode
  )
end

#indexObject



13
14
15
16
17
18
19
# File 'app/controllers/renalware/pathology/requests/requests_controller.rb', line 13

def index
  requests_query = RequestQuery.new(query_params)
  requests = requests_query.call.page(page).per(per_page)
  authorize requests

  render :index, locals: { requests: requests, query: requests_query.search }
end

#newObject

HTML POST NOTE: This needs to be POST since params may exceed url char limit in GET



39
40
41
42
43
44
45
46
47
48
# File 'app/controllers/renalware/pathology/requests/requests_controller.rb', line 39

def new
  render(
    :new,
    locals: local_vars.merge(
      all_clinics: Renalware::Pathology::Clinic.for_algorithm,
      all_consultants: Renalware::Renal::Consultant.ordered,
      all_templates: Renalware::Pathology::Requests::Request::TEMPLATES
    )
  )
end

#showObject

Displays an historical PDF



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/renalware/pathology/requests/requests_controller.rb', line 22

def show
  request = RequestPresenter.new(
    Request.find(params[:id])
  )
  authorize request
  render(
    pdf: "show",
    page_size: "A4",
    layout: "renalware/layouts/pdf",
    locals: { request: request },
    show_as_html: params.key?(:debug),
    extra: "--no-print-media-type" # NOTE: Foundation CSS does not work well in print mode
  )
end