From 0cc0b45e7bf608ea6feddc1ed0bcf4859788111c Mon Sep 17 00:00:00 2001 From: smallGod Date: Thu, 27 Apr 2023 20:09:06 +0300 Subject: [PATCH 1/2] Fixes empty pages issue --- src/components/encounter/ohri-encounter-form.tsx | 9 ++++++++- src/components/page/ohri-form-page.tsx | 8 -------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/components/encounter/ohri-encounter-form.tsx b/src/components/encounter/ohri-encounter-form.tsx index 7202e5d69..f39c42165 100644 --- a/src/components/encounter/ohri-encounter-form.tsx +++ b/src/components/encounter/ohri-encounter-form.tsx @@ -556,9 +556,16 @@ export const OHRIEncounterForm: React.FC = ({ }}> {form.pages.map((page, index) => { - if (isTrue(page.isHidden)) { + const pageHasNoVisibleContent = + page.sections.every(section => section.isHidden) || + page.sections.every(section => section.questions.every(question => question.isHidden)) || + isTrue(page.isHidden); + + if (pageHasNoVisibleContent) { + console.info(`The page "${page.label}" has no visible questions. Its sections will not be rendered.`); return null; } + if (isTrue(page.isSubform) && page.subform?.form) { if (sessionMode != 'enter' && !page.subform?.form.encounter) { return null; diff --git a/src/components/page/ohri-form-page.tsx b/src/components/page/ohri-form-page.tsx index 9e6c578b1..cc4ae9b03 100644 --- a/src/components/page/ohri-form-page.tsx +++ b/src/components/page/ohri-form-page.tsx @@ -12,14 +12,6 @@ function OHRIFormPage({ page, onFieldChange, setSelectedPage, isCollapsed }) { setSelectedPage(elementID); }; - const pageHasNoVisibleQuestions = page.sections.every(section => - section.questions.every(question => question.isHidden), - ); - - if (pageHasNoVisibleQuestions) { - console.info(`The page "${page.label}" has no visible questions. Its sections will not be rendered.`); - } - const visibleSections = page.sections.filter(section => { const hasVisibleQuestions = section.questions.some(question => !isTrue(question.isHidden)); return !isTrue(section.isHidden) && hasVisibleQuestions; From 8b418adcff65257a7d4207483f26d267da702116 Mon Sep 17 00:00:00 2001 From: smallGod Date: Fri, 28 Apr 2023 11:16:29 +0300 Subject: [PATCH 2/2] remove unnecessary logging --- src/components/encounter/ohri-encounter-form.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/encounter/ohri-encounter-form.tsx b/src/components/encounter/ohri-encounter-form.tsx index f39c42165..b0ed31af5 100644 --- a/src/components/encounter/ohri-encounter-form.tsx +++ b/src/components/encounter/ohri-encounter-form.tsx @@ -562,7 +562,6 @@ export const OHRIEncounterForm: React.FC = ({ isTrue(page.isHidden); if (pageHasNoVisibleContent) { - console.info(`The page "${page.label}" has no visible questions. Its sections will not be rendered.`); return null; }