mindee 3.10.0 → 3.12.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/CHANGELOG.md +14 -0
- data/bin/mindee.rb +7 -1
- data/docs/code_samples/financial_document_v1_async.txt +19 -0
- data/docs/code_samples/us_healthcare_cards_v1_async.txt +19 -0
- data/docs/expense_receipts_v5.md +12 -10
- data/docs/financial_document_v1.md +51 -22
- data/docs/invoices_v4.md +4 -3
- data/docs/us_healthcare_cards_v1.md +204 -0
- data/lib/mindee/extraction/ocr_extractor.rb +110 -0
- data/lib/mindee/extraction/tax_extractor.rb +322 -0
- data/lib/mindee/extraction.rb +3 -0
- data/lib/mindee/geometry/utils.rb +19 -0
- data/lib/mindee/image_extraction/common/extracted_image.rb +73 -0
- data/lib/mindee/image_extraction/common/image_extractor.rb +191 -0
- data/lib/mindee/image_extraction/common.rb +3 -0
- data/lib/mindee/image_extraction/multi_receipts_extractor/multi_receipts_extractor.rb +26 -0
- data/lib/mindee/image_extraction/multi_receipts_extractor.rb +3 -0
- data/lib/mindee/image_extraction.rb +4 -0
- data/lib/mindee/input/sources.rb +8 -0
- data/lib/mindee/parsing/common/api_response.rb +1 -1
- data/lib/mindee/parsing/common/ocr/mvision_v1.rb +16 -0
- data/lib/mindee/parsing/common/ocr/ocr.rb +10 -0
- data/lib/mindee/parsing/standard/company_registration_field.rb +17 -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 +7 -0
- data/lib/mindee/product/financial_document/financial_document_v1_page.rb +1 -1
- 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 +7 -0
- data/lib/mindee/product/invoice/invoice_v4_page.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/receipt/receipt_v5_document.rb +1 -1
- data/lib/mindee/product/receipt/receipt_v5_page.rb +1 -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 +57 -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.rb +1 -0
- data/lib/mindee/version.rb +1 -1
- data/lib/mindee.rb +5 -0
- data/mindee.gemspec +1 -0
- metadata +32 -2
@@ -27,6 +27,22 @@ module Mindee
|
|
27
27
|
end
|
28
28
|
out_str.strip
|
29
29
|
end
|
30
|
+
|
31
|
+
# Constructs a line from a column, located underneath given coordinates
|
32
|
+
# @param coordinates [Array<Mindee::Geometry::Point>] Polygon or bounding box where the reconstruction should
|
33
|
+
# start.
|
34
|
+
# @param page_id [Integer] ID of the page to start at
|
35
|
+
# @param x_margin [Float] Margin of misalignment for the x coordinate.
|
36
|
+
# @return [Mindee::Parsing::Common::Ocr::OcrLine]
|
37
|
+
def reconstruct_vertically(coordinates, page_id, x_margin)
|
38
|
+
line_arr = OcrLine.new([])
|
39
|
+
@pages[page_id].all_lines.each do |line|
|
40
|
+
line.each do |word|
|
41
|
+
line_arr.push(word) if Geometry.below?(word.polygon, coordinates, x_margin / 2, x_margin * 2)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
line_arr
|
45
|
+
end
|
30
46
|
end
|
31
47
|
end
|
32
48
|
end
|
@@ -163,6 +163,16 @@ module Mindee
|
|
163
163
|
def to_s
|
164
164
|
@mvision_v1.to_s
|
165
165
|
end
|
166
|
+
|
167
|
+
# Constructs a line from a column, located underneath given coordinates
|
168
|
+
# @param coordinates [Array<Mindee::Geometry::Point>] Polygon or bounding box where the reconstruction should
|
169
|
+
# start
|
170
|
+
# @param page_id [Integer] ID of the page to start at
|
171
|
+
# @param x_margin [Float] Margin of misalignment for the x coordinate (default 10%)
|
172
|
+
# @return [Mindee::Parsing::Common::Ocr::OcrLine]
|
173
|
+
def reconstruct_vertically(coordinates, page_id, x_margin = 0.05)
|
174
|
+
@mvision_v1.reconstruct_vertically(coordinates, page_id, x_margin)
|
175
|
+
end
|
166
176
|
end
|
167
177
|
end
|
168
178
|
end
|
@@ -15,6 +15,23 @@ module Mindee
|
|
15
15
|
super
|
16
16
|
@type = prediction['type']
|
17
17
|
end
|
18
|
+
|
19
|
+
def to_table_line
|
20
|
+
printable = printable_values
|
21
|
+
format('| %<type>-15s | %<value>-20s ', type: printable['type'], value: printable['value'])
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_s
|
25
|
+
printable = printable_values
|
26
|
+
format('Type: %<type>s, Value: %<value>s', type: printable['type'], value: printable['value'])
|
27
|
+
end
|
28
|
+
|
29
|
+
def printable_values
|
30
|
+
printable = {}
|
31
|
+
printable['type'] = type
|
32
|
+
printable['value'] = value
|
33
|
+
printable
|
34
|
+
end
|
18
35
|
end
|
19
36
|
end
|
20
37
|
end
|
@@ -6,7 +6,7 @@ require_relative 'financial_document_v1_line_item'
|
|
6
6
|
module Mindee
|
7
7
|
module Product
|
8
8
|
module FinancialDocument
|
9
|
-
# Financial Document API version 1.
|
9
|
+
# Financial Document API version 1.9 document data.
|
10
10
|
class FinancialDocumentV1Document < Mindee::Parsing::Common::Prediction
|
11
11
|
include Mindee::Parsing::Standard
|
12
12
|
# The customer's address used for billing.
|
@@ -206,6 +206,7 @@ module Mindee
|
|
206
206
|
out_str << "+#{char * 12}"
|
207
207
|
out_str << "+#{char * 14}"
|
208
208
|
out_str << "+#{char * 14}"
|
209
|
+
out_str << "+#{char * 17}"
|
209
210
|
out_str << "+#{char * 12}"
|
210
211
|
out_str << '+'
|
211
212
|
out_str
|
@@ -225,6 +226,7 @@ module Mindee
|
|
225
226
|
out_str << ' Tax Amount |'
|
226
227
|
out_str << ' Tax Rate (%) |'
|
227
228
|
out_str << ' Total Amount |'
|
229
|
+
out_str << ' Unit of measure |'
|
228
230
|
out_str << ' Unit Price |'
|
229
231
|
out_str << "\n#{line_items_separator('=')}"
|
230
232
|
out_str << "\n #{line_items}"
|
@@ -26,6 +26,9 @@ module Mindee
|
|
26
26
|
# The item total amount.
|
27
27
|
# @return [Float]
|
28
28
|
attr_reader :total_amount
|
29
|
+
# The item unit of measure.
|
30
|
+
# @return [String]
|
31
|
+
attr_reader :unit_measure
|
29
32
|
# The item unit price.
|
30
33
|
# @return [Float]
|
31
34
|
attr_reader :unit_price
|
@@ -40,6 +43,7 @@ module Mindee
|
|
40
43
|
@tax_amount = prediction['tax_amount']
|
41
44
|
@tax_rate = prediction['tax_rate']
|
42
45
|
@total_amount = prediction['total_amount']
|
46
|
+
@unit_measure = prediction['unit_measure']
|
43
47
|
@unit_price = prediction['unit_price']
|
44
48
|
@page_id = page_id
|
45
49
|
end
|
@@ -53,6 +57,7 @@ module Mindee
|
|
53
57
|
printable[:tax_amount] = @tax_amount.nil? ? '' : Field.float_to_string(@tax_amount)
|
54
58
|
printable[:tax_rate] = @tax_rate.nil? ? '' : Field.float_to_string(@tax_rate)
|
55
59
|
printable[:total_amount] = @total_amount.nil? ? '' : Field.float_to_string(@total_amount)
|
60
|
+
printable[:unit_measure] = format_for_display(@unit_measure, nil)
|
56
61
|
printable[:unit_price] = @unit_price.nil? ? '' : Field.float_to_string(@unit_price)
|
57
62
|
printable
|
58
63
|
end
|
@@ -67,6 +72,7 @@ module Mindee
|
|
67
72
|
out_str << format('| %- 11s', printable[:tax_amount])
|
68
73
|
out_str << format('| %- 13s', printable[:tax_rate])
|
69
74
|
out_str << format('| %- 13s', printable[:total_amount])
|
75
|
+
out_str << format('| %- 16s', printable[:unit_measure])
|
70
76
|
out_str << format('| %- 11s', printable[:unit_price])
|
71
77
|
out_str << '|'
|
72
78
|
end
|
@@ -81,6 +87,7 @@ module Mindee
|
|
81
87
|
out_str << "\n :Tax Amount: #{printable[:tax_amount]}"
|
82
88
|
out_str << "\n :Tax Rate (%): #{printable[:tax_rate]}"
|
83
89
|
out_str << "\n :Total Amount: #{printable[:total_amount]}"
|
90
|
+
out_str << "\n :Unit of measure: #{printable[:unit_measure]}"
|
84
91
|
out_str << "\n :Unit Price: #{printable[:unit_price]}"
|
85
92
|
out_str
|
86
93
|
end
|
@@ -6,7 +6,7 @@ require_relative 'financial_document_v1_document'
|
|
6
6
|
module Mindee
|
7
7
|
module Product
|
8
8
|
module FinancialDocument
|
9
|
-
# Financial Document API version 1.
|
9
|
+
# Financial Document API version 1.9 page data.
|
10
10
|
class FinancialDocumentV1Page < Mindee::Parsing::Common::Page
|
11
11
|
# @param prediction [Hash]
|
12
12
|
def initialize(prediction)
|
@@ -5,7 +5,7 @@ require_relative '../../parsing'
|
|
5
5
|
module Mindee
|
6
6
|
module Product
|
7
7
|
module InternationalId
|
8
|
-
# International ID API version 2.
|
8
|
+
# International ID API version 2.1 document data.
|
9
9
|
class InternationalIdV2Document < Mindee::Parsing::Common::Prediction
|
10
10
|
include Mindee::Parsing::Standard
|
11
11
|
# The physical address of the document holder.
|
@@ -6,7 +6,7 @@ require_relative 'international_id_v2_document'
|
|
6
6
|
module Mindee
|
7
7
|
module Product
|
8
8
|
module InternationalId
|
9
|
-
# International ID API version 2.
|
9
|
+
# International ID API version 2.1 page data.
|
10
10
|
class InternationalIdV2Page < Mindee::Parsing::Common::Page
|
11
11
|
# @param prediction [Hash]
|
12
12
|
def initialize(prediction)
|
@@ -6,7 +6,7 @@ require_relative 'invoice_v4_line_item'
|
|
6
6
|
module Mindee
|
7
7
|
module Product
|
8
8
|
module Invoice
|
9
|
-
# Invoice API version 4.
|
9
|
+
# Invoice API version 4.7 document data.
|
10
10
|
class InvoiceV4Document < Mindee::Parsing::Common::Prediction
|
11
11
|
include Mindee::Parsing::Standard
|
12
12
|
# The customer's address used for billing.
|
@@ -176,6 +176,7 @@ module Mindee
|
|
176
176
|
out_str << "+#{char * 12}"
|
177
177
|
out_str << "+#{char * 14}"
|
178
178
|
out_str << "+#{char * 14}"
|
179
|
+
out_str << "+#{char * 17}"
|
179
180
|
out_str << "+#{char * 12}"
|
180
181
|
out_str << '+'
|
181
182
|
out_str
|
@@ -195,6 +196,7 @@ module Mindee
|
|
195
196
|
out_str << ' Tax Amount |'
|
196
197
|
out_str << ' Tax Rate (%) |'
|
197
198
|
out_str << ' Total Amount |'
|
199
|
+
out_str << ' Unit of measure |'
|
198
200
|
out_str << ' Unit Price |'
|
199
201
|
out_str << "\n#{line_items_separator('=')}"
|
200
202
|
out_str << "\n #{line_items}"
|
@@ -26,6 +26,9 @@ module Mindee
|
|
26
26
|
# The item total amount.
|
27
27
|
# @return [Float]
|
28
28
|
attr_reader :total_amount
|
29
|
+
# The item unit of measure.
|
30
|
+
# @return [String]
|
31
|
+
attr_reader :unit_measure
|
29
32
|
# The item unit price.
|
30
33
|
# @return [Float]
|
31
34
|
attr_reader :unit_price
|
@@ -40,6 +43,7 @@ module Mindee
|
|
40
43
|
@tax_amount = prediction['tax_amount']
|
41
44
|
@tax_rate = prediction['tax_rate']
|
42
45
|
@total_amount = prediction['total_amount']
|
46
|
+
@unit_measure = prediction['unit_measure']
|
43
47
|
@unit_price = prediction['unit_price']
|
44
48
|
@page_id = page_id
|
45
49
|
end
|
@@ -53,6 +57,7 @@ module Mindee
|
|
53
57
|
printable[:tax_amount] = @tax_amount.nil? ? '' : Field.float_to_string(@tax_amount)
|
54
58
|
printable[:tax_rate] = @tax_rate.nil? ? '' : Field.float_to_string(@tax_rate)
|
55
59
|
printable[:total_amount] = @total_amount.nil? ? '' : Field.float_to_string(@total_amount)
|
60
|
+
printable[:unit_measure] = format_for_display(@unit_measure, nil)
|
56
61
|
printable[:unit_price] = @unit_price.nil? ? '' : Field.float_to_string(@unit_price)
|
57
62
|
printable
|
58
63
|
end
|
@@ -67,6 +72,7 @@ module Mindee
|
|
67
72
|
out_str << format('| %- 11s', printable[:tax_amount])
|
68
73
|
out_str << format('| %- 13s', printable[:tax_rate])
|
69
74
|
out_str << format('| %- 13s', printable[:total_amount])
|
75
|
+
out_str << format('| %- 16s', printable[:unit_measure])
|
70
76
|
out_str << format('| %- 11s', printable[:unit_price])
|
71
77
|
out_str << '|'
|
72
78
|
end
|
@@ -81,6 +87,7 @@ module Mindee
|
|
81
87
|
out_str << "\n :Tax Amount: #{printable[:tax_amount]}"
|
82
88
|
out_str << "\n :Tax Rate (%): #{printable[:tax_rate]}"
|
83
89
|
out_str << "\n :Total Amount: #{printable[:total_amount]}"
|
90
|
+
out_str << "\n :Unit of measure: #{printable[:unit_measure]}"
|
84
91
|
out_str << "\n :Unit Price: #{printable[:unit_price]}"
|
85
92
|
out_str
|
86
93
|
end
|
@@ -6,7 +6,7 @@ require_relative 'invoice_v4_document'
|
|
6
6
|
module Mindee
|
7
7
|
module Product
|
8
8
|
module Invoice
|
9
|
-
# Invoice API version 4.
|
9
|
+
# Invoice API version 4.7 page data.
|
10
10
|
class InvoiceV4Page < Mindee::Parsing::Common::Page
|
11
11
|
# @param prediction [Hash]
|
12
12
|
def initialize(prediction)
|
@@ -5,7 +5,7 @@ require_relative '../../parsing'
|
|
5
5
|
module Mindee
|
6
6
|
module Product
|
7
7
|
module MultiReceiptsDetector
|
8
|
-
# Multi Receipts Detector API version 1.
|
8
|
+
# Multi Receipts Detector API version 1.1 document data.
|
9
9
|
class MultiReceiptsDetectorV1Document < Mindee::Parsing::Common::Prediction
|
10
10
|
include Mindee::Parsing::Standard
|
11
11
|
# Positions of the receipts on the document.
|
@@ -6,7 +6,7 @@ require_relative 'multi_receipts_detector_v1_document'
|
|
6
6
|
module Mindee
|
7
7
|
module Product
|
8
8
|
module MultiReceiptsDetector
|
9
|
-
# Multi Receipts Detector API version 1.
|
9
|
+
# Multi Receipts Detector API version 1.1 page data.
|
10
10
|
class MultiReceiptsDetectorV1Page < Mindee::Parsing::Common::Page
|
11
11
|
# @param prediction [Hash]
|
12
12
|
def initialize(prediction)
|
@@ -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.
|
@@ -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)
|
@@ -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,57 @@
|
|
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, nil)
|
33
|
+
printable
|
34
|
+
end
|
35
|
+
|
36
|
+
# @return [String]
|
37
|
+
def to_table_line
|
38
|
+
printable = printable_values
|
39
|
+
out_str = String.new
|
40
|
+
out_str << format('| %- 13s', printable[:service_fees])
|
41
|
+
out_str << format('| %- 13s', printable[:service_name])
|
42
|
+
out_str << '|'
|
43
|
+
end
|
44
|
+
|
45
|
+
# @return [String]
|
46
|
+
def to_s
|
47
|
+
printable = printable_values
|
48
|
+
out_str = String.new
|
49
|
+
out_str << "\n :Service Fees: #{printable[:service_fees]}"
|
50
|
+
out_str << "\n :Service Name: #{printable[:service_name]}"
|
51
|
+
out_str
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
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
|
data/lib/mindee/product.rb
CHANGED
@@ -26,5 +26,6 @@ require_relative 'product/international_id/international_id_v2'
|
|
26
26
|
require_relative 'product/resume/resume_v1'
|
27
27
|
require_relative 'product/us/bank_check/bank_check_v1'
|
28
28
|
require_relative 'product/us/driver_license/driver_license_v1'
|
29
|
+
require_relative 'product/us/healthcare_card/healthcare_card_v1'
|
29
30
|
require_relative 'product/us/us_mail/us_mail_v2'
|
30
31
|
require_relative 'product/us/w9/w9_v1'
|
data/lib/mindee/version.rb
CHANGED
data/lib/mindee.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'mindee/client'
|
4
|
+
require 'mindee/extraction'
|
4
5
|
|
5
6
|
module Mindee
|
6
7
|
# Mindee internal http module.
|
@@ -18,6 +19,10 @@ module Mindee
|
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
22
|
+
# Custom extraction module
|
23
|
+
module Extraction
|
24
|
+
end
|
25
|
+
|
21
26
|
# Parsing internals and fields.
|
22
27
|
module Parsing
|
23
28
|
# Common fields and functions.
|
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'
|