{enrollment.followUp && (
@@ -89,28 +93,28 @@ export const WidgetEnrollmentPlain = ({
{program.displayIncidentDate && (
-
diff --git a/src/core_modules/capture-core/components/WidgetEnrollment/WidgetEnrollment.container.js b/src/core_modules/capture-core/components/WidgetEnrollment/WidgetEnrollment.container.js
index 8660f704f4..38296cfa32 100644
--- a/src/core_modules/capture-core/components/WidgetEnrollment/WidgetEnrollment.container.js
+++ b/src/core_modules/capture-core/components/WidgetEnrollment/WidgetEnrollment.container.js
@@ -10,8 +10,30 @@ import { useProgram } from './hooks/useProgram';
import type { Props } from './enrollment.types';
import { plainStatus } from './constants/status.const';
-export const WidgetEnrollment = ({ teiId, enrollmentId, programId, onDelete, onAddNew, onError, onSuccess }: Props) => {
- const { error: errorEnrollment, enrollment, refetch: refetchEnrollment } = useEnrollment(enrollmentId);
+export const WidgetEnrollment = ({
+ teiId,
+ enrollmentId,
+ programId,
+ readOnlyMode = false,
+ onDelete,
+ onAddNew,
+ onUpdateEnrollmentDate,
+ onUpdateIncidentDate,
+ onError,
+ onSuccess,
+}: Props) => {
+ const {
+ enrollment,
+ updateEnrollmentDate,
+ updateIncidentDate,
+ error: errorEnrollment,
+ refetch: refetchEnrollment,
+ } = useEnrollment({
+ enrollmentId,
+ onUpdateEnrollmentDate,
+ onUpdateIncidentDate,
+ onError,
+ });
const { error: errorProgram, program } = useProgram(programId);
const {
error: errorOwnerOrgUnit,
@@ -23,6 +45,7 @@ export const WidgetEnrollment = ({ teiId, enrollmentId, programId, onDelete, onA
const canAddNew = enrollments
.filter(item => item.program === programId)
.every(item => item.status !== plainStatus.ACTIVE);
+ const containsAutoGeneratedEvent = program && program.programStages.some(({ autoGenerateEvent }) => autoGenerateEvent);
const error = errorEnrollment || errorProgram || errorOwnerOrgUnit || errorOrgUnit;
if (error) {
@@ -33,6 +56,8 @@ export const WidgetEnrollment = ({ teiId, enrollmentId, programId, onDelete, onA
diff --git a/src/core_modules/capture-core/components/WidgetEnrollment/enrollment.types.js b/src/core_modules/capture-core/components/WidgetEnrollment/enrollment.types.js
index a3eacd0fdb..d4e14794b8 100644
--- a/src/core_modules/capture-core/components/WidgetEnrollment/enrollment.types.js
+++ b/src/core_modules/capture-core/components/WidgetEnrollment/enrollment.types.js
@@ -5,8 +5,11 @@ export type Props = {|
teiId: string,
enrollmentId: string,
programId: string,
+ readOnlyMode?: boolean,
onDelete: () => void,
onAddNew: () => void,
+ onUpdateEnrollmentDate?: (enrollmentDate: string) => void,
+ onUpdateIncidentDate?: (enrollmentDate: string) => void,
onError?: (message: string) => void,
onSuccess?: () => void,
|};
@@ -17,9 +20,13 @@ export type PlainProps = {|
ownerOrgUnit: Object,
refetchEnrollment: QueryRefetchFunction,
refetchTEI: QueryRefetchFunction,
- error?: FetchError,
+ initError?: FetchError,
loading: boolean,
canAddNew: boolean,
+ editDateEnabled: boolean,
+ displayAutoGeneratedEventWarning: boolean,
+ updateEnrollmentDate: (enrollmentDate: string) => void,
+ updateIncidentDate: (incidentDate: string) => void,
onDelete: () => void,
onAddNew: () => void,
onError?: (message: string) => void,
diff --git a/src/core_modules/capture-core/components/WidgetEnrollment/hooks/useEnrollment.js b/src/core_modules/capture-core/components/WidgetEnrollment/hooks/useEnrollment.js
index 87ae5120c4..e9b2d305fd 100644
--- a/src/core_modules/capture-core/components/WidgetEnrollment/hooks/useEnrollment.js
+++ b/src/core_modules/capture-core/components/WidgetEnrollment/hooks/useEnrollment.js
@@ -1,8 +1,23 @@
// @flow
-import { useMemo, useEffect } from 'react';
+import { useMemo, useEffect, useState } from 'react';
import { useDataQuery } from '@dhis2/app-runtime';
+import { useUpdateEnrollment } from './useUpdateEnrollment';
+
+type Props = {
+ enrollmentId: string,
+ onUpdateEnrollmentDate?: (date: string) => void,
+ onUpdateIncidentDate?: (date: string) => void,
+ onError?: (error: any) => void,
+}
+
+export const useEnrollment = ({
+ enrollmentId,
+ onUpdateEnrollmentDate,
+ onUpdateIncidentDate,
+ onError,
+}: Props) => {
+ const [enrollment, setEnrollment] = useState();
-export const useEnrollment = (enrollmentId: string) => {
const { error, loading, data, refetch } = useDataQuery(
useMemo(
() => ({
@@ -20,5 +35,33 @@ export const useEnrollment = (enrollmentId: string) => {
enrollmentId && refetch({ variables: { enrollmentId } });
}, [refetch, enrollmentId]);
- return { error, refetch, enrollment: !loading && data?.enrollment };
+ useEffect(() => {
+ if (data) {
+ setEnrollment(data.enrollment);
+ }
+ }, [setEnrollment, data]);
+
+ const updateEnrollmentDate = useUpdateEnrollment({
+ enrollment,
+ setEnrollment,
+ propertyName: 'enrolledAt',
+ updateHandler: onUpdateEnrollmentDate,
+ onError,
+ });
+
+ const updateIncidentDate = useUpdateEnrollment({
+ enrollment,
+ setEnrollment,
+ propertyName: 'occurredAt',
+ updateHandler: onUpdateIncidentDate,
+ onError,
+ });
+
+ return {
+ error,
+ refetch,
+ enrollment: !loading && enrollment,
+ updateEnrollmentDate,
+ updateIncidentDate,
+ };
};
diff --git a/src/core_modules/capture-core/components/WidgetEnrollment/hooks/useProgram.js b/src/core_modules/capture-core/components/WidgetEnrollment/hooks/useProgram.js
index 937f5644c6..fec7939f6d 100644
--- a/src/core_modules/capture-core/components/WidgetEnrollment/hooks/useProgram.js
+++ b/src/core_modules/capture-core/components/WidgetEnrollment/hooks/useProgram.js
@@ -10,7 +10,7 @@ export const useProgram = (programId: string) => {
resource: `programs/${programId}`,
params: {
fields: [
- 'displayIncidentDate,incidentDateLabel,enrollmentDateLabel,onlyEnrollOnce,trackedEntityType[displayName]',
+ 'displayIncidentDate,incidentDateLabel,enrollmentDateLabel,onlyEnrollOnce,trackedEntityType[displayName],programStages[autoGenerateEvent],access',
],
},
},
diff --git a/src/core_modules/capture-core/components/WidgetEnrollment/hooks/useUpdateEnrollment.js b/src/core_modules/capture-core/components/WidgetEnrollment/hooks/useUpdateEnrollment.js
new file mode 100644
index 0000000000..fd7c96f827
--- /dev/null
+++ b/src/core_modules/capture-core/components/WidgetEnrollment/hooks/useUpdateEnrollment.js
@@ -0,0 +1,42 @@
+// @flow
+import { useCallback } from 'react';
+import { useDataMutation } from '@dhis2/app-runtime';
+import { processErrorReports } from '../processErrorReports';
+
+const enrollmentUpdate = {
+ resource: 'tracker?async=false&importStrategy=UPDATE',
+ type: 'create',
+ data: enrollment => ({
+ enrollments: [enrollment],
+ }),
+};
+
+export const useUpdateEnrollment = ({
+ enrollment,
+ setEnrollment,
+ propertyName,
+ updateHandler,
+ onError,
+}: {
+ enrollment: any,
+ setEnrollment: (enrollment: any) => void,
+ propertyName: string,
+ updateHandler?: (value: any) => void,
+ onError?: (error: any) => void,
+}) => {
+ const [updateEnrollmentMutation] = useDataMutation(enrollmentUpdate, {
+ onError: (e) => {
+ setEnrollment(enrollment);
+ updateHandler && updateHandler(enrollment[propertyName]);
+ onError && onError(processErrorReports(e));
+ },
+ });
+
+ return useCallback((value: string) => {
+ const updatedEnrollment = { ...enrollment };
+ updatedEnrollment[propertyName] = value;
+ setEnrollment(updatedEnrollment);
+ updateEnrollmentMutation(updatedEnrollment);
+ updateHandler && updateHandler(value);
+ }, [enrollment, setEnrollment, propertyName, updateHandler, updateEnrollmentMutation]);
+};
diff --git a/src/core_modules/capture-core/components/WidgetEnrollment/processErrorReports.js b/src/core_modules/capture-core/components/WidgetEnrollment/processErrorReports.js
new file mode 100644
index 0000000000..d60fa40b31
--- /dev/null
+++ b/src/core_modules/capture-core/components/WidgetEnrollment/processErrorReports.js
@@ -0,0 +1,8 @@
+// @flow
+export const processErrorReports = (error: any) => {
+ // $FlowFixMe[prop-missing]
+ const errorReports = error?.details?.validationReport?.errorReports;
+ return errorReports?.length > 0
+ ? errorReports.reduce((acc, errorReport) => `${acc} ${errorReport.message}`, '')
+ : error.message;
+};
diff --git a/src/core_modules/capture-core/reducers/descriptions/enrollmentDomain.reducerDescription.js b/src/core_modules/capture-core/reducers/descriptions/enrollmentDomain.reducerDescription.js
index b3470cbe24..9e0745fa5b 100644
--- a/src/core_modules/capture-core/reducers/descriptions/enrollmentDomain.reducerDescription.js
+++ b/src/core_modules/capture-core/reducers/descriptions/enrollmentDomain.reducerDescription.js
@@ -8,6 +8,8 @@ import { actionTypes as editEventActionTypes } from '../../components/WidgetEven
const initialReducerValue = {};
const {
COMMON_ENROLLMENT_SITE_DATA_SET,
+ UPDATE_ENROLLMENT_DATE,
+ UPDATE_INCIDENT_DATE,
UPDATE_ENROLLMENT_EVENTS,
UPDATE_ENROLLMENT_EVENTS_WITHOUT_ID,
UPDATE_ENROLLMENT_ATTRIBUTE_VALUES,
@@ -25,6 +27,20 @@ export const enrollmentDomainDesc = createReducerDescription(
attributeValues,
enrollmentId: enrollment?.enrollment,
}),
+ [UPDATE_ENROLLMENT_DATE]: (state, { payload: { enrollmentDate } }) => ({
+ ...state,
+ enrollment: {
+ ...state.enrollment,
+ enrolledAt: enrollmentDate,
+ },
+ }),
+ [UPDATE_INCIDENT_DATE]: (state, { payload: { incidentDate } }) => ({
+ ...state,
+ enrollment: {
+ ...state.enrollment,
+ occurredAt: incidentDate,
+ },
+ }),
[UPDATE_ENROLLMENT_EVENTS]: (
state,
{ payload: { eventId, eventData } },
diff --git a/src/core_modules/capture-core/reducers/descriptions/enrollmentPage.reducerDescription.js b/src/core_modules/capture-core/reducers/descriptions/enrollmentPage.reducerDescription.js
index bfff16fabb..87827640b1 100644
--- a/src/core_modules/capture-core/reducers/descriptions/enrollmentPage.reducerDescription.js
+++ b/src/core_modules/capture-core/reducers/descriptions/enrollmentPage.reducerDescription.js
@@ -20,6 +20,7 @@ const {
MISSING_MESSAGE_VIEW,
DELETE_ENROLLMENT,
UPDATE_TEI_DISPLAY_NAME,
+ UPDATE_ENROLLMENT_DATE,
} = enrollmentPageActionTypes;
export const enrollmentPageDesc = createReducerDescription({
@@ -73,6 +74,16 @@ export const enrollmentPageDesc = createReducerDescription({
...state,
teiDisplayName,
}),
+ [UPDATE_ENROLLMENT_DATE]:
+ (state, { payload: { enrollmentId, enrollmentDate } }) => ({
+ ...state,
+ enrollments: state.enrollments.map((enrollment) => {
+ if (enrollment.enrollment === enrollmentId) {
+ enrollment.enrolledAt = enrollmentDate;
+ }
+ return enrollment;
+ }),
+ }),
[PAGE_CLEAN]: () => initialReducerValue,
[DELETE_ENROLLMENT]: (state, { payload: { enrollmentId } }) => ({
...state,
diff --git a/yarn.lock b/yarn.lock
index 0c0d33e902..983b457b91 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2948,7 +2948,7 @@
"@jridgewell/resolve-uri" "3.1.0"
"@jridgewell/sourcemap-codec" "1.4.14"
-"@js-temporal/polyfill@^0.4.2":
+"@js-temporal/polyfill@0.4.3", "@js-temporal/polyfill@^0.4.2":
version "0.4.3"
resolved "https://registry.yarnpkg.com/@js-temporal/polyfill/-/polyfill-0.4.3.tgz#e8f8cf86745eb5050679c46a5ebedb9a9cc1f09b"
integrity sha512-6Fmjo/HlkyVCmJzAPnvtEWlcbQUSRhi8qlN9EtJA/wP7FqXsevLLrlojR44kzNzrRkpf7eDJ+z7b4xQD/Ycypw==
From 85a67db8fe81843bdfb8a6b6a1fd19ad05faad72 Mon Sep 17 00:00:00 2001
From: "@dhis2-bot"
Date: Wed, 6 Sep 2023 09:10:30 +0000
Subject: [PATCH 11/49] chore(release): cut 100.38.0 [skip release]
# [100.38.0](https://github.com/dhis2/capture-app/compare/v100.37.0...v100.38.0) (2023-09-06)
### Features
* [DHIS2-14334] edit enrollment date ([#3350](https://github.com/dhis2/capture-app/issues/3350)) ([9dd1b6a](https://github.com/dhis2/capture-app/commit/9dd1b6a046e94021ae4e63a67a3d6b16a099212d))
---
CHANGELOG.md | 7 +++++++
package.json | 4 ++--
packages/rules-engine/package.json | 2 +-
3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6487c20723..4e24ce53c1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,10 @@
+# [100.38.0](https://github.com/dhis2/capture-app/compare/v100.37.0...v100.38.0) (2023-09-06)
+
+
+### Features
+
+* [DHIS2-14334] edit enrollment date ([#3350](https://github.com/dhis2/capture-app/issues/3350)) ([9dd1b6a](https://github.com/dhis2/capture-app/commit/9dd1b6a046e94021ae4e63a67a3d6b16a099212d))
+
# [100.37.0](https://github.com/dhis2/capture-app/compare/v100.36.0...v100.37.0) (2023-08-22)
diff --git a/package.json b/package.json
index b2ed536c77..523f6082d0 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "capture-app",
"homepage": ".",
- "version": "100.37.0",
+ "version": "100.38.0",
"cacheVersion": "5",
"serverVersion": "38",
"license": "BSD-3-Clause",
@@ -10,7 +10,7 @@
"packages/rules-engine"
],
"dependencies": {
- "@dhis2/rules-engine-javascript": "100.37.0",
+ "@dhis2/rules-engine-javascript": "100.38.0",
"@dhis2/app-runtime": "^3.9.3",
"@dhis2/d2-i18n": "^1.1.0",
"@dhis2/d2-icons": "^1.0.1",
diff --git a/packages/rules-engine/package.json b/packages/rules-engine/package.json
index 7e57d9d6a2..9764aec92c 100644
--- a/packages/rules-engine/package.json
+++ b/packages/rules-engine/package.json
@@ -1,6 +1,6 @@
{
"name": "@dhis2/rules-engine-javascript",
- "version": "100.37.0",
+ "version": "100.38.0",
"license": "BSD-3-Clause",
"main": "./build/cjs/index.js",
"scripts": {
From 4ef2973b71d6376f99db07e70bc4d51facb8018e Mon Sep 17 00:00:00 2001
From: Simona Domnisoru
Date: Thu, 7 Sep 2023 15:32:12 +0300
Subject: [PATCH 12/49] feat: [DHIS2-13343] hidden program stage rule effect
(#3406)
---
.../EnrollmentPage/HiddenProgramStage.feature | 7 ++
.../HiddenProgramStage/index.js | 66 +++++++++++++++++++
i18n/en.pot | 4 +-
.../rulesEffectsProcessor.js | 13 ++++
.../rules-engine/src/rulesEngine.types.js | 4 ++
.../EnrollmentPageDefault.component.js | 3 +
.../EnrollmentPageDefault.container.js | 3 +-
.../EnrollmentPageDefault.types.js | 2 +
.../EnrollmentQuickActions.component.js | 18 +++--
.../EnrollmentPageDefault/hooks/index.js | 3 +-
.../ProgramStageSelector.component.js | 3 +-
.../ProgramStageSelector.container.js | 20 +++++-
.../common/EnrollmentOverviewDomain/index.js | 1 +
.../useRuleEffects/index.js | 3 +
.../useRuleEffects}/useRuleEffects.js | 7 +-
.../useRuleEffects}/useRuleEffects.types.js | 2 +-
.../ErrorText/ErrorText.component.js | 20 ++++++
.../ErrorText/ErrorText.types.js | 5 ++
.../ErrorText/index.js | 2 +
.../FinishButtons/FinishButtons.component.js | 42 ++++++++----
.../FinishButtons/finishButtons.types.js | 4 ++
.../Validated/Validated.component.js | 12 ++--
.../Validated/Validated.container.js | 8 ++-
.../Validated/validated.types.js | 1 +
.../Stages/Stage/Stage.component.js | 44 +++++++++----
.../StageDetail/StageDetail.component.js | 12 +++-
.../Stage/StageDetail/stageDetail.types.js | 1 +
.../types/common.types.js | 4 +-
.../rulesEffects.reducerDescription.js | 17 +++++
.../rulesEffectsForTrackerProgram.test.js | 2 +
.../trackerCapture.reducerDescriptions.js | 2 +
31 files changed, 287 insertions(+), 48 deletions(-)
create mode 100644 cypress/integration/EnrollmentPage/HiddenProgramStage.feature
create mode 100644 cypress/integration/EnrollmentPage/HiddenProgramStage/index.js
create mode 100644 src/core_modules/capture-core/components/Pages/common/EnrollmentOverviewDomain/useRuleEffects/index.js
rename src/core_modules/capture-core/components/Pages/{Enrollment/EnrollmentPageDefault/hooks => common/EnrollmentOverviewDomain/useRuleEffects}/useRuleEffects.js (94%)
rename src/core_modules/capture-core/components/Pages/{Enrollment/EnrollmentPageDefault/hooks => common/EnrollmentOverviewDomain/useRuleEffects}/useRuleEffects.types.js (81%)
create mode 100644 src/core_modules/capture-core/components/WidgetEnrollmentEventNew/ErrorText/ErrorText.component.js
create mode 100644 src/core_modules/capture-core/components/WidgetEnrollmentEventNew/ErrorText/ErrorText.types.js
create mode 100644 src/core_modules/capture-core/components/WidgetEnrollmentEventNew/ErrorText/index.js
diff --git a/cypress/integration/EnrollmentPage/HiddenProgramStage.feature b/cypress/integration/EnrollmentPage/HiddenProgramStage.feature
new file mode 100644
index 0000000000..4e6e427e3e
--- /dev/null
+++ b/cypress/integration/EnrollmentPage/HiddenProgramStage.feature
@@ -0,0 +1,7 @@
+Feature: Hidden program stage
+
+ Scenario: The user cannot add an event in a hidden program stage
+ Given you add an enrollment event that will result in a rule effect to hide a program stage
+ Then the New Postpartum care visit event button is disabled in the stages and events widget
+ And and an error is show in the Postpartum care visit stage
+ And the Postpartum care visit button is disabled in the enrollmentEventNew page
diff --git a/cypress/integration/EnrollmentPage/HiddenProgramStage/index.js b/cypress/integration/EnrollmentPage/HiddenProgramStage/index.js
new file mode 100644
index 0000000000..edf6b833bd
--- /dev/null
+++ b/cypress/integration/EnrollmentPage/HiddenProgramStage/index.js
@@ -0,0 +1,66 @@
+import moment from 'moment';
+
+const cleanUpIfApplicable = () => {
+ cy.buildApiUrl(
+ 'tracker',
+ 'trackedEntities/uW8Y7AIcRKA?program=WSGAb5XwJ3Y&fields=enrollments',
+ )
+ .then(url => cy.request(url))
+ .then(({ body }) => {
+ const enrollment = body.enrollments?.find(e => e.enrollment === 'fmhIsWXVDmS');
+ const event = enrollment?.events?.find(e => e.programStage === 'PFDfvmGpsR3');
+ if (!event) {
+ return null;
+ }
+ return cy
+ .buildApiUrl('events', event.event)
+ .then(eventUrl =>
+ cy.request('DELETE', eventUrl));
+ });
+};
+
+Given('you add an enrollment event that will result in a rule effect to hide a program stage', () => {
+ cleanUpIfApplicable();
+ cy.visit(
+ '/#/enrollmentEventNew?enrollmentId=fmhIsWXVDmS&orgUnitId=s7SLtx8wmRA&programId=WSGAb5XwJ3Y&stageId=PFDfvmGpsR3&teiId=uW8Y7AIcRKA',
+ );
+
+ cy.get('[data-test="capture-ui-input"]')
+ .eq(0)
+ .type(moment().format('YYYY-MM-DD'))
+ .blur();
+
+ cy
+ .get('[data-test="virtualized-select"]')
+ .eq(6)
+ .click()
+ .contains('Termination of pregnancy')
+ .click();
+
+ cy.contains('[data-test="dhis2-uicore-button"]', 'Save without completing').click();
+});
+
+Then('the New Postpartum care visit event button is disabled in the stages and events widget', () => {
+ cy.contains('[data-test="create-new-button"]', 'New Postpartum care visit event')
+ .should('be.disabled');
+});
+
+Then('and an error is show in the Postpartum care visit stage', () => {
+ cy.visit(
+ '/#/enrollmentEventNew?enrollmentId=fmhIsWXVDmS&orgUnitId=s7SLtx8wmRA&programId=WSGAb5XwJ3Y&teiId=uW8Y7AIcRKA&stageId=bbKtnxRZKEP',
+ );
+ cy.contains('[data-test="dhis2-uicore-button"]', 'Complete')
+ .should('be.disabled');
+ cy.contains('[data-test="dhis2-uicore-button"]', 'Save without completing')
+ .should('be.disabled');
+ cy.contains('[data-test="dhis2-uicore-noticebox-content"]', 'You can\'t add any more Postpartum care visit events')
+ .should('exist');
+});
+
+Then('the Postpartum care visit button is disabled in the enrollmentEventNew page', () => {
+ cy.visit(
+ '/#/enrollmentEventNew?enrollmentId=fmhIsWXVDmS&orgUnitId=s7SLtx8wmRA&programId=WSGAb5XwJ3Y&teiId=uW8Y7AIcRKA',
+ );
+
+ cy.contains('[data-test="program-stage-selector-button"]', 'Postpartum care visit').should('be.disabled');
+});
diff --git a/i18n/en.pot b/i18n/en.pot
index 9674ac525a..e179d736a4 100644
--- a/i18n/en.pot
+++ b/i18n/en.pot
@@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
-"POT-Creation-Date: 2023-08-22T12:04:52.436Z\n"
-"PO-Revision-Date: 2023-08-22T12:04:52.436Z\n"
+"POT-Creation-Date: 2023-09-04T07:07:59.195Z\n"
+"PO-Revision-Date: 2023-09-04T07:07:59.195Z\n"
msgid "Choose one or more dates..."
msgstr "Choose one or more dates..."
diff --git a/packages/rules-engine/src/processors/rulesEffectsProcessor/rulesEffectsProcessor.js b/packages/rules-engine/src/processors/rulesEffectsProcessor/rulesEffectsProcessor.js
index da59fe6d94..15951dbc57 100644
--- a/packages/rules-engine/src/processors/rulesEffectsProcessor/rulesEffectsProcessor.js
+++ b/packages/rules-engine/src/processors/rulesEffectsProcessor/rulesEffectsProcessor.js
@@ -12,6 +12,7 @@ import type {
IConvertOutputRulesEffectsValue,
AssignOutputEffect,
HideOutputEffect,
+ HideProgramStageEffect,
MessageEffect,
GeneralErrorEffect,
GeneralWarningEffect,
@@ -207,6 +208,17 @@ export function getRulesEffectsProcessor(
};
}
+ function processHideProgramStage(effect: ProgramRuleEffect): ?HideProgramStageEffect {
+ if (!effect.programStageId) {
+ return null;
+ }
+
+ return {
+ type: effectActions.HIDE_PROGRAM_STAGE,
+ id: effect.programStageId,
+ };
+ }
+
function processMakeCompulsory(effect: ProgramRuleEffect): Array {
return createEffectsForConfiguredDataTypes(effect, () => ({
type: effectActions.MAKE_COMPULSORY,
@@ -267,6 +279,7 @@ export function getRulesEffectsProcessor(
[effectActions.SHOW_WARNING]: processShowWarning,
[effectActions.SHOW_ERROR_ONCOMPLETE]: processShowErrorOnComplete,
[effectActions.SHOW_WARNING_ONCOMPLETE]: processShowWarningOnComplete,
+ [effectActions.HIDE_PROGRAM_STAGE]: processHideProgramStage,
[effectActions.HIDE_SECTION]: processHideSection,
[effectActions.MAKE_COMPULSORY]: processMakeCompulsory,
[effectActions.DISPLAY_TEXT]: processDisplayText,
diff --git a/packages/rules-engine/src/rulesEngine.types.js b/packages/rules-engine/src/rulesEngine.types.js
index e2edca905b..decb2154a0 100644
--- a/packages/rules-engine/src/rulesEngine.types.js
+++ b/packages/rules-engine/src/rulesEngine.types.js
@@ -30,6 +30,10 @@ export type HideOutputEffect = OutputEffect & {
};
+export type HideProgramStageEffect = OutputEffect & {
+
+};
+
export type MessageEffect = OutputEffect & {
message: string,
};
diff --git a/src/core_modules/capture-core/components/Pages/Enrollment/EnrollmentPageDefault/EnrollmentPageDefault.component.js b/src/core_modules/capture-core/components/Pages/Enrollment/EnrollmentPageDefault/EnrollmentPageDefault.component.js
index dac5ca2c8a..0759fcd558 100644
--- a/src/core_modules/capture-core/components/Pages/Enrollment/EnrollmentPageDefault/EnrollmentPageDefault.component.js
+++ b/src/core_modules/capture-core/components/Pages/Enrollment/EnrollmentPageDefault/EnrollmentPageDefault.component.js
@@ -63,6 +63,7 @@ export const EnrollmentPageDefaultPlain = ({
onUpdateEnrollmentDate,
onUpdateIncidentDate,
onEnrollmentError,
+ ruleEffects,
}: PlainProps) => (
<>
{i18n.t('Enrollment Dashboard')}
@@ -71,6 +72,7 @@ export const EnrollmentPageDefaultPlain = ({