Class: Crucible::Tests::RobustSearchTest

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

Constant Summary

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

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, #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_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) ⇒ RobustSearchTest

Returns a new instance of RobustSearchTest.



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

def initialize(client1, client2=nil)
  super(client1, client2)
  @category = {id: 'core_functionality', title: 'Core Functionality'}
end

Instance Method Details

#create_observation(value) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/tests/suites/search_test_robust.rb', line 67

def create_observation(value)
  observation = FHIR::Observation.new
  observation.status = 'preliminary'
  code = FHIR::Coding.new
  code.system = 'http://loinc.org'
  code.code = '2164-2'
  observation.code = FHIR::CodeableConcept.new
  observation.code.coding = [ code ]
  observation.valueQuantity = FHIR::Quantity.new
  observation.valueQuantity.system = 'http://unitofmeasure.org'
  observation.valueQuantity.value = value
  observation.valueQuantity.unit = 'mmol'
  body = FHIR::Coding.new
  body.system = 'http://snomed.info/sct'
  body.code = '182756003'
  observation.bodySite = FHIR::CodeableConcept.new
  observation.bodySite.coding = [ body ]
  reply = @client.create(observation)
  reply.id
end

#descriptionObject



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

def description
  'Deeper testing of search capabilities.'
end

#idObject



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

def id
  'Search002'
end

#setupObject



18
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
57
58
59
60
61
62
63
64
65
# File 'lib/tests/suites/search_test_robust.rb', line 18

def setup
  # Create a patient with gender:missing
  @resources = Crucible::Generator::Resources.new
  @patient = @resources.minimal_patient
  @patient.identifier = [FHIR::Identifier.new]
  @patient.identifier[0].value = SecureRandom.urlsafe_base64
  result = @client.create(@patient)
  @patient_id = result.id

  # read all the patients
  @read_entire_feed=true
  @client.use_format_param = true
  reply = @client.read_feed(FHIR::Patient)
  @read_entire_feed=false if (!reply.nil? && reply.code!=200)
  @total_count = 0
  @entries = []

  while reply != nil && !reply.resource.nil?
    @total_count += reply.resource.entry.size
    @entries += reply.resource.entry
    reply = @client.next_page(reply)
    @read_entire_feed=false if (!reply.nil? && reply.code!=200)
  end

  # create a condition matching the first patient
  @condition = ResourceGenerator.generate(FHIR::Condition,1)
  @condition['patient'] = ResourceGenerator.generate(FHIR::Reference)
  @condition.patient.xmlId = @entries.try(:[],0).try(:resource).try(:xmlId)
  options = {
    :id => @entries.try(:[],0).try(:resource).try(:xmlId),
    :resource => @entries.try(:[],0).try(:resource).try(:class)
  }
  temp = @client.use_format_param
  @client.use_format_param = false
  patient_url = @client.resource_url(options)
  patient_url = patient_url[1..-1] if patient_url[0]=='/'
  @client.use_format_param = temp
  @condition.patient.reference = patient_url
  reply = @client.create(@condition)
  @condition_id = reply.id

  # create some observations
  @obs_a = create_observation(4.12345)
  @obs_b = create_observation(4.12346)
  @obs_c = create_observation(4.12349)
  @obs_d = create_observation(5.12)
  @obs_e = create_observation(6.12)
end

#teardownObject



88
89
90
91
92
93
94
95
96
97
# File 'lib/tests/suites/search_test_robust.rb', line 88

def teardown
  @client.use_format_param = false
  @client.destroy(FHIR::Patient, @patient_id) if @patient_id
  @client.destroy(FHIR::Condition, @condition_id) if @condition_id
  @client.destroy(FHIR::Observation, @obs_a) if @obs_a
  @client.destroy(FHIR::Observation, @obs_b) if @obs_b
  @client.destroy(FHIR::Observation, @obs_c) if @obs_c
  @client.destroy(FHIR::Observation, @obs_d) if @obs_d
  @client.destroy(FHIR::Observation, @obs_e) if @obs_e
end