renalware-core 2.0.0.pre.beta7 → 2.0.0.pre.beta8
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/app/assets/javascripts/renalware/searchables.js +3 -0
- data/app/assets/javascripts/renalware/select2-ajax-search.js +86 -0
- data/app/assets/javascripts/renalware/sortable.js +12 -1
- data/app/assets/stylesheets/renalware/base/_variables.scss +7 -1
- data/app/assets/stylesheets/renalware/modules/_admissions.scss +39 -0
- data/app/assets/stylesheets/renalware/modules/_letters.scss +12 -0
- data/app/assets/stylesheets/renalware/modules/_messaging.scss +0 -4
- data/app/assets/stylesheets/renalware/partials/_animations.scss +12 -0
- data/app/assets/stylesheets/renalware/partials/_modal_window.scss +44 -0
- data/app/assets/stylesheets/renalware/partials/_tables.scss +6 -0
- data/app/controllers/renalware/admissions/requests_controller.rb +100 -0
- data/app/controllers/renalware/devise/passwords_controller.rb +6 -0
- data/app/controllers/renalware/letters/electronic_receipts_controller.rb +81 -0
- data/app/controllers/renalware/letters/letters_controller.rb +18 -3
- data/app/controllers/renalware/messaging/internal/messages_controller.rb +75 -0
- data/app/controllers/renalware/messaging/internal/receipts_controller.rb +74 -0
- data/app/controllers/renalware/patients/patients_controller.rb +11 -1
- data/app/controllers/renalware/session_timeout_controller.rb +1 -1
- data/app/documents/renalware/hd/profile_document.rb +1 -1
- data/app/helpers/renalware/application_helper.rb +5 -0
- data/app/helpers/renalware/xhr_helper.rb +7 -0
- data/app/models/concerns/renalware/deviseable.rb +1 -1
- data/app/models/renalware/admissions.rb +7 -0
- data/app/models/renalware/admissions/request.rb +23 -0
- data/app/models/renalware/admissions/request_reason.rb +11 -0
- data/app/models/renalware/feeds/message_processor.rb +2 -2
- data/app/models/renalware/feeds/persist_message.rb +2 -0
- data/app/models/renalware/hd/sessions/auditable_session.rb +4 -0
- data/app/models/renalware/hd/sessions/auditable_session_collection.rb +5 -0
- data/app/models/renalware/hd/update_rolling_patient_statistics.rb +2 -2
- data/app/models/renalware/letters/electronic_receipt.rb +35 -0
- data/app/models/renalware/letters/electronic_recipient_options.rb +78 -0
- data/app/models/renalware/letters/letter.rb +4 -0
- data/app/models/renalware/letters/letter_factory.rb +21 -1
- data/app/models/renalware/messaging.rb +21 -5
- data/app/models/renalware/messaging/internal/author.rb +11 -0
- data/app/models/renalware/messaging/internal/message.rb +15 -0
- data/app/models/renalware/messaging/internal/message_factory.rb +20 -0
- data/app/models/renalware/messaging/internal/message_form.rb +36 -0
- data/app/models/renalware/messaging/internal/message_form_builder.rb +52 -0
- data/app/models/renalware/messaging/internal/receipt.rb +26 -0
- data/app/models/renalware/messaging/internal/recipient.rb +12 -0
- data/app/models/renalware/messaging/internal/recipient_options.rb +87 -0
- data/app/models/renalware/messaging/internal/send_message.rb +24 -0
- data/app/models/renalware/messaging/message.rb +4 -3
- data/app/models/renalware/pathology.rb +1 -1
- data/app/models/renalware/pathology/message_param_parser.rb +2 -0
- data/app/models/renalware/patients/search_filter.rb +32 -0
- data/app/models/renalware/patients/search_form.rb +17 -0
- data/app/models/renalware/patients/search_query.rb +20 -21
- data/app/models/renalware/patients/summary.rb +1 -1
- data/app/models/renalware/user.rb +18 -2
- data/app/policies/renalware/admissions/request_policy.rb +8 -0
- data/app/policies/renalware/letters/electronic_receipt_policy.rb +23 -0
- data/app/policies/renalware/messaging/{message_policy.rb → internal/message_policy.rb} +2 -3
- data/app/policies/renalware/messaging/internal/receipt_policy.rb +25 -0
- data/app/presenters/renalware/dashboard/dashboard_presenter.rb +9 -2
- data/app/presenters/renalware/hd/station_presenter.rb +0 -1
- data/app/presenters/renalware/letters/electronic_receipt_presenter.rb +15 -0
- data/app/presenters/renalware/letters/letter_presenter.rb +5 -0
- data/app/presenters/renalware/mdm_presenter.rb +2 -0
- data/app/presenters/renalware/messaging/internal/message_presenter.rb +21 -0
- data/app/presenters/renalware/messaging/internal/receipt_presenter.rb +13 -0
- data/app/presenters/renalware/pathology/observation_presenter.rb +4 -0
- data/app/presenters/renalware/ukrdc/patient_presenter.rb +5 -0
- data/app/views/renalware/admissions/requests/_create_request_link.html.slim +10 -0
- data/app/views/renalware/admissions/requests/_form.html.slim +31 -0
- data/app/views/renalware/admissions/requests/_modal_dialog_placeholder.html.slim +2 -0
- data/app/views/renalware/admissions/requests/_request.html.slim +34 -0
- data/app/views/renalware/admissions/requests/_table.html.slim +19 -0
- data/app/views/renalware/admissions/requests/create.js.erb +3 -0
- data/app/views/renalware/admissions/requests/destroy.js.erb +3 -0
- data/app/views/renalware/admissions/requests/edit.html.slim +4 -0
- data/app/views/renalware/admissions/requests/edit.js.erb +4 -0
- data/app/views/renalware/admissions/requests/index.html.slim +3 -0
- data/app/views/renalware/admissions/requests/new.html.slim +4 -0
- data/app/views/renalware/admissions/requests/new.js.erb +4 -0
- data/app/views/renalware/admissions/requests/update.js.erb +9 -0
- data/app/views/renalware/api/ukrdc/patients/_allergies.xml.builder +1 -1
- data/app/views/renalware/api/ukrdc/patients/_clinical_relationships.xml.builder +0 -1
- data/app/views/renalware/api/ukrdc/patients/_lab_orders.xml.builder +7 -2
- data/app/views/renalware/api/ukrdc/patients/_observations.xml.builder +1 -1
- data/app/views/renalware/api/ukrdc/patients/_patient.xml.builder +2 -0
- data/app/views/renalware/api/ukrdc/patients/_sending_facility.xml.builder +1 -1
- data/app/views/renalware/api/ukrdc/patients/lab_orders/_lab_order.xml.builder +46 -0
- data/app/views/renalware/api/ukrdc/patients/lab_orders/_result_item.xml.builder +14 -0
- data/app/views/renalware/clinical/allergies/_mini.html.slim +1 -0
- data/app/views/renalware/dashboard/dashboards/_content.html.slim +6 -2
- data/app/views/renalware/dashboard/letters/_letter.html.slim +7 -7
- data/app/views/renalware/dashboard/letters/_table.html.slim +2 -2
- data/app/views/renalware/devise/passwords/edit.html.erb +27 -0
- data/app/views/renalware/devise/passwords/new.html.erb +18 -0
- data/app/views/renalware/devise/registrations/new.html.slim +25 -0
- data/app/views/renalware/letters/electronic_receipts/_table.html.slim +45 -0
- data/app/views/renalware/letters/electronic_receipts/mark_as_read.js.erb +6 -0
- data/app/views/renalware/letters/electronic_receipts/read.html.slim +5 -0
- data/app/views/renalware/letters/electronic_receipts/sent.html.slim +40 -0
- data/app/views/renalware/letters/electronic_receipts/unread.html.slim +5 -0
- data/app/views/renalware/letters/formatted_letters/_letter.html.slim +12 -1
- data/app/views/renalware/letters/letters/_actions.html.slim +1 -1
- data/app/views/renalware/letters/letters/_electronic_ccs.html.slim +16 -0
- data/app/views/renalware/letters/letters/_form.html.slim +8 -3
- data/app/views/renalware/letters/letters/edit.html.slim +7 -1
- data/app/views/renalware/letters/letters/new.html.slim +6 -1
- data/app/views/renalware/letters/shared/_electronic_cc_type_tabs.html.slim +7 -0
- data/app/views/renalware/messaging/{messages → internal/messages}/_form.html.slim +2 -1
- data/app/views/renalware/messaging/{messages → internal/messages}/_modal_dialog_placeholder.html.slim +0 -0
- data/app/views/renalware/messaging/{messages → internal/messages}/_send_message_link.html.slim +1 -1
- data/app/views/renalware/messaging/{messages → internal/messages}/_send_reply_link.html.slim +3 -3
- data/app/views/renalware/messaging/{messages → internal/messages}/create.js.erb +0 -0
- data/app/views/renalware/messaging/{messages → internal/messages}/new.html.slim +0 -0
- data/app/views/renalware/messaging/{messages → internal/messages}/new.js.erb +0 -0
- data/app/views/renalware/messaging/{receipts → internal/receipts}/_receipt.html.slim +2 -2
- data/app/views/renalware/messaging/{messages/_message.html.slim → internal/receipts/_sent_receipt.html.slim} +2 -1
- data/app/views/renalware/messaging/internal/receipts/_sent_table.html.slim +12 -0
- data/app/views/renalware/messaging/{receipts → internal/receipts}/_table.html.slim +2 -2
- data/app/views/renalware/messaging/{receipts → internal/receipts}/mark_as_read.js.erb +0 -0
- data/app/views/renalware/messaging/{receipts → internal/receipts}/read.html.slim +2 -1
- data/app/views/renalware/messaging/internal/receipts/sent.html.slim +7 -0
- data/app/views/renalware/messaging/{receipts → internal/receipts}/unread.html.slim +2 -1
- data/app/views/renalware/messaging/shared/_messages_type_tabs.html.slim +3 -3
- data/app/views/renalware/navigation/_main.html.slim +1 -1
- data/app/views/renalware/navigation/_patients_admin.html.slim +2 -0
- data/app/views/renalware/navigation/_user.html.slim +2 -1
- data/app/views/renalware/patients/_search_form.html.slim +12 -0
- data/app/views/renalware/patients/side_menu/_actions.html.slim +6 -2
- data/app/views/renalware/renal/profiles/_form.html.slim +0 -1
- data/app/views/renalware/renal/profiles/_mini.html.slim +1 -0
- data/app/views/renalware/{snippets/snippets → shared}/_modal_close_link.html.slim +0 -0
- data/app/views/renalware/snippets/snippets/_list.html.slim +1 -1
- data/app/views/renalware/transplants/donations/_form.html.slim +17 -16
- data/config/initializers/simple_form_foundation.rb +0 -1
- data/config/locales/renalware/admissions/requests.en.yml +12 -0
- data/config/locales/renalware/letters/contact.en.yml +3 -0
- data/config/locales/renalware/messaging/internal/messages.en.yml +33 -0
- data/config/locales/renalware/patients/search_form.en.yml +5 -0
- data/config/locales/renalware/patients/side_menu.en.yml +1 -0
- data/config/routes.rb +32 -10
- data/db/migrate/20170908155011_add_shortfall_column_to_hd_patient_statistics.rb +7 -0
- data/db/migrate/20170908160250_update_hd_overall_audit_to_version4.rb +8 -0
- data/db/migrate/20170911133224_add_type_to_messaging_messages.rb +16 -0
- data/db/migrate/20170912092135_create_letters_electronic_receipts.rb +11 -0
- data/db/migrate/20170920113628_create_admissions_requests.rb +31 -0
- data/db/seeds/default/reporting/audits.yml +1 -0
- data/db/views/reporting_hd_overall_audit_v04.sql +13 -0
- data/lib/renalware/version.rb +1 -1
- data/lib/subscription_registry.rb +1 -1
- data/spec/factories/accesses/plans.rb +2 -3
- data/spec/factories/accesses/profiles.rb +1 -2
- data/spec/factories/admissions/request_reasons.rb +8 -0
- data/spec/factories/admissions/requests.rb +9 -0
- data/spec/factories/clinical/body_compositions.rb +2 -5
- data/spec/factories/clinical/dry_weights.rb +2 -3
- data/spec/factories/clinics/clinic_visits.rb +2 -3
- data/spec/factories/directory/people.rb +1 -2
- data/spec/factories/events/events.rb +1 -2
- data/spec/factories/hd/preference_sets.rb +1 -2
- data/spec/factories/hd/profiles.rb +2 -3
- data/spec/factories/hd/sessions.rb +4 -3
- data/spec/factories/letters/electronic_receipts.rb +6 -0
- data/spec/factories/letters/letters.rb +3 -3
- data/spec/factories/medications/prescription.rb +1 -2
- data/spec/factories/medications/prescription_terminations.rb +1 -2
- data/spec/factories/messaging/internal/authors.rb +5 -0
- data/spec/factories/messaging/{message.rb → internal/messages.rb} +1 -1
- data/spec/factories/messaging/internal/receipts.rb +7 -0
- data/spec/factories/messaging/internal/recipients.rb +5 -0
- data/spec/factories/modalities/modalities.rb +1 -3
- data/spec/factories/pathology/requests/request.rb +1 -3
- data/spec/factories/patients/alerts.rb +1 -2
- data/spec/factories/patients/patients.rb +5 -3
- data/spec/factories/pd/assessments.rb +1 -2
- data/spec/factories/pd/fluid_descriptions.rb +0 -1
- data/spec/factories/pd/training_sessions.rb +1 -2
- data/spec/factories/problems/problems.rb +1 -2
- data/spec/factories/shared/accountable.rb +35 -0
- data/spec/factories/system/roles.rb +2 -4
- data/spec/factories/system/users.rb +30 -15
- data/spec/factories/transplants/donor_stage.rb +1 -2
- data/spec/factories/transplants/registration_statuses.rb +2 -4
- data/spec/support/login_macros.rb +1 -1
- metadata +108 -40
- data/app/controllers/renalware/messaging/messages_controller.rb +0 -73
- data/app/controllers/renalware/messaging/receipts_controller.rb +0 -55
- data/app/controllers/renalware/messaging/sent_messages_controller.rb +0 -22
- data/app/models/renalware/messaging/author.rb +0 -9
- data/app/models/renalware/messaging/message_factory.rb +0 -18
- data/app/models/renalware/messaging/message_form.rb +0 -34
- data/app/models/renalware/messaging/message_form_builder.rb +0 -50
- data/app/models/renalware/messaging/receipt.rb +0 -19
- data/app/models/renalware/messaging/recipient.rb +0 -10
- data/app/models/renalware/messaging/recipient_options.rb +0 -85
- data/app/models/renalware/messaging/send_message.rb +0 -22
- data/app/policies/renalware/messaging/receipt_policy.rb +0 -19
- data/app/presenters/renalware/messaging/internal_message_presenter.rb +0 -19
- data/app/presenters/renalware/messaging/receipt_presenter.rb +0 -11
- data/app/views/renalware/devise/registrations/new.html.erb +0 -46
- data/app/views/renalware/messaging/messages/_table.html.slim +0 -13
- data/app/views/renalware/messaging/messages/sent.html.slim +0 -4
- data/config/locales/renalware/messaging/messages.en.yml +0 -29
- data/spec/factories/messaging/authors.rb +0 -5
- data/spec/factories/messaging/receipt.rb +0 -7
- data/spec/factories/messaging/recipients.rb +0 -5
|
@@ -131,8 +131,12 @@ module Renalware
|
|
|
131
131
|
contacts = find_contacts
|
|
132
132
|
contact = build_contact
|
|
133
133
|
render action, locals: {
|
|
134
|
-
patient: @patient,
|
|
135
|
-
|
|
134
|
+
patient: @patient,
|
|
135
|
+
letter: letter,
|
|
136
|
+
contact: contact,
|
|
137
|
+
contacts: contacts,
|
|
138
|
+
contact_descriptions: find_contact_descriptions,
|
|
139
|
+
electronic_recipient_options: electronic_recipient_options
|
|
136
140
|
}
|
|
137
141
|
end
|
|
138
142
|
|
|
@@ -153,6 +157,10 @@ module Renalware
|
|
|
153
157
|
Contact.new.tap(&:build_person)
|
|
154
158
|
end
|
|
155
159
|
|
|
160
|
+
def electronic_recipient_options
|
|
161
|
+
ElectronicRecipientOptions.new(patient, current_user)
|
|
162
|
+
end
|
|
163
|
+
|
|
156
164
|
def event_class
|
|
157
165
|
@event_class ||= event_type.singularize.classify.constantize
|
|
158
166
|
end
|
|
@@ -178,7 +186,8 @@ module Renalware
|
|
|
178
186
|
:letterhead_id, :author_id, :description, :issued_on, :enclosures,
|
|
179
187
|
:salutation, :body, :notes,
|
|
180
188
|
main_recipient_attributes: main_recipient_attributes,
|
|
181
|
-
cc_recipients_attributes: cc_recipients_attributes
|
|
189
|
+
cc_recipients_attributes: cc_recipients_attributes,
|
|
190
|
+
electronic_cc_recipient_ids: []
|
|
182
191
|
]
|
|
183
192
|
end
|
|
184
193
|
|
|
@@ -194,6 +203,12 @@ module Renalware
|
|
|
194
203
|
]
|
|
195
204
|
end
|
|
196
205
|
|
|
206
|
+
# def electronic_receipts_attributes
|
|
207
|
+
# [
|
|
208
|
+
# :recipient_id
|
|
209
|
+
# ]
|
|
210
|
+
# end
|
|
211
|
+
|
|
197
212
|
def address_attributes
|
|
198
213
|
[
|
|
199
214
|
:id, :name, :organisation_name, :street_1, :street_2, :street_3, :town, :county,
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
require_dependency "renalware/messaging"
|
|
2
|
+
|
|
3
|
+
module Renalware
|
|
4
|
+
module Messaging
|
|
5
|
+
module Internal
|
|
6
|
+
class MessagesController < BaseController
|
|
7
|
+
include Renalware::Concerns::Pageable
|
|
8
|
+
include PresenterHelper
|
|
9
|
+
|
|
10
|
+
def sent
|
|
11
|
+
messages = author.messages.page(page).per(per_page)
|
|
12
|
+
authorize messages
|
|
13
|
+
render locals: { messages: present(messages, MessagePresenter) }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def new
|
|
17
|
+
authorize Message, :new?
|
|
18
|
+
form = MessageFormBuilder.new(patient: patient, params: params).call
|
|
19
|
+
render_new(form)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def create
|
|
23
|
+
authorize Message, :create?
|
|
24
|
+
form = MessageForm.new(message_params)
|
|
25
|
+
|
|
26
|
+
if form.valid?
|
|
27
|
+
message = SendMessage.call(author: author, patient: patient, form: form)
|
|
28
|
+
flash.now[:notice] = "Message was successfully sent"
|
|
29
|
+
render_create(message)
|
|
30
|
+
else
|
|
31
|
+
render_new(form)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
private
|
|
36
|
+
|
|
37
|
+
def message_we_are_replying_to(message)
|
|
38
|
+
return if message.replying_to_message_id.blank?
|
|
39
|
+
MessagePresenter.new(message.replying_to_message)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def render_new(form)
|
|
43
|
+
render :new,
|
|
44
|
+
locals: {
|
|
45
|
+
form: form,
|
|
46
|
+
recipient_options: RecipientOptions.new(patient, author).to_a,
|
|
47
|
+
patient: patient
|
|
48
|
+
},
|
|
49
|
+
layout: false
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def render_create(message)
|
|
53
|
+
render locals: {
|
|
54
|
+
message: MessagePresenter.new(message),
|
|
55
|
+
original_message: message_we_are_replying_to(message)
|
|
56
|
+
}
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def author
|
|
60
|
+
Messaging::Internal.cast_author(current_user)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def patient
|
|
64
|
+
Messaging.cast_patient(Patient.find(params[:patient_id]))
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def message_params
|
|
68
|
+
params
|
|
69
|
+
.require(:internal_message)
|
|
70
|
+
.permit(:subject, :body, :urgent, :replying_to_message_id, recipient_ids: [])
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
require_dependency "renalware/messaging"
|
|
2
|
+
|
|
3
|
+
# A Receipt is cross reference between Message and Recipient.
|
|
4
|
+
# We can for instance mark on a receipt if/when it was read or viewed.
|
|
5
|
+
module Renalware
|
|
6
|
+
module Messaging
|
|
7
|
+
module Internal
|
|
8
|
+
class ReceiptsController < BaseController
|
|
9
|
+
include Renalware::Concerns::Pageable
|
|
10
|
+
include PresenterHelper
|
|
11
|
+
|
|
12
|
+
# GET aka inbox
|
|
13
|
+
def unread
|
|
14
|
+
render_receipts(receipts.unread)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# GET all read messages
|
|
18
|
+
def read
|
|
19
|
+
render_receipts(receipts.read)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def sent
|
|
23
|
+
render_receipts(sent_receipts)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# PATCH
|
|
27
|
+
def mark_as_read
|
|
28
|
+
authorize receipt
|
|
29
|
+
receipt.update(read_at: Time.zone.now)
|
|
30
|
+
render locals: {
|
|
31
|
+
receipt: ReceiptPresenter.new(receipt)
|
|
32
|
+
}
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
private
|
|
36
|
+
|
|
37
|
+
def render_receipts(receipts)
|
|
38
|
+
patient_filter = Patients::SearchFilter.new(search_term, request)
|
|
39
|
+
receipts = receipts.joins(message: [:patient])
|
|
40
|
+
receipts = patient_filter.call(receipts).ordered.page(page).per(per_page)
|
|
41
|
+
authorize receipts
|
|
42
|
+
|
|
43
|
+
render locals: {
|
|
44
|
+
receipts: present(receipts, ReceiptPresenter),
|
|
45
|
+
search_form: patient_filter.search_form
|
|
46
|
+
}
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def receipts
|
|
50
|
+
@receipts ||= recipient.receipts.page(page).per(per_page)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def receipt
|
|
54
|
+
@receipt ||= recipient.receipts.find_by!(
|
|
55
|
+
message_id: params[:message_id],
|
|
56
|
+
id: params[:id]
|
|
57
|
+
)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def recipient
|
|
61
|
+
Messaging::Internal.cast_recipient(current_user)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def search_term
|
|
65
|
+
params.fetch(:patient_search, {}).fetch(:term, nil)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def sent_receipts
|
|
69
|
+
Receipt.sent_by(current_user.id)
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -17,7 +17,8 @@ module Renalware
|
|
|
17
17
|
def search
|
|
18
18
|
skip_authorization
|
|
19
19
|
query = Patients::SearchQuery.new(term: params[:term])
|
|
20
|
-
|
|
20
|
+
patients = query.call.page(page).per(per_page)
|
|
21
|
+
render json: simplify(patients).to_json
|
|
21
22
|
end
|
|
22
23
|
|
|
23
24
|
def new
|
|
@@ -65,6 +66,15 @@ module Renalware
|
|
|
65
66
|
|
|
66
67
|
private
|
|
67
68
|
|
|
69
|
+
def simplify(patients)
|
|
70
|
+
patients.map do |patient|
|
|
71
|
+
{
|
|
72
|
+
id: patient.id,
|
|
73
|
+
text: patient.to_s(:long)
|
|
74
|
+
}
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
68
78
|
def patient_params
|
|
69
79
|
params
|
|
70
80
|
.require(:patient)
|
|
@@ -52,7 +52,7 @@ module Renalware
|
|
|
52
52
|
def referrer_is_a_devise_url?
|
|
53
53
|
referrer = request.referer
|
|
54
54
|
return if request.blank?
|
|
55
|
-
regex_defining_devise_paths =
|
|
55
|
+
regex_defining_devise_paths = %r{(#{new_user_session_path}|users\/password|users\/sign_up)}
|
|
56
56
|
URI.parse(referrer).path =~ regex_defining_devise_paths
|
|
57
57
|
end
|
|
58
58
|
end
|
|
@@ -4,6 +4,11 @@ require "breadcrumb"
|
|
|
4
4
|
|
|
5
5
|
module Renalware
|
|
6
6
|
module ApplicationHelper
|
|
7
|
+
include Renalware::Engine.routes.url_helpers
|
|
8
|
+
|
|
9
|
+
def default_patient_link(patient)
|
|
10
|
+
link_to(patient, patient_clinical_summary_path(patient))
|
|
11
|
+
end
|
|
7
12
|
|
|
8
13
|
def patient_search
|
|
9
14
|
::Renalware::Patients::PatientSearch.call(params)
|
|
@@ -7,5 +7,12 @@ module Renalware
|
|
|
7
7
|
$("#{el}").html("#{escape_javascript(render(partial, locals))}");
|
|
8
8
|
EOS
|
|
9
9
|
end
|
|
10
|
+
|
|
11
|
+
def replace(el, partial:, locals:)
|
|
12
|
+
<<-EOS.squish.html_safe
|
|
13
|
+
$("#{el}").replaceWith("#{escape_javascript(render(partial, locals))}");
|
|
14
|
+
$("#{el}").addClass("post-action-highlight");
|
|
15
|
+
EOS
|
|
16
|
+
end
|
|
10
17
|
end
|
|
11
18
|
end
|
|
@@ -10,7 +10,7 @@ module Renalware
|
|
|
10
10
|
included do
|
|
11
11
|
class_eval do
|
|
12
12
|
devise(:expirable, :database_authenticatable, :registerable,
|
|
13
|
-
:rememberable, :trackable, :validatable, :timeoutable)
|
|
13
|
+
:rememberable, :trackable, :validatable, :timeoutable, :recoverable)
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
# Makes the User 'approvable'
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require_dependency "renalware/admissions"
|
|
2
|
+
|
|
3
|
+
module Renalware
|
|
4
|
+
module Admissions
|
|
5
|
+
class Request < ApplicationRecord
|
|
6
|
+
include Accountable
|
|
7
|
+
extend Enumerize
|
|
8
|
+
|
|
9
|
+
acts_as_paranoid
|
|
10
|
+
|
|
11
|
+
belongs_to :patient
|
|
12
|
+
belongs_to :reason, class_name: "RequestReason"
|
|
13
|
+
|
|
14
|
+
validates :patient_id, presence: true, uniqueness: true
|
|
15
|
+
validates :reason_id, presence: true
|
|
16
|
+
validates :priority, presence: true
|
|
17
|
+
|
|
18
|
+
enumerize :priority, in: %i(low medium high urgent)
|
|
19
|
+
|
|
20
|
+
scope :ordered, ->{ order(position: :asc) }
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -2,8 +2,8 @@ require_dependency "renalware/feeds"
|
|
|
2
2
|
|
|
3
3
|
module Renalware
|
|
4
4
|
module Feeds
|
|
5
|
-
#
|
|
6
|
-
# HL7 message.
|
|
5
|
+
#
|
|
6
|
+
# Responsible for coordinating the processing sequences of a raw HL7 message.
|
|
7
7
|
#
|
|
8
8
|
class MessageProcessor
|
|
9
9
|
include Wisper::Publisher
|
|
@@ -44,6 +44,10 @@ module Renalware
|
|
|
44
44
|
(dialysis_minutes_shortfall.to_f / prescribed_time.to_f) * 100.0
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
+
def dialysis_minutes_shortfall_gt_5_pct?
|
|
48
|
+
dialysis_minutes_shortfall_percentage > 5.0
|
|
49
|
+
end
|
|
50
|
+
|
|
47
51
|
def weight_loss
|
|
48
52
|
document.observations_before.weight.to_f - document.observations_after.weight.to_f
|
|
49
53
|
end
|
|
@@ -33,6 +33,7 @@ module Renalware
|
|
|
33
33
|
mean_blood_flow
|
|
34
34
|
mean_litres_processed
|
|
35
35
|
mean_ufr
|
|
36
|
+
number_of_sessions_with_dialysis_minutes_shortfall_gt_5_pct
|
|
36
37
|
).freeze
|
|
37
38
|
|
|
38
39
|
def to_h
|
|
@@ -86,6 +87,10 @@ module Renalware
|
|
|
86
87
|
MeanValueStrategy.new(sessions: closed_sessions, selector: selector).call.round(2)
|
|
87
88
|
end
|
|
88
89
|
|
|
90
|
+
def number_of_sessions_with_dialysis_minutes_shortfall_gt_5_pct
|
|
91
|
+
sessions.count(&:dialysis_minutes_shortfall_gt_5_pct?)
|
|
92
|
+
end
|
|
93
|
+
|
|
89
94
|
def mean_ufr
|
|
90
95
|
selector = ->(session) { session.ufr }
|
|
91
96
|
MeanValueStrategy.new(sessions: closed_sessions, selector: selector).call
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module Renalware
|
|
2
2
|
module HD
|
|
3
|
-
class UpdateRollingPatientStatistics <
|
|
3
|
+
class UpdateRollingPatientStatistics < ApplicationJob
|
|
4
4
|
|
|
5
5
|
def initialize(patient:)
|
|
6
6
|
@patient = patient
|
|
@@ -24,7 +24,7 @@ module Renalware
|
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def auditable_sessions
|
|
27
|
-
@auditable_sessions ||= Sessions::
|
|
27
|
+
@auditable_sessions ||= Sessions::AuditableSessionCollection.new(recent_sessions)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
def rolling_stats_for_this_patient
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require_dependency "renalware/letters"
|
|
2
|
+
|
|
3
|
+
# Represents an Electronic CC - a reference to a letter sent to a recipient (another user on the
|
|
4
|
+
# system) as a 'CC'. We use the concept of a 'receipt' which, while mainly being a cross table
|
|
5
|
+
# between letter and recipient user, is also a well-named place to store related information
|
|
6
|
+
# for example whether the message has been read (e.g. the letter viewed).
|
|
7
|
+
module Renalware
|
|
8
|
+
module Letters
|
|
9
|
+
class ElectronicReceipt < ApplicationRecord
|
|
10
|
+
belongs_to :letter
|
|
11
|
+
belongs_to :recipient, class_name: "Renalware::User"
|
|
12
|
+
validates :letter, presence: true
|
|
13
|
+
validates :recipient_id, presence: true
|
|
14
|
+
|
|
15
|
+
# Merge scope here to make sure we only get approved letters
|
|
16
|
+
scope :sent_by, lambda{ |user_id|
|
|
17
|
+
joins(:letter)
|
|
18
|
+
.merge(Letter::Approved.all)
|
|
19
|
+
.where(letter_letters: { author_id: user_id })
|
|
20
|
+
}
|
|
21
|
+
scope :unread, -> { where(read_at: nil).joins(:letter).merge(Letter::Approved.all) }
|
|
22
|
+
scope :read, -> { where.not(read_at: nil).joins(:letter).merge(Letter::Approved.all) }
|
|
23
|
+
scope :for_recipient, ->(user_id) { where(recipient_id: user_id) }
|
|
24
|
+
scope :ordered, -> { order(created_at: :desc) }
|
|
25
|
+
|
|
26
|
+
def read?
|
|
27
|
+
read_at.present?
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def unread?
|
|
31
|
+
!read?
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
require_dependency "renalware/letters"
|
|
2
|
+
|
|
3
|
+
module Renalware
|
|
4
|
+
module Letters
|
|
5
|
+
class ElectronicRecipientOptions
|
|
6
|
+
attr_reader :patient, :author
|
|
7
|
+
|
|
8
|
+
class Group
|
|
9
|
+
include Virtus.model
|
|
10
|
+
attribute :name, String
|
|
11
|
+
attribute :users, Array, default: []
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def initialize(patient, author)
|
|
15
|
+
@patient = patient
|
|
16
|
+
@author = author
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def to_a
|
|
20
|
+
[
|
|
21
|
+
users_having_previously_received_been_cced_about_this_patient,
|
|
22
|
+
users_having_recently_been_cced_by_author,
|
|
23
|
+
all_other_users
|
|
24
|
+
]
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
private
|
|
28
|
+
|
|
29
|
+
def users_having_previously_received_been_cced_about_this_patient
|
|
30
|
+
Group.new(
|
|
31
|
+
name: "Previous CC recipients",
|
|
32
|
+
users: User.where(
|
|
33
|
+
id: ids_of_users_having_previously_received_been_cced_about_this_patient
|
|
34
|
+
)
|
|
35
|
+
)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def users_having_recently_been_cced_by_author
|
|
39
|
+
Group.new(
|
|
40
|
+
name: "Other recent recipients",
|
|
41
|
+
users: User.where(id: ids_of_users_having_recently_been_cced_by_author)
|
|
42
|
+
)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def all_other_users
|
|
46
|
+
ids_to_exclude = ids_of_users_having_previously_received_been_cced_about_this_patient +
|
|
47
|
+
ids_of_users_having_recently_been_cced_by_author
|
|
48
|
+
Group.new(
|
|
49
|
+
name: "All other user",
|
|
50
|
+
users: User.where.not(id: ids_to_exclude)
|
|
51
|
+
)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def ids_of_users_having_previously_received_been_cced_about_this_patient
|
|
55
|
+
@ids_of_users_having_previously_received_been_cced_about_this_patient ||= begin
|
|
56
|
+
Letter
|
|
57
|
+
.includes(:electronic_receipts)
|
|
58
|
+
.eager_load(:electronic_receipts)
|
|
59
|
+
.where(patient: patient)
|
|
60
|
+
.limit(20)
|
|
61
|
+
.pluck(:recipient_id)
|
|
62
|
+
.flatten.uniq.compact
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def ids_of_users_having_recently_been_cced_by_author
|
|
67
|
+
@ids_of_users_having_recently_been_cced_by_author ||= begin
|
|
68
|
+
ids = Letter
|
|
69
|
+
.includes(:electronic_receipts).eager_load(:electronic_receipts)
|
|
70
|
+
.where(author: author)
|
|
71
|
+
.limit(20)
|
|
72
|
+
.pluck(:recipient_id).uniq.compact
|
|
73
|
+
ids - ids_of_users_having_previously_received_been_cced_about_this_patient
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|