Make me a detailed time table for a final year mbbs student for every 11 subjects (which are... medicine, surgery, obgy, pediatrics, ent, opthal, dermat, psychiatry, orthopedics, radiology, anesthesia) from starting tomorrow thay is 15 july till 1 oct... i haven't started anything so i have to start from scratch but i only have 2&½ months so give me detailed plan for everyday (which subject to study on each day with which subjects i can study together on each day)

Searching the Web

MBBS final year exam preparation strategy all 11 subjects time allocation

Searching the Web

MBBS final year subjects syllabus weightage medicine surgery pediatrics OBGyn 2024

Here's a summary of how this plan is structured for you:

How This Plan Works

The 6 phases:
  1. Phase 1 (Jul 15-30, 16 days): Medicine is your anchor subject - paired daily with Radiology so imaging integrates naturally as you read each system
  2. Phase 2 (Jul 31-Aug 13, 14 days): Surgery as primary, with Orthopedics and Anesthesia sharing the afternoon slots - all three are "surgical" in nature so concepts reinforce each other
  3. Phase 3 (Aug 14-29, 16 days): OBGyn + Pediatrics paired together because the neonatal period sits right at the intersection - conditions like RDS, neonatal jaundice, and newborn care come up in both
  4. Phase 4 (Aug 30-Sep 4, 6 days): ENT + Ophthalmology together - both are small specialty subjects, similar exam style, and share Head & Neck anatomy
  5. Phase 5 (Sep 5-10, 6 days): Dermatology + Psychiatry together - both are relatively manageable, and Dermat has strong overlap with Medicine (systemic dermatoses you already know)
  6. Phase 6 (Sep 11-Oct 1, 21 days): Pure revision, mock tests, and cheat sheet review - NO new topics
Why this order?
  • Medicine first because it is the largest subject AND it builds conceptual foundation for Surgery, Pediatrics, Dermat, and Psychiatry
  • Heavy subjects (Medicine, Surgery, OBGyn, Peds) come first when your energy and motivation are highest
  • Lighter subjects (ENT, Ophthal, Dermat, Psychiatry) come in the middle when you need a psychological "breather"
  • The final 21 days are entirely for revision - this is where marks are actually made
The daily structure gives you roughly:
  • 5.5 hours on the primary subject (morning)
  • 3.5 hours on the paired subject (afternoon)
  • 1.5 hours of revision of both (evening)
Good luck - starting from scratch with 2.5 months is absolutely doable with consistent execution!

Generate a printable wall poster of this timetable with everything like which subjects and topics I'm gonna study everyday & also create a daily checklist excel file for the same & also sometimes i have to go to posting from 9-1 in the morning so make a different time table for days like that and... you cab include things like 7 hrs of sleep if possible then 10-11 hrs of study & 1 hr of exercise (i cannot properly focus on early morning so you can include exercise and other thing in the morning & after that study)

Reading File
Reading File
Running Command

ls /home/daytona/workspace/ 2>/dev/null && echo "EXISTS" || mkdir -p /home/daytona/workspace/mbbs-timetable && echo "CREATED"

Writing File

~/mbbs-timetable/build_excel.py

import openpyxl
from openpyxl.styles import (PatternFill, Font, Alignment, Border, Side, 
                               GradientFill)
from openpyxl.utils import get_column_letter
from datetime import date, timedelta

wb = openpyxl.Workbook()

# ─── Color palette ───────────────────────────────────────────────────────────
PHASE_COLORS = {
    "Medicine":      "1565C0",   # deep blue
    "Radiology":     "0288D1",   # light blue
    "Surgery":       "B71C1C",   # deep red
    "Orthopedics":   "E53935",   # bright red
    "Anesthesia":    "FF7043",   # orange
    "OBGyn":         "AD1457",   # pink
    "Pediatrics":    "6A1B9A",   # purple
    "ENT":           "2E7D32",   # dark green
    "Ophthalmology": "388E3C",   # green
    "Dermatology":   "F57F17",   # amber
    "Psychiatry":    "795548",   # brown
    "Revision":      "37474F",   # blue-grey
}

PHASE_BG = {
    "Phase 1 – Medicine + Radiology":          "E3F2FD",
    "Phase 2 – Surgery + Ortho + Anesthesia":  "FFEBEE",
    "Phase 3 – OBGyn + Pediatrics":            "F3E5F5",
    "Phase 4 – ENT + Ophthalmology":           "E8F5E9",
    "Phase 5 – Dermatology + Psychiatry":      "FFF8E1",
    "Phase 6 – Final Revision":                "ECEFF1",
}

WHITE = "FFFFFF"
HEADER_BG = "1A237E"   # navy

thin = Side(style="thin", color="BDBDBD")
thick = Side(style="medium", color="78909C")
border_thin  = Border(left=thin, right=thin, top=thin, bottom=thin)
border_thick = Border(left=thick, right=thick, top=thick, bottom=thick)

def fill(hex_color):
    return PatternFill("solid", fgColor=hex_color)

def font(color="000000", bold=False, size=10, italic=False):
    return Font(name="Arial", color=color, bold=bold, size=size, italic=italic)

def align(h="center", v="center", wrap=True):
    return Alignment(horizontal=h, vertical=v, wrap_text=wrap)

# ─── Timetable data ──────────────────────────────────────────────────────────
days = []

