Export
How the Critical Callout Worklist Excel export works — row granularity, data sources, API calls, columns, and file naming.
Worklist Export
The worklist toolbar has an Export button that downloads an .xlsx file of the current filtered grid data. The export is entirely client-side — no API call is made at the time of export.
Files involved:
| File | Role |
|---|---|
utils/helpers.ts — handleExportWorklist() | Entry point — prepares rows, validates, delegates to export |
utils/helpers.ts — getCriticalCalloutExportRows() | Transforms report objects into flat export rows |
utils/exportUtils.js — exportCriticalCalloutWorklist() | Writes the .xlsx file using SheetJS |
Export flow
Row granularity — report-wise, not bill-wise
The grid displays rows bill-wise (grouped by Order ID). The export, however, is report-wise — one row per individual lab report.
getCriticalCalloutExportRows() iterates over filteredReportsData which contains the un-grouped, per-report list. If a bill has three critical reports, the export contains three rows.
Data sources
Export rows are assembled from two data sets:
| Source | What it provides |
|---|---|
filteredReportsData | Already visible grid data — filtered by tab, department, search, and date range. Sourced from Elasticsearch via the worklist fetch API. |
GENERIC.criticalCalloutData (Redux) | Latest CriticalCallout DB records per report — provides callout date, done-by, method, recipients, and comment. |
How criticalCalloutData is fetched
fetchAndStoreCriticalCalloutData() is called after the Elasticsearch response loads. It extracts all unique labReportId values from the worklist data and calls getCriticalCalloutData(batch) in batches:
batch size: 500 labReportIds per request
max concurrent: 3 requests at a time
result stored in: Redux GENERIC.criticalCalloutDataThe latest CriticalCallout record per report is resolved in getLatestCallout() by sorting on created_on descending.
API call — worklist data
File: helpers.ts — fetchCriticalCalloutWorklist()
GET /elastic-request/fetch-patient-reports/{report_type}/
?from_date={ISO}&to_date={ISO}&scroll=1report_type is CRITICAL_CALLOUT_REPORT_TYPE for lab login or CRITICAL_CALLOUT_DOCTOR_REPORT_TYPE for doctor login.
The Elasticsearch response feeds both the grid and the export. No separate export endpoint exists.
Export columns
Columns are in this exact order in the .xlsx sheet:
| Column | Source field |
|---|---|
| Order ID | billId.labBillId |
| Patient ID | userDetailsId.labUserId |
| Patient Name | userDetailsId.designation + fullName |
| Age | userDetailsId.age → parsed as leading digits, or calculated from DOB |
| DOB | userDetailsId.dateOfBirth formatted DD-MMM-YYYY |
| Gender | userDetailsId.sex |
| Accession Number | collectedSampleId.accessionNo → manualSampleID → accessionNo |
| Test Name | reportID.testName |
| Sample Type | reportID.sampleId.type → collectedSampleId.sampleForId.type |
| Report Status | getReportStatus(report, t).status |
| Callout Status | criticalValues → Done / Pending / Attempted |
| Callout Date | Latest CriticalCallout.created_on formatted DD-MMM-YYYY HH:mm |
| Callout Done By | CriticalCallout.performed_by_user_name → performed_by_doctor_name |
| Method | communication_methods joined + "Notified via Phone Call" / "Notified via Fax" appended if already_notified is present |
| Recipient | Org / Referral / Patient / Other names + already-informed contacts from already_notified |
| Comment | CriticalCallout.critical_callout_comment |
| Order Date | billId.billTime formatted DD-MMM-YYYY HH:mm |
| Accession Date | accessionDate formatted DD-MMM-YYYY HH:mm |
| Report Date | reportDate → lastUpdated formatted DD-MMM-YYYY HH:mm |
| Submission Date | reportSubmissionTime formatted DD-MMM-YYYY HH:mm (blank if absent) |
Recipient column format
The Recipient column is a single comma-separated string built from all notified parties — including any contacts recorded under Already Informed.
Organization (OrgName), Referral (DoctorName), Patient (PatientName),
Other (Name: X, Contact: Y, Email: Z, Fax: W),
{phone_call.name} ({phone_call.contact}),
{fax.name} ({fax.fax_number})Only present parties are included. The already-informed entries come from critical_callout_meta.already_notified in the CriticalCallout DB record.
Similarly, the Method column appends "Notified via Phone Call" and/or "Notified via Fax" after the digital channel labels when the corresponding already_notified sub-object is non-empty.
File naming
Function: getCriticalCalloutWorklistFileName()
critical-callout-worklist-{tab}-{department}-{start}-to-{end}.xlsx| Part | Example |
|---|---|
tab | all, pending, done |
department | biochemistry or all-departments |
start / end | 01-04-2026 (DD-MM-YYYY) |
Full example: critical-callout-worklist-pending-biochemistry-01-04-2026-to-27-04-2026.xlsx
Column width auto-sizing
Each column's width is auto-calculated to fit the longest value in that column, capped at 40 characters:
worksheet["!cols"] = headers.map((header) => {
const maxLength = rows.reduce(
(currentMax, row) => Math.max(currentMax, String(row?.[header] || "").length),
header.length
);
return { wch: Math.min(maxLength + 2, 40) };
});The sheet is written as a single tab named "Worklist".