如何通过Google Healthcare API设置defaultSearchHandlingStrict及更新FHIR Store?
设置Google Healthcare API的defaultSearchHandlingStrict属性
核心说明
要更新FHIR Store的defaultSearchHandlingStrict属性,需使用Patch请求(仅修改目标字段,而非全量替换),通过字段掩码限定仅更新该属性。
JavaScript客户端库示例
假设你已通过@google-cloud/healthcare客户端库获取到FHIR Store对象,以下是将defaultSearchHandlingStrict设为true的具体实现:
1. 确保依赖安装
npm install @google-cloud/healthcare
2. 更新属性的代码实现
const {HealthcareServiceClient} = require('@google-cloud/healthcare'); async function enableStrictSearchHandling() { const client = new HealthcareServiceClient(); // 可直接复用已获取的fhirStore对象的name字段,无需重复拼接 const fhirStoreName = 'projects/你的项目ID/locations/你的区域/datasets/你的数据集ID/fhirStores/你的FHIR Store ID'; // 构造更新请求 const updateRequest = { name: fhirStoreName, fhirStore: { defaultSearchHandlingStrict: true }, updateMask: { paths: ['defaultSearchHandlingStrict'] // 指定仅更新该字段,避免覆盖其他属性 } }; // 执行Patch操作 const [updatedFhirStore] = await client.patchFhirStore(updateRequest); console.log('更新后的FHIR Store:', updatedFhirStore); } // 调用执行 enableStrictSearchHandling().catch(console.error);
关键注意点
- 权限要求:调用者需拥有
healthcare.fhirStores.update权限,可通过分配roles/healthcare.fhirStoreEditor角色实现 - 字段掩码:必须指定
updateMask,否则会意外覆盖FHIR Store的其他配置属性
内容的提问来源于stack exchange,提问作者a1-----
相关产品推荐
相关产品推荐

