renalware-core 2.0.0.pre.rc9 → 2.0.0.pre.rc10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/renalware/modules/_clinics.scss +1 -1
  3. data/app/assets/stylesheets/renalware/modules/_letters.scss +7 -0
  4. data/app/assets/stylesheets/renalware/partials/_navigation.scss +1 -1
  5. data/app/controllers/renalware/api/ukrdc/patients_controller.rb +2 -1
  6. data/app/controllers/renalware/application_controller.rb +13 -0
  7. data/app/controllers/renalware/base_controller.rb +0 -2
  8. data/app/controllers/renalware/concerns/cache_busting.rb +21 -0
  9. data/app/controllers/renalware/devise/passwords_controller.rb +0 -2
  10. data/app/controllers/renalware/devise/registrations_controller.rb +0 -2
  11. data/app/controllers/renalware/devise/sessions_controller.rb +0 -2
  12. data/app/controllers/renalware/events/events_controller.rb +2 -0
  13. data/app/controllers/renalware/letters/letters_controller.rb +1 -1
  14. data/app/controllers/renalware/pd/bag_types_controller.rb +1 -1
  15. data/app/controllers/renalware/virology/dashboards_controller.rb +15 -0
  16. data/app/controllers/renalware/virology/vaccinations_controller.rb +11 -0
  17. data/app/documents/renalware/patient_document.rb +9 -0
  18. data/app/jobs/hl7_message_example.yml +12 -12
  19. data/app/models/renalware/events/event.rb +28 -3
  20. data/app/models/renalware/pathology/create_observation_requests.rb +2 -1
  21. data/app/models/renalware/pathology/observation_description.rb +2 -0
  22. data/app/models/renalware/pathology/observation_descriptions_by_code_query.rb +2 -1
  23. data/app/models/renalware/pathology/observation_requests_attributes_builder.rb +14 -1
  24. data/app/models/renalware/pd/bag_type.rb +2 -0
  25. data/app/models/renalware/pd/capd_regime.rb +5 -1
  26. data/app/models/renalware/virology.rb +13 -0
  27. data/app/models/renalware/virology/profile.rb +8 -0
  28. data/app/models/renalware/virology/vaccination.rb +24 -0
  29. data/app/policies/renalware/virology/dasboard_policy.rb +8 -0
  30. data/app/policies/renalware/virology/vaccination_policy.rb +8 -0
  31. data/app/presenters/renalware/admissions/summary_part.rb +30 -0
  32. data/app/presenters/renalware/events/summary_part.rb +31 -0
  33. data/app/presenters/renalware/letters/summary_part.rb +48 -0
  34. data/app/presenters/renalware/medications/summary_part.rb +23 -0
  35. data/app/presenters/renalware/problems/summary_part.rb +19 -0
  36. data/app/presenters/renalware/renal/clinical_summary_presenter.rb +5 -90
  37. data/app/presenters/renalware/summary_part.rb +34 -0
  38. data/app/views/renalware/admissions/_summary_part.html.slim +14 -0
  39. data/app/views/renalware/clinical/_header.html.slim +3 -3
  40. data/app/views/renalware/clinics/visits/index.html.slim +0 -1
  41. data/app/views/renalware/events/events/_event.html.slim +2 -2
  42. data/app/views/renalware/events/events/_form.html.slim +1 -2
  43. data/app/views/renalware/events/events/_summary_part.html.slim +15 -0
  44. data/app/views/renalware/events/events/new.js.erb +2 -3
  45. data/app/views/renalware/events/events/simple/_event.html.slim +1 -2
  46. data/app/views/renalware/layouts/_patient.html.slim +1 -0
  47. data/app/views/renalware/letters/_summary_part.html.slim +16 -0
  48. data/app/views/renalware/letters/letters/index.html.slim +3 -3
  49. data/app/views/renalware/mdm_patients/_table.html.slim +1 -1
  50. data/app/views/renalware/medications/_summary_part.html.slim +18 -0
  51. data/app/views/renalware/patients/clinical_summaries/show.html.slim +6 -32
  52. data/app/views/renalware/patients/patients/_form.html.slim +13 -0
  53. data/app/views/renalware/patients/patients/show.html.slim +2 -0
  54. data/app/views/renalware/patients/patients/show/_psychosocial.html.slim +15 -0
  55. data/app/views/renalware/patients/side_menu/_general.html.slim +4 -0
  56. data/app/views/renalware/problems/problems/_summary_part.html.slim +16 -0
  57. data/app/views/renalware/virology/dashboards/_actions.html.slim +10 -0
  58. data/app/views/renalware/virology/dashboards/show.html.slim +6 -0
  59. data/app/views/renalware/virology/vaccinations/_cell.html.slim +2 -0
  60. data/app/views/renalware/virology/vaccinations/_inputs.html.slim +4 -0
  61. data/app/views/renalware/virology/vaccinations/_list.html.slim +14 -0
  62. data/app/views/renalware/virology/vaccinations/_toggled_cell.html.slim +8 -0
  63. data/config/locales/en-GB.yml +1 -3
  64. data/config/locales/en.yml +0 -11
  65. data/config/locales/renalware/age.yml +0 -1
  66. data/config/locales/renalware/clinical/allergies.en.yml +0 -3
  67. data/config/locales/renalware/clinical/body_composition.yml +0 -2
  68. data/config/locales/renalware/clinical/dry_weight.en.yml +0 -2
  69. data/config/locales/renalware/clinics/visit.yml +0 -2
  70. data/config/locales/renalware/feeds/file.en.yml +0 -1
  71. data/config/locales/renalware/hd/diary_slots.en.yml +0 -1
  72. data/config/locales/renalware/hd/prescription_administration.en.yml +0 -1
  73. data/config/locales/renalware/hd/session.en.yml +0 -1
  74. data/config/locales/renalware/hospitals/unit.yml +0 -2
  75. data/config/locales/renalware/letters/contact.en.yml +0 -1
  76. data/config/locales/renalware/letters/letter.en.yml +0 -2
  77. data/config/locales/renalware/low_clearance/profile.en.yml +0 -1
  78. data/config/locales/renalware/medications/prescription.yml +0 -2
  79. data/config/locales/renalware/messaging/internal/messages.en.yml +0 -2
  80. data/config/locales/renalware/patient.yml +0 -2
  81. data/config/locales/renalware/patients/side_menu.en.yml +1 -1
  82. data/config/locales/renalware/pd/assessments.en.yml +0 -1
  83. data/config/locales/renalware/pd/bag_types.yml +0 -2
  84. data/config/locales/renalware/pd/regime.en.yml +0 -2
  85. data/config/locales/renalware/pd/training_sessions.en.yml +0 -1
  86. data/config/locales/renalware/renal/profile.en.yml +0 -1
  87. data/config/locales/renalware/renal/registry.en.yml +0 -2
  88. data/config/locales/renalware/research/study_participant.en.yml +0 -1
  89. data/config/locales/renalware/snippets/snippets.en.yml +0 -1
  90. data/config/locales/renalware/transplants/donation.yml +0 -3
  91. data/config/locales/renalware/transplants/donor_followup.yml +0 -4
  92. data/config/locales/renalware/transplants/donor_operation.yml +0 -4
  93. data/config/locales/renalware/transplants/donor_workup.yml +0 -4
  94. data/config/locales/renalware/transplants/recipient_followup.yml +0 -2
  95. data/config/locales/renalware/transplants/recipient_operation.yml +0 -4
  96. data/config/locales/renalware/transplants/recipient_workup.yml +0 -4
  97. data/config/locales/renalware/transplants/registration.yml +0 -4
  98. data/config/locales/renalware/virology/virology.en.yml +18 -0
  99. data/config/routes.rb +8 -0
  100. data/db/migrate/20180122173922_create_virology_profiles.rb +6 -0
  101. data/db/migrate/20180213171805_add_display_order_cols_to_observation_descriptions.rb +12 -0
  102. data/db/seeds/default/events/event_types.csv +1 -0
  103. data/db/seeds/default/pathology/measurement_units.csv +45 -38
  104. data/db/seeds/default/pathology/measurement_units.rb +1 -0
  105. data/lib/renalware/configuration.rb +14 -0
  106. data/lib/renalware/engine.rb +0 -4
  107. data/lib/renalware/version.rb +1 -1
  108. data/lib/sql/index_case_stmt.rb +6 -6
  109. data/spec/factories/events/events_types.rb +6 -0
  110. data/spec/factories/virology/vaccinations.rb +6 -0
  111. metadata +265 -243
  112. data/app/controllers/application_controller.rb +0 -6
  113. data/app/models/renalware/pathology/view_current_observation_results.rb.dead +0 -47
  114. data/app/presenters/renalware/pathology/current_observation_results.dead/html_table_view.rb.dead +0 -67
  115. data/app/views/renalware/layouts/application.html.slim +0 -44
  116. data/app/views/renalware/patients/clinical_summaries/_admissions.html.slim +0 -11
  117. data/app/views/renalware/patients/clinical_summaries/_events.html.slim +0 -11
  118. data/app/views/renalware/patients/clinical_summaries/_letters.html.slim +0 -12
  119. data/app/views/renalware/patients/clinical_summaries/_prescriptions.html.slim +0 -16
  120. data/app/views/renalware/patients/clinical_summaries/_problems.html.slim +0 -13
