From 1c4f77daba21773edf4ce0b80038c3c01acea8e7 Mon Sep 17 00:00:00 2001 From: sebastianMindee Date: Mon, 7 Apr 2025 10:29:45 +0200 Subject: [PATCH 1/3] :sparkles: add support for Findoc V1.12, Invoices V4.10, US Healthcare Cards V1.2 --- docs/extras/guide/financial_document_v1.md | 24 ++++++++++++++++--- docs/extras/guide/invoices_v4.md | 24 ++++++++++++++++--- docs/extras/guide/us_healthcare_cards_v1.md | 16 +++++++++++++ .../financial_document_v1_document.py | 9 ++++++- mindee/product/invoice/invoice_v4_document.py | 9 ++++++- .../healthcare_card_v1_document.py | 9 ++++++- .../test_healthcare_card_v1.py | 1 + 7 files changed, 83 insertions(+), 9 deletions(-) diff --git a/docs/extras/guide/financial_document_v1.md b/docs/extras/guide/financial_document_v1.md index fe699702..76689f1d 100644 --- a/docs/extras/guide/financial_document_v1.md +++ b/docs/extras/guide/financial_document_v1.md @@ -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 @@ -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 @@ -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 @@ -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. diff --git a/docs/extras/guide/invoices_v4.md b/docs/extras/guide/invoices_v4.md index eb87e34e..721d2579 100644 --- a/docs/extras/guide/invoices_v4.md +++ b/docs/extras/guide/invoices_v4.md @@ -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 @@ -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 @@ -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 @@ -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. diff --git a/docs/extras/guide/us_healthcare_cards_v1.md b/docs/extras/guide/us_healthcare_cards_v1.md index a0a01a05..6194fc5f 100644 --- a/docs/extras/guide/us_healthcare_cards_v1.md +++ b/docs/extras/guide/us_healthcare_cards_v1.md @@ -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: @@ -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. diff --git a/mindee/product/financial_document/financial_document_v1_document.py b/mindee/product/financial_document/financial_document_v1_document.py index fa9c95bf..7a9f9a35 100644 --- a/mindee/product/financial_document/financial_document_v1_document.py +++ b/mindee/product/financial_document/financial_document_v1_document.py @@ -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.""" @@ -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 @@ -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, @@ -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" diff --git a/mindee/product/invoice/invoice_v4_document.py b/mindee/product/invoice/invoice_v4_document.py index 3a8a2764..fc5773bc 100644 --- a/mindee/product/invoice/invoice_v4_document.py +++ b/mindee/product/invoice/invoice_v4_document.py @@ -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.""" @@ -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 @@ -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, @@ -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) diff --git a/mindee/product/us/healthcare_card/healthcare_card_v1_document.py b/mindee/product/us/healthcare_card/healthcare_card_v1_document.py index 9e73e3d9..16271060 100644 --- a/mindee/product/us/healthcare_card/healthcare_card_v1_document.py +++ b/mindee/product/us/healthcare_card/healthcare_card_v1_document.py @@ -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.""" @@ -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.""" @@ -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, @@ -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" diff --git a/tests/product/us/healthcare_card/test_healthcare_card_v1.py b/tests/product/us/healthcare_card/test_healthcare_card_v1.py index 6cc1fd10..11eacf30 100644 --- a/tests/product/us/healthcare_card/test_healthcare_card_v1.py +++ b/tests/product/us/healthcare_card/test_healthcare_card_v1.py @@ -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 From 7ff4870607727ee37f353d9141805fffd8373f39 Mon Sep 17 00:00:00 2001 From: sebastianMindee Date: Tue, 8 Apr 2025 11:43:43 +0200 Subject: [PATCH 2/3] fix findoc test + update healthcare card table display --- .../product/us/healthcare_card/healthcare_card_v1_copay.py | 4 ++-- .../us/healthcare_card/healthcare_card_v1_document.py | 4 ++-- .../financial_document/test_financial_document_v1.py | 7 +++++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/mindee/product/us/healthcare_card/healthcare_card_v1_copay.py b/mindee/product/us/healthcare_card/healthcare_card_v1_copay.py index 46da8148..1fdfdaaf 100644 --- a/mindee/product/us/healthcare_card/healthcare_card_v1_copay.py +++ b/mindee/product/us/healthcare_card/healthcare_card_v1_copay.py @@ -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: diff --git a/mindee/product/us/healthcare_card/healthcare_card_v1_document.py b/mindee/product/us/healthcare_card/healthcare_card_v1_document.py index 16271060..94487b50 100644 --- a/mindee/product/us/healthcare_card/healthcare_card_v1_document.py +++ b/mindee/product/us/healthcare_card/healthcare_card_v1_document.py @@ -109,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: @@ -122,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('-')}" diff --git a/tests/product/financial_document/test_financial_document_v1.py b/tests/product/financial_document/test_financial_document_v1.py index d7875ede..351c633f 100644 --- a/tests/product/financial_document/test_financial_document_v1.py +++ b/tests/product/financial_document/test_financial_document_v1.py @@ -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 From 3ad9bebf00bbee4bf409f7ffbfc26887427fa673 Mon Sep 17 00:00:00 2001 From: sebastianMindee Date: Tue, 8 Apr 2025 11:51:01 +0200 Subject: [PATCH 3/3] update test lib --- tests/data | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/data b/tests/data index 5de647d4..0c9cfe34 160000 --- a/tests/data +++ b/tests/data @@ -1 +1 @@ -Subproject commit 5de647d4b31fd74e2d5d94ce39134db83f0fd199 +Subproject commit 0c9cfe3416babad79b0689b40eb71917ab996beb