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,47 @@
|
|
1
|
+
SELECT p.id,
|
2
|
+
p.secure_id,
|
3
|
+
(upper(p.family_name::text) || ', '::text) || p.given_name::text AS patient_name,
|
4
|
+
p.nhs_number,
|
5
|
+
p.local_patient_id AS hospital_numbers,
|
6
|
+
p.sex,
|
7
|
+
p.born_on,
|
8
|
+
rprof.esrf_on,
|
9
|
+
latest_op.performed_on AS last_operation_date,
|
10
|
+
date_part('year'::text, age(p.born_on::timestamp with time zone))::integer AS age,
|
11
|
+
mx.modality_name,
|
12
|
+
case when pw.id > 0 then 'Y' else 'N' end as on_worryboard,
|
13
|
+
(select bmi from clinic_visits cv2 where cv2.patient_id = P.id and bmi > 0 order by date desc limit 1) as bmi,
|
14
|
+
case when latest_op.performed_on >= (now() - interval '3 months') then true else false end as tx_in_past_3m,
|
15
|
+
case when latest_op.performed_on >= (now() - interval '12 months') then true else false end as tx_in_past_12m,
|
16
|
+
txrsd.name AS tx_status,
|
17
|
+
(pa."values" -> 'HGB'::text) ->> 'result'::text AS hgb,
|
18
|
+
((pa."values" -> 'HGB'::text) ->> 'observed_at'::text)::date AS hgb_date,
|
19
|
+
(pa."values" -> 'URE'::text) ->> 'result'::text AS ure,
|
20
|
+
((pa."values" -> 'URE'::text) ->> 'observed_at'::text)::date AS ure_date,
|
21
|
+
(pa."values" -> 'CRE'::text) ->> 'result'::text AS cre,
|
22
|
+
((pa."values" -> 'CRE'::text) ->> 'observed_at'::text)::date AS cre_date,
|
23
|
+
(pa."values" -> 'EGFR'::text) ->> 'result'::text AS egfr_on
|
24
|
+
FROM patients p
|
25
|
+
JOIN patient_current_modalities mx ON mx.patient_id = p.id AND mx.modality_code::text = 'transplant'::text
|
26
|
+
LEFT JOIN pathology_current_observation_sets pa ON pa.patient_id = p.id
|
27
|
+
LEFT join patient_worries pw on pw.patient_id = p.id
|
28
|
+
LEFT JOIN transplant_registrations txr ON txr.patient_id = p.id
|
29
|
+
LEFT JOIN transplant_registration_statuses txrs ON txrs.registration_id = txr.id AND txrs.terminated_on IS NULL
|
30
|
+
LEFT JOIN transplant_registration_status_descriptions txrsd ON txrsd.id = txrs.description_id
|
31
|
+
LEFT JOIN renal_profiles rprof ON rprof.patient_id = p.id
|
32
|
+
LEFT JOIN ( SELECT DISTINCT ON (transplant_recipient_operations.patient_id) transplant_recipient_operations.id,
|
33
|
+
transplant_recipient_operations.patient_id,
|
34
|
+
transplant_recipient_operations.performed_on,
|
35
|
+
transplant_recipient_operations.theatre_case_start_time,
|
36
|
+
transplant_recipient_operations.donor_kidney_removed_from_ice_at,
|
37
|
+
transplant_recipient_operations.operation_type,
|
38
|
+
transplant_recipient_operations.hospital_centre_id,
|
39
|
+
transplant_recipient_operations.kidney_perfused_with_blood_at,
|
40
|
+
transplant_recipient_operations.cold_ischaemic_time,
|
41
|
+
transplant_recipient_operations.warm_ischaemic_time,
|
42
|
+
transplant_recipient_operations.notes,
|
43
|
+
transplant_recipient_operations.document,
|
44
|
+
transplant_recipient_operations.created_at,
|
45
|
+
transplant_recipient_operations.updated_at
|
46
|
+
FROM transplant_recipient_operations
|
47
|
+
ORDER BY transplant_recipient_operations.patient_id, transplant_recipient_operations.performed_on DESC) latest_op ON latest_op.patient_id = p.id;
|
@@ -108,6 +108,7 @@ module Renalware
|
|
108
108
|
config_accessor(:generate_pathology_request_forms_from_hd_mdm_listing) { true }
|
109
109
|
config_accessor(:disable_inputs_controlled_by_tissue_typing_feed) { false }
|
110
110
|
config_accessor(:disable_inputs_controlled_by_demographics_feed) { false }
|
111
|
+
config_accessor(:enforce_user_prescriber_flag) { false }
|
111
112
|
config_accessor(:medication_delivery_purchase_order_prefix) { "R" }
|
112
113
|
config_accessor(:medication_homecare_pdf_forms) do
|
113
114
|
# esa: { provider: :generic, version: 1 },
|
@@ -128,6 +129,7 @@ module Renalware
|
|
128
129
|
Renalware::Admissions::SummaryPart
|
129
130
|
Renalware::Admissions::ConsultSummaryPart
|
130
131
|
Renalware::Patients::SummaryPart
|
132
|
+
Renalware::Patients::MessagesComponent
|
131
133
|
)
|
132
134
|
}
|
133
135
|
}
|
data/lib/renalware/engine.rb
CHANGED
@@ -22,7 +22,6 @@ require "dumb_delegator"
|
|
22
22
|
require "email_validator"
|
23
23
|
require "enumerize"
|
24
24
|
require "font-awesome-sass"
|
25
|
-
require "foundation-rails"
|
26
25
|
require "friendly_id"
|
27
26
|
require "groupdate"
|
28
27
|
require "hashdiff"
|
@@ -53,6 +52,7 @@ require "ruby-hl7"
|
|
53
52
|
require "sass-rails"
|
54
53
|
require "scenic"
|
55
54
|
require "slim-rails"
|
55
|
+
require "store_model"
|
56
56
|
require "uglifier"
|
57
57
|
require "validates_timeliness"
|
58
58
|
require "virtus"
|
@@ -92,7 +92,7 @@ module Renalware
|
|
92
92
|
end
|
93
93
|
|
94
94
|
initializer :add_locales do |app|
|
95
|
-
app.config.i18n.load_path += Dir[config.root.join("config
|
95
|
+
app.config.i18n.load_path += Dir[config.root.join("config/locales/**/*.{rb,yml}")]
|
96
96
|
app.config.i18n.default_locale = "en-GB"
|
97
97
|
app.config.i18n.fallbacks = [:en]
|
98
98
|
end
|
data/lib/tasks/db.rake
CHANGED
@@ -3,6 +3,14 @@
|
|
3
3
|
require "benchmark"
|
4
4
|
|
5
5
|
namespace :db do
|
6
|
+
desc "Check that we are not about to drop an anonymised database"
|
7
|
+
task drop_check: :environment do
|
8
|
+
db_name = "rw_anon"
|
9
|
+
if Rails.configuration.database_configuration[Rails.env]["database"] == db_name
|
10
|
+
raise ActiveRecord::ProtectedEnvironmentError, "Cannot drop #{db_name}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
6
14
|
desc "Refreshes all materialized views e.g. audits. May take a while so only run overnight."
|
7
15
|
task refresh_all_materialized_views: :environment do
|
8
16
|
ms = Benchmark.ms do
|
@@ -22,3 +30,4 @@ namespace :db do
|
|
22
30
|
end
|
23
31
|
end
|
24
32
|
end
|
33
|
+
task("db:drop").enhance ["db:drop_check"]
|
data/lib/tasks/pd.rake
CHANGED
@@ -29,4 +29,32 @@ namespace :pd do
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
32
|
+
|
33
|
+
desc "Useful to call this after migrating PET and Adequacy results from the legacy "\
|
34
|
+
"pd_pet_adequacies table. It simulates eding a result and saving it in the UI, which "\
|
35
|
+
"triggers the calculations to be redone"
|
36
|
+
task apply_pet_adequacy_calculations: :environment do
|
37
|
+
Rails.logger = Logger.new(STDOUT)
|
38
|
+
Rails.logger.info "Regenerate all PET calcs"
|
39
|
+
count = 0
|
40
|
+
Renalware::PD::PETResult.find_in_batches(batch_size: 500) do |group|
|
41
|
+
count += group.length
|
42
|
+
group.each do |pet|
|
43
|
+
pet.by = pet.updated_by
|
44
|
+
pet.save(validate: false)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
Rails.logger.info "Total PETResults = #{count}"
|
48
|
+
|
49
|
+
Rails.logger.info "Regenerate all Adequacy calcs"
|
50
|
+
count = 0
|
51
|
+
Renalware::PD::AdequacyResult.find_in_batches(batch_size: 500) do |group|
|
52
|
+
count += group.length
|
53
|
+
group.each do |adequacy|
|
54
|
+
adequacy.by = adequacy.updated_by
|
55
|
+
adequacy.save(validate: false)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
Rails.logger.info "Total AdequacyResults = #{count}"
|
59
|
+
end
|
32
60
|
end
|
@@ -2,8 +2,12 @@
|
|
2
2
|
|
3
3
|
FactoryBot.define do
|
4
4
|
factory :drug_type, class: "Renalware::Drugs::Type" do
|
5
|
+
initialize_with do
|
6
|
+
Renalware::Drugs::Type.find_or_create_by!(code: code, name: name)
|
7
|
+
end
|
8
|
+
|
5
9
|
code { "immuno" }
|
6
|
-
name { "
|
10
|
+
name { "immuno" }
|
7
11
|
|
8
12
|
trait :immunosuppressant do
|
9
13
|
code { "immunosuppressant" }
|
@@ -18,6 +18,7 @@ FactoryBot.define do
|
|
18
18
|
approved { true }
|
19
19
|
professional_position { "Health Minister" }
|
20
20
|
signature { Faker::Name.name }
|
21
|
+
prescriber { true }
|
21
22
|
|
22
23
|
# By default a user has no roles.
|
23
24
|
# If you want a use with a role, use a trait, e.g. create(:user, :clinical)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
FactoryBot.define do
|
4
|
+
factory :view_metadata, class: "Renalware::System::ViewMetadata" do
|
5
|
+
schema_name { "renalware" }
|
6
|
+
view_name { "transplant_mdm_patients" }
|
7
|
+
title { "Title" }
|
8
|
+
slug { "all" }
|
9
|
+
category { "mdm" }
|
10
|
+
scope { "transplant" }
|
11
|
+
columns { [] }
|
12
|
+
filters {
|
13
|
+
[
|
14
|
+
Renalware::System::FilterDefinition.new(code: :sex, type: :list),
|
15
|
+
Renalware::System::FilterDefinition.new(code: :age, type: :search)
|
16
|
+
]
|
17
|
+
}
|
18
|
+
position { 1 }
|
19
|
+
end
|
20
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# rubocop:disable Metrics/MethodLength
|
4
4
|
module LettersSpecHelper
|
5
|
-
def build_letter(state: :draft,
|
5
|
+
def build_letter(to:, patient:, state: :draft, **args)
|
6
6
|
trait = "#{state}_letter".to_sym
|
7
7
|
letter = build(trait, **args)
|
8
8
|
letter.patient = patient
|
@@ -3,7 +3,7 @@
|
|
3
3
|
RSpec::Matchers.define :validate_timeliness_of do |attribute|
|
4
4
|
match do |model|
|
5
5
|
model._validators[attribute.to_sym].detect do |validator|
|
6
|
-
validator.
|
6
|
+
validator.instance_of?(ActiveModel::Validations::TimelinessValidator) &&
|
7
7
|
validator.attributes.include?(attribute)
|
8
8
|
end
|
9
9
|
end
|
@@ -20,11 +20,10 @@ module PathologySpecHelper
|
|
20
20
|
end
|
21
21
|
|
22
22
|
# rubocop:disable Metrics/ParameterLists, Metrics/MethodLength
|
23
|
-
def create_request_with_observations(requestor_order_number: "123",
|
23
|
+
def create_request_with_observations(patient:, requestor_order_number: "123",
|
24
24
|
obr_code: "OBR1",
|
25
25
|
obx_codes: ["OBX1"],
|
26
26
|
requested_at: 1.year.ago,
|
27
|
-
patient:,
|
28
27
|
created_at: nil,
|
29
28
|
count: 1,
|
30
29
|
result: "1.1")
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PolicySpecHelper
|
4
|
+
def user_double_with_role(role)
|
5
|
+
instance_double(Renalware::User).tap do |user|
|
6
|
+
allow(user).to receive(:has_role?).and_return(false)
|
7
|
+
allow(user).to receive(:has_role?).with(role).and_return(true)
|
8
|
+
allow(user).to receive(:roles).and_return([role])
|
9
|
+
allow(user).to receive(:role_names).and_return([role.to_s])
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
;(function ($, window, document, undefined) {
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
Foundation.libs.alert = {
|
5
|
+
name : 'alert',
|
6
|
+
|
7
|
+
version : '5.5.3',
|
8
|
+
|
9
|
+
settings : {
|
10
|
+
callback : function () {}
|
11
|
+
},
|
12
|
+
|
13
|
+
init : function (scope, method, options) {
|
14
|
+
this.bindings(method, options);
|
15
|
+
},
|
16
|
+
|
17
|
+
events : function () {
|
18
|
+
var self = this,
|
19
|
+
S = this.S;
|
20
|
+
|
21
|
+
$(this.scope).off('.alert').on('click.fndtn.alert', '[' + this.attr_name() + '] .close', function (e) {
|
22
|
+
var alertBox = S(this).closest('[' + self.attr_name() + ']'),
|
23
|
+
settings = alertBox.data(self.attr_name(true) + '-init') || self.settings;
|
24
|
+
|
25
|
+
e.preventDefault();
|
26
|
+
if (Modernizr.csstransitions) {
|
27
|
+
alertBox.addClass('alert-close');
|
28
|
+
alertBox.on('transitionend webkitTransitionEnd oTransitionEnd', function (e) {
|
29
|
+
S(this).trigger('close.fndtn.alert').remove();
|
30
|
+
settings.callback();
|
31
|
+
});
|
32
|
+
} else {
|
33
|
+
alertBox.fadeOut(300, function () {
|
34
|
+
S(this).trigger('close.fndtn.alert').remove();
|
35
|
+
settings.callback();
|
36
|
+
});
|
37
|
+
}
|
38
|
+
});
|
39
|
+
},
|
40
|
+
|
41
|
+
reflow : function () {}
|
42
|
+
};
|
43
|
+
}(jQuery, window, window.document));
|
@@ -0,0 +1,468 @@
|
|
1
|
+
;(function ($, window, document, undefined) {
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
Foundation.libs.dropdown = {
|
5
|
+
name : 'dropdown',
|
6
|
+
|
7
|
+
version : '5.5.3',
|
8
|
+
|
9
|
+
settings : {
|
10
|
+
active_class : 'open',
|
11
|
+
disabled_class : 'disabled',
|
12
|
+
mega_class : 'mega',
|
13
|
+
align : 'bottom',
|
14
|
+
is_hover : false,
|
15
|
+
hover_timeout : 150,
|
16
|
+
opened : function () {},
|
17
|
+
closed : function () {}
|
18
|
+
},
|
19
|
+
|
20
|
+
init : function (scope, method, options) {
|
21
|
+
Foundation.inherit(this, 'throttle');
|
22
|
+
|
23
|
+
$.extend(true, this.settings, method, options);
|
24
|
+
this.bindings(method, options);
|
25
|
+
},
|
26
|
+
|
27
|
+
events : function (scope) {
|
28
|
+
var self = this,
|
29
|
+
S = self.S;
|
30
|
+
|
31
|
+
S(this.scope)
|
32
|
+
.off('.dropdown')
|
33
|
+
.on('click.fndtn.dropdown', '[' + this.attr_name() + ']', function (e) {
|
34
|
+
var settings = S(this).data(self.attr_name(true) + '-init') || self.settings;
|
35
|
+
if (!settings.is_hover || Modernizr.touch) {
|
36
|
+
e.preventDefault();
|
37
|
+
if (S(this).parent('[data-reveal-id]').length) {
|
38
|
+
e.stopPropagation();
|
39
|
+
}
|
40
|
+
self.toggle($(this));
|
41
|
+
}
|
42
|
+
})
|
43
|
+
.on('mouseenter.fndtn.dropdown', '[' + this.attr_name() + '], [' + this.attr_name() + '-content]', function (e) {
|
44
|
+
var $this = S(this),
|
45
|
+
dropdown,
|
46
|
+
target;
|
47
|
+
|
48
|
+
clearTimeout(self.timeout);
|
49
|
+
|
50
|
+
if ($this.data(self.data_attr())) {
|
51
|
+
dropdown = S('#' + $this.data(self.data_attr()));
|
52
|
+
target = $this;
|
53
|
+
} else {
|
54
|
+
dropdown = $this;
|
55
|
+
target = S('[' + self.attr_name() + '="' + dropdown.attr('id') + '"]');
|
56
|
+
}
|
57
|
+
|
58
|
+
var settings = target.data(self.attr_name(true) + '-init') || self.settings;
|
59
|
+
|
60
|
+
if (S(e.currentTarget).data(self.data_attr()) && settings.is_hover) {
|
61
|
+
self.closeall.call(self);
|
62
|
+
}
|
63
|
+
|
64
|
+
if (settings.is_hover) {
|
65
|
+
self.open.apply(self, [dropdown, target]);
|
66
|
+
}
|
67
|
+
})
|
68
|
+
.on('mouseleave.fndtn.dropdown', '[' + this.attr_name() + '], [' + this.attr_name() + '-content]', function (e) {
|
69
|
+
var $this = S(this);
|
70
|
+
var settings;
|
71
|
+
|
72
|
+
if ($this.data(self.data_attr())) {
|
73
|
+
settings = $this.data(self.data_attr(true) + '-init') || self.settings;
|
74
|
+
} else {
|
75
|
+
var target = S('[' + self.attr_name() + '="' + S(this).attr('id') + '"]'),
|
76
|
+
settings = target.data(self.attr_name(true) + '-init') || self.settings;
|
77
|
+
}
|
78
|
+
|
79
|
+
self.timeout = setTimeout(function () {
|
80
|
+
if ($this.data(self.data_attr())) {
|
81
|
+
if (settings.is_hover) {
|
82
|
+
self.close.call(self, S('#' + $this.data(self.data_attr())));
|
83
|
+
}
|
84
|
+
} else {
|
85
|
+
if (settings.is_hover) {
|
86
|
+
self.close.call(self, $this);
|
87
|
+
}
|
88
|
+
}
|
89
|
+
}.bind(this), settings.hover_timeout);
|
90
|
+
})
|
91
|
+
.on('click.fndtn.dropdown', function (e) {
|
92
|
+
var parent = S(e.target).closest('[' + self.attr_name() + '-content]');
|
93
|
+
var links = parent.find('a');
|
94
|
+
|
95
|
+
if (links.length > 0 && parent.attr('aria-autoclose') !== 'false') {
|
96
|
+
self.close.call(self, S('[' + self.attr_name() + '-content]'));
|
97
|
+
}
|
98
|
+
|
99
|
+
if (e.target !== document && !$.contains(document.documentElement, e.target)) {
|
100
|
+
return;
|
101
|
+
}
|
102
|
+
|
103
|
+
if (S(e.target).closest('[' + self.attr_name() + ']').length > 0) {
|
104
|
+
return;
|
105
|
+
}
|
106
|
+
|
107
|
+
if (!(S(e.target).data('revealId')) &&
|
108
|
+
(parent.length > 0 && (S(e.target).is('[' + self.attr_name() + '-content]') ||
|
109
|
+
$.contains(parent.first()[0], e.target)))) {
|
110
|
+
e.stopPropagation();
|
111
|
+
return;
|
112
|
+
}
|
113
|
+
|
114
|
+
self.close.call(self, S('[' + self.attr_name() + '-content]'));
|
115
|
+
})
|
116
|
+
.on('opened.fndtn.dropdown', '[' + self.attr_name() + '-content]', function () {
|
117
|
+
self.settings.opened.call(this);
|
118
|
+
})
|
119
|
+
.on('closed.fndtn.dropdown', '[' + self.attr_name() + '-content]', function () {
|
120
|
+
self.settings.closed.call(this);
|
121
|
+
});
|
122
|
+
|
123
|
+
S(window)
|
124
|
+
.off('.dropdown')
|
125
|
+
.on('resize.fndtn.dropdown', self.throttle(function () {
|
126
|
+
self.resize.call(self);
|
127
|
+
}, 50));
|
128
|
+
|
129
|
+
this.resize();
|
130
|
+
},
|
131
|
+
|
132
|
+
close : function (dropdown) {
|
133
|
+
var self = this;
|
134
|
+
dropdown.each(function (idx) {
|
135
|
+
var original_target = $('[' + self.attr_name() + '=' + dropdown[idx].id + ']') || $('aria-controls=' + dropdown[idx].id + ']');
|
136
|
+
original_target.attr('aria-expanded', 'false');
|
137
|
+
if (self.S(this).hasClass(self.settings.active_class)) {
|
138
|
+
self.S(this)
|
139
|
+
.css(Foundation.rtl ? 'right' : 'left', '-99999px')
|
140
|
+
.attr('aria-hidden', 'true')
|
141
|
+
.removeClass(self.settings.active_class)
|
142
|
+
.prev('[' + self.attr_name() + ']')
|
143
|
+
.removeClass(self.settings.active_class)
|
144
|
+
.removeData('target');
|
145
|
+
|
146
|
+
self.S(this).trigger('closed.fndtn.dropdown', [dropdown]);
|
147
|
+
}
|
148
|
+
});
|
149
|
+
dropdown.removeClass('f-open-' + this.attr_name(true));
|
150
|
+
},
|
151
|
+
|
152
|
+
closeall : function () {
|
153
|
+
var self = this;
|
154
|
+
$.each(self.S('.f-open-' + this.attr_name(true)), function () {
|
155
|
+
self.close.call(self, self.S(this));
|
156
|
+
});
|
157
|
+
},
|
158
|
+
|
159
|
+
open : function (dropdown, target) {
|
160
|
+
this
|
161
|
+
.css(dropdown
|
162
|
+
.addClass(this.settings.active_class), target);
|
163
|
+
dropdown.prev('[' + this.attr_name() + ']').addClass(this.settings.active_class);
|
164
|
+
dropdown.data('target', target.get(0)).trigger('opened.fndtn.dropdown', [dropdown, target]);
|
165
|
+
dropdown.attr('aria-hidden', 'false');
|
166
|
+
target.attr('aria-expanded', 'true');
|
167
|
+
dropdown.focus();
|
168
|
+
dropdown.addClass('f-open-' + this.attr_name(true));
|
169
|
+
},
|
170
|
+
|
171
|
+
data_attr : function () {
|
172
|
+
if (this.namespace.length > 0) {
|
173
|
+
return this.namespace + '-' + this.name;
|
174
|
+
}
|
175
|
+
|
176
|
+
return this.name;
|
177
|
+
},
|
178
|
+
|
179
|
+
toggle : function (target) {
|
180
|
+
if (target.hasClass(this.settings.disabled_class)) {
|
181
|
+
return;
|
182
|
+
}
|
183
|
+
var dropdown = this.S('#' + target.data(this.data_attr()));
|
184
|
+
if (dropdown.length === 0) {
|
185
|
+
// No dropdown found, not continuing
|
186
|
+
return;
|
187
|
+
}
|
188
|
+
|
189
|
+
this.close.call(this, this.S('[' + this.attr_name() + '-content]').not(dropdown));
|
190
|
+
|
191
|
+
if (dropdown.hasClass(this.settings.active_class)) {
|
192
|
+
this.close.call(this, dropdown);
|
193
|
+
if (dropdown.data('target') !== target.get(0)) {
|
194
|
+
this.open.call(this, dropdown, target);
|
195
|
+
}
|
196
|
+
} else {
|
197
|
+
this.open.call(this, dropdown, target);
|
198
|
+
}
|
199
|
+
},
|
200
|
+
|
201
|
+
resize : function () {
|
202
|
+
var dropdown = this.S('[' + this.attr_name() + '-content].open');
|
203
|
+
var target = $(dropdown.data("target"));
|
204
|
+
|
205
|
+
if (dropdown.length && target.length) {
|
206
|
+
this.css(dropdown, target);
|
207
|
+
}
|
208
|
+
},
|
209
|
+
|
210
|
+
css : function (dropdown, target) {
|
211
|
+
var left_offset = Math.max((target.width() - dropdown.width()) / 2, 8),
|
212
|
+
settings = target.data(this.attr_name(true) + '-init') || this.settings,
|
213
|
+
parentOverflow = dropdown.parent().css('overflow-y') || dropdown.parent().css('overflow');
|
214
|
+
|
215
|
+
this.clear_idx();
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
if (this.small()) {
|
220
|
+
var p = this.dirs.bottom.call(dropdown, target, settings);
|
221
|
+
|
222
|
+
dropdown.attr('style', '').removeClass('drop-left drop-right drop-top').css({
|
223
|
+
position : 'absolute',
|
224
|
+
width : '95%',
|
225
|
+
'max-width' : 'none',
|
226
|
+
top : p.top
|
227
|
+
});
|
228
|
+
|
229
|
+
dropdown.css(Foundation.rtl ? 'right' : 'left', left_offset);
|
230
|
+
}
|
231
|
+
// detect if dropdown is in an overflow container
|
232
|
+
else if (parentOverflow !== 'visible') {
|
233
|
+
var offset = target[0].offsetTop + target[0].offsetHeight;
|
234
|
+
|
235
|
+
dropdown.attr('style', '').css({
|
236
|
+
position : 'absolute',
|
237
|
+
top : offset
|
238
|
+
});
|
239
|
+
|
240
|
+
dropdown.css(Foundation.rtl ? 'right' : 'left', left_offset);
|
241
|
+
}
|
242
|
+
else {
|
243
|
+
|
244
|
+
this.style(dropdown, target, settings);
|
245
|
+
}
|
246
|
+
|
247
|
+
return dropdown;
|
248
|
+
},
|
249
|
+
|
250
|
+
style : function (dropdown, target, settings) {
|
251
|
+
var css = $.extend({position : 'absolute'},
|
252
|
+
this.dirs[settings.align].call(dropdown, target, settings));
|
253
|
+
|
254
|
+
dropdown.attr('style', '').css(css);
|
255
|
+
},
|
256
|
+
|
257
|
+
// return CSS property object
|
258
|
+
// `this` is the dropdown
|
259
|
+
dirs : {
|
260
|
+
// Calculate target offset
|
261
|
+
_base : function (t, s) {
|
262
|
+
var o_p = this.offsetParent(),
|
263
|
+
o = o_p.offset(),
|
264
|
+
p = t.offset();
|
265
|
+
|
266
|
+
p.top -= o.top;
|
267
|
+
p.left -= o.left;
|
268
|
+
|
269
|
+
//set some flags on the p object to pass along
|
270
|
+
p.missRight = false;
|
271
|
+
p.missTop = false;
|
272
|
+
p.missLeft = false;
|
273
|
+
p.leftRightFlag = false;
|
274
|
+
|
275
|
+
//lets see if the panel will be off the screen
|
276
|
+
//get the actual width of the page and store it
|
277
|
+
var actualBodyWidth;
|
278
|
+
var windowWidth = window.innerWidth;
|
279
|
+
|
280
|
+
if (document.getElementsByClassName('row')[0]) {
|
281
|
+
actualBodyWidth = document.getElementsByClassName('row')[0].clientWidth;
|
282
|
+
} else {
|
283
|
+
actualBodyWidth = windowWidth;
|
284
|
+
}
|
285
|
+
|
286
|
+
var actualMarginWidth = (windowWidth - actualBodyWidth) / 2;
|
287
|
+
var actualBoundary = actualBodyWidth;
|
288
|
+
|
289
|
+
if (!this.hasClass('mega') && !s.ignore_repositioning) {
|
290
|
+
var outerWidth = this.outerWidth();
|
291
|
+
var o_left = t.offset().left;
|
292
|
+
|
293
|
+
//miss top
|
294
|
+
if (t.offset().top <= this.outerHeight()) {
|
295
|
+
p.missTop = true;
|
296
|
+
actualBoundary = windowWidth - actualMarginWidth;
|
297
|
+
p.leftRightFlag = true;
|
298
|
+
}
|
299
|
+
|
300
|
+
//miss right
|
301
|
+
if (o_left + outerWidth > o_left + actualMarginWidth && o_left - actualMarginWidth > outerWidth) {
|
302
|
+
p.missRight = true;
|
303
|
+
p.missLeft = false;
|
304
|
+
}
|
305
|
+
|
306
|
+
//miss left
|
307
|
+
if (o_left - outerWidth <= 0) {
|
308
|
+
p.missLeft = true;
|
309
|
+
p.missRight = false;
|
310
|
+
}
|
311
|
+
}
|
312
|
+
|
313
|
+
return p;
|
314
|
+
},
|
315
|
+
|
316
|
+
top : function (t, s) {
|
317
|
+
var self = Foundation.libs.dropdown,
|
318
|
+
p = self.dirs._base.call(this, t, s);
|
319
|
+
|
320
|
+
this.addClass('drop-top');
|
321
|
+
|
322
|
+
if (p.missTop == true) {
|
323
|
+
p.top = p.top + t.outerHeight() + this.outerHeight();
|
324
|
+
this.removeClass('drop-top');
|
325
|
+
}
|
326
|
+
|
327
|
+
if (p.missRight == true) {
|
328
|
+
p.left = p.left - this.outerWidth() + t.outerWidth();
|
329
|
+
}
|
330
|
+
|
331
|
+
if (t.outerWidth() < this.outerWidth() || self.small() || this.hasClass(s.mega_menu)) {
|
332
|
+
self.adjust_pip(this, t, s, p);
|
333
|
+
}
|
334
|
+
|
335
|
+
if (Foundation.rtl) {
|
336
|
+
return {left : p.left - this.outerWidth() + t.outerWidth(),
|
337
|
+
top : p.top - this.outerHeight()};
|
338
|
+
}
|
339
|
+
|
340
|
+
return {left : p.left, top : p.top - this.outerHeight()};
|
341
|
+
},
|
342
|
+
|
343
|
+
bottom : function (t, s) {
|
344
|
+
var self = Foundation.libs.dropdown,
|
345
|
+
p = self.dirs._base.call(this, t, s);
|
346
|
+
|
347
|
+
if (p.missRight == true) {
|
348
|
+
p.left = p.left - this.outerWidth() + t.outerWidth();
|
349
|
+
}
|
350
|
+
|
351
|
+
if (t.outerWidth() < this.outerWidth() || self.small() || this.hasClass(s.mega_menu)) {
|
352
|
+
self.adjust_pip(this, t, s, p);
|
353
|
+
}
|
354
|
+
|
355
|
+
if (self.rtl) {
|
356
|
+
return {left : p.left - this.outerWidth() + t.outerWidth(), top : p.top + t.outerHeight()};
|
357
|
+
}
|
358
|
+
|
359
|
+
return {left : p.left, top : p.top + t.outerHeight()};
|
360
|
+
},
|
361
|
+
|
362
|
+
left : function (t, s) {
|
363
|
+
var p = Foundation.libs.dropdown.dirs._base.call(this, t, s);
|
364
|
+
|
365
|
+
this.addClass('drop-left');
|
366
|
+
|
367
|
+
if (p.missLeft == true) {
|
368
|
+
p.left = p.left + this.outerWidth();
|
369
|
+
p.top = p.top + t.outerHeight();
|
370
|
+
this.removeClass('drop-left');
|
371
|
+
}
|
372
|
+
|
373
|
+
return {left : p.left - this.outerWidth(), top : p.top};
|
374
|
+
},
|
375
|
+
|
376
|
+
right : function (t, s) {
|
377
|
+
var p = Foundation.libs.dropdown.dirs._base.call(this, t, s);
|
378
|
+
|
379
|
+
this.addClass('drop-right');
|
380
|
+
|
381
|
+
if (p.missRight == true) {
|
382
|
+
p.left = p.left - this.outerWidth();
|
383
|
+
p.top = p.top + t.outerHeight();
|
384
|
+
this.removeClass('drop-right');
|
385
|
+
} else {
|
386
|
+
p.triggeredRight = true;
|
387
|
+
}
|
388
|
+
|
389
|
+
var self = Foundation.libs.dropdown;
|
390
|
+
|
391
|
+
if (t.outerWidth() < this.outerWidth() || self.small() || this.hasClass(s.mega_menu)) {
|
392
|
+
self.adjust_pip(this, t, s, p);
|
393
|
+
}
|
394
|
+
|
395
|
+
return {left : p.left + t.outerWidth(), top : p.top};
|
396
|
+
}
|
397
|
+
},
|
398
|
+
|
399
|
+
// Insert rule to style psuedo elements
|
400
|
+
adjust_pip : function (dropdown, target, settings, position) {
|
401
|
+
var sheet = Foundation.stylesheet,
|
402
|
+
pip_offset_base = 8;
|
403
|
+
|
404
|
+
if (dropdown.hasClass(settings.mega_class)) {
|
405
|
+
pip_offset_base = position.left + (target.outerWidth() / 2) - 8;
|
406
|
+
} else if (this.small()) {
|
407
|
+
pip_offset_base += position.left - 8;
|
408
|
+
}
|
409
|
+
|
410
|
+
this.rule_idx = sheet.cssRules.length;
|
411
|
+
|
412
|
+
//default
|
413
|
+
var sel_before = '.f-dropdown.open:before',
|
414
|
+
sel_after = '.f-dropdown.open:after',
|
415
|
+
css_before = 'left: ' + pip_offset_base + 'px;',
|
416
|
+
css_after = 'left: ' + (pip_offset_base - 1) + 'px;';
|
417
|
+
|
418
|
+
if (position.missRight == true) {
|
419
|
+
pip_offset_base = dropdown.outerWidth() - 23;
|
420
|
+
sel_before = '.f-dropdown.open:before',
|
421
|
+
sel_after = '.f-dropdown.open:after',
|
422
|
+
css_before = 'left: ' + pip_offset_base + 'px;',
|
423
|
+
css_after = 'left: ' + (pip_offset_base - 1) + 'px;';
|
424
|
+
}
|
425
|
+
|
426
|
+
//just a case where right is fired, but its not missing right
|
427
|
+
if (position.triggeredRight == true) {
|
428
|
+
sel_before = '.f-dropdown.open:before',
|
429
|
+
sel_after = '.f-dropdown.open:after',
|
430
|
+
css_before = 'left:-12px;',
|
431
|
+
css_after = 'left:-14px;';
|
432
|
+
}
|
433
|
+
|
434
|
+
if (sheet.insertRule) {
|
435
|
+
sheet.insertRule([sel_before, '{', css_before, '}'].join(' '), this.rule_idx);
|
436
|
+
sheet.insertRule([sel_after, '{', css_after, '}'].join(' '), this.rule_idx + 1);
|
437
|
+
} else {
|
438
|
+
sheet.addRule(sel_before, css_before, this.rule_idx);
|
439
|
+
sheet.addRule(sel_after, css_after, this.rule_idx + 1);
|
440
|
+
}
|
441
|
+
},
|
442
|
+
|
443
|
+
// Remove old dropdown rule index
|
444
|
+
clear_idx : function () {
|
445
|
+
var sheet = Foundation.stylesheet;
|
446
|
+
|
447
|
+
if (typeof this.rule_idx !== 'undefined') {
|
448
|
+
sheet.deleteRule(this.rule_idx);
|
449
|
+
sheet.deleteRule(this.rule_idx);
|
450
|
+
delete this.rule_idx;
|
451
|
+
}
|
452
|
+
},
|
453
|
+
|
454
|
+
small : function () {
|
455
|
+
return matchMedia(Foundation.media_queries.small).matches &&
|
456
|
+
!matchMedia(Foundation.media_queries.medium).matches;
|
457
|
+
},
|
458
|
+
|
459
|
+
off : function () {
|
460
|
+
this.S(this.scope).off('.fndtn.dropdown');
|
461
|
+
this.S('html, body').off('.fndtn.dropdown');
|
462
|
+
this.S(window).off('.fndtn.dropdown');
|
463
|
+
this.S('[data-dropdown-content]').off('.fndtn.dropdown');
|
464
|
+
},
|
465
|
+
|
466
|
+
reflow : function () {}
|
467
|
+
};
|
468
|
+
}(jQuery, window, window.document));
|