@@ -0,0 +1,8 @@
1
+ require_dependency "renalware/virology"
2
+
3
+ module Renalware
4
+ module Virology
5
+ class DashboardPolicy < BasePolicy
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require_dependency "renalware/virology"
2
+
3
+ module Renalware
4
+ module Virology
5
+ class VaccinationPolicy < BasePolicy
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,30 @@
1
+ require_dependency "renalware/medications"
2
+ require "collection_presenter"
3
+
4
+ module Renalware
5
+ module Admissions
6
+ class SummaryPart < Renalware::SummaryPart
7
+ delegate :nhs_number, to: :patient, prefix: true
8
+
9
+ def admissions
10
+ @admissions ||= begin
11
+ CollectionPresenter.new(
12
+ Admissions::Admission.where(patient: patient).limit(5),
13
+ Renalware::Admissions::AdmissionPresenter
14
+ )
15
+ end
16
+ end
17
+
18
+ def admissions_count
19
+ title_friendly_collection_count(
20
+ actual: admissions.size,
21
+ total: Admissions::Admission.where(patient: patient).count
22
+ )
23
+ end
24
+
25
+ def to_partial_path
26
+ "renalware/admissions/summary_part"
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,31 @@
1
+ require_dependency "renalware/events"
2
+
3
+ module Renalware
4
+ module Events
5
+ class SummaryPart < Renalware::SummaryPart
6
+ def current_events
7
+ @current_events ||= begin
8
+ Events::Event.includes([:created_by, :event_type])
9
+ .for_patient(patient)
10
+ .limit(Renalware.config.clinical_summary_max_events_to_display)
11
+ .ordered
12
+ end
13
+ end
14
+
15
+ def current_events_count
16
+ title_friendly_collection_count(
17
+ actual: current_events.size,
18
+ total: patient.summary.events_count
19
+ )
20
+ end
21
+
22
+ def to_partial_path
23
+ "renalware/events/events/summary_part"
24
+ end
25
+
26
+ # def cache_key
27
+ # Events::Event.for_patient(patient).maximum(:updated_at)
28
+ # end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,48 @@
1
+ require_dependency "renalware/letters"
2
+ require "collection_presenter"
3
+
4
+ module Renalware
5
+ module Letters
6
+ class SummaryPart < Renalware::SummaryPart
7
+ def letters
8
+ present_letters(find_letters)
9
+ end
10
+
11
+ def letters_count
12
+ title_friendly_collection_count(
13
+ actual: letters.size,
14
+ total: patient.summary.letters_count
15
+ )
16
+ end
17
+
18
+ def to_partial_path
19
+ "renalware/letters/summary_part"
20
+ end
21
+
22
+ # def cache_key
23
+ # letters_patient.letters.maximum(:updated_at)
24
+ # end
25
+
26
+ private
27
+
28
+ def find_letters
29
+ letters_patient
30
+ .letters
31
+ .with_main_recipient
32
+ .with_letterhead
33
+ .with_author
34
+ .with_patient
35
+ .limit(Renalware.config.clinical_summary_max_letters_to_display)
36
+ .order(issued_on: :desc)
37
+ end
38
+
39
+ def present_letters(letters)
40
+ CollectionPresenter.new(letters, Renalware::Letters::LetterPresenterFactory)
41
+ end
42
+
43
+ def letters_patient
44
+ Renalware::Letters.cast_patient(patient)
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,23 @@
1
+ require_dependency "renalware/medications"
2
+ require "collection_presenter"
3
+
4
+ module Renalware
5
+ module Medications
6
+ class SummaryPart < Renalware::SummaryPart
7
+ def current_prescriptions
8
+ @current_prescriptions ||= begin
9
+ prescriptions = patient.prescriptions
10
+ .includes(drug: [:drug_types, :classifications])
11
+ .includes(:medication_route)
12
+ .current
13
+ .ordered
14
+ CollectionPresenter.new(prescriptions, Medications::PrescriptionPresenter)
15
+ end
16
+ end
17
+
18
+ def to_partial_path
19
+ "renalware/medications/summary_part"
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,19 @@
1
+ require_dependency "renalware/problems"
2
+
3
+ module Renalware
4
+ module Problems
5
+ class SummaryPart < Renalware::SummaryPart
6
+ def current_problems
7
+ @current_problems ||= patient.problems.current.ordered
8
+ end
9
+
10
+ # def cache_key
11
+ # current_problems.maximum(:updated_at)
12
+ # end
13
+
14
+ def to_partial_path
15
+ "renalware/problems/problems/summary_part"
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,99 +1,14 @@
1
1
  require_dependency "renalware/renal"
