Skip to content

2. Create a new search test

Elsa Perelli edited this page Oct 23, 2024 · 17 revisions

Goal

Let's say we're implementing the US Core version 3.1.1 implementation guide. The inferno-template test kit already includes a Patient search test and a validation test for us to start with. Looking at the US Core IG Condition profile, we see that Condition search by Patient is a SHALL requirement.

Our goal is to add a test that searches for Conditions that pertain to the Patient we already searched for. After performing this search, we want to assert the following:

  • http response is 200
  • search result is a resourceType of Bundle
  • search result is a valid FHIR resource

Resources

Solution

group do
  id :search_tests
  title 'Search Tests'

  input :patient_id

  test do
    title 'Condition Search by Patient'

    run do
      fhir_search('Condition', params: { patient: patient_id })

      assert_response_status(200)
      assert_resource_type('Bundle')
      assert_valid_bundle_entries()
    end
  end
end

link to the diff between step-2 and step-2-solution branches: https://github.com/inferno-training/inferno-tutorial/compare/step-2...step-2-solution

Clone this wiki locally