Class: MPI::Messages::FindProfileByFacility

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(facility_id:, vista_id:, search_type: MPI::Constants::CORRELATION_WITH_RELATIONSHIP_DATA) ⇒ FindProfileByFacility

Returns a new instance of FindProfileByFacility.



12
13
14
15
16
# File 'lib/mpi/messages/find_profile_by_facility.rb', line 12

def initialize(facility_id:, vista_id:, search_type: MPI::Constants::CORRELATION_WITH_RELATIONSHIP_DATA)
  @facility_id = facility_id
  @vista_id = vista_id
  @search_type = search_type
end

Instance Attribute Details

#facility_idObject (readonly)

Returns the value of attribute facility_id.



10
11
12
# File 'lib/mpi/messages/find_profile_by_facility.rb', line 10

def facility_id
  @facility_id
end

#search_typeObject (readonly)

Returns the value of attribute search_type.



10
11
12
# File 'lib/mpi/messages/find_profile_by_facility.rb', line 10

def search_type
  @search_type
end

#vista_idObject (readonly)

Returns the value of attribute vista_id.



10
11
12
# File 'lib/mpi/messages/find_profile_by_facility.rb', line 10

def vista_id
  @vista_id
end

Instance Method Details

#build_bodyObject (private)



27
28
29
30
31
32
# File 'lib/mpi/messages/find_profile_by_facility.rb', line 27

def build_body
  body = RequestHelper.build_control_act_process_element
  body << RequestHelper.build_code(code: MPI::Constants::FIND_PROFILE_CONTROL_ACT_PROCESS)
  body << query_by_parameter
  body
end

#build_parameter_listObject (private)



39
40
41
42
# File 'lib/mpi/messages/find_profile_by_facility.rb', line 39

def build_parameter_list
  element = RequestHelper.build_parameter_list_element
  element << RequestHelper.build_identifier(identifier:, root:)
end

#identifierObject (private)



48
49
50
# File 'lib/mpi/messages/find_profile_by_facility.rb', line 48

def identifier
  "#{vista_id}^PI^#{facility_id}^#{MPI::Constants::ACTIVE_VHA_IDENTIFIER}"
end

#performObject



18
19
20
21
22
23
# File 'lib/mpi/messages/find_profile_by_facility.rb', line 18

def perform
  MPI::Messages::RequestBuilder.new(extension: MPI::Constants::FIND_PROFILE, body: build_body).perform
rescue => e
  Rails.logger.error "[FindProfileByFacility] Failed to build request: #{e.message}"
  raise e
end

#query_by_parameterObject (private)



34
35
36
37
# File 'lib/mpi/messages/find_profile_by_facility.rb', line 34

def query_by_parameter
  query_by_parameter = RequestHelper.build_query_by_parameter(search_type:)
  query_by_parameter << build_parameter_list
end

#rootObject (private)



44
45
46
# File 'lib/mpi/messages/find_profile_by_facility.rb', line 44

def root
  MPI::Constants::VA_ROOT_OID
end