-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fyst 550 add healthcare screen to md flow (#5003)
* migrations * md healthcare screen * fix bug with screens opening * merge main * remove prys * rename controller * merge main * rename controller on failing test * remove a pry * rename had health insurance controller spec * update complete intake spec * pr changes * refactor save in had health insurance form * fix es.yml * visual changes on reveals * normalize * acceptance fixes * fix issue missing param issue in controller --------- Co-authored-by: Drew Proebstel <[email protected]>
- Loading branch information
1 parent
53492ff
commit 85e5151
Showing
19 changed files
with
670 additions
and
246 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
15 changes: 15 additions & 0 deletions
15
app/controllers/state_file/questions/md_had_health_insurance_controller.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,15 @@ | ||
module StateFile | ||
module Questions | ||
class MdHadHealthInsuranceController < QuestionsController | ||
def form_params | ||
if params[:state_file_md_had_health_insurance_form] | ||
params | ||
.fetch(:state_file_md_had_health_insurance_form, {}) | ||
.permit( | ||
form_class.attribute_names + | ||
[{ dependents_attributes: [:id, :md_did_not_have_health_insurance] }]) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module StateFile | ||
class MdHadHealthInsuranceForm < QuestionsForm | ||
attr_accessor :dependents_attributes | ||
delegate :dependents, to: :intake | ||
|
||
set_attributes_for :intake, :had_hh_member_without_health_insurance, :primary_did_not_have_health_insurance, :spouse_did_not_have_health_insurance, :authorize_sharing_of_health_insurance_info | ||
|
||
validates :had_hh_member_without_health_insurance, presence: true | ||
validate :one_member_did_not_have_health_insurance, if: -> { had_hh_member_without_health_insurance == "yes"} | ||
|
||
validates :authorize_sharing_of_health_insurance_info, | ||
presence: true, | ||
if: -> { had_hh_member_without_health_insurance == "yes" } | ||
|
||
|
||
def initialize(intake = nil, params = nil) | ||
super | ||
if params.present? | ||
@intake.assign_attributes(dependents_attributes: dependents_attributes.to_h) | ||
end | ||
end | ||
|
||
def save | ||
base_attrs = attributes_for(:intake) | ||
base_attrs.merge({ dependents_attributes: dependents_attributes.to_h }) | ||
@intake.update!(base_attrs) | ||
end | ||
|
||
private | ||
|
||
def one_member_did_not_have_health_insurance | ||
unless @intake.has_dependent_without_health_insurance? || spouse_did_not_have_health_insurance == "yes" || primary_did_not_have_health_insurance == "yes" | ||
errors.add(:household_health_insurance, I18n.t("forms.errors.healthcare.one_box")) | ||
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
Oops, something went wrong.