renalware-core 2.0.108 → 2.0.109

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/renalware/admissions/consults_controller.rb +1 -1
  3. data/app/controllers/renalware/clinics/appointments_controller.rb +1 -1
  4. data/app/controllers/renalware/letters/formatted_letters_controller.rb +5 -1
  5. data/app/jobs/renalware/letters/save_rtf_letter_to_file_job.rb +29 -0
  6. data/app/models/renalware/admissions/consult.rb +12 -0
  7. data/app/models/renalware/admissions/consult_query.rb +2 -2
  8. data/app/models/renalware/hd/profiles_in_date_range_query.rb +21 -16
  9. data/app/models/renalware/letters/rtf_renderer.rb +12 -19
  10. data/app/models/renalware/low_clearance/mdm_patients_query.rb +3 -3
  11. data/app/models/renalware/medications/medication_route.rb +3 -1
  12. data/app/models/renalware/pathology/requests/sample_type.rb +18 -0
  13. data/app/models/renalware/ukrdc/treatment_timeline/hd/generator.rb +23 -9
  14. data/app/values/renalware/address.rb +4 -3
  15. data/app/views/renalware/admissions/consults/_form.html.slim +4 -0
  16. data/app/views/renalware/admissions/consults/_table.html.slim +12 -4
  17. data/app/views/renalware/api/ukrdc/patients/treatments/_generic.xml.builder +5 -0
  18. data/app/views/renalware/clinics/appointments/index.html.slim +18 -6
  19. data/app/views/renalware/clinics/appointments/new.html.slim +2 -0
  20. data/app/views/renalware/medications/prescriptions/_patient_details.html.slim +10 -4
  21. data/app/views/renalware/pathology/patient_rules/_form.html.slim +3 -1
  22. data/db/migrate/20190915071451_add_unique_index_to_medication_routes.rb +8 -0
  23. data/db/migrate/20190915083424_create_pathology_request_sample_types.rb +11 -0
  24. data/db/migrate/20190916160231_add_hd_type_to_ukrdc_treatments.rb +7 -0
  25. data/db/migrate/20190917124204_add_priority_to_admission_consults.rb +8 -0
  26. data/db/views/hd_profile_for_modalities_v01.sql +1 -1
  27. data/lib/renalware/version.rb +1 -1
  28. data/spec/factories/medications/medication_route.rb +7 -4
  29. metadata +8 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ddbc1bf89e7d3c6d32c617656f612b98929fab1110a56a48e52d53cc74251c0
4
- data.tar.gz: a63750e0fc7606ae785449cef68320c84ceedebd983a4ca568341cea7bdf511b
3
+ metadata.gz: c997818b4731d4dacc650d1ee21da4bc8d0731612f4b6afb6992375ad8ab5ebe
4
+ data.tar.gz: ca7fb8bb184625a629f68e685a8af2ed8a931e597496d3ad4f47f4cd7dd20f83
5
5
  SHA512:
6
- metadata.gz: 96ada68134d8d5a5fd76092e38a562ab0c3efdee4c6f7b3d2fc3eac00ef9ea2c7a51f97c43bed32c4647cb39da9e2b3243150f00001575a004d49d44f28310cd
7
- data.tar.gz: 5539d4f554e53988a5de121af668fbaf7ae06fc709cf1c88aa3dac31a6e301238813b670dc2c255d2aa8d28079923f531facd3d459842ee12dc9c3a0debe2d14
6
+ metadata.gz: 1f78547330d9e31903a14a2c794f782589ce3624888912a84bc3204d8e939091e503b29def2e06c7d835db8c70d9cb840986480ae77fbbd57bdf8d6bc7837ff2
7
+ data.tar.gz: 341dd6ad0f4f7c298de70c14b47cae472524fcd502d084c89c24a9020cdc37dde51970b517cd20eb7d2e3c31e4ec77bd31b59c354b72b88e376dd6e50c5884f7
@@ -100,7 +100,7 @@ module Renalware
100
100
  .permit(
101
101
  :consult_site_id, :hospital_ward_id, :patient_id, :q, :other_site_or_ward,
102
102
  :decided_on, :transferred_on, :started_on, :ended_on, :decided_on,
103
- :aki_risk, :transfer_priority, :seen_by_id, :consult_type,
103
+ :aki_risk, :transfer_priority, :priority, :seen_by_id, :consult_type,
104
104
  :requires_aki_nurse, :description, :contact_number, :rrt
105
105
  )
