You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用Java FHIR Client调用$everything获取患者全部关联资源?

Java调用FHIR Client获取患者所有关联资源的正确方式

你之前用include(new Include("$everything"))无效,核心原因是:$everything不是FHIR搜索语法里的include参数,而是针对单个Patient实例的专属操作——对应你用Postman发起的Patient/12345/$everything请求,得用实例操作的方式调用,而非搜索接口。

直接替换成下面的代码就能实现需求:

Bundle bundle = myFhirClient
    .operation()
    .onInstance(new IdType("Patient", patientId)) // 定位到目标患者实例
    .named("$everything") // 调用$everything操作
    .returnResourceType(Bundle.class) // 指定返回结果为Bundle
    .execute();

额外说明

如果需要过滤返回的资源类型(比如只拿Encounter和Appointment),可以添加参数:

Bundle bundle = myFhirClient
    .operation()
    .onInstance(new IdType("Patient", patientId))
    .named("$everything")
    .withParameter(new StringClientParam("_type"), "Encounter,Appointment") // 过滤资源类型
    .returnResourceType(Bundle.class)
    .execute();

这个调用和你Postman里的请求完全等价,会返回该患者关联的所有指定资源。

内容的提问来源于stack exchange,提问作者Rasoul

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.14 16:36:18