diff --git a/src/hooks/useSpecificQuestions.ts b/src/hooks/useSpecificQuestions.ts index 7d71f80..8e49142 100644 --- a/src/hooks/useSpecificQuestions.ts +++ b/src/hooks/useSpecificQuestions.ts @@ -48,6 +48,16 @@ function getQuestions(specificQuestions: Array, formSche .map((question) => { const specificQuestion = specificQuestionsMap.get(question.id) || {}; + const answers = + (specificQuestion as SpecificQuestionConfig).answers?.map((a) => ({ + value: a, + display: conceptLabels[a]?.display, + })) || + (question.questionOptions.answers ?? []).map((answer) => ({ + value: answer.concept, + display: answer.label ?? conceptLabels[answer.concept]?.display, + })); + return { question: { display: question.label ?? conceptLabels[question.questionOptions.concept]?.display, @@ -55,10 +65,7 @@ function getQuestions(specificQuestions: Array, formSche disabled: (specificQuestion as SpecificQuestionConfig).disabled, defaultAnswer: (specificQuestion as SpecificQuestionConfig).defaultAnswer, }, - answers: (question.questionOptions.answers ?? []).map((answer) => ({ - value: answer.concept, - display: answer.label ?? conceptLabels[answer.concept]?.display, - })), + answers, }; }), ), diff --git a/src/types.ts b/src/types.ts index 9213a90..271abde 100644 --- a/src/types.ts +++ b/src/types.ts @@ -19,6 +19,7 @@ export interface SpecificQuestion { export interface SpecificQuestionConfig { forms: Array; questionId: string; + answers?: Array; defaultAnswer?: string; disabled?: boolean; }