Product EngineeringFeaturesCritical CalloutFrontend

Export

How the Critical Callout Worklist Excel export works — row granularity, data sources, API calls, columns, and file naming.

👤 Sachin Sharma📅 Updated: Apr 29, 2026🏷️ feature🏷️ frontend🏷️ worklist🏷️ export

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:

FileRole
utils/helpers.tshandleExportWorklist()Entry point — prepares rows, validates, delegates to export
utils/helpers.tsgetCriticalCalloutExportRows()Transforms report objects into flat export rows
utils/exportUtils.jsexportCriticalCalloutWorklist()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:

SourceWhat it provides
filteredReportsDataAlready 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.criticalCalloutData

The latest CriticalCallout record per report is resolved in getLatestCallout() by sorting on created_on descending.


API call — worklist data

File: helpers.tsfetchCriticalCalloutWorklist()

GET /elastic-request/fetch-patient-reports/{report_type}/
    ?from_date={ISO}&to_date={ISO}&scroll=1

report_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:

ColumnSource field
Order IDbillId.labBillId
Patient IDuserDetailsId.labUserId
Patient NameuserDetailsId.designation + fullName
AgeuserDetailsId.age → parsed as leading digits, or calculated from DOB
DOBuserDetailsId.dateOfBirth formatted DD-MMM-YYYY
GenderuserDetailsId.sex
Accession NumbercollectedSampleId.accessionNomanualSampleIDaccessionNo
Test NamereportID.testName
Sample TypereportID.sampleId.typecollectedSampleId.sampleForId.type
Report StatusgetReportStatus(report, t).status
Callout StatuscriticalValuesDone / Pending / Attempted
Callout DateLatest CriticalCallout.created_on formatted DD-MMM-YYYY HH:mm
Callout Done ByCriticalCallout.performed_by_user_nameperformed_by_doctor_name
Methodcommunication_methods joined + "Notified via Phone Call" / "Notified via Fax" appended if already_notified is present
RecipientOrg / Referral / Patient / Other names + already-informed contacts from already_notified
CommentCriticalCallout.critical_callout_comment
Order DatebillId.billTime formatted DD-MMM-YYYY HH:mm
Accession DateaccessionDate formatted DD-MMM-YYYY HH:mm
Report DatereportDatelastUpdated formatted DD-MMM-YYYY HH:mm
Submission DatereportSubmissionTime 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
PartExample
taball, pending, done
departmentbiochemistry or all-departments
start / end01-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".

On this page