sujataprakashdatycs commited on
Commit
6b0ff68
·
verified ·
1 Parent(s): 722bccb

Update chartdiagnosischecker.py

Browse files
Files changed (1) hide show
  1. chartdiagnosischecker.py +12 -5
chartdiagnosischecker.py CHANGED
@@ -12,6 +12,7 @@ from langchain.text_splitter import RecursiveCharacterTextSplitter
12
  from langchain_community.vectorstores import Chroma
13
  from embedding_manager import DirectoryEmbeddingManager
14
 
 
15
  class ChartDiagnosisChecker:
16
  def __init__(self, pdf_dir: str, model: str = "gpt-4o"):
17
  self.embed_manager = DirectoryEmbeddingManager(pdf_dir)
@@ -43,10 +44,12 @@ class ChartDiagnosisChecker:
43
  f"Diagnosis to validate: {diagnosis} (ICD-10: {icd10})\n\n"
44
  f"Reference: {ref}\n\n"
45
  f"Patient chart excerpts:\n{context}\n\n"
46
- f"Does the patient have {diagnosis} or anything related to this diagnosis"
47
  "Answer Yes or No, with a short justification using ONLY the provided chart text.\n"
 
 
48
  "Output must be valid JSON in the form:\n"
49
- "{'answer': 'yes/no', 'rationale': 'one-line rationale'}"
50
  ),
51
  expected_output="JSON with keys answer and rationale",
52
  agent=self.agent,
@@ -62,8 +65,10 @@ class ChartDiagnosisChecker:
62
  "diagnosis": diagnosis,
63
  "icd10": icd10,
64
  "reference": ref,
65
- "answer": result.get("answer", "unknown"),
66
- "rationale": result.get("rationale", ""),
 
 
67
  "context": context
68
  }
69
 
@@ -75,4 +80,6 @@ class ChartDiagnosisChecker:
75
  result = self.check_one(entry)
76
  results.append(result)
77
  print(f"[ANSWER] {result}")
78
- return results
 
 
 
12
  from langchain_community.vectorstores import Chroma
13
  from embedding_manager import DirectoryEmbeddingManager
14
 
15
+ # ---------- Chart Checker ----------
16
  class ChartDiagnosisChecker:
17
  def __init__(self, pdf_dir: str, model: str = "gpt-4o"):
18
  self.embed_manager = DirectoryEmbeddingManager(pdf_dir)
 
44
  f"Diagnosis to validate: {diagnosis} (ICD-10: {icd10})\n\n"
45
  f"Reference: {ref}\n\n"
46
  f"Patient chart excerpts:\n{context}\n\n"
47
+ f"Does the patient have {diagnosis} from the patient contexts provided"
48
  "Answer Yes or No, with a short justification using ONLY the provided chart text.\n"
49
+ "Also check whether the diagnois can be inferred implicitly like by the medication taken by patient"
50
+ "or any other means. Compare the drugs and tests done by the patient with those required for the diagnosis"
51
  "Output must be valid JSON in the form:\n"
52
+ "{'answer_explicit': 'yes/no', 'rationale_explicit': 'one-line rationale', answer_implicit': 'yes/no', 'rationale_implicit': 'one-line rationale'}"
53
  ),
54
  expected_output="JSON with keys answer and rationale",
55
  agent=self.agent,
 
65
  "diagnosis": diagnosis,
66
  "icd10": icd10,
67
  "reference": ref,
68
+ "answer_explicit": result.get("answer_explicit", "unknown"),
69
+ "rationale_explicit": result.get("rationale_explicit", ""),
70
+ "answer_implicit": result.get("answer_implicit", "unknown"),
71
+ "rationale_implicit": result.get("rationale_implicit", ""),
72
  "context": context
73
  }
74
 
 
80
  result = self.check_one(entry)
81
  results.append(result)
82
  print(f"[ANSWER] {result}")
83
+ return results
84
+
85
+