---
# System prepended metadata

title: 收案類別管理

---

# 收案類別管理
Attribute | Description | IsRequired| Remark
-|-|-|-
id | number | true | Primary Key
name | String | true | 收案類別名稱
active | boolean | true | 收案類別狀態(啟用與否) default true
createdAt | number | true | 建立時間(timestamp)
updatedAt | number | false | 修改時間(timestamp)
level | String | true | 使用層級[醫院(H)/企業(E)/全部(A)]
status | Object Array | false | 收案狀態項目
- id | number | true | Primary Key
- name | String | true | 狀態項目名稱
- active | boolean | true | 使用狀態(default true) [使用中/已停用]
- order | number | true | 順序(由小到大) 
- updatedAt | number | false | 最後更新時間(timestamp)

### 查詢
```url=
GET /caseType
```
Query Params:
|  欄位 | 型態  | 預設   | 說明  | 
|---|---|---|---|---|
| page | number |1| 當前頁數|
| pageSize | number |10| 每頁結果數量，-1 為顯示所有|
| sort | string | id | 排序欄位
| desc | boolean | false | 是否倒序排列？
| fuzzyQuery | string | - | 收案類別, 收案狀態項目的模糊查詢

Response (成功):
```json=
{
    "success": true,
    "total": 20,
    "data": [
        {
            "id": 1,
            "name": "高血壓",
            "active": true,
            "createdAt": 1583991833330,
            "updatedAt": null,
            "level": "A",
            "status": [
                {
                    "id": 1,
                    "name": "第一期",
                    "active": true,
                    "order": 1,
                    "updatedAt": null
                }, {
                    "id": 2,
                    "name": "第二期",
                    "active": true,
                    "order": 2,
                    "updatedAt": 1583992833330
                }
            ]
        }, {
            "id": 2,
            "name": "ECKD",
            "active": false,
            "createdAt": 1583991833330,
            "updatedAt": 1583992833330,
            "level": "H",
            "status": [
                {
                    "id": 3,
                    "name": "第一期",
                    "active": false,
                    "order": 1,
                    "updatedAt": null
                }, {
                    "id": 4,
                    "name": "第二期",
                    "active": true,
                    "order": 2,
                    "updatedAt": 1583992833330
                }
            ]
        },
        ...
    ]
}
```
### 單筆查詢ById
```url=
GET /caseType/$id
```
Response (成功):
```json=
{
    "success": true,
    "data": {
        "id": 1,
        "name": "高血壓",
        "active": true,
        "createdAt": 1583991833330,
        "updatedAt": null,
        "level": "A",
        "status": [
            {
                "id": 1,
                "name": "第一期",
                "active": true,
                "order": 1,
                "updatedAt": null
            }, {
                "id": 2,
                "name": "第二期",
                "active": true,
                "order": 2,
                "updatedAt": 1583992833330
            }
        ]
    }
}
```
### 新增
Request:
```url=
POST /caseType
```

Payload：
```json=
{
    "active": true,
    "level": "A",
    "name": "ECKD",
    "status": [
        {
            "name": "前期",
            "active": true,
            "order": 1
        }, {
            "name": "後期",
            "active": true,
            "order": 2
        }
    ]
}
```
Response (成功):
```json=
{
    "success": true,
    "data": {
        "id": 1,
        "createdAt": 1583991833330
    }
}
```
### 修改
Request:
```url=
PUT /caseType
```
Payload：
```json=
{
    "id": 1,
    "active": true,
    "name": "ECKD",
    "level": "A",
    "status": [
        {
            "id": 1, // not null as update
            "active": true,
            "name": "前期",
            "order": 1
        }, {
            "id": null, // null as created
            "name": "後期",
            "active": true,
            "order": 2
        } //others as delete
    ]
}
```
Response (成功):
```json=
{
    "success": true,
    "data": {
        "id": 1,
        "updatedAt": 1583991833330
    }
}
```
### 停用／啟用
Request:
```url=
PATCH /caseType/$id/activate
```
Payload：
```json=
{ 
    "active": false
}
```
Response (成功):
```json=
{
    "success": true,
    "data": {
        "id": 1,
        "active": false
    }
}
```

## 收案狀態
Attribute | Description | IsRequired| Remark
-|-|-|-
id | number | true | Primary Key
isDeletable | boolean | true | 是否允許被刪除(depend on 是否被使用)
### 檢查是否可以刪除
```url=
GET /caseType/status/$id
```
Response (成功):
```json=
{
    "success": true,
    "data": {
        "id": 1,
        "isDeletable" : true
    }
}
```
### 停用／啟用
Request:
```url=
PATCH /caseType/status/$id/activate
```
Payload：
```json=
{ 
    "active": false
}
```
Response (成功):
```json=
{
    "success": true,
    "data": {
        "id": 1,
        "active": false,
        "updatedAt": 1583991833330
    }
}
```


