renalware-core 2.0.0.pre.beta9 → 2.0.0.pre.beta10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/app/assets/javascripts/renalware/application.js.erb +2 -0
- data/app/assets/javascripts/renalware/dialogs.js.erb +17 -1
- data/app/assets/javascripts/renalware/patient_ajax_search.js +48 -0
- data/app/assets/javascripts/renalware/research.js +18 -0
- data/app/assets/stylesheets/renalware/application.scss +1 -0
- data/app/assets/stylesheets/renalware/base/_variables.scss +13 -0
- data/app/assets/stylesheets/renalware/hd_diary_pdf.scss +57 -0
- data/app/assets/stylesheets/renalware/lib/_foundation_and_overrides.scss +18 -0
- data/app/assets/stylesheets/renalware/modules/_admissions.scss +26 -0
- data/app/assets/stylesheets/renalware/modules/_hd.scss +203 -0
- data/app/assets/stylesheets/renalware/modules/_renal.scss +30 -0
- data/app/assets/stylesheets/renalware/partials/_animation.scss +8 -0
- data/app/assets/stylesheets/renalware/partials/_layout.scss +11 -0
- data/app/assets/stylesheets/renalware/partials/_tables.scss +12 -2
- data/app/assets/stylesheets/renalware/partials/_tabs.scss +45 -0
- data/app/controllers/renalware/admin/users_controller.rb +5 -4
- data/app/controllers/renalware/admissions/consults_controller.rb +88 -0
- data/app/controllers/renalware/clinical/body_compositions_controller.rb +1 -1
- data/app/controllers/renalware/concerns/pageable.rb +1 -1
- data/app/controllers/renalware/hd/current_profile_controller.rb +1 -1
- data/app/controllers/renalware/hd/diaries_controller.rb +87 -0
- data/app/controllers/renalware/hd/diary_slots_controller.rb +172 -0
- data/app/controllers/renalware/hd/patients_controller.rb +43 -0
- data/app/controllers/renalware/hd/preference_sets_controller.rb +4 -1
- data/app/controllers/renalware/hd/sessions_controller.rb +1 -1
- data/app/controllers/renalware/hd/stations_controller.rb +1 -1
- data/app/controllers/renalware/hospitals/units_controller.rb +1 -2
- data/app/controllers/renalware/hospitals/wards_controller.rb +18 -0
- data/app/controllers/renalware/renal/registry_preflight_checks_controller.rb +44 -0
- data/app/controllers/renalware/reporting/audits_controller.rb +4 -8
- data/app/controllers/renalware/research/studies_controller.rb +70 -0
- data/app/controllers/renalware/research/study_participants_controller.rb +85 -0
- data/app/documents/renalware/hd/profile_document.rb +0 -1
- data/app/documents/renalware/hd/session_document.rb +0 -1
- data/app/helpers/renalware/application_helper.rb +5 -1
- data/app/helpers/renalware/dropdown_button_helper.rb +4 -4
- data/app/helpers/renalware/form_helper.rb +8 -0
- data/app/inputs/select_container_input.rb +15 -0
- data/app/models/concerns/renalware/accountable.rb +5 -0
- data/app/models/concerns/renalware/patients_ransack_helper.rb +6 -6
- data/app/models/renalware/admissions/consult.rb +25 -0
- data/app/models/renalware/admissions/consult_query.rb +21 -0
- data/app/models/renalware/clinical/modality_description.rb +1 -0
- data/app/models/renalware/hd/archive_yesterdays_slots_job.rb +68 -0
- data/app/models/renalware/hd/dialysate.rb +16 -0
- data/app/models/renalware/hd/diary.rb +39 -0
- data/app/models/renalware/hd/diary_slot.rb +80 -0
- data/app/models/renalware/hd/diurnal_period_code.rb +5 -0
- data/app/models/renalware/hd/find_or_create_diary_by_week_query.rb +48 -0
- data/app/models/renalware/hd/find_or_create_master_diary.rb +24 -0
- data/app/models/renalware/hd/master_diary.rb +31 -0
- data/app/models/renalware/hd/patient_listener.rb +1 -1
- data/app/models/renalware/hd/patients_dialysing_by_day_and_period_query.rb +39 -0
- data/app/models/renalware/hd/patients_dialysing_by_day_query.rb +32 -0
- data/app/models/renalware/hd/patients_dialysing_by_schedule_query.rb +26 -0
- data/app/models/renalware/hd/patients_with_unmet_preferences_query.rb +2 -2
- data/app/models/renalware/hd/preference_set.rb +2 -2
- data/app/models/renalware/hd/profile.rb +3 -1
- data/app/models/renalware/hd/schedule_definition.rb +44 -0
- data/app/models/renalware/hd/session.rb +1 -0
- data/app/models/renalware/hd/session/closed.rb +3 -2
- data/app/models/renalware/hd/session_factory.rb +2 -2
- data/app/models/renalware/hd/station.rb +1 -10
- data/app/models/renalware/hd/station_location.rb +10 -0
- data/app/models/renalware/hd/weekly_diary.rb +43 -0
- data/app/models/renalware/hospitals/unit.rb +0 -1
- data/app/models/renalware/medications/prescriptions_by_drug_type_query.rb +1 -0
- data/app/models/renalware/messaging.rb +2 -0
- data/app/models/renalware/messaging/patient.rb +2 -2
- data/app/models/renalware/patient.rb +25 -23
- data/app/models/renalware/patients/search_query.rb +7 -3
- data/app/models/renalware/patients/summary.rb +1 -0
- data/app/models/renalware/pd/revise_regime.rb +3 -1
- data/app/models/renalware/renal/patient.rb +3 -0
- data/app/models/renalware/renal/registry/preflight_checks/deaths_query.rb +41 -0
- data/app/models/renalware/renal/registry/preflight_checks/patients_query.rb +65 -0
- data/app/models/renalware/reporting/{generate_audit_json.rb → fetch_audit_json.rb} +10 -9
- data/app/models/renalware/research.rb +7 -0
- data/app/models/renalware/research/study.rb +19 -0
- data/app/models/renalware/research/study_participant.rb +30 -0
- data/app/policies/renalware/admissions/consult_policy.rb +8 -0
- data/app/policies/renalware/hd/diary_policy.rb +6 -0
- data/app/policies/renalware/renal/registry_preflight_check_policy.rb +15 -0
- data/app/policies/renalware/research/study_participant_policy.rb +8 -0
- data/app/policies/renalware/research/study_policy.rb +8 -0
- data/app/presenters/false_class_presenter.rb +2 -0
- data/app/presenters/renalware/admissions/consult_presenter.rb +28 -0
- data/app/presenters/renalware/hd/diary_presenter.rb +77 -0
- data/app/presenters/renalware/hd/diary_slot_presenter.rb +69 -0
- data/app/presenters/renalware/hd/null_slot.rb +38 -0
- data/app/presenters/renalware/hd/patient_presenter.rb +2 -3
- data/app/presenters/renalware/hd/profile_presenter.rb +12 -10
- data/app/presenters/renalware/hd/station_presenter.rb +5 -0
- data/app/presenters/renalware/hd/unmet_preferences_presenter.rb +1 -1
- data/app/presenters/renalware/pathology/observation_presenter.rb +1 -1
- data/app/presenters/renalware/patient_presenter.rb +2 -2
- data/app/presenters/renalware/ukrdc/pathology_observation_presenter.rb +16 -0
- data/app/presenters/renalware/ukrdc/patient_presenter.rb +6 -1
- data/app/presenters/true_class_presenter.rb +2 -0
- data/app/views/renalware/accesses/plans/new.html.slim +0 -1
- data/app/views/renalware/accesses/procedures/_form.html.slim +1 -1
- data/app/views/renalware/accesses/profiles/_form.html.slim +0 -1
- data/app/views/renalware/addresses/_form.html.slim +0 -2
- data/app/views/renalware/admin/users/edit.html.slim +0 -1
- data/app/views/renalware/admin/users/index.html.slim +3 -1
- data/app/views/renalware/admissions/consults/_filters.html.slim +23 -0
- data/app/views/renalware/admissions/consults/_form.html.slim +93 -0
- data/app/views/renalware/admissions/consults/_table.html.slim +61 -0
- data/app/views/renalware/admissions/consults/edit.html.slim +6 -0
- data/app/views/renalware/admissions/consults/index.html.slim +12 -0
- data/app/views/renalware/admissions/consults/new.html.slim +6 -0
- data/app/views/renalware/admissions/requests/_create_request_link.html.slim +2 -1
- data/app/views/renalware/admissions/requests/_request.html.slim +4 -4
- data/app/views/renalware/api/ukrdc/patients/_lab_orders.xml.builder +6 -4
- data/app/views/renalware/api/ukrdc/patients/_name.xml.builder +1 -1
- data/app/views/renalware/api/ukrdc/patients/_sending_facility.xml.builder +1 -1
- data/app/views/renalware/api/ukrdc/patients/encounters/_hd_session.xml.builder +3 -3
- data/app/views/renalware/api/ukrdc/patients/lab_orders/_lab_order.xml.builder +4 -4
- data/app/views/renalware/api/ukrdc/patients/lab_orders/_result_item.xml.builder +7 -5
- data/app/views/renalware/clinical/allergies/_new.html.slim +0 -1
- data/app/views/renalware/clinical/body_compositions/_form.html.slim +0 -1
- data/app/views/renalware/clinical/dry_weights/new.html.slim +0 -1
- data/app/views/renalware/clinical/profiles/show.html.slim +0 -1
- data/app/views/renalware/clinics/appointments/index.html.slim +4 -2
- data/app/views/renalware/clinics/visits/_filters.html.slim +0 -1
- data/app/views/renalware/clinics/visits/_table.html.slim +0 -1
- data/app/views/renalware/dashboard/bookmarks/_bookmark.html.slim +9 -6
- data/app/views/renalware/dashboard/bookmarks/_table.html.slim +2 -1
- data/app/views/renalware/deaths/index.html.slim +6 -8
- data/app/views/renalware/devise/registrations/new.html.slim +0 -1
- data/app/views/renalware/directory/people/_form.html.slim +0 -1
- data/app/views/renalware/events/events/_event.html.slim +3 -1
- data/app/views/renalware/events/events/_filters.html.slim +0 -1
- data/app/views/renalware/events/events/_form.html.slim +4 -4
- data/app/views/renalware/events/events/simple/_event.html.slim +3 -1
- data/app/views/renalware/hd/cannulation_types/edit.html.slim +1 -1
- data/app/views/renalware/hd/cannulation_types/new.html.slim +1 -1
- data/app/views/renalware/hd/current_profile/_form.html.slim +4 -3
- data/app/views/renalware/hd/dashboards/_page_actions.html.slim +6 -6
- data/app/views/renalware/hd/dialysers/_form.html.slim +0 -1
- data/app/views/renalware/hd/diaries/_page_actions.html.slim +23 -0
- data/app/views/renalware/hd/diaries/_table.html.slim +12 -0
- data/app/views/renalware/hd/diaries/_weekly_diary.html.slim +10 -0
- data/app/views/renalware/hd/diaries/edit.html.slim +58 -0
- data/app/views/renalware/hd/diaries/index.html.slim +9 -0
- data/app/views/renalware/hd/diaries/show.pdf.slim +32 -0
- data/app/views/renalware/hd/diary_slots/_form.html.slim +111 -0
- data/app/views/renalware/hd/diary_slots/_slot.html.slim +21 -0
- data/app/views/renalware/hd/diary_slots/_tab.html.slim +27 -0
- data/app/views/renalware/hd/diary_slots/create.js.erb +11 -0
- data/app/views/renalware/hd/diary_slots/destroy.js.erb +11 -0
- data/app/views/renalware/hd/diary_slots/edit.html.slim +26 -0
- data/app/views/renalware/hd/diary_slots/new.html.slim +12 -0
- data/app/views/renalware/hd/diary_slots/new.js.erb +6 -0
- data/app/views/renalware/hd/diary_slots/show.js.erb +5 -0
- data/app/views/renalware/hd/diary_slots/update.js.erb +11 -0
- data/app/views/renalware/hd/historical_profiles/_summary.html.slim +0 -1
- data/app/views/renalware/hd/mdm_patients/_filters.html.slim +2 -2
- data/app/views/renalware/hd/mdm_patients/_patient.html.slim +3 -4
- data/app/views/renalware/hd/mdm_patients/_table.html.slim +4 -6
- data/app/views/renalware/hd/preference_sets/_form.html.slim +5 -4
- data/app/views/renalware/hd/preference_sets/_summary.html.slim +1 -1
- data/app/views/renalware/hd/sessions/_form.html.slim +1 -2
- data/app/views/renalware/hd/sessions/_show.html.slim +2 -1
- data/app/views/renalware/hd/sessions/dna/_row.html.slim +0 -1
- data/app/views/renalware/hd/stations/_form.html.slim +3 -1
- data/app/views/renalware/hd/stations/_station.html.slim +1 -1
- data/app/views/renalware/hd/stations/index.html.slim +0 -1
- data/app/views/renalware/hd/unmet_preferences/_filters.html.slim +2 -2
- data/app/views/renalware/hd/unmet_preferences/_table.html.slim +2 -2
- data/app/views/renalware/hospitals/units/_form.html.slim +0 -1
- data/app/views/renalware/hospitals/units/index.html.slim +16 -13
- data/app/views/renalware/letters/contacts/index.js.erb +0 -1
- data/app/views/renalware/letters/electronic_receipts/_table.html.slim +10 -6
- data/app/views/renalware/letters/electronic_receipts/sent.html.slim +9 -4
- data/app/views/renalware/letters/formatted_letters/_letter.html.slim +0 -3
- data/app/views/renalware/letters/letters/_actions.html.slim +0 -1
- data/app/views/renalware/letters/letters/_form.html.slim +1 -1
- data/app/views/renalware/letters/letters/_main_recipient.html.slim +0 -1
- data/app/views/renalware/letters/letters/_preview.html.slim +0 -1
- data/app/views/renalware/mdm/_top_navigation.html.slim +0 -1
- data/app/views/renalware/mdm_patients/_patient.html.slim +2 -2
- data/app/views/renalware/mdm_patients/_table.html.slim +1 -1
- data/app/views/renalware/medications/prescriptions/index.pdf.slim +0 -2
- data/app/views/renalware/messaging/internal/messages/_form.html.slim +1 -1
- data/app/views/renalware/messaging/internal/receipts/_receipt.html.slim +7 -9
- data/app/views/renalware/messaging/internal/receipts/_sent_receipt.html.slim +5 -2
- data/app/views/renalware/messaging/internal/receipts/_sent_table.html.slim +1 -0
- data/app/views/renalware/messaging/internal/receipts/_table.html.slim +3 -3
- data/app/views/renalware/messaging/internal/receipts/sent.html.slim +0 -1
- data/app/views/renalware/modalities/reasons/index.html.slim +0 -1
- data/app/views/renalware/navigation/_mdms.html.slim +0 -1
- data/app/views/renalware/navigation/_patients_admin.html.slim +6 -10
- data/app/views/renalware/navigation/_renal.html.slim +3 -0
- data/app/views/renalware/navigation/_sign_out.html.slim +0 -1
- data/app/views/renalware/pathology/requests/requests/create.pdf.slim +0 -1
- data/app/views/renalware/pathology/requests/requests/request_form/_manual_form_patient.html.slim +0 -1
- data/app/views/renalware/patients/_mini_profile.html.slim +0 -1
- data/app/views/renalware/patients/_search_form.html.slim +1 -1
- data/app/views/renalware/patients/alerts/_form.html.slim +1 -1
- data/app/views/renalware/patients/bookmarks/_delete.html.slim +3 -4
- data/app/views/renalware/patients/clinical_summaries/_problems.html.slim +0 -1
- data/app/views/renalware/patients/clinical_summaries/show.html.slim +0 -1
- data/app/views/renalware/patients/patients/_form.html.slim +3 -2
- data/app/views/renalware/patients/patients/_patient.html.slim +1 -5
- data/app/views/renalware/patients/patients/_table.html.slim +1 -2
- data/app/views/renalware/patients/patients/show/_hospital_numbers.html.slim +0 -1
- data/app/views/renalware/patients/patients/show/_patient_demographics.html.slim +0 -2
- data/app/views/renalware/patients/primary_care_physician/_form.html.slim +2 -1
- data/app/views/renalware/patients/primary_care_physician/edit.html.slim +3 -5
- data/app/views/renalware/patients/primary_care_physicians/edit.html.slim +1 -1
- data/app/views/renalware/patients/primary_care_physicians/new.html.slim +1 -1
- data/app/views/renalware/patients/worryboard/_table.html.slim +2 -2
- data/app/views/renalware/patients/worryboard/_worry.html.slim +2 -5
- data/app/views/renalware/pd/_apd_regimes.html.slim +0 -1
- data/app/views/renalware/pd/_capd_regimes.html.slim +0 -1
- data/app/views/renalware/pd/_exit_site_infections.html.slim +0 -1
- data/app/views/renalware/pd/_peritonitis_episodes.html.slim +0 -1
- data/app/views/renalware/pd/_pet_adequacies.html.slim +0 -1
- data/app/views/renalware/pd/assessments/show.html.slim +13 -13
- data/app/views/renalware/pd/dashboards/show/_page_actions.html.slim +7 -7
- data/app/views/renalware/pd/regimes/show.html.slim +0 -1
- data/app/views/renalware/problems/notes/form.js.erb +0 -1
- data/app/views/renalware/problems/problems/_current_list.html.slim +0 -1
- data/app/views/renalware/renal/aki_alerts/edit.html.slim +2 -3
- data/app/views/renalware/renal/profiles/_form.html.slim +2 -6
- data/app/views/renalware/renal/profiles/edit.html.slim +9 -0
- data/app/views/renalware/renal/registry_preflight_checks/_navigation.html.slim +3 -0
- data/app/views/renalware/renal/registry_preflight_checks/_table.html.slim +20 -0
- data/app/views/renalware/renal/registry_preflight_checks/deaths.html.slim +4 -0
- data/app/views/renalware/renal/registry_preflight_checks/patients.html.slim +4 -0
- data/app/views/renalware/reporting/audits/show.html.slim +3 -5
- data/app/views/renalware/research/studies/_form.html.slim +9 -0
- data/app/views/renalware/research/studies/edit.html.slim +5 -0
- data/app/views/renalware/research/studies/index.html.slim +32 -0
- data/app/views/renalware/research/studies/new.html.slim +5 -0
- data/app/views/renalware/research/studies/show.html.slim +19 -0
- data/app/views/renalware/research/study_participants/_form.html.slim +45 -0
- data/app/views/renalware/research/study_participants/_table.html.slim +32 -0
- data/app/views/renalware/research/study_participants/create.js.erb +3 -0
- data/app/views/renalware/research/study_participants/edit.html.slim +1 -0
- data/app/views/renalware/research/study_participants/index.html.slim +25 -0
- data/app/views/renalware/research/study_participants/new.html.slim +1 -0
- data/app/views/renalware/research/study_participants/new.js.erb +4 -0
- data/app/views/renalware/research/study_participants/update.js.erb +3 -0
- data/app/views/renalware/shared/documents/_age.html.slim +1 -1
- data/app/views/renalware/shared/documents/_blood_group.html.slim +1 -1
- data/app/views/renalware/shared/documents/_blood_pressure.html.slim +1 -1
- data/app/views/renalware/shared/documents/_dated_test.html.slim +1 -1
- data/app/views/renalware/transplants/donor_dashboards/show.html.slim +0 -1
- data/app/views/renalware/transplants/donor_followups/show.html.slim +0 -1
- data/app/views/renalware/transplants/donor_operations/_form.html.slim +0 -1
- data/app/views/renalware/transplants/donor_operations/_list.html.slim +0 -2
- data/app/views/renalware/transplants/donor_stages/_list.html.slim +0 -1
- data/app/views/renalware/transplants/donor_workups/_form.html.slim +0 -1
- data/app/views/renalware/transplants/recipient_dashboards/_page_actions.html.slim +3 -3
- data/app/views/renalware/transplants/recipient_followups/_form.html.slim +0 -1
- data/app/views/renalware/transplants/recipient_operations/_form.html.slim +0 -1
- data/app/views/renalware/transplants/recipient_operations/_list.html.slim +0 -2
- data/app/views/renalware/transplants/recipient_operations/_operation.html.slim +0 -1
- data/config/initializers/application_controller_renderer.rb +1 -1
- data/config/initializers/backtrace_silencers.rb +1 -1
- data/config/initializers/null_object.rb +2 -0
- data/config/locales/renalware/admissions/consults.en.yml +29 -0
- data/config/locales/renalware/dashboard/dashboard.yml +1 -0
- data/config/locales/renalware/hd/diary_slots.en.yml +13 -0
- data/config/locales/renalware/hd/mdm_patients.yml +1 -2
- data/config/locales/renalware/hd/preference_set.yml +0 -10
- data/config/locales/renalware/hd/profile.yml +2 -14
- data/config/locales/renalware/hd/session.en.yml +1 -7
- data/config/locales/renalware/hospitals/unit.yml +0 -1
- data/config/locales/renalware/mdm.yml +1 -1
- data/config/locales/renalware/messaging/internal/messages.en.yml +1 -0
- data/config/locales/renalware/navigation/renal.en.yml +2 -0
- data/config/locales/renalware/renal/registry.en.yml +12 -0
- data/config/locales/renalware/research/study_participant.en.yml +11 -0
- data/config/routes.rb +31 -1
- data/db/migrate/20170831082043_create_hd_diaries.rb +57 -0
- data/db/migrate/20170831084331_create_hd_diary_slots.rb +36 -0
- data/db/migrate/20170831142819_enable_crosstab_extension.rb +9 -0
- data/db/migrate/20170915090544_create_hd_station_locations.rb +12 -0
- data/db/migrate/20170915115228_add_schedule_diurnal_period_id_to_hd_profiles.rb +52 -0
- data/db/migrate/20170916121019_remove_number_of_hd_stations_from_hospital_units.rb +5 -0
- data/db/migrate/20170917185426_add_indexes_to_diary_slots.rb +19 -0
- data/db/migrate/20171004092235_create_hd_dialysates.rb +13 -0
- data/db/migrate/20171004110909_add_dialysate_id_to_profile_and_session.rb +9 -0
- data/db/migrate/20171012110133_create_research_studies.rb +22 -0
- data/db/migrate/20171012143050_create_research_study_participants.rb +30 -0
- data/db/migrate/20171013145849_set_patients_secure_id.rb +17 -0
- data/db/migrate/20171016152223_add_index_to_diary_slots.rb +17 -0
- data/db/migrate/20171017132738_add_unique_indexes_to_local_patient_ids.rb +13 -0
- data/db/migrate/20171017171625_update_hd_overall_audit_view.rb +8 -0
- data/db/migrate/20171101121130_create_function_to_render_audit_view_as_json.rb +38 -0
- data/db/migrate/20171101162244_create_consults.rb +24 -0
- data/db/migrate/20171106100216_create_pd_audit_view.rb +5 -0
- data/db/seeds/default/hd/{hd_cannulation_types.csv → cannulation_types.csv} +0 -0
- data/db/seeds/default/hd/cannulation_types.rb +1 -1
- data/db/seeds/default/hd/{hd_dialysers.csv → dialysers.csv} +0 -0
- data/db/seeds/default/hd/dialysers.rb +1 -1
- data/db/seeds/default/hd/seeds.rb +0 -1
- data/db/seeds/default/modalities/descriptions.rb +0 -13
- data/db/seeds/default/pathology/seeds.rb +0 -3
- data/db/seeds/default/reporting/audits.yml +265 -49
- data/db/views/reporting_anaemia_audit_v01.sql +1 -1
- data/db/views/reporting_hd_overall_audit_v05.sql +13 -0
- data/db/views/reporting_pd_audit_v01.sql +26 -0
- data/lib/dropdown_button_item.rb +51 -0
- data/lib/renalware/configuration.rb +1 -0
- data/lib/renalware/engine.rb +1 -0
- data/lib/renalware/version.rb +1 -1
- data/lib/renalware/week_period.rb +58 -0
- data/spec/factories/accesses/patients.rb +1 -1
- data/spec/factories/accesses/plans.rb +1 -1
- data/spec/factories/accesses/plans_types.rb +1 -1
- data/spec/factories/accesses/procedures.rb +1 -1
- data/spec/factories/accesses/profiles.rb +1 -1
- data/spec/factories/accesses/sites.rb +1 -1
- data/spec/factories/accesses/types.rb +1 -1
- data/spec/factories/admissions/consults.rb +7 -0
- data/spec/factories/admissions/request_reasons.rb +1 -1
- data/spec/factories/admissions/requests.rb +1 -1
- data/spec/factories/clinical/allergies.rb +1 -1
- data/spec/factories/clinical/body_compositions.rb +1 -1
- data/spec/factories/clinical/dry_weights.rb +1 -1
- data/spec/factories/clinical/patients.rb +1 -1
- data/spec/factories/clinics/appointments.rb +1 -1
- data/spec/factories/clinics/clinic_visits.rb +1 -1
- data/spec/factories/clinics/clinics.rb +1 -1
- data/spec/factories/deaths/cause.rb +1 -1
- data/spec/factories/deaths/modality_descriptions.rb +2 -2
- data/spec/factories/directory/people.rb +1 -1
- data/spec/factories/drugs/drug.rb +1 -1
- data/spec/factories/drugs/drug_types.rb +1 -1
- data/spec/factories/events/events.rb +1 -1
- data/spec/factories/events/events_types.rb +1 -1
- data/spec/factories/hd/cannulation_types.rb +1 -1
- data/spec/factories/hd/dialysates.rb +10 -0
- data/spec/factories/hd/dialysers.rb +1 -1
- data/spec/factories/hd/diaries.rb +12 -0
- data/spec/factories/hd/diurnal_period_codes.rb +18 -0
- data/spec/factories/hd/hd_session_document.rb +3 -4
- data/spec/factories/hd/modality_descriptions.rb +1 -1
- data/spec/factories/hd/patient_statistics.rb +1 -1
- data/spec/factories/hd/patients.rb +1 -1
- data/spec/factories/hd/preference_sets.rb +2 -2
- data/spec/factories/hd/profiles.rb +2 -1
- data/spec/factories/hd/schedule_definitions.rb +20 -0
- data/spec/factories/hd/sessions.rb +2 -1
- data/spec/factories/hd/slots.rb +7 -0
- data/spec/factories/hd/station_locations.rb +6 -0
- data/spec/factories/hd/stations.rb +1 -1
- data/spec/factories/hospitals/centres.rb +1 -1
- data/spec/factories/hospitals/units.rb +1 -3
- data/spec/factories/hospitals/wards.rb +1 -1
- data/spec/factories/letters/archives.rb +1 -1
- data/spec/factories/letters/contact_descriptions.rb +1 -1
- data/spec/factories/letters/contacts.rb +1 -1
- data/spec/factories/letters/descriptions.rb +1 -1
- data/spec/factories/letters/electronic_receipts.rb +1 -1
- data/spec/factories/letters/letterheads.rb +1 -1
- data/spec/factories/letters/letters.rb +1 -1
- data/spec/factories/letters/patients.rb +1 -1
- data/spec/factories/letters/primary_care_physicians.rb +1 -1
- data/spec/factories/letters/recipients.rb +1 -1
- data/spec/factories/medications/medication_route.rb +1 -1
- data/spec/factories/medications/prescription.rb +1 -1
- data/spec/factories/medications/prescription_terminations.rb +1 -1
- data/spec/factories/medications/prescription_version.rb +1 -1
- data/spec/factories/messaging/internal/authors.rb +1 -1
- data/spec/factories/messaging/internal/messages.rb +1 -1
- data/spec/factories/messaging/internal/receipts.rb +1 -1
- data/spec/factories/messaging/internal/recipients.rb +1 -1
- data/spec/factories/messaging/patients.rb +1 -1
- data/spec/factories/modalities/modalities.rb +1 -1
- data/spec/factories/modalities/modality_descriptions.rb +1 -1
- data/spec/factories/modalities/modality_reasons.rb +1 -1
- data/spec/factories/pathology/consultant.rb +1 -1
- data/spec/factories/pathology/lab.rb +1 -1
- data/spec/factories/pathology/measurement_units.rb +1 -1
- data/spec/factories/pathology/observation_descriptions.rb +1 -1
- data/spec/factories/pathology/observation_requests.rb +1 -1
- data/spec/factories/pathology/observations.rb +1 -1
- data/spec/factories/pathology/patients.rb +1 -1
- data/spec/factories/pathology/request_descriptions.rb +1 -1
- data/spec/factories/pathology/requests/drug_category.rb +1 -1
- data/spec/factories/pathology/requests/global_rule.rb +1 -1
- data/spec/factories/pathology/requests/global_rule_set.rb +1 -1
- data/spec/factories/pathology/requests/patient_rule.rb +1 -1
- data/spec/factories/pathology/requests/request.rb +1 -1
- data/spec/factories/patients/alerts.rb +1 -1
- data/spec/factories/patients/bookmarks.rb +1 -1
- data/spec/factories/patients/ethnicities.rb +1 -1
- data/spec/factories/patients/languages.rb +1 -1
- data/spec/factories/patients/patients.rb +2 -2
- data/spec/factories/patients/practices.rb +2 -2
- data/spec/factories/patients/primary_care_physicians.rb +2 -2
- data/spec/factories/patients/religions.rb +1 -1
- data/spec/factories/patients/users.rb +1 -1
- data/spec/factories/pd/assessments.rb +1 -1
- data/spec/factories/pd/bag_types.rb +1 -1
- data/spec/factories/pd/episode_types.rb +1 -1
- data/spec/factories/pd/exit_site_infections.rb +1 -1
- data/spec/factories/pd/fluid_descriptions.rb +1 -1
- data/spec/factories/pd/infection_organisms.rb +1 -1
- data/spec/factories/pd/modality_descriptions.rb +1 -1
- data/spec/factories/pd/organism_codes.rb +1 -1
- data/spec/factories/pd/patients.rb +1 -1
- data/spec/factories/pd/pd_regimes.rb +1 -1
- data/spec/factories/pd/peritonitis_episode_type_descriptions.rb +1 -1
- data/spec/factories/pd/peritonitis_episodes.rb +1 -1
- data/spec/factories/pd/pet_adequacies.rb +1 -1
- data/spec/factories/pd/regime_bags.rb +1 -1
- data/spec/factories/pd/systems.rb +1 -1
- data/spec/factories/pd/training_sessions.rb +1 -1
- data/spec/factories/pd/training_sites.rb +1 -1
- data/spec/factories/pd/training_types.rb +1 -1
- data/spec/factories/problems/problems.rb +1 -1
- data/spec/factories/renal/aki_alert_actions.rb +1 -1
- data/spec/factories/renal/aki_alerts.rb +1 -1
- data/spec/factories/renal/patients.rb +1 -1
- data/spec/factories/renal/prd_description.rb +1 -1
- data/spec/factories/renal/profiles.rb +17 -1
- data/spec/factories/reporting/audits.rb +1 -1
- data/spec/factories/research/studies.rb +11 -0
- data/spec/factories/research/study_participants.rb +7 -0
- data/spec/factories/shared/accountable.rb +2 -2
- data/spec/factories/snippets/snippets.rb +1 -1
- data/spec/factories/snippets/users.rb +1 -1
- data/spec/factories/system/addresses.rb +1 -1
- data/spec/factories/system/countries.rb +1 -1
- data/spec/factories/system/roles.rb +1 -1
- data/spec/factories/system/templates.rb +1 -1
- data/spec/factories/system/users.rb +1 -1
- data/spec/factories/transplants/donations.rb +1 -1
- data/spec/factories/transplants/donor_stage.rb +1 -1
- data/spec/factories/transplants/donor_stage_position.rb +1 -1
- data/spec/factories/transplants/donor_stage_status.rb +1 -1
- data/spec/factories/transplants/live_donor_modality_description.rb +1 -1
- data/spec/factories/transplants/modality_descriptions.rb +1 -1
- data/spec/factories/transplants/patients.rb +1 -1
- data/spec/factories/transplants/recipient_followups.rb +1 -1
- data/spec/factories/transplants/recipient_operations.rb +1 -1
- data/spec/factories/transplants/registration_status_descriptions.rb +1 -1
- data/spec/factories/transplants/registration_statuses.rb +1 -1
- data/spec/factories/transplants/registrations.rb +1 -1
- data/spec/support/{factory_girl.rb → factory_bot.rb} +3 -3
- metadata +130 -51
- data/app/models/concerns/renalware/hd/has_schedule.rb +0 -24
- data/app/views/renalware/clinical/body_compositions/_navigation.html.slim +0 -0
- data/app/views/renalware/clinical/dry_weights/_navigation.html.slim +0 -0
- data/app/views/renalware/clinical/profiles/_navigation.html.slim +0 -0
- data/app/views/renalware/dashboard/dashboards/_navigation.html.slim +0 -0
- data/app/views/renalware/devise/registrations/_navigation.html.slim +0 -0
- data/app/views/renalware/hd/sessions/_sections_nav.html.slim +0 -0
- data/app/views/renalware/letters/letters/_navigation.html.slim +0 -4
- data/app/views/renalware/patients/primary_care_physician/_navigation.html.slim +0 -0
- data/app/views/renalware/pd/peritonitis_episodes/_navigation.html.slim +0 -7
- data/db/seeds/default/hd/diurnal_period_codes.csv +0 -4
- data/db/seeds/default/hd/diurnal_period_codes.rb +0 -13
- data/db/seeds/default/pathology/pathology_labs.csv +0 -9
- data/db/seeds/default/pathology/pathology_labs.rb +0 -12
- data/db/seeds/default/pathology/pathology_observation_descriptions.csv +0 -1741
- data/db/seeds/default/pathology/pathology_observation_descriptions.rb +0 -16
- data/db/seeds/default/pathology/pathology_request_descriptions.csv +0 -196
- data/db/seeds/default/pathology/pathology_request_descriptions.rb +0 -27
- data/db/structure.sql +0 -9775
- data/vendor/assets/fonts/foundation-icons.eot +0 -0
- data/vendor/assets/fonts/foundation-icons.scss +0 -594
- data/vendor/assets/fonts/foundation-icons.svg +0 -970
- data/vendor/assets/fonts/foundation-icons.ttf +0 -0
- data/vendor/assets/fonts/foundation-icons.woff +0 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
.renal-registry-preflight-checks {
|
2
|
+
.missing-data {
|
3
|
+
span {
|
4
|
+
border-radius: 0.2rem;
|
5
|
+
padding: 0.15rem 0.4rem;
|
6
|
+
color: $white;
|
7
|
+
white-space: nowrap;
|
8
|
+
font-size: 0.9rem;
|
9
|
+
font-weight: normal;
|
10
|
+
background-color: $renal-reg-missing-data-default;
|
11
|
+
margin-right: .2rem;
|
12
|
+
|
13
|
+
&.comorbidities_at_esrf {
|
14
|
+
background-color: $renal-reg-missing-data-comorbidities-at-esrf;
|
15
|
+
}
|
16
|
+
|
17
|
+
&.prd {
|
18
|
+
background-color: $renal-reg-missing-data-prd;
|
19
|
+
}
|
20
|
+
|
21
|
+
&.first_seen_on {
|
22
|
+
background-color: $renal-reg-missing-data-first-seen-on;
|
23
|
+
}
|
24
|
+
|
25
|
+
&.ethnicity {
|
26
|
+
background-color: $renal-reg-missing-data-ethnicity;
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
@@ -32,6 +32,17 @@ footer {
|
|
32
32
|
text-align: right;
|
33
33
|
}
|
34
34
|
|
35
|
+
.page-heading {
|
36
|
+
.warning-block {
|
37
|
+
background-color: $table-toggled-content-colour;
|
38
|
+
margin: 0.7rem;
|
39
|
+
|
40
|
+
i {
|
41
|
+
margin-right: 0.5rem;
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
35
46
|
.embedded-scroll {
|
36
47
|
overflow: auto;
|
37
48
|
}
|
@@ -109,6 +109,14 @@ table {
|
|
109
109
|
max-width: 7rem;
|
110
110
|
}
|
111
111
|
|
112
|
+
&.col-width-mediumish-with-ellipsis {
|
113
|
+
overflow: hidden;
|
114
|
+
white-space: nowrap;
|
115
|
+
text-overflow: ellipsis;
|
116
|
+
min-width: 7rem;
|
117
|
+
max-width: 9rem;
|
118
|
+
}
|
119
|
+
|
112
120
|
&.col-width-large-with-ellipsis {
|
113
121
|
overflow: hidden;
|
114
122
|
white-space: nowrap;
|
@@ -117,7 +125,9 @@ table {
|
|
117
125
|
max-width: 20rem;
|
118
126
|
}
|
119
127
|
|
120
|
-
|
128
|
+
&.actions {
|
129
|
+
text-align: right;
|
130
|
+
}
|
121
131
|
}
|
122
132
|
|
123
133
|
tr th,
|
@@ -154,7 +164,7 @@ table {
|
|
154
164
|
}
|
155
165
|
|
156
166
|
&.col-width-nhs-no {
|
157
|
-
width:
|
167
|
+
width: 7rem;
|
158
168
|
min-width: 7rem;
|
159
169
|
white-space: nowrap;
|
160
170
|
}
|
@@ -1,3 +1,48 @@
|
|
1
|
+
.ui-tabs-simple {
|
2
|
+
.ui-tabs {
|
3
|
+
border: none;
|
4
|
+
}
|
5
|
+
|
6
|
+
.ui-tabs-nav {
|
7
|
+
border-bottom: 1px solid #ccc;
|
8
|
+
}
|
9
|
+
|
10
|
+
.ui-widget-header {
|
11
|
+
padding: 0;
|
12
|
+
background: none;
|
13
|
+
border-width: 0;
|
14
|
+
}
|
15
|
+
|
16
|
+
.ui-tabs-tab.ui-tabs-active,
|
17
|
+
.ui-tabs-tab.ui-state-active {
|
18
|
+
background-color: $white;
|
19
|
+
border-color: $table-border-colour;
|
20
|
+
}
|
21
|
+
|
22
|
+
.ui-tabs-anchor {
|
23
|
+
outline: none;
|
24
|
+
}
|
25
|
+
|
26
|
+
.ui-state-active a,
|
27
|
+
.ui-state-active a:link,
|
28
|
+
.ui-state-active a:visited {
|
29
|
+
color: $dark-grey;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
.ui-tabs-simple .ui-tabs-nav {
|
34
|
+
padding-left: 0px;
|
35
|
+
background: transparent;
|
36
|
+
border-width: 0px 0px 1px 0px;
|
37
|
+
-moz-border-radius: 0px;
|
38
|
+
-webkit-border-radius: 0px;
|
39
|
+
border-radius: 0px;
|
40
|
+
}
|
41
|
+
|
42
|
+
.ui-tabs-simple .ui-tabs-panel {
|
43
|
+
border-width: 0px 1px 1px 1px;
|
44
|
+
}
|
45
|
+
|
1
46
|
.tab-strip {
|
2
47
|
list-style-type: none;
|
3
48
|
margin: 0 0 2px 0;
|
@@ -1,11 +1,12 @@
|
|
1
1
|
module Renalware
|
2
2
|
class Admin::UsersController < BaseController
|
3
|
+
include Renalware::Concerns::Pageable
|
3
4
|
|
4
5
|
def index
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
search = User.search(params[:q])
|
7
|
+
users = search.result(distinct: true).page(page).per(per_page)
|
8
|
+
authorize users
|
9
|
+
render locals: { users: users }
|
9
10
|
end
|
10
11
|
|
11
12
|
def edit
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require "renalware/admissions"
|
2
|
+
require "collection_presenter"
|
3
|
+
|
4
|
+
module Renalware
|
5
|
+
module Admissions
|
6
|
+
class ConsultsController < BaseController
|
7
|
+
include Renalware::Concerns::Pageable
|
8
|
+
|
9
|
+
def index
|
10
|
+
query = ConsultQuery.new(params[:q])
|
11
|
+
consults = query.call.page(page).per(per_page)
|
12
|
+
authorize consults
|
13
|
+
render locals: {
|
14
|
+
consults: CollectionPresenter.new(consults, ConsultPresenter),
|
15
|
+
query: query.search
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
def new
|
20
|
+
consult = Consult.new(started_on: Time.zone.today)
|
21
|
+
authorize consult
|
22
|
+
render_new(consult)
|
23
|
+
end
|
24
|
+
|
25
|
+
def create
|
26
|
+
consult = Consult.new(consult_params)
|
27
|
+
authorize consult
|
28
|
+
if consult.save_by(current_user)
|
29
|
+
redirect_to admissions_consults_path, notice: success_msg_for("consult")
|
30
|
+
else
|
31
|
+
render_new(consult)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def edit
|
36
|
+
render_edit(find_and_authorize_consult)
|
37
|
+
end
|
38
|
+
|
39
|
+
def update
|
40
|
+
consult = find_and_authorize_consult
|
41
|
+
if consult.update_by(current_user, consult_params)
|
42
|
+
redirect_to admissions_consults_path, notice: success_msg_for("consult")
|
43
|
+
else
|
44
|
+
render_edit(consult)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def destroy
|
49
|
+
find_and_authorize_consult.destroy!
|
50
|
+
redirect_to admissions_consults_path, notice: success_msg_for("consult")
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def present(consults)
|
56
|
+
CollectionPresenter.new(
|
57
|
+
Consult.all.order(created_at: :desc).page(page).per(per_page),
|
58
|
+
ConsultPresenter
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
def find_and_authorize_consult
|
63
|
+
Consult.find(params[:id]).tap do |consult|
|
64
|
+
authorize consult
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def render_new(consult)
|
69
|
+
render :new, locals: { consult: consult }
|
70
|
+
end
|
71
|
+
|
72
|
+
def render_edit(consult)
|
73
|
+
render :edit, locals: { consult: consult }
|
74
|
+
end
|
75
|
+
|
76
|
+
def consult_params
|
77
|
+
params
|
78
|
+
.require(:admissions_consult)
|
79
|
+
.permit(
|
80
|
+
:hospital_unit_id, :hospital_ward_id, :patient_id, :q,
|
81
|
+
:decided_on, :transferred_on, :started_on, :ended_on, :decided_on,
|
82
|
+
:aki_risk, :transfer_priority, :seen_by_id, :consult_type,
|
83
|
+
:requires_aki_nurse, :description, :contact_number
|
84
|
+
)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -23,7 +23,7 @@ module Renalware
|
|
23
23
|
def create
|
24
24
|
body_composition = build_body_composition
|
25
25
|
if body_composition.save
|
26
|
-
redirect_to patient_clinical_profile_path(
|
26
|
+
redirect_to patient_clinical_profile_path(patient),
|
27
27
|
notice: t(".success", model_name: "body composition")
|
28
28
|
else
|
29
29
|
flash.now[:error] = t(".failed", model_name: "body composition")
|
@@ -61,7 +61,7 @@ module Renalware
|
|
61
61
|
|
62
62
|
def attributes
|
63
63
|
[
|
64
|
-
:
|
64
|
+
:schedule_definition_id, :other_schedule, :hospital_unit_id, :dialysate_id,
|
65
65
|
:prescribed_time, :prescribed_on, :prescriber_id,
|
66
66
|
:named_nurse_id, :transport_decider_id,
|
67
67
|
document: []
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require_dependency "renalware/hd/base_controller"
|
2
|
+
|
3
|
+
# The route to the edit route for this controller takes /:year/:week_number segments
|
4
|
+
# rather than an id. THat is because when we load the diary, and when we navigate back and forth
|
5
|
+
# through diaries, we are concerned with the week more then an id. Its easier to navigate to the
|
6
|
+
# next week with /2017/52 than by looking up the id of the next diary ahead of time.
|
7
|
+
module Renalware
|
8
|
+
module HD
|
9
|
+
class DiariesController < BaseController
|
10
|
+
include Renalware::Concerns::PdfRenderable
|
11
|
+
include Renalware::Concerns::Pageable
|
12
|
+
|
13
|
+
def edit
|
14
|
+
authorize weekly_diary, :show?
|
15
|
+
render locals: {
|
16
|
+
unit: unit,
|
17
|
+
diary: DiaryPresenter.new(current_user, weekly_diary)
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
# Renders a list of diaries for a hospital unit
|
22
|
+
def index
|
23
|
+
authorize WeeklyDiary, :index?
|
24
|
+
render locals: { unit: unit, diaries: weekly_diaries }
|
25
|
+
end
|
26
|
+
|
27
|
+
def show
|
28
|
+
diary = WeeklyDiary.find(params[:id])
|
29
|
+
respond_to do |format|
|
30
|
+
format.pdf do
|
31
|
+
authorize diary
|
32
|
+
options = default_pdf_options.merge!(
|
33
|
+
pdf: pdf_filename,
|
34
|
+
locals: { unit: unit, diary: DiaryPresenter.new(current_user, diary) }
|
35
|
+
)
|
36
|
+
render options
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
# TODO: give a sensible name
|
44
|
+
def pdf_filename
|
45
|
+
"hd_unit_diary"
|
46
|
+
end
|
47
|
+
|
48
|
+
def weekly_diary
|
49
|
+
@weekly_diary ||= begin
|
50
|
+
FindOrCreateDiaryByWeekQuery.new(
|
51
|
+
relation: WeeklyDiary.eager_load(
|
52
|
+
slots: [:patient, :station, :diurnal_period_code],
|
53
|
+
master_diary: { slots: [:patient, :station, :diurnal_period_code] }
|
54
|
+
),
|
55
|
+
unit_id: unit_id,
|
56
|
+
week_period: week_period,
|
57
|
+
by: current_user
|
58
|
+
).call
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# The route segments are /:year/:week_number
|
63
|
+
# We use a WeekPeriod value object to wrap those two things.
|
64
|
+
def week_period
|
65
|
+
WeekPeriod.new(
|
66
|
+
week_number: params[:week_number],
|
67
|
+
year: params[:year]
|
68
|
+
)
|
69
|
+
end
|
70
|
+
|
71
|
+
def unit_id
|
72
|
+
params[:unit_id]
|
73
|
+
end
|
74
|
+
|
75
|
+
def unit
|
76
|
+
Hospitals::Unit.find(unit_id)
|
77
|
+
end
|
78
|
+
|
79
|
+
def weekly_diaries
|
80
|
+
WeeklyDiary
|
81
|
+
.where(hospital_unit_id: unit_id)
|
82
|
+
.ordered
|
83
|
+
.page(page).per(per_page)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,172 @@
|
|
1
|
+
# rubocop:disable Metrics/ClassLength
|
2
|
+
require_dependency "renalware/hd/base_controller"
|
3
|
+
|
4
|
+
module Renalware
|
5
|
+
module HD
|
6
|
+
class DiarySlotsController < BaseController
|
7
|
+
|
8
|
+
# GET html - renders a form
|
9
|
+
# Here we will have been passed in the query string:
|
10
|
+
# - the unit id
|
11
|
+
# - the dirunal_period_code id
|
12
|
+
# - the week and year (and thus the diary)
|
13
|
+
# and from that lot we could look up the master and weekly diaries
|
14
|
+
def new
|
15
|
+
# Be default this assume we are going to add a slot to the weekly diary
|
16
|
+
# but in which button is clicked in the modal dialog determines which diary
|
17
|
+
# (master or weekly) the slot will be added to.
|
18
|
+
slot = DiarySlot.new(
|
19
|
+
diary: weekly_diary,
|
20
|
+
station_id: params[:station_id],
|
21
|
+
day_of_week: params[:day_of_week],
|
22
|
+
diurnal_period_code_id: params[:diurnal_period_code_id]
|
23
|
+
)
|
24
|
+
authorize slot
|
25
|
+
render locals: locals_for(slot), layout: false
|
26
|
+
end
|
27
|
+
|
28
|
+
# POST create js
|
29
|
+
# Here we may be adding a slot to the weekly or master diary.
|
30
|
+
# That should be transparent to us - we make the change and render
|
31
|
+
# create.js.erb which, on the client, will cause an ajax js call to #show. That secondary call
|
32
|
+
# is the one that refreshes the slot in the table with its latest state.
|
33
|
+
# We do this to avoid having to to a check (in each action in this controller) to see if we
|
34
|
+
# are on the master or weekly diary; if we always refresh the diary slot in the ui after any
|
35
|
+
# action, then it will always update correctly.
|
36
|
+
def create
|
37
|
+
diary = Diary.find(params[:diary_id])
|
38
|
+
slot = diary.slots.new(slot_params)
|
39
|
+
slot.patient_id = posted_patient_id
|
40
|
+
authorize slot
|
41
|
+
if slot.save_by(current_user)
|
42
|
+
render locals: { diary: diary, slot: diary.decorate_slot(slot) }
|
43
|
+
else
|
44
|
+
render :new, locals: { slot: DiarySlotPresenter.new(slot) }, layout: false
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# GET .js refresh a slot in a *weekly* diary
|
49
|
+
# See comment on #create.
|
50
|
+
# See show.js.erb where we refresh the slot in the diary
|
51
|
+
# To get here we will have manufactured a url like this
|
52
|
+
# hd/diaries/2/slots/day/1/period/1/station/1
|
53
|
+
# as those bit are will we know.
|
54
|
+
# Basically we are saying find for this weekly diary, find the matching
|
55
|
+
# slot for the station/day/period combo and render the weekly slot if there is
|
56
|
+
# one, or the master behind it if there is one of those, otherwise render an Add button.
|
57
|
+
def show
|
58
|
+
authorize DiarySlot, :show?
|
59
|
+
slot = weekly_then_master_then_empty_slot
|
60
|
+
render layout: false, locals: { slot: DiarySlotPresenter.new(slot) }
|
61
|
+
end
|
62
|
+
|
63
|
+
def edit
|
64
|
+
authorize slot
|
65
|
+
render layout: false, locals: { slot: DiarySlotPresenter.new(slot) }
|
66
|
+
end
|
67
|
+
|
68
|
+
# DELETE js
|
69
|
+
# Delete the slot (we don't know if its on the master or weekly diary).
|
70
|
+
# NB as per #create and #update, the rendered js file (destroy.js.erb) will make a secondary
|
71
|
+
# back into #show to refresh the UI (i.e. we don't attempt to update the UI in destroy.js.erb)
|
72
|
+
def destroy
|
73
|
+
authorize slot
|
74
|
+
slot.destroy!
|
75
|
+
render locals: { slot: DiarySlotPresenter.new(slot) }
|
76
|
+
end
|
77
|
+
|
78
|
+
# PATCH js
|
79
|
+
# See also comments in #create and #destroy.
|
80
|
+
def update
|
81
|
+
authorize slot
|
82
|
+
slot.patient_id = slot_params[:patient_id]
|
83
|
+
slot.save_by!(current_user)
|
84
|
+
diary = slot.diary
|
85
|
+
render locals: { diary: diary, slot: diary.decorate_slot(slot) }
|
86
|
+
end
|
87
|
+
|
88
|
+
private
|
89
|
+
|
90
|
+
# Find the corresponding slot in the master if there is one, otherwise an empty slot
|
91
|
+
# with an 'Add' button ready to set up a new patient
|
92
|
+
def weekly_then_master_then_empty_slot
|
93
|
+
empty_slot = build_empty_weekly_slot
|
94
|
+
find_weekly_slot(empty_slot) || find_master_slot(empty_slot) || empty_slot
|
95
|
+
end
|
96
|
+
|
97
|
+
def find_master_slot(args)
|
98
|
+
slot = master_diary.slots.find_by(
|
99
|
+
diurnal_period_code_id: args.diurnal_period_code_id,
|
100
|
+
station_id: args.station_id,
|
101
|
+
day_of_week: args.day_of_week
|
102
|
+
)
|
103
|
+
slot && master_diary.decorate_slot(slot)
|
104
|
+
end
|
105
|
+
|
106
|
+
def find_weekly_slot(args)
|
107
|
+
slot = weekly_diary.slots.find_by(
|
108
|
+
diurnal_period_code_id: args.diurnal_period_code_id,
|
109
|
+
station_id: args.station_id,
|
110
|
+
day_of_week: args.day_of_week
|
111
|
+
)
|
112
|
+
slot && weekly_diary.decorate_slot(slot)
|
113
|
+
end
|
114
|
+
|
115
|
+
# Used for searching etc
|
116
|
+
def build_empty_weekly_slot
|
117
|
+
weekly_diary.slots.new(
|
118
|
+
day_of_week: params[:day_of_week],
|
119
|
+
station_id: params[:station_id],
|
120
|
+
diurnal_period_code_id: params[:diurnal_period_code_id]
|
121
|
+
)
|
122
|
+
end
|
123
|
+
|
124
|
+
def slot
|
125
|
+
@slot ||= HD::DiarySlot.find(params[:id])
|
126
|
+
end
|
127
|
+
|
128
|
+
# In the url the :diary_id param is always the weekly diary id!
|
129
|
+
def weekly_diary
|
130
|
+
@weekly_diary ||= WeeklyDiary.find(params[:diary_id])
|
131
|
+
end
|
132
|
+
|
133
|
+
def master_diary
|
134
|
+
weekly_diary.master_diary
|
135
|
+
end
|
136
|
+
|
137
|
+
def locals_for(slot)
|
138
|
+
{
|
139
|
+
slot: DiarySlotPresenter.new(slot),
|
140
|
+
weekly_diary: weekly_diary
|
141
|
+
}
|
142
|
+
end
|
143
|
+
|
144
|
+
# In the modal dialog that submits the patient_id there are several (select2) dropdown
|
145
|
+
# a user can use to choose the patient. Each one has the name patient_id[] so they are
|
146
|
+
# submitted in the form as an array. However the array can only hold one id value ie we
|
147
|
+
# might get posted patient_id: ["", "123", ""] but never ["2", "123", ""].
|
148
|
+
# Here we reduce that array down to one patient id.
|
149
|
+
def posted_patient_id
|
150
|
+
patient_ids = Array(slot_params[:patient_id]).reject(&:blank?).uniq
|
151
|
+
if patient_ids.length > 1
|
152
|
+
raise ArgumentError, "More than one id submitted in patient_id[] : #{patient_ids}"
|
153
|
+
end
|
154
|
+
patient_ids.first
|
155
|
+
end
|
156
|
+
|
157
|
+
def slot_params
|
158
|
+
params
|
159
|
+
.require(:hd_diary_slot)
|
160
|
+
.permit(
|
161
|
+
:master_slot,
|
162
|
+
:day_of_week,
|
163
|
+
:diurnal_period_code_id,
|
164
|
+
:station_id,
|
165
|
+
:target_diary_id,
|
166
|
+
:change_type,
|
167
|
+
patient_id: []
|
168
|
+
)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|