Spaces:
Sleeping
Sleeping
File size: 30,913 Bytes
bb76506 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 |
import openai
from extra_functions import extract_text, get_completion, get_dictation
from labs_radiology import get_lab_results
def task(post_data):
if "Task 1:" in post_data:
instance = histroy_of_illness(openai.api_key, post_data)
response = instance.result
elif "Task 2:" in post_data:
instance = plan_of_care(post_data)
response = instance.result
elif "Task 3:" in post_data:
instance = cpt_code(openai.api_key, post_data)
response = instance.result
elif "Task 4:" in post_data:
instance = physical_exam(post_data)
response = instance.result
elif "Task 5:" in post_data:
instance = review_of_system(post_data)
response = instance.result
else:
response = "Task is not justified"
return response
class cpt_code:
def __init__(self, key, post_date, delimiter="####"):
self.key = key
self.post_data = post_date
self.delimiter = delimiter
result = self.final() # Call the final() method and store the result
self.result = result # Store the result as an attribute
def final(self):
prompt = """You are a medical assistant. Your job is to make the python dictionary based on the text that I will provide.
The sequence of the keys are if available:
"Systolic:"
"Diastolic:"
"BMI:"
If the mentioned keys are not available than return the key "nothing" with the value "nothing".
"""
user_1 = """You are a medical assistant. Your job is to make the python dictionary based on the text that I will provide.
The sequence of the keys are if available:
"Systolic:"
"Diastolic:"
"BMI:"
If the mentioned keys are not available than return the key "nothing" with the value "nothing".
"""
result_1 = """
{'Systolic':'120', 'Diastolic':'80', 'BMI':'36.5'}
"""
result_2 = """
{'nothing':'nothing'}
"""
user_text = f"""
You are a medical assistant. Your job is to make the python dictionary based on the text delimited by triple backticks.
'''{self.post_data}'''
The sequence of the keys are if available:
"Systolic:"
"Diastolic:"
"BMI:"
If the mentioned keys are not available than return the key "nothing" with the value "nothing".
"""
messages = [
{'role': 'system', 'content': prompt},
{'role': 'user', 'content': f"{self.delimiter}{user_1}{self.delimiter}"},
{'role': 'assistant', 'content': f"{result_1}"},
{'role': 'user', 'content': f"{self.delimiter}{user_1}{self.delimiter}"},
{'role': 'assistant', 'content': f"{result_2}"},
{'role': 'user', 'content': f"{self.delimiter}{user_text}"}
]
result = get_completion(messages)
return result
class histroy_of_illness:
def __init__(self, key, post_date, delimiter="####"):
self.key = key
self.post_data = post_date
self.delimiter = delimiter
result = self.final() # Call the final() method and store the result
self.result = result # Store the result as an attribute
def get_basic_information(self):
system_0 = """
Remove all the disease or disorders mentioned from the text delimited by triple backticks and rearrange the remaining text.
The headings should be:
1) Patient demographics.
2) Type of Visit.
3) Medications.
Note: Write only medication name and Sig in this heading. Don't write the Qty, Start Date:, Prescribe Date: and End Date:
4) Doctor Dictation.
Note: Pick the doctor dictation that is after the "Doctor Dictation:" in the provided text.
"""
prompt_0 = f"""
Remove all the disease or disorders mentioned from the text delimited by triple backticks and rearrange the remaining text.
```{self.post_data}```
"""
messages_0 = [
{'role': 'system', 'content': system_0},
{'role': 'user', 'content': f"{self.delimiter}{prompt_0}{self.delimiter}"}
]
basic_info = get_completion(messages_0)
return basic_info
def get_history(self):
system_1 = f"""
As a medical assistant, your task is to check for the presence of a doctor's dictation section, typically located\
after the heading "doctor dictation."
If the "doctor dictation" and medications are available, focus on extracting diseases or disorders that are directly related \
to "doctor dictation" and related to mentioned medications. In cases where the doctor's dictation is absent, rely solely \
on mentioned medications. It is mandatory to write the reason of extraction.
Don't extract the disease or disorder if no medication mentioned directly related to this disorder.
If the "doctor dictation" and any medication is not mentioned in the provided text than extract only first five
disease or disorders. In this case the sentence should be start from "The previous history of the patient is "
Don't add the BMI in the output.
Write the short form of disease or disorders. Don't write the complete name.
Don't extract the disease or disorder on the base of causes of medications.
Don't add the word "unspecified" in the output
Return "Noting" if no "doctor dictation" and medications are related to disease or disorder.
At the end it is necessary to write the related disease or disorders in one line.
"""
prompt_1 = f"""
Based on the doctor's dictation and mentioned medications, Choose the diseases or disorders that are directly\
related to the doctor's dictation and mentioned medications from the text
delimited by triple backticks.
Don't add the BMI in the output.
At the end it is necessary to write the related disease or disorders in one line.
```{self.post_data}```
"""
few_shot_user_1 = """
Based on the doctor's dictation and mentioned medications, Choose the diseases or disorders that are directly\
related to the doctor's dictation and mentioned medications from the text
delimited by triple backticks.
Don't add the BMI in the output.
At the end it is necessary to write the related disease or disorders in one line.
"""
few_shot_assistant_1 = """
1) Sleep deprivation - related to the medication hydroxyzine HCl which is used for allergies and sleep.
2) Insomnia - related to the medication hydroxyzine HCl which is used for sleep.
3) Angina pectoris - related to the medication Klonopin which is used for anxiety and panic disorders.
4) Chronic cough and Dysphonia - related to the medication Cepacol Sore Throat which is used for sore throat.
The patient has a history of sleep deprivation, insomnia, angina pectoris, Anxiety, chronic cough and dysphonia.
"""
few_shot_user_2 = """
Based on the doctor's dictation and mentioned medications, Choose the diseases or disorders that are directly\
related to the doctor's dictation and mentioned medications from the text
delimited by triple backticks.
Don't add the BMI in the output.
At the end it is necessary to write the related disease or disorders in one line.
"""
few_shot_assistant_2 = """
1) Anxiety disorder- related to the doctor's dictation which is mentioned in the text.
The patient disease or disorder is Anxiety.
"""
messages_1 = [
{'role': 'system', 'content': system_1},
{'role': 'user', 'content': f"{self.delimiter}{few_shot_user_1}{self.delimiter}"},
{'role': 'assistant', 'content': f"{few_shot_assistant_1}"},
{'role': 'user', 'content': f"{self.delimiter}{few_shot_user_2}{self.delimiter}"},
{'role': 'assistant', 'content': f"{few_shot_assistant_2}"},
{'role': 'user', 'content': f"{self.delimiter}{prompt_1}"}
]
response = get_completion(messages_1)
print(response)
# Split the text into lines
lines = response.split('\n')
# Extract the last line
history = lines[-1].strip()
return history
def final(self):
basic_data = self.get_basic_information()
history = self.get_history()
system_2 = f"""
You are a medical assistant and you job is to write a history of illness of the patient.
The text contains the patient demographics, History of disease or disorder, Medications and Doctor dictation.
Please write a History of illness based on the text delimited by the triple backticks.lets think step by step.
First line contains the patient demographics and provided 'history line'. Don't add the medications in this line.
Second line contains the patient current complains.
It is necessary to concluded with "**No other medical concerns in today's appointment**".
Don't add the headings.
Don't repeat the lines.
Don't write more than 4 lines.
Write lines separately.
"""
prompt_2 = f"""
Please write a History of illness in based on the text delimited by the triple backticks,\
```{basic_data}```
the the patient history is delimited by triple dashes,
---{history}---
and concluded with "No other medical concerns in today's appointment".
"""
few_shot_1 = """Write a history of illness of the patient based on the text that I will provide"""
result_1 = """\
Calvin Mcrae, a 71-year-old male, came in for a follow-up visit. \n \
He has a medical history of Hypertension (HTN), Hypothyroidism, and a history of cellulitis of the face.\n \
He complains of the upper lip infection.\n \
**No other medical concerns in today's appointment**.\n \
"""
messages_2 = [{'role': 'system', 'content': system_2},
{'role': 'user', 'content': f"{self.delimiter}{few_shot_1}{self.delimiter}"},
{'role': 'assistant', 'content': result_1},
{'role': 'user', 'content': f"{self.delimiter}{prompt_2}{self.delimiter}"}]
response = get_completion(messages_2)
return response
class plan_of_care:
def __init__(self, post_date, delimiter="####"):
self.post_data = post_date
self.delimiter = delimiter
medication_start = post_date.find("cutformhere:") + len("cutformhere:")
medication_end = post_date.find("Doctor dictation")
self.medications_text = post_date[medication_start:medication_end].strip()
dictation_start = post_date.find("Doctor dictation:") + len("Doctor dictation:")
doctor_semi = post_date[dictation_start:].strip()
self.diagnosis = extract_text(doctor_semi)
self.dictation_final = get_dictation(doctor_semi)
result = self.final()
self.result = result
def template_1(self):
prompt = f"""
You are a medical assistant. Your job is to organize the medications with the diseases and disorders mentioned in the text by following the \
rules listed below. The medications and disease or disorder will be provided. Let’s think step by step.
Rules for this task:
1) First extract the one relatable disease or disorder for the medication if mentioned in the provided text, and \
than organize the medication with the associated disease and disorder mentioned in the provided text.
2) Only organizes the medication with one disease or disorder. But it is possible that multiple medications \
organize with one disease or disorder if prescribed for same therapeutic use.
3) Include only medication names, dosage, and SIG (instructions for use).
4) Don't add the disease or disorder in the output if no medication is organized with that disease or disorder.
5) Don't add Start Date, Prescribe Date, End Date and Qty of the medication.
6) If the disease and disorder is not organize with the medication, than don't add this disease or disorder in the \
final output
7) Check If the medication is not grouped with the disease or disorder, then add it to \
the "Other Medications" section.
8) At the end add a concise plan of care with 4 to 5 lines for disease or disorder that i will provide.
9) Utilize double asterisks for all headings.
10) Utilize double asterisks for all "medications" with their "SIG".
11) Don't suggest any disease, disorder or symptoms for any medication.
12) If the prompt contain "Other medications". please write these medications at the end with the heading.
13) Don't add heading of "Plan of care:"
14) Don't add ICD-10 codes.
15) It is Mandatory to conclude the plan of care with this line "Follow-up as scheduled"
"""
user_text = f"""
Write a concise plan of care with 4 to 5 lines for disease or disorder with the medication and the doctor dictation.\
The disease or disorders are delimited by triple backticks.
'''{self.diagnosis}'''
The medications are delimited by triple dashes.
---{self.medications_text}---
The doctor dictation is delimited by triple hashtags.
###{self.dictation_final}###
"""
few_shot_user_1 = """
Write a concise plan of care with 4 to 5 lines for disease or disorder if the medication that is the only\
mentioned in the text delimited by triple backticks is organize with it.
Don't write the disease or disorder in the output if "no medication is mentioned in the text" for the disease or disorder.
"""
few_shot_assistant_1 = """
**Asthma**:
- **Ventolin HFA 90 mcg/actuation aerosol inhaler. Sig: 2 puffs every 6 hours as needed.**
- **Breo Ellipta 100 mcg-25 mcg/dose powder for inhalation. Sig: 1 puff daily.**
- Avoid triggers that may worsen cough variant asthma, such as cold air, smoke, and allergens.
- Use a peak flow meter to monitor lung function and adjust medication use as needed.
- Follow an asthma action plan provided by healthcare provider.
- If symptoms persist or worsen, consult with healthcare provider for further evaluation and potential adjustment \
of treatment plan.
**Gastro-esophageal reflux disease:
- **Simethicone 80 mg chewable tablet, Sig: One Tablet Daily q6h.**
- Avoid trigger foods and beverages that can worsen symptoms, such as spicy foods, citrus fruits, and caffeine.
- Eat smaller, more frequent meals and avoid lying down immediately after eating.
- Elevate the head of the bed to reduce nighttime reflux.
- If symptoms persist or worsen, consult with your healthcare provider for further evaluation and potential \
alternative treatment options.
**Other Medications**:
- **Ascorbic Acid (Vitamin C) 500 mg Tablet\n, Sig: Take 1 tablet (500mg) by oral route once daily.**
**Follow-up as scheduled**
"""
messages = [{'role': 'system', 'content': prompt},
{'role': 'user', 'content': f"{self.delimiter}{few_shot_user_1}{self.delimiter}"},
{'role': 'assistant', 'content': few_shot_assistant_1},
{'role': 'user', 'content': f"{self.delimiter}{user_text}{self.delimiter}"}]
response_5 = get_completion(messages)
return response_5
def template_2(self):
text_0 = get_lab_results()
text = f"""
The labs readings of patient is delimited by triple backticks.
```{text_0}```
and the medications are mentioned in the text delimited by triple dashes.
---{self.medications_text}---
"""
messages = [
{
"role": "system",
"content": f"""Your job is to write a plan of care based on the text that i will provide. Lets think step by step:
Write the date on which the lab were conducted.
First, It is mandatory to write the main headings under double asterisks if added.
Than add the readings under the main heading.
Don't write the patient details or additional data.
Don't write the reference intervals in the output.
Don't write the Indications.
Don't suggest any potential issue based on findings.
Make sure nothing is missed in the output.
Also write one line of plan of care below abnormal values of each main heading.
Don't add the heading of "plan of care".
Write the mentioned medications in the related test after the advice.
Double asterisks the test names.
It is Mandatory to conclude with this line "Follow-up as scheduled"
"""
},
{
"role": "user",
"content": "Your job is to write a plan of care based on the lab report.Don't add the results in the"
"future outputs. Only remember the format."
},
{
"role": "assistant",
"content": f"""
**Labs done on:** 11/27/2023
**P14+eGFR:**
**Glucose** 112 (high).
Continue to follow a low carbohydrate diet and monitor blood sugar levels regularly.
**Lipid Panel:**
**Triglycerides** 164 (high).
Maintain a low-fat diet and continue regular exercises.
**Hemoglobin A1c:**
**Hemoglobin A1c** 6.6 (high).
Continue to monitor blood sugar levels and follows a diabetes management plan.
**CBC With Differential/Platelet:**
**MCH** 26.1 (low).
**MCHC** 31.4 (low).
**Eos (Absolute)** 0.6 (high).
Continue taking montelukast 10 mg tablet as prescribed.
**Vitamin D, 25-Hydroxy:**
**Vitamin D, 25-Hydroxy** 23.3 (low).
Continue taking Vitamin D3 125 mcg (5,000 unit) tablet daily as prescribed.
**Follow-up as scheduled**
"""
},
{
"role": "user",
"content": f"{self.delimiter}{text}{self.delimiter}"
}
]
response = get_completion(messages)
return response
def final(self):
if "Type of visit: Lab/Radiology Review" in self.post_data:
response = self.template_2()
else:
response = self.template_1()
return response
class review_of_system:
def __init__(self, post_date, delimiter="####"):
self.post_data = post_date
self.delimiter = delimiter
result = self.final()
self.result = result
def get_symptoms(self):
user_text = f"""
```{self.post_data}```
You are a medical assistant. Your job is to identify the symptoms from the provided text delimited by triple backticks\
Next, extract and compile symptoms from the symptoms_list\
that are possibly related to the identified symptoms. \
Don't suggest any symptoms if it is not mentioned in the symptoms_list. \
Also add the symptoms in the output list that are not in the symptoms_list. \
It is mandatory that output should be in Python list.
Return empty list if no symptoms are present in the provided text.
"""
symptoms_list = """
Your job is to extract the one symptom from this symptoms_list based on the identified symptoms.
symptoms_list = [
"Rashes", "Earache", "Discharge (possibly ear or nose related)",
"Ringing or decreased hearing", "Sneezing", "Sore throat",
"Stuffy or runny nose", "Congestion", "Cough", "Shortness of breath",
"Wheezing", "Mass or lump (possibly in the breast)",
"Abdominal pain", "Change in bowel habits", "Constipation",
"Diarrhea", "GERD (Gastro-esophageal Reflux Disease)", "Nausea",
"Vomiting", "Dysuria (painful urination)",
"Discharges (possibly genitourinary related)", "Cyanosis", "Edema",
"Dizziness", "Headache", "Neuropathic pain", "Numbness", "Paralysis",
"Seizures", "Tremors", "Back pain", "Joint pain", "Joint swelling",
"Muscle cramps", "Muscle weakness", "Anxiety", "Depression",
"Insomnia", "Opioid dependence", "Chest pain", "Palpitations",
"Blurred vision", "Vision loss", "Eye discharge", "Eye itching",
"Eye pain", "Abnormal bruising", "Bleeding", "Lymphadenopathy (enlarged lymph nodes)",
"Excessive thirst", "Excessive hunger", "Heat intolerance", "Cold intolerance", "Hypertension",
"ADHD", "Diabetes Mellitus", "Post-Traumatic Stress Disorder",
"Asthma", "Urinary Tract Infection", "Migraine (Neurologic)",
"Convulsions (Neurologic)", "Joint Pain", "Arthritis", "Osteoarthritis",
"Pain in Hand", "Pain in Foot", "Knee Pain", "Opioid Dependence",
"Depressive Disorder", "Stress Disorder", "Hyperlipidemia",
"Hyperthyroidism", "Hypothyroidism"
]
"""
few_shot_user_1 = """
You are a medical assistant. Your job is to identify the symptoms from the provided text delimited by triple backticks\
Next, extract and compile symptoms from the symptoms_list\
that is possibly related to the identified symptoms.
"""
few_shot_assistant_1 = """
["Shortness of breath", "Cough"]
"""
messages = [{'role': 'system', 'content': symptoms_list},
{'role': 'user', 'content': f"{self.delimiter}{few_shot_user_1}{self.delimiter}"},
{'role': 'assistant', 'content': few_shot_assistant_1},
{'role': 'user', 'content': f"{self.delimiter}{user_text}{self.delimiter}"}]
response = get_completion(messages)
return response
def final(self):
symptoms = self.get_symptoms()
patient_data = """
"**Skin:** Patient denies rashes",
"**Ear/nose/throat:** Patient denies, Earache or discharge, Ringing or decreased hearing, Sneezing, Sore throat, Stuffy or runny nose",
"**Lungs:** Patient denies, Congestion, cough, Shortness of breath, Wheezing",
"**Breast:** Patient denies, Mass or Lump",
"**Abdomen:** Patient denies, Abdominal pain, change in bowel habits, Constipation, Diarrhea, GERD, Nausea, Vomiting",
"**GenitoUrinary:** Patient denies, Dysuria, Discharges",
"**Extremities:** Patient denies, Cyanosis, Edema",
"**Neurologic:** Patient denies, Dizziness, Headache, Neuropathic pain, Numbness, paralysis, Seizures, Tremors",
"**Musculoskeletal:** Patient denies, Back pain, Joint pain, Joint swelling, Muscle cramps, Muscle weakness, Breakthrough pain",
"**Psychiatric:** Patient denies, Anxiety, Depression, Insomnia, Opioid dependence",
"**Cardiovascular:** Patient denies, Chest pain, Palpitation",
"**Eyes:** Patient denies, Blurred or vision loss, Discharge itching or eye pain",
"**Heme/lymphatic:** Patient denies, Abnormal bruising, Bleeding, Lymphadenopathy",
"**Endocrine:** Patient denies, Excessive thirst or hunger, Heat or cold intolerance, Skin or hair changes, Weight gain or loss",
"**Dentistry:** Patient denies, Toothache"
"""
system = """
you are a medical assistant. Your job is to upgrade the template lines based on the symptoms lines based on the symptoms
after adding the line "patient complains of "Symptom" at the end of the that line not in the middle.
Return the template with no changes if no symptoms are given in the provided text.
Don't add extra text in the output.
"""
user_text = f"""
You are a medical assistant. Your job is to rewrite the template lines
{patient_data} after adding the line "patient complains of "symptom"
based on the symptoms list delimited by triple backticks.
'''{symptoms}'''
Use double asterisks for the heading and the added line.
Make sure all the provided text is added in the output.
"""
few_shot_user_1 = """
You are a medical assistant. Your job is to upgrade the template lines based on the symptoms lines based on the symptoms
after adding the line "patient complains of "Symptom"
"""
few_shot_assistant_1 = """
**Skin:** Patient denies rashes.
**Ear/nose/throat:** Patient denies, Earache or discharge, Ringing or decreased hearing, Sneezing, Sore throat, Stuffy or runny nose.
**Lungs:** Patient denies, Congestion, cough, Shortness of breath, Wheezing.
**Breast:** Patient denies, Mass or Lump".
**Abdomen:** Patient denies, Abdominal pain, change in bowel habits, Constipation, Diarrhea, GERD, Nausea, Vomiting.
**GenitoUrinary:** Patient denies, Dysuria, Discharges".
**Extremities:** Patient denies, Cyanosis, Edema".
**Neurologic:** Patient denies, Dizziness, Headache, Neuropathic pain, Numbness, paralysis, Seizures, Tremors.
**Musculoskeletal:** Patient denies, Joint pain, Joint swelling, Muscle cramps, Muscle weakness, Breakthrough pain. **Patient complains of back pain**
**Psychiatric:** Patient denies, Anxiety, Depression, Insomnia, Opioid dependence.
**Cardiovascular:** Patient denies, Chest pain, Palpitation.
**Eyes:** Patient denies, Blurred or vision loss, Discharge itching or eye pain.
**Heme/lymphatic:** Patient denies, Abnormal bruising, Bleeding, Lymphadenopathy.
**Endocrine:** Patient denies, Excessive thirst or hunger, Heat or cold intolerance, Skin or hair changes, Weight gain or loss.
**Dentistry:** Patient denies, Toothache.
"""
few_shot_user_2 = """
You are a medical assistant. Your job is to upgrade the template lines based on the symptoms lines based on the symptoms
after adding the line "patient complains of "Symptom"
"""
few_shot_assistant_2 = """
**Skin:** Patient denies rashes.
**Ear/nose/throat:** Patient denies, Earache or discharge, Ringing or decreased hearing, Sneezing, Sore throat, Stuffy or runny nose.
**Lungs:** Patient denies, Congestion, cough, Shortness of breath, Wheezing.
**Breast:** Patient denies, Mass or Lump".
**Abdomen:** Patient denies, Abdominal pain, change in bowel habits, Constipation, Diarrhea, GERD, Nausea, Vomiting.
**GenitoUrinary:** Patient denies, Dysuria, Discharges".
**Extremities:** Patient denies, Cyanosis, Edema".
**Neurologic:** Patient denies, Dizziness, Headache, Neuropathic pain, Numbness, paralysis, Seizures, Tremors.
"**Musculoskeletal:** Patient denies, Back pain, Joint pain, Joint swelling, Muscle cramps, Muscle weakness, Breakthrough pain".
**Psychiatric:** Patient denies, Anxiety, Depression, Insomnia, Opioid dependence.
**Cardiovascular:** Patient denies, Chest pain, Palpitation.
**Eyes:** Patient denies, Blurred or vision loss, Discharge itching or eye pain.
**Heme/lymphatic:** Patient denies, Abnormal bruising, Bleeding, Lymphadenopathy.
**Endocrine:** Patient denies, Excessive thirst or hunger, Heat or cold intolerance, Skin or hair changes, Weight gain or loss.
**Dentistry:** Patient denies, Toothache.
"""
messages = [{'role': 'system', 'content': system},
{'role': 'user', 'content': f"{self.delimiter}{few_shot_user_1}{self.delimiter}"},
{'role': 'assistant', 'content': few_shot_assistant_1},
{'role': 'user', 'content': f"{self.delimiter}{few_shot_user_2}{self.delimiter}"},
{'role': 'assistant', 'content': few_shot_assistant_2},
{'role': 'user', 'content': f"{self.delimiter}{user_text}{self.delimiter}"}]
response = get_completion(messages)
return response
class physical_exam:
def __init__(self, post_date, delimiter="####"):
self.post_data = post_date
self.delimiter = delimiter
result = self.final()
self.result = result
def final(self):
response_1 = ""
if "Type of visit: Follow Up" in self.post_data:
response_1 = "Patient is AAO x 3. Not in acute distress. Breathing is non-labored. Normal respiratory effort. The affect is normal and appropriate."
elif "Type of visit: Office Visit" in self.post_data:
response_1 = "Well-nourished and well-developed; in no acute distress. Breathing is non-labored, with normal respiratory effort. The affect is normal and appropriate."
elif "Type of visit: Lab/Radiology Review" in self.post_data:
response_1 = "Well-nourished and well-developed; in no acute distress. Breathing is non-labored, with normal respiratory effort. The affect is normal and appropriate."
else:
"Physical exam for this is not developed"
return response_1
|