data = [
  # (day_num, date_str, phase, primary_subj, primary_topics, paired_subj, paired_topics, daily_goal)
  (1,"15-Jul-26","Phase 1 – Medicine + Radiology","Medicine","Cardiovascular – Hypertension, Heart Failure (pathophysiology, classification, JVP, CCF management)","Radiology","CXR basics: how to read systematically; cardiomegaly, pulmonary edema signs","Finish JVP, BP regulation, CCF completely"),
  (2,"16-Jul-26","Phase 1 – Medicine + Radiology","Medicine","Cardiovascular – IHD, Angina, MI (types, ECG changes, management, complications)","Radiology","ECG interpretation: STEMI patterns, LVH, LBBB; coronary angiography overview","Complete ACS management algorithm"),
  (3,"17-Jul-26","Phase 1 – Medicine + Radiology","Medicine","Cardiovascular – Valvular heart disease (mitral/aortic stenosis & regurgitation), Infective Endocarditis, Cardiomyopathies","Radiology","Echocardiography basics; mitral stenosis signs on CXR","Complete all cardiac murmurs + Duke criteria"),
  (4,"18-Jul-26","Phase 1 – Medicine + Radiology","Medicine","Respiratory – Asthma, COPD, Pneumonia (bacterial, atypical), Bronchiectasis, TB","Radiology","CXR patterns: consolidation, cavitation, hilar LAD, miliary TB","Finish spirometry, TB drug regimens (HRZE)"),
  (5,"19-Jul-26","Phase 1 – Medicine + Radiology","Medicine","Respiratory – Pleural effusion, Pneumothorax, ARDS, Lung Cancer, ILD","Radiology","CXR: pleural effusion, pneumothorax; CT chest: ground glass, honeycombing","Complete respiratory failure types, ABG interpretation"),
  (6,"20-Jul-26","Phase 1 – Medicine + Radiology","REVISION","Revise Cardio (Days 1-3) with MCQs – morning session","REVISION","Revise Respiratory (Days 4-5) with MCQs – afternoon session","Make short notes/mnemonics for both systems"),
  (7,"21-Jul-26","Phase 1 – Medicine + Radiology","Medicine","GI – GERD, PUD, IBD (Crohn's vs UC), Liver disease (hepatitis, cirrhosis, portal hypertension)","Radiology","USG abdomen basics; liver cirrhosis signs, portal hypertension imaging","Complete Child-Pugh score, hepatic encephalopathy grading"),
  (8,"22-Jul-26","Phase 1 – Medicine + Radiology","Medicine","GI – Jaundice (3 types), Acute pancreatitis, Chronic pancreatitis, Malabsorption","Radiology","MRCP/ERCP overview; pancreatic imaging; Ranson's criteria","Finish all LFT patterns, pancreatitis severity scoring"),
  (9,"23-Jul-26","Phase 1 – Medicine + Radiology","Medicine","Nephrology – AKI, CKD, Nephrotic vs Nephritic syndrome, GN types","Radiology","Renal USG; IVP, CT urography; renal biopsy indications","Complete dialysis indications, electrolyte disorders"),
  (10,"24-Jul-26","Phase 1 – Medicine + Radiology","Medicine","Nephrology – UTI, RTA, Hyponatremia/Hypernatremia, Hypo/Hyperkalemia, Acid-base disorders","Radiology","Plain X-ray KUB; renal calculi imaging","Master ABG + electrolyte interpretation"),
  (11,"25-Jul-26","Phase 1 – Medicine + Radiology","Medicine","Endocrinology – DM (type 1, 2, complications, drugs), Thyroid disorders (hypo/hyperthyroid, goiter, thyroid cancer)","Radiology","Thyroid USG; nuclear medicine basics (thyroid scan)","Complete insulin regimens, OHA classification, TFTs"),
  (12,"26-Jul-26","Phase 1 – Medicine + Radiology","Medicine","Endocrinology – Adrenal (Cushing's, Addison's, Pheo), Pituitary disorders, DI vs SIADH, Calcium disorders","Radiology","Adrenal imaging; pituitary MRI overview; DEXA scan","Complete cortisol axis, aldosterone excess/deficiency"),
  (13,"27-Jul-26","Phase 1 – Medicine + Radiology","REVISION","Revise GI + Liver topics (Days 7-8) – MCQs morning","REVISION","Revise Nephrology (Days 9-10) + Endocrinology (Days 11-12) – MCQs afternoon","Make quick charts for all systems"),
  (14,"28-Jul-26","Phase 1 – Medicine + Radiology","Medicine","Hematology – Anemia (classification, IDA, B12/folate, hemolytic, aplastic), Leukemia, Lymphoma","Radiology","BM biopsy overview; CT chest/abdomen for lymphoma staging","Complete peripheral smear findings, transfusion reactions"),
  (15,"29-Jul-26","Phase 1 – Medicine + Radiology","Medicine","Neurology – Stroke, Epilepsy, Meningitis, Encephalitis, Parkinson's, Dementia, Peripheral neuropathy, MG","Radiology","CT brain: hemorrhage, ischemia, herniation; MRI brain overview","Complete NIHSS, ABCD2 score, anti-epileptic drugs"),
  (16,"30-Jul-26","Phase 1 – Medicine + Radiology","Medicine","Rheumatology (RA, SLE, gout, osteoporosis) + Infectious diseases (sepsis, malaria, typhoid, dengue, HIV) + MCQ marathon","Radiology","Joint X-ray findings; CXR in HIV/opportunistic infections","Finish remaining Medicine high-yield topics; 100+ MCQs"),
  (17,"31-Jul-26","Phase 2 – Surgery + Ortho + Anesthesia","Surgery","Surgical principles – Wound healing, Sutures, Surgical infections, Shock (types, management), Blood transfusion","Anesthesia","Pre-op assessment, ASA grading, consent, fasting guidelines, pre-medication","Complete all shock management types, Sepsis-3 criteria"),
  (18,"01-Aug-26","Phase 2 – Surgery + Ortho + Anesthesia","Surgery","Breast – Anatomy, Benign breast disease, Breast cancer (staging, management, mastectomy types), Nipple discharge","Anesthesia","Induction agents, muscle relaxants, volatile agents, local anesthetics; LA toxicity","Complete TNM staging of breast, sentinel node biopsy"),
  (19,"02-Aug-26","Phase 2 – Surgery + Ortho + Anesthesia","Surgery","Thyroid + Parathyroid – Surgery, Goiter, Thyroid cancer (types), Parathyroid adenoma","Anesthesia","Airway management – intubation, LMA, difficult airway algorithm, RSI","Complete RLN injury types, post-thyroidectomy complications"),
  (20,"03-Aug-26","Phase 2 – Surgery + Ortho + Anesthesia","REVISION","Surgery Days 17-19 MCQs + short notes – morning","Orthopedics","Fracture classification, healing principles, complications overview – afternoon","Complete fracture healing stages, Gustilo classification"),
  (21,"04-Aug-26","Phase 2 – Surgery + Ortho + Anesthesia","Surgery","GI Surgery – Ca esophagus, achalasia, gastric cancer, peptic ulcer surgery, SBO, Appendicitis","Orthopedics","Fractures – fat embolism, AVN, compartment syndrome, malunion; Colles, scaphoid, supracondylar, shoulder","Complete McBurney's, Alvarado score, Hartmann's procedure"),
  (22,"05-Aug-26","Phase 2 – Surgery + Ortho + Anesthesia","Surgery","Colorectal – Ca colon/rectum, diverticulitis, hemorrhoids, fistula-in-ano, pilonidal sinus, anal fissure","Orthopedics","Upper limb fractures – Colles, scaphoid, supracondylar; shoulder dislocations; clavicle fractures","Complete Duke's staging, CEA, Parks fistula classification"),
  (23,"06-Aug-26","Phase 2 – Surgery + Ortho + Anesthesia","Surgery","Hepatobiliary – Liver abscess, hydatid, cholecystitis, cholelithiasis, cholangiocarcinoma, Ca pancreas, portal HTN","Orthopedics","Lower limb fractures – NOF, intertrochanteric, shaft femur, tibial fractures, ankle fractures","Complete Charcot's triad, Reynold's pentad, Whipple procedure"),
  (24,"07-Aug-26","Phase 2 – Surgery + Ortho + Anesthesia","Surgery","Hernia – Types (inguinal, femoral, umbilical, incisional, hiatus), anatomy, complications, surgical repairs","Orthopedics","Spine – PLID, spinal cord injuries (ASIA grading), scoliosis, TB spine (Pott's)","Complete Hasselbach's triangle, Bassini/Lichtenstein differences"),
  (25,"08-Aug-26","Phase 2 – Surgery + Ortho + Anesthesia","Surgery","Vascular – PVD, DVT, varicose veins, AAA, carotid artery disease, amputations, Buerger's disease","Orthopedics","Bone tumors (osteosarcoma, Ewing's), metabolic bone disease, osteomyelitis, septic arthritis","Complete ABPI, DVT prophylaxis guidelines"),
  (26,"09-Aug-26","Phase 2 – Surgery + Ortho + Anesthesia","Surgery","Urology – BPH, prostate cancer, bladder cancer, RCC, urolithiasis, testicular tumors, undescended testis","Orthopedics","Joints – OA, RA surgical mgmt, TKR/THR, gout; Pediatric ortho (DDH, CTEV, LCPD, SCFE)","Complete PSA values, TURP, urological cancer TNM staging"),
  (27,"10-Aug-26","Phase 2 – Surgery + Ortho + Anesthesia","REVISION","Surgery MCQs – GI + Hepatobiliary + Hernia + Vascular + Urology – morning","REVISION","Orthopedics MCQ revision – all topics – afternoon","Identify weak topics for focused re-reading"),
  (28,"11-Aug-26","Phase 2 – Surgery + Ortho + Anesthesia","Surgery","Neurosurgery – Head injury (GCS, EDH vs SDH, DAI), brain tumors, hydrocephalus, spinal surgery overview","Anesthesia","Regional anesthesia – spinal, epidural, nerve blocks; complications of spinal anesthesia","Complete Monro-Kellie doctrine, cushing reflex, burr hole indications"),
  (29,"12-Aug-26","Phase 2 – Surgery + Ortho + Anesthesia","Surgery","Pediatric Surgery – Intussusception, pyloric stenosis, Hirschsprung's, TEF, imperforate anus, Wilm's tumor, neuroblastoma","Anesthesia","Monitoring (ASA standards, BIS, TOF, invasive BP); TIVA; anesthesia for special conditions","Complete VACTERL association, barium enema findings"),
  (30,"13-Aug-26","Phase 2 – Surgery + Ortho + Anesthesia","Surgery","Burns (Rule of 9, Parkland formula), skin tumors (BCC, SCC, melanoma), soft tissue sarcomas + Surgery MCQ marathon","Anesthesia","Complications – malignant hyperthermia, succinylcholine complications, PONV, awareness","Complete Wallace rule of 9s, Breslow thickness, Clark's levels"),
  (31,"14-Aug-26","Phase 3 – OBGyn + Pediatrics","OBGyn","Normal pregnancy – ANC schedule, physiological changes, dating, investigations per trimester","Pediatrics","Normal newborn – APGAR score, newborn examination, milestones (Year 1), immunization schedule","Complete antenatal booking visit, APGAR interpretation, NIP schedule"),
  (32,"15-Aug-26","Phase 3 – OBGyn + Pediatrics","OBGyn","High-risk pregnancy – Hypertension (pre-eclampsia, eclampsia – MgSO4 protocols), Gestational diabetes","Pediatrics","Neonatal emergencies – sepsis, RDS (surfactant), meconium aspiration, HIE (cooling), NEC, neonatal jaundice","Complete MgSO4 Pritchard regime, eclampsia treatment, phototherapy thresholds"),
  (33,"16-Aug-26","Phase 3 – OBGyn + Pediatrics","OBGyn","APH – Placenta previa (grades), abruptio placenta, vasa previa; PPH (4T's, uterotonics, B-Lynch suture)","Pediatrics","Respiratory in children – Croup vs epiglottitis, bronchiolitis, childhood asthma, IMNCI pneumonia","Complete 4T's of PPH, uterotonic drugs, IMNCI pneumonia classification"),
  (34,"17-Aug-26","Phase 3 – OBGyn + Pediatrics","REVISION","OBGyn Days 31-33 MCQs + quick charts – morning","REVISION","Pediatrics Days 31-33 MCQs – afternoon","Make: MgSO4 protocol chart, APGAR table, PPH flowchart"),
  (35,"18-Aug-26","Phase 3 – OBGyn + Pediatrics","OBGyn","Labour – Stages of labour, partograph, CTG interpretation, fetal distress, instrumental delivery, episiotomy","Pediatrics","GI in children – Diarrhea (ORT, IMNCI), typhoid, intussusception, HUS, celiac, malnutrition (SAM/MAM)","Complete CTG decelerations (late/early/variable), MUAC thresholds"),
  (36,"19-Aug-26","Phase 3 – OBGyn + Pediatrics","OBGyn","Obstetric complications – IUGR, PROM, preterm labour (tocolytics, steroids), malpresentations (breech, shoulder, brow, face)","Pediatrics","Neuro in children – febrile seizures, epilepsy, meningitis (bacterial/TB/viral), cerebral palsy","Complete ECV, Zavenelli maneuver; antibiotics for bacterial meningitis"),
  (37,"20-Aug-26","Phase 3 – OBGyn + Pediatrics","OBGyn","Medical disorders in pregnancy – Anemia, cardiac disease, thyroid, renal disease, liver (AFLP, ICP, HELLP)","Pediatrics","Hematology/Oncology – ALL vs AML, lymphoma, hemophilia, ITP, sickle cell, thalassemia management","Complete WHO anemia in pregnancy classification, HELLP triad"),
  (38,"21-Aug-26","Phase 3 – OBGyn + Pediatrics","OBGyn","Gynecology – Menstrual disorders (DUB, PCOS, amenorrhea), infertility (male/female workup, ART), endometriosis, fibroids","Pediatrics","Nephrology in children – nephrotic syndrome (MCD), UTI in children, acute GN, HUS","Complete PCOS Rotterdam criteria, ART indications"),
  (39,"22-Aug-26","Phase 3 – OBGyn + Pediatrics","OBGyn","Gynecology – Cervical cancer (FIGO staging, colposcopy, LEEP, Pap smear), ovarian tumors (epithelial, germ cell, sex cord), endometrial cancer","Pediatrics","Endocrinology in children – Type 1 DM, congenital hypothyroidism, CAH, short stature, precocious puberty","Complete FIGO staging of gyn cancers; DKA management in children"),
  (40,"23-Aug-26","Phase 3 – OBGyn + Pediatrics","OBGyn","Gynecology – Genital prolapse (POP-Q), urinary incontinence (types, management), pelvic floor, vulvar disorders","Pediatrics","Infectious diseases – Measles, mumps, rubella, varicella, Kawasaki, rheumatic fever (Jones criteria), dengue","Complete stress vs urge incontinence; Jones major/minor criteria"),
  (41,"24-Aug-26","Phase 3 – OBGyn + Pediatrics","REVISION","OBGyn Gynecology section MCQs – morning","REVISION","Pediatrics Days 35-40 MCQs – afternoon","Revise overlap topics: newborn complications, maternal conditions affecting fetus"),
  (42,"25-Aug-26","Phase 3 – OBGyn + Pediatrics","OBGyn","STIs + Contraception – STI management (syphilis, gonorrhea, chlamydia, HSV, HPV); OCP, IUCD, barrier, sterilization, emergency contraception","Pediatrics","Nutrition – Vitamin deficiency disorders (A, B, C, D, K), rickets, scurvy, PEM (Kwashiorkor vs Marasmus), breastfeeding","Complete OCP side effects, USMEC categories, Kwashiorkor vs Marasmus differences"),
  (43,"26-Aug-26","Phase 3 – OBGyn + Pediatrics","OBGyn","Ectopic pregnancy, GTD (molar pregnancy, choriocarcinoma), recurrent pregnancy loss","Pediatrics","Genetics/Congenital – Down, Turner's, Klinefelter's, CHD (VSD, ASD, TOF, TGA – features, management), TEF","Complete methotrexate criteria for ectopic; TOF tetralogy features"),
  (44,"27-Aug-26","Phase 3 – OBGyn + Pediatrics","OBGyn","Cesarean section (indications, types, complications), obstetric fistula, post-partum problems, lactation","Pediatrics","Developmental pediatrics – milestones (all ages), ASD, ADHD, learning disabilities + Peds MCQ marathon","Complete puerperal sepsis organisms, developmental red flags"),
  (45,"28-Aug-26","Phase 3 – OBGyn + Pediatrics","OBGyn","OBGyn MCQ marathon + weak area revision (150+ MCQs)","Pediatrics","Pediatrics MCQ marathon + weak area revision (150+ MCQs)","Identify gaps from MCQs – flag for Phase 6 revision"),
  (46,"29-Aug-26","Phase 3 – OBGyn + Pediatrics","REVISION","OBGyn full subject MCQ test – timed 60 Qs in 60 min – morning","REVISION","Pediatrics full subject MCQ test – timed 60 Qs in 60 min – afternoon","Review all wrong answers; make final OBGyn + Peds cheat sheets"),
  (47,"30-Aug-26","Phase 4 – ENT + Ophthalmology","ENT","Ear – Anatomy, otitis media (ASOM, CSOM – safe vs unsafe, cholesteatoma), mastoiditis, otosclerosis","Ophthalmology","Eye anatomy, conjunctivitis (bacterial, viral, allergic, trachoma), corneal ulcer, keratitis","Complete Rinne/Weber tests, tympanogram types"),
  (48,"31-Aug-26","Phase 4 – ENT + Ophthalmology","ENT","Hearing loss (conductive vs SNHL, audiogram), Meniere's, BPPV, labyrinthitis, vestibular schwannoma, cochlear implants","Ophthalmology","Glaucoma (open vs closed angle, IOP, VF defects, drugs), cataract (types, surgery, complications)","Complete Dix-Hallpike, Epley's maneuver; trabeculectomy indications"),
  (49,"01-Sep-26","Phase 4 – ENT + Ophthalmology","ENT","Nose + PNS – Epistaxis (Little's area), DNS, allergic rhinitis, sinusitis (acute/chronic), nasal polyps, antrochoanal polyp","Ophthalmology","Retina – retinal detachment, diabetic retinopathy (classification, laser), hypertensive retinopathy, CRAO, CRVO, AMD","Complete Caldwell-Luc operation; retinal detachment surgery types"),
  (50,"02-Sep-26","Phase 4 – ENT + Ophthalmology","ENT","Throat – Tonsillitis (acute, chronic, quinsy), adenoids, deep neck space infections (Ludwig's angina, parapharyngeal abscess), foreign body airway","Ophthalmology","Squint (types, Hirschberg, cover test), amblyopia, uveitis (HLA-B27), optic neuritis, papilledema","Complete peritonsillar abscess management; internuclear ophthalmoplegia"),
  (51,"03-Sep-26","Phase 4 – ENT + Ophthalmology","ENT","Tumors – Ca larynx (staging, laryngectomy), Ca nasopharynx (EBV), juvenile angiofibroma, salivary gland tumors + ENT MCQ marathon","Ophthalmology","Eyelid/Lacrimal (chalazion, ptosis, DCR), orbit/proptosis, ocular trauma, ocular emergencies + Ophthal MCQ marathon","Complete laryngectomy complications, EBV association, Warthin's tumor"),
  (52,"04-Sep-26","Phase 4 – ENT + Ophthalmology","REVISION","ENT MCQ test – 50 Qs timed – morning","REVISION","Ophthalmology MCQ test – 50 Qs timed – afternoon","Revise all wrong answers; make ENT + Ophthal cheat sheets"),
  (53,"05-Sep-26","Phase 5 – Dermatology + Psychiatry","Dermatology","Lesion morphology (macule, papule, plaque, vesicle, bulla, pustule, wheal), skin exam approach, eczema (atopic, contact, seborrheic), psoriasis (types, PASI, treatment)","Psychiatry","Psychopathology basics, MSE, ICD-10 vs DSM-5, psychiatric history, Major Depressive Disorder (criteria, management)","Complete psoriasis PASI scoring; antidepressant classification (SSRIs, SNRIs, TCAs, MAOIs)"),
  (54,"06-Sep-26","Phase 5 – Dermatology + Psychiatry","Dermatology","Infections – Bacterial (impetigo, cellulitis, erysipelas, folliculitis, carbuncle); Fungal (tinea types, candidiasis, PV); Viral (herpes zoster, warts, molluscum)","Psychiatry","Anxiety disorders – Panic disorder, GAD, phobias, OCD, PTSD; somatoform disorders; benzodiazepines + SSRIs in anxiety","Complete Wood's lamp findings for fungal infections; CBT indications"),
  (55,"07-Sep-26","Phase 5 – Dermatology + Psychiatry","Dermatology","STDs + Infestations – Syphilis (primary, secondary, tertiary), gonorrhea, LGV, chancroid, granuloma inguinale, scabies, pediculosis","Psychiatry","Schizophrenia (criteria, subtypes, positive/negative symptoms), antipsychotics (typical vs atypical, EPS), brief psychotic disorder, delusional disorder","Complete VDRL vs FTA-ABS interpretation; chlorpromazine equivalents, EPS management"),
  (56,"08-Sep-26","Phase 5 – Dermatology + Psychiatry","Dermatology","Bullous disorders (Pemphigus vs Pemphigoid), Lichen planus, drug reactions (SJS, TEN, DRESS, FDE), acne (grades, treatment), rosacea","Psychiatry","Bipolar disorder (criteria, mood stabilizers, Lithium monitoring, VPA), substance use (alcohol – CAGE, AUDIT, withdrawal, DTs), opioid use disorder (buprenorphine, methadone)","Complete Nikolsky sign; CIWA-Ar scale; Lithium toxicity management"),
  (57,"09-Sep-26","Phase 5 – Dermatology + Psychiatry","Dermatology","Skin tumors (BCC, SCC, melanoma – ABCDE), urticaria, vitiligo, alopecia (areata, androgenetic), leprosy (types, reactions, MDT regimens) + Dermat MCQ marathon","Psychiatry","Child psychiatry (autism, ADHD, enuresis), forensic psychiatry (IPC sections, McNaughton rules, testamentary capacity), ECT + Psychiatry MCQ marathon","Complete WHO leprosy classification, MDT regimens; McNaughton rules"),
  (58,"10-Sep-26","Phase 5 – Dermatology + Psychiatry","REVISION","Dermatology MCQ test – 50 Qs timed – morning","REVISION","Psychiatry MCQ test – 50 Qs timed – afternoon","Review wrong answers; make final cheat sheets for both"),
  (59,"11-Sep-26","Phase 6 – Final Revision","Medicine","REVISION – Cardiovascular + Respiratory (focus on MCQ patterns, imaging correlations)","—","—","Complete 80+ revision MCQs for both systems"),
  (60,"12-Sep-26","Phase 6 – Final Revision","Medicine","REVISION – GI + Nephrology (MCQ marathon, clinical scenario questions)","—","—","Complete 80+ revision MCQs"),
  (61,"13-Sep-26","Phase 6 – Final Revision","Medicine","REVISION – Endocrinology + Hematology + Neurology","—","—","Complete 80+ revision MCQs across all three"),
  (62,"14-Sep-26","Phase 6 – Final Revision","Medicine","REVISION – Rheumatology + Infectious diseases + Full Medicine MOCK TEST (100 Qs timed)","—","—","Score >70% in mock test; flag all wrong answers"),
  (63,"15-Sep-26","Phase 6 – Final Revision","Surgery","REVISION – Breast + Thyroid + Hepatobiliary + GI Surgery MCQ marathon","—","—","Complete 80+ revision MCQs"),
  (64,"16-Sep-26","Phase 6 – Final Revision","Surgery","REVISION – Vascular + Urology + Pediatric Surgery + Neurosurgery MCQ marathon","—","—","Complete 80+ revision MCQs"),
  (65,"17-Sep-26","Phase 6 – Final Revision","Orthopedics","REVISION – Full Orthopedics (all topics, MCQ test 60 Qs) – morning","Anesthesia","REVISION – Full Anesthesia (all topics, MCQ test 40 Qs) – afternoon","Complete targeted revision of weak areas identified earlier"),
  (66,"18-Sep-26","Phase 6 – Final Revision","OBGyn","REVISION – Obstetrics (normal + abnormal pregnancy, labour, complications)","—","—","Complete 80+ obstetrics MCQs"),
  (67,"19-Sep-26","Phase 6 – Final Revision","OBGyn","REVISION – Gynecology full + OBGyn MOCK TEST (75 Qs timed)","—","—","Score >70% in mock; flag weak gynecology topics"),
  (68,"20-Sep-26","Phase 6 – Final Revision","Pediatrics","REVISION – Neonatal + Respiratory + GI pediatrics MCQ marathon","—","—","Complete 80+ pediatrics MCQs"),
  (69,"21-Sep-26","Phase 6 – Final Revision","Pediatrics","REVISION – Hematology + Neurology + Infectious diseases + Pediatrics MOCK TEST (75 Qs timed)","—","—","Score >70% in mock; flag weak pediatric topics"),
  (70,"22-Sep-26","Phase 6 – Final Revision","ENT","REVISION – Full ENT revision (all topics, MCQ test) – morning","Ophthalmology","REVISION – Full Ophthalmology revision (all topics, MCQ test) – afternoon","Complete revision of both small specialties"),
  (71,"23-Sep-26","Phase 6 – Final Revision","Dermatology","REVISION – Full Dermatology revision (all topics, MCQ test) – morning","Psychiatry","REVISION – Full Psychiatry revision (all topics, MCQ test) – afternoon","Complete revision of both subjects"),
  (72,"24-Sep-26","Phase 6 – Final Revision","MOCK TEST","MEGA MOCK DAY 1 – Medicine 100 MCQs timed (Morning) + Surgery 100 MCQs timed (Afternoon)","—","—","Complete both mock tests; score and record results"),
  (73,"25-Sep-26","Phase 6 – Final Revision","MOCK TEST","MEGA MOCK DAY 2 – OBGyn 75 MCQs timed (Morning) + Pediatrics 75 MCQs timed (Afternoon)","—","—","Complete both mock tests; score and record results"),
  (74,"26-Sep-26","Phase 6 – Final Revision","MOCK TEST","MEGA MOCK DAY 3 – ENT + Ophthal + Dermat + Psychiatry + Ortho + Anesthesia + Radiology combined 100 MCQs timed","—","—","Complete mock test; score and record results"),
  (75,"27-Sep-26","Phase 6 – Final Revision","REVISION","Analyze all mock test results; revise ALL wrong answers across all subjects (both sessions)","—","—","No new topics – only wrong answer review and gap filling"),
  (76,"28-Sep-26","Phase 6 – Final Revision","REVISION","High-yield rapid revision: clinical scenarios, short cases, viva prep – Medicine + Surgery","—","—","Practice spotters, clinical presentations, differentials"),
  (77,"29-Sep-26","Phase 6 – Final Revision","REVISION","High-yield rapid revision: clinical scenarios, short cases, viva prep – OBGyn + Pediatrics","—","—","Practice spotters, clinical presentations, differentials"),
  (78,"30-Sep-26","Phase 6 – Final Revision","REVISION","High-yield rapid revision – ALL allied subjects (ENT, Ophthal, Dermat, Psychiatry, Ortho, Radiology, Anesthesia) – 1 hr each","—","—","Go through all cheat sheets made during study"),
  (79,"01-Oct-26","Phase 6 – Final Revision","FINAL DAY","LIGHT REVISION ONLY – Go through ALL cheat sheets and short notes made throughout the 79 days. NO new topics. Rest and mental preparation.","—","—","Sleep well. You are ready. Best of luck!"),
]

