renalware-core 2.0.106 → 2.0.108

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: efb794ae27f5828ca612778342c373a1c21523c321b8d128fc375b599c73e6f5
4
- data.tar.gz: 193b964ca2a0d8dddbe61fdf32ca7dec8a30b13d775d4f711e84f1d348adb0c5
3
+ metadata.gz: 5ddbc1bf89e7d3c6d32c617656f612b98929fab1110a56a48e52d53cc74251c0
4
+ data.tar.gz: a63750e0fc7606ae785449cef68320c84ceedebd983a4ca568341cea7bdf511b
5
5
  SHA512:
6
- metadata.gz: 7897419fac1a376460c4f7e696ca853686845ba2a4c3918928dfc85964c1a3e2bede291f6db07fa7a3fef179e335fe9b0df62d8cf353278fb18a23d84b89d3fc
7
- data.tar.gz: 61043d951f2a2c2194679f0ac9682ee7cb22181ebe3bbc8f51e01f2832facaaef79b8632ef34df056aa7db6c37d2ed4bc3fb2e39af17de9352ae4dbe8353ff9f
6
+ metadata.gz: 96ada68134d8d5a5fd76092e38a562ab0c3efdee4c6f7b3d2fc3eac00ef9ea2c7a51f97c43bed32c4647cb39da9e2b3243150f00001575a004d49d44f28310cd
7
+ data.tar.gz: 5539d4f554e53988a5de121af668fbaf7ae06fc709cf1c88aa3dac31a6e301238813b670dc2c255d2aa8d28079923f531facd3d459842ee12dc9c3a0debe2d14
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Renalware
4
4
  class BloodGroup < NestedAttribute
5
- attribute :group, Document::Enum, enums: %i(A B O AB)
5
+ attribute :group, Document::Enum
6
6
  attribute :rhesus, Document::Enum, enums: %i(positive negative)
7
7
 
8
8
  def to_s
@@ -47,7 +47,7 @@ module Renalware
47
47
  attribute :dialysis, Dialysis
48
48
 
49
49
  class Anticoagulant < Document::Embedded
50
- attribute :type, Document::Enum, enums: %i(heparin enoxyparin warfarin none)
50
+ attribute :type, Document::Enum # See .yml file for values
51
51
  attribute :loading_dose
52
52
  attribute :hourly_dose
53
53
  attribute :stop_time
@@ -28,6 +28,7 @@ module Renalware
28
28
 
29
29
  def validate_administrator_and_witness?
30
30
  return false if skip_validation || not_administered?
31
+ return false unless Renalware.config.hd_session_prescriptions_require_signoff
31
32
 
32
33
  true
33
34
  end
@@ -13,7 +13,9 @@ module Renalware
13
13
  # Each modality_description has a :code fiekd
14
14
  def self.call(modality)
15
15
  type = modality.description.code&.to_s&.camelize
16
- (klass_for(type) || klass_for(DEFAULT_TYPE)).new(modality)
16
+ klass = (klass_for(type) || klass_for(DEFAULT_TYPE)).new(modality)
17
+ Rails.logger.info "GeneratorFactory type = #{type} class = #{klass}"
18
+ klass
17
19
  end
18
20
 
19
21
  def self.klass_for(type)
@@ -80,7 +80,7 @@ module Renalware
80
80
  # - change of site
81
81
  # - change of hd_type to from hd and (hdf_pre || hdf_post)
82
82
  # - change of hd prescription
83
- # Loop through the hd_profiles and trigger an new treatment when these change
83
+ # Loop through the hd_profiles and trigger a new treatment when any of these change
84
84
  # There is a problem here as we are creating duplicate treatments
85
85
  # I think we need to first find the hd profile that is associated with the hd modality
86
86
  # and that becomes the 'last_profile' here
