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,26 @@
|
|
1
|
+
require_dependency "renalware/hd"
|
2
|
+
|
3
|
+
module Renalware
|
4
|
+
module HD
|
5
|
+
class PatientsDialysingByScheduleQuery
|
6
|
+
attr_reader :hospital_unit_id, :schedule_definition_ids
|
7
|
+
|
8
|
+
def initialize(hospital_unit_id, schedule_definition_ids)
|
9
|
+
@hospital_unit_id = hospital_unit_id
|
10
|
+
@schedule_definition_ids = Array(schedule_definition_ids)
|
11
|
+
end
|
12
|
+
|
13
|
+
def call
|
14
|
+
return [] if schedule_definition_ids.empty?
|
15
|
+
Patient
|
16
|
+
.eager_load(hd_profile: [:hospital_unit, { schedule_definition: [:diurnal_period] }])
|
17
|
+
.where(
|
18
|
+
hd_profiles: {
|
19
|
+
schedule_definition_id: schedule_definition_ids,
|
20
|
+
hospital_unit_id: hospital_unit_id
|
21
|
+
})
|
22
|
+
.order(:family_name, :given_name)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -33,8 +33,8 @@ module Renalware
|
|
33
33
|
sql = <<-SQL.squish
|
34
34
|
(hd_preference_sets.hospital_unit_id > 0 AND
|
35
35
|
hd_profiles.hospital_unit_id != hd_preference_sets.hospital_unit_id) OR
|
36
|
-
(coalesce(hd_preference_sets.
|
37
|
-
hd_profiles.
|
36
|
+
(coalesce(hd_preference_sets.schedule_definition_id, 0) != 0 AND
|
37
|
+
hd_profiles.schedule_definition_id != hd_preference_sets.schedule_definition_id) OR
|
38
38
|
(coalesce(hd_preference_sets.other_schedule, '') != '' AND
|
39
39
|
hd_profiles.other_schedule != hd_preference_sets.other_schedule)
|
40
40
|
SQL
|
@@ -5,10 +5,10 @@ module Renalware
|
|
5
5
|
class PreferenceSet < ApplicationRecord
|
6
6
|
include PatientScope
|
7
7
|
include Accountable
|
8
|
-
include HasSchedule
|
9
8
|
|
10
9
|
belongs_to :patient, touch: true
|
11
10
|
belongs_to :hospital_unit, class_name: "Hospitals::Unit"
|
11
|
+
belongs_to :schedule_definition, foreign_key: "schedule_definition_id"
|
12
12
|
|
13
13
|
has_paper_trail class_name: "Renalware::HD::Version"
|
14
14
|
|
@@ -18,7 +18,7 @@ module Renalware
|
|
18
18
|
delegate :hospital_centre, to: :hospital_unit, allow_nil: true
|
19
19
|
|
20
20
|
def preferred_schedule
|
21
|
-
|
21
|
+
other_schedule || schedule_definition&.to_s
|
22
22
|
end
|
23
23
|
|
24
24
|
def self.policy_class
|
@@ -6,15 +6,16 @@ module Renalware
|
|
6
6
|
class Profile < ApplicationRecord
|
7
7
|
include Document::Base
|
8
8
|
include PatientScope
|
9
|
-
include HasSchedule
|
10
9
|
include Accountable
|
11
10
|
include Supersedeable
|
12
11
|
|
13
12
|
belongs_to :patient, touch: true
|
14
13
|
belongs_to :hospital_unit, class_name: "Hospitals::Unit"
|
14
|
+
belongs_to :dialysate
|
15
15
|
belongs_to :prescriber, class_name: "User", foreign_key: "prescriber_id"
|
16
16
|
belongs_to :named_nurse, class_name: "User", foreign_key: "named_nurse_id"
|
17
17
|
belongs_to :transport_decider, class_name: "User", foreign_key: "transport_decider_id"
|
18
|
+
belongs_to :schedule_definition, foreign_key: "schedule_definition_id"
|
18
19
|
|
19
20
|
has_document class_name: "Renalware::HD::ProfileDocument"
|
20
21
|
has_paper_trail class_name: "Renalware::HD::Version"
|
@@ -25,6 +26,7 @@ module Renalware
|
|
25
26
|
delegate :hospital_centre, to: :hospital_unit, allow_nil: true
|
26
27
|
|
27
28
|
scope :ordered, -> { order(deactivated_at: :desc) }
|
29
|
+
scope :dialysing_at_unit, ->(unit_id) { where(hospital_unit_id: unit_id) }
|
28
30
|
|
29
31
|
def self.policy_class
|
30
32
|
BasePolicy
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require_dependency "renalware/hd"
|
2
|
+
|
3
|
+
# A ScheduleDefinition is a database-normalized way of expressing e.g. "Mon Wed Fri AM"
|
4
|
+
# A ScheduleDefinition has a days array e.g. [1,3,5] in the above example, where Monday = 1 etc,
|
5
|
+
# and a reference to a DiurnalPeriodCode e.g. "am".
|
6
|
+
# Defining schedules this way lets a hospital have a bit more control of the possible HD Schedules
|
7
|
+
# that a patient can have - for example it can be defined that on Mon Tu Wed once can dialyse
|
8
|
+
# in am, pm, or eve - and also allows us to define SQL that will find patients that dialyse on a
|
9
|
+
# particular day at a particular time (diurnal period).
|
10
|
+
# For example to find patients who, according to their HD Profile, dialyse on Wednesday (day=3)
|
11
|
+
# evening:
|
12
|
+
# select p.id from patients p
|
13
|
+
# inner join hd_profiles hdp on hdp.patient_id = p.id
|
14
|
+
# inner join hd_schedule_definitions hds on hds.id = hdp.schedule_definition_id
|
15
|
+
# inner join hd_diurnal_period_codes hdc on hdc.id = hds.diurnal_period_id
|
16
|
+
# where hdc.code = 'am' and hds.days @> ARRAY[3]::integer[]
|
17
|
+
#
|
18
|
+
module Renalware
|
19
|
+
module HD
|
20
|
+
class ScheduleDefinition < ApplicationRecord
|
21
|
+
ABBREV_DAY_NAMES = %w(Mon Tue Wed Thu Fri Sat Sun).freeze
|
22
|
+
validates :days, presence: true
|
23
|
+
validates :diurnal_period_id, presence: true
|
24
|
+
belongs_to :diurnal_period, class_name: "DiurnalPeriodCode", foreign_key: :diurnal_period_id
|
25
|
+
scope :ordered, -> { order(days: :asc) }
|
26
|
+
|
27
|
+
# Render the schedule definition to a human friendly format e.g. "Mon, Wed, Fri AM"
|
28
|
+
# to display for example in dropdown lists when choosing a patient's preferred or actual
|
29
|
+
# schedule.
|
30
|
+
# Note that we store days of the week as integers starting at 1 (Monday).
|
31
|
+
# ABBREV_DAY_NAMES is a 0-based array, so we have to subtract 1 from our days of the week
|
32
|
+
# when mapping to a day name string.
|
33
|
+
def to_s
|
34
|
+
day_names = days.map{ |day_number| ABBREV_DAY_NAMES[day_number - 1] }.join(" ")
|
35
|
+
"#{day_names} #{diurnal_period.code.upcase}".strip
|
36
|
+
end
|
37
|
+
|
38
|
+
# Find all schedules that have a day falling on the required day.
|
39
|
+
# For example if day_of_week is 1 (Monday) find any schedules where the Postgres days[] array
|
40
|
+
# contains a 1 - e.g. a Mon Wed Fri AM schedule (where days = [1,3,5])
|
41
|
+
scope :for_day_of_week, ->(day_of_week) { where("days @> ?", "{#{day_of_week}}") }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -17,6 +17,7 @@ module Renalware
|
|
17
17
|
belongs_to :dry_weight, class_name: "Renalware::Clinical::DryWeight"
|
18
18
|
belongs_to :modality_description, class_name: "Modalities::Description"
|
19
19
|
belongs_to :hospital_unit, class_name: "Hospitals::Unit"
|
20
|
+
belongs_to :dialysate
|
20
21
|
belongs_to :signed_on_by, class_name: "User", foreign_key: "signed_on_by_id"
|
21
22
|
belongs_to :signed_off_by, class_name: "User", foreign_key: "signed_off_by_id"
|
22
23
|
has_many :prescription_administrations,
|
@@ -2,8 +2,8 @@ require_dependency "renalware/hd"
|
|
2
2
|
require_dependency "renalware/patients/hdf_presence_validator"
|
3
3
|
require "document/base"
|
4
4
|
|
5
|
-
# This Closed (state) Session adds validation standard HD::Session
|
6
|
-
# most fields.
|
5
|
+
# This Closed (state) Session adds validation to the standard HD::Session in order
|
6
|
+
# to enforce the presence of most fields.
|
7
7
|
module Renalware
|
8
8
|
module HD
|
9
9
|
class Session::Closed < Session
|
@@ -13,6 +13,7 @@ module Renalware
|
|
13
13
|
validates :signed_off_by, presence: true
|
14
14
|
validates :end_time, presence: true
|
15
15
|
validates :signed_off_at, presence: true
|
16
|
+
validates :dialysate, presence: true
|
16
17
|
|
17
18
|
def self.policy_class
|
18
19
|
ClosedSessionPolicy
|
@@ -45,12 +45,12 @@ module Renalware
|
|
45
45
|
session.hospital_unit = profile.hospital_unit
|
46
46
|
unless dna_session?
|
47
47
|
session.document.info.hd_type = profile.document.dialysis.hd_type
|
48
|
-
session.
|
48
|
+
session.dialysate_id = profile.dialysate_id
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
def set_default_access(session) # rubocop:disable
|
53
|
+
def set_default_access(session) # rubocop:disable Naming/AccessorMethodName
|
54
54
|
return if dna_session?
|
55
55
|
accesses_patient = Renalware::Accesses.cast_patient(patient)
|
56
56
|
if (profile = accesses_patient.current_profile)
|
@@ -1,22 +1,13 @@
|
|
1
|
-
# To override the values in the location enum use something like this:
|
2
|
-
# module CustomizeHDStationLocationEnum
|
3
|
-
# extend Enumerize
|
4
|
-
# enumerize :location, in: %i(side_room ante_room cubicle)
|
5
|
-
# end
|
6
|
-
# Renalware::HD::Station.singleton_class.send(:prepend, CustomizeHDStationLocationEnum)
|
7
|
-
#
|
8
1
|
require_dependency "renalware/hd"
|
9
2
|
|
10
3
|
module Renalware
|
11
4
|
module HD
|
12
5
|
class Station < ApplicationRecord
|
13
|
-
extend Enumerize
|
14
6
|
include Accountable
|
7
|
+
belongs_to :location, class_name: "HD::StationLocation", foreign_key: :location_id
|
15
8
|
validates :hospital_unit_id, presence: true
|
16
9
|
validates :name, uniqueness: { scope: :hospital_unit_id }
|
17
10
|
|
18
|
-
enumerize :location, in: %i(side_room)
|
19
|
-
|
20
11
|
scope :for_unit, ->(id){ where(hospital_unit_id: id) }
|
21
12
|
scope :ordered, ->{ order(position: :asc) }
|
22
13
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require_dependency "renalware/hd"
|
2
|
+
|
3
|
+
module Renalware
|
4
|
+
module HD
|
5
|
+
class WeeklyDiary < Diary
|
6
|
+
# Overwrite the existing master attribute to ensure it defaults to false
|
7
|
+
attribute :master, :boolean, default: false
|
8
|
+
belongs_to :master_diary, class_name: "Renalware::HD::MasterDiary"
|
9
|
+
validates :week_number,
|
10
|
+
presence: true,
|
11
|
+
uniqueness: { scope: [:year, :hospital_unit_id] },
|
12
|
+
inclusion: { in: 1..53 }
|
13
|
+
validates :year, presence: true
|
14
|
+
validates :master, inclusion: { in: [false], allow_nil: false }
|
15
|
+
validates :master_diary, presence: true
|
16
|
+
delegate :to_s, to: :week
|
17
|
+
scope :ordered, ->{ order(year: :desc, week_number: :desc) }
|
18
|
+
|
19
|
+
def applies_to_current_week?
|
20
|
+
today = Time.zone.today
|
21
|
+
[today.cweek, today.year] == [week.week_number, week.year]
|
22
|
+
end
|
23
|
+
|
24
|
+
def archived?
|
25
|
+
false
|
26
|
+
end
|
27
|
+
|
28
|
+
class WeeklySlotDecorator < SimpleDelegator
|
29
|
+
def master?
|
30
|
+
false
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def decorate_slot(slot)
|
35
|
+
WeeklySlotDecorator.new(slot)
|
36
|
+
end
|
37
|
+
|
38
|
+
def slot_for(*args)
|
39
|
+
(slot = super) && decorate_slot(slot)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -16,7 +16,6 @@ module Renalware
|
|
16
16
|
validates :name, presence: true
|
17
17
|
validates :renal_registry_code, presence: true
|
18
18
|
validates :unit_type, presence: true
|
19
|
-
validates :number_of_hd_stations, numericality: { allow_blank: true, only_integer: true }
|
20
19
|
|
21
20
|
enumerize :unit_type, in: %i(hospital satellite home)
|
22
21
|
|
@@ -3,6 +3,7 @@ require_dependency "renalware"
|
|
3
3
|
module Renalware
|
4
4
|
module Messaging
|
5
5
|
module_function
|
6
|
+
|
6
7
|
def table_name_prefix
|
7
8
|
"messaging_"
|
8
9
|
end
|
@@ -21,6 +22,7 @@ module Renalware
|
|
21
22
|
|
22
23
|
module Internal
|
23
24
|
module_function
|
25
|
+
|
24
26
|
def cast_patient(patient)
|
25
27
|
ActiveType.cast(patient, ::Renalware::Messaging::Internal::Patient)
|
26
28
|
end
|
@@ -11,16 +11,21 @@ module Renalware
|
|
11
11
|
extend Enumerize
|
12
12
|
extend FriendlyId
|
13
13
|
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
|
18
|
-
|
19
|
-
# The PG function is only invoked at the SQL level to provide a default if none exists when a
|
20
|
-
# patient created.
|
21
|
-
has_secure_token :secure_id
|
14
|
+
# Before creation generate a UUID to use in urls with friendly_id (i.e. in #to_param)
|
15
|
+
# Note if inserting directly into the database (bypassing Rails) this will still work as there
|
16
|
+
# is a default new uuid value on the secure_id column
|
17
|
+
before_create { self.secure_id ||= SecureRandom.uuid }
|
18
|
+
before_save :upcase_local_patient_ids
|
22
19
|
friendly_id :secure_id, use: [:finders]
|
23
20
|
|
21
|
+
# For compactness in urls, remove the dashes, so that
|
22
|
+
# a12d9a8e-9cc9-4fbe-88dd-2d1c983ea04f
|
23
|
+
# becomes
|
24
|
+
# a12d9a8e9cc94fbe88dd2d1c983ea04f
|
25
|
+
def secure_id
|
26
|
+
@secure_id_without_dashes ||= super&.gsub("-", "")
|
27
|
+
end
|
28
|
+
|
24
29
|
enumerize :marital_status, in: %i(married single divorced widowed)
|
25
30
|
|
26
31
|
has_paper_trail class_name: "Renalware::Patients::Version"
|
@@ -123,21 +128,6 @@ module Renalware
|
|
123
128
|
self.primary_care_physician == primary_care_physician
|
124
129
|
end
|
125
130
|
|
126
|
-
# @section services
|
127
|
-
|
128
|
-
# def set_modality(attrs, by: nil)
|
129
|
-
# by ||= attrs[:by]
|
130
|
-
# # if current_modality.present?
|
131
|
-
# # current_modality.transfer!(attrs)
|
132
|
-
# # else
|
133
|
-
# # modalities.create(attrs)
|
134
|
-
# # end
|
135
|
-
# new_modality = modalities.new(attrs)
|
136
|
-
# Modalities::ChangePatientModality
|
137
|
-
# .new(patient: self, by: by)
|
138
|
-
# .call(old_modality: current_modality, new_modality:new_modality)
|
139
|
-
# end
|
140
|
-
|
141
131
|
def current_modality_death?
|
142
132
|
return false if current_modality.blank?
|
143
133
|
|
@@ -154,6 +144,18 @@ module Renalware
|
|
154
144
|
|
155
145
|
private
|
156
146
|
|
147
|
+
# TODO: Use a constant for the max number of local patient ids
|
148
|
+
def upcase_local_patient_ids
|
149
|
+
self.local_patient_id = local_patient_id.upcase if local_patient_id.present?
|
150
|
+
(2..5).each{ |index| upcase_local_patient_id(index) }
|
151
|
+
end
|
152
|
+
|
153
|
+
def upcase_local_patient_id(index)
|
154
|
+
attr_name = :"local_patient_id_#{index}"
|
155
|
+
id_value = send(attr_name)
|
156
|
+
send("#{attr_name}=", id_value.upcase) if id_value.present?
|
157
|
+
end
|
158
|
+
|
157
159
|
def has_title?
|
158
160
|
respond_to?(:title) && title.present?
|
159
161
|
end
|
@@ -13,19 +13,23 @@
|
|
13
13
|
module Renalware
|
14
14
|
module Patients
|
15
15
|
class SearchQuery
|
16
|
-
attr_reader :term
|
17
16
|
|
18
|
-
|
17
|
+
# FIELDS = %i(id family_name given_name nhs_number).freeze
|
18
|
+
attr_reader :term, :scope
|
19
|
+
|
20
|
+
def initialize(scope: Patient.all, term:)
|
19
21
|
@term = term
|
22
|
+
@scope = scope
|
20
23
|
end
|
21
24
|
|
22
25
|
def call
|
23
26
|
search.result
|
24
27
|
end
|
25
28
|
|
29
|
+
# .select(FIELDS)
|
26
30
|
def search
|
27
31
|
@search ||= begin
|
28
|
-
|
32
|
+
scope
|
29
33
|
.search(identity_match: term).tap do |search|
|
30
34
|
search.sorts = %w(family_name given_name)
|
31
35
|
end
|
@@ -14,7 +14,9 @@ module Renalware
|
|
14
14
|
Regime.transaction do
|
15
15
|
regime.assign_attributes(params)
|
16
16
|
return ::Renalware::Success.new(regime) unless regime.anything_changed?
|
17
|
-
|
17
|
+
unless regime.valid?
|
18
|
+
return ::Renalware::Failure.new(regime.with_bag_destruction_marks_removed)
|
19
|
+
end
|
18
20
|
|
19
21
|
new_regime = revise_regime(by: by)
|
20
22
|
::Renalware::Success.new(new_regime)
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require_dependency "renalware/renal"
|
2
|
+
|
3
|
+
module Renalware
|
4
|
+
module Renal
|
5
|
+
module Registry
|
6
|
+
module PreflightChecks
|
7
|
+
class DeathsQuery
|
8
|
+
include ModalityScopes
|
9
|
+
MODALITY_NAMES = %w(Death).freeze
|
10
|
+
|
11
|
+
attr_reader :relation
|
12
|
+
|
13
|
+
def initialize(relation = default_relation)
|
14
|
+
@relation = relation
|
15
|
+
end
|
16
|
+
|
17
|
+
def default_relation
|
18
|
+
Renalware::Patient
|
19
|
+
.preload(current_modality: [:description])
|
20
|
+
.all
|
21
|
+
.order(family_name: :asc)
|
22
|
+
end
|
23
|
+
|
24
|
+
def call
|
25
|
+
relation
|
26
|
+
.extending(ModalityScopes)
|
27
|
+
.with_current_modality_matching(MODALITY_NAMES)
|
28
|
+
.joins("LEFT OUTER JOIN renal_profiles ON renal_profiles.patient_id = patients.id")
|
29
|
+
.where("patients.first_cause_id is NULL AND renal_profiles.esrf_on IS NOT NULL")
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.missing_data_for(patient)
|
33
|
+
[
|
34
|
+
:cause_of_death
|
35
|
+
]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|