renalware-core 2.0.75 → 2.0.76

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: 7bd749bf8191908be7e9bc1d15e9f283eb70a5584dc53ebb45c94cda8afd2060
4
- data.tar.gz: 56679014ae649da1baa18755117a23cc5f199542de3e6bb6d922499b444fec8e
3
+ metadata.gz: 644e883f0c733d49ad49139eb2118a2387f3378db8a6fc9eb5b20eaf5dad4db2
4
+ data.tar.gz: 71cd0139f74aa162bbaedb783d6ce450270de74a64b74751cf1873ead4b9829a
5
5
  SHA512:
6
- metadata.gz: c23f24fd2a0694433493e02129fe01c3e13f1ebb785ed78291d08ffac9e6386eaa33f7b1a3f50f8b9a691749ff86ad447bef490bd89043e8891b1c8c39130f32
7
- data.tar.gz: d5e83fd37cfc7bf6b1a573b30d550b69a7fa2ed9c3d89bdd41fba2935d3940d05574ce681982f5eaaf757f905490169fb49939204694082961ffcc63985725f4
6
+ metadata.gz: 6dfe27f438b2f56ecaec02bda8abce84f8015ca5054f05b7e76bf6c405e6a0632f60013287e913b7e03aa0bf0a7f7ad8127742253fdecba60f3ce5277269abf0
7
+ data.tar.gz: a007bf5ef7be7ee91722e27ac434ed7d49e8edf32cc6408dd048b613272f0938c7073dff9990419d201d711ef574433cfe3faac4835b53e78d8265d2f1f9353b
@@ -39,7 +39,6 @@
39
39
  //= require cocoon
40
40
  //= require mousetrap
41
41
  //= require renalware/iframeResizer
42
- //= require chosen-jquery
43
42
  //= require clipboard
44
43
  //= require renalware/masonry.min
45
44
  //= require rails.validations
