Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,10 @@ export class DocumentProcessorController {
// Extract lab values
report.labValues = result.analysis.labValues || [];

report.confidence = result.analysis.metadata.confidence || 0;

// Create summary from simplified explanation or diagnoses
report.summary =
result.simplifiedExplanation ||
result.analysis.diagnoses.map(d => d.condition).join(', ') ||
'No summary available';
report.summary = result.simplifiedExplanation!;

report.updatedAt = new Date().toISOString();

Expand Down
9 changes: 9 additions & 0 deletions backend/src/reports/models/report.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ export class Report {
@ApiProperty({ description: 'Summary of the report' })
summary: string;

@ApiProperty({ description: 'Confidence score of the analysis (0-100)' })
confidence: number;

@ApiProperty({
description: 'Status of the report',
enum: ReportStatus,
Expand All @@ -60,6 +63,12 @@ export class Report {
@ApiProperty({ description: 'File path of the report' })
filePath: string;

@ApiProperty({ description: 'Original filename of the uploaded file' })
originalFilename: string;

@ApiProperty({ description: 'File size in bytes' })
fileSize: number;

@ApiProperty({ description: 'Creation timestamp' })
createdAt: string;

Expand Down
14 changes: 12 additions & 2 deletions backend/src/reports/reports.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,18 +157,28 @@ export class ReportsController {
type: 'string',
description: 'S3 file path for the report',
},
originalFilename: {
type: 'string',
description: 'Original filename of the uploaded file',
},
fileSize: {
type: 'number',
description: 'Size of the file in bytes',
},
},
required: ['filePath'],
},
description: 'S3 file path for the report',
description: 'S3 file path and metadata for the report',
})
@Post()
async createReport(
@Body('filePath') filePath: string,
@Body('originalFilename') originalFilename: string,
@Body('fileSize') fileSize: number,
@Req() request: RequestWithUser,
): Promise<Report> {
const userId = this.extractUserId(request);
return this.reportsService.saveReport(filePath, userId);
return this.reportsService.saveReport(filePath, userId, originalFilename, fileSize);
}

private extractUserId(request: RequestWithUser): string {
Expand Down
18 changes: 17 additions & 1 deletion backend/src/reports/reports.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,20 @@ export class ReportsService {
}
}

async saveReport(filePath: string, userId: string): Promise<Report> {
/**
* Save a new report to DynamoDB
* @param filePath S3 object path of the uploaded file
* @param userId User ID of the report owner
* @param originalFilename Original filename of the uploaded file
* @param fileSize Size of the file in bytes
* @returns The saved report
*/
async saveReport(
filePath: string,
userId: string,
originalFilename: string = 'Unknown filename',
fileSize: number = 0,
): Promise<Report> {
if (!filePath) {
throw new NotFoundException('File URL is required');
}
Expand All @@ -296,12 +309,15 @@ export class ReportsService {
id: uuidv4(),
userId,
filePath,
originalFilename,
fileSize,
title: 'New Report',
bookmarked: false,
category: '',
processingStatus: ProcessingStatus.UNPROCESSED,
labValues: [],
summary: '',
confidence: 0,
status: ReportStatus.UNREAD,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/common/api/reportService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ export const uploadReport = async (
`${API_URL}/api/reports`,
{
filePath: s3Key,
originalFilename: file.name,
fileSize: file.size,
},
config,
);
Expand Down
13 changes: 12 additions & 1 deletion frontend/src/common/components/Icon/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import {
faArrowUpFromBracket,
faHome,
faFileLines as faSolidFileLines,
faFileAlt as faFileText,
faFilePdf,
faUpload,
faComment,
faUserCircle,
Expand All @@ -36,12 +38,14 @@ import {
faChevronUp,
faChevronDown,
faVial,
faLightbulb as faSolidLightbulb,
} from '@fortawesome/free-solid-svg-icons';
import {
faFileLines as faRegularFileLines,
faComment as faRegularComment,
faUser as faRegularUser,
faBookmark as faRegularBookmark,
faLightbulb as faRegularLightbulb,
} from '@fortawesome/free-regular-svg-icons';
import classNames from 'classnames';

Expand All @@ -63,6 +67,8 @@ export type IconName =
| 'comment'
| 'envelope'
| 'fileLines'
| 'fileText'
| 'filePdf'
| 'home'
| 'house'
| 'link'
Expand All @@ -86,7 +92,8 @@ export type IconName =
| 'flask'
| 'chevronUp'
| 'chevronDown'
| 'vial';
| 'vial'
| 'lightbulb';

/**
* Properties for the `Icon` component.
Expand Down Expand Up @@ -114,6 +121,8 @@ const solidIcons: Record<IconName, IconProp> = {
comment: faComment,
envelope: faEnvelope,
fileLines: faSolidFileLines,
fileText: faFileText,
filePdf: faFilePdf,
home: faHome,
house: faHouse,
link: faLink,
Expand All @@ -138,6 +147,7 @@ const solidIcons: Record<IconName, IconProp> = {
chevronUp: faChevronUp,
chevronDown: faChevronDown,
vial: faVial,
lightbulb: faSolidLightbulb,
};

/**
Expand All @@ -150,6 +160,7 @@ const regularIcons: Partial<Record<IconName, IconProp>> = {
user: faRegularUser,
bookmark: faRegularBookmark,
circleXmark: faCircleXmark,
lightbulb: faRegularLightbulb,
};

/**
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/common/components/Router/TabNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import ChatPage from 'pages/Chat/ChatPage';
import UploadPage from 'pages/Upload/UploadPage';
import ReportsListPage from 'pages/Reports/ReportsListPage';
import ReportDetailPage from 'pages/Reports/ReportDetailPage';
import Processing from 'pages/Processing/Processing';
import ProcessingPage from 'pages/Processing/ProcessingPage';

/**
* The `TabNavigation` component provides a router outlet for all of the
Expand Down Expand Up @@ -92,7 +92,7 @@ const TabNavigation = (): JSX.Element => {
<ReportDetailPage />
</Route>
<Route exact path="/tabs/processing">
<Processing />
<ProcessingPage />
</Route>
<Route exact path="/">
<Redirect to="/tabs/home" />
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/common/models/medicalReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export enum ProcessingStatus {
PROCESSED = 'processed',
UNPROCESSED = 'unprocessed',
IN_PROGRESS = 'in_progress',
FAILED = 'failed',
}

/**
Expand Down Expand Up @@ -50,8 +51,11 @@ export interface MedicalReport {
processingStatus: ProcessingStatus;
labValues: LabValue[];
summary: string;
confidence: number;
status: ReportStatus;
filePath: string;
originalFilename: string;
fileSize: number;
createdAt: string; // ISO date string
updatedAt: string; // ISO date string
}
5 changes: 4 additions & 1 deletion frontend/src/common/utils/i18n/resources/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
"required-path": "{{path}} is required. ",
"url": "Must be a URL. "
},
"loading": {
"report": "Loading report..."
},
"no": "no",
"updated": "updated",
"welcome": "Welcome",
Expand All @@ -79,4 +82,4 @@
"title": "AI Assistant"
}
}
}
}
8 changes: 6 additions & 2 deletions frontend/src/common/utils/i18n/resources/en/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@
},
"ai": {
"content_filtered": "I couldn't find an answer. Please try rephrasing your question or consult your healthcare provider."
}
}
},
"loading": {
"report": "Error loading the report. Please try again."
},
"no-report-data": "No report data available."
}
3 changes: 2 additions & 1 deletion frontend/src/common/utils/i18n/resources/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import common from './common.json';
import errors from './errors.json';
import home from './home.json';
import report from './report.json';
import reportDetail from './reportDetail.json';
import user from './user.json';

export default { account, auth, common, errors, home, report, user };
export default { account, auth, common, errors, home, report, reportDetail, user };
114 changes: 57 additions & 57 deletions frontend/src/common/utils/i18n/resources/en/report.json
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
{
"detail": {
"title": "Report Detail",
"loading": "Loading report...",
"errorLoading": "Error loading report. Please try again later.",
"aiInsights": "AI Insights",
"testResults": "Test Results",
"test": "Test",
"results": "Results",
"refRange": "Ref. Range",
"reportDate": "Report Date",
"medicalComments": "Medical Comments",
"hemoglobin": "Hemoglobin",
"ldl": "LDL Cholesterol",
"glucose": "Fasting Blood Glucose",
"alt": "ALT (Liver Enzyme)",
"wbc": "WBC (White Blood Cells)",
"vitaminD": "Vitamin D (25-OH)",
"cholesterol": "Total Cholesterol",
"bookmarkAdded": "Report added to bookmarks",
"bookmarkRemoved": "Report removed from bookmarks",
"aiInsightsContent": "Based on the blood test results, our AI has identified several points of interest that may require attention or further discussion with your healthcare provider.",
"insight1Title": "Hemoglobin Level",
"insight1Content": "Your hemoglobin level is slightly below the reference range. This could indicate mild anemia, which may cause fatigue and weakness.",
"insight2Title": "Cholesterol Levels",
"insight2Content": "Both your LDL cholesterol and total cholesterol are elevated, which may increase your risk for cardiovascular disease.",
"insight3Title": "Blood Glucose",
"insight3Content": "Your fasting blood glucose is elevated, potentially indicating prediabetes. Lifestyle modifications may help improve this value.",
"hemoglobinComment": "The patient's hemoglobin level is 12.5 g/dL, which falls within the lower end of the normal reference range for most adults. While this value may still be considered acceptable, it is important to assess it in the context of the patient's age, sex, clinical symptoms, and medical history.",
"emergencyWarning": "Please contact your doctor or seek emergency care immediately.",
"flaggedValues": "Flagged values",
"highLdl": "High LDL Cholesterol",
"lowHemoglobin": "Low Hemoglobin (10.1 g/dL)",
"conclusion": "Conclusion:",
"suggestions": "Suggestions:",
"ldlConclusion": "Elevated LDL (bad cholesterol) increases your risk of cardiovascular disease",
"ldlSuggestion1": "Consider a heart-healthy diet (e.g., Mediterranean).",
"ldlSuggestion2": "Increase physical activity.",
"ldlSuggestion3": "Discuss statin therapy with your doctor if not already on one.",
"hemoglobinConclusion": "This level suggests anemia, which may cause fatigue and weakness.",
"hemoglobinSuggestion1": "Test for iron, B12, and folate deficiency.",
"hemoglobinSuggestion2": "Consider iron-rich foods or supplements after medical consultation already on one."
},
"list": {
"title": "Reports",
"emptyState": "No reports found",
"uploadPrompt": "Upload a medical report to get started",
"filterAll": "All",
"filterBookmarked": "Bookmarked",
"noBookmarksTitle": "No Bookmarked Reports",
"noBookmarksMessage": "Bookmark reports to find them quickly here",
"sortButton": "Sort reports",
"filterButton": "Filter reports",
"categoryGeneral": "General",
"categoryBrain": "Brain",
"categoryHeart": "Heart"
}
}
"detail": {
"title": "Report Detail",
"loading": "Loading report...",
"errorLoading": "Error loading report. Please try again later.",
"aiInsights": "AI Insights",
"testResults": "Test Results",
"test": "Test",
"results": "Results",
"refRange": "Ref. Range",
"reportDate": "Report Date",
"medicalComments": "Medical Comments",
"hemoglobin": "Hemoglobin",
"ldl": "LDL Cholesterol",
"glucose": "Fasting Blood Glucose",
"alt": "ALT (Liver Enzyme)",
"wbc": "WBC (White Blood Cells)",
"vitaminD": "Vitamin D (25-OH)",
"cholesterol": "Total Cholesterol",
"bookmarkAdded": "Report added to bookmarks",
"bookmarkRemoved": "Report removed from bookmarks",
"aiInsightsContent": "Based on the blood test results, our AI has identified several points of interest that may require attention or further discussion with your healthcare provider.",
"insight1Title": "Hemoglobin Level",
"insight1Content": "Your hemoglobin level is slightly below the reference range. This could indicate mild anemia, which may cause fatigue and weakness.",
"insight2Title": "Cholesterol Levels",
"insight2Content": "Both your LDL cholesterol and total cholesterol are elevated, which may increase your risk for cardiovascular disease.",
"insight3Title": "Blood Glucose",
"insight3Content": "Your fasting blood glucose is elevated, potentially indicating prediabetes. Lifestyle modifications may help improve this value.",
"hemoglobinComment": "The patient's hemoglobin level is 12.5 g/dL, which falls within the lower end of the normal reference range for most adults. While this value may still be considered acceptable, it is important to assess it in the context of the patient's age, sex, clinical symptoms, and medical history.",
"emergencyWarning": "Please contact your doctor or seek emergency care immediately.",
"flaggedValues": "Flagged values",
"highLdl": "High LDL Cholesterol",
"lowHemoglobin": "Low Hemoglobin (10.1 g/dL)",
"conclusion": "Conclusion:",
"suggestions": "Suggestions:",
"ldlConclusion": "Elevated LDL (bad cholesterol) increases your risk of cardiovascular disease",
"ldlSuggestion1": "Consider a heart-healthy diet (e.g., Mediterranean).",
"ldlSuggestion2": "Increase physical activity.",
"ldlSuggestion3": "Discuss statin therapy with your doctor if not already on one.",
"hemoglobinConclusion": "This level suggests anemia, which may cause fatigue and weakness.",
"hemoglobinSuggestion1": "Test for iron, B12, and folate deficiency.",
"hemoglobinSuggestion2": "Consider iron-rich foods or supplements after medical consultation already on one."
},
"list": {
"title": "Reports",
"emptyState": "No reports found",
"uploadPrompt": "Upload a medical report to get started",
"filterAll": "All",
"filterBookmarked": "Bookmarked",
"noBookmarksTitle": "No Bookmarked Reports",
"noBookmarksMessage": "Bookmark reports to find them quickly here",
"sortButton": "Sort reports",
"filterButton": "Filter reports",
"generalCategory": "General",
"brainCategory": "Brain",
"heartCategory": "Heart"
}
}
Loading