class Crucible::Tests::SprinklerSearchTest
Attributes
use_post[RW]
Public Class Methods
new(client1, client2=nil)
click to toggle source
Calls superclass method
Crucible::Tests::BaseTest::new
# 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
Public Instance Methods
create_observation(value)
click to toggle source
# 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
description()
click to toggle source
# File lib/tests/suites/sprinkler_search_test.rb, line 11 def description 'Initial Sprinkler tests for testing search capabilities.' end
id()
click to toggle source
# File lib/tests/suites/sprinkler_search_test.rb, line 7 def id 'Search001' end
setup()
click to toggle source
# 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
teardown()
click to toggle source
# 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