@@ -0,0 +1,113 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_dependency "renalware/ukrdc"
4
+ require "attr_extras"
5
+
6
+ # QBL TXT Description
7
+ # "20" "20" "Transplant ; Cadaver donor"
8
+ # "21" "21" "Transplant ; Live related - sibling"
9
+ # "74" "74" "Transplant ; Live related - father"
10
+ # "75" "75" "Transplant ; Live related - mother"
11
+ # "77" "77" "Transplant ; Live related - child"
12
+ # "23" "23" "Transplant ; Live related - other"
13
+ # "24" "24" "Transplant ; Live genetically unrelated"
14
+ # "25" "25" "Transplant ; Cadaver donor + transp other organ"
15
+ # "26" "26" "Transplant ; Live donor + transplant other organ"
16
+ # "27" "27" "Transplant ; Live donor non-UK transplant"
17
+ # "28" "28" "Transplant ; non-heart-beating donor"
18
+ # "29" "29" "Transplant ; type unknown"
19
+ module Renalware
20
+ module UKRDC
21
+ module TreatmentTimeline
22
+ module Transplant
23
+ class Generator
24
+ pattr_initialize :modality
25
+ delegate :patient, to: :modality
26
+
27
+ UKRR_TXT = {
28
+ cadaver: 20,
29
+ unknown: 29,
30
+ live_related_other: 23,
31
+ live_related_sibling: 21,
32
+ live_related_father: 74,
33
+ live_related_mother: 75,
34
+ live_related_child: 77,
35
+ non_heart_beating: 28,
36
+ live_unrelated: 24
37
+ }.freeze
38
+
39
+ # We need to create a treatment record to match the UKRDC code expectations
40
+ # based on donor relationship.
41
+ # Otherwise Default to 29 Transplant ; type unknown
42
+ def call
43
+ create_treatment
44
+ end
45
+
46
+ private
47
+
48
+ def create_treatment
49
+ operation
50
+ Treatment.create!(
51
+ patient: modality.patient,
52
+ clinician: modality.created_by,
53
+ started_on: modality.started_on,
54
+ modality_id: modality.id,
55
+ modality_description_id: modality.description_id,
56
+ ended_on: modality.ended_on,
57
+ modality_code: ukrr_modality_code
58
+ )
59
+ end
60
+
61
+ def unknown_transplant_ukrr_modality_code
62
+ ukrr_modality_code_for_txt(UKRR_TXT[:unknown])
63
+ end
64
+
65
+ def ukrr_modality_code
66
+ return unknown_transplant_ukrr_modality_code if operation.nil?
67
+ return unknown_transplant_ukrr_modality_code if donor_type.nil?
68
+
69
+ if donor_type == :live_related
70
+ ukrr_modality_code_for_live_donor_relationship
71
+ else
72
+ ukrr_modality_code_for_txt(UKRR_TXT[donor_type])
73
+ end
74
+ end
75
+
76
+ def donor_type
77
+ operation.document.donor.type&.to_sym
78
+ end
79
+
80
+ def donor_relationship
81
+ operation.document.donor.relationship&.to_sym
82
+ end
83
+
84
+ # rubocop:disable Style/StringLiterals
85
+ def ukrr_modality_code_for_live_donor_relationship
86
+ key = :"live_related_#{donor_relationship || 'other'}"
87
+ ukrr_modality_code_for_txt(UKRR_TXT.fetch(key))
88
+ end
89
+ # rubocop:enable Style/StringLiterals
90
+
91
+ def ukrr_modality_code_for_txt(txt_code)
92
+ UKRDC::ModalityCode.find_by(txt_code: txt_code)
93
+ end
94
+
95
+ # Try and select an operation within the start and end dates of the modality
96
+ def operation
97
+ @operation ||= begin
98
+ Renalware::Transplants::RecipientOperation
99
+ .for_patient(patient)
100
+ .where(
101
+ "performed_on >= ? and performed_on <= ?",
102
+ modality.started_on,
103
+ modality.ended_on || Time.zone.today
104
+ )
105
+ .order(performed_on: :desc)
106
+ .first
107
+ end
108
+ end
109
+ end
110
+ end
111
+ end
112
+ end
113
+ end
@@ -62,11 +62,16 @@ module Renalware
62
62
  )
63
63
  end
64
64
 
65
+ # Use DISTINCT ON (performed_on) and an order(performed_on: :desc) to make sure we only
66
+ # get one hd session per day - the last of the day. This is becuase currrently RW allows
67
+ # a duplicate session to be added, and this occasionally happens.
65
68
  def finished_hd_sessions
66
69
  hd_patient
67
70
  .finished_hd_sessions
68
71
  .includes(:patient, :dialysate, :updated_by)
72
+ .select("distinct on (hd_sessions.performed_on) *")
69
73
  .where("hd_sessions.updated_at > ?", changes_since)
74
+ .order(performed_on: :desc)
70
75
  end
71
76
 
72
77
  def current_registration_status_rr_code
@@ -1,23 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- return if visit.public_send(method).blank?
3
+ measurement = visit.public_send(method)
4
4
 
5
- xml = builder
5
+ if measurement.present? && measurement.to_f.nonzero?
6
+ xml = builder
7
+ i18n_key ||= method
6
8
 
