Class: DaVinciPASTestKit::ClaimEndpoint
- Inherits:
-
Inferno::DSL::SuiteEndpoint
- Object
- Inferno::DSL::SuiteEndpoint
- DaVinciPASTestKit::ClaimEndpoint
show all
- Includes:
- ResponseGenerator, URLs, SubscriptionsTestKit::SubscriptionsR5BackportR4Client::SubscriptionSimulationUtils
- Defined in:
- lib/davinci_pas_test_kit/endpoints/claim_endpoint.rb
Constant Summary
collapse
- WORKFLOW_TAG_MAP =
{
pended: PENDED_WORKFLOW_TAG,
denial: DENIAL_WORKFLOW_TAG,
approval: APPROVAL_WORKFLOW_TAG
}.freeze
Instance Method Summary
collapse
Methods included from URLs
#base_url, #fhir_base_url, #fhir_subscription_url, #inquire_url, #registration_url, #resume_fail_url, #resume_pass_url, #resume_skip_url, #session_fhir_base_url, #session_fhir_subscription_url, #session_inquire_url, #session_submit_url, #submit_url, #token_url, #udap_discovery_url
#mock_full_resource_notification_bundle, #mock_id_only_notification_bundle, #mock_response_bundle, #update_tester_provided_notification, #update_tester_provided_response
Instance Method Details
#make_response ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/davinci_pas_test_kit/endpoints/claim_endpoint.rb', line 53
def make_response
return if response.status == 401
response.status = 200
response.format = :json
req_bundle = FHIR.from_contents(request.body.string)
claim_entry = req_bundle&.entry&.find { |e| e&.resource&.resourceType == 'Claim' }
claim_full_url = claim_entry&.fullUrl
if claim_entry.blank? || claim_full_url.blank?
handle_missing_required_elements(claim_entry, response)
return
end
user_inputted_response = UserInputResponse.user_inputted_response(test, operation, result)
if user_inputted_response.present?
generated_claim_response_uuid = nil
response_bundle_json = update_tester_provided_response(user_inputted_response, claim_full_url)
else
decision =
if operation == 'inquire' && workflow == :pended
:approval
else
workflow
end
generated_claim_response_uuid = SecureRandom.uuid
response_bundle_json = mock_response_bundle(req_bundle, operation, decision, generated_claim_response_uuid)
end
response.body = response_bundle_json
return unless workflow == :pended && operation == 'submit'
start_notification_job(response_bundle_json, :approval, generated_claim_response_uuid)
end
|
#suite_id ⇒ Object
override the one from URLs
15
16
17
|
# File 'lib/davinci_pas_test_kit/endpoints/claim_endpoint.rb', line 15
def suite_id
request.path.split('/custom/')[1].split('/')[0]
end
|
27
28
29
30
31
32
33
34
|
# File 'lib/davinci_pas_test_kit/endpoints/claim_endpoint.rb', line 27
def tags
operation_tag = operation == 'submit' ? SUBMIT_TAG : INQUIRE_TAG
workflow_tag = WORKFLOW_TAG_MAP[workflow]
return [operation_tag, workflow_tag] if workflow_tag.present?
[operation_tag]
end
|
#test_run_identifier ⇒ Object
19
20
21
22
23
24
25
|
# File 'lib/davinci_pas_test_kit/endpoints/claim_endpoint.rb', line 19
def test_run_identifier
return request.params[:session_path] if request.params[:session_path].present?
UDAPSecurityTestKit::MockUDAPServer.issued_token_to_client_id(
request.['authorization']&.delete_prefix('Bearer ')
)
end
|
#update_result ⇒ Object
89
90
91
92
93
94
95
96
|
# File 'lib/davinci_pas_test_kit/endpoints/claim_endpoint.rb', line 89
def update_result
if UDAPSecurityTestKit::MockUDAPServer.request_has_expired_token?(request)
UDAPSecurityTestKit::MockUDAPServer.update_response_for_expired_token(response, 'Bearer token')
return
end
results_repo.update_result(result.id, 'pass') unless test.config.options[:accepts_multiple_requests]
end
|
#workflow ⇒ Object
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/davinci_pas_test_kit/endpoints/claim_endpoint.rb', line 36
def workflow
case test.id
when /.*pended.*/
:pended
when /.*denial.*/
:denial
when /.*approval.*/
:approval
end
end
|