renalware-core 2.0.37 → 2.0.38

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +3 -1
  3. data/app/controllers/renalware/hd/diaries_controller.rb +1 -1
  4. data/app/controllers/renalware/renal/registry_preflight_checks_controller.rb +18 -6
  5. data/app/controllers/renalware/snippets/snippet_clones_controller.rb +2 -2
  6. data/app/controllers/renalware/system/errors_controller.rb +2 -2
  7. data/app/helpers/renalware/article_helper.rb +2 -2
  8. data/app/models/renalware/letters/pathology_layout.rb +2 -0
  9. data/app/models/renalware/null_user.rb +2 -0
  10. data/app/models/renalware/pathology/adjust_observation.rb +2 -0
  11. data/app/models/renalware/pathology/observations_jsonb_serializer.rb +0 -1
  12. data/app/models/renalware/renal/patient.rb +5 -0
  13. data/app/models/renalware/renal/profile.rb +1 -1
  14. data/app/models/renalware/renal/registry/preflight_checks/deaths_query.rb +2 -5
  15. data/app/models/renalware/renal/registry/preflight_checks/patients_query.rb +27 -5
  16. data/app/models/renalware/ukrdc/patients_query.rb +0 -1
  17. data/app/models/renalware/ukrdc/send_patient.rb +1 -1
  18. data/app/presenters/renalware/accesses/dashboard_presenter.rb +2 -0
  19. data/app/presenters/renalware/hd/mdm_presenter.rb +4 -0
  20. data/app/presenters/renalware/hd/session_presenter.rb +2 -2
  21. data/app/presenters/renalware/mdm_presenter.rb +21 -0
  22. data/app/presenters/renalware/patients/banner_presenter.rb +2 -0
  23. data/app/views/renalware/api/ukrdc/patients/_address.xml.builder +2 -0
  24. data/app/views/renalware/api/ukrdc/patients/_allergies.xml.builder +2 -0
  25. data/app/views/renalware/api/ukrdc/patients/_clinic_visit_observation.xml.builder +2 -0
  26. data/app/views/renalware/api/ukrdc/patients/_clinical_relationships.xml.builder +2 -0
  27. data/app/views/renalware/api/ukrdc/patients/_diagnoses.xml.builder +2 -0
  28. data/app/views/renalware/api/ukrdc/patients/_documents.xml.builder +2 -0
  29. data/app/views/renalware/api/ukrdc/patients/_encounters.xml.builder +2 -0
  30. data/app/views/renalware/api/ukrdc/patients/_family_histories.xml.builder +2 -0
  31. data/app/views/renalware/api/ukrdc/patients/_lab_orders.xml.builder +2 -0
  32. data/app/views/renalware/api/ukrdc/patients/_medications.xml.builder +2 -0
  33. data/app/views/renalware/api/ukrdc/patients/_name.xml.builder +2 -0
  34. data/app/views/renalware/api/ukrdc/patients/_observations.xml.builder +2 -0
  35. data/app/views/renalware/api/ukrdc/patients/_patient.xml.builder +2 -0
  36. data/app/views/renalware/api/ukrdc/patients/_program_memberships.xml.builder +2 -0
  37. data/app/views/renalware/api/ukrdc/patients/_sending_facility.xml.builder +2 -0
  38. data/app/views/renalware/api/ukrdc/patients/_social_histories.xml.builder +2 -0
  39. data/app/views/renalware/api/ukrdc/patients/_surveys.xml.builder +2 -0
  40. data/app/views/renalware/api/ukrdc/patients/diagnoses/_cause_of_death.xml.builder +2 -0
  41. data/app/views/renalware/api/ukrdc/patients/encounters/_hd_session.xml.builder +2 -0
  42. data/app/views/renalware/api/ukrdc/patients/lab_orders/_lab_order.xml.builder +2 -0
  43. data/app/views/renalware/api/ukrdc/patients/lab_orders/_result_item.xml.builder +2 -0
  44. data/app/views/renalware/api/ukrdc/patients/show.xml.builder +2 -0
  45. data/app/views/renalware/api/v1/medications/prescriptions/index.json.jbuilder +2 -0
  46. data/app/views/renalware/api/v1/patients/patients/index.json.jbuilder +3 -1
  47. data/app/views/renalware/api/v1/patients/patients/show.json.jbuilder +2 -0
  48. data/app/views/renalware/hd/mdm/_summary.html.slim +21 -0
  49. data/app/views/renalware/hd/mdm/_top.html.slim +2 -0
  50. data/app/views/renalware/renal/prd_descriptions/search.json.jbuilder +2 -0
  51. data/app/views/renalware/renal/registry_preflight_checks/_filters.html.slim +19 -0
  52. data/app/views/renalware/renal/registry_preflight_checks/_table.html.slim +5 -0
  53. data/app/views/renalware/renal/registry_preflight_checks/deaths.html.slim +4 -0
  54. data/app/views/renalware/renal/registry_preflight_checks/patients.html.slim +4 -0
  55. data/lib/document/attribute_initializer.rb +2 -3
  56. data/lib/document/embedded.rb +26 -0
  57. data/lib/renalware/version.rb +1 -1
  58. data/spec/support/capybara.rb +2 -0
  59. metadata +8 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3db0ad6b8f0f4a6d478ecb2b24947e1f92d2e13fc3f8aeb9d5410c3e07e6fe58