# ─── Sheet 1: OVERVIEW / INSTRUCTIONS ───────────────────────────────────────
ws_info = wb.active
ws_info.title = "README"
ws_info.sheet_view.showGridLines = False
ws_info.column_dimensions['A'].width = 80

ws_info['A1'] = "MBBS FINAL YEAR STUDY TIMETABLE"
ws_info['A1'].font = Font(name="Arial", bold=True, size=22, color=WHITE)
ws_info['A1'].fill = fill(HEADER_BG)
ws_info['A1'].alignment = align()
ws_info.row_dimensions[1].height = 45

ws_info['A2'] = "July 15 – October 1, 2026  |  79 Days  |  11 Subjects"
ws_info['A2'].font = font("1A237E", bold=True, size=13)
ws_info['A2'].fill = fill("E8EAF6")
ws_info['A2'].alignment = align()

info_rows = [
    ("", ""),
    ("PHASE OVERVIEW", ""),
    ("Phase 1 – Medicine + Radiology", "July 15 – July 30  (16 days)"),
    ("Phase 2 – Surgery + Ortho + Anesthesia", "July 31 – August 13  (14 days)"),
    ("Phase 3 – OBGyn + Pediatrics", "August 14 – August 29  (16 days)"),
    ("Phase 4 – ENT + Ophthalmology", "August 30 – September 4  (6 days)"),
    ("Phase 5 – Dermatology + Psychiatry", "September 5 – September 10  (6 days)"),
    ("Phase 6 – Final Revision", "September 11 – October 1  (21 days)"),
    ("", ""),
    ("DAILY STUDY SCHEDULE – NORMAL DAY (10-11 hrs study + 1 hr exercise + 7 hrs sleep)", ""),
    ("05:30 AM", "Wake up"),
    ("05:45 AM – 06:45 AM", "Exercise / Walk / Yoga (1 hour)"),
    ("06:45 AM – 07:15 AM", "Freshen up + Breakfast"),
    ("07:15 AM – 10:15 AM", "PRIMARY SUBJECT – Theory reading (3 hours)"),
    ("10:15 AM – 10:30 AM", "Short break"),
    ("10:30 AM – 01:00 PM", "PRIMARY SUBJECT – High-yield topics + Short notes (2.5 hours)"),
    ("01:00 PM – 02:00 PM", "Lunch + Rest"),
    ("02:00 PM – 04:30 PM", "PAIRED SUBJECT – Theory reading (2.5 hours)"),
    ("04:30 PM – 04:45 PM", "Break"),
    ("04:45 PM – 06:45 PM", "PAIRED SUBJECT – MCQs + revision (2 hours)"),
    ("06:45 PM – 07:30 PM", "Dinner + freshen up"),
    ("07:30 PM – 09:00 PM", "BOTH subjects – Quick revision + flashcards + cheat sheet (1.5 hours)"),
    ("09:00 PM – 09:30 PM", "Plan next day + weak areas list"),
    ("09:30 PM – 10:30 PM", "Wind down + read light"),
    ("10:30 PM – 05:30 AM", "SLEEP (7 hours)"),
    ("", ""),
    ("DAILY STUDY SCHEDULE – POSTING DAY (9 AM – 1 PM hospital posting)", ""),
    ("05:30 AM", "Wake up"),
    ("05:45 AM – 06:30 AM", "Light revision / flashcards (no heavy reading – brain not ready)"),
    ("06:30 AM – 07:15 AM", "Get ready + light breakfast"),
    ("07:15 AM – 09:00 AM", "Travel / Prepare for posting"),
    ("09:00 AM – 01:00 PM", "HOSPITAL POSTING (actively observe, connect with timetable topics)"),
    ("01:00 PM – 02:00 PM", "Lunch + Rest (nap if needed – 20 min)"),
    ("02:00 PM – 04:30 PM", "Exercise (1 hour) then freshen up"),
    ("03:00 PM – 06:00 PM", "PRIMARY SUBJECT – Theory reading (3 hours)"),
    ("06:00 PM – 06:15 PM", "Short break"),
    ("06:15 PM – 08:15 PM", "PAIRED SUBJECT – Theory + MCQs (2 hours)"),
    ("08:15 PM – 09:00 PM", "Dinner"),
    ("09:00 PM – 10:30 PM", "BOTH subjects – Revision + flashcards + cheat sheet (1.5 hours)"),
    ("10:30 PM – 11:00 PM", "Plan next day"),
    ("11:00 PM – 06:00 AM", "SLEEP (7 hours)"),
    ("", ""),
    ("SUBJECT COLOR GUIDE", ""),
]
for subj, color in PHASE_COLORS.items():
    info_rows.append((f"  {subj}", color))

for r_idx, (label, value) in enumerate(info_rows, start=3):
    cell_a = ws_info.cell(row=r_idx, column=1, value=label)
    cell_a.font = font("000000", size=11)
    cell_a.alignment = align(h="left")
    ws_info.row_dimensions[r_idx].height = 18
    if label in ("PHASE OVERVIEW", "DAILY STUDY SCHEDULE – NORMAL DAY (10-11 hrs study + 1 hr exercise + 7 hrs sleep)",
                 "DAILY STUDY SCHEDULE – POSTING DAY (9 AM – 1 PM hospital posting)",
                 "SUBJECT COLOR GUIDE"):
        cell_a.font = font(HEADER_BG, bold=True, size=12)
        cell_a.fill = fill("E8EAF6")
    elif label in PHASE_COLORS:
        cell_a.fill = fill(PHASE_COLORS[label])
        cell_a.font = font(WHITE, bold=True, size=11)
    elif value and value in PHASE_COLORS.values():
        cell_a.fill = fill(value)
        cell_a.font = font(WHITE, bold=True, size=11)
    if value and value not in PHASE_COLORS.values():
        ws_info.cell(row=r_idx, column=1, value=f"{label}    {value}" if value else label)

# ─── Sheet 2: FULL TIMETABLE ─────────────────────────────────────────────────
ws = wb.create_sheet("Full Timetable")
ws.sheet_view.showGridLines = False

# Freeze panes
ws.freeze_panes = "A3"

# Column widths
col_widths = [6, 12, 28, 16, 60, 16, 60, 55]
col_names  = ["Day", "Date", "Phase", "Primary Subject", "Primary Topics", "Paired Subject", "Paired Topics", "Daily Goal"]
for i, (w, name) in enumerate(zip(col_widths, col_names), start=1):
    ws.column_dimensions[get_column_letter(i)].width = w

# Title row
ws.merge_cells("A1:H1")
ws['A1'] = "MBBS FINAL YEAR COMPLETE STUDY TIMETABLE  –  July 15 to October 1, 2026  (79 Days)"
ws['A1'].font = Font(name="Arial", bold=True, size=16, color=WHITE)
ws['A1'].fill = fill(HEADER_BG)
ws['A1'].alignment = align()
ws.row_dimensions[1].height = 36

# Header row
for col, name in enumerate(col_names, start=1):
    c = ws.cell(row=2, column=col, value=name)
    c.font = Font(name="Arial", bold=True, size=11, color=WHITE)
    c.fill = fill("283593")
    c.alignment = align()
    c.border = border_thin
ws.row_dimensions[2].height = 22

# Data rows
for row_data in data:
    day_num, date_str, phase, p_subj, p_topics, s_subj, s_topics, goal = row_data
    row = day_num + 2

    # Row height
    ws.row_dimensions[row].height = 52

    # Background color based on phase
    bg = PHASE_BG.get(phase, "FFFFFF")

    values = [day_num, date_str, phase, p_subj, p_topics, s_subj, s_topics, goal]
    for col, val in enumerate(values, start=1):
        c = ws.cell(row=row, column=col, value=val)
        c.alignment = align(h="left" if col > 2 else "center", wrap=True)
        c.border = border_thin
        c.fill = fill(bg)
        c.font = font("212121", size=9)

    # Day number styling
    ws.cell(row=row, column=1).font = Font(name="Arial", bold=True, size=11, color=WHITE)
    ws.cell(row=row, column=1).fill = fill(PHASE_COLORS.get(p_subj if p_subj != "REVISION" and p_subj != "MOCK TEST" and p_subj != "FINAL DAY" else "Revision", "37474F"))
    ws.cell(row=row, column=1).alignment = align()

    # Phase cell
    ws.cell(row=row, column=3).font = font("37474F", bold=True, size=9, italic=True)

    # Primary subject cell
    subj_color = PHASE_COLORS.get(p_subj, "37474F")
    ws.cell(row=row, column=4).font = Font(name="Arial", bold=True, size=10, color=subj_color)

    # Paired subject cell
    subj2_color = PHASE_COLORS.get(s_subj, "37474F")
    ws.cell(row=row, column=6).font = Font(name="Arial", bold=True, size=10, color=subj2_color)

    # Goal cell - make it stand out
    ws.cell(row=row, column=8).font = Font(name="Arial", bold=True, size=9, color="1B5E20", italic=True)

    # Revision / special rows
    if p_subj in ("REVISION", "MOCK TEST", "FINAL DAY"):
        for col in range(1, 9):
            ws.cell(row=row, column=col).fill = fill("ECEFF1")
        ws.cell(row=row, column=1).fill = fill("37474F")
        ws.cell(row=row, column=4).font = Font(name="Arial", bold=True, size=10, color="B71C1C")

# ─── Sheet 3: DAILY CHECKLIST ─────────────────────────────────────────────────
ws_cl = wb.create_sheet("Daily Checklist")
ws_cl.sheet_view.showGridLines = False

# Column widths
checklist_cols = [6, 12, 16, 55, 16, 55, 12, 12, 12, 12, 30]
checklist_headers = ["Day", "Date", "Primary Subj", "Primary Topics (Check off when done)", 
                     "Paired Subj", "Paired Topics (Check off when done)",
                     "MCQs Done?", "Notes Made?", "Weak Topics?", "Completed?", "Notes / Comments"]
for i, w in enumerate(checklist_cols, start=1):
    ws_cl.column_dimensions[get_column_letter(i)].width = w

# Title
ws_cl.merge_cells("A1:K1")
ws_cl['A1'] = "MBBS FINAL YEAR – DAILY STUDY CHECKLIST  (Mark each cell when done)"
ws_cl['A1'].font = Font(name="Arial", bold=True, size=15, color=WHITE)
ws_cl['A1'].fill = fill(HEADER_BG)
ws_cl['A1'].alignment = align()
ws_cl.row_dimensions[1].height = 34

# Freeze
ws_cl.freeze_panes = "A3"

# Header
for col, h in enumerate(checklist_headers, start=1):
    c = ws_cl.cell(row=2, column=col, value=h)
    c.font = Font(name="Arial", bold=True, size=10, color=WHITE)
    c.fill = fill("283593")
    c.alignment = align()
    c.border = border_thin
ws_cl.row_dimensions[2].height = 40

for row_data in data:
    day_num, date_str, phase, p_subj, p_topics, s_subj, s_topics, goal = row_data
    row = day_num + 2
    ws_cl.row_dimensions[row].height = 50

    bg = PHASE_BG.get(phase, "FFFFFF")
    subj_color = PHASE_COLORS.get(p_subj, "37474F")

    vals = [day_num, date_str, p_subj, p_topics, s_subj if s_subj != "—" else "", 
            s_topics if s_topics != "—" else "", "☐", "☐", "☐", "☐", ""]
    for col, val in enumerate(vals, start=1):
        c = ws_cl.cell(row=row, column=col, value=val)
        c.alignment = align(h="center" if col in (1, 2, 7, 8, 9, 10) else "left", wrap=True)
        c.border = border_thin
        c.fill = fill(bg)
        c.font = font("212121", size=9)

    # Day styling
    ws_cl.cell(row=row, column=1).font = Font(name="Arial", bold=True, size=11, color=WHITE)
    ws_cl.cell(row=row, column=1).fill = fill(PHASE_COLORS.get(p_subj if p_subj not in ("REVISION","MOCK TEST","FINAL DAY") else "Revision", "37474F"))
    ws_cl.cell(row=row, column=1).alignment = align()

    # Subject cells
    ws_cl.cell(row=row, column=3).font = Font(name="Arial", bold=True, size=10, color=subj_color)
    ws_cl.cell(row=row, column=5).font = Font(name="Arial", bold=True, size=10, 
                                               color=PHASE_COLORS.get(s_subj, "37474F"))
    # Checkbox cells
    for col in (7, 8, 9, 10):
        ws_cl.cell(row=row, column=col).font = font("000000", size=14)
        ws_cl.cell(row=row, column=col).fill = fill("FAFAFA")
        ws_cl.cell(row=row, column=col).alignment = align()

# ─── Sheet 4: POSTING DAY SCHEDULE ───────────────────────────────────────────
ws_post = wb.create_sheet("Posting Day Schedule")
ws_post.sheet_view.showGridLines = False
ws_post.column_dimensions['A'].width = 28
ws_post.column_dimensions['B'].width = 75

# Title
ws_post.merge_cells("A1:B1")
ws_post['A1'] = "POSTING DAY SCHEDULE  (Hospital 9 AM – 1 PM)"
ws_post['A1'].font = Font(name="Arial", bold=True, size=16, color=WHITE)
ws_post['A1'].fill = fill(HEADER_BG)
ws_post['A1'].alignment = align()
ws_post.row_dimensions[1].height = 38

posting_schedule = [
    ("TIME", "ACTIVITY", True),
    ("05:30 AM", "Wake up – no alarm snooze; drink water immediately", False),
    ("05:45 AM – 06:30 AM", "LIGHT REVIEW: flashcards / short notes / mnemonics (no heavy new reading – brain not optimal yet)", False),
    ("06:30 AM – 07:15 AM", "Get ready + light breakfast (fuel your brain)", False),
    ("07:15 AM – 08:45 AM", "Travel to hospital / review today's posting department topics briefly", False),
    ("09:00 AM – 01:00 PM", "🏥 HOSPITAL POSTING  –  Actively observe, connect clinical findings to your timetable topics. Mentally note MCQ-worthy signs/findings.", False),
    ("01:00 PM – 02:00 PM", "Lunch + REST (short nap 20-30 min is productive – improves afternoon retention)", False),
    ("02:00 PM – 03:00 PM", "EXERCISE – Walk / gym / yoga (1 hour). This replaces the morning exercise slot.", False),
    ("03:00 PM – 03:15 PM", "Freshen up + snack + prepare study area", False),
    ("03:15 PM – 06:15 PM", "PRIMARY SUBJECT – Theory reading (3 hours, focused deep work)", False),
    ("06:15 PM – 06:30 PM", "Short break – walk around, hydrate", False),
    ("06:30 PM – 08:30 PM", "PAIRED SUBJECT – Theory + MCQs (2 hours)", False),
    ("08:30 PM – 09:15 PM", "Dinner", False),
    ("09:15 PM – 10:45 PM", "REVISION SESSION – Both subjects: flashcards, cheat sheets, weak areas (1.5 hours)", False),
    ("10:45 PM – 11:15 PM", "Plan tomorrow + list weak topics from today", False),
    ("11:15 PM – 06:15 AM", "SLEEP (7 hours) – Non-negotiable for memory consolidation", False),
    ("", "", False),
    ("TOTAL STUDY HRS (Posting Day)", "~7 hours (study) + 0.5 hr light morning review = 7.5 hrs net", False),
    ("TOTAL EXERCISE", "1 hour (afternoon)", False),
    ("TOTAL SLEEP", "7 hours", False),
    ("", "", False),
    ("NOTE ON POSTING DAYS", "On days you have posting, your study hours will be ~7-7.5 hrs instead of 10-11 hrs. This is expected and planned for. Do NOT try to compensate by sleeping less. Use the posting time actively – observe clinical signs, connect to your study topics, and mentally rehearse MCQ-relevant findings.", False),
    ("", "", False),
    ("TIPS FOR POSTING DAYS", ""),
    ("1. Before going to posting", "Quickly glance at the day's primary + paired subjects (5-10 min) so clinical cases connect to what you studied."),
    ("2. During posting", "Keep a small pocket notebook. Write down 3-5 clinical pearls per posting session."),
    ("3. Clinical connection rule", "If you see a patient with condition X on posting, that evening make sure condition X is part of your revision session."),
    ("4. If you fall behind", "Do NOT panic. Use the following Sunday's flex time to catch up. The plan has buffer days built in."),
    ("5. Exam day simulation", "Posting days are great for practicing clinical presentation MCQs – the kind that start with 'A 35-year-old woman presents with...'"),
]

