tencent cloud

Search API Reference

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

API Description

This function is used to perform searches based on reference relationships between resources. When a resource field references another type of resource, you can use the reference field as a search parameter to filter data records associated with the target resource.
This example demonstrates how to search for Encounter resources based on the subject reference field. Specifically, it queries the visit records associated with a specified patient and sorts the results in ascending order by date using the _sort parameter.

Input parameters

Parameter Name
Type
Required
Description
HTTP Method
String
Yes
Fixed as GET.
URL
String
Yes
The search address, in the format [baseUrl]/[resourceType]?[searchParams].
Authorization
String
Yes
The access token, in the format Bearer <AccessToken>. For details on how to obtain it, see Calling Method.
Accept
String
No
The response format. It is recommended to use application/fhir+json.
subject
String
Yes
A reference search parameter that indicates the associated patient resource reference. It is typically in the format Patient/{id}. Here, {id} is the unique identifier of the referenced resource, which can be obtained via the Basic Search API or the console resource viewer.
_sort
String
No
A sorting parameter used to specify the field for sorting results. In this example, sorting is performed by date.
resourceType
String
Yes
The FHIR resource type. It supports standard FHIR resource types, such as Patient, Encounter, Observation, and so on. In this example, it is Encounter.
Request URL Example:
https://HOSTNAME/INSTANCE_ID/fhir/Encounter?subject=Patient/k62d9d82-3f2b-44db-b808-04159be709fd&_sort=date
Note:
Reference search is applicable to scenarios where resource association relationships exist.
subject=Patient/{id} specifies that only Encounter records associated with that patient are returned.
_sort=date specifies sorting by the date field. In this example, results are returned in ascending order (from oldest to newest).

Output Parameters

Upon a successful API call, the HTTP status code 200 OK is typically returned. The response body is usually a Bundle resource, which contains a list of Encounter records that meet the specified criteria, along with pagination information.
Key Response Body Field Descriptions:
Field
Type
Description
resourceType
String
Returns the resource type, usually Bundle.
id
String
Unique ID of the Bundle resource, usually a UUID.
meta
Object
Metadata of the Bundle, containing fields such as lastUpdated.
meta.lastUpdated
String
Generation time of the Bundle, in ISO 8601 format.
type
String
The Bundle type is usually searchset in search scenarios.
total
Integer
The total number of matched records. This field may not be returned by default and is only returned when the server can efficiently calculate the total number of records. The current server does not support forcing the return of an accurate total via _total=accurate.
entry
Array
The list of search results.
entry[].fullUrl
String
The complete access URL of the resource.
entry[].resource
Object
The content of the matched Encounter resource.
entry[].resource.id
String
Unique ID of the resource.
entry[].resource.meta
Object
Metadata of the resource, containing fields such as versionId and lastUpdated.
entry[].resource.subject
Object
Reference information of the patient associated with the current encounter record.
entry[].resource.period
Object
Information about the time range of the encounter.
link
Array
Pagination link information.

Examples

Request Example

GET /INSTANCE_ID/fhir/Encounter?subject=Patient/k62d9d82-3f2b-44db-b808-04159be709fd&_sort=date HTTP/1.1
Host: HOSTNAME
Authorization: Bearer <AccessToken>
Accept: application/fhir+json

Response Example

{
"resourceType": "Bundle",
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"meta": {
"lastUpdated": "2024-01-10T08:00:00.000+08:00"
},
"type": "searchset",
"entry": [
{
"fullUrl": "https://HOSTNAME/INSTANCE_ID/fhir/Encounter/enc-10001",
"resource": {
"resourceType": "Encounter",
"id": "enc-10001",
"meta": {
"versionId": "1",
"lastUpdated": "2024-01-10T08:00:00.000+08:00"
},
"subject": {
"reference": "Patient/k62d9d82-3f2b-44db-b808-04159be709fd"
},
"period": {
"start": "2024-01-10T08:00:00+08:00",
"end": "2024-01-10T09:30:00+08:00"
}
}
}
]
}

Error Codes

Common error codes are listed below. For more error codes, see Error Codes.
Error Code
Description
400 Bad Request
The search parameter format is incorrect, or the referenced parameter value is invalid.
401 Unauthorized
Not authenticated, and valid credentials are missing.
403 Forbidden
Authenticated but not authorized to search the resource.
404 Not Found
The specified resource type does not exist.
422 Unprocessable Entity
The search parameter syntax is correct, but it fails business or rule validation.
500 Internal Server Error
Internal server processing exception.

ヘルプとサポート

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

フィードバック