Class: Crucible::Tests::ConnectathonTerminologyTrackTest

Inherits:
BaseSuite show all
Defined in:
lib/tests/suites/connectathon_terminology_track.rb

Constant Summary

Constants inherited from BaseSuite

BaseSuite::EXCLUDED_RESOURCES

Constants inherited from BaseTest

BaseTest::BASE_SPEC_LINK, BaseTest::JSON_FIELDS, BaseTest::METADATA_FIELDS, BaseTest::REST_SPEC_LINK, BaseTest::STATUS

Instance Attribute Summary

Attributes inherited from BaseTest

#category, #tags, #tests_subset, #warnings

Instance Method Summary collapse

Methods inherited from BaseSuite

#build_messages, #collect_metadata, fhir_resources, #links, #metadata, #parse_operation_outcome, #requires, #resource_category, test, #title, #validates

Methods inherited from BaseTest

#author, #details, #execute, #execute_test_method, #execute_test_methods, #ignore_client_exception, #multiserver, #requires_authorization, #tests, #warning

Methods included from Assertions

#assert, #assert_bundle_entry_count, #assert_bundle_response, #assert_bundle_transactions_okay, #assert_equal, #assert_etag_present, #assert_last_modified_present, #assert_minimum, #assert_navigation_links, #assert_operator, #assert_resource_content_type, #assert_resource_type, #assert_response_bad, #assert_response_code, #assert_response_conflict, #assert_response_created, #assert_response_gone, #assert_response_not_found, #assert_response_ok, #assert_valid_content_location_present, #assert_valid_profile, #assert_valid_resource_content_type_present, #assertion_negated, #skip

Constructor Details

#initialize(client1, client2 = nil) ⇒ ConnectathonTerminologyTrackTest

Returns a new instance of ConnectathonTerminologyTrackTest.



13
14
15
16
17
# File 'lib/tests/suites/connectathon_terminology_track.rb', line 13

def initialize(client1, client2=nil)
  super(client1, client2)
  @tags.append('connectathon')
  @category = {id: 'connectathon', title: 'Connectathon'}
end

Instance Method Details

#check_expansion_for_concepts(vs, ref) ⇒ Object



385
386
387
388
389
390
391
392
393
394
395
396
# File 'lib/tests/suites/connectathon_terminology_track.rb', line 385

def check_expansion_for_concepts(vs, ref)
  assert(vs.expansion,'ValueSet should contain expansion.')
  assert(vs.expansion.contains,'ValueSet.expansion.contains elements are missing.')

  concepts = vs.expansion.contains.map{|c|c.code}

  expansion_missing = ref - concepts
  expansion_added = concepts - ref

  assert(expansion_missing.empty?,"ValueSet expansion is missing the following concepts: #{expansion_missing}")
  assert(expansion_added.empty?,"ValueSet expansion contained some unexpected concepts: #{expansion_added}")
end

#check_response_params(contents, name, attribute, value) ⇒ Object



398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
# File 'lib/tests/suites/connectathon_terminology_track.rb', line 398

def check_response_params(contents,name,attribute,value)
  begin
    doc = Nokogiri::XML(contents)
    if doc.errors.empty?
      doc.root.add_namespace_definition('fhir', 'http://hl7.org/fhir')
      doc.root.add_namespace_definition('xhtml', 'http://www.w3.org/1999/xhtml')
      e = doc.root.xpath("./fhir:parameter[fhir:name[@value=\"#{name}\"]]/fhir:#{attribute}").first
      assert(e[:value]==value,"Output parameters do not contain #{name}=#{value}")
    else
      hash = JSON.parse(contents)
      params = hash['parameter']
      p = params.select{|p|p['name']==name}.first
      assert(p[attribute]==value,"Output parameters do not contain #{name}=#{value}")
    end
  rescue Exception => e
    raise AssertionException.new 'Unable to parse response parameters', e.message
  end
end

#descriptionObject



9
10
11
# File 'lib/tests/suites/connectathon_terminology_track.rb', line 9

def description
  'Connectathon Terminology Track focuses on the $expand, $validate-code, $lookup, and $translate operations.'
end

#idObject



5
6
7
# File 'lib/tests/suites/connectathon_terminology_track.rb', line 5

def id
  'ConnectathonTerminologyTrackTest'
end

#setupObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/tests/suites/connectathon_terminology_track.rb', line 19

def setup
  # find FHIRDefinedType valueset
  options = {
    :search => {
      :flag => false,
      :compartment => nil,
      :parameters => {
        'name' => 'FHIRDefinedType'
      }
    }
  }
  @valueset = nil
  reply = @client.search(FHIR::ValueSet, options)
  if reply.code==200 && !reply.resource.nil?
    bundle = reply.resource
    @valueset = bundle.entry[0].resource if bundle.entry.size > 0
  end

  @resources = Crucible::Generator::Resources.new

  if @valueset.nil?
    # The resource was not found, try to create it in case the server
    # dynamically calculates terminology operations based on local resources
    codesystem_types = @resources.load_fixture('terminology/codesystem-data-types.json')
    codesystem_rsrcs = @resources.load_fixture('terminology/codesystem-resource-types.json')
    valueset_defined = @resources.load_fixture('terminology/valueset-defined-types.json')
    @codesystem_types_id = @client.create(codesystem_types).id
    @codesystem_rsrcs_id = @client.create(codesystem_rsrcs).id
    @valueset_defined_id = @client.create(valueset_defined).id
    @valueset_defined.id = @valueset_defined_id
    @valueset = valueset_defined
  end

  v2_codesystem = @resources.load_fixture('terminology/v2-codesystem.json')
  v2_valueset = @resources.load_fixture('terminology/v2-valueset.json')
  @v2_codesystem_id = @client.create(v2_codesystem).id
  @v2_valueset_id = @client.create(v2_valueset).id
end

#teardownObject



58
59
60
61
62
63
64
65
66
67
# File 'lib/tests/suites/connectathon_terminology_track.rb', line 58

def teardown
  @client.destroy(FHIR::ValueSet, @valueset_defined_id) if @valueset_defined_id
  @client.destroy(FHIR::CodeSystem, @codesystem_types_id) if @codesystem_types_id
  @client.destroy(FHIR::CodeSystem, @codesystem_rsrcs_id) if @codesystem_rsrcs_id
  @client.destroy(FHIR::ValueSet, @v2_valueset_id) if @v2_valueset_id
  @client.destroy(FHIR::CodeSystem, @v2_codesystem_id) if @v2_codesystem_id
  # CT13 does # DELETE codesystem_simple
  # CT13 does # DELETE valueset_simple
  # CT17 does # DELETE conceptmap_created_id
end