---
# System prepended metadata

title: Untitled

---

## 1. Get Questionnaries List Data
GET/{contextPath}/questionnarie/list
取得自訂表單列表
- 根據JWT中資訊取得使用者"AreaCode"
- 將回傳accessToken（JWT）帶入呼叫API的header中

API require headers:
```javascript=
{
    Authorization: accessToken
}
```

param: 
```
none.
```

### Response Body:

| Parameter    |  format  |  desc       |
| ------------ | -------- |-------------|
| questionnaireId     | String   | 問卷Id     |
| questionnaireNo     | String   | 問卷代號    |
| kind   | String   | 問卷類別  |
| version   | String   | 問卷的版本代號  |
| disease | String | 疾病類別 |
| createDate | String | 建立日期 |
| updateDate | String | 修改日期 |

response: 200 
```javascript=
{
    "httpCode": 200,
    "result": {
        "data": [
            {
                "questionnaireId": "5abaac9a-43c0-4e66-9dda-16c0a62c547c",
                "questionnaireNo": "A00001",
                "kind": "CHILD_DEVELOPMENT",
                "version": "1",
                "disease": "ECKD",
                "createDate": "2020/01/01",
                "updateDate": "2020/01/02"
            },
            {
                "questionnaireId": "f8b95827-4e15-4ad3-8f38-dfe9877a32df",
                "questionnaireNo": "B00001",
                "kind": "GENERAL",
                "version": "1",
                "disease": "ECKD",
                "createDate": "2020/01/01",
                "updateDate": "2020/01/02"
            }
        ]
    }
}
```

## 2. Get questionnaries by Id
GET/{contextPath}/questionnarie/:id
取得問卷格式內容
- 根據JWT中資訊取得使用者"AreaCode"
- 將回傳accessToken（JWT）帶入呼叫API的header中

API require headers:
```javascript=
{
    Authorization: accessToken
}
```

param: 
```
none.
```

### Response Body:

| Parameter    |  format  |  desc       |
| ------------ | -------- |-------------|
| questionnaireId     | String   | 問卷Id     |
| questionnaireNo     | String   | 問卷代號    |
| kind   | String   | 問卷的類型代碼  |
| version   | String   | 問卷的版本代號  |
| disease | String | 疾病類別 |
| createDate | String | 建立日期 |
| updateDate | String | 修改日期 |
| content    | Json String | 問券內容 |

* 系列問題 (series) # 問題區塊

| Parameter    |  format  |  desc       |
| ------------ | -------- |-------------|
| seriesNo     |  String  |  系列問題代號 |
| seriesOrder  |  int     |  順序       |
| seriesTitle  |  String  |  系列問題標題 |
| seriesRemark |  String  |  系列問題備註 |
| questionList |  Object Array | 系列問題列表 |

* 系列問題 (question) #區塊題目

| Parameter    |  format  |  desc       |
| ------------ | -------- |-------------|
| questionId   |  String  |  問題Id     |
| questionOrder | int     |  問題順序    |
| questionTitle | String  |  問題標題    |
| questionType  | String  |  問題類型 S: Select, C: CheckBox, R: Radio Button, F: FreeText |
| questionLevel | int     |  問題階層    |
| questionIsRequired | bool | 是否必填   |
| questionOptions | Object Array | 選項列表 |

* 問題選項 (option)

| Parameter    |  format  |  desc       |
| ------------ | -------- |-------------|
| optionId     | String   | 選項Id      |
| optionText   | String   | 選項標題     |
| optionScore  | int      | 選項分數     |
| optionDescription | String | 選項描述  |

