File size: 817 Bytes
b171cab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from reportlab.lib.pagesizes import A4
from reportlab.pdfgen import canvas
from reportlab.lib.units import mm
def generate_pdf(path, title, soap, summary):
    c=canvas.Canvas(path,pagesize=A4)
    W,H=A4; x=20*mm; y=H-25*mm
    def p(label,txt):
        nonlocal y
        c.setFont("Helvetica-Bold",12); c.drawString(x,y,label); y-=6*mm
        c.setFont("Helvetica",10)
        for line in txt.split("\n"):
            c.drawString(x,y,line); y-=5*mm
        y-=3*mm
    p("Title",title)
    p("Subjective",soap.get("subjective",""))
    p("Objective",soap.get("objective",""))
    p("Assessment","\n".join(soap.get("assessment",[])))
    p("Plan","\n".join(soap.get("plan",[])))
    p("Red Flags","\n".join(soap.get("red_flags",[])))
    p("Summary",summary or "")
    c.showPage(); c.save()