renalware-core 2.0.0.pre.beta8 → 2.0.0.pre.beta9
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 +19 -1
- data/app/assets/stylesheets/renalware/lib/_select2-foundation5-overrides.scss +2 -2
- data/app/controllers/renalware/directory/people_controller.rb +1 -1
- data/app/controllers/renalware/letters/contacts_controller.rb +1 -1
- data/app/controllers/renalware/letters/letters_controller.rb +1 -1
- data/app/controllers/renalware/patients/patients_controller.rb +3 -5
- data/app/controllers/renalware/patients/primary_care_physicians_controller.rb +1 -1
- data/app/controllers/renalware/renal/aki_alerts_controller.rb +44 -0
- data/app/controllers/renalware/renal/profiles_controller.rb +1 -1
- data/app/controllers/renalware/reporting/audits_controller.rb +9 -3
- data/app/documents/renalware/patient_document.rb +0 -13
- data/app/jobs/hl7_message_example.yml +1 -1
- data/app/jobs/renalware/reporting/refresh_audit_data_job.rb +7 -3
- data/app/models/renalware/clinical/create_allergy.rb +4 -2
- data/app/models/renalware/clinics/create_clinic_visit.rb +6 -2
- data/app/models/renalware/hd/session.rb +12 -0
- data/app/models/renalware/hospitals/unit.rb +4 -0
- data/app/models/renalware/hospitals/ward.rb +22 -0
- data/app/models/renalware/modalities/change_patient_modality.rb +4 -2
- data/app/models/renalware/patient.rb +1 -0
- data/app/models/renalware/patients/language.rb +1 -0
- data/app/models/renalware/pd/create_regime.rb +4 -2
- data/app/models/renalware/pd/revise_regime.rb +5 -3
- data/app/models/renalware/renal/aki_alert.rb +15 -0
- data/app/models/renalware/renal/aki_alert_action.rb +10 -0
- data/app/models/renalware/reporting/audit.rb +2 -3
- data/app/models/renalware/reporting/generate_audit_json.rb +21 -5
- data/app/models/renalware/system/country.rb +21 -0
- data/app/models/renalware/transplants/create_donor_stage.rb +4 -2
- data/app/policies/renalware/base_policy.rb +4 -0
- data/app/policies/renalware/renal/aki_alert_policy.rb +9 -0
- data/app/presenters/renalware/hd/patient_presenter.rb +5 -0
- data/app/presenters/renalware/reporting/audit_presenter.rb +1 -0
- data/app/presenters/renalware/transplants/patient_presenter.rb +2 -1
- data/app/presenters/renalware/ukrdc/patient_presenter.rb +27 -0
- data/app/values/renalware/address.rb +2 -13
- data/app/views/renalware/addresses/_form.html.slim +4 -2
- data/app/views/renalware/api/ukrdc/patients/_address.xml.builder +2 -2
- data/app/views/renalware/api/ukrdc/patients/_diagnoses.xml.builder +5 -2
- data/app/views/renalware/api/ukrdc/patients/_encounters.xml.builder +8 -1
- data/app/views/renalware/api/ukrdc/patients/_medications.xml.builder +30 -0
- data/app/views/renalware/api/ukrdc/patients/_patient.xml.builder +36 -4
- data/app/views/renalware/api/ukrdc/patients/_sending_facility.xml.builder +1 -0
- data/app/views/renalware/api/ukrdc/patients/diagnoses/_cause_of_death.xml.builder +10 -0
- data/app/views/renalware/api/ukrdc/patients/encounters/_hd_session.xml.builder +40 -0
- data/app/views/renalware/api/ukrdc/patients/show.xml.builder +1 -0
- data/app/views/renalware/directory/people/_address_form.html.slim +1 -1
- data/app/views/renalware/hd/sessions/_form.html.slim +43 -33
- data/app/views/renalware/letters/contacts/_person_form.html.slim +1 -1
- data/app/views/renalware/navigation/_renal.html.slim +1 -0
- data/app/views/renalware/patients/patients/_form.html.slim +5 -2
- data/app/views/renalware/patients/patients/show.html.slim +0 -5
- data/app/views/renalware/patients/patients/show/_patient_demographics.html.slim +3 -3
- data/app/views/renalware/patients/side_menu/_actions.html.slim +3 -0
- data/app/views/renalware/renal/aki_alerts/_filters.html.slim +0 -0
- data/app/views/renalware/renal/aki_alerts/edit.html.slim +17 -0
- data/app/views/renalware/renal/aki_alerts/index.html.slim +28 -0
- data/app/views/renalware/reporting/audits/edit.html.slim +1 -1
- data/app/views/renalware/reporting/audits/index.html.slim +11 -7
- data/app/views/renalware/reporting/audits/show.html.slim +2 -17
- data/app/views/renalware/shared/documents/_blood_pressure_input.html.slim +6 -7
- data/config/initializers/inflections.rb +3 -2
- data/config/locales/renalware/navigation/renal.en.yml +1 -0
- data/config/locales/renalware/renal/aki_alerts.en.yml +5 -0
- data/config/locales/renalware/renal/{profile.yml → profile.en.yml} +0 -0
- data/config/locales/renalware/reporting/audit.en.yml +1 -1
- data/config/routes.rb +1 -0
- data/db/migrate/20150312113937_create_drug_types_drugs.rb +2 -2
- data/db/migrate/20170925161033_add_code_to_patient_langauges.rb +6 -0
- data/db/migrate/20170925182738_add_rr_code_to_medication_routes.rb +5 -0
- data/db/migrate/20170926081426_create_countries.rb +14 -0
- data/db/migrate/20170926132845_add_country_of_birth_to_patients.rb +6 -0
- data/db/migrate/20171002175804_add_rr_columns_to_transplant_registration_status_descriptions.rb +12 -0
- data/db/migrate/20171003093347_create_hospital_wards.rb +17 -0
- data/db/migrate/20171003111228_create_aki_alert_actions.rb +10 -0
- data/db/migrate/20171003122425_create_renal_aki_alerts.rb +22 -0
- data/db/migrate/20171005081224_create_reporting_bone_audit.rb +5 -0
- data/db/migrate/20171005091202_reporting_audit_changes.rb +7 -0
- data/db/migrate/20171005130109_create_medication_current_prescriptions.rb +5 -0
- data/db/migrate/20171005144505_create_reporting_anaemia_audit.rb +5 -0
- data/db/migrate/20171009104106_add_legacy_patient_id_to_patients.rb +6 -0
- data/db/seeds/default/events/{event_types_required.csv → event_types.csv} +0 -0
- data/db/seeds/default/events/{event_types_required.rb → event_types.rb} +2 -2
- data/db/seeds/default/events/seeds.rb +1 -2
- data/db/seeds/default/medications/medication_routes.rb +23 -13
- data/db/seeds/default/patients/patients_languages.csv +192 -102
- data/db/seeds/default/patients/patients_languages.rb +1 -1
- data/db/seeds/default/patients/patients_religions.csv +2 -0
- data/db/seeds/default/reporting/audits.rb +4 -3
- data/db/seeds/default/reporting/audits.yml +47 -4
- data/db/seeds/default/system/countries.csv +250 -0
- data/db/seeds/default/system/countries.rb +12 -0
- data/db/seeds/default/system/seeds.rb +1 -0
- data/db/seeds/default/transplants/transplant_registration_statuses.rb +30 -19
- data/db/views/medication_current_prescriptions_v01.sql +28 -0
- data/db/views/reporting_anaemia_audit_v01.sql +41 -0
- data/db/views/reporting_bone_audit_v01.sql +32 -0
- data/lib/renalware/version.rb +1 -1
- data/spec/factories/deaths/cause.rb +1 -1
- data/spec/factories/drugs/drug.rb +6 -0
- data/spec/factories/drugs/drug_types.rb +5 -0
- data/spec/factories/hospitals/wards.rb +9 -0
- data/spec/factories/modalities/modality_descriptions.rb +10 -8
- data/spec/factories/patients/ethnicities.rb +3 -0
- data/spec/factories/patients/languages.rb +12 -1
- data/spec/factories/renal/aki_alert_actions.rb +5 -0
- data/spec/factories/renal/aki_alerts.rb +9 -0
- data/spec/factories/reporting/audits.rb +1 -1
- data/spec/factories/system/addresses.rb +1 -1
- data/spec/factories/system/countries.rb +15 -0
- metadata +42 -13
- data/app/values/renalware/country.rb +0 -19
- data/config/countries.csv +0 -250
- data/db/migrate/20170706120643_create_reporting_data_sources.rb +0 -5
- data/db/seeds/default/events/event_types_blt.csv +0 -109
- data/db/seeds/default/events/event_types_local.rb +0 -10
- data/db/views/reporting_data_sources_v01.sql +0 -17
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 68224d6d74aa9596a06dcdf9d162cc14db3789d2
|
|
4
|
+
data.tar.gz: 4f9a68e60dbeb49050d5df09941a4b2837f4afda
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 153b54410198ca57909984a6d8b084e9d6d87e6572624a9c2d513b584e9d28e836246a99c175a984c28af4c429a15247433fa862eac1751a8b1fce56336ef781
|
|
7
|
+
data.tar.gz: 60c84ffe3ce4f7e70bdc576660e21197410543123de89f0d939046efe0b016391e59ba1398a26b83b2908d578c70e6a3615d75ab4aeabffbfb6469a8422cf7f4
|
data/README.md
CHANGED
|
@@ -27,7 +27,7 @@ for example `renalware-ukrdc` which enables sending data to the UKRDC.
|
|
|
27
27
|
|
|
28
28
|
### Stack
|
|
29
29
|
|
|
30
|
-
- Ruby 2.
|
|
30
|
+
- Ruby 2.x
|
|
31
31
|
- Ruby on Rails 5
|
|
32
32
|
- Postgres 9.6+
|
|
33
33
|
|
|
@@ -161,6 +161,15 @@ to just create
|
|
|
161
161
|
`config.active_record.schema_format = :sql` in `application.rb` is used the engine
|
|
162
162
|
uses Postgres views and functions which are not properly supported in a `schema.rb`
|
|
163
163
|
|
|
164
|
+
##### Creating scenic views
|
|
165
|
+
|
|
166
|
+
As we are an engine this is the workaround for now.
|
|
167
|
+
```sh
|
|
168
|
+
bundle exec spec/dummy/bin/rails generate scenic:view my_view_name
|
|
169
|
+
```
|
|
170
|
+
Then copy the new files from spec/dummy/db/views and spec/dummy/db/migrations
|
|
171
|
+
to ./db/views and ./db/migrations
|
|
172
|
+
|
|
164
173
|
#### Throttling login attempts
|
|
165
174
|
|
|
166
175
|
[rack-attack](https://github.com/kickstarter/rack-attack) is configured to throttle login attempts.
|
|
@@ -182,3 +191,12 @@ To make awesome_print the default formatter in irb, add the following to `~/.irb
|
|
|
182
191
|
|
|
183
192
|
require "awesome_print"
|
|
184
193
|
AwesomePrint.irb!
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
#### Docker - WIP!
|
|
197
|
+
|
|
198
|
+
```
|
|
199
|
+
docker build -t renalware .
|
|
200
|
+
docker-compose run web rake db:create
|
|
201
|
+
docker-compose run web rake app:db:create
|
|
202
|
+
```
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
span.select2 {
|
|
2
2
|
margin: 0;
|
|
3
|
-
|
|
3
|
+
margin: 0 0 0.75rem 0;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
.grouped_select {
|
|
@@ -19,6 +19,6 @@ span.select2 {
|
|
|
19
19
|
|
|
20
20
|
.horizontal_medium {
|
|
21
21
|
span.select2.select2-container.select2-container--default {
|
|
22
|
-
min-width: 500px !important;
|
|
22
|
+
// min-width: 500px !important;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -94,7 +94,7 @@ module Renalware
|
|
|
94
94
|
def address_attributes
|
|
95
95
|
[
|
|
96
96
|
:id, :name, :organisation_name, :street_1, :street_2, :street_3, :town, :county,
|
|
97
|
-
:postcode, :
|
|
97
|
+
:postcode, :country_id, :telephone, :email, :_destroy
|
|
98
98
|
]
|
|
99
99
|
end
|
|
100
100
|
end
|
|
@@ -212,7 +212,7 @@ module Renalware
|
|
|
212
212
|
def address_attributes
|
|
213
213
|
[
|
|
214
214
|
:id, :name, :organisation_name, :street_1, :street_2, :street_3, :town, :county,
|
|
215
|
-
:postcode, :
|
|
215
|
+
:postcode, :country_id, :telephone, :email, :_destroy
|
|
216
216
|
]
|
|
217
217
|
end
|
|
218
218
|
end
|
|
@@ -22,7 +22,7 @@ module Renalware
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def new
|
|
25
|
-
patient = Patient.new
|
|
25
|
+
patient = Patient.new.tap(&:build_current_address)
|
|
26
26
|
authorize patient
|
|
27
27
|
render locals: { patient: patient }
|
|
28
28
|
end
|
|
@@ -83,10 +83,9 @@ module Renalware
|
|
|
83
83
|
.merge(by: current_user)
|
|
84
84
|
end
|
|
85
85
|
|
|
86
|
-
# rubocop:disable Metrics/MethodLength
|
|
87
86
|
def patient_attributes
|
|
88
87
|
[
|
|
89
|
-
:nhs_number, :family_name, :given_name, :sex,
|
|
88
|
+
:nhs_number, :family_name, :given_name, :sex, :country_of_birth_id,
|
|
90
89
|
:ethnicity_id, :born_on, :paediatric_patient_indicator, :cc_on_all_letters,
|
|
91
90
|
:title, :suffix, :marital_status, :telephone1, :telephone2, :email, :religion_id,
|
|
92
91
|
:language_id, :cc_decision_on,
|
|
@@ -97,10 +96,9 @@ module Renalware
|
|
|
97
96
|
current_address_attributes: address_params
|
|
98
97
|
]
|
|
99
98
|
end
|
|
100
|
-
# rubocop:enable Metrics/MethodLength
|
|
101
99
|
|
|
102
100
|
def address_params
|
|
103
|
-
[:id, :name, :organisation_name, :street_1, :street_2, :street_3, :county, :
|
|
101
|
+
[:id, :name, :organisation_name, :street_1, :street_2, :street_3, :county, :country_id,
|
|
104
102
|
:town, :postcode, :telephone, :email]
|
|
105
103
|
end
|
|
106
104
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
require_dependency("renalware/renal")
|
|
2
|
+
|
|
3
|
+
module Renalware
|
|
4
|
+
module Renal
|
|
5
|
+
class AKIAlertsController < BaseController
|
|
6
|
+
include Renalware::Concerns::Pageable
|
|
7
|
+
|
|
8
|
+
def index
|
|
9
|
+
alerts = AKIAlert.includes(:updated_by, :action, :hospital_ward, :patient)
|
|
10
|
+
.ordered.page(page).per(per_page)
|
|
11
|
+
authorize alerts
|
|
12
|
+
render locals: { alerts: alerts }
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def edit
|
|
16
|
+
authorize alert
|
|
17
|
+
render_edit(alert)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def update
|
|
21
|
+
authorize alert
|
|
22
|
+
if alert.update_attributes(aki_alert_params.merge(by: current_user))
|
|
23
|
+
redirect_to renal_aki_alerts_path
|
|
24
|
+
else
|
|
25
|
+
render_edit(alert)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
def render_edit(alert)
|
|
32
|
+
render :edit, locals: { alert: alert }
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def alert
|
|
36
|
+
@alert ||= AKIAlert.find(params[:id])
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def aki_alert_params
|
|
40
|
+
params.require(:renal_aki_alert).permit(:notes, :action_id, :hotlist, :hospital_ward_id)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -49,7 +49,7 @@ module Renalware
|
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
def address_params
|
|
52
|
-
[:id, :name, :organisation_name, :street_1, :street_2, :street_3, :county, :
|
|
52
|
+
[:id, :name, :organisation_name, :street_1, :street_2, :street_3, :county, :country_id,
|
|
53
53
|
:town, :postcode, :telephone, :email]
|
|
54
54
|
end
|
|
55
55
|
|
|
@@ -12,12 +12,12 @@ module Renalware
|
|
|
12
12
|
|
|
13
13
|
def show
|
|
14
14
|
authorize audit
|
|
15
|
-
columns, values = GenerateAuditJson.call(audit.
|
|
15
|
+
columns, values = GenerateAuditJson.call(audit.view_name)
|
|
16
16
|
render(
|
|
17
17
|
locals: {
|
|
18
18
|
audit: audit,
|
|
19
19
|
columns: columns,
|
|
20
|
-
values: values
|
|
20
|
+
values: replace_nils_with_empty_string(values)
|
|
21
21
|
}
|
|
22
22
|
)
|
|
23
23
|
end
|
|
@@ -42,6 +42,12 @@ module Renalware
|
|
|
42
42
|
@audit ||= Audit.find(params[:id])
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
+
# Takes an array (rows) of arrays (cells) and replaces any nil elements
|
|
46
|
+
# with an empty string so JS data tables does not baulk with 'nil undefined' error.
|
|
47
|
+
def replace_nils_with_empty_string(values)
|
|
48
|
+
values.map{ |row| row.map{ |cell| cell || "" } }
|
|
49
|
+
end
|
|
50
|
+
|
|
45
51
|
def render_edit
|
|
46
52
|
render :edit, locals: {
|
|
47
53
|
audit: audit,
|
|
@@ -54,7 +60,7 @@ module Renalware
|
|
|
54
60
|
.permit(
|
|
55
61
|
:name,
|
|
56
62
|
:description,
|
|
57
|
-
:
|
|
63
|
+
:view_name,
|
|
58
64
|
:display_configuration,
|
|
59
65
|
:refresh_schedule
|
|
60
66
|
)
|
|
@@ -15,19 +15,6 @@ module Renalware
|
|
|
15
15
|
end
|
|
16
16
|
attribute :diabetes, Diabetes
|
|
17
17
|
|
|
18
|
-
# TODO: Check if this is used?
|
|
19
|
-
class Address < Document::Embedded
|
|
20
|
-
attribute :name, String
|
|
21
|
-
attribute :organisation_name, String
|
|
22
|
-
attribute :street_1, String
|
|
23
|
-
attribute :street_2, String
|
|
24
|
-
attribute :street_3, String
|
|
25
|
-
attribute :town, String
|
|
26
|
-
attribute :county, String
|
|
27
|
-
attribute :postcode, String
|
|
28
|
-
attribute :country, String
|
|
29
|
-
end
|
|
30
|
-
|
|
31
18
|
class Referral < Document::Embedded
|
|
32
19
|
attribute :referring_physician_name, String
|
|
33
20
|
attribute :referral_date, Date
|
|
@@ -7,7 +7,7 @@ raw_message: |
|
|
|
7
7
|
OBR|1|^PCS|09B0099478^LA|FBC^FULL BLOOD COUNT^MB||200911111841|200911111841|||||||200911111841|B^Blood|MID^KINGS MIDWIVES||09B0099478||||200911121646||HM|F||||||||||||||||||
|
|
8
8
|
OBX|1|TX|WBC^WBC^MB||6.09||||||F|||200911112026||BBKA^Kenneth AMENYAH|
|
|
9
9
|
OBX|2|TX|RBC^RBC^MB||4.00||||||F|||200911112026||BBKA^Kenneth AMENYAH|
|
|
10
|
-
OBX|3|TX|
|
|
10
|
+
OBX|3|TX|HGB^Hb^MB||11.8||||||F|||200911112026||BBKA^Kenneth AMENYAH|
|
|
11
11
|
OBX|4|TX|PCV^PCV^MB||0.344||||||F|||200911112026||BBKA^Kenneth AMENYAH|
|
|
12
12
|
OBX|5|TX|MCV^MCV^MB||85.9||||||F|||200911112026||BBKA^Kenneth AMENYAH|
|
|
13
13
|
OBX|6|TX|MCH^MCH^MB||29.5||||||F|||200911112026||BBKA^Kenneth AMENYAH|
|
|
@@ -7,14 +7,18 @@ module Renalware
|
|
|
7
7
|
|
|
8
8
|
# :reek:UtilityFunction
|
|
9
9
|
def perform(audit)
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
if audit.materialized?
|
|
11
|
+
refresh_materialized_view_associated_with_audit(audit)
|
|
12
|
+
update_audit_refreshment_date(audit)
|
|
13
|
+
else
|
|
14
|
+
Rails.logger.warn("Cannot refresh an view that is not materialized: #{audit.view_name}")
|
|
15
|
+
end
|
|
12
16
|
end
|
|
13
17
|
|
|
14
18
|
private
|
|
15
19
|
|
|
16
20
|
def refresh_materialized_view_associated_with_audit(audit)
|
|
17
|
-
Scenic.database.refresh_materialized_view(audit.
|
|
21
|
+
Scenic.database.refresh_materialized_view(audit.view_name,
|
|
18
22
|
concurrently: false,
|
|
19
23
|
cascade: false)
|
|
20
24
|
end
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
require_dependency "renalware/clinical"
|
|
2
|
+
require_dependency "renalware/success"
|
|
3
|
+
require_dependency "renalware/failure"
|
|
2
4
|
|
|
3
5
|
module Renalware
|
|
4
6
|
module Clinical
|
|
@@ -14,9 +16,9 @@ module Renalware
|
|
|
14
16
|
yield allergy if block_given?
|
|
15
17
|
if allergy.valid?
|
|
16
18
|
save_allergy(allergy)
|
|
17
|
-
Success.new(allergy)
|
|
19
|
+
::Renalware::Success.new(allergy)
|
|
18
20
|
else
|
|
19
|
-
Failure.new(allergy)
|
|
21
|
+
::Renalware::Failure.new(allergy)
|
|
20
22
|
end
|
|
21
23
|
end
|
|
22
24
|
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
require_dependency "renalware/clinics"
|
|
2
|
+
require_dependency "renalware/success"
|
|
3
|
+
require_dependency "renalware/failure"
|
|
4
|
+
|
|
1
5
|
module Renalware
|
|
2
6
|
module Clinics
|
|
3
7
|
class CreateClinicVisit
|
|
@@ -17,9 +21,9 @@ module Renalware
|
|
|
17
21
|
visit = patient.clinic_visits.new(params)
|
|
18
22
|
objects = OpenStruct.new(clinic_visit: visit, appointment: appointment)
|
|
19
23
|
if visit.save && update_appointment_with(visit.id)
|
|
20
|
-
return Success.new(objects)
|
|
24
|
+
return ::Renalware::Success.new(objects)
|
|
21
25
|
else
|
|
22
|
-
return Failure.new(objects)
|
|
26
|
+
return ::Renalware::Failure.new(objects)
|
|
23
27
|
end
|
|
24
28
|
end
|
|
25
29
|
end
|
|
@@ -42,8 +42,20 @@ module Renalware
|
|
|
42
42
|
|
|
43
43
|
delegate :hospital_centre, to: :hospital_unit, allow_nil: true
|
|
44
44
|
|
|
45
|
+
def start_datetime
|
|
46
|
+
datetime_at(start_time)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def stop_datetime
|
|
50
|
+
datetime_at(end_time)
|
|
51
|
+
end
|
|
52
|
+
|
|
45
53
|
private
|
|
46
54
|
|
|
55
|
+
def datetime_at(time)
|
|
56
|
+
Time.zone.parse("#{performed_on.strftime('%F')} #{time.strftime('%T')}")
|
|
57
|
+
end
|
|
58
|
+
|
|
47
59
|
def assign_modality
|
|
48
60
|
self.modality_description = patient.modality_description
|
|
49
61
|
end
|
|
@@ -6,6 +6,10 @@ module Renalware
|
|
|
6
6
|
extend Enumerize
|
|
7
7
|
|
|
8
8
|
belongs_to :hospital_centre, class_name: "Hospitals::Centre"
|
|
9
|
+
has_many :wards,
|
|
10
|
+
class_name: "Hospitals::Ward",
|
|
11
|
+
foreign_key: :hospital_unit_id,
|
|
12
|
+
dependent: :destroy
|
|
9
13
|
|
|
10
14
|
validates :hospital_centre, presence: true
|
|
11
15
|
validates :unit_code, presence: true
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require_dependency "renalware/hospitals"
|
|
2
|
+
|
|
3
|
+
module Renalware
|
|
4
|
+
module Hospitals
|
|
5
|
+
class Ward < ApplicationRecord
|
|
6
|
+
belongs_to :hospital_unit, class_name: "Hospitals::Unit"
|
|
7
|
+
|
|
8
|
+
validates :hospital_unit, presence: true
|
|
9
|
+
validates :name, presence: true, uniqueness: { scope: :hospital_unit_id }
|
|
10
|
+
|
|
11
|
+
scope :ordered, -> { order(:name) }
|
|
12
|
+
|
|
13
|
+
def self.policy_class
|
|
14
|
+
BasePolicy
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def to_s
|
|
18
|
+
name
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
require_dependency "renalware/modalities"
|
|
2
|
+
require_dependency "renalware/success"
|
|
3
|
+
require_dependency "renalware/failure"
|
|
2
4
|
|
|
3
5
|
module Renalware
|
|
4
6
|
module Modalities
|
|
@@ -46,9 +48,9 @@ module Renalware
|
|
|
46
48
|
if new_modality.valid?
|
|
47
49
|
make_new_modality_the_current_one(new_modality)
|
|
48
50
|
broadcast_modality_change_event_to_any_listeners(new_modality)
|
|
49
|
-
Success.new(new_modality)
|
|
51
|
+
::Renalware::Success.new(new_modality)
|
|
50
52
|
else
|
|
51
|
-
Failure.new(new_modality)
|
|
53
|
+
::Renalware::Failure.new(new_modality)
|
|
52
54
|
end
|
|
53
55
|
end
|
|
54
56
|
|
|
@@ -31,6 +31,7 @@ module Renalware
|
|
|
31
31
|
has_one :current_address, as: :addressable, class_name: "Address"
|
|
32
32
|
has_one :summary, class_name: "Patients::Summary"
|
|
33
33
|
belongs_to :ethnicity, class_name: "Patients::Ethnicity"
|
|
34
|
+
belongs_to :country_of_birth, class_name: "System::Country"
|
|
34
35
|
belongs_to :religion, class_name: "Patients::Religion"
|
|
35
36
|
belongs_to :language, class_name: "Patients::Language"
|
|
36
37
|
has_many :bookmarks, class_name: "Patients::Bookmark"
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
require_dependency "renalware/pd"
|
|
2
|
+
require_dependency "renalware/success"
|
|
3
|
+
require_dependency "renalware/failure"
|
|
2
4
|
|
|
3
5
|
module Renalware
|
|
4
6
|
module PD
|
|
@@ -10,9 +12,9 @@ module Renalware
|
|
|
10
12
|
def call(by:, params:)
|
|
11
13
|
regime = patient.pd_regimes.new(params)
|
|
12
14
|
if regime.valid? && save_regime(regime, by)
|
|
13
|
-
return Success.new(regime)
|
|
15
|
+
return ::Renalware::Success.new(regime)
|
|
14
16
|
else
|
|
15
|
-
return Failure.new(regime)
|
|
17
|
+
return ::Renalware::Failure.new(regime)
|
|
16
18
|
end
|
|
17
19
|
end
|
|
18
20
|
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
require_dependency "renalware/pd"
|
|
2
|
+
require_dependency "renalware/success"
|
|
3
|
+
require_dependency "renalware/failure"
|
|
2
4
|
|
|
3
5
|
module Renalware
|
|
4
6
|
module PD
|
|
@@ -11,11 +13,11 @@ module Renalware
|
|
|
11
13
|
def call(by:, params:)
|
|
12
14
|
Regime.transaction do
|
|
13
15
|
regime.assign_attributes(params)
|
|
14
|
-
return Success.new(regime) unless regime.anything_changed?
|
|
15
|
-
return Failure.new(regime.with_bag_destruction_marks_removed) unless regime.valid?
|
|
16
|
+
return ::Renalware::Success.new(regime) unless regime.anything_changed?
|
|
17
|
+
return ::Renalware::Failure.new(regime.with_bag_destruction_marks_removed) unless regime.valid?
|
|
16
18
|
|
|
17
19
|
new_regime = revise_regime(by: by)
|
|
18
|
-
Success.new(new_regime)
|
|
20
|
+
::Renalware::Success.new(new_regime)
|
|
19
21
|
end
|
|
20
22
|
end
|
|
21
23
|
|