本頁說明如何使用 projects.locations.datasets.fhirStores.fhir.search
方法提供的進階查詢功能,搜尋 FHIR 資源。本指南假設您已熟悉「搜尋 FHIR 資源」的內容。
FHIR 軟體包範例
本頁面的範例會使用提供的 JSON FHIR 套件,顯示進階 FHIR 搜尋功能的結果。將 r4_bundle.json
檔案儲存到電腦,以便在範例中使用。
執行範例 FHIR 軟體包
如要在 FHIR 存放區中執行範例 FHIR 軟體包,請參閱「執行軟體包」。FHIR 儲存庫必須具備下列設定:
- 將
enableUpdateCreate
設為true
。 - 將
version
設為 R4。
字串搜尋修飾符
字串搜尋預設為前置字串比對,且不區分大小寫和重音符號,方法是摺疊至標準 Unicode NFC 形式。系統會忽略標點符號和多餘的空白字元。
可用的修飾符如下:
:contains
會比對字串中任何位置含有指定值的資源,例如name:contains=eve
會比對Evelyn
和Severine
。:exact
會比對整個字串,包括大小寫和重音符號,例如name:exact=Eve
不會比對eve
或Evelyn
。
展開下列部分,查看使用搜尋字串修飾符的範例:
字串搜尋修飾符範例
REST
使用任何要求資料之前,請先替換以下項目:
- PROJECT_ID:您的 Google Cloud 專案 ID
- LOCATION:父項資料集的位置
- DATASET_ID:FHIR 儲存庫的父項資料集
- FHIR_STORE_ID:FHIR 儲存庫 ID
如要傳送要求,請選擇以下其中一個選項:
curl
下列範例使用
Patient?name:contains=eve
查詢。
執行下列指令:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient?name:contains=eve"
PowerShell
下列範例使用
Patient?name:contains=eve
查詢。
執行下列指令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient?name:contains=eve" | Select-Object -Expand Content
您應該會收到如下的 JSON 回應:
{ "entry": [ { "fullUrl": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/patient2", "resource": { "active": false, "address": [ { "city": "Mountain View", "district": "KW", "line": [ "1800 Amphibious Blvd" ], "period": { "start": "2000-01-01" }, "text": "1800 Amphibious Blvd", "type": "both", "use": "home" } ], "birthDate": "1989-03-11", "communication": [ { "language": { "coding": [ { "code": "FR", "display": "jkl", "system": "123" }, { "code": "french", "display": "mno", "system": "456" } ], "text": "pqr" } } ], "deceasedBoolean": false, "gender": "female", "id": "patient2", "meta": { "lastUpdated": "YYYY-MM-DDTHH:MM:SS+ZZ:ZZ", "tag": [ { "code": "tag2", "display": "Tag Two", "system": "tag-system" }, { "code": "tag|tag3", "display": "Tag Three", "system": "other" } ], "versionId": "MTYzMTgyMTExMDIyMDk5ODAwMA" }, "name": [ { "family": "Lee", "given": [ "Jane", "Evelyne" ], "use": "usual" } ], "resourceType": "Patient", "telecom": [ { "rank": 1, "system": "phone", "use": "home", "value": "0982344522" }, { "rank": 2, "system": "email", "use": "home", "value": "jane@example.com" } ] }, "search": { "mode": "match" } }, { "fullUrl": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/patient1", "resource": { "active": false, "address": [ { "city": "Mountain View", "district": "KW", "line": [ "1800 Amphibious Blvd" ], "period": { "start": "1974-12-25" }, "text": "1800 Amphibious Blvd", "type": "both", "use": "home" } ], "birthDate": "1974-12-25", "communication": [ { "language": { "coding": [ { "code": "ENG", "display": "def", "system": "123" }, { "code": "english", "display": "ghi", "system": "456" } ], "text": "abc" } } ], "deceasedBoolean": false, "gender": "male", "id": "patient1", "meta": { "lastUpdated": "YYYY-MM-DDTHH:MM:SS+ZZ:ZZ", "tag": [ { "code": "tag1", "display": "Tag One", "system": "tag-system" }, { "code": "tag2", "display": "Tag Two", "system": "other-system" } ], "versionId": "MTYzMTgyMTExMDIyMDk5ODAwMA" }, "name": [ { "family": "Lee", "given": [ "Alex", "Cleve" ], "text": "Alex Lee", "use": "usual" }, { "given": [ "Joe" ], "use": "nickname" } ], "resourceType": "Patient", "telecom": [ { "rank": 1, "system": "phone", "use": "home", "value": "0982344522" }, { "rank": 2, "system": "email", "use": "home", "value": "alex@example.com" } ] }, "search": { "mode": "match" } } ], "link": [ { "relation": "search", "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/?name%3Acontains=eve" }, { "relation": "first", "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/?name%3Acontains=eve" }, { "relation": "self", "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/?name%3Acontains=eve" } ], "resourceType": "Bundle", "total": 2, "type": "searchset" }
數字、日期和數量的比較子和精確度
在數字或日期搜尋中使用的值取決於參數值的精確度。舉例來說,數字 7.00
的隱含範圍為 6.995
(含) 到 7.005
(不含)。日期 2015-08-12
的範圍為包含 2015-08-12T00:00:00
但不含 2015-08-13T00:00:00
。
精確度會影響等式比較傳回的結果。舉例來說,資源中的 7.03
值會與 value=7.0
的搜尋結果相符,但不會與 value=7.00
的搜尋結果相符。
FHIR 中所有具有臨床意義的浮點值,都會以 Decimal 和 Quantity 等類型表示,這些類型會記錄儲存值的精確度。但有少數欄位會使用簡單的整數,例如表示序列中的位置,而對這些欄位進行搜尋時,系統會比對確切的數值。
下列前置字元適用於與單一值進行的數值比較。
如未指定任何前置字元,則預設為 eq
。
eq
:等於,確切的儲存值位於參數值精確度定義的範圍內ne
:不等於,與eq
相反gt
:確切的儲存值大於確切的參數值lt
:確切儲存的值小於確切參數值ge
:確切儲存的值大於或等於確切參數值le
:確切儲存的值小於或等於確切參數值
日期值會根據值的具體程度 (一年、一個月、一天) 隱含範圍。其他資料類型 (例如「範圍」和「週期」) 包含明確的上下限。以下前置字元適用於範圍比較。如未指定任何前置字元,則預設為 eq
。
eq
:等於,參數值的範圍完全包含目標的範圍ne
:不等於,與eq
相反gt
:大於,參數值以上的範圍與目標範圍重疊lt
:小於,參數值以下的範圍與目標範圍重疊ge
:大於或等於le
:小於或等於sa
:參數值的範圍從目標範圍之後開始eb
:參數值範圍在目標範圍之前結束
數字、日期和數量樣本的比較子和精確度
REST
使用任何要求資料之前,請先替換以下項目:
- PROJECT_ID:您的 Google Cloud 專案 ID
- LOCATION:父項資料集的位置
- DATASET_ID:FHIR 儲存庫的父項資料集
- FHIR_STORE_ID:FHIR 儲存庫 ID
如要傳送要求,請選擇以下其中一個選項:
curl
下列範例使用
_lastUpdated=gt2018-01-01
查詢,搜尋 _lastUpdated
值大於 (gt
)2018-01-01
的病患資源。
執行下列指令:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient?_lastUpdated=gt2018-01-01"
PowerShell
下列範例使用
_lastUpdated=gt2018-01-01
查詢,搜尋 _lastUpdated
值大於 (gt
)2018-01-01
的病患資源。
執行下列指令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient?_lastUpdated=gt2018-01-01" | Select-Object -Expand Content
查詢 _lastUpdated=gt2018-01-01
會傳回自 2018 年 1 月 1 日起更新的病患資源。如果您是在該日期之後建立 FHIR 儲存庫中的所有資源,伺服器就會傳回所有資源。如要查看部分資源,請將日期變更為某些資源上次更新後的時間。
{ "entry": [ { "fullUrl": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/patient3", "resource": { "active": false, "address": [ { "city": "Lisbon", "district": "KW", "line": [ "Avenida da Pastelaria, 1903" ], "period": { "start": "1980-01-01" }, "text": "Avenida da Pastelaria, 1903", "type": "both", "use": "home" } ], "birthDate": "1980-01-01", "deceasedBoolean": false, "id": "patient3", "meta": { "lastUpdated": "YYYY-MM-DDTHH:MM:SS+ZZ:ZZ", "tag": [ { "code": "tag3", "display": "Tag $3", "system": "other|tag" }, { "code": "code,4", "display": "Tag 4", "system": "system" } ], "versionId": "MTYzMTgyMTExMDIyMDk5ODAwMA" }, "name": [ { "family": "Smith", "given": [ "Mary" ], "text": "Smith, Mary", "use": "usual" } ], "resourceType": "Patient", "telecom": [ { "rank": 1, "system": "phone", "use": "home", "value": "1110891111" }, { "rank": 2, "system": "email", "use": "home", "value": "mary@example.com" } ] }, "search": { "mode": "match" } }, { "fullUrl": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/patient2", "resource": { "active": false, "address": [ { "city": "Mountain View", "district": "KW", "line": [ "1800 Amphibious Blvd" ], "period": { "start": "2000-01-01" }, "text": "1800 Amphibious Blvd", "type": "both", "use": "home" } ], "birthDate": "1989-03-11", "communication": [ { "language": { "coding": [ { "code": "FR", "display": "jkl", "system": "123" }, { "code": "french", "display": "mno", "system": "456" } ], "text": "pqr" } } ], "deceasedBoolean": false, "gender": "female", "id": "patient2", "meta": { "lastUpdated": "YYYY-MM-DDTHH:MM:SS+ZZ:ZZ", "tag": [ { "code": "tag2", "display": "Tag Two", "system": "tag-system" }, { "code": "tag|tag3", "display": "Tag Three", "system": "other" } ], "versionId": "MTYzMTgyMTExMDIyMDk5ODAwMA" }, "name": [ { "family": "Lee", "given": [ "Jane", "Evelyne" ], "use": "usual" } ], "resourceType": "Patient", "telecom": [ { "rank": 1, "system": "phone", "use": "home", "value": "0982344522" }, { "rank": 2, "system": "email", "use": "home", "value": "jane@example.com" } ] }, "search": { "mode": "match" } }, { "fullUrl": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/8ac08aa9-63d2-4e81-8647-3a138d7f9f5a", "resource": { "address": [ { "country": "US", "line": [ "907 Arlo Cliffs", "Suite 984" ], "postalCode": "XXXXX" } ], "birthDate": "1940-12-01", "communication": [ { "language": { "coding": [ { "code": "en-US", "display": "English (United States)", "system": "urn:ietf:bcp:47" } ] } } ], "deceasedDateTime": "2009-07-26T12:01:23-05:00", "extension": [ { "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race", "valueCodeableConcept": { "coding": [ { "code": "2106-3", "display": "White", "system": "http://hl7.org/fhir/v3/Race" } ], "text": "race" } }, { "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity", "valueCodeableConcept": { "coding": [ { "code": "2186-5", "display": "Nonhispanic", "system": "http://hl7.org/fhir/v3/Ethnicity" } ], "text": "ethnicity" } }, { "url": "http://hl7.org/fhir/StructureDefinition/birthPlace", "valueAddress": { "city": "Tama", "country": "US", "postalCode": "52339", "state": "Iowa" } }, { "url": "http://hl7.org/fhir/StructureDefinition/patient-mothersMaidenName", "valueString": "Farrah Feeney" }, { "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex", "valueCode": "M" }, { "url": "http://hl7.org/fhir/StructureDefinition/patient-interpreterRequired", "valueBoolean": false }, { "url": "http://standardhealthrecord.org/fhir/StructureDefinition/shr-actor-FictionalPerson-extension", "valueBoolean": true }, { "url": "http://standardhealthrecord.org/fhir/StructureDefinition/shr-demographics-FathersName-extension", "valueHumanName": { "text": "Christopher Diaz" } }, { "url": "http://standardhealthrecord.org/fhir/StructureDefinition/shr-demographics-SocialSecurityNumber-extension", "valueString": "999-16-9041" } ], "gender": "male", "generalPractitioner": [ { "reference": "Organization/9fb51c89-1453-406c-8357-578311b43a91" } ], "id": "8ac08aa9-63d2-4e81-8647-3a138d7f9f5a", "identifier": [ { "system": "https://github.com/synthetichealth/synthea", "value": "c1ee4b49-3194-4b39-91ed-4d1393a780c6" }, { "system": "http://hl7.org/fhir/sid/us-ssn", "type": { "coding": [ { "code": "SB", "system": "http://hl7.org/fhir/identifier-type" } ] }, "value": "999169041" }, { "system": "urn:oid:2.16.840.1.113883.4.3.25", "type": { "coding": [ { "code": "DL", "system": "http://hl7.org/fhir/v2/0203" } ] }, "value": "S99992205" }, { "system": "http://standardhealthrecord.org/fhir/StructureDefinition/passportNumber", "type": { "coding": [ { "code": "PPN", "system": "http://hl7.org/fhir/v2/0203" } ] }, "value": "X12551631X" }, { "system": "http://hospital.smarthealthit.org", "type": { "coding": [ { "code": "MR", "system": "http://hl7.org/fhir/v2/0203" } ] }, "value": "c1ee4b49-3194-4b39-91ed-4d1393a780c6" } ], "maritalStatus": { "coding": [ { "code": "S", "system": "http://hl7.org/fhir/v3/MaritalStatus" } ], "text": "S" }, "meta": { "lastUpdated": "YYYY-MM-DDTHH:MM:SS+ZZ:ZZ", "profile": [ "http://standardhealthrecord.org/fhir/StructureDefinition/shr-demographics-PersonOfRecord" ], "versionId": "MTYzMTgyMTExMDIyMDk5ODAwMA" }, "multipleBirthBoolean": false, "name": [ { "family": "Diaz", "given": [ "Christopher" ], "prefix": [ "Mr." ], "use": "official" } ], "resourceType": "Patient", "telecom": [ { "system": "phone", "use": "home", "value": "434-100-2918 x800" } ], "text": { "div": "Generated by Synthea. Version identifier: 2dd4c1c37e2743d14e5073c7b5e42899a3e51531", "status": "generated" } }, "search": { "mode": "match" } }, { "fullUrl": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/patient1", "resource": { "active": false, "address": [ { "city": "Mountain View", "district": "KW", "line": [ "1800 Amphibious Blvd" ], "period": { "start": "1974-12-25" }, "text": "1800 Amphibious Blvd", "type": "both", "use": "home" } ], "birthDate": "1974-12-25", "communication": [ { "language": { "coding": [ { "code": "ENG", "display": "def", "system": "123" }, { "code": "english", "display": "ghi", "system": "456" } ], "text": "abc" } } ], "deceasedBoolean": false, "gender": "male", "id": "patient1", "meta": { "lastUpdated": "YYYY-MM-DDTHH:MM:SS+ZZ:ZZ", "tag": [ { "code": "tag1", "display": "Tag One", "system": "tag-system" }, { "code": "tag2", "display": "Tag Two", "system": "other-system" } ], "versionId": "MTYzMTgyMTExMDIyMDk5ODAwMA" }, "name": [ { "family": "Lee", "given": [ "Alex", "Cleve" ], "text": "Alex Lee", "use": "usual" }, { "given": [ "Joe" ], "use": "nickname" } ], "resourceType": "Patient", "telecom": [ { "rank": 1, "system": "phone", "use": "home", "value": "0982344522" }, { "rank": 2, "system": "email", "use": "home", "value": "alex@example.com" } ] }, "search": { "mode": "match" } } ], "link": [ { "relation": "search", "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/?_lastUpdated=gt2018-01-01" }, { "relation": "first", "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/?_lastUpdated=gt2018-01-01" }, { "relation": "self", "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/?_lastUpdated=gt2018-01-01" } ], "resourceType": "Bundle", "total": 4, "type": "searchset" }
權杖搜尋
如果值不是任意字串,而是命名系統中的實體,就適用權杖搜尋參數。權杖參數的字串比對結果必須完全相符。
大多數權杖搜尋適用於含有 system
的複雜資料類型,該 system
是 URI,指出 code
值取自的命名系統。這些搜尋支援下列值語法:
[parameter]=[code]
符合code
值,不論system
為何[parameter]=[system]|[code]
必須同時符合指定的system
和code
- 如果
system
值為空白,則[parameter]=|[code]
會與code
相符 [parameter]=[system]|
符合具有指定system
值的任何code
有幾種修飾符會觸發替代符記搜尋功能:
:not
會否定符記搜尋的比對條件:text
對與程式碼相關聯的text
或display
欄位執行字串搜尋 (而非完全比對),而不是程式碼值本身:above
只會採用[system]|[code]
形式的參數,並比對資源,其中資源中的程式碼會包含查詢參數。如要使用這個修飾符,指定的system
必須以CodeSystem
資源的形式存在於 FHIR 儲存庫中。:below
與:above
類似,但如果資源中的程式碼由查詢參數涵蓋,就會相符。:in
會使用參照參數語法接收單一參數,例如code:in=ValueSet/1234
。參照必須參照同一 FHIR 儲存庫中的ValueSet
資源。修飾符會比對參照ValueSet
中的任何程式碼。:not-in
會否定:in
的條件
權杖搜尋也適用於布林值和 URI 欄位,以及只允許完全比對的特定字串欄位。在這些情況下,唯一參數格式為 [parameter]=[value]
。
權杖搜尋範例
REST
使用任何要求資料之前,請先替換以下項目:
- PROJECT_ID:您的 Google Cloud 專案 ID
- LOCATION:父項資料集的位置
- DATASET_ID:FHIR 儲存庫的父項資料集
- FHIR_STORE_ID:FHIR 儲存庫 ID
如要傳送要求,請選擇以下其中一個選項:
curl
下列範例使用
Patient?_tag=tag-system|tag2
查詢,搜尋具有指定 system
和 code
的病患資源。
執行下列指令:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient?_tag=tag-system|tag2"
PowerShell
下列範例使用
Patient?_tag=tag-system|tag2
查詢,搜尋具有指定 system
和 code
的病患資源。
執行下列指令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient?_tag=tag-system|tag2" | Select-Object -Expand Content
您應該會收到如下的 JSON 回應:
{ "entry": [ { "fullUrl": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/patient2", "resource": { "active": false, "address": [ { "city": "Mountain View", "district": "KW", "line": [ "1800 Amphibious Blvd" ], "period": { "start": "2000-01-01" }, "text": "1800 Amphibious Blvd", "type": "both", "use": "home" } ], "birthDate": "1989-03-11", "communication": [ { "language": { "coding": [ { "code": "FR", "display": "jkl", "system": "123" }, { "code": "french", "display": "mno", "system": "456" } ], "text": "pqr" } } ], "deceasedBoolean": false, "gender": "female", "id": "patient2", "meta": { "lastUpdated": "YYYY-MM-DDTHH:MM:SS+ZZ:ZZ", "tag": [ { "code": "tag2", "display": "Tag Two", "system": "tag-system" }, { "code": "tag|tag3", "display": "Tag Three", "system": "other" } ], "versionId": "MTYzMTgyMTExMDIyMDk5ODAwMA" }, "name": [ { "family": "Lee", "given": [ "Jane", "Evelyne" ], "use": "usual" } ], "resourceType": "Patient", "telecom": [ { "rank": 1, "system": "phone", "use": "home", "value": "0982344522" }, { "rank": 2, "system": "email", "use": "home", "value": "jane@example.com" } ] }, "search": { "mode": "match" } } ], "link": [ { "relation": "search", "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/?_tag=tag-system%7Ctag2" }, { "relation": "first", "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/?_tag=tag-system%7Ctag2" }, { "relation": "self", "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/?_tag=tag-system%7Ctag2" } ], "resourceType": "Bundle", "total": 1, "type": "searchset" }
搜尋遺漏值
您可以在任何搜尋參數中使用搜尋修飾符 :missing
,根據指定欄位中是否有任何值進行比對。舉例來說,Patient?gender=unknown
會比對明確包含性別 unknown
列舉值的資源,但由於這個欄位並非必填,因此可能會有其他資源完全未填入這個欄位。這類資源可由 Patient?gender:missing=true
比對。反之,Patient?gender:missing=false
會比對明確填入這個欄位的任何資源。
缺少值範例
REST
使用任何要求資料之前,請先替換以下項目:
- PROJECT_ID:您的 Google Cloud 專案 ID
- LOCATION:父項資料集的位置
- DATASET_ID:FHIR 儲存庫的父項資料集
- FHIR_STORE_ID:FHIR 儲存庫 ID
如要傳送要求,請選擇以下其中一個選項:
curl
下列範例使用
gender:missing=false
查詢:
執行下列指令:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient?gender:missing=false"
PowerShell
下列範例使用
gender:missing=false
查詢:
執行下列指令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient?gender:missing=false" | Select-Object -Expand Content
patient3
的病患資源缺少 gender
值:
{ "entry": [ { "fullUrl": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/mydataset/fhirStores/FHIR_STORE_ID/fhir/Patient/patient3", "resource": { "active": false, "address": [ { "city": "Lisbon", "district": "KW", "line": [ "Avenida da Pastelaria, 1903" ], "period": { "start": "1980-01-01" }, "text": "Avenida da Pastelaria, 1903", "type": "both", "use": "home" } ], "birthDate": "1980-01-01", "deceasedBoolean": false, "id": "patient3", "meta": { "lastUpdated": "YYYY-MM-DDTHH:MM:SS+ZZ:ZZ", "tag": [ { "code": "tag3", "display": "Tag $3", "system": "other|tag" }, { "code": "code,4", "display": "Tag 4", "system": "system" } ], "versionId": "MTYzMTgyMTExMDIyMDk5ODAwMA" }, "name": [ { "family": "Smith", "given": [ "Mary" ], "text": "Smith, Mary", "use": "usual" } ], "resourceType": "Patient", "telecom": [ { "rank": 1, "system": "phone", "use": "home", "value": "1110891111" }, { "rank": 2, "system": "email", "use": "home", "value": "mary@example.com" } ] }, "search": { "mode": "match" } } ], "link": [ { "relation": "search", "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/mydataset/fhirStores/FHIR_STORE_ID/fhir/Patient/?gender%3Amissing=true" }, { "relation": "first", "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/mydataset/fhirStores/FHIR_STORE_ID/fhir/Patient/?gender%3Amissing=true" }, { "relation": "self", "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/mydataset/fhirStores/FHIR_STORE_ID/fhir/Patient/?gender%3Amissing=true" } ], "resourceType": "Bundle", "total": 1, "type": "searchset" }
文字搜尋
如果欄位是資源上任何搜尋參數的目標,特殊搜尋參數 _content
會對字串型欄位執行文字比對 (不包括數字、日期或列舉欄位)。根據預設,_content
會比對包含查詢中所有字詞的資源,並支援其他運算子:
|
是 OR 運算子,例如abc | def | ghi xyz
會比對包含xyz
和一或多個abc
def
ghi
的資源。-
是 NOT 運算子,例如abc -def
會比對包含abc
但不包含def
的資源。
比對依據是完整字詞,不比對子字串或非英數字元。字詞順序沒有影響。相符字詞可分布在資源的多個欄位中。
參數 _text
只會對「敘述」欄位執行相同類型的比對,這個欄位應包含資源內容的清楚易懂摘要。Cloud Healthcare API 不會自動產生這份摘要,但如果用戶端在建立或更新資源時填入這項資料,API 就會支援 _text
搜尋參數。
文字搜尋範例
REST
使用任何要求資料之前,請先替換以下項目:
- PROJECT_ID:您的 Google Cloud 專案 ID
- LOCATION:父項資料集的位置
- DATASET_ID:FHIR 儲存庫的父項資料集
- FHIR_STORE_ID:FHIR 儲存庫 ID
如要傳送要求,請選擇以下其中一個選項:
curl
下列範例使用
_content=Smith%20|%20Mountain%20View
查詢:
執行下列指令:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient?_content=Smith%20|%20Mountain%20View"
PowerShell
下列範例使用
_content=Smith%20|%20Mountain%20View
查詢:
執行下列指令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient?_content=Smith%20|%20Mountain%20View" | Select-Object -Expand Content
您應該會收到如下的 JSON 回應:
{ "entry": [ { "fullUrl": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/patient1", "resource": { "active": false, "address": [ { "city": "Mountain View", "district": "KW", "line": [ "1800 Amphibious Blvd" ], "period": { "start": "1974-12-25" }, "text": "1800 Amphibious Blvd", "type": "both", "use": "home" } ], "birthDate": "1974-12-25", "communication": [ { "language": { "coding": [ { "code": "ENG", "display": "def", "system": "123" }, { "code": "english", "display": "ghi", "system": "456" } ], "text": "abc" } } ], "deceasedBoolean": false, "gender": "male", "id": "patient1", "meta": { "lastUpdated": "2021-10-21T16:41:47.211939+00:00", "tag": [ { "code": "tag1", "display": "Tag One", "system": "tag-system" }, { "code": "tag2", "display": "Tag Two", "system": "other-system" } ], "versionId": "MTYzNDgzNDUwNzIxMTkzOTAwMA" }, "name": [ { "family": "Lee", "given": [ "Alex", "Cleve" ], "text": "Alex Lee", "use": "usual" }, { "given": [ "Joe" ], "use": "nickname" } ], "resourceType": "Patient", "telecom": [ { "rank": 1, "system": "phone", "use": "home", "value": "0982344522" }, { "rank": 2, "system": "email", "use": "home", "value": "alex@example.com" } ] }, "search": { "mode": "match" } }, { "fullUrl": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/patient2", "resource": { "active": false, "address": [ { "city": "Mountain View", "district": "KW", "line": [ "1800 Amphibious Blvd" ], "period": { "start": "2000-01-01" }, "text": "1800 Amphibious Blvd", "type": "both", "use": "home" } ], "birthDate": "1989-03-11", "communication": [ { "language": { "coding": [ { "code": "FR", "display": "jkl", "system": "123" }, { "code": "french", "display": "mno", "system": "456" } ], "text": "pqr" } } ], "deceasedBoolean": false, "gender": "female", "id": "patient2", "meta": { "lastUpdated": "2021-10-21T16:41:47.211939+00:00", "tag": [ { "code": "tag2", "display": "Tag Two", "system": "tag-system" }, { "code": "tag|tag3", "display": "Tag Three", "system": "other" } ], "versionId": "MTYzNDgzNDUwNzIxMTkzOTAwMA" }, "name": [ { "family": "Lee", "given": [ "Jane", "Evelyne" ], "use": "usual" } ], "resourceType": "Patient", "telecom": [ { "rank": 1, "system": "phone", "use": "home", "value": "0982344522" }, { "rank": 2, "system": "email", "use": "home", "value": "jane@example.com" } ] }, "search": { "mode": "match" } } ], "link": [ { "relation": "search", "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/?_content=Smith%7CMountain+View" }, { "relation": "first", "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/?_content=Smith%7CMountain+View" }, { "relation": "self", "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/?_content=Smith%7CMountain+View" } ], "resourceType": "Bundle", "total": 2, "type": "searchset" }
複合搜尋參數
使用多個查詢參數搜尋時,有時個別搜尋參數與 AND 結合後,會比對出非預期的結果。複合搜尋參數是一種特殊的搜尋參數,可解決這個問題。
舉例來說,Observation
資源的 component
欄位可能包含多個值,每個值都包含一組 code
和 value
。搜尋 Observation?component-code=8867-4&component-value-quantity=lt50
時,如果資源有一個元件包含 8867-4 的 code
,且另一個元件包含小於 50 的 value
,就會相符。這項搜尋無法用於限制在同一元件中比對這兩個值。
複合搜尋參數會定義新的參數,結合另外兩個搜尋參數,並定義兩者都必須相符的巢狀層級。在查詢中,這兩個值會以 $
聯結。舉例來說,Observation
具有複合參數 component-code-value-quantity
,可透過搜尋 Observation?component-code-value-quantity=8867-4$lt50
,將先前的範例限制為單一元件。這些參數是由 FHIR 規格定義,並非適用於所有搜尋參數組合。
複合搜尋參數不允許使用修飾符。
與所有搜尋參數一樣,如要瞭解 Cloud Healthcare API 支援哪些複合參數,請參閱功能聲明或 FHIR 一致性聲明。
複合搜尋範例
REST
使用任何要求資料之前,請先替換以下項目:
- PROJECT_ID:您的 Google Cloud 專案 ID
- LOCATION:父項資料集的位置
- DATASET_ID:FHIR 儲存庫的父項資料集
- FHIR_STORE_ID:FHIR 儲存庫 ID
如要傳送要求,請選擇以下其中一個選項:
curl
下列範例使用
Observation?component-code-value-quantity=8480-6$lt150
查詢。
執行下列指令:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation?component-code-value-quantity=8480-6\$lt150"
PowerShell
下列範例使用
Observation?component-code-value-quantity=8480-6$lt150
查詢。
執行下列指令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation?component-code-value-quantity=8480-6\$lt150" | Select-Object -Expand Content
component-code=8480-6
和 component-value-quantity
為 133,符合 lt150
的條件。
{ "entry": [ { "fullUrl": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation/a35bf421-1f00-4897-a94d-4d47c3bb306b", "resource": { "category": [ { "coding": [ { "code": "vital-signs", "system": "http://hl7.org/fhir/observation-category" } ] } ], "code": { "coding": [ { "code": "55284-4", "display": "Blood Pressure", "system": "http://loinc.org" } ] }, "component": [ { "code": { "coding": [ { "code": "8480-6", "display": "Systolic Blood Pressure", "system": "http://loinc.org" } ], "text": "Systolic Blood Pressure" }, "valueQuantity": { "code": "mmHg", "system": "http://unitsofmeasure.org", "unit": "mmHg", "value": 133 } }, { "code": { "coding": [ { "code": "8462-4", "display": "Diastolic Blood Pressure", "system": "http://loinc.org" } ], "text": "Diastolic Blood Pressure" }, "valueQuantity": { "code": "mmHg", "system": "http://unitsofmeasure.org", "unit": "mmHg", "value": 84 } } ], "effectiveDateTime": "2008-03-07T17:47:02-05:00", "encounter": { "reference": "Encounter/0e9d631c-4407-45e5-bfbe-689806caaf7b" }, "id": "a35bf421-1f00-4897-a94d-4d47c3bb306b", "issued": "2008-03-07T17:47:02-05:00", "meta": { "lastUpdated": "YYYY-MM-DDTHH:MM:SS+ZZ:ZZ", "profile": [ "http://standardhealthrecord.org/fhir/StructureDefinition/shr-observation-Observation", "http://standardhealthrecord.org/fhir/StructureDefinition/shr-vital-BloodPressure" ], "versionId": "MTYzMTgyMTExMDIyMDk5ODAwMA" }, "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/8ac08aa9-63d2-4e81-8647-3a138d7f9f5a" } }, "search": { "mode": "match" } } ], "link": [ { "relation": "search", "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation/?component-code-value-quantity=8480-6%24lt150" }, { "relation": "first", "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation/?component-code-value-quantity=8480-6%24lt150" }, { "relation": "self", "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation/?component-code-value-quantity=8480-6%24lt150" } ], "resourceType": "Bundle", "total": 1, "type": "searchset" }
鏈結搜尋
鏈結搜尋可讓搜尋在查詢內容的參照中移動。鏈結搜尋的基本語法如下:
[reference parameter]:[resource type].[inner search parameter]=[inner value]
如果參照參數只參照一種資源類型,則可以省略 :[resource
type]
,產生以下結果:
[reference parameter].[inner search parameter]=[inner value]
舉例來說,Observation
具有參照搜尋參數 subject
,可能指向 Group
、Device
、Patient
或 Location
。如要找出名稱開頭為「Joe」的 Patient
,並取得該 Patient
的 subject
,可以搜尋 Observation?subject:Patient.name=Joe
。Observations
如果查詢有多個鏈結參數,系統會分別評估每個鏈結。舉例來說,Patient?general-practitioner.name=Joe&general-practitioner.address-country=Canada
會比對具有兩個 general-practitioner
參照的 Patient
,一個名為「Joe」,另一個的地址位於加拿大。沒有語法可將這些子句分組,只比對來自加拿大的 Joe。
鏈結搜尋可以遞迴處理其他鏈結或反向鏈結,例如 Observation?subject:Patient.organization.name=Acme
會比對參照 subject
的 Observation
,而 subject
參照的 organization
具有 Acme
的 name
。
連鎖搜尋範例
REST
使用任何要求資料之前,請先替換以下項目:
- PROJECT_ID:您的 Google Cloud 專案 ID
- LOCATION:父項資料集的位置
- DATASET_ID:FHIR 儲存庫的父項資料集
- FHIR_STORE_ID:FHIR 儲存庫 ID
如要傳送要求,請選擇以下其中一個選項:
curl
以下範例使用
Observation?subject:Patient.name=Christopher
查詢,傳回所有具有 subject
的「觀測」項目,而 subject
是名稱開頭為 Christopher
的 Patient
。
執行下列指令:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation?subject:Patient.name=Christopher"
PowerShell
以下範例使用
Observation?subject:Patient.name=Christopher
查詢,傳回所有具有 subject
的「觀測」項目,而 subject
是名稱開頭為 Christopher
的 Patient
。
執行下列指令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation?subject:Patient.name=Christopher" | Select-Object -Expand Content
您應該會收到如下的 JSON 回應:
{ "entry": [ { "fullUrl": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation/85652a63-09ba-4a5b-ac5b-b690c6972eb5", "resource": { "category": [ { "coding": [ { "code": "laboratory", "system": "http://hl7.org/fhir/observation-category" } ] } ], "code": { "coding": [ { "code": "2093-3", "display": "Total Cholesterol", "system": "http://loinc.org" } ], "text": "Total Cholesterol" }, "effectiveDateTime": "2008-03-07T17:47:02-05:00", "encounter": { "reference": "Encounter/0e9d631c-4407-45e5-bfbe-689806caaf7b" }, "id": "85652a63-09ba-4a5b-ac5b-b690c6972eb5", "issued": "2008-03-07T17:47:02-05:00", "meta": { "lastUpdated": "YYYY-MM-DDTHH:MM:SS+ZZ:ZZ", "profile": [ "http://standardhealthrecord.org/fhir/StructureDefinition/shr-observation-Observation" ], "versionId": "MTYzMTgyMTExMDIyMDk5ODAwMA" }, "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/8ac08aa9-63d2-4e81-8647-3a138d7f9f5a" }, "valueQuantity": { "code": "mg/dL", "system": "http://unitsofmeasure.org", "unit": "mg/dL", "value": 191 } }, "search": { "mode": "match" } }, { "fullUrl": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation/e7aea507-61af-4290-9323-0b3daed0b7a9", "resource": { "category": [ { "coding": [ { "code": "laboratory", "system": "http://hl7.org/fhir/observation-category" } ] } ], "code": { "coding": [ { "code": "2571-8", "display": "Triglycerides", "system": "http://loinc.org" } ], "text": "Triglycerides" }, "effectiveDateTime": "2008-03-07T17:47:02-05:00", "encounter": { "reference": "Encounter/0e9d631c-4407-45e5-bfbe-689806caaf7b" }, "id": "e7aea507-61af-4290-9323-0b3daed0b7a9", "issued": "2008-03-07T17:47:02-05:00", "meta": { "lastUpdated": "YYYY-MM-DDTHH:MM:SS+ZZ:ZZ", "profile": [ "http://standardhealthrecord.org/fhir/StructureDefinition/shr-observation-Observation" ], "versionId": "MTYzMTgyMTExMDIyMDk5ODAwMA" }, "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/8ac08aa9-63d2-4e81-8647-3a138d7f9f5a" }, "valueQuantity": { "code": "mg/dL", "system": "http://unitsofmeasure.org", "unit": "mg/dL", "value": 143 } }, "search": { "mode": "match" } }, { "fullUrl": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation/a35bf421-1f00-4897-a94d-4d47c3bb306b", "resource": { "category": [ { "coding": [ { "code": "vital-signs", "system": "http://hl7.org/fhir/observation-category" } ] } ], "code": { "coding": [ { "code": "55284-4", "display": "Blood Pressure", "system": "http://loinc.org" } ] }, "component": [ { "code": { "coding": [ { "code": "8480-6", "display": "Systolic Blood Pressure", "system": "http://loinc.org" } ], "text": "Systolic Blood Pressure" }, "valueQuantity": { "code": "mmHg", "system": "http://unitsofmeasure.org", "unit": "mmHg", "value": 133 } }, { "code": { "coding": [ { "code": "8462-4", "display": "Diastolic Blood Pressure", "system": "http://loinc.org" } ], "text": "Diastolic Blood Pressure" }, "valueQuantity": { "code": "mmHg", "system": "http://unitsofmeasure.org", "unit": "mmHg", "value": 84 } } ], "effectiveDateTime": "2008-03-07T17:47:02-05:00", "encounter": { "reference": "Encounter/0e9d631c-4407-45e5-bfbe-689806caaf7b" }, "id": "a35bf421-1f00-4897-a94d-4d47c3bb306b", "issued": "2008-03-07T17:47:02-05:00", "meta": { "lastUpdated": "YYYY-MM-DDTHH:MM:SS+ZZ:ZZ", "profile": [ "http://standardhealthrecord.org/fhir/StructureDefinition/shr-observation-Observation", "http://standardhealthrecord.org/fhir/StructureDefinition/shr-vital-BloodPressure" ], "versionId": "MTYzMTgyMTExMDIyMDk5ODAwMA" }, "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/8ac08aa9-63d2-4e81-8647-3a138d7f9f5a" } }, "search": { "mode": "match" } }, { "fullUrl": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation/14df9701-2dd4-4538-8fac-776c40dec22d", "resource": { "category": [ { "coding": [ { "code": "vital-signs", "system": "http://hl7.org/fhir/observation-category" } ] } ], "code": { "coding": [ { "code": "8302-2", "display": "Body Height", "system": "http://loinc.org" } ], "text": "Body Height" }, "effectiveDateTime": "2008-03-07T17:47:02-05:00", "encounter": { "reference": "Encounter/0e9d631c-4407-45e5-bfbe-689806caaf7b" }, "id": "14df9701-2dd4-4538-8fac-776c40dec22d", "issued": "2008-03-07T17:47:02-05:00", "meta": { "lastUpdated": "YYYY-MM-DDTHH:MM:SS+ZZ:ZZ", "profile": [ "http://standardhealthrecord.org/fhir/StructureDefinition/shr-observation-Observation", "http://standardhealthrecord.org/fhir/StructureDefinition/shr-vital-VitalSign", "http://standardhealthrecord.org/fhir/StructureDefinition/shr-vital-BodyHeight" ], "versionId": "MTYzMTgyMTExMDIyMDk5ODAwMA" }, "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/8ac08aa9-63d2-4e81-8647-3a138d7f9f5a" }, "valueQuantity": { "code": "cm", "system": "http://unitsofmeasure.org", "unit": "centimeters", "value": 177.72961711703704 } }, "search": { "mode": "match" } }, { "fullUrl": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation/1e2fdce6-4c79-4ef8-a5a9-2326cddbc8b3", "resource": { "category": [ { "coding": [ { "code": "vital-signs", "system": "http://hl7.org/fhir/observation-category" } ] } ], "code": { "coding": [ { "code": "39156-5", "display": "Body Mass Index", "system": "http://loinc.org" } ], "text": "Body Mass Index" }, "effectiveDateTime": "2008-03-07T17:47:02-05:00", "encounter": { "reference": "Encounter/0e9d631c-4407-45e5-bfbe-689806caaf7b" }, "id": "1e2fdce6-4c79-4ef8-a5a9-2326cddbc8b3", "issued": "2008-03-07T17:47:02-05:00", "meta": { "lastUpdated": "YYYY-MM-DDTHH:MM:SS+ZZ:ZZ", "profile": [ "http://standardhealthrecord.org/fhir/StructureDefinition/shr-observation-Observation", "http://standardhealthrecord.org/fhir/StructureDefinition/shr-vital-VitalSign", "http://standardhealthrecord.org/fhir/StructureDefinition/shr-vital-BodyMassIndex" ], "versionId": "MTYzMTgyMTExMDIyMDk5ODAwMA" }, "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/8ac08aa9-63d2-4e81-8647-3a138d7f9f5a" }, "valueQuantity": { "code": "kg/m2", "system": "http://unitsofmeasure.org", "unit": "kg/m2", "value": 38.34566163709526 } }, "search": { "mode": "match" } }, { "fullUrl": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation/58357362-6f18-438a-8479-3289ebab1617", "resource": { "category": [ { "coding": [ { "code": "laboratory", "system": "http://hl7.org/fhir/observation-category" } ] } ], "code": { "coding": [ { "code": "18262-6", "display": "Low Density Lipoprotein Cholesterol", "system": "http://loinc.org" } ], "text": "Low Density Lipoprotein Cholesterol" }, "effectiveDateTime": "2008-03-07T17:47:02-05:00", "encounter": { "reference": "Encounter/0e9d631c-4407-45e5-bfbe-689806caaf7b" }, "id": "58357362-6f18-438a-8479-3289ebab1617", "issued": "2008-03-07T17:47:02-05:00", "meta": { "lastUpdated": "YYYY-MM-DDTHH:MM:SS+ZZ:ZZ", "profile": [ "http://standardhealthrecord.org/fhir/StructureDefinition/shr-observation-Observation" ], "versionId": "MTYzMTgyMTExMDIyMDk5ODAwMA" }, "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/8ac08aa9-63d2-4e81-8647-3a138d7f9f5a" }, "valueQuantity": { "code": "mg/dL", "system": "http://unitsofmeasure.org", "unit": "mg/dL", "value": 102 } }, "search": { "mode": "match" } }, { "fullUrl": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation/c6f1b042-a0fc-4bbc-9cd5-7a8a924c00e7", "resource": { "category": [ { "coding": [ { "code": "laboratory", "system": "http://hl7.org/fhir/observation-category" } ] } ], "code": { "coding": [ { "code": "2085-9", "display": "High Density Lipoprotein Cholesterol", "system": "http://loinc.org" } ], "text": "High Density Lipoprotein Cholesterol" }, "effectiveDateTime": "2008-03-07T17:47:02-05:00", "encounter": { "reference": "Encounter/0e9d631c-4407-45e5-bfbe-689806caaf7b" }, "id": "c6f1b042-a0fc-4bbc-9cd5-7a8a924c00e7", "issued": "2008-03-07T17:47:02-05:00", "meta": { "lastUpdated": "YYYY-MM-DDTHH:MM:SS+ZZ:ZZ", "profile": [ "http://standardhealthrecord.org/fhir/StructureDefinition/shr-observation-Observation" ], "versionId": "MTYzMTgyMTExMDIyMDk5ODAwMA" }, "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/8ac08aa9-63d2-4e81-8647-3a138d7f9f5a" }, "valueQuantity": { "code": "mg/dL", "system": "http://unitsofmeasure.org", "unit": "mg/dL", "value": 60 } }, "search": { "mode": "match" } }, { "fullUrl": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation/ac57b908-2804-4d67-a7ad-1e4a4c3225a1", "resource": { "category": [ { "coding": [ { "code": "vital-signs", "system": "http://hl7.org/fhir/observation-category" } ] } ], "code": { "coding": [ { "code": "29463-7", "display": "Body Weight", "system": "http://loinc.org" } ], "text": "Body Weight" }, "effectiveDateTime": "2008-03-07T17:47:02-05:00", "encounter": { "reference": "Encounter/0e9d631c-4407-45e5-bfbe-689806caaf7b" }, "id": "ac57b908-2804-4d67-a7ad-1e4a4c3225a1", "issued": "2008-03-07T17:47:02-05:00", "meta": { "lastUpdated": "YYYY-MM-DDTHH:MM:SS+ZZ:ZZ", "profile": [ "http://standardhealthrecord.org/fhir/StructureDefinition/shr-observation-Observation", "http://standardhealthrecord.org/fhir/StructureDefinition/shr-vital-VitalSign", "http://standardhealthrecord.org/fhir/StructureDefinition/shr-vital-BodyWeight" ], "versionId": "MTYzMTgyMTExMDIyMDk5ODAwMA" }, "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/8ac08aa9-63d2-4e81-8647-3a138d7f9f5a" }, "valueQuantity": { "code": "kg", "system": "http://unitsofmeasure.org", "unit": "kg", "value": 121.12557348891558 } }, "search": { "mode": "match" } } ], "link": [ { "relation": "search", "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation/?subject%3APatient.name=Christopher" }, { "relation": "first", "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation/?subject%3APatient.name=Christopher" }, { "relation": "self", "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation/?subject%3APatient.name=Christopher" } ], "resourceType": "Bundle", "total": 8, "type": "searchset" }
反向鏈結搜尋
反向鏈結搜尋會根據參照資源的其他資源條件,比對資源。反向鏈結搜尋的語法如下:
_has:[resource type]:[reference parameter]:[search parameter]=[value]
舉例來說,Appointment
資源具有參照 Patient
資源的搜尋參數 patient
。如要找出 Appointment
資源在 2020-04-01
日期參照的所有 Patient
資源,請使用 Patient?_has:Appointment:patient:date=eq2020-04-01
。
反向鏈結可與其他鏈結或反向鏈結遞迴,例如 Practitioner?_has:Encounter:practitioner:_has:Claim:encounter:created=eq2020-04-01
會比對 Practitioner
P (如有 Encounter
E 和 Claim
C,且 C 的建立日期為 2020-04-01
、C 透過 encounter
參照 E,而 E 透過 practitioner
參照 P)。
反向鏈結搜尋範例
REST
使用任何要求資料之前,請先替換以下項目:
- PROJECT_ID:您的 Google Cloud 專案 ID
- LOCATION:父項資料集的位置
- DATASET_ID:FHIR 儲存庫的父項資料集
- FHIR_STORE_ID:FHIR 儲存庫 ID
如要傳送要求,請選擇以下其中一個選項:
curl
下列範例使用
Patient?_has:Procedure:patient:date=eq2008-03-07
查詢。
執行下列指令:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient?_has:Procedure:patient:date=eq2008-03-07"
PowerShell
下列範例使用
Patient?_has:Procedure:patient:date=eq2008-03-07
查詢。
執行下列指令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient?_has:Procedure:patient:date=eq2008-03-07" | Select-Object -Expand Content
您應該會收到如下的 JSON 回應:
{ "entry": [ { "fullUrl": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/8ac08aa9-63d2-4e81-8647-3a138d7f9f5a", "resource": { "address": [ { "country": "US", "line": [ "907 Arlo Cliffs", "Suite 984" ], "postalCode": "XXXXX" } ], "birthDate": "1940-12-01", "communication": [ { "language": { "coding": [ { "code": "en-US", "display": "English (United States)", "system": "urn:ietf:bcp:47" } ] } } ], "deceasedDateTime": "2009-07-26T12:01:23-05:00", "extension": [ { "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race", "valueCodeableConcept": { "coding": [ { "code": "2106-3", "display": "White", "system": "http://hl7.org/fhir/v3/Race" } ], "text": "race" } }, { "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity", "valueCodeableConcept": { "coding": [ { "code": "2186-5", "display": "Nonhispanic", "system": "http://hl7.org/fhir/v3/Ethnicity" } ], "text": "ethnicity" } }, { "url": "http://hl7.org/fhir/StructureDefinition/birthPlace", "valueAddress": { "city": "Tama", "country": "US", "postalCode": "52339", "state": "Iowa" } }, { "url": "http://hl7.org/fhir/StructureDefinition/patient-mothersMaidenName", "valueString": "Farrah Feeney" }, { "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex", "valueCode": "M" }, { "url": "http://hl7.org/fhir/StructureDefinition/patient-interpreterRequired", "valueBoolean": false }, { "url": "http://standardhealthrecord.org/fhir/StructureDefinition/shr-actor-FictionalPerson-extension", "valueBoolean": true }, { "url": "http://standardhealthrecord.org/fhir/StructureDefinition/shr-demographics-FathersName-extension", "valueHumanName": { "text": "Christopher Diaz" } }, { "url": "http://standardhealthrecord.org/fhir/StructureDefinition/shr-demographics-SocialSecurityNumber-extension", "valueString": "999-16-9041" } ], "gender": "male", "generalPractitioner": [ { "reference": "Organization/9fb51c89-1453-406c-8357-578311b43a91" } ], "id": "8ac08aa9-63d2-4e81-8647-3a138d7f9f5a", "identifier": [ { "system": "https://github.com/synthetichealth/synthea", "value": "c1ee4b49-3194-4b39-91ed-4d1393a780c6" }, { "system": "http://hl7.org/fhir/sid/us-ssn", "type": { "coding": [ { "code": "SB", "system": "http://hl7.org/fhir/identifier-type" } ] }, "value": "999169041" }, { "system": "urn:oid:2.16.840.1.113883.4.3.25", "type": { "coding": [ { "code": "DL", "system": "http://hl7.org/fhir/v2/0203" } ] }, "value": "S99992205" }, { "system": "http://standardhealthrecord.org/fhir/StructureDefinition/passportNumber", "type": { "coding": [ { "code": "PPN", "system": "http://hl7.org/fhir/v2/0203" } ] }, "value": "X12551631X" }, { "system": "http://hospital.smarthealthit.org", "type": { "coding": [ { "code": "MR", "system": "http://hl7.org/fhir/v2/0203" } ] }, "value": "c1ee4b49-3194-4b39-91ed-4d1393a780c6" } ], "maritalStatus": { "coding": [ { "code": "S", "system": "http://hl7.org/fhir/v3/MaritalStatus" } ], "text": "S" }, "meta": { "lastUpdated": "YYYY-MM-DDTHH:MM:SS+ZZ:ZZ", "profile": [ "http://standardhealthrecord.org/fhir/StructureDefinition/shr-demographics-PersonOfRecord" ], "versionId": "MTYzMTgyMTExMDIyMDk5ODAwMA" }, "multipleBirthBoolean": false, "name": [ { "family": "Diaz", "given": [ "Christopher" ], "prefix": [ "Mr." ], "use": "official" } ], "resourceType": "Patient", "telecom": [ { "system": "phone", "use": "home", "value": "434-100-2918 x800" } ], "text": { "div": "Generated by Synthea. Version identifier: 2dd4c1c37e2743d14e5073c7b5e42899a3e51531", "status": "generated" } }, "search": { "mode": "match" } } ], "link": [ { "relation": "search", "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/?_has%3AProcedure%3Apatient%3Adate=eq2008-03-07" }, { "relation": "first", "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/?_has%3AProcedure%3Apatient%3Adate=eq2008-03-07" }, { "relation": "self", "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/?_has%3AProcedure%3Apatient%3Adate=eq2008-03-07" } ], "resourceType": "Bundle", "total": 1, "type": "searchset" }
在搜尋結果中加入其他資源
_include
和 _revinclude
參數會要求搜尋結果包含與直接符合查詢的資源 (「主要結果」) 相關的其他資源 (「納入的資源」)。與分別發出一連串要求來擷取這些額外資源相比,使用這些參數的效率更高。在搜尋傳回的 searchset
組合中,這些參數新增的資源會標示 entry.search.mode = include
,與標示 entry.search.mode = match
的主要結果有所區別。
使用 _include
正向納入會新增主要結果參照的資源和資源版本,使用 _revinclude
反向納入則會新增參照主要結果的資源。要追蹤的參照是由搜尋參數的名稱指定,且只有可做為搜尋參數的參照欄位,才能以這種方式使用。
_include
和 _revinclude
的參數格式相同,都是以 :
分隔兩個或三個值。第一個值是參照來源的資源類型,第二個值是搜尋參數名稱,第三個值 (選用) 則會在參照可指向多個類型時,將資源類型限制為單一類型。
例如:
MedicationRequest?_include=MedicationRequest:subject
會搜尋MedicationRequest
資源,並針對傳回的每個資源,傳回subject
參照的目標,這可能是 FHIR 規格中定義的Group
或Patient
。MedicationRequest?_include=MedicationRequest:subject:Patient
類似,但只會傳回Patient
資源的subject
參照。MedicationRequest?_revinclude=Provenance:target
會搜尋MedicationRequest
資源,並針對傳回的每個資源,傳回Provenance
上的target
參照所指的相符資源。Provenance
_include
個搜尋樣本
REST
使用任何要求資料之前,請先替換以下項目:
- PROJECT_ID:您的 Google Cloud 專案 ID
- LOCATION:父項資料集的位置
- DATASET_ID:FHIR 儲存庫的父項資料集
- FHIR_STORE_ID:FHIR 儲存庫 ID
如要傳送要求,請選擇以下其中一個選項:
curl
下列範例使用
Observation?code=http://loinc.org|2571-8&_include=*
查詢。
執行下列指令:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation?code=http://loinc.org|2571-8&_include=*"
PowerShell
下列範例使用
Observation?code=http://loinc.org|2571-8&_include=*
查詢。
執行下列指令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation?code=http://loinc.org|2571-8&_include=*" | Select-Object -Expand Content
您應該會收到如下的 JSON 回應:
{ "entry": [ { "fullUrl": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/8ac08aa9-63d2-4e81-8647-3a138d7f9f5a", "resource": { "address": [ { "country": "US", "line": [ "907 Arlo Cliffs", "Suite 984" ], "postalCode": "XXXXX" } ], "birthDate": "1940-12-01", "communication": [ { "language": { "coding": [ { "code": "en-US", "display": "English (United States)", "system": "urn:ietf:bcp:47" } ] } } ], "deceasedDateTime": "2009-07-26T12:01:23-05:00", "extension": [ { "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race", "valueCodeableConcept": { "coding": [ { "code": "2106-3", "display": "White", "system": "http://hl7.org/fhir/v3/Race" } ], "text": "race" } }, { "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity", "valueCodeableConcept": { "coding": [ { "code": "2186-5", "display": "Nonhispanic", "system": "http://hl7.org/fhir/v3/Ethnicity" } ], "text": "ethnicity" } }, { "url": "http://hl7.org/fhir/StructureDefinition/birthPlace", "valueAddress": { "city": "Tama", "country": "US", "postalCode": "52339", "state": "Iowa" } }, { "url": "http://hl7.org/fhir/StructureDefinition/patient-mothersMaidenName", "valueString": "Farrah Feeney" }, { "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex", "valueCode": "M" }, { "url": "http://hl7.org/fhir/StructureDefinition/patient-interpreterRequired", "valueBoolean": false }, { "url": "http://standardhealthrecord.org/fhir/StructureDefinition/shr-actor-FictionalPerson-extension", "valueBoolean": true }, { "url": "http://standardhealthrecord.org/fhir/StructureDefinition/shr-demographics-FathersName-extension", "valueHumanName": { "text": "Christopher Diaz" } }, { "url": "http://standardhealthrecord.org/fhir/StructureDefinition/shr-demographics-SocialSecurityNumber-extension", "valueString": "999-16-9041" } ], "gender": "male", "generalPractitioner": [ { "reference": "Organization/9fb51c89-1453-406c-8357-578311b43a91" } ], "id": "8ac08aa9-63d2-4e81-8647-3a138d7f9f5a", "identifier": [ { "system": "https://github.com/synthetichealth/synthea", "value": "c1ee4b49-3194-4b39-91ed-4d1393a780c6" }, { "system": "http://hl7.org/fhir/sid/us-ssn", "type": { "coding": [ { "code": "SB", "system": "http://hl7.org/fhir/identifier-type" } ] }, "value": "999169041" }, { "system": "urn:oid:2.16.840.1.113883.4.3.25", "type": { "coding": [ { "code": "DL", "system": "http://hl7.org/fhir/v2/0203" } ] }, "value": "S99992205" }, { "system": "http://standardhealthrecord.org/fhir/StructureDefinition/passportNumber", "type": { "coding": [ { "code": "PPN", "system": "http://hl7.org/fhir/v2/0203" } ] }, "value": "X12551631X" }, { "system": "http://hospital.smarthealthit.org", "type": { "coding": [ { "code": "MR", "system": "http://hl7.org/fhir/v2/0203" } ] }, "value": "c1ee4b49-3194-4b39-91ed-4d1393a780c6" } ], "maritalStatus": { "coding": [ { "code": "S", "system": "http://hl7.org/fhir/v3/MaritalStatus" } ], "text": "S" }, "meta": { "lastUpdated": "YYYY-MM-DDTHH:MM:SS+ZZ:ZZ", "profile": [ "http://standardhealthrecord.org/fhir/StructureDefinition/shr-demographics-PersonOfRecord" ], "versionId": "MTYzMTgyMTExMDIyMDk5ODAwMA" }, "multipleBirthBoolean": false, "name": [ { "family": "Diaz", "given": [ "Christopher" ], "prefix": [ "Mr." ], "use": "official" } ], "resourceType": "Patient", "telecom": [ { "system": "phone", "use": "home", "value": "434-100-2918 x800" } ], "text": { "div": "Generated by Synthea. Version identifier: 2dd4c1c37e2743d14e5073c7b5e42899a3e51531", "status": "generated" } }, "search": { "mode": "match" } } ], "link": [ { "relation": "search", "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/?_has%3AProcedure%3Apatient%3Adate=eq2008-03-07" }, { "relation": "first", "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/?_has%3AProcedure%3Apatient%3Adate=eq2008-03-07" }, { "relation": "self", "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/?_has%3AProcedure%3Apatient%3Adate=eq2008-03-07" } ], "resourceType": "Bundle", "total": 1, "type": "searchset" }
修飾符 :iterate
會導致 _include
進行疊代評估。
這個修飾符可以追蹤所含結果的額外參照層級,或追蹤遞迴結構,例如參照另一個 Observation:derived-from
的 Observation
。
遞迴深度限制為兩層:頂層和兩個子層。舉例來說,假設您有下列參照序列:
- 透過
Patient.generalPractitioner
欄位參照 PractitionerRole 資源的 Patient 資源。 - PractitionerRole 資源會透過
PractitionerRole.practitioner
欄位參照 Practitioner 資源。 - 從業人員資源會透過
Practitioner.qualification.issuer
欄位參照機構資源。
以下範例顯示參照順序。由於超出最多兩層的限制,因此第 3 層的機構資源不會納入搜尋結果。
Patient (Level 0)
- Patient.generalPractitioner -> PractitionerRole (Level 1)
- PractitionerRole.practitioner -> Practitioner (Level 2)
- Practitioner.organization -> Organization (Level 3)
下列其他範例說明 :iterate
修飾符的行為:
Observation?_include:iterate=Observation:derived-from:Observation
會搜尋Observation
資源,並遞迴追蹤相符Observation
資源和所含資源的衍生自參照。MedicationRequest?_revinclude=Provenance:target&_include:iterate=Provenance:agent
會搜尋MedicationRequest
資源,包括含有target
的Provenance
資源 (位於這個結果集中),然後也包括透過這些Provenance
資源的agent
參數參照的資源。
萬用字元 *
表示應納入所有可做為搜尋參數的參照。您可以在 _include
中使用 *
萬用字元做為第一個也是唯一的引數,或取代標準 _include
中的搜尋參數名稱,其中選用的第三個值會將資源類型限制為單一類型,與原始行為相同。
例如:
Observation?_include=*
會搜尋Observation
資源,並為每個資源傳回所有參照資源。Observation?_include=Observation:*
等同於上述內容。MedicationRequest?_include=MedicationRequest:*:Patient
會傳回每個MedicationRequest
資源的所有Patient
資源參照。
伺服器會重複資料刪除資源,因此即使資源出現在多個參照中,每個結果頁面也只會包含一個資源副本。如果主要結果與隨附資源相關,隨附資源就會顯示在每個結果頁面上。
管理內含資源數量
使用 _include
和 _revinclude
參數加入其他資源時,請注意下列事項:
內含資源不會計入網頁大小。這些資源不會計入
Bundle.total
,且可能會導致傳回的資源數量大於指定的_count
參數。由於納入的資源不會計入網頁大小,請謹慎使用
_include
和_revinclude
參數,以免產生大量結果。結果過大可能會導致逾時或發生錯誤。如果您預期會有很多納入的結果,請考慮使用較小的_count
值,限制主要結果的數量。避免追蹤一對多關係,其中關係的多方不受限制。個別
_revinclude
參數最多可新增 100 個額外資源。如果參照主要結果的資源可能超過 100 個,請採取下列任一做法:- 使用分頁大小和分頁參數,透過個別的搜尋查詢要求擷取更多結果。
使用內含資源開始搜尋:
假設 ID 為
1234
的 Encounter 資源有數百個 Observation 資源。使用_revinclude
(從 Encounter 開始) 搜尋這些 Observation 資源時,傳回的回應會超過 100 個額外資源的限制:fhir/Encounter?_id=123&_revinclude=Observation:encounter
請改為搜尋 Observation 資源,並使用
_include
納入相關的 Encounter:fhir/Observation?encounter=123&_include=Observation:encounter
這個方法會篩選 Observation 資源,只保留與 Encounter 相關的資源,並只擷取一次 Encounter 資源。
限制搜尋結果中傳回的欄位
_elements
參數可讓用戶端要求只傳回每個搜尋結果的欄位子集,藉此省略不必要的資料,減少回應大小。這個參數接受以半形逗號分隔的資源基本元素名稱清單,例如 Patient?_elements=identifier,contact,link
。只有這些欄位及其子項會納入傳回的資源。如果回應中的資源因這個參數而有所變更,就會包含 meta.tag
值 SUBSETTED
,表示資源不完整。
_elements
個搜尋樣本
REST
使用任何要求資料之前,請先替換以下項目:
- PROJECT_ID:您的 Google Cloud 專案 ID
- LOCATION:父項資料集的位置
- DATASET_ID:FHIR 儲存庫的父項資料集
- FHIR_STORE_ID:FHIR 儲存庫 ID
如要傳送要求,請選擇以下其中一個選項:
curl
下列範例使用
Patient?_elements=identifier,contact,link
查詢。
執行下列指令:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient?_elements=identifier,contact,link"
PowerShell
下列範例使用
Patient?_elements=identifier,contact,link
查詢。
執行下列指令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient?_elements=identifier,contact,link" | Select-Object -Expand Content
您應該會收到如下的 JSON 回應:
{ "entry": [ { "fullUrl": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/patient3", "resource": { "id": "patient3", "meta": { "lastUpdated": "YYYY-MM-DDTHH:MM:SS+ZZ:ZZ", "tag": [ { "code": "SUBSETTED", "system": "http://hl7.org/fhir/v3/ObservationValue" } ], "versionId": "MTYzMTgyMTExMDIyMDk5ODAwMA" }, "resourceType": "Patient" }, "search": { "mode": "match" } }, { "fullUrl": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/patient2", "resource": { "id": "patient2", "meta": { "lastUpdated": "YYYY-MM-DDTHH:MM:SS+ZZ:ZZ", "tag": [ { "code": "SUBSETTED", "system": "http://hl7.org/fhir/v3/ObservationValue" } ], "versionId": "MTYzMTgyMTExMDIyMDk5ODAwMA" }, "resourceType": "Patient" }, "search": { "mode": "match" } }, { "fullUrl": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/8ac08aa9-63d2-4e81-8647-3a138d7f9f5a", "resource": { "id": "8ac08aa9-63d2-4e81-8647-3a138d7f9f5a", "identifier": [ { "system": "https://github.com/synthetichealth/synthea", "value": "c1ee4b49-3194-4b39-91ed-4d1393a780c6" }, { "system": "http://hl7.org/fhir/sid/us-ssn", "type": { "coding": [ { "code": "SB", "system": "http://hl7.org/fhir/identifier-type" } ] }, "value": "999169041" }, { "system": "urn:oid:2.16.840.1.113883.4.3.25", "type": { "coding": [ { "code": "DL", "system": "http://hl7.org/fhir/v2/0203" } ] }, "value": "S99992205" }, { "system": "http://standardhealthrecord.org/fhir/StructureDefinition/passportNumber", "type": { "coding": [ { "code": "PPN", "system": "http://hl7.org/fhir/v2/0203" } ] }, "value": "X12551631X" }, { "system": "http://hospital.smarthealthit.org", "type": { "coding": [ { "code": "MR", "system": "http://hl7.org/fhir/v2/0203" } ] }, "value": "c1ee4b49-3194-4b39-91ed-4d1393a780c6" } ], "meta": { "lastUpdated": "YYYY-MM-DDTHH:MM:SS+ZZ:ZZ", "tag": [ { "code": "SUBSETTED", "system": "http://hl7.org/fhir/v3/ObservationValue" } ], "versionId": "MTYzMTgyMTExMDIyMDk5ODAwMA" }, "resourceType": "Patient" }, "search": { "mode": "match" } }, { "fullUrl": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/patient1", "resource": { "id": "patient1", "meta": { "lastUpdated": "YYYY-MM-DDTHH:MM:SS+ZZ:ZZ", "tag": [ { "code": "SUBSETTED", "system": "http://hl7.org/fhir/v3/ObservationValue" } ], "versionId": "MTYzMTgyMTExMDIyMDk5ODAwMA" }, "resourceType": "Patient" }, "search": { "mode": "match" } } ], "link": [ { "relation": "search", "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/?_elements=identifier%2Ccontact%2Clink" }, { "relation": "first", "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/?_elements=identifier%2Ccontact%2Clink" }, { "relation": "self", "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/?_elements=identifier%2Ccontact%2Clink" } ], "resourceType": "Bundle", "total": 4, "type": "searchset" }
Cloud Healthcare API 對 _summary
參數的支援有限,這個參數會提供預先定義的資源欄位子集,類似於 _elements
:
_summary=text
只會傳回text
、id
和meta
頂層欄位_summary=data
會移除text
欄位,並傳回所有其他欄位