From 9d2ca307e80ebcd3da2cbac922768d516a05b58c Mon Sep 17 00:00:00 2001 From: Tony Valle Date: Tue, 18 Aug 2026 14:04:56 +0200 Subject: [PATCH 1/7] fix: add missing `currentEvent` on initial rule engine run --- i18n/en.pot | 4 ++-- .../DataEntries/Enrollment/actions/open.actionBatchs.ts | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/i18n/en.pot b/i18n/en.pot index 33b83a6757..dfeffb031c 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: 2026-08-12T11:21:02.033Z\n" -"PO-Revision-Date: 2026-08-12T11:21:02.033Z\n" +"POT-Creation-Date: 2026-08-18T12:04:56.846Z\n" +"PO-Revision-Date: 2026-08-18T12:04:56.847Z\n" msgid "The application could not be loaded." msgstr "The application could not be loaded." diff --git a/src/core_modules/capture-core/components/DataEntries/Enrollment/actions/open.actionBatchs.ts b/src/core_modules/capture-core/components/DataEntries/Enrollment/actions/open.actionBatchs.ts index 270ceb864c..27a2de2f24 100644 --- a/src/core_modules/capture-core/components/DataEntries/Enrollment/actions/open.actionBatchs.ts +++ b/src/core_modules/capture-core/components/DataEntries/Enrollment/actions/open.actionBatchs.ts @@ -70,6 +70,13 @@ export const openDataEntryForNewEnrollmentBatchAsync = async ({ const formId = getDataEntryKey(dataEntryId, itemId); const addFormDataActions = addFormData(`${dataEntryId}-${itemId}`, formValues); const firstStageDataEntryPropsToInclude = firstStage && getDataEntryPropsToInclude(firstStage); + + const fabricateFirstStageEvent = (firstStage: ProgramStage) => ({ + programStageId: firstStage.id, + programStageName: firstStage.name, + }); + const firstStageEvent = firstStage && fabricateFirstStageEvent(firstStage); + const dataEntryPropsToInclude = [ ...enrollmentDataEntryPropsToInclude, ...extraDataEntryProps, @@ -94,6 +101,7 @@ export const openDataEntryForNewEnrollmentBatchAsync = async ({ const effects = getApplicableRuleEffectsForTrackerProgram({ program, orgUnit, + currentEvent: firstStageEvent, stage: firstStage, attributeValues: clientValues, enrollmentData: { enrolledAt: new Date().toISOString() }, From c18299f9675e8e260551a7b2e577225442d095f3 Mon Sep 17 00:00:00 2001 From: Tony Valle Date: Wed, 19 Aug 2026 12:26:27 +0200 Subject: [PATCH 2/7] feat: introducing `isFirstStageEventForm` and `evaluateAll` --- i18n/en.pot | 4 +- .../rules/RuleEngine/RuleEngine.ts | 51 ++++++++++++++----- .../rules/RuleEngine/helpers/InputBuilder.ts | 2 +- .../RuleEngine/types/ruleEngine.types.ts | 1 + .../rules/getApplicableRuleEffects.ts | 4 ++ .../capture-core/rules/rules.types.ts | 2 + 6 files changed, 47 insertions(+), 17 deletions(-) diff --git a/i18n/en.pot b/i18n/en.pot index dfeffb031c..b985db40af 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: 2026-08-18T12:04:56.846Z\n" -"PO-Revision-Date: 2026-08-18T12:04:56.847Z\n" +"POT-Creation-Date: 2026-08-19T10:26:27.661Z\n" +"PO-Revision-Date: 2026-08-19T10:26:27.662Z\n" msgid "The application could not be loaded." msgstr "The application could not be loaded." diff --git a/src/core_modules/capture-core/rules/RuleEngine/RuleEngine.ts b/src/core_modules/capture-core/rules/RuleEngine/RuleEngine.ts index b36a1cb3d7..54ca15994b 100644 --- a/src/core_modules/capture-core/rules/RuleEngine/RuleEngine.ts +++ b/src/core_modules/capture-core/rules/RuleEngine/RuleEngine.ts @@ -43,6 +43,7 @@ export class RuleEngine { selectedOrgUnit, selectedUserRoles, optionSets, + isFirstStageEventForm, }: RulesEngineInput): OutputEffects { if (!programRulesContainer.programRules || !selectedOrgUnit || @@ -71,23 +72,45 @@ export class RuleEngine { []; const ruleEngine = new RuleEngineJs(this.flags.verbose || false); - const effects = (currentEvent ? - ruleEngine.evaluateEvent( - inputBuilder.convertEvent(currentEvent), - enrollment, - events, - executionContext, - ) : - ruleEngine.evaluateEnrollment( + let effects; + if (currentEvent) { + const event = inputBuilder.convertEvent(currentEvent); + if (!isFirstStageEventForm) { + effects = ruleEngine.evaluateEvent( + event, + enrollment, + events, + executionContext, + ); + } else { + const duplicateActionIds = new Set; + effects = ruleEngine.evaluateAll(enrollment, [event], executionContext) + .flatMap((entry) => entry.ruleEffects) + .filter((effect) => { + const actionId = effect.ruleAction.values.get('id'); + if (!actionId) { + return true; + } + if (duplicateActionIds.has(actionId)) { + return false; + } + duplicateActionIds.add(actionId); + return true; + } + ); + } + } else { + effects = ruleEngine.evaluateEnrollment( enrollment!, events, executionContext, - )) - .map(effect => ({ - ...Object.fromEntries(effect.ruleAction.values), - action: effect.ruleAction.type, - data: effect.data, - })) as Array; + ); + } + effects = effects.map(effect => ({ + ...Object.fromEntries(effect.ruleAction.values), + action: effect.ruleAction.type, + data: effect.data, + })) as Array; const processRulesEffects = getRulesEffectsProcessor(this.outputConverter); return processRulesEffects({ diff --git a/src/core_modules/capture-core/rules/RuleEngine/helpers/InputBuilder.ts b/src/core_modules/capture-core/rules/RuleEngine/helpers/InputBuilder.ts index acb9c1fa52..6332f9f696 100644 --- a/src/core_modules/capture-core/rules/RuleEngine/helpers/InputBuilder.ts +++ b/src/core_modules/capture-core/rules/RuleEngine/helpers/InputBuilder.ts @@ -362,7 +362,7 @@ export class InputBuilder { const convertDate = (dateString?: string | null) => this.toLocalDate(dateString, RuleLocalDate.currentDate()); return new RuleEnrollmentJs( - enrollment!, + enrollment || 'registration', programName || '', convertDate(incidentDate), convertDate(enrollmentDate), diff --git a/src/core_modules/capture-core/rules/RuleEngine/types/ruleEngine.types.ts b/src/core_modules/capture-core/rules/RuleEngine/types/ruleEngine.types.ts index 9681673ffe..6221bb2845 100644 --- a/src/core_modules/capture-core/rules/RuleEngine/types/ruleEngine.types.ts +++ b/src/core_modules/capture-core/rules/RuleEngine/types/ruleEngine.types.ts @@ -254,6 +254,7 @@ export type RulesEngineInput = { selectedOrgUnit: OrgUnit | null, selectedUserRoles?: Array | null, optionSets: OptionSets, + isFirstStageEventForm?: boolean, }; export type Translator = (value: string) => string; diff --git a/src/core_modules/capture-core/rules/getApplicableRuleEffects.ts b/src/core_modules/capture-core/rules/getApplicableRuleEffects.ts index ef63ee3a98..c28c980e94 100644 --- a/src/core_modules/capture-core/rules/getApplicableRuleEffects.ts +++ b/src/core_modules/capture-core/rules/getApplicableRuleEffects.ts @@ -52,6 +52,7 @@ export const getApplicableRuleEffectsForTrackerProgram = ({ attributeValues, enrollmentData, formFoundation, + isFirstStageEventForm, }: GetApplicableRuleEffectsForTrackerProgramInput, flattenedResult = false, ) => { @@ -83,6 +84,7 @@ flattenedResult = false, programRuleVariables, trackedEntityAttributes: getTrackedEntityAttributesForRulesExecution(program.attributes), foundationForPostProcessing, + isFirstStageEventForm, }); return flattenedResult ? effects : buildEffectsHierarchy(effects); @@ -99,6 +101,7 @@ const getApplicableRuleEffects = ({ programRuleVariables, trackedEntityAttributes, foundationForPostProcessing, + isFirstStageEventForm, }: GetApplicableRuleEffectsInput) => { const dataElements = getDataElementsForRulesExecution(stages); @@ -115,6 +118,7 @@ const getApplicableRuleEffects = ({ selectedEntity: attributeValues, selectedOrgUnit: orgUnit, optionSets, + isFirstStageEventForm, }); return postProcessRulesEffects( diff --git a/src/core_modules/capture-core/rules/rules.types.ts b/src/core_modules/capture-core/rules/rules.types.ts index 5c43298d69..3666fd37a3 100644 --- a/src/core_modules/capture-core/rules/rules.types.ts +++ b/src/core_modules/capture-core/rules/rules.types.ts @@ -19,6 +19,7 @@ export type GetApplicableRuleEffectsForTrackerProgramInput = { attributeValues?: TEIValues, enrollmentData?: Enrollment, formFoundation?: RenderFoundation, + isFirstStageEventForm?: boolean, }; export type GetApplicableRuleEffectsForEventProgramInput = { @@ -38,4 +39,5 @@ export type GetApplicableRuleEffectsInput = { programRuleVariables: Array, trackedEntityAttributes?: TrackedEntityAttributes, foundationForPostProcessing: RenderFoundation, + isFirstStageEventForm?: boolean, }; From 6750a6ab0a31c6bbbd39a21af5d0ccdcde104a89 Mon Sep 17 00:00:00 2001 From: Tony Valle Date: Thu, 20 Aug 2026 10:54:55 +0200 Subject: [PATCH 3/7] fix: set `isFirstStageEventForm` on the appropriate app page --- i18n/en.pot | 4 ++-- .../DataEntries/Enrollment/actions/enrollment.actionBatchs.ts | 1 + .../DataEntries/Enrollment/actions/open.actionBatchs.ts | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/i18n/en.pot b/i18n/en.pot index b985db40af..b983a0ae3e 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: 2026-08-19T10:26:27.661Z\n" -"PO-Revision-Date: 2026-08-19T10:26:27.662Z\n" +"POT-Creation-Date: 2026-08-20T09:17:38.069Z\n" +"PO-Revision-Date: 2026-08-20T09:17:38.069Z\n" msgid "The application could not be loaded." msgstr "The application could not be loaded." diff --git a/src/core_modules/capture-core/components/DataEntries/Enrollment/actions/enrollment.actionBatchs.ts b/src/core_modules/capture-core/components/DataEntries/Enrollment/actions/enrollment.actionBatchs.ts index fba369880b..d28cb90aea 100644 --- a/src/core_modules/capture-core/components/DataEntries/Enrollment/actions/enrollment.actionBatchs.ts +++ b/src/core_modules/capture-core/components/DataEntries/Enrollment/actions/enrollment.actionBatchs.ts @@ -62,6 +62,7 @@ export const runRulesOnUpdateFieldBatch = async ({ enrollmentData, attributeValues, formFoundation, + isFirstStageEventForm: Boolean(currentEvent), }); const effectsWithValidations = await validateAssignEffects({ diff --git a/src/core_modules/capture-core/components/DataEntries/Enrollment/actions/open.actionBatchs.ts b/src/core_modules/capture-core/components/DataEntries/Enrollment/actions/open.actionBatchs.ts index 27a2de2f24..23ac9fe5c3 100644 --- a/src/core_modules/capture-core/components/DataEntries/Enrollment/actions/open.actionBatchs.ts +++ b/src/core_modules/capture-core/components/DataEntries/Enrollment/actions/open.actionBatchs.ts @@ -106,6 +106,7 @@ export const openDataEntryForNewEnrollmentBatchAsync = async ({ attributeValues: clientValues, enrollmentData: { enrolledAt: new Date().toISOString() }, formFoundation, + isFirstStageEventForm: true, }); return batchActions([ From 4c817b3d7b0057e8057e17300268bb365a6e85fb Mon Sep 17 00:00:00 2001 From: Tony Valle Date: Thu, 20 Aug 2026 12:09:23 +0200 Subject: [PATCH 4/7] fix: linter errors Refactored out `evaluateRules` to fix complexity issue --- i18n/en.pot | 4 +- .../Enrollment/actions/open.actionBatchs.ts | 6 +-- .../rules/RuleEngine/RuleEngine.ts | 45 ++++------------ .../rules/RuleEngine/helpers/evaluateRules.ts | 52 +++++++++++++++++++ .../rules/RuleEngine/helpers/index.ts | 1 + 5 files changed, 68 insertions(+), 40 deletions(-) create mode 100644 src/core_modules/capture-core/rules/RuleEngine/helpers/evaluateRules.ts diff --git a/i18n/en.pot b/i18n/en.pot index b983a0ae3e..10fbea1ce9 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: 2026-08-20T09:17:38.069Z\n" -"PO-Revision-Date: 2026-08-20T09:17:38.069Z\n" +"POT-Creation-Date: 2026-08-20T10:11:48.804Z\n" +"PO-Revision-Date: 2026-08-20T10:11:48.804Z\n" msgid "The application could not be loaded." msgstr "The application could not be loaded." diff --git a/src/core_modules/capture-core/components/DataEntries/Enrollment/actions/open.actionBatchs.ts b/src/core_modules/capture-core/components/DataEntries/Enrollment/actions/open.actionBatchs.ts index 23ac9fe5c3..b680f6264b 100644 --- a/src/core_modules/capture-core/components/DataEntries/Enrollment/actions/open.actionBatchs.ts +++ b/src/core_modules/capture-core/components/DataEntries/Enrollment/actions/open.actionBatchs.ts @@ -71,9 +71,9 @@ export const openDataEntryForNewEnrollmentBatchAsync = async ({ const addFormDataActions = addFormData(`${dataEntryId}-${itemId}`, formValues); const firstStageDataEntryPropsToInclude = firstStage && getDataEntryPropsToInclude(firstStage); - const fabricateFirstStageEvent = (firstStage: ProgramStage) => ({ - programStageId: firstStage.id, - programStageName: firstStage.name, + const fabricateFirstStageEvent = (stage: ProgramStage) => ({ + programStageId: stage.id, + programStageName: stage.name, }); const firstStageEvent = firstStage && fabricateFirstStageEvent(firstStage); diff --git a/src/core_modules/capture-core/rules/RuleEngine/RuleEngine.ts b/src/core_modules/capture-core/rules/RuleEngine/RuleEngine.ts index 54ca15994b..38b3cbbce2 100644 --- a/src/core_modules/capture-core/rules/RuleEngine/RuleEngine.ts +++ b/src/core_modules/capture-core/rules/RuleEngine/RuleEngine.ts @@ -2,6 +2,7 @@ import { RuleEngineJs } from '@dhis2/rule-engine'; import { InputBuilder, ValueProcessor, + evaluateRules, getRulesEffectsProcessor, } from './helpers'; import type { @@ -72,41 +73,15 @@ export class RuleEngine { []; const ruleEngine = new RuleEngineJs(this.flags.verbose || false); - let effects; - if (currentEvent) { - const event = inputBuilder.convertEvent(currentEvent); - if (!isFirstStageEventForm) { - effects = ruleEngine.evaluateEvent( - event, - enrollment, - events, - executionContext, - ); - } else { - const duplicateActionIds = new Set; - effects = ruleEngine.evaluateAll(enrollment, [event], executionContext) - .flatMap((entry) => entry.ruleEffects) - .filter((effect) => { - const actionId = effect.ruleAction.values.get('id'); - if (!actionId) { - return true; - } - if (duplicateActionIds.has(actionId)) { - return false; - } - duplicateActionIds.add(actionId); - return true; - } - ); - } - } else { - effects = ruleEngine.evaluateEnrollment( - enrollment!, - events, - executionContext, - ); - } - effects = effects.map(effect => ({ + + const effects = evaluateRules({ + ruleEngine, + enrollment, + currentEvent: currentEvent && inputBuilder.convertEvent(currentEvent), + events, + executionContext, + isFirstStageEventForm, + }).map(effect => ({ ...Object.fromEntries(effect.ruleAction.values), action: effect.ruleAction.type, data: effect.data, diff --git a/src/core_modules/capture-core/rules/RuleEngine/helpers/evaluateRules.ts b/src/core_modules/capture-core/rules/RuleEngine/helpers/evaluateRules.ts new file mode 100644 index 0000000000..c05500ca8f --- /dev/null +++ b/src/core_modules/capture-core/rules/RuleEngine/helpers/evaluateRules.ts @@ -0,0 +1,52 @@ +import { + RuleEngineJs, + RuleEnrollmentJs, + RuleEventJs, + RuleEngineContextJs, +} from '@dhis2/rule-engine'; + +export const evaluateRules = ({ + ruleEngine, + enrollment, + currentEvent, + events, + executionContext, + isFirstStageEventForm, +}: { + ruleEngine: RuleEngineJs + enrollment: RuleEnrollmentJs | null, + currentEvent: RuleEventJs | null | undefined, + events: Array, + executionContext: RuleEngineContextJs, + isFirstStageEventForm: boolean | undefined, +}) => { + if (!currentEvent) { + return ruleEngine.evaluateEnrollment( + enrollment!, + events, + executionContext, + ); + } + if (!isFirstStageEventForm) { + return ruleEngine.evaluateEvent( + currentEvent, + enrollment, + events, + executionContext, + ); + } + const duplicateActionIds = new Set; + return ruleEngine.evaluateAll(enrollment, [currentEvent], executionContext) + .flatMap(entry => entry.ruleEffects) + .filter((effect) => { + const actionId = effect.ruleAction.values.get('id'); + if (!actionId) { + return true; + } + if (duplicateActionIds.has(actionId)) { + return false; + } + duplicateActionIds.add(actionId); + return true; + }); +}; diff --git a/src/core_modules/capture-core/rules/RuleEngine/helpers/index.ts b/src/core_modules/capture-core/rules/RuleEngine/helpers/index.ts index d2fed8e065..969bcbf0ca 100644 --- a/src/core_modules/capture-core/rules/RuleEngine/helpers/index.ts +++ b/src/core_modules/capture-core/rules/RuleEngine/helpers/index.ts @@ -1,3 +1,4 @@ export { InputBuilder } from './InputBuilder'; export { ValueProcessor } from './ValueProcessor'; +export { evaluateRules } from './evaluateRules'; export { getRulesEffectsProcessor } from './rulesEffectsProcessor'; From a0feb24f78d0423fc861812686330d199e91dc22 Mon Sep 17 00:00:00 2001 From: Tony Valle Date: Thu, 20 Aug 2026 12:48:31 +0200 Subject: [PATCH 5/7] test: update snapshots --- i18n/en.pot | 4 ++-- .../getApplicableRuleEffectsForTrackerProgram.test.js.snap | 1 + .../getApplicableRulesEffectsForEventProgram.test.js.snap | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/i18n/en.pot b/i18n/en.pot index 10fbea1ce9..a03203a4f5 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: 2026-08-20T10:11:48.804Z\n" -"PO-Revision-Date: 2026-08-20T10:11:48.804Z\n" +"POT-Creation-Date: 2026-08-20T10:48:31.323Z\n" +"PO-Revision-Date: 2026-08-20T10:48:31.324Z\n" msgid "The application could not be loaded." msgstr "The application could not be loaded." diff --git a/src/core_modules/capture-core/rules/__tests__/__snapshots__/getApplicableRuleEffectsForTrackerProgram.test.js.snap b/src/core_modules/capture-core/rules/__tests__/__snapshots__/getApplicableRuleEffectsForTrackerProgram.test.js.snap index be8d636e1b..8437a2e920 100644 --- a/src/core_modules/capture-core/rules/__tests__/__snapshots__/getApplicableRuleEffectsForTrackerProgram.test.js.snap +++ b/src/core_modules/capture-core/rules/__tests__/__snapshots__/getApplicableRuleEffectsForTrackerProgram.test.js.snap @@ -25,6 +25,7 @@ Object { "valueType": "TEXT", }, }, + "isFirstStageEventForm": undefined, "optionSets": Object { "0": Object { "displayName": undefined, diff --git a/src/core_modules/capture-core/rules/__tests__/__snapshots__/getApplicableRulesEffectsForEventProgram.test.js.snap b/src/core_modules/capture-core/rules/__tests__/__snapshots__/getApplicableRulesEffectsForEventProgram.test.js.snap index e3b154ce97..c970c97532 100644 --- a/src/core_modules/capture-core/rules/__tests__/__snapshots__/getApplicableRulesEffectsForEventProgram.test.js.snap +++ b/src/core_modules/capture-core/rules/__tests__/__snapshots__/getApplicableRulesEffectsForEventProgram.test.js.snap @@ -25,6 +25,7 @@ Object { "valueType": "TEXT", }, }, + "isFirstStageEventForm": undefined, "optionSets": Object { "0": Object { "displayName": undefined, From 5a9752d23a25a588e1f8837b9381447503b4183b Mon Sep 17 00:00:00 2001 From: Tony Valle Date: Mon, 24 Aug 2026 13:40:27 +0200 Subject: [PATCH 6/7] style: add missing constructor parentheses --- i18n/en.pot | 4 ++-- .../capture-core/rules/RuleEngine/helpers/evaluateRules.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/i18n/en.pot b/i18n/en.pot index cb89718162..5db9d45e98 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: 2026-08-17T06:08:25.172Z\n" -"PO-Revision-Date: 2026-08-17T06:08:25.172Z\n" +"POT-Creation-Date: 2026-08-24T11:40:27.191Z\n" +"PO-Revision-Date: 2026-08-24T11:40:27.191Z\n" msgid "The application could not be loaded." msgstr "The application could not be loaded." diff --git a/src/core_modules/capture-core/rules/RuleEngine/helpers/evaluateRules.ts b/src/core_modules/capture-core/rules/RuleEngine/helpers/evaluateRules.ts index c05500ca8f..98df88be96 100644 --- a/src/core_modules/capture-core/rules/RuleEngine/helpers/evaluateRules.ts +++ b/src/core_modules/capture-core/rules/RuleEngine/helpers/evaluateRules.ts @@ -35,7 +35,7 @@ export const evaluateRules = ({ executionContext, ); } - const duplicateActionIds = new Set; + const duplicateActionIds = new Set(); return ruleEngine.evaluateAll(enrollment, [currentEvent], executionContext) .flatMap(entry => entry.ruleEffects) .filter((effect) => { From 0a7e9699de9911b91cbe1598f95b179efdc70ae4 Mon Sep 17 00:00:00 2001 From: Tony Valle Date: Thu, 27 Aug 2026 13:17:19 +0200 Subject: [PATCH 7/7] refactor: rename `isFirstStageEventForm` -> `isEnrollmentFormWithEvent` --- i18n/en.pot | 4 ++-- .../Enrollment/actions/enrollment.actionBatchs.ts | 2 +- .../DataEntries/Enrollment/actions/open.actionBatchs.ts | 2 +- .../capture-core/rules/RuleEngine/RuleEngine.ts | 4 ++-- .../rules/RuleEngine/helpers/evaluateRules.ts | 6 +++--- .../rules/RuleEngine/types/ruleEngine.types.ts | 2 +- ...getApplicableRuleEffectsForTrackerProgram.test.js.snap | 2 +- .../getApplicableRulesEffectsForEventProgram.test.js.snap | 2 +- .../capture-core/rules/getApplicableRuleEffects.ts | 8 ++++---- src/core_modules/capture-core/rules/rules.types.ts | 4 ++-- 10 files changed, 18 insertions(+), 18 deletions(-) diff --git a/i18n/en.pot b/i18n/en.pot index dcc7523fd9..d760a3f0e7 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: 2026-08-24T07:37:43.159Z\n" -"PO-Revision-Date: 2026-08-24T07:37:43.159Z\n" +"POT-Creation-Date: 2026-08-27T11:17:19.858Z\n" +"PO-Revision-Date: 2026-08-27T11:17:19.858Z\n" msgid "The application could not be loaded." msgstr "The application could not be loaded." diff --git a/src/core_modules/capture-core/components/DataEntries/Enrollment/actions/enrollment.actionBatchs.ts b/src/core_modules/capture-core/components/DataEntries/Enrollment/actions/enrollment.actionBatchs.ts index d28cb90aea..737082fea9 100644 --- a/src/core_modules/capture-core/components/DataEntries/Enrollment/actions/enrollment.actionBatchs.ts +++ b/src/core_modules/capture-core/components/DataEntries/Enrollment/actions/enrollment.actionBatchs.ts @@ -62,7 +62,7 @@ export const runRulesOnUpdateFieldBatch = async ({ enrollmentData, attributeValues, formFoundation, - isFirstStageEventForm: Boolean(currentEvent), + isEnrollmentFormWithEvent: Boolean(currentEvent), }); const effectsWithValidations = await validateAssignEffects({ diff --git a/src/core_modules/capture-core/components/DataEntries/Enrollment/actions/open.actionBatchs.ts b/src/core_modules/capture-core/components/DataEntries/Enrollment/actions/open.actionBatchs.ts index b680f6264b..bd6f54d7e1 100644 --- a/src/core_modules/capture-core/components/DataEntries/Enrollment/actions/open.actionBatchs.ts +++ b/src/core_modules/capture-core/components/DataEntries/Enrollment/actions/open.actionBatchs.ts @@ -106,7 +106,7 @@ export const openDataEntryForNewEnrollmentBatchAsync = async ({ attributeValues: clientValues, enrollmentData: { enrolledAt: new Date().toISOString() }, formFoundation, - isFirstStageEventForm: true, + isEnrollmentFormWithEvent: true, }); return batchActions([ diff --git a/src/core_modules/capture-core/rules/RuleEngine/RuleEngine.ts b/src/core_modules/capture-core/rules/RuleEngine/RuleEngine.ts index 38b3cbbce2..8535a4ba75 100644 --- a/src/core_modules/capture-core/rules/RuleEngine/RuleEngine.ts +++ b/src/core_modules/capture-core/rules/RuleEngine/RuleEngine.ts @@ -44,7 +44,7 @@ export class RuleEngine { selectedOrgUnit, selectedUserRoles, optionSets, - isFirstStageEventForm, + isEnrollmentFormWithEvent, }: RulesEngineInput): OutputEffects { if (!programRulesContainer.programRules || !selectedOrgUnit || @@ -80,7 +80,7 @@ export class RuleEngine { currentEvent: currentEvent && inputBuilder.convertEvent(currentEvent), events, executionContext, - isFirstStageEventForm, + isEnrollmentFormWithEvent, }).map(effect => ({ ...Object.fromEntries(effect.ruleAction.values), action: effect.ruleAction.type, diff --git a/src/core_modules/capture-core/rules/RuleEngine/helpers/evaluateRules.ts b/src/core_modules/capture-core/rules/RuleEngine/helpers/evaluateRules.ts index 98df88be96..129cbcc550 100644 --- a/src/core_modules/capture-core/rules/RuleEngine/helpers/evaluateRules.ts +++ b/src/core_modules/capture-core/rules/RuleEngine/helpers/evaluateRules.ts @@ -11,14 +11,14 @@ export const evaluateRules = ({ currentEvent, events, executionContext, - isFirstStageEventForm, + isEnrollmentFormWithEvent, }: { ruleEngine: RuleEngineJs enrollment: RuleEnrollmentJs | null, currentEvent: RuleEventJs | null | undefined, events: Array, executionContext: RuleEngineContextJs, - isFirstStageEventForm: boolean | undefined, + isEnrollmentFormWithEvent: boolean | undefined, }) => { if (!currentEvent) { return ruleEngine.evaluateEnrollment( @@ -27,7 +27,7 @@ export const evaluateRules = ({ executionContext, ); } - if (!isFirstStageEventForm) { + if (!isEnrollmentFormWithEvent) { return ruleEngine.evaluateEvent( currentEvent, enrollment, diff --git a/src/core_modules/capture-core/rules/RuleEngine/types/ruleEngine.types.ts b/src/core_modules/capture-core/rules/RuleEngine/types/ruleEngine.types.ts index 6221bb2845..cb839c3921 100644 --- a/src/core_modules/capture-core/rules/RuleEngine/types/ruleEngine.types.ts +++ b/src/core_modules/capture-core/rules/RuleEngine/types/ruleEngine.types.ts @@ -254,7 +254,7 @@ export type RulesEngineInput = { selectedOrgUnit: OrgUnit | null, selectedUserRoles?: Array | null, optionSets: OptionSets, - isFirstStageEventForm?: boolean, + isEnrollmentFormWithEvent?: boolean, }; export type Translator = (value: string) => string; diff --git a/src/core_modules/capture-core/rules/__tests__/__snapshots__/getApplicableRuleEffectsForTrackerProgram.test.js.snap b/src/core_modules/capture-core/rules/__tests__/__snapshots__/getApplicableRuleEffectsForTrackerProgram.test.js.snap index 8437a2e920..da0104a463 100644 --- a/src/core_modules/capture-core/rules/__tests__/__snapshots__/getApplicableRuleEffectsForTrackerProgram.test.js.snap +++ b/src/core_modules/capture-core/rules/__tests__/__snapshots__/getApplicableRuleEffectsForTrackerProgram.test.js.snap @@ -25,7 +25,7 @@ Object { "valueType": "TEXT", }, }, - "isFirstStageEventForm": undefined, + "isEnrollmentFormWithEvent": undefined, "optionSets": Object { "0": Object { "displayName": undefined, diff --git a/src/core_modules/capture-core/rules/__tests__/__snapshots__/getApplicableRulesEffectsForEventProgram.test.js.snap b/src/core_modules/capture-core/rules/__tests__/__snapshots__/getApplicableRulesEffectsForEventProgram.test.js.snap index c970c97532..96eaaf786f 100644 --- a/src/core_modules/capture-core/rules/__tests__/__snapshots__/getApplicableRulesEffectsForEventProgram.test.js.snap +++ b/src/core_modules/capture-core/rules/__tests__/__snapshots__/getApplicableRulesEffectsForEventProgram.test.js.snap @@ -25,7 +25,7 @@ Object { "valueType": "TEXT", }, }, - "isFirstStageEventForm": undefined, + "isEnrollmentFormWithEvent": undefined, "optionSets": Object { "0": Object { "displayName": undefined, diff --git a/src/core_modules/capture-core/rules/getApplicableRuleEffects.ts b/src/core_modules/capture-core/rules/getApplicableRuleEffects.ts index c28c980e94..5d1b1210fe 100644 --- a/src/core_modules/capture-core/rules/getApplicableRuleEffects.ts +++ b/src/core_modules/capture-core/rules/getApplicableRuleEffects.ts @@ -52,7 +52,7 @@ export const getApplicableRuleEffectsForTrackerProgram = ({ attributeValues, enrollmentData, formFoundation, - isFirstStageEventForm, + isEnrollmentFormWithEvent, }: GetApplicableRuleEffectsForTrackerProgramInput, flattenedResult = false, ) => { @@ -84,7 +84,7 @@ flattenedResult = false, programRuleVariables, trackedEntityAttributes: getTrackedEntityAttributesForRulesExecution(program.attributes), foundationForPostProcessing, - isFirstStageEventForm, + isEnrollmentFormWithEvent, }); return flattenedResult ? effects : buildEffectsHierarchy(effects); @@ -101,7 +101,7 @@ const getApplicableRuleEffects = ({ programRuleVariables, trackedEntityAttributes, foundationForPostProcessing, - isFirstStageEventForm, + isEnrollmentFormWithEvent, }: GetApplicableRuleEffectsInput) => { const dataElements = getDataElementsForRulesExecution(stages); @@ -118,7 +118,7 @@ const getApplicableRuleEffects = ({ selectedEntity: attributeValues, selectedOrgUnit: orgUnit, optionSets, - isFirstStageEventForm, + isEnrollmentFormWithEvent, }); return postProcessRulesEffects( diff --git a/src/core_modules/capture-core/rules/rules.types.ts b/src/core_modules/capture-core/rules/rules.types.ts index 3666fd37a3..15455b2ebb 100644 --- a/src/core_modules/capture-core/rules/rules.types.ts +++ b/src/core_modules/capture-core/rules/rules.types.ts @@ -19,7 +19,7 @@ export type GetApplicableRuleEffectsForTrackerProgramInput = { attributeValues?: TEIValues, enrollmentData?: Enrollment, formFoundation?: RenderFoundation, - isFirstStageEventForm?: boolean, + isEnrollmentFormWithEvent?: boolean, }; export type GetApplicableRuleEffectsForEventProgramInput = { @@ -39,5 +39,5 @@ export type GetApplicableRuleEffectsInput = { programRuleVariables: Array, trackedEntityAttributes?: TrackedEntityAttributes, foundationForPostProcessing: RenderFoundation, - isFirstStageEventForm?: boolean, + isEnrollmentFormWithEvent?: boolean, };