Skip to content

Commit 593130c

Browse files
committed
Add ReportMetadata interface and internationalize missing reference ranges message in reports
- Introduced ReportMetadata interface in frontend/src/common/models/medicalReport.ts to encapsulate metadata related to medical reports. - Added internationalized message for missing reference ranges in English, Spanish, and French translation files. - Updated AiAnalysisTab component to display a notice when reference ranges are missing.
1 parent 5d4f922 commit 593130c

File tree

6 files changed

+53
-0
lines changed

6 files changed

+53
-0
lines changed

frontend/src/common/models/medicalReport.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ export interface LabValue {
3939
suggestions: string;
4040
}
4141

42+
/**
43+
* Interface for report metadata.
44+
*/
45+
export interface ReportMetadata {
46+
isMedicalReport: boolean;
47+
confidence: number;
48+
missingInformation: string[];
49+
}
50+
4251
/**
4352
* Interface representing a medical report.
4453
*/
@@ -60,4 +69,5 @@ export interface MedicalReport {
6069
isMedicalReport?: boolean; // Optional flag to indicate if the report is a medical report
6170
createdAt: string; // ISO date string
6271
updatedAt: string; // ISO date string
72+
metadata?: ReportMetadata; // Optional metadata for the report
6373
}

frontend/src/common/utils/i18n/resources/en/reportDetail.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,5 +89,8 @@
8989
"ai-insights": "AI Insights",
9090
"original-report": "Original Report"
9191
}
92+
},
93+
"reports": {
94+
"missingReferenceRanges": "Reference ranges were not available on this report. The analysis may be limited without this information. Please consult with your healthcare provider for a complete interpretation."
9295
}
9396
}

frontend/src/common/utils/i18n/resources/es/report.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,8 @@
6464
"general": "General",
6565
"heart": "Corazón",
6666
"brain": "Cerebro"
67+
},
68+
"reports": {
69+
"missingReferenceRanges": "Los rangos de referencia no estaban disponibles en este informe. El análisis puede ser limitado sin esta información. Por favor, consulte con su proveedor de atención médica para una interpretación completa."
6770
}
6871
}

frontend/src/common/utils/i18n/resources/fr/report.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,8 @@
6464
"general": "Général",
6565
"heart": "Cœur",
6666
"brain": "Cerveau"
67+
},
68+
"reports": {
69+
"missingReferenceRanges": "Les plages de référence n'étaient pas disponibles dans ce rapport. L'analyse peut être limitée sans cette information. Veuillez consulter votre professionnel de la santé pour une interprétation complète."
6770
}
6871
}

frontend/src/pages/Reports/components/AiAnalysisTab.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import EmergencyAlert from './EmergencyAlert';
44
import FlaggedValuesSection from './FlaggedValuesSection';
55
import NormalValuesSection from './NormalValuesSection';
66
import LowConfidenceNotice from './LowConfidenceNotice';
7+
import MissingReferenceRangesNotice from './MissingReferenceRangesNotice';
78

89
interface AiAnalysisTabProps {
910
reportData: MedicalReport;
@@ -35,6 +36,9 @@ const AiAnalysisTab: React.FC<AiAnalysisTabProps> = ({
3536
const confidenceScore = reportData.confidence;
3637

3738
const isLowConfidence = confidenceScore < 0.75;
39+
40+
// Check if reference ranges are missing
41+
const hasReferenceRangesMissing = reportData.metadata?.missingInformation?.includes('reference-ranges-missing');
3842

3943
return (
4044
<div className="ai-analysis-tab">
@@ -43,6 +47,9 @@ const AiAnalysisTab: React.FC<AiAnalysisTabProps> = ({
4347

4448
{/* Low confidence notice */}
4549
{isLowConfidence && <LowConfidenceNotice />}
50+
51+
{/* Missing reference ranges notice */}
52+
{hasReferenceRangesMissing && <MissingReferenceRangesNotice />}
4653

4754
{/* Flagged values section */}
4855
{flaggedValues.length > 0 && (
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from 'react';
2+
import { useTranslation } from 'react-i18next';
3+
import info from '../../../assets/icons/info.svg';
4+
5+
/**
6+
* Component to display a notice when reference ranges are missing from the report
7+
*/
8+
const MissingReferenceRangesNotice: React.FC = () => {
9+
const { t } = useTranslation();
10+
11+
return (
12+
<div className="low-confidence-notice">
13+
<div className="notice-icon">
14+
<img src={info} alt="Information Icon" />
15+
</div>
16+
<div className="notice-text">
17+
{t('reports.missingReferenceRanges', {
18+
ns: 'reportDetail',
19+
defaultValue:
20+
'Reference ranges were not available on this report. The analysis may be limited without this information. Please consult with your healthcare provider for a complete interpretation.',
21+
})}
22+
</div>
23+
</div>
24+
);
25+
};
26+
27+
export default MissingReferenceRangesNotice;

0 commit comments

Comments
 (0)