-
Notifications
You must be signed in to change notification settings - Fork 0
[ADE-66] process reports asynchronously #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…and add report status checking
There was a problem hiding this 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 |
backend/src/document-processor/controllers/document-processor.controller.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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
There was a problem hiding this 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)
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
filePathwithreportIdfor identifying reports, introducing aProcessingStatusenum for better status management, and implementing a new API endpoint for checking report processing status.Backend Changes
Asynchronous Processing Workflow
DocumentProcessorController. Added aprocessReportAsyncmethod 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))ProcessingStatusenum (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
GET /report-status/:reportIdendpoint 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))reportIdinstead offilePathfor 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
findByFilePathmethod fromReportsServiceand replaced its usage withfindOnefor 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
Processingpage to poll the newGET /report-status/:reportIdendpoint 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))filePathwithreportIdin the state and navigation logic across components, including theUploadModalandProcessingpage. ([[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
isProcessedboolean field with theprocessingStatusenum in theMedicalReportinterface 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
{...}