Product EngineeringFeaturesLab FormsFrontendcrelio-app

State Management

Redux state management for the patient UI form renderer in crelio-app.

šŸ‘¤ Ritu KatariašŸ“… Updated: Mar 13, 2026šŸ·ļø feature

State Management

The patient UI uses Redux with a generic named reducer factory pattern. Each state key gets a dynamically created reducer via createNamedReducer(stateKey, defaultState).


Redux Store Slices

SlicePurpose
valuesForm values — { [formId]: { [fieldId]: value } }
rendererConfigForm configs — { [formId]: IFormConfig & IFormConfigQuestion }
commonShared state: labForm, patientDetails, billDetails, consentQuestions
formManagementIteration tracking: { iteration: {}, iterationValues: [] }
progressSection completion tracking
storeLab config, patient profiles, store settings
alertToast notifications
modalModal state
layoutNavigation button config (labels, visibility, disabled state)

Key Actions

File: multiSectionFormActions.ts

ActionDescription
updateSectionValues(formId, values)Merges values into values[formId]
updateSectionConfig(formId, config)Merges config into rendererConfig[formId]
clearSectionValues(formId)Clears all values for a form
setIterationValues()Saves current values as a completed iteration
updateIterationValues()Updates the iteration values array

Validation Flow

  1. On every currentFormValues change, JsonToForm.validateForm() runs
  2. Checks all mandatoryFields and validationFields against checkHasError()
  3. Calls triggerFormAction('setFormInvalid', [isInvalid, invalidFieldIds]) to notify the parent
  4. Field-level: BaseControl.onBlur → checkHasError() supports mandatory checks, regex validators, and function validators
  5. Custom field validators come from consentValidatorMapper() in ConsentForm/utils.ts

Field onChange Flow

On this page