4
- data.tar.gz: c59c4a12487d819da02c5227a6c2fc444276a635b666fce0390be3b227d8b476
3
+ metadata.gz: bded04d49b6bb55e363f0aea57ff4bb129dee0f9e25ffaa3a4d515aa7942f55b
4
+ data.tar.gz: 2d2513e0f3d161c064f7a7010f4420b0fa7fcbb913e55ecb8130cc88ae0205e3
5
5
  SHA512:
6
- metadata.gz: 14b5fb7212b9a888d725d30ef91bd3b247d5ca16d7da22b7fc201a3aee5ac3c4ddb9c8c8cf04308875d3f6604dc68a2b09c2a8f5d450a06bcbb6da27875c6f99
7
- data.tar.gz: 04e0de968deaf0758b1149925b250914cf517727e89c675140a8f5b6fb9cd56976d86fd4ba4af30e7c24e0cf1e656d836f44e13190e2000470ac9b9488272c0b
6
+ metadata.gz: ce45551e62fdb8f6e03c4845ddbd9fc2b740aeb8f9cdbc2d34197107f285b53fdff81299501822415beabd3413b60e78658837947a30affb147be11fd44188a3
7
+ data.tar.gz: 32ae5f07a4e9f1c1de68b0ab881712cbebab81c6e722288295fc419c0b0cf8d9467cba7c9d1b8516b060de096742c4bcede1b2c0224a6a05f1fe89df9af80881
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Add your own tasks in files placed in lib/tasks ending in .rake,
2
4
  # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
5
 
@@ -11,7 +13,7 @@ end
11
13
 
12
14
  # We can use rake tasks like app:db:reset when APP_RAKEFILE set
13
15
  unless defined?(APP_RAKEFILE)
14
- APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
16
+ APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
15
17
  end
16
18
 
17
19
  load "rails/tasks/engine.rake"
@@ -53,7 +53,7 @@ module Renalware
53
53
  relation: WeeklyDiary.eager_load(
54
54
  slots: [:patient, :station, :diurnal_period_code],
55
55
  master_diary: { slots: [:patient, :station, :diurnal_period_code] }
56
- ),
56
+ ),
57
57
  unit_id: unit_id,
58
58
  week_period: week_period,
59
59
  by: current_user
@@ -18,6 +18,10 @@ module Renalware
18
18
  Renalware::HD.cast_patient(__getobj__)&.hd_profile&.hospital_unit&.unit_code
19
19
  end
20
20
  end
21
+
22
+ def renal_profile
23
+ Renalware::Renal.cast_patient(__getobj__).profile
24
+ end
21
25
  end
22
26
 
