Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/add ins hhdb #700

Merged
merged 45 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
910901c
Rm healthInsurance from default & referrer step dir
ivonne-hernandez Oct 23, 2023
43f0720
Remove healthInsurance q from qs
ivonne-hernandez Oct 23, 2023
67d8b62
Rm HealthIns type, rm hIns from FormData, add hIns to HHData
ivonne-hernandez Oct 23, 2023
6576845
Rm healthInsurance from initalFormData in Wrapper
ivonne-hernandez Oct 23, 2023
a8bfe65
Assign the HealthIns interface to healthInsurance
ivonne-hernandez Oct 24, 2023
a09ce42
Add healthInsurance to initialHouseholdData state
ivonne-hernandez Oct 24, 2023
582ca3d
Convert healthInsuranceOptions to tsx
ivonne-hernandez Oct 24, 2023
f159a5e
Add HealthInsuranceQ component
ivonne-hernandez Oct 24, 2023
6172aba
Refactor key value & hhMemberIndex to num type
ivonne-hernandez Oct 24, 2023
ea7c503
Add displayHealthInsuranceQuestion func to HHDB
ivonne-hernandez Oct 24, 2023
5825676
Add cond rend of healthInsQ based on page num
ivonne-hernandez Oct 24, 2023
2a625d6
Remove extraneous div from return stmt
ivonne-hernandez Oct 25, 2023
00fa51d
Rm healthIns from initialFormData & screenBody
ivonne-hernandez Oct 25, 2023
4a9816e
Add initialHHMHI to initialFormData in fetch & updateScreen
ivonne-hernandez Oct 25, 2023
e3a8145
Update fetch & updateScreens to use insurance field
ivonne-hernandez Oct 25, 2023
246a058
Refactor personDataIsValid to include healthIns
ivonne-hernandez Oct 25, 2023
0d12850
Add healthInsuranceDataIsValid function
ivonne-hernandez Oct 25, 2023
7e9b14a
Add healthIns case to getPersonDataErrorMsg
ivonne-hernandez Oct 25, 2023
a36cebd
Move healthInsurance message func out of getPersonDataErrorMsg
ivonne-hernandez Oct 26, 2023
1ae2d77
Add healthInsuranceDataHasError function
ivonne-hernandez Oct 26, 2023
7da4008
Add hIErrorController to HHDB, pass it to HealthInsQ
ivonne-hernandez Oct 26, 2023
85b74e6
Add hInsErrCtrler & display err msg in healthInsQ
ivonne-hernandez Oct 26, 2023
f1fceee
Delete unused import from Confirmation
ivonne-hernandez Oct 31, 2023
4aaa878
Delete err from state, useEffect to setError based on personDataErrMsg
ivonne-hernandez Oct 31, 2023
f91c6ec
Move none, add emergency medicaid, famPlanning, DK options
ivonne-hernandez Oct 31, 2023
7613b55
Add dont_know, emerMedicaid & famPlanning to fetchScreen, HHDB
ivonne-hernandez Oct 31, 2023
f5ec496
Change private, medicaid text
ivonne-hernandez Oct 31, 2023
3930586
Add if stmt to X translAriaLabel based on hhMIndex && none key
ivonne-hernandez Oct 31, 2023
2e9e637
Change you to I
ivonne-hernandez Oct 31, 2023
0b9031e
Delete console.log from FetchScreen
ivonne-hernandez Nov 1, 2023
a0eac0b
Add displayHealthInsuraceSection function
ivonne-hernandez Nov 1, 2023
48a8588
Add displayHealthInsurance function
ivonne-hernandez Nov 1, 2023
f815fff
Delete old hh ins section from displayAllFormData
ivonne-hernandez Nov 1, 2023
6fed0f7
Add displayHHMHealthInsuranceSection to HHMDB
ivonne-hernandez Nov 1, 2023
0e36c77
Add dont_know if stmts to healthIns error funcs
ivonne-hernandez Nov 1, 2023
18781e4
Make healthInsurance options display inline
ivonne-hernandez Nov 1, 2023
e5da13f
Add an nvmrc file to specify node version
ivonne-hernandez Nov 1, 2023
3e4059b
Fix formatting
ivonne-hernandez Nov 1, 2023
fd2949a
Refactor handleCardClick function
ivonne-hernandez Nov 2, 2023
2997b3d
Add key text to each option card to make it unique
ivonne-hernandez Nov 2, 2023
419c83a
Fix formatting
ivonne-hernandez Nov 2, 2023
e52545d
Move hIns error controller to the HealthInsQ
ivonne-hernandez Nov 2, 2023
f3c73e7
Fix formatting
ivonne-hernandez Nov 2, 2023
61a9ac8
Delete unused getPersonDataErrorMsg function
ivonne-hernandez Nov 2, 2023
38c1884
Replace ageErrCtrller with submittedCount variable
ivonne-hernandez Nov 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16
Binary file added src/Assets/OptionCardIcons/dont_know.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/Assets/OptionCardIcons/emergency_medicaid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/Assets/OptionCardIcons/family_planning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,25 @@ import padlock from './OptionCardIcons/padlock.png';
import redX from './OptionCardIcons/redX.png';
import teddyDoctor from './OptionCardIcons/teddyDoctor.png';
import umbrella from './OptionCardIcons/umbrella.png';
import dontKnow from './OptionCardIcons/dont_know.png';
import emergencyMedicaid from './OptionCardIcons/emergency_medicaid.png';
import familyPlanning from './OptionCardIcons/family_planning.png';
import { HealthInsurance } from '../Types/FormData';

