renalware-core 2.0.111 → 2.0.112
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +9 -0
- data/app/assets/javascripts/renalware/application.js.erb +7 -8
- data/app/assets/javascripts/renalware/charting/charting.js.erb +4 -0
- data/app/assets/javascripts/renalware/dialogs.js.erb +0 -11
- data/app/assets/javascripts/renalware/hd.js +59 -9
- data/app/assets/stylesheets/renalware/application.scss +2 -3
- data/app/assets/stylesheets/renalware/modules/_hd.scss +19 -0
- data/app/assets/stylesheets/renalware/modules/_patients.scss +7 -0
- data/app/assets/stylesheets/renalware/print/pathology_request_forms.scss +26 -0
- data/app/assets/stylesheets/renalware/protocol_pdf.scss +9 -4
- data/app/controllers/renalware/hd/mdm_patients_controller.rb +17 -6
- data/app/controllers/renalware/hd/protocols_controller.rb +22 -31
- data/app/controllers/renalware/hd/session_forms/batches_controller.rb +82 -0
- data/app/controllers/renalware/pathology/requests/requests_controller.rb +20 -6
- data/app/controllers/renalware/surveys/dashboards_controller.rb +24 -0
- data/app/jobs/renalware/hd/session_forms/batch_print_job.rb +40 -0
- data/app/models/concerns/renalware/pdf_compilation.rb +60 -0
- data/app/models/renalware/clinical/allergy_status_form.rb +1 -1
- data/app/models/renalware/clinical/delete_allergy.rb +1 -1
- data/app/models/renalware/clinics/appointment_query.rb +1 -5
- data/app/models/renalware/hd.rb +6 -0
- data/app/models/renalware/hd/patient_listener.rb +1 -1
- data/app/models/renalware/hd/session_forms/batch.rb +26 -0
- data/app/models/renalware/hd/session_forms/batch_compile_pdfs.rb +86 -0
- data/app/models/renalware/hd/session_forms/batch_item.rb +15 -0
- data/app/models/renalware/hd/session_forms/form.rb +16 -0
- data/app/models/renalware/hd/session_forms/pdf_renderer.rb +74 -0
- data/app/models/renalware/letters/batch.rb +2 -0
- data/app/models/renalware/letters/printing/batch_compile_pdfs.rb +0 -3
- data/app/models/renalware/medications/patient_listener.rb +1 -1
- data/app/models/renalware/pathology/ordered_patient_query.rb +1 -1
- data/app/models/renalware/pathology/request_for_patient_request_description_query.rb +1 -1
- data/app/models/renalware/pd/apd/non_tidal_regime_calculations.rb +1 -1
- data/app/models/renalware/pd/apd/tidal_regime_calculations.rb +1 -1
- data/app/models/renalware/snippets/snippet_query.rb +1 -1
- data/app/models/renalware/surveys.rb +9 -0
- data/app/models/renalware/surveys/eq5d_pivoted_response.rb +11 -0
- data/app/models/renalware/surveys/eq5d_summary_part.rb +51 -0
- data/app/models/renalware/surveys/pos_s_pivoted_response.rb +11 -0
- data/app/models/renalware/surveys/pos_s_summary_part.rb +51 -0
- data/app/models/renalware/surveys/question.rb +22 -0
- data/app/models/renalware/surveys/response.rb +28 -0
- data/app/models/renalware/surveys/survey.rb +17 -0
- data/app/models/renalware/ukrdc.rb +3 -0
- data/app/models/renalware/ukrdc/incoming/file_list.rb +21 -0
- data/app/models/renalware/ukrdc/incoming/import_survey.rb +57 -0
- data/app/models/renalware/ukrdc/incoming/import_surveys.rb +77 -0
- data/app/models/renalware/ukrdc/incoming/paths.rb +30 -0
- data/app/models/renalware/ukrdc/incoming/xml_document.rb +68 -0
- data/app/models/renalware/ukrdc/transmission_log.rb +14 -3
- data/app/policies/renalware/hd/session_forms/batch_policy.rb +13 -0
- data/app/policies/renalware/surveys/survey_policy.rb +10 -0
- data/app/presenters/renalware/hd/session_presenter.rb +1 -1
- data/app/views/renalware/clinics/appointments/index.html.slim +22 -11
- data/app/views/renalware/hd/dashboards/_page_actions.html.slim +1 -1
- data/app/views/renalware/hd/diary_slots/_form.html.slim +0 -3
- data/app/views/renalware/hd/mdm_patients/_filters.html.slim +11 -0
- data/app/views/renalware/hd/mdm_patients/_page_actions.html.slim +0 -0
- data/app/views/renalware/hd/mdm_patients/index.html.slim +9 -1
- data/app/views/renalware/hd/protocols/{show.pdf.slim → _protocol.pdf.slim} +1 -7
- data/app/views/renalware/hd/protocols/index.pdf.slim +4 -0
- data/app/views/renalware/hd/session_forms/batches/_create.html.slim +25 -0
- data/app/views/renalware/hd/session_forms/batches/create.js.erb +3 -0
- data/app/views/renalware/hd/sessions/_row.html.slim +1 -1
- data/app/views/renalware/hd/sessions/_thead.html.slim +1 -1
- data/app/views/renalware/pathology/historical_observation_results/_table.html.slim +1 -1
- data/app/views/renalware/pathology/recent_observation_results/_table.html.slim +1 -1
- data/app/views/renalware/pathology/requests/requests/create.pdf.slim +2 -1
- data/app/views/renalware/pathology/requests/requests/new.html.slim +18 -13
- data/app/views/renalware/pathology/requests/requests/request_form/_crs.pdf.slim +1 -0
- data/app/views/renalware/pathology/requests/requests/request_form/_crs_form.html.slim +46 -45
- data/app/views/renalware/pathology/requests/requests/request_form/_manual_form_global.html.slim +9 -8
- data/app/views/renalware/pathology/requests/requests/request_form/_manual_form_patient.html.slim +9 -8
- data/app/views/renalware/pathology/requests/requests/show.pdf.slim +2 -1
- data/app/views/renalware/patients/side_menu/_general.html.slim +4 -0
- data/app/views/renalware/surveys/_eq5d_summary_part.html.slim +26 -0
- data/app/views/renalware/surveys/_pos_s_summary_part.html.slim +26 -0
- data/app/views/renalware/surveys/dashboards/show.html.slim +32 -0
- data/config/initializers/chartkick.rb +6 -0
- data/config/initializers/core_extensions.rb +4 -4
- data/config/initializers/inflections.rb +3 -0
- data/config/locales/renalware/patients/side_menu.en.yml +1 -0
- data/config/routes/hd.rb +5 -1
- data/config/routes/patients.rb +4 -0
- data/db/migrate/20190927124840_create_hd_session_form_batches.rb +16 -0
- data/db/migrate/20190927130911_create_hd_session_form_batch_items.rb +17 -0
- data/db/migrate/20191008010839_create_surveys.rb +70 -0
- data/db/migrate/20191008024636_create_eq5d_views.rb +8 -0
- data/db/migrate/20191008030154_add_validation_regex_to_patient_survey_questions.rb +7 -0
- data/db/migrate/20191008045159_allow_null_patient_in_ukrdc_transmission_logs.rb +8 -0
- data/db/seeds/default/patients/seeds.rb +2 -0
- data/db/seeds/default/patients/surveys/eq5d_5l.rb +22 -0
- data/db/seeds/default/patients/surveys/eq5d_5l_questions.csv +7 -0
- data/db/seeds/default/patients/surveys/pos_s.rb +22 -0
- data/db/seeds/default/patients/surveys/pos_s_questions.csv +23 -0
- data/db/views/survey_eq5d_pivoted_responses_v01.sql +41 -0
- data/db/views/survey_pos_s_pivoted_responses_v01.sql +36 -0
- data/lib/core_extensions/active_record/migration_helpers.rb +1 -1
- data/lib/core_extensions/active_support/duration.rb +1 -1
- data/lib/core_extensions/scenic.rb +1 -1
- data/lib/renalware/engine.rb +4 -4
- data/lib/renalware/version.rb +1 -1
- data/lib/tasks/ukrdc.rake +9 -0
- data/spec/factories/patients/surveys.rb +24 -0
- data/spec/support/ukrdc_helpers.rb +16 -0
- metadata +98 -59
- data/app/views/renalware/letters/batches/show.html.slim +0 -7
- data/app/views/renalware/pathology/requests/requests/_pdf_header.html.slim +0 -13
- data/vendor/assets/javascripts/renalware/masonry.min.js +0 -9
- data/vendor/assets/javascripts/renalware/print.min.js +0 -1
- data/vendor/assets/stylesheets/renalware/balloon.css +0 -383
- data/vendor/assets/stylesheets/renalware/print.min.css +0 -1
- data/vendor/assets/stylesheets/renalware/select2/css/select2.css +0 -431
- data/vendor/assets/stylesheets/renalware/select2/css/select2.min.css +0 -1
@@ -22,7 +22,7 @@ table#observations.column_hover
|
|
22
22
|
th(title=desc.name)= code
|
23
23
|
- table.rows.each do |row|
|
24
24
|
- if row.comment_for(code).present?
|
25
|
-
td(class=code.downcase
|
25
|
+
td(class=code.downcase aria-label=row.comment_for(code) data-balloon-pos="up")
|
26
26
|
.triangle-top-right
|
27
27
|
= row.result_for(code)
|
28
28
|
- else
|
@@ -1,4 +1,5 @@
|
|
1
|
-
=
|
1
|
+
= content_for(:head2) do
|
2
|
+
= wicked_pdf_stylesheet_link_tag "renalware/print/pathology_request_forms.css"
|
2
3
|
|
3
4
|
= render partial: "renalware/pathology/requests/requests/request_form/#{request_html_form_params.template}",
|
4
5
|
locals: { requests: requests }
|
@@ -1,19 +1,24 @@
|
|
1
|
-
doctype html
|
2
|
-
html lang="en"
|
3
|
-
|
4
|
-
|
1
|
+
/ doctype html
|
2
|
+
/ html lang="en"
|
3
|
+
/ head
|
4
|
+
/ meta charset="utf-8"
|
5
5
|
|
6
|
-
|
6
|
+
/ title= content_for?(:title) ? yield(:title) : "Renalware v#{Renalware::VERSION}"
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
/ = stylesheet_link_tag "renalware/application", media: :all
|
9
|
+
/ = stylesheet_link_tag "renalware/print/pathology_request_forms", media: :all
|
10
|
+
/ = javascript_include_tag "renalware/modernizr"
|
11
11
|
|
12
|
-
|
12
|
+
/ = csrf_meta_tag
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
|
15
|
+
/ body.overflow
|
16
|
+
|
17
|
+
= content_for(:css) do
|
18
|
+
= stylesheet_link_tag "renalware/print/pathology_request_forms", media: :all
|
19
|
+
= within_admin_layout(title: "Pathology Request CRS Form Preview") do
|
20
|
+
/ .row
|
21
|
+
/ h4 Pathology Request CRS Form Preview
|
17
22
|
|
18
23
|
.row
|
19
24
|
.large-4.columns
|
@@ -55,4 +60,4 @@ html lang="en"
|
|
55
60
|
= render partial: "renalware/pathology/requests/requests/request_form/#{request_html_form_params.template}",
|
56
61
|
locals: { requests: requests, format: :html }
|
57
62
|
|
58
|
-
|
63
|
+
/= javascript_include_tag "renalware/application"
|
@@ -1,49 +1,50 @@
|
|
1
|
-
.
|
2
|
-
|
1
|
+
.path-request-form
|
2
|
+
.row data-role="form_summary" data-patient-id="#{request_form.patient.id}"
|
3
|
+
h3 Pathology Request Listing
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
5
|
+
table.with_border
|
6
|
+
tr
|
7
|
+
td.header_cell Patient Name:
|
8
|
+
td data-role="patient_name" = request_form.patient_name
|
9
|
+
td.header_cell Date:
|
10
|
+
td data-role="date" = request_form.date
|
11
|
+
tr
|
12
|
+
td.header_cell DOB:
|
13
|
+
td data-role="date_of_birth" = request_form.date_of_birth
|
14
|
+
td.header_cell Consultant:
|
15
|
+
td data-role="consultant" = request_form.consultant
|
16
|
+
tr
|
17
|
+
td.header_cell Clinical Detail:
|
18
|
+
td data-role="clinical_detail" = request_form.clinical_detail
|
19
|
+
td.header_cell Contact:
|
20
|
+
td data-role="contact" = request_form.contact
|
21
|
+
tr
|
22
|
+
td.header_cell
|
23
|
+
td
|
24
|
+
td.header_cell Bleep/Tel No:
|
25
|
+
td data-role="telephone" = request_form.telephone
|
25
26
|
|
26
|
-
.row.full_height data-role="form_pathology" data-patient-id="#{request_form.patient.id}"
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
.row.full_height data-role="form_pathology" data-patient-id="#{request_form.patient.id}"
|
28
|
+
.border_box_half.columns.full_height.global_requests
|
29
|
+
- if request_form.has_global_requests?
|
30
|
+
- request_form.global_requests_by_lab_and_bottle_type.each do |(lab_name, bottle_type), request_descriptions|
|
31
|
+
p
|
32
|
+
| ==== #{lab_name} (#{bottle_type}) ====
|
33
|
+
- request_descriptions.each do |request_description|
|
34
|
+
p = request_description.name.downcase.titleize
|
35
|
+
- else
|
36
|
+
p No tests required.
|
37
|
+
.border_box_half.columns.patient_requests
|
38
|
+
- if request_form.high_risk
|
30
39
|
p
|
31
|
-
|
32
|
-
- request_descriptions.each do |request_description|
|
33
|
-
p = request_description.name.downcase.titleize
|
34
|
-
- else
|
35
|
-
p No tests required.
|
36
|
-
.border_box_half.columns
|
37
|
-
- if request_form.high_risk
|
38
|
-
p
|
39
|
-
h3 HIGH RISK
|
40
|
+
h3 HIGH RISK
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
42
|
+
b Patient Specific Tests:
|
43
|
+
- if request_form.has_patient_requests?
|
44
|
+
- request_form.patient_requests_by_lab.each do |lab_name, patient_rules|
|
45
|
+
p
|
46
|
+
| ======== #{lab_name} ========
|
47
|
+
- patient_rules.each do |patient_rule|
|
48
|
+
= patient_rule
|
49
|
+
- else
|
50
|
+
p No tests required.
|
data/app/views/renalware/pathology/requests/requests/request_form/_manual_form_global.html.slim
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
.path-request-form
|
2
|
+
= render partial: "renalware/pathology/requests/requests/request_form/manual_header.html.slim",
|
3
|
+
locals: { request_form: request_form }
|
3
4
|
|
4
|
-
.row
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
.row
|
6
|
+
p
|
7
|
+
|
|
8
|
+
b #{lab_name} (#{bottle_type})
|
9
|
+
- request_descriptions.each do |request_description|
|
10
|
+
p = request_description.name.downcase.titleize
|
data/app/views/renalware/pathology/requests/requests/request_form/_manual_form_patient.html.slim
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
.path-request-form
|
2
|
+
= render partial: "renalware/pathology/requests/requests/request_form/manual_header.html.slim",
|
3
|
+
locals: { request_form: request_form }
|
3
4
|
|
4
|
-
.row
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
.row
|
6
|
+
p
|
7
|
+
|
|
8
|
+
b #{lab_name}
|
9
|
+
- patient_rules.each do |patient_rule|
|
10
|
+
p = patient_rule
|
@@ -1,4 +1,5 @@
|
|
1
|
-
=
|
1
|
+
= content_for(:head2) do
|
2
|
+
= wicked_pdf_stylesheet_link_tag "renalware/print/pathology_request_forms.css"
|
2
3
|
|
3
4
|
= render partial: "renalware/pathology/requests/requests/request_form/#{request.template}",
|
4
5
|
locals: { requests: [request] }
|
@@ -61,3 +61,7 @@ li.heading= t(".heading")
|
|
61
61
|
= patient_menu_item title: t(".inpatient_admissions", count: summary.admissions_count),
|
62
62
|
path: patient_admissions_path(patient),
|
63
63
|
active_when_controller_matches: %r{renalware/admissions}
|
64
|
+
|
65
|
+
= patient_menu_item title: t(".proms"),
|
66
|
+
path: patient_surveys_dashboard_path(patient),
|
67
|
+
active_when_controller_matches: %r{renalware/surveys}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
.summary-part--eq5d
|
2
|
+
article
|
3
|
+
header
|
4
|
+
h2 EQ5D
|
5
|
+
|
6
|
+
/ b Example WIP for charting one question over time
|
7
|
+
/ = line_chart(eq5d_summary_part.data_for_question_code(1), curve: false)
|
8
|
+
/ br
|
9
|
+
/ br
|
10
|
+
/ br
|
11
|
+
|
12
|
+
- return if eq5d_summary_part.rows.blank?
|
13
|
+
|
14
|
+
.xsss
|
15
|
+
table
|
16
|
+
thead
|
17
|
+
tr
|
18
|
+
th Date
|
19
|
+
- eq5d_summary_part.question_labels.each do |code, label|
|
20
|
+
th= label
|
21
|
+
tbody
|
22
|
+
- eq5d_summary_part.rows.each do |row|
|
23
|
+
tr
|
24
|
+
td= row.answered_on
|
25
|
+
- eq5d_summary_part.question_labels.each do |code, label|
|
26
|
+
td= row.send(code.to_sym)
|
@@ -0,0 +1,26 @@
|
|
1
|
+
.summary-part--pos_s
|
2
|
+
article
|
3
|
+
header
|
4
|
+
h2 POS-S
|
5
|
+
|
6
|
+
/ b Example WIP for charting one question over time
|
7
|
+
/ = line_chart(eq5d_summary_part.data_for_question_code(1), curve: false)
|
8
|
+
/ br
|
9
|
+
/ br
|
10
|
+
/ br
|
11
|
+
|
12
|
+
- return if pos_s_summary_part.rows.blank?
|
13
|
+
|
14
|
+
.xsss
|
15
|
+
table
|
16
|
+
thead
|
17
|
+
tr
|
18
|
+
th Date
|
19
|
+
- pos_s_summary_part.question_labels.each do |code, label|
|
20
|
+
th= label
|
21
|
+
tbody
|
22
|
+
- pos_s_summary_part.rows.each do |row|
|
23
|
+
tr
|
24
|
+
td= row.answered_on
|
25
|
+
- pos_s_summary_part.question_labels.each do |code, label|
|
26
|
+
td= row.send(code.to_sym)
|
@@ -0,0 +1,32 @@
|
|
1
|
+
= within_patient_layout(title: "PROMS") do
|
2
|
+
|
3
|
+
= render Renalware::Surveys::EQ5DSummaryPart.new(patient, current_user)
|
4
|
+
= render Renalware::Surveys::POSSSummaryPart.new(patient, current_user)
|
5
|
+
|
6
|
+
/ .summary-part--eq5d
|
7
|
+
/ article
|
8
|
+
/ header
|
9
|
+
/ h2 EQ5D
|
10
|
+
|
11
|
+
|
12
|
+
/ / b Example WIP for charting one question over time
|
13
|
+
/ / = line_chart(eq5d_summary_part.data_for_question_code(1), curve: false)
|
14
|
+
/ / br
|
15
|
+
/ / br
|
16
|
+
/ / br
|
17
|
+
|
18
|
+
/ / - return if eq5d_summary_part.rows.blank?
|
19
|
+
|
20
|
+
/ .xsss
|
21
|
+
/ table
|
22
|
+
/ thead
|
23
|
+
/ tr
|
24
|
+
/ th Date
|
25
|
+
/ - eq5d_responses.question_labels.each do |code, label|
|
26
|
+
/ th= label
|
27
|
+
/ tbody
|
28
|
+
/ - eq5d_responses.rows.each do |row|
|
29
|
+
/ tr
|
30
|
+
/ td= row.answered_on
|
31
|
+
/ - eq5d_summary_part.question_labels.each do |code, label|
|
32
|
+
/ td= row.send(code.to_sym)
|
@@ -11,8 +11,8 @@ require "core_extensions/hash"
|
|
11
11
|
require "core_extensions/active_record/migration_helpers"
|
12
12
|
|
13
13
|
I18n.extend CoreExtensions::I18n::HandleBlankValue
|
14
|
-
I18n::Backend::Simple.
|
14
|
+
I18n::Backend::Simple.include(I18n::Backend::Cascade)
|
15
15
|
I18n.extend CoreExtensions::I18n::AlwaysCascade
|
16
|
-
ActiveRecord::Base.
|
17
|
-
Date.include
|
18
|
-
Hash.
|
16
|
+
ActiveRecord::Base.include(CoreExtensions::ActiveRecord::Sort)
|
17
|
+
Date.include(CoreExtensions::Date::Constants)
|
18
|
+
Hash.include(CoreExtensions::Hash::OpenStructConversion)
|
@@ -43,6 +43,9 @@ ActiveSupport::Inflector.inflections(:en) do |inflect|
|
|
43
43
|
inflect.acronym "TRUD"
|
44
44
|
inflect.acronym "UKRDC"
|
45
45
|
inflect.acronym "XHR"
|
46
|
+
inflect.acronym "EQ5D"
|
47
|
+
inflect.acronym "EQ5D5L"
|
48
|
+
inflect.acronym "POS"
|
46
49
|
inflect.irregular "feedback", "feedback"
|
47
50
|
inflect.acronym "NHS"
|
48
51
|
inflect.uncountable %w(cache)
|
data/config/routes/hd.rb
CHANGED
@@ -6,7 +6,6 @@ resources :patients, only: [] do
|
|
6
6
|
resource :dashboard, only: :show
|
7
7
|
resource :protocol,
|
8
8
|
only: :show,
|
9
|
-
constraints: { format: /(pdf)/ },
|
10
9
|
defaults: { format: :pdf }
|
11
10
|
resource :preference_set, only: [:edit, :update]
|
12
11
|
resource :current_profile,
|
@@ -51,4 +50,9 @@ namespace :hd do
|
|
51
50
|
to: "diary_slots#show",
|
52
51
|
as: :refresh_slot
|
53
52
|
end
|
53
|
+
namespace :session_forms do
|
54
|
+
resources :batches, only: [:create, :show] do
|
55
|
+
get :status, constraints: { format: :json }, defaults: { format: :json }
|
56
|
+
end
|
57
|
+
end
|
54
58
|
end
|
data/config/routes/patients.rb
CHANGED
@@ -37,4 +37,8 @@ resources :patients, except: [:destroy], controller: "patients/patients" do
|
|
37
37
|
post :sort, on: :collection
|
38
38
|
resources :notes, only: [:index, :new, :create], controller: "problems/notes"
|
39
39
|
end
|
40
|
+
|
41
|
+
namespace :surveys do
|
42
|
+
resource :dashboard, only: :show
|
43
|
+
end
|
40
44
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateHDSessionFormBatches < ActiveRecord::Migration[5.2]
|
2
|
+
def change
|
3
|
+
within_renalware_schema do
|
4
|
+
create_table :hd_session_form_batches do |t|
|
5
|
+
t.integer :status, null: false, default: 0, index: true
|
6
|
+
t.jsonb :query_params, default: {}, null: false
|
7
|
+
t.references :created_by, foreign_key: { to_table: :users }, index: true, null: false
|
8
|
+
t.references :updated_by, foreign_key: { to_table: :users }, index: true, null: false
|
9
|
+
t.string :filepath
|
10
|
+
t.string :last_error
|
11
|
+
t.integer :batch_items_count
|
12
|
+
t.timestamps null: false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# rubocop:disable Rails/CreateTableWithTimestamps
|
2
|
+
class CreateHDSessionFormBatchItems < ActiveRecord::Migration[5.2]
|
3
|
+
def change
|
4
|
+
within_renalware_schema do
|
5
|
+
create_table :hd_session_form_batch_items do |t|
|
6
|
+
t.references :batch, foreign_key: { to_table: :hd_session_form_batches }, null: false, index: false
|
7
|
+
# As a precurosr to combining letter batches and session form batches into one table
|
8
|
+
# eg print_batches, use a generic reference here to something printable, rather than a
|
9
|
+
# t.references :patient etc
|
10
|
+
t.integer :printable_id, null: false, index: false
|
11
|
+
t.integer(:status, default: 0, null: false, limit: 2, index: true) # smallint
|
12
|
+
end
|
13
|
+
add_index :hd_session_form_batch_items, [:batch_id, :printable_id], unique: true
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
# rubocop:enable Rails/CreateTableWithTimestamps
|
@@ -0,0 +1,70 @@
|
|
1
|
+
class CreateSurveys < ActiveRecord::Migration[5.2]
|
2
|
+
def change
|
3
|
+
within_renalware_schema do
|
4
|
+
create_table :survey_surveys do |t|
|
5
|
+
t.string :name, null: false
|
6
|
+
t.string :code, null: false
|
7
|
+
t.string :description
|
8
|
+
t.datetime :deleted_at, index: true
|
9
|
+
t.timestamps null: false
|
10
|
+
end
|
11
|
+
|
12
|
+
# name must be unique among non-deleted surveys
|
13
|
+
add_index(
|
14
|
+
:survey_surveys,
|
15
|
+
:name,
|
16
|
+
unique: true,
|
17
|
+
where: "deleted_at is NULL"
|
18
|
+
)
|
19
|
+
|
20
|
+
# code must be unique among non-deleted surveys
|
21
|
+
add_index(
|
22
|
+
:survey_surveys,
|
23
|
+
:code,
|
24
|
+
unique: true,
|
25
|
+
where: "deleted_at is NULL"
|
26
|
+
)
|
27
|
+
|
28
|
+
create_table :survey_questions do |t|
|
29
|
+
t.references(
|
30
|
+
:survey,
|
31
|
+
foreign_key: { to_table: :survey_surveys },
|
32
|
+
index: true,
|
33
|
+
null: false
|
34
|
+
)
|
35
|
+
t.string :code, null: false
|
36
|
+
t.string :label
|
37
|
+
t.integer :position, null: false, default: 0, index: true
|
38
|
+
t.datetime :deleted_at, index: true
|
39
|
+
t.timestamps null: false
|
40
|
+
end
|
41
|
+
|
42
|
+
# Prevent a unique index on code within any survey, but exclusing deleted questions.
|
43
|
+
add_index(
|
44
|
+
:survey_questions,
|
45
|
+
[:code, :survey_id],
|
46
|
+
unique: true,
|
47
|
+
where: "deleted_at is NULL"
|
48
|
+
)
|
49
|
+
|
50
|
+
create_table :survey_responses do |t|
|
51
|
+
t.date :answered_on, null: false, index: true
|
52
|
+
t.references(:patient, null: false)
|
53
|
+
t.references(
|
54
|
+
:question,
|
55
|
+
foreign_key: { to_table: :survey_questions },
|
56
|
+
null: false
|
57
|
+
)
|
58
|
+
t.string :value
|
59
|
+
t.string :reference # for future use - possibly to tie responses together?
|
60
|
+
t.timestamps null: false
|
61
|
+
end
|
62
|
+
|
63
|
+
add_index(
|
64
|
+
:survey_responses,
|
65
|
+
[:answered_on, :patient_id, :question_id],
|
66
|
+
name: :survey_responses_compound_index
|
67
|
+
)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|