Module: AUPSTestKit::BasicTestCapabilityOperationsModule

Included in:
BasicTest
Defined in:
lib/au_ps_inferno/utils/basic_test/capability_operations_module.rb

Overview

CapabilityStatement operation discovery (summary, docref, etc.).

Instance Method Summary collapse

Instance Method Details

#operation_defined?(operations, op_def_url, names_arr, scratch_key) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/au_ps_inferno/utils/basic_test/capability_operations_module.rb', line 6

def operation_defined?(operations, op_def_url, names_arr, scratch_key)
  operation_defined = operations.any? do |operation|
    operation.definition == op_def_url || names_arr.include?(operation.name.downcase)
  end

  if operation_defined
    info "Server CapabilityStatement declares support for operation #{op_def_url}: ✅ Declared"
  else
    info "Server CapabilityStatement does not declare support for operation #{op_def_url}. " \
         'This operation is not required by AU PS; this message is informational only.'
  end

  scratch[scratch_key] = operation_defined
end

#operationsObject



21
22
23
24
25
26
27
# File 'lib/au_ps_inferno/utils/basic_test/capability_operations_module.rb', line 21

def operations
  fhir_get_capability_statement
  scratch[:capability_statement] = resource
  resource.rest&.flat_map do |rest|
    select_op(rest)
  end&.compact
end

#select_op(rest) ⇒ Object



29
30
31
32
33
# File 'lib/au_ps_inferno/utils/basic_test/capability_operations_module.rb', line 29

def select_op(rest)
  rest.resource
      &.select { |res| res.respond_to?(:operation) }
      &.flat_map(&:operation)
end

#summary_op_defined?Boolean

Returns:

  • (Boolean)


35
36
37
38
# File 'lib/au_ps_inferno/utils/basic_test/capability_operations_module.rb', line 35

def summary_op_defined?
  operation_defined?(operations, 'http://hl7.org/fhir/uv/ips/OperationDefinition/summary',
                     %w[summary patient-summary], :summary_op_defined)
end