const healthInsuranceOptions = {
export type HealthInsuranceOptions = {
[Property in keyof HealthInsurance]: {
formattedMessage: JSX.Element;
image: string;
};
};

const healthInsuranceOptions: HealthInsuranceOptions = {
none: {
formattedMessage: (
<FormattedMessage id="healthInsuranceOptions.none-they" defaultMessage="They do not have health insurance" />
),
image: redX,
},
employer: {
formattedMessage: (
<FormattedMessage id="healthInsuranceOptions.employer" defaultMessage="Employer-provided health insurance" />
Expand All @@ -15,13 +32,13 @@ const healthInsuranceOptions = {
},
private: {
formattedMessage: (
<FormattedMessage id="healthInsuranceOptions.private" defaultMessage="Private health insurance" />
<FormattedMessage id="healthInsuranceOptions.private" defaultMessage="Private (non-employer) health insurance" />
),
image: padlock,
},
medicaid: {
formattedMessage: (
<FormattedMessage id="healthInsuranceOptions.medicaid" defaultMessage="Health First Colorado (Medicaid)" />
<FormattedMessage id="healthInsuranceOptions.medicaid" defaultMessage="Health First Colorado (Full Medicaid)" />
),
image: bill,
},
Expand All @@ -35,14 +52,24 @@ const healthInsuranceOptions = {
),
image: teddyDoctor,
},
none: {
emergency_medicaid: {
formattedMessage: (
<FormattedMessage
id="healthInsuranceOptions.none"
defaultMessage="One or more household member(s) do not have health insurance"
id="healthInsuranceOptions.emergency_medicaid"
defaultMessage="Emergency Medicaid / Reproductive Health"
/>
),
image: redX,
image: emergencyMedicaid,
},
family_planning: {
formattedMessage: (
<FormattedMessage id="healthInsuranceOptions.family_planning" defaultMessage="Family Planning Limited Medicaid" />
),
image: familyPlanning,
},
dont_know: {
formattedMessage: <FormattedMessage id="healthInsuranceOptions.dont_know" defaultMessage="Don't Know" />,
image: dontKnow,
},
};

Expand Down
21 changes: 0 additions & 21 deletions src/Assets/questions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,19 @@ import {
selectHasError,
displayReferralSourceHelperText,
signUpOptionsHaveError,
healthInsuranceHasError,
acuteHHConditionsHasError,
displayHealthInsuranceHelperText,
displayBenefitsHelperText,
countySelectHelperText,
otherReferalSourceHelperText,
} from './validationFunctions.tsx';
import referralOptions from './referralOptions.tsx';
import countiesByZipcode from './countiesByZipcode.js';
import signUpOptions from './signUpOptions.js';
import healthInsuranceOptions from './healthInsuranceOptions.js';
import acuteConditionOptions from './acuteConditionOptions';
import { FormattedMessage } from 'react-intl';

export type QuestionNames =
| 'zipcode'
| 'healthInsurance'
| 'householdSize'
| 'householdData'
| 'hasExpenses'
Expand Down Expand Up @@ -75,23 +71,6 @@ const questions = {
],
headerType: 'aboutHousehold',
},
healthInsurance: {
name: 'healthInsurance',
question: (
<FormattedMessage
id="questions.healthInsurance"
defaultMessage="Which type(s) of health insurance do members of your household have? Check all that apply."
/>
),
componentDetails: {
componentType: 'OptionCardGroup',
inputName: 'healthInsurance',
options: healthInsuranceOptions,
inputError: healthInsuranceHasError,
inputHelperText: displayHealthInsuranceHelperText,
},
headerType: 'aboutHousehold',
},
householdSize: {
name: 'householdSize',
question: (
Expand Down
2 changes: 0 additions & 2 deletions src/Assets/stepDirectory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import questions, { type QuestionNames } from './questions';
export const startingQuestionNumber = 3;
const defaultStepDirectory: QuestionNames[] = [
'zipcode',
'healthInsurance',
//the hhSize and hhData have to be consecutive
'householdSize',
'householdData',
Expand All @@ -16,7 +15,6 @@ const defaultStepDirectory: QuestionNames[] = [
];
const referrerStepDirectory: QuestionNames[] = [
'zipcode',
'healthInsurance',
//the hhSize and hhData have to be consecutive
'householdSize',
'householdData',
Expand Down
11 changes: 2 additions & 9 deletions src/Assets/updateScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ const getScreensBody = (formData, languageCode) => {
has_wic: formData.benefits.wic,
has_upk: formData.benefits.upk,
has_coctc: formData.benefits.coctc,
has_employer_hi: formData.healthInsurance.employer,
has_private_hi: formData.healthInsurance.private,
has_medicaid_hi: formData.healthInsurance.medicaid,
has_medicare_hi: formData.healthInsurance.medicare,
has_chp_hi: formData.healthInsurance.chp,
has_no_hi: formData.healthInsurance.none,
referral_source: finalReferralSource,
referrer_code: formData.immutableReferrer,
needs_food: formData.acuteHHConditions.food,
Expand Down Expand Up @@ -78,16 +72,15 @@ const getHouseholdMemberBody = (householdMemberData) => {
const incomes = getIncomeStreamsBodies(householdMemberData);

return {
relationship: householdMemberData.relationshipToHH,
age: Number(householdMemberData.age),
relationship: householdMemberData.relationshipToHH,
student: householdMemberData.student,
pregnant: householdMemberData.pregnant,
visually_impaired: householdMemberData.blindOrVisuallyImpaired,
disabled: householdMemberData.disabled,
medicaid: householdMemberData.medicaid,
disability_medicaid: householdMemberData.disabilityRelatedMedicaid,
has_income: householdMemberData.hasIncome,
income_streams: incomes,
insurance: householdMemberData.healthInsurance,
};
};

Expand Down
86 changes: 55 additions & 31 deletions src/Assets/validationFunctions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,47 +218,70 @@ const displayHouseholdMemberAgeHelperText: MessageFunction<string> = (applicantA
};

const personDataIsValid: ValidationFunction<HouseholdData> = (householdDataState) => {
const { age, relationshipToHH, hasIncome, incomeStreams } = householdDataState;
const { age, relationshipToHH, hasIncome, incomeStreams, healthInsurance } = householdDataState;

const ageIsValid = Number(age) >= 0 && age !== '';
const relationshipToHHIsValid = relationshipToHH !== '';
const incomeIsValid = (hasIncome && incomeStreamsAreValid(incomeStreams)) || !hasIncome;

return ageIsValid && relationshipToHHIsValid && incomeIsValid;
const healthInsuranceIsValid = healthInsuranceDataIsValid(healthInsurance);

return ageIsValid && relationshipToHHIsValid && incomeIsValid && healthInsuranceIsValid;
};

const getHealthInsuranceError: MessageFunction<HealthInsurance> = (healthInsurance: HealthInsurance) => {
if (healthInsuranceDataIsValid(healthInsurance) === false) {
if (healthInsurance.none === true) {
//then they chose none and another option
return (
<ErrorMessageWrapper fontSize="1rem">
<FormattedMessage
id="validation-helperText.hhMemberInsuranceNone"
defaultMessage="Please do not select any other options if you/they do not have health insurance"
/>
</ErrorMessageWrapper>
);
} else if (healthInsurance.dont_know === true) {
//then they chose dont_know and another option
return (
<ErrorMessageWrapper fontSize="1rem">
<FormattedMessage
id="validation-helperText.hhMemberInsuranceDontKnow"
defaultMessage="Please do not select any other options if you/they don't know"
/>
</ErrorMessageWrapper>
);
} else {
//they haven't selected an option
return (
<ErrorMessageWrapper fontSize="1rem">
<FormattedMessage
id="validation-helperText.hhMemberInsurance"
defaultMessage="Please select at least one health insurance option"
/>
</ErrorMessageWrapper>
);
}
}
};

const getPersonDataErrorMsg: MessageFunction<HouseholdData> = (householdDataState) => {
const { age, relationshipToHH, hasIncome, incomeStreams } = householdDataState;
const healthInsuranceDataIsValid: ValidationFunction<HealthInsurance> = (hhMemberHealthInsData) => {
const numOfTrueValues = Object.values(hhMemberHealthInsData).filter(
(healthInsuranceValue) => healthInsuranceValue === true,
).length;

if (Number(age) < 0 || age === '') {
return (
<ErrorMessageWrapper fontSize="1rem">
<FormattedMessage
id="validation-helperText.hhMemberAgeB"
defaultMessage="Please enter 0 or a positive number for the household member's age"
/>
</ErrorMessageWrapper>
);
} else if (relationshipToHH === '') {
return (
<ErrorMessageWrapper fontSize="1rem">
<FormattedMessage id="errorMessage-HHMemberRelationship" defaultMessage="Please select a relationship" />
</ErrorMessageWrapper>
);
} else if (hasIncome && incomeStreamsAreValid(incomeStreams) === false) {
return (
<ErrorMessageWrapper fontSize="1rem">
<FormattedMessage
id="validation-helperText.hhMemberIncome"
defaultMessage="Please select and enter a response for all income fields"
/>
</ErrorMessageWrapper>
);
if (hhMemberHealthInsData.none === true || hhMemberHealthInsData.dont_know === true) {
//check here to ensure that that is the ONLY option that was selected via numOfTrueValues
return numOfTrueValues === 1;
} else {
return '';
const atLeastOneOptionWasSelected = numOfTrueValues > 0;
return atLeastOneOptionWasSelected;
ivonne-hernandez marked this conversation as resolved.
Show resolved Hide resolved
}
};

const healthInsuranceDataHasError: ValidationFunction<HealthInsurance> = (hhMemberHealthInsData: HealthInsurance) => {
return !healthInsuranceDataIsValid(hhMemberHealthInsData);
};

const emailHasError: ValidationFunction<string> = (email) => {
return !/^.+@(?:[a-zA-Z0-9]+\.)+[A-Za-z]+$/.test(email);
};
Expand Down Expand Up @@ -571,7 +594,6 @@ export {
acuteHHConditionsHasError,
benefitsHasError,
displayBenefitsHelperText,
getPersonDataErrorMsg,
countySelectHelperText,
expenseTypeHelperText,
relationTypeHelperText,
Expand All @@ -580,4 +602,6 @@ export {
otherReferalSourceHelperText,
termsOfServiceHasError,
displayAgreeToTermsErrorMessage,
healthInsuranceDataHasError,
getHealthInsuranceError,
};
57 changes: 45 additions & 12 deletions src/Components/Confirmation/Confirmation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useNavigate, Link, useParams } from 'react-router-dom';
import { Button } from '@mui/material';
import { FormattedMessage, useIntl } from 'react-intl';
import relationshipOptions from '../../Assets/relationshipOptions';
import taxYearOptions from '../../Assets/taxYearOptions';
import referralOptions from '../../Assets/referralOptions';
import incomeOptions from '../../Assets/incomeOptions';
import frequencyOptions from '../../Assets/frequencyOptions';
Expand Down Expand Up @@ -62,7 +61,7 @@ const Confirmation = () => {
const allHouseholdAges = getAllHouseholdAges();

const householdMemberDataBlocks = householdData.map((personData, i) => {
const { hasIncome, incomeStreams } = personData;
const { hasIncome, incomeStreams, healthInsurance } = personData;

return (
<div key={i}>
Expand Down Expand Up @@ -95,6 +94,7 @@ const Confirmation = () => {
{hasIncome && incomeStreams.length > 0 && <ul> {listAllIncomeStreams(incomeStreams)} </ul>}
{hasIncome === false && <FormattedMessage id="confirmation.noIncome" defaultMessage=" None" />}
</article>
{displayHHMHealthInsuranceSection(healthInsurance)}
</Grid>
<Grid item xs={2} display="flex" justifyContent="flex-end">
<button
Expand All @@ -113,6 +113,20 @@ const Confirmation = () => {
return householdMemberDataBlocks;
};

const displayHHMHealthInsuranceSection = (hHMemberHealthInsurance) => {
return (
<article className="section-p">
<b>
<FormattedMessage
id="confirmation.headOfHouseholdDataBlock-healthInsuranceText"
defaultMessage="Health Insurance: "
/>{' '}
</b>
{displayHealthInsurance(hHMemberHealthInsurance)}
</article>
);
};

const displayHouseholdExpenses = () => {
const { hasExpenses, expenses } = formData;

Expand Down Expand Up @@ -387,16 +401,6 @@ const Confirmation = () => {
<>
{displayZipcodeSection()}
<p className="confirmation-section-underline"></p>
{displayHHCheckboxSection(
'healthInsurance',
'confirmation.displayAllFormData-healthInsurance',
'Household Insurance',
getQuestionUrl('healthInsurance'),
refactorOptionsList(healthInsuranceOptions),
<MedicalServicesIcon className="home-icon" />,
'edit health insurance',
)}
<p className="confirmation-section-underline"></p>
{displayHouseholdSizeSection()}
<p className="confirmation-section-underline"></p>
{displayAllMembersDataBlock()}
Expand Down Expand Up @@ -568,6 +572,35 @@ const Confirmation = () => {
return getStepDirectory(formData.immutableReferrer).length + startingQuestionNumber;
};

const displayHealthInsurance = (hHMemberHealthInsurance) => {
const selectedDontKnow = hHMemberHealthInsurance.dont_know === true;
const selectedNone = hHMemberHealthInsurance.none === true;
const allOtherSelectedOptions = Object.entries(hHMemberHealthInsurance).filter(
(hHMemberInsEntry) => hHMemberInsEntry[1] === true,
);

const allOtherSelectedOptionsString = allOtherSelectedOptions.reduce((acc, filteredHHMInsEntry, index) => {
const formattedMessageProp = healthInsuranceOptions[filteredHHMInsEntry[0]].formattedMessage.props;
const translatedAriaLabel = intl.formatMessage({ ...formattedMessageProp });

if (allOtherSelectedOptions.length - 1 === index) {
//we're at the last element in the array => don't include the comma
return (acc += translatedAriaLabel);
} else {
//include a comma to separate each string
return (acc += translatedAriaLabel + ', ');
}
}, '');

if (selectedDontKnow) {
return <>{healthInsuranceOptions.dont_know.formattedMessage}</>;
} else if (selectedNone) {
return <>{healthInsuranceOptions.none.formattedMessage}</>;
} else {
return <>{allOtherSelectedOptionsString}</>;
}
};

return (
<main className="benefits-form">
<h1 className="sub-header">
Expand Down
Loading
Loading