Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Ao consultar dados de saúde, você pode usar filtros para refinar as respostas da pesquisa. Em uma solicitação de pesquisa, é possível fornecer filtros para aplicar critérios que
incluem ou excluem determinadas respostas de pesquisa.
Por exemplo, ao pesquisar os dados de um único paciente, o corpo da solicitação de pesquisa precisa conter a seguinte expressão de filtro que especifica o ID do paciente:
"filter": "patient_id: ANY(\"PATIENT_ID\")"
Nesta página, mostramos como definir filtros para a pesquisa de saúde.
Confira a lista de recursos do FHIR R4 compatíveis com a Vertex AI para Pesquisa
como campos indexáveis, pesquisáveis e recuperáveis.
Para mais informações, consulte Referência do esquema de dados R4 do FHIR de saúde.
Os filtros são especificados no campo filter no corpo da solicitação do método
servingConfigs.search.
A definição de filtro segue a sintaxe da expressão de filtro.
Na expressão de filtro, o literal pode ser qualquer campo indexável da resposta à consulta de pesquisa. Por exemplo, se a resposta contiver um recurso "Observation",
o patient_id referenciado por ele poderá ser usado como um literal de filtro.
As seções a seguir mostram alguns exemplos de como criar filtros.
Definir um filtro resource_datetime
Este exemplo mostra como especificar um filtro para uma pesquisa que inclui apenas os recursos com um valor resource_datetime posterior à data e hora especificadas.
O exemplo a seguir mostra como criar um filtro que usa um operador AND
para primeiro filtrar todos os recursos de composição e depois aqueles cuja
data é posterior a uma data e hora especificadas.
"filter": "resource_type: ANY("Composition") AND Composition.date > "2022-08-05T01:00:00+00:00""
Definir um filtro de recursos FHIR
É possível usar um filtro para verificar se um recurso FHIR está presente no repositório de dados da Vertex AI para Pesquisa. Por exemplo, é possível pesquisar um recurso
DocumentReference que tenha o ID
6112d1ac-c6bd-4755-d689-bfb71d59afc5 usando o filtro a seguir.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-19 UTC."],[[["\u003cp\u003eGenerative AI services within this platform are restricted from use in clinical settings for direct diagnosis or treatment without a licensed professional's review, although non-clinical administrative tasks are permitted.\u003c/p\u003e\n"],["\u003cp\u003eThe outputs generated by this service, being based on large language models, may contain inaccuracies, biases, or stereotypes, and should always be treated as drafts requiring review.\u003c/p\u003e\n"],["\u003cp\u003eThis tool is intended solely for retrieving and summarizing existing medical information, not for providing advice on the prevention, diagnosis, or treatment of any illness or disease.\u003c/p\u003e\n"],["\u003cp\u003eThe applicability of this product is limited for individuals under 18 and over 85 due to limited testing data, necessitating careful consideration of the source data's subpopulation representation when analyzing results.\u003c/p\u003e\n"],["\u003cp\u003eWhen querying healthcare data, users can utilize filters such as patient ID, date/time, and resource type to refine search responses by including or excluding specific criteria.\u003c/p\u003e\n"]]],[],null,["# Filter healthcare search\n\n| **Caution:**\n|\n| - Restrictions for healthcare: As a customer, you will not, and will not allow End Users to, use the Generative AI Services for clinical purposes (for clarity, non-clinical research, scheduling, or other administrative tasks is not restricted), as a substitute for professional medical advice, or in any manner that is overseen by or requires clearance or approval from any applicable regulatory authority. For more information, see [Service Specific Terms](https://cloud.google.com/terms/service-terms).\n|\n| For clarity, with respect to the use of Vertex AI Search to retrieve and\n| summarize existing medical information, the restriction on the use for clinical\n| purposes means the restriction on the use for direct diagnosis or treatment purposes without review by\n| a licensed professional in compliance with applicable laws and regulations.\n| - The generated output may not always be completely reliable. Due to the nature of LLMs and Generative AI, outputs may have incorrect or biased (for example, stereotypes or other harmful content) information and should be reviewed. All summaries or answers should be considered draft and not final.\n| - This product's intended usage 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. This product's intended use is to retrieve and summarize existing medical information provided by users.\n| - Due to limited test data, this product may or may not be applicable to age group 0-18 and to age group 85 and above. Therefore, when reviewing the generated output, customers must consider the representativeness of subpopulations within their source data.\n\n\u003cbr /\u003e\n\nWhen you're querying healthcare data, you can use filters to refine your search\nresponses. In a search request, you can provide filters to enforce criteria that\ninclude or exclude certain search responses.\n\nFor example, when you're\n[searching over a single patient's data](/generative-ai-app-builder/docs/search-hc-data), the search request\nbody must contain the following filter expression that specifies the patient ID: \n\n```\n\"filter\": \"patient_id: ANY(\\\"PATIENT_ID\\\")\"\n```\n\nThis page shows you how to define filters for healthcare search.\n\nBefore you begin\n----------------\n\nBefore you begin, do the following:\n\n- Create a healthcare search app and a healthcare search data store, and import FHIR R4 data. For more information, see [Create a healthcare search app](/generative-ai-app-builder/docs/create-app-hc) and [Create a healthcare search data store](/generative-ai-app-builder/docs/create-data-store-hc).\n- Review the list of FHIR R4 resources that Vertex AI Search supports as indexable, searchable, and retrievable fields. For more information, see [Healthcare FHIR R4 data schema reference](/generative-ai-app-builder/docs/fhir-schema-reference).\n- Understand the [filter expression syntax](/generative-ai-app-builder/docs/filter-search-metadata#filter-expression-syntax).\n\nDefine filters\n--------------\n\nFilters are specified in the `filter` field in the request body of the\n[`servingConfigs.search`](/generative-ai-app-builder/docs/reference/rest/v1alpha/projects.locations.collections.dataStores.servingConfigs/search) method.\n\nThe filter definition follows the [filter expression syntax](/generative-ai-app-builder/docs/filter-search-metadata#filter-expression-syntax).\nIn the filter expression, the literal can be any indexable field from the\nresponse to the search query. For example, if the response contains an Observation resource,\nthe `patient_id` that the Observation resource references can be used as a filter\nliteral.\n\nThe following sections show a few examples on how to construct filters.\n\n### Define a `resource_datetime` filter\n\nThis example shows you how to specify a filter for a search that includes only\nthose resources that have a `resource_datetime` value later than the specified date\nand time value. \n\n### REST\n\n```\ncurl -X POST -H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n -H \"Content-Type: application/json\" \\\n \"https://us-discoveryengine.googleapis.com/v1alpha/projects/PROJECT_ID/locations/us/collections/default_collection/dataStores/DATA_STORE_ID/servingConfigs/default_search:search\" \\\n -d '{\n\"query\": \"QUERY\",\n\"filter\": \"patient_id: ANY(\\\"PATIENT_ID\\\") AND resource_datetime \u003e \\\"DATE_TIME_VALUE,\n\"contentSearchSpec\":{\"snippetSpec\":{\"returnSnippet\":true}}\n}'\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the ID of your Google Cloud project.\n- \u003cvar translate=\"no\"\u003eDATA_STORE_ID\u003c/var\u003e: the ID of the Vertex AI Search data store.\n- \u003cvar translate=\"no\"\u003eQUERY\u003c/var\u003e: the search query.\n- \u003cvar translate=\"no\"\u003ePATIENT_ID\u003c/var\u003e: the resource ID of the patient whose data you want to search.\n- \u003cvar translate=\"no\"\u003eDATE_TIME_VALUE\u003c/var\u003e: the value of the `resource_datetime` field that represents a date and time in the FHIR [dateTime](https://build.fhir.org/datatypes.html#dateTime) format. Some examples of this field are as follows:\n - To specify a date and time with a time zone separated by a `T` separator: `2022-08-05T01:00:00+00:00`\n - To specify a date: `2022-08-05`\n - To specify a month: `2022-08`\n - To specify a year: `2022`\n\n#### Response\n\n\nYou should receive a JSON response similar to the following truncated\nresponse. The response contains itemized search results listed in reverse\nchronological order with snippets, if snippets are available. The\n`structData` field contains the structured JSON data for the\ndocument. \n\n```\n{\n \"results\": [\n {\n \"id\": \"DOCUMENT_ID\",\n \"document\": {\n \"name\": \"projects/PROJECT_ID/locations/us/collections/default_collection/dataStores/DATA_STORE_ID/branches/0/documents/DOCUMENT_ID\",\n \"id\": \"DOCUMENT_ID\",\n \"structData\": {\n ...\n \"resource_type\": \"FHIR_RESOURCE_TYPE\",\n \"resource_datetime\": \"RESOURCE_DATETIME\",\n \"patient_id\": \"PATIENT_ID\",\n \"FHIR_RESOURCE_TYPE\": { ... }\n },\n \"derivedStructData\": {\n \"snippets\": [\n {\n \"snippet\": \"SNIPPET_TEXT\",\n \"snippet_status\": \"SUCCESS\"\n }\n ]\n }\n }\n }]\n}\n```\n\n\u003cbr /\u003e\n\n### Define a resource type filter\n\nThe following example shows how to construct a filter that uses an `AND`\noperator to first filter all Composition resources and then filter those whose\ndate is later than a specified date and time. \n\n```\n\"filter\": \"resource_type: ANY(\"Composition\") AND Composition.date \u003e \"2022-08-05T01:00:00+00:00\"\"\n```\n\n### Define a FHIR resource filter\n\nYou can use a filter to check whether a FHIR resource is present in the\nVertex AI Search data store. For example, you can search for a\nDocumentReference resource that has the ID\n`6112d1ac-c6bd-4755-d689-bfb71d59afc5` using the following filter. \n\n```\n\"filter\": \"DocumentReference.id: ANY(\\\"6112d1ac-c6bd-4755-d689-bfb71d59afc5\\\")\"\n```"]]