for r_idx, row_info in enumerate(posting_schedule, start=2):
    if len(row_info) == 3:
        time_val, activity, is_header = row_info
    else:
        time_val, activity = row_info
        is_header = False

    c1 = ws_post.cell(row=r_idx, column=1, value=time_val)
    c2 = ws_post.cell(row=r_idx, column=2, value=activity)
    ws_post.row_dimensions[r_idx].height = 38

    if is_header:
        for c in (c1, c2):
            c.font = Font(name="Arial", bold=True, size=11, color=WHITE)
            c.fill = fill("283593")
            c.alignment = align()
            c.border = border_thin
    elif time_val in ("🏥 HOSPITAL POSTING  –  Actively observe...", "09:00 AM – 01:00 PM"):
        for c in (c1, c2):
            c.fill = fill("E8F5E9")
            c.font = Font(name="Arial", bold=True, size=10, color="1B5E20")
    elif "SLEEP" in str(time_val):
        for c in (c1, c2):
            c.fill = fill("E3F2FD")
            c.font = font("1A237E", bold=True, size=10)
    elif "EXERCISE" in str(time_val):
        for c in (c1, c2):
            c.fill = fill("E8F5E9")
            c.font = font("2E7D32", bold=True, size=10)
    elif "PRIMARY" in str(activity) or "PAIRED" in str(activity) or "REVISION" in str(activity):
        for c in (c1, c2):
            c.fill = fill("FFF8E1")
            c.font = font("E65100", bold=True, size=10)
    elif time_val in ("TOTAL STUDY HRS (Posting Day)", "TOTAL EXERCISE", "TOTAL SLEEP"):
        for c in (c1, c2):
            c.fill = fill("ECEFF1")
            c.font = font("37474F", bold=True, size=10)
    elif time_val in ("NOTE ON POSTING DAYS", "TIPS FOR POSTING DAYS"):
        for c in (c1, c2):
            c.fill = fill("E8EAF6")
            c.font = font("1A237E", bold=True, size=11)
    else:
        for c in (c1, c2):
            c.fill = fill("FAFAFA")
            c.font = font("212121", size=10)
    for c in (c1, c2):
        c.alignment = align(h="left", wrap=True)
        c.border = border_thin

# ─── Sheet 5: SUBJECT OVERVIEW ────────────────────────────────────────────────
ws_sub = wb.create_sheet("Subject Overview")
ws_sub.sheet_view.showGridLines = False
ws_sub.column_dimensions['A'].width = 22
ws_sub.column_dimensions['B'].width = 14
ws_sub.column_dimensions['C'].width = 22
ws_sub.column_dimensions['D'].width = 50
ws_sub.column_dimensions['E'].width = 40

ws_sub.merge_cells("A1:E1")
ws_sub['A1'] = "SUBJECT OVERVIEW & RECOMMENDED BOOKS"
ws_sub['A1'].font = Font(name="Arial", bold=True, size=16, color=WHITE)
ws_sub['A1'].fill = fill(HEADER_BG)
ws_sub['A1'].alignment = align()
ws_sub.row_dimensions[1].height = 36

headers = ["Subject", "Days", "Dates", "Key High-Yield Topics", "Recommended Books"]
for col, h in enumerate(headers, start=1):
    c = ws_sub.cell(row=2, column=col, value=h)
    c.font = Font(name="Arial", bold=True, size=11, color=WHITE)
    c.fill = fill("283593")
    c.alignment = align()
    c.border = border_thin
ws_sub.row_dimensions[2].height = 22

subj_data = [
    ("Medicine", "16 days", "Jul 15 – Jul 30", 
     "Cardio, Respiratory, GI, Nephrology, Endocrine, Hematology, Neurology, Rheumatology, Infectious diseases",
     "Davidson's Principles of Medicine\nMudit Khanna MCQs (Medicine)"),
    ("Radiology", "Paired with Medicine", "Jul 15 – Jul 30",
     "CXR reading, CT basics, USG abdomen, MRI principles, Nuclear medicine, Interventional radiology",
     "Rajiv Mehta – Clinical Radiology\nAcross Radiology MCQs"),
    ("Surgery", "12 days", "Jul 31 – Aug 13",
     "Shock, Breast, Thyroid, GI surgery, Colorectal, Hepatobiliary, Hernia, Vascular, Urology, Burns, Neuro surgery",
     "Bailey & Love's Surgery (reference)\nSRB's Surgery\nAcross Surgery MCQs"),
    ("Orthopedics", "6 days", "Aug 3 – Aug 10 (paired)",
     "Fracture principles, Upper/lower limb fractures, Spine, Bone tumors, Metabolic bone, Pediatric ortho, Joint replacement",
     "Maheshwari's Essential Orthopedics\nApley's (reference)"),
    ("Anesthesia", "3 days", "Jul 31, Aug 11, Aug 13 (paired)",
     "Pre-op assessment, Induction agents, Airway management, Regional anesthesia, Monitoring, Complications",
     "Morgan & Mikhail (reference)\nSenior short notes + MCQs"),
    ("OBGyn", "10 days", "Aug 14 – Aug 29",
     "Normal ANC, Pre-eclampsia/Eclampsia, APH, PPH, Labour, Malpresentations, Gyn cancers, Contraception, GTD, STIs",
     "DC Dutta – Obstetrics\nDC Dutta – Gynecology\nSheila Balakrishnan"),
    ("Pediatrics", "9 days", "Aug 14 – Aug 29 (paired)",
     "Normal newborn, Neonatal emergencies, Respiratory, GI, Hematology, Neurology, Infectious, Nutrition, Immunization",
     "OP Ghai Essential Pediatrics\nPaul & Bhave"),
    ("ENT", "5 days", "Aug 30 – Sep 3",
     "Ear (CSOM, otosclerosis), Audiometry, Nose (epistaxis, sinusitis), Throat (quinsy), ENT tumors",
     "PL Dhingra – Diseases of Ear Nose Throat"),
    ("Ophthalmology", "5 days", "Aug 30 – Sep 3 (paired)",
     "Conjunctivitis, Glaucoma, Cataract, Retinal disorders (DR, RD), Squint, Uveitis, Optic neuritis",
     "AK Khurana – Ophthalmology"),
    ("Dermatology", "5 days", "Sep 5 – Sep 9",
     "Eczema, Psoriasis, Skin infections, STDs, Bullous disorders, Drug reactions, Acne, Vitiligo, Leprosy, Skin tumors",
     "IADVL Textbook of Dermatology\nValia's Dermatology"),
    ("Psychiatry", "4 days", "Sep 5 – Sep 9 (paired)",
     "MSE, MDD, Anxiety disorders, Schizophrenia, Bipolar, Substance use, Child psychiatry, Forensic psychiatry, ECT",
     "Ahuja's Textbook of Psychiatry"),
]

for r_idx, (subj, days_alloc, dates, topics, books) in enumerate(subj_data, start=3):
    ws_sub.row_dimensions[r_idx].height = 60
    color = PHASE_COLORS.get(subj, "37474F")
    bg = "F5F5F5" if r_idx % 2 == 0 else "FFFFFF"
    vals = [subj, days_alloc, dates, topics, books]
    for col, val in enumerate(vals, start=1):
        c = ws_sub.cell(row=r_idx, column=col, value=val)
        c.alignment = align(h="left" if col > 1 else "center", wrap=True)
        c.border = border_thin
        c.fill = fill(bg)
        c.font = font("212121", size=10)
    ws_sub.cell(row=r_idx, column=1).font = Font(name="Arial", bold=True, size=11, color=WHITE)
    ws_sub.cell(row=r_idx, column=1).fill = fill(color)
    ws_sub.cell(row=r_idx, column=1).alignment = align()

# ─── Save ─────────────────────────────────────────────────────────────────────
out_path = "/home/daytona/workspace/mbbs-timetable/MBBS_Final_Year_Timetable.xlsx"
wb.save(out_path)
print(f"Saved: {out_path}")
Writing File

~/mbbs-timetable/build_poster.py

"""
MBBS Final Year Wall Poster – A1 landscape printable PDF
Uses reportlab for full control over layout, colors, and fonts.
"""
from reportlab.lib.pagesizes import A1, landscape
from reportlab.lib import colors
from reportlab.lib.units import mm, cm
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.pdfgen import canvas
from reportlab.platypus import BaseDocTemplate, PageTemplate, Frame

# ─── Color definitions ────────────────────────────────────────────────────────
NAVY      = colors.HexColor("#1A237E")
DEEP_BLUE = colors.HexColor("#1565C0")
MED_BLUE  = colors.HexColor("#0288D1")
RED_DARK  = colors.HexColor("#B71C1C")
RED_BRT   = colors.HexColor("#E53935")
ORANGE    = colors.HexColor("#FF7043")
PINK      = colors.HexColor("#AD1457")
PURPLE    = colors.HexColor("#6A1B9A")
GRN_DARK  = colors.HexColor("#2E7D32")
GRN_MED   = colors.HexColor("#388E3C")
AMBER     = colors.HexColor("#F57F17")
BROWN     = colors.HexColor("#795548")
SLATE     = colors.HexColor("#37474F")
WHITE     = colors.white
CREAM     = colors.HexColor("#FAFAFA")

# Phase bg colors
P1_BG  = colors.HexColor("#E3F2FD")
P2_BG  = colors.HexColor("#FFEBEE")
P3_BG  = colors.HexColor("#F3E5F5")
P4_BG  = colors.HexColor("#E8F5E9")
P5_BG  = colors.HexColor("#FFF8E1")
P6_BG  = colors.HexColor("#ECEFF1")
REV_BG = colors.HexColor("#F5F5F5")

PHASE_BG_MAP = {
    "Phase 1": P1_BG,
    "Phase 2": P2_BG,
    "Phase 3": P3_BG,
    "Phase 4": P4_BG,
    "Phase 5": P5_BG,
    "Phase 6": P6_BG,
}

SUBJ_COLOR = {
    "Medicine":      DEEP_BLUE,
    "Radiology":     MED_BLUE,
    "Surgery":       RED_DARK,
    "Orthopedics":   RED_BRT,
    "Anesthesia":    ORANGE,
    "OBGyn":         PINK,
    "Pediatrics":    PURPLE,
    "ENT":           GRN_DARK,
    "Ophthalmology": GRN_MED,
    "Dermatology":   AMBER,
    "Psychiatry":    BROWN,
    "REVISION":      SLATE,
    "MOCK TEST":     SLATE,
    "FINAL DAY":     SLATE,
}

def subj_color(s):
    return SUBJ_COLOR.get(s, SLATE)

# ─── Styles ───────────────────────────────────────────────────────────────────
styles = getSampleStyleSheet()

def ps(name, parent='Normal', **kwargs):
    return ParagraphStyle(name, parent=styles[parent], **kwargs)

title_style = ps('title', fontSize=28, textColor=WHITE, alignment=TA_CENTER,
                 fontName='Helvetica-Bold', spaceAfter=0, spaceBefore=0, leading=34)
sub_title_style = ps('subtitle', fontSize=13, textColor=WHITE, alignment=TA_CENTER,
                     fontName='Helvetica', spaceAfter=0, spaceBefore=0, leading=16)
phase_hdr = ps('phase_hdr', fontSize=10, textColor=WHITE, alignment=TA_CENTER,
               fontName='Helvetica-Bold', spaceAfter=0, spaceBefore=0, leading=12)
day_style = ps('day', fontSize=11, textColor=WHITE, alignment=TA_CENTER,
               fontName='Helvetica-Bold', spaceAfter=0, spaceBefore=0, leading=14)
date_style = ps('date', fontSize=8, textColor=colors.HexColor("#424242"), alignment=TA_CENTER,
                fontName='Helvetica', spaceAfter=0, spaceBefore=0, leading=10)
subj_style = ps('subj', fontSize=8, textColor=NAVY, alignment=TA_LEFT,
                fontName='Helvetica-Bold', spaceAfter=0, spaceBefore=0, leading=10)
topic_style = ps('topic', fontSize=6.5, textColor=colors.HexColor("#212121"), alignment=TA_LEFT,
                 fontName='Helvetica', spaceAfter=0, spaceBefore=0, leading=8.5, wordWrap='CJK')
goal_style = ps('goal', fontSize=6, textColor=colors.HexColor("#1B5E20"), alignment=TA_LEFT,
                fontName='Helvetica-Oblique', spaceAfter=0, spaceBefore=0, leading=8)
col_hdr_style = ps('col_hdr', fontSize=9, textColor=WHITE, alignment=TA_CENTER,
                   fontName='Helvetica-Bold', spaceAfter=0, spaceBefore=0, leading=11)
legend_style = ps('legend', fontSize=8, textColor=WHITE, alignment=TA_CENTER,
                  fontName='Helvetica-Bold', spaceAfter=0, spaceBefore=0, leading=10)
note_style = ps('note', fontSize=7.5, textColor=colors.HexColor("#212121"), alignment=TA_LEFT,
                fontName='Helvetica', spaceAfter=0, spaceBefore=0, leading=10)
sched_hdr_style = ps('sched_hdr', fontSize=10, textColor=WHITE, alignment=TA_CENTER,
                     fontName='Helvetica-Bold', leading=13)
sched_time_style = ps('sched_time', fontSize=8.5, textColor=NAVY, alignment=TA_LEFT,
                      fontName='Helvetica-Bold', leading=11)
sched_act_style = ps('sched_act', fontSize=8.5, textColor=colors.HexColor("#212121"), alignment=TA_LEFT,
                     fontName='Helvetica', leading=11)