7
- i18n_key ||= method
8
- xml.Observation do
9
- xml.ObservationTime visit.datetime
9
+ xml.Observation do
10
+ xml.ObservationTime visit.datetime
10
11
 
11
- xml.ObservationCode do
12
- xml.CodingStandard "UKRR"
13
- xml.Code I18n.t("loinc.#{i18n_key}.code")
14
- xml.Description I18n.t("loinc.#{i18n_key}.description")
15
- end
12
+ xml.ObservationCode do
13
+ xml.CodingStandard "UKRR"
14
+ xml.Code I18n.t("loinc.#{i18n_key}.code")
15
+ xml.Description I18n.t("loinc.#{i18n_key}.description")
16
+ end
16
17
 
17
- xml.ObservationValue visit.public_send(method)
18
- xml.ObservationUnits I18n.t("loinc.#{i18n_key}.units")
18
+ xml.ObservationValue measurement
19
+ xml.ObservationUnits I18n.t("loinc.#{i18n_key}.units")
19
20
 
20
- xml.Clinician do
21
- xml.Description visit.updated_by&.to_s
21
+ xml.Clinician do
22
+ xml.Description visit.updated_by&.to_s
23
+ end
22
24
  end
23
25
  end
@@ -18,17 +18,19 @@ observation_times = {
18
18
  }
19
19
 
20
20
  measurements.each do |i18n_key, value|
21
- xml.Observation do
22
- xml.ObservationTime observation_times[pre_post].iso8601
23
- xml.ObservationCode do
24
- xml.CodingStandard "UKRR"
25
- xml.Code I18n.t("loinc.#{i18n_key}.code")
26
- xml.Description I18n.t("loinc.#{i18n_key}.description")
27
- end
21
+ if value.present? && value.to_f.nonzero?
22
+ xml.Observation do
23
+ xml.ObservationTime observation_times[pre_post].iso8601
24
+ xml.ObservationCode do
25
+ xml.CodingStandard "UKRR"
26
+ xml.Code I18n.t("loinc.#{i18n_key}.code")
27
+ xml.Description I18n.t("loinc.#{i18n_key}.description")
28
+ end
28
29
 
29
- xml.ObservationValue value
30
- xml.ObservationUnits I18n.t("loinc.#{i18n_key}.units")
31
- xml.PrePost pre_post.to_s.upcase # eg PRE or POST
30
+ xml.ObservationValue value
31
+ xml.ObservationUnits I18n.t("loinc.#{i18n_key}.units")
32
+ xml.PrePost pre_post.to_s.upcase # eg PRE or POST
33
+ end
32
34
  end
33
35
  end
34
36
  end
@@ -18,8 +18,7 @@
18
18
  when false then "not-administered"
19
19
  else "undecided"
20
20
  end
