---
# System prepended metadata

title: 個案管理

---

# 個案管理

## 個案管理

### (OK) 新增個案

Request:

    POST /case

Payload：

```json=
    {
        "username": "帳號（證件號碼） <string>",
        "name": "使用者名稱（姓名） <string>",
    		"userNumber": "企業員工編號 <string>",
        "birthDate": "使用者生日 <string>",  // birthDate Regex: ([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2][0-9]|3[0-1]))?)?
    		"department": "1001234 <number>",
    		"departmentName": "管理一部 <string>",
    		"height": "身高 <string>", 
        "gender": "性別 <string> enum: [ male | female | other | unknown ]",
        "telecomEmail": "主要信箱 <string>",
        "telecomSubEmail": "次要信箱 <string>",
        "telecomPhone": "電話號碼 <string>",
    		"address": "地址 <string>",
        "managingOrganization": "單位組織編號 <string>",
    		"nationality": "國籍 <string> 參考 ISO 3166-1 二位字母代號",
    		"diseaseHistory": [ //個人罹病史
    			{ "date": "2019", "description": "高血壓"  },
    			...
    		],
    		"surgeryHistory": [ //個人開刀史
    			{ "date": "2019", "description": "脊椎...."  },
    			...
    		],
    		"familyHistory": [
    			{ 
    				"id": "資料庫中caseid （若資料庫子存在此人時）帶入，非必填"
    				"username": "A123456789",
    				"name": "王大明",
    				"birthDate": "1866-01-01",
    				"title": "哥哥",
    				"liveWithFamily": false,
    				"diseaseHistory": "XX病、XX病 <string>",
    				"caseTypeList": [
    					{
    						"caseType": "收案別（case id）<number>",
    						"caseStatus": "收案狀態 (狀態id) <number>"
    					}
    				]
    			}
    		],
    		"caseTypeList": [
    			{
    				"receiveDate": "收案時間 <timestamp>",
    				"caseType": "收案別（case id）<number>",
    				"caseStatus": "收案狀態 (狀態id) <number>"
    			}
    		],
    		"active": true
    }
```

Response (成功):

```json=
    {
        "success": true,
        "data": { 
    			"createdAt": "建立時間 <number, bigint>"
        }
    }
```
### (OK) 編輯個案

Request:

    PUT /case/$id

Payload：

```json=
    {
        "username": "帳號（證件號碼） <string>",
        "name": "使用者名稱（姓名） <string>",
    		"userNumber": "企業員工編號 <string>",
        "birthDate": "使用者生日 <string>",  // birthDate Regex: ([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2][0-9]|3[0-1]))?)?
    		"department": "1001234 <number>",
    		"departmentName": "管理一部 <string>",
    		"height": "身高 <string>",
        "gender": "性別 <string> enum: [ male | female | other | unknown ]",
        "telecomEmail": "主要信箱 <string>",
        "telecomSubEmail": "次要信箱 <string>",
        "telecomPhone": "電話號碼 <string>",
    		"address": "地址 <string>",
        "managingOrganization": "單位組織編號 <string>",
        "nationality": "國籍 <string> 參考 ISO 3166-1 二位字母代號",
    		"diseaseHistory": [ //個人罹病史
    			{ "date": "2019", "description": "高血壓"  },
    			...
    		],
    		"surgeryHistory": [ //個人開刀史
    			{ "date": "2019", "description": "脊椎...."  },
    			...
    		],
    		"familyHistory": [
    			{ 
    				"id": "資料庫中caseid （若資料庫子存在此人時）帶入，非必填"
    				"username": "A123456789",
    				"name": "王大明",
    				"birthDate": "1866-01-01",
    				"title": "哥哥",
    				"liveWithFamily": false,
    				"diseaseHistory": "XX病、XX病 <string>",
    				"caseTypeList": [
    								{
    									"caseType": "收案別（case id）<number>",
    									"caseStatus": "收案狀態 (狀態id) <number>"
    								}
    							]
    			}
    		],
    		"caseTypeList": [
    			{
    				"caseType": "收案別（case id）<number>",
    				"caseStatus": "收案狀態 (狀態id) <number>"
    			}
    		],
    		"active": true
    }
```

