在SmartHealthIt FHIR服务器查询DiagnosticReport未获预期结果
如何在FHIR服务器上查找所有包含DiagnosticReport的患者集合
可行方案
方案1:从DiagnosticReport资源反向提取患者ID
利用DiagnosticReport必然关联Patient的特性,按以下步骤操作:
- 发起查询获取所有DiagnosticReport(可加
_summary=true精简返回内容):GET /DiagnosticReport?_summary=true - 遍历返回结果中的每个DiagnosticReport,提取其
subject字段里的Patient引用(格式为Patient/[患者ID])。 - 对提取到的患者ID去重,得到所有关联了DiagnosticReport的患者集合。
- 如果结果分页,跟随返回内容中的
next链接继续获取剩余DiagnosticReport,重复提取步骤。
方案2:用Patient的反向关联搜索(推荐)
FHIR标准支持_has参数实现反向关联筛选,直接查询符合条件的Patient:
GET /Patient?_has:DiagnosticReport:subject:exists=true
这个查询的逻辑是:筛选所有存在以该患者为subject的DiagnosticReport的Patient资源。服务器会直接返回符合条件的患者集合,无需手动提取去重。
关于你之前尝试的问题说明
- 你用的
Patient?_type=DiagnosticReport不是标准FHIR查询语法:_type参数用于指定返回的资源类型,同时指定Patient和DiagnosticReport会导致逻辑矛盾,服务器返回的结果是兼容处理的产物,不具备通用性。 Patient/[ID]?_elements=DiagnosticReport无效的原因是:Patient资源本身不包含DiagnosticReport元素,DiagnosticReport是独立的关联资源,需要通过$everything操作或单独查询DiagnosticReport来获取关联内容。
内容的提问来源于stack exchange,提问作者John
相关产品推荐
相关产品推荐

