diff --git a/src/data/utils/questionHelper.ts b/src/data/utils/questionHelper.ts index faa3b0d..29ea326 100644 --- a/src/data/utils/questionHelper.ts +++ b/src/data/utils/questionHelper.ts @@ -170,7 +170,7 @@ export const getQuestion = ( const dateQ: DateQuestion = { ...base, type: "date", - value: dataValue ? new Date(dataValue as string) : new Date(), + value: dataValue ? new Date(dataValue as string) : undefined, }; return dateQ; } @@ -179,9 +179,7 @@ export const getQuestion = ( const dateQ: DateTimeQuestion = { ...base, type: "datetime", - value: dataValue - ? new Date(dataValue as string).toISOString() - : new Date().toISOString(), + value: dataValue ? new Date(dataValue as string).toISOString() : undefined, }; return dateQ; } diff --git a/src/domain/entities/Questionnaire/QuestionnaireQuestion.ts b/src/domain/entities/Questionnaire/QuestionnaireQuestion.ts index 23a27a0..d2dac2e 100644 --- a/src/domain/entities/Questionnaire/QuestionnaireQuestion.ts +++ b/src/domain/entities/Questionnaire/QuestionnaireQuestion.ts @@ -225,12 +225,14 @@ export class QuestionnaireQuestion { if (!applicableRules || applicableRules.length === 0) return question.isVisible; const updatedQuestionVisibility = applicableRules.flatMap(rule => { - return rule.actions.flatMap(action => { - if (action.programRuleActionType === "HIDEFIELD") { - if (rule.parsedResult === true) return false; - else return; - } else return question.isVisible; - }); + return rule.actions + .filter(action => action.programRuleActionType === "HIDEFIELD") + .flatMap(action => { + if (action.programRuleActionType === "HIDEFIELD") { + if (rule.parsedResult === true) return false; + else return; + } else return question.isVisible; + }); }); //If even one of the rules asks to hide the field, hide the question diff --git a/src/domain/entities/Questionnaire/QuestionnaireSection.ts b/src/domain/entities/Questionnaire/QuestionnaireSection.ts index c6107e4..afa5370 100644 --- a/src/domain/entities/Questionnaire/QuestionnaireSection.ts +++ b/src/domain/entities/Questionnaire/QuestionnaireSection.ts @@ -94,12 +94,14 @@ export class QuestionnaireSectionM { if (!applicableRules || applicableRules.length === 0) return section.isVisible; const updatedSectionVisibility = applicableRules.flatMap(rule => { - return rule.actions.flatMap(action => { - if (action.programRuleActionType === "HIDESECTION") { - if (rule.parsedResult === true) return false; - else return true; - } else return section.isVisible; - }); + return rule.actions + .filter(action => action.programRuleActionType === "HIDESECTION") + .flatMap(action => { + if (action.programRuleActionType === "HIDESECTION") { + if (rule.parsedResult === true) return false; + else return true; + } else return section.isVisible; + }); }); // If even one of the rules asks to hide the section, hide the section