From 593130c31c9809bbea2f378181a04c484e78c6a4 Mon Sep 17 00:00:00 2001 From: Adam Refaey Date: Fri, 25 Apr 2025 19:01:00 +0300 Subject: [PATCH] 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. --- frontend/src/common/models/medicalReport.ts | 10 +++++++ .../utils/i18n/resources/en/reportDetail.json | 3 +++ .../utils/i18n/resources/es/report.json | 3 +++ .../utils/i18n/resources/fr/report.json | 3 +++ .../Reports/components/AiAnalysisTab.tsx | 7 +++++ .../MissingReferenceRangesNotice.tsx | 27 +++++++++++++++++++ 6 files changed, 53 insertions(+) create mode 100644 frontend/src/pages/Reports/components/MissingReferenceRangesNotice.tsx diff --git a/frontend/src/common/models/medicalReport.ts b/frontend/src/common/models/medicalReport.ts index a175338d..31f12e35 100644 --- a/frontend/src/common/models/medicalReport.ts +++ b/frontend/src/common/models/medicalReport.ts @@ -39,6 +39,15 @@ export interface LabValue { suggestions: string; } +/** + * Interface for report metadata. + */ +export interface ReportMetadata { + isMedicalReport: boolean; + confidence: number; + missingInformation: string[]; +} + /** * Interface representing a medical report. */ @@ -60,4 +69,5 @@ export interface MedicalReport { isMedicalReport?: boolean; // Optional flag to indicate if the report is a medical report createdAt: string; // ISO date string updatedAt: string; // ISO date string + metadata?: ReportMetadata; // Optional metadata for the report } diff --git a/frontend/src/common/utils/i18n/resources/en/reportDetail.json b/frontend/src/common/utils/i18n/resources/en/reportDetail.json index c26a6444..04d559e5 100644 --- a/frontend/src/common/utils/i18n/resources/en/reportDetail.json +++ b/frontend/src/common/utils/i18n/resources/en/reportDetail.json @@ -89,5 +89,8 @@ "ai-insights": "AI Insights", "original-report": "Original Report" } + }, + "reports": { + "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." } } diff --git a/frontend/src/common/utils/i18n/resources/es/report.json b/frontend/src/common/utils/i18n/resources/es/report.json index c2dc29b8..a46e17a1 100644 --- a/frontend/src/common/utils/i18n/resources/es/report.json +++ b/frontend/src/common/utils/i18n/resources/es/report.json @@ -64,5 +64,8 @@ "general": "General", "heart": "Corazón", "brain": "Cerebro" + }, + "reports": { + "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." } } diff --git a/frontend/src/common/utils/i18n/resources/fr/report.json b/frontend/src/common/utils/i18n/resources/fr/report.json index 1e034d34..fb970cd8 100644 --- a/frontend/src/common/utils/i18n/resources/fr/report.json +++ b/frontend/src/common/utils/i18n/resources/fr/report.json @@ -64,5 +64,8 @@ "general": "Général", "heart": "Cœur", "brain": "Cerveau" + }, + "reports": { + "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." } } diff --git a/frontend/src/pages/Reports/components/AiAnalysisTab.tsx b/frontend/src/pages/Reports/components/AiAnalysisTab.tsx index fe6217cc..3668fd02 100644 --- a/frontend/src/pages/Reports/components/AiAnalysisTab.tsx +++ b/frontend/src/pages/Reports/components/AiAnalysisTab.tsx @@ -4,6 +4,7 @@ import EmergencyAlert from './EmergencyAlert'; import FlaggedValuesSection from './FlaggedValuesSection'; import NormalValuesSection from './NormalValuesSection'; import LowConfidenceNotice from './LowConfidenceNotice'; +import MissingReferenceRangesNotice from './MissingReferenceRangesNotice'; interface AiAnalysisTabProps { reportData: MedicalReport; @@ -35,6 +36,9 @@ const AiAnalysisTab: React.FC = ({ const confidenceScore = reportData.confidence; const isLowConfidence = confidenceScore < 0.75; + + // Check if reference ranges are missing + const hasReferenceRangesMissing = reportData.metadata?.missingInformation?.includes('reference-ranges-missing'); return (
@@ -43,6 +47,9 @@ const AiAnalysisTab: React.FC = ({ {/* Low confidence notice */} {isLowConfidence && } + + {/* Missing reference ranges notice */} + {hasReferenceRangesMissing && } {/* Flagged values section */} {flaggedValues.length > 0 && ( diff --git a/frontend/src/pages/Reports/components/MissingReferenceRangesNotice.tsx b/frontend/src/pages/Reports/components/MissingReferenceRangesNotice.tsx new file mode 100644 index 00000000..ecc1a60a --- /dev/null +++ b/frontend/src/pages/Reports/components/MissingReferenceRangesNotice.tsx @@ -0,0 +1,27 @@ +import React from 'react'; +import { useTranslation } from 'react-i18next'; +import info from '../../../assets/icons/info.svg'; + +/** + * Component to display a notice when reference ranges are missing from the report + */ +const MissingReferenceRangesNotice: React.FC = () => { + const { t } = useTranslation(); + + return ( +
+
+ Information Icon +
+
+ {t('reports.missingReferenceRanges', { + ns: 'reportDetail', + defaultValue: + '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.', + })} +
+
+ ); +}; + +export default MissingReferenceRangesNotice; \ No newline at end of file