mindee 3.11.0 → 3.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +27 -0
- data/README.md +23 -23
- data/Rakefile +5 -0
- data/bin/mindee.rb +7 -1
- data/docs/bank_account_details_v2.md +5 -1
- data/docs/bank_check_v1.md +6 -2
- data/docs/bank_statement_fr_v1.md +3 -0
- data/docs/barcode_reader_v1.md +5 -1
- data/docs/bill_of_lading_v1.md +202 -0
- data/docs/carte_grise_v1.md +5 -1
- data/docs/carte_vitale_v1.md +5 -1
- data/docs/code_samples/bill_of_lading_v1_async.txt +19 -0
- data/docs/code_samples/energy_bill_fra_v1_async.txt +19 -0
- data/docs/code_samples/financial_document_v1_async.txt +19 -0
- data/docs/code_samples/invoices_v4_async.txt +19 -0
- data/docs/code_samples/nutrition_facts_v1_async.txt +19 -0
- data/docs/code_samples/payslip_fra_v2_async.txt +19 -0
- data/docs/code_samples/us_healthcare_cards_v1_async.txt +19 -0
- data/docs/cropper_v1.md +6 -2
- data/docs/custom_v1.md +5 -3
- data/docs/energy_bill_fra_v1.md +249 -0
- data/docs/eu_driver_license_v1.md +6 -2
- data/docs/expense_receipts_v5.md +38 -11
- data/docs/financial_document_v1.md +80 -23
- data/docs/generated_v1.md +3 -0
- data/docs/getting_started.md +3 -0
- data/docs/idcard_fr_v2.md +15 -2
- data/docs/international_id_v2.md +13 -1
- data/docs/invoice_splitter_v1.md +16 -13
- data/docs/invoices_v4.md +57 -23
- data/docs/license_plates_v1.md +5 -1
- data/docs/multi_receipts_detector_v1.md +5 -1
- data/docs/nutrition_facts_v1.md +295 -0
- data/docs/passport_v1.md +5 -1
- data/docs/payslip_fra_v2.md +218 -0
- data/docs/proof_of_address_v1.md +5 -1
- data/docs/resume_v1.md +24 -1
- data/docs/us_driver_license_v1.md +6 -2
- data/docs/us_healthcare_cards_v1.md +208 -0
- data/docs/us_mail_v2.md +5 -1
- data/docs/us_w9_v1.md +6 -2
- data/examples/auto_invoice_splitter_extraction.rb +43 -0
- data/lib/mindee/client.rb +20 -8
- data/lib/mindee/extraction/common/extracted_image.rb +73 -0
- data/lib/mindee/extraction/common/image_extractor.rb +189 -0
- data/lib/mindee/extraction/common.rb +4 -0
- data/lib/mindee/extraction/multi_receipts_extractor/multi_receipts_extractor.rb +26 -0
- data/lib/mindee/extraction/multi_receipts_extractor.rb +3 -0
- data/lib/mindee/extraction/pdf_extractor/extracted_pdf.rb +55 -0
- data/lib/mindee/extraction/pdf_extractor/pdf_extractor.rb +111 -0
- data/lib/mindee/extraction/pdf_extractor.rb +4 -0
- data/lib/mindee/extraction/tax_extractor/tax_extractor.rb +322 -0
- data/lib/mindee/extraction/tax_extractor.rb +1 -320
- data/lib/mindee/extraction.rb +3 -0
- data/lib/mindee/http/endpoint.rb +18 -6
- data/lib/mindee/input/sources.rb +8 -0
- data/lib/mindee/parsing/common/api_response.rb +1 -1
- data/lib/mindee/parsing/common/document.rb +31 -1
- data/lib/mindee/parsing/common/extras/cropper_extra.rb +29 -0
- data/lib/mindee/parsing/common/extras/extras.rb +50 -0
- data/lib/mindee/parsing/common/extras/full_text_ocr_extra.rb +32 -0
- data/lib/mindee/parsing/common/extras.rb +5 -0
- data/lib/mindee/parsing/common/page.rb +5 -0
- data/lib/mindee/parsing/standard/base_field.rb +1 -0
- data/lib/mindee/parsing/standard/company_registration_field.rb +17 -0
- data/lib/mindee/product/bill_of_lading/bill_of_lading_v1.rb +39 -0
- data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier.rb +52 -0
- data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier_item.rb +95 -0
- data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_consignee.rb +58 -0
- data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_document.rb +136 -0
- data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_notify_party.rb +58 -0
- data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_page.rb +32 -0
- data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_shipper.rb +58 -0
- data/lib/mindee/product/financial_document/financial_document_v1_document.rb +3 -1
- data/lib/mindee/product/financial_document/financial_document_v1_line_item.rb +22 -1
- data/lib/mindee/product/financial_document/financial_document_v1_page.rb +1 -1
- data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2_bban.rb +4 -15
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1.rb +41 -0
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_document.rb +235 -0
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_consumer.rb +48 -0
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_supplier.rb +48 -0
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_usage.rb +97 -0
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_meter_detail.rb +54 -0
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_page.rb +34 -0
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_subscription.rb +97 -0
- data/lib/mindee/product/fr/energy_bill/energy_bill_v1_taxes_and_contribution.rb +97 -0
- data/lib/mindee/product/fr/payslip/payslip_v2.rb +41 -0
- data/lib/mindee/product/fr/payslip/payslip_v2_bank_account_detail.rb +54 -0
- data/lib/mindee/product/fr/payslip/payslip_v2_document.rb +128 -0
- data/lib/mindee/product/fr/payslip/payslip_v2_employee.rb +78 -0
- data/lib/mindee/product/fr/payslip/payslip_v2_employer.rb +78 -0
- data/lib/mindee/product/fr/payslip/payslip_v2_employment.rb +72 -0
- data/lib/mindee/product/fr/payslip/payslip_v2_page.rb +34 -0
- data/lib/mindee/product/fr/payslip/payslip_v2_pay_detail.rb +100 -0
- data/lib/mindee/product/fr/payslip/payslip_v2_pay_period.rb +66 -0
- data/lib/mindee/product/fr/payslip/payslip_v2_pto.rb +56 -0
- data/lib/mindee/product/fr/payslip/payslip_v2_salary_detail.rb +81 -0
- data/lib/mindee/product/international_id/international_id_v2_document.rb +1 -1
- data/lib/mindee/product/international_id/international_id_v2_page.rb +1 -1
- data/lib/mindee/product/invoice/invoice_v4_document.rb +3 -1
- data/lib/mindee/product/invoice/invoice_v4_line_item.rb +22 -1
- data/lib/mindee/product/invoice/invoice_v4_page.rb +1 -1
- data/lib/mindee/product/invoice_splitter/invoice_splitter_v1_document.rb +1 -1
- data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_document.rb +1 -1
- data/lib/mindee/product/multi_receipts_detector/multi_receipts_detector_v1_page.rb +1 -1
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1.rb +39 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_added_sugar.rb +52 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_calorie.rb +52 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_cholesterol.rb +52 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_dietary_fiber.rb +52 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_document.rb +173 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_nutrient.rb +87 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_page.rb +32 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_protein.rb +52 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_saturated_fat.rb +52 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_serving_size.rb +46 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_sodium.rb +58 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_carbohydrate.rb +52 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_fat.rb +52 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_sugar.rb +52 -0
- data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_trans_fat.rb +52 -0
- data/lib/mindee/product/receipt/receipt_v5_document.rb +1 -1
- data/lib/mindee/product/receipt/receipt_v5_line_item.rb +11 -1
- data/lib/mindee/product/receipt/receipt_v5_page.rb +1 -1
- data/lib/mindee/product/resume/resume_v1_certificate.rb +11 -1
- data/lib/mindee/product/resume/resume_v1_education.rb +14 -1
- data/lib/mindee/product/resume/resume_v1_language.rb +9 -1
- data/lib/mindee/product/resume/resume_v1_professional_experience.rb +15 -1
- data/lib/mindee/product/resume/resume_v1_social_networks_url.rb +9 -1
- data/lib/mindee/product/us/healthcare_card/healthcare_card_v1.rb +41 -0
- data/lib/mindee/product/us/healthcare_card/healthcare_card_v1_copay.rb +65 -0
- data/lib/mindee/product/us/healthcare_card/healthcare_card_v1_document.rb +127 -0
- data/lib/mindee/product/us/healthcare_card/healthcare_card_v1_page.rb +34 -0
- data/lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb +14 -1
- data/lib/mindee/product/us/us_mail/us_mail_v2_sender_address.rb +5 -17
- data/lib/mindee/product.rb +6 -1
- data/lib/mindee/version.rb +1 -1
- data/mindee.gemspec +1 -0
- metadata +91 -3
- /data/lib/mindee/extraction/{ocr_extractor.rb → tax_extractor/ocr_extractor.rb} +0 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../../parsing'
|
|
4
|
+
|
|
5
|
+
module Mindee
|
|
6
|
+
module Product
|
|
7
|
+
module NutritionFactsLabel
|
|
8
|
+
# The amount of trans fat in the product.
|
|
9
|
+
class NutritionFactsLabelV1TransFat < Mindee::Parsing::Standard::FeatureField
|
|
10
|
+
include Mindee::Parsing::Standard
|
|
11
|
+
# DVs are the recommended amounts of trans fat to consume or not to exceed each day.
|
|
12
|
+
# @return [Float]
|
|
13
|
+
attr_reader :daily_value
|
|
14
|
+
# The amount of trans fat per 100g of the product.
|
|
15
|
+
# @return [Float]
|
|
16
|
+
attr_reader :per_100g
|
|
17
|
+
# The amount of trans fat per serving of the product.
|
|
18
|
+
# @return [Float]
|
|
19
|
+
attr_reader :per_serving
|
|
20
|
+
|
|
21
|
+
# @param prediction [Hash]
|
|
22
|
+
# @param page_id [Integer, nil]
|
|
23
|
+
def initialize(prediction, page_id)
|
|
24
|
+
super(prediction, page_id)
|
|
25
|
+
@daily_value = prediction['daily_value']
|
|
26
|
+
@per_100g = prediction['per_100g']
|
|
27
|
+
@per_serving = prediction['per_serving']
|
|
28
|
+
@page_id = page_id
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# @return [Hash]
|
|
32
|
+
def printable_values
|
|
33
|
+
printable = {}
|
|
34
|
+
printable[:daily_value] = @daily_value.nil? ? '' : Field.float_to_string(@daily_value)
|
|
35
|
+
printable[:per_100g] = @per_100g.nil? ? '' : Field.float_to_string(@per_100g)
|
|
36
|
+
printable[:per_serving] = @per_serving.nil? ? '' : Field.float_to_string(@per_serving)
|
|
37
|
+
printable
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# @return [String]
|
|
41
|
+
def to_s
|
|
42
|
+
printable = printable_values
|
|
43
|
+
out_str = String.new
|
|
44
|
+
out_str << "\n :Daily Value: #{printable[:daily_value]}"
|
|
45
|
+
out_str << "\n :Per 100g: #{printable[:per_100g]}"
|
|
46
|
+
out_str << "\n :Per Serving: #{printable[:per_serving]}"
|
|
47
|
+
out_str
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -6,7 +6,7 @@ require_relative 'receipt_v5_line_item'
|
|
|
6
6
|
module Mindee
|
|
7
7
|
module Product
|
|
8
8
|
module Receipt
|
|
9
|
-
# Receipt API version 5.
|
|
9
|
+
# Receipt API version 5.3 document data.
|
|
10
10
|
class ReceiptV5Document < Mindee::Parsing::Common::Prediction
|
|
11
11
|
include Mindee::Parsing::Standard
|
|
12
12
|
# The purchase category among predefined classes.
|
|
@@ -34,6 +34,16 @@ module Mindee
|
|
|
34
34
|
|
|
35
35
|
# @return [Hash]
|
|
36
36
|
def printable_values
|
|
37
|
+
printable = {}
|
|
38
|
+
printable[:description] = format_for_display(@description)
|
|
39
|
+
printable[:quantity] = @quantity.nil? ? '' : Field.float_to_string(@quantity)
|
|
40
|
+
printable[:total_amount] = @total_amount.nil? ? '' : Field.float_to_string(@total_amount)
|
|
41
|
+
printable[:unit_price] = @unit_price.nil? ? '' : Field.float_to_string(@unit_price)
|
|
42
|
+
printable
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# @return [Hash]
|
|
46
|
+
def table_printable_values
|
|
37
47
|
printable = {}
|
|
38
48
|
printable[:description] = format_for_display(@description, 36)
|
|
39
49
|
printable[:quantity] = @quantity.nil? ? '' : Field.float_to_string(@quantity)
|
|
@@ -44,7 +54,7 @@ module Mindee
|
|
|
44
54
|
|
|
45
55
|
# @return [String]
|
|
46
56
|
def to_table_line
|
|
47
|
-
printable =
|
|
57
|
+
printable = table_printable_values
|
|
48
58
|
out_str = String.new
|
|
49
59
|
out_str << format('| %- 37s', printable[:description])
|
|
50
60
|
out_str << format('| %- 9s', printable[:quantity])
|
|
@@ -6,7 +6,7 @@ require_relative 'receipt_v5_document'
|
|
|
6
6
|
module Mindee
|
|
7
7
|
module Product
|
|
8
8
|
module Receipt
|
|
9
|
-
# Receipt API version 5.
|
|
9
|
+
# Receipt API version 5.3 page data.
|
|
10
10
|
class ReceiptV5Page < Mindee::Parsing::Common::Page
|
|
11
11
|
# @param prediction [Hash]
|
|
12
12
|
def initialize(prediction)
|
|
@@ -34,6 +34,16 @@ module Mindee
|
|
|
34
34
|
|
|
35
35
|
# @return [Hash]
|
|
36
36
|
def printable_values
|
|
37
|
+
printable = {}
|
|
38
|
+
printable[:grade] = format_for_display(@grade)
|
|
39
|
+
printable[:name] = format_for_display(@name)
|
|
40
|
+
printable[:provider] = format_for_display(@provider)
|
|
41
|
+
printable[:year] = format_for_display(@year)
|
|
42
|
+
printable
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# @return [Hash]
|
|
46
|
+
def table_printable_values
|
|
37
47
|
printable = {}
|
|
38
48
|
printable[:grade] = format_for_display(@grade, 10)
|
|
39
49
|
printable[:name] = format_for_display(@name, 30)
|
|
@@ -44,7 +54,7 @@ module Mindee
|
|
|
44
54
|
|
|
45
55
|
# @return [String]
|
|
46
56
|
def to_table_line
|
|
47
|
-
printable =
|
|
57
|
+
printable = table_printable_values
|
|
48
58
|
out_str = String.new
|
|
49
59
|
out_str << format('| %- 11s', printable[:grade])
|
|
50
60
|
out_str << format('| %- 31s', printable[:name])
|
|
@@ -46,6 +46,19 @@ module Mindee
|
|
|
46
46
|
|
|
47
47
|
# @return [Hash]
|
|
48
48
|
def printable_values
|
|
49
|
+
printable = {}
|
|
50
|
+
printable[:degree_domain] = format_for_display(@degree_domain)
|
|
51
|
+
printable[:degree_type] = format_for_display(@degree_type)
|
|
52
|
+
printable[:end_month] = format_for_display(@end_month)
|
|
53
|
+
printable[:end_year] = format_for_display(@end_year)
|
|
54
|
+
printable[:school] = format_for_display(@school)
|
|
55
|
+
printable[:start_month] = format_for_display(@start_month)
|
|
56
|
+
printable[:start_year] = format_for_display(@start_year)
|
|
57
|
+
printable
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# @return [Hash]
|
|
61
|
+
def table_printable_values
|
|
49
62
|
printable = {}
|
|
50
63
|
printable[:degree_domain] = format_for_display(@degree_domain, 15)
|
|
51
64
|
printable[:degree_type] = format_for_display(@degree_type, 25)
|
|
@@ -59,7 +72,7 @@ module Mindee
|
|
|
59
72
|
|
|
60
73
|
# @return [String]
|
|
61
74
|
def to_table_line
|
|
62
|
-
printable =
|
|
75
|
+
printable = table_printable_values
|
|
63
76
|
out_str = String.new
|
|
64
77
|
out_str << format('| %- 16s', printable[:degree_domain])
|
|
65
78
|
out_str << format('| %- 26s', printable[:degree_type])
|
|
@@ -26,6 +26,14 @@ module Mindee
|
|
|
26
26
|
|
|
27
27
|
# @return [Hash]
|
|
28
28
|
def printable_values
|
|
29
|
+
printable = {}
|
|
30
|
+
printable[:language] = format_for_display(@language)
|
|
31
|
+
printable[:level] = format_for_display(@level)
|
|
32
|
+
printable
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# @return [Hash]
|
|
36
|
+
def table_printable_values
|
|
29
37
|
printable = {}
|
|
30
38
|
printable[:language] = format_for_display(@language, nil)
|
|
31
39
|
printable[:level] = format_for_display(@level, 20)
|
|
@@ -34,7 +42,7 @@ module Mindee
|
|
|
34
42
|
|
|
35
43
|
# @return [String]
|
|
36
44
|
def to_table_line
|
|
37
|
-
printable =
|
|
45
|
+
printable = table_printable_values
|
|
38
46
|
out_str = String.new
|
|
39
47
|
out_str << format('| %- 9s', printable[:language])
|
|
40
48
|
out_str << format('| %- 21s', printable[:level])
|
|
@@ -50,6 +50,20 @@ module Mindee
|
|
|
50
50
|
|
|
51
51
|
# @return [Hash]
|
|
52
52
|
def printable_values
|
|
53
|
+
printable = {}
|
|
54
|
+
printable[:contract_type] = format_for_display(@contract_type)
|
|
55
|
+
printable[:department] = format_for_display(@department)
|
|
56
|
+
printable[:employer] = format_for_display(@employer)
|
|
57
|
+
printable[:end_month] = format_for_display(@end_month)
|
|
58
|
+
printable[:end_year] = format_for_display(@end_year)
|
|
59
|
+
printable[:role] = format_for_display(@role)
|
|
60
|
+
printable[:start_month] = format_for_display(@start_month)
|
|
61
|
+
printable[:start_year] = format_for_display(@start_year)
|
|
62
|
+
printable
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# @return [Hash]
|
|
66
|
+
def table_printable_values
|
|
53
67
|
printable = {}
|
|
54
68
|
printable[:contract_type] = format_for_display(@contract_type, 15)
|
|
55
69
|
printable[:department] = format_for_display(@department, 10)
|
|
@@ -64,7 +78,7 @@ module Mindee
|
|
|
64
78
|
|
|
65
79
|
# @return [String]
|
|
66
80
|
def to_table_line
|
|
67
|
-
printable =
|
|
81
|
+
printable = table_printable_values
|
|
68
82
|
out_str = String.new
|
|
69
83
|
out_str << format('| %- 16s', printable[:contract_type])
|
|
70
84
|
out_str << format('| %- 11s', printable[:department])
|
|
@@ -26,6 +26,14 @@ module Mindee
|
|
|
26
26
|
|
|
27
27
|
# @return [Hash]
|
|
28
28
|
def printable_values
|
|
29
|
+
printable = {}
|
|
30
|
+
printable[:name] = format_for_display(@name)
|
|
31
|
+
printable[:url] = format_for_display(@url)
|
|
32
|
+
printable
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# @return [Hash]
|
|
36
|
+
def table_printable_values
|
|
29
37
|
printable = {}
|
|
30
38
|
printable[:name] = format_for_display(@name, 20)
|
|
31
39
|
printable[:url] = format_for_display(@url, 50)
|
|
@@ -34,7 +42,7 @@ module Mindee
|
|
|
34
42
|
|
|
35
43
|
# @return [String]
|
|
36
44
|
def to_table_line
|
|
37
|
-
printable =
|
|
45
|
+
printable = table_printable_values
|
|
38
46
|
out_str = String.new
|
|
39
47
|
out_str << format('| %- 21s', printable[:name])
|
|
40
48
|
out_str << format('| %- 51s', printable[:url])
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../../../parsing'
|
|
4
|
+
require_relative 'healthcare_card_v1_document'
|
|
5
|
+
require_relative 'healthcare_card_v1_page'
|
|
6
|
+
|
|
7
|
+
module Mindee
|
|
8
|
+
module Product
|
|
9
|
+
module US
|
|
10
|
+
# Healthcare Card module.
|
|
11
|
+
module HealthcareCard
|
|
12
|
+
# Healthcare Card API version 1 inference prediction.
|
|
13
|
+
class HealthcareCardV1 < Mindee::Parsing::Common::Inference
|
|
14
|
+
@endpoint_name = 'us_healthcare_cards'
|
|
15
|
+
@endpoint_version = '1'
|
|
16
|
+
|
|
17
|
+
# @param prediction [Hash]
|
|
18
|
+
def initialize(prediction)
|
|
19
|
+
super
|
|
20
|
+
@prediction = HealthcareCardV1Document.new(prediction['prediction'], nil)
|
|
21
|
+
@pages = []
|
|
22
|
+
prediction['pages'].each do |page|
|
|
23
|
+
if page.key?('prediction') && !page['prediction'].nil? && !page['prediction'].empty?
|
|
24
|
+
@pages.push(HealthcareCardV1Page.new(page))
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
class << self
|
|
30
|
+
# Name of the endpoint for this product.
|
|
31
|
+
# @return [String]
|
|
32
|
+
attr_reader :endpoint_name
|
|
33
|
+
# Version for this product.
|
|
34
|
+
# @return [String]
|
|
35
|
+
attr_reader :endpoint_version
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../../../parsing'
|
|
4
|
+
|
|
5
|
+
module Mindee
|
|
6
|
+
module Product
|
|
7
|
+
module US
|
|
8
|
+
module HealthcareCard
|
|
9
|
+
# Is a fixed amount for a covered service.
|
|
10
|
+
class HealthcareCardV1Copay < Mindee::Parsing::Standard::FeatureField
|
|
11
|
+
include Mindee::Parsing::Standard
|
|
12
|
+
# The price of service.
|
|
13
|
+
# @return [Float]
|
|
14
|
+
attr_reader :service_fees
|
|
15
|
+
# The name of service of the copay.
|
|
16
|
+
# @return [String]
|
|
17
|
+
attr_reader :service_name
|
|
18
|
+
|
|
19
|
+
# @param prediction [Hash]
|
|
20
|
+
# @param page_id [Integer, nil]
|
|
21
|
+
def initialize(prediction, page_id)
|
|
22
|
+
super(prediction, page_id)
|
|
23
|
+
@service_fees = prediction['service_fees']
|
|
24
|
+
@service_name = prediction['service_name']
|
|
25
|
+
@page_id = page_id
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# @return [Hash]
|
|
29
|
+
def printable_values
|
|
30
|
+
printable = {}
|
|
31
|
+
printable[:service_fees] = @service_fees.nil? ? '' : Field.float_to_string(@service_fees)
|
|
32
|
+
printable[:service_name] = format_for_display(@service_name)
|
|
33
|
+
printable
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# @return [Hash]
|
|
37
|
+
def table_printable_values
|
|
38
|
+
printable = {}
|
|
39
|
+
printable[:service_fees] = @service_fees.nil? ? '' : Field.float_to_string(@service_fees)
|
|
40
|
+
printable[:service_name] = format_for_display(@service_name, nil)
|
|
41
|
+
printable
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# @return [String]
|
|
45
|
+
def to_table_line
|
|
46
|
+
printable = table_printable_values
|
|
47
|
+
out_str = String.new
|
|
48
|
+
out_str << format('| %- 13s', printable[:service_fees])
|
|
49
|
+
out_str << format('| %- 13s', printable[:service_name])
|
|
50
|
+
out_str << '|'
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# @return [String]
|
|
54
|
+
def to_s
|
|
55
|
+
printable = printable_values
|
|
56
|
+
out_str = String.new
|
|
57
|
+
out_str << "\n :Service Fees: #{printable[:service_fees]}"
|
|
58
|
+
out_str << "\n :Service Name: #{printable[:service_name]}"
|
|
59
|
+
out_str
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../../../parsing'
|
|
4
|
+
require_relative 'healthcare_card_v1_copay'
|
|
5
|
+
|
|
6
|
+
module Mindee
|
|
7
|
+
module Product
|
|
8
|
+
module US
|
|
9
|
+
module HealthcareCard
|
|
10
|
+
# Healthcare Card API version 1.0 document data.
|
|
11
|
+
class HealthcareCardV1Document < Mindee::Parsing::Common::Prediction
|
|
12
|
+
include Mindee::Parsing::Standard
|
|
13
|
+
# The name of the company that provides the healthcare plan.
|
|
14
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
15
|
+
attr_reader :company_name
|
|
16
|
+
# Is a fixed amount for a covered service.
|
|
17
|
+
# @return [Array<Mindee::Product::US::HealthcareCard::HealthcareCardV1Copay>]
|
|
18
|
+
attr_reader :copays
|
|
19
|
+
# The list of dependents covered by the healthcare plan.
|
|
20
|
+
# @return [Array<Mindee::Parsing::Standard::StringField>]
|
|
21
|
+
attr_reader :dependents
|
|
22
|
+
# The date when the member enrolled in the healthcare plan.
|
|
23
|
+
# @return [Mindee::Parsing::Standard::DateField]
|
|
24
|
+
attr_reader :enrollment_date
|
|
25
|
+
# The group number associated with the healthcare plan.
|
|
26
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
27
|
+
attr_reader :group_number
|
|
28
|
+
# The organization that issued the healthcare plan.
|
|
29
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
30
|
+
attr_reader :issuer80840
|
|
31
|
+
# The unique identifier for the member in the healthcare system.
|
|
32
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
33
|
+
attr_reader :member_id
|
|
34
|
+
# The name of the member covered by the healthcare plan.
|
|
35
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
36
|
+
attr_reader :member_name
|
|
37
|
+
# The unique identifier for the payer in the healthcare system.
|
|
38
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
39
|
+
attr_reader :payer_id
|
|
40
|
+
# The BIN number for prescription drug coverage.
|
|
41
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
42
|
+
attr_reader :rx_bin
|
|
43
|
+
# The group number for prescription drug coverage.
|
|
44
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
45
|
+
attr_reader :rx_grp
|
|
46
|
+
# The PCN number for prescription drug coverage.
|
|
47
|
+
# @return [Mindee::Parsing::Standard::StringField]
|
|
48
|
+
attr_reader :rx_pcn
|
|
49
|
+
|
|
50
|
+
# @param prediction [Hash]
|
|
51
|
+
# @param page_id [Integer, nil]
|
|
52
|
+
def initialize(prediction, page_id)
|
|
53
|
+
super()
|
|
54
|
+
@company_name = StringField.new(prediction['company_name'], page_id)
|
|
55
|
+
@copays = []
|
|
56
|
+
prediction['copays'].each do |item|
|
|
57
|
+
@copays.push(HealthcareCardV1Copay.new(item, page_id))
|
|
58
|
+
end
|
|
59
|
+
@dependents = []
|
|
60
|
+
prediction['dependents'].each do |item|
|
|
61
|
+
@dependents.push(StringField.new(item, page_id))
|
|
62
|
+
end
|
|
63
|
+
@enrollment_date = DateField.new(prediction['enrollment_date'], page_id)
|
|
64
|
+
@group_number = StringField.new(prediction['group_number'], page_id)
|
|
65
|
+
@issuer80840 = StringField.new(prediction['issuer_80840'], page_id)
|
|
66
|
+
@member_id = StringField.new(prediction['member_id'], page_id)
|
|
67
|
+
@member_name = StringField.new(prediction['member_name'], page_id)
|
|
68
|
+
@payer_id = StringField.new(prediction['payer_id'], page_id)
|
|
69
|
+
@rx_bin = StringField.new(prediction['rx_bin'], page_id)
|
|
70
|
+
@rx_grp = StringField.new(prediction['rx_grp'], page_id)
|
|
71
|
+
@rx_pcn = StringField.new(prediction['rx_pcn'], page_id)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# @return [String]
|
|
75
|
+
def to_s
|
|
76
|
+
dependents = @dependents.join("\n #{' ' * 12}")
|
|
77
|
+
copays = copays_to_s
|
|
78
|
+
out_str = String.new
|
|
79
|
+
out_str << "\n:Company Name: #{@company_name}".rstrip
|
|
80
|
+
out_str << "\n:Member Name: #{@member_name}".rstrip
|
|
81
|
+
out_str << "\n:Member ID: #{@member_id}".rstrip
|
|
82
|
+
out_str << "\n:Issuer 80840: #{@issuer80840}".rstrip
|
|
83
|
+
out_str << "\n:Dependents: #{dependents}".rstrip
|
|
84
|
+
out_str << "\n:Group Number: #{@group_number}".rstrip
|
|
85
|
+
out_str << "\n:Payer ID: #{@payer_id}".rstrip
|
|
86
|
+
out_str << "\n:RX BIN: #{@rx_bin}".rstrip
|
|
87
|
+
out_str << "\n:RX GRP: #{@rx_grp}".rstrip
|
|
88
|
+
out_str << "\n:RX PCN: #{@rx_pcn}".rstrip
|
|
89
|
+
out_str << "\n:copays:"
|
|
90
|
+
out_str << copays
|
|
91
|
+
out_str << "\n:Enrollment Date: #{@enrollment_date}".rstrip
|
|
92
|
+
out_str[1..].to_s
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
private
|
|
96
|
+
|
|
97
|
+
# @param char [String]
|
|
98
|
+
# @return [String]
|
|
99
|
+
def copays_separator(char)
|
|
100
|
+
out_str = String.new
|
|
101
|
+
out_str << ' '
|
|
102
|
+
out_str << "+#{char * 14}"
|
|
103
|
+
out_str << "+#{char * 14}"
|
|
104
|
+
out_str << '+'
|
|
105
|
+
out_str
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# @return [String]
|
|
109
|
+
def copays_to_s
|
|
110
|
+
return '' if @copays.empty?
|
|
111
|
+
|
|
112
|
+
line_items = @copays.map(&:to_table_line).join("\n#{copays_separator('-')}\n ")
|
|
113
|
+
out_str = String.new
|
|
114
|
+
out_str << "\n#{copays_separator('-')}"
|
|
115
|
+
out_str << "\n |"
|
|
116
|
+
out_str << ' Service Fees |'
|
|
117
|
+
out_str << ' Service Name |'
|
|
118
|
+
out_str << "\n#{copays_separator('=')}"
|
|
119
|
+
out_str << "\n #{line_items}"
|
|
120
|
+
out_str << "\n#{copays_separator('-')}"
|
|
121
|
+
out_str
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../../../parsing'
|
|
4
|
+
require_relative 'healthcare_card_v1_document'
|
|
5
|
+
|
|
6
|
+
module Mindee
|
|
7
|
+
module Product
|
|
8
|
+
module US
|
|
9
|
+
module HealthcareCard
|
|
10
|
+
# Healthcare Card API version 1.0 page data.
|
|
11
|
+
class HealthcareCardV1Page < Mindee::Parsing::Common::Page
|
|
12
|
+
# @param prediction [Hash]
|
|
13
|
+
def initialize(prediction)
|
|
14
|
+
super(prediction)
|
|
15
|
+
@prediction = HealthcareCardV1PagePrediction.new(
|
|
16
|
+
prediction['prediction'],
|
|
17
|
+
prediction['id']
|
|
18
|
+
)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Healthcare Card V1 page prediction.
|
|
23
|
+
class HealthcareCardV1PagePrediction < HealthcareCardV1Document
|
|
24
|
+
# @return [String]
|
|
25
|
+
def to_s
|
|
26
|
+
out_str = String.new
|
|
27
|
+
out_str << "\n#{super}"
|
|
28
|
+
out_str
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -47,6 +47,19 @@ module Mindee
|
|
|
47
47
|
|
|
48
48
|
# @return [Hash]
|
|
49
49
|
def printable_values
|
|
50
|
+
printable = {}
|
|
51
|
+
printable[:city] = format_for_display(@city)
|
|
52
|
+
printable[:complete] = format_for_display(@complete)
|
|
53
|
+
printable[:is_address_change] = format_for_display(@is_address_change)
|
|
54
|
+
printable[:postal_code] = format_for_display(@postal_code)
|
|
55
|
+
printable[:private_mailbox_number] = format_for_display(@private_mailbox_number)
|
|
56
|
+
printable[:state] = format_for_display(@state)
|
|
57
|
+
printable[:street] = format_for_display(@street)
|
|
58
|
+
printable
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# @return [Hash]
|
|
62
|
+
def table_printable_values
|
|
50
63
|
printable = {}
|
|
51
64
|
printable[:city] = format_for_display(@city, 15)
|
|
52
65
|
printable[:complete] = format_for_display(@complete, 35)
|
|
@@ -60,7 +73,7 @@ module Mindee
|
|
|
60
73
|
|
|
61
74
|
# @return [String]
|
|
62
75
|
def to_table_line
|
|
63
|
-
printable =
|
|
76
|
+
printable = table_printable_values
|
|
64
77
|
out_str = String.new
|
|
65
78
|
out_str << format('| %- 16s', printable[:city])
|
|
66
79
|
out_str << format('| %- 36s', printable[:complete])
|
|
@@ -40,26 +40,14 @@ module Mindee
|
|
|
40
40
|
# @return [Hash]
|
|
41
41
|
def printable_values
|
|
42
42
|
printable = {}
|
|
43
|
-
printable[:city] = format_for_display(@city
|
|
44
|
-
printable[:complete] = format_for_display(@complete
|
|
45
|
-
printable[:postal_code] = format_for_display(@postal_code
|
|
46
|
-
printable[:state] = format_for_display(@state
|
|
47
|
-
printable[:street] = format_for_display(@street
|
|
43
|
+
printable[:city] = format_for_display(@city)
|
|
44
|
+
printable[:complete] = format_for_display(@complete)
|
|
45
|
+
printable[:postal_code] = format_for_display(@postal_code)
|
|
46
|
+
printable[:state] = format_for_display(@state)
|
|
47
|
+
printable[:street] = format_for_display(@street)
|
|
48
48
|
printable
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
-
# @return [String]
|
|
52
|
-
def to_table_line
|
|
53
|
-
printable = printable_values
|
|
54
|
-
out_str = String.new
|
|
55
|
-
out_str << format('| %- 16s', printable[:city])
|
|
56
|
-
out_str << format('| %- 36s', printable[:complete])
|
|
57
|
-
out_str << format('| %- 12s', printable[:postal_code])
|
|
58
|
-
out_str << format('| %- 6s', printable[:state])
|
|
59
|
-
out_str << format('| %- 26s', printable[:street])
|
|
60
|
-
out_str << '|'
|
|
61
|
-
end
|
|
62
|
-
|
|
63
51
|
# @return [String]
|
|
64
52
|
def to_s
|
|
65
53
|
printable = printable_values
|
data/lib/mindee/product.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative 'product/barcode_reader/barcode_reader_v1'
|
|
4
|
+
require_relative 'product/bill_of_lading/bill_of_lading_v1'
|
|
4
5
|
require_relative 'product/custom/custom_v1'
|
|
5
6
|
require_relative 'product/proof_of_address/proof_of_address_v1'
|
|
6
7
|
require_relative 'product/financial_document/financial_document_v1'
|
|
@@ -15,16 +16,20 @@ require_relative 'product/eu/driver_license/driver_license_v1'
|
|
|
15
16
|
require_relative 'product/fr/bank_account_details/bank_account_details_v1'
|
|
16
17
|
require_relative 'product/fr/bank_account_details/bank_account_details_v2'
|
|
17
18
|
require_relative 'product/fr/bank_statement/bank_statement_v1'
|
|
19
|
+
require_relative 'product/fr/carte_grise/carte_grise_v1'
|
|
18
20
|
require_relative 'product/fr/carte_vitale/carte_vitale_v1'
|
|
19
21
|
require_relative 'product/fr/id_card/id_card_v1'
|
|
20
22
|
require_relative 'product/fr/id_card/id_card_v2'
|
|
21
|
-
require_relative 'product/fr/
|
|
23
|
+
require_relative 'product/fr/energy_bill/energy_bill_v1'
|
|
24
|
+
require_relative 'product/fr/payslip/payslip_v2'
|
|
22
25
|
require_relative 'product/generated/generated_v1'
|
|
23
26
|
require_relative 'product/invoice_splitter/invoice_splitter_v1'
|
|
24
27
|
require_relative 'product/international_id/international_id_v1'
|
|
25
28
|
require_relative 'product/international_id/international_id_v2'
|
|
29
|
+
require_relative 'product/nutrition_facts_label/nutrition_facts_label_v1'
|
|
26
30
|
require_relative 'product/resume/resume_v1'
|
|
27
31
|
require_relative 'product/us/bank_check/bank_check_v1'
|
|
28
32
|
require_relative 'product/us/driver_license/driver_license_v1'
|
|
33
|
+
require_relative 'product/us/healthcare_card/healthcare_card_v1'
|
|
29
34
|
require_relative 'product/us/us_mail/us_mail_v2'
|
|
30
35
|
require_relative 'product/us/w9/w9_v1'
|
data/lib/mindee/version.rb
CHANGED
data/mindee.gemspec
CHANGED
|
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
|
|
|
30
30
|
spec.required_ruby_version = Gem::Requirement.new('>= 2.6')
|
|
31
31
|
|
|
32
32
|
spec.add_runtime_dependency 'marcel', '~> 1.0.2'
|
|
33
|
+
spec.add_runtime_dependency 'mini_magick', '~> 4.13.0'
|
|
33
34
|
spec.add_runtime_dependency 'origamindee', '~> 3.1.0'
|
|
34
35
|
|
|
35
36
|
spec.add_development_dependency 'rake', '~> 12.3.3'
|