Hospital Invoice
API Documentation for Hospital Invoice
Response Definition
| HTTP Status | Code | Message | Description |
|---|---|---|---|
| 200 | - | - | Document information extraction successfully. |
| 206 | partial_content | Partial_content | The API was unable to retrieve information on some images or pages when multiple inputs are submitted. |
| 400 | bad_request | Bad Request | Not a valid base64 image request (must be .jpg, .jpeg, .png, .pdf), invalid size, or malformed schema. |
| 500 | internal_server_error | Internal server error | Some errors occurred inside the server. |
Extract invoice information
POST https://api.aigen.online/aiscript/hospital-invoice/v2
Request Body Parameters
| Key | Type | Description |
|---|---|---|
| image* | String | The encoded images are provided in base64 format (.jpg, .jpeg, .png, or .pdf). |
Response Keys
| Key | Type | Description |
|---|---|---|
| status | str | The summary status. |
| error | List[dict] | The list of errors that occurred while extracting information for each image or page. |
| data | List[dict] | The response payload for each requested page or image. |
Response Data Keys
All object-like fields below use the Object information V2 schema and return an empty dictionary when undetected, unless otherwise noted.
| Key | Field schema | Description |
|---|---|---|
| admissionNumber | Object information V2 | Patient admission number. |
| clientName | Object information V2 | Patient name. |
| date_of_admission | Object information V2 | Admission date. |
| date_of_discharge | Object information V2 | Discharge date. |
| discount | Object information V2 | Invoice discount. |
| grand_total | Object information V2 | Invoice grand total. |
| hospitalName | Object information V2 | Hospital name. |
| hospitalNumber | Object information V2 | Hospital number. |
| invoice_no | Object information V2 | Invoice number. |
| net_total | Object information V2 | Invoice net total. |
| simb | Object information V2 | Simb topic outside the table. |
| time_of_admission | Object information V2 | Admission time. |
| time_of_discharge | Object information V2 | Discharge time. |
| total | Object information V2 | Invoice total. |
| table_data | List[List[TableCellV2]] | Table content extracted from the invoice. Returns an empty list if missing. |
Object information V2 schema
| Key | Type | Description |
|---|---|---|
| value | str | The string value of the field. |
| datetime_iso | str | ISO 8601 representation of the detected datetime, if applicable. |
| bboxes | List[List[List[int]]] | OCR bounding boxes in the source documents. |
| bboxes_norm | List[List[List[float]]] | OCR bounding boxes normalized to the [0, 1] range. |
| confidence | float | OCR confidence score for the extracted value. |
TableCellV2 schema
| Key | Type | Description |
|---|---|---|
| value | str | The string value contained in the table cell. |
| row | int | Row index of the cell in the table. |
| column | int | Column index of the cell in the table. |
| bboxes | Optional(List[List[List[int]]]) | OCR bounding boxes for the cell, when available. |
| bboxes_norm | Optional(List[List[List[float]]]) | Normalized OCR bounding boxes for the cell, when available. |
| confidence | float | OCR confidence score for the cell content. |
- 200: OK Successful response
- 400: Bad Request
- 206: Partial Content Partial content
{
"status": "success",
"error": [],
"data": [
{
"admissionNumber": {
"value": "[REDACTED]",
"datetime_iso": null,
"confidence": 0.9897,
"bboxes": [
[
[1252, 247],
[1386, 247],
[1386, 280],
[1252, 280]
]
],
"bboxes_norm": [
[
[0.7574107683000605, 0.10560068405301411],
[0.838475499092559, 0.10560068405301411],
[0.838475499092559, 0.11970927746900385],
[0.7574107683000605, 0.11970927746900385]
]
]
},
"clientName": {
"value": "[REDACTED]",
"datetime_iso": null,
"confidence": 0.989,
"bboxes": [
[
[130, 231],
[386, 231],
[386, 276],
[130, 276]
]
],
"bboxes_norm": [
[
[0.07864488808227466, 0.09876015391192818],
[0.2335148215366001, 0.09876015391192818],
[0.2335148215366001, 0.11799914493373237],
[0.07864488808227466, 0.11799914493373237]
]
]
},
"date_of_admission": {
"value": "[REDACTED]",
"datetime_iso": null,
"confidence": 0.9777,
"bboxes": [
[
[128, 318],
[404, 318],
[404, 350],
[128, 350]
]
],
"bboxes_norm": [
[
[0.07743496672716274, 0.13595553655408293],
[0.24440411373260737, 0.13595553655408293],
[0.24440411373260737, 0.1496365968362548],
[0.07743496672716274, 0.1496365968362548]
]
]
},
"date_of_discharge": {
"value": "[REDACTED]",
"datetime_iso": null,
"confidence": 0.9836,
"bboxes": [
[
[659, 322],
[928, 322],
[928, 353],
[659, 353]
]
],
"bboxes_norm": [
[
[0.3986690865093769, 0.13766566908935443],
[0.5614035087719298, 0.13766566908935443],
[0.5614035087719298, 0.15091919623770841],
[0.3986690865093769, 0.15091919623770841]
]
]
},
"discount": {},
"grand_total": {
"value": "[REDACTED]",
"datetime_iso": null,
"confidence": 0.9953,
"bboxes": [
[
[1186, 1010],
[1272, 1010],
[1272, 1043],
[1186, 1043]
]
],
"bboxes_norm": [
[
[0.7174833635813672, 0.4318084651560496],
[0.7695099818511797, 0.4318084651560496],
[0.7695099818511797, 0.44591705857203934],
[0.7174833635813672, 0.44591705857203934]
]
]
},
"hospitalName": {
"value": "[REDACTED]",
"datetime_iso": null,
"confidence": 0.98974609375,
"bboxes": [
[
[664, 128],
[930, 128],
[930, 177],
[664, 177]
]
],
"bboxes_norm": [
[
[0.4016938898971567, 0.05472424112868747],
[0.5626134301270418, 0.05472424112868747],
[0.5626134301270418, 0.07567336468576315],
[0.4016938898971567, 0.07567336468576315]
]
]
},
"hospitalNumber": {
"value": "[REDACTED]",
"datetime_iso": null,
"confidence": 0.99365234375,
"bboxes": [
[
[727, 243],
[859, 243],
[859, 280],
[727, 280]
]
],
"bboxes_norm": [
[
[0.4398064125831821, 0.10389055151774262],
[0.5196612220205686, 0.10389055151774262],
[0.5196612220205686, 0.11970927746900385],
[0.4398064125831821, 0.11970927746900385]
]
]
},
"invoice_no": {},
"net_total": {},
"simb": {
"value": "[REDACTED]",
"datetime_iso": null,
"confidence": 0.9774,
"bboxes": [
[
[1120, 397],
[1403, 397],
[1403, 428],
[1120, 428]
]
],
"bboxes_norm": [
[
[0.677555958862674, 0.16973065412569474],
[0.8487598306110102, 0.16973065412569474],
[0.8487598306110102, 0.18298418127404875],
[0.677555958862674, 0.18298418127404875]
]
]
},
"time_of_admission": {
"value": "[REDACTED]",
"datetime_iso": null,
"confidence": 0.9746,
"bboxes": [
[
[128, 318],
[404, 318],
[404, 350],
[128, 350]
]
],
"bboxes_norm": [
[
[0.07743496672716274, 0.13595553655408293],
[0.24440411373260737, 0.13595553655408293],
[0.24440411373260737, 0.1496365968362548],
[0.07743496672716274, 0.1496365968362548]
]
]
},
"time_of_discharge": {
"value": "[REDACTED]",
"datetime_iso": null,
"confidence": 0.9778,
"bboxes": [
[
[659, 322],
[928, 322],
[928, 353],
[659, 353]
]
],
"bboxes_norm": [
[
[0.3986690865093769, 0.13766566908935443],
[0.5614035087719298, 0.13766566908935443],
[0.5614035087719298, 0.15091919623770841],
[0.3986690865093769, 0.15091919623770841]
]
]
},
"total": {},
"table_data": [
[
{
"row": 0,
"column": 0,
"value": "DATETIME",
"confidence": 0.99853515625,
"bboxes": [
[
[87, 24],
[174, 26],
[173, 55],
[86, 53]
]
],
"bboxes_norm": [
[
[0.0729, 0.0397],
[0.1459, 0.043],
[0.145, 0.0909],
[0.0721, 0.0876]
]
]
},
{
"row": 0,
"column": 1,
"value": "CODE",
"confidence": 0.99853515625,
"bboxes": [
[
[262, 26],
[314, 26],
[314, 56],
[262, 56]
]
],
"bboxes_norm": [
[
[0.2196, 0.043],
[0.2632, 0.043],
[0.2632, 0.0926],
[0.2196, 0.0926]
]
]
},
{
"row": 0,
"column": 2,
"value": "NAME",
"confidence": 0.9990234375,
"bboxes": [
[
[525, 28],
[583, 30],
[581, 57],
[524, 54]
]
],
"bboxes_norm": [
[
[0.4401, 0.0463],
[0.4887, 0.0496],
[0.487, 0.0942],
[0.4392, 0.0893]
]
]
},
{
"row": 0,
"column": 3,
"value": "QUANTITY",
"confidence": 0.99853515625,
"bboxes": [
[
[781, 28],
[858, 28],
[858, 57],
[781, 57]
]
],
"bboxes_norm": [
[
[0.6547, 0.0463],
[0.7192, 0.0463],
[0.7192, 0.0942],
[0.6547, 0.0942]
]
]
},
{
"row": 0,
"column": 4,
"value": "PRICE",
"confidence": 0.99658203125,
"bboxes": [
[
[926, 29],
[974, 29],
[974, 57],
[926, 57]
]
],
"bboxes_norm": [
[
[0.7762, 0.0479],
[0.8164, 0.0479],
[0.8164, 0.0942],
[0.7762, 0.0942]
]
]
},
{
"row": 0,
"column": 5,
"value": "AMOUNT",
"confidence": 0.99853515625,
"bboxes": [
[
[1057, 30],
[1132, 32],
[1131, 58],
[1056, 55]
]
],
"bboxes_norm": [
[
[0.886, 0.0496],
[0.9489, 0.0529],
[0.948, 0.0959],
[0.8852, 0.0909]
]
]
},
{
"row": 1,
"column": 0,
"value": "",
"confidence": 0.0,
"bboxes": null,
"bboxes_norm": null
},
{
"row": 1,
"column": 1,
"value": "",
"confidence": 0.0,
"bboxes": null,
"bboxes_norm": null
},
{
"row": 1,
"column": 2,
"value": "[REDACTED-ITEM]",
"confidence": 0.9833984375,
"bboxes": [
[
[346, 77],
[585, 77],
[585, 103],
[346, 103]
]
],
"bboxes_norm": [
[
[0.29, 0.1273],
[0.4904, 0.1273],
[0.4904, 0.1702],
[0.29, 0.1702]
]
]
},
{
"row": 1,
"column": 3,
"value": "",
"confidence": 0.0,
"bboxes": null,
"bboxes_norm": null
},
{
"row": 1,
"column": 4,
"value": "",
"confidence": 0.0,
"bboxes": null,
"bboxes_norm": null
},
{
"row": 1,
"column": 5,
"value": "",
"confidence": 0.0,
"bboxes": null,
"bboxes_norm": null
}
]
]
}
]
}
{
"status": "error",
"error": [
{
"object": "error",
"code": "can_not_extract_data",
"message": "Page 1 : can not extract data"
}
],
"data": null
}
{
"status": "error",
"error": [
{
"object": "error",
"code": "can_not_extract_data",
"message": "Page 2 : can not extract data"
}
],
"data": [
{
"admissionNumber": {
"value": "[REDACTED]",
"datetime_iso": null,
"confidence": 0.9922,
"bboxes": [
[
[1249, 239],
[1377, 239],
[1377, 270],
[1249, 270]
]
],
"bboxes_norm": [
[
[0.7347058823529412, 0.10863636363636364],
[0.81, 0.10863636363636364],
[0.81, 0.12272727272727273],
[0.7347058823529412, 0.12272727272727273]
]
]
},
"clientName": {
"value": "[REDACTED]",
"datetime_iso": null,
"confidence": 0.9919,
"bboxes": [
[
[192, 220],
[436, 220],
[436, 264],
[192, 264]
]
],
"bboxes_norm": [
[
[0.11294117647058824, 0.1],
[0.2564705882352941, 0.1],
[0.2564705882352941, 0.12],
[0.11294117647058824, 0.12]
]
]
},
"date_of_admission": {
"value": "[REDACTED]",
"datetime_iso": null,
"confidence": 0.9816,
"bboxes": [
[
[193, 301],
[453, 301],
[453, 332],
[193, 332]
]
],
"bboxes_norm": [
[
[0.11352941176470588, 0.1368181818181818],
[0.2664705882352941, 0.1368181818181818],
[0.2664705882352941, 0.1509090909090909],
[0.11352941176470588, 0.1509090909090909]
]
]
},
"date_of_discharge": {
"value": "[REDACTED]",
"datetime_iso": null,
"confidence": 0.9747,
"bboxes": [
[
[697, 308],
[945, 308],
[945, 334],
[697, 334]
]
],
"bboxes_norm": [
[
[0.41, 0.14],
[0.5558823529411765, 0.14],
[0.5558823529411765, 0.15181818181818182],
[0.41, 0.15181818181818182]
]
]
},
"discount": {},
"grand_total": {
"value": "[REDACTED]",
"datetime_iso": null,
"confidence": 0.9943,
"bboxes": [
[
[1188, 952],
[1269, 952],
[1269, 983],
[1188, 983]
]
],
"bboxes_norm": [
[
[0.6988235294117647, 0.43272727272727274],
[0.7464705882352941, 0.43272727272727274],
[0.7464705882352941, 0.44681818181818184],
[0.6988235294117647, 0.44681818181818184]
]
]
},
"hospitalName": {
"value": "[REDACTED]",
"datetime_iso": null,
"confidence": 0.98779296875,
"bboxes": [
[
[697, 127],
[948, 127],
[948, 171],
[697, 171]
]
],
"bboxes_norm": [
[
[0.41, 0.057727272727272724],
[0.5576470588235294, 0.057727272727272724],
[0.5576470588235294, 0.07772727272727273],
[0.41, 0.07772727272727273]
]
]
},
"hospitalNumber": {
"value": "[REDACTED]",
"datetime_iso": null,
"confidence": 0.990234375,
"bboxes": [
[
[756, 231],
[884, 231],
[884, 266],
[756, 266]
]
],
"bboxes_norm": [
[
[0.4447058823529412, 0.105],
[0.52, 0.105],
[0.52, 0.12090909090909091],
[0.4447058823529412, 0.12090909090909091]
]
]
},
"invoice_no": {},
"net_total": {},
"simb": {
"value": "[REDACTED]",
"datetime_iso": null,
"confidence": 0.974,
"bboxes": [
[
[1125, 376],
[1388, 376],
[1388, 407],
[1125, 407]
]
],
"bboxes_norm": [
[
[0.6617647058823529, 0.1709090909090909],
[0.8164705882352942, 0.1709090909090909],
[0.8164705882352942, 0.185],
[0.6617647058823529, 0.185]
]
]
},
"time_of_admission": {
"value": "[REDACTED]",
"datetime_iso": null,
"confidence": 0.9788,
"bboxes": [
[
[193, 301],
[453, 301],
[453, 332],
[193, 332]
]
],
"bboxes_norm": [
[
[0.11352941176470588, 0.1368181818181818],
[0.2664705882352941, 0.1368181818181818],
[0.2664705882352941, 0.1509090909090909],
[0.11352941176470588, 0.1509090909090909]
]
]
},
"time_of_discharge": {
"value": "[REDACTED]",
"datetime_iso": null,
"confidence": 0.9679,
"bboxes": [
[
[697, 308],
[945, 308],
[945, 334],
[697, 334]
]
],
"bboxes_norm": [
[
[0.41, 0.14],
[0.5558823529411765, 0.14],
[0.5558823529411765, 0.15181818181818182],
[0.41, 0.15181818181818182]
]
]
},
"total": {},
"table_data": [
[
{
"row": 0,
"column": 0,
"value": "DATETIME",
"confidence": 0.9990234375,
"bboxes": [
[
[88, 26],
[170, 26],
[170, 54],
[88, 54]
]
],
"bboxes_norm": [
[
[0.0781, 0.0452],
[0.1508, 0.0452],
[0.1508, 0.0939],
[0.0781, 0.0939]
]
]
},
{
"row": 0,
"column": 1,
"value": "CODE",
"confidence": 0.9990234375,
"bboxes": [
[
[250, 26],
[302, 26],
[302, 56],
[250, 56]
]
],
"bboxes_norm": [
[
[0.2218, 0.0452],
[0.268, 0.0452],
[0.268, 0.0974],
[0.2218, 0.0974]
]
]
},
{
"row": 0,
"column": 2,
"value": "NAME",
"confidence": 0.99853515625,
"bboxes": [
[
[499, 29],
[554, 29],
[554, 55],
[499, 55]
]
],
"bboxes_norm": [
[
[0.4428, 0.0504],
[0.4916, 0.0504],
[0.4916, 0.0957],
[0.4428, 0.0957]
]
]
},
{
"row": 0,
"column": 3,
"value": "QUANTITY",
"confidence": 0.9990234375,
"bboxes": [
[
[740, 31],
[812, 31],
[812, 57],
[740, 57]
]
],
"bboxes_norm": [
[
[0.6566, 0.0539],
[0.7205, 0.0539],
[0.7205, 0.0991],
[0.6566, 0.0991]
]
]
},
{
"row": 0,
"column": 4,
"value": "PRICE",
"confidence": 0.9990234375,
"bboxes": [
[
[876, 27],
[924, 32],
[921, 59],
[874, 54]
]
],
"bboxes_norm": [
[
[0.7773, 0.047],
[0.8199, 0.0557],
[0.8172, 0.1026],
[0.7755, 0.0939]
]
]
},
{
"row": 0,
"column": 5,
"value": "AMOUNT",
"confidence": 0.99853515625,
"bboxes": [
[
[999, 32],
[1070, 32],
[1070, 57],
[999, 57]
]
],
"bboxes_norm": [
[
[0.8864, 0.0557],
[0.9494, 0.0557],
[0.9494, 0.0991],
[0.8864, 0.0991]
]
]
},
{
"row": 1,
"column": 0,
"value": "",
"confidence": 0.0,
"bboxes": null,
"bboxes_norm": null
},
{
"row": 1,
"column": 1,
"value": "",
"confidence": 0.0,
"bboxes": null,
"bboxes_norm": null
},
{
"row": 1,
"column": 2,
"value": "[REDACTED-ITEM]",
"confidence": 0.97998046875,
"bboxes": [
[
[331, 76],
[556, 76],
[556, 100],
[331, 100]
]
],
"bboxes_norm": [
[
[0.2937, 0.1322],
[0.4933, 0.1322],
[0.4933, 0.1739],
[0.2937, 0.1739]
]
]
},
{
"row": 1,
"column": 3,
"value": "",
"confidence": 0.0,
"bboxes": null,
"bboxes_norm": null
},
{
"row": 1,
"column": 4,
"value": "",
"confidence": 0.0,
"bboxes": null,
"bboxes_norm": null
},
{
"row": 1,
"column": 5,
"value": "",
"confidence": 0.0,
"bboxes": null,
"bboxes_norm": null
}
]
]
},
{}
]
}
- Python
- Nodejs
- PHP
- CURL
import requests
api = "https://api.aigen.online/aiscript/hospital-invoice/v2"
headers = {"x-aigen-key": "<key>"}
data = {
"image": "base64_image"
}
res = requests.post(api, json=data, headers=headers)
print(res.json())
const axios = require("axios");
const api = "https://api.aigen.online/aiscript/hospital-invoice/v2";
const headers = { "x-aigen-key": "" };
const data = {
image: "<base64_string>",
};
axios
.post(api, data, { headers: headers })
.then((res) => {
console.log(res.data);
})
.catch((err) => {
console.error(err.response.data);
});
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.aigen.online/aiscript/hospital-invoice/v2',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"image": "<base64_string>",
"option" : {}
}',
CURLOPT_HTTPHEADER => array(
'X-AIGEN-KEY: <aigen-key>',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
curl --location 'https://api.aigen.online/aiscript/hospital-invoice/v2' \
--header 'X-AIGEN-KEY: <aigen-key>' \
--header 'Content-Type: application/json' \
--data '{
"image": "<base64_string>"
}'