106
106
  end
@@ -56,7 +56,7 @@ module Renalware
56
56
  def appointment_params
57
57
  params
58
58
  .require(:clinics_appointment)
59
- .permit(:patient_id, :clinic_id, :starts_at)
59
+ .permit(:patient_id, :clinic_id, :starts_at, :outcome_notes, :dna_notes, :clinician_id)
60
60
  end
61
61
  end
62
62
  end
@@ -47,7 +47,11 @@ module Renalware
47
47
  end
48
48
 
49
49
  def render_rtf(letter)
50
- RTFRenderer.new(letter, self).render
50
+ renderer = RTFRenderer.new(letter)
51
+ send_data renderer.render,
52
+ type: "text/richtext",
53
+ filename: renderer.filename,
54
+ disposition: disposition
51
55
  end
52
56
 
53
57
  def disposition
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_dependency "renalware/letters"
4
+ require "fileutils"
5
+
6
+ module Renalware
7
+ module Letters
8
+ # Used for example in a host app like renalware-blt to generate an RTF letter for saving to
9
+ # the electronic public register, aka EPR/CRS.
10
+ class SaveRtfLetterToFileJob < ApplicationJob
11
+ queue_as :rtf_generation
12
+ queue_with_priority 1
13
+
14
+ def perform(letter:, file_path:)
15
+ file_path = Pathname(file_path)
16
+ create_folder_if_not_exists(file_path)
17
+ File.open(file_path, "wb") { |file| file << rtf_data_for(letter) }
18
+ end
19
+
20
+ def rtf_data_for(letter)
21
+ RTFRenderer.new(LetterPresenterFactory.new(letter)).render
22
+ end
23
+
24
+ def create_folder_if_not_exists(path)
25
+ FileUtils.mkdir_p(path.dirname)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -8,12 +8,20 @@ module Renalware
8
8
  include Accountable
9
9
  extend Enumerize
10
10
  include PatientsRansackHelper
11
+ PRIORITY_VALUES = (1..20).freeze
11
12
  validates :patient_id, presence: true
12
13
  validates :started_on, presence: true
13
14
  validates :description, presence: true
14
15
  # Currently #consult_type is a string and we are not sure what should be in there
15
16
  # Migrated consults may not have a type so only enforce it creation of new ones.
16
17
  validates :consult_type, presence: true, on: :create
18
+ validates :priority,
19
+ numericality: {
20
+ only_integer: true,
21
+ less_than_or_equal_to: PRIORITY_VALUES.last,
22
+ allow_blank: true
23
+ }
24
+
17
25
  validates :other_site_or_ward, presence: {
18
26
  if: ->(consult) { consult.consult_site_id.blank? && consult.hospital_ward_id.blank? }
19
27
  }
@@ -27,6 +35,10 @@ module Renalware
27
35
  enumerize :aki_risk, in: %i(yes no unknown)
28
36
 
29
37
  scope :active, -> { where(ended_on: nil) }
38
+
39
+ ransacker :priority do
40
+ Arel.sql("coalesce(priority, -1)")
41
+ end
30
42
  end
31
43
  end
32
44
  end
@@ -32,9 +32,9 @@ module Renalware
32
32
  .eager_load(patient: [current_modality: :description])