23
27
  class DeceasedPatientPresenter < SimpleDelegator
@@ -26,13 +30,15 @@ module Renalware
26
30
  end
27
31
 
28
32
  def hd_unit; end
33
+
34
+ def renal_profile
35
+ Renalware::Renal.cast_patient(__getobj__).profile
36
+ end
29
37
  end
30
38
 
31
39
  def patients
32
40
  authorize [:renalware, :renal, :registry_preflight_check], :patients?
33
- query = Registry::PreflightChecks::PatientsQuery.new(
34
- query_params: params.fetch(:q, {})
35
- )
41
+ query = Registry::PreflightChecks::PatientsQuery.new(query_params: query_params)
36
42
  patients = query.call.page(page).per(per_page)
37
43
  patients = CollectionPresenter.new(patients, PatientPresenter)
38
44
  render locals: { patients: patients, query: query.search }
@@ -40,13 +46,19 @@ module Renalware
40
46
 
41
47
  def deaths
42
48
  authorize [:renalware, :renal, :registry_preflight_check], :deaths?
43
- query = Registry::PreflightChecks::DeathsQuery.new(
44
- query_params: params.fetch(:q, {})
45
- )
49
+ query = Registry::PreflightChecks::DeathsQuery.new(query_params: query_params)
46
50
  patients = query.call.page(page).per(per_page)
47
51
  patients = CollectionPresenter.new(patients, DeceasedPatientPresenter)
48
52
  render locals: { patients: patients, query: query.search }
49
53
  end
54
+
55
+ private
56
+
57
+ def query_params
58
+ qparams = params.fetch(:q, {})
59
+ qparams[:profile_esrf_on_gteq] ||= 3.years.ago
60
+ qparams
61
+ end
50
62
  end
51
63
  end
52
64
  end
@@ -9,8 +9,8 @@ require_dependency "renalware/snippets"
9
9
  module Renalware
10
10
  module Snippets
11
11
  class SnippetClonesController < BaseController
12
- COPY_SUFFIX = "[COPY]".freeze
13
- CLONE_SUFFIX = "[CLONE]".freeze
12
+ COPY_SUFFIX = "[COPY]"
13
+ CLONE_SUFFIX = "[CLONE]"
14
14
 
15
15
  def create
16
16
  snippet = duplicate_current_snippet
@@ -6,11 +6,11 @@ module Renalware
6
6
  layout "renalware/layouts/error"
7
7
 
8
8
  def not_found
9
- render status: 404, formats: [:html]
9
+ render status: :not_found, formats: [:html]
10
10
  end
11
11
 
12
12
  def internal_server_error
13
- render status: 500, formats: [:html]
13
+ render status: :internal_server_error, formats: [:html]
14
14
  end
15
15
 
16
16
  def generate_test_internal_server_error
@@ -13,8 +13,8 @@ module Renalware
13
13
  output = tag(:article, options, true)
14
14
  if title.present?
15
15
  output.safe_concat(
16
- content_tag("header".freeze) do
17
- content_tag("h1".freeze, title)
16
+ content_tag("header") do
17
+ content_tag("h1", title)
18
18
  end
19
19
  )
20
20
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_dependency "renalware/letters"
2
4
 
3
5
  module Renalware
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Renalware
2
4
  NullUser = Naught.build do |config|
3
5
  config.black_hole
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_dependency "renalware/pathology"
2
4
  require "attr_extras"
3
5
 
@@ -16,7 +16,6 @@ module Renalware
16
16
  # values.hgb_observed_at # => "2017-17-01"
17
17
  # So the values has methods corresponding to the entire set of possible
18
18
  # OBX codes, and also methods to reach in and get their result and observed_at date.
19
- # rubocop:disable Style/MethodMissing
20
19
  def method_missing(method_name, *_args, &_block)
21
20
  code, suffix = method_parts(method_name)
22
21
  if VALID_SUFFIXES.include?(suffix) || AllObservationCodes.include?(code)
