Class: SMART_UDAP_HarmonizationTestKit::SMART_UDAP_EncounterContextTest

Inherits:
SMART_UDAP_ContextTest
  • Object
show all
Defined in:
lib/smart_udap_harmonization_test_kit/smart_udap_encounter_context_test.rb

Overview

rubocop:disable Naming/ClassAndModuleCamelCase

Constant Summary collapse

FHIR_ID_REGEX =
/[A-Za-z0-9\-\.]{1,64}/

Instance Attribute Summary

Attributes inherited from SMART_UDAP_ContextTest

#token_response

Instance Method Summary collapse

Methods inherited from SMART_UDAP_ContextTest

#context_field, #context_field_present?, #missing_received_context_scopes, #missing_received_scopes_string, #missing_requested_context_scopes, #missing_requested_scopes_string, #received_scopes, #received_scopes_list, #requested_scopes, #requested_scopes_list

Instance Method Details

#context_field_nameObject



26
27
28
# File 'lib/smart_udap_harmonization_test_kit/smart_udap_encounter_context_test.rb', line 26

def context_field_name
  'encounter'
end

#context_scopesObject



30
31
32
# File 'lib/smart_udap_harmonization_test_kit/smart_udap_encounter_context_test.rb', line 30

def context_scopes
  ['launch', 'launch/encounter'].freeze
end

#missing_received_context_scopes?Boolean

Returns:

  • (Boolean)


38
39
40
41
42
43
# File 'lib/smart_udap_harmonization_test_kit/smart_udap_encounter_context_test.rb', line 38

def missing_received_context_scopes?
  # There is no expectation that Encounter context be included when just the
  # "launch" scope is used, so we shouldn't expect to see the "encounter"
  # context field just because "launch" was received
  received_scopes_list.exclude? 'launch/encounter'
end

#missing_requested_context_scopes?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/smart_udap_harmonization_test_kit/smart_udap_encounter_context_test.rb', line 34

def missing_requested_context_scopes?
  context_scopes.none? { |scope| requested_scopes_list.include? scope }
end

#validate_context_fieldObject



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/smart_udap_harmonization_test_kit/smart_udap_encounter_context_test.rb', line 45

def validate_context_field
  assert context_field.is_a?(String),
         "Expected `#{context_field_name}` to be a String, but found: `#{context_field.class.name}`"

  warn do
    assert context_field.match?(FHIR_ID_REGEX), "`#{context_field}` is not a valid FHIR resource id."
  end

  fhir_read(:encounter, context_field)

  assert_response_status(200)
  assert_resource_type(:encounter)
end