From 55620ec2066544d6b35ee9079674c8ff13133434 Mon Sep 17 00:00:00 2001 From: Jennica Stiehl <25069483+stiehlrod@users.noreply.github.com> Date: Thu, 9 Jan 2025 12:31:26 -0700 Subject: [PATCH 1/6] Removes decisin and find files. --- .../power_of_attorney_request/decision.rb | 58 ------------------- .../power_of_attorney_request/find.rb | 40 ------------- 2 files changed, 98 deletions(-) delete mode 100644 modules/claims_api/app/models/claims_api/power_of_attorney_request/decision.rb delete mode 100644 modules/claims_api/app/models/claims_api/power_of_attorney_request/find.rb diff --git a/modules/claims_api/app/models/claims_api/power_of_attorney_request/decision.rb b/modules/claims_api/app/models/claims_api/power_of_attorney_request/decision.rb deleted file mode 100644 index af2df79bb08..00000000000 --- a/modules/claims_api/app/models/claims_api/power_of_attorney_request/decision.rb +++ /dev/null @@ -1,58 +0,0 @@ -# frozen_string_literal: true - -module ClaimsApi - class PowerOfAttorneyRequest - class Decision < - Data.define( - :status, - :declining_reason, - :created_at, - :created_by - ) - - module Statuses - ALL = [ - ACCEPTING = 'accepting', - DECLINING = 'declining' - ].freeze - end - - class << self - def create(id, decision) - Create.perform(id, decision) - end - - def build(attrs) - created_by = - Representative.new( - **attrs.delete(:created_by) - ) - - new( - **attrs, - # A bit weird. Because we're working with immutable value objects, - # we don't have the opportunity to mutate only when creation - # actually occurs. - created_at: Time.current, - created_by: - ) - end - end - - Representative = - Data.define( - :first_name, - :last_name, - :email - ) - - def accepting? - status == Statuses::ACCEPTING - end - - def declining? - status == Statuses::DECLINING - end - end - end -end diff --git a/modules/claims_api/app/models/claims_api/power_of_attorney_request/find.rb b/modules/claims_api/app/models/claims_api/power_of_attorney_request/find.rb deleted file mode 100644 index 99c1a839e19..00000000000 --- a/modules/claims_api/app/models/claims_api/power_of_attorney_request/find.rb +++ /dev/null @@ -1,40 +0,0 @@ -# frozen_string_literal: true - -module ClaimsApi - class PowerOfAttorneyRequest - module Find - class << self - def perform(id) # rubocop:disable Metrics/MethodLength - participant_id, proc_id = id.split('_') - - action = - BGSClient::Definitions:: - VeteranRepresentativeService:: - ReadAllVeteranRepresentatives:: - DEFINITION - - result = - BGSClient.perform_request(action) do |xml, data_aliaz| - xml[data_aliaz].CorpPtcpntIdFormTypeCode do - xml.formTypeCode('21-22') - xml.veteranCorpPtcpntId(participant_id) - end - end - - poa_request = - Array.wrap(result).find do |data| - data['procId'] == proc_id - end - - poa_request.nil? and - raise ::Common::Exceptions::RecordNotFound, id - - Load.perform( - participant_id, - poa_request - ) - end - end - end - end -end From e21742304923b30d35df7bcef84324e4825aeb82 Mon Sep 17 00:00:00 2001 From: Jennica Stiehl <25069483+stiehlrod@users.noreply.github.com> Date: Thu, 9 Jan 2025 12:36:26 -0700 Subject: [PATCH 2/6] Removes load and summary files. --- .../power_of_attorney_request/load.rb | 57 ------------------- .../power_of_attorney_request/summary.rb | 46 --------------- 2 files changed, 103 deletions(-) delete mode 100644 modules/claims_api/app/models/claims_api/power_of_attorney_request/load.rb delete mode 100644 modules/claims_api/app/models/claims_api/power_of_attorney_request/summary.rb diff --git a/modules/claims_api/app/models/claims_api/power_of_attorney_request/load.rb b/modules/claims_api/app/models/claims_api/power_of_attorney_request/load.rb deleted file mode 100644 index d7ddad115eb..00000000000 --- a/modules/claims_api/app/models/claims_api/power_of_attorney_request/load.rb +++ /dev/null @@ -1,57 +0,0 @@ -# frozen_string_literal: true - -module ClaimsApi - class PowerOfAttorneyRequest - # Deserialization is inherently linked to a particular BGS service action, - # as it maps from the representation for that action. For now, since only - # one such mapping is needed, we showcase it in isolation here. - class Load - class << self - def perform(participant_id, data) - new(participant_id, data).perform - end - end - - def initialize(participant_id, data) - @participant_id = participant_id - @data = data - end - - def perform - PowerOfAttorneyRequest.new( - power_of_attorney_code:, - veteran:, - obsolete:, - decision_status: - ) - end - - private - - def power_of_attorney_code - @data['poaCode'] - end - - def veteran - Veteran.new( - participant_id: @participant_id, - file_number: @data['veteranVAFileNumber'], - ssn: @data['veteranSSN'] - ) - end - - def obsolete - @data['secondaryStatus'] == 'Obsolete' - end - - def decision_status - case @data['secondaryStatus'] - when 'Accepted' - Decision::Statuses::ACCEPTING - when 'Declined' - Decision::Statuses::DECLINING - end - end - end - end -end diff --git a/modules/claims_api/app/models/claims_api/power_of_attorney_request/summary.rb b/modules/claims_api/app/models/claims_api/power_of_attorney_request/summary.rb deleted file mode 100644 index f4b369a63cf..00000000000 --- a/modules/claims_api/app/models/claims_api/power_of_attorney_request/summary.rb +++ /dev/null @@ -1,46 +0,0 @@ -# frozen_string_literal: true - -module ClaimsApi - class PowerOfAttorneyRequest - class Summary < - Data.define( - :id, - :power_of_attorney_code, - :veteran, - :claimant, - :claimant_address, - :decision, - :authorizes_address_changing, - :authorizes_treatment_disclosure, - :created_at - ) - - class << self - def search(query) - Search.perform(query) - end - end - - Veteran = - Data.define( - :first_name, - :middle_name, - :last_name - ) - - Claimant = - Data.define( - :first_name, - :last_name, - :relationship_to_veteran - ) - - Address = - Data.define( - :city, :state, :zip, :country, - :military_post_office, - :military_postal_code - ) - end - end -end From 0fafe5082b4ee9cbcf40a3d8d7f61843d2134207 Mon Sep 17 00:00:00 2001 From: Jennica Stiehl <25069483+stiehlrod@users.noreply.github.com> Date: Thu, 16 Jan 2025 10:55:28 -0700 Subject: [PATCH 3/6] Removes additional model. --- .../decision/create.rb | 23 ------------------- 1 file changed, 23 deletions(-) delete mode 100644 modules/claims_api/app/models/claims_api/power_of_attorney_request/decision/create.rb diff --git a/modules/claims_api/app/models/claims_api/power_of_attorney_request/decision/create.rb b/modules/claims_api/app/models/claims_api/power_of_attorney_request/decision/create.rb deleted file mode 100644 index 5d5cc018392..00000000000 --- a/modules/claims_api/app/models/claims_api/power_of_attorney_request/decision/create.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -module ClaimsApi - class PowerOfAttorneyRequest - class Decision - module Create - class << self - def perform(id, decision) - action = - BGSClient::Definitions:: - ManageRepresentativeService:: - UpdatePoaRequest:: - DEFINITION - - BGSClient.perform_request(action) do |xml, data_aliaz| - Dump.perform(id, decision, xml, data_aliaz) - end - end - end - end - end - end -end From a960f8ea1088dcd0d2f7c8573b4e89320dd7ec9d Mon Sep 17 00:00:00 2001 From: Jennica Stiehl <25069483+stiehlrod@users.noreply.github.com> Date: Thu, 16 Jan 2025 11:09:08 -0700 Subject: [PATCH 4/6] Removes additional model. --- .../summary/search/query.rb | 106 ------------------ 1 file changed, 106 deletions(-) delete mode 100644 modules/claims_api/app/models/claims_api/power_of_attorney_request/summary/search/query.rb diff --git a/modules/claims_api/app/models/claims_api/power_of_attorney_request/summary/search/query.rb b/modules/claims_api/app/models/claims_api/power_of_attorney_request/summary/search/query.rb deleted file mode 100644 index 27a41e5809b..00000000000 --- a/modules/claims_api/app/models/claims_api/power_of_attorney_request/summary/search/query.rb +++ /dev/null @@ -1,106 +0,0 @@ -# frozen_string_literal: true - -module ClaimsApi - class PowerOfAttorneyRequest - class Summary - module Search - module Query - module Filter - module Decision - module Statuses - ALL = [ - NONE = 'none', - ACCEPTING = PowerOfAttorneyRequest::Decision::Statuses::ACCEPTING, - DECLINING = PowerOfAttorneyRequest::Decision::Statuses::DECLINING - ].freeze - end - end - end - - module Page - # These values currently duplicate the behavior of BGS, but they can - # be changed so long as: - # - bgs_min <= min - # - max <= bgs_max - # - min <= default <= max - module Size - DEFAULT = 25 - MAX = 100 - MIN = 1 - end - end - - module Sort - module Fields - ALL = [ - CREATED_AT = 'createdAt' - ].freeze - end - - module Orders - ALL = [ - ASCENDING = 'asc', - DESCENDING = 'desc' - ].freeze - end - end - - class << self - def dump(query, xml, data_aliaz) # rubocop:disable Metrics/MethodLength - filter = query[:filter] - - xml[data_aliaz].SecondaryStatusList do - statuses = filter.dig(:decision, :statuses) - statuses.each do |status| - case status - when Filter::Decision::Statuses::NONE - xml.SecondaryStatus('New') - xml.SecondaryStatus('Pending') - when Filter::Decision::Statuses::ACCEPTING - xml.SecondaryStatus('Accepted') - when Filter::Decision::Statuses::DECLINING - xml.SecondaryStatus('Declined') - end - end - end - - xml[data_aliaz].POACodeList do - filter[:poaCodes].each do |poa_code| - xml.POACode(poa_code) - end - end - - xml[data_aliaz].POARequestParameter do - page = query[:page] - sort = query[:sort] - - xml.pageIndex(page[:number]) - xml.pageSize(page[:size]) - - xml.poaSortField( - case sort[:field] - when Sort::Fields::CREATED_AT - 'DATE_RECEIVED' - else - raise "unknown sort field: #{sort[:field]}" - end - ) - - xml.poaSortOrder( - case sort[:order] - when Sort::Orders::ASCENDING - 'ASCENDING' - when Sort::Orders::DESCENDING - 'DESCENDING' - else - raise "unknown sort order: #{sort[:order]}" - end - ) - end - end - end - end - end - end - end -end From 90dcf4cacc48d2fc15c1d87f1f41a44c7df868c8 Mon Sep 17 00:00:00 2001 From: Jennica Stiehl <25069483+stiehlrod@users.noreply.github.com> Date: Fri, 17 Jan 2025 13:46:14 -0700 Subject: [PATCH 5/6] Deletes references to deleted items --- .../power_of_attorney_request_service/search/query.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/modules/claims_api/app/services/claims_api/power_of_attorney_request_service/search/query.rb b/modules/claims_api/app/services/claims_api/power_of_attorney_request_service/search/query.rb index 3ac4f06a437..1ec36d1a590 100644 --- a/modules/claims_api/app/services/claims_api/power_of_attorney_request_service/search/query.rb +++ b/modules/claims_api/app/services/claims_api/power_of_attorney_request_service/search/query.rb @@ -4,10 +4,6 @@ module ClaimsApi module PowerOfAttorneyRequestService module Search module Query - Filter = PowerOfAttorneyRequest::Summary::Search::Query::Filter - Page = PowerOfAttorneyRequest::Summary::Search::Query::Page - Sort = PowerOfAttorneyRequest::Summary::Search::Query::Sort - # TODO: If keeping `dry-schema`, consider a good point to load these # extensions. The `hints` extension has to load before our `Schema` # definition, otherwise it won't do its thing. And that may be true for From 98b474627b804348e716dbaacbae5a7ec99d1d61 Mon Sep 17 00:00:00 2001 From: Jennica Stiehl <25069483+stiehlrod@users.noreply.github.com> Date: Fri, 17 Jan 2025 14:46:43 -0700 Subject: [PATCH 6/6] Removes file so tests will pass. --- .../search/query.rb | 78 ------------------- 1 file changed, 78 deletions(-) delete mode 100644 modules/claims_api/app/services/claims_api/power_of_attorney_request_service/search/query.rb diff --git a/modules/claims_api/app/services/claims_api/power_of_attorney_request_service/search/query.rb b/modules/claims_api/app/services/claims_api/power_of_attorney_request_service/search/query.rb deleted file mode 100644 index 1ec36d1a590..00000000000 --- a/modules/claims_api/app/services/claims_api/power_of_attorney_request_service/search/query.rb +++ /dev/null @@ -1,78 +0,0 @@ -# frozen_string_literal: true - -module ClaimsApi - module PowerOfAttorneyRequestService - module Search - module Query - # TODO: If keeping `dry-schema`, consider a good point to load these - # extensions. The `hints` extension has to load before our `Schema` - # definition, otherwise it won't do its thing. And that may be true for - # the `json_schema` extension too. - Dry::Schema.load_extensions(:json_schema) - Dry::Schema.load_extensions(:hints) - - Schema = - # See https://dry-rb.org/gems/dry-schema - Dry::Schema.Params do - required(:filter).hash do - required(:poaCodes).filled(:array).each(:string, :filled?) - optional(:decision).hash do - optional(:statuses).filled(:array).each( - :string, included_in?: Filter::Decision::Statuses::ALL - ) - end - end - - optional(:page).hash do - optional(:number).value(:integer, gteq?: 1) - optional(:size).value( - :integer, - gteq?: Page::Size::MIN, - lteq?: Page::Size::MAX - ) - end - - optional(:sort).hash do - # If the client is going to send one of these, it only really - # makes sense to send both, because otherwise it's kind of a - # nonsensical query for them to make. - required(:field).value(:string, included_in?: Sort::Fields::ALL) - required(:order).value(:string, included_in?: Sort::Orders::ALL) - end - end - - class << self - def compile!(params) - result = Schema.call(params) - result.success? or raise( - ::Common::Exceptions::SchemaValidationErrors, - [{ errors: result.messages.to_h, params: }] - ) - - result.to_h.tap do |query| - apply_defaults(query) - end - end - - private - - def apply_defaults(query) - query[:filter][:decision] ||= {} - query[:filter][:decision][:statuses] ||= - Filter::Decision::Statuses::ALL - - query[:sort] ||= { - # These only make sense as defaults together. - field: Sort::Fields::CREATED_AT, - order: Sort::Orders::DESCENDING - } - - page = query[:page] ||= {} - page[:size] ||= Page::Size::DEFAULT - page[:number] ||= 1 - end - end - end - end - end -end