Skip to main content

AI-assisted FHIR search

Use AIFhirResources() to turn a natural-language question into a FHIR search plan and a summarized response. The method returns the generated plan, resources found for the plan, and a Markdown summary.

Pass the question in the text property. The authenticated client and project determine the data available to the search.

const result = await client.AIFhirResources({
text: 'Summarize the latest blood pressure observations',
});

renderSummary(result.markdown);

The example's renderSummary() is application UI code. The response can also be used to show the search plan and its matched resources:

for (const request of result.plan.requests) {
console.log(request.identifier, request.resourceType, request.query);
}

for (const [identifier, matches] of Object.entries(result.results)) {
console.log(identifier, matches.map((match) => match.resource));
}

Understand the response​

FieldContents
markdownA generated Markdown summary of the search results.
planThe generated query plan. It contains requests and can include a child plan or visible result identifiers.
resultsA map from request identifiers to arrays of result objects. Each result object contains a resource.

Each plan request provides an identifier, a FHIR resourceType, and a query. Use the identifier to associate the corresponding result group with the plan request. Resource values are returned as untyped data, so validate the fields your UI reads before rendering them.

Review generated output​

The query plan and summary are AI-generated and can be incorrect or incomplete. Treat them as search assistance: inspect the returned resources and apply the application's own access controls and validation before using the result. Do not use the generated summary as a diagnosis or clinical decision.

For resource formats, see the FHIR Observation reference and the data ingestion guide. For typed measurement read and save workflows, see Measurements and health data.