Response (成功):

```json=
    {
        "success": true,
        "data": [
            "updatedAt": "更新時間 <number, bigint>"
        ]
    }
```
### (OK) 移除個案

Request:

    DEL /case/$id

Response (成功):

```json=
    {
        "success": true
    }
```

### 停用／啟用個案

Request:

    PUT /case/$id/activate

Payload：

```json=
    { 
        "active": "是否啟用 <boolean>"
    }
```
Response (成功):

```json=
    {
        "success": true
    }
```
### (OK) 查看個案清單

Request:

    GET /case?$queryParams

[Query Params:](Untitled%203/Query%20Params.csv)

|  欄位 | 型態  | IsRequired | 說明  | 
|---|---|---|---|---|
name | string | false | Case name
gender | string | false | 'M' for male, other string for female 
page | number | false | 
sort | string | false | 'userNumber', 'name', 'gender', 'departmentName', 'managingOrganizationName'
desc | boolean | false |

Response (成功):

```json=
    {
        "success": true,
        "data": [
            {
                "id": "個案使用者編號 <string>",
                "username": "帳號（證件號碼） <string>",
                "name": "使用者名稱 <string>",
    						"userNumber": "企業員工編號 <string>",
                "birthDate": "使用者生日 <string>",
                // birthDate Regex: ([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2][0-9]|3[0-1]))?)?
                "gender": "性別 <string> enum: [ male | female | other | unknown ]",
                "managingOrganizationName": "台大醫院",
    						"department": "1001234 <number>",
    						"departmentName": "業務一部 <string>",
    	          "caseTypeList": [
    							{
    								"receiveDate": "收案時間 <timestamp>",
    								"caseType": "收案別（case id）<number>",
    								"caseStatus": "收案狀態 (狀態id) <number>"
    							}
    						],
                "updateAt": "更新時間 <number, bigint>"
            },
            ...
        ]
    }
```

### (OK) 查看個案資料

Request:

    GET /case/$id

Response (成功):

```json=
    {
        "success": true,
        "data": [
            {
              "username": "帳號（證件號碼） <string>",
    			    "name": "使用者名稱（姓名） <string>",
    					"userNumber": "企業員工編號 <string>",
    			    "birthDate": "使用者生日 <string>",  // birthDate Regex: ([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2][0-9]|3[0-1]))?)?
    					"department": "1001234 <number>",
    					"departmentName": "業務一部 <string>",
    					"height": "身高 <string>",
    			    "gender": "性別 <string> enum: [ male | female | other | unknown ]",
    			    "telecomEmail": "主要信箱 <string>",
    			    "telecomSubEmail": "次要信箱 <string>",
    			    "telecomPhone": "電話號碼 <string>",
    					"address": "地址 <string>",
    			    "managingOrganizationId": "1",
    			    "managingOrganizationName": "Wistron OWicare Test Organization",
    			    "managingOrganizationType": "bus",
    			    "nationality": "國籍 <string> 參考 ISO 3166-1 二位字母代號",
    					"diseaseHistory": [ //個人罹病史
    						{ "date": "2019", "description": "高血壓"  },
    						...
    					],
    					"surgeryHistory": [ //個人開刀史
    						{ "date": "2019", "description": "脊椎...."  },
    						...
    					],
    					"familyHistory": [
    						{ 
    							"id": "資料庫中caseid （若資料庫子存在此人時）帶入，非必填"
    							"username": "A123456789",
    							"name": "王大明",
    							"birthDate": "1866-01-01",
    							"title": "哥哥",
    							"liveWithFamily": false,
    							"diseaseHistory": [ //家庭罹病史
    								{ "date": "2019", "description": "高血壓"  },
    									...
    							],
    							"caseTypeList": [
    								{
    									"caseType": "收案別（case id）<number>",
    									"caseStatus": "收案狀態 (狀態id) <number>"
    								}
    							]
    						}
    					],
    					"caseTypeList": [
    						{
    							"receiveDate": "收案時間 <timestamp>",
    							"caseType": "收案別（case id）<number>",
    							"caseStatus": "收案狀態 (狀態id) <number>"
    						}
    					],
    					"updateAt": "更新時間 <number, bigint>"
    			 }
        ]
    }
```

