Frontend
livehealth-frontend entry points, upload helpers, presigned orchestration, request contracts, and operator-facing items.
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, callsm_generate_presigned_url/,uploadFileOnPresigned(S3 POST),reconcileUploadedPresignedFile, thenuploadFileTypeReport/withinitialFilePathonly (no raw file body on the happy path). - Legacy branch when header/footer is selected: base64 /
fileDatasubmission touploadFileWithHeaderviauploadFileTypeReportWithHeader. - Optional post-upload
mark_report_as_done_apiwhen 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
labReportDetailsin 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
| Function | Role |
|---|---|
uploadFileTypeReport | Main revamp path - presigned URL, direct S3 upload, reconcile, then uploadFileTypeReport/ with metadata (initialFilePath, etc.). |
uploadFileTypeReportWithHeader | Older 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:
POSTtosm_reconcile_presigned_url/with the uploadedfilepath.- 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/withlabReportId. - 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
| Operation | Endpoint | Payload type |
|---|---|---|
| Convert report mode | convertReportToFileOrNormal/ | labReportId |
| Generate presigned upload | sm_generate_presigned_url/ | filename, file_category, cloud_path, patient_id, request_host_origin |
| Reconcile uploaded file | sm_reconcile_presigned_url/ | filepath |
| Finalize file report | uploadFileTypeReport/ | fileName, extension, initialFilePath, labReportId |
| Optional sibling completion | mark_report_as_done_api/ | list of lab_reports + comments |
| Header/footer (legacy) | uploadFileWithHeader/ (via helper) | base64 / structured file payload |
Frontend Engineering checklist
| Gotcha | Why it matters |
|---|---|
| Header/footer path still posts file to backend | Does not get the full presigned-scale benefit; payload size and app-server pressure return. |
| Browser still builds data URL / base64 before presigned POST | Memory pressure exists client-side; the win is offloading backend transport, not eliminating client-side reads. |
| Images are first-class in accept lists | Downstream print pipelines sometimes wrap images into PDF pages - not “PDF-only” in code. |
| Encrypted PDFs rejected client-side | Operators may see failure before any presigned call; distinguish from SM / S3 errors. |
| “Lambda finishes everything” is not guaranteed by FE alone | Observed 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:
static/components/4.0/operations/modals/FileUploadModal.jsxstatic/components/4.0/operations/apiCalls.js
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.