-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add eligibility rules for alive status verification type (#4041)
* add eligibility rules for alive status verification type * refactor validation logic * rubocop fix * add more code changes and specs * add specs * fix typo * add more specs --------- Co-authored-by: haridhar yamjala <[email protected]>
- Loading branch information
Showing
8 changed files
with
391 additions
and
84 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
56 changes: 56 additions & 0 deletions
56
...main/operations/fdsh/payload_eligibility/check_determination_subject_eligibility_rules.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,56 @@ | ||
# frozen_string_literal: true | ||
|
||
# This module defines operations related to FDSH payload eligibility. | ||
module Operations | ||
module Fdsh | ||
module PayloadEligibility | ||
# This class checks the eligibility rules for a determination subject within the FDSH payload. | ||
# It extends `CheckBaseEligibilityRules` to leverage common eligibility rule checks. | ||
class CheckDeterminationSubjectEligibilityRules < CheckBaseEligibilityRules | ||
# Valid eligibility states for health and dental product enrollments. | ||
VALID_ELIGIBLITY_STATES = [ | ||
'health_product_enrollment_status', | ||
'dental_product_enrollment_status' | ||
].freeze | ||
|
||
private | ||
|
||
# Validates the payload entity to ensure it is a valid Subject object and then | ||
# calls the superclass's validate method. | ||
# | ||
# @param payload_entity [Subject Hash] The subject entity to validate. | ||
# @param request_type [Symbol] The type of request being validated. | ||
# @return [Dry::Monads::Result] Success or Failure indicating the validation result. | ||
def validate(payload_entity, request_type) | ||
return Failure("Invalid Subject Object #{payload_entity}") unless payload_entity.is_a?(Hash) | ||
super(request_type) | ||
end | ||
|
||
# Validates the Social Security Number (SSN) of the payload entity. | ||
# | ||
# @param payload_entity [Subject Hash] The subject entity whose SSN is to be validated. | ||
# @return [Dry::Monads::Result] Success or Failure indicating the validation result of the SSN. | ||
def validate_ssn(payload_entity) | ||
encrypted_ssn = payload_entity[:encrypted_ssn] | ||
return Failure("No SSN for member #{payload_entity[:hbx_id]}") if encrypted_ssn.nil? || encrypted_ssn.empty? | ||
|
||
AcaEntities::Operations::EncryptedSsnValidator.new.call(encrypted_ssn) | ||
end | ||
|
||
# Checks if the member is enrolled based on the eligibility states provided in the payload. | ||
# | ||
# @param payload_entity [Subject Hash] The subject entity to check enrollment status for. | ||
# @return [Dry::Monads::Result] Success if the subject is enrolled in either health or dental enrollment, | ||
# otherwise Failure. | ||
def is_member_enrolled?(payload_entity) | ||
states = payload_entity[:eligibility_states].collect { |k, v| v[:is_eligible] if VALID_ELIGIBLITY_STATES.include?(k.to_s) }.flatten.compact | ||
|
||
return Failure("No states found for the given subject/member hbx_id: #{payload_entity[:hbx_id]} ") unless states.present? | ||
return Success() if states.any?(true) | ||
|
||
Failure("subject is not enrolled in health or dental enrollment") | ||
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
Oops, something went wrong.