2
- require "collection_presenter"
2
+ require "attr_extras"
3
3
 
4
4
  module Renalware
5
5
  module Renal
6
6
  class ClinicalSummaryPresenter
7
- def initialize(patient)
8
- @patient = patient
9
- end
10
-
11
- def current_prescriptions
12
- @current_prescriptions ||= begin
13
- prescriptions = @patient.prescriptions
14
- .includes(drug: [:drug_types, :classifications])
15
- .includes(:medication_route)
16
- .current
17
- .ordered
18
- CollectionPresenter.new(prescriptions, Medications::PrescriptionPresenter)
19
- end
20
- end
21
-
22
- def current_problems
23
- @current_problems ||= @patient.problems
24
- .current
25
- .ordered
26
- end
27
-
28
- def current_events
29
- @current_events ||= begin
30
- Events::Event.includes([:created_by, :event_type])
31
- .for_patient(@patient)
32
- .limit(Renalware.config.clinical_summary_max_events_to_display)
33
- .ordered
34
- end
35
- end
36
-
37
- def current_events_count
38
- title_friendly_collection_count(
39
- actual: current_events.size,
40
- total: patient.summary.events_count
41
- )
42
- end
43
-
44
- def letters
45
- present_letters(find_letters)
46
- end
47
-
48
- def letters_count
49
- title_friendly_collection_count(
50
- actual: letters.size,
51
- total: patient.summary.letters_count
52
- )
53
- end
54
-
55
- def admissions
56
- @admissions ||= begin
57
- CollectionPresenter.new(
58
- Admissions::Admission.where(patient: patient).limit(5),
59
- Renalware::Admissions::AdmissionPresenter
60
- )
61
- end
62
- end
63
-
64
- def admissions_count
65
- title_friendly_collection_count(
66
- actual: admissions.size,
67
- total: Admissions::Admission.where(patient: patient).count
68
- )
69
- end
70
-
71
- private
72
-
73
- attr_reader :patient
74
-
75
- # Returns e.g. "9" or "10 of 11"
76
- def title_friendly_collection_count(actual:, total:)
77
- if total > actual
78
- "#{actual} of #{total}"
79
- else
80
- actual
81
- end
82
- end
83
-
84
- def find_letters
85
- patient = Renalware::Letters.cast_patient(@patient)
86
- patient.letters
87
- .with_main_recipient
88
- .with_letterhead
89
- .with_author
90
- .with_patient
91
- .limit(Renalware.config.clinical_summary_max_letters_to_display)
92
- .order(issued_on: :desc)
93
- end
7
+ rattr_initialize :patient
94
8
 
