renalware-core 2.0.130 → 2.0.131
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/app/controllers/renalware/admin/users_controller.rb +1 -0
- data/app/controllers/renalware/medications/prescriptions_controller.rb +2 -2
- data/app/controllers/renalware/patients/patients_controller.rb +1 -1
- data/app/jobs/renalware/letters/calculate_page_count_job.rb +5 -0
- data/app/models/concerns/renalware/pdf_compilation.rb +2 -2
- data/app/models/renalware/events/lists/form.rb +1 -1
- data/app/models/renalware/letters/approve_letter.rb +3 -1
- data/app/models/renalware/letters/delivery/email_letter_to_practice.rb +6 -14
- data/app/models/renalware/letters/lists/form.rb +2 -2
- data/app/models/renalware/letters/pdf_renderer.rb +1 -0
- data/app/models/renalware/letters/printing/pdf_combining.rb +2 -2
- data/app/models/renalware/medications/dose_unit.rb +2 -0
- data/app/models/renalware/modalities/description.rb +10 -2
- data/app/models/renalware/pd/apd/glucose_calculator.rb +2 -2
- data/app/models/renalware/system/update_user.rb +3 -0
- data/app/models/renalware/ukrdc/create_encrypted_patient_xml_files.rb +15 -4
- data/app/models/renalware/ukrdc/create_patient_xml_file.rb +16 -3
- data/app/models/renalware/ukrdc/outgoing/rendering/address.rb +38 -0
- data/app/models/renalware/ukrdc/outgoing/rendering/allergy.rb +27 -0
- data/app/models/renalware/ukrdc/outgoing/rendering/base.rb +20 -0
- data/app/models/renalware/ukrdc/outgoing/rendering/cause_of_death.rb +38 -0
- data/app/models/renalware/ukrdc/outgoing/rendering/clinic_visit_observation.rb +24 -0
- data/app/models/renalware/ukrdc/outgoing/rendering/clinician.rb +12 -0
- data/app/models/renalware/ukrdc/outgoing/rendering/diagnoses.rb +63 -0
- data/app/models/renalware/ukrdc/outgoing/rendering/diagnosis.rb +52 -0
- data/app/models/renalware/ukrdc/outgoing/rendering/dialysis_session.rb +81 -0
- data/app/models/renalware/ukrdc/outgoing/rendering/document.rb +46 -0
- data/app/models/renalware/ukrdc/outgoing/rendering/entered_at.rb +26 -0
- data/app/models/renalware/ukrdc/outgoing/rendering/entered_by.rb +12 -0
- data/app/models/renalware/ukrdc/outgoing/rendering/family_doctor.rb +30 -0
- data/app/models/renalware/ukrdc/outgoing/rendering/hd_session_observations.rb +51 -0
- data/app/models/renalware/ukrdc/outgoing/rendering/hd_treatment.rb +26 -0
- data/app/models/renalware/ukrdc/outgoing/rendering/lab_order.rb +80 -0
- data/app/models/renalware/ukrdc/outgoing/rendering/lab_orders.rb +30 -0
- data/app/models/renalware/ukrdc/outgoing/rendering/medication.rb +77 -0
- data/app/models/renalware/ukrdc/outgoing/rendering/name.rb +29 -0
- data/app/models/renalware/ukrdc/outgoing/rendering/observation.rb +70 -0
- data/app/models/renalware/ukrdc/outgoing/rendering/observations.rb +58 -0
- data/app/models/renalware/ukrdc/outgoing/rendering/patient.rb +167 -0
- data/app/models/renalware/ukrdc/outgoing/rendering/patient_number.rb +27 -0
- data/app/models/renalware/ukrdc/outgoing/rendering/patient_numbers.rb +53 -0
- data/app/models/renalware/ukrdc/outgoing/rendering/pd_treatment.rb +27 -0
- data/app/models/renalware/ukrdc/outgoing/rendering/primary_language.rb +35 -0
- data/app/models/renalware/ukrdc/outgoing/rendering/procedures.rb +40 -0
- data/app/models/renalware/ukrdc/outgoing/rendering/renal_diagnosis.rb +35 -0
- data/app/models/renalware/ukrdc/outgoing/rendering/transplant.rb +69 -0
- data/app/models/renalware/ukrdc/outgoing/rendering/treatment.rb +78 -0
- data/app/models/renalware/ukrdc/outgoing/rendering/user.rb +33 -0
- data/app/models/renalware/ukrdc/pathology_observation_requests_query.rb +1 -0
- data/app/models/renalware/ukrdc/xml_renderer.rb +54 -75
- data/app/models/renalware/user.rb +4 -1
- data/app/presenters/renalware/hd/scheduling/diary_presenter.rb +2 -2
- data/app/presenters/renalware/system/users_presenter.rb +1 -1
- data/app/presenters/renalware/ukrdc/transplant_operation_presenter.rb +4 -0
- data/app/views/renalware/admin/users/edit.html.slim +6 -0
- data/app/views/renalware/admin/users/index.html.slim +6 -1
- data/app/views/renalware/api/ukrdc/patients/_clinic_visit_observation.xml.builder +3 -3
- data/app/views/renalware/api/ukrdc/patients/_documents.xml.builder +28 -24
- data/app/views/renalware/api/ukrdc/patients/_sending_facility.xml.builder +1 -1
- data/app/views/renalware/api/ukrdc/patients/_treatments.xml.builder +0 -27
- data/app/views/renalware/api/ukrdc/patients/show.xml.builder +1 -5
- data/app/views/renalware/medications/drug_types/prescriptions/_table.html.slim +1 -1
- data/app/views/renalware/patients/patients/_form.html.slim +1 -0
- data/app/views/renalware/patients/patients/show/_contact_details.html.slim +2 -1
- data/config/initializers/core_extensions.rb +1 -0
- data/config/initializers/devise.rb +1 -1
- data/config/locales/renalware/medications/prescription.yml +2 -0
- data/db/migrate/20170526060804_enable_uuid_extension.rb +1 -1
- data/db/migrate/20191219145651_add_hidden_to_users.rb +8 -0
- data/db/migrate/20200106073329_add_next_of_kin_to_patients.rb +7 -0
- data/db/migrate/20200106210851_create_case_insensitive_index_on_patients.rb +22 -0
- data/lib/core_extensions/active_record/migration_helpers.rb +7 -0
- data/lib/core_extensions/ox/element_additions.rb +18 -0
- data/lib/renalware/engine.rb +2 -1
- data/lib/renalware/version.rb +1 -1
- data/lib/tasks/spec.rake +33 -0
- data/spec/factories/accesses/assessments.rb +18 -0
- data/spec/factories/accesses/catheter_insertion_techniques.rb +8 -0
- data/spec/factories/accesses/plans.rb +1 -1
- data/spec/factories/accesses/plans_types.rb +1 -1
- data/spec/factories/accesses/procedures.rb +2 -2
- data/spec/factories/accesses/profiles.rb +1 -1
- data/spec/factories/accesses/sites.rb +1 -1
- data/spec/factories/accesses/types.rb +1 -1
- data/spec/factories/hd/hd_session_document.rb +8 -8
- data/spec/factories/transplants/donations.rb +1 -1
- data/spec/factories/transplants/recipient_followups.rb +1 -1
- data/spec/factories/transplants/recipient_operations.rb +1 -1
- data/spec/factories/transplants/registration_status_descriptions.rb +1 -1
- data/spec/factories/transplants/registration_statuses.rb +1 -1
- data/spec/factories/transplants/registrations.rb +1 -1
- data/spec/factories/transplants/rejection_episodes.rb +1 -1
- data/spec/factories/transplants/rejection_treatments.rb +1 -1
- data/spec/factories/ukrdc/modality_codes.rb +1 -1
- data/spec/support/capybara_helper.rb +6 -0
- data/spec/support/letters_spec_helper.rb +2 -2
- data/spec/support/pages/accesses/procedure_page.rb +53 -0
- data/spec/support/pages/accesses/profile_page.rb +45 -0
- data/spec/support/pages/clinical/allergy_page.rb +74 -0
- data/spec/support/pages/letters/form.rb +5 -3
- data/spec/support/shared_contexts/a_global_rule_set.rb +1 -1
- data/spec/support/xml_spec_helper.rb +9 -0
- metadata +60 -11
- data/app/views/renalware/api/ukrdc/patients/_clinical_relationships.xml.builder +0 -7
- data/app/views/renalware/api/ukrdc/patients/_family_histories.xml.builder +0 -7
- data/app/views/renalware/api/ukrdc/patients/_program_memberships.xml.builder +0 -7
- data/app/views/renalware/api/ukrdc/patients/_surveys.xml.builder +0 -7
- data/app/views/renalware/api/ukrdc/patients/observations/_blood_pressure.xml.builder +0 -0
- data/app/views/renalware/api/ukrdc/patients/observations/_standing_blood_pressure.xml.builder +0 -0
- data/app/views/renalware/api/ukrdc/patients/observations/_weight.xml.builder +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35b6c3d73ccaf2718acd3d48e5982b3453521ca161126690a51af0de3bb08733
|
4
|
+
data.tar.gz: e0fcdc5ade9caf2e87745953b7d6c060fabb96720ac90e8978618b36a48d31b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 645842282347e02444bdd310dc575b72137c3613139a7dee8543b21a085cd6437ec6b521aa66881f097ee17567a58048d118815926b81ca095b560cfe38b4a2c
|
7
|
+
data.tar.gz: 57b3894daa3d58de88660f763d8e4b4a61fb8cad3361210c6567d074d1b8c6ee71a75effaba63cb9ee0905aa9fce3b39d3d564e1de65bcc4ec8029d1833acf72
|
data/README.md
CHANGED
@@ -54,8 +54,9 @@ psql template1
|
|
54
54
|
At the psql prompt run the following (replacing `<username>` and `<password>` accordingly):
|
55
55
|
|
56
56
|
```sql
|
57
|
-
CREATE USER
|
58
|
-
ALTER USER
|
57
|
+
CREATE USER renalware WITH PASSWORD 'renalware';
|
58
|
+
ALTER USER renalware WITH SUPERUSER;
|
59
|
+
ALTER USER renalware WITH LOGIN;
|
59
60
|
```
|
60
61
|
|
61
62
|
### Configure Ruby
|
@@ -73,7 +73,7 @@ module Renalware
|
|
73
73
|
render :index, locals: locals
|
74
74
|
end
|
75
75
|
|
76
|
-
# rubocop:disable
|
76
|
+
# rubocop:disable Layout/LineLength
|
77
77
|
def render_prescriptions_list_to_hand_to_patient
|
78
78
|
render(
|
79
79
|
pdf_options.merge(
|
@@ -89,7 +89,7 @@ module Renalware
|
|
89
89
|
)
|
90
90
|
)
|
91
91
|
end
|
92
|
-
# rubocop:enable
|
92
|
+
# rubocop:enable Layout/LineLength
|
93
93
|
|
94
94
|
def pdf_filename
|
95
95
|
"#{patient.family_name}_#{patient.hospital_identifier&.id}" \
|
@@ -93,7 +93,7 @@ module Renalware
|
|
93
93
|
:nhs_number, :family_name, :given_name, :sex, :country_of_birth_id,
|
94
94
|
:ethnicity_id, :born_on, :paediatric_patient_indicator, :cc_on_all_letters,
|
95
95
|
:title, :suffix, :marital_status, :telephone1, :telephone2, :email, :religion_id,
|
96
|
-
:language_id, :cc_decision_on,
|
96
|
+
:language_id, :cc_decision_on, :next_of_kin,
|
97
97
|
:local_patient_id, :local_patient_id_2, :local_patient_id_3,
|
98
98
|
:local_patient_id_4, :local_patient_id_5, :external_patient_id,
|
99
99
|
:send_to_renalreg, :send_to_rpv, :renalreg_decision_on, :rpv_decision_on,
|
@@ -29,6 +29,11 @@ module Renalware
|
|
29
29
|
|
30
30
|
def call
|
31
31
|
letter.update_column(:page_count, pdf_reader.page_count)
|
32
|
+
rescue StandardError => e
|
33
|
+
# In Wisper async jobs, rescue_from blocks defined on the ApplicationJob class
|
34
|
+
# do not seem to be called, so we need to invoke them ourselves with this call to a fn on
|
35
|
+
# ActiveSupport::Rescuable which is already mixed into ActiveJob::Base.
|
36
|
+
rescue_with_handler(e) || raise
|
32
37
|
end
|
33
38
|
|
34
39
|
private
|
@@ -22,7 +22,7 @@ module Renalware
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
# rubocop:disable
|
25
|
+
# rubocop:disable Layout/LineLength
|
26
26
|
def shell_to_ghostscript_to_combine_files(filenames, dir, outputfile)
|
27
27
|
outputfile = Pathname(outputfile)
|
28
28
|
cmd = "gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=#{outputfile} -dBATCH #{filenames.join(' ')}"
|
@@ -35,7 +35,7 @@ module Renalware
|
|
35
35
|
raise "Error combining PDFs: #{[err, msg].join(' ')} command: #{cmd}"
|
36
36
|
end
|
37
37
|
end
|
38
|
-
# rubocop:enable
|
38
|
+
# rubocop:enable Layout/LineLength
|
39
39
|
|
40
40
|
def move_tempfile_to_output_file(tmp_outfile, output_file)
|
41
41
|
FileUtils.mv tmp_outfile.path, output_file
|
@@ -19,7 +19,9 @@ module Renalware
|
|
19
19
|
archive_recipients
|
20
20
|
sign(by: by)
|
21
21
|
archive_content(by: by)
|
22
|
-
|
22
|
+
# Cast the letter to the base Letter class in case it becomes a Letters::Completed
|
23
|
+
# before any async listeners have time to process it.
|
24
|
+
broadcast(:letter_approved, letter.becomes(Letters::Letter))
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
@@ -28,23 +28,15 @@ module Renalware
|
|
28
28
|
|
29
29
|
private
|
30
30
|
|
31
|
+
# Note we are already in a tx here from the letterlistener, so for safety we call
|
32
|
+
# call #deliver_later and not #deliver; its possible we could get a
|
33
|
+
# LetterIsNotApprovedOrCompletedError error in the mailer we and we don't want that to
|
34
|
+
# roll back the txn. We could possibly use an async Listener and remove the
|
35
|
+
# deliver_later here.
|
31
36
|
def email_letter_to_the_patients_practice
|
32
|
-
# Note we cast the letter back to the superclass Letters::Letter here to prevent
|
33
|
-
# GlobalID from trying to load the letter using e.g. Letters::Approved.find(123), because
|
34
|
-
# in the meantime the letter's class might have progressed to Letters::Completed in which
|
35
|
-
# case GlobalId/ ActiveJob would not be able to find the letter!
|
36
|
-
# Casting to Letters::Letter means in the delayed job the handler says e.g.
|
37
|
-
# - letter:
|
38
|
-
# _aj_globalid: gid://dummy/Renalware::Letters::Letter/3
|
39
|
-
# which it turns out works fine when the letter is loaded by GlobalId/ActiveJob;
|
40
|
-
# it correctly casts the letter to its STI type e.g. Letters::Approved in the job.
|
41
|
-
# Note we are already in a tx here from the letterlistener so if we for instance
|
42
|
-
# call deliver and not deliver_later, we will get a LetterIsNotApprovedOrCompletedError
|
43
|
-
# error when it looks up the letter as its approved state has not yet been saved.
|
44
|
-
# We could possibly use an async LetterListener and remove the async here.
|
45
37
|
Letter.transaction do
|
46
38
|
PracticeMailer.patient_letter(
|
47
|
-
letter: letter
|
39
|
+
letter: letter,
|
48
40
|
to: practice_email_address
|
49
41
|
).deliver_later # ! see comment
|
50
42
|
|
@@ -43,11 +43,11 @@ module Renalware
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def author_options
|
46
|
-
@author_options ||= User.author.
|
46
|
+
@author_options ||= User.author.picklist
|
47
47
|
end
|
48
48
|
|
49
49
|
def typist_options
|
50
|
-
@typist_options ||= User.
|
50
|
+
@typist_options ||= User.picklist
|
51
51
|
end
|
52
52
|
|
53
53
|
def letterhead_options
|
@@ -27,7 +27,7 @@ module Renalware
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
# rubocop:disable
|
30
|
+
# rubocop:disable Layout/LineLength
|
31
31
|
def shell_to_ghostscript_to_combine_files(filenames, dir, outputfile)
|
32
32
|
outputfile = Pathname(outputfile)
|
33
33
|
cmd = "gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=#{outputfile} -dBATCH #{filenames.join(' ')}"
|
@@ -40,7 +40,7 @@ module Renalware
|
|
40
40
|
raise "Error combining PDFs: #{[err, msg].join(' ')} command: #{cmd}"
|
41
41
|
end
|
42
42
|
end
|
43
|
-
# rubocop:enable
|
43
|
+
# rubocop:enable Layout/LineLength
|
44
44
|
|
45
45
|
def move_tempfile_to_output_file(tmp_outfile, output_file)
|
46
46
|
FileUtils.mv tmp_outfile.path, output_file
|
@@ -28,11 +28,19 @@ module Renalware
|
|
28
28
|
end
|
29
29
|
|
30
30
|
# For a ModalityDescription with type Renalware::HD::ModalityDescription
|
31
|
-
# this will return "
|
31
|
+
# this will return "hd"
|
32
32
|
def namespace
|
33
33
|
return if type.blank?
|
34
34
|
|
35
|
-
|
35
|
+
namespace_raw.underscore
|
36
|
+
end
|
37
|
+
|
38
|
+
# For a ModalityDescription with type Renalware::HD::ModalityDescription
|
39
|
+
# this will return "HD"
|
40
|
+
def namespace_raw
|
41
|
+
return if type.blank?
|
42
|
+
|
43
|
+
type.gsub("::", "").gsub(/^Renalware/, "").gsub(/ModalityDescription$/, "")
|
36
44
|
end
|
37
45
|
end
|
38
46
|
end
|
@@ -44,11 +44,11 @@ module Renalware
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
# rubocop:disable
|
47
|
+
# rubocop:disable Layout/LineLength
|
48
48
|
def glucose_for_bag(bag)
|
49
49
|
(((bag.volume.to_f * bag.days_per_week.to_f) / available_overnight_volume.to_f) * overnight_volume) / 7
|
50
50
|
end
|
51
|
-
# rubocop:enable
|
51
|
+
# rubocop:enable Layout/LineLength
|
52
52
|
|
53
53
|
def available_overnight_volume
|
54
54
|
@available_overnight_volume ||= AvailableOvernightVolume.new(regime: regime).value
|
@@ -20,11 +20,13 @@ module Renalware
|
|
20
20
|
|
21
21
|
private
|
22
22
|
|
23
|
+
# rubocop:disable Metrics/AbcSize
|
23
24
|
def update!(params)
|
24
25
|
User.transaction do
|
25
26
|
approve if can_approve?(params)
|
26
27
|
unexpire if can_unexpire?(params)
|
27
28
|
user.consultant = true?(params[:consultant])
|
29
|
+
user.hidden = true?(params[:hidden])
|
28
30
|
authorise(params)
|
29
31
|
user.telephone = params[:telephone]
|
30
32
|
user.save!
|
@@ -32,6 +34,7 @@ module Renalware
|
|
32
34
|
rescue ActiveRecord::RecordInvalid
|
33
35
|
false
|
34
36
|
end
|
37
|
+
# rubocop:enable Metrics/AbcSize
|
35
38
|
|
36
39
|
def notify!
|
37
40
|
notifications.each { |n| n.public_send(delivery_method) } if notifications.any?
|
@@ -10,7 +10,7 @@ module Renalware
|
|
10
10
|
# about them. Encrypt the xml files and copy to an outgoing folder
|
11
11
|
# which might for example be a symlink to an outgoing folder in /media/ukrdc which in turn
|
12
12
|
# is mount on a remote share for example on an SFTP server.
|
13
|
-
#
|
13
|
+
# rubocop:disable Metrics/ClassLength:
|
14
14
|
class CreateEncryptedPatientXMLFiles
|
15
15
|
attr_reader(
|
16
16
|
:patient_ids,
|
@@ -34,6 +34,7 @@ module Renalware
|
|
34
34
|
@force_send = force_send
|
35
35
|
end
|
36
36
|
|
37
|
+
# rubocop:disable Metrics/MethodLength
|
37
38
|
def call
|
38
39
|
logger.tagged(request_uuid) do
|
39
40
|
summary.milliseconds_taken = Benchmark.ms do
|
@@ -51,6 +52,7 @@ module Renalware
|
|
51
52
|
Engine.exception_notifier.notify(e)
|
52
53
|
raise e
|
53
54
|
end
|
55
|
+
# rubocop:enable Metrics/MethodLength
|
54
56
|
|
55
57
|
private
|
56
58
|
|
@@ -64,12 +66,20 @@ module Renalware
|
|
64
66
|
end
|
65
67
|
end
|
66
68
|
|
69
|
+
def schema
|
70
|
+
xsd_path = File.join(Renalware::Engine.root, "vendor/xsd/ukrdc/Schema/UKRDC.xsd")
|
71
|
+
xsddoc = Nokogiri::XML(File.read(xsd_path), xsd_path)
|
72
|
+
Nokogiri::XML::Schema.from_document(xsddoc)
|
73
|
+
end
|
74
|
+
|
75
|
+
# rubocop:disable Metrics/MethodLength
|
67
76
|
def create_patient_xml_files
|
68
77
|
count = 0
|
69
78
|
patients = ukrdc_patients_who_have_changed_since_last_send
|
70
79
|
summary.num_changed_patients = patients.count
|
71
80
|
patients.find_each do |patient|
|
72
81
|
count += 1
|
82
|
+
Rails.logger.info count
|
73
83
|
CreatePatientXMLFile.new(
|
74
84
|
patient: patient,
|
75
85
|
dir: paths.timestamped_xml_folder,
|
@@ -77,13 +87,15 @@ module Renalware
|
|
77
87
|
request_uuid: request_uuid,
|
78
88
|
batch_number: batch_number,
|
79
89
|
logger: logger,
|
80
|
-
force_send: force_send
|
90
|
+
force_send: force_send,
|
91
|
+
schema: schema
|
81
92
|
).call
|
82
93
|
|
83
94
|
# Every n patients, force the garbage collector to kick in
|
84
95
|
GC.start if (count % 10).zero?
|
85
96
|
end
|
86
97
|
end
|
98
|
+
# rubocop:enable Metrics/MethodLength
|
87
99
|
|
88
100
|
def build_summary
|
89
101
|
summary.count_of_files_in_outgoing_folder = count_of_files_in_outgoing_folder
|
@@ -115,14 +127,12 @@ module Renalware
|
|
115
127
|
end
|
116
128
|
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
117
129
|
|
118
|
-
# rubocop:disable Metrics/AbcSize
|
119
130
|
def print_summary
|
120
131
|
logger.info("Files saved to #{summary.archive_folder}")
|
121
132
|
logger.info "*** Summary ***"
|
122
133
|
logger.info "Took #{summary.milliseconds_taken.to_i / 1000} seconds"
|
123
134
|
summary.results.map { |key, value| logger.info("#{key}: #{value}") }
|
124
135
|
end
|
125
|
-
# rubocop:enable Metrics/AbcSize
|
126
136
|
|
127
137
|
def email_summary
|
128
138
|
UKRDC::SummaryMailer.export_summary(
|
@@ -166,5 +176,6 @@ module Renalware
|
|
166
176
|
)
|
167
177
|
end
|
168
178
|
end
|
179
|
+
# rubocop:enable Metrics/ClassLength:
|
169
180
|
end
|
170
181
|
end
|
@@ -10,6 +10,7 @@ module Renalware
|
|
10
10
|
:patient!,
|
11
11
|
:dir!,
|
12
12
|
:request_uuid!,
|
13
|
+
:schema,
|
13
14
|
:changes_since,
|
14
15
|
:logger,
|
15
16
|
:batch_number,
|
@@ -18,7 +19,7 @@ module Renalware
|
|
18
19
|
:force_send
|
19
20
|
]
|
20
21
|
|
21
|
-
# rubocop:disable Metrics/AbcSize
|
22
|
+
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
22
23
|
# If force_send is true then send all files even if they have not changed since the last
|
23
24
|
# send. This is primarily for debugging and testing phases with UKRDC
|
24
25
|
def call
|
@@ -39,7 +40,7 @@ module Renalware
|
|
39
40
|
logger.info " Status: #{log.status}"
|
40
41
|
end
|
41
42
|
end
|
42
|
-
# rubocop:enable Metrics/AbcSize
|
43
|
+
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
43
44
|
|
44
45
|
private
|
45
46
|
|
@@ -101,8 +102,20 @@ module Renalware
|
|
101
102
|
nil
|
102
103
|
end
|
103
104
|
|
105
|
+
def schema
|
106
|
+
@schema ||= begin
|
107
|
+
Rails.logger.info "Creating Nokogiri::XML::Schema"
|
108
|
+
xsd_path = File.join(Renalware::Engine.root, "vendor/xsd/ukrdc/Schema/UKRDC.xsd")
|
109
|
+
xsddoc = Nokogiri::XML(File.read(xsd_path), xsd_path)
|
110
|
+
Nokogiri::XML::Schema.from_document(xsddoc)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
104
114
|
def default_renderer
|
105
|
-
Renalware::UKRDC::XmlRenderer.new(
|
115
|
+
Renalware::UKRDC::XmlRenderer.new(
|
116
|
+
schema: schema,
|
117
|
+
locals: { patient: presenter_for(patient) }
|
118
|
+
)
|
106
119
|
end
|
107
120
|
|
108
121
|
def presenter_for(patient)
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Renalware
|
4
|
+
module UKRDC
|
5
|
+
module Outgoing
|
6
|
+
module Rendering
|
7
|
+
class Address < Rendering::Base
|
8
|
+
pattr_initialize [:address!]
|
9
|
+
|
10
|
+
def xml
|
11
|
+
address_element
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def address_element
|
17
|
+
create_node("Address") do |elem|
|
18
|
+
elem[:use] = "H"
|
19
|
+
elem << create_node("Street", address.street)
|
20
|
+
elem << create_node("Town", address.town)
|
21
|
+
elem << create_node("County", address.county)
|
22
|
+
elem << create_node("Postcode", address.postcode&.strip)
|
23
|
+
elem << country_element
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def country_element
|
28
|
+
create_node("Country") do |elem|
|
29
|
+
elem << create_node(:CodingStandard, "ISO3166-1")
|
30
|
+
elem << create_node(:Code, address&.country&.alpha3)
|
31
|
+
elem << create_node(:Description, address&.country&.to_s)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Renalware
|
4
|
+
module UKRDC
|
5
|
+
module Outgoing
|
6
|
+
module Rendering
|
7
|
+
class Allergy < Rendering::Base
|
8
|
+
pattr_initialize [:allergy!]
|
9
|
+
|
10
|
+
def xml
|
11
|
+
allergy_element
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def allergy_element
|
17
|
+
create_node("Allergy") do |elem|
|
18
|
+
create_node("Allergy") # this is correct, see schema
|
19
|
+
elem << Rendering::Clinician.new(user: allergy.updated_by).xml
|
20
|
+
elem << create_node("FreeTextAllergy", allergy.description)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|