# 樂晴繳費機API
:::info
:bulb: **串接IP:** http://<serverip>:7123
:::
# Update
## 2021.8.5
* 新增 API `/pay/fee` response欄位欄位 `"prescription"`
## 2021.4.16
* 新增 API `/pay/fee` response欄位欄位 `"linpre"` 、 `"oe"`
## 2021.3.19
* 拿掉 API `/pay/regpay` & `/pay/medical`
* 新增 API `/pay/fee`
* 更改 API`/pay/result` request欄位 `type`值為 `"regpay"` 或 `"oepay"`
## 2021.3.18
* 拿掉 API `/pay/regpay` response欄位 `cussn`
* 更改 API`/pay/medical` response欄位,新增健保收據欄位
## 2021.3.10
* 更改 API`/pay/result` request欄位 `payment_status` 型態為`<int>`(0 or 1)
# 費用
## 取得費用(掛號費 OR 自費)
> 當患者`掛號`或`看診完畢`至繳費機插卡繳費時,繳費機需從樂晴APㄑI來取得該筆看診費用。
* **URL**
`/pay/fee`
* **Method**
`POST`
* **Header**
```Header
Content-Type: application/json
```
* **Request Body**
```JSON
{
"cusid": <string>,
"type" : <int>
}
```
::: info
cusid
: 病患身分證字號
type
: 0 取費用
: 1 取預約資料
:::
* **Success Response**
* **Status Code:** 200
**Content:**
```JSON
{
"status": "success",
"type": <string>,
"info": {
"cusname": <string>,
"cusid": <string>,
"cusbirthday": <date>, //ex. 1991-01-01
"cussex": <string>,
"ddate": <date>, //ex. 2021-03-18
"icstatus": <string>,
"ic_seqno": <string>,
"nhi_status": <string>,
"section": <string>,
"sfname": <string>,
"cusno": <string>,
"bsname": <string>,
"nhicode": <string>,
"bstel": <string>,
"bsaddr": <string>
},
// type 為 `regpay` 時 才會顯示 `prescription`
"prescription": {
"nhicode": <string>,
"cusno": <string>,
"cusname": <string>,
"cusid": <string>,
"cusbirthday": <date>,
"treatno": <int>,
"category": <int>,
"nhiname": <string>,
"division": <string>,
"ddate": <date>,
"ic_seqno": <string>,
"rx_day": <int>,
"sfname": <string>,
"bstel": <string>,
"icd10": {
"icd10": <string>,
"cname": <string>
},
"drug": [
{
"nhidrugno": <string>,
"name": <string>,
"druguse": <string>,
"day": <int>,
"totalQ": <int>
},...
]
},
"fee": {
// type 為 `regpay` 時顯示
"trpay": <int>,
"regpay": <int>,
"nhi_damt": <int>,
"nhi_partpay": <int>,
"drugsv": <int>,
"drug_partpay": <int>,
"nhi_tamt": <int>,
"surgery": <int>,
"amount": <int>,
"sum_partpay": <int>,
"discreg": <int>,
"discpart": <int>,
"balance": <int>,
"linpre": <int>
// type 為 `oepay` 時顯示
"sales": [
{
"kind": <string>,
"name": <string>,
"price": <int>,
"qty": <int>,
"amount": <int>
} ...
],
"oe": [
{
"name": <string>,
"amount": <int>
} ...
]
"balance": <int>,
"linpre": <int>
}
}
```
::: info
status
: 狀態
成功 = `"success"`
失敗 = `"failed"`
type
: 繳費類型
掛號費 = `"regpay"`
自費 = `"oepay"`
prescription:bulb:
: 處方籤
nhicode(代號)
cusno(病歷編號)
cusname(姓名)
cusid(⾝分證號)
cusbirthday(出⽣⽇期)
treatno(特定治療項目代碼)
category(案件分類)
nhiname(免部份負擔代碼及原因)
division(科別)
ddate(日期)
ic_seqno(卡號)
rx_day(給藥日份)
sfname(診治醫師)
bstel(聯絡電話)
icd10(傷病)
> icd10(病疾代碼)
> cname(傷病名稱及主要症候)
drug(藥品)
> nhidrugno(藥品代號)
> name(藥品名稱)
> druguse(用量及用法)
> day(天數)
> totalQ(總量)
info
: 收據表頭資料
cusname(姓名)
cusid(⾝分證號)
cusbirthday(出⽣⽇期)
cussex(性別)
ddate(就診⽇期)
icstatus(就診⾝份)
ic_seqno(就醫序)
nhi_status(部份負擔代碼)
section(診別)
sfname(醫師姓名)
cusno(病歷編號)
bsname(診所名稱)
nhicode(診所代號)
bstel(診所電話)
bsaddr(診所地址)
* 就醫科別 為 `牙科`。
fee
: 掛號費用 type = `regpay`
trpay(診察費)
regpay(掛號費/⼩計:掛號費)
nhi_damt(藥費)
nhi_partpay(部份負擔)
drugsv(藥事服務費)
drug_partpay(藥品部份負擔)
nhi_tamt(處置費)
surgery(⼿術費)
amount(⼩計:健保申報)
sum_partpay(部分負擔)
discreg(優待掛號費)
discpart(部分優待)
balance(應繳⾦額)
linpre(押金)
: 自費費用 type = `oepay`
sales(銷售明細)
> kind(銷貨種類 銷`S`或退`R`)
> name(名稱)
> price(單價)
> qty(數量)
> amount(合計)
oe(治療規劃明細)
> name(名稱)
> amount(合計)
balance(應繳⾦額)
* 基本部份負擔/注射費/檢驗費/復健部分負擔/檢查費/檢驗檢查/藥品/衛材/材料費/其他⾦額 都為`0`。
:::
* **Error Response**
* **Status Code:** 404
**Content:**
```JSON
{
"status": "failed",
"message": "無掛號資料或找不到該患者"
}
```
* **Status Code:** 422
**Content:**
```JSON
{
"status": "failed",
"message": "Validation failed, entered data is incorrect.",
"data": [...]
}
```
# 通用
## 回傳繳費狀態
> 當患者在繳費機繳費完成後,需回傳樂晴API繳費完成與否。
* **URL**
`/pay/result`
* **Method**
`POST`
* **Header**
```Header
Content-Type: application/json
```
* **Request Body**
```JSON
{
"cusid": <string>,
"fee": <int>,
"type": <string>,
"payment_status": <int>
}
```
::: info
cusid
: 病患身分證字號
fee
: 費用
type
: 繳費類型
掛號 = `"regpay"`
自費 = `"oepay"`
payment_status
: 繳費狀態
成功 = `1`
失敗 = `0`
:::
* **Success Response**
* **Status Code:** 200
**Content:**
```JSON
{
"status": "success",
"paysn": <int>
}
```
::: info
status
: 狀態
成功 = `"success"`
失敗 = `"failed"`
paysn
: 繳費ID
:::
* **Error Response**
* **Status Code:** 404
**Content:**
```JSON
{
"status": "failed",
"message": "無掛號資料或找不到該患者"
}
```
* **Status Code:** 422
**Content:**
```JSON
{
"status": "failed",
"message": "Validation failed, entered data is incorrect.",
"data": [...]
}
```
## 查詢快速預約
> 當患者在面板進行預約時,回傳可預約日期及時間。
* **URL**
`/quick_resv`
* **Method**
`POST`
* **Header**
```Header
Content-Type: application/json
```
* **Request Body**
```JSON
{
"start": <string>,
"end": <int>,
"room_no": <string>,
"period": <int>,
"checkin": <int>,
"Authorization": <token>
}
```
::: info
start
: 查詢開始日,YYYY-MM-DD,不可以小於明天
end
: 查詢結束日,YYYY-MM-DD,不可以超過三個月
room_no
: 診間
period
: 需要時間(分)
checkin
: 提前報到時間(分)
Authorization
: token
備註
: 看診時長 period 和 提前到診時間 checkin 是診所預設
:::
* **Success Response**
* **Status Code:** 200
**Content:**
```JSON
{
"status": "success",
"msg": "",
"data": {
"2021-12": {
"2021-12-09": [
{
"sort": "2021-12-09-15:00",
"date": "2021-12-09",
"slot": {
"key": "afternoon",
"name": "午"
},
"time": [
"15:00",
"16:00"
],
"room": {
"no": "3",
"name": "果酸"
},
"staff": {
"id": 9,
"name": "黑醫師",
"forecolor": "#000000",
"bgcolor": "#fafafa",
"sex": 0
}
}
]
}
}
```
::: info
status
: 狀態
成功 = `"success"`
失敗 = `"failed"`
msg
: 訊息
data
: 可預約日期及時間
有些資料用不到請略過
:::
* **Error Response**
* **Status Code:** 404
**Content:**
```JSON
{
"status": "failed",
"message": "新患者請至櫃檯預約"
}
```
* **Status Code:** 404
**Content:**
```JSON
{
"status": "failed",
"message": "無可預約日期及時間,請聯繫櫃檯"
}
```
* **Status Code:** 422
**Content:**
```JSON
{
"status": "failed",
"message": "Validation failed, entered data is incorrect.",
"data": [...]
}
```
## 回傳預約狀態
> 當患者在面板預約完成後,需回傳樂晴API預約狀態。
* **URL**
`/resvs`
* **Method**
`POST`
* **Header**
```Header
Content-Type: application/json
```
* **Request Body**
```JSON
{
"date": <string>,
"sch_time": <int>,
"schlen": <int>,
"checkin": <int>,
"staff_id": <int>,
"room_no": <int>,
"sch_note": <string>,
"Authorization": <token>,
}
```
::: info
date
: 預約日期
sch_time
: 預約時間
schlen
: 預約長度(分)
checkin
: 報到時間(分)
staff_id
: 約診醫師
room_no
: 診間編號
sch_note
: 預約事項
Authorization
: token
:::
* **Success Response**
* **Status Code:** 200
**Content:**
```JSON
{
"status": "success",
"message": "預約成功"
}
```
::: info
status
: 狀態
成功 = `"success"`
失敗 = `"failed"`
resvs
: 可預約日期及時間
:::
* **Error Response**
* **Status Code:** 404
**Content:**
```JSON
{
"status": "failed",
"message": "預約失敗,請聯繫櫃檯"
}
```
* **Status Code:** 422
**Content:**
```JSON
{
"status": "failed",
"message": "Validation failed, entered data is incorrect.",
"data": [...]
}
```
## 註冊新患者
> 接收新患者註冊資料。
* **URL**
`/registerNewpatient`
* **Method**
`POST`
* **Header**
```Header
Content-Type: application/json
```
* **Request Body**
```JSON
{
"cusid": <string>,
"cusname": <int>,
"cusbirthday": <int>,
"cussex": <int>,
"cusblood": <int>,
"iccardid": <int>,
"custel": <string>,
"cusofficetel": <token>,
"iccardid": <int>,
"cusjob": <int>,
"cuslv": <int>,
"cuszip": <int>,
"cusaddr": <int>,
"cusofficezip": <int>,
"cusaddr2": <int>,
"cusmob": <int>,
"cusemail": <int>,
"cusmemo": <int>,
"emergcont": <int>,
"emergcont_phone": <int>,
"emergcont_relation": <int>,
}
```
::: info
date
: 預約日期
sch_time
: 預約時間
schlen
: 預約長度(分)
checkin
: 報到時間(分)
staff_id
: 約診醫師
room_no
: 診間編號
sch_note
: 預約事項
Authorization
: token
:::
* **Success Response**
* **Status Code:** 200
**Content:**
```JSON
{
"status": "success",
"message": "預約成功"
}
```
::: info
status
: 狀態
成功 = `"success"`
失敗 = `"failed"`
resvs
: 可預約日期及時間
:::
* **Error Response**
* **Status Code:** 404
**Content:**
```JSON
{
"status": "failed",
"message": "預約失敗,請聯繫櫃檯"
}
```
* **Status Code:** 422
**Content:**
```JSON
{
"status": "failed",
"message": "Validation failed, entered data is incorrect.",
"data": [...]
}
```