forked from PrajjwalDewangan/digital-medical-scribes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ehr_generation.py
71 lines (54 loc) · 2.63 KB
/
ehr_generation.py
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
# -*- coding: utf-8 -*-
"""EHR Generation.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1uCYpESdVhWv0DRtVD1CN6IncklkYsATI
"""
import re
from datetime import datetime
f = open('/content/transcription.txt', 'r')
conversation = f. read()
name_match = re.search(r"Hello, Doctor. My name is ([A-Za-z\s]+)", conversation)
name = name_match.group(1) if name_match else None
symptom_match = re.search(r"I've been experiencing (.+?) for", conversation)
symptom = symptom_match.group(1) if symptom_match else None
chest_discomfort_match = re.search(r"It's more like a (.+?) and it often radiates", conversation)
chest_discomfort = chest_discomfort_match.group(1) if chest_discomfort_match else None
physical_activity_match = re.search(r"It seems to happen more often when I'm active,", conversation)
physical_activity = "Yes" if physical_activity_match else "No"
dizziness_match = re.search(r"Yes, I've felt dizzy and sweaty a couple of times", conversation)
dizziness = "Yes" if dizziness_match else "No"
test_results_match = re.search(r"Welcome back. I have the test results with me.", conversation)
test_results = "Available" if test_results_match else "Not available"
ldl_cholesterol_match = re.search(r"LDL Cholesterol: (\d+\s?mg/dL)", conversation)
ldl_cholesterol = ldl_cholesterol_match.group(1) if ldl_cholesterol_match else None
cardiac_enzymes_match = re.search(r"Cardiac Enzymes are (\w+)", conversation)
cardiac_enzymes = cardiac_enzymes_match.group(1) if cardiac_enzymes_match else None
hemoglobin_content_match = re.search(r"Hemoglobin Content is (\d+\.\d+\s?g/dL)", conversation)
hemoglobin_content = hemoglobin_content_match.group(1) if hemoglobin_content_match else None
# Generate the EHR report
ehr_report = f"""**Electronic Health Record Report**
Patient Information:
- Name: {name}
- Symptom: {symptom}
- Chest Discomfort: {chest_discomfort}
- Occurs During Physical Activity: {physical_activity}
- Dizziness: {dizziness}
Medical History:
- Chief Complaint: {symptom}
- Past Medical History: None reported.
- Medications: [List of current medications, if any]
- Allergies: None reported.
Diagnostic Tests:
- Electrocardiogram (ECG): {test_results}
- Stress Test: {test_results}
- Blood Test: {test_results}
- LDL Cholesterol: {ldl_cholesterol}
- Cardiac Enzymes: {cardiac_enzymes}
- Hemoglobin Content: {hemoglobin_content}
"""
# Treatment Plan:
# - Further evaluation needed: Coronary angiography recommended.
# - Medication Management: Prescription of medications as necessary.
# - Lifestyle modifications: Discuss diet, exercise, and stress management to support recovery.
print(ehr_report)