renalware-core 2.0.149 → 2.0.151
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +23 -2
- data/app/assets/config/renalware/core/manifest.js +1 -0
- data/app/assets/images/renalware/icons/align-justify.svg +3 -0
- data/app/assets/images/renalware/icons/bar-chart.svg +1 -0
- data/app/assets/images/renalware/icons/chart-bar.svg +1 -0
- data/app/assets/images/renalware/icons/chart.svg +3 -0
- data/app/assets/images/renalware/icons/list-bullet.svg +1 -0
- data/app/assets/images/renalware/icons/list.svg +8 -0
- data/app/assets/javascripts/renalware/README.md +25 -1
- data/app/assets/javascripts/renalware/components/dialogs.js.erb +3 -1
- data/app/assets/javascripts/renalware/components/hd.js +2 -2
- data/app/assets/javascripts/renalware/components/letters.js +1 -1
- data/app/assets/javascripts/renalware/components/masonry.run.js +2 -2
- data/app/assets/javascripts/renalware/components/patient_menu.js +1 -1
- data/app/assets/javascripts/renalware/components/toggler.js +1 -1
- data/app/assets/javascripts/renalware/rollup_compiled.css +87457 -0
- data/app/assets/javascripts/renalware/rollup_compiled.js +3148 -3
- data/app/assets/stylesheets/renalware/core.scss +1 -0
- data/app/assets/stylesheets/renalware/modules/_hd.scss +8 -4
- data/app/assets/stylesheets/renalware/modules/_pathology.scss +8 -1
- data/app/assets/stylesheets/renalware/modules/_pd.scss +35 -0
- data/app/assets/stylesheets/renalware/partials/_charting.scss +17 -0
- data/app/assets/stylesheets/renalware/partials/_forms.scss +5 -1
- data/app/assets/stylesheets/renalware/partials/_simple_form.scss +8 -0
- data/app/assets/stylesheets/renalware/partials/_utilities.scss +12 -0
- data/app/assets/stylesheets/tailwind/tailwind.css +3 -0
- data/app/components/renalware/application_component.rb +2 -1
- data/app/components/renalware/events/{biopsies_component.html.slim → event_list_component.html.slim} +5 -4
- data/app/components/renalware/events/event_list_component.rb +77 -0
- data/app/components/renalware/hd/administer_prescription_dropdown_component.rb +1 -5
- data/app/components/renalware/hd/prescription_last_administration_component.html.slim +0 -1
- data/app/components/renalware/hd/prescription_last_administration_component.rb +8 -7
- data/app/components/renalware/letters/unread_electronic_ccs_component.rb +1 -0
- data/app/components/renalware/pathology/chart_component.html.slim +5 -0
- data/app/components/renalware/pathology/chart_component.rb +40 -0
- data/app/components/renalware/pathology/sparkline_component.html.slim +15 -0
- data/app/components/renalware/pathology/sparkline_component.rb +135 -0
- data/app/components/renalware/patients/side_menu_component.rb +2 -11
- data/app/components/renalware/pd/adequacy_results_component.html.slim +9 -0
- data/app/components/renalware/pd/adequacy_results_component.rb +39 -0
- data/app/components/renalware/pd/pet_results_component.html.slim +37 -0
- data/app/components/renalware/pd/pet_results_component.rb +84 -0
- data/app/{views/renalware/surveys/_eq5d_summary_part.html.slim → components/renalware/surveys/eq5d_component.html.slim} +5 -5
- data/app/{models/renalware/surveys/eq5d_summary_part.rb → components/renalware/surveys/eq5d_component.rb} +7 -5
- data/app/{views/renalware/surveys/_pos_s_summary_part.html.slim → components/renalware/surveys/pos_s_component.html.slim} +6 -9
- data/app/{models/renalware/surveys/pos_s_summary_part.rb → components/renalware/surveys/pos_s_component.rb} +9 -5
- data/app/components/renalware/system/admin_menu_component.rb +2 -2
- data/app/components/renalware/system/article_component.html.slim +3 -0
- data/app/components/renalware/system/article_component.rb +9 -0
- data/app/controllers/renalware/admissions/consults_controller.rb +1 -1
- data/app/controllers/renalware/concerns/pdf_renderable.rb +1 -1
- data/app/controllers/renalware/hd/scheduling/diaries_controller.rb +1 -1
- data/app/controllers/renalware/medications/prescriptions_controller.rb +1 -1
- data/app/controllers/renalware/pathology/charts_controller.rb +21 -0
- data/app/controllers/renalware/pathology/current_observation_results_controller.rb +1 -1
- data/app/controllers/renalware/pathology/historical_observation_results_controller.rb +1 -1
- data/app/controllers/renalware/pathology/nearest_observation_results_controller.rb +52 -0
- data/app/controllers/renalware/pathology/observation_requests_controller.rb +1 -1
- data/app/controllers/renalware/pathology/observations_controller.rb +26 -2
- data/app/controllers/renalware/pathology/requests/requests_controller.rb +7 -5
- data/app/controllers/renalware/pd/adequacy_completions_controller.rb +18 -0
- data/app/controllers/renalware/pd/adequacy_results_controller.rb +98 -0
- data/app/controllers/renalware/pd/pet_completions_controller.rb +18 -0
- data/app/controllers/renalware/pd/pet_results_controller.rb +122 -0
- data/app/controllers/renalware/pd/unified_pet_adequacies_controller.rb +102 -0
- data/app/controllers/renalware/renal/aki_alerts_controller.rb +1 -1
- data/app/controllers/renalware/renal/registry_preflight_checks_controller.rb +55 -19
- data/app/documents/renalware/age.rb +3 -1
- data/app/helpers/renalware/application_helper.rb +7 -7
- data/app/helpers/renalware/article_helper.rb +3 -3
- data/app/helpers/renalware/boolean_helper.rb +15 -0
- data/app/helpers/renalware/clipboard_helper.rb +2 -3
- data/app/helpers/renalware/dashboards_helper.rb +2 -2
- data/app/helpers/renalware/definition_list_helper.rb +3 -3
- data/app/helpers/renalware/devise_helper.rb +1 -1
- data/app/helpers/renalware/form_helper.rb +2 -2
- data/app/helpers/renalware/letters_helper.rb +1 -1
- data/app/helpers/renalware/link_helper.rb +1 -1
- data/app/helpers/renalware/mdm_helper.rb +1 -0
- data/app/helpers/renalware/navigation_helper.rb +1 -1
- data/app/helpers/renalware/patient_helper.rb +2 -2
- data/app/helpers/renalware/snippets_helper.rb +9 -10
- data/app/helpers/renalware/toggle_helper.rb +6 -6
- data/app/helpers/renalware/tooltip_helper.rb +14 -16
- data/app/inputs/clock_picker_input.rb +3 -3
- data/app/inputs/date_picker_input.rb +3 -3
- data/app/inputs/simple_time_input.rb +3 -3
- data/app/inputs/trix_editor_input.rb +2 -0
- data/app/javascript/renalware/controllers/blas_controller.js +37 -0
- data/app/javascript/renalware/controllers/modal_controller.js +137 -0
- data/app/javascript/renalware/controllers/pathology/sparklines_controller.js +206 -0
- data/app/javascript/renalware/controllers/pd/pet_charts_controller.js +169 -0
- data/app/javascript/renalware/controllers/session_controller.js +1 -1
- data/app/javascript/renalware/controllers/simple_toggle_controller.js +17 -0
- data/app/javascript/renalware/controllers/tabs_controller.js +43 -0
- data/app/javascript/renalware/controllers/toggle_controller.js +2 -2
- data/app/javascript/renalware/index.js +10 -0
- data/app/models/concerns/renalware/patients_ransack_helper.rb +2 -0
- data/app/models/renalware/clinics/body_surface_area.rb +40 -0
- data/app/models/renalware/clinics/clinic_visit.rb +21 -1
- data/app/models/renalware/clinics/total_body_water.rb +63 -0
- data/app/models/renalware/events/advanced_care_plan.rb +24 -0
- data/app/models/renalware/events/clinical_frailty_score.rb +24 -0
- data/app/models/renalware/feeds/hl7_message.rb +1 -0
- data/app/models/renalware/hd/prescription_last_administration_query.rb +4 -0
- data/app/models/renalware/hd/session_forms/pdf_renderer.rb +1 -1
- data/app/models/renalware/hd/sessions/auditable_session_collection.rb +4 -1
- data/app/models/renalware/letters/html_renderer.rb +1 -1
- data/app/models/renalware/letters/printing/duplex_interleaved_pdf_renderer.rb +1 -1
- data/app/models/renalware/letters/recipient_address_pdf_renderer.rb +1 -1
- data/app/models/renalware/pathology/nearest_observations_query.rb +44 -0
- data/app/models/renalware/pathology/observations_jsonb_serializer.rb +1 -1
- data/app/models/renalware/patient.rb +16 -1
- data/app/models/renalware/patients/alert.rb +1 -0
- data/app/models/renalware/patients/ingestion/update_master_patient_index.rb +1 -0
- data/app/models/renalware/patients/patient_hospital_identifiers.rb +1 -0
- data/app/models/renalware/pd.rb +2 -0
- data/app/models/renalware/pd/adequacy_calculated_attributes.rb +159 -0
- data/app/models/renalware/pd/adequacy_result.rb +76 -0
- data/app/models/renalware/pd/apd/glucose_calculator.rb +1 -0
- data/app/models/renalware/pd/patient.rb +4 -0
- data/app/models/renalware/pd/pet_dextrose_concentration.rb +17 -0
- data/app/models/renalware/pd/pet_result.rb +92 -0
- data/app/models/renalware/pd/unified_pet_adequacy_form.rb +46 -0
- data/app/models/renalware/renal/registry/preflight_checks/missing_esrf_query.rb +50 -0
- data/app/models/renalware/snippets/duplicate_snippet_title_generator.rb +1 -0
- data/app/models/renalware/transplants/recipient_workup_builder.rb +1 -0
- data/app/models/renalware/transplants/registration_status.rb +1 -1
- data/app/models/renalware/ukrdc/outgoing/rendering/patient_number.rb +1 -1
- data/app/models/renalware/user.rb +10 -0
- data/app/pdfs/renalware/events/event_pdf.rb +1 -0
- data/app/policies/renalware/events/advanced_care_plan_policy.rb +10 -0
- data/app/policies/renalware/events/clinical_frailty_score_policy.rb +10 -0
- data/app/policies/renalware/pd/adequacy_result_policy.rb +15 -0
- data/app/policies/renalware/pd/pet_result_policy.rb +15 -0
- data/app/policies/renalware/renal/registry_preflight_check_policy.rb +4 -0
- data/app/presenters/renalware/clinical/profile_presenter.rb +1 -0
- data/app/presenters/renalware/hd/dashboard_presenter.rb +1 -0
- data/app/presenters/renalware/hd/profile_presenter.rb +1 -0
- data/app/presenters/renalware/hd/scheduling/diary_presenter.rb +1 -0
- data/app/presenters/renalware/hd/session_presenter.rb +1 -0
- data/app/presenters/renalware/hd/unmet_preferences_presenter.rb +1 -1
- data/app/presenters/renalware/mdm_patients_presenter.rb +1 -0
- data/app/presenters/renalware/pd/dashboard_presenter.rb +10 -2
- data/app/presenters/renalware/ukrdc/patient_presenter.rb +1 -0
- data/app/presenters/renalware/user_session_presenter.rb +1 -1
- data/app/validators/renalware/patients/nhs_number_validator.rb +88 -0
- data/app/values/renalware/address.rb +1 -0
- data/app/views/renalware/accesses/assessments/show.html.slim +1 -1
- data/app/views/renalware/accesses/procedures/show.html.slim +1 -1
- data/app/views/renalware/accesses/profiles/show.html.slim +1 -1
- data/app/views/renalware/admin/cache/show.html.slim +36 -0
- data/app/views/renalware/admin/playgrounds/show.html.slim +3 -0
- data/app/views/renalware/clinical/profiles/show.html.slim +11 -1
- data/app/views/renalware/clinics/clinic_visits/_table.html.slim +2 -0
- data/app/views/renalware/clinics/clinic_visits/_table_row.html.slim +2 -0
- data/app/views/renalware/dashboard/letters/_letter.html.slim +1 -1
- data/app/views/renalware/directory/people/show.html.slim +1 -1
- data/app/views/renalware/events/advanced_care_plans/_cell.html.slim +2 -0
- data/app/views/renalware/events/advanced_care_plans/_inputs.html.slim +4 -0
- data/app/views/renalware/events/advanced_care_plans/_toggled_cell.html.slim +8 -0
- data/app/views/renalware/events/clinical_frailty_score/_cell.html.slim +2 -0
- data/app/views/renalware/events/clinical_frailty_score/_inputs.html.slim +4 -0
- data/app/views/renalware/events/clinical_frailty_score/_toggled_cell.html.slim +8 -0
- data/app/views/renalware/events/events/_table.html.slim +1 -1
- data/app/views/renalware/hd/current_profile/_show.html.slim +1 -1
- data/app/views/renalware/hd/current_profile/show.html.slim +1 -1
- data/app/views/renalware/hd/prescription_administrations/_form.html.slim +2 -0
- data/app/views/renalware/hd/sessions/_show.html.slim +1 -1
- data/app/views/renalware/hd/witnesses/_form.html.slim +2 -0
- data/app/views/renalware/letters/electronic_receipts/_table.html.slim +1 -1
- data/app/views/renalware/low_clearance/dashboards/show.html.slim +10 -0
- data/app/views/renalware/mdm/_pathology.html.slim +0 -1
- data/app/views/renalware/mdm/show.html.slim +1 -1
- data/app/views/renalware/navigation/_menu.html.slim +1 -0
- data/app/views/renalware/navigation/_pd.html.slim +5 -0
- data/app/views/renalware/pathology/charts/show.html.slim +11 -0
- data/app/views/renalware/pathology/current_observation_results/index.html.slim +6 -0
- data/app/views/renalware/pathology/historical_observation_results/_table.html.slim +4 -3
- data/app/views/renalware/pathology/historical_observation_results/index.html.slim +1 -1
- data/app/views/renalware/pathology/observations/_diff.html.slim +1 -1
- data/app/views/renalware/patients/patients/show.html.slim +1 -1
- data/app/views/renalware/pd/_exit_site_infections.html.slim +4 -0
- data/app/views/renalware/pd/_peritonitis_episodes.html.slim +3 -0
- data/app/views/renalware/pd/adequacy_completions/_filters.html.slim +19 -0
- data/app/views/renalware/pd/adequacy_completions/index.html.slim +4 -0
- data/app/views/renalware/pd/adequacy_results/_form_fields.html.slim +9 -0
- data/app/views/renalware/pd/adequacy_results/_table.html.slim +72 -0
- data/app/views/renalware/pd/adequacy_results/edit.html.slim +89 -0
- data/app/views/renalware/pd/adequacy_results/index.js.erb +1 -0
- data/app/views/renalware/pd/adequacy_results/new.html.slim +8 -0
- data/app/views/renalware/pd/dashboards/show.html.slim +3 -0
- data/app/views/renalware/pd/dashboards/show/_page_actions.html.slim +14 -0
- data/app/views/renalware/pd/pet_completions/_filters.html.slim +24 -0
- data/app/views/renalware/pd/pet_completions/index.html.slim +4 -0
- data/app/views/renalware/pd/pet_results/_form_fields.html.slim +12 -0
- data/app/views/renalware/pd/pet_results/_pathology_results.html.slim +36 -0
- data/app/views/renalware/pd/pet_results/_table.html.slim +62 -0
- data/app/views/renalware/pd/pet_results/edit.html.slim +35 -0
- data/app/views/renalware/pd/pet_results/index.js.erb +1 -0
- data/app/views/renalware/pd/pet_results/new.html.slim +8 -0
- data/app/views/renalware/pd/unified_pet_adequacies/_form.html.slim +22 -0
- data/app/views/renalware/pd/unified_pet_adequacies/new.html.slim +2 -0
- data/app/views/renalware/renal/profiles/show.html.slim +1 -1
- data/app/views/renalware/renal/registry_preflight_checks/_filters.html.slim +5 -3
- data/app/views/renalware/renal/registry_preflight_checks/_navigation.html.slim +1 -0
- data/app/views/renalware/renal/registry_preflight_checks/deaths.html.slim +2 -1
- data/app/views/renalware/renal/registry_preflight_checks/missing_esrf.html.slim +12 -0
- data/app/views/renalware/renal/registry_preflight_checks/patients.html.slim +1 -2
- data/app/views/renalware/surveys/dashboards/show.html.slim +2 -2
- data/app/views/renalware/transplants/donor_workups/show.html.slim +1 -1
- data/app/views/renalware/transplants/mdm/_bottom.html.slim +3 -1
- data/app/views/renalware/transplants/recipient_followups/show.html.slim +1 -1
- data/app/views/renalware/transplants/recipient_operations/show.html.slim +1 -1
- data/app/views/renalware/transplants/recipient_workups/show.html.slim +1 -1
- data/app/views/renalware/transplants/registrations/show.html.slim +1 -1
- data/config/initializers/inflections.rb +8 -0
- data/config/initializers/wicked_pdf.rb +12 -0
- data/config/locales/en-GB.yml +1 -1
- data/config/locales/renalware/events/advanced_care_plan.en.yml +12 -0
- data/config/locales/renalware/events/biopsy.en.yml +2 -0
- data/config/locales/renalware/events/clinical_frailty_score.en.yml +16 -0
- data/config/locales/renalware/events/clinical_frailty_score_component.en.yml +8 -0
- data/config/locales/renalware/nhs_number.en.yml +6 -0
- data/config/locales/renalware/pd/adequacy_result.en.yml +9 -0
- data/config/locales/renalware/pd/dashboard.en.yml +3 -0
- data/config/locales/renalware/pd/pet_result.en.yml +23 -0
- data/config/locales/renalware/renal/registry.en.yml +1 -0
- data/config/routes/pathology.rb +6 -0
- data/config/routes/pd.rb +5 -0
- data/config/routes/renal.rb +1 -0
- data/db/functions/generate_secure_id_v01.sql +1 -1
- data/db/migrate/20200226145010_add_unique_indexes.rb +46 -0
- data/db/migrate/20200421082715_add_body_surface_area_to_clinic_visits.rb +8 -0
- data/db/migrate/20200421132911_create_pd_pet_dextrose_concentrations.rb +13 -0
- data/db/migrate/20200421143546_create_pet_results.rb +66 -0
- data/db/migrate/20200427123229_create_adequacy_results.rb +54 -0
- data/db/migrate/20200616115709_add_height_weight_to_pd_adequacy_results.rb +8 -0
- data/db/migrate/20200618144228_add_feature_flags_to_users.rb +14 -0
- data/db/seeds/default/events/event_types.csv +2 -0
- data/lib/renalware/engine.rb +4 -2
- data/lib/renalware/version_number.rb +11 -0
- data/lib/tasks/renalware.rake +7 -1
- data/spec/factories/accesses/profiles.rb +1 -0
- data/spec/factories/events/events_types.rb +12 -0
- data/spec/factories/patients/patients.rb +22 -1
- data/spec/factories/pd/adequacy_results.rb +16 -0
- data/spec/factories/pd/pet_results.rb +9 -0
- metadata +115 -25
- data/app/components/renalware/events/biopsies_component.rb +0 -20
- data/lib/renalware/version.rb +0 -5
@@ -218,6 +218,6 @@ export default class extends Controller {
|
|
218
218
|
// If you add data-session-debug=1 then logging will be enabled
|
219
219
|
// This is evaluated each time we can add debugging into a running page
|
220
220
|
get debug() {
|
221
|
-
return this.data.get("debug")
|
221
|
+
return this.data.get("debug") === "true"
|
222
222
|
}
|
223
223
|
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { Controller } from "stimulus"
|
2
|
+
|
3
|
+
export default class extends Controller {
|
4
|
+
static targets = ["toggleable"]
|
5
|
+
|
6
|
+
connect() {
|
7
|
+
this.toggleClass = this.data.get("class") || "hidden"
|
8
|
+
}
|
9
|
+
|
10
|
+
toggle(event) {
|
11
|
+
event.preventDefault()
|
12
|
+
|
13
|
+
this.toggleableTargets.forEach(target => {
|
14
|
+
target.classList.toggle(this.toggleClass)
|
15
|
+
})
|
16
|
+
}
|
17
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
//
|
2
|
+
// Adapted from https://github.com/excid3/tailwindcss-stimulus-components#tabs
|
3
|
+
//
|
4
|
+
import { Controller } from "stimulus"
|
5
|
+
|
6
|
+
export default class extends Controller {
|
7
|
+
static targets = ["tab", "panel"]
|
8
|
+
connect() {
|
9
|
+
}
|
10
|
+
|
11
|
+
initialize() {
|
12
|
+
this.activeTabClasses = (this.data.get("activeTab") || "active").split(" ")
|
13
|
+
this.showTab()
|
14
|
+
}
|
15
|
+
|
16
|
+
change(event) {
|
17
|
+
event.preventDefault()
|
18
|
+
this.index = this.tabTargets.indexOf(event.currentTarget)
|
19
|
+
}
|
20
|
+
|
21
|
+
showTab() {
|
22
|
+
this.tabTargets.forEach((tab, index) => {
|
23
|
+
const panel = this.panelTargets[index]
|
24
|
+
|
25
|
+
if (index === this.index) {
|
26
|
+
panel.classList.remove("hidden")
|
27
|
+
tab.classList.add(...this.activeTabClasses)
|
28
|
+
} else {
|
29
|
+
panel.classList.add("hidden")
|
30
|
+
tab.classList.remove(...this.activeTabClasses)
|
31
|
+
}
|
32
|
+
})
|
33
|
+
}
|
34
|
+
|
35
|
+
get index() {
|
36
|
+
return parseInt(this.data.get("index") || 0)
|
37
|
+
}
|
38
|
+
|
39
|
+
set index(value) {
|
40
|
+
this.data.set("index", value)
|
41
|
+
this.showTab()
|
42
|
+
}
|
43
|
+
}
|
@@ -15,7 +15,7 @@ export default class extends Controller {
|
|
15
15
|
const tbody = event.target.closest("tbody")
|
16
16
|
tbody.classList.toggle("toggleable--open")
|
17
17
|
// Update masonry - TODO: move to a module
|
18
|
-
$(".
|
18
|
+
$(".mgrid > .row").masonry("layout")
|
19
19
|
}
|
20
20
|
|
21
21
|
// Toggle the last tr in each tbody in the current table.
|
@@ -31,6 +31,6 @@ export default class extends Controller {
|
|
31
31
|
thead.classList.toggle("toggleable--open")
|
32
32
|
tbodies.forEach(function(tbody) { tbody.classList.toggle("toggleable--open", !hide) })
|
33
33
|
// Update masonry - TODO: move to a module
|
34
|
-
$(".
|
34
|
+
$(".mgrid > .row").masonry("layout")
|
35
35
|
}
|
36
36
|
}
|
@@ -1,3 +1,5 @@
|
|
1
|
+
import "../../assets/stylesheets/tailwind/tailwind.css"
|
2
|
+
|
1
3
|
import "@stimulus/polyfills" // required for IE11 support
|
2
4
|
import { Application } from "stimulus"
|
3
5
|
|
@@ -21,6 +23,10 @@ import LettersFormController from "./controllers/letters/form_controller"
|
|
21
23
|
import PrescriptionsController from "./controllers/medications/prescriptions_controller"
|
22
24
|
import ChartsController from "./controllers/charts_controller"
|
23
25
|
import SessionController from "./controllers/session_controller"
|
26
|
+
import SimpleToggleController from "./controllers/simple_toggle_controller"
|
27
|
+
import TabsController from "./controllers/tabs_controller"
|
28
|
+
import PDPetChartsController from "./controllers/pd/pet_charts_controller"
|
29
|
+
import PathologySparklinesController from "./controllers/pathology/sparklines_controller"
|
24
30
|
|
25
31
|
const application = Application.start()
|
26
32
|
application.register("toggle", ToggleController)
|
@@ -31,5 +37,9 @@ application.register("letters-form", LettersFormController)
|
|
31
37
|
application.register("prescriptions", PrescriptionsController)
|
32
38
|
application.register("charts", ChartsController)
|
33
39
|
application.register("session", SessionController)
|
40
|
+
application.register("simple-toggle", SimpleToggleController)
|
41
|
+
application.register("tabs", TabsController)
|
42
|
+
application.register("pd-pet-chart", PDPetChartsController)
|
43
|
+
application.register("pathology-sparklines", PathologySparklinesController)
|
34
44
|
|
35
45
|
window.Chartkick.use(window.Highcharts)
|
@@ -6,7 +6,9 @@ module Renalware
|
|
6
6
|
module PatientsRansackHelper
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
|
+
# rubocop:disable Layout/LineLength
|
9
10
|
UUID_REGEXP = /[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}/.freeze
|
11
|
+
# rubocop:enable Layout/LineLength
|
10
12
|
|
11
13
|
included do
|
12
14
|
class_eval do
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_dependency "renalware/clinics"
|
4
|
+
|
5
|
+
# The body surface area (BSA) of a patient calculated using DuBois/DuBois
|
6
|
+
# BSA = 0.007184 * Height^0.725 * Weight^0.425
|
7
|
+
# Resources:
|
8
|
+
# - Calculators
|
9
|
+
# - https://www.msdmanuals.com/en-gb/medical-calculators/BodySurfaceArea.htm
|
10
|
+
# - http://www.medcalc.com/body.html
|
11
|
+
module Renalware
|
12
|
+
module Clinics
|
13
|
+
class BodySurfaceArea
|
14
|
+
pattr_initialize [:weight!, :height!]
|
15
|
+
|
16
|
+
def self.calculate(weight:, height:, dp: 2)
|
17
|
+
new(weight: weight, height: height).calculate(dp: dp)
|
18
|
+
end
|
19
|
+
|
20
|
+
def calculate(dp: 2)
|
21
|
+
return if height_cm.zero?
|
22
|
+
return if weight_kg.zero?
|
23
|
+
|
24
|
+
# NB ** is ruby syntax for power of (^)
|
25
|
+
result = 0.007184 * (weight_kg**0.425) * (height_cm**0.725)
|
26
|
+
result.round(dp)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def height_cm
|
32
|
+
height.to_f * 100
|
33
|
+
end
|
34
|
+
|
35
|
+
def weight_kg
|
36
|
+
weight.to_f
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -19,7 +19,7 @@ module Renalware
|
|
19
19
|
|
20
20
|
belongs_to :patient, touch: true
|
21
21
|
belongs_to :clinic
|
22
|
-
has_many :clinic_letters
|
22
|
+
has_many :clinic_letters # TODO: remove as possibly redundant
|
23
23
|
|
24
24
|
validates :date, presence: true
|
25
25
|
validates :clinic, presence: true
|
@@ -35,6 +35,10 @@ module Renalware
|
|
35
35
|
|
36
36
|
scope :ordered, -> { order(date: :desc, created_at: :desc) }
|
37
37
|
scope :most_recent_for_patient, ->(patient) { for_patient(patient).ordered.limit(1) }
|
38
|
+
scope :where_weight_was_measured, -> { where("weight > 0") }
|
39
|
+
|
40
|
+
before_save :calculate_body_surface_area
|
41
|
+
before_save :calculate_total_body_water
|
38
42
|
|
39
43
|
def bmi
|
40
44
|
BMI.new(weight: weight, height: height).to_f
|
@@ -72,6 +76,22 @@ module Renalware
|
|
72
76
|
def datetime_from_date_and_time
|
73
77
|
DateTime.new(date.year, date.month, date.day, time.hour, time.min, 0, time.zone)
|
74
78
|
end
|
79
|
+
|
80
|
+
def calculate_body_surface_area
|
81
|
+
self.body_surface_area = BodySurfaceArea.calculate(
|
82
|
+
height: height,
|
83
|
+
weight: weight
|
84
|
+
)
|
85
|
+
end
|
86
|
+
|
87
|
+
def calculate_total_body_water
|
88
|
+
self.total_body_water = TotalBodyWater.calculate(
|
89
|
+
height: height,
|
90
|
+
weight: weight,
|
91
|
+
age: patient.age,
|
92
|
+
sex: patient.sex
|
93
|
+
)
|
94
|
+
end
|
75
95
|
end
|
76
96
|
end
|
77
97
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_dependency "renalware/clinics"
|
4
|
+
|
5
|
+
# Total Body Water (TBW) calcuated using WATSON
|
6
|
+
# References:
|
7
|
+
# - https://qxmd.com/calculate/calculator_344/total-body-water-watson-formula
|
8
|
+
#
|
9
|
+
# Total Body Water
|
10
|
+
# TBW = 2.447 - 0.09156 X age + 0.1074 X height + 0.3362 X weight
|
11
|
+
# (females) TBW = -2.097 + 0.1069 X height + 0.2466 X weight
|
12
|
+
#
|
13
|
+
# Water in Litres
|
14
|
+
# Age in years
|
15
|
+
# Height in cm
|
16
|
+
# Weight in kg
|
17
|
+
module Renalware
|
18
|
+
module Clinics
|
19
|
+
class TotalBodyWater
|
20
|
+
pattr_initialize [:height!, :weight!, :age, :sex]
|
21
|
+
|
22
|
+
NOTHING = nil
|
23
|
+
SEX_PROC_MAP = {
|
24
|
+
M: ->(age:, height:, weight:) { 2.447 - 0.09156 * age + 0.1074 * height + 0.3362 * weight },
|
25
|
+
F: ->(height:, weight:, **) { -2.097 + 0.1069 * height + 0.2466 * weight }
|
26
|
+
}.freeze
|
27
|
+
NOOP = ->(**) { NullObject.instance }
|
28
|
+
|
29
|
+
def self.calculate(dp: 2, **args)
|
30
|
+
new(**args).calculate(dp: dp)
|
31
|
+
end
|
32
|
+
|
33
|
+
def calculate(dp: 2)
|
34
|
+
return NOTHING if height_cm.zero?
|
35
|
+
return NOTHING if weight_kg.zero?
|
36
|
+
return NOTHING if age.to_i.zero?
|
37
|
+
|
38
|
+
proc_for_sex = SEX_PROC_MAP.fetch(sex_sym, NOOP)
|
39
|
+
|
40
|
+
proc_for_sex.call(
|
41
|
+
age: age,
|
42
|
+
height: height_cm,
|
43
|
+
weight: weight_kg
|
44
|
+
).round(dp)
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
# Note sex can be nil but here that would evaluate to :""
|
50
|
+
def sex_sym
|
51
|
+
sex.to_s&.to_sym
|
52
|
+
end
|
53
|
+
|
54
|
+
def height_cm
|
55
|
+
height.to_f * 100
|
56
|
+
end
|
57
|
+
|
58
|
+
def weight_kg
|
59
|
+
weight.to_f
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_dependency "renalware/events"
|
4
|
+
require "document/base"
|
5
|
+
require "document/embedded"
|
6
|
+
require "document/enum"
|
7
|
+
|
8
|
+
module Renalware
|
9
|
+
module Events
|
10
|
+
class AdvancedCarePlan < Events::Event
|
11
|
+
include Document::Base
|
12
|
+
|
13
|
+
class Document < Document::Embedded
|
14
|
+
attribute :state, ::Document::Enum # See i18n for options
|
15
|
+
validates :state, presence: true
|
16
|
+
end
|
17
|
+
has_document
|
18
|
+
|
19
|
+
def partial_for(partial_type)
|
20
|
+
File.join("renalware/events/advanced_care_plans", partial_type)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_dependency "renalware/events"
|
4
|
+
require "document/base"
|
5
|
+
require "document/embedded"
|
6
|
+
require "document/enum"
|
7
|
+
|
8
|
+
module Renalware
|
9
|
+
module Events
|
10
|
+
class ClinicalFrailtyScore < Events::Event
|
11
|
+
include Document::Base
|
12
|
+
|
13
|
+
class Document < Document::Embedded
|
14
|
+
attribute :score, ::Document::Enum # See i18n for options
|
15
|
+
validates :score, presence: true, numericality: true
|
16
|
+
end
|
17
|
+
has_document
|
18
|
+
|
19
|
+
def partial_for(partial_type)
|
20
|
+
File.join("renalware/events/clinical_frailty_score", partial_type)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -8,6 +8,10 @@ module Renalware
|
|
8
8
|
pattr_initialize [:prescription!]
|
9
9
|
delegate :patient, to: :prescription
|
10
10
|
|
11
|
+
def self.call(prescription:)
|
12
|
+
new(prescription: prescription).call
|
13
|
+
end
|
14
|
+
|
11
15
|
def call
|
12
16
|
raise ArgumentError if prescription.blank?
|
13
17
|
raise ArgumentError if patient.blank?
|
@@ -23,7 +23,7 @@ module Renalware
|
|
23
23
|
def pdf_html
|
24
24
|
@pdf_html ||= begin
|
25
25
|
# Note we don't actually hit the ProtocolController#index action here.
|
26
|
-
controller.
|
26
|
+
controller.render_to_string_with_wicked_pdf(
|
27
27
|
template: "renalware/hd/protocols/index",
|
28
28
|
layout: "renalware/layouts/pdf",
|
29
29
|
locals: {
|
@@ -146,7 +146,10 @@ module Renalware
|
|
146
146
|
# Any values like "## TEST CANCELLED" etc are thus excluded from the calculation
|
147
147
|
def values
|
148
148
|
@values ||= begin
|
149
|
-
sessions
|
149
|
+
sessions
|
150
|
+
.map { |session| selector.call(session) }
|
151
|
+
.compact
|
152
|
+
.select { |val| number?(val) }
|
150
153
|
end
|
151
154
|
end
|
152
155
|
|
@@ -8,7 +8,7 @@ module Renalware
|
|
8
8
|
class HTMLRenderer
|
9
9
|
def call(letter)
|
10
10
|
context = LettersController.new
|
11
|
-
context.
|
11
|
+
context.render_to_string_with_wicked_pdf(
|
12
12
|
partial: "/renalware/letters/formatted_letters/letter",
|
13
13
|
locals: { letter: letter },
|
14
14
|
encoding: "UTF-8"
|
@@ -24,7 +24,7 @@ module Renalware
|
|
24
24
|
# using a hex digest of the interleaved letter but currently would not be.
|
25
25
|
# PdfLetterCache.fetch(letter) do
|
26
26
|
WickedPdf.new.pdf_from_string(
|
27
|
-
LettersController.new.
|
27
|
+
LettersController.new.render_to_string_with_wicked_pdf(
|
28
28
|
template: "/renalware/letters/printable_letters/show",
|
29
29
|
locals: { letter: letter, recipients: PrintableRecipients.for(letter) },
|
30
30
|
encoding: "UTF-8"
|
@@ -13,7 +13,7 @@ module Renalware
|
|
13
13
|
recipient = RecipientPresenter::WithCurrentAddress.new(recipient)
|
14
14
|
end
|
15
15
|
WickedPdf.new.pdf_from_string(
|
16
|
-
LettersController.new.
|
16
|
+
LettersController.new.render_to_string_with_wicked_pdf(
|
17
17
|
partial: "/renalware/letters/formatted_letters/recipient_address_cover_sheet",
|
18
18
|
locals: { recipient: recipient },
|
19
19
|
encoding: "UTF-8"
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_dependency "renalware/pathology"
|
4
|
+
|
5
|
+
module Renalware
|
6
|
+
module Pathology
|
7
|
+
class NearestObservationsQuery
|
8
|
+
pattr_initialize [:patient!, :date!, :code_group!, look_behind_days!: 2]
|
9
|
+
|
10
|
+
# rubocop:disable Metrics/MethodLength
|
11
|
+
def call
|
12
|
+
pathology_patient
|
13
|
+
.observations
|
14
|
+
.joins(:description)
|
15
|
+
.where(description_id: observation_description_ids)
|
16
|
+
.where("observed_at >= ?", (date - look_behind_days.days).beginning_of_day)
|
17
|
+
.select(
|
18
|
+
:observed_at,
|
19
|
+
:result,
|
20
|
+
:description_id,
|
21
|
+
"pathology_observation_descriptions.code as code"
|
22
|
+
)
|
23
|
+
.map do |row|
|
24
|
+
{
|
25
|
+
code: row.code,
|
26
|
+
observed_on: row.observed_at.to_date,
|
27
|
+
result: row.result
|
28
|
+
}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
# rubocop:enable Metrics/MethodLength
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def pathology_patient
|
36
|
+
Pathology.cast_patient(patient)
|
37
|
+
end
|
38
|
+
|
39
|
+
def observation_description_ids
|
40
|
+
@observation_description_ids ||= code_group.memberships.pluck(:observation_description_id)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -34,7 +34,7 @@ module Renalware
|
|
34
34
|
|
35
35
|
def observation_hash_or_hash_element_for(code, suffix)
|
36
36
|
obs_hash = self[code]
|
37
|
-
return nil if obs_hash.blank? #
|
37
|
+
return nil if obs_hash.blank? # patient may not have this code in the set, or it might be {}
|
38
38
|
return obs_hash[:result] if suffix == "_result"
|
39
39
|
return Date.parse(obs_hash[:observed_at]) if suffix == "_observed_at"
|
40
40
|
|