Search healthcare data

After importing FHIR R4 data into your healthcare search app, you can query the imported data to get relevant results. You can search using the following types of queries:

  • Keyword query
  • Natural language query
  • Natural language query with a generative AI answer

Additionally, you can filter your search using date-filtered queries. For more information, see Define a resource_datetime filter.

When you search in the Google Cloud console, you must first provide a patient ID and search over a single patient's data at a time. When you search using the REST API, you can search over your entire data store.

This page shows how to search healthcare data using the various types of queries.

Intended use of Vertex AI Search for searching healthcare data

The intended usage of Vertex AI Search is not to provide information pertaining to the prevention, diagnosis, or treatment of illness or disease. Questions regarding diagnosis or treatment recommendations are not intended to be addressed by the product. The intended use of this product is to retrieve and summarize existing medical information provided by users.

Due to limited test data, this product may or may not be applicable to age groups 0-18, and 85 and above. Therefore, when reviewing the generated output, customers must consider the representativeness of subpopulations within their source data.

The following are a few examples of how this product is intended to be used:

  • Exploratory queries to find a patient's information relevant to a topic:

    • "Summarize the aspirin uses"
    • "blood pressure"
    • "diabetes management?"
  • Navigational queries to find specific resources that could be mapped to a structured query:

    • "Show me the most recent a1c"
  • Extractive questions and answers to answer specific questions where evidence may be spread across resources:

    • "Has this patient ever been treated with a cephalsporin"
    • "Has the patient ever undergone psychiatry evaluation"

The following are examples of how this product is not intended to be used:

  • Diagnosis recommendations and treatment recommendations:

    • "What is the differential diagnosis for this patient?"
    • "What drugs should I prescribe to the patient?"

Before you begin

Before you search, do the following:

You can search your healthcare data store using a keyword. For example, you can search using keywords such as "a1c", "insulin", or "ulcer" to get relevant FHIR resources.

The following image shows the search results when the keyword is "lipid". This example doesn't include a summary or generative AI answer.

Query is 'lipid'.
Figure 1. Search using keyword.

To search using a keyword, complete the following steps.

Console

  1. In the Google Cloud console, go to the Agent Builder page.

    Agent Builder

  2. Select the healthcare search app that you want to query.

  3. In the navigation menu, click Preview.

  4. In the Patient ID field, enter the ID of the patient whose data you want to query. Patient IDs are case-sensitive.

  5. Press Enter or click Preview to submit the patient ID.

  6. In the Search here search bar, type a keyword to search.

    If you enabled autocomplete, you see a list of autocomplete suggestions below the search bar as you type.

  7. Press Enter to submit the query.

    The search results are displayed in paginated tables that are categorized based on their FHIR resource type.

  8. Optional. Select one or more FHIR resource categories that are under the search bar to filter the results.

REST

The following sample shows how to search a single patient's FHIR R4 data in the healthcare search app using a keyword. This sample uses the servingConfigs.search method.

  1. Search using a keyword.

    curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" \
      -H "Content-Type: application/json" \
      "https://us-discoveryengine.googleapis.com/v1alpha/projects/PROJECT_ID/locations/us/collections/default_collection/dataStores/DATA_STORE_ID/servingConfigs/default_search:search" \
      -d '{
    "query": "KEYWORD_QUERY",
    "filter": "patient_id: ANY(\"PATIENT_ID\")",
    "contentSearchSpec":{"snippetSpec":{"returnSnippet":true}}
    }'
    

    Replace the following:

    • PROJECT_ID: the ID of your Google Cloud project.
    • DATA_STORE_ID: the ID of the Vertex AI Search data store.
    • KEYWORD_QUERY: the keyword that you want to search across the patient clinical data for the filtered patient, such as "diabetes" or "a1c".
    • PATIENT_ID: the resource ID of the patient whose data you want to search.

Using Vertex AI Search, you can get results for complex natural language queries. For example, the following image shows the results for the the natural language query: "Lab results related to diabetes".

Query is 'What are the patient's lipid labs'.
Figure 2. Search using natural language query.

To search using natural language query, complete the following steps.

Console

  1. In the Google Cloud console, go to the Agent Builder page.

    Agent Builder

  2. Select the healthcare search app that you want to query.

  3. In the navigation menu, click Preview.

  4. In the Patient ID field, enter the patient ID of the patient whose data you want to query. Patient IDs are case-sensitive.

  5. Press Enter or click Preview to submit the patient ID.

  6. In the Search here search bar, enter a natural language query, such as "Lab results related to diabetes".

    If you enabled autocomplete, you see a list of autocomplete suggestions below the search bar as you type.

  7. Press Enter to submit the query.

    The search results are displayed in paginated tables that are categorized based on their FHIR resource type.

  8. Optional. Select one or more FHIR resource categories that are under the search bar to filter the results.

REST

