tencent cloud

Condition Creation

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

API Description

This function is used to perform conditional create operations within a transaction Bundle. When submitting a resource to be created, the client also provides a set of search criteria. The server first queries whether matching resources already exist based on these criteria. If no matching resources are found, it creates the resource. If matches are found, it does not create a duplicate. This mechanism is suitable for preventing duplicate writes of data with natural unique identifiers, such as patients and test results.
In a transaction Bundle, conditional create is specified via Bundle.entry.request.ifNoneExist, and the request method remains POST.

Input parameters

Parameter Name
Type
Required
Description
HTTP Method
String
Yes
Fixed to POST.
URL
String
Yes
The Bundle submission URL, usually [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 conditional create entries.
Request Body Main Field Descriptions:
Field
Type
Required
Description
entry[].resource
Object
Yes
Content of the resource to be created.
entry[].request.method
String
Yes
Fixed to POST.
entry[].request.url
String
Yes
Path to the target resource type.
entry[].request.ifNoneExist
String
No
Conditional creation search expression. When the conditional creation search expression is omitted, this entry degrades to a normal creation (POST) and no conditional matching is performed.
Note:
If the ifNoneExist query finds no matching resources, the system performs the creation.
If the query finds existing matching resources, the system does not create duplicates.
Conditional expressions typically use business-unique identifier fields, such as identifier.

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 result and resource location of each 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 result Bundle, assigned by the server.
type
String
The type of the result Bundle, which is fixed as transaction-response for transaction responses.
link
Array
Pagination-related link information, containing the relation and url fields.
entry
Array
Execution results of the entries.
entry[].response.status
String
Execution status of the entry.
entry[].response.location
String
The location of the newly created or matched resource.
entry[].response.etag
String
Version identifier of the resource corresponding to the entry.

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": "POST",
"url": "Patient",
"ifNoneExist": "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": "POST",
"url": "Condition",
"ifNoneExist": "Condition?identifier=http://acme.org/cond|46253"
}
}
]
}

Response Example

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

Error Codes

Common error codes are listed below. For more error codes, see Error Codes.
Error Code
Description
400 Bad Request
Conditional creation expression format error
401 Unauthorized
Not authenticated, and valid credentials are missing.
403 Forbidden
Authenticated but not authorized to perform Bundle operations.
409 Conflict
Non-unique matching result or conflicting resource state.
412 Precondition Failed
The conditional creation search expression matched multiple resources, and a unique 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


ヘルプとサポート

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

フィードバック