dawit45 commited on
Commit
4d3e829
·
verified ·
1 Parent(s): 132a04a

Create utils/pdf_export.py

Browse files
Files changed (1) hide show
  1. utils/pdf_export.py +18 -0
utils/pdf_export.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fpdf import FPDF
2
+
3
+ def generate_pdf(patient_name, notes, filename):
4
+ pdf = FPDF()
5
+ pdf.add_page()
6
+ pdf.set_font("Arial", size=12)
7
+ pdf.cell(0, 8, txt=f"Patient: {patient_name}", ln=True)
8
+ pdf.ln(4)
9
+ for note in notes:
10
+ created = note.get('created_at', '')
11
+ content = note.get('content', '')
12
+ ai_analysis = note.get('ai_analysis', '')
13
+ ai_suggestion = note.get('ai_suggestion', '')
14
+ ai_diff = note.get('ai_differential', '')
15
+ pdf.multi_cell(0, 7, txt=f"{created}\n{content}\nAI Analysis: {ai_analysis}\nAI Suggestion: {ai_suggestion}\nDifferential: {ai_diff}\n")
16
+ pdf.ln(4)
17
+ pdf.output(filename)
18
+ return filename