33
33
  .includes(
34
34
  :consult_site,
35
- :hospital_ward,
36
35
  :created_by,
37
- patient: { current_modality: :description }
36
+ patient: { current_modality: :description },
37
+ hospital_ward: :hospital_unit
38
38
  )
39
39
  .order(created_at: :desc)
40
40
  .ransack(query)
@@ -7,25 +7,30 @@ module Renalware
7
7
  class ProfilesInDateRangeQuery
8
8
  pattr_initialize [:patient!, :from!, :to!]
9
9
 
10
+ # We are looking for HD Profiles within a certain period.
11
+ # Some HD profiles have no prescribed_on populated (and it is not always acurate - if the
12
+ # profile is edited and a copy made, they sometimes to do not change the prescribed_on date)
13
+ # so for the start date of the profile we always use created_at and ignore prescribed_on,
14
+ # even if it is present.
10
15
  def call
11
- scope = Renalware::HD::Profile
12
- .with_deactivated
13
- .order(created_at: :asc, deactivated_at: :desc)
14
-
15
- scope
16
- .where(conditions.merge(deactivated_at: from..to))
17
- .or(
18
- scope.where(conditions.merge(deactivated_at: nil))
19
- )
20
- end
16
+ # p " from #{from}"
17
+ # p " to #{to}"
21
18
 
22
- private
19
+ # If to is nil it is because modality we are targetting is a current one.
20
+ # We need a date for the from..to range to work so use a far future one.
21
+ @to ||= Date.parse("3000-01-01")
23
22
 
24
- def conditions
25
- {
26
- patient_id: patient.id,
27
- created_at: from..DateTime::Infinity.new
28
- }
23
+ # Be sure not to reselect profiles we have already used in a previous treatment otherwise
24
+ # we will have duplicate Treatments with odd state/end date ordering
25
+ used_profiles_ids = UKRDC::Treatment
26
+ .where(patient: patient)
27
+ .where("hd_profile_id is not null")
28
+ .pluck(:hd_profile_id)
29
+ HD::Profile
30
+ .with_deactivated
31
+ .order(created_at: :asc, deactivated_at: :desc)
32
+ .where(patient_id: patient.id, created_at: from..to)
33
+ .where.not(id: used_profiles_ids)
29
34
  end
30
35
  end
31
36
  end
@@ -1,29 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_dependency "renalware/letters"
4
+ require "attr_extras"
4
5
 
5
6
  module Renalware
6
7
  module Letters
8
+ # Use pandoc to convert the html letter to RTF
7
9
  class RTFRenderer
