tencent cloud

Conditional Update

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

API Description

This is used to perform a conditional update operation within a transaction Bundle. When submitting resource content, the client does not directly specify a target resource ID but instead provides a search criteria. The server first queries the target resource based on this criteria and then decides whether to perform an update or a creation.
The processing rules for conditional updates are typically as follows:
If no matching resource is found, a new resource is created.
If a matching resource exists, it is updated with the content from Bundle.entry.resource.
In a transaction Bundle, the request method is typically PUT, and the search expression is placed in Bundle.entry.request.url.

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
No
The MIME type of the request body. For write-type requests, it is typically application/fhir+json; if not specified, the server will automatically infer it based on the request content.
Request Body
JSON Object
Yes
A transaction Bundle containing conditional update entries.
Request URL Example:
https://HOSTNAME/INSTANCE_ID/fhir
Request Body Main Field Descriptions:
Field
Type
Required
Description
entry[].resource
Object
Yes
Content of the resource to be updated
entry[].request.method
String
Yes
Fixed as PUT
entry[].request.url
String
Yes
Conditional update search expression
Note:
Conditional updates do not directly hardcode a resource ID but instead locate the target resource through search criteria.
If the matching result is empty, it is typically handled as a creation.
If the matching result is unique, the resource is updated.

Output Parameters

Upon a successful API call, the HTTP status code 200 OK is returned. The response headers contain the content type and request trace information, and the response body is a result Bundle that includes the execution status and resource location of each entry.
Response Header Example Description:
Parameter Name
Type
Description
Status Code
Integer
Returns 200 OK when successful.
Location
String
The access URL for the result Bundle.
Content-Location
String
The content location URL for the result Bundle.
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 ID of the result Bundle.
type
String
The Bundle type. Returns transaction-response for conditional updates.
link
Array
Navigation links, containing the relation and url fields. When relation is self, it points to the current request address.
entry
Array
Execution results of the entries.
entry[].response.status
String
The execution status of the entry. Returns 200 OK when an existing resource is matched; returns 201 Created when no matching resource is found, resulting in the creation of a new one.
entry[].response.location
String
The location of the updated or newly created resource.
entry[].response.etag
String
Resource version identifier.
entry[].response.outcome
Object
Details of the entry execution, containing OperationOutcome information.

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": "urn:uuid:95dbbf93-5829-46ba-9021-2545a1da3aa5",
"resource": {
"resourceType": "Patient",
"identifier": [
{
"system": "http://acme.org/mrns",
"value": "013873"
}
],
"name": [
{
"family": "Simpson",
"given": [
"Homer"
]
}
],
"gender": "male"
},
"request": {
"method": "PUT",
"url": "Patient?identifier=http://acme.org/mrns|013873"
}
},
{
"fullUrl": "urn:uuid:124ff3c8-f251-4bd9-8c44-cc6568180eae",
"resource": {
"resourceType": "Condition",
"identifier": [
{
"system": "http://acme.org/cond",
"value": "46253"
}
],
"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": "urn:uuid:95dbbf93-5829-46ba-9021-2545a1da3aa5"
}
},
"request": {
"method": "PUT",
"url": "Condition?identifier=http://acme.org/cond|46253"
}
}
]
}

Response Example

HTTP/1.1 200 OK
Location: https://HOSTNAME/INSTANCE_ID/fhir/Bundle/<bundle-id>
Content-Location: https://HOSTNAME/INSTANCE_ID/fhir/Bundle/<bundle-id>
Content-Type: application/fhir+json
x-request-id: <REQUEST_ID>
{
"resourceType": "Bundle",
"id": "<bundle-id>",
"type": "transaction-response",
"link": [
{
"relation": "self",
"url": "https://HOSTNAME/INSTANCE_ID/fhir"
}
],
"entry": [
{
"response": {
"status": "200 OK",
"location": "Patient/95dbbf93-5829-46ba-9021-2545a1da3aa5/_history/2",
"etag": "2"
}
},
{
"response": {
"status": "200 OK",
"location": "Condition/124ff3c8-f251-4bd9-8c44-cc6568180eae/_history/2",
"etag": "2"
}
}
]
}

Error Codes

Common error codes are listed below. For more error codes, see Error Codes.
Error Code
Description
400 Bad Request
Conditional update expression format error
401 Unauthorized
Not authenticated, and valid credentials are missing.
403 Forbidden
Authenticated but not authorized to perform Bundle operations.
409 Conflict
Resource state conflict
412 Precondition Failed
The conditional update search criteria matched multiple resources, and a unique update target cannot be determined.
422 Unprocessable Entity
The Bundle syntax is correct, but it fails business or rule validation.
500 Internal Server Error
Internal server processing exception


ヘルプとサポート

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

フィードバック