FHIR Server API有許多特別的規則及識別符,可以透過添加不同的識別符進行複雜的檢索查詢,簡單來說就是不用再寫複雜到爆的子查詢來拉資料啦!!!真是可喜可賀。今天會介紹這些規則及識別符的應用,媽媽再也不擔心我寫不出SQL查詢語句啦!!!
{prefix}/fhir/Observation
註:測試環境的prefix為 http://127.0.0.1:8080,以獲取所有的測量數據為例,完整的API為 http://127.0.0.1:8080/fhir/Observation
HTTP Method : GET
{prefix}/fhir/Observation?subject=Patient/23
{prefix}/fhir/Observation?subject:Patient/23
{prefix}/fhir/Observation?patient=23
以上三種寫法都能拿到patient id 23所有的測量數據
{prefix}/fhir/Observation?patient=23&_lastUpdated=eq{日期}
獲取patient id 23於2024-09-01當天的檢測數據
{prefix}/fhir/Observation?patient=23&_lastUpdated=eq2024-09-01
獲取patient id 23於2024-09-01前的檢測數據
{prefix}/fhir/Observation?patient=23&_lastUpdated=lt2024-09-01
獲取patient id 23於2024-09-01後的檢測數據
{prefix}/fhir/Observation?patient=23&_lastUpdated=gt2024-09-01
獲取patient id 23於2024-09-01當天及之前的檢測數據
{prefix}/fhir/Observation?patient=23&_lastUpdated=le2024-09-01
獲取patient id 23於2024-09-01當天及之後的檢測數據
{prefix}/fhir/Observation?patient=23&_lastUpdated=ge2024-09-01
也可以獲取特定時間區段的測量數據
獲取patient id 23在2024-09-01到2024-09-15之間的檢測數據(不包含2024-09-01和2024-09-15當日)
{prefix}/fhir/Observation?patient=23&_lastUpdated=gt2024-09-01&_lastUpdated=lt2024-09-15
{prefix}/fhir/Observation?patient=23&_content={測量數據種類}
註:可以一次查詢多種檢測數據,不同種類數據間以逗號隔開
獲取patient id 23於2024-09-01當天的血壓檢測數據
{prefix}/fhir/Observation?patient=23&_lastUpdated=eq2024-09-01&_content=Blood%20pressure
獲取patient id 23於2024-09-01當天的血壓和血糖檢測數據
{prefix}/fhir/Observation?patient=23&_lastUpdated=eq2024-09-01&_content=Blood%20pressure,Glucose
{prefix}/fhir/Observation?patient=23&_content={測量數據種類}&value-quantity={搜尋的數值範圍}
獲取patient id 23於2024-09-01當天體溫超過37.5度的檢測數據
{prefix}/fhir/Observation?patient=23&_lastUpdated=eq2024-09-01&_content=Body%20temperature&value-quantity=gt37.5
Tips
{
"resourceType": "Observation",
"id": "8",
"meta": {
"versionId": "1",
"lastUpdated": "2024-09-01T06:38:14.556+00:00",
"source": "#h7dsukROEewNVBhv",
},
"category": [
{
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/observation-category",
"code": "vital-signs",
"display": "Vital Signs"
}
]
},
{
"text": "Vital Signs"
}
],
"code": {
"coding": [
{
"system": "http://loinc.org",
"code": "85354-9",
"display": "Blood pressure panel with all children optional"
}
],
"text": "Blood pressure systolic & diastolic"
},
"component": [
{
"code": {
"coding": [
{
"system": "http://loinc.org",
"code": "8480-6",
"display": "Systolic blood pressure"
}
]
},
"valueQuantity": {
"value": 136,
"unit": "mmHg",
"system": "http://unitsofmeasure.org",
"code": "mm[Hg]"
}
},
{
"code": {
"coding": [
{
"system": "http://loinc.org",
"code": "8462-4",
"display": "Diastolic blood pressure"
}
]
},
"valueQuantity": {
"value": 96,
"unit": "mmHg",
"system": "http://unitsofmeasure.org",
"code": "mm[Hg]"
}
}
]
}
{
"resourceType": "Observation",
"id": "28",
"meta": {
"versionId": "1",
"lastUpdated": "2024-09-01T08:39:04.541+00:00",
"source": "#IzEiKEYCk8sSi0pf",
},
"category": [
{
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/observation-category",
"code": "vital-signs",
"display": "Vital Signs"
}
]
},
{
"text": "Vital Signs"
}
],
"code": {
"coding": [
{
"system": "http://loinc.org",
"code": "8867-4",
"display": "Heart rate"
}
],
"text": "Heart rate"
},
"valueQuantity": {
"value": 100,
"unit": "beats/minute",
"system": "http://unitsofmeasure.org",
"code": "/min"
}
}
{
"resourceType": "Observation",
"id": "33",
"meta": {
"versionId": "1",
"lastUpdated": "2024-09-01T09:31:41.444+00:00",
"source": "#DcaQT7lUmbHLbQJR",
},
"code": {
"coding": [
{
"system": "http://loinc.org",
"code": "15074-8",
"display": "Glucose [Moles/volume] in Blood"
}
],
"text": "Glucose [Moles/volume] in Blood"
},
"valueQuantity": {
"value": 3.2,
"unit": "mmol/l",
"system": "http://unitsofmeasure.org",
"code": "mmol/L"
}
}
{
"resourceType": "Observation",
"id": "40",
"meta": {
"versionId": "1",
"lastUpdated": "2023-2024-09-01T07:44:53.245+00:00",
"source": "#X7wEhCdW0dIOLBrz",
},
"category": [
{
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/observation-category",
"code": "vital-signs",
"display": "Vital Signs"
}
]
},
{
"text": "Vital Signs"
}
],
"code": {
"coding": [
{
"system": "http://loinc.org",
"code": "2708-6",
"display": "Oxygen saturation in Arterial blood"
},
{
"system": "http://loinc.org",
"code": "59408-5",
"display": "Oxygen saturation in Arterial blood by Pulse oximetry"
}
],
"text": "oxygen_saturation"
},
"valueQuantity": {
"value": 99.0,
"unit": "%O2",
"system": "http://unitsofmeasure.org",
"code": "%"
}
}
{
"resourceType": "Observation",
"id": "54",
"meta": {
"versionId": "1",
"lastUpdated": "2024-09-01T08:33:02.252+00:00",
"source": "#xEtU1b3aEZaMWdgl",
},
"category": [
{
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/observation-category",
"code": "vital-signs",
"display": "Vital Signs"
}
]
},
{
"text": "Vital Signs"
}
],
"code": {
"coding": [
{
"system": "http://loinc.org",
"code": "8310-5",
"display": "Body temperature"
}
],
"text": "Body temperature"
},
"valueQuantity": {
"value": 39.1,
"unit": "C",
"system": "http://unitsofmeasure.org",
"code": "Cel"
}
}
以上是各種常見的Observation範例及一些常用的FHIR API 規則,主要圍繞在Patient和Observation上。可以調換不同的Resource進行查詢檢索,如以Patient為查詢主體,Organization為檢索條件,搜尋出某一個Organization內全部的病患。還有更多其他有用的API規則,若需要使用可以再到HL7官網查詢。