tencent cloud

Bundling Multiple Associated Resources

Download
フォーカスモード
フォントサイズ
最終更新日: 2026-08-28 16:06:55
AI翻訳

API Description

This function is used to submit multiple related resources in a single Bundle transaction. This approach is suitable for writing patient data and related resources such as lab tests, visits, and diagnoses together, ensuring these resources are processed as a whole within the same submission.
When the resource identifier is known, you can use a client-defined ID and directly establish reference relationships between resources using these IDs.

Input parameters

Parameter Name
Type
Required
Description
HTTP Method
String
Yes
Fixed to POST.
URL
String
Yes
The Bundle submission URL, in the format [baseUrl].
Authorization
String
Yes
The authentication token, in the format Bearer <AccessToken>. The AccessToken is obtained via the GetAccessToken API in Calling Methods (or via the GetWebAccessToken API in the instance console scenario).
Content-Type
String
Yes
The MIME type of the request body, with application/fhir+json as an example.
Request Body
JSON Object
Yes
A transaction Bundle containing multiple associated resources.
Request Body Main Field Descriptions:
Field
Type
Required
Description
resourceType
String
Yes
Fixed as Bundle.
type
String
No
The Bundle type specifies the transaction processing method. The values are as follows:
transaction: The transaction mode, where all entries are submitted as a whole, and if any entry fails, all are rolled back.
batch: The batch processing mode, where entries are processed independently without affecting each other. For details, see FHIR BundleType.
When not specified, the server processes requests in transaction mode by default.
entry
Array
Yes
Multiple resource entries.
entry[].fullUrl
String
No
Unique identifier of the resource within the Bundle.
entry[].resource.id
String
No
The client specifies the resource ID. When a client-defined ID is used, ensure that entry[].request.method is PUT and entry[].request.url is [resourceType]/[id]. The server then creates or updates the resource with this ID. If the resource ID is not specified, the server generates the ID automatically.
entry[].resource.subject.reference
String
No
A reference to other resources.
entry[].request.method
String
Yes
The request method for the entry.
entry[].request.url
String
Yes
The target resource path for the entry.

Output Parameters

Upon a successful API call, the HTTP status code 200 OK or 201 Created is typically returned. The response headers contain the content type and request trace information, and the response body is usually a result Bundle that includes the execution status of each resource entry.
Response Header Example Description:
Parameter Name
Type
Description
Status Code
Integer
Returns 200 OK or 201 Created when successful.
Content-Type
String
The MIME type of the response body, typically application/fhir+json.
x-request-id
String
Request trace ID.
Key Response Body Field Descriptions:
Field
Type
Description
resourceType
String
Returns the resource type, usually Bundle.
id
String
The unique identifier of the Bundle, generated by the server.
type
String
The type of the response Bundle. It is transaction-response for a transaction response and batch-response for a batch response.
link
Array
A list of links associated with the Bundle.
link[].relation
String
The type of link relation. For example, self indicates the current request itself.
link[].url
String
Link address.
entry
Array
Execution results of the resource entries.
entry[].response.status
String
Execution status of the entry.
entry[].response.location
String
Resource location or version address.
entry[].response.etag
String
Resource version identifier.

Examples

Request Example

POST /INSTANCE_ID/fhir HTTP/1.1
Host: HOSTNAME
Authorization: Bearer YOUR_ACCESS_TOKEN
Content-Type: application/fhir+json
{
"resourceType": "Bundle",
"type": "transaction",
"entry": [
{
"fullUrl": "Patient/PTA",
"resource": {
"resourceType": "Patient",
"id": "PTA",
"identifier": [
{
"system": "http://acme.org/mrns",
"value": "013872"
}
],
"name": [
{
"family": "Simpson",
"given": [
"Homer"
]
}
],
"gender": "male"
},
"request": {
"method": "PUT",
"url": "Patient/PTA"
}
},
{
"fullUrl": "Condition/CD1",
"resource": {
"resourceType": "Condition",
"id": "CD1",
"clinicalStatus": {
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/condition-clinical",
"code": "active"
}
]
},
"verificationStatus": {
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/condition-ver-status",
"code": "confirmed"
}
]
},
"category": [
{
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/condition-category",
"code": "problem-list-item",
"display": "Problem List Item"
}
]
}
],
"code": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "59621000",
"display": "Essential hypertension"
}
]
},
"subject": {
"reference": "Patient/PTA"
}
},
"request": {
"method": "PUT",
"url": "Condition/CD1"
}
},
{
"fullUrl": "Condition/CD2",
"resource": {
"resourceType": "Condition",
"id": "CD2",
"clinicalStatus": {
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/condition-clinical",
"code": "active"
}
]
},
"verificationStatus": {
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/condition-ver-status",
"code": "confirmed"
}
]
},
"category": [
{
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/condition-category",
"code": "problem-list-item",
"display": "Problem List Item"
}
]
}
],
"code": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "44054006",
"display": "Type 2 diabetes mellitus"
}
]
},
"subject": {
"reference": "Patient/PTA"
}
},
"request": {
"method": "PUT",
"url": "Condition/CD2"
}
}
]
}

Response Example

HTTP/1.1 200 OK
Content-Type: application/fhir+json
x-request-id: <REQUEST_ID>
{
"resourceType": "Bundle",
"id": "b67e4a2f-3c5d-4e8a-9f01-7a2b3c4d5e6f",
"type": "transaction-response",
"link": [
{
"relation": "self",
"url": "https://HOSTNAME/INSTANCE_ID/fhir"
}
],
"entry": [
{
"response": {
"status": "201 Created",
"location": "Patient/PTA/_history/1",
"etag": "1"
}
},
{
"response": {
"status": "201 Created",
"location": "Condition/CD1/_history/1",
"etag": "1"
}
},
{
"response": {
"status": "201 Created",
"location": "Condition/CD2/_history/1",
"etag": "1"
}
}
]
}

Error Codes

Common error codes are listed below. For more error codes, see Error Codes.
Error Code
Description
400 Bad Request
Incorrect resource associations in the Bundle or invalid request format.
401 Unauthorized
Not authenticated, and valid credentials are missing.
403 Forbidden
Authenticated but not authorized to perform Bundle operations.
409 Conflict
Resource ID or reference relationship conflict
422 Unprocessable Entity
The Bundle syntax is correct, but it fails business or rule validation.
500 Internal Server Error
Internal server processing exception


ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック