renalware-core 2.0.32 → 2.0.33

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/renalware/partials/_tables.scss +1 -1
  3. data/app/controllers/renalware/hd/dialysates_controller.rb +78 -0
  4. data/app/controllers/renalware/hd/dialysers_controller.rb +3 -1
  5. data/app/models/renalware/hd/dialysate.rb +5 -1
  6. data/app/models/renalware/hd/dialyser.rb +2 -0
  7. data/app/models/renalware/letters/letter_query.rb +1 -1
  8. data/app/policies/renalware/hd/dialysate_policy.rb +8 -0
  9. data/app/presenters/renalware/dashboard/dashboard_presenter.rb +3 -1
  10. data/app/presenters/renalware/ukrdc/patient_presenter.rb +5 -0
  11. data/app/views/renalware/api/ukrdc/patients/_patient.xml.builder +1 -1
  12. data/app/views/renalware/dashboard/letters/_letter.html.slim +1 -1
  13. data/app/views/renalware/dashboard/letters/_table.html.slim +1 -1
  14. data/app/views/renalware/hd/dialysates/_form.html.slim +12 -0
  15. data/app/views/renalware/hd/dialysates/edit.html.slim +2 -0
  16. data/app/views/renalware/hd/dialysates/index.html.slim +35 -0
  17. data/app/views/renalware/hd/dialysates/new.html.slim +2 -0
  18. data/app/views/renalware/hd/dialysers/_form.html.slim +2 -0
  19. data/app/views/renalware/hd/dialysers/index.html.slim +10 -6
  20. data/app/views/renalware/letters/letters/_letter.html.slim +1 -1
  21. data/app/views/renalware/letters/letters/_table.html.slim +1 -1
  22. data/app/views/renalware/letters/lists/_letter.html.slim +1 -1
  23. data/app/views/renalware/letters/lists/_table.html.slim +1 -1
  24. data/app/views/renalware/navigation/_super_admin.html.slim +1 -0
  25. data/app/views/renalware/research/_alerts.html.slim +4 -6
  26. data/config/permissions.yml +1 -0
  27. data/config/routes.rb +1 -0
  28. data/db/migrate/20180524072633_add_columns_to_dialysates.rb +15 -0
  29. data/db/migrate/20180524074320_add_columns_to_hd_dialysers.rb +10 -0
  30. data/lib/renalware/version.rb +1 -1
  31. data/spec/factories/hd/dialysers.rb +2 -0
  32. data/spec/factories/patients/languages.rb +6 -1
  33. metadata +10 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0616c45358e54ea9da9260af10d1790d3cf1ac2d209d80cdab18f7696dbf572
4
- data.tar.gz: be29d4c73b6dfb3679c4dc0306a5f9adb62aeddf9f57d78fa591286663c41b15
3
+ metadata.gz: 6cb83ec4abb560e829604647e54cc9ad09d82dc7a5505d8f5f07491995f5b23f
4
+ data.tar.gz: 2a2113a1fbfde978e756208df0c8bf73e3fb6634f0bcde25ba3d48d45dfb8907
5
5
  SHA512:
