Skip to content

(feat) O3-3230: Add rule builder to interactive builder #450

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 120 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
59b7e09
Optimize useCallback dependencies
senthil-athiban May 25, 2024
320ad15
fix: Add "and" and "then" translations
senthil-athiban May 25, 2024
293afd4
(feat): register rule builder as feature flag
senthil-athiban May 28, 2024
22d3b81
(enhance): improve handler function logic & add fails action
senthil-athiban May 28, 2024
6a6ca13
(feat): create global state for storing the rules
senthil-athiban May 29, 2024
b2e16da
(chore): Refactor rule types and handler functions
senthil-athiban May 29, 2024
7812167
(chore): optimize handler functions and use debounce mechanism for er…
senthil-athiban May 30, 2024
055089a
(chore): remove rule from global state and fixing infinite re-renders
senthil-athiban May 30, 2024
1188740
(chore): Refactor condition, and action selection logic in dropdown
senthil-athiban May 30, 2024
d9921af
(fix): fixed handleElementChange logic
senthil-athiban May 31, 2024
efbf728
(feat): ability to add multiple logics for same question field
senthil-athiban Jun 1, 2024
5203e23
(chore): update translation
senthil-athiban Jun 1, 2024
7876196
(chore): optimize the global state rules
senthil-athiban Jun 3, 2024
d7e688a
(chore): update conditional rendering logic of rule builder
senthil-athiban Jun 3, 2024
c0df37b
(chore): refactor RuleHeader component in rule-builder
senthil-athiban Jun 3, 2024
3537c10
(chore): update translation
senthil-athiban Jun 4, 2024
b016de8
(feat): add unit test for rule header component
senthil-athiban Jun 6, 2024
dfaf32c
(feat): add unit test for rule-builder component
senthil-athiban Jun 6, 2024
92c1912
(refactor): Refactor mockup values for unit testing
senthil-athiban Jun 7, 2024
62699ac
(feat): add unit test in rule-header
senthil-athiban Jun 7, 2024
6eb5785
(feat): add link to docs
senthil-athiban Jun 7, 2024
87586a6
(refactor): enhance conditional rendering of docs link
senthil-athiban Jun 10, 2024
0f320ab
(feat): Improve performance by memoizing React components
senthil-athiban Jun 10, 2024
2ce4f97
(feat): add delete conditional logic modal
senthil-athiban Jun 10, 2024
06e89ba
(feat): add translation
senthil-athiban Jun 10, 2024
288fd25
(fix): enhance id of delete conditional logic
senthil-athiban Jun 10, 2024
3db16e0
(refactor): enhance naming conventions
senthil-athiban Jun 10, 2024
84f7022
(feat): add translation
senthil-athiban Jun 10, 2024
f80dda5
(feat): improve conditional logic delete modal
senthil-athiban Jun 11, 2024
ddb54da
(feat): add translation
senthil-athiban Jun 11, 2024
e44284e
(feat): add delete conditions or actions modal
senthil-athiban Jun 12, 2024
b739e9d
(feat): add custom combo box for target value
senthil-athiban Jun 12, 2024
1fad9e9
(feat): add translation
senthil-athiban Jun 12, 2024
679ccfd
(feat): add toggle functionality for allowing future dates
senthil-athiban Jun 12, 2024
e704610
(feat): add disallow decimal value toggle functionality
senthil-athiban Jun 12, 2024
8d20fe6
(fix): delete the specified conditional logic
senthil-athiban Jun 13, 2024
d04bd20
(feat): update trigger actions with calculate expression
senthil-athiban Jun 18, 2024
2f3b3e1
(feat): add hideWhenExpression and calculateExpression logics
senthil-athiban Jun 19, 2024
0d50a30
(fix): review changes
senthil-athiban Jun 19, 2024
567eb13
(feat): add ability to remove the deleted logics from schema
senthil-athiban Jun 20, 2024
cb18806
(feat): add translation
senthil-athiban Jun 20, 2024
1b3ed42
(feat): add date calculation logic
senthil-athiban Jun 24, 2024
b24117c
(feat): add doesNotMatchExpression logic
senthil-athiban Jun 24, 2024
427119c
(refactor): add enums and interface for rule-builder
senthil-athiban Jun 24, 2024
a754afa
merge main
senthil-athiban Jun 27, 2024
30fe732
(fix): rename modal file
senthil-athiban Jun 27, 2024
ae66130
(feat): add arrContains and arrContainsAny logic
senthil-athiban Jun 27, 2024
5736ee7
(feat): add translation
senthil-athiban Jun 27, 2024
c50b43e
(test): unit test coverage for calculate expression and arrContains l…
senthil-athiban Jun 28, 2024
86f01ec
(fix): build issue
senthil-athiban Jul 2, 2024
b0700c6
(feat): add hidingRule for pages, and sections
senthil-athiban Jul 4, 2024
d1999f5
(feat): add disableWhenExpression logic
senthil-athiban Jul 4, 2024
71b9cff
(test): add unit test for dynamic rendering of action fields
senthil-athiban Jul 4, 2024
05f8619
(feat): add translation
senthil-athiban Jul 4, 2024
ae227e1
(fix): fix typo in arrContains logic
senthil-athiban Jul 4, 2024
268ca8a
(fix): typo
senthil-athiban Jul 5, 2024
330d3a9
(fix): fixed renderingType in date validation
senthil-athiban Jul 10, 2024
db0b7cc
(fix): avoided direct access of DOM element
senthil-athiban Jul 10, 2024
012015e
(feat): add calcTimeDifference helper function
senthil-athiban Jul 11, 2024
dc18bcb
(feat): add includes helper function
senthil-athiban Jul 11, 2024
84a8384
(feat): add viral load status helper function
senthil-athiban Jul 11, 2024
8be1421
(fix): add calcTimeDifference in months
senthil-athiban Jul 11, 2024
5d2b565
(feat): add dayjs
senthil-athiban Jul 13, 2024
4821071
(feat): add date validation
senthil-athiban Jul 13, 2024
6f0e626
(test): unit test coverage for date validation
senthil-athiban Jul 13, 2024
af93297
(feat): add translation
senthil-athiban Jul 13, 2024
0b4e56b
(feat): add mechanism for processing Calculate()
senthil-athiban Jul 19, 2024
e87e475
(feat): add calcNextVisitDate helper function
senthil-athiban Jul 19, 2024
d63518b
(feat): add calcTreatmentEndDate()
senthil-athiban Jul 19, 2024
736da4c
(feat): add calcGravida()
senthil-athiban Jul 19, 2024
9f4158d
(fix): use today()
senthil-athiban Jul 19, 2024
113459d
(feat): enable historical expression using toggle functionality
senthil-athiban Jul 26, 2024
bb2e53a
(test): add unit test for historical expression
senthil-athiban Jul 26, 2024
d57f61c
(feat): add translation
senthil-athiban Jul 26, 2024
f1dfdae
(feat): add helper function for historical Expression
senthil-athiban Jul 26, 2024
a4eb211
(feat): move findQuestionIndex() to utils
senthil-athiban Jul 26, 2024
ae0245c
(fix): typo
senthil-athiban Jul 26, 2024
2e17283
(refactor): review feedback
senthil-athiban Jul 27, 2024
74c5486
(fix): hide logic
senthil-athiban Jul 27, 2024
20ae8b2
(fix): disable the deletePreviousAction()
senthil-athiban Jul 27, 2024
b34dfbc
(feat): add e2e test for toggle functionality
senthil-athiban Aug 2, 2024
8407e18
(fix): remove log
senthil-athiban Aug 2, 2024
0e606ba
(fix): typo in e2e test
senthil-athiban Aug 2, 2024
38d76d4
(fix): rename file
senthil-athiban Aug 2, 2024
94fc8d2
(feat): add e2e for hiding logic
senthil-athiban Aug 2, 2024
ee828d1
(feat): add e2e test for calculation logic
senthil-athiban Aug 2, 2024
8f8231a
(feat): add e2e test for calculating EDD
senthil-athiban Aug 2, 2024
04cb84c
(feat): add e2e test for calculate viral load status
senthil-athiban Aug 2, 2024
cac8a54
(feat): add e2e test for date validation
senthil-athiban Aug 3, 2024
f4bffb7
(test): replace string with regex in e2e test
senthil-athiban Aug 3, 2024
60a8ac1
(test): refactor the e2e test with test.step()
senthil-athiban Aug 3, 2024
6178525
(fix): use renderSWR in test
senthil-athiban Aug 10, 2024
fcaa7de
(fix): change DOM element in test
senthil-athiban Aug 10, 2024
566fa5f
(fix): use conditional rendering
senthil-athiban Aug 10, 2024
cea3483
(refactor): improve handling statement
senthil-athiban Aug 10, 2024
317a4f5
(chore): add descriptive commands
senthil-athiban Aug 10, 2024
b345671
(feat): add new hide type
senthil-athiban Aug 10, 2024
105cdfd
(refactor): remove unused deletePreviousAction function
senthil-athiban Aug 10, 2024
13a886a
(refactor): add descriptive commands for handler functions
senthil-athiban Aug 11, 2024
08cb761
(fix): avoid direct mutation
senthil-athiban Aug 11, 2024
3442ca4
(fix): adjust css of combo box
senthil-athiban Aug 11, 2024
0190d0a
(fix): increase padding in combobx
senthil-athiban Aug 11, 2024
9b74723
(fix): typo
senthil-athiban Aug 15, 2024
6dbcc1d
(fix): use const assertions over enums
senthil-athiban Aug 15, 2024
9123308
(feat): remove enum and declare const assertions
senthil-athiban Aug 15, 2024
ef0b7c2
(fix): update validatorIndex in formRule interface instead of setState
senthil-athiban Aug 15, 2024
79b66bf
(fix): delete conditional logic
senthil-athiban Aug 15, 2024
1f8b6b8
(fix): update isNewRule when first rule gets deleted
senthil-athiban Aug 15, 2024
c77fb2f
(fix): delete all conditional logic and update schema
senthil-athiban Aug 17, 2024
7faa724
(fix): delete previous action
senthil-athiban Aug 17, 2024
481b513
(feat): add (calculate, disable) action types in deletePreviousAction
senthil-athiban Aug 17, 2024
0229c92
(feat): add descriptive comments in handleElementChange()
senthil-athiban Aug 17, 2024
5a05484
(feat): add delete functionality to remove mistakenly chosen actions
senthil-athiban Aug 17, 2024
2401125
(fix): apply DRY principle
senthil-athiban Aug 17, 2024
6cbfea0
(fix): remove delete keyword
senthil-athiban Aug 18, 2024
d092a85
merge main
senthil-athiban Aug 29, 2024
bcb0db3
misc fixes
NethmiRodrigo Apr 9, 2025
4f962dd
fix unit tests
NethmiRodrigo Apr 9, 2025
3375f37
fix e2e tests
NethmiRodrigo Apr 9, 2025
36cb0b8
update yarn.lock
NethmiRodrigo Apr 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 167 additions & 0 deletions __mocks__/rule-builder.mock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
import { type FormRule } from '../src/components/rule-builder/rule-builder.component';
import { type Schema, type Question } from '../src/types';

