Module: DaVinciDTRTestKit::MockPayer

Included in:
NextQuestionEndpoint, QuestionnairePackageEndpoint
Defined in:
lib/davinci_dtr_test_kit/endpoints/mock_payer.rb,
lib/davinci_dtr_test_kit/endpoints/mock_payer/next_question_endpoint.rb,
lib/davinci_dtr_test_kit/endpoints/mock_payer/next_question_proxy_endpoint.rb,
lib/davinci_dtr_test_kit/endpoints/mock_payer/questionnaire_package_endpoint.rb,
lib/davinci_dtr_test_kit/endpoints/mock_payer/full_ehr_next_question_endpoint.rb,
lib/davinci_dtr_test_kit/endpoints/mock_payer/questionnaire_package_proxy_endpoint.rb,
lib/davinci_dtr_test_kit/endpoints/mock_payer/full_ehr_questionnaire_package_endpoint.rb

Defined Under Namespace

Classes: FullEHRNextQuestionEndpoint, FullEHRQuestionnairePackageEndpoint, NextQuestionEndpoint, NextQuestionProxyEndpoint, QuestionnairePackageEndpoint, QuestionnairePackageProxyEndpoint

Instance Method Summary collapse

Instance Method Details

#build_outcome_param(issues) ⇒ Object



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

def build_outcome_param(issues)
  FHIR::Parameters::Parameter.new(
    name: 'Outcome',
    resource: FHIR::OperationOutcome.new(issue: issues)
  )
end

#find_questionnaire_response(input_parameters) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/davinci_dtr_test_kit/endpoints/mock_payer.rb', line 9

def find_questionnaire_response(input_parameters)
  questionnaire_response_param = input_parameters.try(&:parameter)&.find do |param|
    param.name == 'questionnaire-response'
  end
  return questionnaire_response_param if questionnaire_response_param

  operation_outcome('error', 'business-rule',
                    'Input parameter does not have a `parameter:questionnaire-response` slice.')
end

#operation_outcome(severity, code, text = nil) ⇒ Object



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

def operation_outcome(severity, code, text = nil)
  FHIR::OperationOutcome.new(issue: outcome_issue(severity, code, text))
end

#outcome_issue(severity, code, text = nil) ⇒ Object



30
31
32
33
34
# File 'lib/davinci_dtr_test_kit/endpoints/mock_payer.rb', line 30

def outcome_issue(severity, code, text = nil)
  FHIR::OperationOutcome::Issue.new(severity:, code:).tap do |issue|
    issue.details = FHIR::CodeableConcept.new(text:) if text.present?
  end
end

#parse_fhir_object(str) ⇒ Object



3
4
5
6
7
# File 'lib/davinci_dtr_test_kit/endpoints/mock_payer.rb', line 3

def parse_fhir_object(str)
  FHIR.from_contents(str)
rescue StandardError
  operation_outcome('error', 'invalid', 'No valid input parameters')
end