diff --git a/src/components/interactive-builder/edit-question.modal.tsx b/src/components/interactive-builder/edit-question.modal.tsx index 803dbb18..62ea6870 100644 --- a/src/components/interactive-builder/edit-question.modal.tsx +++ b/src/components/interactive-builder/edit-question.modal.tsx @@ -144,7 +144,10 @@ const EditQuestionModal: React.FC = ({ ); const [programWorkflows, setProgramWorkflows] = useState>([]); - const hasConceptChanged = selectedConcept && questionToEdit?.questionOptions?.concept !== selectedConcept?.uuid; + const hasConceptChanged = + selectedConcept && + questionToEdit?.questionOptions.concept && + questionToEdit?.questionOptions?.concept !== selectedConcept?.uuid; const [addInlineDate, setAddInlineDate] = useState(false); // Maps the data type of a concept to a date picker type. @@ -276,8 +279,8 @@ const EditQuestionModal: React.FC = ({ rendering: fieldType ? fieldType : questionToEdit.questionOptions.rendering, ...((selectedConcept || questionToEdit.questionOptions.concept) && { concept: selectedConcept ? selectedConcept.uuid : questionToEdit.questionOptions.concept, + conceptMappings: conceptMappings?.length ? conceptMappings : questionToEdit.questionOptions.conceptMappings, }), - conceptMappings: conceptMappings?.length ? conceptMappings : questionToEdit.questionOptions.conceptMappings, answers: mappedAnswers, ...(questionType === 'patientIdentifier' && { identifierType: selectedPatientIdentifierType diff --git a/src/hooks/useConceptName.ts b/src/hooks/useConceptName.ts index 048b87cf..ea118fc0 100644 --- a/src/hooks/useConceptName.ts +++ b/src/hooks/useConceptName.ts @@ -1,5 +1,6 @@ import useSWR from 'swr'; import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework'; +import { isEmpty } from '@openmrs/openmrs-form-engine-lib'; export function useConceptName(conceptId: string | undefined) { const customRepresentation = 'custom:(name:(display))'; @@ -10,6 +11,6 @@ export function useConceptName(conceptId: string | undefined) { return { conceptName: data?.data?.name?.display ?? null, conceptNameLookupError: error, - isLoadingConceptName: (!data && !error) || false, + isLoadingConceptName: !conceptId || isEmpty(conceptId) ? false : (!data && !error) || false, }; }