# 健康時間軸
* 身體指標列表(10個)
weight(體重)
BFP(體脂)
BMI(BMI)
sphygmus(脈博)
SBP(收縮壓)
DBP(舒張壓)
bloodSugar(血糖)
bloodOxygen(血氧)
insulin(胰島素)
bodyTemperature(體溫)
## 取回某人的量測數值及跟上次記錄作比較
UIUX : 使用於時間軸上方的legend數值
DESC - 取最後一筆不為null的值(v1),並與倒數第二筆同樣不為null記錄(v2)作對比,得到上升,持平,下降的趨勢
role - v1 > v2 -> 上升
v1 = v2 -> 持平
v1 < v2 -> 下降
Attribute | Description | Remark
-|-|-
value | number | 量測數值
trend | number | 1(上升)/0(持平)/-1(下降)
updateTime | timeStamp | 更新時間
Request
```url=
POST /case/$id/timeline/legend
```
PayLoad
* indicator 請見上述"身體指標列表"
```json=
{
indicator: ['weight', 'BMI']
}
```
Response
```json=
{
weight: {
value: 60,
trend: -1, //-1(下降)/0(持平)/1(上升)/null
updateTime: 1583991833330
},
BMI: {
value: null,
trend: null,
updateTime: null
}
// 無值或無趨勢需要補null
}
```
## 取回某人的-量測記錄
UIUX : 使用於顯示量測記錄
DESC - 取回某人某段日期、時間區間的量測記錄
role - 例如日期為2020/02/10 - 2020/02/12,時間為08:00-14:00
需取回
2020/02/10 08:00-1400
2020/02/11 08:00-1400
2020/02/12 08:00-1400的量測記錄
Attribute | Description | Remark
-|-|-
indicator | String Array | 指標
startAt | timeStamp | 起始時間
endAt | timeStamp | 結束時間
timeStartAt | String | 起始時間區段
timeEndAt | String | 結束時間區段
Request
```url=
POST /case/$id/timeline/record
```
PayLoad
* indicator 請見上述"身體指標列表"
```json=
{
indicator: ['weight', 'BMI'],
startAt: 1583991833330,
endAt: 1583992833330,
timeStartAt: '08:00',
timeEndAt: '14:00'
}
```
Response
```json=
respon
{
data: {
weight: [{
date: 1585294669231, // 日期
isUnusual: true, // 該筆是否超出理想值
value: 100, // 值
unit: 'kg', // 單位
equipment: 'Bathroom scale' // 量測設備名稱
},{
date: 1585294669231,
isUnusual: true,
value: 100,
unit: 'kg',
equipment: 'Bathroom scale'
}],
BMI: [{
date: 1585294669231,
isUnusual: true,
value: 18,
unit: '%',
equipment: 'Bathroom scale'
}]
}
}...
```
## 取回某人的-健康趨勢
UIUX : 使用於顯示健康時間軸
DESC - 取回某人某段日期的量測數據(需事先運算)
role - 每一筆記錄需有四個資料
最大值、最小值、平均值,量測筆數(從該「區間」中的所有量測資料得到max,min,avg,amount)
區間
周 -> 一天有四個區間,分別為「早,中,晚,飯前」, 將區間內的量測記錄計算匯整成一筆記錄
月 -> 以天為區間,將區間內的量測記錄計算匯整成一筆記錄
年 -> 以週為區間,將區間內的量測記錄計算匯整成一筆記錄
Attribute | Description | Remark
-|-|-
indicator | String Array | 指標
startAt | timeStamp | 起始時間
endAt | timeStamp | 結束時間
period| String| 'w'(周)/'m'(月)/'y'(年)
Request
```url=
POST /case/$id/timeline/trend
```
PayLoad
* indicator 請見上述"身體指標列表"
```json=
{
indicator: ['weight', 'BMI'],
startAt: 1583991833330,
endAt: 1583992833330,
period: 'w'
}
```
Response
```json=
response
{
data: {
weight: [{
date: 1585294669231,
max: 71,
min: 68,
avg: 69,
amount: 3
},{
date: 1585294669231,
max: null,
min: null,
avg: null,
amount: null,
}],
BMI: [{
date: 1585294669231,
max: 20.1,
min: 19.4,
avg: 19.8,
amount: 7
}]
無值需要補區間,值需要補null
}
}...
```
## 取回某人的-健康狀況
UIUX : 使用於顯示-健康狀況
DESC - 取回某人最近七天(不包含當天)顯示不正常之量測數據統計
Attribute | Description | Remark
-|-|-
id | String | Primary Key
systolicBloodPressureTimes | number | 收縮壓-高於正常值(140)次數
diastolicBloodPressureTimes | number | 舒張壓-高於正常值(90)次數
beforeMealBloodSugarTimes | number | 空腹血糖-高於正常值(100)次數
afterMealBloodSugarTimes | number | 飯後血糖-高於正常值(150)次數
digestCaloriesDays | number | 消耗熱量-小於建議(500kcal)天數
forgetMedicine | number | 忘記用藥次數
suggestion | String | 照護建議
dateTimeStart | timeStamp | 起始時間
dateTimeEnd | timeStamp | 結束時間
Request
```url=
POST /case/$id/status
```
Response
```json=
{
"success": true,
"data": {
systolicBloodPressureTimes: 6,
diastolicBloodPressureTimes: 5,
beforeMealBloodSugarTimes: 2,
afterMealBloodSugarTimes: 2,
digestCaloriesDays: 3,
digestCaloriesDays: 3,
suggestion: '建議進行飲食評估並增加運動量以改善體重與血壓情形',
dateTimeStart: 1585294669231,
dateTimeEnd: 1585296669231
}
}
```