@@ -53,3 +53,8 @@ Renalware.PdRegimes = (function () {
53
53
  $(document).ready(Renalware.PdRegimes.init);
54
54
  $(document).ready(Renalware.PdRegimes.toggleAddRemoveBags);
55
55
  $(document).on('nested:fieldAdded:bags', Renalware.PdRegimes.toggleAddRemoveBags);
56
+
57
+
58
+ $(document).on('ready ajaxSuccess', function(event, xhr, status) {
59
+ $("#peritonitis_episode_types .searchable_select").select2();
60
+ });
@@ -10,7 +10,6 @@
10
10
  @import "font-awesome";
11
11
  @import "foundation-datepicker";
12
12
  @import "dataTables/jquery.dataTables.foundation";
13
- @import "chosen";
14
13
  @import "trix";
15
14
  @import "renalware/balloon";
16
15
  @import "./lib/foundation_and_overrides";
@@ -30,10 +30,6 @@ textarea.monospace {
30
30
  }
31
31
  }
32
32
 
33
- .chosen-container-multi {
34
- margin-bottom: 0.5rem;
35
- }
36
-
37
33
  // Hide up down arrows on number inputs
38
34
  input[type="number"]::-webkit-inner-spin-button,
39
35
  input[type="number"]::-webkit-outer-spin-button {
@@ -23,6 +23,28 @@ module Renalware
23
23
  def requested_on
24
24
  requested_at.to_date
25
25
  end
26
+
27
+ # Exlucludes duplicate rows; there may be an original OBR and one or more updates (with more
28
+ # complete results) and we only want the last received one got any requestor_order_number
29
+ # (actually for any requestor_order_number + requested_at + description_id) combination
30
+ # because requestor_order_number is sometimes blank
31
+ # rubocop:disable Metrics/MethodLength
32
+ def self.distinct_for_patient_id(patient_id)
33
+ select(
34
+ Arel.sql(
35
+ "DISTINCT ON (patient_id, requestor_order_number, requested_at, description_id) id"
36
+ )
37
+ )
38
+ .where(patient_id: patient_id)
39
+ .order(
40
+ patient_id: :asc,
41
+ requestor_order_number: :asc,
42
+ requested_at: :asc,
43
+ description_id: :asc,
44
+ created_at: :desc
45
+ )
46
+ end
47
+ # rubocop:enable Metrics/MethodLength
26
48
  end
27
49
  end
28
50
  end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_dependency "renalware/ukrdc"
4
+ require "attr_extras"
5
+
6
+ module Renalware
7
+ module UKRDC
8
+ class PathologyObservationRequestsQuery
9
+ pattr_initialize [:patient_id!, :changes_since!]
10
+
11
+ def call
12
+ observation_requests
13
+ end
14
+
15
+ private
16
+
17
+ def observation_requests
18
+ Pathology::ObservationRequest
19
+ .where(id: Pathology::ObservationRequest.distinct_for_patient_id(patient_id))
20
+ .where("requested_at >= ?", changes_since)
21
+ .where("loinc_code is not null")
22
+ .eager_load(
23
+ :description,
24
+ observations: { description: :measurement_unit }
25
+ )
26
+ end
27
+ end
28
+ end
29
+ end
@@ -8,7 +8,21 @@ module Renalware
8
8
  def destroy?
9
9
  return false unless record.persisted?
10
10
 
11
- record.created_at > Renalware.config.new_clinic_visit_deletion_window.ago
11
+ record.created_at > Renalware.config.new_clinic_visit_deletion_window.ago &&
12
+ (user_created_record? || user_is_super_admin?)
13
+ end
14
+
15
+ def edit?
16
+ return false unless record.persisted?
17
+
18
+ record.created_at > Renalware.config.new_clinic_visit_edit_window.ago &&
19
+ (user_created_record? || user_is_super_admin?)
20
+ end
21
+
22
+ private
23
+
24
+ def user_created_record?
25
+ record.created_by_id == user.id
12
26
  end
13
27
  end
14
28
  end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Renalware
4
+ module UKRDC
5
+ class PathologyObservationRequestPresenter < SimpleDelegator
6
+ # Note that we can't just use requestor_order_number as some OBR
7
+ # segments arrive with a blank one. We need put something in the XML
8
+ # that is unique per observation_request, but will still _be_ something
9
+ # when requestor_order is blank
10
+ def placer_id
11
+ [
12
+ requestor_order_number,
13
+ requested_at.strftime("%Y%m%d%H%M%S%L"),
14
+ description_id
15
+ ].reject(&:blank?).join("-")
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_dependency "renalware"
3
+ require_dependency "renalware/ukrdc"
4
4
 
5
5
  # rubocop:disable Metrics/ClassLength
6
6
  module Renalware
@@ -102,41 +102,12 @@ module Renalware
102
102
  __getobj__.prescriptions.current.includes(:termination, :medication_route, :drug)
103
103
  end
104
104
 
105
- # We want to avoid returning duplicate pathology_observation_requests. We might have had
106
- # and update to a pathology_observation_requests, adding a previously missing result,
107
- # and the requestor_order_number is the same, so we have two rows with the same
108
- # patient_id and requestor_order_number. We want to just select that latest one. We'll use
109
- # created_at for this, even though it would be more accurate to look at the timestamp in the
110
- # OBR or MSH segment (these not currently available).
111
- # We use fully qualified column names here to prevent SQL errors when AR compiles the SQL.
112
- def latest_observation_requests
113
- Pathology::ObservationRequest
114
- .select(<<-SELECT)
115
- DISTINCT ON (
116
- pathology_observation_requests.patient_id,
117
- pathology_observation_requests.requestor_order_number,
118
- pathology_observation_requests.requested_at,
119
- pathology_observation_requests.description_id)
120
- *
121
- SELECT
122
- .order(<<-ORDER)
123
- pathology_observation_requests.patient_id ASC,
124
- pathology_observation_requests.requestor_order_number ASC,
125
- pathology_observation_requests.requested_at ASC,
126
- pathology_observation_requests.description_id ASC,
127
- pathology_observation_requests.created_at DESC
128
- ORDER
129
- end
130
-
131
105
  def observation_requests
132
- latest_observation_requests
133
- .where(patient_id: id)
134
- .where("requested_at >= ?", changes_since)
135
- .where("loinc_code is not null")
136
- .eager_load(
137
- :description,
138
- observations: { description: :measurement_unit }
139
- )
106
+ requests = UKRDC::PathologyObservationRequestsQuery.new(
107
+ patient_id: id,
108
+ changes_since: changes_since
109
+ ).call
110
+ CollectionPresenter.new(requests, UKRDC::PathologyObservationRequestPresenter)
140
111
  end
141
112
 
142
113
  private
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ return if visit.public_send(method).blank?
4
+
3
5
  xml = builder
4
6
 
5
7
  i18n_key ||= method
@@ -2,22 +2,6 @@
2
2
 
3
3
  # See HL7 spec http://pacs.hk/Doc/HL7/Hl7V231.pdf
4
4
 
5
- # A Note about PlacerId
6
- # ---------------------
7
- # In UKRDC terms an OBR equates to their LabOrder. Each LabOrder must have a unique
8
- # PlacerId. However an HL7 message (for example at KCH) can have multiple OBRs with the same
9
- # placer id (aka requester order number) thus causing duplicate placer ids to appear in the XML.
10
- # After email discussion with George and Nick at UKRDC it was decided that PlacerID could be
11
- # any value as long as it is unique and is persisted in Renalware (in case an update needs to be
12
- # sent, and the original LabOrder identified). To solve this we obfuscate the request.id (slightly)
13
- # by converting to base 16 (hex) and then append it to the original requester order number.
14
- # Its not good practice to expose a database id in this way though it is to an internal NHS consumer
15
- # and the hex obfuscation helps slightly.
16
- # A better approach might be to generate a GUID for each pathology_observation_request and pass
17
- # this as the placer id. However that would introduce more moving parts (calling the SQL function
18
- # to generate the uuid) and increases storage and XML file sizes.
19
- placer_id = "#{request.requestor_order_number}-#{request.id.to_s(16)}".upcase
20
-
21
5
  xml = builder
22
6
 
23
7
  xml.LabOrder do
@@ -25,7 +9,7 @@ xml.LabOrder do
25
9
  # xml.Code ""
26
10
  # xml.Description # request.pathology_lab.name
27
11
  # end
28
- xml.PlacerId placer_id
12
+ xml.PlacerId request.placer_id
29
13
  # xml.FillerId "??ORC:3 Labs Order Id"
30
14
  # xml.OrderedBy do
31
15
  # xml.Code "unknown"
@@ -1,7 +1,9 @@
1
1
  tr(class="#{'dna' if clinic_visit.did_not_attend?}")
2
2
  td
3
- = link_to "Edit", edit_patient_clinic_visit_path(patient, clinic_visit)
4
- = pipe_separator
3
+ - if policy(clinic_visit).edit?
4
+ = link_to "Edit",
5
+ edit_patient_clinic_visit_path(patient, clinic_visit)
6
+ = pipe_separator
5
7
  = link_to("Toggle",
6
8
  "#clinic_visit-quick-preview-#{clinic_visit.id}",
7
9
  data: { behaviour: "toggler" })
@@ -6,14 +6,17 @@
6
6
  .row
7
7
  .large-12.columns
8
8
  = field_set_tag t(".fieldsets.outcomes") do
9
- = f.input :episode_types,
10
- collection: Renalware::PD::PeritonitisEpisodeTypeDescription.pluck(:term, :id),
11
- include_blank: t("collection.blank_option"),
12
- input_html: { data: { placeholder: t("collection.blank_option_for_multiple") } },
13
- as: :multiple_select,
14
- include_hidden: false,
15
- selected: f.object.episode_types.map(&:peritonitis_episode_type_description_id)
9
+ #peritonitis_episode_types
10
+ = f.input :episode_types,
11
+ collection: Renalware::PD::PeritonitisEpisodeTypeDescription.pluck(:term, :id),
12
+ include_blank: t("collection.blank_option"),
13
+ input_html: { data: { placeholder: t("collection.blank_option_for_multiple") },
14
+ class: "searchable_select",
15
+ multiple: "multiple"},
16
+ include_hidden: false,
17
+ selected: f.object.episode_types.map(&:peritonitis_episode_type_description_id)
16
18
  = f.input :catheter_removed, as: :inline_radio_buttons
19
+
17
20
  .row
18
21
  .large-12.columns
19
22
  = field_set_tag t(".fieldsets.causes") do
@@ -9,7 +9,7 @@ en:
9
9
  diastolic:
10
10
  # code: 76539-6
11
11
  code: bpdia
12
- description: Blood pressure device Cuff pressure.systolic
12
+ description: Blood pressure device Cuff pressure.diastolic
13
13
  units: "mmHg"
14
14
  weight:
15
15
  # code: 3141-9
@@ -20,4 +20,3 @@ en:
20
20
  code: height
21
21
  description: Height Measured
22
22
  units: "m"
23
-
@@ -0,0 +1,11 @@
1
+ class StreamlineDailySummaryReports < ActiveRecord::Migration[5.2]
2
+ def change
3
+ within_renalware_schema do
4
+ update_view(
5
+ :reporting_daily_pathology,
6
+ version: 3,
7
+ revert_to_version: 2
8
+ )
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ -- A pathology report to help identify any HL7/delayed_job issues
2
+ -- the name of the view (the filename here) is significant as we'll compile all reporting_daily_*
3
+ -- views into a daily digest email
4
+ select
5
+ (select count(*) from delayed_jobs) as delayed_jobs_total,
6
+ (select count(*) from delayed_jobs where attempts = 0) as delayed_jobs_unprocessed,
7
+ (select count(*) from delayed_jobs where last_error is not null and failed_at is null ) as delayed_jobs_retrying,
8
+ (select count(*) from delayed_jobs where last_error is not null and failed_at is not null ) as delayed_jobs_failed,
9
+ (select max(created_at) from delayed_jobs) as delayed_jobs_latest_entry,
10
+ (select count(*) from delayed_jobs where created_at >= now()::date) as delayed_jobs_added_today,
11
+ (select json_object_agg(priority, count) from (select priority, count(*) from delayed_jobs group by priority ) query) as delayed_jobs_priority_counts,
12
+ (select json_object_agg(coalesce(queue, 'unset'), count) from (select queue, count(*) from delayed_jobs group by queue ) query) as delayed_jobs_queue_counts,
13
+ (select json_object_agg(attempts, count) from (select attempts, count(*) from delayed_jobs group by attempts ) query) as delayed_jobs_attempts_counts
@@ -25,6 +25,7 @@ module Renalware
25
25
  config_accessor(:hospital_name) { "KINGS COLLEGE HOSPITAL" }
26
26
  config_accessor(:delay_after_which_a_finished_session_becomes_immutable) { 6.hours }
27
27
  config_accessor(:new_clinic_visit_deletion_window) { 24.hours }
28
+ config_accessor(:new_clinic_visit_edit_window) { 7.days }
28
29
  config_accessor(:salutation_prefix) { "Dear" }
29
30
  config_accessor(:page_title_spearator) { " : " }
30
31
  config_accessor(:patient_hospital_identifiers) { {} }
@@ -5,7 +5,6 @@ require "active_type"
5
5
  require "activerecord-import"
6
6
  require "ahoy"
7
7
  require "autoprefixer-rails"
8
- require "chosen-rails"
9
8
  require "simple_form"
10
9
  require "client_side_validations"
11
10
  require "client_side_validations/simple_form"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Renalware
4
- VERSION = "2.0.75"
4
+ VERSION = "2.0.76"
5
5
  end
@@ -19,6 +19,36 @@ module PathologySpecHelper
19
19
  end
20
20
  end
21
21
 
22
+ # rubocop:disable Metrics/ParameterLists, Metrics/MethodLength
23
+ def create_request_with_observations(requestor_order_number: "123",
24
+ obr_code: "OBR1",
25
+ obx_codes: ["OBX1"],
26
+ requested_at: 1.year.ago,
27
+ patient:,
28
+ created_at: nil)
29
+ request_desc = create(:pathology_request_description, code: obr_code)
30
+ create(
31
+ :pathology_observation_request,
32
+ patient: patient,
33
+ requestor_order_number: requestor_order_number,
34
+ requested_at: requested_at,
35
+ description: request_desc,
36
+ created_at: created_at
37
+ ).tap do |request|
38
+ obx_codes.each do |obx_code|
39
+ description = create(:pathology_observation_description, code: obx_code)
40
+ create(
41
+ :pathology_observation,
42
+ request: request,
43
+ description: description,
44
+ observed_at: 1.year.ago,
45
+ result: "1.1"
46
+ )
47
+ end
48
+ end
49
+ end
50
+ # rubocop:enable Metrics/ParameterLists, Metrics/MethodLength
51
+
22
52
  # name and code will be the same
23
53
  def create_observation_description(name)
24
54
  create(:pathology_observation_description, name: name, code: name)
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.75
4
+ version: 2.0.76
5
5
  platform: ruby
6
6
  authors:
7
7
  - Airslie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-11 00:00:00.000000000 Z
11
+ date: 2019-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_type
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 9.4.2
83
- - !ruby/object:Gem::Dependency
84
- name: chosen-rails
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 1.8.3
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: 1.8.3
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: client_side_validations
99
85
  requirement: !ruby/object:Gem::Requirement
@@ -686,16 +672,16 @@ dependencies:
686
672
  name: rails-assets-select2
687
673
  requirement: !ruby/object:Gem::Requirement
688
674
  requirements:
689
- - - "~>"
675
+ - - '='
690
676
  - !ruby/object:Gem::Version
691
- version: 4.0.2
677
+ version: 4.0.5
692
678
  type: :runtime
693
679
  prerelease: false
694
680
  version_requirements: !ruby/object:Gem::Requirement
695
681
  requirements:
696
- - - "~>"
682
+ - - '='
697
683
  - !ruby/object:Gem::Version
698
- version: 4.0.2
684
+ version: 4.0.5
699
685
  - !ruby/object:Gem::Dependency
700
686
  name: ransack
701
687
  requirement: !ruby/object:Gem::Requirement
@@ -989,7 +975,6 @@ files:
989
975
  - app/assets/javascripts/renalware/appointments.js
990
976
  - app/assets/javascripts/renalware/auto_complete.js
991
977
  - app/assets/javascripts/renalware/behaviours.js
992
- - app/assets/javascripts/renalware/chosen.js
993
978
  - app/assets/javascripts/renalware/clipboard_setup.js
994
979
  - app/assets/javascripts/renalware/clockpicker.js
995
980
  - app/assets/javascripts/renalware/contacts.js
@@ -1337,7 +1322,6 @@ files:
1337
1322
  - app/inputs/datetime_picker_input.rb
1338
1323
  - app/inputs/hidden_array_input.rb
1339
1324
  - app/inputs/inline_radio_buttons_input.rb
1340
- - app/inputs/multiple_select_input.rb
1341
1325
  - app/inputs/select_container_input.rb
1342
1326
  - app/inputs/simple_time_input.rb
1343
1327
  - app/inputs/user_picker_input.rb
@@ -1829,6 +1813,7 @@ files:
1829
1813
  - app/models/renalware/ukrdc/create_patient_xml_file.rb
1830
1814
  - app/models/renalware/ukrdc/export_summary.rb
1831
1815
  - app/models/renalware/ukrdc/filename.rb
1816
+ - app/models/renalware/ukrdc/pathology_observation_requests_query.rb
1832
1817
  - app/models/renalware/ukrdc/paths.rb
1833
1818
  - app/models/renalware/ukrdc/patients_query.rb
1834
1819
  - app/models/renalware/ukrdc/transmission_log.rb
@@ -2007,6 +1992,7 @@ files:
2007
1992
  - app/presenters/renalware/transplants/wait_list_registration_presenter.rb
2008
1993
  - app/presenters/renalware/ukrdc/modality_presenter.rb
2009
1994
  - app/presenters/renalware/ukrdc/pathology_observation_presenter.rb
1995
+ - app/presenters/renalware/ukrdc/pathology_observation_request_presenter.rb
2010
1996
  - app/presenters/renalware/ukrdc/patient_presenter.rb
2011
1997
  - app/presenters/string_presenter.rb
2012
1998
  - app/presenters/time_presenter.rb
@@ -3460,6 +3446,7 @@ files:
3460
3446
  - db/migrate/20190225103005_add_info_to_hospital_centres.rb
3461
3447
  - db/migrate/20190315125638_add_timestamps_to_pathology_description_tables.rb
3462
3448
  - db/migrate/20190401105149_create_function_for_hl7_insertion_from_mirth.rb
3449
+ - db/migrate/20190422095620_streamline_daily_summary_reports.rb
3463
3450
  - db/seeds.rb
3464
3451
  - db/seeds/default/accesses/access_pd_catheter_insertion_techniques.csv
3465
3452
  - db/seeds/default/accesses/access_pd_catheter_insertion_techniques.rb
@@ -3564,6 +3551,7 @@ files:
3564
3551
  - db/views/reporting_daily_letters_v02.sql
3565
3552
  - db/views/reporting_daily_pathology_v01.sql
3566
3553
  - db/views/reporting_daily_pathology_v02.sql
3554
+ - db/views/reporting_daily_pathology_v03.sql
3567
3555
  - db/views/reporting_daily_ukrdc_v01.sql
3568
3556
  - db/views/reporting_hd_blood_pressures_audit_v01.sql
3569
3557
  - db/views/reporting_hd_overall_audit_v01.sql
@@ -1,7 +0,0 @@
1
-
2
- $(document).on('ready ajaxSuccess', function(event, xhr, status) {
3
- $('.chosen-select').chosen({
4
- allow_single_deselect: true,
5
- no_results_text: 'No results matched',
6
- width: '400px'})
7
- });
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class MultipleSelectInput < SimpleForm::Inputs::CollectionSelectInput
4
- def input_type
5
- :multiple_select
6
- end
7
-
8
- def input_html_options
9
- options = super
10
- klass = (options[:class] ||= [])
11
- klass << "chosen-select"
12
- options[:multiple] = "multiple"
13
- options
14
- end
15
- end