Class: MPI::Messages::RequestHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/mpi/messages/request_helper.rb

Class Method Summary collapse

Class Method Details

.build_assigned_person_elementObject



79
80
81
# File 'lib/mpi/messages/request_helper.rb', line 79

def build_assigned_person_element
  element('assignedPerson', classCode: 'ASSIGNED')
end

.build_assigned_person_instance(given_names:, family_name:) ⇒ Object



64
65
66
67
68
69
70
71
72
73
# File 'lib/mpi/messages/request_helper.rb', line 64

def build_assigned_person_instance(given_names:, family_name:)
  name_element = element('name')
  given_names.each do |given_name|
    name_element << text_element('given', given_name)
  end
  name_element << text_element('family', family_name)
  assigned_person_instance = element('assignedPerson', classCode: 'PSN', determinerCode: 'INSTANCE')
  assigned_person_instance << name_element
  assigned_person_instance
end

.build_assigned_person_ssn(ssn:) ⇒ Object



83
84
85
# File 'lib/mpi/messages/request_helper.rb', line 83

def build_assigned_person_ssn(ssn:)
  build_identifier(identifier: ssn, root: '2.16.840.1.113883.777.999')
end

.build_birth_date(birth_date:) ⇒ Object



23
24
25
26
27
28
# File 'lib/mpi/messages/request_helper.rb', line 23

def build_birth_date(birth_date:)
  birth_time_element = element('livingSubjectBirthTime')
  birth_time_element << element('value', value: Date.parse(birth_date)&.strftime('%Y%m%d'))
  birth_time_element << text_element('semanticsText', 'Date of Birth')
  birth_time_element
end

.build_code(code:) ⇒ Object



181
182
183
# File 'lib/mpi/messages/request_helper.rb', line 181

def build_code(code:)
  element('code', code:, codeSystem: '2.16.840.1.113883.1.6')
end

.build_control_act_process_elementObject



177
178
179
# File 'lib/mpi/messages/request_helper.rb', line 177

def build_control_act_process_element
  element('controlActProcess', classCode: 'CACT', moodCode: 'EVN')
end

.build_custodianObject



164
165
166
167
168
# File 'lib/mpi/messages/request_helper.rb', line 164

def build_custodian
  custodian = element('custodian', typeCode: 'CST')
  custodian << build_assigned_entity
  custodian
end

.build_data_enterer_elementObject



75
76
77
# File 'lib/mpi/messages/request_helper.rb', line 75

def build_data_enterer_element
  element('dataEnterer', typeCode: 'ENT', contextControlCode: 'AP')
end

.build_gender(gender:) ⇒ Object



37
38
39
40
41
42
# File 'lib/mpi/messages/request_helper.rb', line 37

def build_gender(gender:)
  gender_element = element('livingSubjectAdministrativeGender')
  gender_element << element('value', code: gender)
  gender_element << text_element('semanticsText', 'Gender')
  gender_element
end

.build_id_null_flavor(type:) ⇒ Object



95
96
97
# File 'lib/mpi/messages/request_helper.rb', line 95

def build_id_null_flavor(type:)
  element('id', nullFlavor: type)
end

.build_identifier(identifier:, root:) ⇒ Object



7
8
9
# File 'lib/mpi/messages/request_helper.rb', line 7

def build_identifier(identifier:, root:)
  element('id', root:, extension: identifier)
end

.build_name(given_names:, family_name:) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/mpi/messages/request_helper.rb', line 11

def build_name(given_names:, family_name:)
  name_value = element('value', use: 'L')
  given_names.each do |given_name|
    name_value << text_element('given', given_name)
  end
  name_value << text_element('family', family_name)
  subject_name = element('livingSubjectName')
  subject_name << name_value
  subject_name << text_element('semanticsText', 'Legal Name')
  subject_name
end

.build_parameter_list_elementObject



185
186
187
# File 'lib/mpi/messages/request_helper.rb', line 185

def build_parameter_list_element
  element('parameterList')
end

.build_patient_elementObject



107
108
109
# File 'lib/mpi/messages/request_helper.rb', line 107

def build_patient_element
  element('patient', classCode: 'PAT')
end

.build_patient_identifier(identifier:, root:, class_code:) ⇒ Object



141
142
143
144
145
146
# File 'lib/mpi/messages/request_helper.rb', line 141

def build_patient_identifier(identifier:, root:, class_code:)
  ssn_element = element('asOtherIDs', classCode: class_code)
  ssn_element << build_identifier(identifier:, root:)
  ssn_element << build_scoping_organization(root:)
  ssn_element
end

.build_patient_person_address(street:, state:, city:, postal_code:, country:) ⇒ Object



131
132
133
134
135
136
137
138
139
# File 'lib/mpi/messages/request_helper.rb', line 131

def build_patient_person_address(street:, state:, city:, postal_code:, country:)
  address_element = element('addr', use: 'HP')
  address_element << text_element('streetAddressLine', street)
  address_element << text_element('city', city)
  address_element << text_element('state', state)
  address_element << text_element('postalCode', postal_code)
  address_element << text_element('country', country)
  address_element
