1. 接口描述
接口请求域名: ocr.tencentcloudapi.com 。
医疗发票识别目前支持全国统一门诊发票、全国统一住院发票、以及部分地方的门诊和住院发票的识别。
默认接口请求频率限制:5次/秒。
推荐使用 API Explorer
点击调试
API Explorer 提供了在线调用、签名验证、SDK 代码生成和快速检索接口等能力。您可查看每次调用的请求内容和返回结果以及自动生成 SDK 调用示例。
2. 输入参数
以下请求参数列表仅列出了接口请求参数和部分公共参数,完整公共参数列表见 公共请求参数。
参数名称 | 必选 | 类型 | 描述 |
---|---|---|---|
Action | 是 | String | 公共参数,本接口取值:RecognizeMedicalInvoiceOCR。 |
Version | 是 | String | 公共参数,本接口取值:2018-11-19。 |
Region | 否 | String | 公共参数,此参数为可选参数。 |
ImageBase64 | 否 | String | 图片的Base64 值。 支持的文件格式:PNG、JPG、JPEG,暂不支持 GIF 格式。 支持的图片大小:所下载文件经Base64编码后不超过 7M。文件下载时间不超过 3 秒。 输入参数 ImageUrl、ImageBase64 必须提供一个,如果都提供,只使用 ImageUrl。 示例值:/9j/4AAQSkZJRg.....s97n//2Q== |
ImageUrl | 否 | String | 图片的Url 地址。 支持的文件格式:PNG、JPG、JPEG,暂不支持 GIF 格式。 支持的图片大小:所下载文件经 Base64 编码后不超过 7M。文件下载时间不超过 3 秒。 图片存储于腾讯云的 Url 可保障更高的下载速度和稳定性,建议图片存储于腾讯云。 非腾讯云存储的 Url 速度和稳定性可能受一定影响。 示例值:https://ocr-demo-1254418846.cos.ap-guangzhou.myqcloud.com/invoice/RecognizeMedicalInvoiceOCR/RecognizeMedicalInvoiceOCR1.jpg |
ReturnVertex | 否 | Boolean | 是否需要返回识别出的文本行在原图上的四点坐标,默认不返回 示例值:false |
ReturnCoord | 否 | Boolean | 是否需要返回识别出的文本行在旋转纠正之后的图像中的四点坐标,默认不返回 示例值:false |
IsPdf | 否 | Boolean | 是否开启PDF识别,默认值为true,开启后可同时支持图片和PDF的识别。 示例值:false |
PdfPageNumber | 否 | Integer | 需要识别的PDF页面的对应页码,仅支持PDF单页识别,当上传文件为PDF且IsPdf参数值为true时有效,默认值为1。 示例值:1 |
3. 输出参数
参数名称 | 类型 | 描述 |
---|---|---|
MedicalInvoiceInfos | Array of MedicalInvoiceInfo | 识别出的字段信息 |
Angle | Float | 图片旋转角度(角度制),文本的水平方向为0°,顺时针为正,逆时针为负。 示例值:0 |
RequestId | String | 唯一请求 ID,由服务端生成,每次请求都会返回(若请求因其他原因未能抵达服务端,则该次请求不会获得 RequestId)。定位问题时需要提供该次请求的 RequestId。 |
4. 示例
示例1 医疗发票识别示例
医疗发票识别示例
输入示例
POST / HTTP/1.1
Host: ocr.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: RecognizeMedicalInvoiceOCR
Version:2018-11-19
Region:ap-beijing
<公共请求参数>
{
"ImageUrl": "https://ocr-demo-1254418846.cos.ap-guangzhou.myqcloud.com/invoice/RecognizeMedicalInvoiceOCR/RecognizeMedicalInvoiceOCR1.jpg",
"ReturnVertex": true,
"ReturnCoord": true
}
输出示例
{
"Response": {
"Angle": -0.1712096631526947,
"MedicalInvoiceInfos": [
{
"MedicalInvoiceItems": [
{
"Content": "检查费",
"Coord": {
"Height": 20,
"Width": 57,
"X": 700,
"Y": 277
},
"Name": "大项名称",
"Vertex": {
"LeftBottom": {
"X": 698,
"Y": 294
},
"LeftTop": {
"X": 698,
"Y": 274
},
"RightBottom": {
"X": 755,
"Y": 294
},
"RightTop": {
"X": 755,
"Y": 274
}
}
},
{
"Content": "81.90",
"Coord": {
"Height": 17,
"Width": 50,
"X": 554,
"Y": 278
},
"Name": "大项金额",
"Vertex": {
"LeftBottom": {
"X": 552,
"Y": 292
},
"LeftTop": {
"X": 552,
"Y": 275
},
"RightBottom": {
"X": 602,
"Y": 292
},
"RightTop": {
"X": 602,
"Y": 275
}
}
}
]
},
{
"MedicalInvoiceItems": [
{
"Content": "治疗费",
"Coord": {
"Height": 20,
"Width": 57,
"X": 700,
"Y": 277
},
"Name": "大项名称",
"Vertex": {
"LeftBottom": {
"X": 698,
"Y": 294
},
"LeftTop": {
"X": 698,
"Y": 274
},
"RightBottom": {
"X": 755,
"Y": 294
},
"RightTop": {
"X": 755,
"Y": 274
}
}
},
{
"Content": "25.20",
"Coord": {
"Height": 17,
"Width": 49,
"X": 1153,
"Y": 280
},
"Name": "大项金额",
"Vertex": {
"LeftBottom": {
"X": 1151,
"Y": 294
},
"LeftTop": {
"X": 1151,
"Y": 277
},
"RightBottom": {
"X": 1200,
"Y": 294
},
"RightTop": {
"X": 1200,
"Y": 277
}
}
}
]
},
{
"MedicalInvoiceItems": [
{
"Content": "实县人民医",
"Coord": {
"Height": 23,
"Width": 104,
"X": 261,
"Y": 822
},
"Name": "收款单位",
"Vertex": {
"LeftBottom": {
"X": 259,
"Y": 842
},
"LeftTop": {
"X": 259,
"Y": 819
},
"RightBottom": {
"X": 363,
"Y": 842
},
"RightTop": {
"X": 363,
"Y": 819
}
}
}
]
},
{
"MedicalInvoiceItems": [
{
"Content": "0.00",
"Coord": {
"Height": 20,
"Width": 48,
"X": 521,
"Y": 737
},
"Name": "个人自费",
"Vertex": {
"LeftBottom": {
"X": 519,
"Y": 754
},
"LeftTop": {
"X": 519,
"Y": 734
},
"RightBottom": {
"X": 567,
"Y": 754
},
"RightTop": {
"X": 567,
"Y": 734
}
}
}
]
},
{
"MedicalInvoiceItems": [
{
"Content": "54.81",
"Coord": {
"Height": 18,
"Width": 53,
"X": 225,
"Y": 737
},
"Name": "个人自付",
"Vertex": {
"LeftBottom": {
"X": 223,
"Y": 752
},
"LeftTop": {
"X": 223,
"Y": 734
},
"RightBottom": {
"X": 276,
"Y": 752
},
"RightTop": {
"X": 276,
"Y": 734
}
}
}
]
},
{
"MedicalInvoiceItems": [
{
"Content": "0.00",
"Coord": {
"Height": 20,
"Width": 54,
"X": 831,
"Y": 697
},
"Name": "个人账户支付",
"Vertex": {
"LeftBottom": {
"X": 829,
"Y": 714
},
"LeftTop": {
"X": 829,
"Y": 694
},
"RightBottom": {
"X": 883,
"Y": 714
},
"RightTop": {
"X": 883,
"Y": 694
}
}
}
]
},
{
"MedicalInvoiceItems": [
{
"Content": "0.00",
"Coord": {
"Height": 20,
"Width": 50,
"X": 521,
"Y": 695
},
"Name": "其他支付",
"Vertex": {
"LeftBottom": {
"X": 519,
"Y": 712
},
"LeftTop": {
"X": 519,
"Y": 692
},
"RightBottom": {
"X": 569,
"Y": 712
},
"RightTop": {
"X": 569,
"Y": 692
}
}
}
]
},
{
"MedicalInvoiceItems": [
{
"Content": "52.29",
"Coord": {
"Height": 19,
"Width": 58,
"X": 293,
"Y": 695
},
"Name": "医保统筹基金支付",
"Vertex": {
"LeftBottom": {
"X": 291,
"Y": 711
},
"LeftTop": {
"X": 291,
"Y": 692
},
"RightBottom": {
"X": 349,
"Y": 711
},
"RightTop": {
"X": 349,
"Y": 692
}
}
}
]
},
{
"MedicalInvoiceItems": [
{
"Content": "贵州省医保",
"Coord": {
"Height": 21,
"Width": 110,
"X": 518,
"Y": 647
},
"Name": "医保类型",
"Vertex": {
"LeftBottom": {
"X": 516,
"Y": 665
},
"LeftTop": {
"X": 516,
"Y": 644
},
"RightBottom": {
"X": 626,
"Y": 665
},
"RightTop": {
"X": 626,
"Y": 644
}
}
}
]
},
{
"MedicalInvoiceItems": [
{
"Content": "非营利综合二级医院",
"Coord": {
"Height": 21,
"Width": 162,
"X": 266,
"Y": 647
},
"Name": "医疗机构类型",
"Vertex": {
"LeftBottom": {
"X": 264,
"Y": 665
},
"LeftTop": {
"X": 264,
"Y": 644
},
"RightBottom": {
"X": 426,
"Y": 665
},
"RightTop": {
"X": 426,
"Y": 644
}
}
}
]
},
{
"MedicalInvoiceItems": [
{
"Content": "107.10",
"Coord": {
"Height": 22,
"Width": 54,
"X": 839,
"Y": 562
},
"Name": "总金额",
"Vertex": {
"LeftBottom": {
"X": 837,
"Y": 581
},
"LeftTop": {
"X": 837,
"Y": 559
},
"RightBottom": {
"X": 891,
"Y": 581
},
"RightTop": {
"X": 891,
"Y": 559
}
}
}
]
},
{
"MedicalInvoiceItems": [
{
"Content": "壹佰零柒元壹角",
"Coord": {
"Height": 24,
"Width": 140,
"X": 245,
"Y": 559
},
"Name": "总金额大写",
"Vertex": {
"LeftBottom": {
"X": 243,
"Y": 580
},
"LeftTop": {
"X": 243,
"Y": 556
},
"RightBottom": {
"X": 383,
"Y": 580
},
"RightTop": {
"X": 383,
"Y": 556
}
}
}
]
},
{
"MedicalInvoiceItems": [
{
"Content": "2022-03-11",
"Coord": {
"Height": 22,
"Width": 93,
"X": 986,
"Y": 201
},
"Name": "开票日期",
"Vertex": {
"LeftBottom": {
"X": 984,
"Y": 220
},
"LeftTop": {
"X": 984,
"Y": 198
},
"RightBottom": {
"X": 1077,
"Y": 220
},
"RightTop": {
"X": 1077,
"Y": 198
}
}
}
]
},
{
"MedicalInvoiceItems": [
{
"Content": "1",
"Coord": {
"Height": 20,
"Width": 20,
"X": 1166,
"Y": 826
},
"Name": "收款人",
"Vertex": {
"LeftBottom": {
"X": 1164,
"Y": 843
},
"LeftTop": {
"X": 1164,
"Y": 823
},
"RightBottom": {
"X": 1184,
"Y": 843
},
"RightTop": {
"X": 1184,
"Y": 823
}
}
}
]
},
{
"MedicalInvoiceItems": [
{
"Content": "2022-03-11",
"Coord": {
"Height": 17,
"Width": 77,
"X": 1115,
"Y": 603
},
"Name": "就诊日期",
"Vertex": {
"LeftBottom": {
"X": 1113,
"Y": 617
},
"LeftTop": {
"X": 1113,
"Y": 600
},
"RightBottom": {
"X": 1190,
"Y": 617
},
"RightTop": {
"X": 1190,
"Y": 600
}
}
}
]
},
{
"MedicalInvoiceItems": [
{
"Content": "54.81",
"Coord": {
"Height": 20,
"Width": 56,
"X": 1146,
"Y": 697
},
"Name": "个人现金支付",
"Vertex": {
"LeftBottom": {
"X": 1144,
"Y": 714
},
"LeftTop": {
"X": 1144,
"Y": 694
},
"RightBottom": {
"X": 1200,
"Y": 714
},
"RightTop": {
"X": 1200,
"Y": 694
}
}
}
]
},
{
"MedicalInvoiceItems": [
{
"Content": "女",
"Coord": {
"Height": 18,
"Width": 21,
"X": 1075,
"Y": 651
},
"Name": "性别",
"Vertex": {
"LeftBottom": {
"X": 1073,
"Y": 666
},
"LeftTop": {
"X": 1073,
"Y": 648
},
"RightBottom": {
"X": 1094,
"Y": 666
},
"RightTop": {
"X": 1094,
"Y": 648
}
}
}
]
},
{
"MedicalInvoiceItems": [
{
"Content": "贵州省",
"Coord": {
"Height": 0,
"Width": 0,
"X": 0,
"Y": 0
},
"Name": "发票属地",
"Vertex": null
}
]
},
{
"MedicalInvoiceItems": [
{
"Content": "门诊发票",
"Coord": {
"Height": 0,
"Width": 0,
"X": 0,
"Y": 0
},
"Name": "发票类型",
"Vertex": null
}
]
},
{
"MedicalInvoiceItems": [
{
"Content": "贵州省医疗门诊收费票据(电子)",
"Coord": {
"Height": 38,
"Width": 556,
"X": 407,
"Y": 47
},
"Name": "发票名称",
"Vertex": {
"LeftBottom": {
"X": 405,
"Y": 82
},
"LeftTop": {
"X": 405,
"Y": 44
},
"RightBottom": {
"X": 961,
"Y": 82
},
"RightTop": {
"X": 961,
"Y": 44
}
}
}
]
}
],
"RequestId": "a02d7a4d-3458-4139-828c-7add732d5c24"
}
}
5. 开发者资源
腾讯云 API 平台
腾讯云 API 平台 是综合 API 文档、错误码、API Explorer 及 SDK 等资源的统一查询平台,方便您从同一入口查询及使用腾讯云提供的所有 API 服务。
API Inspector
用户可通过 API Inspector 查看控制台每一步操作关联的 API 调用情况,并自动生成各语言版本的 API 代码,也可前往 API Explorer 进行在线调试。
SDK
云 API 3.0 提供了配套的开发工具集(SDK),支持多种编程语言,能更方便的调用 API。
- Tencent Cloud SDK 3.0 for Python: GitHub Gitee
- Tencent Cloud SDK 3.0 for Java: GitHub Gitee
- Tencent Cloud SDK 3.0 for PHP: GitHub Gitee
- Tencent Cloud SDK 3.0 for Go: GitHub Gitee
- Tencent Cloud SDK 3.0 for Node.js: GitHub Gitee
- Tencent Cloud SDK 3.0 for .NET: GitHub Gitee
- Tencent Cloud SDK 3.0 for C++: GitHub Gitee
- Tencent Cloud SDK 3.0 for Ruby: GitHub Gitee
命令行工具
6. 错误码
以下仅列出了接口业务逻辑相关的错误码,其他错误码详见 公共错误码。
错误码 | 描述 |
---|---|
FailedOperation.DownLoadError | 文件下载失败。 |
FailedOperation.EmptyImageError | 图片内容为空。 |
FailedOperation.EngineRecognizeTimeout | 引擎识别超时。 |
FailedOperation.ImageDecodeFailed | 图片解码失败。 |
FailedOperation.OcrFailed | OCR识别失败。 |
FailedOperation.UnKnowError | 未知错误。 |
FailedOperation.UnOpenError | 服务未开通。 |
InvalidParameterValue.InvalidParameterValueLimit | 参数值错误。 |
LimitExceeded.TooLargeFileError | 文件内容太大。 |
ResourceUnavailable.InArrears | 账号已欠费。 |
ResourceUnavailable.ResourcePackageRunOut | 账号资源包耗尽。 |
ResourcesSoldOut.ChargeStatusException | 计费状态异常。 |