renalware-core 2.0.153 → 2.0.155
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/renalware/components/navigation.js +0 -7
- data/app/assets/javascripts/renalware/components/sortable.js +3 -0
- data/app/assets/javascripts/renalware/core.js.erb +0 -2
- data/app/assets/javascripts/renalware/rollup_compiled.css +69147 -50289
- data/app/assets/javascripts/renalware/rollup_compiled.js +10 -14
- data/app/assets/stylesheets/renalware/base/_variables.scss +1 -0
- data/app/assets/stylesheets/renalware/lib/_foundation_and_overrides.scss +1 -620
- data/app/assets/stylesheets/renalware/lib/_select2-foundation5-overrides.scss +1 -1
- data/app/assets/stylesheets/renalware/modules/_medications.scss +9 -9
- data/app/assets/stylesheets/renalware/modules/_patients.scss +4 -0
- data/app/assets/stylesheets/renalware/modules/_users.scss +2 -1
- data/app/assets/stylesheets/renalware/partials/_forms.scss +11 -0
- data/app/assets/stylesheets/renalware/partials/_navigation.scss +15 -12
- data/app/assets/stylesheets/renalware/partials/_simple_form.scss +1 -1
- data/app/assets/stylesheets/renalware/partials/_tables.scss +15 -8
- data/app/assets/stylesheets/renalware/partials/_toggle.scss +0 -66
- data/app/assets/stylesheets/renalware/partials/_toggling.scss +18 -0
- data/app/assets/stylesheets/renalware/partials/_trix.scss +12 -0
- data/app/components/renalware/admissions/active_consult_alert_component.html.slim +4 -0
- data/app/components/renalware/admissions/active_consult_alert_component.rb +25 -0
- data/app/components/renalware/article_component.html.slim +5 -0
- data/app/components/renalware/article_component.rb +12 -0
- data/app/components/renalware/events/event_list_component.rb +6 -1
- data/app/components/renalware/medications/tabbed_prescriptions_list_component.html.slim +41 -0
- data/app/components/renalware/medications/tabbed_prescriptions_list_component.rb +47 -0
- data/app/components/renalware/patients/messages_component.html.slim +45 -0
- data/app/components/renalware/patients/messages_component.rb +52 -0
- data/app/components/renalware/pd/adequacy_results_component.html.slim +3 -5
- data/app/components/renalware/system/admin_menu_component.html.slim +3 -1
- data/app/components/renalware/users/last_signin_component.html.slim +3 -0
- data/app/components/renalware/users/last_signin_component.rb +23 -0
- data/app/controllers/renalware/admin/playgrounds_controller.rb +1 -1
- data/app/controllers/renalware/admin/users_controller.rb +1 -0
- data/app/controllers/renalware/drugs/drugs_controller.rb +4 -0
- data/app/controllers/renalware/hd/historical_profiles_controller.rb +1 -1
- data/app/controllers/renalware/medications/prescriptions_controller.rb +5 -2
- data/app/controllers/renalware/messaging/internal/messages_controller.rb +14 -5
- data/app/controllers/renalware/pathology/observation_descriptions_controller.rb +58 -0
- data/app/controllers/renalware/patients/mdms_controller.rb +104 -0
- data/app/controllers/renalware/system/view_metadata_controller.rb +61 -0
- data/app/controllers/renalware/users_controller.rb +25 -0
- data/app/helpers/renalware/drugs_helper.rb +6 -0
- data/app/helpers/renalware/layout_helper.rb +1 -1
- data/app/models/concerns/renalware/sortable.rb +49 -0
- data/app/models/renalware/accesses/patient.rb +2 -2
- data/app/models/renalware/accesses/plan.rb +1 -1
- data/app/models/renalware/admissions/request.rb +1 -0
- data/app/models/renalware/clinical/body_composition.rb +1 -1
- data/app/models/renalware/clinical/dry_weight.rb +1 -1
- data/app/models/renalware/clinics/clinic_visit.rb +5 -4
- data/app/models/renalware/feeds/files/create_feed_file.rb +1 -1
- data/app/models/renalware/hd/patient.rb +1 -1
- data/app/models/renalware/hd/preference_set.rb +1 -1
- data/app/models/renalware/hd/profile.rb +4 -4
- data/app/models/renalware/hd/schedule_definition.rb +1 -1
- data/app/models/renalware/hd/session.rb +2 -2
- data/app/models/renalware/hd/session_forms/batch_compile_pdfs.rb +1 -1
- data/app/models/renalware/hd/station.rb +2 -1
- data/app/models/renalware/letters/description.rb +2 -0
- data/app/models/renalware/letters/letter.rb +1 -1
- data/app/models/renalware/letters/part/prescriptions.rb +12 -3
- data/app/models/renalware/letters/pdf_letter_cache.rb +1 -1
- data/app/models/renalware/letters/printing/batch_compile_pdfs.rb +1 -1
- data/app/models/renalware/letters/recipient_params_processor.rb +1 -1
- data/app/models/renalware/medications/prescription.rb +0 -4
- data/app/models/renalware/messaging/internal/message_form.rb +1 -0
- data/app/models/renalware/messaging/internal/message_form_builder.rb +2 -1
- data/app/models/renalware/pathology/current_observations_for_descriptions_query.rb +3 -3
- data/app/models/renalware/pathology/measurement_unit.rb +13 -0
- data/app/models/renalware/pathology/observation_description.rb +23 -5
- data/app/models/renalware/pathology/observation_descriptions_by_code_query.rb +1 -1
- data/app/models/renalware/pathology/observation_requests_attributes_builder.rb +45 -5
- data/app/models/renalware/pathology/observations_within_date_range_query.rb +1 -1
- data/app/models/renalware/patient.rb +2 -2
- data/app/models/renalware/patients/bookmark.rb +2 -2
- data/app/models/renalware/patients/mdm_menu.rb +41 -0
- data/app/models/renalware/patients/mdm_patients_query.rb +1 -1
- data/app/models/renalware/patients/search_query.rb +1 -1
- data/app/models/renalware/patients/worry.rb +0 -1
- data/app/models/renalware/pd/mdm_patients_query.rb +1 -1
- data/app/models/renalware/problems/problem.rb +2 -1
- data/app/models/renalware/snippets/snippet_query.rb +1 -1
- data/app/models/renalware/surveys/question.rb +1 -2
- data/app/models/renalware/system/column_definition.rb +43 -0
- data/app/models/renalware/system/filter_definition.rb +29 -0
- data/app/models/renalware/system/update_user.rb +5 -0
- data/app/models/renalware/system/version.rb +11 -0
- data/app/models/renalware/system/view_metadata.rb +25 -0
- data/app/models/renalware/transplants/donation.rb +1 -1
- data/app/models/renalware/transplants/donor_followup.rb +0 -1
- data/app/models/renalware/transplants/failure_cause_description.rb +1 -1
- data/app/models/renalware/transplants/mdm_patients_query.rb +2 -2
- data/app/models/renalware/transplants/patient.rb +1 -1
- data/app/models/renalware/transplants/recipient_followup.rb +1 -3
- data/app/models/renalware/transplants/registration.rb +1 -3
- data/app/models/renalware/transplants/registrations/wait_list_query.rb +4 -4
- data/app/models/renalware/ukrdc/measurement_unit.rb +21 -0
- data/app/models/renalware/ukrdc/outgoing/rendering/lab_order.rb +30 -2
- data/app/models/renalware/ukrdc/paths.rb +1 -1
- data/app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb +1 -1
- data/app/models/renalware/ukrdc/treatment_timeline/remap_model_table_names_to_their_prepared_equivalents.rb +1 -1
- data/app/policies/application_policy.rb +1 -1
- data/app/policies/renalware/medications/prescription_policy.rb +35 -0
- data/app/policies/renalware/system/view_metadata_policy.rb +17 -0
- data/app/presenters/concerns/renalware/accountable_presentation.rb +33 -0
- data/app/presenters/renalware/clinics/visit_presenter.rb +11 -0
- data/app/presenters/renalware/events/event_presenter.rb +11 -0
- data/app/presenters/renalware/mdm_presenter.rb +11 -0
- data/app/presenters/renalware/pathology/results_presenter.rb +1 -2
- data/app/presenters/renalware/renal/clinical_summary_presenter.rb +9 -6
- data/app/views/renalware/admin/playgrounds/show.html.slim +2 -6
- data/app/views/renalware/admin/users/edit.html.slim +9 -0
- data/app/views/renalware/admin/users/index.html.slim +6 -0
- data/app/views/renalware/admissions/admissions/_filters.html.slim +8 -16
- data/app/views/renalware/clinical/allergies/_list.html.slim +3 -1
- data/app/views/renalware/dashboard/dashboards/show.html.slim +1 -0
- data/app/views/renalware/hd/protocols/_virology.html.slim +4 -5
- data/app/views/renalware/letters/letters/_form.html.slim +1 -1
- data/app/views/renalware/letters/parts/_prescriptions.html.slim +4 -0
- data/app/views/renalware/mdm/_prescriptions.html.slim +4 -13
- data/app/views/renalware/mdm/prescriptions/_table.html.slim +3 -1
- data/app/views/renalware/medications/prescriptions/_current_hd.html.slim +13 -0
- data/app/views/renalware/medications/prescriptions/_filter_form.html.slim +26 -13
- data/app/views/renalware/medications/prescriptions/_form.html.slim +3 -2
- data/app/views/renalware/medications/prescriptions/_options.html.slim +3 -3
- data/app/views/renalware/medications/prescriptions/_table.html.slim +5 -4
- data/app/views/renalware/medications/prescriptions/_tables.html.slim +13 -16
- data/app/views/renalware/medications/prescriptions/index.html.slim +5 -4
- data/app/views/renalware/messaging/internal/messages/_form.html.slim +3 -0
- data/app/views/renalware/messaging/internal/messages/index.html.slim +36 -0
- data/app/views/renalware/navigation/_mdms.html.slim +5 -0
- data/app/views/renalware/navigation/_renal.html.slim +1 -0
- data/app/views/renalware/navigation/{_super_admin.html.slim → _super_admin.html.slim.dead} +0 -0
- data/app/views/renalware/pathology/code_groups/edit.html.slim +5 -5
- data/app/views/renalware/pathology/code_groups/index.html.slim +4 -5
- data/app/views/renalware/pathology/code_groups/show.html.slim +25 -26
- data/app/views/renalware/pathology/observation_descriptions/_filters.html.slim +14 -0
- data/app/views/renalware/pathology/observation_descriptions/edit.html.slim +21 -0
- data/app/views/renalware/pathology/observation_descriptions/index.html.slim +38 -0
- data/app/views/renalware/pathology/requests/requests/request_form/_crs_form.html.slim +1 -1
- data/app/views/renalware/patients/alerts/_list.html.slim +1 -0
- data/app/views/renalware/patients/mdms/_filters.html.slim +38 -0
- data/app/views/renalware/patients/mdms/_table.html.slim +72 -0
- data/app/views/renalware/patients/mdms/show.html.slim +18 -0
- data/app/views/renalware/patients/side_menu/_general.html.slim +4 -0
- data/app/views/renalware/patients/worryboard/_filters.html.slim +18 -13
- data/app/views/renalware/pd/_peritonitis_episodes.html.slim +13 -13
- data/app/views/renalware/pd/adequacy_results/_form_fields.html.slim +1 -1
- data/app/views/renalware/pd/adequacy_results/_table.html.slim +2 -2
- data/app/views/renalware/pd/peritonitis_episodes/show.html.slim +8 -6
- data/app/views/renalware/shared/_fieldset.html.slim +1 -2
- data/app/views/renalware/shared/_magellan_block.html.slim +1 -2
- data/app/views/renalware/system/view_metadata/_columns_table.html.slim +44 -0
- data/app/views/renalware/system/view_metadata/_filters_form.html.slim +19 -0
- data/app/views/renalware/system/view_metadata/_versions.html.slim +23 -0
- data/app/views/renalware/system/view_metadata/edit.html.slim +66 -0
- data/app/views/renalware/transplants/mdm/_prescriptions.html.slim +6 -22
- data/app/views/renalware/users/_filters.html.slim +11 -0
- data/app/views/renalware/users/index.html.slim +24 -0
- data/config/initializers/core_extensions.rb +2 -2
- data/config/initializers/delayed_job.rb +1 -1
- data/config/initializers/inflections.rb +1 -0
- data/config/initializers/pagy.rb +5 -0
- data/config/locales/renalware/clinical/allergies.en.yml +1 -0
- data/config/locales/renalware/medications/tabbed_prescriptions_list_component.yml +15 -0
- data/config/locales/renalware/navigation/renal.en.yml +1 -0
- data/config/locales/renalware/patients/side_menu.en.yml +1 -0
- data/config/permissions.yml +1 -0
- data/config/routes.rb +1 -0
- data/config/routes/messaging.rb +9 -1
- data/config/routes/pathology.rb +1 -0
- data/config/routes/patients.rb +1 -0
- data/config/routes/system.rb +3 -0
- data/config/routes/users.rb +3 -0
- data/db/functions/convert_to_float_with_explicit_return_v01.sql +18 -0
- data/db/functions/update_current_observation_set_from_trigger_v05.sql +92 -0
- data/db/functions/update_pathology_observations_nresult_from_trigger_v01.sql +13 -0
- data/db/migrate/20200122182018_update_patient_current_modalities.rb +7 -0
- data/db/migrate/20200122182036_create_transplant_mdm_patients.rb +7 -0
- data/db/migrate/20200122190909_create_view_metadata.rb +44 -0
- data/db/migrate/20200131133223_create_hd_mdm_patients.rb +7 -0
- data/db/migrate/20200205185151_add_columns_to_system_view_metadata.rb +13 -0
- data/db/migrate/20200219113324_create_supportive_care_mdm_patients_view.rb +7 -0
- data/db/migrate/20200622120232_add_limits_to_path_obs_descriptions.rb +18 -0
- data/db/migrate/20200626081248_overload_convert_to_float_function.rb +13 -0
- data/db/migrate/20200626090256_add_nresult_to_pathology_observations.rb +29 -0
- data/db/migrate/20200628094228_add_prescriber_to_users.rb +14 -0
- data/db/migrate/20200812074223_add_public_flag_to_messages.rb +18 -0
- data/db/migrate/20200815150303_create_system_versions.rb +16 -0
- data/db/migrate/20200817085618_create_pd_mdm_patients.rb +7 -0
- data/db/migrate/20200817103930_create_low_clearance_mdm_patients.rb +7 -0
- data/db/migrate/20201001144512_update_fn_update_current_obs_set_triggerv05.rb +13 -0
- data/db/migrate/20201001145452_add_position_to_letter_descriptions.rb +5 -0
- data/db/migrate/20201009090959_make_drug_types_unique.rb +8 -0
- data/db/migrate/20201012160414_add_suggested_measurement_unit_to_pathology_observation_descriptions.rb +18 -0
- data/db/migrate/20201012171428_create_ukrdc_measurement_units.rb +18 -0
- data/db/migrate/20201015160542_add_position_to_drug_types.rb +31 -0
- data/db/migrate/20201020155510_add_bmi_to_clinic_visits.rb +28 -0
- data/db/migrate/20201020164524_update_pd_mdm_patients_view.rb +7 -0
- data/db/migrate/20201020170921_update_hd_mdm_patients_view.rb +7 -0
- data/db/migrate/20201020171139_update_low_clearance_mdm_patients_view.rb +7 -0
- data/db/migrate/20201021153832_update_supportive_care_mdm_patients_view.rb +7 -0
- data/db/migrate/20201021154809_update_transplant_mdm_patients_view.rb +7 -0
- data/db/migrate/20201023092859_remove_unused_indexes.rb +20 -0
- data/db/seeds/default/system/seeds.rb +1 -0
- data/db/seeds/default/system/view_metadata.rb +91 -0
- data/db/seeds/default/ukrdc/measurement_units.csv +12 -0
- data/db/seeds/default/ukrdc/measurement_units.rb +15 -0
- data/db/seeds/default/ukrdc/seeds.rb +1 -0
- data/db/triggers/update_pathology_observations_nresult_trigger_v01.sql +11 -0
- data/db/views/hd_mdm_patients_v01.sql +69 -0
- data/db/views/hd_mdm_patients_v02.sql +70 -0
- data/db/views/low_clearance_mdm_patients_v01.sql +38 -0
- data/db/views/low_clearance_mdm_patients_v02.sql +39 -0
- data/db/views/patient_current_modalities_v02.sql +18 -0
- data/db/views/pd_mdm_patients_v01.sql +42 -0
- data/db/views/pd_mdm_patients_v02.sql +43 -0
- data/db/views/supportive_care_mdm_patients_v01.sql +28 -0
- data/db/views/supportive_care_mdm_patients_v02.sql +29 -0
- data/db/views/transplant_mdm_patients_v01.sql +46 -0
- data/db/views/transplant_mdm_patients_v02.sql +47 -0
- data/lib/renalware/configuration.rb +2 -0
- data/lib/renalware/engine.rb +2 -2
- data/lib/renalware/version_number.rb +1 -1
- data/lib/tasks/db.rake +9 -0
- data/lib/tasks/pd.rake +28 -0
- data/spec/factories/drugs/drug_types.rb +5 -1
- data/spec/factories/messaging/internal/messages.rb +1 -0
- data/spec/factories/patients/practices.rb +1 -1
- data/spec/factories/patients/primary_care_physicians.rb +1 -1
- data/spec/factories/system/users.rb +1 -0
- data/spec/factories/system/view_metadata.rb +20 -0
- data/spec/support/capybara_helper.rb +2 -4
- data/spec/support/letters_spec_helper.rb +1 -1
- data/spec/support/matchers/validate_timeliness_of.rb +1 -1
- data/spec/support/pathology_spec_helper.rb +1 -2
- data/spec/support/policy_spec_helper.rb +12 -0
- data/vendor/assets/javascripts/foundation/foundation.alert.js +43 -0
- data/vendor/assets/javascripts/foundation/foundation.dropdown.js +468 -0
- data/vendor/assets/javascripts/foundation/foundation.js +727 -0
- data/vendor/assets/javascripts/foundation/foundation.reveal.js +522 -0
- data/vendor/assets/javascripts/foundation/foundation.tab.js +247 -0
- data/vendor/assets/javascripts/foundation/foundation.tooltip.js +348 -0
- data/vendor/assets/javascripts/foundation/foundation.topbar.js +458 -0
- data/vendor/assets/stylesheets/foundation/_functions.scss +156 -0
- data/vendor/assets/stylesheets/foundation/components/_alert-boxes.scss +128 -0
- data/vendor/assets/stylesheets/foundation/components/_buttons.scss +261 -0
- data/vendor/assets/stylesheets/foundation/components/_dropdown-buttons.scss +130 -0
- data/vendor/assets/stylesheets/foundation/components/_dropdown.scss +269 -0
- data/vendor/assets/stylesheets/foundation/components/_forms.scss +601 -0
- data/vendor/assets/stylesheets/foundation/components/_global.scss +566 -0
- data/vendor/assets/stylesheets/foundation/components/_grid.scss +292 -0
- data/vendor/assets/stylesheets/foundation/components/_labels.scss +106 -0
- data/vendor/assets/stylesheets/foundation/components/_pagination.scss +163 -0
- data/vendor/assets/stylesheets/foundation/components/_panels.scss +107 -0
- data/vendor/assets/stylesheets/foundation/components/_reveal.scss +212 -0
- data/vendor/assets/stylesheets/foundation/components/_side-nav.scss +120 -0
- data/vendor/assets/stylesheets/foundation/components/_split-buttons.scss +203 -0
- data/vendor/assets/stylesheets/foundation/components/_sub-nav.scss +125 -0
- data/vendor/assets/stylesheets/foundation/components/_tables.scss +135 -0
- data/vendor/assets/stylesheets/foundation/components/_tabs.scss +142 -0
- data/vendor/assets/stylesheets/foundation/components/_tooltips.scss +142 -0
- data/vendor/assets/stylesheets/foundation/components/_top-bar.scss +745 -0
- data/vendor/assets/stylesheets/foundation/components/_type.scss +525 -0
- data/vendor/assets/stylesheets/foundation/components/_visibility.scss +425 -0
- metadata +162 -64
- data/app/views/renalware/pd/infection_organisms/_edit.html.slim.obsolete +0 -16
- data/app/views/renalware/transplants/donor_operations/_sections_nav.html.slim +0 -11
- data/app/views/renalware/transplants/donor_workups/_sections_nav.html.slim +0 -15
- data/app/views/renalware/transplants/recipient_operations/_sections_nav.html.slim +0 -14
- data/app/views/renalware/transplants/recipient_workups/_sections_nav.html.slim +0 -15
- data/lib/core_extensions/active_record/sort.rb +0 -52
- data/spec/support/pages/accesses/procedure_page.rb +0 -53
- data/spec/support/pages/accesses/profile_page.rb +0 -45
- data/spec/support/pages/admissions/consults_page.rb +0 -26
- data/spec/support/pages/clinical/allergy_page.rb +0 -74
- data/spec/support/pages/clinical/profile_page.rb +0 -28
- data/spec/support/pages/hd/prescription_administration_dialog.rb +0 -132
- data/spec/support/pages/letters/form.rb +0 -63
- data/spec/support/pages/letters/mailshots/form.rb +0 -58
- data/spec/support/pages/letters/patient_letters.rb +0 -20
- data/spec/support/pages/low_clearance/profile_page.rb +0 -70
- data/spec/support/pages/medications/home_delivery_dialog.rb +0 -77
- data/spec/support/pages/medications/prescription_fom.rb +0 -62
- data/spec/support/pages/page_object.rb +0 -10
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_dependency "renalware"
|
4
|
+
|
5
|
+
# Note we rely on template inheritance with this MDM Base class i.e. subclasses (e.g.
|
6
|
+
# HD::MDMPatientsController) can override templates and partials (e.g. add a _filters partial
|
7
|
+
# or override the _patient partial to replace what is displayed in the table).
|
8
|
+
# Otherwise the default template location is of course app/views/renalware/mdm_patients.
|
9
|
+
module Renalware
|
10
|
+
class UsersController < BaseController
|
11
|
+
include Pagy::Backend
|
12
|
+
|
13
|
+
def index
|
14
|
+
query = params.fetch(:q, {})
|
15
|
+
query[:s] ||= "family_name"
|
16
|
+
search = User
|
17
|
+
.includes(:roles)
|
18
|
+
.where.not(username: [:rwdev, :systemuser])
|
19
|
+
.ransack(query)
|
20
|
+
pagy, users = pagy(search.result(distinct: true))
|
21
|
+
authorize users
|
22
|
+
render locals: { users: users, pagy: pagy, user_search: search }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -11,6 +11,12 @@ module Renalware
|
|
11
11
|
)
|
12
12
|
end
|
13
13
|
|
14
|
+
# Now that we have a drug_types.colour column e.g. '#aaa' we can use here.
|
15
|
+
# Where the drug belongs to 2 drug types, we need to be sure to choose the colour of the most
|
16
|
+
# clinically significant drug type - eg 'ESA' wins over 'My other drug type'.
|
17
|
+
# This should be done by ordering a drugs types and taking the one with the highest value
|
18
|
+
# in the #weighting column - i.e. ESA will have a a large value in this column to ensure it
|
19
|
+
# trumps other types and its colour is used.
|
14
20
|
def drug_types_colour_tag(drug_types)
|
15
21
|
drug_names = drug_types.map(&:name)
|
16
22
|
return "esa" if drug_names.include?("ESA")
|
@@ -59,7 +59,7 @@ module Renalware
|
|
59
59
|
# where Demographics is a link back in the navigation, like a true breadcrumb.
|
60
60
|
# :breadcrumbs can be anchors or just a page name, and is single does not need to be an array.
|
61
61
|
# :title is normally just a string as it represents the current page, and should not be a link.
|
62
|
-
def breadcrumbs_and_title(breadcrumbs: []
|
62
|
+
def breadcrumbs_and_title(title:, breadcrumbs: [])
|
63
63
|
safe_join(Array(breadcrumbs).map(&:anchor).append(title), " / ")
|
64
64
|
end
|
65
65
|
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Renalware
|
4
|
+
module Sortable
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
# Assumes that the model has the #position attribute and adds 2 features to a model that
|
8
|
+
# includes it:
|
9
|
+
# 1. Set the :position to the next highest value when a new row is added. If the model has a
|
10
|
+
# position_sorting_scope scope or class method, this is used to narrow the range of records
|
11
|
+
# searched when finding the current max position
|
12
|
+
# 2. Add ability to sort rows based on an array of ids.
|
13
|
+
|
14
|
+
included do
|
15
|
+
before_create :set_position
|
16
|
+
end
|
17
|
+
|
18
|
+
class_methods do
|
19
|
+
# A controller #sort action might for instance invoke this class method on an object.
|
20
|
+
# The array of ids are the model to sort, and sorting is done by updating each model's
|
21
|
+
# position to reflect their place in the array.
|
22
|
+
def sort(ids)
|
23
|
+
Array(ids).each_with_index do |id, index|
|
24
|
+
where(id: id).update_all(["position=?", index + 1])
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Invoked by the callback when a record is created to set the initial value of #position.
|
30
|
+
# If no position_sorting_scope is defined on the model class, we set position to the max
|
31
|
+
# position in the whole table. If position_sorting_scope is provided we use it to refine the
|
32
|
+
# grouping and hence the max(position) found - for example to get the max position where
|
33
|
+
# patient_id = 123
|
34
|
+
#
|
35
|
+
# Example scope in a model:
|
36
|
+
# scope :position_sorting_scope, ->(problem) { where(patient_id: problem.patient.id) }
|
37
|
+
#
|
38
|
+
def set_position
|
39
|
+
return unless respond_to?(:position)
|
40
|
+
|
41
|
+
scope = if self.class.respond_to?(:position_sorting_scope)
|
42
|
+
self.class.position_sorting_scope(self)
|
43
|
+
else
|
44
|
+
self.class
|
45
|
+
end
|
46
|
+
self.position = (scope.maximum(:position) || 0) + 1
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -19,7 +19,7 @@ module Renalware
|
|
19
19
|
end
|
20
20
|
|
21
21
|
scope :with_current_plan, lambda {
|
22
|
-
joins(<<-SQL)
|
22
|
+
joins(<<-SQL.squish)
|
23
23
|
left outer join access_plans on access_plans.patient_id = patients.id
|
24
24
|
and access_plans.terminated_at is null
|
25
25
|
left outer join access_plan_types
|
@@ -31,7 +31,7 @@ module Renalware
|
|
31
31
|
# needs to choose just one, otherwise queries that merge in this scope
|
32
32
|
# can have duplicates, or worse, broken pagination.
|
33
33
|
scope :with_profile, lambda {
|
34
|
-
joins(<<-SQL)
|
34
|
+
joins(<<-SQL.squish)
|
35
35
|
left outer join (
|
36
36
|
select distinct on (patient_id) * from access_profiles
|
37
37
|
where
|
@@ -9,7 +9,7 @@ module Renalware
|
|
9
9
|
|
10
10
|
belongs_to :patient, touch: true
|
11
11
|
belongs_to :plan_type
|
12
|
-
belongs_to :decided_by, class_name: "User"
|
12
|
+
belongs_to :decided_by, class_name: "User"
|
13
13
|
|
14
14
|
validates :plan_type, presence: true
|
15
15
|
validates :decided_by, presence: true
|
@@ -16,7 +16,7 @@ module Renalware
|
|
16
16
|
}
|
17
17
|
|
18
18
|
belongs_to :patient, class_name: "Renalware::Clinical::Patient", touch: true
|
19
|
-
belongs_to :assessor, class_name: "User"
|
19
|
+
belongs_to :assessor, class_name: "User"
|
20
20
|
belongs_to :modality_description, class_name: "Modalities::Description"
|
21
21
|
|
22
22
|
has_paper_trail(
|
@@ -10,7 +10,7 @@ module Renalware
|
|
10
10
|
include Accountable
|
11
11
|
|
12
12
|
belongs_to :patient, class_name: "Renalware::Clinical::Patient", touch: true
|
13
|
-
belongs_to :assessor, class_name: "User"
|
13
|
+
belongs_to :assessor, class_name: "User"
|
14
14
|
|
15
15
|
has_paper_trail(
|
16
16
|
versions: { class_name: "Renalware::Clinical::Version" },
|
@@ -39,10 +39,7 @@ module Renalware
|
|
39
39
|
|
40
40
|
before_save :calculate_body_surface_area
|
41
41
|
before_save :calculate_total_body_water
|
42
|
-
|
43
|
-
def bmi
|
44
|
-
BMI.new(weight: weight, height: height).to_f
|
45
|
-
end
|
42
|
+
before_save :calculate_bmi
|
46
43
|
|
47
44
|
def bp
|
48
45
|
return unless systolic_bp.present? && diastolic_bp.present?
|
@@ -92,6 +89,10 @@ module Renalware
|
|
92
89
|
sex: patient.sex
|
93
90
|
)
|
94
91
|
end
|
92
|
+
|
93
|
+
def calculate_bmi
|
94
|
+
self.bmi = BMI.new(weight: weight, height: height).to_f
|
95
|
+
end
|
95
96
|
end
|
96
97
|
end
|
97
98
|
end
|
@@ -34,7 +34,7 @@ module Renalware
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def uploads_dir
|
37
|
-
Rails.root.join("tmp
|
37
|
+
Rails.root.join("tmp/uploads").tap do |uploads_path|
|
38
38
|
warn "using upload path #{uploads_path}"
|
39
39
|
Dir.mkdir(uploads_path) unless Dir.exist?(uploads_path)
|
40
40
|
end
|
@@ -11,7 +11,7 @@ module Renalware
|
|
11
11
|
has_many :prescription_administrations
|
12
12
|
scope :with_profile, lambda {
|
13
13
|
includes(hd_profile: :hospital_unit)
|
14
|
-
.joins(<<-SQL)
|
14
|
+
.joins(<<-SQL.squish)
|
15
15
|
LEFT OUTER JOIN hd_profiles ON hd_profiles.patient_id = patients.id
|
16
16
|
LEFT OUTER JOIN hospital_units ON hd_profiles.hospital_unit_id = hospital_units.id
|
17
17
|
SQL
|
@@ -10,7 +10,7 @@ module Renalware
|
|
10
10
|
|
11
11
|
belongs_to :patient, touch: true
|
12
12
|
belongs_to :hospital_unit, class_name: "Hospitals::Unit"
|
13
|
-
belongs_to :schedule_definition
|
13
|
+
belongs_to :schedule_definition
|
14
14
|
|
15
15
|
has_paper_trail(
|
16
16
|
versions: { class_name: "Renalware::HD::Version" },
|
@@ -14,10 +14,10 @@ module Renalware
|
|
14
14
|
belongs_to :patient, touch: true
|
15
15
|
belongs_to :hospital_unit, class_name: "Hospitals::Unit"
|
16
16
|
belongs_to :dialysate
|
17
|
-
belongs_to :prescriber, class_name: "User"
|
18
|
-
belongs_to :named_nurse, class_name: "User"
|
19
|
-
belongs_to :transport_decider, class_name: "User"
|
20
|
-
belongs_to :schedule_definition
|
17
|
+
belongs_to :prescriber, class_name: "User"
|
18
|
+
belongs_to :named_nurse, class_name: "User"
|
19
|
+
belongs_to :transport_decider, class_name: "User"
|
20
|
+
belongs_to :schedule_definition
|
21
21
|
has_document class_name: "Renalware::HD::ProfileDocument"
|
22
22
|
|
23
23
|
has_paper_trail(
|
@@ -23,7 +23,7 @@ module Renalware
|
|
23
23
|
ABBREV_DAY_NAMES = %w(Mon Tue Wed Thu Fri Sat Sun).freeze
|
24
24
|
validates :days, presence: true
|
25
25
|
validates :diurnal_period_id, presence: true
|
26
|
-
belongs_to :diurnal_period, class_name: "DiurnalPeriodCode"
|
26
|
+
belongs_to :diurnal_period, class_name: "DiurnalPeriodCode"
|
27
27
|
scope :ordered, -> { order(days: :asc) }
|
28
28
|
|
29
29
|
# Render the schedule definition to a human friendly format e.g. "Mon, Wed, Fri AM"
|
@@ -24,8 +24,8 @@ module Renalware
|
|
24
24
|
belongs_to :modality_description, class_name: "Modalities::Description"
|
25
25
|
belongs_to :hospital_unit, class_name: "Hospitals::Unit"
|
26
26
|
belongs_to :dialysate
|
27
|
-
belongs_to :signed_on_by, class_name: "User"
|
28
|
-
belongs_to :signed_off_by, class_name: "User"
|
27
|
+
belongs_to :signed_on_by, class_name: "User"
|
28
|
+
belongs_to :signed_off_by, class_name: "User"
|
29
29
|
has_many :prescription_administrations,
|
30
30
|
class_name: "PrescriptionAdministration",
|
31
31
|
foreign_key: "hd_session_id",
|
@@ -6,7 +6,8 @@ module Renalware
|
|
6
6
|
module HD
|
7
7
|
class Station < ApplicationRecord
|
8
8
|
include Accountable
|
9
|
-
|
9
|
+
include Sortable
|
10
|
+
belongs_to :location, class_name: "HD::StationLocation"
|
10
11
|
validates :hospital_unit_id, presence: true
|
11
12
|
validates :name, uniqueness: { scope: :hospital_unit_id }
|
12
13
|
|
@@ -35,7 +35,7 @@ module Renalware
|
|
35
35
|
through: :electronic_receipts,
|
36
36
|
source: :recipient
|
37
37
|
has_one :signature, dependent: :destroy
|
38
|
-
has_one :archive,
|
38
|
+
has_one :archive, inverse_of: :letter
|
39
39
|
serialize :pathology_snapshot, Pathology::ObservationsJsonbSerializer
|
40
40
|
|
41
41
|
accepts_nested_attributes_for :main_recipient
|
@@ -22,12 +22,17 @@ module Renalware
|
|
22
22
|
def prescriptions
|
23
23
|
presenter_klass = ::Renalware::Medications::PrescriptionPresenter
|
24
24
|
::OpenStruct.new(
|
25
|
-
current: present(
|
25
|
+
current: present(current_non_hd, presenter_klass),
|
26
26
|
recently_changed: present(recently_changed_current_prescriptions, presenter_klass),
|
27
|
-
recently_stopped: present(recently_stopped_prescriptions, presenter_klass)
|
27
|
+
recently_stopped: present(recently_stopped_prescriptions, presenter_klass),
|
28
|
+
current_hd: present(current_hd, presenter_klass)
|
28
29
|
)
|
29
30
|
end
|
30
31
|
|
32
|
+
def current_non_hd
|
33
|
+
@current_non_hd ||= current_prescriptions.where.not(administer_on_hd: true)
|
34
|
+
end
|
35
|
+
|
31
36
|
def current_prescriptions
|
32
37
|
@current_prescriptions ||= patient_prescriptions.current
|
33
38
|
end
|
@@ -36,7 +41,7 @@ module Renalware
|
|
36
41
|
# Because we terminated a prescription if the dosage changes, and create a new one,
|
37
42
|
# we just need to search for prescriptions created in the last 14 days.
|
38
43
|
def recently_changed_current_prescriptions
|
39
|
-
@
|
44
|
+
@recently_changed_current_prescriptions ||= begin
|
40
45
|
current_prescriptions.prescribed_between(from: 14.days.ago, to: ::Time.zone.now)
|
41
46
|
end
|
42
47
|
end
|
@@ -51,6 +56,10 @@ module Renalware
|
|
51
56
|
end
|
52
57
|
end
|
53
58
|
|
59
|
+
def current_hd
|
60
|
+
@current_hd ||= current_prescriptions.where(administer_on_hd: true)
|
61
|
+
end
|
62
|
+
|
54
63
|
def patient_prescriptions
|
55
64
|
@patient_prescriptions ||= begin
|
56
65
|
@patient.prescriptions
|
@@ -43,7 +43,7 @@ module Renalware
|
|
43
43
|
attr_reader :batch, :dir, :user
|
44
44
|
|
45
45
|
def append_files
|
46
|
-
folder = Rails.root.join("tmp
|
46
|
+
folder = Rails.root.join("tmp/batched_letters")
|
47
47
|
FileUtils.mkdir_p folder
|
48
48
|
pdf_file = folder.join("#{batch.id}.pdf")
|
49
49
|
glob = Dir.glob(dir.join("*.pdf"))
|
@@ -17,6 +17,7 @@ module Renalware
|
|
17
17
|
attribute :urgent, Boolean, default: false
|
18
18
|
attribute :recipient_ids, Array, default: []
|
19
19
|
attribute :replying_to_message_id
|
20
|
+
attribute :public, Boolean, default: true
|
20
21
|
|
21
22
|
validates :body, presence: true
|
22
23
|
validates :subject, presence: true
|
@@ -42,17 +42,17 @@ module Renalware
|
|
42
42
|
# the same.
|
43
43
|
Observation
|
44
44
|
.includes(:description)
|
45
|
-
.select(<<-SQL)
|
45
|
+
.select(<<-SQL.squish)
|
46
46
|
DISTINCT ON (pathology_observation_descriptions.id)
|
47
47
|
pathology_observations.*,
|
48
48
|
pathology_observation_descriptions.code AS description_code,
|
49
49
|
pathology_observation_descriptions.name AS description_name
|
50
50
|
SQL
|
51
|
-
.joins(<<-SQL)
|
51
|
+
.joins(<<-SQL.squish)
|
52
52
|
LEFT JOIN pathology_observation_requests
|
53
53
|
ON pathology_observations.request_id = pathology_observation_requests.id
|
54
54
|
SQL
|
55
|
-
.joins(<<-SQL)
|
55
|
+
.joins(<<-SQL.squish)
|
56
56
|
RIGHT JOIN pathology_observation_descriptions
|
57
57
|
ON pathology_observations.description_id = pathology_observation_descriptions.id
|
58
58
|
SQL
|
@@ -7,6 +7,19 @@ module Renalware
|
|
7
7
|
class MeasurementUnit < ApplicationRecord
|
8
8
|
validates :name, presence: true
|
9
9
|
has_many :observation_descriptions, inverse_of: :measurement_unit
|
10
|
+
belongs_to :ukrdc_measurement_unit, class_name: "Renalware::UKRDC::MeasurementUnit"
|
11
|
+
|
12
|
+
def self.for_collection_select
|
13
|
+
order(:name).select(:id, :name, :description).map { |row| [row.title, row.id] }
|
14
|
+
end
|
15
|
+
|
16
|
+
# A friendly string containing name and description (if present) in parentheses
|
17
|
+
# e.g. "l (litres)"
|
18
|
+
def title
|
19
|
+
return name if description.blank? || name == description
|
20
|
+
|
21
|
+
"#{name} (#{description})"
|
22
|
+
end
|
10
23
|
end
|
11
24
|
end
|
12
25
|
end
|
@@ -6,15 +6,14 @@ module Renalware
|
|
6
6
|
module Pathology
|
7
7
|
class ObservationDescription < ApplicationRecord
|
8
8
|
belongs_to :measurement_unit
|
9
|
+
belongs_to :suggested_measurement_unit, class_name: "MeasurementUnit"
|
10
|
+
|
9
11
|
has_many :observations,
|
10
12
|
class_name: "Pathology::Observation",
|
11
13
|
inverse_of: :description,
|
12
14
|
dependent: :restrict_with_exception
|
13
|
-
has_many :code_group_memberships,
|
14
|
-
|
15
|
-
dependent: :destroy
|
16
|
-
has_many :code_groups,
|
17
|
-
through: :code_group_memberships
|
15
|
+
has_many :code_group_memberships, dependent: :destroy
|
16
|
+
has_many :code_groups, through: :code_group_memberships
|
18
17
|
|
19
18
|
scope :in_display_order, lambda {
|
20
19
|
where("display_group is not null and display_order is not null")
|
@@ -24,6 +23,10 @@ module Renalware
|
|
24
23
|
enum rr_type: { rr_type_simple: 0, rr_type_interpretation: 1 }
|
25
24
|
enum rr_coding_standard: { ukrr: 0, pv: 1 }
|
26
25
|
|
26
|
+
validates :lower_threshold, numericality: { allow_nil: true }
|
27
|
+
validates :upper_threshold, numericality: { allow_nil: true }
|
28
|
+
validate :lower_threshold_lteq_upper_threshold
|
29
|
+
|
27
30
|
def self.for(codes)
|
28
31
|
ObservationDescriptionsByCodeQuery.new(codes: codes).call
|
29
32
|
end
|
@@ -31,6 +34,21 @@ module Renalware
|
|
31
34
|
def to_s
|
32
35
|
code
|
33
36
|
end
|
37
|
+
|
38
|
+
def self.policy_class
|
39
|
+
BasePolicy
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def lower_threshold_lteq_upper_threshold
|
45
|
+
return if lower_threshold.blank?
|
46
|
+
return if upper_threshold.blank?
|
47
|
+
|
48
|
+
if lower_threshold.to_f >= upper_threshold.to_f
|
49
|
+
errors.add(:lower_threshold, "must be less than the upper threshold")
|
50
|
+
end
|
51
|
+
end
|
34
52
|
end
|
35
53
|
end
|
36
54
|
end
|