Product EngineeringFeaturesFile Type Report Upload

Frontend

livehealth-frontend entry points, upload helpers, presigned orchestration, request contracts, and operator-facing items.

👤 Rucha Mahesh Kulkarni📅 Updated: Mar 18, 2026📁 File Type Report Upload

Frontend (livehealth-frontend)

This page maps where the feature lives in the React codebase, how uploadFileTypeReport sequences presigned generation → S3 POST → reconcile → PY-2 finalization, and how header/footer deliberately diverges to the legacy path.

Cross-links: Overview, Workflow Guide, Backend.

What frontend owns

  • Operator UX for conversion (ReportConversionModal) and for upload (UploadFileButton, UploadFileTypeReportModal).
  • Client-side validation before network (encrypted PDF rejection, extension acceptance, session/lab guards in helpers).
  • Orchestration of the revamp path: build temp cloud_path, call sm_generate_presigned_url/, uploadFileOnPresigned (S3 POST), reconcileUploadedPresignedFile, then uploadFileTypeReport/ with initialFilePath only (no raw file body on the happy path).
  • Legacy branch when header/footer is selected: base64 / fileData submission to uploadFileWithHeader via uploadFileTypeReportWithHeader.
  • Optional post-upload mark_report_as_done_api when the modal option is enabled.

Frontend Technicalities

1. Upload entry point

File: src/components/reusable/TestWaitingList/UploadFileButton.tsx

Role:

  • Surfaces the Upload File action for file-enabled reports in the waiting list / operations surfaces.
  • Stashes selected labReportDetails in generic Redux state.
  • Opens the upload modal.

2. Upload modal

File: src/components/reusable/TestWaitingList/UploadFileTypeReportModal.tsx

Responsibilities:

  • File picker with extension acceptance aligned to backend/SM rules (PDF + common images).
  • Optional Apply header and footer - dispatches to uploadFileTypeReportWithHeader (legacy).
  • Optional Mark all other reports in this bill as Done - post-upload call to mark-as-done API.
  • Patient/report context from modal state (labReportDetails).

3. Main upload helper (revamp vs legacy)

File: src/utils/helpers.ts

FunctionRole
uploadFileTypeReportMain revamp path - presigned URL, direct S3 upload, reconcile, then uploadFileTypeReport/ with metadata (initialFilePath, etc.).
uploadFileTypeReportWithHeaderOlder path - reads file to base64 / data URL and posts fileData to backend header/footer endpoint.

The revamp path’s practical contract: metadata finalization after the binary is already in object storage.

4. Presigned direct upload helper

File: src/redux/actions/PromotionActions.ts

Function: uploadFileOnPresigned(...)

Responsibilities (conceptual):

  • Convert local data URL back to Blob / File.
  • Submit multipart/form-data to the presigned POST target (S3).
  • Apply short post-upload delay where implemented (eventual consistency buffer).
  • Invoke reconcile helper after successful POST.

This is the browser-side locus of the performance breakthrough: the application server is not the binary transport hop on the happy path.

5. Reconcile helper

File: src/components/reusable/MultiAttachments/helper.ts

Function: reconcileUploadedPresignedFile

Responsibilities:

  • POST to sm_reconcile_presigned_url/ with the uploaded filepath.
  • Normalize success/failure shape for upstream callers (modal + helpers).

Reconcile is not cosmetic for operators of Storage Manager observability: it closes the presigned lifecycle in logs and records authoritative size after head_object-style verification on the PY-2 side.

6. Report conversion UI

File: src/components/reusable/Modals/ReportConversionModal/index.tsx

Responsibilities:

  • Confirmation UX (values cleared, signing reset).
  • Calls convertReportToFileOrNormal/ with labReportId.
  • Radiology / permission failures surface per API responses.

7. Permission label (admin UI)

File: src/components/LabAdmin/UserManagement/utils/operationSettingConstants.ts

Permission label: “Allow Convert to file Report” → backend flag allow_report_file_conversion.

Frontend request contract summary

OperationEndpointPayload type
Convert report modeconvertReportToFileOrNormal/labReportId
Generate presigned uploadsm_generate_presigned_url/filename, file_category, cloud_path, patient_id, request_host_origin
Reconcile uploaded filesm_reconcile_presigned_url/filepath
Finalize file reportuploadFileTypeReport/fileName, extension, initialFilePath, labReportId
Optional sibling completionmark_report_as_done_api/list of lab_reports + comments
Header/footer (legacy)uploadFileWithHeader/ (via helper)base64 / structured file payload

Frontend Engineering checklist

GotchaWhy it matters
Header/footer path still posts file to backendDoes not get the full presigned-scale benefit; payload size and app-server pressure return.
Browser still builds data URL / base64 before presigned POSTMemory pressure exists client-side; the win is offloading backend transport, not eliminating client-side reads.
Images are first-class in accept listsDownstream print pipelines sometimes wrap images into PDF pages - not “PDF-only” in code.
Encrypted PDFs rejected client-sideOperators may see failure before any presigned call; distinguish from SM / S3 errors.
“Lambda finishes everything” is not guaranteed by FE aloneObserved FE path finalizes through PY-2 with initialFilePath; Lambda path is parallel architecture, not implied by FE source alone.

PY-2 legacy static references (if still deployed)

Some deployments retain older static operations modals:

Treat these as historical / parallel surfaces unless your lab still ships that bundle; the React paths above are the primary modern integration for file-type report upload in livehealth-frontend.

On this page