```javascript=
{
    "httpCode": 200,
    "result": {
        "data": {
            "questionnaireId":"5abaac9a-43c0-4e66-9dda-16c0a62c547c",
            "questionnaireNo":"A00001",
            "kind":"CHILD_DEVELOPMENT",
            "version": "1",
            "disease": "ECKD",
            "createDate":"2020/12/12",
            "updateDate":"2020/12/27",
            "content": [
                {
                    "seriesNo":"1",
                    "seriesOrder": 1,
                    "seriesTitle":"i18N.Series.Title.SOF",
                    "seriesRemark": "i18N.Series.Remark.SOF",
                    "questionList":[
                        {
                            "questionId": "SCSSKOK-SJUC-SMKMCKS-XJSGXM",
                            "questionOrder":1,
                            "questionTitle":"i18N.Question.Title.Q1",
                            "questionType":"R",
                            "questionLevel": 1,
                            "questionIsRequired": true,
                            "questionOptions": [
                                {
                                    "optionId": "CSKOKWMJIW-SWWHUOIWS-WNNLKXSW",
                                    "optionText": "i18N.Question.Q1.Option.YES",
                                    "optionScore": 1,
                                    "optionDescription": null
                                },
                                {
                                    "optionId": "KOSJIW-SMLMCDWmi-WJDUIJIW-FCEI",
                                    "optionText": "i18N.Question.Q1.Option.NO",
                                    "optionScore": 0,
                                    "optionDescription": null
                                }
                            ]
                        },
                        {
                            "questionId": "SHUHWH-WBDCDEBUI-HDWLMXWWIJ",
                            "questionOrder":2,
                            "questionTitle":"i18N.Question.Title.Q2",
                            "questionType":"C",
                            "questionLevel": 1,
                            "questionIsRequired": true,
                            "questionOptions": [
                                {
                                    "optionId": "LCJWIHDE-JIXWS-XWHXEHUIW",
                                    "optionText": "i18N.Question.Q2.Option.YES",
                                    "optionScore": null,
                                    "optionDescription": null
                                },
                                {
                                    "optionId": "XWUHBXOW-WXWUBXBE-DBXUWB",
                                    "optionText": "i18N.Question.Q2.Option.NO",
                                    "optionScore": null,
                                    "optionDescription": null,
                                    "QuestionList":[
                                        {
                                            "questionId": "SCMUJENC-WXHUNIWW-XCNUEE",
                                            "questionOrder":1,
                                            "questionTitle":"i18N.Question.Title.Q2.Q1",
                                            "questionType":"C",
                                            "questionLevel": 2,
                                            "questionIsRequired": true,
                                            "questionOptions": [
                                                {
                                                    "optionId": "LCJWIHDE-JIXWS-XWHXEHUIW",
                                                    "optionText": "i18N.Question.Q2.Q1.Option.Rice",
                                                    "optionScore": null,
                                                    "optionDescription": null
                                                },
                                                {
                                                    "optionId": "LCJWIHDE-JIXWS-XWHXEHUIW",
                                                    "optionText": "i18N.Question.Q2.Q1.Option.Noodle",
                                                    "optionScore": null,
                                                    "optionDescription": null
                                                }
                                            ]
                                        },
                                        {
                                            "questionId": "NCDWUBXW-WBXUWNXW-HBCUEDYE",
                                            "questionOrder":2,
                                            "questionTitle":"i18N.Question.Title.Q2.Q2",
                                            "questionType":"F",
                                            "questionLevel": 2,
                                            "questionIsRequired": false
                                        }
                                    ]
                                }
                            ]
                        }    
                    ]
                }
            ]
        }
    }
}
```
 
## 3. Create Questionnarie
POST/ {contextPath}/questionnarie/create

建立問券給特定AreaCode
- 根據JWT中資訊取得使用者"AreaCode"
- 將回傳accessToken（JWT）帶入呼叫API的header中

API require headers:
```javascript=
{
      Content-Type: 'application/json',
      Accept: 'application/json',
      Authorization: accessToken,
}
```

### Request Body:
 
| Parameter     | Required |  format  |  desc             |
| ------------- | -------- | -------- |------------------ |
| questionnaireNo | Y      | String   | 問券代碼           |
| kind          | Y        | String   | 問券類別           |
| version       | Y        | String   | 問券版本           |
| disease       | Y        | String   | 疾病類別           |
| content       | Y        | string   | 問券內容 Json      |