interface UseFormMockValues {
rules: Array<FormRule>;
setRules: () => jest.Mock;
}

export const useFormMockValues: UseFormMockValues = { rules: [], setRules: () => jest.fn() };

export const numberRenderingQuestion: Question = {
label: 'Age',
type: 'obs',
required: true,
id: 'age',
questionOptions: {
rendering: 'number',
concept: '162370AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
conceptMappings: [
{
relationship: 'SAME-AS',
type: 'CIEL',
value: '162370',
},
{
relationship: 'SAME-AS',
type: 'SNOMED CT',
value: '419702001',
},
],
answers: [
{
concept: 'a899b35c-1350-11df-a1f1-0026b9348838',
label: 'Yes',
},
{
concept: 'a899b42e-1350-11df-a1f1-0026b9348838',
label: 'No',
},
]
},
validators: [],
};

export const dateRenderingQuestion: Question = {
label: 'date',
type: 'obs',
required: false,
id: 'date',
questionOptions: {
rendering: 'date',
concept: '162370AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
conceptMappings: [
{
relationship: 'SAME-AS',
type: 'CIEL',
value: '162370',
},
{
relationship: 'SAME-AS',
type: 'SNOMED CT',
value: '419702001',
},
],
answers: [],
},
validators: [],
};

export const schema: Schema = {
name: 'form1',
pages: [
{
label: 'page1',
sections: [
{
label: 'section1',
isExpanded: 'true',
questions: [
{
label: 'Name',
type: 'obs',
required: true,
id: 'name',
questionOptions: {
rendering: 'text',
concept: '162370AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
conceptMappings: [
{
relationship: 'SAME-AS',
type: 'CIEL',
value: '162370',
},
{
relationship: 'SAME-AS',
type: 'SNOMED CT',
value: '419702001',
},
],
},
validators: [],
},
{
label: 'Are you currently in HIV care or under ART?',
id: 'currentlyOnArt',
type: 'obs',
questionOptions: {
rendering: 'select',
concept: 'a8afba58-1350-11df-a1f1-0026b9348838',
answers: [
{
concept: 'a899b35c-1350-11df-a1f1-0026b9348838',
label: 'Yes',
},
{
concept: 'a899b42e-1350-11df-a1f1-0026b9348838',
label: 'No',
},
],
},
validators: [],
},
],
},
],
},
{
label: 'page2',
sections: [
{
label: 'section2',
isExpanded: 'true',
questions: [
{
label: 'Age',
type: 'obs',
required: true,
id: 'age',
questionOptions: {
rendering: 'text',
concept: '162370AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
conceptMappings: [
{
relationship: 'SAME-AS',
type: 'CIEL',
value: '162370',
},
{
relationship: 'SAME-AS',
type: 'SNOMED CT',
value: '419702001',
},
],
},
validators: [],
},
],
},
],
},
],
processor: 'EncounterFormProcessor',
encounterType: '',
referencedForms: [],
uuid: '',
description: 'desc1',
};
12 changes: 11 additions & 1 deletion e2e/pages/form-builder-page.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import type { Page } from '@playwright/test';

