renalware-core 2.0.39 → 2.0.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -2
- data/app/assets/javascripts/renalware/clockpicker.js +2 -2
- data/app/assets/javascripts/renalware/letters.js +1 -1
- data/app/assets/javascripts/renalware/messaging.js +1 -1
- data/app/assets/javascripts/renalware/patient_ajax_search.js +1 -1
- data/app/assets/javascripts/renalware/pd.js +1 -1
- data/app/assets/javascripts/renalware/primary_care_physician_search.js +1 -2
- data/app/assets/javascripts/renalware/primary_care_physicians.js +1 -1
- data/app/assets/javascripts/renalware/renal.js +1 -1
- data/app/assets/javascripts/renalware/research.js +1 -1
- data/app/assets/javascripts/renalware/select2-ajax-search.js +1 -1
- data/app/assets/stylesheets/renalware/partials/_lists.scss +8 -0
- data/app/assets/stylesheets/renalware/partials/_mdm.scss +11 -20
- data/app/assets/stylesheets/renalware/protocol_pdf.scss +2 -7
- data/app/controllers/renalware/events/events_controller.rb +1 -0
- data/app/controllers/renalware/hd/diary_slots_controller.rb +1 -0
- data/app/controllers/renalware/hd/mdm_patients_controller.rb +19 -5
- data/app/controllers/renalware/letters/letters_controller.rb +1 -0
- data/app/controllers/renalware/mdm_patients_controller.rb +1 -1
- data/app/controllers/renalware/modalities/modalities_controller.rb +1 -0
- data/app/controllers/renalware/virology/profiles_controller.rb +1 -0
- data/app/documents/renalware/hd/profile_document.rb +1 -0
- data/app/documents/renalware/virology/profile_document.rb +1 -0
- data/app/models/renalware/accesses/patient.rb +22 -4
- data/app/models/renalware/clinical/patient.rb +1 -1
- data/app/models/renalware/feeds/file_type.rb +1 -1
- data/app/models/renalware/feeds/files/practices/convert_xml_to_csv.rb +2 -1
- data/app/models/renalware/feeds/files/practices/xml_parser.rb +2 -0
- data/app/models/renalware/hd/mdm_patients_form.rb +34 -0
- data/app/models/renalware/hd/mdm_patients_query.rb +43 -8
- data/app/models/renalware/hd/schedule_definition_filter.rb +15 -0
- data/app/models/renalware/hd/sessions/auditable_session_collection.rb +1 -0
- data/app/models/renalware/letters/author.rb +1 -1
- data/app/models/renalware/letters/description.rb +1 -1
- data/app/models/renalware/letters/part/problems.rb +5 -0
- data/app/models/renalware/letters/patient.rb +2 -2
- data/app/models/renalware/letters/primary_care_physician.rb +1 -1
- data/app/models/renalware/low_clearance/mdm_patients_query.rb +6 -1
- data/app/models/renalware/low_clearance.rb +1 -1
- data/app/models/renalware/medications/medication_route.rb +1 -1
- data/app/models/renalware/messaging/internal/author.rb +1 -1
- data/app/models/renalware/messaging/internal/message.rb +1 -1
- data/app/models/renalware/messaging/internal/recipient.rb +1 -1
- data/app/models/renalware/messaging/patient.rb +1 -1
- data/app/models/renalware/pathology/patient.rb +1 -1
- data/app/models/renalware/patient.rb +1 -0
- data/app/models/renalware/patients/practice.rb +1 -1
- data/app/models/renalware/patients/primary_care_physician.rb +2 -2
- data/app/models/renalware/patients/user.rb +1 -1
- data/app/models/renalware/pd/fluid_description.rb +1 -1
- data/app/models/renalware/pd/organism_code.rb +1 -1
- data/app/models/renalware/pd/patient.rb +1 -1
- data/app/models/renalware/pd/pet_adequacy_result.rb +1 -0
- data/app/models/renalware/transplants/donor_operation.rb +4 -1
- data/app/models/renalware/transplants/patient.rb +18 -4
- data/app/policies/renalware/base_policy.rb +3 -3
- data/app/presenters/renalware/dashboard/dashboard_presenter.rb +2 -1
- data/app/presenters/renalware/hd/diary_slot_presenter.rb +1 -0
- data/app/presenters/renalware/hd/mdm_presenter.rb +0 -11
- data/app/presenters/renalware/hd/patient_presenter.rb +1 -0
- data/app/presenters/renalware/mdm_presenter.rb +18 -0
- data/app/views/renalware/hd/mdm_patients/_filters.html.slim +7 -5
- data/app/views/renalware/hd/mdm_patients/_patient.html.slim +1 -0
- data/app/views/renalware/hd/mdm_patients/_table.html.slim +5 -4
- data/app/views/renalware/hd/mdm_patients/index.html.slim +1 -1
- data/app/views/renalware/hd/protocols/_virology.html.slim +1 -1
- data/app/views/renalware/hd/sessions/_row.html.slim +3 -2
- data/app/views/renalware/letters/letters/_form.html.slim +3 -0
- data/app/views/renalware/letters/letters/_problems_prescriptions.html.slim +22 -0
- data/app/views/renalware/letters/parts/_problems.html.slim +1 -1
- data/app/views/renalware/low_clearance/mdm/_summary.html.slim +9 -0
- data/app/views/renalware/low_clearance/mdm/_top.html.slim +10 -0
- data/app/views/renalware/patients/side_menu/_transplants.html.slim +1 -1
- data/app/views/renalware/transplants/recipient_dashboards/_page_actions.html.slim +3 -3
- data/app/views/renalware/virology/profiles/_summary.html.slim +8 -1
- data/app/views/renalware/virology/profiles/edit.html.slim +1 -0
- data/config/locales/renalware/hd/mdm_patients.yml +1 -0
- data/config/locales/renalware/low_clearance/low_clearance.en.yml +1 -0
- data/config/locales/renalware/virology/virology.en.yml +1 -0
- data/db/migrate/20180725132557_add_days_text_to_hd_schedule_definitions.rb +27 -0
- data/db/migrate/20180725132808_create_hd_schedule_definition_filters_view.rb +5 -0
- data/db/migrate/20180802103013_add_hd_mdm_missing_indexes.rb +8 -0
- data/db/views/hd_schedule_definition_filters_v01.sql +47 -0
- data/lib/renalware/version.rb +1 -1
- data/spec/factories/hd/schedule_definitions.rb +2 -0
- metadata +24 -16
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4c3d9338a0d4d5c869623f1f05fae525bb69315935feaa19bcb144a6816c2bd5
|
|
4
|
+
data.tar.gz: 6b0726dc261af4365e1fc62a01103e98d57c0569276b8269ccf547bdac0ece5b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 169887f515113d57a0af78685994267dc4d64621b2d03fc6d8ea6661f6baf64f567cb147f9b76fa98d13d180450523fc68da58118b984574e3eac8e26b48481b
|
|
7
|
+
data.tar.gz: '0859821f1051c9cf0fe83f73c8e9fb5a691e819a0e1a9068a35a0bdd07d0910f354c007e7fa5fa9f848fe203c8b084f869d0bee8a398522bd11c8e492e2e9353'
|
data/README.md
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
# Renalware
|
|
2
2
|
|
|
3
|
-
[](https://codeclimate.com/github/airslie/renalware-core/maintainability)
|
|
4
4
|
[](https://codeclimate.com/repos/58beee3ed41d600266000147/coverage)
|
|
5
|
-
[](https://gemnasium.com/github.com/airslie/renalware-core)
|
|
6
5
|
[](https://badge.fury.io/rb/renalware-core)
|
|
7
6
|
|
|
8
7
|
Renalware uses demographic, clinical, pathology, and nephrology datasets to improve patient care,
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
supported = (el.firstChild && el.firstChild.namespaceURI) == svgNS;
|
|
25
25
|
el.innerHTML = '';
|
|
26
26
|
return supported;
|
|
27
|
-
}
|
|
27
|
+
}());
|
|
28
28
|
|
|
29
29
|
// Can I use transition ?
|
|
30
30
|
var transitionSupported = (function(){
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
'MozTransition' in style ||
|
|
35
35
|
'msTransition' in style ||
|
|
36
36
|
'OTransition' in style;
|
|
37
|
-
}
|
|
37
|
+
}());
|
|
38
38
|
|
|
39
39
|
// Listen touch events in touch screen device, instead of mouse events in desktop.
|
|
40
40
|
var touchSupported = 'ontouchstart' in window,
|
|
@@ -26,25 +26,16 @@
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
clear: both;
|
|
41
|
-
height: 0;
|
|
42
|
-
opacity: 0;
|
|
43
|
-
|
|
44
|
-
&.expanded {
|
|
45
|
-
height: auto;
|
|
46
|
-
opacity: 1;
|
|
47
|
-
transition: all .3s ease .15s;
|
|
48
|
-
}
|
|
29
|
+
.expandable {
|
|
30
|
+
clear: both;
|
|
31
|
+
height: 0;
|
|
32
|
+
opacity: 0;
|
|
33
|
+
float: left;
|
|
34
|
+
width: 100%;
|
|
35
|
+
|
|
36
|
+
&.expanded {
|
|
37
|
+
height: auto;
|
|
38
|
+
opacity: 1;
|
|
39
|
+
transition: all .2s; // ease .15s;
|
|
49
40
|
}
|
|
50
41
|
}
|
|
@@ -6,11 +6,14 @@ module Renalware
|
|
|
6
6
|
module HD
|
|
7
7
|
class MDMPatientsController < Renalware::MDMPatientsController
|
|
8
8
|
def index
|
|
9
|
+
filter_form = HD::MDMPatientsForm.new(filter_form_params)
|
|
10
|
+
|
|
9
11
|
query = HD::MDMPatientsQuery.new(
|
|
10
|
-
|
|
11
|
-
q: params[:q]
|
|
12
|
+
params: filter_form.ransacked_parameters.merge(query_params).with_indifferent_access
|
|
12
13
|
)
|
|
13
|
-
|
|
14
|
+
|
|
15
|
+
render_index(filter_form: filter_form,
|
|
16
|
+
query: query,
|
|
14
17
|
page_title: t(".page_title"),
|
|
15
18
|
view_proc: ->(patient) { patient_hd_mdm_path(patient) },
|
|
16
19
|
patient_presenter_class: HD::PatientPresenter)
|
|
@@ -18,10 +21,21 @@ module Renalware
|
|
|
18
21
|
|
|
19
22
|
private
|
|
20
23
|
|
|
21
|
-
def
|
|
24
|
+
def filter_form_params
|
|
25
|
+
params.fetch(:filter, {}).permit!
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def query_params
|
|
29
|
+
params.fetch(:q, {}).permit!
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def render_index(filter_form:, **args)
|
|
22
33
|
presenter = build_presenter(params: params, **args)
|
|
23
34
|
authorize presenter.patients
|
|
24
|
-
render
|
|
35
|
+
render(
|
|
36
|
+
:index,
|
|
37
|
+
locals: { presenter: presenter, filter_form: filter_form }
|
|
38
|
+
)
|
|
25
39
|
end
|
|
26
40
|
end
|
|
27
41
|
end
|
|
@@ -23,7 +23,7 @@ module Renalware
|
|
|
23
23
|
query = args.fetch(:query)
|
|
24
24
|
|
|
25
25
|
MDMPatientsPresenter.new(
|
|
26
|
-
patients: query.call.page(page),
|
|
26
|
+
patients: query.call.page(page).per(per_page),
|
|
27
27
|
page_title: args.fetch(:page_title),
|
|
28
28
|
view_proc: args.fetch(:view_proc),
|
|
29
29
|
q: query.search,
|
|
@@ -37,6 +37,7 @@ module Renalware
|
|
|
37
37
|
document.hiv = YearDatedDiagnosis.new(document_params[:hiv])
|
|
38
38
|
document.hepatitis_b = YearDatedDiagnosis.new(document_params[:hepatitis_b])
|
|
39
39
|
document.hepatitis_c = YearDatedDiagnosis.new(document_params[:hepatitis_c])
|
|
40
|
+
document.htlv = YearDatedDiagnosis.new(document_params[:htlv])
|
|
40
41
|
profile.save_by(current_user)
|
|
41
42
|
end
|
|
42
43
|
|
|
@@ -5,10 +5,10 @@ require_dependency "renalware/accesses"
|
|
|
5
5
|
module Renalware
|
|
6
6
|
module Accesses
|
|
7
7
|
class Patient < ActiveType::Record[Renalware::Patient]
|
|
8
|
-
has_many :profiles
|
|
9
|
-
has_many :plans
|
|
10
|
-
has_many :procedures
|
|
11
|
-
has_many :assessments
|
|
8
|
+
has_many :profiles, dependent: :destroy
|
|
9
|
+
has_many :plans, dependent: :destroy
|
|
10
|
+
has_many :procedures, dependent: :destroy
|
|
11
|
+
has_many :assessments, dependent: :destroy
|
|
12
12
|
|
|
13
13
|
def current_profile
|
|
14
14
|
profiles.current.first
|
|
@@ -17,6 +17,24 @@ module Renalware
|
|
|
17
17
|
def current_plan
|
|
18
18
|
plans.current.first
|
|
19
19
|
end
|
|
20
|
+
|
|
21
|
+
scope :with_current_plan, lambda {
|
|
22
|
+
joins(<<-SQL)
|
|
23
|
+
left outer join access_plans on access_plans.patient_id = patients.id
|
|
24
|
+
and access_plans.terminated_at is null
|
|
25
|
+
left outer join access_plan_types
|
|
26
|
+
on access_plans.plan_type_id = access_plan_types.id
|
|
27
|
+
SQL
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
scope :with_profile, lambda {
|
|
31
|
+
joins(<<-SQL)
|
|
32
|
+
left outer join access_profiles on (access_profiles.patient_id = patients.id
|
|
33
|
+
and access_profiles.terminated_on is not null
|
|
34
|
+
and access_profiles.started_on <= current_date)
|
|
35
|
+
left outer join access_types on access_types.id = access_profiles.type_id
|
|
36
|
+
SQL
|
|
37
|
+
}
|
|
20
38
|
end
|
|
21
39
|
end
|
|
22
40
|
end
|
|
@@ -5,7 +5,7 @@ require_dependency "renalware/clinical"
|
|
|
5
5
|
module Renalware
|
|
6
6
|
module Clinical
|
|
7
7
|
class Patient < ActiveType::Record[Renalware::Patient]
|
|
8
|
-
has_many :allergies
|
|
8
|
+
has_many :allergies, dependent: :restrict_with_exception
|
|
9
9
|
|
|
10
10
|
# These statuses match NHS standards for the display of recorded allergy status.
|
|
11
11
|
# Note that
|
|
@@ -144,7 +144,8 @@ module Renalware
|
|
|
144
144
|
|
|
145
145
|
class CountryNotFoundError < StandardError; end
|
|
146
146
|
end
|
|
147
|
-
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
|
147
|
+
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize, Metrics/PerceivedComplexity
|
|
148
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
|
148
149
|
end
|
|
149
150
|
end
|
|
150
151
|
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Renalware
|
|
4
|
+
module HD
|
|
5
|
+
# Form object to help us map chosen input values in the HD MDM patient list filters form
|
|
6
|
+
# into ransack predicates. Used in this instance because mapping the form's
|
|
7
|
+
# schedule_definition_ids dropdown value in the format of e.g "[1, 3, 6]" into the
|
|
8
|
+
# integer arry [1, 3, 6] is not something Ransack can do - hence this intermediate form object
|
|
9
|
+
# to do the mapping.
|
|
10
|
+
class MDMPatientsForm
|
|
11
|
+
include ActiveModel::Model
|
|
12
|
+
include Virtus::Model
|
|
13
|
+
|
|
14
|
+
attribute :hospital_unit_id, Integer
|
|
15
|
+
attribute :schedule_definition_ids, String # an Integer array in string form e.g. "[1 ,2]"
|
|
16
|
+
|
|
17
|
+
# The hash returned here is passed into the Ransack #search method later i the ouery object.
|
|
18
|
+
def ransacked_parameters
|
|
19
|
+
{
|
|
20
|
+
hd_profile_hospital_unit_id_eq: hospital_unit_id,
|
|
21
|
+
hd_profile_schedule_definition_id_in: schedule_definition_ids_array
|
|
22
|
+
}
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
# Convert e.g. "[1,2,3]" to [1,2,3]
|
|
28
|
+
def schedule_definition_ids_array
|
|
29
|
+
return if schedule_definition_ids.blank?
|
|
30
|
+
schedule_definition_ids.scan(/\d+/).map(&:to_i)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# TODO: code here bleeds across modules
|
|
4
|
+
|
|
3
5
|
module Renalware
|
|
4
6
|
module HD
|
|
5
7
|
class MDMPatientsQuery
|
|
@@ -7,27 +9,60 @@ module Renalware
|
|
|
7
9
|
include PatientPathologyScopes
|
|
8
10
|
MODALITY_NAMES = "HD"
|
|
9
11
|
DEFAULT_SEARCH_PREDICATE = "hgb_date desc"
|
|
10
|
-
attr_reader :
|
|
12
|
+
attr_reader :params
|
|
11
13
|
|
|
12
|
-
def initialize(
|
|
13
|
-
@
|
|
14
|
-
@
|
|
15
|
-
@relation = relation
|
|
14
|
+
def initialize(params:)
|
|
15
|
+
@params = params || {}
|
|
16
|
+
@params[:s] = DEFAULT_SEARCH_PREDICATE if @params[:s].blank?
|
|
16
17
|
end
|
|
17
18
|
|
|
18
19
|
def call
|
|
19
20
|
search.result
|
|
20
21
|
end
|
|
21
22
|
|
|
23
|
+
# rubocop:disable Metrics/MethodLength
|
|
22
24
|
def search
|
|
23
25
|
@search ||= begin
|
|
24
|
-
|
|
25
|
-
.
|
|
26
|
+
HD::Patient
|
|
27
|
+
.include(QueryablePatient)
|
|
28
|
+
.merge(Accesses::Patient.with_current_plan)
|
|
29
|
+
.merge(Accesses::Patient.with_profile)
|
|
30
|
+
.merge(Transplants::Patient.with_registration_statuses)
|
|
31
|
+
.eager_load(hd_profile: [:hospital_unit])
|
|
26
32
|
.extending(ModalityScopes)
|
|
27
33
|
.extending(PatientPathologyScopes)
|
|
28
34
|
.with_current_pathology
|
|
29
35
|
.with_current_modality_matching(MODALITY_NAMES)
|
|
30
|
-
.search(
|
|
36
|
+
.search(params)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
# rubocop:enable Metrics/MethodLength
|
|
40
|
+
|
|
41
|
+
# Module to allow us to mixin ransackers
|
|
42
|
+
module QueryablePatient
|
|
43
|
+
extend ActiveSupport::Concern
|
|
44
|
+
included do
|
|
45
|
+
# Using a custom ransacker to be able to order by access plan create_at
|
|
46
|
+
# becuase I believe using an implcit :access_plan_create_at in the sort_link
|
|
47
|
+
# will not work because there is no belongs_to access_plan on HD::Patient
|
|
48
|
+
# and even adding a custom join to access_plans as we do, Ransack will not resolve
|
|
49
|
+
# :access_plans_created_at. Still this seens a reasonable solution.
|
|
50
|
+
# We mix this module into HD::Patient at runtime.
|
|
51
|
+
ransacker :access_plan_date, type: :date do
|
|
52
|
+
Arel.sql("coalesce(access_plans.created_at, '1900-01-01'::timestamp)")
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
ransacker :access_plan_type, type: :string do
|
|
56
|
+
Arel.sql("coalesce(access_plan_types.name, '')")
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
ransacker :current_access, type: :string do
|
|
60
|
+
Arel.sql("access_types.name")
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
ransacker :transplant_registration_status do
|
|
64
|
+
Arel.sql("transplant_registration_status_descriptions.name")
|
|
65
|
+
end
|
|
31
66
|
end
|
|
32
67
|
end
|
|
33
68
|
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_dependency "renalware/hd"
|
|
4
|
+
|
|
5
|
+
module Renalware
|
|
6
|
+
module HD
|
|
7
|
+
# Backed by a Postgres view which defines all the possible permutations of
|
|
8
|
+
# filter that can be selected in a schedule definition filter dropdown, for example
|
|
9
|
+
# days: "Mon Wed Fri", ids: [1,3,4]
|
|
10
|
+
# days: "Mon Wed Fri PM", ids: [3]
|
|
11
|
+
# See also HD::MDMPatientsForm and db/views/hd_schedule_definition_filters_*.sql
|
|
12
|
+
class ScheduleDefinitionFilter < ApplicationRecord
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -10,6 +10,11 @@ module Renalware
|
|
|
10
10
|
super(patient.problems.includes(:notes))
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
+
# If you are wondering why #to_partial_path is not getting called when doing 'render part'
|
|
14
|
+
# in a view, note this object is array-like so Rails' render only looks for #to_partial_path
|
|
15
|
+
# on the array elements, not the top level arrary object. To render a single instance of
|
|
16
|
+
# this part class, wrap it in an array like so:
|
|
17
|
+
# = render [part]
|
|
13
18
|
def to_partial_path
|
|
14
19
|
"renalware/letters/parts/problems"
|
|
15
20
|
end
|
|
@@ -5,8 +5,8 @@ require_dependency "renalware/letters"
|
|
|
5
5
|
module Renalware
|
|
6
6
|
module Letters
|
|
7
7
|
class Patient < ActiveType::Record[Renalware::Patient]
|
|
8
|
-
has_many :letters
|
|
9
|
-
has_many :contacts
|
|
8
|
+
has_many :letters, dependent: :restrict_with_exception
|
|
9
|
+
has_many :contacts, dependent: :restrict_with_exception
|
|
10
10
|
belongs_to :primary_care_physician, class_name: "Renalware::Letters::PrimaryCarePhysician"
|
|
11
11
|
|
|
12
12
|
def cc_on_letter?(letter)
|
|
@@ -5,7 +5,7 @@ require_dependency "renalware/letters"
|
|
|
5
5
|
module Renalware
|
|
6
6
|
module Letters
|
|
7
7
|
class PrimaryCarePhysician < ActiveType::Record[Renalware::Patients::PrimaryCarePhysician]
|
|
8
|
-
has_many :patients
|
|
8
|
+
has_many :patients, dependent: :restrict_with_exception
|
|
9
9
|
has_many :letters, through: :patients
|
|
10
10
|
|
|
11
11
|
def cc_on_letter?(letter)
|
|
@@ -9,7 +9,7 @@ module Renalware
|
|
|
9
9
|
DEFAULT_SEARCH_PREDICATE = "hgb_date DESC"
|
|
10
10
|
attr_reader :query, :relation, :named_filter
|
|
11
11
|
|
|
12
|
-
def initialize(relation: Patient.all, query: nil, named_filter: nil)
|
|
12
|
+
def initialize(relation: LowClearance::Patient.all, query: nil, named_filter: nil)
|
|
13
13
|
@query = query || {}
|
|
14
14
|
@named_filter = named_filter || :none
|
|
15
15
|
@query[:s] = DEFAULT_SEARCH_PREDICATE if @query[:s].blank?
|
|
@@ -39,6 +39,11 @@ module Renalware
|
|
|
39
39
|
self # NOOP
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
+
def supportive_care
|
|
43
|
+
joins(:profile)
|
|
44
|
+
.where("low_clearance_profiles.document ->> 'dialysis_plan' LIKE 'not_for_dial%'")
|
|
45
|
+
end
|
|
46
|
+
|
|
42
47
|
def on_worryboard
|
|
43
48
|
joins("RIGHT OUTER JOIN patient_worries ON patient_worries.patient_id = patients.id")
|
|
44
49
|
end
|
|
@@ -4,7 +4,7 @@ require_dependency "renalware"
|
|
|
4
4
|
|
|
5
5
|
module Renalware
|
|
6
6
|
module LowClearance
|
|
7
|
-
MDM_FILTERS = %w(urea hgb_low hgb_high on_worryboard).freeze
|
|
7
|
+
MDM_FILTERS = %w(urea hgb_low hgb_high on_worryboard supportive_care).freeze
|
|
8
8
|
|
|
9
9
|
def self.table_name_prefix
|
|
10
10
|
"low_clearance_"
|
|
@@ -7,7 +7,7 @@ module Renalware
|
|
|
7
7
|
module Internal
|
|
8
8
|
class Message < Renalware::Messaging::Message
|
|
9
9
|
belongs_to :author, class_name: "Internal::Author"
|
|
10
|
-
has_many :receipts
|
|
10
|
+
has_many :receipts, dependent: :destroy
|
|
11
11
|
has_many :recipients, through: :receipts
|
|
12
12
|
belongs_to :replying_to_message, class_name: name
|
|
13
13
|
scope :ordered, ->{ order(sent_at: :desc) }
|