Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- python -c
- from reportlab.lib.pagesizes import letter
- from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle
- from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
- from reportlab.lib.units import inch
- from reportlab.lib import colors
- from reportlab.lib.enums import TA_CENTER, TA_LEFT
- from datetime import datetime, timedelta
- doc = SimpleDocTemplate('hospital_discharge_summary.pdf', pagesize=letter)
- elements = []
- styles = getSampleStyleSheet()
- title_style = ParagraphStyle('CustomTitle', parent=styles['Heading1'], fontSize=18, spaceAfter=30, alignment=TA_CENTER, textColor=colors.darkblue)
- heading_style = ParagraphStyle('CustomHeading', parent=styles['Heading2'], fontSize=14, spaceAfter=12, textColor=colors.darkblue)
- normal_style = ParagraphStyle('CustomNormal', parent=styles['Normal'], fontSize=11, spaceAfter=6, leading=14)
- admission_date = datetime(2026, 6, 29)
- discharge_date = admission_date + timedelta(days=14)
- header_data = [['<b>SPOTSYLVANIA REGIONAL MEDICAL CENTER</b>', ''], ['<b>A Member of the Virginia Health System</b>', ''], ['123 Medical Center Drive, Fredericksburg, VA 22408', ''], ['Phone: (540) 741-1000 | Fax: (540) 741-1001', ''], ['<b>PATIENT DISCHARGE SUMMARY</b>', '']]
- header_table = Table(header_data, colWidths=[5.5*inch, 1.5*inch])
- header_table.setStyle(TableStyle([('ALIGN', (0, 0), (-1, -1), 'LEFT'), ('FONTNAME', (0, 0), (0, 0), 'Helvetica-Bold'), ('FONTSIZE', (0, 0), (0, 0), 16), ('FONTNAME', (0, 1), (0, 1), 'Helvetica'), ('FONTSIZE', (0, 1), (0, 1), 10), ('FONTNAME', (0, 2), (0, 2), 'Helvetica'), ('FONTSIZE', (0, 2), (0, 2), 10), ('FONTNAME', (0, 3), (0, 3), 'Helvetica'), ('FONTSIZE', (0, 3), (0, 3), 9), ('FONTNAME', (0, 4), (0, 4), 'Helvetica-Bold'), ('FONTSIZE', (0, 4), (0, 4), 14), ('TEXTCOLOR', (0, 4), (0, 4), colors.darkblue), ('BOTTOMPADDING', (0, 4), (0, 4), 20)]))
- elements.append(header_table)
- elements.append(Spacer(1, 0.25*inch))
- elements.append(Paragraph('PATIENT INFORMATION', heading_style))
- patient_data = [['<b>Patient Name:</b>', 'Barry Allen Carrington'], ['<b>Date of Birth:</b>', 'March 15, 1975 (Age: 51)'], ['<b>Medical Record #:</b>', 'MRN-854721369'], ['<b>Account #:</b>', 'ACCT-20260629-7854'], ['<b>Admission Date:</b>', admission_date.strftime('%B %d, %Y at 4:32 PM')], ['<b>Discharge Date:</b>', discharge_date.strftime('%B %d, %Y at 11:15 AM')], ['<b>Length of Stay:</b>', '14 days'], ['<b>Admitting Physician:</b>', 'Natasha Y. Powell, DO'], ['<b>Primary Nurse:</b>', 'NJ'], ['<b>Room/Bed:</b>', '312-B'], ['<b>Service:</b>', 'Medicine'], ['<b>Discharge Disposition:</b>', 'Home']]
- patient_table = Table(patient_data, colWidths=[2.5*inch, 3.5*inch])
- patient_table.setStyle(TableStyle([('ALIGN', (0, 0), (-1, -1), 'LEFT'), ('FONTNAME', (0, 0), (0, -1), 'Helvetica-Bold'), ('FONTSIZE', (0, 0), (-1, -1), 10), ('BOTTOMPADDING', (0, 0), (-1, -1), 5), ('TOPPADDING', (0, 0), (-1, -1), 5), ('LINEBELOW', (0, 0), (-1, -1), colors.grey, 0.5)]))
- elements.append(patient_table)
- elements.append(Spacer(1, 0.25*inch))
- elements.append(Paragraph('DISCHARGE DIAGNOSES (ICD-10-CM)', heading_style))
- diagnosis_data = [['1. B37.9', 'Candidiasis, unspecified - Severe fungal infection with cutaneous manifestations'], ['2. N17.9', 'Acute kidney failure, unspecified - Secondary to systemic infection'], ['3. R60.9', 'Edema, unspecified - Bilateral lower extremity edema'], ['4. L03.915', 'Cellulitis of lower limb - Bilateral lower extremities']]
- diagnosis_table = Table(diagnosis_data, colWidths=[1*inch, 5*inch])
- diagnosis_table.setStyle(TableStyle([('ALIGN', (0, 0), (-1, -1), 'LEFT'), ('FONTNAME', (0, 0), (0, -1), 'Helvetica-Bold'), ('FONTSIZE', (0, 0), (-1, -1), 10), ('LEFTPADDING', (0, 0), (0, -1), 20), ('BOTTOMPADDING', (0, 0), (-1, -1), 5), ('TOPPADDING', (0, 0), (-1, -1), 5)]))
- elements.append(diagnosis_table)
- elements.append(Spacer(1, 0.25*inch))
- elements.append(Paragraph('HOSPITAL COURSE SUMMARY', heading_style))
- course_text = '<b>History of Present Illness:</b> Patient is a 51-year-old male with no significant past medical history who presented to the Emergency Department on June 29, 2026 with a 3-day history of progressive swelling and erythema of hands and feet. Patient reported inability to perform basic ADLs including holding a cup due to severe swelling and pain. No recent travel or sick contacts. No known exposure to fungal agents.<br/><br/><b>Hospital Course:</b> Patient was admitted to Medicine service under Dr. Natasha Powell. Initial evaluation showed extensive cutaneous involvement with early signs of systemic response. Laboratory studies revealed elevated inflammatory markers (WBC 14.3, CRP 12.4 mg/dL) and evidence of acute renal insufficiency (Creatinine 2.1 mg/dL, BUN 32 mg/dL). Blood cultures were obtained and initially negative. Dermatology consultation was obtained and skin biopsy performed, confirming severe fungal infection. Patient was started on intravenous fluconazole 400mg daily and later switched to oral therapy based on sensitivity testing. Renal function gradually improved with supportive care and hydration. Physical therapy was involved for functional recovery. Patient condition gradually improved over 14-day hospitalization with resolution of acute symptoms and improvement in renal function (discharge Creatinine 1.3 mg/dL).<br/><br/><b>Discharge Condition:</b> Patient is afebrile, hemodynamically stable, with significant improvement in swelling and pain of extremities. Renal function has returned to near baseline. Patient is able to ambulate with minimal assistance and perform basic ADLs.'
- elements.append(Paragraph(course_text, normal_style))
- elements.append(Spacer(1, 0.25*inch))
- elements.append(Paragraph('DISCHARGE MEDICATIONS', heading_style))
- medication_data = [['<b>Medication</b>', '<b>Dosage</b>', '<b>Duration</b>', '<b>Refills</b>', '<b>NDC Code</b>'], ['Cephalexin', '500 mg orally three times daily', '7 days', '0', 'NDC: 55319-078-01'], ['Sulfamethoxazole-Trimethoprim (Bactrim DS)', '1 tablet orally twice daily', '7 days', '0', 'NDC: 51079-513-20'], ['Fluconazole', '200 mg orally once daily', '14 days', '0', 'NDC: 60505-3539-1'], ['Lisinopril', '10 mg orally once daily', '30 days', '2', 'NDC: 68180-519-10']]
- medication_table = Table(medication_data, colWidths=[2.5*inch, 1.5*inch, 1*inch, 0.8*inch, 1.2*inch])
- medication_table.setStyle(TableStyle([('ALIGN', (0, 0), (-1, -1), 'LEFT'), ('FONTNAME', (0, 0), (-1, 0), 'Helvetica-Bold'), ('FONTSIZE', (0, 0), (-1, -1), 9), ('BOTTOMPADDING', (0, 0), (-1, -1), 5), ('TOPPADDING', (0, 0), (-1, -1), 5), ('LINEBELOW', (0, 0), (-1, 0), colors.black, 1), ('LINEBELOW', (0, 1), (-1, -1), colors.grey, 0.5)]))
- elements.append(medication_table)
- elements.append(Spacer(1, 0.25*inch))
- doc.build(elements)
- print('Medical document created successfully: hospital_discharge_summary.pdf')
Advertisement
Add Comment
Please, Sign In to add comment