roqua-healthy 1.5.9 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.document +0 -0
  3. data/.gitlab-ci.yml +11 -5
  4. data/.rspec +0 -0
  5. data/.rubocop.yml +7 -1
  6. data/.yardopts +0 -0
  7. data/Appraisals +7 -6
  8. data/ChangeLog.md +18 -0
  9. data/Guardfile +1 -1
  10. data/LICENSE.txt +0 -0
  11. data/Rakefile +0 -0
  12. data/circle.yml +0 -0
  13. data/gemfiles/rails52.gemfile +10 -0
  14. data/gemfiles/rails60.gemfile +9 -0
  15. data/gemfiles/rails61.gemfile +9 -0
  16. data/lib/roqua/healthy/a19.rb +0 -0
  17. data/lib/roqua/healthy/a19/address_parser.rb +10 -2
  18. data/lib/roqua/healthy/a19/correct_patient_check.rb +0 -0
  19. data/lib/roqua/healthy/a19/fetcher.rb +1 -2
  20. data/lib/roqua/healthy/a19/impulse_name_parser.rb +0 -0
  21. data/lib/roqua/healthy/a19/name_parser.rb +0 -0
  22. data/lib/roqua/healthy/a19/phone_parser.rb +18 -11
  23. data/lib/roqua/healthy/a19/phone_validator.rb +1 -1
  24. data/lib/roqua/healthy/a19/response_parser.rb +0 -0
  25. data/lib/roqua/healthy/a19/response_validator.rb +11 -13
  26. data/lib/roqua/healthy/a19/transformer.rb +19 -19
  27. data/lib/roqua/healthy/message_cleaner.rb +0 -0
  28. data/lib/roqua/healthy/oru/client.rb +0 -1
  29. data/lib/roqua/healthy/version.rb +1 -1
  30. data/lib/roqua_healthy.rb +0 -0
  31. data/roqua-healthy.gemspec +5 -6
  32. data/spec/fixtures/comez_patient.xml +0 -0
  33. data/spec/fixtures/ggzwnb_patient.xml +0 -0
  34. data/spec/fixtures/oru-requests/spsy1218j.hl7 +0 -0
  35. data/spec/fixtures/oru-requests/spsy1218o.hl7 +0 -0
  36. data/spec/fixtures/oru-requests/spsy1218o2.hl7 +0 -0
  37. data/spec/fixtures/oru-requests/spsy411o.hl7 +0 -0
  38. data/spec/fixtures/oru-requests/spsy411o2.hl7 +0 -0
  39. data/spec/fixtures/oru-requests/spsyl.hl7 +0 -0
  40. data/spec/fixtures/oru-responses/xmcare_nack.hl7 +0 -0
  41. data/spec/fixtures/user_patient.xml +0 -0
  42. data/spec/fixtures/user_patient_not_found.xml +0 -0
  43. data/spec/fixtures/user_patient_with_gsm_and_email.xml +0 -0
  44. data/spec/fixtures/user_patient_with_maiden_name.xml +0 -0
  45. data/spec/fixtures/xmcare_house_number_addendum.xml +335 -0
  46. data/spec/fixtures/xmcare_missing_whole_pids.xml +162 -0
  47. data/spec/fixtures/xmcare_patient.xml +0 -0
  48. data/spec/fixtures/xmcare_patient_email_in_field_number_four.xml +0 -0
  49. data/spec/fixtures/xmcare_patient_not_found.xml +0 -0
  50. data/spec/fixtures/xmcare_patient_with_maiden_name.xml +0 -0
  51. data/spec/fixtures/xmcare_patient_without_birthdate.xml +0 -0
  52. data/spec/fixtures/xmcare_phone_cell_in_prn.xml +0 -0
  53. data/spec/fixtures/xmcare_phone_cell_in_prn_orn.xml +0 -0
  54. data/spec/fixtures/xmcare_phone_home_in_prn.xml +0 -0
  55. data/spec/fixtures/xmcare_timeout_waiting_for_ack.xml +0 -0
  56. data/spec/fixtures/xmcare_unconventional_phone_cell_in_orn.xml +0 -0
  57. data/spec/fixtures/xmcare_unconventional_phone_cell_in_orn2.xml +0 -0
  58. data/spec/healthy_spec.rb +0 -0
  59. data/spec/integration/xmcare_spec.rb +18 -0
  60. data/spec/spec_helper.rb +0 -0
  61. data/spec/support/fixtures.rb +0 -0
  62. data/spec/unit/a19/address_parser_spec.rb +49 -0
  63. data/spec/unit/a19/correct_patient_check_spec.rb +0 -0
  64. data/spec/unit/a19/phone_parser_spec.rb +7 -0
  65. data/spec/unit/a19_spec.rb +0 -0
  66. data/spec/unit/message_cleaner_spec.rb +0 -0
  67. data/spec/unit/oru/client_spec.rb +2 -2
  68. metadata +31 -36
  69. data/gemfiles/rails41.gemfile +0 -8
  70. data/gemfiles/rails42.gemfile +0 -8
  71. data/gemfiles/rails50.gemfile +0 -8
  72. data/lib/roqua/errors.rb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd1dc3e8ce6e055eaa889059f77e2d31c85cdb304610f897488fe5b62aaad19c
