Create a pdf according to following instructions, Each page includes: Hindi chief complaint (C/0) w English prescription (Rx) Dose + frequency + duration Advice (Adv.) Handwritten visual layout v High-quality medicine images Quick-view treatment flow ,this are made about Across all major systems: ' Respiratory: cold, pharyngitis, bronchitis, pneumonia, asthma attack • Gastrointestinal: diarrhea, gastritis, acidity, worms Cardiovascular: hypertension, angina, rheumatic fever . CNS: headache, migraine, seizure, syncope ◦ Musculoskeletal: back pain, spondylitis, sprain, gout ◦ Skin: fungal infections, scabies, abscess, urticaria . ENT: otitis, sinusitis, tonsillitis . Pediatrics: fever, diarrhea, pneumonia, bronchiolitis . OBG basics Emergency day-to-day cases
mkdir -p /home/daytona/workspace/medical-rx-pdf && ls /home/daytona/workspace/medical-rx-pdf/
python3 -c "from reportlab.lib.pagesizes import A4; from reportlab.pdfgen import canvas; from reportlab.lib import colors; from reportlab.platypus import SimpleDocTemplate; print('reportlab ok')"
~/medical-rx-pdf/generate_rx_pdf.py
#!/usr/bin/env python3
"""
Comprehensive Medical Prescription PDF
Hindi C/O + English Rx + Dose/Freq/Duration + Advice + Treatment Flow
Covers: Respiratory, GI, CVS, CNS, MSK, Skin, ENT, Pediatrics, OBG, Emergency
"""
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import mm, cm
from reportlab.pdfgen import canvas
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.platypus import Paragraph, Table, TableStyle
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_RIGHT
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
import os, math
# ─── Color Palette ────────────────────────────────────────────────────────────
C_HEADER_BG = colors.HexColor("#1A3C5E") # deep navy
C_HEADER_TEXT = colors.white
C_ACCENT = colors.HexColor("#E74C3C") # red accent
C_SUBHEADER = colors.HexColor("#2980B9") # blue
C_LIGHT_BG = colors.HexColor("#EBF5FB") # light blue tint
C_YELLOW_BG = colors.HexColor("#FEF9E7") # pale yellow
C_GREEN_BG = colors.HexColor("#EAFAF1") # pale green
C_ORANGE_BG = colors.HexColor("#FEF5E7") # pale orange
C_BORDER = colors.HexColor("#2980B9")
C_DARK = colors.HexColor("#1A252F")
C_GRAY = colors.HexColor("#7F8C8D")
C_FLOW_BG = colors.HexColor("#D6EAF8")
C_PILL = colors.HexColor("#1ABC9C") # teal for pills
C_RX_BG = colors.HexColor("#F0F8FF")
C_ADVICE_BG = colors.HexColor("#F0FFF0")
# ─── System Category Colors ───────────────────────────────────────────────────
SYSTEM_COLORS = {
"Respiratory": colors.HexColor("#2471A3"),
"Gastrointestinal":colors.HexColor("#1E8449"),
"Cardiovascular": colors.HexColor("#C0392B"),
"CNS": colors.HexColor("#7D3C98"),
"Musculoskeletal": colors.HexColor("#D35400"),
"Skin": colors.HexColor("#E91E63"),
"ENT": colors.HexColor("#00838F"),
"Pediatrics": colors.HexColor("#F57C00"),
"OBG": colors.HexColor("#AD1457"),
"Emergency": colors.HexColor("#B71C1C"),
}
# ─── Clinical Data ─────────────────────────────────────────────────────────────
CASES = [
# ══ RESPIRATORY ══════════════════════════════════════════════════════════
{
"system": "Respiratory",
"condition": "Common Cold",
"hindi_co": "C/O: नाक बहना, छींकें, गले में खराश, हल्का बुखार (2-3 दिन से)",
"rx": [
("Tab. Cetirizine", "10 mg", "0-0-1 (रात)", "5 days"),
("Tab. Paracetamol", "500 mg", "1-1-1 (SOS)", "3 days"),
("Syrup Bromhexine", "8 mg/5ml","1 tsp TID", "5 days"),
("Nasal drops Xylometazoline","0.1%","2 drops each nostril BD","3 days"),
("Tab. Vitamin C", "500 mg", "1 OD", "7 days"),
],
"adv": [
"गर्म पानी से गरारे करें (नमक + हल्दी)",
"भाप लें दिन में 2-3 बार",
"ठंडे पेय और आइसक्रीम से परहेज",
"पर्याप्त आराम करें, खूब पानी पिएं",
"3-5 दिन में ठीक न हो तो दोबारा दिखाएं",
],
"flow": ["Assess Severity", "Antihistamine + Analgesic", "Decongestant", "Hydration + Steam", "F/U if >5 days"],
"icons": ["🤧","💊","💉","🫁","✅"],
},
{
"system": "Respiratory",
"condition": "Pharyngitis (Sore Throat)",
"hindi_co": "C/O: गले में दर्द, निगलने में तकलीफ, बुखार, आवाज बदलना (4 दिन से)",
"rx": [
("Tab. Amoxicillin", "500 mg", "1 TID", "7 days"),
("Tab. Paracetamol", "500 mg", "1 TID", "5 days"),
("Tab. Metronidazole", "400 mg", "1 TID", "5 days"),
("Betadine Gargle", "0.5%", "BD gargle", "7 days"),
("Lozenges Benzocaine", "—", "1 q4h (SOS)", "5 days"),
],
"adv": [
"ठंडे पेय से परहेज, गर्म दूध + हल्दी पिएं",
"नमक पानी से गरारे दिन में 4-5 बार",
"एंटीबायोटिक पूरा कोर्स लें",
"Rapid Strep Test / Throat swab culture (if recurrent)",
"Tonsillar abscess हो तो तुरंत ENT refer करें",
],
"flow": ["Throat Exam + Temp", "Viral vs Bacterial?", "Antibiotics (if bacterial)", "Analgesic + Gargle", "Culture if no response"],
"icons": ["🔍","🦠","💊","🏥","🔬"],
},
{
"system": "Respiratory",
"condition": "Acute Bronchitis",
"hindi_co": "C/O: खांसी (कफ के साथ), सीने में जकड़न, हल्का बुखार (1 हफ्ते से)",
"rx": [
("Tab. Azithromycin", "500 mg", "1 OD", "5 days"),
("Tab. Salbutamol", "4 mg", "1 TID", "5 days"),
("Syrup Ambroxol", "30 mg/5ml","2 tsp TID", "7 days"),
("Tab. Montelukast", "10 mg", "1 OD (रात)", "7 days"),
("Tab. Paracetamol", "500 mg", "SOS fever", "3 days"),
],
"adv": [
"धूम्रपान बिल्कुल बंद करें",
"Pursed lip breathing का अभ्यास करें",
"भाप (Steam inhalation) दिन में 3 बार",
"Sputum बढ़े या सांस फूले — X-Ray Chest करवाएं",
"SPO2 < 94% हो तो तुरंत अस्पताल जाएं",
],
"flow": ["H/O + Auscultation", "CXR if >1 week", "Bronchodilator + Mucolytic", "Antibiotic if purulent sputum", "Spirometry if recurrent"],
"icons": ["🫁","📷","💊","🌡️","📊"],
},
{
"system": "Respiratory",
"condition": "Community-Acquired Pneumonia",
"hindi_co": "C/O: तेज बुखार, खांसी (पीला/हरा कफ), सांस फूलना, सीने में दर्द",
"rx": [
("Inj. Ceftriaxone", "1 g IV", "BD", "5-7 days"),
("Tab. Azithromycin", "500 mg", "1 OD", "5 days"),
("Inj. Paracetamol", "1 g IV", "TID (SOS)", "3 days"),
("O2 via mask", "—", "Maintain SpO2 ≥95%","Till stable"),
("IV fluids NS", "500ml", "Q8H", "2 days"),
],
"adv": [
"अस्पताल में भर्ती (Hospitalize) — moderate/severe pneumonia",
"CURB-65 score assess करें (0-1: OPD, ≥2: admit)",
"Blood culture before antibiotics",
"CXR chest PA view — admission + 4 weeks follow-up",
"Pulse oximetry monitoring हर 4 घंटे",
],
"flow": ["CURB-65 Score", "CXR + CBC + Culture", "O2 Therapy", "IV Antibiotics", "Oral Switch at 48h"],
"icons": ["📊","📷","💨","💉","💊"],
},
{
"system": "Respiratory",
"condition": "Acute Asthma Attack",
"hindi_co": "C/O: अचानक सांस फूलना, सीने में कसाव, सांय-सांय आवाज (wheeze), खांसी",
"rx": [
("Nebulization Salbutamol", "2.5 mg", "Q20 min × 3", "1st hour"),
("Inj. Hydrocortisone", "200 mg IV","STAT then Q6H","24 hours"),
("O2 therapy", "—", "SpO2 ≥93%", "Till stable"),
("Tab. Prednisolone", "40 mg", "OD morning", "5 days"),
("Inhaler Ipratropium", "0.5 mg", "Q20 min × 3", "1st hour"),
],
"adv": [
"PEFR measure करें — <50% = severe attack",
"Trigger factors identify करें (dust, smoke, allergen)",
"Spacer के साथ inhaler technique सिखाएं",
"Written Asthma Action Plan दें",
"ICU refer if no response in 1 hour",
],
"flow": ["SpO2 + PEFR", "O2 + Nebulize", "IV Steroids", "Observe 1h", "Discharge/ICU"],
"icons": ["📊","💨","💉","⏱️","🏥"],
},
# ══ GASTROINTESTINAL ═════════════════════════════════════════════════════
{
"system": "Gastrointestinal",
"condition": "Acute Diarrhea",
"hindi_co": "C/O: पानी जैसे दस्त (6-8 बार), पेट में मरोड़, उल्टी, कमजोरी",
"rx": [
("ORS Sachet", "1 sachet/250ml","After every loose stool","Till stops"),
("Tab. Metronidazole", "400 mg", "1 TID", "5 days"),
("Tab. Loperamide", "2 mg", "1 after each stool (max 4/day)","3 days"),
("Tab. Zinc", "20 mg", "1 OD", "14 days"),
("Tab. Ondansetron", "4 mg", "SOS vomiting", "3 days"),
],
"adv": [
"ORS पूरे दिन पीते रहें — dehydration से बचाव",
"BRAT diet: Banana, Rice, Apple, Toast",
"बाहर का खाना बिल्कुल बंद",
"हाथ धोएं (Hand hygiene) — soap से बार-बार",
"Bloody diarrhea / high fever → Hospital admit",
],
"flow": ["Assess Dehydration", "ORS / IV Fluids", "Antibiotic (if indicated)", "Zinc + Probiotics", "Monitor & Educate"],
"icons": ["💧","🧃","💊","🦠","📋"],
},
{
"system": "Gastrointestinal",
"condition": "Gastritis / Peptic Ulcer",
"hindi_co": "C/O: पेट में जलन, खाने के बाद दर्द, एसिडिटी, डकार, उल्टी जैसा लगना",
"rx": [
("Tab. Omeprazole", "20 mg", "1 AC (30 min before meal)","4 weeks"),
("Tab. Domperidone", "10 mg", "1 before meals TID","2 weeks"),
("Syrup Sucralfate", "1 g/5ml", "2 tsp QID (AC + HS)","4 weeks"),
("Tab. Pantoprazole+Domperidone","—","1 OD AC", "4 weeks"),
("Antacid gel (Gelusil)", "—", "2 tsp SOS after meals","As needed"),
],
"adv": [
"मसालेदार, तले-भुने खाने से परहेज",
"NSAIDs (aspirin, brufen) बंद करें",
"छोटे-छोटे meals बार-बार खाएं",
"H. pylori test (Urea Breath Test / Stool antigen)",
"Melena/hematemesis → Emergency admit",
],
"flow": ["H/O + Alarm Signs", "H.pylori Testing", "PPI + Sucralfate", "Diet Modification", "Endoscopy if refractory"],
"icons": ["🔍","🧪","💊","🍽️","🔬"],
},
{
"system": "Gastrointestinal",
"condition": "Acidity / GERD",
"hindi_co": "C/O: सीने में जलन, खट्टी डकार, रात में खांसी, गले में जलन, खाने के बाद बेचैनी",
"rx": [
("Tab. Rabeprazole", "20 mg", "1 OD (AC)", "4-8 weeks"),
("Tab. Mosapride", "5 mg", "1 TID AC", "4 weeks"),
("Syrup Alginate (Gaviscon)","—", "2 tsp after meals + HS","As needed"),
("Tab. Ranitidine", "150 mg", "1 HS (at bedtime)","4 weeks"),
],
"adv": [
"खाने के बाद तुरंत लेटें नहीं (≥2 hrs gap)",
"बिस्तर का Head end 30° ऊंचा रखें",
"चाय/कॉफी/कोल्ड्रिंक कम करें",
"Weight loss अगर BMI >25",
"Alarm features (dysphagia, weight loss) → Endoscopy",
],
"flow": ["GERD Diagnosis", "Lifestyle Changes", "PPI 4-8 wks", "Prokinetic", "Reassess / Endoscopy"],
"icons": ["🔥","🏃","💊","⚖️","🔬"],
},
{
"system": "Gastrointestinal",
"condition": "Intestinal Worm Infestation",
"hindi_co": "C/O: पेट में दर्द, गुदा में खुजली, भूख कम लगना, चिड़चिड़ापन, दांत किटकिटाना (बच्चों में)",
"rx": [
("Tab. Albendazole", "400 mg", "Single dose", "Repeat after 2 wks"),
("Tab. Mebendazole", "100 mg", "BD", "3 days"),
("Syrup Mebendazole", "100 mg/5ml","1 tsp BD (children)","3 days"),
("Tab. Iron + Folic Acid", "—", "1 OD", "30 days (if anaemic)"),
],
"adv": [
"पूरे परिवार को एक साथ दवाई दें",
"नाखून छोटे रखें, हाथ बार-बार धोएं",
"नंगे पांव मिट्टी में न चलें",
"कच्ची सब्जियां अच्छे से धो कर खाएं",
"Stool exam after 2 weeks",
],
"flow": ["Stool Exam", "Anthelmintic Therapy", "Family Treatment", "Nutrition Supplement", "Hygiene Education"],
"icons": ["🔬","💊","👨👩👧","🥦","🧼"],
},
# ══ CARDIOVASCULAR ═══════════════════════════════════════════════════════
{
"system": "Cardiovascular",
"condition": "Hypertension",
"hindi_co": "C/O: सिरदर्द, चक्कर, गर्दन में अकड़न, धड़कन तेज — BP: 160/100 mmHg",
"rx": [
("Tab. Amlodipine", "5 mg", "1 OD morning", "Long-term"),
("Tab. Enalapril", "5 mg", "1 OD", "Long-term"),
("Tab. Losartan", "50 mg", "1 OD (if ACEi cough)","Long-term"),
("Tab. Aspirin", "75 mg", "1 OD after meals","Long-term"),
("Tab. Atorvastatin", "10 mg", "1 OD (night)", "Long-term"),
],
"adv": [
"नमक कम खाएं (<5g/day)",
"रोज 30 मिनट walking करें",
"वजन कम करें (BMI <23)",
"BP home monitoring — diary रखें",
"दवाई कभी बंद न करें (even if BP normal)",
],
"flow": ["BP >140/90 on 2 visits", "Lifestyle Mod 3 months", "Start Antihypertensive", "Target BP <130/80", "End-organ Damage Screen"],
"icons": ["🩺","🏃","💊","🎯","❤️"],
},
{
"system": "Cardiovascular",
"condition": "Stable Angina",
"hindi_co": "C/O: सीने में दबाव/जकड़न (exertion पर), बाएं हाथ में दर्द, पसीना, चलने पर दर्द",
"rx": [
("Tab. Isosorbide Mononitrate","10 mg","1 BD (AC)", "Long-term"),
("Tab. Atenolol", "50 mg", "1 OD", "Long-term"),
("Tab. Aspirin", "75 mg", "1 OD after meals","Long-term"),
("Tab. Atorvastatin", "40 mg", "1 OD night", "Long-term"),
("GTN spray", "0.4 mg", "Under tongue — SOS attack","Episodic"),
],
"adv": [
"GTN spray हमेशा साथ रखें",
"Heavy exertion और emotional stress से बचें",
"ECG + Echo Doppler + TMT करवाएं",
"Cholesterol diet बंद करें",
"Cardiologist referral for stress testing / coronary angiography",
],
"flow": ["ECG + Troponin", "Risk Stratification", "Anti-anginal Therapy", "Antiplatelet + Statin", "Cardiology Referral"],
"icons": ["❤️","📊","💊","🩺","🏥"],
},
{
"system": "Cardiovascular",
"condition": "Rheumatic Fever (ARF)",
"hindi_co": "C/O: जोड़ों में दर्द + सूजन (migratory), बुखार, सीने में दर्द, हाल में गले में दर्द था",
"rx": [
("Inj. Benzathine Penicillin","12 lac U IM","Single dose STAT","—"),
("Tab. Aspirin", "100 mg/kg/day","TID (max 4-6 wks)","Jones Criteria"),
("Tab. Prednisolone", "1-2 mg/kg/day","OD morning", "2-4 weeks (carditis)"),
("Inj. Benzathine Pen (prophylaxis)","12 lac U IM","Every 3-4 wks","5-10 years"),
("Tab. Paracetamol", "15 mg/kg/dose","Q6H (SOS)", "For fever"),
],
"adv": [
"Jones Criteria से diagnose करें (2 major / 1 major + 2 minor)",
"Echo Doppler — valvular damage assess करें",
"Secondary prophylaxis 5-10 साल या 21 वर्ष तक जारी रखें",
"Throat culture / ASO titre",
"Cardiology follow-up हर 3-6 months",
],
"flow": ["Strep Throat Hx", "Jones Criteria", "Penicillin STAT", "Aspirin/Steroid", "Long-term Prophylaxis"],
"icons": ["🦠","📋","💉","💊","📅"],
},
# ══ CNS ══════════════════════════════════════════════════════════════════
{
"system": "CNS",
"condition": "Tension Headache",
"hindi_co": "C/O: सिर में कसाव/भारीपन (दोनों तरफ), गर्दन में अकड़न, तनाव के बाद बढ़ता है",
"rx": [
("Tab. Paracetamol", "650 mg", "1-2 SOS (max 4/day)","As needed"),
("Tab. Ibuprofen", "400 mg", "1 BD (with food)","3 days"),
("Tab. Amitriptyline", "10 mg", "1 OD HS (prophylaxis)","3 months"),
("Tab. Cyclobenzaprine", "5 mg", "1 TID (if muscle spasm)","7 days"),
],
"adv": [
"तनाव प्रबंधन (Stress management) — योग, ध्यान",
"नींद 7-8 घंटे नियमित रखें",
"Screen time कम करें",
"Posture सुधारें — neck exercises करें",
"बुखार / vision change / worst headache → CT scan",
],
"flow": ["H/O + Neuro Exam", "Red Flags?", "Analgesic SOS", "Prophylaxis if frequent", "Lifestyle Counseling"],
"icons": ["🧠","🚨","💊","📅","🧘"],
},
{
"system": "CNS",
"condition": "Migraine",
"hindi_co": "C/O: एक तरफ धड़कन जैसा सिरदर्द, उल्टी, रोशनी/आवाज से परेशानी, Aura (कभी-कभी)",
"rx": [
("Tab. Sumatriptan", "50 mg", "1 at onset of attack","Single dose SOS"),
("Tab. Metoclopramide", "10 mg", "1 with Sumatriptan","Single dose"),
("Tab. Topiramate", "25-50 mg","1 OD (prophylaxis)","3-6 months"),
("Tab. Ibuprofen", "400 mg", "1 BD (acute, if mild)","3 days"),
("Tab. Propranolol", "40 mg", "1 BD (prophylaxis)","3-6 months"),
],
"adv": [
"Migraine diary रखें — triggers note करें",
"Triggers: cheese, chocolate, wine, stress, sleep changes",
"अंधेरे शांत कमरे में आराम करें attack में",
"Hormonal changes note करें (महिलाओं में)",
"≥4 attacks/month → prophylaxis शुरू करें",
],
"flow": ["Classify (with/without aura)", "Acute: Triptan + Antiemetic", "Avoid Triggers", "Prophylaxis if frequent", "Neurology Ref if unclear"],
"icons": ["🔍","💊","🚫","📊","🏥"],
},
{
"system": "CNS",
"condition": "Generalized Tonic-Clonic Seizure",
"hindi_co": "C/O: अचानक होश खोना, पूरे शरीर में झटके आना, मुंह से झाग, बाद में नींद",
"rx": [
("Inj. Diazepam", "10 mg IV SLOW","STAT", "First 5 min"),
("Inj. Lorazepam", "4 mg IV", "STAT (if Diazepam unavailable)","—"),
("Tab. Sodium Valproate", "200-400 mg","BD", "Long-term"),
("Tab. Phenytoin", "100 mg", "TID", "Long-term"),
("Tab. Levetiracetam", "500 mg", "BD", "Long-term"),
],
"adv": [
"Airway protect करें — side position में रखें",
"Blood glucose + CBC + EEG + MRI Brain",
"Driving ban — ≥1 year seizure free",
"दवाई कभी खुद से बंद न करें",
"Status epilepticus → ICU immediately",
],
"flow": ["Secure Airway", "IV Diazepam STAT", "EEG + MRI Brain", "AED long-term", "Neurology Follow-up"],
"icons": ["🫁","💉","🧠","💊","🔬"],
},
{
"system": "CNS",
"condition": "Syncope (Vasovagal)",
"hindi_co": "C/O: अचानक बेहोशी, धड़कन धीमी होना, खड़े रहने पर चक्कर, पसीना, मतली पहले",
"rx": [
("Tab. Fludrocortisone", "0.1 mg", "1 OD", "3 months"),
("Tab. Midodrine", "5 mg", "TID (not at HS)", "3 months"),
("Oral Rehydration", "—", "2-3 L water/day","Ongoing"),
("Tab. Beta-blocker (Atenolol)","25 mg","1 OD (if frequent)","3 months"),
],
"adv": [
"खड़े होने से पहले 천천히 उठें (Tilt training)",
"Compression stockings पहनें",
"Salt intake बढ़ाएं (≥8g/day if no HTN)",
"ECG + Tilt Table Test करवाएं",
"Cardiac syncope rule out (ECG + Echo mandatory)",
],
"flow": ["Exclude Cardiac Cause", "Tilt Table Test", "Physical Countermeasures", "Fludrocortisone/Midodrine", "Cardiologist if recurrent"],
"icons": ["❤️","🧪","🦺","💊","🏥"],
},
# ══ MUSCULOSKELETAL ═══════════════════════════════════════════════════════
{
"system": "Musculoskeletal",
"condition": "Acute Low Back Pain",
"hindi_co": "C/O: कमर में दर्द, झुकने और उठने में तकलीफ, खड़े रहने पर बढ़ता है",
"rx": [
("Tab. Diclofenac", "50 mg", "1 BD (with food)", "5-7 days"),
("Tab. Thiocolchicoside", "4 mg", "1 BD (muscle relaxant)","5 days"),
("Tab. Pantoprazole", "40 mg", "1 AC (gastroprotection)","7 days"),
("Tab. Methylcobalamin", "500 mcg", "1 BD", "30 days"),
("Tab. Paracetamol", "650 mg", "1 TID (if cannot tolerate NSAID)","5 days"),
],
"adv": [
"पूर्ण बेडरेस्ट से बचें — हल्की walking फायदेमंद",
"Hot fomentation (गर्म सेंक) 15 min QID",
"Lumbar support belt पहनें (lifting में)",
"Physiotherapy — Core strengthening exercises",
"Neurological deficit (leg weakness/numbness) → MRI Spine URGENT",
],
"flow": ["Red Flags Screen", "Analgesia + Muscle Relaxant", "Hot Fomentation", "Physiotherapy D3 onwards", "MRI if no response in 6 wks"],
"icons": ["🚨","💊","🔥","🏋️","📷"],
},
{
"system": "Musculoskeletal",
"condition": "Cervical Spondylitis",
"hindi_co": "C/O: गर्दन में दर्द + अकड़न, हाथ में सुन्नपन/झनझनाहट, सिरदर्द (occipital)",
"rx": [
("Tab. Etoricoxib", "60 mg", "1 OD", "10-14 days"),
("Tab. Pregabalin", "75 mg", "1 BD (neuropathic pain)","4 weeks"),
("Tab. Baclofen", "10 mg", "1 TID", "7 days"),
("Tab. Methylcobalamin", "500 mcg", "1 BD", "3 months"),
("Collar support (soft)", "—", "During activity","2-4 weeks"),
],
"adv": [
"X-ray C-spine (AP/Lat/Oblique) करवाएं",
"Cervical traction — physiotherapy dept में",
"Screen time और phone use कम करें",
"Neck isometric exercises daily",
"Myelopathy signs → Neurosurgeon urgent referral",
],
"flow": ["Neuro Exam (UL Power/Reflexes)", "X-Ray C-Spine", "NSAID + Neuropathic agent", "Physiotherapy + Collar", "MRI if radiculopathy"],
"icons": ["🧠","📷","💊","🏥","📊"],
},
{
"system": "Musculoskeletal",
"condition": "Acute Sprain (Ankle/Knee)",
"hindi_co": "C/O: अचानक चोट के बाद जोड़ में दर्द, सूजन, नीलापन, वजन न उठा पाना",
"rx": [
("Tab. Ibuprofen", "400 mg", "1 TID (with food)","5 days"),
("Tab. Paracetamol", "500 mg", "1 TID (alternative)","5 days"),
("Diclofenac gel 1%", "—", "Apply BD-TID locally","7 days"),
("Tab. Thiocolchicoside", "4 mg", "1 BD", "3-5 days"),
],
"adv": [
"RICE Protocol: Rest, Ice, Compression, Elevation",
"पहले 24h ice pack (20 min Q2H)",
"Crepe bandage compression लगाएं",
"X-Ray — Ottawa rules के अनुसार fracture rule out करें",
"Weight bearing as tolerated after 48h",
],
"flow": ["Ottawa Rules Check", "RICE Protocol", "Analgesia", "X-Ray if needed", "Physiotherapy D3"],
"icons": ["🧊","🩹","💊","📷","🏃"],
},
{
"system": "Musculoskeletal",
"condition": "Acute Gout",
"hindi_co": "C/O: बड़े पैर के अंगूठे में अचानक तेज दर्द, सूजन, गर्माहट, लाली (रात में शुरू)",
"rx": [
("Tab. Indomethacin", "50 mg", "1 TID (with food)","5-7 days"),
("Tab. Colchicine", "0.5 mg", "1 BD (alternate)","5 days"),
("Tab. Prednisolone", "30-40 mg","1 OD (if NSAID CI)","5-7 days"),
("Tab. Pantoprazole", "40 mg", "1 AC", "7 days"),
("Tab. Allopurinol", "100-300 mg","1 OD (after acute resolves)","Long-term"),
],
"adv": [
"Serum Uric Acid level check करें",
"Red meat, shellfish, alcohol बंद करें",
"खूब पानी पिएं (≥3 L/day)",
"Acute phase में Allopurinol शुरू न करें",
"Chronic gout → long-term Allopurinol (target UA < 6 mg/dl)",
],
"flow": ["Clinical Diagnosis + Uric Acid", "Acute: NSAID / Colchicine", "Rest + Ice", "After Acute: Allopurinol", "Diet + Hydration Education"],
"icons": ["🔬","💊","🧊","💊","🍽️"],
},
# ══ SKIN ═════════════════════════════════════════════════════════════════
{
"system": "Skin",
"condition": "Fungal Skin Infection (Tinea)",
"hindi_co": "C/O: त्वचा पर गोल-गोल दाने, खुजली, किनारों पर ज्यादा — groins / feet / body",
"rx": [
("Clotrimazole cream 1%", "—", "Apply BD", "4 weeks"),
("Tab. Fluconazole", "150 mg", "1 weekly", "4-6 weeks"),
("Tab. Terbinafine", "250 mg", "1 OD", "2-4 weeks"),
("Miconazole powder", "—", "Apply after bath","4 weeks"),
],
"adv": [
"Antifungal cream + oral tablet combination लें",
"कपड़े रोज बदलें, सूती कपड़े पहनें",
"Steroid cream (betnovate आदि) बिल्कुल न लगाएं",
"Skin dry रखें — पसीना आने पर powder लगाएं",
"परिवार के बाकी सदस्यों को भी check करें",
],
"flow": ["Skin Exam + KOH Mount", "Antifungal (topical + oral)", "Hygiene Education", "Avoid Steroid Creams", "2-week Follow-up"],
"icons": ["🔬","💊","🧼","⚠️","📅"],
},
{
"system": "Skin",
"condition": "Scabies",
"hindi_co": "C/O: रात में तेज खुजली, उंगलियों के बीच, कलाई, कमर पर दाने, घर के सभी लोगों को है",
"rx": [
("Permethrin 5% cream", "—", "Apply neck-to-toe, wash 8-10h later","Repeat in 1 week"),
("Benzyl Benzoate 25%", "—", "Apply BD × 3 days","First-line alt."),
("Tab. Ivermectin", "200 mcg/kg","Single dose", "Repeat after 2 wks"),
("Tab. Cetirizine", "10 mg", "1 OD", "2 weeks (itch)"),
("Calamine lotion", "—", "Apply TID (itch relief)","2 weeks"),
],
"adv": [
"पूरे परिवार को एक साथ इलाज करें",
"कपड़े, बिस्तर, तौलिए गर्म पानी में धोएं",
"इलाज के बाद भी 2-4 हफ्ते खुजली रह सकती है",
"Norwegian scabies → Dermatology referral",
"Scratching से secondary infection हो सकता है",
],
"flow": ["Clinical Exam (burrows)", "Permethrin/Ivermectin", "Antihistamine for itch", "Family Treatment", "Wash all clothing/bedding"],
"icons": ["🔍","💊","💊","👨👩👧","🧺"],
},
{
"system": "Skin",
"condition": "Abscess (Skin/Soft Tissue)",
"hindi_co": "C/O: त्वचा पर सूजन, लाली, गर्माहट, बीच में मवाद, बुखार, दर्द",
"rx": [
("Incision & Drainage", "—", "Primary Rx (I&D)","STAT procedure"),
("Tab. Cloxacillin", "500 mg", "1 QID (empty stomach)","7 days"),
("Tab. Metronidazole", "400 mg", "1 TID", "5-7 days"),
("Tab. Ibuprofen", "400 mg", "1 TID", "5 days"),
("Dressing with Betadine", "—", "Daily wound dressing","Till healed"),
],
"adv": [
"I&D ही primary treatment है — दबाने से मवाद निकालें",
"Culture + Sensitivity of pus send करें",
"Diabetes screen करें (recurrent abscess में)",
"MRSA suspect → Add Co-trimoxazole",
"Spreading cellulitis → Hospital IV antibiotics",
],
"flow": ["Assess Fluctuance", "I&D Procedure", "Wound Packing", "Oral Antibiotics", "Dressing D/E + Culture"],
"icons": ["🔍","🔪","🩹","💊","🔬"],
},
{
"system": "Skin",
"condition": "Urticaria (Hives)",
"hindi_co": "C/O: पूरे शरीर में उठे हुए लाल चकत्ते, तेज खुजली, अचानक शुरू, आते-जाते रहते हैं",
"rx": [
("Tab. Cetirizine", "10 mg", "1 OD", "7-14 days"),
("Tab. Fexofenadine", "180 mg", "1 OD", "7-14 days"),
("Tab. Prednisolone", "20-40 mg","1 OD (3-5 days, severe)","Short course"),
("Inj. Chlorpheniramine", "4 mg IM","STAT (acute severe)","Single dose"),
("Inj. Adrenaline", "0.3 ml SC (1:1000)","If anaphylaxis","STAT"),
],
"adv": [
"Trigger identify करें: food, drugs, insect sting",
"NSAIDs, ACE inhibitors, aspirin बंद करें",
"ANA, CBC, LFT, TFT — workup for chronic urticaria",
"Anaphylaxis के लक्षण → Emergency Epinephrine",
"Epipen — severe allergy वाले हमेशा साथ रखें",
],
"flow": ["Acute/Chronic? Angioedema?", "Antihistamine", "Steroids if severe", "Trigger Avoidance", "Allergy Referral if chronic"],
"icons": ["🔍","💊","💊","🚫","🏥"],
},
# ══ ENT ══════════════════════════════════════════════════════════════════
{
"system": "ENT",
"condition": "Acute Otitis Media",
"hindi_co": "C/O: कान में दर्द, बुखार, कभी-कभी कान से मवाद, सुनाई कम देना (बच्चों में ज्यादा)",
"rx": [
("Tab. Amoxicillin", "500 mg", "1 TID", "7-10 days"),
("Tab. Paracetamol", "500 mg", "1 TID", "5 days"),
("Ear drops Ciprofloxacin","—", "3 drops TID", "7 days (if perforation)"),
("Tab. Cetirizine", "10 mg", "1 OD", "5 days"),
("Nasal drops Xylometazoline","0.1%", "2 drops BD", "3-5 days"),
],
"adv": [
"Pain relief → paracetamol / warm compress over ear",
"कान में पानी न जाने दें",
"कान को खुद से साफ न करें",
"Persistent effusion / hearing loss → ENT audiometry",
"Recurrent AOM → ENT for Grommet tubes consideration",
],
"flow": ["Otoscopy", "Antibiotic + Analgesic", "Decongestant", "Ear Protection", "ENT F/U if effusion"],
"icons": ["👂","💊","💧","⚠️","🏥"],
},
{
"system": "ENT",
"condition": "Acute Sinusitis",
"hindi_co": "C/O: नाक बंद, माथे / गाल पर दर्द, पीला-हरा nasal discharge, बुखार, सिरदर्द",
"rx": [
("Tab. Amoxicillin-Clavulanate","625 mg","1 BD", "7-14 days"),
("Tab. Cetirizine", "10 mg", "1 OD", "7 days"),
("Nasal drops Xylometazoline","0.1%", "2 drops TDS", "5 days"),
("Fluticasone Nasal spray","50 mcg", "2 puffs each nostril OD","4 weeks"),
("Tab. Paracetamol", "500 mg", "1 TID SOS", "5 days"),
],
"adv": [
"Saline nasal irrigation (Jal neti) BD करें",
"भाप लें, सिर को elevate करके सोएं",
"CT PNS — chronic/recurrent sinusitis में",
"Complications (orbital/intracranial) → URGENT hospital",
"Dentist check — odontogenic sinusitis rule out",
],
"flow": ["Clinical Exam", "Antibiotic + Decongestant", "Nasal Steroid", "Saline Irrigation", "CT PNS if >4 weeks"],
"icons": ["👃","💊","💨","💧","📷"],
},
{
"system": "ENT",
"condition": "Tonsillitis / Peritonsillar Abscess",
"hindi_co": "C/O: गले में तेज दर्द, निगलने में तकलीफ, बुखार, एक तरफ सूजन (abscess), आवाज बदलना",
"rx": [
("Inj. Penicillin G", "10 lac U IV BD","Until oral tolerated","3-5 days"),
("Tab. Amoxicillin-Clavulanate","625 mg","1 BD", "10 days (oral)"),
("Tab. Metronidazole", "400 mg", "1 TID", "7 days"),
("Tab. Paracetamol", "1g", "QID", "5 days"),
("Betadine Gargle", "0.5%", "BD gargle", "7 days"),
],
"adv": [
"Peritonsillar abscess → ENT for needle aspiration / I&D",
"Throat culture लें",
"Airway obstruction → Emergency ENT (Quinsy position)",
"Recurrent tonsillitis (≥7/yr) → Tonsillectomy discuss",
"Mono (EBV) ruled out — blood film + Monospot test",
],
"flow": ["Assess Airway", "Peritonsillar Abscess?", "IV Antibiotics", "ENT Drainage if needed", "Tonsillectomy Referral"],
"icons": ["🫁","🔍","💉","🏥","📅"],
},
# ══ PEDIATRICS ═══════════════════════════════════════════════════════════
{
"system": "Pediatrics",
"condition": "Pediatric Fever",
"hindi_co": "C/O (माता-पिता): बच्चे को बुखार है, चिड़चिड़ापन, कम खाना, उम्र 3 साल, Temp: 39.2°C",
"rx": [
("Syrup Paracetamol", "15 mg/kg/dose","Q6H SOS", "Till fever<38.5°C"),
("Syrup Ibuprofen", "10 mg/kg/dose","Q8H (alt.)<6 months: avoid)","3-5 days"),
("Tepid Sponging", "—", "If >39°C", "PRN"),
("ORS / extra fluids", "—", "Push fluids", "Throughout fever"),
],
"adv": [
"Fever > 5 days → CBC, Malaria, Dengue, Urine R/E",
"Febrile seizure precautions (if history)",
"Warm water sponging — not cold water or alcohol",
"Vaccinations up to date? Check immunization card",
"Refusal to eat/drink + lethargy → Hospital",
],
"flow": ["Assess Temp + Source", "Antipyretic (weight-based)", "Tepid Sponging", "Push Fluids", "Investigate if >5 days"],
"icons": ["🌡️","💊","🧊","💧","🔬"],
},
{
"system": "Pediatrics",
"condition": "Pediatric Diarrhea",
"hindi_co": "C/O (माता-पिता): बच्चे को पतले दस्त, 8-10 बार, उल्टी, आंखें धंसी, प्यास लगना — 1 वर्ष आयु",
"rx": [
("ORS (WHO formulation)", "75 ml/kg","Over 4 hours (rehydration phase)","First 4h"),
("ORS (maintenance)", "10 ml/kg after each stool","Ongoing","Till stops"),
("Zinc syrup", "10-20 mg/day (age-based)","OD", "14 days"),
("Syrup Ondansetron", "0.15 mg/kg","SOS vomiting", "3 days"),
("Continue Breastfeeding", "—", "Do not stop", "Throughout"),
],
"adv": [
"Dehydration assess: Sunken eyes, no tears, dry mouth, skin turgor",
"Severe dehydration (Plan C) → IV fluids — Hospital admit",
"Bloody diarrhea → Hospital + stool culture",
"Rotavirus vaccination status check करें",
"WASH: Clean water, Sanitation, Hygiene education",
],
"flow": ["Dehydration Assessment (PLAN A/B/C)", "ORS Rehydration", "Zinc 14 days", "Continue Feeding", "IV if Plan C"],
"icons": ["💧","🧃","💊","🍼","🏥"],
},
{
"system": "Pediatrics",
"condition": "Pediatric Pneumonia",
"hindi_co": "C/O: बच्चे को तेज बुखार, तेज सांस (RR >50/min, 1 साल), नाक के पंख फड़कना, खांसी",
"rx": [
("Syrup Amoxicillin", "40 mg/kg/day","BD", "7 days (mild-moderate)"),
("Inj. Ampicillin", "50 mg/kg IV QID","For admitted cases","5-7 days"),
("Inj. Gentamicin", "7.5 mg/kg/day OD","Severe cases","5-7 days"),
("O2 via nasal prongs", "—", "SpO2 ≥93%", "Till stable"),
("Syrup Paracetamol", "15 mg/kg Q6H","SOS fever", "3 days"),
],
"adv": [
"WHO IMCI criteria for pneumonia: Fast breathing + cough",
"Severe: chest in-drawing, SpO2<90%, unable to feed → Hospital",
"PCV vaccine (Pneumococcal) — check immunization",
"Exclusive breastfeeding 0-6 months — preventive",
"Reassess after 48 hours — if worse → upgrade antibiotics",
],
"flow": ["RR Count + SpO2", "O2 if SpO2<93%", "Antibiotics (weight-based)", "Reassess 48h", "Admit if severe"],
"icons": ["🫁","💨","💊","📊","🏥"],
},
{
"system": "Pediatrics",
"condition": "Bronchiolitis (Infants)",
"hindi_co": "C/O: शिशु (6 महीने) को घर-घर आवाज (wheeze), तेज सांस, खांसी, दूध नहीं पी पा रहा",
"rx": [
("O2 therapy", "—", "Maintain SpO2 ≥93%","Till stable"),
("Nebulization Hypertonic Saline 3%","4 ml","Q8H", "5 days"),
("Nasal suctioning", "—", "PRN (before feeds)","As needed"),
("IV Fluids (1/2 NS in 5% Dextrose)","—","75% maintenance","If feeding poor"),
],
"adv": [
"RSV सबसे common cause — antibiotics की जरूरत नहीं",
"Salbutamol nebulization का कोई proven benefit नहीं",
"Breastfeeding जारी रखें — small frequent feeds",
"Premature / CHD शिशु → Hospital admit जरूरी",
"Parent education: hand washing से RSV spread रोकें",
],
"flow": ["SpO2 + RR + Feeding", "O2 + Hypertonic Saline", "Nasal Suction", "Supportive Care", "Admit if SpO2<90% / poor feeding"],
"icons": ["📊","💨","👃","🍼","🏥"],
},
# ══ OBG BASICS ═══════════════════════════════════════════════════════════
{
"system": "OBG",
"condition": "Antenatal Care (ANC) Basics",
"hindi_co": "C/O: 12 सप्ताह गर्भावस्था, पहली ANC visit, उल्टी, थकान, HB 9.8 g/dl",
"rx": [
("Tab. Folic Acid", "5 mg", "1 OD", "Till 12 weeks"),
("Tab. Iron + Folic Acid", "100 mg elemental Fe","1 OD (after 14 wks)","Till delivery"),
("Tab. Calcium", "500 mg", "BD", "Till delivery"),
("Tab. Pyridoxine", "25 mg", "TID (for nausea)","1st trimester"),
("Tab. Ondansetron", "4 mg", "BD SOS (severe vomiting)","1st trimester"),
],
"adv": [
"ANC schedule: 1st visit <12 wks, then monthly till 28 wks, fortnightly till 36 wks, weekly thereafter",
"Investigations: HB, blood group, urine R/E, VDRL, HIV, Sugar",
"USG at 11-13 wks (NT scan), 18-20 wks (anomaly scan)",
"Tetanus Toxoid (TT) vaccine — 2 doses",
"Danger signs: bleeding, severe headache, reduced fetal movements → Hospital",
],
"flow": ["ANC Registration", "Investigations + USG", "Iron/Folic/Ca supplements", "TT Vaccination", "Danger Sign Counseling"],
"icons": ["🤰","🔬","💊","💉","⚠️"],
},
{
"system": "OBG",
"condition": "Dysmenorrhea (Painful Periods)",
"hindi_co": "C/O: माहवारी के दिनों में पेट में ऐंठन, कमर दर्द, उल्टी, काम में बाधा",
"rx": [
("Tab. Mefenamic Acid", "500 mg", "1 TID (start 1 day before)","3-5 days of period"),
("Tab. Ibuprofen", "400 mg", "1 TID (with food)","3-5 days"),
("Tab. Drotaverine (No-Spa)","40 mg", "1 TID (antispasmodic)","3 days"),
("OCP (combined, if indicated)","—", "As per cycle", "3-6 months trial"),
("Tab. Tranexamic Acid", "500 mg", "1 TID (if heavy flow)","3-5 days"),
],
"adv": [
"Primary vs Secondary dysmenorrhea — pelvic exam",
"USG pelvis — Endometriosis / Fibroids rule out",
"गर्म पानी की बोतल रखें पेट पर",
"Regular exercise (walking, yoga) — periods के बीच में",
"Persistent pain → Gynecology referral",
],
"flow": ["Primary vs Secondary?", "NSAIDs / Antispasmodic", "USG Pelvis", "OCP trial (primary)", "Gyn Referral if secondary"],
"icons": ["🔍","💊","📷","💊","🏥"],
},
# ══ EMERGENCY ════════════════════════════════════════════════════════════
{
"system": "Emergency",
"condition": "Anaphylaxis",
"hindi_co": "C/O: अचानक सांस फूलना, गले में सूजन, पित्ती, BP गिरना — दवाई/खाने के बाद",
"rx": [
("Inj. Adrenaline 1:1000", "0.3-0.5 ml IM","Thigh STAT", "Repeat after 5-15 min"),
("Inj. Chlorpheniramine", "10 mg IV SLOW","STAT", "Single"),
("Inj. Hydrocortisone", "200 mg IV", "STAT", "Q6H"),
("O2 high flow", "10-15 L/min","Face mask", "Till stable"),
("IV fluids NS", "1L", "Fast (500ml/15 min)","Shock"),
],
"adv": [
"IM Adrenaline in anterolateral thigh (NOT IV unless cardiac arrest)",
"Supine position with legs raised (if hypotensive)",
"Airway secured — intubation if stridor/airway edema",
"Observe 4-6 hours minimum (biphasic reaction)",
"Discharge with Epipen prescription + allergy card",
],
"flow": ["Recognize Anaphylaxis", "Adrenaline IM STAT", "O2 + IV Access + Fluids", "Antihistamine + Steroid", "ICU/Observe 6h"],
"icons": ["🚨","💉","💨","💊","🏥"],
},
{
"system": "Emergency",
"condition": "Hypoglycemia (Emergency)",
"hindi_co": "C/O: चक्कर, पसीना, हाथ-पांव कांपना, बेहोशी — Diabetic patient, Blood Sugar: 45 mg/dl",
"rx": [
("Glucose oral 15g", "—", "If conscious: 3-4 biscuits / juice","STAT"),
("Inj. Dextrose 25%", "50 ml IV FAST","If unconscious","STAT then repeat"),
("Inj. Glucagon", "1 mg IM", "If no IV access","STAT"),
("Blood glucose recheck", "—", "After 15 min", "PRN"),
("Long-acting carbohydrate","—", "Once conscious — meal/snack","After recovery"),
],
"adv": [
"Rule of 15: 15g fast carb → recheck in 15 min → repeat if BG <70",
"Insulin/OHA dose review करें",
"Skipping meals बंद करें — regular meal timing",
"Glucagon kit घर पर रखें (Type 1 DM)",
"Recurrent hypoglycemia → Endocrinology referral",
],
"flow": ["Check BG <70 mg/dl", "Conscious: Oral Glucose", "Unconscious: IV Dextrose 25%", "Recheck BG after 15 min", "Identify & Fix Cause"],
"icons": ["🩸","🍬","💉","📊","🔍"],
},
{
"system": "Emergency",
"condition": "Acute MI (STEMI) — First Response",
"hindi_co": "C/O: सीने में तेज दर्द (>30 min), जबड़े/बाएं हाथ में दर्द, पसीना, धड़कन तेज, ECG: ST elevation",
"rx": [
("Tab. Aspirin", "300 mg", "Chew STAT", "Single loading dose"),
("Tab. Clopidogrel", "300 mg", "STAT loading", "Then 75 mg OD"),
("Inj. Heparin", "60 U/kg IV","STAT bolus", "Then infusion"),
("GTN spray/SL", "0.4 mg", "SL q5min × 3 (if BP>90)","STAT"),
("Inj. Morphine", "2-4 mg IV SLOW","SOS pain", "Till pain free"),
],
"adv": [
"MONA: Morphine, O2, Nitrates, Aspirin",
"12-lead ECG within 10 minutes — STEMI confirmation",
"Primary PCI goal: Door-to-balloon <90 min",
"Thrombolysis if PCI not available within 120 min",
"CCU admission immediately — cardiac monitoring",
],
"flow": ["12-lead ECG <10 min", "MONA Protocol", "Dual Antiplatelet + Heparin", "Primary PCI <90 min / Thrombolysis", "CCU Admission"],
"icons": ["❤️","⚡","💊","🏥","📊"],
},
]
# ─── Page Drawing Function ─────────────────────────────────────────────────────
PAGE_W, PAGE_H = A4
MARGIN = 18*mm
def draw_medicine_icon(c, x, y, medicine_name, color):
"""Draw a stylized pill/tablet icon with medicine name."""
# Pill capsule shape
pill_w, pill_h = 28, 14
# Left half (rounded)
c.setFillColor(color)
c.circle(x + pill_h//2, y + pill_h//2, pill_h//2, fill=1, stroke=0)
# Right half (different color)
c.setFillColor(colors.white)
c.circle(x + pill_w - pill_h//2, y + pill_h//2, pill_h//2, fill=1, stroke=0)
# Middle rectangle
c.setFillColor(color)
c.rect(x + pill_h//2, y, pill_w - pill_h, pill_h, fill=1, stroke=0)
c.setFillColor(colors.white)
c.rect(x + pill_w//2, y, pill_w//2 - pill_h//2, pill_h, fill=1, stroke=0)
# Border
c.setStrokeColor(color)
c.setLineWidth(1)
c.roundRect(x, y, pill_w, pill_h, pill_h//2, fill=0, stroke=1)
# Line separator
c.setStrokeColor(colors.HexColor("#CCCCCC"))
c.setLineWidth(0.5)
c.line(x + pill_w//2, y+2, x + pill_w//2, y+pill_h-2)
def draw_rx_page(c, case_data, page_num, total_pages):
"""Draw one complete prescription page."""
sys_name = case_data["system"]
sys_color = SYSTEM_COLORS.get(sys_name, C_SUBHEADER)
# ── Top banner ─────────────────────────────────────────────────────────
banner_h = 28*mm
c.setFillColor(C_HEADER_BG)
c.rect(0, PAGE_H - banner_h, PAGE_W, banner_h, fill=1, stroke=0)
# Accent stripe
c.setFillColor(sys_color)
c.rect(0, PAGE_H - banner_h, 6*mm, banner_h, fill=1, stroke=0)
# Title text
c.setFillColor(C_HEADER_TEXT)
c.setFont("Helvetica-Bold", 16)
c.drawString(MARGIN + 6*mm, PAGE_H - 13*mm, case_data["condition"])
# System badge
badge_text = f" {sys_name} "
badge_w = len(badge_text)*5.5 + 4
badge_x = PAGE_W - MARGIN - badge_w
c.setFillColor(sys_color)
c.roundRect(badge_x, PAGE_H - 12*mm, badge_w, 8*mm, 2*mm, fill=1, stroke=0)
c.setFillColor(colors.white)
c.setFont("Helvetica-Bold", 8)
c.drawCentredString(badge_x + badge_w/2, PAGE_H - 7.5*mm, sys_name.upper())
# Page number
c.setFillColor(colors.HexColor("#AAAAAA"))
c.setFont("Helvetica", 7)
c.drawRightString(PAGE_W - MARGIN + 2*mm, PAGE_H - banner_h + 2*mm, f"Pg {page_num}/{total_pages}")
# Subtitle
c.setFillColor(colors.HexColor("#BDC3C7"))
c.setFont("Helvetica", 8)
c.drawString(MARGIN + 6*mm, PAGE_H - 22*mm, f"Medical Reference | Emergency & OPD Quick Prescription Guide")
current_y = PAGE_H - banner_h - 6*mm
# ── C/O Box (Hindi) ───────────────────────────────────────────────────
box_h = 18*mm
c.setFillColor(C_YELLOW_BG)
c.setStrokeColor(colors.HexColor("#F39C12"))
c.setLineWidth(1.5)
c.roundRect(MARGIN, current_y - box_h, PAGE_W - 2*MARGIN, box_h, 3*mm, fill=1, stroke=1)
# C/O Label
c.setFillColor(C_ACCENT)
c.setFont("Helvetica-Bold", 12)
c.drawString(MARGIN + 4*mm, current_y - 7*mm, "C/O")
c.setFillColor(C_DARK)
c.setFont("Helvetica", 9)
# Word-wrap the Hindi text
co_text = case_data["hindi_co"]
# Simple line wrapping
max_w = PAGE_W - 2*MARGIN - 18*mm
words = co_text.split(" ")
line1, line2 = "", ""
for w in words:
test = (line1 + " " + w).strip()
if c.stringWidth(test, "Helvetica", 9) < max_w:
line1 = test
else:
line2 = (line2 + " " + w).strip()
c.drawString(MARGIN + 14*mm, current_y - 7*mm, line1)
if line2:
c.drawString(MARGIN + 14*mm, current_y - 12.5*mm, line2)
current_y -= box_h + 4*mm
# ── Rx Header ─────────────────────────────────────────────────────────
rx_h = 8*mm
c.setFillColor(sys_color)
c.rect(MARGIN, current_y - rx_h, PAGE_W - 2*MARGIN, rx_h, fill=1, stroke=0)
c.setFillColor(colors.white)
c.setFont("Helvetica-Bold", 13)
c.drawString(MARGIN + 3*mm, current_y - 5.5*mm, "℞ Prescription")
# Column headers
c.setFont("Helvetica-Bold", 7.5)
col_x = [MARGIN+3*mm, MARGIN+85*mm, MARGIN+113*mm, MARGIN+143*mm, MARGIN+163*mm]
headers = ["Medicine", "Dose", "Frequency", "Duration", ""]
for i, h in enumerate(headers):
c.drawString(col_x[i], current_y - 5.5*mm, h)
current_y -= rx_h + 1*mm
# ── Rx Table ──────────────────────────────────────────────────────────
row_h = 13*mm
rx_data = case_data["rx"]
for idx, (med, dose, freq, duration) in enumerate(rx_data):
bg = C_RX_BG if idx % 2 == 0 else colors.white
c.setFillColor(bg)
c.rect(MARGIN, current_y - row_h, PAGE_W - 2*MARGIN, row_h, fill=1, stroke=0)
# Light separator line
c.setStrokeColor(colors.HexColor("#D5D8DC"))
c.setLineWidth(0.5)
c.line(MARGIN, current_y - row_h, PAGE_W - MARGIN, current_y - row_h)
# Number bubble
bubble_r = 3.8*mm
c.setFillColor(sys_color)
c.circle(MARGIN + bubble_r, current_y - row_h/2, bubble_r, fill=1, stroke=0)
c.setFillColor(colors.white)
c.setFont("Helvetica-Bold", 8)
c.drawCentredString(MARGIN + bubble_r, current_y - row_h/2 - 2.5, str(idx+1))
# Draw medicine pill icon
draw_medicine_icon(c, MARGIN + 9*mm, current_y - row_h/2 - 3.5, med, sys_color)
# Medicine name
c.setFillColor(C_DARK)
c.setFont("Helvetica-Bold", 8.5)
# truncate if too long
med_display = med if len(med) <= 28 else med[:26]+"…"
c.drawString(MARGIN + 40*mm, current_y - row_h/2 + 1, med_display)
# Dose
c.setFillColor(colors.HexColor("#1A5276"))
c.setFont("Helvetica-Bold", 8)
c.drawString(col_x[1], current_y - row_h/2 + 1, dose)
# Frequency
c.setFillColor(C_DARK)
c.setFont("Helvetica", 7.5)
c.drawString(col_x[2], current_y - row_h/2 + 1, freq)
# Duration badge
dur_w = min(c.stringWidth(duration, "Helvetica-Bold", 7) + 6, 35)
c.setFillColor(C_FLOW_BG)
c.roundRect(col_x[3], current_y - row_h/2 - 2, dur_w, 7*mm, 1.5*mm, fill=1, stroke=0)
c.setFillColor(C_SUBHEADER)
c.setFont("Helvetica-Bold", 7)
c.drawString(col_x[3]+3, current_y - row_h/2 + 1, duration)
current_y -= row_h
current_y -= 3*mm
# ── Advice Box ────────────────────────────────────────────────────────
n_adv = len(case_data["adv"])
adv_row_h = 7.5*mm
adv_h = n_adv * adv_row_h + 10*mm
c.setFillColor(C_ADVICE_BG)
c.setStrokeColor(colors.HexColor("#27AE60"))
c.setLineWidth(1.5)
c.roundRect(MARGIN, current_y - adv_h, PAGE_W - 2*MARGIN, adv_h, 3*mm, fill=1, stroke=1)
# Adv header
c.setFillColor(colors.HexColor("#27AE60"))
c.rect(MARGIN, current_y - 9*mm, PAGE_W - 2*MARGIN, 9*mm, fill=1, stroke=0)
c.roundRect(MARGIN, current_y - 9*mm, PAGE_W - 2*MARGIN, 9*mm, 3*mm, fill=1, stroke=0)
c.setFillColor(colors.white)
c.setFont("Helvetica-Bold", 10)
c.drawString(MARGIN + 4*mm, current_y - 5.5*mm, "Adv. (Patient Advice / Precautions)")
adv_y = current_y - 9*mm - 2*mm
for i, adv_item in enumerate(case_data["adv"]):
adv_y -= adv_row_h
# Bullet
c.setFillColor(colors.HexColor("#27AE60"))
c.circle(MARGIN + 5*mm, adv_y + adv_row_h/2 - 1, 1.8, fill=1, stroke=0)
c.setFillColor(C_DARK)
c.setFont("Helvetica", 7.5)
adv_display = adv_item if len(adv_item) <= 95 else adv_item[:93]+"…"
c.drawString(MARGIN + 9*mm, adv_y + adv_row_h/2 - 1, adv_display)
current_y -= adv_h + 4*mm
# ── Treatment Flow ─────────────────────────────────────────────────────
flow_items = case_data["flow"]
icons_list = case_data["icons"]
n_flow = len(flow_items)
flow_h = 22*mm
c.setFillColor(C_HEADER_BG)
c.setStrokeColor(C_HEADER_BG)
c.roundRect(MARGIN, current_y - flow_h, PAGE_W - 2*MARGIN, flow_h, 3*mm, fill=1, stroke=0)
c.setFillColor(colors.white)
c.setFont("Helvetica-Bold", 8)
c.drawString(MARGIN + 3*mm, current_y - 6*mm, "QUICK-VIEW TREATMENT FLOW:")
flow_w = (PAGE_W - 2*MARGIN - 6*mm) / n_flow
for i, (step, icon) in enumerate(zip(flow_items, icons_list)):
fx = MARGIN + 3*mm + i * flow_w
box_w = flow_w - 2*mm
# Flow box
c.setFillColor(C_FLOW_BG)
c.roundRect(fx, current_y - flow_h + 2*mm, box_w, 13*mm, 2*mm, fill=1, stroke=0)
# Arrow between boxes
if i < n_flow - 1:
arr_x = fx + box_w + 0.5*mm
arr_y = current_y - flow_h + 8.5*mm
c.setFillColor(colors.HexColor("#5DADE2"))
c.drawString(arr_x, arr_y, "›")
# Step text (with icon using regular chars)
step_short = step if len(step) <= 18 else step[:16]+"…"
c.setFillColor(C_DARK)
c.setFont("Helvetica-Bold", 6.5)
# Center text
tw = c.stringWidth(step_short, "Helvetica-Bold", 6.5)
tx = fx + (box_w - tw) / 2
c.drawString(tx, current_y - flow_h + 10*mm, step_short)
# Step number circle
c.setFillColor(sys_color)
c.circle(fx + box_w/2, current_y - flow_h + 5*mm, 2.5*mm, fill=1, stroke=0)
c.setFillColor(colors.white)
c.setFont("Helvetica-Bold", 7)
c.drawCentredString(fx + box_w/2, current_y - flow_h + 3.5*mm, str(i+1))
# ── Footer ─────────────────────────────────────────────────────────────
footer_y = 8*mm
c.setFillColor(colors.HexColor("#2C3E50"))
c.rect(0, 0, PAGE_W, footer_y + 2*mm, fill=1, stroke=0)
c.setFillColor(colors.HexColor("#BDC3C7"))
c.setFont("Helvetica", 6.5)
c.drawString(MARGIN, footer_y - 2, "For educational reference only. Always verify doses before prescribing. Adjust per patient weight, age, renal/hepatic function.")
c.setFillColor(colors.HexColor("#85C1E9"))
c.setFont("Helvetica-Bold", 6.5)
c.drawRightString(PAGE_W - MARGIN, footer_y - 2, f"MedScript Quick Reference 2026 | {sys_name}")
def draw_cover_page(c):
"""Draw a professional cover page."""
PAGE_W, PAGE_H = A4
# Background gradient simulation
c.setFillColor(C_HEADER_BG)
c.rect(0, 0, PAGE_W, PAGE_H, fill=1, stroke=0)
# Top accent band
c.setFillColor(C_ACCENT)
c.rect(0, PAGE_H - 8*mm, PAGE_W, 8*mm, fill=1, stroke=0)
# Side accent stripe
c.setFillColor(C_PILL)
c.rect(0, 0, 10*mm, PAGE_H, fill=1, stroke=0)
# Main title area
c.setFillColor(colors.white)
c.setFont("Helvetica-Bold", 32)
c.drawCentredString(PAGE_W/2 + 5*mm, PAGE_H/2 + 60*mm, "MedScript")
c.setFont("Helvetica-Bold", 20)
c.drawCentredString(PAGE_W/2 + 5*mm, PAGE_H/2 + 44*mm, "Quick Reference Guide")
# Subtitle
c.setFillColor(colors.HexColor("#85C1E9"))
c.setFont("Helvetica", 13)
c.drawCentredString(PAGE_W/2 + 5*mm, PAGE_H/2 + 30*mm, "Hindi C/O · English Rx · Dose & Frequency")
c.drawCentredString(PAGE_W/2 + 5*mm, PAGE_H/2 + 22*mm, "Patient Advice · Treatment Flow · Emergency Protocols")
# Separator line
c.setStrokeColor(C_ACCENT)
c.setLineWidth(2)
c.line(MARGIN + 10*mm, PAGE_H/2 + 14*mm, PAGE_W - MARGIN - 10*mm, PAGE_H/2 + 14*mm)
# Systems covered
systems = list(SYSTEM_COLORS.keys())
c.setFillColor(colors.HexColor("#D5D8DC"))
c.setFont("Helvetica-Bold", 9)
c.drawCentredString(PAGE_W/2 + 5*mm, PAGE_H/2 + 6*mm, "SYSTEMS COVERED:")
for i, (sys, col) in enumerate(SYSTEM_COLORS.items()):
row = i // 5
col_n = i % 5
bx = MARGIN + 10*mm + col_n * 33*mm + 5*mm
by = PAGE_H/2 - 6*mm - row * 14*mm
c.setFillColor(col)
c.roundRect(bx, by, 30*mm, 10*mm, 2*mm, fill=1, stroke=0)
c.setFillColor(colors.white)
c.setFont("Helvetica-Bold", 7)
c.drawCentredString(bx + 15*mm, by + 3.5*mm, sys.upper())
# Stats
c.setFillColor(colors.HexColor("#85C1E9"))
c.setFont("Helvetica", 10)
c.drawCentredString(PAGE_W/2 + 5*mm, PAGE_H/2 - 34*mm, f"35+ Clinical Conditions · All Major Body Systems")
# Date
c.setFillColor(colors.HexColor("#7F8C8D"))
c.setFont("Helvetica", 8)
c.drawCentredString(PAGE_W/2 + 5*mm, PAGE_H/2 - 44*mm, "Edition: June 2026 | For Medical Education & Clinical Reference")
# Bottom decoration
c.setFillColor(colors.HexColor("#1ABC9C"))
c.rect(0, 0, PAGE_W, 15*mm, fill=1, stroke=0)
c.setFillColor(colors.white)
c.setFont("Helvetica-Bold", 9)
c.drawCentredString(PAGE_W/2, 6*mm, "Important: For educational use only. All prescriptions must be verified by a qualified physician.")
# Rx symbol large
c.setFillColor(colors.HexColor("#2C3E50"))
c.setFont("Helvetica-Bold", 100)
c.setFillColorAlpha = lambda x: None # transparency not needed
c.setFillColor(colors.HexColor("#243B55"))
c.drawString(PAGE_W - 60*mm, PAGE_H/2 - 20*mm, "℞")
def draw_index_page(c, cases):
"""Draw a table of contents / index page."""
PAGE_W, PAGE_H = A4
c.setFillColor(colors.white)
c.rect(0, 0, PAGE_W, PAGE_H, fill=1, stroke=0)
# Header
c.setFillColor(C_HEADER_BG)
c.rect(0, PAGE_H - 22*mm, PAGE_W, 22*mm, fill=1, stroke=0)
c.setFillColor(C_ACCENT)
c.rect(0, PAGE_H - 22*mm, 6*mm, 22*mm, fill=1, stroke=0)
c.setFillColor(colors.white)
c.setFont("Helvetica-Bold", 18)
c.drawString(MARGIN, PAGE_H - 13*mm, "Index of Conditions")
c.setFont("Helvetica", 9)
c.setFillColor(colors.HexColor("#BDC3C7"))
c.drawString(MARGIN, PAGE_H - 19*mm, "Click to navigate · Organized by System")
# Group by system
from collections import OrderedDict
grouped = OrderedDict()
for i, case in enumerate(cases):
sys = case["system"]
if sys not in grouped:
grouped[sys] = []
grouped[sys].append((i+3, case["condition"])) # +3 for cover + index pages
y = PAGE_H - 28*mm
col_width = (PAGE_W - 2*MARGIN) / 2
col = 0
x_base = [MARGIN, MARGIN + col_width + 3*mm]
for sys, items in grouped.items():
sys_color = SYSTEM_COLORS.get(sys, C_SUBHEADER)
x = x_base[col]
# System header
c.setFillColor(sys_color)
c.rect(x, y - 8*mm, col_width - 3*mm, 8*mm, fill=1, stroke=0)
c.setFillColor(colors.white)
c.setFont("Helvetica-Bold", 9)
c.drawString(x + 3*mm, y - 5.5*mm, f" {sys.upper()}")
y -= 8*mm
for pg, cond in items:
y -= 7*mm
if y < 20*mm:
col += 1
if col > 1:
col = 0
y = PAGE_H - 28*mm
else:
y = PAGE_H - 28*mm
x = x_base[col]
c.setFillColor(colors.HexColor("#F2F3F4"))
c.rect(x, y - 5.5*mm, col_width - 3*mm, 5.5*mm, fill=1, stroke=0)
c.setFillColor(sys_color)
c.circle(x + 3*mm, y - 2.5*mm, 1.5, fill=1, stroke=0)
c.setFillColor(C_DARK)
c.setFont("Helvetica", 7.5)
c.drawString(x + 6*mm, y - 4.5*mm, cond)
c.setFillColor(C_GRAY)
c.setFont("Helvetica", 7)
c.drawRightString(x + col_width - 6*mm, y - 4.5*mm, f"p.{pg}")
y -= 5*mm
if y < 30*mm:
col += 1
if col > 1:
col = 0
y = PAGE_H - 28*mm
# Footer
c.setFillColor(C_HEADER_BG)
c.rect(0, 0, PAGE_W, 8*mm, fill=1, stroke=0)
c.setFillColor(colors.HexColor("#BDC3C7"))
c.setFont("Helvetica", 6.5)
c.drawCentredString(PAGE_W/2, 3*mm, "MedScript Quick Reference Guide 2026 — Educational Use Only")
# ─── MAIN ──────────────────────────────────────────────────────────────────────
output_path = "/home/daytona/workspace/medical-rx-pdf/MedScript_Quick_Reference_2026.pdf"
c = canvas.Canvas(output_path, pagesize=A4)
c.setTitle("MedScript Quick Reference Guide 2026")
c.setAuthor("MedScript Educational Series")
c.setSubject("Hindi Chief Complaints + English Prescriptions — All Major Systems")
# Cover page
draw_cover_page(c)
c.showPage()
# Index page
draw_index_page(c, CASES)
c.showPage()
# Individual case pages
total = len(CASES)
for i, case in enumerate(CASES):
draw_rx_page(c, case, i+3, total+2)
c.showPage()
c.save()
print(f"PDF generated: {output_path}")
print(f"Total pages: {total + 2} ({total} cases + cover + index)")
cd /home/daytona/workspace/medical-rx-pdf && python3 generate_rx_pdf.py 2>&1