Skip to content

Commit 9e64312

Browse files
✨ add support for Findoc V1.12, Invoices V4.10, US Healthcare Cards V1.2 (#316)
1 parent bb9b719 commit 9e64312

File tree

10 files changed

+95
-14
lines changed

10 files changed

+95
-14
lines changed

docs/extras/guide/financial_document_v1.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ print(result.document)
5858
########
5959
Document
6060
########
61-
:Mindee ID: f469a24d-3875-4a83-ad43-e0d5aa9da604
61+
:Mindee ID: a80ac0ee-26f6-4e2e-988a-960b240d5ba7
6262
:Filename: default_sample.jpg
6363
6464
Inference
@@ -83,7 +83,7 @@ Prediction
8383
+---------------+--------+----------+---------------+
8484
| Base | Code | Rate (%) | Amount |
8585
+===============+========+==========+===============+
86-
| | | 5.00 | 9.75 |
86+
| 195.00 | | 5.00 | 9.75 |
8787
+---------------+--------+----------+---------------+
8888
:Supplier Payment Details:
8989
:Supplier Name: JOHN SMITH
@@ -135,7 +135,7 @@ Page 0
135135
+---------------+--------+----------+---------------+
136136
| Base | Code | Rate (%) | Amount |
137137
+===============+========+==========+===============+
138-
| | | 5.00 | 9.75 |
138+
| 195.00 | | 5.00 | 9.75 |
139139
+---------------+--------+----------+---------------+
140140
:Supplier Payment Details:
141141
:Supplier Name: JOHN SMITH
@@ -341,6 +341,24 @@ print(result.document.inference.prediction.document_number.value)
341341
print(result.document.inference.prediction.document_type.value)
342342
```
343343

344+
## Document Type Extended
345+
**document_type_extended** ([ClassificationField](#classificationfield)): Document type extended.
346+
347+
#### Possible values include:
348+
- 'CREDIT NOTE'
349+
- 'INVOICE'
350+
- 'OTHER'
351+
- 'OTHER_FINANCIAL'
352+
- 'PAYSLIP'
353+
- 'PURCHASE ORDER'
354+
- 'QUOTE'
355+
- 'RECEIPT'
356+
- 'STATEMENT'
357+
358+
```py
359+
print(result.document.inference.prediction.document_type_extended.value)
360+
```
361+
344362
## Due Date
345363
**due_date** ([DateField](#datefield)): The date on which the payment is due.
346364

docs/extras/guide/invoices_v4.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ print(result.document)
5858
########
5959
Document
6060
########
61-
:Mindee ID: 86b1833f-138b-4a01-8387-860204b0e631
61+
:Mindee ID: b55db8f9-ae3b-4f05-b2f1-ec0ced5e5b70
6262
:Filename: default_sample.jpg
6363
6464
Inference
@@ -82,7 +82,7 @@ Prediction
8282
+---------------+--------+----------+---------------+
8383
| Base | Code | Rate (%) | Amount |
8484
+===============+========+==========+===============+
85-
| | | 8.00 | 193.20 |
85+
| 2145.00 | | 8.00 | 193.20 |
8686
+---------------+--------+----------+---------------+
8787
:Supplier Payment Details:
8888
:Supplier Name: TURNPIKE DESIGNS
@@ -128,7 +128,7 @@ Page 0
128128
+---------------+--------+----------+---------------+
129129
| Base | Code | Rate (%) | Amount |
130130
+===============+========+==========+===============+
131-
| | | 8.00 | 193.20 |
131+
| 2145.00 | | 8.00 | 193.20 |
132132
+---------------+--------+----------+---------------+
133133
:Supplier Payment Details:
134134
:Supplier Name: TURNPIKE DESIGNS
@@ -303,6 +303,24 @@ print(result.document.inference.prediction.date.value)
303303
print(result.document.inference.prediction.document_type.value)
304304
```
305305

306+
## Document Type Extended
307+
**document_type_extended** ([ClassificationField](#classificationfield)): Document type extended.
308+
309+
#### Possible values include:
310+
- 'CREDIT NOTE'
311+
- 'INVOICE'
312+
- 'OTHER'
313+
- 'OTHER_FINANCIAL'
314+
- 'PAYSLIP'
315+
- 'PURCHASE ORDER'
316+
- 'QUOTE'
317+
- 'RECEIPT'
318+
- 'STATEMENT'
319+
320+
```py
321+
print(result.document.inference.prediction.document_type_extended.value)
322+
```
323+
306324
## Due Date
307325
**due_date** ([DateField](#datefield)): The date on which the payment is due.
308326

docs/extras/guide/us_healthcare_cards_v1.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,15 @@ A `HealthcareCardV1Copay` implements the following attributes:
112112
* **service_fees** (`float`): The price of service.
113113
* **service_name** (`str`): The name of service of the copay.
114114

115+
#### Possible values include:
116+
- primary_care
117+
- emergency_room
118+
- urgent_care
119+
- specialist
120+
- office_visit
121+
- prescription
122+
123+
115124
# Attributes
116125
The following fields are extracted for Healthcare Card V1:
117126

@@ -194,6 +203,13 @@ print(result.document.inference.prediction.rx_bin.value)
194203
print(result.document.inference.prediction.rx_grp.value)
195204
```
196205

206+
## RX ID
207+
**rx_id** ([StringField](#stringfield)): The ID number for prescription drug coverage.
208+
209+
```py
210+
print(result.document.inference.prediction.rx_id.value)
211+
```
212+
197213
## RX PCN
198214
**rx_pcn** ([StringField](#stringfield)): The PCN number for prescription drug coverage.
199215

mindee/product/financial_document/financial_document_v1_document.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818

1919
class FinancialDocumentV1Document(Prediction):
20-
"""Financial Document API version 1.11 document data."""
20+
"""Financial Document API version 1.12 document data."""
2121

2222
billing_address: StringField
2323
"""The customer's address used for billing."""
@@ -40,6 +40,8 @@ class FinancialDocumentV1Document(Prediction):
4040
The type of the document: INVOICE or CREDIT NOTE if it is an invoice, CREDIT CARD RECEIPT or EXPENSE
4141
RECEIPT if it is a receipt.
4242
"""
43+
document_type_extended: ClassificationField
44+
"""Document type extended."""
4345
due_date: DateField
4446
"""The date on which the payment is due."""
4547
invoice_number: StringField
@@ -135,6 +137,10 @@ def __init__(
135137
raw_prediction["document_type"],
136138
page_id=page_id,
137139
)
140+
self.document_type_extended = ClassificationField(
141+
raw_prediction["document_type_extended"],
142+
page_id=page_id,
143+
)
138144
self.due_date = DateField(
139145
raw_prediction["due_date"],
140146
page_id=page_id,
@@ -303,6 +309,7 @@ def __str__(self) -> str:
303309
out_str += f":Shipping Address: {self.shipping_address}\n"
304310
out_str += f":Billing Address: {self.billing_address}\n"
305311
out_str += f":Document Type: {self.document_type}\n"
312+
out_str += f":Document Type Extended: {self.document_type_extended}\n"
306313
out_str += f":Purchase Subcategory: {self.subcategory}\n"
307314
out_str += f":Purchase Category: {self.category}\n"
308315
out_str += f":Total Tax: {self.total_tax}\n"

mindee/product/invoice/invoice_v4_document.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616

1717
class InvoiceV4Document(Prediction):
18-
"""Invoice API version 4.9 document data."""
18+
"""Invoice API version 4.10 document data."""
1919

2020
billing_address: StringField
2121
"""The customer billing address."""
@@ -31,6 +31,8 @@ class InvoiceV4Document(Prediction):
3131
"""The date the purchase was made."""
3232
document_type: ClassificationField
3333
"""Document type: INVOICE or CREDIT NOTE."""
34+
document_type_extended: ClassificationField
35+
"""Document type extended."""
3436
due_date: DateField
3537
"""The date on which the payment is due."""
3638
invoice_number: StringField
@@ -110,6 +112,10 @@ def __init__(
110112
raw_prediction["document_type"],
111113
page_id=page_id,
112114
)
115+
self.document_type_extended = ClassificationField(
116+
raw_prediction["document_type_extended"],
117+
page_id=page_id,
118+
)
113119
self.due_date = DateField(
114120
raw_prediction["due_date"],
115121
page_id=page_id,
@@ -261,5 +267,6 @@ def __str__(self) -> str:
261267
out_str += f":Shipping Address: {self.shipping_address}\n"
262268
out_str += f":Billing Address: {self.billing_address}\n"
263269
out_str += f":Document Type: {self.document_type}\n"
270+
out_str += f":Document Type Extended: {self.document_type_extended}\n"
264271
out_str += f":Line Items: {self._line_items_to_str()}\n"
265272
return clean_out_string(out_str)

mindee/product/us/healthcare_card/healthcare_card_v1_copay.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ def _table_printable_values(self) -> Dict[str, str]:
5050
"""Return values for printing inside an RST table."""
5151
out_dict: Dict[str, str] = {}
5252
out_dict["service_fees"] = float_to_string(self.service_fees)
53-
out_dict["service_name"] = format_for_display(self.service_name, None)
53+
out_dict["service_name"] = format_for_display(self.service_name, 20)
5454
return out_dict
5555

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

6363
def __str__(self) -> str:

mindee/product/us/healthcare_card/healthcare_card_v1_document.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
class HealthcareCardV1Document(Prediction):
14-
"""Healthcare Card API version 1.1 document data."""
14+
"""Healthcare Card API version 1.2 document data."""
1515

1616
company_name: StringField
1717
"""The name of the company that provides the healthcare plan."""
@@ -35,6 +35,8 @@ class HealthcareCardV1Document(Prediction):
3535
"""The BIN number for prescription drug coverage."""
3636
rx_grp: StringField
3737
"""The group number for prescription drug coverage."""
38+
rx_id: StringField
39+
"""The ID number for prescription drug coverage."""
3840
rx_pcn: StringField
3941
"""The PCN number for prescription drug coverage."""
4042

@@ -94,6 +96,10 @@ def __init__(
9496
raw_prediction["rx_grp"],
9597
page_id=page_id,
9698
)
99+
self.rx_id = StringField(
100+
raw_prediction["rx_id"],
101+
page_id=page_id,
102+
)
97103
self.rx_pcn = StringField(
98104
raw_prediction["rx_pcn"],
99105
page_id=page_id,
@@ -103,7 +109,7 @@ def __init__(
103109
def _copays_separator(char: str) -> str:
104110
out_str = " "
105111
out_str += f"+{char * 14}"
106-
out_str += f"+{char * 14}"
112+
out_str += f"+{char * 22}"
107113
return out_str + "+"
108114

109115
def _copays_to_str(self) -> str:
@@ -116,7 +122,7 @@ def _copays_to_str(self) -> str:
116122
out_str = ""
117123
out_str += f"\n{self._copays_separator('-')}\n "
118124
out_str += " | Service Fees"
119-
out_str += " | Service Name"
125+
out_str += " | Service Name "
120126
out_str += f" |\n{self._copays_separator('=')}"
121127
out_str += f"\n {lines}"
122128
out_str += f"\n{self._copays_separator('-')}"
@@ -134,6 +140,7 @@ def __str__(self) -> str:
134140
out_str += f":Group Number: {self.group_number}\n"
135141
out_str += f":Payer ID: {self.payer_id}\n"
136142
out_str += f":RX BIN: {self.rx_bin}\n"
143+
out_str += f":RX ID: {self.rx_id}\n"
137144
out_str += f":RX GRP: {self.rx_grp}\n"
138145
out_str += f":RX PCN: {self.rx_pcn}\n"
139146
out_str += f":copays: {self._copays_to_str()}\n"

tests/product/financial_document/test_financial_document_v1.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,15 @@ def test_empty_doc(empty_doc: FinancialDocumentV1DocumentType):
8181
assert prediction.locale.value is None
8282
assert prediction.invoice_number.value is None
8383
assert len(prediction.reference_numbers) == 0
84+
assert prediction.billing_address.value is None
85+
assert len(prediction.customer_company_registrations) == 0
86+
assert prediction.customer_id.value is None
87+
assert prediction.customer_name.value is None
8488
assert prediction.date.value is None
8589
assert prediction.due_date.value is None
90+
assert prediction.document_type.value is not None
91+
assert prediction.document_type_extended.value is not None
92+
assert prediction.document_number.value is None
8693
assert prediction.total_net.value is None
8794
assert prediction.total_amount.value is None
8895
assert len(prediction.taxes) == 0

tests/product/us/healthcare_card/test_healthcare_card_v1.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def test_empty_doc(empty_doc: HealthcareCardV1DocumentType):
5151
assert prediction.group_number.value is None
5252
assert prediction.payer_id.value is None
5353
assert prediction.rx_bin.value is None
54+
assert prediction.rx_id.value is None
5455
assert prediction.rx_grp.value is None
5556
assert prediction.rx_pcn.value is None
5657
assert len(prediction.copays) == 0

0 commit comments

Comments
 (0)