Skip to content

✨ add support for Findoc V1.12, Invoices V4.10, US Healthcare Cards V1.2 #316

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions docs/extras/guide/financial_document_v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ print(result.document)
########
Document
########
:Mindee ID: f469a24d-3875-4a83-ad43-e0d5aa9da604
:Mindee ID: a80ac0ee-26f6-4e2e-988a-960b240d5ba7
:Filename: default_sample.jpg

Inference
Expand All @@ -83,7 +83,7 @@ Prediction
+---------------+--------+----------+---------------+
| Base | Code | Rate (%) | Amount |
+===============+========+==========+===============+
| | | 5.00 | 9.75 |
| 195.00 | | 5.00 | 9.75 |
+---------------+--------+----------+---------------+
:Supplier Payment Details:
:Supplier Name: JOHN SMITH
Expand Down Expand Up @@ -135,7 +135,7 @@ Page 0
+---------------+--------+----------+---------------+
| Base | Code | Rate (%) | Amount |
+===============+========+==========+===============+
| | | 5.00 | 9.75 |
| 195.00 | | 5.00 | 9.75 |
+---------------+--------+----------+---------------+
:Supplier Payment Details:
:Supplier Name: JOHN SMITH
Expand Down Expand Up @@ -341,6 +341,24 @@ print(result.document.inference.prediction.document_number.value)
print(result.document.inference.prediction.document_type.value)
```

## Document Type Extended
**document_type_extended** ([ClassificationField](#classificationfield)): Document type extended.

#### Possible values include:
- 'CREDIT NOTE'
- 'INVOICE'
- 'OTHER'
- 'OTHER_FINANCIAL'
- 'PAYSLIP'
- 'PURCHASE ORDER'
- 'QUOTE'
- 'RECEIPT'
- 'STATEMENT'

```py
print(result.document.inference.prediction.document_type_extended.value)
```

## Due Date
**due_date** ([DateField](#datefield)): The date on which the payment is due.

Expand Down
24 changes: 21 additions & 3 deletions docs/extras/guide/invoices_v4.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ print(result.document)
########
Document
########
:Mindee ID: 86b1833f-138b-4a01-8387-860204b0e631
:Mindee ID: b55db8f9-ae3b-4f05-b2f1-ec0ced5e5b70
:Filename: default_sample.jpg

Inference
Expand All @@ -82,7 +82,7 @@ Prediction
+---------------+--------+----------+---------------+
| Base | Code | Rate (%) | Amount |
+===============+========+==========+===============+
| | | 8.00 | 193.20 |
| 2145.00 | | 8.00 | 193.20 |
+---------------+--------+----------+---------------+
:Supplier Payment Details:
:Supplier Name: TURNPIKE DESIGNS
Expand Down Expand Up @@ -128,7 +128,7 @@ Page 0
+---------------+--------+----------+---------------+
| Base | Code | Rate (%) | Amount |
+===============+========+==========+===============+
| | | 8.00 | 193.20 |
| 2145.00 | | 8.00 | 193.20 |
+---------------+--------+----------+---------------+
:Supplier Payment Details:
:Supplier Name: TURNPIKE DESIGNS
Expand Down Expand Up @@ -303,6 +303,24 @@ print(result.document.inference.prediction.date.value)
print(result.document.inference.prediction.document_type.value)
```