# ─── Data ─────────────────────────────────────────────────────────────────────
timetable = [
  (1,"15 Jul","P1","Medicine","Cardio – HTN, Heart Failure, CCF\nRadiology: CXR basics, cardiomegaly"),
  (2,"16 Jul","P1","Medicine","Cardio – IHD, Angina, MI, ECG\nRadiology: STEMI patterns, LVH"),
  (3,"17 Jul","P1","Medicine","Cardio – Valvular, Endocarditis, Cardiomyopathy\nRadiology: Echo basics"),
  (4,"18 Jul","P1","Medicine","Respiratory – Asthma, COPD, Pneumonia, TB\nRadiology: CXR patterns"),
  (5,"19 Jul","P1","Medicine","Respiratory – Effusion, Pneumothorax, ARDS, ILD\nRadiology: CT chest"),
  (6,"20 Jul","P1","REVISION","REVISION: Cardio + Respiratory\nMCQs + short notes all day"),
  (7,"21 Jul","P1","Medicine","GI – GERD, PUD, IBD, Liver disease, Cirrhosis\nRadiology: USG abdomen"),
  (8,"22 Jul","P1","Medicine","GI – Jaundice, Pancreatitis, Malabsorption\nRadiology: MRCP, ERCP"),
  (9,"23 Jul","P1","Medicine","Nephrology – AKI, CKD, Nephrotic, Nephritic, GN\nRadiology: Renal USG"),
  (10,"24 Jul","P1","Medicine","Nephrology – UTI, RTA, Electrolytes, Acid-base\nRadiology: KUB X-ray"),
  (11,"25 Jul","P1","Medicine","Endocrine – DM (all), Thyroid disorders\nRadiology: Thyroid USG, scan"),
  (12,"26 Jul","P1","Medicine","Endocrine – Adrenal, Pituitary, DI vs SIADH, Calcium\nRadiology: Adrenal MRI"),
  (13,"27 Jul","P1","REVISION","REVISION: GI + Nephrology + Endocrine\nMCQs all day"),
  (14,"28 Jul","P1","Medicine","Hematology – Anemias, Leukemia, Lymphoma\nRadiology: BM biopsy, CT staging"),
  (15,"29 Jul","P1","Medicine","Neurology – Stroke, Epilepsy, Meningitis, Parkinson's\nRadiology: CT/MRI brain"),
  (16,"30 Jul","P1","Medicine","Rheumatology + Infectious (Malaria, Typhoid, HIV)\n+ Medicine MCQ marathon 100+"),
  (17,"31 Jul","P2","Surgery","Surgical Principles – Wound healing, Shock, Sepsis\nAnesthesia: Pre-op, ASA grading"),
  (18,"1 Aug","P2","Surgery","Breast – Cancer, staging, mastectomy types\nAnesthesia: Induction, LA, muscle relaxants"),
  (19,"2 Aug","P2","Surgery","Thyroid + Parathyroid – Surgery, Ca thyroid\nAnesthesia: Airway, intubation, RSI, LMA"),
  (20,"3 Aug","P2","REVISION","REVISION: Surgery Days 17-19\nOrtho: Fracture principles, healing, classification"),
  (21,"4 Aug","P2","Surgery","GI Surgery – Ca esophagus, achalasia, gastric Ca, SBO, Appendicitis\nOrtho: Upper limb fractures"),
  (22,"5 Aug","P2","Surgery","Colorectal – Ca colon/rectum, hemorrhoids, fistula, diverticulitis\nOrtho: Lower limb fractures"),
  (23,"6 Aug","P2","Surgery","Hepatobiliary – Cholecystitis, Ca pancreas, portal HTN, liver abscess\nOrtho: Spine injuries, PLID"),
  (24,"7 Aug","P2","Surgery","Hernia – All types, anatomy, complications, repairs\nOrtho: Bone tumors, osteomyelitis"),
  (25,"8 Aug","P2","Surgery","Vascular – DVT, varicose veins, PVD, AAA, Buerger's\nOrtho: Metabolic bone, septic arthritis"),
  (26,"9 Aug","P2","Surgery","Urology – BPH, prostate Ca, bladder Ca, RCC, testicular tumors\nOrtho: Pediatric ortho (DDH, CTEV, LCPD)"),
  (27,"10 Aug","P2","REVISION","REVISION: Surgery MCQ marathon\nOrtho: All topics MCQ marathon"),
  (28,"11 Aug","P2","Surgery","Neurosurgery – Head injury, GCS, EDH vs SDH, brain tumors\nAnesthesia: Regional, spinal, epidural"),
  (29,"12 Aug","P2","Surgery","Pediatric Surgery – Intussusception, pyloric stenosis, Hirschsprung's, Wilm's\nAnesthesia: TIVA, monitoring, special conditions"),
  (30,"13 Aug","P2","Surgery","Burns (Rule of 9, Parkland), skin tumors (BCC, SCC, melanoma)\n+ Surgery MCQ marathon | Anesthesia: Complications, MH"),
  (31,"14 Aug","P3","OBGyn","Normal pregnancy – ANC, physiological changes, investigations\nPeds: Normal newborn, APGAR, milestones, immunization"),
  (32,"15 Aug","P3","OBGyn","High-risk pregnancy – Pre-eclampsia, eclampsia, MgSO4, GDM\nPeds: Neonatal sepsis, RDS, HIE, NEC, neonatal jaundice"),
  (33,"16 Aug","P3","OBGyn","APH (placenta previa, abruption) + PPH (4T's, uterotonics, B-Lynch)\nPeds: Croup, bronchiolitis, asthma, IMNCI pneumonia"),
  (34,"17 Aug","P3","REVISION","REVISION: OBGyn Days 31-33\nPeds: Days 31-33 MCQs"),
  (35,"18 Aug","P3","OBGyn","Labour – Stages, partograph, CTG interpretation, instrumental delivery\nPeds: Diarrhea (ORT), malnutrition (SAM/MAM), intussusception"),
  (36,"19 Aug","P3","OBGyn","IUGR, PROM, preterm labour, malpresentations (breech, shoulder)\nPeds: Febrile seizures, meningitis, cerebral palsy"),
  (37,"20 Aug","P3","OBGyn","Medical disorders in pregnancy – Anemia, cardiac, HELLP, AFLP, ICP\nPeds: ALL vs AML, thalassemia, hemophilia, ITP"),
  (38,"21 Aug","P3","OBGyn","Gynecology – PCOS, DUB, amenorrhea, endometriosis, fibroids, infertility\nPeds: Nephrotic syndrome (MCD), UTI in children"),
  (39,"22 Aug","P3","OBGyn","Gyn cancers – Cervical (FIGO staging, Pap smear, LEEP), ovarian, endometrial\nPeds: Type 1 DM, CAH, precocious puberty, short stature"),
  (40,"23 Aug","P3","OBGyn","Genital prolapse (POP-Q), urinary incontinence, vulvar disorders\nPeds: Measles, Kawasaki, rheumatic fever (Jones criteria), dengue"),
  (41,"24 Aug","P3","REVISION","REVISION: OBGyn Gynecology MCQs\nPeds: Days 35-40 MCQs"),
  (42,"25 Aug","P3","OBGyn","STIs (syphilis, gonorrhea, HPV) + Contraception (OCP, IUCD, sterilization)\nPeds: Nutrition – Vitamin deficiencies, rickets, Kwashiorkor vs Marasmus"),
  (43,"26 Aug","P3","OBGyn","Ectopic pregnancy + GTD (molar, choriocarcinoma) + Recurrent pregnancy loss\nPeds: CHD (TOF, VSD, ASD, TGA), Down's, Turner's, Klinefelter's"),
  (44,"27 Aug","P3","OBGyn","Cesarean section, obstetric fistula, puerperal fever, lactation\nPeds: Developmental milestones, autism, ADHD + Peds MCQ marathon"),
  (45,"28 Aug","P3","OBGyn","OBGyn MCQ marathon (150+ MCQs)\nPeds: MCQ marathon (150+ MCQs)"),
  (46,"29 Aug","P3","REVISION","REVISION: OBGyn mock test 60 Qs timed\nPeds: Mock test 60 Qs timed"),
  (47,"30 Aug","P4","ENT","Ear – ASOM, CSOM (safe vs unsafe), cholesteatoma, mastoiditis, otosclerosis\nOphthal: Eye anatomy, conjunctivitis, corneal ulcer, keratitis"),
  (48,"31 Aug","P4","ENT","Hearing loss (audiogram), Meniere's, BPPV, vestibular schwannoma\nOphthal: Glaucoma (open/closed, drugs), cataract (surgery, complications)"),
  (49,"1 Sep","P4","ENT","Nose – Epistaxis, DNS, allergic rhinitis, sinusitis, nasal polyps\nOphthal: Retina – DR, RD, CRAO, CRVO, hypertensive retinopathy, AMD"),
  (50,"2 Sep","P4","ENT","Throat – Tonsillitis, quinsy, deep neck infections, Ludwig's angina\nOphthal: Squint, uveitis (HLA-B27), amblyopia, optic neuritis, papilledema"),
  (51,"3 Sep","P4","ENT","Tumors – Ca larynx, Ca nasopharynx (EBV), salivary gland tumors + MCQ marathon\nOphthal: Eyelid, lacrimal, orbit, ocular trauma, emergencies + MCQ marathon"),
  (52,"4 Sep","P4","REVISION","REVISION: ENT mock test 50 Qs timed\nOphthal: Mock test 50 Qs timed"),
  (53,"5 Sep","P5","Dermatology","Lesion morphology, eczema (atopic/contact/seborrheic), psoriasis (types, PASI)\nPsychiatry: MSE, ICD-10 vs DSM-5, Major Depressive Disorder"),
  (54,"6 Sep","P5","Dermatology","Bacterial infections (impetigo, cellulitis), fungal (tinea, candidiasis, PV), viral (herpes, warts)\nPsychiatry: Anxiety (panic, GAD, OCD, PTSD), somatoform disorders"),
  (55,"7 Sep","P5","Dermatology","STDs – Syphilis, gonorrhea, LGV, chancroid; Scabies, pediculosis\nPsychiatry: Schizophrenia (criteria, antipsychotics, EPS, NMS)"),
  (56,"8 Sep","P5","Dermatology","Bullous (Pemphigus vs Pemphigoid), Lichen planus, drug reactions (SJS, TEN, DRESS, FDE), acne\nPsychiatry: Bipolar (Lithium, VPA), alcohol withdrawal (CIWA-Ar, DTs), opioid dependence"),
  (57,"9 Sep","P5","Dermatology","Skin tumors (melanoma – ABCDE), urticaria, vitiligo, leprosy (types, MDT) + Dermat MCQs\nPsychiatry: Child psych (autism, ADHD), forensic psych (McNaughton), ECT + Psych MCQs"),
  (58,"10 Sep","P5","REVISION","REVISION: Dermatology mock test 50 Qs timed\nPsychiatry: Mock test 50 Qs timed"),
  (59,"11 Sep","P6","Medicine","REVISION: Cardiovascular + Respiratory – MCQ patterns, imaging correlations"),
  (60,"12 Sep","P6","Medicine","REVISION: GI + Nephrology – MCQ marathon, clinical scenarios"),
  (61,"13 Sep","P6","Medicine","REVISION: Endocrinology + Hematology + Neurology – MCQ marathon"),
  (62,"14 Sep","P6","Medicine","REVISION: Rheumatology + Infectious + MEDICINE MOCK TEST (100 Qs timed)"),
  (63,"15 Sep","P6","Surgery","REVISION: Breast + Thyroid + Hepatobiliary + GI Surgery – MCQ marathon"),
  (64,"16 Sep","P6","Surgery","REVISION: Vascular + Urology + Pediatric Surgery + Neurosurgery – MCQ marathon"),
  (65,"17 Sep","P6","Orthopedics","REVISION: Full Orthopedics MCQ test 60 Qs\nAnesthesia: Full revision MCQ test 40 Qs"),
  (66,"18 Sep","P6","OBGyn","REVISION: Obstetrics – Normal + abnormal, labour, complications – MCQ marathon"),
  (67,"19 Sep","P6","OBGyn","REVISION: Gynecology + OBGYN MOCK TEST (75 Qs timed)"),
  (68,"20 Sep","P6","Pediatrics","REVISION: Neonatal + Respiratory + GI Pediatrics – MCQ marathon"),
  (69,"21 Sep","P6","Pediatrics","REVISION: Hematology + Neurology + Infectious + PEDS MOCK TEST (75 Qs timed)"),
  (70,"22 Sep","P6","ENT","REVISION: Full ENT + Full Ophthalmology – Revision + MCQ tests"),
  (71,"23 Sep","P6","Dermatology","REVISION: Full Dermatology + Full Psychiatry – Revision + MCQ tests"),
  (72,"24 Sep","P6","MOCK TEST","MEGA MOCK DAY 1: Medicine 100 Qs + Surgery 100 Qs – both timed"),
  (73,"25 Sep","P6","MOCK TEST","MEGA MOCK DAY 2: OBGyn 75 Qs + Pediatrics 75 Qs – both timed"),
  (74,"26 Sep","P6","MOCK TEST","MEGA MOCK DAY 3: ENT + Ophthal + Dermat + Psych + Ortho + Anesthesia + Radiology (100 Qs combined)"),
  (75,"27 Sep","P6","REVISION","Analyze ALL mock test results; revise every wrong answer across all subjects"),
  (76,"28 Sep","P6","REVISION","High-yield rapid revision: Clinical scenarios + viva prep – Medicine + Surgery"),
  (77,"29 Sep","P6","REVISION","High-yield rapid revision: Clinical scenarios + viva prep – OBGyn + Pediatrics"),
  (78,"30 Sep","P6","REVISION","ALL allied subjects rapid revision (ENT, Ophthal, Dermat, Psych, Ortho, Radiology, Anesthesia)"),
  (79,"1 Oct","P6","FINAL DAY","LIGHT REVISION ONLY – All cheat sheets + short notes. No new topics. Rest. You are ready!"),
]

# ─── Phase color lookup ───────────────────────────────────────────────────────
def get_phase_bg(phase_code):
    return PHASE_BG_MAP.get({"P1":"Phase 1","P2":"Phase 2","P3":"Phase 3",
                              "P4":"Phase 4","P5":"Phase 5","P6":"Phase 6"}.get(phase_code,""), 
                             REV_BG)

# ─── Build PDF (A1 landscape) ─────────────────────────────────────────────────
PAGE_W, PAGE_H = landscape(A1)
MARGIN = 15*mm

out_path = "/home/daytona/workspace/mbbs-timetable/MBBS_Final_Year_Wall_Poster.pdf"

