Skip to content

Commit

Permalink
Merge pull request #50 from EyeSeeTea/fix/path-iso-form
Browse files Browse the repository at this point in the history
Pathogen Iso form data entry fixes.
  • Loading branch information
MiquelAdell authored May 22, 2024
2 parents 30771a7 + ee20c27 commit 5821b3e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
6 changes: 2 additions & 4 deletions src/data/utils/questionHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
14 changes: 8 additions & 6 deletions src/domain/entities/Questionnaire/QuestionnaireQuestion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 8 additions & 6 deletions src/domain/entities/Questionnaire/QuestionnaireSection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5821b3e

Please sign in to comment.