8
- include ActionController::Rendering
10
+ pattr_initialize :letter
9
11
  REGEX_TO_STRIP_IMAGES = %r{(?m)<img\s*.*?"\s*\/>}.freeze
10
12
 
11
- def initialize(letter, controller)
12
- @letter = letter
13
- @controller = controller
14
- end
15
-
16
13
  def render
17
14
  using_temp_html_file do |temp_file|
18
- controller.send_data rtf_content_converted_from(temp_file),
19
- type: "text/richtext",
20
- filename: filename
15
+ rtf_content_converted_from(temp_file)
21
16
  end
22
17
  end
23
18
 
24
- private
19
+ def filename
20
+ "#{letter.pdf_filename}.rtf"
21
+ end
25
22
 
26
- attr_accessor :letter, :controller
23
+ def disposition
24
+ "attachment; filename=\"#{filename}\""
25
+ end
26
+
27
+ private
27
28
 
28
29
  def using_temp_html_file
29
30
  temp_html_file = Tempfile.new("html_to_be_converted_to_rtf")
@@ -35,14 +36,6 @@ module Renalware
35
36
  temp_html_file.unlink # allows garbage collection and temp file removal
36
37
  end
37
38
 
38
- def filename
39
- "#{letter.pdf_filename}.rtf"
40
- end
41
-
42
- def disposition
43
- "attachment; filename=\"#{filename}\""
44
- end
45
-
46
39
  def rtf_content_converted_from(html_temp_file)
47
40
  rtf_template = File.join(Engine.root, "lib", "pandoc", "templates", "default.rtf")
48
41
  options = { template: rtf_template }
@@ -57,15 +57,15 @@ module Renalware
57
57
  end
58
58
 
59
59
  def urea
60
- where("cast(values->'URE'->>'result' as float) >= 30.0")
60
+ where("convert_to_float(values->'URE'->>'result') >= 30.0")
61
61
  end
62
62
 
63
63
  def hgb_low
64
- where("cast(values->'HGB'->>'result' as float) < 100.0")
64
+ where("convert_to_float(values->'HGB'->>'result') < 100.0")
65
65
  end
66
66
 
67
67
  def hgb_high
68
- where("cast(values->'HGB'->>'result' as float) > 130.0")
68
+ where("convert_to_float(values->'HGB'->>'result') > 130.0")
69
69
  end
70
70
  end
71
71
  end
@@ -19,9 +19,11 @@ module Renalware
19
19
  through: :prescriptions,
20
20
  source: :treatable,
21
21
  source_type: "PeritonitisEpisode"
22
+ validates :code, presence: true
23
+ validates :name, presence: true
22
24
 
23
25
  def other?
24
- code == "Other"
26
+ code.casecmp("other").zero?
25
27
  end
26
28
  end
27
29
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_dependency "renalware/pathology/requests"
4
+
5
+ module Renalware
6
+ module Pathology
7
+ module Requests
8
+ # This is a sample lookup table of sample type values to use in a dropdown
9
+ # when creating a new new rule.
10
+ class SampleType < ApplicationRecord
11
+ validates :name, presence: true
12
+ validates :code, presence: true
13
+
14
+ scope :ordered, -> { order(code: :asc) }
15
+ end
16
+ end
17
+ end
18
+ end
@@ -3,6 +3,8 @@
3
3
  require_dependency "renalware/ukrdc"
4
4
  require "attr_extras"
5
5
 
6
+ # rubocop:disable Lint/UnneededCopDisableDirective, Rails/Output
7
+ # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
6
8
  module Renalware
7
9
  module UKRDC
8
10
  module TreatmentTimeline
@@ -14,6 +16,11 @@ module Renalware
14
16
  # a treatment for each significant change in the HD::Profile during the period of the
15
17
  # modality (ie until it ends).
16
18
  #
19
+ # Note that the first HD Profile associated with any HD Modality is determined in the SQL
20
+ # view hd_profile_for_modalities. Test with
21
+ # select * from hd_profile_for_modalities;
22
+ # It looks ahead to find the very first HD profile.
23
+ #
17
24
  class Generator
18
25
  pattr_initialize :modality
19
26
  delegate :patient, to: :modality
@@ -33,7 +40,6 @@ module Renalware
33
40
  )
34
41
  end
35
42
 
36
- # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
37
43
  def create_treatment(profile, start_date, end_date)
38
44
  treatments << Treatment.create!(
39
45
  patient: patient,
@@ -44,17 +50,18 @@ module Renalware
44
50
  hospital_unit: profile&.hospital_unit,
45
51
  ended_on: end_date,
46
52
  modality_code: ukrdc_modality_code_from_profile(profile),
47
- hd_profile: profile
53
+ hd_profile: profile,
54
+ hd_type: profile&.document&.dialysis&.hd_type
48
55
  )
49
56
 
50
57
  # Update the end date on the previous treatment - ie the one we just added is
51
58
  # taking over as the currently active treatment
52
- unless treatments.length <= 1
59
+ if treatments.length > 1
53
60
  previous_treatment = treatments[treatments.length - 2]
61
+ # p "updating end date from #{previous_treatment.ended_on} to #{start_date}"
54
62
  previous_treatment.update!(ended_on: start_date)
55
63
  end
