---
# System prepended metadata

title: 用藥提醒、紀錄

---

# 用藥提醒、紀錄

[TOC]

## 常數定義
### 用藥週期
 欄位 | 型態  | 說明  
 ---|---|---
 weekDays | string array | 用藥週期 ("MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", "SUNDAY")


## API清單
### 新增用藥時段提醒 

```url
POST /medication/remind/add
```
* 如果沒有傳householdMemberId，會從token裡去抓取

#### Request-新增用藥時段提醒
 欄位 | 型態  | 必填 | 長度限制 | 預設 | 說明  
 ---|---|---|---|---|---
 medicationName | string | Y | 100 |  | 藥包名稱
 isEnable | bool | Y | | | 是否啟用
 durations | int array | Y  | | | 用藥時、分(800 表示 08:00, 2030 表示 20:30, 以此類推)
 weekDays | string array | Y | 7 | | 用藥週期, 請參閱 [用藥週期](#用藥週期)
 remindStartDate | date | Y | | | 用藥提醒起始日期
 remindEndDate | date | Y | | | 用藥提醒結束日期

```javascript
{
    "medicationName": "藥包B-糖尿病",
    "isEnable": false,
    "durations": [
        800, 1300, 1800 
    ], 
    "weekDays": [
        "MONDAY","WEDNESDAY","FRIDAY"
    ],
    "remindStartDate": "2023-01-01",
    "remindEndDate": "2023-12-31"
}
```

#### Response-新增用藥時段提醒
 欄位 | 型態 | 說明 
 ---  | --- | ---
 id | string | 用藥時段提醒id
 medicationName | string | 藥包名稱
 counts | int | 每日用藥次數
 isEnable | bool | 是否啟用
 remindStartDate | date | 用藥提醒起始日期
 remindEndDate | date | 用藥提醒結束日期

```javascript
{
    "httpCode": 200,
    "result": {
        "data": {
            "id": "6499d554-45e7-45e2-93b6-32d5ca65b9d5",
            "medicationName": "藥包B-糖尿病",
            "counts": 3
            "isEnable": false,
            "createTime": 1611196161158,
            "updateTime": null,
            "remindStartDate": 1672502400000,
            "remindEndDate": 1703952000000
        }
    }
}
```
----

### 修改用藥時段提醒 

```url
POST /medication/remind/update
```
* 如果沒有傳householdMemberId，會從token裡去抓取

#### Request-修改用藥時段提醒
 欄位 | 型態  | 必填 | 長度限制 | 預設 | 說明  
 ---|---|---|---|---|---
 id | string | Y | 36 | | 用藥時段提醒id
 medicationName | string | Y | 100 |  | 藥包名稱
 isEnable | bool | Y | | | 是否啟用
 durations | string array | Y  | | | 用藥時、分(800 表示 08:00, 2030 表示 20:30, 以此類推)
 weekDays | string array | Y | 7 | | 用藥週期, 請參閱 [用藥週期](#用藥週期)
 remindStartDate | date | Y | | | 用藥提醒起始日期
 remindEndDate | date | Y | | | 用藥提醒結束日期

```javascript
{
    "id": "6499d554-45e7-45e2-93b6-32d5ca65b9d5",
    "medicationName": "藥包C-糖尿病",
    "isEnable": true,
    "durations": [
         0, 900, 1800, 2330
    ], 
    "weekDays": [
        "MONDAY","WEDNESDAY","SUNDAY"
    ],
    "remindStartDate": "2023-01-01",
    "remindEndDate": "2023-12-31"
}
```

#### Response-修改用藥時段提醒
 欄位 | 型態 | 說明 
 ---  | --- | ---
 id | string | 用藥時段提醒id
 medicationName | string | 藥包名稱
 counts | int | 每日用藥次數
 isEnable | bool | 是否啟用
 remindStartDate | date | 用藥提醒起始日期
 remindEndDate | date | 用藥提醒結束日期

```javascript
{
    "httpCode": 200,
    "result": {
        "data": {
            "id": "6499d554-45e7-45e2-93b6-32d5ca65b9d5",
            "medicationName": "藥包C-糖尿病",
            "counts": 4
            "isEnable": true,
            "createTime": 1611196161158,
            "updateTime": null,
            "remindStartDate": 1672502400000,
            "remindEndDate": 1703952000000
        }
    }
}
```
---

### 取得所有用藥時段

```url
GET /medication/remind/list
```

#### Response-取得所有用藥時段
 欄位 | 型態 | 說明 
 ---  | --- | ---
 id  | string | 用藥時段提醒id
 medicationName   | string | 藥包名稱
 counts | int | 用藥次數
 isEnable | bool | 是否啟用
 createTime | timestamp | 建立時間
 updateTime | timestamp | 最後更新時間
 remindStartDate | date | 用藥提醒起始日期
 remindEndDate | date | 用藥提醒結束日期
 
```javascript
{
    "httpCode": 200,
    "result": {
        "data": [
            {
                "id": "fbedea40-66fe-4d64-a621-a4fa9f2c6c51",
                "medicationName": "魚油123",
                "counts": 1,
                "isEnable": true,
                "createTime": 1694152197126,
                "updateTime": 1694152600322,
                "remindStartDate": 1672502400000,
                "remindEndDate": 1703952000000
            },
            {
                "id": "b5d4fa0f-bf2e-4ced-ac92-ab0fa5f95b2b",
                "medicationName": "ECKD",
                "counts": 2,
                "isEnable": true,
                "createTime": 1612842021000,
                "updateTime": null
            },
            {
                "id": "d047801d-1a2d-41c9-ad09-e9753b8a6b01",
                "medicationName": "心臟病",
                "counts": 1,
                "isEnable": true,
                "createTime": 1612842021090,
                "updateTime": null
            }
        ],
        "total": 2
    }
}
```
---

### 依照用藥提醒Id取得明細
```url
GET /medication/remind/detail/list/{masterId}
```

#### Response-依照用藥提醒Id取得明細
 欄位 | 型態 | 說明 
 ---  | --- | ---
 durations | int array | 用藥時、分(800 表示 08:00, 2030 表示 20:30, 以此類推)
 weekDays | string array | 用藥週期, 請參閱 [用藥週期](#用藥週期)

```javascript
{
    "httpCode": 200,
    "result": {
        "data": {
            "weekDays": [
                "MONDAY",
                "WEDNESDAY"
            ],
            "durations": [
                1100,
                1800
            ]
        }
    }
}
```
---

### 依照"星期幾"取得所有用藥時段

```url
POST /medication/remind/list/{householdMemberId}
```

* 如果沒有傳householdMemberId，會從token裡去抓取

#### Request-依照"星期幾"取得所有用藥時段
 欄位 | 型態  | 必填 | 長度限制 | 預設 | 說明  
 ---|---|---|---|---|---
 weekDays | string array | true | 用藥週期, 請參閱 [用藥週期](#用藥週期)

```javascript
{
    "weekDays": ["MONDAY"]
}
```

#### Response-依照"星期幾"取得所有用藥時段
 欄位 | 型態 | 說明 
 ---  | --- | ---
 id  | string | 用藥時段提醒id
 counts | int | 用藥次數
 remindStartDate | date | 用藥提醒起始日期
 remindEndDate | date | 用藥提醒結束日期
 durations | int | 用藥時、分(800 表示 08:00, 2030 表示 20:30, 以此類推)
 weekDays | string | 用藥週期, 請參閱 [用藥週期](#用藥週期)

```javascript
{
    "httpCode": 200,
    "result": {
        "data": [
            {
                "id": "6cf39565-4b23-4c7d-9e1c-d7f6b7e611ab",
                "duration": 1800,
                "weekDays": "MONDAY",
                "counts": 2
            },
            {
                "id": "0afe674e-b050-4db2-8702-8469188dc8d4",
                "duration": 2000,
                "weekDays": "MONDAY",
                "counts": 2
            }
        ]
    }
}
```
---


### ~~新增用藥記錄~~

``` url
POST /medication/recoord/add
```
* 如果沒有傳householdMemberId，會從token裡去抓取
* medicationTime從訊息通知(notificationRecord)取用
* 如果已經新增，會直接修改，可變更欄位為 **isTaken**

#### Request Payload:
```javascript
{
    "medicationTime":"2021/01/22 18:55",
    "medicationName":"心臟病",
    "isTaken":true
}
```

#### Response Body:
```javascript
{
    "httpCode": 200,
    "result": {
        "data": {
            "id": "e30096ed-b8ea-4424-890a-2c4a2189cad0",
            "isTaken": true,
            "medicationTime": "2021/01/22 18:55",
            "medicationName":"心臟病",
            "createTime": 1611543142033,
            "updateTime": null
        }
    }
}
```

#### ErrorMsg：＃medicationTime
＊A. 時間格式不符合
```javascript
{
    "errorMsg": "API_ERROR.ARGUMENT_ERROR",
    "errorDesc": "[{\"medicationTime\":\"medicationTime too long and it's format must be like 2010/01/01 00:00\"}]",
    "httpCode": 400
}
```
＊Ｂ. 時間格式不符合或是設定時間太小不符合規定
```javascript
{
    "errorMsg": "API_ERROR.ARGUMENT_ERROR",
    "errorDesc": "[{\"medicationTime\":\"The medicationTime's format must be like 2010/01/01 00:00 and it must after 2010/01/01 00:00\"}]",
    "httpCode": 400
}
```
---

### 編輯用藥備註

```url
POST /medication/record/update
```

#### Request Payload:
```javascript
{
    "id": "e30096ed-b8ea-4424-890a-2c4a2189cad0",
    "isTaken": false
}
```

#### Response Body:
```javascript
{
    "httpCode": 200,
    "result": {
        "data": {
            "id": "e30096ed-b8ea-4424-890a-2c4a2189cad0"
        }
    }
}
```
---

### ~~刪除用藥記錄~~

```url
DELETE /medication/recoord/{id}
```

#### Response Body:
```javascript
{
    "httpCode": 200,
    "result": {
        "data": {
            "id": "984bd148-f487-416e-8c5d-e19b57112d9c"
        }
    }
}
```
---

### 取得用藥列表

``` url
POST /medication/record/list
``` 

#### Request Payload:
```javascript
{
    "query":{
        "startAt": 1611273600000,
        "endAt": 1611273600000	
    },
    "pagination": {
        "current": 1,
        "total": 1,
        "pageSize": 10
    },
    "sorter": {}
}
```

#### Response Body:
```javascript
{
    "httpCode": 200,
    "result": {
        "data": [
            {
                "id": "e30096ed-b8ea-4424-890a-2c4a2189cad0",
                "isTaken": false,
                "medicationTime": "2021/01/22 18:55",
                "createTime": 1611543142033,
                "updateTime": 1611543753539
            }
        ],
        "total": 1
    }
}
```
---

### 用Id取得某一筆用藥記錄

```url
POST /medication/record/detail
``` 

#### Request Payload:
```javascript
{
    // "medicationTime":"2021/01/22 18:55"
    "id": "XXXXX-SSSSS-ZZZZZZ-JJJJJJ"
}
```

#### Response Body:
```javascript
{
    "httpCode": 200,
    "result": {
        "data": {
            "id": "e30096ed-b8ea-4424-890a-2c4a2189cad0",
            "isTaken": false,
            "medicationTime": "2021/01/22 18:55",
            "createTime": 1611543142033,
            "updateTime": 1611543753539
        }
    }
}
```
---
