Cómo ordenar los resultados de la búsqueda de atención médica
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
De forma predeterminada, cuando buscas datos de atención médica, los resultados de la búsqueda se muestran en orden cronológico inverso.
Cuando buscas en los siguientes tipos de recursos de FHIR que contienen texto no estructurado, puedes ordenar los resultados de la búsqueda según su relevancia para tu consulta:
Composición
DiagnosticReport
DocumentReference
Situación de ejemplo
Supongamos que buscas la palabra clave insulin para un paciente determinado y filtraste los resultados para mostrar los recursos que contienen texto no estructurado. Entre otros resultados, recibirás los siguientes documentos:
Resultado 1: Un recurso DocumentReference, con fecha del 24 de abril de 2024, que contiene notas sobre los niveles de "HbA1c" del paciente.
Resultado 2: Un recurso DiagnosticReport, con fecha del 11 de enero de 2024, que contiene notas sobre el "régimen de insulina" que debe seguir el paciente.
De forma predeterminada, el resultado 1 se muestra más arriba en los resultados porque es un documento más reciente, pero cuando los ordenas por relevancia, el resultado 2 aparece más arriba. Esto se debe a que es más relevante para la búsqueda insulin.
Cómo ordenar los resultados de la búsqueda de atención médica
Para ordenar los resultados de la búsqueda según su relevancia, completa los siguientes pasos:
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-09-08 (UTC)"],[[["\u003cp\u003eHealthcare data searches initially display results in reverse chronological order by default.\u003c/p\u003e\n"],["\u003cp\u003eWhen searching FHIR resource types like Composition, DiagnosticReport, and DocumentReference that contain unstructured text, results can be ordered by relevance instead.\u003c/p\u003e\n"],["\u003cp\u003eOrdering by relevance prioritizes results that are most closely related to the search query, rather than the newest document, as shown with the example of searching the keyword \u003ccode\u003einsulin\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eUsers can change the sorting order from reverse chronological to relevance within the Google Cloud console by selecting the "Relevance" filter for these specific resource types.\u003c/p\u003e\n"],["\u003cp\u003eUsing REST, sorting by relevance can be achieved by adding a \u003ccode\u003efilter\u003c/code\u003e field to limit the search results to Composition, DiagnosticReport, and DocumentReference resources and adding the \u003ccode\u003eorderBy\u003c/code\u003e field with the value \u003ccode\u003e_RELEVANCE\u003c/code\u003e in the request.\u003c/p\u003e\n"]]],[],null,["# Order healthcare search results\n\nBy default, when you [search healthcare data](/generative-ai-app-builder/docs/search-hc-data), the search results are returned in\nreverse chronological order.\nWhen you search over the following FHIR resource types that contain unstructured text, you can\norder your search results according to their relevance to your query:\n\n- Composition\n- DiagnosticReport\n- DocumentReference\n\nExample scenario\n----------------\n\nSuppose that you're searching for the keyword\n`insulin` for a given patient and you've filtered the results to the resources\nthat contain unstructured text. Among other results, you receive the following\ndocuments:\n\n- Result 1: A DocumentReference resource, dated 24 April, 2024, that contains notes about the patient's \"HbA1c\" levels.\n- Result 2: A DiagnosticReport resource, dated 11 January, 2024, that contains notes about the \"insulin regimen\" that the patient must follow.\n\nBy default, Result 1 is shown higher in the results because it is a newer\ndocument, but when you order by relevance, Result 2 shows up higher in the\nresults. This is because it is more relevant to the search query `insulin`.\n\nOrder your healthcare search results\n------------------------------------\n\nTo order your search results according to relevance, complete the following\nsteps: \n\n### Console\n\n1. In the Google Cloud console, go to the **AI Applications** page.\n\n [AI Applications](https://console.cloud.google.com/gen-app-builder/)\n2. Select the healthcare search app that you want to query.\n\n3. In the navigation menu, click **Preview**.\n\n4. In the **Patient ID** field, enter the ID of the patient whose data\n you want to query. Patient IDs are case-sensitive.\n\n5. Press **Enter** or click **Preview** to submit the patient ID.\n\n6. In the **Search here** search bar, enter your query.\n\n If you enabled autocomplete, you see a list of autocomplete suggestions below\n the search bar as you type.\n7. Press **Enter** to submit the query.\n\n - The search results are displayed in paginated tables that are categorized based on their FHIR resource type.\n - By default, the search results for all FHIR resource types are displayed in reverse chronological order.\n8. For the Composition, the DocumentReference, and the DiagnosticReport\n resources, click the **Sort: Reverse Chronological** filter and select\n **Relevance** from the list. The results for these resources are then ordered\n according to relevance.\n\n### REST\n\nTo order your search results according to relevance, modify your\n[`search`](/generative-ai-app-builder/docs/reference/rest/v1/projects.locations.collections.engines.servingConfigs/search) request in the following way:\n\n- Add the `filter` field to your request to limit the search results to only those FHIR resources that contain unstructured text: Composition, DiagnosticReport, and DocumentReference.\n- Add the `orderBy` field to your search request and set its value to `_RELEVANCE` to get search responses that are sorted according to their relevance.\n\n1. Send the search request.\n\n ```\n curl -X POST -H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n -H \"Content-Type: application/json\" \\\n \"https://us-discoveryengine.googleapis.com/v1/projects/PROJECT_ID/locations/us/collections/default_collection/engines/APP_ID/servingConfigs/default_search:search\" \\\n -d '{\n \"query\": \"KEYWORD_QUERY\",\n \"filter\": \"patient_id: ANY(\\\"PATIENT_ID\\\") AND resource_type: ANY(\\\"Composition\\\", \\\"DiagnosticReport\\\", \\\"DocumentReference\\\")\",\n \"orderBy\": \"_RELEVANCE\"\n }'\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the ID of your Google Cloud project.\n - \u003cvar translate=\"no\"\u003eAPP_ID\u003c/var\u003e: the ID of the Vertex AI Search app that you want to query.\n - \u003cvar translate=\"no\"\u003eKEYWORD_QUERY\u003c/var\u003e: the keyword that you want to search across the patient clinical data for the filtered patient, such as \"diabetes\" or \"a1c\".\n - \u003cvar translate=\"no\"\u003ePATIENT_ID\u003c/var\u003e: the resource ID of the patient whose data you want to search.\n\n You should receive a JSON response that contains itemized search results\n listed in the order of their relevance.\n\n\u003cbr /\u003e"]]