From eba6f45a486d11d9a754a8e74c02c4e8945d88ba Mon Sep 17 00:00:00 2001 From: sebastianMindee Date: Mon, 7 Apr 2025 10:37:10 +0200 Subject: [PATCH 1/4] :sparkles: add support for Findoc V1.12, Invoices V4.10, US Healthcare Cards V1.2 --- docs/financial_document_v1.md | 24 ++++++++++++++++--- docs/invoices_v4.md | 24 ++++++++++++++++--- docs/us_healthcare_cards_v1.md | 16 +++++++++++++ .../FinancialDocumentV1Document.java | 11 ++++++++- .../product/invoice/InvoiceV4Document.java | 11 ++++++++- .../HealthcareCardV1Document.java | 11 ++++++++- .../mindee/product/invoice/InvoiceV4Test.java | 1 + .../healthcarecard/HealthcareCardV1Test.java | 1 + 8 files changed, 90 insertions(+), 9 deletions(-) diff --git a/docs/financial_document_v1.md b/docs/financial_document_v1.md index 980e8aff3..c052c1c22 100644 --- a/docs/financial_document_v1.md +++ b/docs/financial_document_v1.md @@ -107,7 +107,7 @@ public class SimpleMindeeClient { ######## Document ######## -:Mindee ID: f469a24d-3875-4a83-ad43-e0d5aa9da604 +:Mindee ID: a80ac0ee-26f6-4e2e-988a-960b240d5ba7 :Filename: default_sample.jpg Inference @@ -132,7 +132,7 @@ Prediction +---------------+--------+----------+---------------+ | Base | Code | Rate (%) | Amount | +===============+========+==========+===============+ - | | | 5.00 | 9.75 | + | 195.00 | | 5.00 | 9.75 | +---------------+--------+----------+---------------+ :Supplier Payment Details: :Supplier Name: JOHN SMITH @@ -184,7 +184,7 @@ Page 0 +---------------+--------+----------+---------------+ | Base | Code | Rate (%) | Amount | +===============+========+==========+===============+ - | | | 5.00 | 9.75 | + | 195.00 | | 5.00 | 9.75 | +---------------+--------+----------+---------------+ :Supplier Payment Details: :Supplier Name: JOHN SMITH @@ -389,6 +389,24 @@ System.out.println(result.getDocument().getInference().getPrediction().getDocume System.out.println(result.getDocument().getInference().getPrediction().getDocumentType().value); ``` +## Document Type Extended +**documentTypeExtended**: Document type extended. + +#### Possible values include: + - 'CREDIT NOTE' + - 'INVOICE' + - 'OTHER' + - 'OTHER_FINANCIAL' + - 'PAYSLIP' + - 'PURCHASE ORDER' + - 'QUOTE' + - 'RECEIPT' + - 'STATEMENT' + +```java +System.out.println(result.getDocument().getInference().getPrediction().getDocumentTypeExtended().value); +``` + ## Due Date **dueDate**: The date on which the payment is due. diff --git a/docs/invoices_v4.md b/docs/invoices_v4.md index db9a8cc54..8556df50e 100644 --- a/docs/invoices_v4.md +++ b/docs/invoices_v4.md @@ -107,7 +107,7 @@ public class SimpleMindeeClient { ######## Document ######## -:Mindee ID: 86b1833f-138b-4a01-8387-860204b0e631 +:Mindee ID: b55db8f9-ae3b-4f05-b2f1-ec0ced5e5b70 :Filename: default_sample.jpg Inference @@ -131,7 +131,7 @@ Prediction +---------------+--------+----------+---------------+ | Base | Code | Rate (%) | Amount | +===============+========+==========+===============+ - | | | 8.00 | 193.20 | + | 2145.00 | | 8.00 | 193.20 | +---------------+--------+----------+---------------+ :Supplier Payment Details: :Supplier Name: TURNPIKE DESIGNS @@ -177,7 +177,7 @@ Page 0 +---------------+--------+----------+---------------+ | Base | Code | Rate (%) | Amount | +===============+========+==========+===============+ - | | | 8.00 | 193.20 | + | 2145.00 | | 8.00 | 193.20 | +---------------+--------+----------+---------------+ :Supplier Payment Details: :Supplier Name: TURNPIKE DESIGNS @@ -351,6 +351,24 @@ System.out.println(result.getDocument().getInference().getPrediction().getDate() System.out.println(result.getDocument().getInference().getPrediction().getDocumentType().value); ``` +## Document Type Extended +**documentTypeExtended**: Document type extended. + +#### Possible values include: + - 'CREDIT NOTE' + - 'INVOICE' + - 'OTHER' + - 'OTHER_FINANCIAL' + - 'PAYSLIP' + - 'PURCHASE ORDER' + - 'QUOTE' + - 'RECEIPT' + - 'STATEMENT' + +```java +System.out.println(result.getDocument().getInference().getPrediction().getDocumentTypeExtended().value); +``` + ## Due Date **dueDate**: The date on which the payment is due. diff --git a/docs/us_healthcare_cards_v1.md b/docs/us_healthcare_cards_v1.md index 6a7846bb7..cac538e09 100644 --- a/docs/us_healthcare_cards_v1.md +++ b/docs/us_healthcare_cards_v1.md @@ -137,6 +137,15 @@ A `HealthcareCardV1Copay` implements the following attributes: * **serviceFees** (`Double`): The price of service. * **serviceName** (`String`): 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: @@ -223,6 +232,13 @@ System.out.println(result.getDocument().getInference().getPrediction().getRxBin( System.out.println(result.getDocument().getInference().getPrediction().getRxGrp().value); ``` +## RX ID +**rxId**: The ID number for prescription drug coverage. + +```java +System.out.println(result.getDocument().getInference().getPrediction().getRxId().value); +``` + ## RX PCN **rxPcn**: The PCN number for prescription drug coverage. diff --git a/src/main/java/com/mindee/product/financialdocument/FinancialDocumentV1Document.java b/src/main/java/com/mindee/product/financialdocument/FinancialDocumentV1Document.java index 02035d9ec..6d12be94b 100644 --- a/src/main/java/com/mindee/product/financialdocument/FinancialDocumentV1Document.java +++ b/src/main/java/com/mindee/product/financialdocument/FinancialDocumentV1Document.java @@ -20,7 +20,7 @@ import lombok.Getter; /** - * Financial Document API version 1.11 document data. + * Financial Document API version 1.12 document data. */ @Getter @EqualsAndHashCode(callSuper = false) @@ -72,6 +72,11 @@ public class FinancialDocumentV1Document extends Prediction { */ @JsonProperty("document_type") protected ClassificationField documentType; + /** + * Document type extended. + */ + @JsonProperty("document_type_extended") + protected ClassificationField documentTypeExtended; /** * The date on which the payment is due. */ @@ -218,6 +223,7 @@ public boolean isEmpty() { && this.shippingAddress == null && this.billingAddress == null && this.documentType == null + && this.documentTypeExtended == null && this.subcategory == null && this.category == null && this.totalTax == null @@ -324,6 +330,9 @@ public String toString() { outStr.append( String.format(":Document Type: %s%n", this.getDocumentType()) ); + outStr.append( + String.format(":Document Type Extended: %s%n", this.getDocumentTypeExtended()) + ); outStr.append( String.format(":Purchase Subcategory: %s%n", this.getSubcategory()) ); diff --git a/src/main/java/com/mindee/product/invoice/InvoiceV4Document.java b/src/main/java/com/mindee/product/invoice/InvoiceV4Document.java index d638c3de0..d77056254 100644 --- a/src/main/java/com/mindee/product/invoice/InvoiceV4Document.java +++ b/src/main/java/com/mindee/product/invoice/InvoiceV4Document.java @@ -20,7 +20,7 @@ import lombok.Getter; /** - * Invoice API version 4.9 document data. + * Invoice API version 4.10 document data. */ @Getter @EqualsAndHashCode(callSuper = false) @@ -62,6 +62,11 @@ public class InvoiceV4Document extends Prediction { */ @JsonProperty("document_type") protected ClassificationField documentType; + /** + * Document type extended. + */ + @JsonProperty("document_type_extended") + protected ClassificationField documentTypeExtended; /** * The date on which the payment is due. */ @@ -187,6 +192,7 @@ public boolean isEmpty() { && this.shippingAddress == null && this.billingAddress == null && this.documentType == null + && this.documentTypeExtended == null && (this.lineItems == null || this.lineItems.isEmpty()) ); } @@ -285,6 +291,9 @@ public String toString() { outStr.append( String.format(":Document Type: %s%n", this.getDocumentType()) ); + outStr.append( + String.format(":Document Type Extended: %s%n", this.getDocumentTypeExtended()) + ); String lineItemsSummary = ""; if (!this.getLineItems().isEmpty()) { int[] lineItemsColSizes = new int[]{38, 14, 10, 12, 14, 14, 17, 12}; diff --git a/src/main/java/com/mindee/product/us/healthcarecard/HealthcareCardV1Document.java b/src/main/java/com/mindee/product/us/healthcarecard/HealthcareCardV1Document.java index 91636ad72..f6440a8c8 100644 --- a/src/main/java/com/mindee/product/us/healthcarecard/HealthcareCardV1Document.java +++ b/src/main/java/com/mindee/product/us/healthcarecard/HealthcareCardV1Document.java @@ -12,7 +12,7 @@ import lombok.Getter; /** - * Healthcare Card API version 1.1 document data. + * Healthcare Card API version 1.2 document data. */ @Getter @EqualsAndHashCode(callSuper = false) @@ -74,6 +74,11 @@ public class HealthcareCardV1Document extends Prediction { */ @JsonProperty("rx_grp") protected StringField rxGrp; + /** + * The ID number for prescription drug coverage. + */ + @JsonProperty("rx_id") + protected StringField rxId; /** * The PCN number for prescription drug coverage. */ @@ -91,6 +96,7 @@ public boolean isEmpty() { && this.groupNumber == null && this.payerId == null && this.rxBin == null + && this.rxId == null && this.rxGrp == null && this.rxPcn == null && (this.copays == null || this.copays.isEmpty()) @@ -129,6 +135,9 @@ public String toString() { outStr.append( String.format(":RX BIN: %s%n", this.getRxBin()) ); + outStr.append( + String.format(":RX ID: %s%n", this.getRxId()) + ); outStr.append( String.format(":RX GRP: %s%n", this.getRxGrp()) ); diff --git a/src/test/java/com/mindee/product/invoice/InvoiceV4Test.java b/src/test/java/com/mindee/product/invoice/InvoiceV4Test.java index 6d67fcf4d..be0750c37 100644 --- a/src/test/java/com/mindee/product/invoice/InvoiceV4Test.java +++ b/src/test/java/com/mindee/product/invoice/InvoiceV4Test.java @@ -59,6 +59,7 @@ void whenEmptyDeserialized_mustHaveValidProperties() throws IOException { Assertions.assertNull(docPrediction.getShippingAddress().getValue()); Assertions.assertNull(docPrediction.getBillingAddress().getValue()); Assertions.assertInstanceOf(ClassificationField.class, docPrediction.getDocumentType()); + Assertions.assertInstanceOf(ClassificationField.class, docPrediction.getDocumentTypeExtended()); Assertions.assertTrue(docPrediction.getLineItems().isEmpty()); } diff --git a/src/test/java/com/mindee/product/us/healthcarecard/HealthcareCardV1Test.java b/src/test/java/com/mindee/product/us/healthcarecard/HealthcareCardV1Test.java index 2cb343161..8bf7fb0a6 100644 --- a/src/test/java/com/mindee/product/us/healthcarecard/HealthcareCardV1Test.java +++ b/src/test/java/com/mindee/product/us/healthcarecard/HealthcareCardV1Test.java @@ -42,6 +42,7 @@ void whenEmptyDeserialized_mustHaveValidProperties() throws IOException { Assertions.assertNull(docPrediction.getGroupNumber().getValue()); Assertions.assertNull(docPrediction.getPayerId().getValue()); Assertions.assertNull(docPrediction.getRxBin().getValue()); + Assertions.assertNull(docPrediction.getRxId().getValue()); Assertions.assertNull(docPrediction.getRxGrp().getValue()); Assertions.assertNull(docPrediction.getRxPcn().getValue()); Assertions.assertTrue(docPrediction.getCopays().isEmpty()); From a307d72eddd27ed63242c11d976e4f7dc00e4ec0 Mon Sep 17 00:00:00 2001 From: sebastianMindee Date: Tue, 8 Apr 2025 11:48:11 +0200 Subject: [PATCH 2/4] update table display for us healthcare cards --- .../product/us/healthcarecard/HealthcareCardV1Copay.java | 4 ++-- .../product/us/healthcarecard/HealthcareCardV1Document.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/mindee/product/us/healthcarecard/HealthcareCardV1Copay.java b/src/main/java/com/mindee/product/us/healthcarecard/HealthcareCardV1Copay.java index 19dcaa9cc..a0aedbfd8 100644 --- a/src/main/java/com/mindee/product/us/healthcarecard/HealthcareCardV1Copay.java +++ b/src/main/java/com/mindee/product/us/healthcarecard/HealthcareCardV1Copay.java @@ -41,7 +41,7 @@ private Map tablePrintableValues() { "serviceFees", SummaryHelper.formatAmount(this.serviceFees) ); - printable.put("serviceName", SummaryHelper.formatForDisplay(this.serviceName, null)); + printable.put("serviceName", SummaryHelper.formatForDisplay(this.serviceName, 20)); return printable; } @@ -51,7 +51,7 @@ private Map tablePrintableValues() { public String toTableLine() { Map printable = this.tablePrintableValues(); return String.format("| %-12s ", printable.get("serviceFees")) - + String.format("| %-12s |", printable.get("serviceName")); + + String.format("| %-20s |", printable.get("serviceName")); } @Override diff --git a/src/main/java/com/mindee/product/us/healthcarecard/HealthcareCardV1Document.java b/src/main/java/com/mindee/product/us/healthcarecard/HealthcareCardV1Document.java index f6440a8c8..0eaa5c0ae 100644 --- a/src/main/java/com/mindee/product/us/healthcarecard/HealthcareCardV1Document.java +++ b/src/main/java/com/mindee/product/us/healthcarecard/HealthcareCardV1Document.java @@ -146,11 +146,11 @@ public String toString() { ); String copaysSummary = ""; if (!this.getCopays().isEmpty()) { - int[] copaysColSizes = new int[]{14, 14}; + int[] copaysColSizes = new int[]{14, 22}; copaysSummary = String.format("%n%s%n ", SummaryHelper.lineSeparator(copaysColSizes, "-")) + "| Service Fees " - + "| Service Name " + + "| Service Name " + String.format("|%n%s%n ", SummaryHelper.lineSeparator(copaysColSizes, "=")); copaysSummary += SummaryHelper.arrayToString(this.getCopays(), copaysColSizes); copaysSummary += String.format("%n%s", SummaryHelper.lineSeparator(copaysColSizes, "-")); From ee93615044aefb07fd499d742cea6db11eaf96b6 Mon Sep 17 00:00:00 2001 From: sebastianMindee Date: Tue, 8 Apr 2025 11:51:16 +0200 Subject: [PATCH 3/4] update test lib --- src/test/resources | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources b/src/test/resources index 01336a096..0c9cfe341 160000 --- a/src/test/resources +++ b/src/test/resources @@ -1 +1 @@ -Subproject commit 01336a096b6e31d30668afdb86b3f677d8ed93d0 +Subproject commit 0c9cfe3416babad79b0689b40eb71917ab996beb From cc7ab45c0b7e8aa385443925c4b3d409533fc273 Mon Sep 17 00:00:00 2001 From: sebastianMindee Date: Tue, 8 Apr 2025 15:49:46 +0200 Subject: [PATCH 4/4] fix findoc test --- .../FinancialDocumentV1Test.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/test/java/com/mindee/product/financialdocument/FinancialDocumentV1Test.java b/src/test/java/com/mindee/product/financialdocument/FinancialDocumentV1Test.java index 1d7dbea85..cd27c6fb7 100644 --- a/src/test/java/com/mindee/product/financialdocument/FinancialDocumentV1Test.java +++ b/src/test/java/com/mindee/product/financialdocument/FinancialDocumentV1Test.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; +import com.mindee.parsing.common.Document; import com.mindee.parsing.common.PredictResponse; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -100,5 +101,48 @@ void givenFinancialV1_withReceipt_firstPage_MustHaveAValidSummary() throws IOExc Assertions.assertEquals(expectedSummary, actualSummary); } + @Test + void givenFinancialV1_withEmptyDocument_whenDeserialized_MustHaveExpectedValues() throws IOException { + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.findAndRegisterModules(); + JavaType type = objectMapper.getTypeFactory().constructParametricType(PredictResponse.class, + FinancialDocumentV1.class); + PredictResponse response = objectMapper.readValue( + new File("src/test/resources/products/financial_document/response_v1/empty.json"), + type); + + Document doc = response.getDocument(); + FinancialDocumentV1Document prediction = doc.getInference().getPrediction(); + + Assertions.assertEquals("EUR;", prediction.getLocale().toString()); + Assertions.assertNull(prediction.getTotalAmount().getValue()); + Assertions.assertNull(prediction.getTotalNet().getValue()); + Assertions.assertNull(prediction.getTotalTax().getValue()); + Assertions.assertNull(prediction.getDate().getValue()); + Assertions.assertNull(prediction.getInvoiceNumber().getValue()); + Assertions.assertNull(prediction.getBillingAddress().getValue()); + Assertions.assertNull(prediction.getDueDate().getValue()); + Assertions.assertNull(prediction.getDocumentNumber().getValue()); + Assertions.assertEquals("EXPENSE RECEIPT", prediction.getDocumentType().getValue()); + Assertions.assertEquals("EXPENSE RECEIPT", prediction.getDocumentTypeExtended().getValue()); + Assertions.assertNull(prediction.getSupplierName().getValue()); + Assertions.assertNull(prediction.getSupplierAddress().getValue()); + Assertions.assertNull(prediction.getCustomerId().getValue()); + Assertions.assertNull(prediction.getCustomerName().getValue()); + Assertions.assertNull(prediction.getCustomerAddress().getValue()); + Assertions.assertTrue(prediction.getCustomerCompanyRegistrations().isEmpty()); + Assertions.assertTrue(prediction.getTaxes().isEmpty()); + Assertions.assertTrue(prediction.getSupplierPaymentDetails().isEmpty()); + Assertions.assertTrue(prediction.getSupplierCompanyRegistrations().isEmpty()); + Assertions.assertNull(prediction.getTip().getValue()); + Assertions.assertNull(prediction.getTotalAmount().getValue()); + Assertions.assertNull(prediction.getTotalNet().getValue()); + Assertions.assertNull(prediction.getTotalTax().getValue()); + Assertions.assertNull(prediction.getDate().getValue()); + Assertions.assertNull(prediction.getTime().getValue()); + Assertions.assertNull(prediction.getSupplierName().getValue()); + Assertions.assertNull(prediction.getSupplierAddress().getValue()); + Assertions.assertTrue(prediction.getTaxes().isEmpty()); + } }