Skip to content

Commit

Permalink
bug/WP-741: Registration Form cleanup tasks (#358)
Browse files Browse the repository at this point in the history
* Move 'On behalf of' help text div to arrange correctly under radio buttons

* Fix validation messages for entity grouped 'atleast one' inputs + checkboxes not writing correctly to db

* Fix checkboxes writing to db from reg form - inputs now return bool instead of str
  • Loading branch information
edmondsgarrett authored Nov 13, 2024
1 parent 43b0441 commit 3cbbc80
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 24 deletions.
32 changes: 16 additions & 16 deletions apcd-cms/src/apps/utils/apcd_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,14 +354,14 @@ def create_registration_entity(entity, reg_id, from_update_reg=None):#, old_reg_
_set_int(entity['total_covered_lives']),
_clean_value(entity['entity_name']),
_clean_value(entity['fein']),
True if 'types_of_plans_commercial' in entity else False,
True if 'types_of_plans_medicare' in entity else False,
True if 'types_of_plans_medicaid' in entity else False,
entity['types_of_plans_commercial'],
entity['types_of_plans_medicare'],
entity['types_of_plans_medicaid'],
True,
True if 'types_of_files_provider' in entity else False,
True if 'types_of_files_medical' in entity else False,
True if 'types_of_files_pharmacy' in entity else False,
True if 'types_of_files_dental' in entity else False
entity['types_of_files_provider'],
entity['types_of_files_medical'],
entity['types_of_files_pharmacy'],
entity['types_of_files_dental']
)