@@ -9,9 +9,14 @@ module Renalware
9
9
  scope :having_no_primary_renal_diagnosis, lambda {
10
10
  where(renal_profile: nil)
11
11
  }
12
+
12
13
  scope :with_profile, lambda {
13
14
  joins("LEFT OUTER JOIN renal_profiles ON renal_profiles.patient_id = patients.id")
14
15
  }
16
+
17
+ scope :with_profile_avoiding_redefinition_of_renal_profiles_alias, lambda {
18
+ eager_load(:profile)
19
+ }
15
20
  end
16
21
  end
17
22
  end
@@ -17,7 +17,7 @@ module Renalware
17
17
 
18
18
  has_document class_name: "Renalware::Renal::ProfileDocument"
19
19
 
20
- validates :patient, presence: true
20
+ validates :patient, presence: true, uniqueness: true
21
21
  validates :esrf_on, timeliness: { type: :date, allow_nil: true }, allow_blank: true
22
22
  validates :first_seen_on,
23
23
  timeliness: {
@@ -19,18 +19,15 @@ module Renalware
19
19
  end
20
20
 
21
21
  def default_relation
22
- Renalware::Patient
23
- .preload(current_modality: [:description])
24
- .all
25
- .order(family_name: :asc)
22
+ Renalware::Renal::Patient.left_outer_joins(:profile)
26
23
  end
27
24
 
28
25
  def call
29
26
  search
30
27
  .result
31
28
  .extending(ModalityScopes)
29
+ .preload(current_modality: [:description])
32
30
  .with_current_modality_matching(MODALITY_NAMES)
33
- .joins("LEFT OUTER JOIN renal_profiles ON renal_profiles.patient_id = patients.id")
34
31
  .where("patients.first_cause_id is NULL AND renal_profiles.esrf_on IS NOT NULL")
35
32
  end
36
33
 
@@ -11,25 +11,47 @@ module Renalware
11
11
  MODALITY_NAMES = %w(HD PD Transplant).freeze
12
12
  attr_reader :relation, :query_params
13
13
 
14
+ # rubocop:disable Lint/UnusedMethodArgument
14
15
  def initialize(relation: nil, query_params: {})
15
16
  @relation ||= default_relation
16
17
  @query_params = query_params
17
18
  @query_params[:s] = "modality_descriptions_name ASC" if @query_params[:s].blank?
18
19
  end
20
+ # rubocop:enable Lint/UnusedMethodArgument
19
21
 
22
+ # The way I understand Ransack is that if you use a query like profile_esrf_gt
23
+ # (that's the RenalProfile in this case as we are dealing with a Renal::Patient)
24
+ # it will do the left out join itself onto renal_profiles.
25
+ # At one point I did a manual join onto renal_profiles here like this
26
+ # .joins("LEFT OUTER JOIN renal_profiles ON renal_profiles.patient_id = patients.id")
27
+ # but that only worked when there was no search predicate passed; when you pass eg
28
+ # profile_esrf_gt it joins onto renal_profiles again and you get a duplicate join.
29
+ # However using left_outer_joins here somehow prevents a duplicate join;
30
+ # one join onto renal_profiles is there whether there is a renal_profile_esrf_gt present
31
+ # or not. However it ONLY works if you use left_outer_joins BEFORE calling .ransack
32
+ # - calling it afterwards (in #call below) still results in a duplicate join IF
33
+ # renal_profile_esrf_gt is present in the query.
34
+ #
35
+ # I have to say, ransack eats up a lot of time and presents a lot of cognitive friction.
36
+ # Building a custom form object would have shaved an hour off the writing (mainly
37
+ # debugging) of this code.
38
+ #
39
+ # Update: moved loading of profile to #call.
40
+ # Having it in #default_relation leads to a duplicate alias if sorting on esrf for
41
+ # instance. Having to use .eager_load(:profile) in #call. However this creates n+1
42
+ # queries. Ransack again creating more confusion...
20
43
  def default_relation
21
- Renalware::Patient
22
- .preload(current_modality: [:description])
23
- .all
44
+ Renalware::Renal::Patient.all
24
45
  end
25
46
 
26
47
  def call
27
48
  search
28
49
  .result
50
+ .eager_load(:profile)
51
+ .joins("LEFT OUTER JOIN hd_profiles ON hd_profiles.patient_id = patients.id")
29
52
  .extending(ModalityScopes)
53
+ .preload(current_modality: [:description])
30
54
  .with_current_modality_matching(MODALITY_NAMES)
31
- .merge(HD::Patient.with_profile)
32
- .joins("LEFT OUTER JOIN renal_profiles ON renal_profiles.patient_id = patients.id")
33
55
  .where(where_conditions)
34
56
  end
35
57
 
@@ -9,7 +9,6 @@ module Renalware
9
9
  # patients who have changed since the last time they were exported.
10
10
  class PatientsQuery
11
11
  def call(changed_since: nil)
12
-
13
12
  if changed_since.present?
14
13
  rpv_patients.where("updated_at > ?", changed_since)
15
14
  else
@@ -99,7 +99,7 @@ module Renalware
99
99
  def time_neutral_payload
100
100
  payload
101
101
  .gsub(/<Stream>[^<]*<\/Stream>/, "<Stream>removed</Stream>")
102
- .gsub(/ (time|start|stop)=["'][^'"]*['"]/, '')
102
+ .gsub(/ (time|start|stop)=["'][^'"]*['"]/, "")
103
103
  .gsub(/<UpdatedOn>[^<]*<\/UpdatedOn>/, "<UpdatedOn>removed</UpdatedOn>")
104
104
  end
105
105
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_dependency "renalware/accesses"
2
4
  require "attr_extras"
3
5
 
@@ -50,6 +50,10 @@ module Renalware
50
50
  def audits
51
51
  @audits ||= PatientStatistics.for_patient(patient).limit(6).ordered
52
52
  end
53
+
54
+ def rolling_audit
55
+ @rolling_audit ||= audits.find_by(rolling: true)
56
+ end
53
57
  end
54
58
  end
55
59
  end
@@ -70,8 +70,8 @@ module Renalware
70
70
  post = after_measurement_for(measurement)
71
71
  return if pre.blank? || post.blank?
72
72
  case pre
73
- when ::Float; (post - pre).round(1)
74
- when ::Integer; (post - pre)
73
+ when ::Float then (post - pre).round(1)
74
+ when ::Integer then (post - pre)
75
75
  end
76
76
  rescue StandardError => exception
77
77
  nil
@@ -108,6 +108,26 @@ module Renalware
108
108
  CollectionPresenter.new(letters_, Renalware::Letters::LetterPresenterFactory)
109
109
  end
110
110
 
111
+ def current_pathology_for_code(code)
112
+ result = OpenStruct.new(value: nil, date: nil)
113
+ hash = patient.current_observation_set&.values_for_codes(code) || {}
114
+ obs = hash[code]
115
+ if obs.present?
116
+ result.value = obs["result"]
117
+ result.date = obs["observed_at"]
118
+ result.date = Date.parse(result.date)
119
+ end
120
+ result
121
+ end
122
+
123
+ def transplant_status
124
+ Renalware::Transplants::Registration.for_patient(patient)
125
+ .first
126
+ &.current_status
127
+ &.description
128
+ &.name
129
+ end
130
+
111
131
  private
112
132
 
113
133
  def pathology_descriptions_for_codes(codes)
@@ -137,3 +157,4 @@ module Renalware
137
157
  end
138
158
  end
139
159
  end
160
+ # rubocop:enable Metrics/ClassLength
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_dependency "renalware/patients"
2
4
 
3
5
  module Renalware
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  xml = builder
2
4
 
3
5
  # From National MIM H=Home TMP=Temporary PST=Postal
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #
2
4
  # https://github.com/renalreg/ukrdc/blob/6d95e364dd8de857839fe6cdbd4e7fc3fb4c1d42/Schema/Allergies/Allergy.xsd
3
5
  # This should be snomed-defined but we are just sending free text as that is all we have.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  xml = builder
2
4
 
3
5
  i18n_key ||= method
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  xml = builder
2
4
 
3
5
  xml.ClinicalRelationships do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # https://github.com/renalreg/ukrdc/blob/6d95e364dd8de857839fe6cdbd4e7fc3fb4c1d42/Schema/Diagnoses/Diagnosis.xsd
2
4
  # This is snomed-based, so might not be possible?
3
5
  xml = builder
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  xml = builder
2
4
 
3
5
  xml.Documents do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  xml = builder
2
4
 
3
5
  xml.Encounters do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  xml = builder
2
4
 
3
5
  xml.FamilyHistories do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  xml = builder
2
4
 
3
5
  # TODO: Implement start stop dates
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  xml = builder
2
4
 
3
5
  xml.Medications do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  builder.Name(use: "L") do
2
4
  builder.Prefix nameable.title
3
5
  builder.Family nameable.family_name
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # What are observations in RW?
2
4
  # - clinic visit
3
5
  # - weight
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #
2
4
  # Things we are not going to include in RW2.0
3
5
  # - PersonToContact
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  xml = builder
2
4
 
3
5
  xml.ProgramMemberships do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  xml = builder
2
4
 
3
5
  xml.SendingFacility Renalware.config.ukrdc_sending_facility_name,
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  xml = builder
2
4
 
3
5
  # Currently only used for smoking for which CodingStandard=RRSMOKE Code=YES/NO/EX
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  xml = builder
2
4
 
3
5
  xml.Surveys do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  xml = builder
2
4
 
3
5
  xml.CauseOfDeath do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  xml = builder
2
4
 
3
5
  xml.Treatment do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # See HL7 spec http://pacs.hk/Doc/HL7/Hl7V231.pdf
2
4
 
3
5
  # A Note about PlacerId
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  xml = builder
2
4
  observation = Renalware::Pathology::ObservationPresenter.new(observation)
3
5
  observation = Renalware::UKRDC::PathologyObservationPresenter.new(observation)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # See
2
4
  # https://www.ukrdc.org/2015/09/15/ukrdc-schema/
3
5
  # https://github.com/renalreg/ukrdc
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.array!(
2
4
  prescriptions,
3
5
  :id,
@@ -1,4 +1,6 @@
1
- def modify_query(url, options={})
1
+ # frozen_string_literal: true
2
+
3
+ def modify_query(url, options = {})
2
4
  uri = URI(url)
3
5
  query_hash = Rack::Utils.parse_query(uri.query)
4
6
  query_hash.merge!(options)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.id patient.id
2
4
  json.secure_id patient.secure_id
3
5
  json.nhs_number patient.nhs_number
@@ -0,0 +1,21 @@
1
+ article
2
+ header
3
+ h2 Additional Information
4
+
5
+ dl.dl-horizontal.xlarge
6
+ dt Latest Pre mean BP
7
+ - if mdm.rolling_audit.present?
8
+ dd= "#{mdm.rolling_audit.pre_mean_systolic_blood_pressure.to_i} / #{mdm.rolling_audit.pre_mean_diastolic_blood_pressure.to_i}"
9
+ dt Latest Post mean BP
10
+ - if mdm.rolling_audit.present?
11
+ dd= "#{mdm.rolling_audit.post_mean_systolic_blood_pressure.to_i} / #{mdm.rolling_audit.post_mean_diastolic_blood_pressure.to_i}"
12
+
13
+ dt Latest URR
14
+ dd
15
+ - obs = mdm.current_pathology_for_code("URR")
16
+ = obs.value
17
+ | &nbsp;&nbsp;
18
+ = "(#{l(obs.date)})" if obs.date.present?
19
+
20
+ dt Transplant status
21
+ dd= mdm.transplant_status
@@ -9,3 +9,5 @@
9
9
  positive_results_only: true
10
10
  .columns.medium-12.large-6
11
11
  = render "prescriptions", mdm: mdm, with_esa: true
12
+ .columns.medium-12.large-6
13
+ = render "summary", mdm: mdm
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  json.array! @prd_descriptions do |prd_description|
2
4
  json.id prd_description.id
3
5
  json.label prd_description.to_s
@@ -0,0 +1,19 @@
1
+ .search-form.filters
2
+ = simple_form_for query,
3
+ url: url,
4
+ method: :get,
5
+ html: { autocomplete: "off" } do |f|
6
+ .row
7
+ .medium-2.columns
8
+ = f.input :profile_esrf_on_gteq, as: :date_picker, label: "ESRF after"
9
+
10
+ -if defined?(display_modality_filter) && display_modality_filter
11
+ .medium-4.large-3.columns
12
+ = f.input :current_modality_description_id_eq,
13
+ collection: Renalware::Modalities::Description.pluck("name", "id"),
14
+ label: "Modality"
15
+
16
+ .medium-4.columns.actions.end
17
+ = f.submit t("helpers.submit.filter"), class: "button", name: nil
18
+ span= " or "
19
+ = link_to t("helpers.reset"), url
@@ -10,6 +10,10 @@ table.renal-registry-preflight-checks
10
10
  "Modality",
11
11
  default_order: :asc)
12
12
  td.col-width-small HD Site
13
+ td.col-width-date
14
+ = sort_link([:renalware, query],
15
+ :profile_esrf_on,
16
+ "ESRF date")
13
17
  td Missing data
14
18
  tbody
15
19
  - patients.each do |patient|
@@ -19,6 +23,7 @@ table.renal-registry-preflight-checks
19
23
  td= patient.hospital_identifiers
20
24
  td= patient.current_modality
21
25
  td= patient.hd_unit
26
+ td= l(patient.renal_profile&.esrf_on)
22
27
  td.missing-data
23
28
  - patient.missing_data.map do |data_item|
24
29
  span(class=data_item)= t(".#{data_item}")
@@ -1,4 +1,8 @@
1
1
  = within_admin_layout(title: "Renal Registry Return: Preflight Checks") do
2
+ = render "filters",
3
+ query: query,
4
+ url: deaths_renal_registry_preflight_checks_path,
5
+ display_modality_filter: false
2
6
  = render "navigation"
3
7
  = render "table", patients: patients, query: query
4
8
  = paginate patients
@@ -1,4 +1,8 @@
1
1
  = within_admin_layout(title: "Renal Registry Return: Preflight Checks") do
2
+ = render "filters",
3
+ query: query,
4
+ url: patients_renal_registry_preflight_checks_path,
5
+ display_modality_filter: true
2
6
  = render "navigation"
3
7
  = render "table", patients: patients, query: query
4
8
  = paginate patients
@@ -12,10 +12,9 @@ module Document
12
12
  end
13
13
 
14
14
  def self.build_class(type)
15
- case
16
- when type == Document::Enum
15
+ if type == Document::Enum
17
16
  AttributeInitializer::Enum
18
- when type && type.included_modules.include?(::ActiveModel::Model)
17
+ elsif type&.included_modules&.include?(::ActiveModel::Model)
19
18
  AttributeInitializer::ActiveModel
20
19
  else
21
20
  AttributeInitializer::Base
@@ -105,7 +105,33 @@ module Document
105
105
  class Embedded
106
106
  include Virtus.model
107
107
  include ActiveModel::Model
108
+ include ActiveModel::Validations::Callbacks
108
109
  extend Enumerize
110
+ STRIPPABLE_TYPES = %w(Float Integer).freeze
111
+
112
+ before_validation :strip_leading_trailing_whitespace_from_numbers
113
+
114
+ def strip_leading_trailing_whitespace_from_numbers
115
+ attributes.keys.each do |att|
116
+ # Find the type defined in the document definition eg `attribute :weight, Integer``
117
+ # Note that primitive could be a string or class, hence :to_s
118
+ primitive = self.class.attribute_set[att].type.primitive.to_s
119
+
120
+ # If the type is in STRIPPABLE_TYPES ie its a numeric type,
121
+ # and it has arrived as a string (which responds to :strip) then
122
+ # ensure there are no leading or trailing spaces, otherwise Virtus cannot
123
+ # coerce it into the correct type. For example Virtus won't corece
124
+ # " 1" into 1 but will coerce "1" into 1 (FYI the Dry::Types gem (the successor to Virtus)
125
+ # rectifies this).
126
+ # Note also that here in this before_validation callback, the act of assignment in
127
+ # `self[att] =` prompts Virtus to re-attempt to coerce the value, which now, if space
128
+ # has prevented it from doing so before, it will do successfully.
129
+ next unless STRIPPABLE_TYPES.include?(primitive)
130
+ if self[att].respond_to?(:strip)
131
+ self[att] = self[att].strip
132
+ end
133
+ end
134
+ end
109
135
 
110
136
  # Assign a default value to the attributes using a custom type.
111
137
  # Set a validation on nested object.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Renalware
4
- VERSION = "2.0.37"
4
+ VERSION = "2.0.38"
5
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # # frozen_string_literal: true
2
4
 
3
5
  Capybara.register_driver(:headless_chrome) do |app|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: renalware-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.37
4
+ version: 2.0.38
5
5
  platform: ruby
6
6
  authors:
7
7
  - Airslie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-28 00:00:00.000000000 Z
11
+ date: 2018-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_type
@@ -226,14 +226,14 @@ dependencies:
226
226
  requirements:
227
227
  - - "~>"
228
228
  - !ruby/object:Gem::Version
229
- version: 2.4.0
229
+ version: 2.5.0
230
230
  type: :runtime
231
231
  prerelease: false
232
232
  version_requirements: !ruby/object:Gem::Requirement
233
233
  requirements:
234
234
  - - "~>"
235
235
  - !ruby/object:Gem::Version
236
- version: 2.4.0
236
+ version: 2.5.0
237
237
  - !ruby/object:Gem::Dependency
238
238
  name: dumb_delegator
239
239
  requirement: !ruby/object:Gem::Requirement
@@ -590,14 +590,14 @@ dependencies:
590
590
  requirements:
591
591
  - - "~>"
592
592
  - !ruby/object:Gem::Version
593
- version: 5.2.0
593
+ version: 5.3.0
594
594
  type: :runtime
595
595
  prerelease: false
596
596
  version_requirements: !ruby/object:Gem::Requirement
597
597
  requirements:
598
598
  - - "~>"
599
599
  - !ruby/object:Gem::Version
600
- version: 5.2.0
600
+ version: 5.3.0
601
601
  - !ruby/object:Gem::Dependency
602
602
  name: rails
603
603
  requirement: !ruby/object:Gem::Requirement
@@ -2174,6 +2174,7 @@ files:
2174
2174
  - app/views/renalware/hd/mdm/_bottom.html.slim
2175
2175
  - app/views/renalware/hd/mdm/_middle.html.slim
2176
2176
  - app/views/renalware/hd/mdm/_sessions.html.slim
2177
+ - app/views/renalware/hd/mdm/_summary.html.slim
2177
2178
  - app/views/renalware/hd/mdm/_top.html.slim
2178
2179
  - app/views/renalware/hd/mdm_patients/_filters.html.slim
2179
2180
  - app/views/renalware/hd/mdm_patients/_patient.html.slim
@@ -2578,6 +2579,7 @@ files:
2578
2579
  - app/views/renalware/renal/profiles/_mini.html.slim
2579
2580
  - app/views/renalware/renal/profiles/edit.html.slim
2580
2581
  - app/views/renalware/renal/profiles/show.html.slim
2582
+ - app/views/renalware/renal/registry_preflight_checks/_filters.html.slim
2581
2583
  - app/views/renalware/renal/registry_preflight_checks/_navigation.html.slim
2582
2584
  - app/views/renalware/renal/registry_preflight_checks/_table.html.slim
2583
2585
  - app/views/renalware/renal/registry_preflight_checks/deaths.html.slim