Frontend
Component structure, state management, and interaction patterns for the Order Update UI in livehealth-frontend.
Frontend
Repo: livehealth-frontend
Root path: src/components/reusable/OrderUpdates/
Component Tree
OrderUpdates (index.tsx) β Entry point; renders as a modal (page mode built-in but unused)
βββ BillDetailsSidebar β Left panel: past bills list + search
β βββ RenderBillCard β Individual bill card row
β
βββ OrderUpdate β Right panel: bill editing area
βββ DeveloperNames β Shows which staff members are viewing this bill
βββ BillTab β Main content orchestrator
β βββ [Lock Banner] β Alert bar for locked/cancelled/invoiced bills
β βββ BasicBillDetails β Bill date, sample date, source, ICD, tests
β βββ AdditionalDetails β Org, referral, comments, branch, agent fields
β β βββ PriceListModal β Price list comparison when org/referral changes
β βββ PaymentDetails β Bill summary + payment status cards (non-insurance)
β βββ InsurancePaymentDetailsβ Co-pay, deductible, insurance payable (insurance bills)
β βββ PaymentHistory β Past payments table + Add Payment button
β β βββ BillPaymentModalBody β Modal for adding/editing a payment entry
β βββ BillUpdateFooter β All action buttons + modals
β β βββ BillUpdateConfirmationModal β Shows diff before confirming
β β βββ CancelOrderModal β Confirms bill cancellation
β β βββ AOEModal β AOE form (for new tests being added)
β β βββ PatientConsentDetails β Consent form (for new tests)
β β βββ UnsavedMessageModal β Prompts on unsaved insurance changes
β βββ ResetBillModal β Confirm reset of a cancelled bill
β βββ UnlockBillModal β Confirm unlock of a locked bill
β
βββ AOEModal β Top-level AOE modal (for viewing existing AOE)Entry Point β OrderUpdates
File: src/components/reusable/OrderUpdates/index.tsx
Github Link
The OrderUpdates component is the public-facing entry point. It is React.memo-wrapped and accepts these props:
| Prop | Type | Description |
|---|---|---|
patientDetails | JsonObject | Patient record passed in from the calling page |
setOrderUpdate | (boolean) => void | Callback to close/exit the order update view |
dropdownBill | JsonObject | The specific bill to auto-select on open |
userDetailsId | number | Patient's UserDetails ID |
mode | "modal" | "page" | Defaults to "modal". "page" mode is built into the component but not yet used anywhere in the app. |
afterSuccessfulUpdate | () => void | Callback fired after a successful bill update |
afterSuccessfulCancel | () => void | Callback fired after a successful bill cancellation |
Rendering behaviour:
- Currently always renders in
"modal"mode β all call sites use the default - In
"modal"mode: wraps everything in aConfirmationModal - In
"page"mode (unused): would render a plaindivwithout a modal wrapper - If
aoeFormsexist in Redux state, rendersAOEModalinstead of the normal layout
Bill Details Sidebar β BillDetailsSidebar
File: src/components/reusable/OrderUpdates/BillDetailsSidebar.tsx
Github Link
A virtualised list of all bills for the patient, with a search input at the top.
Key behaviours:
- Uses
react-virtualized(VirtualizedList+CellMeasurerCache) for performance β renders only the visible rows even if the patient has hundreds of bills - Bills are grouped using
groupData()whenbillListis available - The
scrollToRowstate auto-scrolls to the currently active bill wheneversearchedBillschanges - The search input filters by
labBillId(exact match or prefix) - Keyboard: pressing
Enterwhile a row is highlighted calls theonClickhandler
State source: genericState.allBillsData[userDetailsId] from Redux
Main Panel β OrderUpdate
File: src/components/reusable/OrderUpdates/OrderUpdate.tsx
Github Link
Renders the header, the BillTab, and the unsaved-insurance-changes guard.
Header shows:
- Patient full name, age, sex
- Emergency badge (if
labReportList[0].modeis truthy) - Bill Approval status badge (shown when the modal is opened from the bill-approval page)
- Close icon (hidden when
claimSubmissionFlagis true)
Loading state: while orderUpdateLoader is true in Redux, a <Loading> spinner fills the panel.
Unsaved insurance guard: if the user closes the panel while editInsurance is true in the bill data, UnsavedMessageModal is shown. On "Continue", the insurance edits are discarded and the panel closes.
Bill Content β BillTab
File: src/components/reusable/OrderUpdates/BillTab/BillTab.tsx
Github Link
The orchestrator for all bill editing sections. Reads genericState from Redux to determine which modals are open and what the current bill state is.
Lock/restriction banner: shown when any of these is true:
billLocked === 1restrictBillUpdateForClaims(has_active_claim)returns trueinvoiceIdis set- Bill time restriction exceeded (
!billUpdateRestriction(billTime)) isCancel === 1
The banner shows a different action button per condition:
isCancel β "Reset Bill" β opens ResetBillModal
invoiceId β "View Invoice Details" β dispatches showInvoiceUpdateModal to Redux
billLocked β "Unlock Bill" β opens UnlockBillModalScroll height: the body area dynamically adjusts its CSS scroll height class based on whether the lock banner is visible and whether DeveloperNames is shown.
Conditional payment sections:
- Non-insurance source β
PaymentDetails+PaymentHistory - Insurance source +
insuranceListExistsβInsurancePaymentDetails+PaymentHistory - Insurance source but no insurance list β neither section is shown
Basic Bill Details β BasicBillDetails
File: src/components/reusable/OrderUpdates/BillTab/BasicBillDetails.tsx
Github Link
Handles the top section of the bill form: dates, source, ICD codes, modifiers, existing tests, and add-test capability.
Notable logic:
- On mount (
useEffect([])): syncs org source to Redux, initialisessampleDatefrom the latest lab report, and fetchesMissingFieldstates from the API - Sample Date Tooltip: if not all tests have the same sample date, a note "Showing the latest sample date for this bill" is displayed below the picker
- Bill ICD β Missing Field integration: if the lab has configured Bill ICD as a missing field, a
MissingFieldCustomCheckBoxappears. Checking it auto-fills the ICD from the lab's missing-field configuration value - Modifiers: rendered via the
<Modifiers>component; state is kept locally inselectedModifiersand synced tobillingData.billModifiersin Redux
Disabled state: the entire section is disabled when billLocked, has_active_claim, invoiceId, isCancel, or claimSubmissionFlag is true.
Additional Details β AdditionalDetails
File: src/components/reusable/OrderUpdates/BillTab/AdditionalDetails.tsx
Github Link
Handles organisation, referral, comments, branch, agent, order number, and other metadata fields.
Organisation change flow:
- User selects a new org from the dropdown
orgChangeHandlerfires β checks if the bill is completed with advance and the new org has a different payment type (blocks walk-in β non-walk-in changes with an error)- Calls
checkOrganisationPriceList()β if the org has a price list, shows Update Price List link - Calls
checkIsOptionalId()β if the lab restricts org-wise duplicate MRNs, checks for a conflict
Referral doctor change flow:
- Calls
checkReferralPriceList()on doctor selection - If the doctor has a revenue price list, shows Update Doctor Revenue link
- If the doctor has a standard price list, shows Update Price List link
- Clicking either opens
PriceListModalshowing a comparison of existing vs. new prices
Bill Comments:
- Stored as an array of strings (split by
\n), rendered as separate<InputBox>fields - If
showTimestampsis enabled, timestamps are interspersed between comment entries and rendered as read-only<span>elements (not editable inputs) - Supports Instant Comments dropdown β pre-configured comment templates that append to the comment array
Payment Details β PaymentDetails
File: src/components/reusable/OrderUpdates/BillTab/PaymentDetails.tsx
Github Link
Calculates and displays the bill summary (test total, concession, additional amount, VAT, TDS) and payment status (payable, paid, due).
Amount calculation (getPaymentDetails): runs whenever any of these change in Redux:
billTestList,paidAmount,existingTests,additionalAmount,testConcession,tdsConcession,paymentList,preSetAmountFlag,newTestTotal,billingData.orgId
Concession cap: the handleConcessionChange function enforces allowedDiscountOnBill β the maximum concession percentage a lab user is allowed to give. Fetched from getLabUserAPI() on mount.
VAT handling: supports both org-level VAT disable flag (disable_tax_for_organisation) and manually entered VAT amounts.
Output to Redux: dispatches finalPayableAmount, advanceAmount, totalConcession, dueAmount, vatAmount, vatPercent, tdsAmount on every recalculation β these values are read by BillUpdateFooter during submission.
Insurance Payment Details β InsurancePaymentDetails
File: src/components/reusable/OrderUpdates/BillTab/InsurancePaymentDetails.tsx
Github Link
Shown instead of PaymentDetails for insurance-sourced bills with insurance data.
Calculates and displays:
- Test Amount β sum of
testAmountacross all tests - Co-pay Amount β
co_pay_amount(existing tests) +patientAmount(new tests) - Deductible Amount β
deductible_amountacross all tests - Patient Payable Amount β co-pay + deductible
- Insurance Payable Amount β test total β patient payable
Payment History β PaymentHistory
File: src/components/reusable/OrderUpdates/BillTab/PaymentHistory.tsx
Github Link
Renders a table of past payments from billApiData.paymentList. Refund-type rows are visually highlighted with an alternate row background (row-bg-color).
The Add Payment button opens BillPaymentModalBody in a modal β this is the same payment entry form used during billing, reused here with orderUpdateFlag={true}.
Footer β BillUpdateFooter
File: src/components/reusable/OrderUpdates/BillTab/BillUpdateFooter.tsx
Github Link
The most complex component in the module. Manages all submission paths and secondary actions.
Submission guard (handleBillUpdate):
- Checks bill time restriction β shows restriction alert if exceeded
- Checks if concession changed but comments are empty β blocks submission if so
- Checks ICD code requirements (bill-level and source-based test-level)
- If insurance is being edited β shows unsaved-changes modal first
- If all checks pass β opens
BillUpdateConfirmationModal
footerActionMapper: a lookup object mapping footer action strings to their handlers, used by the unsaved-insurance guard to resume the correct action after discarding insurance edits:
{
confirmAndUpdate: () => setBillUpdateConfirmation(true),
cancelBill: () => setCancelBill(true),
updateAndAddToBill: () => addTest(),
addToNewBill: () => addNewTestModal(1),
consentForm: () => setShowPatientConsentModal(true),
showAOE: () => setShowAOEModal(true),
}Bill Approval actions (shown only when the modal is opened from the /bill-approval URL β detected via window.location.href):
Holdβ setsbill_approval_statusto"on-hold"Rejectβ setsbill_approval_statusto"rejected"Approve/Resolve & Approveβ setsbill_approval_statusto"approved"
Redux State Used
All bill data is stored in GENERIC redux slice under billingData[userId][labBillId]. Key shape:
billingData: {
[userId]: {
[labBillId]: {
billingData: { ... }, // Core bill fields
paymentList: [ ... ], // Payment records
labReportList: [ ... ], // Lab report relations
billICD: { bill: {}, tests: {} }, // ICD codes
billModifiers: { bill: {}, tests: {} }, // Modifiers
bill_insurances: [ ... ], // Insurance list
insuranceListExists: boolean,
editInsurance: boolean,
}
}
}Additional keys used across components:
| Redux Key | Used By |
|---|---|
labBillId | All components β current active bill |
userId | All components β current patient |
allBillsData | BillDetailsSidebar β list of bills |
orderUpdateLoader | OrderUpdate β loading spinner |
existingTests | BasicBillDetails, PaymentDetails, BillUpdateFooter |
billTestList | PaymentDetails, BillUpdateFooter β staged new tests |
sampleDate | BasicBillDetails β latest sample date |
aoeForms | OrderUpdates, BillUpdateFooter β AOE form list |
totalConcession | BillUpdateFooter β concession change detection |
finalPayableAmount | BillUpdateFooter β used in bill submission payload |
dueAmount | BillUpdateFooter β payment due validation |
validation | BillUpdateFooter β aggregated field errors |
missingFieldState | BasicBillDetails β missing field toggles |
Workflow Guide
Step-by-step guide covering how lab staff open, edit, and submit a bill update β including locked bill handling, payment management, and adding tests.
Backend
API contract, database changes, business logic orchestration, and integration points for the Order Update backend in crelio-app.