## (OK)查詢個案相關課程紀錄

Request:

    GET /case/$uid/record

[Copy of Query Params:](Untitled%203/Copy%20of%20Query%20Params.csv)

Response (成功):

```json=
    {
      "success": true,
      "total": 5,
      "data": [
        {
          "lessonId": "課程班次編號 <number>",
          "lessonStartedAt": "課程班次時間(timestamp) <string> ",
          "lessonName": "課程班次名稱 <string>",
          "courseId": "系列課程編號 <number>",
          "courseName": "系列課程名稱 <string>",
          "courseType": "系列課程類型 <number>",
          "courseDuration": "持續時間 <number>",
          "courseUnit": [
            {
              "unitId": "主題單元編號 <number>",
              "unitName": "主題單元名稱 <string>",
              "unitDuration": "持續時間 <number>",
              "courseTraining": [
                {
                  "trainingId": "訓練項目編號 <number>",
                  "trainingName": "訓練項目名稱 <string>",
                  "trainingDuration": "持續時間 <number>",
                  "trainingType": "復能",
                  "trainingEndType" : "高血壓",
                  "trainingEndStatus" : "第一期",
                  "currentLevel": { // 團體沒有等級問題
                      "target": "當前目標值 <number>",
                      "actual": "當前等級達成次數 <number>",
                      "rank": "當前等級 <number>",
                  },
                  "record": [
                    {
                      "id": "訓練紀錄 ID <number>",
                      "lessonId": "課程班次編號 <number>",
                      "recordDuration": "持續時間 <number>",
                      "recordActualValue": "實際值 <number>"
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
```

# 課程紀錄

## Schema

[課程紀錄 (CaseRecord)](Untitled%203/CaseRecord.csv)

## (OK) 新增課程訓練

Request:

    POST /case/record

Payload:

傳送陣列則為批量新增

```json=
    {
       "record": [{
           "actualValue": 100,
            "type": 3,
            "duration": 10,
            "startedAt": 1595925005000,
            "user": 3,
            "course": 41,
            "courseUnit": 8,
            "courseTraining": 13,
            "lesson": null,
            "startDate": 1595925005000,
            "endDate": 1595925005000
           }
    	 ]
    }
```

Response (成功):

```json=
    {
    		"success": true,
    		"data": {
    						CaseRecord
    		}
    }
```

## (OK) 編輯課程訓練

Request:

    PUT /case/record/$id

Payload:

```json=
    {
       CaseRecord
    }
```

Response (成功):

```json=
    {
    		"success": true,
    		"data": {
    						CaseRecord
    		}
    }
```

## (OK) 查詢課程訓練列表

Request:

    GET /case/record?$queryParams

[Query Params:](Untitled%203/Query%20Params%201.csv)

Response (成功):

```json=
    {
    		"success": true,
    	  "total": 5,
    		"data": [
    						CaseRecord,
    						CaseRecord,
             ...
    		]
    }
```

## (OK) 查詢課程訓練

Request:

    GET /case/record/$id

Response (成功):

```json=
    {
    		"success": true,
    		"data": {
            CaseRecord
        }
    }
```

## (OK) 刪除課程訓練

Request:

    DELETE /case/record/$id

Response (成功):

```json=
    {
    		"success": true,
    		"data": {}
    }
```
# 健康時間軸（上半）

Request:

    GET /case/$id/timeline/legend
    
    
# 個人訓練表現監測