4
- data.tar.gz: 7c51e0e0f982adc0085d05a5cb71234fa71a039b9244e060446e73c3d30e3437
3
+ metadata.gz: 676e3d78e93d705fbf01f1e7eb726ca8c250b64fb7e226262b8bebd9d4ca540d
4
+ data.tar.gz: 5a5eac93225350b7446eaf8c3c22f29d53d3673437488fe04e4c8d8b9ccc25ca
5
5
  SHA512:
6
- metadata.gz: 46c3a927a35d6ebd92be5a3342774dd9cfc421e4fee5d2200998c36b886b6795bc9cd31f3ba106d21361ac947ad97f29a65d731397f04fb6cc6a1ab93ce1e163
7
- data.tar.gz: af5d642130dff9324205ee27c33591fbc21fd2fbf8963127f13fbb4abbed39f572530cb3c8442d82c691bf679bf6b6e3881b4821456d5201186e0b2efeb6e624
6
+ metadata.gz: 7b54a9724e9035399b542b8d034cde91808a32938293c1da699dc1ab9d5ba626bc5a56bc0afc047fc1989b12e307e728562abc87d1d04147691791327f99a01b
7
+ data.tar.gz: d992da02d82847037d5881ead65ee81281ccc1a1eb111f44b5f68600f26c6af31e31f0b5acf2304fba34bf48db98dfe8bf44f9dd90188bbcb972a955ad4509c0
data/.document CHANGED
File without changes
data/.gitlab-ci.yml CHANGED
@@ -1,4 +1,4 @@
1
- image: "registry.roqua.nl/roqua/docker-base-images:ruby-2.5"
1
+ image: "registry.roqua.nl/roqua/docker-base-images:ruby-2.7-builder"
2
2
 
3
3
  cache:
4
4
  paths:
@@ -15,8 +15,14 @@ rubocop:
15
15
  script:
16
16
  - bundle exec rubocop -D
17
17
 
18
- rspec:
18
+ rails52:
19
19
  script:
20
- - bundle exec appraisal rails41 bundle exec rspec
21
- - bundle exec appraisal rails42 bundle exec rspec
22
- - bundle exec appraisal rails50 bundle exec rspec
20
+ - bundle exec appraisal rails52 bundle exec rspec
21
+
22
+ rails60:
23
+ script:
24
+ - bundle exec appraisal rails60 bundle exec rspec
25
+
26
+ rails61:
27
+ script:
28
+ - bundle exec appraisal rails61 bundle exec rspec
data/.rspec CHANGED
File without changes
data/.rubocop.yml CHANGED
@@ -4,7 +4,7 @@ AllCops:
4
4
  Exclude:
5
5
  - vendor/**/*
