Skip to content

Commit

Permalink
(fix) unkown patient name and estimated dob config fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Jexsie committed May 17, 2023
1 parent 3ea2167 commit c882b5b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ export const DobField: React.FC = () => {
const { t } = useTranslation();
const {
fieldConfigurations: { dateOfBirth },
} = useConfig() as RegistrationConfig;
} = useConfig<RegistrationConfig>();
const allowEstimatedBirthDate = dateOfBirth?.useEstimatedDateOfBirth?.enabled;
const [dobUnknown] = useField('birthdateEstimated');
const dobKnown = !dobUnknown.value;
const [birthdate, birthdateMeta] = useField('birthdate');
Expand Down Expand Up @@ -75,15 +76,17 @@ export const DobField: React.FC = () => {
return (
<div className={styles.halfWidthInDesktopView}>
<h4 className={styles.productiveHeading02Light}>{t('birthFieldLabelText', 'Birth')}</h4>
<div className={styles.dobField}>
<div className={styles.dobContentSwitcherLabel}>
<span className={styles.label01}>{t('dobToggleLabelText', 'Date of Birth Known?')}</span>
{allowEstimatedBirthDate && (
<div className={styles.dobField}>
<div className={styles.dobContentSwitcherLabel}>
<span className={styles.label01}>{t('dobToggleLabelText', 'Date of Birth Known?')}</span>
</div>
<ContentSwitcher onChange={onToggle}>
<Switch name="known" text={t('yes', 'Yes')} />
<Switch name="unknown" text={t('no', 'No')} />
</ContentSwitcher>
</div>
<ContentSwitcher onChange={onToggle}>
<Switch name="known" text={t('yes', 'Yes')} />
<Switch name="unknown" text={t('no', 'No')} />
</ContentSwitcher>
</div>
)}
<Layer>
{dobKnown ? (
<div className={styles.dobField}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,17 @@ export const NameField = () => {
},
} = useConfig() as RegistrationConfig;
const { t } = useTranslation();
const { setCapturePhotoProps, currentPhoto, setFieldValue } = useContext(PatientRegistrationContext);
const { fieldConfigurations } = useConfig();
const { setCapturePhotoProps, currentPhoto, setFieldValue, initialFormValues } =
useContext(PatientRegistrationContext);
const { fieldConfigurations } = useConfig<RegistrationConfig>();
const fieldConfigs = fieldConfigurations?.name;
const [{ value: unidentified }] = useField('unidentifiedPatient');
const nameKnown = !unidentified;
const showToggleUnknownName =
fieldConfigs?.unidentifiedPatient ||
(initialFormValues?.familyName === 'UNKNOWN' && initialFormValues?.givenName === 'UNKNOWN')
? true
: false;

const onCapturePhoto = useCallback(
(dataUri: string, photoDateTime: string) => {
Expand Down Expand Up @@ -68,13 +74,20 @@ export const NameField = () => {
)}

<div className={styles.nameField}>
<div className={styles.dobContentSwitcherLabel}>
<span className={styles.label01}>{t('patientNameKnown', "Patient's Name is Known?")}</span>
</div>
<ContentSwitcher className={styles.contentSwitcher} onChange={toggleNameKnown}>
<Switch name="known" text={t('yes', 'Yes')} />
<Switch name="unknown" text={t('no', 'No')} />
</ContentSwitcher>
{showToggleUnknownName && (
<>
<div className={styles.dobContentSwitcherLabel}>
<span className={styles.label01}>{t('patientNameKnown', "Patient's Name is Known?")}</span>
</div>
<ContentSwitcher
className={styles.contentSwitcher}
onChange={toggleNameKnown}
selectedIndex={nameKnown ? 0 : 1}>
<Switch name="known" text={t('yes', 'Yes')} />
<Switch name="unknown" text={t('no', 'No')} />
</ContentSwitcher>
</>
)}
{nameKnown && (
<>
<Input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ export function getFormValuesFromFhirPatient(patient: fhir.Patient) {
result.givenName = patientName?.given[0];
result.middleName = patientName?.given[1];
result.familyName = patientName?.family;
result.unidentifiedPatient =
patientName.given[0] === 'UNKNOWN' && patientName.family === 'unknown' ? true : undefined;
result.unidentifiedPatient = patientName.given[0] === 'UNKNOWN' && patientName.family === 'UNKNOWN' ? true : false;

result.addNameInLocalLanguage = !!additionalPatientName ? true : undefined;
result.additionalGivenName = additionalPatientName?.given[0];
Expand Down

0 comments on commit c882b5b

Please sign in to comment.