Class: MPI::Messages::AddPersonProxyAddMessage
- Inherits:
-
Object
- Object
- MPI::Messages::AddPersonProxyAddMessage
- Defined in:
- lib/mpi/messages/add_person_proxy_add_message.rb
Instance Attribute Summary collapse
-
#birth_date ⇒ Object
readonly
Returns the value of attribute birth_date.
-
#edipi ⇒ Object
readonly
Returns the value of attribute edipi.
-
#first_name ⇒ Object
readonly
Returns the value of attribute first_name.
-
#icn ⇒ Object
readonly
Returns the value of attribute icn.
-
#last_name ⇒ Object
readonly
Returns the value of attribute last_name.
-
#search_token ⇒ Object
readonly
Returns the value of attribute search_token.
-
#ssn ⇒ Object
readonly
Returns the value of attribute ssn.
Instance Method Summary collapse
- #build_assigned_person ⇒ Object private
- #build_body ⇒ Object private
- #build_data_enterer ⇒ Object private
- #build_patient ⇒ Object private
- #build_patient_person ⇒ Object private
- #build_registration_event ⇒ Object private
- #build_subject ⇒ Object private
- #build_subject_1 ⇒ Object private
- #icn_root ⇒ Object private
- #icn_with_aaid ⇒ Object private
-
#initialize(first_name:, last_name:, ssn:, birth_date:, edipi:, icn:, search_token:) ⇒ AddPersonProxyAddMessage
constructor
rubocop:disable Metrics/ParameterLists.
- #null_flavor_type ⇒ Object private
-
#perform ⇒ Object
rubocop:enable Metrics/ParameterLists.
- #ssn_class_code ⇒ Object private
- #ssn_root ⇒ Object private
- #validate_required_fields ⇒ Object private
Constructor Details
#initialize(first_name:, last_name:, ssn:, birth_date:, edipi:, icn:, search_token:) ⇒ AddPersonProxyAddMessage
rubocop:disable Metrics/ParameterLists
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/mpi/messages/add_person_proxy_add_message.rb', line 13 def initialize(first_name:, last_name:, ssn:, birth_date:, edipi:, icn:, search_token:) @first_name = first_name @last_name = last_name @ssn = ssn @icn = icn @birth_date = birth_date @edipi = edipi @search_token = search_token end |
Instance Attribute Details
#birth_date ⇒ Object (readonly)
Returns the value of attribute birth_date.
10 11 12 |
# File 'lib/mpi/messages/add_person_proxy_add_message.rb', line 10 def birth_date @birth_date end |
#edipi ⇒ Object (readonly)
Returns the value of attribute edipi.
10 11 12 |
# File 'lib/mpi/messages/add_person_proxy_add_message.rb', line 10 def edipi @edipi end |
#first_name ⇒ Object (readonly)
Returns the value of attribute first_name.
10 11 12 |
# File 'lib/mpi/messages/add_person_proxy_add_message.rb', line 10 def first_name @first_name end |
#icn ⇒ Object (readonly)
Returns the value of attribute icn.
10 11 12 |
# File 'lib/mpi/messages/add_person_proxy_add_message.rb', line 10 def icn @icn end |
#last_name ⇒ Object (readonly)
Returns the value of attribute last_name.
10 11 12 |
# File 'lib/mpi/messages/add_person_proxy_add_message.rb', line 10 def last_name @last_name end |
#search_token ⇒ Object (readonly)
Returns the value of attribute search_token.
10 11 12 |
# File 'lib/mpi/messages/add_person_proxy_add_message.rb', line 10 def search_token @search_token end |
#ssn ⇒ Object (readonly)
Returns the value of attribute ssn.
10 11 12 |
# File 'lib/mpi/messages/add_person_proxy_add_message.rb', line 10 def ssn @ssn end |
Instance Method Details
#build_assigned_person ⇒ Object (private)
67 68 69 70 71 72 73 |
# File 'lib/mpi/messages/add_person_proxy_add_message.rb', line 67 def build_assigned_person element = RequestHelper.build_assigned_person_element element << RequestHelper.build_identifier(identifier: icn_with_aaid, root: icn_root) element << RequestHelper.build_assigned_person_instance(given_names: [first_name], family_name: last_name) element << RequestHelper.build_represented_organization(edipi:) element end |
#build_body ⇒ Object (private)
54 55 56 57 58 59 |
# File 'lib/mpi/messages/add_person_proxy_add_message.rb', line 54 def build_body element = RequestHelper.build_control_act_process_element element << build_data_enterer element << build_subject element end |
#build_data_enterer ⇒ Object (private)
61 62 63 64 65 |
# File 'lib/mpi/messages/add_person_proxy_add_message.rb', line 61 def build_data_enterer element = RequestHelper.build_data_enterer_element element << build_assigned_person element end |
#build_patient ⇒ Object (private)
96 97 98 99 100 101 102 103 |
# File 'lib/mpi/messages/add_person_proxy_add_message.rb', line 96 def build_patient element = RequestHelper.build_patient_element element << RequestHelper.build_identifier(identifier: icn_with_aaid, root: icn_root) element << RequestHelper.build_status_code element << build_patient_person element << RequestHelper.build_provider_organization element end |
#build_patient_person ⇒ Object (private)
105 106 107 108 109 110 111 112 |
# File 'lib/mpi/messages/add_person_proxy_add_message.rb', line 105 def build_patient_person element = RequestHelper.build_patient_person_element element << RequestHelper.build_patient_person_name(given_names: [first_name], family_name: last_name) element << RequestHelper.build_patient_person_birth_date(birth_date:) element << RequestHelper.build_patient_identifier(identifier: ssn, root: ssn_root, class_code: ssn_class_code) element << RequestHelper.build_patient_person_proxy_add element end |
#build_registration_event ⇒ Object (private)
81 82 83 84 85 86 87 88 |
# File 'lib/mpi/messages/add_person_proxy_add_message.rb', line 81 def build_registration_event element = RequestHelper.build_registration_event_element element << RequestHelper.build_id_null_flavor(type: null_flavor_type) element << RequestHelper.build_status_code element << build_subject_1 element << RequestHelper.build_custodian element end |
#build_subject ⇒ Object (private)
75 76 77 78 79 |
# File 'lib/mpi/messages/add_person_proxy_add_message.rb', line 75 def build_subject element = RequestHelper.build_subject_element element << build_registration_event element end |
#build_subject_1 ⇒ Object (private)
90 91 92 93 94 |
# File 'lib/mpi/messages/add_person_proxy_add_message.rb', line 90 def build_subject_1 element = RequestHelper.build_subject_1_element element << build_patient element end |
#icn_root ⇒ Object (private)
130 131 132 |
# File 'lib/mpi/messages/add_person_proxy_add_message.rb', line 130 def icn_root MPI::Constants::VA_ROOT_OID end |
#icn_with_aaid ⇒ Object (private)
118 119 120 |
# File 'lib/mpi/messages/add_person_proxy_add_message.rb', line 118 def icn_with_aaid "#{icn}^NI^200M^USVHA^P" end |
#null_flavor_type ⇒ Object (private)
114 115 116 |
# File 'lib/mpi/messages/add_person_proxy_add_message.rb', line 114 def null_flavor_type 'NA' end |
#perform ⇒ Object
rubocop:enable Metrics/ParameterLists
30 31 32 33 34 35 36 37 38 |
# File 'lib/mpi/messages/add_person_proxy_add_message.rb', line 30 def perform validate_required_fields MPI::Messages::RequestBuilder.new(extension: MPI::Constants::ADD_PERSON, body: build_body, search_token:).perform rescue => e Rails.logger.error "[AddPersonProxyAddMessage] Failed to build request: #{e.}" raise e end |
#ssn_class_code ⇒ Object (private)
126 127 128 |
# File 'lib/mpi/messages/add_person_proxy_add_message.rb', line 126 def ssn_class_code 'SSN' end |
#ssn_root ⇒ Object (private)
122 123 124 |
# File 'lib/mpi/messages/add_person_proxy_add_message.rb', line 122 def ssn_root '2.16.840.1.113883.4.1' end |
#validate_required_fields ⇒ Object (private)
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/mpi/messages/add_person_proxy_add_message.rb', line 42 def validate_required_fields missing_values = [] missing_values << :first_name if first_name.blank? missing_values << :last_name if last_name.blank? missing_values << :ssn if ssn.blank? missing_values << :birth_date if birth_date.blank? missing_values << :icn if icn.blank? missing_values << :edipi if edipi.blank? missing_values << :search_token if search_token.blank? raise Errors::ArgumentError, "Required values missing: #{missing_values}" if missing_values.present? end |