56
64
  end
57
- # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
58
65
 
59
66
  # Find the modality that was active on the day of the modality change
60
67
  # The profile might have been added up to say 14 days later however so if there is none
@@ -86,10 +93,9 @@ module Renalware
86
93
  # and that becomes the 'last_profile' here
87
94
  def create_treatments_within_modality
88
95
  last_profile = hd_profile_at_start_of_modality
89
-
90
96
  hd_profiles.each do |profile_|
91
97
  profile = HD::ProfileDecorator.new(profile_, last_profile: last_profile)
92
- create_treatment_from(profile) if last_profile.nil? || profile.changed?
98
+ create_treatment_from(profile) # if last_profile.nil? || profile.changed?
93
99
  last_profile = profile
94
100
  end
95
101
  end
@@ -100,12 +106,18 @@ module Renalware
100
106
  from: modality.started_on,
101
107
  to: modality.ended_on
102
108
  ).call
103
- profiles - Array(hd_profile_at_start_of_modality)
109
+
110
+ # p profiles.to_sql
111
+
112
+ profiles -= Array(hd_profile_at_start_of_modality)
113
+ # p "found #{profiles.size} profiles #{profiles.map(&:id)} between "\
114
+ # "#{modality.started_on} and #{modality.ended_on}"
115
+ profiles
104
116
  end
105
117
 
106
118
  def create_treatment_from(profile)
107
- start_date = profile.present? ? profile.created_at : modality.started_on
108
- end_date = profile.present? ? profile.deactivated_at : modality.ended_on
119
+ start_date = profile.created_at.presence || modality.started_on
120
+ end_date = profile.deactivated_at.presence || modality.ended_on
109
121
 
110
122
  create_treatment(profile, start_date, end_date)
111
123
  end
@@ -126,3 +138,5 @@ module Renalware
126
138
  end
127
139
  end
128
140
  end
141
+ # rubocop:enable Lint/UnneededCopDisableDirective, Rails/Output
142
+ # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
@@ -35,9 +35,10 @@ module Renalware
35
35
  self
36
36
  end
37
37
 
38
- def to_s
39
- [name, organisation_name, street_1, street_2, street_3, town, county, postcode, country]
40
- .reject(&:blank?).join(", ")
38
+ def to_s(format = nil)
39
+ parts = [name, organisation_name, street_1, street_2, street_3, town, county]
40
+ parts += [postcode, country] unless format == :without_postcode
41
+ parts.reject(&:blank?).join(", ")
41
42
  end
42
43
 
43
44
  def street
@@ -32,6 +32,10 @@
32
32
  = f.input :consult_type, wrapper: :horizontal_medium
33
33
  = f.input :decided_on, as: :date_picker, wrapper: :horizontal_datepicker
34
34
  = f.input :transfer_priority, include_blank: false, wrapper: :horizontal_small
35
+ = f.input :priority,
36
+ include_blank: true,
37
+ collection: Renalware::Admissions::Consult::PRIORITY_VALUES,
38
+ wrapper: :horizontal_tiny
35
39
  = f.input :transferred_on, as: :date_picker, wrapper: :horizontal_datepicker
36
40
  = f.association :seen_by,
37
41
  as: :user_picker,
@@ -20,6 +20,16 @@
20
20
  - else
21
21
  | Ward
22
22
  th.col-width-tiny RRT
23
+ th.col-width-small.nowrap
24
+ - if allow_sorting
25
+ = sort_link(query, :transfer_priority, "Transfer Priority")
26
+ - else
27
+ | Transfer Priority
28
+ th.col-width-tiny
29
+ - if allow_sorting
30
+ = sort_link(query, :priority, "Priority")
31
+ - else
32
+ | Priority
23
33
  th.col-width-date.noprint
24
34
  - if allow_sorting
25
35
  = sort_link(query, :started_on, "Started")