``` json=
{
    "questionnaireNo": "X00001",
    "kind" : "XXXXX",
    "version": "00001",
    "disease": "ECKD",
    "content":
    {
        "questionnaireNo":"Q10001",
        "createDate":"2020/12/12",
        "kind":"A",
        "updateDate":"2020/12/25",
        "completionDate":"2020/12/27",
        "content": [
            {
                "seriesNo":"1",
                "seriesOrder": 1,
                "seriesTitle":"i18N.Series.Title.SOF",
                "seriesRemark": "i18N.Series.Remark.SOF",
                "questionList":[
                    {
                        "questionId": "SCSSKOK-SJUC-SMKMCKS-XJSGXM",
                        "questionOrder":1,
                        "questionTitle":"i18N.Question.Title.Q1",
                        "questionType":"R",
                        "questionLevel": 1,
                        "questionIsRequired": true,
                        "questionOptions": [
                            {
                                "optionId": "CSKOKWMJIW-SWWHUOIWS-WNNLKXSW",
                                "optionText": "i18N.Question.Q1.Option.YES",
                                "optionScore": 1,
                                "optionDescription": null
                            },
                            {
                                "optionId": "KOSJIW-SMLMCDWmi-WJDUIJIW-FCEI",
                                "optionText": "i18N.Question.Q1.Option.NO",
                                "optionScore": 0,
                                "optionDescription": null
                            }
                        ]
                    }
                ]
            }
        ]
    }
}
```

### Response Body:
```json=
{
    "httpCode": 200,
    "result": {
        "data": {
            "questionnaireId": "40623d2d-0209-41b1-8a76-b08de0807447",
            "isSuccess": "true"
        }
    }
}
```

## 4. Update Questionnarie 
POST/ {contextPath}/questionnarie/update

修改訂購單
- 根據JWT中資訊取得使用者"AreaCode"
- 將回傳accessToken（JWT）帶入呼叫API的header中

### Request Body:

| Parameter     | Required |  format  |  desc             |
| ------------- | -------- | -------- |------------------ |
| questionnaireId | Y      | String   | 問券Id            |
| questionnaireNo | Y      | String   | 問券代碼           |
| kind          | Y        | String   | 問券類別           |
| version       | Y        | String   | 問券版本           |
| disease       | Y        | String   | 疾病類別           |
| content       | Y        | string   | 問券內容 Json      |

``` json=
{
    "questionnaireId": "40623d2d-0209-41b1-8a76-b08de0807447",
    "questionnaireNo": "X00002",
	"kind" : "YYYYY",
	"version": "00002",
	"disease": "ECKD",
	"content": 
        {
            "questionnaireNo": "Q10001",
            "createDate": "2020/12/12",
            "kind": "A",
            "updateDate": "2020/12/25",
            "completionDate": "2020/12/27",
            "content": [
                {
                    "seriesNo": "1",
                    "seriesOrder": 1,
                    "seriesTitle": "i18N.Series.Title.SOF",
                    "seriesRemark": "i18N.Series.Remark.SOF",
                    "questionList":[
                        {
                            "questionId": "SCSSKOK-SJUC-SMKMCKS-XJSGXM",
                            "questionOrder": 1,
                            "questionTitle": "i18N.Question.Title.Q1",
                            "questionType": "R",
                            "questionLevel": 1,
                            "questionIsRequired": true,
                            "questionOptions": [
                                {
                                    "optionId": "CSKOKWMJIW-SWWHUOIWS-WNNLKXSW",
                                    "optionText": "i18N.Question.Q1.Option.YES",
                                    "optionScore": 1,
                                    "optionDescription": null
                                },
                                {
                                    "optionId": "KOSJIW-SMLMCDWmi-WJDUIJIW-FCEI",
                                    "optionText": "i18N.Question.Q1.Option.NO",
                                    "optionScore": 0,
                                    "optionDescription": null
                                }
                           ]
                       }
                   ]
               }
          ]
      }
    
}
```

### Response Body:
```json=
{
    "httpCode": 200,
    "result": {
        "data": {
            "questionnaireId": "40623d2d-0209-41b1-8a76-b08de0807447",
            "isSuccess": "true"
        }
    }
}
```

## 5. Delete questionnarie  
POST/ {contextPath}/questionnarie/delete

刪除問券
- 根據JWT中資訊取得使用者"AreaCode"
- 將回傳accessToken（JWT）帶入呼叫API的header中

API require headers:
```javascript=
{
    "Content-Type" : 'application/json',
    "Accept" : 'application/json',
    "Authorization" : accessToken,
}
```

### Request Body:
 
