Skip to content

Conversation

@adamrefaey
Copy link
Collaborator

@adamrefaey adamrefaey commented Apr 17, 2025

Change

This pull request introduces significant changes to the document processing feature, including a new asynchronous processing workflow, enhanced status tracking, and updates to both the backend and frontend to support these improvements. The primary focus is on replacing filePath with reportId for identifying reports, introducing a ProcessingStatus enum for better status management, and implementing a new API endpoint for checking report processing status.

Backend Changes

Asynchronous Processing Workflow

  • Replaced synchronous processing logic with an asynchronous workflow in DocumentProcessorController. Added a processReportAsync method to handle background processing and update the report status accordingly. ([[1]](https://github.com/ModusCreateOrg/app-med-ai-gen/pull/83/files#diff-d447fd4ea0593ae5a76e621fc7bce2d97e41ec8981273a5c1db2ae765d303157L117-R123), [[2]](https://github.com/ModusCreateOrg/app-med-ai-gen/pull/83/files#diff-d447fd4ea0593ae5a76e621fc7bce2d97e41ec8981273a5c1db2ae765d303157L131-R199), [[3]](https://github.com/ModusCreateOrg/app-med-ai-gen/pull/83/files#diff-d447fd4ea0593ae5a76e621fc7bce2d97e41ec8981273a5c1db2ae765d303157L165-R234))
  • Introduced a new ProcessingStatus enum (PROCESSED, UNPROCESSED, IN_PROGRESS, FAILED) to track the processing lifecycle of reports. ([[1]](https://github.com/ModusCreateOrg/app-med-ai-gen/pull/83/files#diff-6f31e7a7ef0fedc1f210f18e9bb6d163faeda4f13d64f20ef5b32638a0161cc5R8-R14), [[2]](https://github.com/ModusCreateOrg/app-med-ai-gen/pull/83/files#diff-6f31e7a7ef0fedc1f210f18e9bb6d163faeda4f13d64f20ef5b32638a0161cc5L24-R36), [[3]](https://github.com/ModusCreateOrg/app-med-ai-gen/pull/83/files#diff-bddee7786693003544778b34e29ed93924a2b6bb0355f19c9488cb0520775022L18-R18), [[4]](https://github.com/ModusCreateOrg/app-med-ai-gen/pull/83/files#diff-bddee7786693003544778b34e29ed93924a2b6bb0355f19c9488cb0520775022L302-R302))

API Enhancements

  • Added a new GET /report-status/:reportId endpoint to fetch the current processing status of a report. ([backend/src/document-processor/controllers/document-processor.controller.tsR672-R706](https://github.com/ModusCreateOrg/app-med-ai-gen/pull/83/files#diff-d447fd4ea0593ae5a76e621fc7bce2d97e41ec8981273a5c1db2ae765d303157R672-R706))
  • Updated existing endpoints to use reportId instead of filePath for identifying reports. ([[1]](https://github.com/ModusCreateOrg/app-med-ai-gen/pull/83/files#diff-d447fd4ea0593ae5a76e621fc7bce2d97e41ec8981273a5c1db2ae765d303157L41-R42), [[2]](https://github.com/ModusCreateOrg/app-med-ai-gen/pull/83/files#diff-d447fd4ea0593ae5a76e621fc7bce2d97e41ec8981273a5c1db2ae765d303157L117-R123))

Simplification and Cleanup

  • Removed the findByFilePath method from ReportsService and replaced its usage with findOne for fetching reports by ID. ([backend/src/reports/reports.service.tsL336-L435](https://github.com/ModusCreateOrg/app-med-ai-gen/pull/83/files#diff-bddee7786693003544778b34e29ed93924a2b6bb0355f19c9488cb0520775022L336-L435))

Frontend Changes

Status Tracking and Navigation

  • Updated the Processing page to poll the new GET /report-status/:reportId endpoint every 5 seconds to check the processing status. Redirects to the report detail page when processing is complete. ([[1]](https://github.com/ModusCreateOrg/app-med-ai-gen/pull/83/files#diff-d44d21544843f462db7189b68e1d21d830c619226b21d4feddafe6676e4a2e5aR24-R79), [[2]](https://github.com/ModusCreateOrg/app-med-ai-gen/pull/83/files#diff-d44d21544843f462db7189b68e1d21d830c619226b21d4feddafe6676e4a2e5aL50-R100))
  • Replaced filePath with reportId in the state and navigation logic across components, including the UploadModal and Processing page. ([[1]](https://github.com/ModusCreateOrg/app-med-ai-gen/pull/83/files#diff-63c8e35f84c023e1f96c46e1fcea7cec405b3bac44dbe912cc7e72d74326cce4L66-R69), [[2]](https://github.com/ModusCreateOrg/app-med-ai-gen/pull/83/files#diff-d44d21544843f462db7189b68e1d21d830c619226b21d4feddafe6676e4a2e5aR24-R79))

Model Updates

  • Replaced the isProcessed boolean field with the processingStatus enum in the MedicalReport interface for better status representation. ([[1]](https://github.com/ModusCreateOrg/app-med-ai-gen/pull/83/files#diff-10a5dbd3286548c3f0864cbf77a14808ac6192fcc050f285818d883c76614cb6L45-R54), [[2]](https://github.com/ModusCreateOrg/app-med-ai-gen/pull/83/files#diff-83c804b1de0db6fac4836f5932b3b3a78ef14b0f8d535b4172cdaec436c6fd24L15-R15), [[3]](https://github.com/ModusCreateOrg/app-med-ai-gen/pull/83/files#diff-83c804b1de0db6fac4836f5932b3b3a78ef14b0f8d535b4172cdaec436c6fd24L29-R29))

These changes collectively enhance the system's scalability, improve user experience with real-time status updates, and simplify the backend logic by consolidating report identification and status tracking.

Does this PR introduce a breaking change?

{...}

What needs to be documented once your changes are merged?

{...}

Additional Comments

{...}

@adamrefaey adamrefaey self-assigned this Apr 17, 2025
@adamrefaey adamrefaey requested review from GuidoBR and Copilot and removed request for Copilot April 18, 2025 08:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR transitions the document processing workflow from a file-path-based system to a report-ID-based system and adds asynchronous processing with status tracking. Key changes include:

  • Replacing filePath with reportId in both backend and frontend components.
  • Introducing a new ProcessingStatus enum to manage processing states.
  • Adding a new endpoint for fetching report processing status.

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
frontend/src/pages/Upload/tests/UploadPage.test.tsx Updated import and mock data to use ProcessingStatus instead of isProcessed
frontend/src/pages/Processing/Processing.tsx Replaced filePath with reportId and added periodic status checks with interval cleanup
frontend/src/common/models/medicalReport.ts Updated the report model to include ProcessingStatus
frontend/src/common/components/Upload/UploadModal.tsx Changed navigation to pass reportId instead of filePath
frontend/src/common/api/reportService.ts Updated mock report data and imports to use ProcessingStatus
backend/src/reports/reports.service.ts Updated report initialization to use processingStatus instead of isProcessed
backend/src/reports/models/report.model.ts Added ProcessingStatus enum and replaced isProcessed with processingStatus
backend/src/iac/backend-stack.ts Removed unused timeout configuration
backend/src/document-processor/controllers/document-processor.controller.ts Renamed and updated processing endpoints to use reportId and handle async processing

@adamrefaey adamrefaey requested a review from Copilot April 18, 2025 08:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the document processing workflow to use a report-ID-based system with asynchronous processing and a new ProcessingStatus enum, replacing the legacy file-path approach. Key changes include:

  • Backend updates to process reports asynchronously, update processing status, and expose a new status endpoint.
  • Frontend modifications to use reportId (instead of filePath) in navigation, polling for report status, and test/mock updates.
  • Miscellaneous cleanup such as removal of an unused API Gateway timeout configuration.

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
frontend/src/pages/Upload/tests/UploadPage.test.tsx Updated test fixture to expect processingStatus instead of isProcessed.
frontend/src/pages/Processing/Processing.tsx Replaced filePath with reportId, added interval cleanup, and status checks for async processing.
frontend/src/common/models/medicalReport.ts Removed isProcessed and added ProcessingStatus enum.
frontend/src/common/components/Upload/UploadModal.tsx Updated navigation state from filePath to reportId.
frontend/src/common/api/reportService.ts Updated mock reports to use processingStatus instead of isProcessed.
backend/src/reports/reports.service.ts Adjusted report creation logic to use processingStatus.
backend/src/reports/models/report.model.ts Added ProcessingStatus enum and replaced isProcessed with processingStatus.
backend/src/iac/backend-stack.ts Removed unused timeout configuration.
backend/src/document-processor/controllers/document-processor.controller.ts Refactored processing endpoints to use reportId, updated status handling, and added new report status retrieval endpoint.
Comments suppressed due to low confidence (1)

backend/src/document-processor/controllers/document-processor.controller.ts:221

  • [nitpick] Consider introducing a distinct FAILED processing status in the ProcessingStatus enum to clearly represent asynchronous processing failures instead of reusing UNPROCESSED.
report.processingStatus = ProcessingStatus.UNPROCESSED; // Could add a FAILED status in the enum if needed

@adamrefaey adamrefaey requested a review from Copilot April 18, 2025 08:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements asynchronous processing for medical reports by replacing the filePath-based workflow with a reportId-driven flow and a new processingStatus management. Key changes include:

  • Migrating from synchronous to asynchronous report processing with enhanced status tracking using a new ProcessingStatus enum.
  • Updating API endpoints, frontend components, and tests to replace filePath with reportId.
  • Removing legacy methods (e.g., findByFilePath) and cleaning up integration configurations.

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
frontend/src/pages/Upload/tests/UploadPage.test.tsx Updated test mocks to use processingStatus instead of isProcessed.
frontend/src/pages/Processing/Processing.tsx Revised state and polling logic to work with reportId and status checks.
frontend/src/common/models/medicalReport.ts Updated MedicalReport interface and enums to reflect processingStatus.
frontend/src/common/components/Upload/UploadModal.tsx Transitioned from filePath to reportId in routing logic.
frontend/src/common/api/reportService.ts Modified mock report data to use processingStatus.
backend/src/reports/reports.service.ts Removed the legacy findByFilePath method and updated default report data.
backend/src/reports/models/report.model.ts Added ProcessingStatus to report model and replaced isProcessed field.
backend/src/iac/backend-stack.ts Removed timeout configuration from API integration options.
backend/src/document-processor/controllers/document-processor.controller.ts Updated endpoints and processing methods to use reportId and processingStatus.
Comments suppressed due to low confidence (1)

backend/src/iac/backend-stack.ts:407

  • The removal of the 5-minute timeout from the integration options might lead to unintended behavior under heavy load. Please verify that this change is intentional or add an alternative timeout configuration if needed.
timeout: cdk.Duration.seconds(300), // Adding 5-minute timeout (300 seconds)

@GuidoBR GuidoBR merged commit af2fd2f into main Apr 18, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants