Skip to content

Commit 5101128

Browse files
committed
refactor: Remove 'keyMedicalTerms' from MedicalDocumentAnalysis and related tests for simplification
1 parent 924fbb2 commit 5101128

File tree

6 files changed

+8
-37
lines changed

6 files changed

+8
-37
lines changed

backend/src/app.module.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ describe('AppModule', () => {
4949
.useValue({
5050
generateResponse: vi.fn().mockResolvedValue('test response'),
5151
analyzeMedicalDocument: vi.fn().mockResolvedValue({
52-
keyMedicalTerms: [],
5352
labValues: [],
5453
diagnoses: [],
5554
metadata: {

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

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ vi.mock('@aws-sdk/client-bedrock-runtime', () => {
6767
text: JSON.stringify({
6868
title: 'Blood Test Results',
6969
category: 'general',
70-
keyMedicalTerms: [
71-
{ term: 'RBC', definition: 'Red Blood Cells' },
72-
{ term: 'WBC', definition: 'White Blood Cells' },
73-
],
7470
labValues: [
7571
{
7672
name: 'Hemoglobin',
@@ -133,10 +129,6 @@ describe('AwsBedrockService', () => {
133129
const mockMedicalAnalysis: MedicalDocumentAnalysis = {
134130
title: 'Blood Test Results',
135131
category: 'general',
136-
keyMedicalTerms: [
137-
{ term: 'RBC', definition: 'Red Blood Cells' },
138-
{ term: 'WBC', definition: 'White Blood Cells' },
139-
],
140132
labValues: [
141133
{
142134
name: 'Hemoglobin',
@@ -299,10 +291,8 @@ describe('AwsBedrockService', () => {
299291
const invalidResponses = [
300292
null,
301293
{},
302-
{ keyMedicalTerms: 'not an array' },
303-
{ keyMedicalTerms: [], labValues: [], diagnoses: [] }, // Missing metadata
294+
{ labValues: [], diagnoses: [] }, // Missing metadata
304295
{
305-
keyMedicalTerms: [],
306296
labValues: [],
307297
diagnoses: [],
308298
metadata: { isMedicalReport: 'not a boolean', confidence: 0.5, missingInformation: [] },
@@ -320,7 +310,6 @@ describe('AwsBedrockService', () => {
320310
const validResponse: MedicalDocumentAnalysis = {
321311
title: 'Test Report',
322312
category: 'general',
323-
keyMedicalTerms: [],
324313
labValues: [],
325314
diagnoses: [],
326315
metadata: {

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

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { createHash } from 'crypto';
1414
export interface MedicalDocumentAnalysis {
1515
title: string;
1616
category: string;
17-
keyMedicalTerms: Array<{ term: string; definition: string }>;
1817
labValues: Array<{
1918
name: string;
2019
value: string;
@@ -50,18 +49,16 @@ export class AwsBedrockService {
5049
Look for and extract the following information:
5150
1. Document title or main subject based on content
5251
2. Document category based on organ system focus
53-
3. Key medical terms visible in the document with their definitions
54-
4. Lab test values with their normal ranges and whether they are normal, high, or low (particularly important for blood work, metabolic panels, etc.)
55-
5. Any diagnoses, findings, or medical observations with details and recommendations
56-
6. Analyze if this is a medical document (lab report, test result, medical chart, prescription, etc.) and provide confidence level
52+
3. Lab test values with their normal ranges and whether they are normal, high, or low (particularly important for blood work, metabolic panels, etc.)
53+
4. Any diagnoses, findings, or medical observations with details and recommendations
54+
5. Analyze if this is a medical document (lab report, test result, medical chart, prescription, etc.) and provide confidence level
5755
5856
This document may be a lab report showing blood work or other test results, so please pay special attention to tables, numeric values, reference ranges, and medical terminology.
5957
6058
Format the response as a JSON object with the following structure:
6159
{
6260
"title": string,
6361
"category": string,
64-
"keyMedicalTerms": [{"term": string, "definition": string}],
6562
"labValues": [{"name": string, "value": string, "unit": string, "normalRange": string, "status": "normal" | "high" | "low", "conclusion": string, "suggestions": string}],
6663
"diagnoses": [{"condition": string, "details": string, "recommendations": string}],
6764
"metadata": {
@@ -116,16 +113,16 @@ INCORRECT RESPONSE FORMATS (DO NOT DO THESE):
116113
"This appears to be a medical report. Here is the information extracted in the requested JSON format:
117114
118115
{
119-
\"keyMedicalTerms\": [...],
116+
\"category\": \"heart\",
120117
...
121118
}"
122119
123120
2) DO NOT DO THIS - Nested JSON:
124121
{
125-
"keyMedicalTerms": [
122+
"labValues": [
126123
{
127-
"term": "Here is the information extracted",
128-
"definition": "{\"keyMedicalTerms\": [{\"term\": \"RBC\", \"definition\": \"Red blood cells\"}]}"
124+
"name": "Here is the information extracted",
125+
"value": "{\"labValues\": [{\"name\": \"RBC\", \"value\": \"14.2\"}]}"
129126
}
130127
]
131128
}
@@ -134,10 +131,6 @@ CORRECT FORMAT (DO THIS):
134131
{
135132
"title": "Complete Blood Count Results",
136133
"category": "heart",
137-
"keyMedicalTerms": [
138-
{"term": "RBC", "definition": "Red blood cells"},
139-
{"term": "WBC", "definition": "White blood cells"}
140-
],
141134
"labValues": [
142135
{
143136
"name": "Hemoglobin",
@@ -432,7 +425,6 @@ Document text:
432425
!response ||
433426
typeof response.title !== 'string' ||
434427
typeof response.category !== 'string' ||
435-
!Array.isArray(response.keyMedicalTerms) ||
436428
!Array.isArray(response.labValues) ||
437429
!Array.isArray(response.diagnoses) ||
438430
!response.metadata

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ describe('DocumentProcessorService', () => {
3636
const medicalAnalysis = {
3737
title: 'Test Report',
3838
category: 'general',
39-
keyMedicalTerms: [],
4039
labValues: [],
4140
diagnoses: [],
4241
metadata: {
@@ -148,7 +147,6 @@ describe('DocumentProcessorService', () => {
148147
analysis: {
149148
title: 'Document 1 Report',
150149
category: 'general',
151-
keyMedicalTerms: [],
152150
labValues: [],
153151
diagnoses: [],
154152
metadata: {
@@ -174,7 +172,6 @@ describe('DocumentProcessorService', () => {
174172
analysis: {
175173
title: 'Document 2 Report',
176174
category: 'general',
177-
keyMedicalTerms: [],
178175
labValues: [],
179176
diagnoses: [],
180177
metadata: {

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ export class DocumentProcessorService {
8484
this.logger.log(`Document processing completed in ${processingTime}ms`, {
8585
isMedicalReport: analysis.metadata.isMedicalReport,
8686
confidence: analysis.metadata.confidence,
87-
keyTermCount: analysis.keyMedicalTerms.length,
8887
labValueCount: analysis.labValues.length,
8988
hasExplanation: !!simplifiedExplanation,
9089
});
@@ -156,7 +155,6 @@ export class DocumentProcessorService {
156155
analysis: {
157156
title: 'Failed Document',
158157
category: 'general',
159-
keyMedicalTerms: [],
160158
labValues: [],
161159
diagnoses: [],
162160
metadata: {

backend/src/services/README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ The structured medical information from Bedrock:
5959

6060
```typescript
6161
export interface MedicalDocumentAnalysis {
62-
keyMedicalTerms: Array<{ term: string; definition: string }>;
6362
labValues: Array<{
6463
name: string;
6564
value: string;
@@ -111,9 +110,6 @@ curl -X POST \
111110
]
112111
},
113112
"analysis": {
114-
"keyMedicalTerms": [
115-
{ "term": "Hemoglobin", "definition": "Oxygen-carrying protein in red blood cells" }
116-
],
117113
"labValues": [
118114
{
119115
"name": "Hemoglobin",

0 commit comments

Comments
 (0)