| Parameter     | Required |  format  |  desc             |
| ------------- | -------- | -------- |------------------ |
| questionnaireId  | Y     | String   | 問券Id            |

```javascript=
{
    "questionnaireId": "38f70f88-aff5-44bd-abe4-a08dad46643c"
}
```

### Response Body:

| Parameter    |  format  |  desc       |
| ------------ | -------- |-------------|
| questionnaireId |  String  | 問券Id   |
| isSuccess    |  String |  是否刪除成功 |   

```json=
{
    "httpCode": 200,
    "result": {
        "data": {
            "questionnaireId": "38f70f88-aff5-44bd-abe4-a08dad46643c",
            "isSuccess": "true"
        }
    }
}
```

## 6. Get Questionnarie Answer by Id
GET/{contextPath}/questionnarie/answer/:id
取得問卷格式內容
- 根據JWT中資訊取得使用者"AreaCode"
- 將回傳accessToken（JWT）帶入呼叫API的header中

API require headers:
```javascript=
{
    "Authorization" : accessToken
}
```

param: 
```
none.
```

### Response Body:

| Parameter    |  format  |  desc       |
| ------------ | -------- |-------------|
| questionnaireId     | String   | 問卷Id     |
| questionnaireNo     | String   | 問卷代號    |
| householdMemberId | String   | 家戶成員Id  |  
| completionDate | timestamp | 填寫時間 |
| answers | String | json 答案 |
| totalScore | int | 總分數    |

```json=
{
    "questionnaireId": "38f70f88-aff5-44bd-abe4-a08dad46643c",
    "questionnaireNo": "xxxxx-0001",
    "householdMemberId": "XSHUH-SWHUHCS0-EUDEYSWJN-WDUHBUW",
    "completionDate": 1612842021000,
    "answers": [
        {
            "questionId": "SCSSKOK-SJUC-SMKMCKS-XJSGXM",
            "questionType": "S",
            "option": "CSKOKWMJIW-SWWHUOIWS-WNNLKXSW",
            "score": 3,
        },
        {
            "questionId": "CBUBWN-SWXBUWX-WNXUWBCE",
            "questionType": "F",
            "option": "最近感冒，常常流鼻水"
        }
    ],
    "totalScore": 90
}
```


## 7. Create Questionnarie Answer
POST/ {contextPath}/questionnarie/answer/create

建立問券答案給特定AreaCode
- 根據JWT中資訊取得使用者"AreaCode"
- 將回傳accessToken（JWT）帶入呼叫API的header中

API require headers:
```javascript=
{
    "Content-Type" : 'application/json',
    "Accept" : 'application/json',
    "Authorization" : accessToken,
}
```

### Request Body:
| Parameter     | Required |  format  |  desc             |
| ------------- | -------- | -------- |------------------ |
| questionnaireId | Y      | String   | 問券Id             |
| householdMemberId | Y  | String   | 家戶成員Id         |    
| answer          | Y        | Json Array   | 答案        |


```json=
{
    "questionnaireId": "38f70f88-aff5-44bd-abe4-a08dad46643c",
    "householdMemberId": "SHDUSW-SWHXIUWBXWS-WXBWBUBWS-WXNHUW",
    "answers": [
        {
            "questionId": "SCSSKOK-SJUC-SMKMCKS-XJSGXM",
            "questionType": "S",
            "option": "CSKOKWMJIW-SWWHUOIWS-WNNLKXSW",
            "score": 3,
        },
        {
            "questionId": "CBUBWN-SWXBUWX-WNXUWBCE",
            "questionType": "F",
            "option": "最近感冒，常常流鼻水"
        }
    ]
}
```

### Response Body:

| Parameter    |  format  |  desc       |
| ------------ | -------- |-------------|
| questionnaireId |  String  | 問券Id   |
| questionnaireAnswerId |  String  | 答案Id   |
| isSuccess    |  String |  是否刪除成功 |   

```json=
{
    "httpCode": 200,
    "result": {
        "data": {
            "questionnaireId": "38f70f88-aff5-44bd-abe4-a08dad46643c",
            "questionnaireAnswerId": "2893nhbc23f-023ediuiu23-d23bur2",
            "isSuccess": "true"
        }
    }
}
```