import customSchema from '../support/validation-custom-schema.json';
export class FormBuilderPage {
constructor(readonly page: Page) {}

Expand Down Expand Up @@ -65,11 +65,21 @@ export class FormBuilderPage {
readonly answer = () => this.page.getByRole('menuitem', { name: /tested for covid 19/i });
readonly questionIdInput = () => this.page.getByRole('textbox', { name: /question id/i });
readonly questionCreatedMessage = () => this.page.getByText(/new question created/i);
readonly dateInput = (fieldName: string) => this.page.getByRole('group', { name: fieldName }).locator('div');
readonly dateDayInput = (fieldName: string) => this.page.getByRole('spinbutton', { name: `day, ${fieldName}` });
readonly dateMonthInput = (fieldName: string) => this.page.getByRole('spinbutton', { name: `month, ${fieldName}` });
readonly dateYearInput = (fieldName: string) => this.page.getByRole('spinbutton', { name: `year, ${fieldName}` });

async gotoFormBuilder() {
await this.page.goto('form-builder');
}

async formBuilderSetupForRuleBuilder() {
await this.createNewFormButton().click();
await this.schemaInput().fill(JSON.stringify(customSchema, null, 2));
await this.renderChangesButton().click();
}

async searchForForm(formName: string) {
await this.page.getByRole('searchbox').fill(formName);
}
Expand Down
Loading