95
- def present_letters(letters)
96
- CollectionPresenter.new(letters, Renalware::Letters::LetterPresenterFactory)
9
+ # Host application may override the order or add other summary presenters
10
+ def summary_parts
11
+ Renalware.config.page_layouts[:clinical_summary].map(&:constantize)
97
12
  end
98
13
  end
99
14
  end
@@ -0,0 +1,34 @@
1
+ require "attr_extras"
2
+
3
+ module Renalware
4
+ # A base class for Summary presenters in other name-spaces. SummaryParts can be composed into
5
+ # reporting dashboards or summary pages. The Clinical Summary for instance comprises an array
6
+ # of various SummaryParts
7
+ class SummaryPart
8
+ rattr_initialize :patient
9
+ attr_implement :to_partial_path
10
+
11
+ # If the subclass defines a cache_key Rails will cache the partial
12
+ def cache_key
13
+ nil
14
+ end
15
+
16
+ def cache?
17
+ cache_key.present?
18
+ end
19
+
20
+ def render?
21
+ true
22
+ end
23
+
24
+ protected
25
+
26
+ def title_friendly_collection_count(actual:, total:)
27
+ if total > actual
28
+ "#{actual} of #{total}"
29
+ else
30
+ actual
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,14 @@
1
+ .columns.large-12.xlarge-6
2
+ #admissions
3
+ article
4
+ header
5
+ h2= "Admissions (#{summary_part.admissions_count})"
6
+
7
+ ul
8
+ li= link_to admissions_admissions_path(query: { term: summary_part.patient_nhs_number }),
9
+ class: "button" do
10
+ | View All
11
+
12
+ = render "renalware/admissions/admissions/table",
13
+ admissions: summary_part.admissions,
14
+ compact: true
@@ -10,7 +10,7 @@ ruby:
10
10
  - result = header.blood_pressure_measurement.compact.join("/")
