Class: DaVinciDTRTestKit::MockPayer::NextQuestionEndpoint

Inherits:
Inferno::DSL::SuiteEndpoint
  • Object
show all
Includes:
DaVinciDTRTestKit::MockPayer
Defined in:
lib/davinci_dtr_test_kit/endpoints/mock_payer/next_question_endpoint.rb

Direct Known Subclasses

FullEHRNextQuestionEndpoint

Instance Method Summary collapse

Methods included from DaVinciDTRTestKit::MockPayer

#build_outcome_param, #find_questionnaire_response, #operation_outcome, #outcome_issue, #parse_fhir_object

Instance Method Details

#complete_questionnaire?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/davinci_dtr_test_kit/endpoints/mock_payer/next_question_endpoint.rb', line 44

def complete_questionnaire?
  custom_questionnaires && next_custom_questionnaire.blank?
end

#custom_next_question_requestsObject



25
26
27
# File 'lib/davinci_dtr_test_kit/endpoints/mock_payer/next_question_endpoint.rb', line 25

def custom_next_question_requests
  requests_repo.tagged_requests(test_run.test_session_id, ["custom_#{DaVinciDTRTestKit::CLIENT_NEXT_TAG}"])
end

#custom_questionnairesObject



29
30
31
32
33
34
35
36
37
38
# File 'lib/davinci_dtr_test_kit/endpoints/mock_payer/next_question_endpoint.rb', line 29

def custom_questionnaires
  return @custom_questionnaires unless @custom_questionnaires.nil?

  questionnaires = JSON.parse(result.input_json)
    .find { |input| input['name'].include?('custom_next_question_questionnaires') }
    &.dig('value')
  return unless questionnaires

  @custom_questionnaires = [JSON.parse(questionnaires)].flatten.compact
end

#make_responseObject



18
19
20
21
22
23
# File 'lib/davinci_dtr_test_kit/endpoints/mock_payer/next_question_endpoint.rb', line 18

def make_response
  response.status = 200
  response.format = 'application/fhir+json'
  response.headers['Access-Control-Allow-Origin'] = '*'
  response.body = build_questionnaire_next_response.to_json
end

#next_custom_questionnaireObject



40
41
42
# File 'lib/davinci_dtr_test_kit/endpoints/mock_payer/next_question_endpoint.rb', line 40

def next_custom_questionnaire
  custom_questionnaires[custom_next_question_requests.length]
end

#tagsObject



14
15
16
# File 'lib/davinci_dtr_test_kit/endpoints/mock_payer/next_question_endpoint.rb', line 14

def tags
  [test.config.options[:next_tag]]
end

#test_run_identifierObject



10
11
12
# File 'lib/davinci_dtr_test_kit/endpoints/mock_payer/next_question_endpoint.rb', line 10

def test_run_identifier
  MockAuthorization.extract_client_id_from_bearer_token(request)
end

#update_resultObject



48
49
50
# File 'lib/davinci_dtr_test_kit/endpoints/mock_payer/next_question_endpoint.rb', line 48

def update_result
  results_repo.update_result(result.id, 'pass') unless test.config.options[:accepts_multiple_requests]
end