|  欄位 | 型態  | IsRequired | 說明  | 
|---|---|---|---|---|
caseTypeId | number | true | 收案項目(目前僅需失智症與衰弱症)
patienId | number | false | 個案ID
type | number | true | 0:全部，1:復能，2:篩檢
time | string | true | last: 最近一次，first:首次，beforeLast:前次，monthHigh:當月最高，monthLow: 當月最低
dateTime | number | false | 日期
sort | string | false | 3種排序: "training", "byFirst", "bySecond"
desc | boolean | false | 順序


## 查詢個人訓練表現列表

Request:

    POST /case/record/monitor

Payload:

```json=
{
    "caseTypeId": 14, // 暫定14失智症、15衰弱症
    "patientId": 2, // 不傳將由token自動查詢帶入
    "condition": [
        { "type": 0, "time": "first" },
        { "type": 2, "time": "monthHigh", "dateTime": 1595925005000 }
        ]
    "sort": "training", // training, byFirst, bySecond
    "desc": true
        // monthHigh, monthLow 需要dateTime(僅取年月)
}
```
<!-- 
```json=
{
    "caseTypeId": 14, // 暫定14失智症、15衰弱症
    "patientId": 2, // 不傳將由token自動查詢帶入
    "condition": {
        "firstCondition" : {
            "type": 1,
            "time": "first"
            // first, last, beforeLast, monthHigh, monthLow
        },
        "secondCondition" : {
            "type": 2,
            "time": "monthHigh",
            "dateTime": 1595925005000
            // monthHigh, monthLow 需要timestamp(僅取年月)
        }
    }
}
``` -->

Response (成功):

```json=
{
    	"success": true,
    	"data": [
          {"training": "測試項目1", "trainingId": 11, "target": 5, "actualValue": [4, 6], "level": [1, 2], "isRed":[true, false], "unitType": "sec"},
          {"training": "測試項目1", "trainingId": 11, "target": 5, "actualValue": [3, 7], "level": [1, 2], "isRed":[true, false], "unitType": "times"},
          {"training": "測試項目1", "trainingId": 11, "target": 5, "actualValue": [2, 8], "level": [1, 2], "isRed":[true, false], "unitType": "angel"},
          {"training": "測試項目1", "trainingId": 11, "target": 5, "actualValue": [1, 9], "level": [1, 2], "isRed":[true, false], "unitType": "sec"},
        ]
}
```
<!-- 
```json=
{
    	"success": true,
    	"data": {[
          {"courseTraining": "測試項目1", "courseTrainingId": 11, "target": 5, "firstCondition": 4, "secondCondition": 6, "unitType": "sec"},
          {"courseTraining": "測試項目2", "courseTrainingId": 12, "target": 5, "firstCondition": 4, "secondCondition": 6, "unitType": "angle"},
          {"courseTraining": "測試項目3", "courseTrainingId": 20, "target": 5, "firstCondition": 4, "secondCondition": 6, "unitType": "times"},
          {"courseTraining": "測試項目4", "courseTrainingId": 25, "target": 5, "firstCondition": 4, "secondCondition": 6, "unitType": "sec"},
        ]}
}
```
 -->
## 查詢個人訓練表現紀錄

Query Params:
|  欄位 | 型態  | IsRequired   | 說明  | 
|---|---|---|---|---|
| trainingId | number | true | 訓練項目ID|
| patientId | number | false | 個案ID|


Request:

    GET /case/record/training?$queryParams

Response (成功):

```json=
{
    "success": true,
    "total": 6,
    "data": [
        {"actualValue": 5, "target": 11, "dateTime": 1595925005000},
        {"actualValue": 7, "target": 11, "dateTime": 1595925005000},
        {"actualValue": 2, "target": 11, "dateTime": 1595925005000},
        {"actualValue": 5, "target": 11, "dateTime": 1595925005000},
        {"actualValue": 4, "target": 11, "dateTime": 1595925005000},
        {"actualValue": 9, "target": 11, "dateTime": 1595925005000},
    ]
}
```