# 排程類別管理
## 排程類別項目
[權限敘述]
-企業及醫院管理員可增刪修自己單位的排程項目
-企業及醫院個管師可檢視自己單位的排程項目
-企業及醫院間各自獨立,無繼承關係
Attribute | Description | IsRequired| Remark
-|-|-|-
id | number | true | Primary Key
name | String | true | 排程類別項目名稱
description | string | true | 說明
timeInterval | number | false | 時間間隔限制
timeIntervalUnit | string | false | 時間間隔限制單位[d(天)/w(週)/m(月)/y(年)]
active | boolean | true | 狀態(啟用與否) default false
organId | String | false | 組織ID - FK (by token info)
createdAt | timestamp | false | 建立時間(timestamp)
updatedAt | timestamp | false | 修改時間(timestamp)
### 查詢
```url=
GET /schedule/category
```
Query Params:
| 欄位 | 型態 | 預設 | 說明 |
|---|---|---|---|---|
| page | number |1| 當前頁數|
| pageSize | number |10| 每頁結果數量,-1 為顯示所有|
| sort | string | createdAt | 排序欄位
| desc | boolean | false | 是否倒序排列?
Response (成功):
```json=
{
"success": true,
"totoal": 2,
"data": [
{
"id": 1,
"name": "一對一健檢",
"description": "當日請空腹",
"timeInterval": 100,
"timeIntervalUnit": "d",
"active": false,
"organId" : "1101",
"createdAt": 1583991833330,
"updatedAt": null
}, {
"id": 2,
"name": "過勞評估",
"description": "",
"timeInterval": 1,
"timeIntervalUnit": "y",
"active": true,
"organId" : "1101",
"createdAt": 1583991833330,
"updatedAt": 1583996833330
},
...
]
}
```
### 新增
Request:
```url=
POST /schedule/category
```
Payload:
```json=
{
"name": "一對一健檢",
"description": "當日請空腹",
"timeInterval": 100,
"timeIntervalUnit": "d",
"active": false,
}
```
Response (成功):
```json=
{
"success": true,
"data": {
"id": 1,
"name": "一對一健檢",
"description": "當日請空腹",
"timeInterval": 100,
"timeIntervalUnit": "d",
"organId" : "1101",
"active": false,
"createdAt": 1583991833330
}
}
```
### 編輯
Request:
```url=
PUT /schedule/category/$scheduleCategoryId
```
Payload:
```json=
{
"name": "一對一健檢XXX",
"description": "當日請空腹XXX",
"timeInterval": 10,
"timeIntervalUnit": "w",
"active": true,
}
```
Response (成功):
```json=
{
"success": true,
"data": {
"id": 1,
"updatedAt": 1583996833330
}
}
```
### 刪除
Request:
```url=
DEL /schedule/category/$scheduleCategoryId
```
Response (成功):
```json=
{
"success": true
}
```
### 停用/啟用
Request:
```url=
PATCH /schedule/category/$scheduleCategoryId/activate
```
Payload:
```json=
{
"active": true
}
```
Response (成功):
```json=
{
"success": true
}
```
## 開放時段
[權限敘述]
-企業及醫院管理員/個管師可增刪修開放時段
-L1醫療單位設定時段時可指定開放給特定轄下機關(L2)
-L1醫療單位設定時段時可指定開放給院內或轄下機關之特定收案別族群
-L2企業單位設定時段時可指定給內部特定部門及特定收案別族群
-L1與L2的設定時段沒有繼承關係
Attribute | Description | IsRequired| Remark
-|-|-|-
id | number | true | Primary Key
categoryId | number | true | FK
categoryName | String | false | 排程類別項目名稱
categoryDescription | string | true | 說明
categoryTimeInterval | number | false | 時間間隔限制
categoryTimeIntervalUnit | string | false | 時間間隔限制單位[d(天)/w(週)/m(月)/y(年)]
allowMembers | number | true | 可預約人數
dateTimeStart | timestamp | true | 開放時段起始時間(timestamp)
dateTimeEnd | timestamp | true | 開放時段結束時間(timestamp)
cycleType | number | false | 1(每天)/2(每週)/3(每月)
userId | String | true | 負責人Id
userName | String | true | 負責人姓名
organId | String | true | 組織ID - FK (by token info)
createdAt | timestamp | false | 建立時間(timestamp)
updatedAt | timestamp | false | 修改時間(timestamp)
kind | String | true | 對象類型[1(收案別)/2(授權單位)]
cases | Object Array | true | Object array shown as below
- id | number | true | Primary Key
- caseTypeId | number | depend on kind | 收案別ID
- caseStatusId | number | depend on kind | 收案別狀態ID
- organId | String | depend on kind | 授權單位ID
- organName | String | depend on kind | 授權單位名稱
### 查詢
```url=
GET /schedule/openhour
```
Query Parameters
| 欄位 | 型態 | 預設 | 說明 |
|---|---|---|---|---|
| page | number |1| 當前頁數|
| pageSize | number |10| 每頁結果數量,-1 為顯示所有|
| sort | string | createdAt | 排序欄位
| desc | boolean | false | 是否倒序排列?
| startAt | timeStamp | false | 起始時間
| endAt | timeStamp | false | 結束時間
| FuzzyQuery | String | false | 模糊查詢,欄位(排程類別項目名稱、開放預約對象)
Response (成功):
```json=
{
"success": true,
"totoal": 2,
"data": [
{
"id": 1,
"categoryId": 1,
"categoryName": "一對一健檢",
"categoryDescription": "當日請空腹",
"categoryTimeInterval": 100,
"categoryTimeIntervalUnit": "d",
"allowMembers": 50,
"dateTimeStart": 1585991833330,
"dateTimeEnd": 1585991853330,
"cycleType": 1,
"userId": "3301",
"userName": "王XX",
"organId" : "1101",
"createdAt": 1583991833330,
"updatedAt": null,
"kind": "1",
"cases": [
{
"id": 1,
"caseTypeId": 1,
"caseStatusId": 1,
"organId": null,
"organName": null,
}
]
}, {
"id": 2,
"categoryId": 2,
"categoryName": "過勞評估",
"categoryDescription": "",
"categoryTimeInterval": 1,
"categoryTimeIntervalUnit": "y",
"allowMembers": 50,
"dateTimeStart": 1585991833330,
"dateTimeEnd": 1585991873330,
"cycleType": 2,
"userId": "3302",
"userName": "陳OO",
"organId" : "1101",
"createdAt": 1583991833330,
"updatedAt": null,
"kind": "2",
"cases": [
{
"id": 2,
"caseTypeId": null,
"caseStatusId": null,
"organId": "1102",
"organName": "國軍高雄總醫院左營分院多元照顧中心",
}
]
},
...
]
}
```
### 新增
Request:
```url=
POST /schedule/openhour
```
Payload:
```json=
{
"categoryId": 1,
"allowMembers": 50,
"dateTimeStart": 1585991833330,
"dateTimeEnd": 1585991853330,
"cycleType": 1,
"userId": "3302",
"kind": "1",
"cases": [
{
"caseTypeId": 1,
"caseStatusId": 1,
"organId": null,
}
]
}
```
Response (成功):
```json=
{
"success": true,
"data": {
"id": 100,
"categoryId": 1,
"allowMembers": 50,
"dateTimeStart": 1585991833330,
"dateTimeEnd": 1585991853330,
"cycleType": 1,
"userId": "3302",
"kind": "1",
"cases": [
{
"id": 101,
"caseTypeId": 1,
"caseStatusId": 1,
"organId": null
}
],
"createdAt": 1583991853330
}
}
```
### 編輯
Request:
```url=
PUT /schedule/openhour/$scheduleOpenHourId
```
Payload:
```json=
{
"categoryId": 1,
"allowMembers": 50,
"dateTimeStart": 1585992833330,
"dateTimeEnd": 1585992853330,
"cycleType": 1,
"userId": "3302",
"kind": "1",
"cases": [
{
"id": 101, //修改
"caseTypeId": 1,
"caseStatusId": 1,
"organId": null
}, {
"id": null, //新增
"caseTypeId": 1,
"caseStatusId": 1,
"organId": null
} // 其他的為刪除
],
}
```
Response (成功):
```json=
{
"success": true,
"data": {
"id": 1,
"categoryId": 1,
"allowMembers": 50,
"dateTimeStart": 1585992833330,
"dateTimeEnd": 1585992853330,
"cycleType": 1,
"userId": "3302",
"kind": "1",
"cases": [
{
"id": 101,
"caseTypeId": 1,
"caseStatusId": 1,
"organId": null
}, {
"id": 122,
"caseTypeId": 1,
"caseStatusId": 1,
"organId": null
}
],
"updatedAt": 1583996833330,
}
}
```
### 刪除
Request:
```url=
DEL /schedule/openhour/$scheduleOpenHourId
```
Response (成功):
```json=
{
"success": true
}
```
### 依照OpenHourId查詢所有合法預約名單
*依據收案別/授權單位撈出範圍內users
Attribute | Description | IsRequired | Remark
-|-|-|-
userId | number | true | Primary Key
userNo | String | true | 編號
userName | String | true | 姓名
gender | String | true | 性別
organId | String | true | 部門Id
organName | String | true | 部門科別
cases | Object Array | true | 收案
- caseTypeId | number | true | 收案別Id
- caseTypeName | String | true | 收案別
- caseStatusId | number | true | 收案狀態Id
- caseStatusName | String | true | 收案狀態
Query Parameters
| 欄位 | 型態 | 預設 | 說明 |
|---|---|---|---|---|
| page | number |1| 當前頁數|
| pageSize | number |10| 每頁結果數量,-1 為顯示所有|
| sort | string | memberUserId | 排序欄位
| desc | boolean | false | 是否倒序排列?
Request:
```url=
GET /schedule/openhour/$openHourId/members
```
Response (成功):
```json=
{
"success": true,
"totoal": 80,
"data": [
{
"id": 101, // openHourId
"userId": 1,
"userNo": "1001234",
"userName": "葉子元",
"organId": "3456",
"organName": "業務一部",
"gender": "male",
"cases": [
{
"caseTypeId": 1,
"caseTypeName": "高血壓",
"caseStatusId": 1,
"caseStatusName": "第一期"
},
...
]
}
...
]
}
```
### 依照OpenHourId查詢已選取預約名單
*依據收案別/授權單位撈出範圍內users
Attribute | Description | IsRequired | Remark
-|-|-|-
userId | number | true | Primary Key
isCheckIn | boolean | true | 報到(default false)
Request:
```url=
GET /schedule/openhour/$openHourId/members/selected
```
Response (成功):
```json=
{
"success": true,
"totoal": 60,
"data": {
"id": 101, // openHourId
"members": [
{
"userId": 1,
"isCheckIn": true,
}, {
"userId": 2,
"isCheckIn": false,
}
...
]
}
}
```
### 依照OpenHourId批次修改預約名單
Request:
```url=
PUT /schedule/openhour/$openhourid/members/selected
```
Payload:
```json=
{
"members": [
{
"userId": 1,
"isCheckIn": true,
}, {
"userId": 2,
"isCheckIn": false,
}
]
}
```
Response (成功):
```json=
{
"success": true,
"total": 2,
"data": {
"id": 1, // $openhourid
"updatedAt": 1583996833330
}
}
```
## 活動內容
* <span style="color:red">使用userId 還是caseId需要再深入看看DB設計</span>
Attribute | Description | IsRequired| Remark
-|-|-|-
id | number | true | Primary Key
categoryId | number | true | FK
categoryName | String | false | 排程類別項目名稱
categoryDescription | string | true | 說明
categoryTimeInterval | number | false | 時間間隔限制
categoryTimeIntervalUnit | string | false | 時間間隔限制單位[d(天)/w(週)/m(月)/y(年)]
allowMembers | number | true | 可預約人數
dateTimeStart | timestamp | true | 開放時段起始時間(timestamp)
dateTimeEnd | timestamp | true | 開放時段結束時間(timestamp)
cycleType | number | false | 1(每天)/2(每週)/3(每月)
userId | String | true | 負責人Id
userName | String | true | 負責人姓名
organId | String | true | 組織ID - FK (by token info)
organName | String | true | 組織名稱
createdAt | timestamp | false | 建立時間(timestamp)
updatedAt | timestamp | false | 修改時間(timestamp)
### 查詢(可以參加的)活動列表
* 查詢<span style="color:red">尚未開始</span>並且該個案人員可以參予(已報名/未報名)的活動列表
```url=
GET /schedule/openhour/user/$userId
```
Response (成功):
```json=
{
"success": true,
"totoal": 20,
"data": [
{
"id": 1,
"categoryId": 1,
"categoryName": "一對一健檢",
"categoryDescription": "當日請空腹",
"allowMembers": 50,
"dateTimeStart": 1585991833330,
"dateTimeEnd": 1585991853330,
"cycleType": 1,
"userId": "3301",
"userName": "王XX",
"organId": "1101",
"orgName": "人文關懷處"
}, {
"id": 2,
"categoryId": 2,
"categoryName": "過勞評估",
"categoryDescription": "",
"allowMembers": 50,
"dateTimeStart": 1585991833330,
"dateTimeEnd": 1585991873330,
"cycleType": 2,
"userId": "3302",
"userName": "陳OO",
"organId" : "1101",
"orgName": "人文關懷處"
},
...
]
}
```
### 查詢已報名且尚未開始的活動列表
* 查詢<span style="color:red">尚未開始</span>並且該個案人員"已報名參予"的活動列表
```url=
GET /schedule/openhour/user/$userId/selected
```
Response (成功):
```json=
{
"success": true,
"totoal": 60,
"data": {
"userId": 101,
"openhourIds": [
101,
102,
108,
...
]
}
}
```
### 查詢歷史活動列表
* 查詢<span style="color:red">已經結束</span>並且該個案人員"已報名參予"的活動列表
```url=
GET /schedule/openhour/user/$userId/selected/history
```
Response (成功):
```json=
{
"success": true,
"totoal": 20,
"data": [
{
"id": 1,
"categoryId": 1,
"categoryName": "一對一健檢",
"categoryDescription": "當日請空腹",
"allowMembers": 50,
"dateTimeStart": 1585991833330,
"dateTimeEnd": 1585991853330,
"cycleType": 1,
"userId": "3301",
"userName": "王XX",
"organId": "1101",
"orgName": "人文關懷處"
}, {
"id": 2,
"categoryId": 2,
"categoryName": "過勞評估",
"categoryDescription": "",
"allowMembers": 50,
"dateTimeStart": 1585991833330,
"dateTimeEnd": 1585991873330,
"cycleType": 2,
"userId": "3302",
"userName": "陳OO",
"organId" : "1101",
"orgName": "人文關懷處"
},
...
]
}
```
### 報名活動
Request:
```url=
POST /schedule/openhour/$openhourId
```
Response (成功):
```json=
{
"success": true,
"total": 2,
"data": {
"id": 1, // $openhourid
"updatedAt": 1583996833330
}
}
```