## Document Type Extended
**document_type_extended** ([ClassificationField](#classificationfield)): Document type extended.

#### Possible values include:
- 'CREDIT NOTE'
- 'INVOICE'
- 'OTHER'
- 'OTHER_FINANCIAL'
- 'PAYSLIP'
- 'PURCHASE ORDER'
- 'QUOTE'
- 'RECEIPT'
- 'STATEMENT'

```py
print(result.document.inference.prediction.document_type_extended.value)
```

## Due Date
**due_date** ([DateField](#datefield)): The date on which the payment is due.

Expand Down
16 changes: 16 additions & 0 deletions docs/extras/guide/us_healthcare_cards_v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ A `HealthcareCardV1Copay` implements the following attributes:
* **service_fees** (`float`): The price of service.
* **service_name** (`str`): The name of service of the copay.

#### Possible values include:
- primary_care
- emergency_room
- urgent_care
- specialist
- office_visit
- prescription


# Attributes
The following fields are extracted for Healthcare Card V1:

Expand Down Expand Up @@ -194,6 +203,13 @@ print(result.document.inference.prediction.rx_bin.value)
print(result.document.inference.prediction.rx_grp.value)
```

## RX ID
**rx_id** ([StringField](#stringfield)): The ID number for prescription drug coverage.

```py
print(result.document.inference.prediction.rx_id.value)
```

## RX PCN
**rx_pcn** ([StringField](#stringfield)): The PCN number for prescription drug coverage.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


class FinancialDocumentV1Document(Prediction):
"""Financial Document API version 1.11 document data."""
"""Financial Document API version 1.12 document data."""

billing_address: StringField
"""The customer's address used for billing."""
Expand All @@ -40,6 +40,8 @@ class FinancialDocumentV1Document(Prediction):
The type of the document: INVOICE or CREDIT NOTE if it is an invoice, CREDIT CARD RECEIPT or EXPENSE
RECEIPT if it is a receipt.
"""
document_type_extended: ClassificationField
"""Document type extended."""
due_date: DateField
"""The date on which the payment is due."""
invoice_number: StringField
Expand Down Expand Up @@ -135,6 +137,10 @@ def __init__(
raw_prediction["document_type"],
page_id=page_id,
)
self.document_type_extended = ClassificationField(
raw_prediction["document_type_extended"],
page_id=page_id,
)
self.due_date = DateField(
raw_prediction["due_date"],
page_id=page_id,
Expand Down Expand Up @@ -303,6 +309,7 @@ def __str__(self) -> str:
out_str += f":Shipping Address: {self.shipping_address}\n"
out_str += f":Billing Address: {self.billing_address}\n"
out_str += f":Document Type: {self.document_type}\n"
out_str += f":Document Type Extended: {self.document_type_extended}\n"
out_str += f":Purchase Subcategory: {self.subcategory}\n"
out_str += f":Purchase Category: {self.category}\n"
out_str += f":Total Tax: {self.total_tax}\n"
Expand Down
9 changes: 8 additions & 1 deletion mindee/product/invoice/invoice_v4_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


class InvoiceV4Document(Prediction):
"""Invoice API version 4.9 document data."""
"""Invoice API version 4.10 document data."""

billing_address: StringField
"""The customer billing address."""
Expand All @@ -31,6 +31,8 @@ class InvoiceV4Document(Prediction):
"""The date the purchase was made."""
document_type: ClassificationField
"""Document type: INVOICE or CREDIT NOTE."""
document_type_extended: ClassificationField
"""Document type extended."""
due_date: DateField
"""The date on which the payment is due."""
invoice_number: StringField
Expand Down Expand Up @@ -110,6 +112,10 @@ def __init__(
raw_prediction["document_type"],
page_id=page_id,
)
self.document_type_extended = ClassificationField(
raw_prediction["document_type_extended"],
page_id=page_id,
)
self.due_date = DateField(
raw_prediction["due_date"],
page_id=page_id,
Expand Down Expand Up @@ -261,5 +267,6 @@ def __str__(self) -> str:
out_str += f":Shipping Address: {self.shipping_address}\n"
out_str += f":Billing Address: {self.billing_address}\n"
out_str += f":Document Type: {self.document_type}\n"
out_str += f":Document Type Extended: {self.document_type_extended}\n"
out_str += f":Line Items: {self._line_items_to_str()}\n"
return clean_out_string(out_str)
4 changes: 2 additions & 2 deletions mindee/product/us/healthcare_card/healthcare_card_v1_copay.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ def _table_printable_values(self) -> Dict[str, str]:
"""Return values for printing inside an RST table."""
out_dict: Dict[str, str] = {}
out_dict["service_fees"] = float_to_string(self.service_fees)
out_dict["service_name"] = format_for_display(self.service_name, None)
out_dict["service_name"] = format_for_display(self.service_name, 20)
return out_dict

def to_table_line(self) -> str:
"""Output in a format suitable for inclusion in an rST table."""
printable = self._table_printable_values()
out_str: str = f"| {printable['service_fees']:<12} | "
out_str += f"{printable['service_name']:<12} | "
out_str += f"{printable['service_name']:<20} | "
return clean_out_string(out_str)

def __str__(self) -> str:
Expand Down
13 changes: 10 additions & 3 deletions mindee/product/us/healthcare_card/healthcare_card_v1_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


class HealthcareCardV1Document(Prediction):
"""Healthcare Card API version 1.1 document data."""
"""Healthcare Card API version 1.2 document data."""

company_name: StringField
"""The name of the company that provides the healthcare plan."""
Expand All @@ -35,6 +35,8 @@ class HealthcareCardV1Document(Prediction):
"""The BIN number for prescription drug coverage."""
rx_grp: StringField
"""The group number for prescription drug coverage."""
rx_id: StringField
"""The ID number for prescription drug coverage."""
rx_pcn: StringField
"""The PCN number for prescription drug coverage."""

Expand Down Expand Up @@ -94,6 +96,10 @@ def __init__(
raw_prediction["rx_grp"],
page_id=page_id,
)
self.rx_id = StringField(
raw_prediction["rx_id"],
page_id=page_id,
)
self.rx_pcn = StringField(
raw_prediction["rx_pcn"],
page_id=page_id,
Expand All @@ -103,7 +109,7 @@ def __init__(
def _copays_separator(char: str) -> str:
out_str = " "
out_str += f"+{char * 14}"
out_str += f"+{char * 14}"
out_str += f"+{char * 22}"
return out_str + "+"

def _copays_to_str(self) -> str:
Expand All @@ -116,7 +122,7 @@ def _copays_to_str(self) -> str:
out_str = ""
out_str += f"\n{self._copays_separator('-')}\n "
out_str += " | Service Fees"
out_str += " | Service Name"
out_str += " | Service Name "
out_str += f" |\n{self._copays_separator('=')}"
out_str += f"\n {lines}"
out_str += f"\n{self._copays_separator('-')}"
Expand All @@ -134,6 +140,7 @@ def __str__(self) -> str:
out_str += f":Group Number: {self.group_number}\n"
out_str += f":Payer ID: {self.payer_id}\n"
out_str += f":RX BIN: {self.rx_bin}\n"
out_str += f":RX ID: {self.rx_id}\n"
out_str += f":RX GRP: {self.rx_grp}\n"
out_str += f":RX PCN: {self.rx_pcn}\n"
out_str += f":copays: {self._copays_to_str()}\n"
Expand Down
2 changes: 1 addition & 1 deletion tests/data
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,15 @@ def test_empty_doc(empty_doc: FinancialDocumentV1DocumentType):
assert prediction.locale.value is None
assert prediction.invoice_number.value is None
assert len(prediction.reference_numbers) == 0
assert prediction.billing_address.value is None
assert len(prediction.customer_company_registrations) == 0
assert prediction.customer_id.value is None
assert prediction.customer_name.value is None
assert prediction.date.value is None
assert prediction.due_date.value is None
assert prediction.document_type.value is not None
assert prediction.document_type_extended.value is not None
assert prediction.document_number.value is None
assert prediction.total_net.value is None
assert prediction.total_amount.value is None
assert len(prediction.taxes) == 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def test_empty_doc(empty_doc: HealthcareCardV1DocumentType):
assert prediction.group_number.value is None
assert prediction.payer_id.value is None
assert prediction.rx_bin.value is None
assert prediction.rx_id.value is None
assert prediction.rx_grp.value is None
assert prediction.rx_pcn.value is None
assert len(prediction.copays) == 0
Expand Down