operation = """INSERT INTO registration_entities(
Expand Down Expand Up @@ -423,13 +423,13 @@ def update_registration_entity(entity, reg_id):
_set_int(entity['total_covered_lives']),
_clean_value(entity['entity_name']),
_clean_value(entity['fein']),
True if 'types_of_plans_commercial' in entity else False,
True if 'types_of_plans_medicare' in entity else False,
True if 'types_of_plans_medicaid' in entity else False,
True if 'types_of_files_provider' in entity else False,
True if 'types_of_files_medical' in entity else False,
True if 'types_of_files_pharmacy' in entity else False,
True if 'types_of_files_dental' in entity else False,
entity['types_of_plans_commercial'],
entity['types_of_plans_medicare'],
entity['types_of_plans_medicaid'],
entity['types_of_files_provider'],
entity['types_of_files_medical'],
entity['types_of_files_pharmacy'],
entity['types_of_files_dental'],
reg_id,
entity['entity_id']
)
Expand Down Expand Up @@ -556,7 +556,7 @@ def create_registration_contact(contact, reg_id, from_update_reg=None):
#str_end = f'{iteration}{ f"_{reg_id}" if from_update_reg else (f"_{old_reg_id}" if old_reg_id else "") }'
values = (
reg_id,
True if 'contact_notifications' in contact else False,
contact['contact_notifications'],
_clean_value(contact['contact_type']),
_clean_value(contact['contact_name']),
re.sub("[^0-9]", "", contact['contact_phone']),
Expand Down Expand Up @@ -606,7 +606,7 @@ def update_registration_contact(contact, reg_id):
return create_registration_contact(contact, reg_id)

values = (
True if 'contact_notifications' in contact else False,
contact['contact_notifications'],
_clean_value(contact['contact_type']),
_clean_value(contact['contact_name']),
re.sub("[^0-9]", "", contact['contact_phone']),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export const RegistrationEntity: React.FC<{ index: number }> = ({ index }) => {
/>
</FormGroup>
))}
<ErrorMessage name={`entities.${index}.types_of_plans_hidden`} component="div" className={styles.isInvalid} />
</FormGroup>

<h6>File Submission</h6>
Expand Down Expand Up @@ -150,6 +151,7 @@ export const RegistrationEntity: React.FC<{ index: number }> = ({ index }) => {
/>
</FormGroup>
))}
<ErrorMessage name={`entities.${index}.types_of_files_hidden`} component="div" className={styles.isInvalid} />
</FormGroup>

<h6>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const validationSchema = Yup.object().shape({
if (!value.fein && !value.license_number && !value.naic_company_code) {
return this.createError({
message: 'Please fill in at least one Number/Code.',
path: this.path + '.fein',
});
}
return true;
Expand All @@ -85,6 +86,7 @@ const validationSchema = Yup.object().shape({
) {
return this.createError({
message: 'Please select at least one plan type.',
path: this.path + ".types_of_plans_hidden"
});
}
return true;
Expand All @@ -97,6 +99,7 @@ const validationSchema = Yup.object().shape({
) {
return this.createError({
message: 'Please select at least one claims file type (see above).',
path: this.path + ".types_of_files_hidden"
});
}
return true;
Expand Down Expand Up @@ -133,14 +136,16 @@ const initialValues: RegistrationFormValues = {
fein: '',
license_number: '',
naic_company_code: '',
types_of_plans_commerical: false,
types_of_plans_commercial: false,
types_of_plans_medicare: false,
types_of_plans_medicaid: false,
types_of_plans_hidden: false,
types_of_files_eligibility_enrollment: true,
types_of_files_provider: false,
types_of_files_medical: false,
types_of_files_pharmacy: false,
types_of_files_dental: false,
types_of_files_hidden: false,
total_covered_lives: '',
claims_encounters_volume: '',
total_claims_value: '',
Expand All @@ -159,6 +164,23 @@ const initialValues: RegistrationFormValues = {
],
};

const initialTouched = {
on_behalf_of: true,
type: true,
entities: [
{
types_of_plans_commercial: true,
types_of_plans_medicare: true,
types_of_plans_medicaid: true,
types_of_files_eligibility_enrollment: true,
types_of_files_provider: true,
types_of_files_medical: true,
types_of_files_pharmacy: true,
types_of_files_dental: true,
}
]
}

export const RegistrationForm: React.FC<{
isEdit?: boolean;
inputValues?: RegistrationFormValues;
Expand Down Expand Up @@ -237,6 +259,7 @@ export const RegistrationForm: React.FC<{
? transformToRegistrationFormValues(data)
: inputValues ?? initialValues
}
initialTouched={initialTouched}
validationSchema={validationSchema}
onSubmit={handleSubmit}
>
Expand Down Expand Up @@ -304,11 +327,11 @@ export const RegistrationForm: React.FC<{
/>{' '}
Other
</Label>
<div className="help-text">
</FormGroup>
<div className="help-text">
Whether you submit on behalf of your own organization
(Self) or another organization (Other)
</div>
</FormGroup>
</div>
</FormGroup>
<TextFormField
name="reg_year"
Expand Down Expand Up @@ -417,14 +440,16 @@ export const RegistrationForm: React.FC<{
fein: '',
license_number: '',
naic_company_code: '',
types_of_plans_commerical: false,
types_of_plans_commercial: false,
types_of_plans_medicare: false,
types_of_plans_medicaid: false,
types_of_plans_hidden: false,
types_of_files_eligibility_enrollment: true,
types_of_files_provider: false,
types_of_files_medical: false,
types_of_files_pharmacy: false,
types_of_files_dental: false,
types_of_files_hidden: false,
total_covered_lives: '',
claims_encounters_volume: '',
total_claims_value: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export const TextFormField: React.FC<{
)}
</Label>
<Field name={name} as="input" id={name} className="textinput" />
<ErrorMessage name={name} component="div" className={styles.isInvalid} />
{helpText ? <div className="help-text">{helpText}</div> : <></>}
<ErrorMessage name={name} component="div" className={styles.isInvalid} />
</FormGroup>
);
};
6 changes: 4 additions & 2 deletions apcd-cms/src/client/src/hooks/registrations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,16 @@ export type RegistrationFormValues = {
fein: string;
license_number: string;
naic_company_code: string;
types_of_plans_commerical: boolean;
types_of_plans_commercial: boolean;
types_of_plans_medicare: boolean;
types_of_plans_medicaid: boolean;
types_of_plans_hidden?: boolean;
types_of_files_eligibility_enrollment: boolean;
types_of_files_provider: boolean;
types_of_files_medical: boolean;
types_of_files_pharmacy: boolean;
types_of_files_dental: boolean;
types_of_files_hidden?: boolean;
total_covered_lives: any;
claims_encounters_volume: any;
total_claims_value: any;
Expand Down Expand Up @@ -125,7 +127,7 @@ export function transformToRegistrationFormValues(
fein: entity.fein ?? '',
license_number: entity.license ?? '',
naic_company_code: entity.naic ?? '',
types_of_plans_commerical: entity.plans_type['Commercial'],
types_of_plans_commercial: entity.plans_type['Commercial'],
types_of_plans_medicare: entity.plans_type['Medicare'],
types_of_plans_medicaid: entity.plans_type['Medicaid'],
types_of_files_eligibility_enrollment:
Expand Down

0 comments on commit 3cbbc80

Please sign in to comment.