21
- # administration_klass = "not-administered" unless administration.administered?
22
- #- administration_klass = "undecided" if administration.administered.nil?
21
+
23
22
  .hd-drug-administration(
24
23
  data-token-count="#{'2' if administration.administrator_authorised? && administration.witness_authorised?}"
25
24
  class="#{administration_klass}"
@@ -51,34 +50,35 @@
51
50
  = fpa.label :reason_id
52
51
  = fpa.association :reason, wrapper: :zilch
53
52
 
54
- .authentication(
55
- class="#{'disabled-with-faded-overlay' unless administration.administered?}"
56
- data-authentication-url=renalware.hd_prescription_administration_authorisations_path
57
- )
58
- / Output username and password fields for administrator and witness
59
- - { administrator: :administered, witness: :witnessed }.each do |user_role, prefix|
53
+ - if Renalware.config.hd_session_prescriptions_require_signoff
54
+ .authentication(
55
+ class="#{'disabled-with-faded-overlay' unless administration.administered?}"
56
+ data-authentication-url=renalware.hd_prescription_administration_authorisations_path
57
+ )
58
+ / Output username and password fields for administrator and witness
59
+ - { administrator: :administered, witness: :witnessed }.each do |user_role, prefix|
60
60
 
61
- - authorised = administration.public_send(:"#{user_role}_authorised?")
62
- - token_symbol = :"#{user_role}_authorisation_token"
63
- .user-and-password(
64
- class="user-and-password--#{user_role} #{'authorised' if authorised} #{'error' if fpa.object.errors[token_symbol].any?}"
65
- )
66
- = fpa.hidden_field token_symbol, class: "authentication-token"
67
- = fpa.label :"#{prefix}_by"
68
- = fpa.association :"#{prefix}_by",
69
- as: :user_picker,
70
- collection: Renalware::User.ordered,
71
- wrapper: :zilch,
72
- label: false,
73
- input_html: { class: "authentication-user-id" }
61
+ - authorised = administration.public_send(:"#{user_role}_authorised?")
62
+ - token_symbol = :"#{user_role}_authorisation_token"
63
+ .user-and-password(
64
+ class="user-and-password--#{user_role} #{'authorised' if authorised} #{'error' if fpa.object.errors[token_symbol].any?}"
65
+ )
66
+ = fpa.hidden_field token_symbol, class: "authentication-token"
67
+ = fpa.label :"#{prefix}_by"
68
+ = fpa.association :"#{prefix}_by",
69
+ as: :user_picker,
70
+ collection: Renalware::User.ordered,
71
+ wrapper: :zilch,
72
+ label: false,
73
+ input_html: { class: "authentication-user-id" }
74
74
 
75
- / Password is only visible as long as the user has not been authenticated
76
- = password_field_tag :"#{prefix}_by_password",
77
- "",
78
- placeholder: "Password",
79
- class: "user-password",
80
- autocomplete: :off
81
- small.error.invalid-password Invalid password
82
- .confirmed
83
- i.fas.fa-check-circle
84
- = link_to "Clear", "#", class: "user-and-password--clear"
75
+ / Password is only visible as long as the user has not been authenticated
76
+ = password_field_tag :"#{prefix}_by_password",
77
+ "",
78
+ placeholder: "Password",
79
+ class: "user-password",
80
+ autocomplete: :off
81
+ small.error.invalid-password Invalid password
82
+ .confirmed
83
+ i.fas.fa-check-circle
84
+ = link_to "Clear", "#", class: "user-and-password--clear"
@@ -21,7 +21,7 @@
21
21
  = sort_link_if(treatable.sortable?, search, :prescribed_on, "Prescribed on")
22
22
  th Prescribed By
23
23
  - unless current_scope
24
- th Terminated On
24
+ th.col-width-date Terminated On
25
25
  th Terminated By
26
26
  tbody
27
27
  - prescriptions.each do |prescription|
@@ -51,6 +51,14 @@ en:
51
51
  hdf_pre: HDF-PRE
52
52
  hdf_post: HDF-POST
53
53
 
54
+ renalware/hd/profile_document/anticoagulant:
55
+ # The host app should implement this I18n key to specify available coagulants.
56
+ # See e.g. dummy/config/locales for anticoagulant types
57
+ # We always specify a Non option because enumerize complains if the key is not
58
+ # a non-empty array.
59
+ type:
60
+ none: None
61
+
54
62
  renalware/hd/profile_document/transport:
55
63
  type:
56
64
  ambulance_wheelchair: Ambulance (wheelchair)
@@ -83,6 +83,8 @@ module Renalware
83
83
  # of the PDF so we can examine its content
84
84
  config_accessor(:render_pdf_as_html_for_debugging) { false }
85
85
 
86
+ config_accessor(:hd_session_prescriptions_require_signoff) { true }
87
+
86
88
  # A host app can override this to add/remove/re-order the clinical summary display
87
89
  # Note these have to be strings - they mapped to constants in ClinicalSummaryPresenter.
88
90
  config_accessor(:page_layouts) {
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Renalware
4
- VERSION = "2.0.106"
4
+ VERSION = "2.0.108"
5
5
  end
@@ -43,5 +43,59 @@ FactoryBot.define do
43
43
  txt_code { 111 }
44
44
  qbl_code { 111 }
45
45
  end
46
+
47
+ trait :type_unknown do
48
+ description { "Transplant ; type unknown" }
49
+ txt_code { 29 }
50
+ qbl_code { 29 }
51
+ end
52
+
53
+ trait :cadaver do
54
+ description { "Transplant ; Cadaver donor" }
55
+ txt_code { 20 }
56
+ qbl_code { 20 }
57
+ end
58
+
59
+ trait :live_related_sibling do
60
+ description { "Transplant ; Transplant; Live related - sibling" }
61
+ txt_code { 21 }
62
+ qbl_code { 21 }
63
+ end
64
+
65
+ trait :live_related_father do
66
+ description { "Transplant ; Transplant; Live related - father" }
67
+ txt_code { 74 }
68
+ qbl_code { 74 }
69
+ end
70
+
71
+ trait :live_related_mother do
72
+ description { "Transplant ; Transplant; Live related - mother" }
73
+ txt_code { 75 }
74
+ qbl_code { 75 }
75
+ end
76
+
77
+ trait :live_related_child do
78
+ description { "Transplant ; Transplant; Live related - child" }
79
+ txt_code { 77 }
80
+ qbl_code { 77 }
81
+ end
82
+
83
+ trait :live_related_other do
84
+ description { "Transplant ; Transplant; Live related - other" }
85
+ txt_code { 23 }
86
+ qbl_code { 23 }
87
+ end
88
+
89
+ trait :non_heart_beating do
90
+ description { "Transplant ; non-heart-beating donor" }
91
+ txt_code { 28 }
92
+ qbl_code { 28 }
93
+ end
94
+
95
+ trait :live_unrelated do
96
+ description { "Transplant ; Live genetically unrelated" }
97
+ txt_code { 24 }
98
+ qbl_code { 24 }
99
+ end
46
100
  end
47
101
  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.106
4
+ version: 2.0.108
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-10 00:00:00.000000000 Z
11
+ date: 2019-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_type
@@ -198,14 +198,14 @@ dependencies:
198
198
  requirements:
199
199
  - - "~>"
200
200
  - !ruby/object:Gem::Version
201
- version: 4.6.0
201
+ version: 4.7.1
202
202
  type: :runtime
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - "~>"
207
207
  - !ruby/object:Gem::Version
208
- version: 4.6.0
208
+ version: 4.7.1
209
209
  - !ruby/object:Gem::Dependency
210
210
  name: devise-security
211
211
  requirement: !ruby/object:Gem::Requirement
@@ -660,14 +660,14 @@ dependencies:
660
660
  requirements:
661
661
  - - '='
662
662
  - !ruby/object:Gem::Version
663
- version: 2.22.2
663
+ version: 2.24.0
664
664
  type: :runtime
665
665
  prerelease: false
666
666
  version_requirements: !ruby/object:Gem::Requirement
667
667
  requirements:
668
668
  - - '='
669
669
  - !ruby/object:Gem::Version
670
- version: 2.22.2
670
+ version: 2.24.0
671
671
  - !ruby/object:Gem::Dependency
672
672
  name: rails-assets-mousetrap
673
673
  requirement: !ruby/object:Gem::Requirement
@@ -1864,7 +1864,7 @@ files:
1864
1864
  - app/models/renalware/ukrdc/treatment_timeline/prepare_tables.rb
1865
1865
  - app/models/renalware/ukrdc/treatment_timeline/remap_model_table_names_to_their_prepared_equivalents.rb
1866
1866
  - app/models/renalware/ukrdc/treatment_timeline/transfer_out/generator.rb
1867
- - app/models/renalware/ukrdc/treatment_timeline/transplant/generator.rb.wip
1867
+ - app/models/renalware/ukrdc/treatment_timeline/transplant/generator.rb
1868
1868
  - app/models/renalware/ukrdc/xml_renderer.rb
1869
1869
  - app/models/renalware/user.rb
1870
1870
  - app/models/renalware/version.rb
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_dependency "renalware/ukrdc"
4
- require "attr_extras"
5
-
6
- # QBL TXT Description
7
- # "20" "20" "Transplant ; Cadaver donor"
8
- # "21" "21" "Transplant ; Live related - sibling"
9
- # "74" "74" "Transplant ; Live related - father"
10
- # "75" "75" "Transplant ; Live related - mother"
11
- # "77" "77" "Transplant ; Live related - child"
12
- # "23" "23" "Transplant ; Live related - other"
13
- # "24" "24" "Transplant ; Live genetically unrelated"
14
- # "25" "25" "Transplant ; Cadaver donor + transp other organ"
15
- # "26" "26" "Transplant ; Live donor + transplant other organ"
16
- # "27" "27" "Transplant ; Live donor non-UK transplant"
17
- # "28" "28" "Transplant ; non-heart-beating donor"
18
- # "29" "29" "Transplant ; type unknown"
19
- module Renalware
20
- module UKRDC
21
- module TreatmentTimeline
22
- module Transplant
23
- class Generator
24
- pattr_initialize :modality
25
- delegate :patient, to: :modality
26
-
27
- # We need to create a treatment record to match the UKRDC code expectations
28
- # based on donor relationship.
29
- # Otherwise Default to 29 Transplant ; type unknown
30
- def call
31
-
32
- end
33
- end
34
- end
35
- end
36
- end
37
- end