-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* BDN import * ingress awards also
- Loading branch information
Showing
11 changed files
with
207 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
--- | ||
:main_line: | ||
:ssn: 9 | ||
:file_number: 9 | ||
:suffix: 2 | ||
:dob: 8 | ||
:mr_status: 1 | ||
:rem_ent: 7 | ||
:cert_issue_date: 8 | ||
:del_date: 8 | ||
:date_last_certified: 8 | ||
:veteran_name: 20 | ||
:address1: 20 | ||
:address2: 20 | ||
:address3: 20 | ||
:address4: 20 | ||
:address5: 20 | ||
:zip_code: 9 | ||
:stub_nm: 7 | ||
:rpo_code: 3 | ||
:fac_code: 8 | ||
:payment_amt: 7 | ||
:award_line: | ||
:award_begin_date: 8 | ||
:award_end_date: 8 | ||
:training_time: 1 | ||
:payment_date: 8 | ||
:monthly_rate: 7 | ||
:begin_rsn: 2 | ||
:end_rsn: 2 | ||
:type_training: 1 | ||
:number_hours: 2 | ||
:type_hours: 1 | ||
:cur_award_ind: 1 | ||
:mappings: | ||
:profile: | ||
- :ssn | ||
- :file_number | ||
:info: | ||
- :ssn | ||
- :file_number | ||
- :dob | ||
- :mr_status | ||
- :rem_ent | ||
- :cert_issue_date | ||
- :del_date | ||
- :date_last_certified | ||
- :stub_nm | ||
- :rpo_code | ||
- :fac_code | ||
- :payment_amt | ||
- :indicator | ||
:address: | ||
- :veteran_name | ||
- :address1 | ||
- :address2 | ||
- :address3 | ||
- :address4 | ||
- :address5 | ||
- :zip_code | ||
:indicator: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
modules/vye/lib/vye/batch_transfer/ingress_files/bdn_line_extraction.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# frozen_string_literal: true | ||
|
||
module Vye | ||
module BatchTransfer | ||
module IngressFiles | ||
BdnLineExtraction = Struct.new(:line, :result, :award_lines, :awards) do | ||
def initialize(line:, result:, award_lines:, awards:) | ||
super | ||
|
||
extract_main | ||
extract_award_lines | ||
extract_indicator | ||
extract_awards | ||
end | ||
|
||
def config | ||
@config ||= YAML.load_file Vye::Engine.root / 'config/bdn_line_extraction_config.yaml' | ||
end | ||
|
||
def extract_main | ||
config[:main_line] | ||
.each do |field, length| | ||
extracted = line.slice!(0...length).strip | ||
result.update(field => extracted) | ||
end | ||
end | ||
|
||
def extract_award_lines | ||
(0...4) | ||
.each do |_i| | ||
dead = line[0...8].strip == '' | ||
extracted = line.slice!(0...41) | ||
award_lines << extracted unless dead | ||
end | ||
end | ||
|
||
def extract_awards | ||
# iterate over the fields for each award line and extract the data | ||
# think list comprehensions in python, haskell, or erlang | ||
award_lines | ||
.each_with_index.to_a | ||
.product(config[:award_line].each_pair.to_a) | ||
.each do |(award_line, i), (field, length)| | ||
extracted = award_line.slice!(0...length).strip | ||
awards[i] ||= {} | ||
awards[i].update(field => extracted) | ||
end | ||
end | ||
|
||
def extract_indicator | ||
return unless config[:indicator] | ||
|
||
result.update(indicator: line.slice!(0...1).strip) | ||
end | ||
|
||
def attributes | ||
raise 'incomplete extraction' unless line.blank? && award_lines.all?(&:blank?) | ||
|
||
profile = result.slice(*config[:mappings][:profile]) | ||
info = result.slice(*config[:mappings][:info]) | ||
address = result.slice(*config[:mappings][:address]) | ||
|
||
{ profile:, info:, address:, awards: } | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
123456789 19800101E3600000198603281996020519860328JOHN APPLESEED 1 Mockingbird Ln APT 1 Houston TX 77401 JAPPLES316119071110011550 00000000198603281198603280003500 66 00 C A |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters