本页介绍了如何配置 FHIR 存储区以支持 FHIR 标准搜索参数未涵盖的字段和扩展程序的自定义搜索参数。
自定义搜索参数在许多情况下都非常有用,包括以下情况:
- 您需要在 FHIR 资源中搜索字段,但该字段没有支持的搜索参数。
- 您需要在添加到 FHIR 数据模型的扩展程序中进行搜索。
概览
默认情况下,搜索 FHIR 资源支持 FHIR 规范中定义的标准搜索参数,但有一些例外情况,详见 FHIR 功能声明或 FHIR 一致性声明。
您可以创建一个或多个自定义搜索参数,然后配置 FHIR 存储区,以便通过 search 方法在查询中支持这些参数。自定义搜索参数非常适合用于以下情况:
- 在标准搜索参数未涵盖的字段中进行搜索。
- 在 FHIR 数据模型的扩展程序中进行搜索。
许多 FHIR 实现指南定义了搜索参数,您可以在搜索中使用这些参数。
自定义搜索参数支持与标准搜索参数相同的搜索行为,包括高级 FHIR 搜索功能,例如:
- 修饰符
_include和_revinclude- 链式搜索
_sort
如需为 FHIR 存储区启用自定义搜索,您必须先创建一个或多个定义搜索行为的 SearchParameter 资源。SearchParameter 是标准的 FHIR 资源类型,可以使用与任何其他资源类型相同的方法创建、更新或删除。 请参阅在存储区中创建搜索参数资源。
使用 configureSearch 方法配置 FHIR 存储区中的 SearchParameter 资源后,它们才会生效。此方法会启用自定义搜索参数列表。每次被调用时,它会替换之前的参数列表。系统会针对 configureSearch 触发长时间运行的操作,从而根据新搜索配置将存储区中的所有相关资源重新编入索引。方法调用后的所有新资源和更新资源都会根据新配置编入索引。配置中不再存在的自定义搜索参数的所有索引数据都会被移除。
如需详细了解如何使用 configureSearch,请参阅为 FHIR 存储区启用自定义搜索参数。
存储区的 CapabilityStatement(通过 fhir.capabilities 方法检索)将列出标准和自定义搜索参数。资源的搜索参数位于 rest.resource.searchParam 字段中。
创建自定义 FHIR 搜索
在 FHIR 存储区中创建 SearchParameter 资源
以下示例展示了如何使用 projects.locations.datasets.fhirStores.fhir.create 方法创建自定义搜索参数资源。 您还可以使用 projects.locations.datasets.fhirStores.import 方法。
如需了解搜索参数的相关字段,请参阅 SearchParameter 资源字段。
curl
以下示例展示了使用 curl 的 POST 请求。
curl -X POST \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/json; charset=utf-8" \ --data "{ \"resourceType\": \"SearchParameter\", \"url\": \"CANONICAL_URL\", \"base\": [\"RESOURCE_TYPE\"], \"code\": \"SEARCH_PARAMETER_CODE\", \"name\": \"SEARCH_PARAMETER_NAME\", \"type\": \"SEARCH_PARAMETER_TYPE\", \"expression\": \"SEARCH_PARAMETER_EXPRESSION\", \"status\": \"active\", \"description\": \"SEARCH_PARAMETER_DESCRIPTION\" }" \ "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/SearchParameter"
如果请求成功,服务器将以 JSON 格式返回响应:
{
"resourceType": "SearchParameter",
"url": "CANONICAL_URL",
"base": ["RESOURCE_TYPE"],
"code": "SEARCH_PARAMETER_CODE",
"name": "SEARCH_PARAMETER_NAME",
"type": "SEARCH_PARAMETER_TYPE",
"expression": "SEARCH_PARAMETER_EXPRESSION",
"status": "active",
"description": "SEARCH_PARAMETER_DESCRIPTION",
"meta": {
"lastUpdated": "LAST_UPDATED",
"versionId": "VERSION_ID"
},
}
PowerShell
以下示例展示了使用 Windows PowerShell 的 POST 请求。
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } $SearchParameter = '{ "resourceType": "SearchParameter", "url": "CANONICAL_URL", "base": ["RESOURCE_TYPE"], "code": "SEARCH_PARAMETER_CODE", "name": "SEARCH_PARAMETER_NAME", "type": "SEARCH_PARAMETER_TYPE", "expression": "SEARCH_PARAMETER_EXPRESSION", "status": "active", "description": "SEARCH_PARAMETER_DESCRIPTION" }' Invoke-WebRequest ` -Method Post ` -Headers $headers ` -ContentType: "application/json; charset=utf-8" ` -Body $SearchParameter ` -Uri "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/SearchParameter" | ConvertTo-Json
如果请求成功,服务器将以 JSON 格式返回响应:
{
"resourceType": "SearchParameter",
"url": "CANONICAL_URL",
"base": ["RESOURCE_TYPE"],
"code": "SEARCH_PARAMETER_CODE",
"name": "SEARCH_PARAMETER_NAME",
"type": "SEARCH_PARAMETER_TYPE",
"expression": "SEARCH_PARAMETER_EXPRESSION",
"status": "active",
"description": "SEARCH_PARAMETER_DESCRIPTION",
"meta": {
"lastUpdated": "LAST_UPDATED",
"versionId": "VERSION_ID"
},
}
为 FHIR 存储区启用自定义搜索参数
如需为 FHIR 存储区启用一个或多个自定义搜索参数,请向 [store base URL]:configureSearch 方法发出 POST 请求,并为您启用的每个搜索参数指定规范网址。
规范网址以以下任一格式指定:
uri:选择适用于该 URI 的存储区中可用的最大version。uri|version:选择特定版本。
例如,如果存储区包含带有 http://example.com/search URI 的搜索参数的 1.0.0 和 1.0.1 版本,则规范网址 http://example.com/search|1.0.0 选择 1.0.0 版本。规范网址 http://example.com/search 选择 1.0.1 版本。
提供给此方法的网址列表会替换任何先前的配置,并移除先前有效的自定义搜索参数。系统会根据 configureSearch 调用时存在的 SearchParameter 资源的内容缓存配置。如果更新或删除 SearchParameter 资源,则配置不会更新,直到系统再次调用 configureSearch 为止。
[store base URL]:configureSearch 方法调用成功后,返回值将是一个长时间运行的操作的名称,该操作会根据新配置将存储区中的资源重新编入索引。您可以使用 operations.get 方法查看长时间运行的操作的状态,还可以使用 operations.cancel 方法取消该操作。状态包含一个计数器,指示已成功重新编入索引的资源数量。
在长时间运行的操作运行时,对存储区的搜索将继续正常进行,但此操作添加或更改的自定义搜索参数会返回部分结果。取消该操作是安全的,但会导致自定义搜索参数部分编入索引。在使用新添加或更改的参数进行搜索之前,请务必完成整个成功的索引操作。
如果存在错误,则它们会显示在 Cloud Logging 中。
configureSearch 方法也可与 "validate_only": true 选项搭配使用,以验证指定的搜索参数,而无需修改存储区配置,且不会将任何数据重新编入索引。
以下示例展示了如何使用 projects.locations.datasets.fhirStores.configureSearch 方法为 FHIR 存储区启用一个或多个自定义搜索参数。
curl
以下示例展示了使用 curl 的 POST 请求。
curl -X POST \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/json; charset=utf-8" \ --data "{ \"canonicalUrls\": [\"CANONICAL_URL1\",\"CANONICAL_URL2\"], }" \ "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID:configureSearch"
如果请求成功,服务器将以 JSON 格式返回响应:
{
"name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID"
}
响应包含操作名称。要跟踪操作的状态,您可以使用 Operation get 方法:
curl -X GET \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID"
如果长时间运行的操作仍在运行,服务器会以 JSON 格式返回包含待重新编入索引的 FHIR 资源数量的响应:
{
"name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID",
"metadata": {
"@type": "type.googleapis.com/google.cloud.healthcare.v1beta1.OperationMetadata",
"apiMethodName": "google.cloud.healthcare.v1beta1.fhir.FhirStoreService.ConfigureSearch",
"createTime": "CREATE_TIME",
"logsUrl": "https://console.cloud.google.com/logs/query/CLOUD_LOGGING_URL",
"counter": {
"pending": "PENDING_COUNT"
}
}
}
当 LRO 完成时,服务器将以 JSON 格式返回包含操作状态的响应:
{
"name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID",
"metadata": {
"@type": "type.googleapis.com/google.cloud.healthcare.v1.OperationMetadata",
"apiMethodName": "google.cloud.healthcare.v1.fhir.FhirService.configureSearch",
"createTime": "CREATE_TIME",
"endTime": "END_TIME",
"logsUrl": "https://console.cloud.google.com/logs/query/CLOUD_LOGGING_URL",
"counter": {
"success": "SUCCESS_COUNT"
}
},
"done": true,
"response": {
"@type": "type.googleapis.com/google.protobuf.Empty",
}
}
如果 LRO 成功,响应将包含成功重新编入索引的 FHIR 资源数量以及 google.protobuf.Empty 响应类型。
PowerShell
以下示例展示了使用 Windows PowerShell 的 POST 请求。
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } $configureSearch = '{ "canonical_urls": [ "CANONICAL_URL1", "CANONICAL_URL2" ] }' Invoke-WebRequest ` -Method Post ` -Headers $headers ` -ContentType: "application/json; charset=utf-8" ` -Body $configureSearch ` -Uri "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID:configureSearch"
如果请求成功,服务器将以 JSON 格式返回响应:
{
"name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID"
}
响应包含操作名称。要跟踪操作的状态,您可以使用 Operation get 方法:
curl -X GET \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID"
如果长时间运行的操作仍在运行,服务器会以 JSON 格式返回包含待重新编入索引的 FHIR 资源数量的响应:
{
"name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID",
"metadata": {
"@type": "type.googleapis.com/google.cloud.healthcare.v1beta1.OperationMetadata",
"apiMethodName": "google.cloud.healthcare.v1beta1.fhir.FhirStoreService.ConfigureSearch",
"createTime": "CREATE_TIME",
"logsUrl": "https://console.cloud.google.com/logs/query/CLOUD_LOGGING_URL",
"counter": {
"pending": "PENDING_COUNT"
}
}
}
当 LRO 完成时,服务器将以 JSON 格式返回包含操作状态的响应:
{
"name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID",
"metadata": {
"@type": "type.googleapis.com/google.cloud.healthcare.v1.OperationMetadata",
"apiMethodName": "google.cloud.healthcare.v1.fhir.FhirService.configureSearch",
"createTime": "CREATE_TIME",
"endTime": "END_TIME",
"logsUrl": "https://console.cloud.google.com/logs/query/CLOUD_LOGGING_URL",
"counter": {
"success": "SUCCESS_COUNT"
}
},
"done": true,
"response": {
"@type": "type.googleapis.com/google.protobuf.Empty",
}
}
如果 LRO 成功,响应将包含成功重新编入索引的 FHIR 资源数量以及 google.protobuf.Empty 响应类型。
使用“自定义搜索”搜索资源
您可以像使用自定义搜索一样,使用自定义 SearchParameter 进行搜索。使用搜索参数资源中的 code 值作为搜索查询的 key。如需了解详情,请参阅搜索 FHIR 资源。
SearchParameter 资源字段
以下部分介绍了与自定义搜索相关的 SearchParameter 资源字段。这些字段同时适用于 STU3 和 R4 版本的 FHIR。
uri 和 version
uri 字段(必需)和 version 字段(可选)用于定义 SearchParameter 资源的规范网址。uri 和 version 的组合在 FHIR 存储区中必须是唯一的。
规范网址是在 configureSearch 调用中使用的网址。
name、description 和 status
name、description 和 status 是必填字段,但没有任何功能效果。
base
base 字段列出了此搜索适用的 FHIR 资源类型。
如果存在多个类型,则 expression 字段必须具有每个类型的子句。针对两种类型定义一个参数或为每个类型定义一个参数之间没有区别。为多种资源类型定义一个参数可使定义更紧凑。
code
code 字段定义要在 FHIR 搜索查询中使用的键。例如,如果 code 定义为 payment-type,而 base 定义为 Claim,则使用此参数的搜索查询将为 Claim?payment-type=ABC。
code 字段的值不能与同一资源类型上的任何其他标准或自定义搜索参数相同。无法使用自定义搜索参数重新定义或修改标准搜索参数。configureSearch 方法会拒绝重复的搜索参数。
code 字段的值必须满足以下要求:
- 必须以字母开头
- 不能超过 64 个字符
- 只能包含:
- 字母数字字符
- 连字符
- - 下划线字符
_
code 字段的 FHIR 标准惯例是小写且带有短划线。
type
type 字段定义搜索参数类型。搜索参数类型决定搜索条件的语义(如 FHIR 搜索规范中所定义)。type 的值必须与 expression 字段指定的字段的数据类型兼容。如果不兼容,configureSearch 会拒绝自定义搜索参数。
type 字段必须定义为以下字段之一:
numberdatestringtokenreferencequantityuri
不支持 composite 和 special 类型。
expression
expression 字段定义搜索参数查询的字段或扩展。此字段使用的一组语法和函数受限于 FHIRPath。
字段语法
expression 字段定义为以资源类型开头且后跟一个或多个由 . 分隔的字段(例如 Patient.contact.name.given)的路径。FHIR 数据的字段结构可在 FHIR 资源和 FHIR 数据类型中找到。
多个子句
expression 字段可以包含多个由 | 分隔的子句。在这种情况下,如果任何子句与资源匹配,则搜索参数将匹配。例如,表达式为 Patient.name.given | Patient.name.family 的搜索参数将与这两个字段中的任何一个匹配。在 base 中指定多个资源类型时,请使用多个子句,例如,适用于 Patient 和 Practitioner 的搜索参数的 Patient.name.given | Practitioner.name.given。
.as([data type])
如果某个字段有多个可能的数据类型,请使用 .as([data type]) 函数。例如,Observation.value 字段可以包含许多不同类型的类型,例如 Quantity 和 String,这些类型适用于不同的搜索类型。您可以使用 Observation.value.as(Quantity) 或 Observation.value.as(String) 选择这些搜索类型。
选择附加信息
您可以使用 .extension([canonical url]) 函数选择扩展字段。由于扩展字段包含 value 字段(该字段可包含任何数据类型),因此完整路径定义为 .extension([canonical url]).value.as([data type])。复杂扩展字段可以使用多个 .extension() 组成部分,例如 Patient.extension('http://hl7.org/fhir/StructureDefinition/patient-citizenship').extension('code').value.as(CodeableConcept)。
您还可以使用 .extension.where(url='[canonical url]') 函数来选择扩展程序。这是允许使用 where() 函数的唯一上下文。
不支持其他 FHIRPath 函数。
target
如果 type 字段定义为 reference,则 target 字段必须包含一个或多个 FHIR 资源类型,这些资源类型定义哪些资源类型可以是此参考搜索的目标。
例如,如果 Patient.generalPractitioner 字段允许对 Practitioner、PractitionerRole 和Organization 的引用,则搜索参数可明确匹配对 Practitioner、PractitionerRole 或 Organization 的引用。如需匹配引用的所有目标类型,请在 target 字段中包含所有类型。
modifier、comparator、multipleOr、multipleAnd和chain
系统会忽略 modifier、comparator、multipleOr、multipleAnd 和 chain 字段。自定义搜索参数提供的选项和功能与 FHIR 存储区在相同类型的标准搜索参数上支持的选项和功能相同。
使用实现指南中的搜索参数
如果您正在实施从 FHIR 实现指南获取的搜索参数,请使用以下方法之一将 SearchParameter 资源从实现指南的 JSON 文件导入 FHIR 存储区。
在某些情况下,您必须转换已发布的搜索参数,以便 Cloud Healthcare API 支持该参数。如果未转换搜索参数,则 configureSearch 方法会拒绝这些参数。以下限制条件适用于实现指南中的搜索参数:
如果搜索参数与基本 FHIR 规范中的参数相同,则
configureSearch方法将拒绝重复的搜索参数。调用configureSearch时,请省略此类重复项。如需了解详情,请参阅code。如果搜索参数仅包含
xpath表达式,请将表达式转换为等效的 FHIRPath 表达式并在expression字段中使用它。如需了解详情,请参阅expression。不支持
composite和special搜索参数类型。不支持其他类型转换语法
([field] as [data type])。转换为受支持的等效[field].as([data type])。如需了解详情,请参阅.as([data type])。不支持限制引用资源的类型的
[reference field].where(resolve() is [resource type])惯例。移除where()子句,并将引用的资源类型存储在SearchParameter.target字段中。如需了解详情,请参阅target。某些实现指南使用扩展表达式来省略 Cloud Healthcare API FHIR 存储区所需的一些路径组成部分。例如,
Patient.extension('url')必须修改为Patient.extension('url').value.as([data type]),而Patient.extension('url').extension.value必须修改为Patient.extension('url').extension('url2').value.as([data type])。
示例
使用自定义搜索来搜索扩展字段
以下步骤展示了如何在患者资源的 mothersMaidenName 扩展程序中搜索文本的示例。
创建患者资源示例:
curl
以下示例展示了如何使用
curl发出POST请求来创建患者资源。此患者资源已将mothersMaidenName扩展字段设置为Marca。curl -X POST \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/json; charset=utf-8" \ --data "{ \"name\": [ { \"use\": \"official\", \"family\": \"Smith\", \"given\": [ \"Darcy\" ] } ], \"gender\": \"female\", \"birthDate\": \"1970-01-01\", \"resourceType\": \"Patient\", \"extension\": [ { \"url\": \"http://hl7.org/fhir/StructureDefinition/patient-mothersMaidenName\", \"valueString\": \"Marca\" } ] }" \ "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient"
如果请求成功,则服务器返回 JSON 格式的类似下列示例的响应:
{ "birthDate": "1970-01-01", "gender": "female", "id": "PATIENT_ID", "meta": { "lastUpdated": "2020-01-01T00:00:00+00:00", "versionId": "VERSION_ID" }, "name": [ { "family": "Smith", "given": [ "Darcy" ], "use": "official" } ], "resourceType": "Patient" "extension": [ { "url": "http://hl7.org/fhir/StructureDefinition/patient-mothersMaidenName", "valueString": "Marca" } ] }PowerShell
以下示例展示了如何使用 Windows PowerShell 发出
POST请求来创建患者资源。此患者资源已将mothersMaidenName扩展字段设置为Marca。$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } $Patient = '{ "name": [ { "use": "official", "family": "Smith", "given": [ "Darcy" ] } ], "gender": "female", "birthDate": "1970-01-01", "resourceType": "Patient", "extension": [ { "url": "http://hl7.org/fhir/StructureDefinition/patient-mothersMaidenName", "valueString": "Marca" } ] }' Invoke-RestMethod ` -Method Post ` -Headers $headers ` -ContentType: "application/fhir+json; charset=utf-8" ` -Body $Patient ` -Uri "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient" | ConvertTo-Json
如果请求成功,则服务器返回 JSON 格式的类似下列示例的响应:
{ "birthDate": "1970-01-01", "gender": "female", "id": "PATIENT_ID", "meta": { "lastUpdated": "2020-01-01T00:00:00+00:00", "versionId": "VERSION_ID" }, "name": [ { "family": "Smith", "given": [ "Darcy" ], "use": "official" } ], "resourceType": "Patient" "extension": [ { "url": "http://hl7.org/fhir/StructureDefinition/patient-mothersMaidenName", "valueString": "Marca" } ] }创建自定义搜索参数资源:
如需在curl
以下示例展示了如何使用
curl发出POST请求,为mothersMaidenName扩展字段创建自定义搜索参数资源。curl -X POST \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/json; charset=utf-8" \ --data "{ \"resourceType\": \"SearchParameter\", \"url\": \"http://example.com/SearchParameter/patient-mothersMaidenName\", \"base\": [\"Patient\"], \"code\": \"mothers-maiden-name\", \"name\": \"mothers-maiden-name\", \"type\": \"string\", \"expression\": \"Patient.extension('http://hl7.org/fhir/StructureDefinition/patient-mothersMaidenName').value.as(String)\", \"status\": \"active\", \"description\": \"search on mother's maiden name\" }" \ "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/SearchParameter"
如果请求成功,服务器将以 JSON 格式返回响应:
{
"resourceType": "SearchParameter",
"url": "http://example.com/SearchParameter/patient-mothersMaidenName",
"base": ["Patient"],
"code": "mothers-maiden-name",
"name": "mothers-maiden-name",
"type": "string",
"expression": "Patient.extension('http://hl7.org/fhir/StructureDefinition/patient-mothersMaidenName').value.as(String)",
"status": "active",
"description": "search on mother's maiden name",
"meta": {
"lastUpdated": "2020-01-01T00:00:00+00:00",
"versionId": "VERSION_ID"
},
}PowerShell
下面展示了如何使用 Windows PowerShell 发出“POST”请求,为“mothersMaidenName”扩展字段创建自定义搜索参数资源。$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } $SearchParameter = '{ "resourceType": "SearchParameter", "url": "http://example.com/SearchParameter/patient-mothersMaidenName", "base": ["Patient"], "code": "mothers-maiden-name", "name": "mothers-maiden-name", "type": "string", "expression": "Patient.extension(''http://hl7.org/fhir/StructureDefinition/patient-mothersMaidenName'').value.as(String)", "status": "active", "description": "search on mother''s maiden name" }' Invoke-WebRequest ` -Method Post ` -Headers $headers ` -ContentType: "application/json; charset=utf-8" ` -Body $SearchParameter ` -Uri "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/SearchParameter"
如果请求成功,服务器将以 JSON 格式返回响应:
{
"resourceType": "SearchParameter",
"url": "http://example.com/SearchParameter/patient-mothersMaidenName",
"base": ["Patient"],
"code": "mothers-maiden-name",
"name": "mothers-maiden-name",
"type": "string",
"expression": "Patient.extension('http://hl7.org/fhir/StructureDefinition/patient-mothersMaidenName').value.as(String)",
"status": "active",
"description": "search on mother's maiden name",
"meta": {
"lastUpdated": "2020-01-01T00:00:00+00:00",
"versionId": "VERSION_ID"
},
}expression字段中指定其他数据类型,请使用函数.as([data type])。例如,如需为布尔值指定搜索表达式,请使用.value.as(Boolean)。如需了解详情,请参阅.as([data type])。启用搜索参数:
curl
要启用自定义搜索参数,请发出
POST请求并为您要启用的每个搜索参数指定规范网址。以下示例展示了使用
curl的POST请求。curl -X POST \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/json; charset=utf-8" \ --data "{ \"canonicalUrls\": [\"http://example.com/SearchParameter/patient-mothersMaidenName\"], }" \ "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID:configureSearch"
如果请求成功,服务器将以 JSON 格式返回响应:
{ "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID" }PowerShell
要启用自定义搜索参数,请发出
POST请求并为您要启用的每个搜索参数指定规范网址。以下示例展示了使用 Windows PowerShell 的
POST请求。$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } $configureSearch = '{ "canonicalUrls": "http://example.com/SearchParameter/patient-mothersMaidenName" }' ` Invoke-WebRequest ` -Method Post ` -Headers $headers ` -ContentType: "application/json; charset=utf-8" ` -Body $configureSearch ` -Uri "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID:configureSearch"
如果请求成功,服务器将以 JSON 格式返回响应:
{ "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID" }使用自定义搜索参数进行搜索:
curl
以下示例展示了如何使用
curl发出GET请求,以便在患者资源中搜索mothersMaidenName扩展字段中的字符串Marca。curl -X GET \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient?mothers-maiden-name:exact=Marca"
如果请求成功,服务器将以 JSON 格式的 FHIR
Bundle形式返回响应。Bundle.type是searchset,搜索结果是Bundle.entry数组中的条目。在此示例中,请求返回单个患者资源,包括该资源内的数据:{ "entry": [ { "fullUrl": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/PATIENT_ID", "resource": { "birthDate": "1970-01-01", "gender": "female", "id": "PATIENT_ID", "meta": { "lastUpdated": "LAST_UPDATED", "versionId": "VERSION_ID" }, "name": [ { "family": "Smith", "given": [ "Darcy" ], "use": "official" } ], "resourceType": "Patient" "extension": [ { "url": "http://hl7.org/fhir/StructureDefinition/patient-mothersMaidenName", "valueString": "Marca" } ] }, "search": { "mode": "match" } } ], "link": [ { "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/?family%3Aexact=Smith" } ], "resourceType": "Bundle", "total": 1, "type": "searchset" }PowerShell
以下示例展示了如何使用 Windows PowerShell 发出“GET”请求,以便在患者资源中搜索“mothersMaidenName”扩展字段中的字符串“Marca”。$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } Invoke-RestMethod ` -Method Get ` -Headers $headers ` -Uri "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient?mothers-maiden-name:exact=Marca" | ConvertTo-Json
如果请求成功,服务器将以 JSON 格式的 FHIR
Bundle形式返回响应。Bundle.type是searchset,搜索结果是Bundle.entry数组中的条目。在此示例中,请求返回单个患者资源,包括该资源内的数据:{ "entry": [ { "fullUrl": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/PATIENT_ID", "resource": { "birthDate": "1970-01-01", "gender": "female", "id": "PATIENT_ID", "meta": { "lastUpdated": "LAST_UPDATED", "versionId": "VERSION_ID" }, "name": [ { "family": "Smith", "given": [ "Darcy" ], "use": "official" } ], "resourceType": "Patient" "extension": [ { "url": "http://hl7.org/fhir/StructureDefinition/patient-mothersMaidenName", "valueString": "Marca" } ] }, "search": { "mode": "match" } } ], "link": [ { "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/?family%3Aexact=Smith" } ], "resourceType": "Bundle", "total": 1, "type": "searchset" }
使用自定义搜索在 2 级扩展字段中进行搜索
以下步骤展示了如何在“患者”资源的 us-core-ethnicity 扩展字段中搜索代码。
创建患者资源示例:
curl
以下示例展示了如何使用
curl发出POST请求来创建患者资源。此患者资源已设置us-core-ethnicity扩展字段。curl -X POST \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/json; charset=utf-8" \ --data "{ \"name\": [ { \"use\": \"official\", \"family\": \"Smith\", \"given\": [ \"Darcy\" ] } ], \"gender\": \"female\", \"birthDate\": \"1970-01-01\", \"resourceType\": \"Patient\", \"extension\": [ { \"url\": \"http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity\", \"extension\": [ { \"url\" : \"ombCategory\", \"valueCoding\" : { \"system\" : \"urn:oid:2.16.840.1.113883.6.238\", \"code\" : \"2028-9\", \"display\" : \"Asian\" } } ] } ] }" \ "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient"
如果请求成功,则服务器返回 JSON 格式的类似下列示例的响应:
{ "birthDate": "1970-01-01", "gender": "female", "id": "PATIENT_ID", "meta": { "lastUpdated": "2020-01-01T00:00:00+00:00", "versionId": "VERSION_ID" }, "name": [ { "family": "Smith", "given": [ "Darcy" ], "use": "official" } ], "resourceType": "Patient" "extension": [ { "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity", "extension": [ { "url" : "ombCategory", "valueCoding" : { "system" : "urn:oid:2.16.840.1.113883.6.238", "code" : "2028-9", "display" : "Asian" } } ] } ] }PowerShell
以下示例展示了如何使用 Windows PowerShell 发出
POST请求来创建患者资源。此患者资源已设置us-core-ethnicity扩展字段。$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } $Patient = '{ "name": [ { "use": "official", "family": "Smith", "given": [ "Darcy" ] } ], "gender": "female", "birthDate": "1970-01-01", "resourceType": "Patient", "extension": [ { "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity", "extension": [ { "url" : "ombCategory", "valueCoding" : { "system" : "urn:oid:2.16.840.1.113883.6.238", "code" : "2028-9", "display" : "Asian" } } ] } ] }' Invoke-RestMethod ` -Method Post ` -Headers $headers ` -ContentType: "application/fhir+json; charset=utf-8" ` -Body $Patient ` -Uri "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient" | ConvertTo-Json
如果请求成功,则服务器返回 JSON 格式的类似下列示例的响应:
{ "birthDate": "1970-01-01", "gender": "female", "id": "PATIENT_ID", "meta": { "lastUpdated": "2020-01-01T00:00:00+00:00", "versionId": "VERSION_ID" }, "name": [ { "family": "Smith", "given": [ "Darcy" ], "use": "official" } ], "resourceType": "Patient" "extension": [ { "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity", "extension": [ { "url" : "ombCategory", "valueCoding" : { "system" : "urn:oid:2.16.840.1.113883.6.238", "code" : "2028-9", "display" : "Asian" } } ] } ] }创建自定义搜索参数资源:
curl
以下示例展示了如何使用curl发出POST请求,为us-core-ethnicity扩展字段创建自定义搜索参数资源。curl -X POST \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/json; charset=utf-8" \ --data "{ \"resourceType\": \"SearchParameter\", \"url\": \"http://example.com/SearchParameter/patient-us-core-ethnicity\", \"base\": [\"Patient\"], \"code\": \"ethnicity\", \"name\": \"ethnicity\", \"type\": \"token\", \"expression\": \"Patient.extension('http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity').extension('ombCategory').value.as(Coding)\", \"status\": \"active\", \"description\": \"search on the ombCategory of a patient.\" }" \ "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/SearchParameter"
如果请求成功,服务器将以 JSON 格式返回响应:
{ "resourceType": "SearchParameter", "url": "http://example.com/SearchParameter/patient-us-core-ethnicity", "base": ["Patient"], "code": "ethnicity", "name": "ethnicity", "type": "token", "expression": "Patient.extension('http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity').extension('ombCategory').value.as(Coding)", "status": "active", "description": "search on the ombCategory of a patient.", "meta": { "lastUpdated": "2020-01-01T00:00:00+00:00", "versionId": "VERSION_ID" }, }PowerShell
以下示例展示了如何使用 Windows PowerShell 发出“POST”请求,为“mothersMaidenName”扩展字段创建自定义搜索参数资源。$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } $SearchParameter = '{ "resourceType": "SearchParameter", "url": "http://example.com/SearchParameter/patient-us-core-ethnicity", "base": ["Patient"], "code": "ethnicity", "name": "ethnicity", "type": "token", "expression": "Patient.extension(''http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity'').extension(''ombCategory'').value.as(Coding)", "status": "active", "description": "search on the ombCategory of a patient." }' Invoke-WebRequest ` -Method Post ` -Headers $headers ` -ContentType: "application/json; charset=utf-8" ` -Body $SearchParameter ` -Uri "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/SearchParameter"
如果请求成功,服务器将以 JSON 格式返回响应:
{ "resourceType": "SearchParameter", "url": "http://example.com/SearchParameter/patient-us-core-ethnicity", "base": ["Patient"], "code": "ethnicity", "name": "ethnicity", "type": "token", "expression": "Patient.extension('http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity').extension('ombCategory').value.as(Coding)", "status": "active", "description": "search on the ombCategory of a patient.", "meta": { "lastUpdated": "2020-01-01T00:00:00+00:00", "versionId": "VERSION_ID" }, }启用搜索参数:
curl
要启用自定义搜索参数,请发出
POST请求并为您要启用的每个搜索参数指定规范网址。以下示例展示了使用
curl的POST请求。curl -X POST \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/json; charset=utf-8" \ --data "{ \"canonicalUrls\": [\"http://example.com/SearchParameter/patient-us-core-ethnicity\"], }" \ "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID:configureSearch"
如果请求成功,服务器将以 JSON 格式返回响应:
{ "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID" }PowerShell
要启用自定义搜索参数,请发出
POST请求并为您要启用的每个搜索参数指定规范网址。以下示例展示了使用 Windows PowerShell 的
POST请求。$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } $configureSearch = '{ "canonicalUrls": "http://example.com/SearchParameter/patient-us-core-ethnicity" }' ` Invoke-WebRequest ` -Method Post ` -Headers $headers ` -ContentType: "application/json; charset=utf-8" ` -Body $configureSearch ` -Uri "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID:configureSearch"
如果请求成功,服务器将以 JSON 格式返回响应:
{ "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID" }使用自定义搜索参数进行搜索:
curl
以下示例展示了如何使用
curl发出GET请求,以便在患者资源中搜索us-core-ethnicity扩展字段中的代码urn:oid:2.16.840.1.113883.6.238|2028-9。curl -X GET \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient?ethnicity=urn:oid:2.16.840.1.113883.6.238|2028-9"
如果请求成功,服务器将以 JSON 格式的 FHIR
Bundle形式返回响应。Bundle.type是searchset,搜索结果是Bundle.entry数组中的条目。在此示例中,请求返回单个患者资源,包括该资源内的数据:{ "entry": [ { "fullUrl": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/PATIENT_ID", "resource": { "birthDate": "1970-01-01", "gender": "female", "id": "PATIENT_ID", "meta": { "lastUpdated": "LAST_UPDATED", "versionId": "VERSION_ID" }, "name": [ { "family": "Smith", "given": [ "Darcy" ], "use": "official" } ], "resourceType": "Patient" "extension": [ { "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity", "extension": [ { "url" : "ombCategory", "valueCoding" : { "system" : "urn:oid:2.16.840.1.113883.6.238", "code" : "2028-9", "display" : "Asian" } } ] } ] }, "search": { "mode": "match" } } ], "link": [ { "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/?ethnicity=urn:oid:2.16.840.1.113883.6.238|2028-9" } ], "resourceType": "Bundle", "total": 1, "type": "searchset" }PowerShell
以下示例展示了如何使用 Windows PowerShell 发出“GET”请求,以便在患者资源中搜索“us-core-ethnicity”扩展字段中的代码“urn:oid:2.16.840.1.113883.6.238|2028-9”。$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } Invoke-RestMethod ` -Method Get ` -Headers $headers ` -Uri "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient?ethnicity=urn:oid:2.16.840.1.113883.6.238|2028-9 | ConvertTo-Json
如果请求成功,服务器将以 JSON 格式的 FHIR
Bundle形式返回响应。Bundle.type是searchset,搜索结果是Bundle.entry数组中的条目。在此示例中,请求返回单个患者资源,包括该资源内的数据:{ "entry": [ { "fullUrl": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/PATIENT_ID", "resource": { "birthDate": "1970-01-01", "gender": "female", "id": "PATIENT_ID", "meta": { "lastUpdated": "LAST_UPDATED", "versionId": "VERSION_ID" }, "name": [ { "family": "Smith", "given": [ "Darcy" ], "use": "official" } ], "resourceType": "Patient" "extension": [ { "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity", "extension": [ { "url" : "ombCategory", "valueCoding" : { "system" : "urn:oid:2.16.840.1.113883.6.238", "code" : "2028-9", "display" : "Asian" } } ] } ] }, "search": { "mode": "match" } } ], "link": [ { "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/?ethnicity=urn:oid:2.16.840.1.113883.6.238|2028-9" } ], "resourceType": "Bundle", "total": 1, "type": "searchset" }