11
11
  - if result.present?
12
12
  dd= result
13
- dd.date= l(header.blood_pressure_date)
13
+ dd.date= l(header.blood_pressure_date, format: :compact)
14
14
  - else
15
15
  dd.empty
16
16
  li
@@ -19,7 +19,7 @@ ruby:
19
19
  - result = header.weight_measurement
20
20
  - if result.present?
21
21
  dd= "#{result} kg"
22
- dd.date= l(header.weight_date)
22
+ dd.date= l(header.weight_date, format: :compact)
23
23
  - else
24
24
  dd.empty
25
25
  li
@@ -42,6 +42,6 @@ ruby:
42
42
  - result = current_pathology.send(:"#{code}_result")
43
43
  - if result.present?
44
44
  dd= result
45
- dd.date= l(current_pathology.send(:"#{code}_observed_at"))
45
+ dd.date= l(current_pathology.send(:"#{code}_observed_at"), format: :compact)
46
46
  - else
47
47
  dd.empty
@@ -1,4 +1,3 @@
1
- - content_for(:body_class) { "page--cinic-visits" }
2
1
 
3
2
  = within_admin_layout(title: "Clinic Visits") do
4
3
  = render "filters", query: query, clinics: clinics, users: users
@@ -12,12 +12,12 @@ tr
12
12
  - unless local_assigns[:exclude_type_column] == true
13
13
  td= event.event_type
