2025-12-03 11:42:15 -05:00
|
|
|
class BenefitsWordDocProcessor
|
|
|
|
|
|
2026-01-15 11:37:50 -05:00
|
|
|
def initialize(word_doc, employer=nil)
|
2025-12-03 11:42:15 -05:00
|
|
|
@word_doc = word_doc
|
2026-01-15 11:37:50 -05:00
|
|
|
if employer
|
|
|
|
|
@employer = employer
|
2025-12-03 11:42:15 -05:00
|
|
|
else
|
2026-01-15 11:37:50 -05:00
|
|
|
@employer = Employer.new
|
2025-12-03 11:42:15 -05:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def call
|
|
|
|
|
doc = Docx::Document.open(@word_doc)
|
2025-12-10 13:22:33 -05:00
|
|
|
data_lines = doc.paragraphs.map { |p| p.to_s.squish }.reject!(&:empty?)
|
2025-12-03 11:42:15 -05:00
|
|
|
|
2026-01-15 11:37:50 -05:00
|
|
|
employer_information, plans_and_network = data_lines.split("Medical Plan")
|
|
|
|
|
plan_information, network_information = plans_and_network.split("Claims Submission")
|
2025-12-03 11:42:15 -05:00
|
|
|
|
2026-01-15 11:37:50 -05:00
|
|
|
# employer_information = data_lines.slice(0, start_of_plans_index)
|
|
|
|
|
# plan_information = data_lines.slice(start_of_plans_index + 1..)
|
|
|
|
|
# network_information = data_lines.slice(start_of_network_index + 1..)
|
2025-12-03 11:42:15 -05:00
|
|
|
|
2026-01-15 11:37:50 -05:00
|
|
|
@employer = BenefitsWordDoc::MapEmployerInformation.new(@employer, employer_information).call
|
|
|
|
|
@employer = BenefitsWordDoc::MapEmployerLogo.new(@employer, @word_doc).call
|
|
|
|
|
@employer = BenefitsWordDoc::MapPlansInformation.new(@employer, plan_information).call
|
|
|
|
|
@employer = BenefitsWordDoc::MapNetworkInformation.new(@employer, network_information).call
|
2025-12-03 11:42:15 -05:00
|
|
|
|
2026-01-15 11:37:50 -05:00
|
|
|
@employer
|
2025-12-03 11:42:15 -05:00
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|