@@ -44,8 +54,6 @@
44
54
  = sort_link(query, :patient_born_on, "DOB")
45
55
  - else
46
56
  | DOB
47
- - unless compact
48
- th.col-width-tiny.show-for-large-up Age
49
57
  th.col-width-tiny.noprint
50
58
  - if allow_sorting
51
59
  = sort_link(query, :aki_risk, "AKI Risk")
@@ -93,6 +101,8 @@
93
101
  td= consult.patient_hospital_identifiers&.to_s_multiline
94
102
  td= consult.hospital_ward
95
103
  td= yes_no(consult.rrt?)
104
+ td.nowrap= consult.transfer_priority&.text
105
+ td= consult.priority
96
106
  td.noprint= l(consult.started_on)
97
107
  td.noprint= l(consult.ended_on)
98
108
  - unless compact
@@ -101,8 +111,6 @@
101
111
  td.show-for-large-up= consult.patient_sex
102
112
  - unless compact
103
113
  td.show-for-large-up= l(consult.patient.born_on)
104
- - unless compact
105
- td.show-for-large-up= consult.patient_age
106
114
  td.noprint= consult.aki_risk&.text
107
115
  /td.show-for-xlarge-up.consult-author.col-width-medium-with-ellipsis(title=consult.created_by)= consult.created_by
108
116
  /td.col-width-medium-with-ellipsis(title=consult.description)= consult.description
@@ -8,6 +8,11 @@ xml.Treatment do
8
8
  xml.FromTime treatment.started_on&.iso8601
9
9
  xml.ToTime(treatment.ended_on&.iso8601) if treatment.ended_on.present?
10
10
 
11
+ xml.HealthCareFacility do
12
+ xml.CodingStandard "ODS"
13
+ xml.Code Renalware.config.ukrdc_site_code
14
+ end
15
+
11
16
  xml.AdmitReason do
12
17
  xml.CodingStandard "CF_RR7_TREATMENT"
13
18
  xml.Code treatment.modality_code.txt_code
@@ -38,7 +38,7 @@
38
38
  br
39
39
  |
40
40
  = link_to "(Uncheck all)", "#", id: "uncheck_all_appointments_link"
41
- th.col-width-medium
41
+ th.col-width-medium-ish
42
42
  th.col-width-date
43
43
  = sort_link([:renalware, query], :starts_at, "Date", default_order: :asc)
44
44
  th.col-width-time
@@ -54,24 +54,27 @@
54
54
  default_order: :asc)
55
55
  th= sort_link([:renalware, query], :clinic_name, "Clinic", default_order: :asc)
56
56
  th= sort_link([:renalware, query], :user_family_name, "Consultant", default_order: :asc)
57
+ th.show-for-large-up Outcome notes
58
+ th.show-for-large-up DNA notes
57
59
 
58
60
  tbody
59
61
  - appointments.each do |appointment|
60
62
  tr
61
63
  td= check_box_tag nil, appointment.patient.id, true, class: "patient_checkbox"
62
- td
64
+ td.nowrap
65
+ = link_to("Toggle",
66
+ "#appointment-quick-preview-#{appointment.id}",
67
+ data: { behaviour: "toggler" })
68
+ = " | "
63
69
  - if appointment.becomes_visit_id.present?
64
70
  = link_to edit_patient_clinic_visit_path(appointment.patient,
65
71
  id: appointment.becomes_visit_id) do
66
- i.fas.fa-file
67
- | &nbsp;&nbsp;
68
72
  | View Clinic Visit
69
73
  - else
70
74
  = link_to new_patient_clinic_visit_path(appointment.patient,
71
75
  appointment_id: appointment.id) do
72
76
  i.fas.fa-pencil-alt
73
- | &nbsp;&nbsp;
74
- | Create Clinic Visit
77
+ = " Create Clinic Visit"
75
78
 
76
79
  td= I18n.l appointment.starts_on
77
80
  td= appointment.start_time
