Product EngineeringFeaturesLab FormsFrontendlivehealth-frontend

Admin Configuration

Admin CRUD flows for creating and editing Lab Form configurations in livehealth-frontend.

๐Ÿ‘ค Ritu Kataria๐Ÿ“… Updated: Mar 13, 2026๐Ÿท๏ธ feature

Admin Configuration (CRUD)

The admin configuration flow lets lab admins create, edit, enable/disable, and map Lab Form configurations. The entry point is the LabFormConfiguration list page.


5.1 List Page โ€” LabFormConfiguration

Component: src/components/LabAdmin/LabForms/components/index.tsx

  • Renders an AG Grid table of all configurations for the selected formType.
  • Row click โ†’ navigates to the edit page.
  • Copy โ†’ duplicates the selected configuration.
  • Enable / Disable โ†’ opens EnableDisableConfigurationModal for confirmation.
  • Bulk Instance Mapping โ†’ opens MapConfigurationsToInstancesModal to bulk-assign configurations to test/profile/promotion instances.

5.2 Add / Edit Page โ€” AddEditLabFormConfiguration

Component: src/components/LabAdmin/LabForms/components/AddEditConfiguration/index.tsx

Two-tab layout:

  • Tab 1: Basic Information โ€” form metadata fields
  • Tab 2: Form Components โ€” drag-and-drop section/question builder

Lifecycle:

  1. On mount (edit mode): calls getLabFormConfig(formType, configId) โ†’ loads config into Redux LAB_FORM slice.
  2. On tab switch: validation runs on the current tab's fields before proceeding.
  3. On save: calls validateLabForm() โ†’ on pass, calls createLabFormConfiguration() or updateFormConfiguration().

5.3 Basic Information Tab

Component: src/components/LabAdmin/LabForms/components/AddEditConfiguration/BasicInformation/index.tsx

Fields:

  • Name โ€” process name
  • Description โ€” optional description
  • Icon โ€” icon picker
  • Process Type โ€” dropdown (options vary by formType):
Form TypeAvailable Process Types
aoeBill, Test, Profile, Promotion, Store, Other
consentPatient, Bill, Test, Profile, Start Up, Close Down, Other
additional_patient_infoPatient (locked โ€” auto-set by backend)
  • Response Preference โ€” "Capture once for all instances" vs "Capture separately per instance" (applicable to Test, Profile, Promotion types)
  • TTL / Expiry โ€” only shown for consent + Patient process type; value + mode (Day/Month/Year)
  • Mapped Tests/Profiles/Promotions โ€” MappedTests sub-component with AG Grid; shown for instance-dependent process types

Changing the Process Type after questions have been added shows a SwitchProcessTypeConfirmationModal warning, as it may invalidate existing instance mappings.


5.4 Form Components Tab (Drag-and-Drop Builder)

Component: src/components/LabAdmin/LabForms/components/AddEditConfiguration/FormComponents/index.tsx

Two-panel layout:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Section Sidebar    โ”‚        Main Content Area                 โ”‚
โ”‚                      โ”‚                                          โ”‚
โ”‚  Section A           โ”‚  โ–บ Section A                            โ”‚
โ”‚    โ€ข Question 1      โ”‚      Question 1 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ [edit] [ร—]  โ”‚
โ”‚    โ€ข Question 2      โ”‚      Question 2 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ [edit] [ร—]  โ”‚
โ”‚  Section B           โ”‚      [+] Add Question                    โ”‚
โ”‚    โ€ข Question 3      โ”‚  โ–บ Section B                            โ”‚
โ”‚                      โ”‚      Question 3 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ [edit] [ร—]  โ”‚
โ”‚  [+] Add Section     โ”‚      [+] Add Question                    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

The main content area uses react-beautiful-dnd to allow dragging sections and questions to reorder them. Reordering updates the sequence field in the Redux state.


5.5 Sections

Component: src/components/LabAdmin/LabForms/components/AddEditConfiguration/FormComponents/Section/index.tsx

Each section (SectionComponent) manages:

  • Name, Icon, Code, Mandatory, Hidden fields
  • Import Section โ€” ImportSectionModal allows importing a section from another configuration of the same form type
  • Communication Section โ€” special type available only for consent forms; triggers AddCommunicationSectionModal for confirmation
  • Delete โ€” DeleteSectionModal with confirmation; removes from labForm state and tracks in removedSections

Shared Section Guard: If a section is shared across multiple configurations, editing it shows EditExistingSectionModal listing all affected configurations. The user must explicitly acknowledge this before changes are applied.


5.6 Questions

Component: src/components/LabAdmin/LabForms/components/AddEditConfiguration/FormComponents/Question/index.tsx

Each question (QuestionComponent) displays:

  • Question text, Code, Field Type selector, Mandatory / Hidden toggles
  • Attribute panel โ€” rendered based on the selected field type (see ยง5.7)
  • Conditional Config โ€” shown if allow_skipping is enabled; renders skip_to_conditions builder
  • Prefilling Config โ€” shown if allow_prefilling is enabled; source + source field picker
  • Delete โ€” DeleteQuestionModal; for existing questions, sets is_disabled: true and tracks in removedQuestions

Shared Section Guard: If the question belongs to a shared section, editing shows EditExistingQuestionModal. Adding a question to a shared section shows AddQuestionModal.


