Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Lorsque vous interrogez des données de santé, vous pouvez utiliser des filtres pour affiner les réponses à vos recherches. Dans une demande de recherche, vous pouvez fournir des filtres pour appliquer des critères qui incluent ou excluent certaines réponses de recherche.
Par exemple, lorsque vous recherchez les données d'un seul patient, le corps de la requête de recherche doit contenir l'expression de filtre suivante qui spécifie l'ID du patient :
"filter": "patient_id: ANY(\"PATIENT_ID\")"
Cette page vous explique comment définir des filtres pour la recherche dans le secteur de la santé.
Les filtres sont spécifiés dans le champ filter du corps de la requête de la méthode servingConfigs.search.
La définition du filtre suit la syntaxe des expressions de filtre.
Dans l'expression de filtre, le littéral peut être n'importe quel champ indexable de la réponse à la requête de recherche. Par exemple, si la réponse contient une ressource Observation, le patient_id auquel la ressource Observation fait référence peut être utilisé comme littéral de filtre.
Les sections suivantes présentent quelques exemples de création de filtres.
Définir un filtre resource_datetime
Cet exemple vous montre comment spécifier un filtre pour une recherche qui n'inclut que les ressources dont la valeur resource_datetime est postérieure à la date et à l'heure spécifiées.
L'exemple suivant montre comment créer un filtre qui utilise un opérateur AND pour filtrer d'abord toutes les ressources Composition, puis celles dont la date est postérieure à une date et une heure spécifiées.
"filter": "resource_type: ANY("Composition") AND Composition.date > "2022-08-05T01:00:00+00:00""
Définir un filtre de ressources FHIR
Vous pouvez utiliser un filtre pour vérifier si une ressource FHIR est présente dans le data store Vertex AI Search. Par exemple, vous pouvez rechercher une ressource DocumentReference dont l'ID est 6112d1ac-c6bd-4755-d689-bfb71d59afc5 à l'aide du filtre suivant.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/05 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 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```"]]