Class: SMART_UDAP_HarmonizationTestKit::SMART_UDAP_PatientContextTest

Inherits:
SMART_UDAP_ContextTest show all
Defined in:
lib/smart_udap_harmonization_test_kit/smart_udap_patient_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



28
29
30
# File 'lib/smart_udap_harmonization_test_kit/smart_udap_patient_context_test.rb', line 28

def context_field_name
  'patient'
end

#context_scopesObject



32
33
34
# File 'lib/smart_udap_harmonization_test_kit/smart_udap_patient_context_test.rb', line 32

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

#missing_received_context_scopes?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/smart_udap_harmonization_test_kit/smart_udap_patient_context_test.rb', line 40

def missing_received_context_scopes?
  context_scopes.none? { |scope| received_scopes_list.include? scope }
end

#missing_requested_context_scopes?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/smart_udap_harmonization_test_kit/smart_udap_patient_context_test.rb', line 36

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

#validate_context_fieldObject



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

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(:patient, context_field)

  assert_response_status(200)
  assert_resource_type(:patient)
end