5.7 Field Types & Attributes

19 supported field types, each with a dedicated attributes component:

Field TypeAttributes ComponentKey Attributes
texttextQuestionAttributesmax_length
textareatextQuestionAttributesmax_length
emailcommonQuestionAttributesplaceHolder
pincommonQuestionAttributesplaceHolder
phonenumbercommonQuestionAttributesplaceHolder
numbernumberQuestionAttributesmin_value, max_value
floatfloatQuestionAttributesmin_value, max_value, max_decimal_places
selectoptionsQuestionAttributesoptions (add/edit/delete table)
checkboxoptionsQuestionAttributesoptions
checkbox-groupoptionsQuestionAttributesoptions
radiobuttonoptionsQuestionAttributesoptions (exactly 1 option)
radiobutton-groupoptionsQuestionAttributesoptions
datedateQuestionAttributesdateformat, allow_past_dates, allow_future_dates
timedateQuestionAttributestimeformat, allow_past_dates, allow_future_dates
datetimedateQuestionAttributesdateformat, timeformat, date constraints
filefileQuestionAttributeslabel, allowed_file_types
imagefileQuestionAttributeslabel, allowed_file_types
camerafileQuestionAttributeslabel
signaturecommonQuestionAttributesplaceHolder
addresscommonQuestionAttributesplaceHolder, address line config
barcodecommonQuestionAttributesplaceHolder

Date formats supported: DD-MM-YYYY, MM-DD-YYYY, YYYY-MM-DD, DD/MM/YYYY, MM/DD/YYYY, YYYY/MM/DD

Allowed file types: PDF, JPG, JPEG, PNG, DOC, DOCX, CSV, XLSX, MP4, HEIC


5.8 Presets / Templates

Component: AddConfigViaPresetModal

  • Full-screen modal accessible from the list page.
  • Left sidebar: labFormPresetSidebar โ€” virtualized list of preset categories.
  • Main area: labFormPresetList โ€” AG Grid of presets in the selected category.
  • Preview button โ†’ labFormPresetPreview shows a disabled (read-only) form preview.
  • Use Template โ†’ copies the preset's structure into a new configuration (loads into Redux LAB_FORM state and navigates to the add page).

5.9 Instance Mapping

Two entry points:

Bulk (from list page):
MapConfigurationsToInstancesModal โ€” select multiple configurations and map them all to a set of instances in one operation.

Inline (from edit page, Basic Information tab):
MappedTests grid โ€” add/remove individual test, profile, or promotion instances. Changes are tracked in addedInstanceIds / removedInstanceIds Redux state and sent on save.

API call: POST api-v3/account/lab/form/{formType}/linked-instances/bulk

Promotion and Store Mapping Rules

  • Promotion: A form can be created with Promotion process type and mapped to a specific promotion (example: Promo 1). In CRM, this can also be managed from CRM โ†’ Promotions โ†’ <Promotion> โ†’ Configuration, where forms of any supported process type can be mapped/unmapped (not limited to Promotion-type forms).
  • Store: In CRM โ†’ Store โ†’ Configurations โ†’ Checkout, bill and store forms are available by default for mapping, and only Bill and Store process type mappings are allowed.
  • Booking runtime: For both Promotion and Store flows, all forms mapped to that entity are rendered during booking.

5.10 Validation

validateLabForm() runs before every save. It checks all fields and auto-focuses the first invalid input.

RuleApplies To
Name requiredAll
Process Type requiredAll
At least 1 section requiredAll
Section name requiredAll sections
At least 1 question per sectionAll sections
Question text requiredAll questions
Question code required + unique within sectionAll questions
Field type requiredAll questions
Options non-emptyselect, radiobutton, checkbox-group, radiobutton-group
Exactly 1 optionradiobutton
Min date โ‰ค max dateDate/DateTime fields with constraints
TTL value required if TTL mode setConsent + Patient type only
Instance mappings requiredInstance-dependent process types

Errors are stored in Redux.LAB_FORM.validationState and surfaced inline next to each field.


5.11 Save Flow

validateLabForm()
    โ”‚
    โ”œโ”€โ”€ FAIL โ†’ scroll to first error, abort
    โ”‚
    โ””โ”€โ”€ PASS
         โ”‚
         โ”œโ”€โ”€ NEW CONFIG (no id):
         โ”‚     stringifyQuestionAttributes()
         โ”‚     POST api-v3/account/lab/form/{formType}/config/new
         โ”‚     โ†’ redirect to edit page with new configId
         โ”‚
         โ””โ”€โ”€ EXISTING CONFIG (has id):
               stringifyQuestionAttributes()
               Compute delta in updatedFields
               PUT api-v3/account/lab/form/{formType}/config/{configId}/update
               โ†’ stay on edit page, refresh config

stringifyQuestionAttributes(): Before the API call, the following attributes are serialized from objects to JSON strings:

  • skip_to_conditions
  • confirmation_messages
  • prefilling_options

Dual-Track State: Every mutation in the form builder maintains two parallel Redux states:

  • labForm โ€” full current form (what the user sees in the UI)
  • updatedFields โ€” only the delta of what changed (what is sent to the API)

This minimizes payload size and avoids overwriting unrelated fields on update.

On this page