sujataprakashdatycs commited on
Commit
eb7971a
·
verified ·
1 Parent(s): a997108

Update PatientInfoExtractionEngine.py

Browse files
Files changed (1) hide show
  1. PatientInfoExtractionEngine.py +5 -3
PatientInfoExtractionEngine.py CHANGED
@@ -16,7 +16,7 @@ class PatientInfoExtractionEngine:
16
  """
17
  def __init__(self, pdf_dir: str):
18
  self.embed_manager = DirectoryEmbeddingManager(pdf_dir)
19
- self.llm = ChatOpenAI(model=os.environ.get("OPENAI_MODEL_NAME", "gpt-4-turbo"), temperature=0)
20
 
21
  @tool("patient_chart_search")
22
  def patient_chart_search(query: str) -> str:
@@ -59,7 +59,7 @@ class PatientInfoExtractionEngine:
59
  "Extract patient demographics from the patient chart. "
60
  "All patient demographic information is usually located together in one section "
61
  "(for example, at the beginning or in a 'Patient Information' block). "
62
- "Extract details only from that section do NOT search or aggregate information "
63
  "from multiple parts of the chart.\n\n"
64
  "Fields to extract:\n"
65
  "- name\n"
@@ -81,7 +81,9 @@ class PatientInfoExtractionEngine:
81
  "}\n\n"
82
  "Rules:\n"
83
  "- Extract data only from the section where all patient demographic information is grouped together.\n"
84
- "- Do not collect or merge values scattered across different notes or sections.\n"
 
 
85
  "- Only include values explicitly mentioned in the chart.\n"
86
  "- If a value is missing or not mentioned, leave it as an empty string.\n"
87
  "- Do not hallucinate, infer, or guess missing details."
 
16
  """
17
  def __init__(self, pdf_dir: str):
18
  self.embed_manager = DirectoryEmbeddingManager(pdf_dir)
19
+ self.llm = ChatOpenAI(model=os.environ.get("OPENAI_MODEL_NAME", "gpt-4o"), temperature=0)
20
 
21
  @tool("patient_chart_search")
22
  def patient_chart_search(query: str) -> str:
 
59
  "Extract patient demographics from the patient chart. "
60
  "All patient demographic information is usually located together in one section "
61
  "(for example, at the beginning or in a 'Patient Information' block). "
62
+ "Patient demographics may appear in different nearby sections, such as 'Patient Information', 'Reason for Visit', or 'History of Present Illness'. You may extract all demographics from these closely related sections."
63
  "from multiple parts of the chart.\n\n"
64
  "Fields to extract:\n"
65
  "- name\n"
 
81
  "}\n\n"
82
  "Rules:\n"
83
  "- Extract data only from the section where all patient demographic information is grouped together.\n"
84
+ "- You may extract values like gender, age, or DOB even if they appear within sentences (e.g., 'This 66-year-old male...')."
85
+ "- If both a name and a gender word appear, always prioritize the gender word in text, not inferred gender from name."
86
+ "- If the chart uses gender-descriptive words like 'gentleman' or 'lady', interpret them as 'male' or 'female' respectively."
87
  "- Only include values explicitly mentioned in the chart.\n"
88
  "- If a value is missing or not mentioned, leave it as an empty string.\n"
89
  "- Do not hallucinate, infer, or guess missing details."