Skip to content

Commit 354705e

Browse files
committed
feat: Refactor report processing status to use enum and update related components
1 parent 6869a4a commit 354705e

File tree

6 files changed

+32
-12
lines changed

6 files changed

+32
-12
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { RequestWithUser } from '../../auth/auth.middleware';
2525
import { Readable } from 'stream';
2626
import { S3Client, GetObjectCommand } from '@aws-sdk/client-s3';
2727
import { ConfigService } from '@nestjs/config';
28+
import { ProcessingStatus } from '../../reports/models/report.model';
2829

2930
@Controller('document-processor')
3031
export class DocumentProcessorController {
@@ -146,7 +147,7 @@ export class DocumentProcessorController {
146147
// Update the report with analysis results
147148
report.title = result.analysis.title || 'Untitled Report';
148149
report.category = result.analysis.category || 'general';
149-
report.isProcessed = true;
150+
report.processingStatus = ProcessingStatus.PROCESSED;
150151

151152
// Extract lab values
152153
report.labValues = result.analysis.labValues || [];

backend/src/reports/models/report.model.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ export enum ReportStatus {
55
READ = 'READ',
66
}
77

8+
export enum ProcessingStatus {
9+
PROCESSED = 'processed',
10+
UNPROCESSED = 'unprocessed',
11+
IN_PROGRESS = 'in_progress',
12+
}
13+
814
export class Report {
915
@ApiProperty({ description: 'Unique identifier for the report' })
1016
id: string;
@@ -21,8 +27,12 @@ export class Report {
2127
@ApiProperty({ description: 'Category of the report' })
2228
category: string;
2329

24-
@ApiProperty({ description: 'Whether the report has been processed' })
25-
isProcessed: boolean;
30+
@ApiProperty({
31+
description: 'Processing status of the report',
32+
enum: ProcessingStatus,
33+
default: ProcessingStatus.UNPROCESSED,
34+
})
35+
processingStatus: ProcessingStatus;
2636

2737
@ApiProperty({ description: 'List of lab values' })
2838
labValues: Array<{

backend/src/reports/reports.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
QueryCommand,
1616
} from '@aws-sdk/client-dynamodb';
1717
import { marshall, unmarshall } from '@aws-sdk/util-dynamodb';
18-
import { Report, ReportStatus } from './models/report.model';
18+
import { Report, ReportStatus, ProcessingStatus } from './models/report.model';
1919
import { GetReportsQueryDto } from './dto/get-reports.dto';
2020
import { UpdateReportStatusDto } from './dto/update-report-status.dto';
2121
import { v4 as uuidv4 } from 'uuid';
@@ -299,7 +299,7 @@ export class ReportsService {
299299
title: 'New Report',
300300
bookmarked: false,
301301
category: '',
302-
isProcessed: false,
302+
processingStatus: ProcessingStatus.UNPROCESSED,
303303
labValues: [],
304304
summary: '',
305305
status: ReportStatus.UNREAD,

frontend/src/common/api/reportService.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import axios, { AxiosProgressEvent } from 'axios';
2-
import { MedicalReport, ReportCategory, ReportStatus } from '../models/medicalReport';
2+
import { MedicalReport, ReportCategory, ReportStatus, ProcessingStatus } from '../models/medicalReport';
33
import { fetchAuthSession } from '@aws-amplify/auth';
44
// Get the API URL from environment variables
55
const API_URL = import.meta.env.VITE_BASE_URL_API || '';
@@ -12,7 +12,7 @@ const mockReports: MedicalReport[] = [
1212
title: 'Blood Test Report',
1313
category: ReportCategory.GENERAL,
1414
bookmarked: false,
15-
isProcessed: true,
15+
processingStatus: ProcessingStatus.PROCESSED,
1616
labValues: [],
1717
summary: 'Blood test results within normal range',
1818
status: ReportStatus.UNREAD,
@@ -26,7 +26,7 @@ const mockReports: MedicalReport[] = [
2626
title: 'Heart Checkup',
2727
category: ReportCategory.HEART,
2828
bookmarked: true,
29-
isProcessed: true,
29+
processingStatus: ProcessingStatus.PROCESSED,
3030
labValues: [],
3131
summary: 'Heart functioning normally',
3232
status: ReportStatus.READ,

frontend/src/common/models/medicalReport.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,17 @@ export enum ReportCategory {
1515
* Status of a medical report.
1616
*/
1717
export enum ReportStatus {
18+
UNREAD = 'UNREAD',
1819
READ = 'READ',
19-
UNREAD = 'UNREAD'
20+
}
21+
22+
/**
23+
* Processing status of a medical report.
24+
*/
25+
export enum ProcessingStatus {
26+
PROCESSED = 'processed',
27+
UNPROCESSED = 'unprocessed',
28+
IN_PROGRESS = 'in_progress',
2029
}
2130

2231
/**
@@ -42,7 +51,7 @@ export interface MedicalReport {
4251
title: string;
4352
category: ReportCategory | string;
4453
bookmarked: boolean;
45-
isProcessed: boolean;
54+
processingStatus: ProcessingStatus;
4655
labValues: LabValue[];
4756
summary: string;
4857
status: ReportStatus;

frontend/src/pages/Upload/__tests__/UploadPage.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { vi, describe, test, expect, beforeEach } from 'vitest';
22
import { render, screen, fireEvent } from '@testing-library/react';
33
import UploadPage from '../UploadPage';
44
import { MemoryRouter } from 'react-router-dom';
5-
import { MedicalReport, ReportCategory, ReportStatus } from 'common/models/medicalReport';
5+
import { MedicalReport, ReportCategory, ReportStatus, ProcessingStatus } from 'common/models/medicalReport';
66
import '@testing-library/jest-dom';
77

88
// Mock the dependencies
@@ -48,7 +48,7 @@ vi.mock('common/components/Upload/UploadModal', () => {
4848
createdAt: '2023-01-01',
4949
status: ReportStatus.UNREAD,
5050
bookmarked: false,
51-
isProcessed: true,
51+
processingStatus: ProcessingStatus.PROCESSED,
5252
labValues: [],
5353
summary: 'Test report summary',
5454
filePath: '/reports/test-report.pdf',

0 commit comments

Comments
 (0)