|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
3 | 3 | class VaccinationRecordsController < ApplicationController |
4 | | - include Pagy::Backend |
5 | 4 | include VaccinationMailerConcern |
6 | 5 |
|
7 | | - before_action :set_vaccination_record, except: :index |
| 6 | + before_action :set_vaccination_record |
8 | 7 | before_action :set_return_to, only: %i[confirm_destroy destroy] |
9 | 8 |
|
10 | | - def index |
11 | | - @pagy, @vaccination_records = pagy(vaccination_records) |
12 | | - |
13 | | - render layout: "full" |
14 | | - end |
15 | | - |
16 | 9 | def show |
17 | 10 | end |
18 | 11 |
|
@@ -48,31 +41,21 @@ def destroy |
48 | 41 |
|
49 | 42 | private |
50 | 43 |
|
51 | | - def programme |
52 | | - @programme ||= |
53 | | - policy_scope(Programme).find_by!(type: params[:programme_type]) |
54 | | - end |
55 | | - |
56 | | - def vaccination_records |
57 | | - @vaccination_records ||= |
58 | | - policy_scope(VaccinationRecord) |
59 | | - .includes( |
60 | | - :batch, |
61 | | - :immunisation_imports, |
62 | | - :location, |
63 | | - :performed_by_user, |
64 | | - :programme, |
65 | | - patient: [:gp_practice, :school, { parent_relationships: :parent }], |
66 | | - session: %i[session_dates], |
67 | | - vaccine: :programme |
68 | | - ) |
69 | | - .where(programme:) |
70 | | - .order(:performed_at) |
71 | | - end |
72 | | - |
73 | 44 | def set_vaccination_record |
74 | | - @vaccination_record = vaccination_records.find(params[:id]) |
| 45 | + @vaccination_record = |
| 46 | + policy_scope(VaccinationRecord).includes( |
| 47 | + :batch, |
| 48 | + :immunisation_imports, |
| 49 | + :location, |
| 50 | + :performed_by_user, |
| 51 | + :programme, |
| 52 | + patient: [:gp_practice, :school, { parent_relationships: :parent }], |
| 53 | + session: %i[session_dates], |
| 54 | + vaccine: :programme |
| 55 | + ).find(params[:id]) |
| 56 | + |
75 | 57 | @patient = @vaccination_record.patient |
| 58 | + @programme = @vaccination_record.programme |
76 | 59 | @session = @vaccination_record.session |
77 | 60 | end |
78 | 61 |
|
|
0 commit comments