Skip to content

Commit

Permalink
Wrap MVI ID Parser changes in a feature toggle (#3453)
Browse files Browse the repository at this point in the history
* Wrap MVI ID Parser changes in a feature toggle
  • Loading branch information
Johnny Holton authored Oct 21, 2019
1 parent 1a58537 commit b4d817f
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 12 deletions.
3 changes: 3 additions & 0 deletions config/features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ features:
profile_show_direct_deposit:
description: >
https://www.va.gov/profile/ show Direct Deposit
mvi_id_parser:
description: >
logic changes for parsing IDs from MVI responses
55 changes: 43 additions & 12 deletions lib/mvi/responses/id_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,51 @@ class IdParser
# processes to utilize the 1 active
# PCE = Pending Cat Edit correlations (unsure if this should be used, likely not)

# rubocop:disable Metrics/MethodLength
# rubocop:disable Metrics/AbcSize
def parse(ids)
ids = ids.map(&:attributes)
{
icn: select_ids(select_extension(ids, PERMANENT_ICN_REGEX, VA_ROOT_OID))&.first,
sec_id: select_ids(select_extension(ids, /^\w+\^PN\^200PROV\^USDVA\^A$/, VA_ROOT_OID))&.first,
mhv_ids: select_ids(select_extension(ids, /^\w+\^PI\^200MH.{0,1}\^\w+\^\w+$/, VA_ROOT_OID)),
active_mhv_ids: select_ids(select_extension(ids, /^\w+\^PI\^200MH.{0,1}\^\w+\^A$/, VA_ROOT_OID)),
edipi: select_ids(select_extension(ids, /^\w+\^NI\^200DOD\^USDOD\^A$/, DOD_ROOT_OID))&.first,
vba_corp_id: select_ids(select_extension(ids, /^\w+\^PI\^200CORP\^USVBA\^A$/, VA_ROOT_OID))&.first,
vha_facility_ids: select_facilities(select_extension(ids, /^\w+\^PI\^\w+\^USVHA\^\w+$/, VA_ROOT_OID)),
birls_id: select_ids(select_extension(ids, /^\w+\^PI\^200BRLS\^USVBA\^A$/, VA_ROOT_OID))&.first,
vet360_id: select_ids(select_extension(ids, /^\w+\^PI\^200VETS\^USDVA\^A$/, VA_ROOT_OID))&.first,
icn_with_aaid: ICNWithAAIDParser.new(full_icn_with_aaid(ids)).without_id_status
}
if Flipper.enabled?('mvi_id_parser')
{
icn: select_ids(select_extension(ids, PERMANENT_ICN_REGEX, VA_ROOT_OID))&.first,
sec_id: select_ids(select_extension(ids, /^\w+\^PN\^200PROV\^USDVA\^A$/, VA_ROOT_OID))&.first,
mhv_ids: select_ids(select_extension(ids, /^\w+\^PI\^200MH.{0,1}\^\w+\^\w+$/, VA_ROOT_OID)),
active_mhv_ids: select_ids(select_extension(ids, /^\w+\^PI\^200MH.{0,1}\^\w+\^A$/, VA_ROOT_OID)),
edipi: select_ids(select_extension(ids, /^\w+\^NI\^200DOD\^USDOD\^A$/, DOD_ROOT_OID))&.first,
vba_corp_id: select_ids(select_extension(ids, /^\w+\^PI\^200CORP\^USVBA\^A$/, VA_ROOT_OID))&.first,
vha_facility_ids: select_facilities(select_extension(ids, /^\w+\^PI\^\w+\^USVHA\^\w+$/, VA_ROOT_OID)),
birls_id: select_ids(select_extension(ids, /^\w+\^PI\^200BRLS\^USVBA\^A$/, VA_ROOT_OID))&.first,
vet360_id: select_ids(select_extension(ids, /^\w+\^PI\^200VETS\^USDVA\^A$/, VA_ROOT_OID))&.first,
icn_with_aaid: ICNWithAAIDParser.new(full_icn_with_aaid(ids)).without_id_status
}
else
{
icn: select_ids(select_extension(ids, ICN_REGEX, VA_ROOT_OID))&.first,
sec_id: select_ids(select_extension(ids, /^\w+\^PN\^200PROV\^USDVA\^\w+$/, VA_ROOT_OID))&.first,
mhv_ids: select_ids(select_extension(ids, /^\w+\^PI\^200MH.{0,1}\^\w+\^\w+$/, VA_ROOT_OID)),
active_mhv_ids: select_ids(select_extension(ids, /^\w+\^PI\^200MH.{0,1}\^\w+\^A$/, VA_ROOT_OID)),
edipi: select_ids(select_extension(ids, /^\w+\^NI\^200DOD\^USDOD\^\w+$/, DOD_ROOT_OID))&.first,
vba_corp_id: select_ids_except(select_extension(ids, /^\w+\^PI\^200CORP\^USVBA\^\w+$/, VA_ROOT_OID),
%w[H L])&.first,
vha_facility_ids: select_facilities(select_extension(ids, /^\w+\^PI\^\w+\^USVHA\^\w+$/, VA_ROOT_OID)),
birls_id: select_ids(select_extension(ids, /^\w+\^PI\^200BRLS\^USVBA\^\w+$/, VA_ROOT_OID))&.first,
vet360_id: select_ids(select_extension(ids, /^\w+\^PI\^200VETS\^USDVA\^A$/, VA_ROOT_OID))&.first,
icn_with_aaid: ICNWithAAIDParser.new(full_icn_with_aaid(ids)).without_id_status
}
end
end
# rubocop:enable Metrics/MethodLength
# rubocop:enable Metrics/AbcSize

# TODO: remove when Flipper toggle is removed.
def select_ids_except(extensions, reject_status)
# ultaimately, I'd rather have a list complete list of statuses to accept, but for now we can reject
return nil if extensions.empty?

extensions.map do |e|
split_extension = e[:extension].split('^')
split_extension&.first unless split_extension[4] && reject_status.include?(split_extension[4])
end.compact
end

def select_ids_with_extension(ids, pattern, root)
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
SimpleCov.start 'rails' do
track_files '**/{app,lib}/**/*.rb'

add_filter 'lib/mvi/responses/id_parser.rb' # TODO: remove when removing Flipper toggle in file.
add_filter 'app/controllers/concerns/accountable.rb'
add_filter 'config/initializers/clamscan.rb'
add_filter 'lib/config_helper.rb'
Expand Down

0 comments on commit b4d817f

Please sign in to comment.