如何在 HAPI FHIR 中包含完整对象而不是 "contained"
How to include the full object instead of "contained" in 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));
以上代码是 java 用于在 CoverageEligibilityRequest 中填充患者的代码段。
{
"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": [ {
...
...
} ]
},
我想用 actual string
省略 contained
的地方?
FHIR 通常不允许您将整个对象图表示为单个资源,因此如果您尝试将 Patient
资源作为 CoverageEligibilityRequest
资源的一部分发送,则唯一的方法是在 contained
字段中设置患者。 CoverageEligibilityResource.patient
字段定义为 Reference
类型,因此只能包含 the data allowed by a Reference
data type 而不是任意数据。
看起来您真正想要做的是向 HAPI FHIR 服务器添加一个 Patient
和一个引用患者的 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);
我是 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));
以上代码是 java 用于在 CoverageEligibilityRequest 中填充患者的代码段。
{
"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": [ {
...
...
} ]
},
我想用 actual string
省略 contained
的地方?
FHIR 通常不允许您将整个对象图表示为单个资源,因此如果您尝试将 Patient
资源作为 CoverageEligibilityRequest
资源的一部分发送,则唯一的方法是在 contained
字段中设置患者。 CoverageEligibilityResource.patient
字段定义为 Reference
类型,因此只能包含 the data allowed by a Reference
data type 而不是任意数据。
看起来您真正想要做的是向 HAPI FHIR 服务器添加一个 Patient
和一个引用患者的 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);