Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Quando esegui query sui dati sanitari, puoi utilizzare i filtri per perfezionare le risposte della ricerca. In una richiesta di ricerca, puoi fornire filtri per applicare criteri che
includono o escludono determinate risposte di ricerca.
Ad esempio, quando cerchi i dati di un singolo paziente, il corpo della richiesta di ricerca deve contenere la seguente espressione di filtro che specifica l'ID paziente:
"filter": "patient_id: ANY(\"PATIENT_ID\")"
Questa pagina mostra come definire i filtri per la ricerca sanitaria.
I filtri vengono specificati nel campo filter nel corpo della richiesta del metodo
servingConfigs.search.
La definizione del filtro segue la sintassi delle espressioni di filtro.
Nell'espressione di filtro, il valore letterale può essere qualsiasi campo indicizzabile della
risposta alla query di ricerca. Ad esempio, se la risposta contiene una risorsa Observation, il patient_id a cui fa riferimento la risorsa Observation può essere utilizzato come valore letterale del filtro.
Le sezioni seguenti mostrano alcuni esempi di come creare filtri.
Definisci un filtro resource_datetime
Questo esempio mostra come specificare un filtro per una ricerca che includa solo
le risorse con un valore resource_datetime successivo al valore di data
e ora specificato.
L'esempio seguente mostra come creare un filtro che utilizza un operatore AND
per filtrare prima tutte le risorse Composition e poi quelle la cui
data è successiva a una data e un'ora specificate.
"filter": "resource_type: ANY("Composition") AND Composition.date > "2022-08-05T01:00:00+00:00""
Definisci un filtro delle risorse FHIR
Puoi utilizzare un filtro per verificare se una risorsa FHIR è presente nel datastore di Vertex AI Search. Ad esempio, puoi cercare una risorsa DocumentReference con l'ID 6112d1ac-c6bd-4755-d689-bfb71d59afc5 utilizzando il seguente filtro.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-05 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```"]]