From cb6bbb1f3f515f660221aaa0fe88bb885c66f49c Mon Sep 17 00:00:00 2001 From: Faith Kamau <121166087+hiqedme@users.noreply.github.com> Date: Thu, 22 Feb 2024 11:18:50 +0300 Subject: [PATCH] fix/concept-answers: added customConceptAnswers check --- .../coded-person-attribute-field.component.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/esm-patient-registration-app/src/patient-registration/field/person-attributes/coded-person-attribute-field.component.tsx b/packages/esm-patient-registration-app/src/patient-registration/field/person-attributes/coded-person-attribute-field.component.tsx index 5a2a5e02d..3a8b75241 100644 --- a/packages/esm-patient-registration-app/src/patient-registration/field/person-attributes/coded-person-attribute-field.component.tsx +++ b/packages/esm-patient-registration-app/src/patient-registration/field/person-attributes/coded-person-attribute-field.component.tsx @@ -26,12 +26,13 @@ export function CodedPersonAttributeField({ const { data: conceptAnswers, isLoading: isLoadingConceptAnswers } = useConceptAnswers( customConceptAnswers.length ? '' : answerConceptSetUuid, ); + const { t } = useTranslation(); const fieldName = `attributes.${personAttributeType.uuid}`; const [error, setError] = useState(false); useEffect(() => { - if (!answerConceptSetUuid) { + if (!answerConceptSetUuid && !customConceptAnswers.length) { reportError( t( 'codedPersonAttributeNoAnswerSet', @@ -41,10 +42,10 @@ export function CodedPersonAttributeField({ ); setError(true); } - }, [answerConceptSetUuid]); + }, [answerConceptSetUuid, customConceptAnswers]); useEffect(() => { - if (!isLoadingConceptAnswers) { + if (!isLoadingConceptAnswers && !customConceptAnswers.length) { if (!conceptAnswers) { reportError( t( @@ -69,7 +70,7 @@ export function CodedPersonAttributeField({ setError(true); } } - }, [isLoadingConceptAnswers, conceptAnswers]); + }, [isLoadingConceptAnswers, conceptAnswers, customConceptAnswers]); const answers = useMemo(() => { if (customConceptAnswers.length) {