diff --git a/client/src/pages/patients/PatientRegistrationAccordion.jsx b/client/src/pages/patients/PatientRegistrationAccordion.jsx index 95cc48ce..e87efd07 100644 --- a/client/src/pages/patients/PatientRegistrationAccordion.jsx +++ b/client/src/pages/patients/PatientRegistrationAccordion.jsx @@ -19,6 +19,29 @@ const PatientRegistrationAccordionProps = { handleAccordionChange: PropTypes.func.isRequired, }; +const FORM_SELECT_ENUM_VALUES = { + language: [ + 'CANTONESE', + 'ENGLISH', + 'MANDARIN', + 'RUSSIAN', + 'SPANISH', + 'TAGALOG', + ], + gender: ['FEMALE', 'MALE', 'TRANS_MALE', 'TRANS_FEMALE', 'OTHER', 'UNKNOWN'], + relationship: ['SPOUSE', 'PARENT', 'CHILD', 'SIBLING', 'OTHER', 'UNKNOWN'], + codeStatus: ['COMFORT', 'DNR', 'DNI', 'DNR_DNI', 'FULL'], +}; + +/** + * Converts a string to title case + * @param {string} string + * @returns {string} + */ +function toTitleCase(string) { + return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase(); +} + /** * Patient Registration Accordion component * @param {PropTypes.InferProps} props @@ -72,14 +95,10 @@ export default function PatientRegistrationAccordion({ label="Gender" placeholder="Select Gender" withAsterisk - data={[ - 'FEMALE', - 'MALE', - 'TRANS_MALE', - 'TRANS_FEMALE', - 'OTHER', - 'UNKNOWN', - ]} + data={FORM_SELECT_ENUM_VALUES.gender.map((value) => ({ + value, + label: toTitleCase(value), + }))} searchable key={form.key('patientData.gender')} {...form.getInputProps('patientData.gender')} @@ -88,14 +107,10 @@ export default function PatientRegistrationAccordion({ label="Language" placeholder="Select Language" withAsterisk - data={[ - 'CANTONESE', - 'ENGLISH', - 'MANDARIN', - 'RUSSIAN', - 'SPANISH', - 'TAGALOG', - ]} + data={FORM_SELECT_ENUM_VALUES.language.map((value) => ({ + value, + label: toTitleCase(value), + }))} searchable key={form.key('patientData.language')} {...form.getInputProps('patientData.language')} @@ -156,14 +171,10 @@ export default function PatientRegistrationAccordion({ ({ + value, + label: toTitleCase(value), + }))} searchable key={form.key('codeStatus')} {...form.getInputProps('codeStatus')}