Give the patient counselling based on the discharge summary
python3 -c " import pdfplumber with pdfplumber.open('/tmp/workspace/attachments/71241d33-6177-4cef-a37d-d5861eded4fa/Sandhiya discharge summary .pdf') as pdf: for i, page in enumerate(pdf.pages): print(f'=== PAGE {i+1} ===') print(page.extract_text()) "
python3 -c " from pypdf import PdfReader reader = PdfReader('/tmp/workspace/attachments/71241d33-6177-4cef-a37d-d5861eded4fa/Sandhiya discharge summary .pdf') print(f'Pages: {len(reader.pages)}') for i, page in enumerate(reader.pages[:5]): text = page.extract_text() print(f'=== PAGE {i+1} ===') print(repr(text[:500]) if text else 'EMPTY') "
python3 -c " from pypdf import PdfReader, PdfWriter import os # Check if pdf2image or PIL is available try: from pdf2image import convert_from_path print('pdf2image available') except ImportError: print('pdf2image NOT available') try: import fitz # PyMuPDF print('PyMuPDF (fitz) available') except ImportError: print('PyMuPDF NOT available') try: from PIL import Image print('PIL available') except ImportError: print('PIL NOT available') "
python3 -c " from pdf2image import convert_from_path import os os.makedirs('/tmp/workspace/sandhiya_pages', exist_ok=True) pages = convert_from_path('/tmp/workspace/attachments/71241d33-6177-4cef-a37d-d5861eded4fa/Sandhiya discharge summary .pdf', dpi=150, first_page=1, last_page=5) for i, page in enumerate(pages): path = f'/tmp/workspace/sandhiya_pages/page_{i+1:02d}.jpg' page.save(path, 'JPEG', quality=85) print(f'Saved {path}') print('Done') " 2>&1
python3 -c " from pdf2image import convert_from_path import os os.makedirs('/tmp/workspace/sandhiya_pages', exist_ok=True) pages = convert_from_path('/tmp/workspace/attachments/71241d33-6177-4cef-a37d-d5861eded4fa/Sandhiya discharge summary .pdf', dpi=150, first_page=3, last_page=10) for i, page in enumerate(pages): path = f'/tmp/workspace/sandhiya_pages/page_{i+3:02d}.jpg' page.save(path, 'JPEG', quality=85) print(f'Saved {path}') print('Done') " 2>&1
| # | Medicine | Dose / Schedule | Purpose |
|---|---|---|---|
| 1 | T. Mondeslor (Montelukast + Desloratadine) | BD (twice daily) | Reduces airway inflammation and allergy |
| 2 | T. Pulmoclear | BD (twice daily) | Bronchodilator/mucolytic support |
| 3 | T. Norflox 100 mg | Morning only (1-0-1) x 5 days | Antibiotic course - complete fully |
| 4 | T. Wysolone 20 mg | x 5 days, then STEP DOWN to | Steroid to reduce airway swelling |
| T. Wysolone 10 mg | x 5 days (taper) | Do NOT stop suddenly | |
| 5 | Cap. Budamate Rotacaps 400 mcg | 1 Puff - 0 - 1 Puff (morning and night) via Rotahaler | Long-term asthma controller inhaler - Gargle and rinse mouth after every use |
| 6 | Syp. Ascoril LS | 5 mL - 5 mL - 5 mL (three times daily) | Mucolytic - loosens phlegm |
| 7 | Syp. Lactulose 15 mL | 0 - 0 - 15 mL (at night) | Stool softener (as steroids can cause constipation) |
| 8 | Fluticasone Nasal Spray | At bedtime (HS) | Reduces nasal congestion and post-nasal drip |
| 9 | Duolin Respules (S) | SOS (only if needed during breathlessness) | Rescue nebuliser - use during emergency |
| 10 | Budesonide Respules (S) | SOS (only if needed during breathlessness) | Rescue nebuliser - use together with Duolin |
Create a printable medication schedule chart for home use
python3 << 'EOF' from reportlab.lib.pagesizes import A4 from reportlab.lib import colors from reportlab.lib.units import cm, mm from reportlab.platypus import SimpleDocTemplate, Table, TableStyle, Paragraph, Spacer, HRFlowable from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_RIGHT from reportlab.platypus import KeepTogether import os os.makedirs('/tmp/workspace/sandhiya_meds', exist_ok=True) doc = SimpleDocTemplate( '/tmp/workspace/sandhiya_meds/Sandhiya_Medication_Schedule.pdf', pagesize=A4, topMargin=1.2*cm, bottomMargin=1.2*cm, leftMargin=1.4*cm, rightMargin=1.4*cm ) styles = getSampleStyleSheet() # Custom styles title_style = ParagraphStyle('Title', parent=styles['Normal'], fontSize=15, fontName='Helvetica-Bold', alignment=TA_CENTER, textColor=colors.HexColor('#003366'), spaceAfter=2) subtitle_style = ParagraphStyle('Sub', parent=styles['Normal'], fontSize=10, fontName='Helvetica', alignment=TA_CENTER, textColor=colors.HexColor('#555555'), spaceAfter=2) patient_style = ParagraphStyle('Patient', parent=styles['Normal'], fontSize=10, fontName='Helvetica-Bold', alignment=TA_CENTER, textColor=colors.HexColor('#003366'), spaceAfter=4) section_style = ParagraphStyle('Section', parent=styles['Normal'], fontSize=10, fontName='Helvetica-Bold', textColor=colors.white, alignment=TA_LEFT) note_style = ParagraphStyle('Note', parent=styles['Normal'], fontSize=8, fontName='Helvetica', textColor=colors.HexColor('#333333'), leading=12) warn_style = ParagraphStyle('Warn', parent=styles['Normal'], fontSize=8, fontName='Helvetica-Bold', textColor=colors.HexColor('#cc0000'), leading=12) small_style = ParagraphStyle('Small', parent=styles['Normal'], fontSize=7.5, fontName='Helvetica', textColor=colors.HexColor('#333333'), leading=11) # ---- COLOUR PALETTE ---- HEADER_BG = colors.HexColor('#003366') ALT_ROW = colors.HexColor('#EBF3FF') WHITE = colors.white BORDER = colors.HexColor('#003366') GREEN_BG = colors.HexColor('#1a7a3a') RED_BG = colors.HexColor('#cc0000') ORANGE_BG = colors.HexColor('#e07b00') GREY_BG = colors.HexColor('#f0f0f0') TICK_GREEN = colors.HexColor('#1a7a3a') # ======== HEADER ======== elements = [] elements.append(Paragraph("NANDHA MEDICAL COLLEGE AND HOSPITAL", title_style)) elements.append(Paragraph("Pitchandampalayam Post, Erode - 638052 | Ph: 04294-222222", subtitle_style)) elements.append(HRFlowable(width="100%", thickness=2, color=HEADER_BG)) elements.append(Spacer(1, 3*mm)) elements.append(Paragraph("MEDICATION SCHEDULE CHART - HOME USE", ParagraphStyle('H', parent=styles['Normal'], fontSize=13, fontName='Helvetica-Bold', alignment=TA_CENTER, textColor=WHITE, backColor=HEADER_BG, spaceAfter=4, spaceBefore=2, leading=18))) elements.append(Spacer(1, 2*mm)) # ======== PATIENT INFO BOX ======== info_data = [ [Paragraph('<b>Patient Name:</b> Mrs. K. SANDHIYA', small_style), Paragraph('<b>Age / Sex:</b> 27 Years / Female', small_style), Paragraph('<b>IP No:</b> IP260406067', small_style)], [Paragraph('<b>Diagnosis:</b> Acute Exacerbation of Bronchial Asthma', small_style), Paragraph('<b>Discharged:</b> 09/04/2026', small_style), Paragraph('<b>Review Date:</b> 17/04/2026', small_style)], [Paragraph('<b>Doctor:</b> Dr. N. Sathya, MBBS MD (Respiratory Medicine)', small_style), Paragraph('<b>Dept:</b> Pulmonology OPD', small_style), Paragraph('<b>Contact:</b> 9585166029', small_style)], ] info_table = Table(info_data, colWidths=[7.2*cm, 5.2*cm, 5.2*cm]) info_table.setStyle(TableStyle([ ('BACKGROUND', (0,0), (-1,-1), colors.HexColor('#f5f9ff')), ('BOX', (0,0), (-1,-1), 1.5, BORDER), ('INNERGRID', (0,0), (-1,-1), 0.4, colors.HexColor('#aaaacc')), ('TOPPADDING', (0,0), (-1,-1), 4), ('BOTTOMPADDING', (0,0), (-1,-1), 4), ('LEFTPADDING', (0,0), (-1,-1), 5), ])) elements.append(info_table) elements.append(Spacer(1, 3*mm)) # ======== MAIN MEDICATION TABLE ======== header_para = lambda t: Paragraph(f'<b>{t}</b>', ParagraphStyle('TH', parent=styles['Normal'], fontSize=8.5, fontName='Helvetica-Bold', textColor=WHITE, alignment=TA_CENTER, leading=12)) cell_para = lambda t, bold=False, color='#222222': Paragraph( f'<b>{t}</b>' if bold else t, ParagraphStyle('TD', parent=styles['Normal'], fontSize=8, fontName='Helvetica-Bold' if bold else 'Helvetica', textColor=colors.HexColor(color), leading=11)) tick = lambda: Paragraph('<b>✓</b>', ParagraphStyle('TK', parent=styles['Normal'], fontSize=10, fontName='Helvetica-Bold', textColor=TICK_GREEN, alignment=TA_CENTER)) dash = lambda: Paragraph('—', ParagraphStyle('DS', parent=styles['Normal'], fontSize=9, textColor=colors.grey, alignment=TA_CENTER)) sos = lambda: Paragraph('<b>SOS</b>', ParagraphStyle('SS', parent=styles['Normal'], fontSize=8, fontName='Helvetica-Bold', textColor=colors.HexColor('#e07b00'), alignment=TA_CENTER)) col_w = [0.6*cm, 4.3*cm, 3.5*cm, 1.5*cm, 1.5*cm, 1.5*cm, 1.6*cm, 3.1*cm] med_header = [ header_para('#'), header_para('Medicine Name'), header_para('Dose & Purpose'), header_para('Morning\n🌅'), header_para('Afternoon\n☀️'), header_para('Night\n🌙'), header_para('Duration'), header_para('Special Instructions'), ] def np(t, sz=7.5, bold=False, color='#222222', align=TA_LEFT): return Paragraph(f'<b>{t}</b>' if bold else t, ParagraphStyle('NP', parent=styles['Normal'], fontSize=sz, fontName='Helvetica-Bold' if bold else 'Helvetica', textColor=colors.HexColor(color), alignment=align, leading=11)) meds = [ # Regular medicines ['1', 'T. Mondeslor\n(Montelukast +\nDesloratadine)', 'Prevents airway\ninflammation &\nallergy', '✓', '—', '✓', 'Ongoing', 'Take after food'], ['2', 'T. Pulmoclear', 'Bronchodilator\n& mucolytic\nsupport', '✓', '—', '✓', 'Ongoing', 'Take after food'], ['3', 'T. Norflox 100 mg', 'Antibiotic -\nComplete full\ncourse', '✓', '—', '✓', '5 Days\nOnly', 'Complete course\neven if feeling\nbetter'], ['4', 'T. Wysolone 20 mg\n→ then 10 mg', 'Steroid - reduces\nairway swelling', '✓', '—', '—', '5+5 Days\n(Taper)', 'Take with food.\nDo NOT stop\nsuddenly'], ['5', 'Cap. Budamate\nRotacaps 400 mcg\n(via Rotahaler)', 'Controller\ninhaler -\nLong-term', '1 Puff', '—', '1 Puff', 'Daily\n(Ongoing)', '⚠ GARGLE mouth\nwith water after\nevery use'], ['6', 'Syp. Ascoril LS\n5 mL', 'Loosens phlegm\n(Mucolytic)', '5 mL', '5 mL', '5 mL', 'Ongoing', 'Shake well\nbefore use'], ['7', 'Syp. Lactulose\n15 mL', 'Prevents\nconstipation', '—', '—', '15 mL', 'Ongoing', 'Take at night\nbefore bed'], ['8', 'Fluticasone\nNasal Spray', 'Reduces nasal\ncongestion', '—', '—', '2 Sprays\neach nostril', 'Ongoing', 'Spray at bedtime\n(HS)'], # SOS medicines ['9', 'Duolin Respules\n(Nebuliser)', 'Rescue -\nfor breathing\ndifficulty', 'SOS', 'SOS', 'SOS', 'Only if\nneeded', '⚠ Use ONLY\nwhen breathing\nis difficult'], ['10', 'Budesonide\nRespules\n(Nebuliser)', 'Rescue steroid\n(with Duolin)', 'SOS', 'SOS', 'SOS', 'Only if\nneeded', '⚠ Use together\nwith Duolin\nRespule'], ] tick_sym = '✓' dash_sym = '—' sos_sym = 'SOS' def time_cell(t): if t == tick_sym: return Paragraph(f'<b>{t}</b>', ParagraphStyle('C', parent=styles['Normal'], fontSize=11, fontName='Helvetica-Bold', textColor=TICK_GREEN, alignment=TA_CENTER)) elif t == dash_sym: return Paragraph(t, ParagraphStyle('C', parent=styles['Normal'], fontSize=9, textColor=colors.grey, alignment=TA_CENTER)) elif t == sos_sym: return Paragraph(f'<b>{t}</b>', ParagraphStyle('C', parent=styles['Normal'], fontSize=8, fontName='Helvetica-Bold', textColor=ORANGE_BG, alignment=TA_CENTER)) else: return Paragraph(t, ParagraphStyle('C', parent=styles['Normal'], fontSize=8, textColor=colors.HexColor('#003399'), alignment=TA_CENTER, leading=11)) table_data = [med_header] for m in meds: row = [ np(m[0], bold=True, align=TA_CENTER), np(m[1], bold=True, color='#003366'), np(m[2], sz=7.5), time_cell(m[3]), time_cell(m[4]), time_cell(m[5]), np(m[6], sz=7.5, align=TA_CENTER), np(m[7], sz=7.5), ] table_data.append(row) med_table = Table(table_data, colWidths=col_w, repeatRows=1) # Style ts = [ # Header ('BACKGROUND', (0,0), (-1,0), HEADER_BG), ('TEXTCOLOR', (0,0), (-1,0), WHITE), ('ALIGN', (0,0), (-1,0), 'CENTER'), ('VALIGN', (0,0), (-1,-1), 'MIDDLE'), ('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'), ('FONTSIZE', (0,0), (-1,0), 8.5), ('TOPPADDING', (0,0), (-1,-1), 4), ('BOTTOMPADDING', (0,0), (-1,-1), 4), ('LEFTPADDING', (0,0), (-1,-1), 4), ('RIGHTPADDING', (0,0), (-1,-1), 3), # Alternating rows ('BOX', (0,0), (-1,-1), 1.5, BORDER), ('INNERGRID', (0,0), (-1,-1), 0.5, colors.HexColor('#aaaacc')), # SOS rows (9,10 → index 9,10 in table_data) ('BACKGROUND', (0,9), (-1,9), colors.HexColor('#fff7ee')), ('BACKGROUND', (0,10), (-1,10), colors.HexColor('#fff7ee')), ] # Alternating row colors for regular meds for i in range(1, 9): if i % 2 == 0: ts.append(('BACKGROUND', (0,i), (-1,i), ALT_ROW)) else: ts.append(('BACKGROUND', (0,i), (-1,i), WHITE)) med_table.setStyle(TableStyle(ts)) elements.append(med_table) elements.append(Spacer(1, 4*mm)) # ======== STEROID TAPER GUIDE ======== taper_title = Paragraph("📅 STEROID TAPER SCHEDULE (Wysolone)", ParagraphStyle('TT', parent=styles['Normal'], fontSize=9.5, fontName='Helvetica-Bold', textColor=WHITE, backColor=colors.HexColor('#7a3a00'), alignment=TA_LEFT, leading=16, leftIndent=4)) elements.append(taper_title) taper_data = [ [np('Days 1-5', bold=True, color='#ffffff'), np('Days 6-10', bold=True, color='#ffffff'), np('After Day 10', bold=True, color='#ffffff')], [np('T. Wysolone 20 mg\nMorning only (1-0-0)', sz=8, color='#003366'), np('T. Wysolone 10 mg\nMorning only (1-0-0)', sz=8, color='#003366'), np('STOP - Do not take\nwithout doctor advice', sz=8, color='#cc0000')], ] taper_table = Table(taper_data, colWidths=[6*cm, 6*cm, 5.6*cm]) taper_table.setStyle(TableStyle([ ('BACKGROUND', (0,0), (-1,0), colors.HexColor('#c96a00')), ('BACKGROUND', (0,1), (-1,1), colors.HexColor('#fff3e0')), ('BOX', (0,0), (-1,-1), 1.2, colors.HexColor('#7a3a00')), ('INNERGRID', (0,0), (-1,-1), 0.5, colors.HexColor('#c96a00')), ('ALIGN', (0,0), (-1,-1), 'CENTER'), ('VALIGN', (0,0), (-1,-1), 'MIDDLE'), ('TOPPADDING', (0,0), (-1,-1), 5), ('BOTTOMPADDING', (0,0), (-1,-1), 5), ])) elements.append(taper_table) elements.append(Spacer(1, 4*mm)) # ======== TWO-COLUMN: WARNINGS + FOLLOW-UP ======== warn_lines = [ "⚠ Do NOT stop any medicine without doctor's advice.", "⚠ GARGLE mouth after every Budamate Rotacaps inhalation.", "⚠ Complete the full Norflox antibiotic course (5 days).", "⚠ Take Wysolone with food. Never stop suddenly.", "⚠ Use Duolin + Budesonide Respules ONLY when breathing is difficult.", "⚠ Avoid dust, smoke, cold air, strong perfumes, pet exposure.", "⚠ Do NOT take Aspirin / Ibuprofen / NSAIDs (can trigger asthma).", ] warn_text = '<br/>'.join(warn_lines) danger_lines = [ "🚨 Go to EMERGENCY if you experience:", " • Severe breathlessness / cannot complete a sentence", " • Bluish lips or fingertips", " • No relief after using Duolin + Budesonide Respules", " • Chest pain or fast heart beat", " • High fever with worsening cough", " • Confusion or excessive drowsiness", "", "📅 REVIEW: 17/04/2026 - Pulmonology OPD", "📞 Emergency Contact: 9585166029", ] danger_text = '<br/>'.join(danger_lines) warn_para = Paragraph(warn_text, ParagraphStyle('WP', parent=styles['Normal'], fontSize=7.8, fontName='Helvetica', textColor=colors.HexColor('#7a0000'), leading=13)) danger_para = Paragraph(danger_text, ParagraphStyle('DP', parent=styles['Normal'], fontSize=7.8, fontName='Helvetica', textColor=colors.HexColor('#222222'), leading=13)) bottom_data = [[ [Paragraph('⚠ IMPORTANT REMINDERS', ParagraphStyle('BT', parent=styles['Normal'], fontSize=9, fontName='Helvetica-Bold', textColor=WHITE, alignment=TA_CENTER)), Spacer(1,2), warn_para], [Paragraph('🚨 DANGER SIGNS & FOLLOW-UP', ParagraphStyle('BT2', parent=styles['Normal'], fontSize=9, fontName='Helvetica-Bold', textColor=WHITE, alignment=TA_CENTER)), Spacer(1,2), danger_para], ]] # Use inner tables def make_box(title_text, body_para, bg, title_bg): t_data = [ [Paragraph(title_text, ParagraphStyle('BX', parent=styles['Normal'], fontSize=9, fontName='Helvetica-Bold', textColor=WHITE, alignment=TA_CENTER))], [body_para], ] t = Table(t_data, colWidths=[8.5*cm]) t.setStyle(TableStyle([ ('BACKGROUND', (0,0), (0,0), title_bg), ('BACKGROUND', (0,1), (0,1), bg), ('BOX', (0,0), (-1,-1), 1.2, title_bg), ('INNERGRID', (0,0), (-1,-1), 0.3, colors.HexColor('#cccccc')), ('TOPPADDING', (0,0), (-1,-1), 5), ('BOTTOMPADDING', (0,0), (-1,-1), 5), ('LEFTPADDING', (0,0), (-1,-1), 6), ('RIGHTPADDING', (0,0), (-1,-1), 6), ('VALIGN', (0,0), (-1,-1), 'TOP'), ])) return t box1 = make_box('⚠ IMPORTANT REMINDERS', warn_para, colors.HexColor('#fff5f5'), colors.HexColor('#8b0000')) box2 = make_box('🚨 DANGER SIGNS & FOLLOW-UP', danger_para, colors.HexColor('#f0fff0'), colors.HexColor('#1a5c1a')) two_col = Table([[box1, Spacer(0.4*cm, 1), box2]], colWidths=[8.5*cm, 0.4*cm, 8.5*cm]) two_col.setStyle(TableStyle([ ('VALIGN', (0,0), (-1,-1), 'TOP'), ('TOPPADDING', (0,0), (-1,-1), 0), ('BOTTOMPADDING', (0,0), (-1,-1), 0), ('LEFTPADDING', (0,0), (-1,-1), 0), ('RIGHTPADDING', (0,0), (-1,-1), 0), ])) elements.append(two_col) elements.append(Spacer(1, 4*mm)) # ======== DAILY TRACKING GRID ======== track_title = Paragraph("📋 DAILY MEDICATION TRACKING - Week 1 (Tick ✓ after each dose)", ParagraphStyle('TR', parent=styles['Normal'], fontSize=9, fontName='Helvetica-Bold', textColor=WHITE, backColor=colors.HexColor('#1a4c7a'), alignment=TA_LEFT, leading=16, leftIndent=4)) elements.append(track_title) days = ['Day 1\n09/04', 'Day 2\n10/04', 'Day 3\n11/04', 'Day 4\n12/04', 'Day 5\n13/04', 'Day 6\n14/04', 'Day 7\n15/04'] track_meds = [ 'T. Mondeslor (M/N)', 'T. Pulmoclear (M/N)', 'T. Norflox 100 mg (M/N)', 'T. Wysolone 20mg (M)', 'Cap. Budamate Rotacaps (M/N)', 'Syp. Ascoril LS (M/A/N)', 'Syp. Lactulose (N)', 'Fluticasone Nasal Spray (N)', ] track_header = [np('Medicine', bold=True, color='#ffffff')] + [np(d, bold=True, color='#ffffff', align=TA_CENTER) for d in days] track_data = [track_header] for tm in track_meds: row = [np(tm, sz=7.5)] + [np('□', sz=10, align=TA_CENTER) for _ in days] track_data.append(row) track_col_w = [5.2*cm] + [1.85*cm]*7 track_table = Table(track_data, colWidths=track_col_w) track_ts = [ ('BACKGROUND', (0,0), (-1,0), colors.HexColor('#1a4c7a')), ('TEXTCOLOR', (0,0), (-1,0), WHITE), ('BOX', (0,0), (-1,-1), 1.2, colors.HexColor('#1a4c7a')), ('INNERGRID', (0,0), (-1,-1), 0.4, colors.HexColor('#aaaacc')), ('ALIGN', (1,0), (-1,-1), 'CENTER'), ('VALIGN', (0,0), (-1,-1), 'MIDDLE'), ('TOPPADDING', (0,0), (-1,-1), 4), ('BOTTOMPADDING', (0,0), (-1,-1), 4), ('LEFTPADDING', (0,0), (-1,-1), 3), ] for i in range(1, len(track_data)): if i % 2 == 0: track_ts.append(('BACKGROUND', (0,i), (-1,i), ALT_ROW)) else: track_ts.append(('BACKGROUND', (0,i), (-1,i), WHITE)) track_table.setStyle(TableStyle(track_ts)) elements.append(track_table) elements.append(Spacer(1, 3*mm)) # ======== FOOTER ======== footer = Paragraph( "This chart is prepared based on discharge advice by Dr. N. Sathya, MBBS MD (Respiratory Medicine), Nandha Medical College and Hospital, Erode. " "For emergencies call: <b>9585166029</b> | Review appointment: <b>17/04/2026 - Pulmonology OPD</b>", ParagraphStyle('FT', parent=styles['Normal'], fontSize=7.5, fontName='Helvetica', textColor=colors.HexColor('#555555'), alignment=TA_CENTER, backColor=colors.HexColor('#eef4ff'), leading=12)) elements.append(footer) doc.build(elements) print("PDF created successfully!") EOF
Sandhiya Medication Schedule
PDF Document · PDF