java - 如何在 HAPI FHIR 中包含完整对象而不是“包含”
问题描述
我对 hapi FHIR 很陌生,我正在尝试以以下格式对请求进行编码。
CoverageEligibilityRequest coverageEligibilityRequest = new CoverageEligibilityRequest();
Patient patient = new Patient().addIdentifier(new Identifier().setType(getPatientIdentifierCodeableConcept()).setSystem("http://www.abc.xyz").setValue("123"));
coverageEligibilityRequest.setPatient(new Reference(patient));
上面的代码是用于在 CoverageEligibilityRequest 中填充患者的 java 片段。
{
"resourceType": "Bundle",
"type": "batch",
"entry": [ {
"resource": {
"resourceType": "CoverageEligibilityRequest",
"id": "7890",
"contained": [ {
"resourceType": "Patient",
"id": "1",
"identifier": [ {
"type": {
"coding": [ {
...
...
}
但我希望请求应采用以下格式
{
"resourceType": "Bundle",
"type": "batch",
"entry": [ {
"resource": {
"resourceType": "CoverageEligibilityRequest",
"id": "7890",
"patient": {
"type": "Patient",
"identifier": {
"type": {
"coding": [ {
...
...
} ]
},
我想在哪里contained
省略actual string
?
解决方案
FHIR 通常不允许您将整个对象图表示为单个资源,因此如果您尝试将Patient
资源作为资源的一部分发送CoverageEligibilityRequest
,那么您可以做到这一点的唯一方法是将患者设置在contained
现场。该CoverageEligibilityResource.patient
字段被定义为一种Reference
类型,因此只能包含数据类型允许的Reference
数据,不能包含任意数据。
看起来您实际上想要做的是向Patient
HAPI FHIR 服务器和CoverageEligibilityRequest
引用患者的资源添加一个。在 FHIR 中执行此操作的正确方法是构建包含这两种资源的单个batch
或transaction
捆绑包。基本上,您想要构建一个Bundle
看起来像这样的:
{
"resourceType": "Bundle",
"type": "batch",
"entry": [ {
"resource": {
"resourceType": "Patient",
"id": "1",
"identifier": [ {
"type": {
"coding": [ {
...
}
}, {
"resource": {
"resourceType": "CoverageEligibilityRequest",
"id": "7890",
"patient": "Patient/1",
...
在 HAPI FHIR 中构造类似内容的最简单方法是使用这样的transaction
包:
IGenericClient client = ...
CoverageEligibilityRequest coverageEligibilityRequest = new CoverageEligibilityRequest();
Patient patient = new Patient().addIdentifier(new Identifier().setType(getPatientIdentifierCodeableConcept()).setSystem("http://www.abc.xyz").setValue("123"));
coverageEligibilityRequest.setPatient(new Reference(patient));
client.transaction().withResources(patient, coverageEligibilityRequest);
推荐阅读
- php - e型控制器laravel
- wolfram-mathematica - 在 Wolfram Mathematica 中,我应该如何高效方便地查询 Counts 运算的结果?
- java - REST API Jersey 2.0 NoSuchFieldError: INCLUDE_ALL
- hibernate - 如何使用 JPA 匹配表的列
- regex - 如何否定一个?(问题字符)golang regexp 中的字符
- xcode - Flutter stable 1.17.1 和 Xcode 11.5 问题
- python - 将 numpy 函数数组应用于元素数组
- android - 给定的工件包含一个带有包引用“android.support.v4”的字符串文字,无法安全地重写
- freemarker - Freemarker 模板中的空值
- r - 在 ggplot 中使用参数占位符