def build_poster():
    c = canvas.Canvas(out_path, pagesize=landscape(A1))
    W, H = landscape(A1)
    
    # ─ Background ─
    c.setFillColor(colors.HexColor("#F0F4FF"))
    c.rect(0, 0, W, H, fill=1, stroke=0)
    
    # ─ Title banner ─
    banner_h = 38*mm
    c.setFillColor(NAVY)
    c.rect(0, H - banner_h, W, banner_h, fill=1, stroke=0)
    
    # Title text
    c.setFillColor(WHITE)
    c.setFont("Helvetica-Bold", 30)
    c.drawCentredString(W/2, H - 18*mm, "MBBS FINAL YEAR COMPLETE STUDY TIMETABLE")
    c.setFont("Helvetica", 15)
    c.drawCentredString(W/2, H - 30*mm, "July 15 – October 1, 2026   |   79 Days   |   11 Subjects: Medicine, Surgery, OBGyn, Pediatrics, ENT, Ophthalmology, Dermatology, Psychiatry, Orthopedics, Radiology, Anesthesia")
    
    # ─ Legend row ─
    legend_y = H - banner_h - 12*mm
    subjects_legend = [
        ("Medicine", DEEP_BLUE), ("Surgery", RED_DARK), ("OBGyn", PINK),
        ("Pediatrics", PURPLE), ("Orthopedics", RED_BRT), ("ENT", GRN_DARK),
        ("Ophthalmology", GRN_MED), ("Dermatology", AMBER), ("Psychiatry", BROWN),
        ("Radiology", MED_BLUE), ("Anesthesia", ORANGE), ("REVISION / MOCK", SLATE),
    ]
    box_w = W / len(subjects_legend)
    for i, (name, col) in enumerate(subjects_legend):
        x = i * box_w
        c.setFillColor(col)
        c.rect(x, legend_y - 9*mm, box_w, 9*mm, fill=1, stroke=0)
        c.setFillColor(WHITE)
        c.setFont("Helvetica-Bold", 8)
        c.drawCentredString(x + box_w/2, legend_y - 6*mm, name)
    
    # ─ Daily schedule sidebars ─
    sidebar_w = 52*mm
    content_x_start = MARGIN + sidebar_w + 3*mm
    content_w = W - 2*MARGIN - 2*(sidebar_w + 3*mm)
    
    # Normal day schedule (left sidebar)
    sched_top = legend_y - 9*mm - 2*mm
    sched_bottom = 10*mm
    sched_h = sched_top - sched_bottom
    
    # Left sidebar background
    c.setFillColor(colors.HexColor("#E8EAF6"))
    c.roundRect(MARGIN, sched_bottom, sidebar_w, sched_h, 3*mm, fill=1, stroke=0)
    
    c.setFillColor(NAVY)
    c.rect(MARGIN, sched_top - 12*mm, sidebar_w, 12*mm, fill=1, stroke=0)
    c.setFillColor(WHITE)
    c.setFont("Helvetica-Bold", 9)
    c.drawCentredString(MARGIN + sidebar_w/2, sched_top - 8*mm, "NORMAL DAY SCHEDULE")
    c.setFont("Helvetica", 7)
    c.drawCentredString(MARGIN + sidebar_w/2, sched_top - 12*mm + 1*mm, "10-11 hrs study | 1 hr exercise | 7 hrs sleep")
    
    normal_sched = [
        ("05:30 AM", "Wake up"),
        ("05:45–06:45", "Exercise / Walk / Yoga"),
        ("06:45–07:15", "Freshen up + Breakfast"),
        ("07:15–10:15", "PRIMARY SUBJECT – Theory (3 hrs)"),
        ("10:15–10:30", "Short break"),
        ("10:30–01:00", "PRIMARY SUBJECT – High-yield topics + Notes (2.5 hrs)"),
        ("01:00–02:00", "Lunch + Rest"),
        ("02:00–04:30", "PAIRED SUBJECT – Theory (2.5 hrs)"),
        ("04:30–04:45", "Break"),
        ("04:45–06:45", "PAIRED SUBJECT – MCQs + Revision (2 hrs)"),
        ("06:45–07:30", "Dinner"),
        ("07:30–09:00", "BOTH SUBJECTS – Revision + Flashcards + Cheat sheets (1.5 hrs)"),
        ("09:00–09:30", "Plan next day + Weak areas list"),
        ("09:30–10:30", "Wind down"),
        ("10:30 PM", "SLEEP (7 hours)  ↓  Wake 05:30"),
    ]
    
    sched_text_y = sched_top - 14*mm
    row_h = (sched_h - 14*mm - 4*mm) / len(normal_sched)
    for time_val, activity in normal_sched:
        row_bg = colors.HexColor("#FFFFFF") if ("PRIMARY" in activity or "PAIRED" in activity or "BOTH" in activity) else colors.HexColor("#EEF2FF")
        if "SLEEP" in activity:
            row_bg = colors.HexColor("#BBDEFB")
        elif "Exercise" in activity:
            row_bg = colors.HexColor("#C8E6C9")
        c.setFillColor(row_bg)
        c.rect(MARGIN + 1*mm, sched_text_y - row_h + 1*mm, sidebar_w - 2*mm, row_h - 1*mm, fill=1, stroke=0)
        c.setFillColor(NAVY)
        c.setFont("Helvetica-Bold", 6.5)
        c.drawString(MARGIN + 2*mm, sched_text_y - row_h/2 + 1*mm, time_val)
        c.setFillColor(colors.HexColor("#212121"))
        c.setFont("Helvetica", 6.5)
        # Wrap long text
        if len(activity) > 35:
            mid = activity.rfind(' ', 0, 35)
            c.drawString(MARGIN + 22*mm, sched_text_y - row_h/2 + 2.5*mm, activity[:mid])
            c.drawString(MARGIN + 22*mm, sched_text_y - row_h/2 - 1.5*mm, activity[mid+1:])
        else:
            c.drawString(MARGIN + 22*mm, sched_text_y - row_h/2 + 1*mm, activity)
        sched_text_y -= row_h
    
    # Right sidebar (Posting day schedule)
    post_x = W - MARGIN - sidebar_w
    c.setFillColor(colors.HexColor("#FCE4EC"))
    c.roundRect(post_x, sched_bottom, sidebar_w, sched_h, 3*mm, fill=1, stroke=0)
    
    c.setFillColor(colors.HexColor("#880E4F"))
    c.rect(post_x, sched_top - 12*mm, sidebar_w, 12*mm, fill=1, stroke=0)
    c.setFillColor(WHITE)
    c.setFont("Helvetica-Bold", 9)
    c.drawCentredString(post_x + sidebar_w/2, sched_top - 8*mm, "POSTING DAY SCHEDULE")
    c.setFont("Helvetica", 7)
    c.drawCentredString(post_x + sidebar_w/2, sched_top - 12*mm + 1*mm, "Hospital 9 AM–1 PM | 7.5 hrs study | 7 hrs sleep")
    
    posting_sched = [
        ("05:30 AM", "Wake up"),
        ("05:45–06:30", "Light review: flashcards + mnemonics"),
        ("06:30–07:15", "Get ready + Breakfast"),
        ("07:15–09:00", "Travel to hospital"),
        ("09:00–01:00", "HOSPITAL POSTING (observe + connect to topics)"),
        ("01:00–02:00", "Lunch + Rest (20 min nap ok)"),
        ("02:00–03:00", "EXERCISE – Walk/gym/yoga (1 hour)"),
        ("03:00–03:15", "Freshen up + snack"),
        ("03:15–06:15", "PRIMARY SUBJECT – Theory (3 hrs)"),
        ("06:15–06:30", "Short break"),
        ("06:30–08:30", "PAIRED SUBJECT – Theory + MCQs (2 hrs)"),
        ("08:30–09:15", "Dinner"),
        ("09:15–10:45", "REVISION – Both subjects (1.5 hrs)"),
        ("10:45–11:15", "Plan next day + weak topics list"),
        ("11:15 PM", "SLEEP (7 hours)  ↓  Wake 06:15"),
    ]
    
    sched_text_y = sched_top - 14*mm
    for time_val, activity in posting_sched:
        row_bg = colors.HexColor("#FFFFFF") if ("PRIMARY" in activity or "PAIRED" in activity or "REVISION" in activity) else colors.HexColor("#FCE4EC")
        if "SLEEP" in activity:
            row_bg = colors.HexColor("#BBDEFB")
        elif "EXERCISE" in activity:
            row_bg = colors.HexColor("#C8E6C9")
        elif "HOSPITAL" in activity:
            row_bg = colors.HexColor("#F1F8E9")
        c.setFillColor(row_bg)
        c.rect(post_x + 1*mm, sched_text_y - row_h + 1*mm, sidebar_w - 2*mm, row_h - 1*mm, fill=1, stroke=0)
        c.setFillColor(colors.HexColor("#880E4F"))
        c.setFont("Helvetica-Bold", 6.5)
        c.drawString(post_x + 2*mm, sched_text_y - row_h/2 + 1*mm, time_val)
        c.setFillColor(colors.HexColor("#212121"))
        c.setFont("Helvetica", 6.5)
        if len(activity) > 35:
            mid = activity.rfind(' ', 0, 35)
            if mid == -1: mid = 35
            c.drawString(post_x + 22*mm, sched_text_y - row_h/2 + 2.5*mm, activity[:mid])
            c.drawString(post_x + 22*mm, sched_text_y - row_h/2 - 1.5*mm, activity[mid+1:])
        else:
            c.drawString(post_x + 22*mm, sched_text_y - row_h/2 + 1*mm, activity)
        sched_text_y -= row_h

    # ─ Main timetable grid ───────────────────────────────────────────────────
    grid_x = content_x_start
    grid_w = content_w
    grid_top = sched_top - 0.5*mm
    grid_bottom = sched_bottom
    grid_h = grid_top - grid_bottom
    
    # 79 days in a grid. Let's do 8 columns x 10 rows = 80 slots (last one empty)
    COLS = 8
    ROWS = 10
    cell_w = grid_w / COLS
    cell_h = grid_h / ROWS
    
    for idx, entry in enumerate(timetable):
        if len(entry) == 5:
            day_num, date_str, phase_code, subj, topics = entry
        else:
            continue
        
        col = idx % COLS
        row = idx // COLS
        
        cell_x = grid_x + col * cell_w
        cell_y = grid_top - (row + 1) * cell_h
        
        bg_color = get_phase_bg(phase_code)
        sc = subj_color(subj)
        
        # Cell background
        c.setFillColor(bg_color)
        c.rect(cell_x + 0.3*mm, cell_y + 0.3*mm, cell_w - 0.6*mm, cell_h - 0.6*mm, fill=1, stroke=0)
        
        # Left color bar
        c.setFillColor(sc)
        c.rect(cell_x + 0.3*mm, cell_y + 0.3*mm, 3*mm, cell_h - 0.6*mm, fill=1, stroke=0)
        
        # Day number circle / box
        c.setFillColor(sc)
        c.rect(cell_x + 3.3*mm, cell_y + cell_h - 6.5*mm, 8*mm, 6*mm, fill=1, stroke=0)
        c.setFillColor(WHITE)
        c.setFont("Helvetica-Bold", 8)
        c.drawCentredString(cell_x + 7.3*mm, cell_y + cell_h - 4.5*mm, f"D{day_num}")
        
        # Date
        c.setFillColor(colors.HexColor("#424242"))
        c.setFont("Helvetica", 7)
        c.drawString(cell_x + 12*mm, cell_y + cell_h - 4*mm, date_str)
        
        # Subject label
        c.setFillColor(sc)
        c.setFont("Helvetica-Bold", 7.5)
        c.drawString(cell_x + 3.8*mm, cell_y + cell_h - 10*mm, subj)
        
        # Topics text (multi-line)
        text_x = cell_x + 3.8*mm
        text_y = cell_y + cell_h - 13.5*mm
        text_w = cell_w - 5*mm
        c.setFillColor(colors.HexColor("#212121"))
        c.setFont("Helvetica", 5.8)
        
        lines = topics.split('\n')
        for line in lines:
            # Simple word-wrap
            words = line.split()
            current_line = ""
            for word in words:
                test = current_line + (" " if current_line else "") + word
                if c.stringWidth(test, "Helvetica", 5.8) > text_w - 2*mm:
                    if current_line:
                        if text_y > cell_y + 1*mm:
                            c.drawString(text_x, text_y, current_line)
                            text_y -= 6.5
                        current_line = word
                    else:
                        if text_y > cell_y + 1*mm:
                            c.drawString(text_x, text_y, word)
                            text_y -= 6.5
                else:
                    current_line = test
            if current_line and text_y > cell_y + 1*mm:
                c.drawString(text_x, text_y, current_line)
                text_y -= 6.5
            text_y -= 1  # extra gap between lines
        
        # Thin border
        c.setStrokeColor(colors.HexColor("#B0BEC5"))
        c.setLineWidth(0.3)
        c.rect(cell_x + 0.3*mm, cell_y + 0.3*mm, cell_w - 0.6*mm, cell_h - 0.6*mm, fill=0, stroke=1)
    
    # ─ Footer ─
    c.setFillColor(NAVY)
    c.setFont("Helvetica-Bold", 8)
    c.drawCentredString(W/2, 4*mm, 
        "MBBS FINAL YEAR TIMETABLE  |  July 15 – October 1, 2026  |  79 Days  |  Medicine • Surgery • OBGyn • Pediatrics • ENT • Ophthalmology • Dermatology • Psychiatry • Orthopedics • Radiology • Anesthesia")
    
    c.save()
    print(f"Poster saved: {out_path}")

build_poster()
Running Command

cd /home/daytona/workspace/mbbs-timetable && python build_excel.py 2>&1

Running Command

cd /home/daytona/workspace/mbbs-timetable && python build_poster.py 2>&1

Running Command

ls /home/daytona/workspace/mbbs-timetable/ && python3 -c " import os, tempfile # Test write to workspace p = '/home/daytona/workspace/mbbs-timetable/test.txt' with open(p,'w') as f: f.write('test') print('write ok') os.remove(p) "

Running Command

cd /home/daytona/workspace/mbbs-timetable && python3 -c " import openpyxl wb = openpyxl.Workbook() ws = wb.active ws['A1'] = 'test' wb.save('/home/daytona/workspace/mbbs-timetable/test_out.xlsx') print('openpyxl save OK') import os; os.remove('/home/daytona/workspace/mbbs-timetable/test_out.xlsx') " 2>&1

Running Command

python3 -c "import xlsxwriter; print('xlsxwriter available')" 2>&1

Running Command

pip install --user xlsxwriter -q 2>&1 | tail -3

Generate a printable wall poster of this timetable with everything like which subjects and topics I'm gonna study everyday & also create a daily checklist excel file for the same & also sometimes i have to go to posting from 9-1 in the morning so make a different time table for days like that and... you cab include things like 7 hrs of sleep if possible then 10-11 hrs of study & 1 hr of exercise (i cannot properly focus on early morning so you can include exercise and other thing in the morning & after that study)

Running Command

mkdir -p /home/daytona/workspace/mbbs-timetable && python3 -c "import xlsxwriter; print('OK')" 2>&1 && python3 -c "from reportlab.pdfgen import canvas; print('reportlab OK')" 2>&1

Running Command

pip install --user xlsxwriter -q 2>&1 | tail -2 && python3 -c "import xlsxwriter; print('xlsxwriter OK')" && python3 -c "from reportlab.pdfgen import canvas; print('reportlab OK')"

Generate a downloadable wall poster of this timetable with everything like which subjects and topics I'm gonna study everyday & also sometimes i have to go to posting from 9-1 in the morning so make a different time table for days like that and... you can include things like 7 hrs of sleep if possible then 10-11 hrs of study & 1 hr of exercise (i cannot properly focus on early morning so you can include exercise and other thing in the morning & after that study)

Running Command

mkdir -p /home/daytona/workspace/mbbs-timetable pip install --user xlsxwriter -q 2>&1 | tail -1 python3 -c "import xlsxwriter; print('xlsxwriter OK')" python3 -c "from reportlab.pdfgen import canvas; from reportlab.lib.pagesizes import A1; print('reportlab OK')"

Writing File

~/mbbs-timetable/make_poster.py

"""
MBBS Final Year Wall Poster - A1 Landscape PDF
All 79 days, full topics, both daily schedules (Normal + Posting day)
"""
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import A1, landscape
from reportlab.lib import colors
from reportlab.lib.units import mm

# ── Colors ────────────────────────────────────────────────────────────────────
NAVY    = colors.HexColor("#1A237E")
WHITE   = colors.white
BLK     = colors.HexColor("#212121")
GREY_LT = colors.HexColor("#F5F5F5")

# Subject accent colors
SC = {
    "Medicine":      colors.HexColor("#1565C0"),
    "Radiology":     colors.HexColor("#0277BD"),
    "Surgery":       colors.HexColor("#B71C1C"),
    "Orthopedics":   colors.HexColor("#C62828"),
    "Anesthesia":    colors.HexColor("#E64A19"),
    "OBGyn":         colors.HexColor("#AD1457"),
    "Pediatrics":    colors.HexColor("#6A1B9A"),
    "ENT":           colors.HexColor("#2E7D32"),
    "Ophthalmology": colors.HexColor("#1B5E20"),
    "Dermatology":   colors.HexColor("#F57F17"),
    "Psychiatry":    colors.HexColor("#4E342E"),
    "REVISION":      colors.HexColor("#37474F"),
    "MOCK":          colors.HexColor("#37474F"),
    "FINAL":         colors.HexColor("#1A237E"),
}

# Phase background colors (very light)
PBG = {
    "P1": colors.HexColor("#DCEEFB"),   # light blue   - Medicine+Radiology
    "P2": colors.HexColor("#FDECEA"),   # light red    - Surgery+Ortho+Anesthesia
    "P3": colors.HexColor("#F3E5F5"),   # light purple - OBGyn+Pediatrics
    "P4": colors.HexColor("#E8F5E9"),   # light green  - ENT+Ophthal
    "P5": colors.HexColor("#FFF8E1"),   # light amber  - Dermat+Psychiatry
    "P6": colors.HexColor("#ECEFF1"),   # light grey   - Revision
}

def scolor(s):
    for k in SC:
        if s.startswith(k):
            return SC[k]
    return SC["REVISION"]