6
- metadata.gz: 16371d75df1c3a0a85a89e607d7e1f7f3eada6ce54111ad6f9a30277c3f7df3b40d77be83a0c7d8c15729df6d626295f194738fc9056af9a321990839f2f7ad9
7
- data.tar.gz: b230a562d38f8ed18c3bd2ae10d01f3981e2970cd4d99e68aba3db5ec8f92f8a57abb00b1364bf94a2591d423655f072727e0a107eee2fcadf70e85135e9e45e
6
+ metadata.gz: 1324b463a16ae76bbbcb00a1c23a071eec16fa95494f536ea2be996d4931720ccddd896a42f1c03557921e4efadeaae8c2f17b67dc29075f491c8545f3257ccb
7
+ data.tar.gz: a0de64f66ec38ee3b10f5cc9cbaee028d762cf5986364e2c50dfc521ff206c916abfdea83bb15127ff7b3f2d372b8369e01f422f589361d280a48e8469d37e11
@@ -182,7 +182,7 @@ table {
182
182
 
183
183
  &.col-width-date-time {
184
184
  width: 9.5rem;
185
- min-width: 9.3rem;
185
+ min-width: 9.4rem;
186
186
  }
187
187
 
188
188
  &.col-width-reference-without-prefix {
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_dependency "renalware/hd/base_controller"
4
+
5
+ module Renalware
6
+ module HD
7
+ class DialysatesController < HD::BaseController
8
+ def index
9
+ dialysates = Dialysate.all
10
+ authorize dialysates
11
+ render locals: { dialysates: dialysates }
12
+ end
13
+
14
+ def new
15
+ dialysate = Dialysate.new
16
+ authorize dialysate
17
+ render_new(dialysate)
18
+ end
19
+
20
+ def create
21
+ dialysate = Dialysate.new(dialysate_params)
22
+ authorize dialysate
23
+
24
+ if dialysate.save
25
+ redirect_to hd_dialysates_path, notice: success_msg_for("dialysate")
26
+ else
27
+ flash.now[:error] = failed_msg_for("dialysate")
28
+ render_new(dialysate)
29
+ end
30
+ end
31
+
32
+ def edit
33
+ render_edit(find_and_authorize_dialysate)
34
+ end
35
+
36
+ def update
37
+ dialysate = find_and_authorize_dialysate
38
+ if dialysate.update(dialysate_params)
39
+ redirect_to hd_dialysates_path, notice: success_msg_for("dialysate")
40
+ else
41
+ flash.now[:error] = failed_msg_for("dialysate")
42
+ render_edit(dialysate)
43
+ end
44
+ end
45
+
46
+ def destroy
47
+ find_and_authorize_dialysate.destroy!
48
+ redirect_to hd_dialysates_path, notice: success_msg_for("dialysate")
49
+ end
50
+
51
+ private
52
+
53
+ def render_new(dialysate)
54
+ render :new, locals: { dialysate: dialysate }
55
+ end
56
+
57
+ def render_edit(dialysate)
58
+ render :edit, locals: { dialysate: dialysate }
59
+ end
60
+
61
+ def find_and_authorize_dialysate
62
+ Dialysate.find(params[:id]).tap { |dialysate| authorize(dialysate) }
63
+ end
64
+
65
+ def dialysate_params
66
+ params
67
+ .require(:dialysate)
68
+ .permit(
69
+ :name, :description,
70
+ :sodium_content, :sodium_content_uom,
71
+ :bicarbonate_content, :bicarbonate_content_uom,
72
+ :calcium_content, :calcium_content_uom,
73
+ :potassium_content, :potassium_content_uom
74
+ )
75
+ end
76
+ end
77
+ end
78
+ end
@@ -53,7 +53,9 @@ module Renalware
53
53
  private
54
54
 
55
55
  def dialyser_params
56
- params.require(:hd_dialyser).permit(:group, :name)
56
+ params
57
+ .require(:hd_dialyser)
58
+ .permit(:group, :name, :membrane_surface_area, :membrane_surface_area_coefficient_k0a)
57
59
  end
58
60
 
59
61
  def load_and_authorize_dialyser
@@ -7,8 +7,12 @@ module Renalware
7
7
  class Dialysate < ApplicationRecord
8
8
  acts_as_paranoid
9
9
  validates :name, presence: true, uniqueness: true
10
- validates :sodium_content, presence: true
10
+ validates :sodium_content, presence: true, numericality: true
11
11
  validates :sodium_content_uom, presence: true
12
+ validates :bicarbonate_content, numericality: true, allow_blank: true
13
+ validates :calcium_content, numericality: true, allow_blank: true
14
+ validates :glucose_content, numericality: true, allow_blank: true
15
+ validates :potassium_content, numericality: true, allow_blank: true
12
16
 
13
17
  def to_s
14
18
  name
@@ -9,6 +9,8 @@ module Renalware
9
9
 
10
10
  validates :group, presence: true
11
11
  validates :name, presence: true
12
+ validates :membrane_surface_area, numericality: true, allow_blank: true
13
+ validates :membrane_surface_area_coefficient_k0a, numericality: true, allow_blank: true
12
14
 
13
15
  scope :ordered, -> { order(:group, :name) }
14
16
 
@@ -21,7 +21,7 @@ module Renalware
21
21
  class LetterQuery
22
22
  def initialize(q: nil)
23
23
  @q = q || {}
24
- @q[:s] ||= ["issued_on desc"]
24
+ @q[:s] ||= ["updated_at desc"]
25
25
  end
26
26
 
27
27
  def call
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Renalware
4
+ module HD
5
+ class DialysatePolicy < BasePolicy
6
+ end
7
+ end
8
+ end
@@ -21,13 +21,15 @@ module Renalware
21
21
  end
22
22
  end
23
23
 
24
+ # Note we want oldest letters ordered first on the dashboard - elsewhere letters
25
+ # are newest first
24
26
  def letters_in_progress
25
27
  @letters_in_progress ||= begin
26
28
  present_letters(
27
29
  Letters::Letter
28
30
  .where("author_id = ? or created_by_id = ?", user.id, user.id)
29
31
  .in_progress
30
- .reverse
32
+ .order(updated_at: :asc)
31
33
  )
32
34
  # Renalware::Letters.cast_author(user)
33
35
  end
@@ -26,6 +26,11 @@ module Renalware
26
26
  super(patient)
27
27
  end
28
28
 
29
+ def language
30
+ return if super.nil? || super.name == "Unknown"
31
+ super
32
+ end
33
+
29
34
  def dead?
30
35
  current_modality_death?
31
36
  end
@@ -58,7 +58,7 @@ xml.Patient do
58
58
 
59
59
  if patient.language.present?
60
60
  xml.PrimaryLanguage do
61
- xml.CodingStandard "NHS_DATA_DICTIONARY_LANGUAGE_CODE" # ISO 639-1 plus braille an sign
61
+ xml.CodingStandard "NHS_DATA_DICTIONARY_LANGUAGE_CODE" # ISO 639-1 plus braille and sign
62
62
  xml.Code patient.language&.code
63
63
  xml.Description patient.language
64
64
  end
@@ -1,7 +1,7 @@
1
1
  tr(class=letter.state.dasherize)
2
2
  td.state
3
3
  span= letter.state_description
4
- td= l letter.issued_on
4
+ td= l letter.updated_at
5
5
  td= letter.author
6
6
  td= link_to letter.patient, patient_clinical_summary_path(letter.patient)
7
7
  td= letter.description
@@ -2,7 +2,7 @@ table.auto-layout.letters
2
2
  thead
3
3
  tr
4
4
  th.col-width-tiny State
5
- th.col-width-date Date
5
+ th.col-width-date-time Date
6
6
  th.col-width-medium Author
7
7
  th.col-width-large Patient
8
8
  th Description
@@ -0,0 +1,12 @@
1
+ = render "renalware/shared/errors", model: dialysate
2
+
3
+ = simple_form_for dialysate, as: :dialysate, html: { autocomplete: "off" } do |f|
4
+ = f.input :name, autofocus: true, wrapper: :horizontal_medium
5
+ = f.input :description, wrapper: :horizontal_large
6
+ - %i(sodium bicarbonate potassium calcium glucose).each do |element|
7
+ = f.input :"#{element}_content", wrapper: :horizontal_small
8
+ = f.input :"#{element}_content_uom", wrapper: :horizontal_small
9
+
10
+ = f.button :submit
11
+ span= " or "
12
+ = link_to "cancel", hd_dialysates_path
@@ -0,0 +1,2 @@
1
+ = within_admin_layout(title: "Edit HD Disalysate") do
2
+ = render "form", dialysate: dialysate
@@ -0,0 +1,35 @@
1
+ = content_for(:actions) do
2
+ = link_to "Add",
3
+ new_hd_dialysate_path,
4
+ class: "button"
5
+
6
+ = within_admin_layout(title: "HD Dialysates") do
7
+
8
+ table.hd-dialysates
9
+ thead
10
+ th.col-width-tiny
11
+ th.col-width-medium Name
12
+ th.col-width-medium Description
13
+ - %i(sodium bicarbonate potassium calcium glocose).each do |element|
14
+ th.col-width-tiny= element.to_s.capitalize
15
+ tbody
16
+ - dialysates.each do |dialysate|
17
+ tr
18
+ td
19
+ - if policy(dialysate).edit?
20
+ = link_to "Edit", edit_hd_dialysate_path(dialysate)
21
+ / Disabling destroy for now as it seems to let you delete a dialysate that is in use
22
+ / Need to add a FK first
23
+ / - if policy(dialysate).destroy?
24
+ / = pipe_separator
25
+ / = link_to "Delete",
26
+ / hd_dialysate_path(dialysate),
27
+ / method: :delete,
28
+ / data: { confirm: "Are you sure?" }
29
+ td= dialysate.name
30
+ td= dialysate.description
31
+ - %i(sodium bicarbonate potassium calcium glucose).each do |element|
32
+ - line = [ \
33
+ dialysate.public_send(:"#{element}_content"), \
34
+ dialysate.public_send(:"#{element}_content_uom")].compact.join(" ")
35
+ td= line
@@ -0,0 +1,2 @@
1
+ = within_admin_layout(title: "New HD Disalysate") do
2
+ = render "form", dialysate: dialysate
@@ -4,6 +4,8 @@
4
4
  = simple_form_for dialyser, html: { autocomplete: "off" } do |f|
5
5
  = f.input :group, autofocus: true, wrapper: :horizontal_small
6
6
  = f.input :name, wrapper: :horizontal_small
7
+ = f.input :membrane_surface_area, wrapper: :horizontal_small
8
+ = f.input :membrane_surface_area_coefficient_k0a, wrapper: :horizontal_small
7
9
 
8
10
  = f.button :submit
9
11
  span= " or "
@@ -8,16 +8,20 @@
8
8
  tr
9
9
  th.col-width-small
10
10
  th.col-width-small Group
11
- th Name
11
+ th.col-width-large Name
12
+ th.col-width-small Membrane Surface Area
13
+ th Membrane Surface Area (K0A)
12
14
  tbody
13
- - dialysers.each do |t|
15
+ - dialysers.each do |dialyser|
14
16
  tr
15
17
  td
16
- = link_to "Edit", edit_hd_dialyser_path(t.id)
18
+ = link_to "Edit", edit_hd_dialyser_path(dialyser.id)
17
19
  = pipe_separator
18
20
  = link_to "Delete",
19
- hd_dialyser_path(t.id),
21
+ hd_dialyser_path(dialyser.id),
20
22
  method: :delete,
21
23
  data: { confirm: I18n.t("prompts.confirm_delete") }
22
- td= t.group
23
- td= t.name
24
+ td= dialyser.group
25
+ td= dialyser.name
26
+ td= dialyser.membrane_surface_area
27
+ td= dialyser.membrane_surface_area_coefficient_k0a
@@ -17,7 +17,7 @@
17
17
 
18
18
  td.state
19
19
  span= letter.state_description
20
- td= l(letter.issued_on)
20
+ td= l(letter.updated_at)
21
21
  - if columns.include?(:author)
22
22
  td.col-width-medium-with-ellipsis= letter.author
23
23
  - if columns.include?(:patient)
@@ -5,7 +5,7 @@ table.auto-layout.letters.has-togglable-rows
5
5
  tr
6
6
  th.col-width-small
7
7
  th.col-width-tiny State
8
- th.col-width-date Date
8
+ th.col-width-date-time Date
9
9
  - if columns.include?(:author)
10
10
  th.col-width-medium Author
11
11
  - if columns.include?(:patient)
@@ -29,7 +29,7 @@ tr(class=letter.state.dasherize)
29
29
  td.full-name= default_patient_link(letter.patient)
30
30
  td= letter.patient.nhs_number
31
31
  td= letter.enclosures&.truncate(6)
32
- td= l letter.issued_on
32
+ td= l letter.updated_at
33
33
  td= letter.author
34
34
  td= letter.typist
35
35
  td.col-width-medium-with-ellipsis= letter.main_recipient.address
@@ -8,7 +8,7 @@
8
8
  th.col-width-medium= sort_link([:renalware, q], :patient_family_name, "Patient")
9
9
  th.col-width-nhs-no= sort_link([:renalware, q], :patient_nhs_number, "NHS No")
10
10
  th= sort_link([:renalware, q], :enclosures, "Enc.")
11
- th.col-width-date = sort_link([:renalware, q], :issued_on, "Date", default_order: :desc)
11
+ th.col-width-date-time = sort_link([:renalware, q], :updated_at, "Date", default_order: :desc)
12
12
  th= sort_link([:renalware, q], :author_family_name, "Author")
13
13
  th= sort_link([:renalware, q], :created_by_family_name, "Typist")
14
14
  th.col-width-small Recipient
@@ -10,3 +10,4 @@ li.has-dropdown
10
10
  li= link_to "File Imports", admin_feeds_files_path
11
11
  li= link_to "User Feedback", system_user_feedback_index_path
12
12
  li= link_to "System Messages", system_messages_path
13
+ li= link_to "HD Dialysates", hd_dialysates_path
@@ -1,6 +1,4 @@
1
- / Note the caching here relies on study_participant edit/create/destroy touching patient
2
- - cache(patient)
3
- - participations = Renalware::Research::StudyParticipant.where(participant_id: patient.id).where("joined_on <= ?", Time.zone.now).where("left_on is null or left_on > ?", Time.zone.now)
4
- = render partial: "renalware/research/alert",
5
- collection: participations,
6
- as: :participation
1
+ - participations = Renalware::Research::StudyParticipant.where(participant_id: patient.id).where("joined_on <= ?", Time.zone.now).where("left_on is null or left_on > ?", Time.zone.now)
2
+ = render partial: "renalware/research/alert",
3
+ collection: participations,
4
+ as: :participation
@@ -1,6 +1,7 @@
1
1
  super_admin:
2
2
  - Renalware::Role
3
3
  - Renalware::Hospitals::Ward
4
+ - Renalware::HD::Dialysate
4
5
  admin:
5
6
  - Renalware::User
6
7
  - Renalware::BagType
data/config/routes.rb CHANGED
@@ -158,6 +158,7 @@ Renalware::Engine.routes.draw do
158
158
 
159
159
  resources :cannulation_types, except: :show
160
160
  resources :dialysers, except: :show
161
+ resources :dialysates, except: :show
161
162
  resource :ongoing_sessions, only: :show
162
163
  resources :mdm_patients, only: :index
163
164
  resources :unmet_preferences, only: :index
@@ -0,0 +1,15 @@
1
+ class AddColumnsToDialysates < ActiveRecord::Migration[5.1]
2
+ def change
3
+ add_column :hd_dialysates, :bicarbonate_content, :decimal, precision: 10, scale: 2
4
+ add_column :hd_dialysates, :bicarbonate_content_uom, :string, default: "mmol/L"
5
+
6
+ add_column :hd_dialysates, :calcium_content, :decimal, precision: 10, scale: 2
7
+ add_column :hd_dialysates, :calcium_content_uom, :string, default: "mmol/L"
8
+
9
+ add_column :hd_dialysates, :glucose_content, :decimal, precision: 10, scale: 2
10
+ add_column :hd_dialysates, :glucose_content_uom, :string, default: "g/L"
11
+
12
+ add_column :hd_dialysates, :potassium_content, :decimal, precision: 10, scale: 2
13
+ add_column :hd_dialysates, :potassium_content_uom, :string, default: "mmol/L"
14
+ end
15
+ end
@@ -0,0 +1,10 @@
1
+ class AddColumnsToHDDialysers < ActiveRecord::Migration[5.1]
2
+ def change
3
+ add_column :hd_dialysers,
4
+ :membrane_surface_area,
5
+ :decimal, precision: 10, scale: 2
6
+ add_column :hd_dialysers,
7
+ :membrane_surface_area_coefficient_k0a,
8
+ :decimal, precision: 10, scale: 2
9
+ end
10
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Renalware
4
- VERSION = "2.0.32"
4
+ VERSION = "2.0.33"
5
5
  end
@@ -4,5 +4,7 @@ FactoryBot.define do
4
4
  factory :hd_dialyser, class: "Renalware::HD::Dialyser" do
5
5
  group "FX"
6
6
  name "FX80"
7
+ membrane_surface_area 234.12
8
+ membrane_surface_area_coefficient_k0a 999.99
7
9
  end
8
10
  end
@@ -10,9 +10,14 @@ FactoryBot.define do
10
10
  code "en"
11
11
  end
12
12
 
13
- trait :aftrikaans do
13
+ trait :afrikaans do
14
14
  name "Afrikaans"
15
15
  code "af"
16
16
  end
17
+
18
+ trait :unknown do
19
+ name "Unknown"
20
+ code "un"
21
+ end
17
22
  end
18
23
  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.32
4
+ version: 2.0.33
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-14 00:00:00.000000000 Z
11
+ date: 2018-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_type
@@ -1080,6 +1080,7 @@ files:
1080
1080
  - app/controllers/renalware/hd/cannulation_types_controller.rb
1081
1081
  - app/controllers/renalware/hd/current_profile_controller.rb
1082
1082
  - app/controllers/renalware/hd/dashboards_controller.rb
1083
+ - app/controllers/renalware/hd/dialysates_controller.rb
1083
1084
  - app/controllers/renalware/hd/dialysers_controller.rb
1084
1085
  - app/controllers/renalware/hd/diaries_controller.rb
1085
1086
  - app/controllers/renalware/hd/diary_slots_controller.rb
@@ -1766,6 +1767,7 @@ files:
1766
1767
  - app/policies/renalware/events/swab_policy.rb
1767
1768
  - app/policies/renalware/feeds/file_policy.rb
1768
1769
  - app/policies/renalware/hd/closed_session_policy.rb
1770
+ - app/policies/renalware/hd/dialysate_policy.rb
1769
1771
  - app/policies/renalware/hd/diary_policy.rb
1770
1772
  - app/policies/renalware/hd/dna_session_policy.rb
1771
1773
  - app/policies/renalware/hd/open_session_policy.rb
@@ -2140,6 +2142,10 @@ files:
2140
2142
  - app/views/renalware/hd/current_profile/show.html.slim
2141
2143
  - app/views/renalware/hd/dashboards/_page_actions.html.slim
2142
2144
  - app/views/renalware/hd/dashboards/show.html.slim
2145
+ - app/views/renalware/hd/dialysates/_form.html.slim
2146
+ - app/views/renalware/hd/dialysates/edit.html.slim
2147
+ - app/views/renalware/hd/dialysates/index.html.slim
2148
+ - app/views/renalware/hd/dialysates/new.html.slim
2143
2149
  - app/views/renalware/hd/dialysers/_form.html.slim
2144
2150
  - app/views/renalware/hd/dialysers/edit.html.slim
2145
2151
  - app/views/renalware/hd/dialysers/index.html.slim
@@ -3264,6 +3270,8 @@ files:
3264
3270
  - db/migrate/20180511171835_create_unique_indexes_on_obr_obr_codes.rb
3265
3271
  - db/migrate/20180514151627_create_system_messages.rb
3266
3272
  - db/migrate/20180516111411_create_view_patient_current_modalities.rb
3273
+ - db/migrate/20180524072633_add_columns_to_dialysates.rb
3274
+ - db/migrate/20180524074320_add_columns_to_hd_dialysers.rb
3267
3275
  - db/migrate/20180605114332_create_pseudo_encrypt_function.rb
3268
3276
  - db/migrate/20180605141806_add_external_id_to_research_study_participants.rb
3269
3277
  - db/migrate/20180605175211_add_application_url_to_research_studies.rb