renalware-core 2.0.137 → 2.0.138
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/images/renalware/icons/home.svg +1 -0
- data/app/assets/images/renalware/icons/settings.svg +1 -0
- data/app/assets/javascripts/renalware/components/hd.js +0 -109
- data/app/assets/javascripts/renalware/components/toggler.js +0 -29
- data/app/assets/javascripts/renalware/core.js.erb +5 -1
- data/app/assets/javascripts/renalware/rollup_compiled.js +3888 -0
- data/app/assets/stylesheets/renalware/modules/_hd.scss +40 -17
- data/app/assets/stylesheets/renalware/partials/_dashboards.scss +1 -1
- data/app/assets/stylesheets/renalware/partials/_modal_window.scss +1 -0
- data/app/assets/stylesheets/renalware/partials/_navigation.scss +45 -2
- data/app/assets/stylesheets/renalware/partials/_pagination.scss +21 -0
- data/app/assets/stylesheets/renalware/partials/_tables.scss +9 -0
- data/app/assets/stylesheets/renalware/protocol_pdf.scss +45 -6
- data/app/components/renalware/application_component.rb +1 -1
- data/app/components/renalware/hd/administer_prescription_dropdown_component.html.slim +22 -0
- data/app/components/renalware/hd/administer_prescription_dropdown_component.rb +22 -0
- data/app/components/renalware/hd/prescription_last_administration_component.html.slim +6 -0
- data/app/components/renalware/hd/prescription_last_administration_component.rb +19 -0
- data/app/components/renalware/letters/letters_in_progress_component.html.slim +1 -1
- data/app/components/renalware/system/admin_menu_component.html.slim +25 -0
- data/app/components/renalware/system/admin_menu_component.rb +56 -0
- data/app/components/renalware/system/users_awaiting_approval_component.html.slim +6 -0
- data/app/components/renalware/system/users_awaiting_approval_component.rb +25 -0
- data/app/controllers/renalware/admin/dashboards_controller.rb +9 -0
- data/app/controllers/renalware/hd/base_controller.rb +4 -0
- data/app/controllers/renalware/hd/prescription_administrations_controller.rb +87 -0
- data/app/controllers/renalware/hd/sessions_controller.rb +6 -44
- data/app/controllers/renalware/hd/transmission_logs_controller.rb +7 -6
- data/app/controllers/renalware/hd/witnesses_controller.rb +62 -0
- data/app/helpers/renalware/application_helper.rb +1 -0
- data/app/helpers/renalware/layout_helper.rb +12 -0
- data/app/helpers/renalware/toggle_helper.rb +13 -4
- data/app/javascript/renalware/controllers/another_test_controller.js +8 -0
- data/app/javascript/renalware/controllers/hd/prescription_administration_controller.js +22 -0
- data/app/javascript/renalware/controllers/test_controller.js +8 -0
- data/app/javascript/renalware/controllers/toggle_controller.js +36 -0
- data/app/javascript/renalware/index.js +25 -0
- data/app/models/renalware/hd/patient.rb +1 -0
- data/app/models/renalware/hd/prescription_administration.rb +57 -33
- data/app/models/renalware/hd/prescription_last_administration_query.rb +29 -0
- data/app/models/renalware/hd/sessions/save_session.rb +1 -25
- data/app/models/renalware/hd/witness_form.rb +31 -0
- data/app/policies/renalware/hd/prescription_administration_policy.rb +8 -0
- data/app/presenters/renalware/admin/users/{summary_part.rb → summary_part.rb.dead} +0 -0
- data/app/presenters/renalware/hd/dashboard_presenter.rb +16 -7
- data/app/views/renalware/accesses/plans/_details.html.slim +1 -1
- data/app/views/renalware/admin/cache/show.html.slim +1 -1
- data/app/views/renalware/admin/dashboards/show.html.slim +4 -0
- data/app/views/renalware/admin/users/{_summary_part.html.slim → _summary_part.html.slim.dead} +1 -1
- data/app/views/renalware/admin/users/edit.html.slim +1 -1
- data/app/views/renalware/admin/users/index.html.slim +1 -1
- data/app/views/renalware/admissions/_summary_part.html.slim +5 -4
- data/app/views/renalware/admissions/consults/_summary_part.html.slim +7 -7
- data/app/views/renalware/dashboard/dashboards/_content.html.slim +5 -5
- data/app/views/renalware/drugs/drugs/edit.html.slim +2 -2
- data/app/views/renalware/drugs/drugs/index.html.slim +1 -1
- data/app/views/renalware/drugs/drugs/new.html.slim +1 -1
- data/app/views/renalware/events/types/edit.html.slim +1 -1
- data/app/views/renalware/events/types/index.html.slim +1 -1
- data/app/views/renalware/events/types/new.html.slim +1 -1
- data/app/views/renalware/hd/cannulation_types/edit.html.slim +1 -1
- data/app/views/renalware/hd/cannulation_types/index.html.slim +5 -5
- data/app/views/renalware/hd/cannulation_types/new.html.slim +1 -1
- data/app/views/renalware/hd/dashboards/_page_actions.html.slim +4 -1
- data/app/views/renalware/hd/dashboards/show.html.slim +1 -0
- data/app/views/renalware/hd/dialysates/edit.html.slim +1 -1
- data/app/views/renalware/hd/dialysates/index.html.slim +1 -1
- data/app/views/renalware/hd/dialysates/new.html.slim +1 -1
- data/app/views/renalware/hd/dialysers/edit.html.slim +1 -1
- data/app/views/renalware/hd/dialysers/index.html.slim +4 -5
- data/app/views/renalware/hd/dialysers/new.html.slim +1 -1
- data/app/views/renalware/hd/prescription_administrations/_form.html.slim +96 -0
- data/app/views/renalware/hd/prescription_administrations/_row.html.slim +25 -0
- data/app/views/renalware/hd/prescription_administrations/_table.html.slim +8 -0
- data/app/views/renalware/hd/prescription_administrations/_thead.html.slim +11 -0
- data/app/views/renalware/hd/prescription_administrations/create.js.erb +4 -0
- data/app/views/renalware/hd/prescription_administrations/edit.html.slim +5 -0
- data/app/views/renalware/hd/prescription_administrations/edit.js.erb +11 -0
- data/app/views/renalware/hd/prescription_administrations/index.html.slim +3 -0
- data/app/views/renalware/hd/prescription_administrations/new.html.slim +3 -0
- data/app/views/renalware/hd/prescription_administrations/new.js.erb +5 -0
- data/app/views/renalware/hd/protocols/_allergies.html.slim +3 -0
- data/app/views/renalware/hd/protocols/_latest_dry_weight.html.slim +3 -2
- data/app/views/renalware/hd/protocols/_prescriptions.html.slim +15 -7
- data/app/views/renalware/hd/protocols/_profile.html.slim +12 -12
- data/app/views/renalware/hd/protocols/_protocol.pdf.slim +2 -3
- data/app/views/renalware/hd/sessions/_form.html.slim +2 -6
- data/app/views/renalware/hd/sessions/_index_tabs.html.slim +11 -0
- data/app/views/renalware/hd/sessions/_list.html.slim +21 -1
- data/app/views/renalware/hd/sessions/_table.html.slim +1 -18
- data/app/views/renalware/hd/sessions/closed/_form.html.slim +1 -2
- data/app/views/renalware/hd/sessions/edit.html.slim +1 -2
- data/app/views/renalware/hd/sessions/new.html.slim +1 -2
- data/app/views/renalware/hd/sessions/open/_form.html.slim +1 -2
- data/app/views/renalware/hd/transmission_logs/index.html.slim +2 -2
- data/app/views/renalware/hd/witnesses/_form.html.slim +49 -0
- data/app/views/renalware/hd/witnesses/edit.html.slim +1 -0
- data/app/views/renalware/hd/witnesses/edit.js.erb +3 -0
- data/app/views/renalware/hd/witnesses/update.js.erb +4 -0
- data/app/views/renalware/layouts/_admin.html.slim +28 -0
- data/app/views/renalware/layouts/_patient.html.slim +1 -1
- data/app/views/renalware/letters/batches/index.html.slim +1 -1
- data/app/views/renalware/letters/letters/_letter.html.slim +1 -1
- data/app/views/renalware/modalities/descriptions/edit.html.slim +1 -1
- data/app/views/renalware/modalities/descriptions/index.html.slim +1 -1
- data/app/views/renalware/modalities/descriptions/new.html.slim +1 -1
- data/app/views/renalware/navigation/_admin.html.slim +1 -1
- data/app/views/renalware/navigation/_menu.html.slim +7 -6
- data/app/views/renalware/navigation/_user.html.slim +3 -4
- data/app/views/renalware/pathology/observation_requests/_filters.html.slim +1 -1
- data/app/views/renalware/pathology/requests/requests/index.html.slim +1 -1
- data/app/views/renalware/pathology/requests/rules/index.html.slim +1 -1
- data/app/views/renalware/patients/_layout.html.slim +1 -1
- data/app/views/renalware/patients/_summary_part.html.slim +1 -1
- data/app/views/renalware/patients/primary_care_physicians/edit.html.slim +1 -1
- data/app/views/renalware/patients/primary_care_physicians/index.html.slim +3 -5
- data/app/views/renalware/patients/primary_care_physicians/new.html.slim +1 -1
- data/app/views/renalware/pd/bag_types/edit.html.slim +1 -1
- data/app/views/renalware/pd/bag_types/index.html.slim +1 -1
- data/app/views/renalware/pd/bag_types/new.html.slim +1 -1
- data/app/views/renalware/problems/problems/_summary_part.html.slim +1 -1
- data/app/views/renalware/research/study_participants/index.html.slim +2 -3
- data/app/views/renalware/surveys/_pos_s_summary_part.html.slim +2 -1
- data/app/views/renalware/system/email_templates/index.html.slim +5 -1
- data/app/views/renalware/system/messages/edit.html.slim +1 -1
- data/app/views/renalware/system/messages/index.html.slim +1 -1
- data/app/views/renalware/system/messages/new.html.slim +1 -1
- data/app/views/renalware/system/user_feedback/edit.html.slim +1 -1
- data/app/views/renalware/system/user_feedback/index.html.slim +1 -1
- data/app/views/renalware/transplants/mdm/_bottom.html.slim +1 -1
- data/config/initializers/pagy.rb +9 -0
- data/config/locales/renalware/hd/dashboards.en.yml +1 -0
- data/config/locales/renalware/hd/session.en.yml +2 -1
- data/config/routes/admin.rb +1 -0
- data/config/routes/hd.rb +9 -0
- data/db/migrate/20190627141751_add_tokens_to_hd_prescription_administrations.rb +0 -2
- data/db/migrate/20200204153231_alter_hd_prescription_administrations.rb +18 -0
- data/db/seeds/default/accesses/access_pd_catheter_insertion_techniques.rb +0 -1
- data/db/seeds/default/accesses/access_plan_types.rb +0 -1
- data/db/seeds/default/accesses/access_sites.rb +0 -1
- data/db/seeds/default/clinics/clinics.rb +0 -1
- data/db/seeds/default/events/event_types.rb +0 -1
- data/db/seeds/default/hd/cannulation_types.rb +0 -1
- data/db/seeds/default/hd/dialysers.rb +0 -1
- data/db/seeds/default/modalities/reasons.rb +19 -19
- data/db/seeds/default/pathology/measurement_units.rb +0 -1
- data/db/seeds/default/patients/patients_ethnicities.rb +0 -1
- data/db/seeds/default/patients/patients_languages.rb +1 -0
- data/db/seeds/default/patients/patients_religions.rb +0 -1
- data/db/seeds/default/pd/bag_types.rb +0 -1
- data/db/seeds/default/pd/organisms.rb +0 -1
- data/db/seeds/default/pd/systems.rb +0 -1
- data/db/seeds/default/pd/training_sites.rb +0 -1
- data/db/seeds/default/pd/training_types.rb +0 -1
- data/db/seeds/default/practices/practices.rb +2 -2
- data/db/seeds/default/practices/primary_care_physicians.rb +1 -2
- data/db/seeds/default/renal/prd_descriptions.rb +1 -0
- data/db/seeds/default/system/roles.rb +1 -1
- data/lib/renalware/engine.rb +1 -0
- data/lib/renalware/version.rb +1 -1
- data/spec/factories/hd/prescription_administrations.rb +17 -0
- data/spec/support/factory_bot.rb +2 -0
- data/spec/support/pages/hd/prescription_administration_dialog.rb +132 -0
- metadata +62 -12
- data/app/assets/javascripts/renalware/components/bla.es6 +0 -1
- data/app/controllers/renalware/hd/prescription_administration_authorisations_controller.rb +0 -27
- data/app/javascript/controllers/clipboard_controller.js.dead +0 -16
- data/app/views/renalware/hd/sessions/_administered_drugs_row.html.slim +0 -27
- data/app/views/renalware/hd/sessions/_administered_drugs_thead.html.slim +0 -11
- data/app/views/renalware/hd/sessions/_prescription_administrations.html.slim +0 -20
- data/app/views/renalware/hd/sessions/closed/_administered_drugs_row.html.slim +0 -3
- data/app/views/renalware/hd/sessions/form/_drugs_to_be_administered.html.slim +0 -84
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Renalware
|
4
|
+
module System
|
5
|
+
# Experimental ActionView component
|
6
|
+
class AdminMenuComponent < ApplicationComponent
|
7
|
+
include Renalware::UsersHelper
|
8
|
+
attr_reader :current_user
|
9
|
+
|
10
|
+
def initialize(current_user:)
|
11
|
+
@current_user = current_user
|
12
|
+
end
|
13
|
+
|
14
|
+
def admin_menu_item(*args)
|
15
|
+
return unless
|
16
|
+
current_user_is_admin? ||
|
17
|
+
current_user_is_super_admin? ||
|
18
|
+
current_user_is_developer?
|
19
|
+
|
20
|
+
menu_item(*args)
|
21
|
+
end
|
22
|
+
|
23
|
+
def super_admin_menu_item(*args)
|
24
|
+
return unless current_user_is_super_admin? || current_user_is_developer?
|
25
|
+
|
26
|
+
menu_item(*args)
|
27
|
+
end
|
28
|
+
|
29
|
+
def developer_menu_item(*args)
|
30
|
+
return unless current_user_is_developer?
|
31
|
+
|
32
|
+
menu_item(*args)
|
33
|
+
end
|
34
|
+
|
35
|
+
def menu_item(title, path, active_when_controller_matches, enabled = true)
|
36
|
+
klasses = %w(link)
|
37
|
+
klasses << "active" if current_controller_matches(active_when_controller_matches)
|
38
|
+
content_tag :li, class: klasses.join(" ") do
|
39
|
+
if enabled
|
40
|
+
link_to(title, path)
|
41
|
+
else
|
42
|
+
content_tag :span, title
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def current_controller_matches(regex)
|
48
|
+
regex.match(params[:controller]).present?
|
49
|
+
end
|
50
|
+
|
51
|
+
def formatted_nhs_number(patient)
|
52
|
+
::Renalware::PatientPresenter.new(patient).nhs_number
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Renalware
|
4
|
+
module System
|
5
|
+
class UsersAwaitingApprovalComponent < ApplicationComponent
|
6
|
+
attr_reader :current_user
|
7
|
+
|
8
|
+
def initialize(current_user:)
|
9
|
+
@current_user = current_user
|
10
|
+
end
|
11
|
+
|
12
|
+
def users_needing_approval_count
|
13
|
+
@users_needing_approval_count ||= User.unapproved.count
|
14
|
+
end
|
15
|
+
|
16
|
+
def users_needing_approval_title
|
17
|
+
[
|
18
|
+
users_needing_approval_count,
|
19
|
+
"user".pluralize(users_needing_approval_count),
|
20
|
+
"awaiting approval"
|
21
|
+
].join(" ")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_dependency "renalware/hd/base_controller"
|
4
|
+
require "collection_presenter"
|
5
|
+
|
6
|
+
module Renalware
|
7
|
+
module HD
|
8
|
+
class PrescriptionAdministrationsController < BaseController
|
9
|
+
include Renalware::Concerns::Pageable
|
10
|
+
|
11
|
+
def index
|
12
|
+
hd_patient = HD.cast_patient(patient)
|
13
|
+
administrations = hd_patient
|
14
|
+
.prescription_administrations
|
15
|
+
.includes(:administered_by, :witnessed_by, :reason, :prescription)
|
16
|
+
.ordered
|
17
|
+
.page(page)
|
18
|
+
.per(per_page)
|
19
|
+
authorize administrations
|
20
|
+
render locals: { prescription_administrations: administrations }
|
21
|
+
end
|
22
|
+
|
23
|
+
# GET HTML
|
24
|
+
def new
|
25
|
+
administration = hd_patient.prescription_administrations.build(
|
26
|
+
prescription: prescription,
|
27
|
+
administered_by: current_user,
|
28
|
+
recorded_on: Date.current
|
29
|
+
)
|
30
|
+
render_new(administration)
|
31
|
+
end
|
32
|
+
|
33
|
+
# POST JS
|
34
|
+
# issues - user validation not working
|
35
|
+
def create
|
36
|
+
administration = hd_patient.prescription_administrations.build(
|
37
|
+
prescription_administration_parameters
|
38
|
+
)
|
39
|
+
clear_irrelevant_attributes_if_drug_was_not_administered(administration)
|
40
|
+
authorize administration
|
41
|
+
if administration.save_by(current_user)
|
42
|
+
# will render create.js
|
43
|
+
else
|
44
|
+
render_new(administration) # re-display dialog with errors
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def clear_irrelevant_attributes_if_drug_was_not_administered(administration)
|
51
|
+
unless administration.administered
|
52
|
+
administration.administered_by = nil
|
53
|
+
administration.witnessed_by = nil
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def prescription
|
58
|
+
@prescription ||= Medications::Prescription.find_by(
|
59
|
+
id: params[:prescription_id],
|
60
|
+
administer_on_hd: true
|
61
|
+
)
|
62
|
+
end
|
63
|
+
|
64
|
+
def hd_patient
|
65
|
+
HD.cast_patient(prescription.patient)
|
66
|
+
end
|
67
|
+
|
68
|
+
def render_new(administration)
|
69
|
+
authorize administration
|
70
|
+
render :new, locals: { prescription_administration: administration }, layout: false
|
71
|
+
end
|
72
|
+
|
73
|
+
def prescription_administration_parameters
|
74
|
+
params
|
75
|
+
.require(:hd_prescription_administration)
|
76
|
+
.permit(
|
77
|
+
[
|
78
|
+
:administered, :prescription_id, :notes, :reason_id,
|
79
|
+
:administered_by_id,
|
80
|
+
:witnessed_by_id, :administered_by_password, :witnessed_by_password,
|
81
|
+
:skip_witness_validation, :recorded_on
|
82
|
+
]
|
83
|
+
)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -5,7 +5,6 @@ require "collection_presenter"
|
|
5
5
|
|
6
6
|
module Renalware
|
7
7
|
module HD
|
8
|
-
# rubocop:disable Metrics/ClassLength
|
9
8
|
class SessionsController < BaseController
|
10
9
|
include PresenterHelper
|
11
10
|
include Renalware::Concerns::Pageable
|
@@ -16,24 +15,13 @@ module Renalware
|
|
16
15
|
query = sessions_query
|
17
16
|
sessions = query
|
18
17
|
.call
|
19
|
-
.eager_load(
|
20
|
-
:hospital_unit,
|
21
|
-
:patient,
|
22
|
-
:signed_on_by,
|
23
|
-
:signed_off_by,
|
24
|
-
prescription_administrations: [
|
25
|
-
{
|
26
|
-
prescription: [:medication_route, :drug]
|
27
|
-
},
|
28
|
-
:administered_by,
|
29
|
-
:reason
|
30
|
-
])
|
18
|
+
.eager_load(:hospital_unit, :patient, :signed_on_by, :signed_off_by)
|
31
19
|
.page(page)
|
32
20
|
.per(per_page || 15)
|
33
21
|
authorize sessions
|
34
22
|
presenter = CollectionPresenter.new(sessions, SessionPresenter, view_context)
|
35
23
|
@q = query.search
|
36
|
-
render :index, locals: { sessions: presenter }
|
24
|
+
render :index, locals: { patient: patient, sessions: presenter }
|
37
25
|
end
|
38
26
|
|
39
27
|
def show
|
@@ -57,14 +45,6 @@ module Renalware
|
|
57
45
|
|
58
46
|
def edit
|
59
47
|
session = Session.for_patient(patient).find(params[:id])
|
60
|
-
session.prescription_administrations.each do |a|
|
61
|
-
if a.administrator_authorised?
|
62
|
-
a.administrator_authorisation_token = a.administered_by&.auth_token
|
63
|
-
end
|
64
|
-
if a.witness_authorised?
|
65
|
-
a.witness_authorisation_token = a.witnessed_by&.auth_token
|
66
|
-
end
|
67
|
-
end
|
68
48
|
authorize session
|
69
49
|
render :edit, locals: locals(session)
|
70
50
|
rescue Pundit::NotAuthorizedError
|
@@ -110,18 +90,10 @@ module Renalware
|
|
110
90
|
def locals(session)
|
111
91
|
{
|
112
92
|
session: session,
|
113
|
-
patient: patient
|
114
|
-
prescriptions_to_be_administered_on_hd: prescriptions_on_hd
|
93
|
+
patient: patient
|
115
94
|
}
|
116
95
|
end
|
117
96
|
|
118
|
-
def prescriptions_on_hd
|
119
|
-
@prescriptions_on_hd ||= begin
|
120
|
-
prescriptions = patient.prescriptions.includes([:drug]).to_be_administered_on_hd
|
121
|
-
present(prescriptions, Medications::PrescriptionPresenter)
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
97
|
def sessions_query
|
126
98
|
Sessions::PatientQuery.new(patient: patient, q: params[:q])
|
127
99
|
end
|
@@ -129,13 +101,9 @@ module Renalware
|
|
129
101
|
def session_params
|
130
102
|
@session_params ||= begin
|
131
103
|
params.require(:hd_session).require(:type)
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
(sesh_params[:prescription_administrations_attributes] || {}).each do |_key, hash|
|
136
|
-
hash[:by] = current_user
|
137
|
-
end
|
138
|
-
sesh_params
|
104
|
+
params.require(:hd_session)
|
105
|
+
.permit(attributes)
|
106
|
+
.merge(document: document_attributes, by: current_user)
|
139
107
|
end
|
140
108
|
end
|
141
109
|
|
@@ -143,11 +111,6 @@ module Renalware
|
|
143
111
|
[:performed_on, :start_time, :end_time,
|
144
112
|
:hospital_unit_id, :notes, :dialysate_id,
|
145
113
|
:signed_on_by_id, :signed_off_by_id, :type,
|
146
|
-
prescription_administrations_attributes: [
|
147
|
-
:id, :hd_session_id, :prescription_id, :administered, :notes,
|
148
|
-
:administered_by_id, :administrator_authorisation_token,
|
149
|
-
:witnessed_by_id, :witness_authorisation_token, :reason_id
|
150
|
-
],
|
151
114
|
document: []]
|
152
115
|
end
|
153
116
|
|
@@ -162,6 +125,5 @@ module Renalware
|
|
162
125
|
Delayed::Job.enqueue UpdateRollingPatientStatisticsDjJob.new(patient.id)
|
163
126
|
end
|
164
127
|
end
|
165
|
-
# rubocop:enable Metrics/ClassLength
|
166
128
|
end
|
167
129
|
end
|
@@ -7,17 +7,18 @@ module Renalware
|
|
7
7
|
module HD
|
8
8
|
class TransmissionLogsController < BaseController
|
9
9
|
include PresenterHelper
|
10
|
-
include
|
10
|
+
include Pagy::Backend
|
11
11
|
|
12
12
|
# NB be sure not to select the payload as this will slow things down.
|
13
13
|
# The payload is loaded by clicking on a link in the table
|
14
14
|
def index
|
15
|
-
logs =
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
pagy, logs = pagy(
|
16
|
+
TransmissionLog
|
17
|
+
.order(created_at: :desc)
|
18
|
+
.select(TransmissionLog.attribute_names - [:payload])
|
19
|
+
)
|
19
20
|
authorize logs
|
20
|
-
render locals: { logs: logs }
|
21
|
+
render locals: { logs: logs, pagy: pagy }
|
21
22
|
end
|
22
23
|
|
23
24
|
def show
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_dependency "renalware/hd/base_controller"
|
4
|
+
require "collection_presenter"
|
5
|
+
|
6
|
+
module Renalware
|
7
|
+
module HD
|
8
|
+
# PrescriptionAdministration witnesses
|
9
|
+
class WitnessesController < BaseController
|
10
|
+
# GET HTML
|
11
|
+
def edit
|
12
|
+
form = WitnessForm.new(
|
13
|
+
prescription_administration_id: administration.id,
|
14
|
+
user_id: administration.witnessed_by_id
|
15
|
+
)
|
16
|
+
render_edit(form)
|
17
|
+
end
|
18
|
+
|
19
|
+
# PATCH JS
|
20
|
+
def update
|
21
|
+
form = WitnessForm.new(
|
22
|
+
form_params.merge(prescription_administration_id: administration.id)
|
23
|
+
)
|
24
|
+
|
25
|
+
administration.skip_administrator_validation = true
|
26
|
+
administration.skip_witness_validation = true if form.update_user_only
|
27
|
+
if update_administration_from(form)
|
28
|
+
# will render update.js
|
29
|
+
else
|
30
|
+
render_edit(form) # re-display dialog with errors
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def update_administration_from(form)
|
37
|
+
return unless form.valid?
|
38
|
+
|
39
|
+
administration.witnessed_by_id = form.user_id
|
40
|
+
administration.witnessed_by_password = form.password
|
41
|
+
unless form.update_user_only
|
42
|
+
administration.witness_authorised = true
|
43
|
+
end
|
44
|
+
administration.save_by(current_user)
|
45
|
+
end
|
46
|
+
|
47
|
+
def administration
|
48
|
+
@administration ||= PrescriptionAdministration
|
49
|
+
.find(params[:prescription_administration_id])
|
50
|
+
.tap { |administration| authorize administration }
|
51
|
+
end
|
52
|
+
|
53
|
+
def render_edit(form)
|
54
|
+
render :edit, locals: { form: form, administration: administration }, layout: false
|
55
|
+
end
|
56
|
+
|
57
|
+
def form_params
|
58
|
+
params.require(:form).permit(:user_id, :password, :update_user_only)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -16,6 +16,18 @@ module Renalware
|
|
16
16
|
**opts) { yield }
|
17
17
|
end
|
18
18
|
|
19
|
+
def within_non_patient_layout
|
20
|
+
within_layout(layout: "renalware/layouts/non_patient",
|
21
|
+
title: opts.fetch(:page_title, title),
|
22
|
+
**opts) { yield }
|
23
|
+
end
|
24
|
+
|
25
|
+
def within_new_admin_layout(title: nil, **opts)
|
26
|
+
within_layout(layout: "renalware/layouts/admin",
|
27
|
+
title: opts.fetch(:page_title, title),
|
28
|
+
**opts) { yield }
|
29
|
+
end
|
30
|
+
|
19
31
|
def within_layout(layout:, title: nil, **opts)
|
20
32
|
title ||= t?(".page_title") ? t(".page_title") : t(".title", cascade: false)
|
21
33
|
opts[:title] = title
|
@@ -9,6 +9,7 @@ module Renalware
|
|
9
9
|
data: { behaviour: "css-toggler" }
|
10
10
|
end
|
11
11
|
|
12
|
+
# Non-stimulus implemention for adding a link to toggle open all an adjacent row
|
12
13
|
def toggler(row_selector, link_title: "Toggle")
|
13
14
|
link_to(
|
14
15
|
row_selector,
|
@@ -20,6 +21,7 @@ module Renalware
|
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
24
|
+
# Non-stimulus implemention for adding a link to toggle open all togglebale rows in the table
|
23
25
|
def table_toggler(link_title: "Toggle all rows")
|
24
26
|
link_to(
|
25
27
|
"#",
|
@@ -43,11 +45,15 @@ module Renalware
|
|
43
45
|
end
|
44
46
|
end
|
45
47
|
|
46
|
-
# Create a link in a thead > tr > th that will toggle the last row in all tbodies in the table
|
48
|
+
# Create a link in a thead > tr > th that will toggle the last row in all tbodies in the table,
|
49
|
+
# where the table contains multiple tbodies and the last row in each is the one that
|
50
|
+
# a user can toggle open/closed (to see extended detail for instance).
|
51
|
+
# Works in conjunction with the stimulus ToggleController.
|
52
|
+
# The enclosing html table must have data-controller="toggle" attribute.
|
47
53
|
def rows_toggler(link_title: "Toggle all rows")
|
48
54
|
link_to(
|
49
55
|
"#",
|
50
|
-
data: { action: "
|
56
|
+
data: { action: "toggle#table" },
|
51
57
|
class: "toggler",
|
52
58
|
title: link_title
|
53
59
|
) do
|
@@ -56,11 +62,14 @@ module Renalware
|
|
56
62
|
end
|
57
63
|
|
58
64
|
# Create a link to be used in a tbody > tr > td that will toggle the last row in the current
|
59
|
-
# tbody
|
65
|
+
# tbody, where the table contains multiple tbodies and the last row in each is the one that
|
66
|
+
# a user can toggle open/closed (to see extended detail for instance).
|
67
|
+
# Works in conjunction with the stimulus ToggleController.
|
68
|
+
# The enclosing html table must have data-controller="toggle" attribute.
|
60
69
|
def row_toggler(link_title: "Toggle")
|
61
70
|
link_to(
|
62
71
|
"#",
|
63
|
-
data: { action: "row
|
72
|
+
data: { action: "click->toggle#row" },
|
64
73
|
class: "toggler",
|
65
74
|
title: link_title
|
66
75
|
) do
|