6
6
  - gemfiles/*
7
- TargetRubyVersion: 2.3
7
+ TargetRubyVersion: 2.6
8
8
 
9
9
  Documentation:
10
10
  Enabled: false
@@ -27,7 +27,13 @@ SignalException:
27
27
  Layout/EmptyLineAfterMagicComment:
28
28
  Enabled: False
29
29
 
30
+ Layout/EmptyLineBetweenDefs:
31
+ AllowAdjacentOneLineDefs: true
32
+
30
33
  Naming/FileName:
31
34
  Exclude:
32
35
  - Appraisals
33
36
 
37
+ # No, I don't want to call my exceptions 'e' instead of 'exception' or 'error'.
38
+ Naming/RescuedExceptionsVariableName:
39
+ Enabled: false
data/.yardopts CHANGED
File without changes
data/Appraisals CHANGED
@@ -1,13 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- appraise "rails41" do
4
- gem "activesupport", "4.1"
3
+ appraise "rails52" do
4
+ gem "activesupport", "5.2"
5
+ gem "roqua-support", "~> 0.3.0"
5
6
  end
6
7
 
7
- appraise "rails42" do
8
- gem "activesupport", "4.2"
8
+ appraise "rails60" do
9
+ gem "activesupport", "6.0"
9
10
  end
10
11
 
11
- appraise "rails50" do
12
- gem "activesupport", "5.0"
12
+ appraise "rails61" do
13
+ gem "activesupport", "6.1"
13
14
  end
data/ChangeLog.md CHANGED
@@ -1,3 +1,21 @@
1
+ ### 1.6.0
2
+
3
+ * ActiveSupport 6.1 support
4
+ * Removed ActiveSupport 4.1, 4.2, 5.0 and 5.1
5
+ * Add roqua_support 0.4 support.
6
+
7
+ ### 1.5.12
8
+
9
+ * ActiveSupport 6.0 support
10
+
11
+ ### 1.5.11
12
+
13
+ * Support for PID.11 and PID.13 completely missing from an hl7 response.
14
+
15
+ ### 1.5.10
16
+
17
+ * Support for house number suffices in PID 11.2
18
+
1
19
  ### 1.5.9
2
20
 
3
21
  * Ruby 2.5 support
data/Guardfile CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- guard 'rspec', cmd: 'bundle exec rspec -f Fuubar' do
2
+ guard 'rspec', cmd: 'bundle exec rspec' do
3
3
  watch(%r{^spec/.+_spec\.rb$})
4
4
  watch(%r{^lib/healthy/(.+)\.rb$}) { |m| ["spec/unit/#{m[1]}_spec.rb", "spec/integration"] }
5
5
  watch('spec/spec_helper.rb') { "spec" }
data/LICENSE.txt CHANGED
File without changes
data/Rakefile CHANGED
File without changes
data/circle.yml CHANGED
File without changes
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "codeclimate-test-reporter", "~> 1.0.0", group: :test, require: nil
6
+ gem "roqua_styleguide", git: "https://gitlab.roqua.nl/roqua/styleguide.git"
7
+ gem "activesupport", "5.2"
8
+ gem "roqua-support", "~> 0.3.0"
9
+
10
+ gemspec path: "../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "codeclimate-test-reporter", "~> 1.0.0", group: :test, require: nil
6
+ gem "roqua_styleguide", git: "https://gitlab.roqua.nl/roqua/styleguide.git"
7
+ gem "activesupport", "6.0"
8
+
9
+ gemspec path: "../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "codeclimate-test-reporter", "~> 1.0.0", group: :test, require: nil
6
+ gem "roqua_styleguide", git: "https://gitlab.roqua.nl/roqua/styleguide.git"
7
+ gem "activesupport", "6.1"
8
+
9
+ gemspec path: "../"
File without changes
@@ -16,7 +16,15 @@ module Roqua
16
16
 
17
17
  def street
18
18
  return nil if record.blank? || record.fetch('PID.11.1').blank?
19
- record.fetch('PID.11.1').fetch('PID.11.1.1')
19
+
20
+ street = record.fetch('PID.11.1').fetch('PID.11.1.1')
21
+ suffix = record.fetch('PID.11.2', nil)
22
+
23
+ if suffix.present? && !street.end_with?(suffix)
24
+ street + suffix
25
+ else
26
+ street
27
+ end
20
28
  end
21
29
 
22
30
  def city
@@ -50,7 +58,7 @@ module Roqua
50
58
  private
51
59
 
52
60
  def get_address_of_type(message, type)
53
- message.fetch('PID').fetch('PID.11').find do |record|
61
+ message.dig('PID', 'PID.11')&.find do |record|
54
62
  record.fetch('PID.11.7', :unknown_type_of_address_record) == type
55
63
  end
56
64
  end
File without changes
@@ -9,8 +9,7 @@ module Roqua
9
9
  module Healthy
10
10
  module A19
11
11
  class Fetcher
12
- attr_reader :patient_id
13
- attr_reader :client
12
+ attr_reader :client, :patient_id
14
13
 
15
14
  def initialize(patient_id, client)
16
15
  @patient_id = patient_id
File without changes
File without changes
@@ -11,26 +11,33 @@ module Roqua
11
11
 
12
12
  # this is a heuristic to pick likely dutch cell phone numbers from hl7 messages
13
13
  def to_s
14
- pid13 = message.fetch('PID').fetch('PID.13')
15
-
16
14
  # prefer PRN (Primary Residence Number) that contains a cell phone number
17
- phone_cell_record = pid13.find do |record|
18
- phone_cell_number?(record.fetch('PID.13.1', '') || '') &&
19
- record.fetch('PID.13.2', :unknown_type_of_phone_record) == 'PRN'
20
- end
21
-
22
15
  # otherwise choose the first occuring cell phone number
23
- phone_cell_record ||= pid13.find do |record|
24
- phone_cell_number?(record.fetch('PID.13.1', '') || '')
25
- end
26
-
27
16
  # any number for which phone_cell_number? returns false is ignored
17
+ phone_cell_record = first_matching_prn_record || first_matching_record
28
18
 
29
19
  strip_non_phone_number_characters(phone_cell_record.fetch('PID.13.1')) if phone_cell_record.present?
30
20
  end
31
21
 
32
22
  private
33
23
 
24
+ def pid13
25
+ @pid13 ||= message.dig('PID', 'PID.13') || []
26
+ end
27
+
28
+ def first_matching_prn_record
29
+ pid13.find do |record|
30
+ phone_cell_number?(record.fetch('PID.13.1', '') || '') &&
31
+ record.fetch('PID.13.2', :unknown_type_of_phone_record) == 'PRN'
32
+ end
33
+ end
34
+
35
+ def first_matching_record
36
+ pid13.find do |record|
37
+ phone_cell_number?(record.fetch('PID.13.1', '') || '')
38
+ end
39
+ end
40
+
34
41
  def strip_non_phone_number_characters(number)
35
42
  Roqua::Healthy::A19::PhoneValidator.strip_non_phone_number_characters number
36
43
  end
@@ -28,7 +28,7 @@ module Roqua
28
28
  end
29
29
 
30
30
  def self.strip_non_phone_number_characters(number)
31
- number.gsub(/[-\s\.]/, '')
31
+ number.gsub(/[-\s.]/, '')
32
32
  end
33
33
  end
34
34
  end
File without changes
@@ -7,9 +7,7 @@ module Roqua
7
7
  class ResponseValidator
8
8
  require 'roqua/healthy/errors'
9
9
 
10
- attr_reader :response_code
11
- attr_reader :parser
12
- attr_reader :patient_id
10
+ attr_reader :parser, :patient_id, :response_code
13
11
 
14
12
  def initialize(response_code, parser, patient_id)
15
13
  @response_code = response_code
@@ -20,41 +18,41 @@ module Roqua
20
18
  def validate
21
19
  case response_code
22
20
  when '200'
23
- validate_200
21
+ validate200
24
22
  when '401', '403'
25
- validate_403
23
+ validate403
26
24
  when '404'
27
- validate_404
25
+ validate404
28
26
  when '500'
29
- validate_500
27
+ validate500
30
28
  else
31
29
  raise ::Roqua::Healthy::UnknownFailure, "Unexpected HTTP response code #{response_code}."
32
30
  end
33
31
  end
34
32
 
35
- def validate_200
33
+ private
34
+
35
+ def validate200
36
36
  parsed_message = parser.fetch("HL7Message")
37
37
  ensure_patient_found(parsed_message)
38
38
  ensure_correct_patient(parsed_message)
39
39
  true
40
40
  end
41
41
 
42
- def validate_403
42
+ def validate403
43
43
  raise ::Roqua::Healthy::AuthenticationFailure
44
44
  end
45
45
 
46
- def validate_404
46
+ def validate404
47
47
  raise ::Roqua::Healthy::PatientNotFound
48
48
  end
49
49
 
50
- def validate_500
50
+ def validate500
51
51
  error = parser.fetch('failure')['error']
52
52
  raise ::Roqua::Healthy::ERRORS[error], error if ::Roqua::Healthy::ERRORS[error]
53
53
  raise ::Roqua::Healthy::UnknownFailure, error
54
54
  end
55
55
 
56
- private
57
-
58
56
  def ensure_patient_found(parsed_message)
59
57
  raise ::Roqua::Healthy::PatientNotFound if parsed_message.key?("ERR") && parsed_message.fetch("ERR").fetch("ERR.1").fetch("ERR.1.4").fetch("ERR.1.4.2") =~ /Patient \(@\) niet gevonden\(.*\)/
60
58
  raise ::Roqua::Healthy::PatientNotFound if parsed_message.key?("QAK") && parsed_message.fetch("QAK").fetch("QAK.2").fetch("QAK.2.1") == "NF"
@@ -19,33 +19,33 @@ module Roqua
19
19
  raise ::Roqua::Healthy::PatientNotFound unless message['PID'].present?
20
20
  message['PID']['PID.3'] = [message.fetch('PID').fetch('PID.3')].flatten.compact
21
21
  message['PID']['PID.5'] = [message.fetch('PID').fetch('PID.5')].flatten.compact
22
- message['PID']['PID.11'] = [message.fetch('PID').fetch('PID.11')].flatten.compact
23
- message['PID']['PID.13'] = [message.fetch('PID').fetch('PID.13')].flatten.compact
22
+ message['PID']['PID.11'] = [message.dig('PID', 'PID.11')].flatten.compact
23
+ message['PID']['PID.13'] = [message.dig('PID', 'PID.13')].flatten.compact
24
24
  @message = MessageCleaner.new(message).message
25
25
  end
26
26
 
27
27
  # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
28
28
  def to_patient
29
29
  {
30
- status: status,
31
- source: source,
32
- identities: identities,
33
- firstname: name.firstname,
34
- initials: name.initials,
35
- lastname: name.lastname,
30
+ status: status,
31
+ source: source,
32
+ identities: identities,
33
+ firstname: name.firstname,
34
+ initials: name.initials,
35
+ lastname: name.lastname,
36
36
  display_name: name.display_name,
37
- nickname: name.nickname,
38
- email: email,
37
+ nickname: name.nickname,
38
+ email: email,
39
39
  address_type: address.address_type,
40
- street: address.street,
41
- city: address.city,
42
- zipcode: address.zipcode,
43
- country: address.country,
44
- birthdate: birthdate,
45
- gender: gender,
46
- phone_cell: phone_cell,
47
- medoq_data: medoq_data,
48
- deceased: deceased
40
+ street: address.street,
41
+ city: address.city,
42
+ zipcode: address.zipcode,
43
+ country: address.country,
44
+ birthdate: birthdate,
45
+ gender: gender,
46
+ phone_cell: phone_cell,
47
+ medoq_data: medoq_data,
48
+ deceased: deceased
49
49
  }
50
50
  end
51
51
  # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
File without changes
@@ -22,7 +22,6 @@ module Roqua
22
22
  headers: {content_type: 'text/xml'},
23
23
  timeout: timeout.to_i
24
24
  ) do |response, _request, _result|
25
-
26
25
  xml_response = Hash.from_xml(response.body)
27
26
 
28
27
  if response.code == 200 && xml_response['oru']['status'] == 'ACK'
@@ -2,6 +2,6 @@
2
2
  module Roqua
3
3
  module Healthy
4
4
  # healthy version
5
- VERSION = "1.5.9"
5
+ VERSION = "1.6.0"
6
6
  end
7
7
  end
data/lib/roqua_healthy.rb CHANGED
File without changes
@@ -13,19 +13,19 @@ Gem::Specification.new do |gem|
13
13
  gem.email = "support@roqua.nl"
14
14
  gem.homepage = "https://github.com/roqua/healthy"
15
15
 
16
- gem.required_ruby_version = '~> 2.3'
16
+ gem.required_ruby_version = '>= 2.6'
17
17
 
18
18
  gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
19
19
  gem.executables = [] # executables in bin/ are helpers for use during development
20
20
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
21
21
  gem.require_paths = ['lib']
22
22
 
23
- gem.add_dependency 'activesupport', '>= 3.2', '< 6'
23
+ gem.add_dependency 'activesupport', '>= 5.1', '< 6.2'
24
24
  gem.add_dependency 'addressable', '~> 2.3'
25
25
  gem.add_dependency 'builder'
26
26
  gem.add_dependency 'phonelib', '~> 0.6'
27
27
  gem.add_dependency 'rest-client', '>= 2.0.2'
28
- gem.add_dependency 'roqua-support', '~> 0.3.0'
28
+ gem.add_dependency 'roqua-support', '>= 0.3.0', '< 0.5.0'
29
29
 
30
30
  gem.add_development_dependency 'appraisal'
31
31
  gem.add_development_dependency 'bundler'
@@ -37,10 +37,9 @@ Gem::Specification.new do |gem|
37
37
  gem.add_development_dependency 'webmock', '~> 3.2'
38
38
 
39
39
  # Workflow and tools
40
- gem.add_development_dependency 'fuubar'
41
40
  gem.add_development_dependency 'guard', '~> 2.1'
42
- gem.add_development_dependency 'guard-rspec', '~> 4.2.4'
43
- gem.add_development_dependency 'guard-rubocop', '~> 1.2.0'
41
+ gem.add_development_dependency 'guard-rspec', '~> 4.2'
42
+ gem.add_development_dependency 'guard-rubocop', '~> 1.2'
44
43
  gem.add_development_dependency 'listen', '~> 2.1'
45
44
  gem.add_development_dependency 'simplecov'
46
45