14
14
  td.col-width-medium-with-ellipsis
15
- = render partial: "renalware/events/events/cell/#{event.to_partial_path}",
15
+ = render partial: event.to_cell_partial_path,
16
16
  locals: { event: event }
17
17
  td.created_at= l(event.date_time)
18
18
  td.created_by= event.created_by.full_name
19
19
  = content_tag(:tr, id: "#{toggle_prefix}-quick-preview-#{event.id}", style: "display: none")
20
20
  td(colspan=6)
21
21
  .quick-preview
22
- = render partial: "renalware/events/events/toggled_cell/#{event.to_partial_path}",
22
+ = render partial: event.to_toggled_cell_partial_path,
23
23
  locals: { event: event }
@@ -24,8 +24,7 @@
24
24
  / The contents of this div will get replaced if a user selects an alternative
25
25
  / event type in the drop-down above. See events.js.
26
26
  #event-type-specific-inputs
27
- = render partial: "renalware/events/events/inputs/#{event.to_partial_path}",
28
- locals: { event: event, f: f }
27
+ = render partial: event.to_input_partial_path, locals: { event: event, f: f }
29
28
 
30
29
  = f.label :notes
31
30
  = snippets_modal_and_link_to_open_it(target_input_for_seleted_snippet: ".event-notes")
@@ -0,0 +1,15 @@
1
+ .columns.large-12.xlarge-6
2
+ span
3
+ #events
4
+ article
5
+ header
6
+ h2= link_to "Events (#{summary_part.current_events_count})",
7
+ patient_events_path(summary_part.patient)
8
+
9
+ ul
10
+ li= link_to new_patient_event_path(summary_part.patient), class: "button" do
11
+ | Add
12
+ li= link_to patient_events_path(summary_part.patient), class: "button" do
13
+ | View All
14
+
15
+ = render "renalware/events/events/table", events: summary_part.current_events
@@ -9,10 +9,9 @@
9
9
  // still means the ruby is interpreted and the block and its argument f are available!
10
10
  '<%= simple_form_for(event, url: new_patient_event_path(patient), as: :events_event, wrapper: "horizontal_form") do |f| %>'
11
11
  <%=
12
- partial_name = "renalware/events/events/inputs/#{event.to_partial_path}"
13
12
  refresh("#event-type-specific-inputs",
14
- partial: partial_name,
15
- locals: { f: f, event: event })
13
+ partial: event.to_partial_path,
14
+ locals: { f: f, event: event })
16
15
  %>
17
16
  '<% end %>'
18
17
  initDatepickersIn("#event-type-specific-inputs");
@@ -8,5 +8,4 @@ tr
8
8
  = content_tag(:tr, id: "#{toggle_prefix}-quick-preview-#{event.id}", style: "display: none")
9
9
  td(colspan=4)
10
10
  .quick-preview
11
- = render partial: "renalware/events/events/toggled_cell/#{event.to_partial_path}",
12
- locals: { event: event }
11
+ = render partial: event.to_toggled_cell_partial_path, locals: { event: event }
@@ -32,6 +32,7 @@
32
32
  = render_if_exists partial, local_assigns.reverse_merge!(patient: current_patient)
33
33
  .row
34
34
  = yield
35
+ = yield(:below_content)
35
36
 
36
37
  nav.patient-side-nav.full-screenable
37
38
  .layout-wrapper
@@ -0,0 +1,16 @@
1
+ #letters.summary-part--letters
2
+ article
3
+ header
4
+ h2
5
+ = link_to "Letters (#{summary_part.letters_count})",
6
+ patient_letters_letters_path(summary_part.patient)
7
+
8
+ ul
9
+ li= link_to patient_letters_letters_path(summary_part.patient), class: "button" do
10
+ | Draft letter
11
+ li= link_to patient_letters_letters_path(summary_part.patient), class: "button" do
12
+ | View All
13
+
14
+ = render "renalware/letters/letters/table",
15
+ letters: summary_part.letters,
16
+ patient: summary_part.patient