end

.build_patient_person_birth_date(birth_date:) ⇒ Object



127
128
129
# File 'lib/mpi/messages/request_helper.rb', line 127

def build_patient_person_birth_date(birth_date:)
  element('birthTime', value: Date.parse(birth_date)&.strftime('%Y%m%d'))
end

.build_patient_person_elementObject



111
112
113
# File 'lib/mpi/messages/request_helper.rb', line 111

def build_patient_person_element
  element('patientPerson')
end

.build_patient_person_name(given_names:, family_name:) ⇒ Object



115
116
117
118
119
120
121
# File 'lib/mpi/messages/request_helper.rb', line 115

def build_patient_person_name(given_names:, family_name:)
  name_value = element('name', use: 'L')
  given_names.each do |given_name|
    name_value << text_element('given', given_name)
  end
  name_value << text_element('family', family_name)
end

.build_patient_person_proxy_addObject



148
149
150
151
152
153
154
# File 'lib/mpi/messages/request_helper.rb', line 148

def build_patient_person_proxy_add
  proxy_add_element = element('asOtherIDs', classCode: 'PAT')
  proxy_add_element << build_identifier(identifier: 'PROXY_ADD^PI^200VBA^USVBA',
                                        root: MPI::Constants::VA_ROOT_OID)
  proxy_add_element << build_scoping_organization(root: MPI::Constants::VA_ROOT_OID, orchestration: true)
  proxy_add_element
end

.build_provider_organizationObject



156
157
158
159
160
161
162
# File 'lib/mpi/messages/request_helper.rb', line 156

def build_provider_organization
  provider_organization = element('providerOrganization', determinerCode: 'INSTANCE', classCode: 'ORG')
  provider_organization << element('id', root: '2.16.840.1.113883.3.933')
  provider_organization << text_element('name', 'Good Health Clinic')
  provider_organization << build_contact_party
  provider_organization
end

.build_query_by_parameter(search_type:) ⇒ Object



55
56
57
58
59
60
61
62
# File 'lib/mpi/messages/request_helper.rb', line 55

def build_query_by_parameter(search_type:)
  query_element = element('queryByParameter')
  query_element << element('queryId', root: '1.2.840.114350.1.13.28.1.18.5.999', extension: '18204')
  query_element << element('statusCode', code: 'new')
  query_element << element('modifyCode', code: search_type)
  query_element << element('initialQuantity', value: 1)
  query_element
end

.build_registration_event_elementObject



91
92
93
# File 'lib/mpi/messages/request_helper.rb', line 91

def build_registration_event_element
  element('registrationEvent', classCode: 'REG', moodCode: 'EVN')
end

.build_represented_organization(edipi:) ⇒ Object



44
45
46
47
48
49
50
51
52
53
# File 'lib/mpi/messages/request_helper.rb', line 44

def build_represented_organization(edipi:)
  orchestrated_search_element = element('representedOrganization', determinerCode: 'INSTANCE', classCode: 'ORG')
  orchestrated_search_element << build_identifier(identifier: "dslogon.#{edipi}",
                                                  root: MPI::Constants::VA_ROOT_OID)
  orchestrated_search_element << element('code', code: Time.now.utc.strftime('%Y-%m-%d %H:%M:%S'))
  orchestrated_search_element << text_element('desc', 'vagov')
  ip_address = Socket.ip_address_list.find { |ip| ip.ipv4? && !ip.ipv4_loopback? }.ip_address
  orchestrated_search_element << element('telecom', value: ip_address)
  orchestrated_search_element
end

.build_ssn(ssn:) ⇒ Object



30
31
32
33
34
35
# File 'lib/mpi/messages/request_helper.rb', line 30

def build_ssn(ssn:)
  ssn_element = element('livingSubjectId')
  ssn_element << element('value', root: '2.16.840.1.113883.4.1', extension: ssn)
  ssn_element << text_element('semanticsText', 'SSN')
  ssn_element
end

.build_status_codeObject



99
100
101
# File 'lib/mpi/messages/request_helper.rb', line 99

def build_status_code
  element('statusCode', code: 'active')
end

.build_subject_1_elementObject



103
104
105
# File 'lib/mpi/messages/request_helper.rb', line 103

def build_subject_1_element
  element('subject1', typeCode: 'SBJ')
end

.build_subject_elementObject



87
88
89
# File 'lib/mpi/messages/request_helper.rb', line 87

def build_subject_element
  element('subject', typeCode: 'SUBJ')
end

.build_telecom(type:, value:) ⇒ Object



123
124
125
# File 'lib/mpi/messages/request_helper.rb', line 123

def build_telecom(type:, value:)
  element('telecom', use: type, value:)
end

.build_vba_orchestrationObject



170
171
172
173
174
175
# File 'lib/mpi/messages/request_helper.rb', line 170

def build_vba_orchestration
  vba_element = element('otherIDsScopingOrganization')
  vba_element << element('value', extension: 'VBA', root: MPI::Constants::VA_ROOT_OID)
  vba_element << text_element('semanticsText', 'MVI.ORCHESTRATION')
  vba_element
end