tencent cloud

Updating

Download
Mode fokus
Ukuran font
Terakhir diperbarui: 2026-08-28 16:06:55
Diterjemahkan oleh AI

API Description

This is used to update the resource instance corresponding to a specified resource ID. This API follows the standard FHIR Update operation. The client submits the complete resource content to the specified resource address via the HTTP PUT method. After the server successfully updates the resource, it returns the latest version of the resource data along with its version information.
Attention:
The PUT method is updated to a full replacement operation. The request body submitted will completely overwrite the existing content of the target resource. If you need to add or modify specific fields based on the original resource, the request body must contain all fields of the resource (existing fields + new fields). If you submit only partial fields, any existing fields not included will be cleared. To update only specific fields while keeping the rest unchanged, use the patch interface (PATCH method + application/json-patch+json).
This example demonstrates how to call the API to update a Patient resource by adding address information to the existing patient data (the request body contains the complete patient information along with the new address fields).

Input parameters

Parameter Name
Type
Required
Description
HTTP Method
String
Yes
Fixed as PUT.
URL
String
Yes
The address for updating resources, in the format [baseUrl]/[resourceType]/[id].
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
The complete FHIR resource content to be updated, which must contain a resource ID consistent with the URL. PUT is a full replacement operation; fields not included in the request body will be cleared.
Request URL Example:
https://HOSTNAME/INSTANCE_ID/fhir/Patient/id
Request Body Example Field Descriptions:
Field
Type
Required
Description
resourceType
String
Yes
The FHIR resource type. In this example, it is Patient. To view all resource types actually supported by the current instance, call the CapabilityStatement API via GET /INSTANCE_ID/fhir/metadata and check the returned rest[].resource[].type (the resource types supported by an instance can be configured and trimmed during creation via supported_resource_types, which may vary across instances). For field definitions of each resource type, refer to FHIR Resource Types.
id
String
Yes
The unique ID of the resource. It is the logical ID automatically assigned by the server when the resource is created, and can be obtained in the following ways:
Call the Create API (POST) to create a resource. Obtain the resource identifier from the Content-Location response header or the id field in the response body.
Call the Search API (GET /[resourceType]?_id= or /[resourceType]?identifier=) to query for existing resource IDs.
identifier
Array
No
Patient identification information.
name
Array
No
Name information.
gender
String
No
Gender. The valid values are male (male), female (female), other (other), and unknown (unknown). For details, see FHIR Patient.gender.
birthDate
String
No
Date of birth. The format is YYYY-MM-DD.
address
Array
No
Address information.
address[].line
Array
No
Street address.
address[].city
String
No
City.
address[].state
String
No
Province/State.
address[].postalCode
String
No
Postal code.

Output Parameters

Upon a successful API call, the HTTP status code 200 OK is typically returned. The response headers contain the resource version information and the latest version address, and the response body returns the complete updated resource content. Some instances may be configured not to return a response body upon update. In this case, you can call the Read API using the Content-Location address in the response headers to obtain the complete resource content.
Response Header Example Description:
Parameter Name
Type
Description
Status Code
Integer
Returns 200 OK when successful.
ETag
String
Resource version identifier, for example W/"2".
Content-Location
String
The historical version address of the updated resource.
x-request-id
String
Request trace ID.
Key Response Body Field Descriptions:
Field
Type
Description
resourceType
String
Resource type
id
String
Unique ID of the updated resource.
meta.versionId
String
Version ID of the current resource.
meta.lastUpdated
String
Last update time of the resource.
meta.source
String
The source identifier of the resource, in the format #<hash value>. It is returned only if this field was specified during resource creation or update. It can be set via the request header X-Source (requires the server to enable CaptureResourceSourceFromHeaderInterceptor) or by the client directly writing to meta.source. For details, see FHIR Meta.source.
meta.profile
Array
List of FHIR StructureDefinition profiles that the resource conforms to.
identifier
Array
Resource identification information.
name
Array
Name information of the resource.
gender
String
Gender.
birthDate
String
Date of birth.
address
Array
Updated address information.
Note:
text is the Narrative (human-readable summary) field of a FHIR resource and contains two sub-fields: status and div. By default, the server does not automatically generate a Narrative, and the response body typically does not include the text field. The server retains and returns the text field only when the client actively provides it in the request body. The valid values for text.status are generated (system-generated), extensions (containing only extension information), and additional (containing additional content). For details, see FHIR NarrativeStatus.

Examples

Request Example

PUT /INSTANCE_ID/fhir/Patient/id HTTP/1.1
Host: HOSTNAME
Authorization: Bearer YOUR_ACCESS_TOKEN
Content-Type: application/fhir+json
{
"resourceType": "Patient",
"id": "id",
"identifier": [
{
"system": "urn:oid:1.2.36.146.595.217.0.1",
"value": "12345"
}
],
"name": [
{
"family": "Chalmers",
"given": [
"Peter",
"James"
]
}
],
"gender": "male",
"birthDate": "1974-12-25",
"address": [
{
"line": [
"534 Erewhon St"
],
"city": "PleasantVille",
"state": "Vic",
"postalCode": "3999"
}
]
}

Response Example

HTTP/1.1 200 OK
ETag: W/"2"
Content-Location: https://HOSTNAME/INSTANCE_ID/fhir/Patient/id/_history/2
x-request-id: faiRG8M5xyXBhbvf
{
"resourceType": "Patient",
"id": "id",
"meta": {
"versionId": "2",
"lastUpdated": "2022-10-10T07:51:04.607-04:00",
"source": "#oYcdS7hlfUBnsSlX",
"profile": [
"http://hl7.org/fhir/StructureDefinition/Patient"
]
},
"identifier": [
{
"system": "urn:oid:1.2.36.146.595.217.0.1",
"value": "12345"
}
],
"name": [
{
"family": "Chalmers",
"given": [
"Peter",
"James"
]
}
],
"gender": "male",
"birthDate": "1974-12-25",
"address": [
{
"line": [
"534 Erewhon St"
],
"city": "PleasantVille",
"state": "Vic",
"postalCode": "3999"
}
]
}

Error Codes

Common error codes are listed below. For more error codes, see Error Codes.
Error Code
Description
400 Bad Request
The request parameters are incorrect, or the submitted resource content does not conform to the JSON/FHIR structure requirements.
401 Unauthorized
Not authenticated, and valid credentials are missing.
403 Forbidden
Authenticated but not authorized to update the resource.
404 Not Found
The specified resource does not exist.
409 Conflict
Resource state conflict, for example, a version conflict.
415 Unsupported Media Type
The Content-Type is not supported, for example, application/fhir+json is not used.
422 Unprocessable Entity
The resource content passes syntax validation but fails business or FHIR rule validation.
500 Internal Server Error
Internal server processing exception.


Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan