Frontend
Frontend responsibilities, state shapes, UI behavior, and key components for Molecular.
Frontend
What Frontend Owns
| Concern | Frontend responsibility |
|---|---|
| Entry points | Gene Master, Antibiotic Master, and Organism Master under Drug Master / Panel Master |
| Report setup | Molecular test type and molecular report parameter components in Test List |
| UI state | List tabs, selected rows, filters, modal form values, selected antibiotics, component configuration tabs |
| Validation | Required fields such as gene name, antibiotic name/category/code/unit, organism name/category/code, component title, and referring list |
| API calls | Fetch, create, update, disable, download, bulk-action, system-default request actions, and report-parameter save actions |
| Display / statuses | Enabled/disabled status, system default/custom/disabled tabs, row action menus, report component configuration |
Frontend Perspective
- The sidebar exposes
Drug Master / Panel Masteras the entry point. - Gene Master shows the gene catalog with tabs for all, system default, custom, and disabled genes.
- Antibiotic Master shows the antibiotic catalog with tabs for all, system default, custom, and disabled antibiotics.
- Organism Master lets users manage organism records and view their linked antibiotics.
- List pages support download, bulk actions, filtering, row actions, and system-default requests.
- Test List lets users create a report/test with test type
Molecular. - Report Parameters lets users add molecular components such as Gene, Organism, Antibiotic Resistance, and Molecular Pivot.
- Gene configuration controls report-entry fields and display metadata.
- Organism configuration includes a Viral Load field in addition to the standard gene-style fields.
- Antibiotic Resistance links to a Gene component and provides antibiogram-style display with resistance filtering.
- Molecular Pivot links to Antibiotic Resistance components and supports group-by, sort-by, and order-by metadata.
Core Frontend State Objects
| State key | What it stores | Why it exists |
|---|---|---|
allGenes | Genes loaded into Redux MODEL | Persists the gene list for report-entry default row resolution |
disabledGenes | Disabled genes loaded lazily on tab click | Populates the Disabled Genes tab without an initial load cost |
allAntibiotics | Antibiotics loaded into Redux MODEL | Persists the antibiotic list for cross-component usage |
disabledAntibiotics | Disabled antibiotics loaded lazily on tab click | Populates the Disabled Antibiotics tab |
allOrganisms | Organisms loaded into Redux MODEL | Persists the organism list for report-entry usage |
disabledOrganisms | Disabled organisms loaded lazily on tab click | Populates the Disabled Organisms tab |
selectedTab | Current list tab such as all/system/custom/disabled | Controls list filtering per master |
selectedData | Currently selected row for edit/copy/disable flows | Drives the create/update modal with pre-filled values |
createGeneModal / createDrugModal | Whether the create/update modal is open | Controls modal visibility per master |
disableGeneModal / disableDrugModal | Whether the disable confirmation modal is open | Requires explicit user confirmation before disable |
antibioticsRelatedOrganisms | Organisms linked to the antibiotic being disabled | Shown in the disable modal to warn about dependencies |
selectedComponent | Current report parameter component such as Gene | Drives the right-side component configuration panel |
selectedFields | Fields selected for a component | Controls report-entry fields and labels |
componentMeta | Group By, Sort By, and Order By settings | Controls Molecular Pivot report-entry and display organization |
linkedComponent | Component selected by Antibiotic Resistance or Molecular Pivot | Tells the component which Gene or Antibiotic Resistance result set to link |
geneDisabledApiCall | Whether the disabled-genes API has already been called | Prevents duplicate API calls on repeated tab visits |
antibioticDisabledApiCall | Whether the disabled-antibiotics API has already been called | Prevents duplicate API calls on repeated tab visits |
organismDisabledApiCall | Whether the disabled-organisms API has already been called | Prevents duplicate API calls on repeated tab visits |
Visibility Rules
The feature appears when the user has access to the Drug Master / Panel Master sidebar section.
The Gene Master, Antibiotic Master, and Organism Master screens are siblings inside the same sidebar group that also contains Drug Master, Panel Master, and Brand Master.
Molecular report components appear from the Add New Parameter menu after the test/report is configured with test type Molecular.
Antibiotic Resistance component requires at least one Gene component to be present in the same test because it must link to a Gene component.
Molecular Pivot component requires at least one Antibiotic Resistance component to be present.
Runtime UI Behaviors
- When a user opens Gene Master, the initial load calls
/reporting/genes/?is_disabled=0and stores results inMODEL.allGenes. - When a user clicks the
Disabled Genestab, the disabled-genes API is called once and stored inMODEL.disabledGenes. - When a user opens Antibiotic Master, the initial load calls
/reporting/antibiotics/?is_disabled=0and stores results inMODEL.allAntibiotics. - When a user opens Organism Master, the initial load calls
/reporting/organisms/?is_disabled=0and stores results inMODEL.allOrganisms. - When the
Disabled AntibioticsorDisabled Organismstab is clicked, the corresponding disabled list is fetched once and cached. - When a user copies a gene, antibiotic, or organism, the name is prefixed with
Copy ofand a new record is created immediately. - When a user disables an antibiotic, the related organisms are fetched from
/reporting/antibiotics/{id}/organismsand shown in the disable confirmation modal before the disable action proceeds. - When a user disables an organism, the related antibiotics are fetched from
/reporting/organisms/{id}/antibioticsand shown in the disable confirmation modal. - When a user disables a gene, no dependency check is performed before showing the confirmation modal.
- When validation fails, the modal should keep entered data and show actionable validation feedback.
- When save succeeds, the modal closes and the list reflects the updated record.
- When the user selects test type
Molecular, the Report Parameters tab can add molecular components. - When the user adds a
Genecomponent, it opens withConfiguration,Meta, andDefaultstabs. - When the user adds an
Organismcomponent, it opens withConfiguration,Meta, andDefaultstabs. - When the user adds an
Antibiotic Resistancecomponent, it links to a Gene component and exposes theConfigurationandMetatabs with an antibiotic filter toggle. - When the user adds a
Molecular Pivotcomponent, it links to Antibiotic Resistance components and exposes aMetatab with Group By, Sort By, and Order By fields. - During report entry, the Gene component grid shows
Detectedwhen the entered value is at or below the cut-off, andNot Detectedwhen above. - During report entry, the Organism component behaves the same way as Gene regarding the detection logic.
Detectedrows are highlighted;Not Detectedrows are not highlighted.- The Antibiotic Resistance component has a
Calculatebutton that populates antibiotic resistance data based on the linked Gene results. - The Antibiotic Resistance filter toggles (
Show All Antibiotics,Only Resistant,Only Sensitive) filter the visible antibiotic rows.
Important Molecular Snippets (Frontend)
Report entry component renderer
Source: livehealth-frontend/src/components/reusable/Modals/Report/EditReportView/index.tsx
renderComponent(...) is the report-entry switchboard. It reads component_type from each report format row and renders the matching molecular component.
Important behavior:
GENEandORGANISMrender collapsible grids with anAdd GenesorAdd Organismsdropdown.- Both pass
component_typeinto the grid helpers so detection logic can be applied correctly. ANTIBIOTIC_RESISTANCErenders an antibiogram-style grid linked to Gene components, with aCalculatebutton and a resistance filter.MOLECULAR_PIVOTrenders a summary pivot of Antibiotic Resistance findings using metadata for group-by, sort-by, and order-by.
Molecular detection logic in renderCell
Source: livehealth-frontend/src/components/reusable/Modals/Report/EditReportView/AgGrid/helpers.tsx
renderCell(...) applies molecular-specific result logic when componentType is GENE or ORGANISM.
Key behavior:
- When
result_1is entered, the comparison checksvalue > cut_offinstead ofvalue >= cut_off. - If value is above the cut-off, interpretation is
Not Detected,is_positive = 0,highlightFlag = 0. - If value is at or below the cut-off, interpretation is
Detected,is_positive = 1,highlightFlag = 1. - Non-numeric values default to
Detected. - This is the opposite of toxicology logic where higher values trigger
Positive.
Minimal control flow:
const molecularCheck =
componentType?.toUpperCase() == "GENE" ||
componentType?.toUpperCase() == "ORGANISM";
if (molecularCheck) {
condition = Number(updatedValue) > Number(copyData?.cut_off);
// Non-numeric or empty → treated as detected
if (isNaN(Number(updatedValue)) || String(updatedValue)?.trim()?.length === 0) {
condition = true;
}
}
if (condition) {
result = molecularCheck ? "Not Detected" : "Positive";
is_positive = molecularCheck ? 0 : 1;
highlightFlag = molecularCheck ? 0 : 1;
} else {
is_positive = molecularCheck ? 1 : 0;
highlightFlag = molecularCheck ? 1 : 0;
}Molecular row color helper
Source: livehealth-frontend/src/components/reusable/Modals/Report/EditReportView/AgGrid/helpers.tsx
getColorForMolecular(...) highlights rows where the result value is at or below the cut-off, indicating detection.
if (
data[colObj?.column_ref] !== null &&
data[colObj?.column_ref] !== "" &&
Number(data[colObj?.column_ref]) <= data?.cut_off
) {
return UPPER_LIMIT_COLOR; // row is highlighted for detected values
}
return WHITE_COLOR;Molecular Pivot column helper
Source: livehealth-frontend/src/components/reusable/Modals/Report/EditReportView/AgGrid/helpers.tsx
prepareSummaryComponentColumnDefForMolecular(...) builds the column definitions for the Molecular Pivot grid. It appends an Antibiotic Name column to the standard configured columns and applies group-by, sort-by, and order-by from component meta.
Antibiotic Resistance grid helper
Source: livehealth-frontend/src/components/reusable/Modals/Report/EditReportView/AgGrid/helpers.tsx
prepareColumnDefMicro(...) and renderCellMicro(...) build the column definitions and cell rendering for the Antibiotic Resistance component. The method_type from component meta influences how result values are interpreted and displayed in the antibiogram grid.
Default row resolution
Source: livehealth-frontend/src/components/reusable/Modals/Report/EditReportView/AgGrid/helpers.tsx
prepareDefaultRowData(...) resolves default instances for report entry. When linked_model is GENE, it reads from MODEL.allGenes instead of MODEL.allDrugs or MODEL.allAntibiotics.
Gene Master container
Source: livehealth-frontend/src/components/reusable/Gene/container/index.tsx
GeneMaster owns the Gene Master list screen.
Important behavior:
- Initial load calls
getDrugListApi("/reporting/genes/?is_disabled=0"). - Stores active genes in
MODEL.allGenes. Disabled Genestab lazily calls/reporting/genes/?is_disabled=1.- Tabs split the list into
All Genes,System Defaults,Custom Genes, andDisabled Genes. Add GeneopensCreateGene.- Row click/edit loads the selected gene into the update flow.
- Copy creates a new gene by cloning the selected row and prefixing the name with
Copy of. - Enable calls
/reporting/genes/{id}/enable/. - Disable opens a confirmation modal and then calls
/reporting/genes/{id}/disable/. - Tab state syncs to
GENERIC.selectedTabfor sub-tab navigation inside the modal.
Antibiotic Master container
Source: livehealth-frontend/src/components/reusable/Antibiotic/container/index.tsx
AntibioticMaster owns the Antibiotic Master list screen.
Important behavior:
- Initial load calls
getDrugListApi("/reporting/antibiotics/?is_disabled=0"). - Stores active antibiotics in
MODEL.allAntibiotics. Disabled Antibioticstab lazily calls/reporting/antibiotics/?is_disabled=1.- Tabs split the list into
All Antibiotics,System Defaults,Custom Antibiotics, andDisabled Antibiotics. Add AntibioticopensCreateAntibiotic.- Row click/edit loads the selected antibiotic through
convertObjForResponse(...). - Copy creates a new antibiotic by cloning and prefixing the name with
Copy of. - Before disabling an antibiotic, fetches related organisms from
/reporting/antibiotics/{id}/organismsand shows them in the disable modal. - Enable calls
/reporting/antibiotics/{id}/enable/. - Disable calls
/reporting/antibiotics/{id}/disable/.
Organism Master container
Source: livehealth-frontend/src/components/reusable/Organism/container/index.tsx
OrganismMaster owns the Organism Master list screen.
Important behavior:
- Initial load calls
getDrugListApi("/reporting/organisms/?is_disabled=0"). - Stores active organisms in
MODEL.allOrganisms. Disabled Organismstab lazily calls/reporting/organisms/?is_disabled=1.- Tabs split the list into
All Organisms,System Defaults,Custom Organisms, andDisabled Organisms. Add OrganismopensCreateOrganism.- Row click/edit loads the selected organism through
convertObjForResponse(...). - Copy creates a new organism by cloning and prefixing with
Copy of. - Before disabling an organism, fetches related antibiotics from
/reporting/organisms/{id}/antibioticsand shows them in the disable modal. - Enable calls
/reporting/organisms/{id}/enable/. - Disable calls
/reporting/organisms/{id}/disable/. - On clear,
GENERIC.organismMappingTabresets toMolecular Mapping, indicating a Molecular Mapping sub-tab inside the organism modal.
Key Frontend Locations & Helpers
| Area | Function / component | Path | Role |
|---|---|---|---|
| Gene Master list | GeneMaster | livehealth-frontend/src/components/reusable/Gene/container/index.tsx | Lists all/system/custom/disabled genes, opens create/update modal, handles copy, enable, disable |
| Antibiotic Master list | AntibioticMaster | livehealth-frontend/src/components/reusable/Antibiotic/container/index.tsx | Lists all/system/custom/disabled antibiotics, opens create/update modal, handles copy, enable, disable |
| Organism Master list | OrganismMaster | livehealth-frontend/src/components/reusable/Organism/container/index.tsx | Lists all/system/custom/disabled organisms, opens create/update modal, handles copy, enable, disable |
| Report entry renderer | renderComponent | livehealth-frontend/src/components/reusable/Modals/Report/EditReportView/index.tsx | Renders Gene, Organism, Antibiotic Resistance, Molecular Pivot, and other component types |
| Gene report-entry grid | GENE case in renderComponent | livehealth-frontend/src/components/reusable/Modals/Report/EditReportView/index.tsx | Add genes, render configured grid columns with detection logic |
| Organism report-entry grid | ORGANISM case in renderComponent | livehealth-frontend/src/components/reusable/Modals/Report/EditReportView/index.tsx | Add organisms, render configured grid columns with detection logic and Viral Load |
| Antibiotic Resistance grid | ANTIBIOTIC_RESISTANCE case in renderComponent | livehealth-frontend/src/components/reusable/Modals/Report/EditReportView/index.tsx | Calculate and display linked antibiotic resistance with resistance filter |
| Molecular Pivot grid | MOLECULAR_PIVOT case in renderComponent | livehealth-frontend/src/components/reusable/Modals/Report/EditReportView/index.tsx | Renders pivot of Antibiotic Resistance findings using meta settings |
| Molecular detection logic | renderCell | livehealth-frontend/src/components/reusable/Modals/Report/EditReportView/AgGrid/helpers.tsx | Applies GENE/ORGANISM-specific detection logic: Detected/Not Detected with inverted cut-off |
| Molecular row color | getColorForMolecular | livehealth-frontend/src/components/reusable/Modals/Report/EditReportView/AgGrid/helpers.tsx | Highlights detected rows where value ≤ cut_off |
| Molecular Pivot column helper | prepareSummaryComponentColumnDefForMolecular | livehealth-frontend/src/components/reusable/Modals/Report/EditReportView/AgGrid/helpers.tsx | Builds Molecular Pivot grid columns, appending Antibiotic Name column to configured fields |
| Antibiotic Resistance column helper | prepareColumnDefMicro | livehealth-frontend/src/components/reusable/Modals/Report/EditReportView/AgGrid/helpers.tsx | Builds Antibiotic Resistance grid column definitions |
| Antibiotic Resistance cell renderer | renderCellMicro | livehealth-frontend/src/components/reusable/Modals/Report/EditReportView/AgGrid/helpers.tsx | Renders Antibiotic Resistance cells with microbiology-specific input and interpretation |
| Default row resolver | prepareDefaultRowData | livehealth-frontend/src/components/reusable/Modals/Report/EditReportView/AgGrid/helpers.tsx | Reads from MODEL.allGenes when linked_model is GENE |