Skip to content

Commit 6833cde

Browse files
committed
feat: Add 'isCritical' field to MedicalDocumentAnalysis and Report models for enhanced lab value analysis
1 parent 5101128 commit 6833cde

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

backend/src/document-processor/services/aws-bedrock.service.spec.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ vi.mock('@aws-sdk/client-bedrock-runtime', () => {
7474
unit: 'g/dL',
7575
normalRange: '13.5-17.5',
7676
status: 'normal',
77+
isCritical: false,
7778
conclusion:
7879
'Normal hemoglobin levels indicate adequate oxygen-carrying capacity.',
7980
suggestions: 'Continue regular health maintenance.',
@@ -136,6 +137,7 @@ describe('AwsBedrockService', () => {
136137
unit: 'g/dL',
137138
normalRange: '13.5-17.5',
138139
status: 'normal',
140+
isCritical: false,
139141
conclusion: 'Normal hemoglobin levels indicate adequate oxygen-carrying capacity.',
140142
suggestions: 'Continue regular health maintenance.',
141143
},
@@ -310,7 +312,19 @@ describe('AwsBedrockService', () => {
310312
const validResponse: MedicalDocumentAnalysis = {
311313
title: 'Test Report',
312314
category: 'general',
313-
labValues: [],
315+
labValues: [
316+
// Adding an empty lab value with required properties
317+
{
318+
name: 'Sample Test',
319+
value: '0',
320+
unit: 'units',
321+
normalRange: '0-1',
322+
status: 'normal',
323+
isCritical: false,
324+
conclusion: 'Normal test result',
325+
suggestions: 'No action needed',
326+
},
327+
],
314328
diagnoses: [],
315329
metadata: {
316330
isMedicalReport: true,

backend/src/document-processor/services/aws-bedrock.service.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export interface MedicalDocumentAnalysis {
2020
unit: string;
2121
normalRange: string;
2222
status: 'normal' | 'high' | 'low';
23+
isCritical: boolean;
2324
conclusion: string;
2425
suggestions: string;
2526
}>;
@@ -59,7 +60,7 @@ Format the response as a JSON object with the following structure:
5960
{
6061
"title": string,
6162
"category": string,
62-
"labValues": [{"name": string, "value": string, "unit": string, "normalRange": string, "status": "normal" | "high" | "low", "conclusion": string, "suggestions": string}],
63+
"labValues": [{"name": string, "value": string, "unit": string, "normalRange": string, "status": "normal" | "high" | "low", "isCritical": boolean, "conclusion": string, "suggestions": string}],
6364
"diagnoses": [{"condition": string, "details": string, "recommendations": string}],
6465
"metadata": {
6566
"isMedicalReport": boolean,
@@ -84,8 +85,9 @@ When extracting lab values:
8485
1. Look for tables with numeric values and reference ranges
8586
2. Include any values even if you're not sure of the meaning
8687
3. For each lab value, use "status" field with values "normal", "high", or "low" based on whether the value falls within, above, or below the normal range
87-
4. Include a "conclusion" field that provides a brief interpretation of what this value indicates about the patient's health
88-
5. Include a "suggestions" field that provides brief recommendations based on this value
88+
4. Set "isCritical" to true when the value indicates an urgent medical situation. Set it to false for values that are normal or only slightly abnormal.
89+
5. Include a "conclusion" field that provides a brief interpretation of what this value indicates about the patient's health
90+
6. Include a "suggestions" field that provides brief recommendations based on this value
8991
9092
EXTREMELY IMPORTANT FORMATTING INSTRUCTIONS:
9193
1. ABSOLUTELY DO NOT START YOUR RESPONSE WITH ANY TEXT. Begin immediately with the JSON object.
@@ -138,6 +140,7 @@ CORRECT FORMAT (DO THIS):
138140
"unit": "g/dL",
139141
"normalRange": "13.5-17.5",
140142
"status": "normal",
143+
"isCritical": false,
141144
"conclusion": "Normal hemoglobin levels indicate adequate oxygen-carrying capacity.",
142145
"suggestions": "Continue regular health maintenance."
143146
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export class Report {
3131
unit: string;
3232
normalRange: string;
3333
status: 'normal' | 'high' | 'low';
34+
isCritical: boolean;
3435
conclusion: string;
3536
suggestions: string;
3637
}>;

0 commit comments

Comments
 (0)