Class: Crucible::Tests::SprinklerSearchTest

Inherits:
BaseSuite show all
Defined in:
lib/tests/suites/sprinkler_search_test.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 collapse

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) ⇒ SprinklerSearchTest

Returns a new instance of SprinklerSearchTest.



15
16
17
18
# File 'lib/tests/suites/sprinkler_search_test.rb', line 15

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

Instance Attribute Details

#use_postObject

Returns the value of attribute use_post.



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

def use_post
  @use_post
end

Instance Method Details

#create_observation(value) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/tests/suites/sprinkler_search_test.rb', line 60

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



11
12
13
# File 'lib/tests/suites/sprinkler_search_test.rb', line 11

def description
  'Initial Sprinkler tests for testing search capabilities.'
end

#idObject



7
8
9
# File 'lib/tests/suites/sprinkler_search_test.rb', line 7

def id
  'Search001'
end

#setupObject



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
# File 'lib/tests/suites/sprinkler_search_test.rb', line 20

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
  @patient.gender = nil
  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,3)
  @condition.subject = @entries.first.try(:resource).try(:to_reference)
  reply = @client.create(@condition)
  @condition_id = reply.id

  # create some observations
  @obs_a = create_observation(2.0)
  @obs_b = create_observation(1.96)
  @obs_c = create_observation(2.04)
  @obs_d = create_observation(1.80)
  @obs_e = create_observation(5.12)
  @obs_f = create_observation(6.12)
end

#teardownObject



81
82
83
84
85
86
87
88
89
90
91
# File 'lib/tests/suites/sprinkler_search_test.rb', line 81

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
  @client.destroy(FHIR::Observation, @obs_f) if @obs_f
end