@@ -81,5 +84,14 @@
81
84
  td= appointment.patient.current_modality
82
85
  td= appointment.clinic.name
83
86
  td= appointment.user.full_name
87
+ td.show-for-large-up.col-width-medium-with-ellipsis= appointment.outcome_notes
88
+ td.show-for-large-up.col-width-medium-with-ellipsis= appointment.dna_notes
89
+ = content_tag(:tr, id: "appointment-quick-preview-#{appointment.id}", style: "display: none")
90
+ td
91
+ td(colspan=13)
92
+ .quick-preview
93
+ = definition_list_for(appointment, size: :large) do |list|
94
+ = list.definition(:outcome_notes){ |value| simple_format(value) }
95
+ = list.definition(:dna_notes){ |value| simple_format(value) }
84
96
 
85
97
  = paginate appointments
@@ -27,4 +27,6 @@
27
27
  collection: Renalware::Clinics::Clinic.all,
28
28
  wrapper: :horizontal_medium
29
29
  = f.input :starts_at, as: :datetime_picker, wrapper: :horizontal_datepicker
30
+ = f.input :outcome_notes, as: :text, wrapper: :horizontal_large
31
+ = f.input :dna_notes, as: :text, wrapper: :horizontal_large
30
32
  = f.submit class: :button
@@ -1,10 +1,16 @@
1
1
  section
2
2
  dl
3
+ dt Hospital Numbers
4
+ dd= patient.hospital_identifiers
5
+ dt NHS Number
6
+ dd= formatted_nhs_number(patient)
3
7
  dt Name
4
8
  dd= patient.to_s
5
9
  dt Date of Birth
6
10
  dd= l(patient.born_on)
7
- dt NHS Number
8
- dd= patient.nhs_number
9
- dt Hospital no
10
- dd= patient.hospital_identifier
11
+ dt Address
12
+ dd= patient.current_address&.to_s(:without_postcode)
13
+ dt Postcode
14
+ dd= patient.current_address&.postcode
15
+ dt Telephone
16
+ dd= patient.telephone1.presence || patient.telephone2
@@ -1,7 +1,9 @@
1
1
  = f.input :lab_id, collection: labs, input_html: { class: "small-input" }
2
2
  = f.input :test_description, as: :text, input_html: { class: "small-input" }
3
3
  = f.input :sample_number_bottles, collection: 0..10, input_html: { class: "small-input" }
4
- = f.input :sample_type, input_html: { class: "small-input" }
4
+ = f.input :sample_type,
5
+ collection: Renalware::Pathology::Requests::SampleType.ordered.pluck(:name, :code),
6
+ input_html: { class: "small-input" }
5
7
  = f.input :frequency_type, collection: frequencies, input_html: { class: "small-input" }
6
8
  = f.input :start_date, as: :date_picker, input_html: { class: "small-input" }
7
9
  = f.input :end_date, as: :date_picker, input_html: { class: "small-input" }
@@ -0,0 +1,8 @@
1
+ class AddUniqueIndexToMedicationRoutes < ActiveRecord::Migration[5.2]
2
+ def change
3
+ within_renalware_schema do
4
+ add_index :medication_routes, :code, unique: true
5
+ add_index :medication_routes, :name, unique: true
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,11 @@
1
+ class CreatePathologyRequestSampleTypes < ActiveRecord::Migration[5.2]
2
+ def change
3
+ within_renalware_schema do
4
+ create_table :pathology_requests_sample_types do |t|
5
+ t.string :name, index: { unique: true }, null: false
6
+ t.string :code, index: { unique: true }, null: false
7
+ t.timestamps null: false
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ class AddHDTypeToUKRDCTreatments < ActiveRecord::Migration[5.2]
2
+ def change
3
+ within_renalware_schema do
4
+ add_column :ukrdc_treatments, :hd_type, :string
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,8 @@
1
+ class AddPriorityToAdmissionConsults < ActiveRecord::Migration[5.2]
2
+ def change
3
+ within_renalware_schema do
4
+ add_column :admission_consults, :priority, :integer, null: true
5
+ add_index :admission_consults, :priority
6
+ end
7
+ end
8
+ end
@@ -1,4 +1,4 @@
1
- -- This view is HD-specific, but really serevers to make UKRDC export easier.
1
+ -- This view is HD-specific, but really serves to make UKRDC export easier.
2
2
  -- It attempts to solve the gnarly problem of finding the hd profile associated with the start
