Skip to content

Commit 86f7932

Browse files
✨ add support for Findoc V1.12, Invoices V4.10, US Healthcare Cards V1.2 (#231)
1 parent 9406c4c commit 86f7932

File tree

11 files changed

+139
-14
lines changed

11 files changed

+139
-14
lines changed

docs/financial_document_v1.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public class SimpleMindeeClient {
107107
########
108108
Document
109109
########
110-
:Mindee ID: f469a24d-3875-4a83-ad43-e0d5aa9da604
110+
:Mindee ID: a80ac0ee-26f6-4e2e-988a-960b240d5ba7
111111
:Filename: default_sample.jpg
112112
113113
Inference
@@ -132,7 +132,7 @@ Prediction
132132
+---------------+--------+----------+---------------+
133133
| Base | Code | Rate (%) | Amount |
134134
+===============+========+==========+===============+
135-
| | | 5.00 | 9.75 |
135+
| 195.00 | | 5.00 | 9.75 |
136136
+---------------+--------+----------+---------------+
137137
:Supplier Payment Details:
138138
:Supplier Name: JOHN SMITH
@@ -184,7 +184,7 @@ Page 0
184184
+---------------+--------+----------+---------------+
185185
| Base | Code | Rate (%) | Amount |
186186
+===============+========+==========+===============+
187-
| | | 5.00 | 9.75 |
187+
| 195.00 | | 5.00 | 9.75 |
188188
+---------------+--------+----------+---------------+
189189
:Supplier Payment Details:
190190
:Supplier Name: JOHN SMITH
@@ -389,6 +389,24 @@ System.out.println(result.getDocument().getInference().getPrediction().getDocume
389389
System.out.println(result.getDocument().getInference().getPrediction().getDocumentType().value);
390390
```
391391

392+
## Document Type Extended
393+
**documentTypeExtended**: Document type extended.
394+
395+
#### Possible values include:
396+
- 'CREDIT NOTE'
397+
- 'INVOICE'
398+
- 'OTHER'
399+
- 'OTHER_FINANCIAL'
400+
- 'PAYSLIP'
401+
- 'PURCHASE ORDER'
402+
- 'QUOTE'
403+
- 'RECEIPT'
404+
- 'STATEMENT'
405+
406+
```java
407+
System.out.println(result.getDocument().getInference().getPrediction().getDocumentTypeExtended().value);
408+
```
409+
392410
## Due Date
393411
**dueDate**: The date on which the payment is due.
394412

docs/invoices_v4.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public class SimpleMindeeClient {
107107
########
108108
Document
109109
########
110-
:Mindee ID: 86b1833f-138b-4a01-8387-860204b0e631
110+
:Mindee ID: b55db8f9-ae3b-4f05-b2f1-ec0ced5e5b70
111111
:Filename: default_sample.jpg
112112
113113
Inference
@@ -131,7 +131,7 @@ Prediction
131131
+---------------+--------+----------+---------------+
132132
| Base | Code | Rate (%) | Amount |
133133
+===============+========+==========+===============+
134-
| | | 8.00 | 193.20 |
134+
| 2145.00 | | 8.00 | 193.20 |
135135
+---------------+--------+----------+---------------+
136136
:Supplier Payment Details:
137137
:Supplier Name: TURNPIKE DESIGNS
@@ -177,7 +177,7 @@ Page 0
177177
+---------------+--------+----------+---------------+
178178
| Base | Code | Rate (%) | Amount |
179179
+===============+========+==========+===============+
180-
| | | 8.00 | 193.20 |
180+
| 2145.00 | | 8.00 | 193.20 |
181181
+---------------+--------+----------+---------------+
182182
:Supplier Payment Details:
183183
:Supplier Name: TURNPIKE DESIGNS
@@ -351,6 +351,24 @@ System.out.println(result.getDocument().getInference().getPrediction().getDate()
351351
System.out.println(result.getDocument().getInference().getPrediction().getDocumentType().value);
352352
```
353353

354+
## Document Type Extended
355+
**documentTypeExtended**: Document type extended.
356+
357+
#### Possible values include:
358+
- 'CREDIT NOTE'
359+
- 'INVOICE'
360+
- 'OTHER'
361+
- 'OTHER_FINANCIAL'
362+
- 'PAYSLIP'
363+
- 'PURCHASE ORDER'
364+
- 'QUOTE'
365+
- 'RECEIPT'
366+
- 'STATEMENT'
367+
368+
```java
369+
System.out.println(result.getDocument().getInference().getPrediction().getDocumentTypeExtended().value);
370+
```
371+
354372
## Due Date
355373
**dueDate**: The date on which the payment is due.
356374

docs/us_healthcare_cards_v1.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,15 @@ A `HealthcareCardV1Copay` implements the following attributes:
137137
* **serviceFees** (`Double`): The price of service.
138138
* **serviceName** (`String`): The name of service of the copay.
139139

140+
#### Possible values include:
141+
- primary_care
142+
- emergency_room
143+
- urgent_care
144+
- specialist
145+
- office_visit
146+
- prescription
147+
148+
140149
# Attributes
141150
The following fields are extracted for Healthcare Card V1:
142151

@@ -223,6 +232,13 @@ System.out.println(result.getDocument().getInference().getPrediction().getRxBin(
223232
System.out.println(result.getDocument().getInference().getPrediction().getRxGrp().value);
224233
```
225234

235+
## RX ID
236+
**rxId**: The ID number for prescription drug coverage.
237+
238+
```java
239+
System.out.println(result.getDocument().getInference().getPrediction().getRxId().value);
240+
```
241+
226242
## RX PCN
227243
**rxPcn**: The PCN number for prescription drug coverage.
228244

src/main/java/com/mindee/product/financialdocument/FinancialDocumentV1Document.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import lombok.Getter;
2121

2222
/**
23-
* Financial Document API version 1.11 document data.
23+
* Financial Document API version 1.12 document data.
2424
*/
2525
@Getter
2626
@EqualsAndHashCode(callSuper = false)
@@ -72,6 +72,11 @@ public class FinancialDocumentV1Document extends Prediction {
7272
*/
7373
@JsonProperty("document_type")
7474
protected ClassificationField documentType;
75+
/**
76+
* Document type extended.
77+
*/
78+
@JsonProperty("document_type_extended")
79+
protected ClassificationField documentTypeExtended;
7580
/**
7681
* The date on which the payment is due.
7782
*/
@@ -218,6 +223,7 @@ public boolean isEmpty() {
218223
&& this.shippingAddress == null
219224
&& this.billingAddress == null
220225
&& this.documentType == null
226+
&& this.documentTypeExtended == null
221227
&& this.subcategory == null
222228
&& this.category == null
223229
&& this.totalTax == null
@@ -324,6 +330,9 @@ public String toString() {
324330
outStr.append(
325331
String.format(":Document Type: %s%n", this.getDocumentType())
326332
);
333+
outStr.append(
334+
String.format(":Document Type Extended: %s%n", this.getDocumentTypeExtended())
335+
);
327336
outStr.append(
328337
String.format(":Purchase Subcategory: %s%n", this.getSubcategory())
329338
);

src/main/java/com/mindee/product/invoice/InvoiceV4Document.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import lombok.Getter;
2121

2222
/**
23-
* Invoice API version 4.9 document data.
23+
* Invoice API version 4.10 document data.
2424
*/
2525
@Getter
2626
@EqualsAndHashCode(callSuper = false)
@@ -62,6 +62,11 @@ public class InvoiceV4Document extends Prediction {
6262
*/
6363
@JsonProperty("document_type")
6464
protected ClassificationField documentType;
65+
/**
66+
* Document type extended.
67+
*/
68+
@JsonProperty("document_type_extended")
69+
protected ClassificationField documentTypeExtended;
6570
/**
6671
* The date on which the payment is due.
6772
*/
@@ -187,6 +192,7 @@ public boolean isEmpty() {
187192
&& this.shippingAddress == null
188193
&& this.billingAddress == null
189194
&& this.documentType == null
195+
&& this.documentTypeExtended == null
190196
&& (this.lineItems == null || this.lineItems.isEmpty())
191197
);
192198
}
@@ -285,6 +291,9 @@ public String toString() {
285291
outStr.append(
286292
String.format(":Document Type: %s%n", this.getDocumentType())
287293
);
294+
outStr.append(
295+
String.format(":Document Type Extended: %s%n", this.getDocumentTypeExtended())
296+
);
288297
String lineItemsSummary = "";
289298
if (!this.getLineItems().isEmpty()) {
290299
int[] lineItemsColSizes = new int[]{38, 14, 10, 12, 14, 14, 17, 12};

src/main/java/com/mindee/product/us/healthcarecard/HealthcareCardV1Copay.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ private Map<String, String> tablePrintableValues() {
4141
"serviceFees",
4242
SummaryHelper.formatAmount(this.serviceFees)
4343
);
44-
printable.put("serviceName", SummaryHelper.formatForDisplay(this.serviceName, null));
44+
printable.put("serviceName", SummaryHelper.formatForDisplay(this.serviceName, 20));
4545
return printable;
4646
}
4747

@@ -51,7 +51,7 @@ private Map<String, String> tablePrintableValues() {
5151
public String toTableLine() {
5252
Map<String, String> printable = this.tablePrintableValues();
5353
return String.format("| %-12s ", printable.get("serviceFees"))
54-
+ String.format("| %-12s |", printable.get("serviceName"));
54+
+ String.format("| %-20s |", printable.get("serviceName"));
5555
}
5656

5757
@Override

src/main/java/com/mindee/product/us/healthcarecard/HealthcareCardV1Document.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import lombok.Getter;
1313

1414
/**
15-
* Healthcare Card API version 1.1 document data.
15+
* Healthcare Card API version 1.2 document data.
1616
*/
1717
@Getter
1818
@EqualsAndHashCode(callSuper = false)
@@ -74,6 +74,11 @@ public class HealthcareCardV1Document extends Prediction {
7474
*/
7575
@JsonProperty("rx_grp")
7676
protected StringField rxGrp;
77+
/**
78+
* The ID number for prescription drug coverage.
79+
*/
80+
@JsonProperty("rx_id")
81+
protected StringField rxId;
7782
/**
7883
* The PCN number for prescription drug coverage.
7984
*/
@@ -91,6 +96,7 @@ public boolean isEmpty() {
9196
&& this.groupNumber == null
9297
&& this.payerId == null
9398
&& this.rxBin == null
99+
&& this.rxId == null
94100
&& this.rxGrp == null
95101
&& this.rxPcn == null
96102
&& (this.copays == null || this.copays.isEmpty())
@@ -129,6 +135,9 @@ public String toString() {
129135
outStr.append(
130136
String.format(":RX BIN: %s%n", this.getRxBin())
131137
);
138+
outStr.append(
139+
String.format(":RX ID: %s%n", this.getRxId())
140+
);
132141
outStr.append(
133142
String.format(":RX GRP: %s%n", this.getRxGrp())
134143
);
@@ -137,11 +146,11 @@ public String toString() {
137146
);
138147
String copaysSummary = "";
139148
if (!this.getCopays().isEmpty()) {
140-
int[] copaysColSizes = new int[]{14, 14};
149+
int[] copaysColSizes = new int[]{14, 22};
141150
copaysSummary =
142151
String.format("%n%s%n ", SummaryHelper.lineSeparator(copaysColSizes, "-"))
143152
+ "| Service Fees "
144-
+ "| Service Name "
153+
+ "| Service Name "
145154
+ String.format("|%n%s%n ", SummaryHelper.lineSeparator(copaysColSizes, "="));
146155
copaysSummary += SummaryHelper.arrayToString(this.getCopays(), copaysColSizes);
147156
copaysSummary += String.format("%n%s", SummaryHelper.lineSeparator(copaysColSizes, "-"));

src/test/java/com/mindee/product/financialdocument/FinancialDocumentV1Test.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.fasterxml.jackson.databind.JavaType;
44
import com.fasterxml.jackson.databind.ObjectMapper;
5+
import com.mindee.parsing.common.Document;
56
import com.mindee.parsing.common.PredictResponse;
67
import org.junit.jupiter.api.Assertions;
78
import org.junit.jupiter.api.Test;
@@ -100,5 +101,48 @@ void givenFinancialV1_withReceipt_firstPage_MustHaveAValidSummary() throws IOExc
100101

101102
Assertions.assertEquals(expectedSummary, actualSummary);
102103
}
104+
@Test
105+
void givenFinancialV1_withEmptyDocument_whenDeserialized_MustHaveExpectedValues() throws IOException {
106+
ObjectMapper objectMapper = new ObjectMapper();
107+
objectMapper.findAndRegisterModules();
103108

109+
JavaType type = objectMapper.getTypeFactory().constructParametricType(PredictResponse.class,
110+
FinancialDocumentV1.class);
111+
PredictResponse<FinancialDocumentV1> response = objectMapper.readValue(
112+
new File("src/test/resources/products/financial_document/response_v1/empty.json"),
113+
type);
114+
115+
Document<FinancialDocumentV1> doc = response.getDocument();
116+
FinancialDocumentV1Document prediction = doc.getInference().getPrediction();
117+
118+
Assertions.assertEquals("EUR;", prediction.getLocale().toString());
119+
Assertions.assertNull(prediction.getTotalAmount().getValue());
120+
Assertions.assertNull(prediction.getTotalNet().getValue());
121+
Assertions.assertNull(prediction.getTotalTax().getValue());
122+
Assertions.assertNull(prediction.getDate().getValue());
123+
Assertions.assertNull(prediction.getInvoiceNumber().getValue());
124+
Assertions.assertNull(prediction.getBillingAddress().getValue());
125+
Assertions.assertNull(prediction.getDueDate().getValue());
126+
Assertions.assertNull(prediction.getDocumentNumber().getValue());
127+
Assertions.assertEquals("EXPENSE RECEIPT", prediction.getDocumentType().getValue());
128+
Assertions.assertEquals("EXPENSE RECEIPT", prediction.getDocumentTypeExtended().getValue());
129+
Assertions.assertNull(prediction.getSupplierName().getValue());
130+
Assertions.assertNull(prediction.getSupplierAddress().getValue());
131+
Assertions.assertNull(prediction.getCustomerId().getValue());
132+
Assertions.assertNull(prediction.getCustomerName().getValue());
133+
Assertions.assertNull(prediction.getCustomerAddress().getValue());
134+
Assertions.assertTrue(prediction.getCustomerCompanyRegistrations().isEmpty());
135+
Assertions.assertTrue(prediction.getTaxes().isEmpty());
136+
Assertions.assertTrue(prediction.getSupplierPaymentDetails().isEmpty());
137+
Assertions.assertTrue(prediction.getSupplierCompanyRegistrations().isEmpty());
138+
Assertions.assertNull(prediction.getTip().getValue());
139+
Assertions.assertNull(prediction.getTotalAmount().getValue());
140+
Assertions.assertNull(prediction.getTotalNet().getValue());
141+
Assertions.assertNull(prediction.getTotalTax().getValue());
142+
Assertions.assertNull(prediction.getDate().getValue());
143+
Assertions.assertNull(prediction.getTime().getValue());
144+
Assertions.assertNull(prediction.getSupplierName().getValue());
145+
Assertions.assertNull(prediction.getSupplierAddress().getValue());
146+
Assertions.assertTrue(prediction.getTaxes().isEmpty());
147+
}
104148
}

src/test/java/com/mindee/product/invoice/InvoiceV4Test.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ void whenEmptyDeserialized_mustHaveValidProperties() throws IOException {
5959
Assertions.assertNull(docPrediction.getShippingAddress().getValue());
6060
Assertions.assertNull(docPrediction.getBillingAddress().getValue());
6161
Assertions.assertInstanceOf(ClassificationField.class, docPrediction.getDocumentType());
62+
Assertions.assertInstanceOf(ClassificationField.class, docPrediction.getDocumentTypeExtended());
6263
Assertions.assertTrue(docPrediction.getLineItems().isEmpty());
6364
}
6465

src/test/java/com/mindee/product/us/healthcarecard/HealthcareCardV1Test.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ void whenEmptyDeserialized_mustHaveValidProperties() throws IOException {
4242
Assertions.assertNull(docPrediction.getGroupNumber().getValue());
4343
Assertions.assertNull(docPrediction.getPayerId().getValue());
4444
Assertions.assertNull(docPrediction.getRxBin().getValue());
45+
Assertions.assertNull(docPrediction.getRxId().getValue());
4546
Assertions.assertNull(docPrediction.getRxGrp().getValue());
4647
Assertions.assertNull(docPrediction.getRxPcn().getValue());
4748
Assertions.assertTrue(docPrediction.getCopays().isEmpty());

0 commit comments

Comments
 (0)