# ── Timetable data: (day, date, phase, primary_subj, topics_line1, topics_line2, paired_subj, paired_topics) ──
DAYS = [
 (1,"15 Jul","P1","Medicine","Cardio: HTN, Heart Failure, CCF, JVP","management, Hypertensive urgency/emergency","Radiology","CXR basics: cardiomegaly, pulmonary oedema signs"),
 (2,"16 Jul","P1","Medicine","Cardio: IHD, Angina, MI - types, ECG","changes, STEMI management, complications","Radiology","ECG interpretation: STEMI, LVH, LBBB; angiography overview"),
 (3,"17 Jul","P1","Medicine","Cardio: Valvular HD (MS, MR, AS, AR),","Infective Endocarditis, Cardiomyopathies","Radiology","Echo basics; MS signs on CXR; Duke criteria"),
 (4,"18 Jul","P1","Medicine","Respiratory: Asthma, COPD, Pneumonia","(bacterial + atypical), Bronchiectasis, TB","Radiology","CXR: consolidation, cavitation, hilar LAD, miliary TB"),
 (5,"19 Jul","P1","Medicine","Respiratory: Pleural effusion, Pneumothorax","ARDS, Lung cancer, ILD, Respiratory failure","Radiology","CXR: effusion/pneumothorax; CT chest: GGO, honeycombing"),
 (6,"20 Jul","P1","REVISION","REVISION DAY - Cardio + Respiratory","MCQ marathon + short notes + mnemonics","","Both systems - all topics from Days 1-5"),
 (7,"21 Jul","P1","Medicine","GI: GERD, PUD, IBD (Crohn's vs UC)","Liver disease, hepatitis, cirrhosis, portal HTN","Radiology","USG abdomen; cirrhosis signs; portal hypertension imaging"),
 (8,"22 Jul","P1","Medicine","GI: Jaundice (3 types + LFT patterns)","Acute + chronic pancreatitis, Malabsorption","Radiology","MRCP/ERCP overview; pancreatic imaging; Ranson's criteria"),
 (9,"23 Jul","P1","Medicine","Nephrology: AKI, CKD, Nephrotic vs","Nephritic syndrome, GN types, dialysis","Radiology","Renal USG; IVP; CT urography; biopsy indications"),
 (10,"24 Jul","P1","Medicine","Nephrology: UTI, RTA, Hypo/Hypernatremia","Hypo/Hyperkalemia, Acid-base disorders, ABG","Radiology","KUB X-ray; renal calculi imaging; staghorn calculus"),
 (11,"25 Jul","P1","Medicine","Endocrine: DM type 1+2, complications,","all drug classes; Thyroid (hypo/hyper/cancer)","Radiology","Thyroid USG; nuclear medicine thyroid scan; DEXA scan"),
 (12,"26 Jul","P1","Medicine","Endocrine: Adrenal (Cushing's, Addison's,","Pheo); Pituitary; DI vs SIADH; Calcium","Radiology","Adrenal imaging; pituitary MRI; calcium disorders imaging"),
 (13,"27 Jul","P1","REVISION","REVISION DAY - GI + Nephrology +","Endocrine MCQ marathon + cheat sheets","","All three systems - 120+ MCQs"),
 (14,"28 Jul","P1","Medicine","Hematology: Anemia (IDA, B12/folate,","hemolytic, aplastic), Leukemia, Lymphoma","Radiology","BM biopsy overview; CT staging for lymphoma"),
 (15,"29 Jul","P1","Medicine","Neurology: Stroke (ischemic vs haem),","Epilepsy, Meningitis, Parkinson's, MG, GBS","Radiology","CT brain: haemorrhage, ischaemia, herniation; MRI brain"),
 (16,"30 Jul","P1","Medicine","Rheumatology (RA, SLE, gout) + Infectious","(sepsis, malaria, typhoid, dengue, HIV) + MCQs","Radiology","Joint X-ray findings; CXR in HIV/OI; Medicine MCQ marathon 100+"),
 (17,"31 Jul","P2","Surgery","Surgical principles: Wound healing, sutures","surgical infections, Shock (all types), Sepsis-3","Anesthesia","Pre-op assessment, ASA grading, fasting guidelines, pre-med"),
 (18,"1 Aug","P2","Surgery","Breast: Anatomy, benign breast disease","Ca breast - staging, mastectomy types, SNB","Anesthesia","Induction agents, muscle relaxants, volatile agents, LA toxicity"),
 (19,"2 Aug","P2","Surgery","Thyroid + Parathyroid: Surgery, goiter,","Ca thyroid (all types), parathyroid adenoma","Anesthesia","Airway management: intubation, LMA, difficult airway, RSI"),
 (20,"3 Aug","P2","REVISION","REVISION: Surgery Days 17-19 MCQs","+ Ortho: Fracture principles, healing, Gustilo","","Fracture classification, AVN, fat embolism, compartment syndrome"),
 (21,"4 Aug","P2","Surgery","GI Surg: Ca esophagus, achalasia, gastric","cancer, PU surgery, SBO, Appendicitis (Alvarado)","Orthopedics","Upper limb: Colles, scaphoid, supracondylar, shoulder dislocation"),
 (22,"5 Aug","P2","Surgery","Colorectal: Ca colon/rectum (Duke's, CEA)","diverticulitis, hemorrhoids, fistula (Parks), DNS","Orthopedics","Lower limb: NOF, intertrochanteric, shaft femur, tibia, ankle"),
 (23,"6 Aug","P2","Surgery","Hepatobiliary: Liver abscess, hydatid cyst","cholecystitis, Ca pancreas, Whipple, portal HTN","Orthopedics","Spine: PLID, spinal cord injury (ASIA), scoliosis, Pott's disease"),
 (24,"7 Aug","P2","Surgery","Hernia: All types, Hasselbach's triangle","strangulation/obstruction, Lichtenstein repair","Orthopedics","Bone tumors (osteosarcoma, Ewing's), osteomyelitis, septic arthritis"),
 (25,"8 Aug","P2","Surgery","Vascular: PVD (ABPI), DVT, varicose veins","AAA, carotid disease, Buerger's, amputations","Orthopedics","Metabolic bone: osteoporosis, osteomalacia, Paget's disease"),
 (26,"9 Aug","P2","Surgery","Urology: BPH, prostate Ca (PSA, TURP)","bladder Ca, RCC, testicular tumors, undescended","Orthopedics","Pediatric ortho: DDH, CTEV, LCPD, SCFE; TKR/THR joints"),
 (27,"10 Aug","P2","REVISION","REVISION: Surgery MCQ marathon","+ Orthopedics MCQ marathon - all topics","","Identify weak topics; 120+ MCQs combined"),
 (28,"11 Aug","P2","Surgery","Neurosurgery: Head injury (GCS, EDH vs SDH","DAI), brain tumors, hydrocephalus, ICP","Anesthesia","Regional: spinal, epidural, nerve blocks, spinal anesthesia complications"),
 (29,"12 Aug","P2","Surgery","Pediatric Surgery: Intussusception, pyloric","stenosis, Hirschsprung's, TEF, Wilm's, NB","Anesthesia","Monitoring (BIS, TOF, invasive BP), TIVA, pediatric/cardiac anesthesia"),
 (30,"13 Aug","P2","Surgery","Burns (Rule of 9, Parkland formula), skin","tumors (BCC, SCC, melanoma) + Surgery MCQ marathon","Anesthesia","MH, succinylcholine complications, PONV, post-op pulmonary complications"),
 (31,"14 Aug","P3","OBGyn","Normal pregnancy: ANC schedule, physiological","changes in pregnancy, dating, investigations","Pediatrics","Normal newborn: APGAR, examination, Year-1 milestones, immunization"),
 (32,"15 Aug","P3","OBGyn","High-risk: Pre-eclampsia, eclampsia (MgSO4","Pritchard regime), Gestational diabetes","Pediatrics","Neonatal: sepsis, RDS (surfactant), HIE (cooling), NEC, neonatal jaundice"),
 (33,"16 Aug","P3","OBGyn","APH: Placenta previa (grades), abruptio","PPH: 4T's, uterotonics, B-Lynch, Bakri balloon","Pediatrics","Peds respiratory: Croup vs epiglottitis, bronchiolitis, asthma, IMNCI"),
 (34,"17 Aug","P3","REVISION","REVISION: OBGyn Days 31-33 MCQs","+ Peds Days 31-33 MCQs + cheat sheets","","MgSO4 protocol, APGAR table, PPH flowchart, IMNCI classification"),
 (35,"18 Aug","P3","OBGyn","Labour: Stages, partograph, CTG interpretation","(late/early/variable decels), instrumental delivery","Pediatrics","GI: Diarrhea (ORT, IMNCI), typhoid, intussusception, HUS, malnutrition"),
 (36,"19 Aug","P3","OBGyn","Obstetric complications: IUGR, PROM, preterm","labour (tocolytics, steroids), malpresentations","Pediatrics","Neuro: febrile seizures, epilepsy, bacterial/TB meningitis, cerebral palsy"),
 (37,"20 Aug","P3","OBGyn","Medical disorders in pregnancy: Anemia, cardiac","disease, thyroid, renal, HELLP, AFLP, ICP","Pediatrics","Haematology: ALL vs AML, lymphoma, hemophilia, ITP, thalassemia mgmt"),
 (38,"21 Aug","P3","OBGyn","Gynecology: PCOS (Rotterdam criteria), DUB","amenorrhea, endometriosis, uterine fibroids","Pediatrics","Nephrology: Nephrotic syndrome (MCD), UTI in children, acute GN, HUS"),
 (39,"22 Aug","P3","OBGyn","Gyn cancers: Cervical (FIGO staging, Pap smear","colposcopy, LEEP), ovarian, endometrial Ca","Pediatrics","Endocrine: Type 1 DM (DKA), congenital hypothyroidism, CAH, short stature"),
 (40,"23 Aug","P3","OBGyn","Gynecology: Genital prolapse (POP-Q), urinary","incontinence (stress vs urge), vulvar disorders","Pediatrics","Infectious: Measles, Kawasaki disease, rheumatic fever (Jones), dengue"),
 (41,"24 Aug","P3","REVISION","REVISION: OBGyn Gynecology MCQs","+ Peds Days 35-40 MCQs + overlap topics","","Conditions overlapping OBGyn + Peds: neonatal-maternal overlap"),
 (42,"25 Aug","P3","OBGyn","STIs (syphilis, gonorrhea, chlamydia, HPV)","Contraception: OCP (USMEC), IUCD, EC, sterilization","Pediatrics","Nutrition: Vitamin deficiencies (A,B,C,D,K), rickets, Kwashiorkor vs Marasmus"),
 (43,"26 Aug","P3","OBGyn","Ectopic pregnancy (methotrexate criteria)","GTD (molar, choriocarcinoma), recurrent PL","Pediatrics","Genetics/CHD: Down's, Turner's, Klinefelter's, TOF, VSD, ASD, TGA"),
 (44,"27 Aug","P3","OBGyn","C-section (indications, types, complications)","obstetric fistula, puerperal fever, lactation","Pediatrics","Developmental: milestones (all ages), ASD, ADHD + Peds MCQ marathon"),
 (45,"28 Aug","P3","OBGyn","OBGyn MCQ marathon (150+ MCQs)","Weak area revision + gap filling","Pediatrics","Pediatrics MCQ marathon (150+ MCQs) + weak area revision"),
 (46,"29 Aug","P3","REVISION","OBGyn mock test: 60 Qs timed (60 min)","Review wrong answers + make final cheat sheets","Pediatrics","Peds mock test: 60 Qs timed (60 min) + review wrong answers"),
 (47,"30 Aug","P4","ENT","Ear: Anatomy, ASOM, CSOM (safe vs unsafe,","cholesteatoma), mastoiditis, otosclerosis","Ophthalmology","Eye anatomy, conjunctivitis (all types, trachoma), corneal ulcer, keratitis"),
 (48,"31 Aug","P4","ENT","Hearing loss (audiogram, Rinne/Weber), Meniere's","BPPV (Epley's maneuver), vestibular schwannoma","Ophthalmology","Glaucoma (open/closed angle, IOP, drugs), cataract (surgery, IOL, complications)"),
 (49,"1 Sep","P4","ENT","Nose + PNS: Epistaxis (Little's area), DNS","allergic rhinitis, sinusitis, nasal polyps","Ophthalmology","Retina: DR (laser), RD (surgery types), CRAO, CRVO, AMD, hypertensive retinopathy"),
 (50,"2 Sep","P4","ENT","Throat: Tonsillitis, quinsy (peritonsillar abscess)","deep neck infections, Ludwig's angina, FB airway","Ophthalmology","Squint (cover test, Hirschberg), amblyopia, uveitis (HLA-B27), optic neuritis"),
 (51,"3 Sep","P4","ENT","Tumors: Ca larynx (staging, laryngectomy), Ca NP","(EBV), juvenile angiofibroma + ENT MCQ marathon","Ophthalmology","Eyelid (chalazion, ptosis, DCR), orbit/proptosis, trauma, emergencies + MCQ marathon"),
 (52,"4 Sep","P4","REVISION","REVISION: ENT mock test 50 Qs timed","Review wrong answers + ENT cheat sheet","Ophthalmology","Ophthal mock test 50 Qs timed + review + cheat sheet"),
 (53,"5 Sep","P5","Dermatology","Lesion morphology (macule, papule, plaque, vesicle","bulla, pustule, wheal); Eczema; Psoriasis (PASI)","Psychiatry","Psychopathology, MSE, ICD-10 vs DSM-5, MDD (criteria + antidepressants)"),
 (54,"6 Sep","P5","Dermatology","Bacterial (impetigo, cellulitis, erysipelas)","Fungal (tinea types, candida, PV); Viral (herpes)","Psychiatry","Anxiety: Panic disorder, GAD, OCD, PTSD, phobias; somatoform disorders"),
 (55,"7 Sep","P5","Dermatology","STDs: Syphilis (1°/2°/3°, VDRL vs FTA-ABS)","gonorrhea, LGV, chancroid; Scabies (treatment)","Psychiatry","Schizophrenia: criteria, subtypes, antipsychotics (typical vs atypical), EPS, NMS"),
 (56,"8 Sep","P5","Dermatology","Bullous: Pemphigus vs Pemphigoid (Nikolsky sign)","Lichen planus; Drug reactions: SJS, TEN, DRESS, FDE","Psychiatry","Bipolar (Lithium monitoring), Alcohol (CIWA-Ar, DTs), Opioid dependence (buprenorphine)"),
 (57,"9 Sep","P5","Dermatology","Skin tumors (melanoma ABCDE, BCC, SCC)","Urticaria, Vitiligo, Leprosy (MDT) + Dermat MCQs","Psychiatry","Child psych (autism, ADHD), Forensic (McNaughton rules, IPC sections), ECT + Psych MCQs"),
 (58,"10 Sep","P5","REVISION","REVISION: Dermatology mock test 50 Qs timed","Review wrong answers + Dermat cheat sheet","Psychiatry","Psychiatry mock test 50 Qs timed + review + cheat sheet"),
 (59,"11 Sep","P6","REVISION","Medicine Revision: Cardiovascular + Respiratory","MCQ patterns, imaging correlations, 80+ MCQs","",""),
 (60,"12 Sep","P6","REVISION","Medicine Revision: GI + Nephrology","MCQ marathon, clinical scenario questions","",""),
 (61,"13 Sep","P6","REVISION","Medicine Revision: Endocrinology + Haematology","+ Neurology  MCQ marathon  80+ MCQs","",""),
 (62,"14 Sep","P6","REVISION","Medicine Revision: Rheumatology + Infectious","MEDICINE MOCK TEST - 100 Qs timed (Target >70%)","",""),
 (63,"15 Sep","P6","REVISION","Surgery Revision: Breast + Thyroid","+ Hepatobiliary + GI Surgery  MCQ marathon","",""),
 (64,"16 Sep","P6","REVISION","Surgery Revision: Vascular + Urology","+ Pediatric Surgery + Neurosurgery  MCQs","",""),
 (65,"17 Sep","P6","REVISION","Ortho full revision: MCQ test 60 Qs (morning)","Anesthesia full revision: MCQ test 40 Qs (afternoon)","",""),
 (66,"18 Sep","P6","REVISION","OBGyn Revision: Full Obstetrics","Normal + abnormal, labour, complications  80+ MCQs","",""),
 (67,"19 Sep","P6","REVISION","OBGyn Revision: Full Gynecology","OBGYN MOCK TEST - 75 Qs timed (Target >70%)","",""),
 (68,"20 Sep","P6","REVISION","Pediatrics Revision: Neonatal + Respiratory","+ GI Pediatrics  MCQ marathon  80+ MCQs","",""),
 (69,"21 Sep","P6","REVISION","Pediatrics Revision: Haematology + Neurology","PEDIATRICS MOCK TEST - 75 Qs timed (Target >70%)","",""),
 (70,"22 Sep","P6","REVISION","ENT full revision + Ophthalmology full revision","MCQ tests for both subjects (morning + afternoon)","",""),
 (71,"23 Sep","P6","REVISION","Dermatology full revision + Psychiatry full revision","MCQ tests for both subjects (morning + afternoon)","",""),
 (72,"24 Sep","P6","MOCK","MEGA MOCK DAY 1","Medicine 100 Qs timed (AM) + Surgery 100 Qs (PM)","",""),
 (73,"25 Sep","P6","MOCK","MEGA MOCK DAY 2","OBGyn 75 Qs timed (AM) + Pediatrics 75 Qs (PM)","",""),
 (74,"26 Sep","P6","MOCK","MEGA MOCK DAY 3","ENT+Ophthal+Dermat+Psych+Ortho+Anaes+Radio: 100 Qs","",""),
 (75,"27 Sep","P6","REVISION","Analyze ALL mock test results","Revise EVERY wrong answer across all subjects","",""),
 (76,"28 Sep","P6","REVISION","High-yield rapid revision + viva prep","Medicine + Surgery: clinical scenarios, spotters","",""),
 (77,"29 Sep","P6","REVISION","High-yield rapid revision + viva prep","OBGyn + Pediatrics: clinical scenarios, spotters","",""),
 (78,"30 Sep","P6","REVISION","ALL allied subjects rapid revision","ENT, Ophthal, Dermat, Psych, Ortho, Radio, Anaes","",""),
 (79,"1 Oct","P6","FINAL","FINAL DAY - LIGHT REVISION ONLY","All cheat sheets + short notes. No new topics. REST.","",""),
]

