Module: DaVinciCRDTestKit::MockEHREndpoints

Defined in:
lib/davinci_crd_test_kit/server/endpoints/mock_ehr_endpoints.rb

Overview

Include this module within a suite class to add Mock FHIR Server endpoints with data supplied by an input containing a Bundle that can be accessed and updated by calls to the suite’s endpoints. Defaults to driving the CapabilityStatement and supported search parameters off of US Core 6.1.0, but a different set of metadata can be provided at inclusion time by using ‘with` and specifying either a `metadata_dir:` or providing a block that resolves to a list of metadata files to use.

Examples:

Default US Core 6.1.0 metadata

class MyTestSuite < Inferno::TestSuite
  include MockEHREndpoints
end

Custom metadata directory (e.g. US Core 7.0.0)

US_CORE_7_DIR = File.join(
  Gem::Specification.find_by_name('us_core_test_kit').gem_dir,
  'lib', 'us_core_test_kit', 'generated', 'v7.0.0'
)

class MyTestSuite < Inferno::TestSuite
  include MockEHREndpoints.with(metadata_dir: US_CORE_7_DIR)
end

Custom file list via block

class MyTestSuite < Inferno::TestSuite
  include(MockEHREndpoints.with { Dir.glob('/path/to/my/metadata/**/metadata.yml') })
end

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



38
39
40
# File 'lib/davinci_crd_test_kit/server/endpoints/mock_ehr_endpoints.rb', line 38

def self.included(base)
  configure(base)
end

.with(metadata_dir: nil, &block) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/davinci_crd_test_kit/server/endpoints/mock_ehr_endpoints.rb', line 42

def self.with(metadata_dir: nil, &block)
  Module.new do
    define_singleton_method(:included) do |base|
      MockEHREndpoints.send(:configure, base, metadata_dir:, metadata_files_proc: block)
    end
  end
end