Module: DaVinciPDexTestKit::ClientValidationTest

Instance Method Summary collapse

Instance Method Details

#all_member_match_requestsObject

def patient_id_from_match_request

@patient_id_from_match_request ||= member_match_request ? "999" : nil #TODO: Change from static response

end



49
50
51
# File 'lib/davinci_pdex_test_kit/pdex_payer_client/client_validation_test.rb', line 49

def all_member_match_requests
  @all_member_match_requests ||= load_tagged_requests(MEMBER_MATCH_TAG)
end

#connect_bundle(export_binary) ⇒ Object



17
18
19
# File 'lib/davinci_pdex_test_kit/pdex_payer_client/client_validation_test.rb', line 17

def connect_bundle(export_binary)
  export_binary.split(/(?<=}\n)(?={)/).map { |str| FHIR.from_contents(str)}
end

#everything_requestObject



29
30
31
# File 'lib/davinci_pdex_test_kit/pdex_payer_client/client_validation_test.rb', line 29

def everything_request
  @everything_request ||= load_tagged_requests(EVERYTHING_TAG).first
end

#export_requestObject



37
38
39
# File 'lib/davinci_pdex_test_kit/pdex_payer_client/client_validation_test.rb', line 37

def export_request
  @export_request ||= load_tagged_requests(EXPORT_TAG).first
end

#export_resourcesObject



21
22
23
# File 'lib/davinci_pdex_test_kit/pdex_payer_client/client_validation_test.rb', line 21

def export_resources
  @export_resources ||= (load_tagged_requests(BINARY_TAG).map { |binary_read| binary_read.response_body.split("\n") }.flatten).map { |resource_in_binary| FHIR.from_contents(resource_in_binary)}
end

#export_status_requestObject



41
42
43
# File 'lib/davinci_pdex_test_kit/pdex_payer_client/client_validation_test.rb', line 41

def export_status_request
  @export_status_request ||= load_tagged_requests(EXPORT_STATUS_TAG).first
end

#flattened_all_resourcesObject



53
54
55
# File 'lib/davinci_pdex_test_kit/pdex_payer_client/client_validation_test.rb', line 53

def flattened_all_resources
  @flattened_all_resources ||= previous_clinical_data_request_resources.values.flatten
end

#member_match_requestObject



33
34
35
# File 'lib/davinci_pdex_test_kit/pdex_payer_client/client_validation_test.rb', line 33

def member_match_request
  @member_match_request ||= load_tagged_requests(MEMBER_MATCH_TAG).first
end

#previous_clinical_data_request_resourcesObject



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/davinci_pdex_test_kit/pdex_payer_client/client_validation_test.rb', line 4

def previous_clinical_data_request_resources
  hash = Hash.new { |hash, key| hash[key] = [] }
  previous_clinical_data_requests.each_with_object(hash) do |request, request_resource_hash|
    request_resources =
      if request.status == 200
        request.resource.entry.map(&:resource)
      else
        []
      end
    request_resource_hash[request].concat(request_resources)
  end
end

#previous_clinical_data_requestsObject



25
26
27
# File 'lib/davinci_pdex_test_kit/pdex_payer_client/client_validation_test.rb', line 25

def previous_clinical_data_requests
  @previous_clinical_data_requests ||= load_tagged_requests(SUBMIT_TAG) + [everything_request].compact
end