3
3
  -- of an HD modality. For example if a patient goes on to HD, an HD modality row is created.
4
4
  -- However it could be a couple of weeks before they have an HD profile setup. This view
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Renalware
4
- VERSION = "2.0.108"
4
+ VERSION = "2.0.109"
5
5
  end
@@ -2,12 +2,15 @@
2
2
 
3
3
  FactoryBot.define do
4
4
  factory :medication_route, class: "Renalware::Medications::MedicationRoute" do
5
+ initialize_with do
6
+ Renalware::Medications::MedicationRoute.find_or_create_by!(code: code, name: name)
7
+ end
5
8
  code { "PO" }
6
9
  name { "Per Oral" }
7
- end
8
10
 
9
- trait :other do
10
- code { "Other" }
11
- name { "Other" }
11
+ trait :other do
12
+ code { "Other" }
13
+ name { "Other" }
14
+ end
12
15
  end
13
16
  end
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.108
4
+ version: 2.0.109
5
5
  platform: ruby
6
6
  authors:
7
7
  - Airslie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-13 00:00:00.000000000 Z
11
+ date: 2019-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_type
@@ -1359,6 +1359,7 @@ files:
1359
1359
  - app/jobs/renalware/hd/update_rolling_patient_statistics_job.rb
1360
1360
  - app/jobs/renalware/letters/calculate_page_count_job.rb
1361
1361
  - app/jobs/renalware/letters/save_pdf_letter_to_file_job.rb
1362
+ - app/jobs/renalware/letters/save_rtf_letter_to_file_job.rb
1362
1363
  - app/jobs/renalware/reporting/refresh_audit_data_job.rb
1363
1364
  - app/mailers/renalware/admin/user_mailer.rb
1364
1365
  - app/mailers/renalware/letters/delivery/errors.rb
@@ -1698,6 +1699,7 @@ files:
1698
1699
  - app/models/renalware/pathology/requests/request_params_factory.rb
1699
1700
  - app/models/renalware/pathology/requests/request_query.rb
1700
1701
  - app/models/renalware/pathology/requests/requests_factory.rb
1702
+ - app/models/renalware/pathology/requests/sample_type.rb
1701
1703
  - app/models/renalware/pathology/results.rb
1702
1704
  - app/models/renalware/pathology/view_observation_results.rb
1703
1705
  - app/models/renalware/patient.rb
@@ -3555,6 +3557,10 @@ files:
3555
3557
  - db/migrate/20190823105642_add_asked_for_write_access_to_users.rb
3556
3558
  - db/migrate/20190830082736_add_pd_regime_columns_for_blt.rb
3557
3559
  - db/migrate/20190909084425_add_columns_to_support_data_migration.rb
3560
+ - db/migrate/20190915071451_add_unique_index_to_medication_routes.rb
3561
+ - db/migrate/20190915083424_create_pathology_request_sample_types.rb
3562
+ - db/migrate/20190916160231_add_hd_type_to_ukrdc_treatments.rb
3563
+ - db/migrate/20190917124204_add_priority_to_admission_consults.rb
3558
3564
  - db/seeds.rb
3559
3565
  - db/seeds/default/accesses/access_pd_catheter_insertion_techniques.csv
3560
3566
  - db/seeds/default/accesses/access_pd_catheter_insertion_techniques.rb