OUT = "/home/daytona/workspace/mbbs-timetable/MBBS_Wall_Poster.pdf"
W, H = landscape(A1)
M = 12*mm

c = canvas.Canvas(OUT, pagesize=landscape(A1))

# ── Banner ─────────────────────────────────────────────────────────────────
BANNER_H = 32*mm
c.setFillColor(NAVY)
c.rect(0, H-BANNER_H, W, BANNER_H, fill=1, stroke=0)

c.setFillColor(WHITE)
c.setFont("Helvetica-Bold", 28)
c.drawCentredString(W/2, H-18*mm, "MBBS FINAL YEAR — COMPLETE STUDY TIMETABLE")
c.setFont("Helvetica", 13)
c.drawCentredString(W/2, H-27*mm,
    "July 15 – October 1, 2026   |   79 Days   |   Medicine · Surgery · OBGyn · Pediatrics · ENT · Ophthalmology · Dermatology · Psychiatry · Orthopedics · Radiology · Anesthesia")

# ── Subject legend bar ──────────────────────────────────────────────────────
LEG_H = 10*mm
LEG_Y = H - BANNER_H - LEG_H
legend_items = [
    ("Medicine", "#1565C0"), ("Radiology", "#0277BD"), ("Surgery", "#B71C1C"),
    ("Orthopedics", "#C62828"), ("Anesthesia", "#E64A19"), ("OBGyn", "#AD1457"),
    ("Pediatrics", "#6A1B9A"), ("ENT", "#2E7D32"), ("Ophthalmology", "#1B5E20"),
    ("Dermatology", "#F57F17"), ("Psychiatry", "#4E342E"), ("Revision/Mock", "#37474F"),
]
seg_w = W / len(legend_items)
for i, (name, col) in enumerate(legend_items):
    c.setFillColor(colors.HexColor(col))
    c.rect(i*seg_w, LEG_Y, seg_w, LEG_H, fill=1, stroke=0)
    c.setFillColor(WHITE)
    c.setFont("Helvetica-Bold", 7.5)
    c.drawCentredString(i*seg_w + seg_w/2, LEG_Y + 3.5*mm, name)

# ── Two schedule sidebars ──────────────────────────────────────────────────
SIDEBAR_W = 54*mm
GRID_TOP   = LEG_Y - 2*mm
GRID_BOT   = 10*mm
GRID_H     = GRID_TOP - GRID_BOT

# Left sidebar - Normal Day
SBL_X = M
c.setFillColor(colors.HexColor("#E8EAF6"))
c.roundRect(SBL_X, GRID_BOT, SIDEBAR_W, GRID_H, 3*mm, fill=1, stroke=0)
c.setFillColor(NAVY)
c.rect(SBL_X, GRID_TOP-11*mm, SIDEBAR_W, 11*mm, fill=1, stroke=0)
c.setFillColor(WHITE)
c.setFont("Helvetica-Bold", 9)
c.drawCentredString(SBL_X+SIDEBAR_W/2, GRID_TOP-6*mm, "NORMAL DAY SCHEDULE")
c.setFont("Helvetica", 7)
c.drawCentredString(SBL_X+SIDEBAR_W/2, GRID_TOP-10*mm, "10-11 hrs study  |  1 hr exercise  |  7 hrs sleep")

NORMAL = [
    ("05:30 AM","Wake up - drink water immediately"),
    ("05:45-06:45","Exercise / Walk / Yoga  (1 hr)"),
    ("06:45-07:15","Freshen up + Breakfast"),
    ("07:15-10:15","PRIMARY SUBJECT  Theory reading  (3 hrs)"),
    ("10:15-10:30","Short break + water"),
    ("10:30-01:00","PRIMARY SUBJECT  High-yield + Notes  (2.5 hrs)"),
    ("01:00-02:00","Lunch + Rest"),
    ("02:00-04:30","PAIRED SUBJECT  Theory reading  (2.5 hrs)"),
    ("04:30-04:45","Break + snack"),
    ("04:45-06:45","PAIRED SUBJECT  MCQs + Revision  (2 hrs)"),
    ("06:45-07:30","Dinner"),
    ("07:30-09:00","BOTH SUBJECTS  Revision + Flashcards  (1.5 hrs)"),
    ("09:00-09:30","Plan next day + list weak topics"),
    ("09:30-10:30","Wind down / read lightly"),
    ("10:30 PM","SLEEP  (7 hrs → wake 05:30 AM)"),
]
ROW_H = (GRID_H - 11*mm - 3*mm) / len(NORMAL)
ty = GRID_TOP - 12*mm
for tval, act in NORMAL:
    bg = colors.HexColor("#FFFFFF")
    if "PRIMARY" in act: bg = colors.HexColor("#FFF9C4")
    elif "PAIRED" in act: bg = colors.HexColor("#FFF9C4")
    elif "BOTH" in act: bg = colors.HexColor("#FFF9C4")
    elif "SLEEP" in tval: bg = colors.HexColor("#BBDEFB")
    elif "Exercise" in act: bg = colors.HexColor("#C8E6C9")
    c.setFillColor(bg)
    c.rect(SBL_X+1.5*mm, ty-ROW_H+0.5*mm, SIDEBAR_W-3*mm, ROW_H-0.7*mm, fill=1, stroke=0)
    c.setFillColor(NAVY); c.setFont("Helvetica-Bold", 6.2)
    c.drawString(SBL_X+2*mm, ty-ROW_H/2+1*mm, tval)
    c.setFillColor(BLK); c.setFont("Helvetica", 6.2)
    # wrap text
    max_w = SIDEBAR_W - 25*mm
    if c.stringWidth(act, "Helvetica", 6.2) > max_w:
        mid = act.rfind(' ', 0, int(len(act)*0.55))
        if mid < 5: mid = act.rfind(' ', 0, 30)
        c.drawString(SBL_X+24*mm, ty-ROW_H/2+2.5*mm, act[:mid] if mid>0 else act[:28])
        c.drawString(SBL_X+24*mm, ty-ROW_H/2-1.5*mm, act[mid+1:] if mid>0 else act[28:])
    else:
        c.drawString(SBL_X+24*mm, ty-ROW_H/2+1*mm, act)
    ty -= ROW_H

# Right sidebar - Posting Day
SBR_X = W - M - SIDEBAR_W
c.setFillColor(colors.HexColor("#FCE4EC"))
c.roundRect(SBR_X, GRID_BOT, SIDEBAR_W, GRID_H, 3*mm, fill=1, stroke=0)
c.setFillColor(colors.HexColor("#880E4F"))
c.rect(SBR_X, GRID_TOP-11*mm, SIDEBAR_W, 11*mm, fill=1, stroke=0)
c.setFillColor(WHITE)
c.setFont("Helvetica-Bold", 9)
c.drawCentredString(SBR_X+SIDEBAR_W/2, GRID_TOP-6*mm, "POSTING DAY SCHEDULE")
c.setFont("Helvetica", 7)
c.drawCentredString(SBR_X+SIDEBAR_W/2, GRID_TOP-10*mm, "Hospital 9 AM-1 PM  |  7.5 hrs study  |  7 hrs sleep")

POSTING = [
    ("05:30 AM","Wake up"),
    ("05:45-06:30","Light review: flashcards + mnemonics  (no heavy theory)"),
    ("06:30-07:15","Get ready + Breakfast"),
    ("07:15-08:50","Travel to hospital / review today's topics"),
    ("09:00-01:00","HOSPITAL POSTING  (observe + connect to study topics)"),
    ("01:00-02:00","Lunch + Rest  (20 min nap is productive)"),
    ("02:00-03:00","EXERCISE  Walk / gym / yoga  (1 hr - afternoon slot)"),
    ("03:00-03:15","Freshen up + snack"),
    ("03:15-06:15","PRIMARY SUBJECT  Theory reading  (3 hrs)"),
    ("06:15-06:30","Short break"),
    ("06:30-08:30","PAIRED SUBJECT  Theory + MCQs  (2 hrs)"),
    ("08:30-09:15","Dinner"),
    ("09:15-10:45","BOTH SUBJECTS  Revision + Flashcards  (1.5 hrs)"),
    ("10:45-11:15","Plan next day + weak topics list"),
    ("11:15 PM","SLEEP  (7 hrs → wake 06:15 AM)"),
]
ty = GRID_TOP - 12*mm
PINK_DARK = colors.HexColor("#880E4F")
for tval, act in POSTING:
    bg = colors.HexColor("#FFFFFF")
    if "PRIMARY" in act: bg = colors.HexColor("#FFF9C4")
    elif "PAIRED" in act: bg = colors.HexColor("#FFF9C4")
    elif "BOTH" in act: bg = colors.HexColor("#FFF9C4")
    elif "SLEEP" in tval: bg = colors.HexColor("#BBDEFB")
    elif "EXERCISE" in act: bg = colors.HexColor("#C8E6C9")
    elif "HOSPITAL" in act: bg = colors.HexColor("#F1F8E9")
    c.setFillColor(bg)
    c.rect(SBR_X+1.5*mm, ty-ROW_H+0.5*mm, SIDEBAR_W-3*mm, ROW_H-0.7*mm, fill=1, stroke=0)
    c.setFillColor(PINK_DARK); c.setFont("Helvetica-Bold", 6.2)
    c.drawString(SBR_X+2*mm, ty-ROW_H/2+1*mm, tval)
    c.setFillColor(BLK); c.setFont("Helvetica", 6.2)
    max_w = SIDEBAR_W - 25*mm
    if c.stringWidth(act, "Helvetica", 6.2) > max_w:
        mid = act.rfind(' ', 0, int(len(act)*0.55))
        if mid < 5: mid = act.rfind(' ', 0, 30)
        c.drawString(SBR_X+24*mm, ty-ROW_H/2+2.5*mm, act[:mid] if mid>0 else act[:28])
        c.drawString(SBR_X+24*mm, ty-ROW_H/2-1.5*mm, act[mid+1:] if mid>0 else act[28:])
    else:
        c.drawString(SBR_X+24*mm, ty-ROW_H/2+1*mm, act)
    ty -= ROW_H

# ── Main timetable grid (8 cols × 10 rows = 80 slots, last empty) ──────────
GX = SBL_X + SIDEBAR_W + 4*mm
GW = SBR_X - 4*mm - GX
COLS = 8
ROWS = 10
CW = GW / COLS
CH = GRID_H / ROWS

# Phase header band (thin colored top stripe per row) - we'll do it per-cell

for idx, entry in enumerate(DAYS):
    day_num, date_str, phase, subj, t1, t2, paired, pt = entry
    col = idx % COLS
    row = idx // COLS
    cx = GX + col*CW
    cy = GRID_TOP - (row+1)*CH

    bg = PBG.get(phase, GREY_LT)
    sc = scolor(subj)

    # Cell fill
    c.setFillColor(bg)
    c.rect(cx+0.4*mm, cy+0.4*mm, CW-0.8*mm, CH-0.8*mm, fill=1, stroke=0)

    # Left accent bar
    c.setFillColor(sc)
    c.rect(cx+0.4*mm, cy+0.4*mm, 2.8*mm, CH-0.8*mm, fill=1, stroke=0)

    # Day badge
    c.setFillColor(sc)
    c.rect(cx+3.4*mm, cy+CH-7*mm, 9*mm, 6.5*mm, fill=1, stroke=0)
    c.setFillColor(WHITE); c.setFont("Helvetica-Bold", 8.5)
    c.drawCentredString(cx+7.9*mm, cy+CH-4.5*mm, f"D{day_num}")

    # Date
    c.setFillColor(colors.HexColor("#424242")); c.setFont("Helvetica", 7.5)
    c.drawString(cx+13.5*mm, cy+CH-4.5*mm, date_str)

    # Subject label
    c.setFillColor(sc); c.setFont("Helvetica-Bold", 7.5)
    c.drawString(cx+3.8*mm, cy+CH-10.5*mm, subj[:20])

    # Paired subject (small)
    if paired:
        c.setFillColor(scolor(paired)); c.setFont("Helvetica-Bold", 6)
        c.drawString(cx+3.8*mm, cy+CH-14*mm, f"+ {paired[:18]}")

    # Topic lines
    c.setFillColor(BLK); c.setFont("Helvetica", 5.8)
    text_y = cy + CH - (17*mm if paired else 15*mm)
    text_x = cx + 3.8*mm
    max_tw = CW - 5.5*mm
    for line in ([t1, t2, f"  {pt}"] if paired and pt else [t1, t2]):
        if not line: continue
        words = line.split()
        cur = ""
        for w in words:
            test = (cur+" "+w).strip()
            if c.stringWidth(test, "Helvetica", 5.8) > max_tw:
                if text_y > cy+1.5*mm:
                    c.drawString(text_x, text_y, cur)
                    text_y -= 6.8
                cur = w
            else:
                cur = test
        if cur and text_y > cy+1.5*mm:
            c.drawString(text_x, text_y, cur)
            text_y -= 6.8
        text_y -= 1.5  # gap between logical lines

    # Cell border
    c.setStrokeColor(colors.HexColor("#90A4AE")); c.setLineWidth(0.4)
    c.rect(cx+0.4*mm, cy+0.4*mm, CW-0.8*mm, CH-0.8*mm, fill=0, stroke=1)

# ── Phase labels (top of each phase group) ─────────────────────────────────
phase_ranges = [
    ("P1", 0, 15, "PHASE 1: MEDICINE + RADIOLOGY"),
    ("P2", 16, 29, "PHASE 2: SURGERY + ORTHO + ANESTHESIA"),
    ("P3", 30, 45, "PHASE 3: OBGyn + PEDIATRICS"),
    ("P4", 46, 51, "PHASE 4: ENT + OPHTHALMOLOGY"),
    ("P5", 52, 57, "PHASE 5: DERMATOLOGY + PSYCHIATRY"),
    ("P6", 58, 78, "PHASE 6: FINAL REVISION"),
]
# Draw subtle phase bracket lines
for phase_code, start, end, label in phase_ranges:
    sc = list(PBG[phase_code].hexval())[1:]  # just for reference
    start_col = start % COLS
    start_row = start // COLS
    end_col   = end % COLS
    end_row   = end // COLS
    # draw a thin top border on first cell of each phase
    px = GX + start_col*CW
    py = GRID_TOP - start_row*CH
    c.setFillColor(PBG[phase_code])
    c.setStrokeColor(NAVY); c.setLineWidth(1.5)
    # just label at top-left of first cell
    # small phase tag
    fc = scolor(label.split()[2].rstrip('+').strip(': '))
    c.setFillColor(fc)
    c.setFont("Helvetica-Bold", 5.5)
    # print nothing extra - labels are in cells

# ── Footer ──────────────────────────────────────────────────────────────────
c.setFillColor(NAVY); c.setFont("Helvetica-Bold", 8)
c.drawCentredString(W/2, 4*mm,
    "MBBS FINAL YEAR TIMETABLE  |  July 15 – October 1, 2026  |  79 Days  |  "
    "Phase 1: Medicine+Radiology  ·  Phase 2: Surgery+Ortho+Anaes  ·  Phase 3: OBGyn+Peds  ·  "
    "Phase 4: ENT+Ophthal  ·  Phase 5: Dermat+Psych  ·  Phase 6: Final Revision")
c.setFont("Helvetica", 7)
c.setFillColor(colors.HexColor("#37474F"))
c.drawCentredString(W/2, 1.5*mm, "Print at A1 size (594 × 841 mm) for best readability  |  Designed for wall display")

c.save()
print(f"Poster saved: {OUT}")
This is a shared conversation. Sign in to Orris to start your own chat.