Skip to main content

Hospital Invoice

API Documentation for Hospital Invoice

Response Definition

HTTP StatusCodeMessageDescription
200--Document information extraction successfully.
206partial_contentPartial_contentThe API was unable to retrieve information on some images or pages when multiple inputs are submitted.
400bad_requestBad RequestNot a valid base64 image request (must be .jpg, .jpeg, .png, .pdf), invalid size, or malformed schema.
500internal_server_errorInternal server errorSome errors occurred inside the server.

Extract invoice information

POST https://api.aigen.online/aiscript/hospital-invoice/v2

Request Body Parameters

KeyTypeDescription
image*StringThe encoded images are provided in base64 format (.jpg, .jpeg, .png, or .pdf).

Response Keys

KeyTypeDescription
statusstrThe summary status.
errorList[dict]The list of errors that occurred while extracting information for each image or page.
dataList[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.

KeyField schemaDescription
admissionNumberObject information V2Patient admission number.
clientNameObject information V2Patient name.
date_of_admissionObject information V2Admission date.
date_of_dischargeObject information V2Discharge date.
discountObject information V2Invoice discount.
grand_totalObject information V2Invoice grand total.
hospitalNameObject information V2Hospital name.
hospitalNumberObject information V2Hospital number.
invoice_noObject information V2Invoice number.
net_totalObject information V2Invoice net total.
simbObject information V2Simb topic outside the table.
time_of_admissionObject information V2Admission time.
time_of_dischargeObject information V2Discharge time.
totalObject information V2Invoice total.
table_dataList[List[TableCellV2]]Table content extracted from the invoice. Returns an empty list if missing.
Object information V2 schema
KeyTypeDescription
valuestrThe string value of the field.
datetime_isostrISO 8601 representation of the detected datetime, if applicable.
bboxesList[List[List[int]]]OCR bounding boxes in the source documents.
bboxes_normList[List[List[float]]]OCR bounding boxes normalized to the [0, 1] range.
confidencefloatOCR confidence score for the extracted value.
TableCellV2 schema
KeyTypeDescription
valuestrThe string value contained in the table cell.
rowintRow index of the cell in the table.
columnintColumn index of the cell in the table.
bboxesOptional(List[List[List[int]]])OCR bounding boxes for the cell, when available.
bboxes_normOptional(List[List[List[float]]])Normalized OCR bounding boxes for the cell, when available.
confidencefloatOCR confidence score for the cell 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
}
]
]
}
]
}
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())