Class: DaVinciCRDTestKit::FormCompletionResponseValidationTest

Inherits:
Inferno::Test
  • Object
show all
Includes:
SuggestionActionsValidation, TestHelper
Defined in:
lib/davinci_crd_test_kit/server_tests/form_completion_response_validation_test.rb

Instance Method Summary collapse

Methods included from SuggestionActionsValidation

#action_fields_validation, #action_required_fields, #action_resource_field_validation, #action_resource_id_field_validation, #action_resource_type_check, #action_type_field_validation, #actions_check, #create_or_update_action_check, #delete_action_check, #draft_orders_bundle_entry_refs, #extract_resource_types_by_action

Methods included from ServerHookRequestValidation

#client_test?, #server_test?

Methods included from HookRequestFieldValidation

#appointment_book_context_check, #bundle_entries_check, #check_patient_scope_requirement, #common_context_fields, #context_optional_fields_by_hook, #context_required_fields_by_hook, #context_selections_check, #context_user_types_by_hook, #context_validate_optional_fields, #encounter_start_or_discharge_context_check, #fhir_auth_fields_valid?, #fhir_authorization_required_fields, #hook_optional_fields, #hook_request_context_check, #hook_request_fhir_auth_check, #hook_request_optional_fields_check, #hook_request_prefetch_check, #hook_request_required_fields_check, #hook_required_fields, #hook_specific_context_check, #hook_user_type_check, #id_only_fields_check, #json_parse, #no_error_validation, #optional_field_resource_types, #order_dispatch_context_check, #order_select_or_sign_context_check, #parse_fhir_bundle_from_context, #query_and_validate_id_field, #request_number, #resource_reference_check, #status_check, #structure_definition_map, #valid_id_format?, #valid_reference_format?, #valid_url?, #validate_hash_fields, #validate_prefetch_coverage, #validate_prefetch_resource, #validate_presence_and_type

Methods included from TestHelper

#parse_json, #verify_at_least_one_test_passes

Instance Method Details

#hook_nameObject



34
35
36
# File 'lib/davinci_crd_test_kit/server_tests/form_completion_response_validation_test.rb', line 34

def hook_name
  config.options[:hook_name]
end

#request_form_completion_card?(card) ⇒ Boolean

Returns:

  • (Boolean)


48
49
50
51
52
53
54
# File 'lib/davinci_crd_test_kit/server_tests/form_completion_response_validation_test.rb', line 48

def request_form_completion_card?(card)
  card['suggestions'].all? do |suggestion|
    actions = suggestion['actions']
    task_actions = task_actions(actions)
    task_actions.present? && task_actions.all? { |action| task_questionnaire?(action) }
  end
end

#task_actions(actions) ⇒ Object



38
39
40
# File 'lib/davinci_crd_test_kit/server_tests/form_completion_response_validation_test.rb', line 38

def task_actions(actions)
  actions&.select { |action| action['type'] == 'create' && action_resource_type_check(action, ['Task']) }
end

#task_questionnaire?(task_action) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
45
46
# File 'lib/davinci_crd_test_kit/server_tests/form_completion_response_validation_test.rb', line 42

def task_questionnaire?(task_action)
  task = FHIR.from_contents(task_action['resource'].to_json)
  task.code.coding.any? { |code| code.code == 'complete-questionnaire' } &&
    task.input.any? { |input| input.type.text == 'questionnaire' && valid_url?(input.valueCanonical) }
end