Skip to content

Commit

Permalink
bug/WP-741: Missed bugs follow on (#359)
Browse files Browse the repository at this point in the history
* Import get_registration db util functions to view

* Front-end fixes: Add/Remove Entity/Contacts button wrapping, Entity/Contact header styling, add initial value + initial touched for state field

* Add style class for bolding nested headers on form

* Add some padding above  labels for entity and contact entries

* Data transfer bugs when pre-loading data to form: for self value now goes to form as string rather than bool, and type display value is mapped to the database value

---------

Co-authored-by: Chandra Y <[email protected]>
  • Loading branch information
edmondsgarrett and chandra-tacc authored Nov 15, 2024
1 parent 264b4da commit cc5cbab
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 108 deletions.
8 changes: 4 additions & 4 deletions apcd-cms/src/apps/registrations/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from apps.utils.apcd_database import create_registration, create_registration_entity, create_registration_contact
from apps.utils.apcd_database import create_registration, create_registration_entity, create_registration_contact, get_registrations, get_registration_entities, get_registration_contacts
from apps.utils.apcd_groups import has_apcd_group
from apps.utils.registrations_data_formatting import _set_registration
from apps.submitter_renewals_listing.views import get_submitter_code
Expand Down Expand Up @@ -30,10 +30,10 @@ def get(self, request):
try:
response = get_submitter_code(request.user)
submitter_code = json.loads(response.content)['submitter_code']
submitter_registrations = apcd_database.get_registrations(submitter_code=submitter_code)
submitter_registrations = get_registrations(submitter_code=submitter_code)
registration_content = [registration for registration in submitter_registrations if registration[0] == int(reg_id)][0]
registration_entities = apcd_database.get_registration_entities(reg_id=reg_id)
registration_contacts = apcd_database.get_registration_contacts(reg_id=reg_id)
registration_entities = get_registration_entities(reg_id=reg_id)
registration_contacts = get_registration_contacts(reg_id=reg_id)
renew = True
formatted_reg_data = _set_registration(registration_content, registration_entities, registration_contacts)
except Exception as exception:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import FieldWrapper from 'core-wrappers/FieldWrapperFormik/FieldWrapperFormik';
export const RegistrationContact: React.FC<{ index: number }> = ({ index }) => {
return (
<div>
<h5>Contact {index + 1}</h5>
<h5 className={`${styles.boldedHeader} ${styles.spacedHeader}`}>CONTACT {index + 1}</h5>

<TextFormField
name={`contacts.${index}.contact_type`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import FieldWrapper from 'core-wrappers/FieldWrapperFormik';
export const RegistrationEntity: React.FC<{ index: number }> = ({ index }) => {
return (
<div>
<h5>Entity {index + 1}</h5>
<h5 className={`${styles.boldedHeader} ${styles.spacedHeader}`}>ENTITY {index + 1}</h5>
<TextFormField
name={`entities.${index}.entity_name`}
label="Name"
Expand All @@ -29,11 +29,11 @@ export const RegistrationEntity: React.FC<{ index: number }> = ({ index }) => {
helpText="Enter in format 12-3456789."
/>

<TextFormField
name={`entities.${index}.license_number`}
label="License Number"
helpText="Enter digits only."
/>
<TextFormField
name={`entities.${index}.license_number`}
label="License Number"
helpText="Enter digits only."
/>

<TextFormField
name={`entities.${index}.naic_company_code`}
Expand All @@ -43,7 +43,7 @@ export const RegistrationEntity: React.FC<{ index: number }> = ({ index }) => {
</FormGroup>
</FieldWrapper>

<h6>Type of Plan</h6>
<h6 className={styles.boldedHeader}>Type of Plan</h6>
<FieldWrapper
name={`entities.${index}.types_of_plans_hidden`}
label="Plan Types"
Expand Down Expand Up @@ -84,7 +84,7 @@ export const RegistrationEntity: React.FC<{ index: number }> = ({ index }) => {
</FormGroup>
</FieldWrapper>

<h6>File Submission</h6>
<h6 className={styles.boldedHeader}>File Submission</h6>
<FieldWrapper
name={`entities.${index}.types_of_files_hidden`}
label="Types of Files"
Expand Down Expand Up @@ -136,7 +136,7 @@ export const RegistrationEntity: React.FC<{ index: number }> = ({ index }) => {
</FormGroup>
</FieldWrapper>

<h6>
<h6 className={styles.boldedHeader}>
Coverage Estimates
<small>
{' '}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,17 @@
.isRequired {
color: red;
}

.contactsAndEntitiesButtons {
background-color: var(--global-color-accent--normal);
border-color: var(--global-color-accent--normal);
color: var(--global-color-primary--xx-light);
}

.boldedHeader {
font-weight: bold;
}

.spacedHeader {
margin-top: 2rem;
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ const initialValues: RegistrationFormValues = {
business_name: '',
mailing_address: '',
city: '',
state: 'AL',
zip_code: '',
reg_id: -1,
entities: [
Expand Down Expand Up @@ -165,21 +166,22 @@ 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,
},
],
};
on_behalf_of: true,
type: true,
state: 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;
Expand Down Expand Up @@ -404,87 +406,91 @@ export const RegistrationForm: React.FC<{
(displayed after submitting this form).
</p>
)}
<Button
className="c-button c-button--primary"
type="button"
color="primary"
disabled={values.entities.length === 5}
onClick={() =>
setFieldValue('entities', [
...values.entities,
{
entity_name: '',
fein: '',
license_number: '',
naic_company_code: '',
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: '',
},
])
}
>
+ Add Another Entity
</Button>{' '}
<Button
className="c-button c-button--secondary"
type="button"
onClick={() =>
values.entities.length > 1 &&
setFieldValue('entities', values.entities.slice(0, -1))
}
color="secondary"
disabled={values.entities.length === 1}
>
- Remove Last Entity
</Button>
<div className='button-wrapper'>
<Button
className={`c-button c-button--primary ${styles.contactsAndEntitiesButtons}`}
type="button"
color="primary"
disabled={values.entities.length === 5}
onClick={() =>
setFieldValue('entities', [
...values.entities,
{
entity_name: '',
fein: '',
license_number: '',
naic_company_code: '',
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: '',
},
])
}
>
+ Add Another Entity
</Button>{' '}
<Button
className="c-button c-button--secondary"
type="button"
onClick={() =>
values.entities.length > 1 &&
setFieldValue('entities', values.entities.slice(0, -1))
}
color="secondary"
disabled={values.entities.length === 1}
>
- Remove Last Entity
</Button>
</div>
<hr />
<h4>Contact Information</h4>
{values.contacts.map((contact, index) => (
<RegistrationContact key={index} index={index} />
))}
<Button
className="c-button c-button--primary"
type="button"
color="primary"
disabled={values.contacts.length === 5}
onClick={() =>
setFieldValue('contacts', [
...values.contacts,
{
contact_type: '',
contact_name: '',
contact_phone: '',
contact_email: '',
contact_notifications: false,
},
])
}
>
+ Add Another Contact
</Button>{' '}
<Button
className="c-button c-button--secondary"
type="button"
onClick={() =>
values.contacts.length > 1 &&
setFieldValue('contacts', values.contacts.slice(0, -1))
}
color="secondary"
disabled={values.contacts.length === 1}
>
- Remove Last Contact
</Button>
<div className='button-wrapper'>
<Button
className={`c-button c-button--primary ${styles.contactsAndEntitiesButtons}`}
type="button"
color="primary"
disabled={values.contacts.length === 5}
onClick={() =>
setFieldValue('contacts', [
...values.contacts,
{
contact_type: '',
contact_name: '',
contact_phone: '',
contact_email: '',
contact_notifications: false,
},
])
}
>
+ Add Another Contact
</Button>{' '}
<Button
className="c-button c-button--secondary"
type="button"
onClick={() =>
values.contacts.length > 1 &&
setFieldValue('contacts', values.contacts.slice(0, -1))
}
color="secondary"
disabled={values.contacts.length === 1}
>
- Remove Last Contact
</Button>
</div>
<div className="button-wrapper submit">
<Button
type="submit"
Expand Down
13 changes: 10 additions & 3 deletions apcd-cms/src/client/src/hooks/registrations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export type RegistrationFormValues = {
business_name: string;
mailing_address: string;
city: string;
state?: string | undefined;
state: string;
zip_code: string;
reg_id?: number;
entities: {
Expand Down Expand Up @@ -112,10 +112,17 @@ export type RegistrationFormValues = {
export function transformToRegistrationFormValues(
registration: RegistrationContent
): RegistrationFormValues {

const typeValueMap:Record<string, string> = { // to set database value for field rather than display value
'Insurance Carrier': 'carrier',
'Plan Administrator¹ (TPA/ASO)': 'tpa_aso',
'Pharmacy Benefit Manager (PBM)': 'pbm'
}

return {
on_behalf_of: registration.for_self ?? '',
on_behalf_of: registration.for_self?.toString() ?? '',
reg_year: registration.year.toString(),
type: registration.type ?? '',
type: registration.type ? typeValueMap[registration.type] : '',
business_name: registration.biz_name,
mailing_address: registration.address,
city: registration.city,
Expand Down

0 comments on commit cc5cbab

Please sign in to comment.