The following sample shows how to search a single patient's FHIR R4 data in the healthcare search app using a natural language query. This sample uses the servingConfigs.search method. To search using a natural language query, you must add the natural_language_query_understanding_spec field to the request body.

  1. Post a query in natural language.

    curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" \
      -H "Content-Type: application/json" \
      "https://us-discoveryengine.googleapis.com/v1alpha/projects/PROJECT_ID/locations/us/collections/default_collection/dataStores/DATA_STORE_ID/servingConfigs/default_search:search" \
      -d '{
    "query": "NATURAL_LANGUAGE_QUERY",
    "filter": "patient_id: ANY(\"PATIENT_ID\")",
    "contentSearchSpec":{"snippetSpec":{"returnSnippet":true}},
    "natural_language_query_understanding_spec":{"filter_extraction_condition":"ENABLED"}
    }'
    

    Replace the following:

    • PROJECT_ID: the ID of your Google Cloud project.
    • DATA_STORE_ID: the ID of the Vertex AI Search data store.
    • NATURAL_LANGUAGE_QUERY: the query in natural language, such as "Lab results related to diabetes" or "Is the patient currently on any medication".
    • PATIENT_ID: the resource ID of the patient whose data you want to search.

Search using natural language query with generative AI answer

When you search a patient's FHIR data using a natural language query, you can choose to get a generative AI answer along with the search results. The answer summarizes the search results and also shows the references that are used to generate the answer.

When using the console, you can select the large language model (LLM) for generative AI answers. For more information, see Configure search results for healthcare data.

When using the REST API, you can specify one of the following LLM models to give you generative AI answers in the version field:

  • text-bison@001/answer_gen/v1 or stable: a stable, generally available model that's based on the text-bison model (default). For more information, see Generally available (GA) models.
  • gemini-1.0-pro-001/answer_gen/v1: a preview model that's based on the gemini-pro model. For more information, see Preview models.
  • preview: a preview model that's based on the MedLM model. For more information, see MedLM model.

The following image shows an example of a natural language query with generative AI answer. The search summary provides an answer for the query by summarizing the findings from relevant results. You can expand segments that have citations to see the references that are used to generate the selected segment. Not all generated answers have citations.

Query is 'What are the
patient's lipid labs'. The search results are shown in a tabular
format . The
search results are accompanied by a generative AI generated summary that reads quote The patient has no
known allergies endquote.
Figure 3. Search using natural language query with generative AI answer.

To search with generative AI answer, do the following:

Console

  1. In the Google Cloud console, go to the Agent Builder page.

    Agent Builder

  2. Select the healthcare search app that you want to query.

  3. In the navigation menu, click Configurations.

  4. Customize the search widget:

    1. In the Search type field, select Search with an answer.
    2. Select the model that you want to use to generate the summary. For more information, see Configure search results for healthcare data
    3. Save and publish your preferences.
  5. In the navigation menu, click Preview.

  6. In the Patient ID field, enter the patient ID of the patient whose data you want to query. Patient IDs are case-sensitive.

  7. Press Enter or click Preview to submit the patient ID.

  8. In the Search here search bar, enter a natural language query, such as "nsaids", "What are the patient's lipid labs", or "What is the most recent A1C result".

    If you enabled autocomplete, you see a list of autocomplete suggestions below the search bar as you type.

  9. Press Enter to submit the query.

    The search results are displayed in paginated tables that are categorized based on their FHIR resource type.

  10. Optional. Select one or more FHIR resource categories that are under the search bar to filter the results.

  11. Optional. Expand a segment of the answer that has citations to see its references from the search results.

REST

The following sample shows how to search a single patient's FHIR R4 data in the healthcare search app using a natural language query with generative AI answers. This sample uses the servingConfigs.search method. To search using a natural language query, you must add the natural_language_query_understanding_spec field to the request body.

  1. Post a query in natural language.

    curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" \
      -H "Content-Type: application/json" \
      "https://us-discoveryengine.googleapis.com/v1alpha/projects/PROJECT_ID/locations/us/collections/default_collection/dataStores/DATA_STORE_ID/servingConfigs/default_search:search" \
      -d '{
            "query": "QUERY",
            "filter": "patient_id: ANY(\"PATIENT_ID\")",
            "contentSearchSpec": {
              "snippetSpec": {
                "returnSnippet": true
              },
              "summary_spec": {
                "summary_result_count": 1,
                "model_spec": {
                  "version": "MODEL_VERSION"
                }
              }
            },
            "natural_language_query_understanding_spec": {
              "filter_extraction_condition": "ENABLED"
            }
          }'
    

    Replace the following:

    • PROJECT_ID: the ID of your Google Cloud project.
    • DATA_STORE_ID: the ID of the Vertex AI Search data store.
    • QUERY: the query in natural language, such as "nsaids", "What are the patients lipid labs", or "What is the most recent A1C result". If the query includes an apostrophe ', you must replace it with apostrophe's numeric character reference: '.
    • PATIENT_ID: the resource ID of the patient whose data you want to search.
    • MODEL_VERSION: the model version that you want to use to generate the answer.