Please create a colorful pdf handbook of all these questions in English, translate to English all these list of questions.
cd "/tmp/workspace/attachments/8bfd6c04-34a1-4779-95f7-e18bcb845175/" && python3 -c " import pdfplumber with pdfplumber.open('20260527_122336 (4).pdf') as pdf: for i, page in enumerate(pdf.pages): print(f'=== PAGE {i+1} ===') text = page.extract_text() print(text) print() "
mkdir -p /tmp/workspace/medical-handbook && ls /tmp/workspace/medical-handbook/
~/medical-handbook/create_handbook.py
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import cm, mm
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, HRFlowable, Table, TableStyle, PageBreak
from reportlab.platypus import KeepTogether
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.pdfgen import canvas
from reportlab.platypus.frames import Frame
from reportlab.platypus.doctemplate import PageTemplate, BaseDocTemplate
import os
# Color palette
DARK_BLUE = colors.HexColor('#1A3A5C')
MED_BLUE = colors.HexColor('#2E6DA4')
LIGHT_BLUE = colors.HexColor('#D6E8F7')
TEAL = colors.HexColor('#1B7A78')
LIGHT_TEAL = colors.HexColor('#D0EFEE')
GREEN = colors.HexColor('#2E7D32')
LIGHT_GREEN = colors.HexColor('#C8E6C9')
ORANGE = colors.HexColor('#E65100')
LIGHT_ORANGE = colors.HexColor('#FFE0B2')
PURPLE = colors.HexColor('#4A148C')
LIGHT_PURPLE = colors.HexColor('#E1BEE7')
RED = colors.HexColor('#B71C1C')
LIGHT_RED = colors.HexColor('#FFCDD2')
GOLD = colors.HexColor('#F57F17')
LIGHT_GOLD = colors.HexColor('#FFF9C4')
GRAY = colors.HexColor('#546E7A')
LIGHT_GRAY = colors.HexColor('#ECEFF1')
WHITE = colors.white
# Section color mapping
SECTION_COLORS = {
'General': (DARK_BLUE, LIGHT_BLUE),
'Pulmonology': (TEAL, LIGHT_TEAL),
'Cardiology': (RED, LIGHT_RED),
'Rheumatology': (PURPLE, LIGHT_PURPLE),
'Gastroenterology': (GREEN, LIGHT_GREEN),
'Nephrology': (MED_BLUE, LIGHT_BLUE),
'Hematology & Endocrinology': (ORANGE, LIGHT_ORANGE),
'Surgery & Vascular': (TEAL, LIGHT_TEAL),
'Obstetrics & Gynecology': (colors.HexColor('#880E4F'), colors.HexColor('#FCE4EC')),
'Neurology': (PURPLE, LIGHT_PURPLE),
'Pediatrics': (GREEN, LIGHT_GREEN),
'Urology & Oncology': (ORANGE, LIGHT_ORANGE),
'ENT & Ophthalmology': (MED_BLUE, LIGHT_BLUE),
'Infectious Diseases': (RED, LIGHT_RED),
'Dermatology & STI': (colors.HexColor('#4E342E'), colors.HexColor('#EFEBE9')),
'Pulmonary TB': (GRAY, LIGHT_GRAY),
'Traumatology': (GOLD, LIGHT_GOLD),
'Clinical Pharmacology': (TEAL, LIGHT_TEAL),
'Emergency Medicine': (RED, LIGHT_RED),
'Palliative Care': (PURPLE, LIGHT_PURPLE),
}
# All 163 questions translated to English, organized by section
SECTIONS = [
{
'title': 'SECTION I: General Practice Fundamentals',
'color_key': 'General',
'questions': [
(1, "Ethics and deontology in the work of a general practitioner."),
(2, "Accounting and reporting documentation in the work of a general practitioner."),
(3, "Normative legal acts and other legislation of the Republic of Belarus regulating the activities of healthcare organizations and medical workers in the field of preserving, strengthening, and restoring the health of the population."),
]
},
{
'title': 'SECTION II: Pulmonology',
'color_key': 'Pulmonology',
'questions': [
(4, "Pneumonia: classification, clinical manifestations, diagnosis, severity criteria, treatment, clinical follow-up, tactics of the general practitioner."),
(5, "Bronchial asthma: classification, clinical manifestations, diagnosis, severity levels, treatment, clinical follow-up, tactics of the general practitioner."),
(6, "Chronic obstructive pulmonary disease (COPD): classification, clinical manifestations, diagnosis, severity levels, treatment, clinical follow-up, tactics of the general practitioner."),
]
},
{
'title': 'SECTION III: Cardiology',
'color_key': 'Cardiology',
'questions': [
(7, "Ischemic heart disease – angina pectoris: classification, clinical manifestations, diagnosis, treatment and prevention in the outpatient setting of a general practitioner, medical rehabilitation, clinical follow-up."),
(8, "Acute coronary syndrome: clinical manifestations, diagnosis, tactics of the general practitioner in providing pre-hospital medical care."),
(9, "Acute coronary syndrome without ST-segment elevation: clinical manifestations, diagnosis, patient management tactics, risk assessment, prognosis evaluation, clinical follow-up, tactics of the general practitioner."),
(10, "Acute coronary syndrome with ST-segment elevation: clinical manifestations, laboratory and instrumental diagnostics, atypical forms, tactics of the general practitioner in providing pre-hospital medical care, clinical follow-up."),
(11, "Medical rehabilitation of patients with myocardial infarction, secondary prevention in outpatient settings, clinical follow-up."),
(12, "Arterial hypertension: classification, clinical manifestations, diagnosis of target organ damage, risk stratification and prognosis of complications."),
(13, "Arterial hypertension: treatment, prevention in the outpatient setting of a general practitioner."),
(14, "Symptomatic hypertensions: clinical manifestations, diagnosis, tactics of the general practitioner."),
(15, "Myocarditis: clinical manifestations, diagnosis, treatment, tactics of the general practitioner."),
(16, "Diagnosis, treatment, and prevention of dyslipidemia."),
(17, "Sudden coronary death: risk factors, clinical manifestations, diagnosis, resuscitation measures, prevention."),
(18, "Arterial hypertension in pregnant women: features of treatment."),
(19, "Hypertensive crises: diagnostic criteria, management of complicated and uncomplicated hypertensive crises."),
(20, "Pulmonary artery thromboembolism: clinical manifestations, diagnosis, differential diagnosis, treatment, prognosis."),
(21, "Supraventricular paroxysmal tachycardia: clinical manifestations, ECG diagnosis, relief of paroxysms, indications for electrical pulse therapy, indications for surgical treatment, prevention of paroxysms."),
(22, "Atrial fibrillation and flutter: clinical manifestations, diagnosis, ECG diagnosis, patient management strategies, treatment, indications for electrical pulse therapy and defibrillator implantation, treatment of patients after restoration of sinus rhythm, prognosis."),
(23, "Atrial fibrillation: indications for anticoagulant therapy, stroke risk and bleeding risk assessment scales."),
(24, "Hypertrophic cardiomyopathy: pathogenesis, risk factors, classification, diagnosis, treatment, indications for surgical treatment."),
(25, "Dilated cardiomyopathy: pathogenesis, risk factors, classification, diagnosis, treatment, indications for heart transplantation."),
(26, "Pericarditis: etiology, classification, clinical manifestations, diagnosis of various pericarditis variants, treatment, indications for pericardial puncture, indications and types of surgical treatment."),
(27, "Acquired heart defects (mitral valve insufficiency, mitral stenosis): pathogenesis of hemodynamic disturbances, course, complications, therapeutic tactics, indications for surgical treatment, prognosis."),
(28, "Acquired heart defects (aortic valve insufficiency, aortic orifice stenosis): pathogenesis of hemodynamic disturbances, course, complications, therapeutic tactics, indications for surgical treatment, prognosis."),
(29, "Infective endocarditis: clinical manifestations, diagnosis, diagnostic criteria, antibacterial treatment tactics, indications for surgical treatment, prevention of relapses, prognosis."),
(30, "Coronary angiography: indications and contraindications, interpretation of results."),
(31, "Revascularization in patients with stable angina pectoris: patient management after revascularization."),
(32, "Invasive treatment strategy for patients with acute coronary syndrome: timing of reperfusion therapy, patient management after revascularization."),
(33, "Types of cardiac pacing, indications, nomenclature of implantable pacemakers, complications."),
(34, "Main groups of syncope, examination program, emergency medical care for syncope, prevention."),
(35, "Concept of cardiovascular disease risk factors, prevention strategies, assessment of overall cardiovascular risk from an evidence-based medicine perspective, preventive counseling."),
]
},
{
'title': 'SECTION IV: Rheumatology',
'color_key': 'Rheumatology',
'questions': [
(36, "Rheumatoid arthritis: classification, clinical manifestations, diagnosis, principles of treatment, clinical follow-up, tactics of the general practitioner."),
(37, "Osteoarthritis and gout: clinical manifestations, diagnosis, principles of treatment, clinical follow-up, tactics of the general practitioner."),
(38, "Systemic lupus erythematosus: classification, clinical manifestations, diagnosis, principles of treatment, clinical follow-up, tactics of the general practitioner."),
]
},
{
'title': 'SECTION V: Gastroenterology',
'color_key': 'Gastroenterology',
'questions': [
(39, "Gastric and duodenal ulcer: classification, clinical manifestations, diagnosis, complications, principles of treatment, clinical follow-up, tactics of the general practitioner."),
(40, "Nonspecific ulcerative colitis: classification, clinical manifestations, diagnosis, principles of treatment, clinical follow-up, tactics of the general practitioner."),
(41, "Chronic hepatitis: classification, clinical manifestations, diagnosis, principles of treatment, clinical follow-up, tactics of the general practitioner."),
(42, "Liver cirrhosis: classification, clinical manifestations, diagnosis, principles of treatment, clinical follow-up, tactics of the general practitioner."),
]
},
{
'title': 'SECTION VI: Nephrology',
'color_key': 'Nephrology',
'questions': [
(43, "Acute glomerulonephritis: classification, clinical manifestations, diagnosis, principles of treatment, clinical follow-up, tactics of the general practitioner."),
(44, "Acute and chronic pyelonephritis: classification, clinical manifestations, diagnosis, principles of treatment, clinical follow-up, tactics of the general practitioner."),
(45, "Chronic kidney disease: classification, clinical manifestations, diagnosis, principles of treatment, clinical follow-up, tactics of the general practitioner."),
]
},
{
'title': 'SECTION VII: Hematology & Endocrinology',
'color_key': 'Hematology & Endocrinology',
'questions': [
(46, "Anemias: classification, clinical manifestations, diagnosis, principles of treatment, clinical follow-up, tactics of the general practitioner."),
(47, "Diabetes mellitus: classification, clinical manifestations, diagnosis, principles of treatment, clinical follow-up, tactics of the general practitioner."),
(48, "Thyroid gland diseases: classification, clinical manifestations, diagnosis, principles of treatment, clinical follow-up, tactics of the general practitioner."),
]
},
{
'title': 'SECTION VIII: Surgery & Vascular Medicine',
'color_key': 'Surgery & Vascular',
'questions': [
(49, "Strangulated hernia: clinical manifestations, diagnosis, tactics of the general practitioner."),
(50, "Acute appendicitis: clinical manifestations, diagnosis, tactics of the general practitioner."),
(51, "Acute cholecystitis: clinical manifestations, diagnosis, tactics of the general practitioner."),
(52, "Acute pancreatitis: clinical manifestations, diagnosis, tactics of the general practitioner."),
(53, "Acute abdominal diseases: clinical manifestations, differential diagnosis, tactics of the general practitioner."),
(54, "Abdominal trauma: clinical manifestations, diagnosis, emergency medical care and tactics of the general practitioner."),
(55, "Chest injuries: clinical manifestations, diagnosis, emergency medical care and tactics of the general practitioner."),
(56, "Thrombophlebitis of superficial and deep veins of the lower extremities: clinical manifestations, diagnosis, tactics of the general practitioner."),
(57, "Obliterating atherosclerosis and endarteritis of the lower extremity vessels: clinical manifestations, diagnosis, tactics of the general practitioner."),
(58, "Inflammatory diseases of the skin and subcutaneous tissue (furuncle, carbuncle, hidradenitis, abscess, phlegmon): clinical manifestations, diagnosis, tactics of the general practitioner."),
(59, "Purulent diseases of the hand (panaritium, phlegmon): clinical manifestations, diagnosis, tactics of the general practitioner."),
(60, "Acute proctitis and paraproctitis, hemorrhoids, anal fissures: clinical manifestations, diagnosis, tactics of the general practitioner."),
]
},
{
'title': 'SECTION IX: Obstetrics & Gynecology',
'color_key': 'Obstetrics & Gynecology',
'questions': [
(61, "Family planning, prevention of unplanned pregnancy, role of the general practitioner in family planning."),
(62, "Climacterium, premenopause, menopause, postmenopause: prevention of pathology of the climacteric period and osteoporosis."),
(63, "Modern methods of pregnancy diagnosis."),
(64, "Physiology of pregnancy."),
(65, "Pathology of the first half of pregnancy: clinical manifestations, treatment, prevention."),
(66, "Preeclampsia and eclampsia: clinical manifestations, diagnosis, treatment, emergency medical care, tactics of the general practitioner."),
(67, "Non-specific inflammatory diseases of the genitals: clinical manifestations, diagnosis, tactics of the general practitioner."),
(68, "Specific inflammatory diseases of the genitals (trichomoniasis, chlamydiosis, gonorrhea, tuberculosis of the urogenital organs): clinical manifestations, diagnosis, tactics of the general practitioner."),
(69, "Lactational mastitis: classification, clinical manifestations, diagnosis, therapeutic tactics, prevention, indications for cessation of lactation."),
(70, "\"Acute abdomen\" syndrome in gynecology: diagnostic and therapeutic tactics of the general practitioner."),
(71, "Ectopic pregnancy: clinical manifestations, diagnosis, tactics of the general practitioner."),
]
},
{
'title': 'SECTION X: Neurology',
'color_key': 'Neurology',
'questions': [
(72, "Neuropathies and neuritis: etiology, pathogenesis, clinical manifestations, syndromic diagnosis at the outpatient-polyclinic stage, treatment, clinical follow-up, tactics of the general practitioner."),
(73, "Vertebrogenic lesions of the nervous system: syndromic diagnosis, treatment, features of patient management in outpatient-polyclinic conditions, indications for hospitalization, medical rehabilitation, tactics of the general practitioner."),
(74, "Brain concussion and contusion, intracranial hypertension syndrome: clinical manifestations, diagnosis, tactics of the general practitioner."),
(75, "Acute cerebrovascular accident (stroke): pathogenesis, clinical manifestations, diagnosis, tactics of the general practitioner, medical rehabilitation of patients who suffered a stroke."),
(76, "Chronic cerebrovascular insufficiency (dyscirculatory encephalopathy, vertebrobasilar insufficiency, vascular epilepsy, atherosclerotic Parkinsonism): clinical manifestations, diagnosis, symptomatic treatment, assessment of temporary disability, tactics of the general practitioner."),
(77, "Diseases of the autonomic nervous system: clinical manifestations, treatment, tactics of the general practitioner."),
(78, "Parkinsonism: clinical manifestations, differential diagnosis, tactics of the general practitioner."),
(79, "Epilepsy: clinical forms of seizures and epilepsy, diagnosis in outpatient conditions, treatment, occupational adaptation, tactics of the general practitioner."),
(80, "Subarachnoid hemorrhage: clinical manifestations, diagnosis, tactics of the general practitioner."),
]
},
{
'title': 'SECTION XI: Pediatrics',
'color_key': 'Pediatrics',
'questions': [
(81, "Physiology and pathology of newborns."),
(82, "Prevention and diagnosis of early health and developmental deviations in children, methods of health improvement in children."),
(83, "Health groups and risk groups in children."),
(84, "Diseases of the respiratory organs in children: features of clinical manifestations, diagnosis, and treatment; tactics of the general practitioner."),
(85, "Acute respiratory viral infection and pneumonia in young children: tactics of the general practitioner."),
(86, "Diseases of the circulatory organs in children: features of clinical manifestations, diagnosis, and treatment; tactics of the general practitioner."),
(87, "Acute rheumatic fever in children: clinical manifestations, diagnosis, principles of treatment, tactics of the general practitioner."),
(88, "Diseases of the esophagus, stomach, and duodenum in children: clinical manifestations, diagnosis, treatment in outpatient conditions."),
(89, "Diseases of the liver and biliary tract in children: clinical manifestations, diagnosis, tactics of the general practitioner."),
(90, "Kidney diseases in children: features of clinical manifestations, diagnosis, and treatment; tactics of the general practitioner."),
(91, "Allergic diseases in children: clinical manifestations, diagnosis, tactics of the general practitioner."),
]
},
{
'title': 'SECTION XII: Urology & Oncology',
'color_key': 'Urology & Oncology',
'questions': [
(92, "Acute inflammatory diseases of the kidneys, urinary bladder, urethra, and genitals: clinical picture, diagnosis, tactics of the general practitioner."),
(93, "Lung cancer: clinical manifestations, diagnosis, tactics of the general practitioner."),
(94, "Gastric cancer: clinical manifestations, diagnosis, tactics of the general practitioner."),
(95, "Breast cancer: clinical manifestations, diagnosis, tactics of the general practitioner."),
(96, "Skin neoplasms: clinical manifestations, diagnosis, tactics of the general practitioner."),
]
},
{
'title': 'SECTION XIII: ENT & Ophthalmology',
'color_key': 'ENT & Ophthalmology',
'questions': [
(97, "Inflammatory diseases of the outer and middle ear: clinical manifestations, diagnosis, treatment, tactics of the general practitioner."),
(98, "Diseases of the nose and paranasal sinuses: clinical manifestations, diagnosis, treatment in outpatient conditions."),
(99, "Acute and chronic laryngitis: clinical manifestations, diagnosis, tactics of the general practitioner."),
(100, "Foreign bodies of the ear and upper respiratory tract: clinical manifestations, diagnosis, emergency medical care, tactics of the general practitioner."),
(101, "Tonsillitis and chronic tonsillitis: clinical manifestations, diagnosis, treatment in outpatient conditions, tactics of the general practitioner."),
(102, "Inflammatory diseases of the conjunctiva and cornea: clinical manifestations, tactics of the general practitioner."),
(102, "Inflammatory diseases of the eyelids and lacrimal ducts: clinical manifestations, diagnosis, and treatment in outpatient conditions."),
(103, "Glaucoma: clinical manifestations, diagnosis, tactics of the general practitioner."),
(104, "Eye trauma: tactics of the general practitioner."),
]
},
{
'title': 'SECTION XIV: Infectious Diseases',
'color_key': 'Infectious Diseases',
'questions': [
(105, "Foodborne infections: clinical manifestations, diagnostic and therapeutic tactics, prevention."),
(106, "Salmonellosis and dysentery: clinical manifestations, diagnostic and therapeutic tactics, prevention, indications for hospitalization, clinical follow-up of convalescents, tactics of the general practitioner."),
(107, "Acute viral hepatitis: clinical manifestations, modern approaches to diagnosis, treatment, clinical follow-up, tactics of the general practitioner."),
(108, "Diphtheria in children and adults: clinical manifestations, diagnosis, treatment."),
(109, "Acute infectious diseases of the brain and its membranes: clinical manifestations, diagnosis, tactics of the general practitioner."),
(110, "Herpetic infection: modern approaches to diagnosis and treatment, tactics of the general practitioner."),
(111, "HIV infection, AIDS: clinical manifestations, diagnostic and therapeutic tactics, prevention, tactics of the general practitioner."),
(112, "Diagnosis and treatment of influenza and other acute respiratory viral infections (ARVI)."),
]
},
{
'title': 'SECTION XV: Dermatology & Sexually Transmitted Infections',
'color_key': 'Dermatology & STI',
'questions': [
(113, "Clinical manifestations, diagnosis, and treatment of the most common non-infectious skin diseases (dermatitis, toxicoderma, eczema, neurodermatitis) in outpatient conditions."),
(114, "Fungal diseases of the skin and nails: clinical manifestations, diagnosis, tactics of the general practitioner."),
(115, "Psoriasis: clinical manifestations, diagnosis, tactics of the general practitioner."),
(116, "Syphilis: clinical manifestations, diagnosis, tactics of the general practitioner."),
(117, "Gonorrhea and trichomoniasis: clinical manifestations, differential diagnosis, treatment, tactics of the general practitioner."),
]
},
{
'title': 'SECTION XVI: Pulmonary Tuberculosis',
'color_key': 'Pulmonary TB',
'questions': [
(118, "Clinical and laboratory diagnostic methods for suspected pulmonary tuberculosis, methods of pathological material collection."),
(119, "Mandatory diagnostic minimum for examining a patient suspected of tuberculosis by a general practitioner when referring to a tuberculosis dispensary."),
(120, "Formation of risk groups ('threatened contingent') for tuberculosis disease, work of the general practitioner with risk groups."),
(121, "Sarcoidosis: clinical manifestations, diagnosis and treatment of respiratory sarcoidosis, dispensary observation, tactics of the general practitioner."),
]
},
{
'title': 'SECTION XVII: Traumatology',
'color_key': 'Traumatology',
'questions': [
(122, "Bone cracks, fractures, dislocations, bruises, sprains: clinical manifestations, diagnosis, tactics of the general practitioner."),
(123, "Burns and frostbite: clinical manifestations, diagnosis, tactics of the general practitioner."),
]
},
{
'title': 'SECTION XVIII: Clinical Pharmacology',
'color_key': 'Clinical Pharmacology',
'questions': [
(124, "Clinical pharmacology of antibacterial drugs."),
(125, "Clinical pharmacology of antianginal drugs."),
(126, "Clinical pharmacology of antiarrhythmic drugs."),
(127, "Clinical pharmacology of hypolipidemic drugs."),
(128, "Clinical pharmacology of antihypertensive drugs."),
(129, "Clinical pharmacology of diuretics."),
(130, "Clinical pharmacology of thrombolytics and antiaggregants."),
(131, "Clinical pharmacology of bronchodilators."),
(132, "Clinical pharmacology of anti-inflammatory drugs."),
(133, "Clinical pharmacology of glucocorticoids."),
(134, "Clinical pharmacology of oral hypoglycemic drugs."),
(135, "Clinical pharmacology of antisecretory drugs."),
(136, "Clinical pharmacology of antihistamine drugs."),
(137, "Clinical pharmacology of iron-containing drugs."),
]
},
{
'title': 'SECTION XIX: Emergency Medicine',
'color_key': 'Emergency Medicine',
'questions': [
(138, "Shock (anaphylactic, exotoxic, traumatic, hemorrhagic, cardiogenic, etc.): clinical manifestations, diagnosis, provision of medical care at the pre-hospital stage."),
(139, "Fainting and collapse: clinical manifestations, diagnosis, provision of medical care at the pre-hospital stage."),
(140, "Differential diagnosis of comatose states at the pre-hospital stage, provision of medical care at the pre-hospital stage."),
(141, "Laryngeal edema, false croup: clinical manifestations, diagnosis, provision of medical care at the pre-hospital stage."),
(142, "Quincke's edema (angioedema): clinical manifestations, diagnosis, provision of medical care at the pre-hospital stage."),
(143, "Bronchial asthma attack: diagnosis, differential diagnosis, provision of medical care at the pre-hospital stage."),
(144, "Open, closed, and tension pneumothorax: clinical manifestations, diagnosis, provision of medical care at the pre-hospital stage."),
(145, "Pulmonary artery thromboembolism: clinical manifestations, diagnosis, provision of medical care at the pre-hospital stage."),
(146, "Acute heart failure: clinical picture, diagnosis, provision of medical care at the pre-hospital stage."),
(147, "Hypertensive crisis: clinical manifestations, diagnosis, provision of medical care at the pre-hospital stage."),
(148, "Relief of pain syndrome in acute coronary syndrome, provision of medical care at the pre-hospital stage."),
(149, "Sudden coronary death: provision of medical care at the pre-hospital stage."),
(150, "Resuscitation in ventricular fibrillation: provision of medical care at the pre-hospital stage."),
(151, "Gastrointestinal and pulmonary bleeding: clinical manifestations, diagnosis, provision of medical care at the pre-hospital stage."),
(152, "Renal colic, acute urinary retention: clinical manifestations, diagnosis, provision of medical care at the pre-hospital stage."),
(153, "Acute renal failure: clinical manifestations, diagnosis, provision of medical care at the pre-hospital stage."),
(154, "Convulsive states, epileptic status: clinical manifestations, diagnosis, provision of medical care at the pre-hospital stage."),
(155, "Alcoholic delirium, withdrawal syndrome: clinical manifestations, diagnosis, provision of medical care at the pre-hospital stage."),
(156, "Acute glaucoma attack: clinical manifestations, diagnosis, provision of medical care at the pre-hospital stage."),
(157, "Chemical and thermal burns, frostbite: clinical manifestations, diagnosis, provision of medical care at the pre-hospital stage."),
(158, "Poisoning: clinical manifestations, diagnosis, provision of medical care at the pre-hospital stage."),
(159, "Eclampsia: clinical manifestations, diagnosis, provision of medical care at the pre-hospital stage."),
(160, "Acute cerebrovascular accident (stroke): clinical manifestations, diagnosis, provision of medical care at the pre-hospital stage."),
(161, "Subarachnoid hemorrhage: clinical manifestations, diagnosis, provision of medical care at the pre-hospital stage."),
]
},
{
'title': 'SECTION XX: Palliative Care',
'color_key': 'Palliative Care',
'questions': [
(162, "Organization of palliative medical care in the Republic of Belarus."),
(163, "Pharmacotherapy of chronic pain syndrome in the provision of palliative medical care in inpatient, outpatient conditions, and at home."),
]
},
]
class HandbookDocTemplate(BaseDocTemplate):
def __init__(self, filename, **kwargs):
BaseDocTemplate.__init__(self, filename, **kwargs)
frame = Frame(
self.leftMargin, self.bottomMargin,
self.width, self.height,
id='normal'
)
template = PageTemplate(id='main', frames=frame, onPage=self.add_page_decorations)
self.addPageTemplates([template])
def add_page_decorations(self, canvas, doc):
canvas.saveState()
w, h = A4
# Header bar
canvas.setFillColor(DARK_BLUE)
canvas.rect(0, h - 1.2*cm, w, 1.2*cm, fill=1, stroke=0)
# Header text
canvas.setFillColor(WHITE)
canvas.setFont('Helvetica-Bold', 9)
canvas.drawString(1*cm, h - 0.8*cm, "QUALIFICATION EXAMINATION HANDBOOK")
canvas.drawRightString(w - 1*cm, h - 0.8*cm, "General Practice Medicine")
# Footer
canvas.setFillColor(DARK_BLUE)
canvas.rect(0, 0, w, 0.9*cm, fill=1, stroke=0)
canvas.setFillColor(WHITE)
canvas.setFont('Helvetica', 8)
canvas.drawCentredString(w/2, 0.3*cm, f"Page {doc.page}")
canvas.drawString(1*cm, 0.3*cm, "Republic of Belarus")
canvas.drawRightString(w - 1*cm, 0.3*cm, "General Practitioner Exam Questions")
# Left accent bar
canvas.setFillColor(MED_BLUE)
canvas.rect(0, 0.9*cm, 0.3*cm, h - 2.1*cm, fill=1, stroke=0)
canvas.restoreState()
def build_pdf():
output_path = '/tmp/workspace/medical-handbook/GP_Qualification_Exam_Handbook.pdf'
doc = HandbookDocTemplate(
output_path,
pagesize=A4,
leftMargin=1.5*cm,
rightMargin=1.5*cm,
topMargin=1.8*cm,
bottomMargin=1.5*cm,
)
styles = getSampleStyleSheet()
# Custom styles
title_style = ParagraphStyle(
'HandbookTitle',
parent=styles['Normal'],
fontName='Helvetica-Bold',
fontSize=22,
textColor=WHITE,
alignment=TA_CENTER,
spaceAfter=6,
spaceBefore=6,
)
subtitle_style = ParagraphStyle(
'HandbookSubtitle',
parent=styles['Normal'],
fontName='Helvetica',
fontSize=12,
textColor=LIGHT_BLUE,
alignment=TA_CENTER,
spaceAfter=4,
)
section_style = ParagraphStyle(
'SectionHeader',
parent=styles['Normal'],
fontName='Helvetica-Bold',
fontSize=11,
textColor=WHITE,
alignment=TA_LEFT,
spaceBefore=10,
spaceAfter=4,
leftIndent=6,
)
q_num_style = ParagraphStyle(
'QuestionNumber',
parent=styles['Normal'],
fontName='Helvetica-Bold',
fontSize=10,
textColor=WHITE,
alignment=TA_CENTER,
)
q_text_style = ParagraphStyle(
'QuestionText',
parent=styles['Normal'],
fontName='Helvetica',
fontSize=9.5,
textColor=colors.HexColor('#1A1A1A'),
alignment=TA_JUSTIFY,
leading=14,
)
toc_style = ParagraphStyle(
'TOCEntry',
parent=styles['Normal'],
fontName='Helvetica',
fontSize=10,
textColor=DARK_BLUE,
leading=16,
)
story = []
# ---- COVER PAGE ----
story.append(Spacer(1, 3*cm))
# Title box
cover_data = [[Paragraph("QUALIFICATION EXAMINATION", title_style)],
[Paragraph("HANDBOOK", title_style)],
[Spacer(1, 0.3*cm)],
[Paragraph("General Practice Medicine", subtitle_style)],
[Paragraph("Republic of Belarus", subtitle_style)],
[Spacer(1, 0.5*cm)],
[Paragraph("163 Examination Questions — English Translation", ParagraphStyle(
'sub2', parent=styles['Normal'], fontName='Helvetica-Oblique',
fontSize=11, textColor=LIGHT_GOLD, alignment=TA_CENTER))],
]
cover_table = Table(cover_data, colWidths=[16*cm])
cover_table.setStyle(TableStyle([
('BACKGROUND', (0,0), (-1,-1), DARK_BLUE),
('ROUNDEDCORNERS', [12]),
('TOPPADDING', (0,0), (-1,-1), 10),
('BOTTOMPADDING', (0,0), (-1,-1), 10),
('LEFTPADDING', (0,0), (-1,-1), 20),
('RIGHTPADDING', (0,0), (-1,-1), 20),
]))
story.append(cover_table)
story.append(Spacer(1, 1.5*cm))
# Info box
info_data = [
[Paragraph("<b>Document Type:</b>", ParagraphStyle('i', parent=styles['Normal'], fontSize=10)),
Paragraph("Qualification Exam Preparation Handbook", ParagraphStyle('i', parent=styles['Normal'], fontSize=10))],
[Paragraph("<b>Specialty:</b>", ParagraphStyle('i', parent=styles['Normal'], fontSize=10)),
Paragraph("General Practice / Family Medicine", ParagraphStyle('i', parent=styles['Normal'], fontSize=10))],
[Paragraph("<b>Total Questions:</b>", ParagraphStyle('i', parent=styles['Normal'], fontSize=10)),
Paragraph("163", ParagraphStyle('i', parent=styles['Normal'], fontSize=10))],
[Paragraph("<b>Sections:</b>", ParagraphStyle('i', parent=styles['Normal'], fontSize=10)),
Paragraph("20 Clinical Sections", ParagraphStyle('i', parent=styles['Normal'], fontSize=10))],
[Paragraph("<b>Language:</b>", ParagraphStyle('i', parent=styles['Normal'], fontSize=10)),
Paragraph("English (Translated from Russian)", ParagraphStyle('i', parent=styles['Normal'], fontSize=10))],
]
info_table = Table(info_data, colWidths=[5*cm, 11*cm])
info_table.setStyle(TableStyle([
('BACKGROUND', (0,0), (-1,-1), LIGHT_BLUE),
('BACKGROUND', (0,0), (0,-1), MED_BLUE),
('TEXTCOLOR', (0,0), (0,-1), WHITE),
('FONTNAME', (0,0), (0,-1), 'Helvetica-Bold'),
('GRID', (0,0), (-1,-1), 0.5, colors.white),
('TOPPADDING', (0,0), (-1,-1), 8),
('BOTTOMPADDING', (0,0), (-1,-1), 8),
('LEFTPADDING', (0,0), (-1,-1), 10),
('RIGHTPADDING', (0,0), (-1,-1), 10),
]))
story.append(info_table)
story.append(PageBreak())
# ---- TABLE OF CONTENTS ----
toc_title_style = ParagraphStyle(
'TOCTitle', parent=styles['Normal'],
fontName='Helvetica-Bold', fontSize=16,
textColor=DARK_BLUE, alignment=TA_CENTER,
spaceAfter=16,
)
story.append(Paragraph("TABLE OF CONTENTS", toc_title_style))
story.append(HRFlowable(width='100%', thickness=2, color=DARK_BLUE, spaceAfter=12))
for i, section in enumerate(SECTIONS):
color, _ = SECTION_COLORS[section['color_key']]
q_range = f"Q{section['questions'][0][0]}–Q{section['questions'][-1][0]}"
toc_row_data = [[
Paragraph(f"<b>{i+1:02d}.</b> {section['title'].replace('SECTION ' + 'I'*(i+1) + ': ', '').replace('SECTION X: ', '').replace('SECTION XI: ','').replace('SECTION XII: ','').replace('SECTION XIII: ','').replace('SECTION XIV: ','').replace('SECTION XV: ','').replace('SECTION XVI: ','').replace('SECTION XVII: ','').replace('SECTION XVIII: ','').replace('SECTION XIX: ','').replace('SECTION XX: ', '')}",
ParagraphStyle('toc_e', parent=styles['Normal'], fontSize=10, textColor=DARK_BLUE, leading=14)),
Paragraph(q_range, ParagraphStyle('toc_r', parent=styles['Normal'], fontSize=9, textColor=color, alignment=TA_CENTER, fontName='Helvetica-Bold')),
]]
toc_row = Table(toc_row_data, colWidths=[13.5*cm, 2.5*cm])
bg = LIGHT_BLUE if i % 2 == 0 else colors.white
toc_row.setStyle(TableStyle([
('BACKGROUND', (0,0), (-1,-1), bg),
('TOPPADDING', (0,0), (-1,-1), 5),
('BOTTOMPADDING', (0,0), (-1,-1), 5),
('LEFTPADDING', (0,0), (0,-1), 8),
('RIGHTPADDING', (0,0), (-1,-1), 8),
('LINEBELOW', (0,0), (-1,-1), 0.3, colors.HexColor('#BBDEFB')),
]))
story.append(toc_row)
story.append(PageBreak())
# ---- SECTIONS ----
for section in SECTIONS:
color, light_color = SECTION_COLORS[section['color_key']]
# Section header
sec_header_data = [[Paragraph(section['title'], section_style)]]
sec_count = Paragraph(
f"<font color='white'>{len(section['questions'])} Questions</font>",
ParagraphStyle('cnt', parent=styles['Normal'], fontName='Helvetica', fontSize=9,
textColor=WHITE, alignment=TA_CENTER)
)
sec_header_table = Table(
[[Paragraph(section['title'], section_style), sec_count]],
colWidths=[13*cm, 3*cm]
)
sec_header_table.setStyle(TableStyle([
('BACKGROUND', (0,0), (-1,-1), color),
('TOPPADDING', (0,0), (-1,-1), 8),
('BOTTOMPADDING', (0,0), (-1,-1), 8),
('LEFTPADDING', (0,0), (0,-1), 10),
('RIGHTPADDING', (0,0), (-1,-1), 8),
('VALIGN', (0,0), (-1,-1), 'MIDDLE'),
]))
story.append(KeepTogether([sec_header_table, Spacer(1, 4)]))
# Questions
for q_num, q_text in section['questions']:
q_data = [[
Paragraph(f"<b>{q_num}</b>", q_num_style),
Paragraph(q_text, q_text_style),
]]
q_table = Table(q_data, colWidths=[1*cm, 15*cm])
q_table.setStyle(TableStyle([
('BACKGROUND', (0,0), (0,-1), color),
('BACKGROUND', (1,0), (1,-1), light_color),
('TOPPADDING', (0,0), (-1,-1), 6),
('BOTTOMPADDING', (0,0), (-1,-1), 6),
('LEFTPADDING', (0,0), (0,-1), 3),
('RIGHTPADDING', (0,0), (-1,-1), 8),
('LEFTPADDING', (1,0), (1,-1), 8),
('VALIGN', (0,0), (-1,-1), 'MIDDLE'),
('LINEBELOW', (0,0), (-1,-1), 0.5, WHITE),
]))
story.append(q_table)
story.append(Spacer(1, 2))
story.append(Spacer(1, 10))
doc.build(story)
print(f"PDF created: {output_path}")
return output_path
if __name__ == '__main__':
build_pdf()
cd /tmp/workspace/medical-handbook && python3 create_handbook.py 2>&1
ls -lh /tmp/workspace/medical-handbook/GP_Qualification_Exam_Handbook.pdf && python3 -c " from pypdf import PdfReader r = PdfReader('/tmp/workspace/medical-handbook/GP_Qualification_Exam_Handbook.pdf') print(f'Pages: {len(r.pages)}') "
GP Qualification Exam Handbook
PDF Document · PDF
| # | Section | Questions |
|---|---|---|
| I | General Practice Fundamentals | Q1–3 |
| II | Pulmonology | Q4–6 |
| III | Cardiology (largest section) | Q7–35 |
| IV | Rheumatology | Q36–38 |
| V | Gastroenterology | Q39–42 |
| VI | Nephrology | Q43–45 |
| VII | Hematology & Endocrinology | Q46–48 |
| VIII | Surgery & Vascular Medicine | Q49–60 |
| IX | Obstetrics & Gynecology | Q61–71 |
| X | Neurology | Q72–80 |
| XI | Pediatrics | Q81–91 |
| XII | Urology & Oncology | Q92–96 |
| XIII | ENT & Ophthalmology | Q97–104 |
| XIV | Infectious Diseases | Q105–112 |
| XV | Dermatology & STI | Q113–117 |
| XVI | Pulmonary Tuberculosis | Q118–121 |
| XVII | Traumatology | Q122–123 |
| XVIII | Clinical Pharmacology | Q124–137 |
| XIX | Emergency Medicine | Q138–161 |
| XX | Palliative Care | Q162–163 |
Now please create a similar colorful handbook pdf for all answers of above mentioned Opthalmology clinical cases ,try to provide all the Opthalmology clinical cases answers in short for intern in postings to Opthalmology department.
~/medical-handbook/create_ophthalmology_handbook.py
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import cm, mm
from reportlab.platypus import (SimpleDocTemplate, Paragraph, Spacer, HRFlowable,
Table, TableStyle, PageBreak, KeepTogether)
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.platypus.frames import Frame
from reportlab.platypus.doctemplate import PageTemplate, BaseDocTemplate
# ── Colour palette ──────────────────────────────────────────────────────────
DARK_TEAL = colors.HexColor('#004D4D')
MED_TEAL = colors.HexColor('#00796B')
LIGHT_TEAL = colors.HexColor('#E0F2F1')
ROYAL_BLUE = colors.HexColor('#1565C0')
SKY_BLUE = colors.HexColor('#E3F2FD')
DEEP_PURPLE = colors.HexColor('#4A148C')
LAVENDER = colors.HexColor('#EDE7F6')
CRIMSON = colors.HexColor('#B71C1C')
LIGHT_RED = colors.HexColor('#FFEBEE')
AMBER = colors.HexColor('#E65100')
LIGHT_AMBER = colors.HexColor('#FFF8E1')
FOREST = colors.HexColor('#1B5E20')
LIGHT_GREEN = colors.HexColor('#E8F5E9')
INDIGO = colors.HexColor('#283593')
LIGHT_INDIGO= colors.HexColor('#E8EAF6')
MAGENTA = colors.HexColor('#880E4F')
LIGHT_PINK = colors.HexColor('#FCE4EC')
SLATE = colors.HexColor('#37474F')
LIGHT_SLATE = colors.HexColor('#ECEFF1')
WHITE = colors.white
GOLD = colors.HexColor('#F9A825')
# ── Ophthalmology section color assignments ──────────────────────────────────
Q_COLORS = {
97: (MED_TEAL, LIGHT_TEAL), # Ear/eye inflammatory
98: (ROYAL_BLUE, SKY_BLUE), # Nose/sinuses (not ophtho, skipped)
99: (FOREST, LIGHT_GREEN), # Laryngitis (skipped)
100: (SLATE, LIGHT_SLATE), # Foreign bodies
101: (INDIGO, LIGHT_INDIGO), # Tonsillitis (skipped)
102: (MED_TEAL, LIGHT_TEAL), # Conjunctiva/cornea
'102b': (DEEP_PURPLE, LAVENDER), # Eyelids/lacrimal
103: (CRIMSON, LIGHT_RED), # Glaucoma
104: (AMBER, LIGHT_AMBER), # Eye trauma
}
# ── Page template with header/footer ────────────────────────────────────────
class OphthDocTemplate(BaseDocTemplate):
def __init__(self, filename, **kwargs):
BaseDocTemplate.__init__(self, filename, **kwargs)
frame = Frame(self.leftMargin, self.bottomMargin,
self.width, self.height, id='normal')
template = PageTemplate(id='main', frames=frame,
onPage=self._page_deco)
self.addPageTemplates([template])
def _page_deco(self, canvas, doc):
canvas.saveState()
w, h = A4
# Top bar
canvas.setFillColor(DARK_TEAL)
canvas.rect(0, h - 1.3*cm, w, 1.3*cm, fill=1, stroke=0)
canvas.setFillColor(WHITE)
canvas.setFont('Helvetica-Bold', 9)
canvas.drawString(1.2*cm, h - 0.85*cm, 'OPHTHALMOLOGY INTERN HANDBOOK')
canvas.drawRightString(w - 1.2*cm, h - 0.85*cm,
"General Practice — Ophtho Posting")
# Gold accent line under header
canvas.setFillColor(GOLD)
canvas.rect(0, h - 1.35*cm, w, 0.05*cm, fill=1, stroke=0)
# Bottom bar
canvas.setFillColor(DARK_TEAL)
canvas.rect(0, 0, w, 0.9*cm, fill=1, stroke=0)
canvas.setFillColor(WHITE)
canvas.setFont('Helvetica', 8)
canvas.drawCentredString(w/2, 0.3*cm, f'Page {doc.page}')
canvas.drawString(1.2*cm, 0.3*cm, 'Kanski\'s Clinical Ophthalmology — Quick Reference')
canvas.drawRightString(w - 1.2*cm, 0.3*cm, 'Exam-Ready Answers')
# Left accent bar
canvas.setFillColor(MED_TEAL)
canvas.rect(0, 0.9*cm, 0.35*cm, h - 2.25*cm, fill=1, stroke=0)
canvas.restoreState()
def tag(text, bold=False, color=None, size=None):
"""Return XML-tagged paragraph fragment."""
if bold:
text = f'<b>{text}</b>'
if color:
text = f'<font color="{color}">{text}</font>'
if size:
text = f'<font size="{size}">{text}</font>'
return text
def build_pdf():
out = '/tmp/workspace/medical-handbook/Ophthalmology_Intern_Handbook.pdf'
doc = OphthDocTemplate(
out,
pagesize=A4,
leftMargin=1.6*cm, rightMargin=1.4*cm,
topMargin=1.9*cm, bottomMargin=1.4*cm,
)
styles = getSampleStyleSheet()
# ── Shared styles ────────────────────────────────────────────────────────
def ps(name, **kw):
return ParagraphStyle(name, parent=styles['Normal'], **kw)
title_s = ps('T', fontName='Helvetica-Bold', fontSize=24,
textColor=WHITE, alignment=TA_CENTER, spaceAfter=4)
sub_s = ps('S', fontName='Helvetica-Oblique', fontSize=11,
textColor=colors.HexColor('#B2EBF2'), alignment=TA_CENTER)
sec_hdr_s = ps('SH', fontName='Helvetica-Bold', fontSize=11.5,
textColor=WHITE, leading=15)
q_num_s = ps('QN', fontName='Helvetica-Bold', fontSize=11,
textColor=WHITE, alignment=TA_CENTER)
body_s = ps('B', fontName='Helvetica', fontSize=9.5,
textColor=colors.HexColor('#212121'),
alignment=TA_JUSTIFY, leading=14)
bullet_s = ps('BL', fontName='Helvetica', fontSize=9,
textColor=colors.HexColor('#1A1A1A'),
leftIndent=10, leading=13)
sub_hdr_s = ps('SHB', fontName='Helvetica-Bold', fontSize=9.5,
textColor=DARK_TEAL, spaceBefore=4, spaceAfter=2)
alert_s = ps('AL', fontName='Helvetica-Bold', fontSize=9,
textColor=CRIMSON)
tip_s = ps('TIP', fontName='Helvetica-Oblique', fontSize=9,
textColor=FOREST)
toc_s = ps('TOC', fontName='Helvetica', fontSize=10,
textColor=DARK_TEAL, leading=17)
toc_hdr_s = ps('TH', fontName='Helvetica-Bold', fontSize=15,
textColor=DARK_TEAL, alignment=TA_CENTER, spaceAfter=14)
story = []
# ════════════════════════════════════════════════════════════════════════
# COVER
# ════════════════════════════════════════════════════════════════════════
story.append(Spacer(1, 2.5*cm))
cover_rows = [
[Paragraph('OPHTHALMOLOGY', title_s)],
[Paragraph('INTERN HANDBOOK', title_s)],
[Spacer(1, 0.3*cm)],
[Paragraph('Clinical Answers for GP Qualification Exam', sub_s)],
[Paragraph('Questions 97 · 102 · 103 · 104', sub_s)],
[Spacer(1, 0.6*cm)],
[Paragraph('Quick Reference for Ophthalmology Department Posting',
ps('cs', fontName='Helvetica', fontSize=10,
textColor=colors.HexColor('#FFF9C4'), alignment=TA_CENTER))],
]
cover_tbl = Table(cover_rows, colWidths=[16*cm])
cover_tbl.setStyle(TableStyle([
('BACKGROUND', (0,0), (-1,-1), DARK_TEAL),
('TOPPADDING', (0,0), (-1,-1), 10),
('BOTTOMPADDING', (0,0), (-1,-1), 10),
('LEFTPADDING', (0,0), (-1,-1), 20),
('RIGHTPADDING', (0,0), (-1,-1), 20),
]))
story.append(cover_tbl)
story.append(Spacer(1, 1.5*cm))
meta = [
['Questions Covered:', '5 clinical topics (Q97, Q102a, Q102b, Q103, Q104)'],
['Format:', 'Concise clinical answers for interns on posting'],
['Source:', "Kanski's Clinical Ophthalmology 10th Ed + Standard Guidelines"],
['Audience:', 'Medical Interns — Ophthalmology Department Rotation'],
['Exam:', 'General Practitioner Qualification Examination'],
]
meta_ps_k = ps('mk', fontName='Helvetica-Bold', fontSize=9.5,
textColor=WHITE)
meta_ps_v = ps('mv', fontName='Helvetica', fontSize=9.5,
textColor=DARK_TEAL)
meta_rows = [[Paragraph(k, meta_ps_k), Paragraph(v, meta_ps_v)]
for k, v in meta]
meta_tbl = Table(meta_rows, colWidths=[4.5*cm, 11.5*cm])
meta_tbl.setStyle(TableStyle([
('BACKGROUND', (0,0), (0,-1), MED_TEAL),
('BACKGROUND', (1,0), (1,-1), LIGHT_TEAL),
('GRID', (0,0), (-1,-1), 0.5, WHITE),
('TOPPADDING', (0,0), (-1,-1), 7),
('BOTTOMPADDING', (0,0), (-1,-1), 7),
('LEFTPADDING', (0,0), (-1,-1), 10),
('RIGHTPADDING', (0,0), (-1,-1), 10),
]))
story.append(meta_tbl)
story.append(PageBreak())
# ════════════════════════════════════════════════════════════════════════
# TABLE OF CONTENTS
# ════════════════════════════════════════════════════════════════════════
story.append(Paragraph('TABLE OF CONTENTS', toc_hdr_s))
story.append(HRFlowable(width='100%', thickness=2, color=DARK_TEAL, spaceAfter=10))
toc_entries = [
('Q 97', 'Inflammatory Diseases of the Outer and Middle Ear', MED_TEAL),
('Q 102a','Inflammatory Diseases of the Conjunctiva and Cornea', MED_TEAL),
('Q 102b','Inflammatory Diseases of the Eyelids and Lacrimal Ducts', DEEP_PURPLE),
('Q 103', 'Glaucoma — Clinical Manifestations, Diagnosis & Management',CRIMSON),
('Q 104', 'Eye Trauma — Emergency Tactics', AMBER),
]
for i, (qnum, qtitle, qcolor) in enumerate(toc_entries):
bg = LIGHT_TEAL if i % 2 == 0 else WHITE
row = Table(
[[Paragraph(f'<b>{qnum}</b>',
ps('tn', fontName='Helvetica-Bold', fontSize=10,
textColor=qcolor)),
Paragraph(qtitle, toc_s)]],
colWidths=[2.5*cm, 13.5*cm]
)
row.setStyle(TableStyle([
('BACKGROUND', (0,0), (-1,-1), bg),
('TOPPADDING', (0,0), (-1,-1), 6),
('BOTTOMPADDING', (0,0), (-1,-1), 6),
('LEFTPADDING', (0,0), (0,-1), 10),
('LEFTPADDING', (1,0), (1,-1), 8),
('LINEBELOW', (0,0), (-1,-1), 0.4, colors.HexColor('#B2DFDB')),
]))
story.append(row)
story.append(PageBreak())
# ════════════════════════════════════════════════════════════════════════
# HELPER: render a question block
# ════════════════════════════════════════════════════════════════════════
def render_question(q_label, q_title, color_h, color_bg, content_rows):
"""
content_rows: list of ('subheading'|'body'|'bullet'|'alert'|'tip', text)
"""
elements = []
# Question header bar
hdr = Table(
[[Paragraph(q_label, q_num_s),
Paragraph(q_title, sec_hdr_s)]],
colWidths=[2*cm, 14*cm]
)
hdr.setStyle(TableStyle([
('BACKGROUND', (0,0), (-1,-1), color_h),
('TOPPADDING', (0,0), (-1,-1), 9),
('BOTTOMPADDING', (0,0), (-1,-1), 9),
('LEFTPADDING', (0,0), (0,-1), 4),
('LEFTPADDING', (1,0), (1,-1), 10),
('VALIGN', (0,0), (-1,-1), 'MIDDLE'),
]))
elements.append(hdr)
# Content rows inside colored box
para_items = []
for kind, text in content_rows:
if kind == 'subheading':
para_items.append(Paragraph(f'<b>{text}</b>',
ps('sh2', fontName='Helvetica-Bold', fontSize=9.5,
textColor=color_h, spaceBefore=5, spaceAfter=2)))
elif kind == 'body':
para_items.append(Paragraph(text, body_s))
para_items.append(Spacer(1, 2))
elif kind == 'bullet':
para_items.append(Paragraph(f'• {text}', bullet_s))
elif kind == 'alert':
para_items.append(Paragraph(f'⚠ {text}',
ps('al2', fontName='Helvetica-Bold', fontSize=9,
textColor=CRIMSON, spaceBefore=3)))
elif kind == 'tip':
para_items.append(Paragraph(f'💡 {text}',
ps('tip2', fontName='Helvetica-Oblique', fontSize=9,
textColor=FOREST, spaceBefore=3)))
elif kind == 'divider':
para_items.append(HRFlowable(width='100%', thickness=0.5,
color=color_h, spaceAfter=4, spaceBefore=4))
content_tbl = Table([[para_items]], colWidths=[16*cm])
content_tbl.setStyle(TableStyle([
('BACKGROUND', (0,0), (-1,-1), color_bg),
('TOPPADDING', (0,0), (-1,-1), 8),
('BOTTOMPADDING', (0,0), (-1,-1), 10),
('LEFTPADDING', (0,0), (-1,-1), 12),
('RIGHTPADDING', (0,0), (-1,-1), 12),
]))
elements.append(content_tbl)
elements.append(Spacer(1, 14))
return KeepTogether(elements)
# ════════════════════════════════════════════════════════════════════════
# Q 97 — Inflammatory Diseases of Outer and Middle Ear
# ════════════════════════════════════════════════════════════════════════
story.append(render_question(
'Q 97',
'Inflammatory Diseases of the Outer & Middle Ear',
MED_TEAL, LIGHT_TEAL,
[
('subheading', 'OTITIS EXTERNA (Outer Ear Inflammation)'),
('body', 'Inflammation of the external auditory canal (EAC). Commonly bacterial (Pseudomonas, Staph aureus) or fungal (Aspergillus — otomycosis).'),
('subheading', 'Clinical Manifestations'),
('bullet', 'Otalgia (pain worsened by pulling the pinna or pressing the tragus)'),
('bullet', 'Otorrhea — purulent or serous discharge'),
('bullet', 'Pruritus, canal oedema, hearing loss (conductive)'),
('bullet', 'Malignant otitis externa: severe pain, granulation tissue at bony-cartilaginous junction; in diabetics/immunocompromised — can spread to skull base'),
('subheading', 'Diagnosis'),
('bullet', 'Otoscopy: erythema, oedema of EAC, debris, discharge'),
('bullet', 'Swab C&S to guide antibiotic choice'),
('bullet', 'CT temporal bone if malignant OE suspected'),
('subheading', 'Treatment'),
('bullet', 'Topical: acetic acid 2%, ciprofloxacin/dexamethasone drops (first-line)'),
('bullet', 'Keep canal dry; wick placement if severe oedema'),
('bullet', 'Oral antibiotics (ciprofloxacin) if spreading cellulitis'),
('bullet', 'Malignant OE: IV anti-pseudomonal antibiotics + surgical debridement'),
('divider', ''),
('subheading', 'ACUTE OTITIS MEDIA (Middle Ear Inflammation)'),
('body', 'Acute bacterial or viral infection of the middle ear. Most common in children. Key pathogens: Streptococcus pneumoniae, H. influenzae, Moraxella catarrhalis.'),
('subheading', 'Clinical Manifestations'),
('bullet', 'Sudden otalgia (especially in children — irritability, ear-pulling)'),
('bullet', 'Fever, hearing loss, sensation of fullness'),
('bullet', 'Otorrhea if tympanic membrane perforates (→ pain relief follows)'),
('bullet', 'Otoscopy: bulging, erythematous, opaque TM; reduced light reflex'),
('subheading', 'Diagnosis'),
('bullet', 'Clinical — otoscopy is key'),
('bullet', 'Tympanometry: type B (flat) curve — middle ear effusion'),
('bullet', 'Audiometry: conductive hearing loss'),
('subheading', 'Treatment'),
('bullet', 'First-line: Amoxicillin 500 mg TID × 7–10 days (or 90 mg/kg/day in children)'),
('bullet', 'Beta-lactam allergy: azithromycin or clarithromycin'),
('bullet', 'Amoxicillin-clavulanate if no improvement in 48–72 h'),
('bullet', 'Paracetamol/ibuprofen for analgesia'),
('bullet', 'Myringotomy if severe pain, complications suspected'),
('subheading', 'Complications'),
('bullet', 'Mastoiditis, meningitis, brain abscess, facial nerve palsy, labyrinthitis'),
('alert', 'Refer urgently if signs of complications: neck stiffness, facial palsy, vertigo, severe headache.'),
('subheading', 'GP Tactics'),
('bullet', 'Watchful waiting for 48–72 h in mild cases (age >2 yrs, no otorrhea)'),
('bullet', 'Prescribe analgesia; antibiotic if symptoms worsen or do not improve'),
('bullet', 'Follow-up in 2–3 weeks; refer ENT for recurrent episodes (>3/year)'),
('tip', 'Tympanic membrane perforation with acute AOM: topical antibiotic drops are NOT recommended initially — use systemic antibiotics.'),
]
))
# ════════════════════════════════════════════════════════════════════════
# Q 102a — Conjunctiva and Cornea
# ════════════════════════════════════════════════════════════════════════
story.append(render_question(
'Q 102a',
'Inflammatory Diseases of the Conjunctiva & Cornea',
MED_TEAL, LIGHT_TEAL,
[
('subheading', 'CONJUNCTIVITIS — Overview'),
('body', 'Inflammation of the conjunctiva. Types: bacterial, viral, allergic, chlamydial. Key principle: distinguish from more serious causes of red eye (acute glaucoma, keratitis, uveitis).'),
('subheading', 'Clinical Manifestations'),
('bullet', 'Red eye (conjunctival injection), discharge, foreign body sensation'),
('bullet', 'Bacterial: mucopurulent/purulent discharge; lids stuck together in morning'),
('bullet', 'Viral: watery discharge, follicles; often preceded by URTI; unilateral then bilateral'),
('bullet', 'Allergic: bilateral, intense itch, watery discharge, chemosis, papillae'),
('bullet', 'Chlamydial (adult inclusion): chronic unilateral follicular conjunctivitis, preauricular lymphadenopathy'),
('subheading', 'Diagnosis'),
('bullet', 'Slit-lamp exam: follicles vs. papillae (bacterial/allergic → papillae; viral/chlamydial → follicles)'),
('bullet', 'Conjunctival swab: Gram stain + C&S for bacterial; PCR for chlamydia'),
('bullet', 'Discharge characteristic: purulent = bacterial; watery = viral; mucoid-stringy = allergic'),
('subheading', 'Treatment'),
('bullet', 'Bacterial: topical ciprofloxacin 0.3% or tobramycin drops QID × 5–7 days'),
('bullet', 'Viral: supportive (cold compresses, artificial tears); resolves in 10–14 days; topical steroids CONTRAINDICATED'),
('bullet', 'Allergic: topical antihistamine/mast-cell stabilizer (olopatadine); avoid allergen; cool compresses'),
('bullet', 'Chlamydial: systemic azithromycin 1 g single dose OR doxycycline 100 mg BD × 7 days + treat partner'),
('bullet', 'Gonococcal: ceftriaxone 1 g IM single dose + saline irrigation'),
('alert', 'Corneal involvement (keratitis, dendrites) — refer urgently to ophthalmology. Do NOT use topical steroids until HSV excluded.'),
('divider', ''),
('subheading', 'KERATITIS (Corneal Inflammation)'),
('body', 'Infection/inflammation of the cornea. A sight-threatening emergency. Causes: bacterial, viral (HSV), fungal, Acanthamoeba.'),
('subheading', 'Clinical Manifestations'),
('bullet', 'Severe eye pain, photophobia, lacrimation, reduced vision'),
('bullet', 'Ciliary injection (redness maximal around limbus)'),
('bullet', 'Corneal ulcer/opacity on slit-lamp; fluorescein staining reveals epithelial defect'),
('bullet', 'HSV dendrites: branching ulcer with terminal bulbs on fluorescein stain'),
('bullet', 'Bacterial: purulent stromal infiltrate with overlying epithelial defect'),
('bullet', 'Acanthamoeba (contact lens wearers): severe pain disproportionate to signs; ring infiltrate'),
('subheading', 'Diagnosis'),
('bullet', 'Slit-lamp exam with fluorescein staining (ESSENTIAL)'),
('bullet', 'Corneal scraping for Gram stain, C&S, KOH (fungal), PCR (HSV/Acanthamoeba)'),
('subheading', 'Treatment'),
('bullet', 'Bacterial: intensive topical fluoroquinolone (ciprofloxacin 0.3% or moxifloxacin) every 1 h initially; URGENT ophthalmology referral'),
('bullet', 'HSV epithelial: topical acyclovir 3% ointment 5×/day × 10–14 days (NO steroids in epithelial stage)'),
('bullet', 'HSV stromal (disciform): judicious topical steroids + prophylactic topical acyclovir'),
('bullet', 'Acanthamoeba: PHMB + chlorhexidine drops hourly (long course)'),
('bullet', 'Fungal: topical natamycin 5% or voriconazole; systemic antifungals if deep involvement'),
('tip', 'Any contact lens wearer with red painful eye = Acanthamoeba keratitis until proven otherwise. Stop lens use immediately.'),
('subheading', 'GP Tactics'),
('bullet', 'Do NOT patch the eye in infectious keratitis'),
('bullet', 'Do NOT prescribe topical steroids without ophthalmology supervision'),
('bullet', 'URGENT same-day referral for any corneal ulcer'),
]
))
# ════════════════════════════════════════════════════════════════════════
# Q 102b — Eyelids and Lacrimal Ducts
# ════════════════════════════════════════════════════════════════════════
story.append(render_question(
'Q 102b',
'Inflammatory Diseases of the Eyelids & Lacrimal Ducts',
DEEP_PURPLE, LAVENDER,
[
('subheading', 'BLEPHARITIS'),
('body', 'Chronic bilateral inflammation of the eyelid margins. Two main types: anterior (lash base) and posterior (meibomian gland/MGD). Often co-exists with rosacea and dry eye.'),
('subheading', 'Clinical Manifestations'),
('bullet', 'Burning, itching, grittiness of the eyelids; worse in morning'),
('bullet', 'Anterior (staphylococcal): collarettes/scales around lashes, lash loss (madarosis)'),
('bullet', 'Seborrhoeic: greasy anterior scales; associated with scalp seborrhoea'),
('bullet', 'Posterior (MGD): foam in tear film, turbid meibomian secretions, telangiectasia of lid margin, chalazia'),
('subheading', 'Diagnosis'),
('bullet', 'Clinical — slit-lamp examination of lid margins'),
('bullet', 'Swab if secondary bacterial infection suspected'),
('subheading', 'Treatment'),
('bullet', 'Lid hygiene (FIRST-LINE): warm compresses × 5 min + lid massage + lid scrubs (dilute baby shampoo or commercial wipes) BD'),
('bullet', 'Artificial tears for dry eye component'),
('bullet', 'Topical antibiotics (chloramphenicol ointment OR azithromycin 1%) to lid margin if bacterial component'),
('bullet', 'Oral doxycycline 100 mg OD × 6–12 weeks for severe posterior blepharitis/rosacea'),
('tip', 'Blepharitis is CHRONIC and recurrent. Patients need ongoing lid hygiene for life.'),
('divider', ''),
('subheading', 'CHALAZION (Meibomian Cyst)'),
('body', 'Sterile lipogranuloma from retained meibomian secretions. Distinguished from stye (hordeolum) by being chronic, painless, and not pointing at lash.'),
('bullet', 'Painless, firm, round swelling within the tarsal plate'),
('bullet', 'Treatment: warm compresses; steroid injection (triamcinolone); surgical incision & curettage if persistent'),
('alert', 'Recurrent/atypical chalazia in elderly patients → biopsy to exclude sebaceous gland carcinoma.'),
('divider', ''),
('subheading', 'HORDEOLUM (Stye)'),
('bullet', 'External (Zeis/Moll glands): painful lash follicle abscess at lid margin'),
('bullet', 'Internal (meibomian gland): deeper, more painful; may point through conjunctiva'),
('bullet', 'Treatment: hot compresses; topical antibiotic ointment; oral antibiotics if preseptal cellulitis develops; incision & drainage if pointing'),
('divider', ''),
('subheading', 'DACRYOCYSTITIS (Lacrimal Sac Inflammation)'),
('body', 'Infection of the lacrimal sac, usually secondary to nasolacrimal duct obstruction. Causative organisms: Staphylococcus aureus, Streptococcus species.'),
('subheading', 'Acute Dacryocystitis'),
('bullet', 'Sudden pain, erythema, and tender swelling at the medial canthus'),
('bullet', 'Epiphora (overflow of tears), possible abscess formation, preseptal cellulitis'),
('bullet', 'On pressure over sac → mucopurulent reflux through puncta'),
('subheading', 'Chronic Dacryocystitis'),
('bullet', 'Chronic epiphora + recurrent conjunctivitis; painless medial canthal swelling (mucocele)'),
('bullet', 'Pressure on sac → mucopurulent canalicular reflux'),
('subheading', 'Diagnosis'),
('bullet', 'Clinical exam; syringing of lacrimal system to confirm obstruction'),
('bullet', 'Dacryocystography (DCG) or nasolacrimal probing to locate obstruction level'),
('bullet', 'Swab for C&S in acute phase'),
('subheading', 'Treatment'),
('bullet', 'Acute: warm compresses + oral antibiotics (flucloxacillin or co-amoxiclav); do NOT probe in acute phase'),
('bullet', 'Incision & drainage if abscess forming (risk: lacrimal fistula)'),
('bullet', 'Dacryocystorhinostomy (DCR) once acute infection settled — creates new drainage ostium into nasal cavity (definitive treatment)'),
('alert', 'Do NOT perform intraocular surgery in the presence of dacryocystitis — risk of endophthalmitis.'),
('divider', ''),
('subheading', 'CANALICULITIS'),
('bullet', 'Infection of the canaliculus (usually Actinomyces israelii — "sulfur granules")'),
('bullet', 'Chronic discharge, pouting punctum with expressible concretions'),
('bullet', 'Treatment: canaliculotomy + curettage of concretions; penicillin V'),
('subheading', 'GP Tactics'),
('bullet', 'Refer all acute dacryocystitis not responding to 48 h oral antibiotics to ophthalmology'),
('bullet', 'Chronic epiphora with no obvious cause → refer for lacrimal assessment'),
('bullet', 'Lid margin changes + conjunctivitis → consider blepharitis as underlying cause'),
]
))
# ════════════════════════════════════════════════════════════════════════
# Q 103 — Glaucoma
# ════════════════════════════════════════════════════════════════════════
story.append(render_question(
'Q 103',
'Glaucoma — Clinical Manifestations, Diagnosis & GP Tactics',
CRIMSON, LIGHT_RED,
[
('subheading', 'DEFINITION & CLASSIFICATION'),
('body', 'Glaucoma = progressive optic neuropathy with characteristic optic disc changes and visual field loss, usually (but not always) associated with elevated IOP (>21 mmHg). Two major forms for the GP:'),
('bullet', '1. Primary Open-Angle Glaucoma (POAG) — chronic, insidious, most common (>90% in Western populations)'),
('bullet', '2. Primary Angle-Closure Glaucoma (PACG) — acute or chronic; a medical emergency in acute form'),
('divider', ''),
('subheading', 'PRIMARY OPEN-ANGLE GLAUCOMA (POAG)'),
('body', 'Bilateral, slowly progressive. Trabecular meshwork dysfunctional → raised IOP → optic nerve damage. Silent until late.'),
('subheading', 'Risk Factors'),
('bullet', 'IOP >21 mmHg; family history (1st degree relative ×4 risk); age >40 yrs; Afro-Caribbean ethnicity; myopia; diabetes; hypertension; thin central corneal thickness'),
('subheading', 'Clinical Manifestations'),
('bullet', 'EARLY: No symptoms — peripheral visual field defects (missed by patient)'),
('bullet', 'LATE: Tunnel vision; central vision preserved until advanced stage'),
('bullet', 'Optic disc: enlarged cup-to-disc ratio (>0.6), notching of neuroretinal rim (esp. superior/inferior), disc haemorrhages, RNFL defects'),
('subheading', 'Diagnosis'),
('bullet', 'Tonometry (Goldmann applanation): IOP measurement'),
('bullet', 'Gonioscopy: open angle'),
('bullet', 'Optic disc assessment: OCT (RNFL thickness) + disc photography'),
('bullet', 'Visual field testing (Humphrey perimetry): arcuate scotoma, nasal step, paracentral defect'),
('bullet', 'Central corneal thickness (pachymetry): thin cornea → underestimates true IOP'),
('subheading', 'Treatment'),
('bullet', 'First-line: Prostaglandin analogues (latanoprost 0.005% once nightly) — most effective IOP-lowering'),
('bullet', 'Second-line: Beta-blockers (timolol 0.5% BD); Alpha-2 agonists (brimonidine BD); CAI (dorzolamide/brinzolamide)'),
('bullet', 'Laser trabeculoplasty (SLT) — first-line alternative to drops; NICE recommends as initial treatment'),
('bullet', 'Surgery: trabeculectomy or drainage tube if medical/laser therapy fails'),
('tip', 'Target IOP = 30% reduction from baseline, or individualized based on optic nerve damage severity.'),
('divider', ''),
('subheading', 'ACUTE ANGLE-CLOSURE GLAUCOMA (AACG) — EMERGENCY'),
('body', 'Pupillary block → iris occludes trabecular meshwork → sudden IOP spike (often 40–70 mmHg). Predisposed: hypermetropic eyes, narrow angles, Asian populations, older females.'),
('subheading', 'Triggers'),
('bullet', 'Dim lighting (pupil dilation), mydriatic eye drops, anticholinergics, adrenergics (nasal decongestants), emotional stress'),
('subheading', 'Clinical Manifestations'),
('bullet', 'SEVERE unilateral headache + eye pain + nausea/vomiting (can mimic migraine or GI illness!)'),
('bullet', 'Blurred vision with coloured haloes around lights'),
('bullet', 'Red eye (conjunctival and ciliary injection)'),
('bullet', 'Mid-dilated, oval, FIXED pupil (non-reactive)'),
('bullet', 'Corneal oedema: cloudy/steamy cornea'),
('bullet', 'Rock-hard globe on palpation; IOP extremely elevated'),
('subheading', 'Diagnosis'),
('bullet', 'Clinical — above triad (pain + fixed mid-dilated pupil + corneal oedema) is pathognomonic'),
('bullet', 'Tonometry: markedly elevated IOP'),
('bullet', 'Gonioscopy (after IOP lowered): closed angle'),
('bullet', 'Slit-lamp: shallow AC, corneal epithelial oedema, iris bombe if pupillary block'),
('subheading', 'Immediate Emergency Treatment'),
('bullet', 'STEP 1: Reduce IOP immediately — IV/oral acetazolamide 500 mg STAT (contraindicated in sulfa allergy/renal failure)'),
('bullet', 'STEP 2: Topical IOP-lowering: timolol 0.5% + apraclonidine 1% + pilocarpine 2% (to break pupil block)'),
('bullet', 'STEP 3: IV mannitol 20% (1–2 g/kg over 30–45 min) if IOP not controlled'),
('bullet', 'STEP 4: Definitive — Nd:YAG laser peripheral iridotomy (LPI) in BOTH eyes (prophylactic in fellow eye)'),
('bullet', 'Analgesia + antiemetics as needed'),
('alert', 'AACG is an OPHTHALMIC EMERGENCY. Any delay risks permanent visual loss within hours. Call ophthalmology immediately.'),
('divider', ''),
('subheading', 'NORMAL TENSION GLAUCOMA (NTG)'),
('bullet', 'Glaucomatous optic nerve damage with IOP consistently ≤21 mmHg'),
('bullet', 'Associated with nocturnal hypotension, vasospasm, migraine, Raynaud\'s'),
('bullet', 'Treat: IOP lowering (target ~30% reduction); address vascular risk factors'),
('subheading', 'GP Screening & Referral Tactics'),
('bullet', 'Screen high-risk patients: IOP check + optic disc assessment at routine appointments'),
('bullet', 'Any IOP >21 mmHg on two occasions → refer to ophthalmology'),
('bullet', 'C:D ratio >0.7 or asymmetry >0.2 between eyes → refer'),
('bullet', 'First-degree relative with glaucoma → recommend regular screening from age 40'),
('bullet', 'ACUTE: IMMEDIATE (same-hour) emergency ophthalmology referral; start acetazolamide while arranging transfer'),
('tip', 'Beta-blocker eye drops (timolol) can cause systemic effects — contraindicated in asthma, COPD, bradycardia, heart block. Always ask about systemic conditions before prescribing.'),
]
))
# ════════════════════════════════════════════════════════════════════════
# Q 104 — Eye Trauma
# ════════════════════════════════════════════════════════════════════════
story.append(render_question(
'Q 104',
'Eye Trauma — GP Emergency Tactics',
AMBER, LIGHT_AMBER,
[
('subheading', 'INITIAL ASSESSMENT — All Eye Trauma'),
('bullet', 'Visual acuity (VA): ALWAYS measure first, even in emergency — defines severity and medicolegal documentation'),
('bullet', 'History: mechanism of injury (blunt/sharp/chemical/flash burn), time, materials involved, use of protective eyewear'),
('bullet', 'External inspection: lids, periorbital area, then ocular structures'),
('alert', 'If open globe (penetrating/perforating injury) suspected: DO NOT apply pressure, remove foreign body or perform tonometry. Rigid eye shield, NBM, urgent surgery.'),
('divider', ''),
('subheading', '1. CHEMICAL BURNS — IMMEDIATE EMERGENCY (Priority #1)'),
('body', 'Alkalis (lime, cement, ammonia, lye) are MORE dangerous than acids — alkalis penetrate deeper via saponification. Treat BEFORE full history.'),
('subheading', 'Classification (Roper-Hall / Dua)'),
('bullet', 'Grade I: corneal epithelial damage, no ischaemia — good prognosis'),
('bullet', 'Grade II: cornea hazy but iris visible, <1/3 limbal ischaemia'),
('bullet', 'Grade III: total corneal opacity, 1/3–1/2 limbal ischaemia'),
('bullet', 'Grade IV: opaque cornea, >1/2 limbal ischaemia — poor prognosis'),
('subheading', 'Emergency Treatment'),
('bullet', 'IMMEDIATE copious irrigation with NS/Ringer\'s (or water if no saline) — minimum 30 minutes, ideally 2 L'),
('bullet', 'Use lid speculum if blepharospasm; sweep fornices with wet cotton bud to remove particulate'),
('bullet', 'Check pH — target pH 7.0–7.4; continue irrigation until pH normalised'),
('bullet', 'Topical tetracaine for analgesia before/during irrigation'),
('bullet', 'After irrigation: topical antibiotic, mydriatics, ascorbate drops, topical steroids (consultant-guided)'),
('bullet', 'URGENT ophthalmology transfer after initial irrigation'),
('divider', ''),
('subheading', '2. CORNEAL FOREIGN BODY & ABRASION'),
('bullet', 'FB: remove with slit-lamp using 25G needle; rust ring may need burr removal'),
('bullet', 'Corneal abrasion: fluorescein staining shows defect; topical antibiotic (chloramphenicol QID × 5 days); cycloplegic (cyclopentolate 1%) for ciliary spasm pain'),
('bullet', 'Eye pad: NOT recommended for abrasions — delays healing; use lubricant drops'),
('bullet', 'Contact lens-related abrasion: treat as pseudomonas risk — fluoroquinolone drops'),
('tip', 'Always evert upper lid to check for subtarsal foreign body if linear corneal abrasion present.'),
('divider', ''),
('subheading', '3. BLUNT OCULAR TRAUMA (Contusion)'),
('subheading', 'Structures Affected (anterior → posterior)'),
('bullet', 'Periorbital: ecchymosis ("black eye") — rule out orbital wall fracture (diplopia, enophthalmos, infraorbital hypoesthesia → CT face)'),
('bullet', 'Cornea: traumatic oedema (Descemet\'s folds)'),
('bullet', 'Anterior chamber: hyphaema (blood in AC) — grade 1–4; lie flat 45°, cycloplegia, topical steroids, avoid NSAIDs/aspirin; beware IOP spike'),
('bullet', 'Iris: iridodialysis, mydriasis, angle recession glaucoma (years later)'),
('bullet', 'Lens: traumatic cataract, lens subluxation/dislocation'),
('bullet', 'Vitreous: vitreous haemorrhage — B-scan US to exclude retinal detachment'),
('bullet', 'Retina: commotio retinae (Berlin\'s oedema), retinal tear/detachment, choroidal rupture; macular hole'),
('bullet', 'Optic nerve: traumatic optic neuropathy — IV methylprednisolone or observation; consider surgery'),
('subheading', 'Orbital Blowout Fracture'),
('bullet', 'Floor/medial wall fracture from blunt force to orbit'),
('bullet', 'Signs: diplopia (inferior rectus entrapment), enophthalmos, periorbital emphysema, hypoesthesia of cheek (infraorbital nerve)'),
('bullet', 'CT orbit: confirms fracture + muscle entrapment'),
('bullet', 'Treatment: surgery if diplopia/enophthalmos; antibiotics (sinus flora); avoid nose-blowing'),
('divider', ''),
('subheading', '4. PENETRATING / PERFORATING EYE INJURY'),
('body', 'Sharp objects (glass, metal, wood, needles) or high-velocity particles. Full thickness corneal/scleral laceration.'),
('subheading', 'Signs of Open Globe'),
('bullet', 'Peaked/teardrop-shaped pupil (iris prolapse)'),
('bullet', 'Uveal tissue or vitreous visible at wound'),
('bullet', 'Marked hypotony (soft globe), deep/shallow AC asymmetry'),
('bullet', 'Subconjunctival haemorrhage (360° chemosis → suspect scleral perforation)'),
('subheading', 'Immediate Management'),
('bullet', 'Do NOT: remove protruding FB, apply pressure, instil drops, measure IOP with applanation'),
('bullet', 'DO: rigid (Fox) shield over eye, nil by mouth, IV antibiotics (ciprofloxacin/vancomycin), antiemetics, analgesia'),
('bullet', 'CT orbit (no MRI) to rule out intraocular FB before surgery'),
('bullet', 'Tetanus prophylaxis for soil/organic matter'),
('bullet', 'Emergency surgical repair within 24 hours'),
('divider', ''),
('subheading', '5. RADIATION INJURIES (UV/Flash Burn)'),
('bullet', 'Photokeratitis (welder\'s flash, snow blindness): bilateral pain, photophobia, foreign body sensation 6–12 h after UV exposure'),
('bullet', 'Fluorescein: diffuse punctate epithelial erosions'),
('bullet', 'Treatment: topical NSAID (ketorolac) + antibiotic ointment + cycloplegic; self-resolving in 24–72 h; no eye pad'),
('divider', ''),
('subheading', 'GP Referral Summary'),
('bullet', 'IMMEDIATE (999/emergency): chemical burn, open globe, penetrating injury, AACG, central retinal artery occlusion'),
('bullet', 'SAME-DAY URGENT: hyphaema, corneal ulcer, vitreous haemorrhage, traumatic optic neuropathy, orbital fracture with diplopia'),
('bullet', 'ROUTINE (within days): corneal FB removed, simple abrasion, blunt trauma with normal VA and no hyphaema'),
('tip', 'Sympathetic ophthalmia: granulomatous uveitis in the NON-injured eye weeks to months after penetrating trauma. Requires lifelong immunosuppression. Preventable by early enucleation of a blind injured eye.'),
]
))
# ════════════════════════════════════════════════════════════════════════
# QUICK REFERENCE CARD — Red Eye Differential
# ════════════════════════════════════════════════════════════════════════
story.append(PageBreak())
ref_title = ps('RT', fontName='Helvetica-Bold', fontSize=14,
textColor=WHITE, alignment=TA_CENTER)
ref_hdr_tbl = Table([[Paragraph('QUICK REFERENCE: RED EYE DIFFERENTIAL DIAGNOSIS', ref_title)]],
colWidths=[16*cm])
ref_hdr_tbl.setStyle(TableStyle([
('BACKGROUND', (0,0), (-1,-1), DARK_TEAL),
('TOPPADDING', (0,0), (-1,-1), 10),
('BOTTOMPADDING', (0,0), (-1,-1), 10),
]))
story.append(ref_hdr_tbl)
story.append(Spacer(1, 6))
col_hdr_s = ps('CH', fontName='Helvetica-Bold', fontSize=9,
textColor=WHITE, alignment=TA_CENTER)
cell_s = ps('CE', fontName='Helvetica', fontSize=8.5,
textColor=colors.HexColor('#1A1A1A'), alignment=TA_CENTER, leading=12)
cell_s_l = ps('CL', fontName='Helvetica', fontSize=8.5,
textColor=colors.HexColor('#1A1A1A'), alignment=TA_LEFT, leading=12)
headers = ['Feature', 'Conjunctivitis', 'Keratitis', 'Acute Glaucoma (AACG)', 'Anterior Uveitis']
rows = [
['Onset', 'Gradual', 'Hours–days', 'SUDDEN', 'Hours–days'],
['Pain', 'Mild/Gritty', 'Severe', 'SEVERE + headache', 'Moderate ache'],
['Vision', 'Normal', 'Reduced', 'MARKEDLY reduced', 'Mildly reduced'],
['Redness', 'Diffuse', 'Ciliary flush', 'Ciliary + conj.', 'Ciliary flush (perilimbal)'],
['Pupil', 'Normal', 'Small/irreg.', 'Mid-dilated FIXED', 'Small, irregular (PAS)'],
['Cornea', 'Clear', 'Ulcer/opaque', 'Cloudy/oedematous', 'Keratic precipitates'],
['Discharge', 'Yes (+/-)', 'Watery', 'None', 'None'],
['IOP', 'Normal', 'Normal/low', 'VERY HIGH (>40)', 'Normal/slightly low'],
['Treatment', 'Topical ABx/AH','Topical ABx/antiviral — URGENT', 'IV Acetazolamide — EMERGENCY', 'Topical steroids + cycloplegic'],
]
hdr_row = [Paragraph(h, col_hdr_s) for h in headers]
data = [hdr_row]
for row in rows:
data.append([Paragraph(row[0], ps('rh', fontName='Helvetica-Bold', fontSize=8.5,
textColor=DARK_TEAL))] +
[Paragraph(c, cell_s) for c in row[1:]])
ref_tbl = Table(data, colWidths=[2.6*cm, 2.7*cm, 2.9*cm, 3.8*cm, 4*cm])
ref_tbl_style = [
('BACKGROUND', (0,0), (-1,0), DARK_TEAL),
('TEXTCOLOR', (0,0), (-1,0), WHITE),
('GRID', (0,0), (-1,-1), 0.5, colors.HexColor('#B2DFDB')),
('TOPPADDING', (0,0), (-1,-1), 5),
('BOTTOMPADDING', (0,0), (-1,-1), 5),
('LEFTPADDING', (0,0), (-1,-1), 4),
('RIGHTPADDING', (0,0), (-1,-1), 4),
('VALIGN', (0,0), (-1,-1), 'MIDDLE'),
# Highlight AACG column
('BACKGROUND', (3,1), (3,-1), colors.HexColor('#FFEBEE')),
('FONTNAME', (3,1), (3,-1), 'Helvetica-Bold'),
]
for i in range(1, len(data)):
if i % 2 == 0:
ref_tbl_style.append(('BACKGROUND', (0,i), (2,i), colors.HexColor('#F5F5F5')))
ref_tbl_style.append(('BACKGROUND', (4,i), (4,i), colors.HexColor('#E8EAF6')))
ref_tbl.setStyle(TableStyle(ref_tbl_style))
story.append(ref_tbl)
story.append(Spacer(1, 12))
# ── Common Topical Eye Drops Quick Guide ─────────────────────────────────
drops_hdr_tbl = Table([[Paragraph('COMMON OPHTHALMIC MEDICATIONS — INTERN REFERENCE', ref_title)]],
colWidths=[16*cm])
drops_hdr_tbl.setStyle(TableStyle([
('BACKGROUND', (0,0), (-1,-1), ROYAL_BLUE),
('TOPPADDING', (0,0), (-1,-1), 8),
('BOTTOMPADDING', (0,0), (-1,-1), 8),
]))
story.append(drops_hdr_tbl)
story.append(Spacer(1, 6))
drops_data = [
['Drug / Class', 'Dose', 'Indication', 'Key Notes'],
['Ciprofloxacin 0.3% drops', 'Q2h → QID', 'Bacterial conjunctivitis, keratitis', 'Broad-spectrum; use intensively in keratitis'],
['Chloramphenicol 0.5% drops', 'QID × 5–7 d', 'Bacterial conjunctivitis (mild)', 'First-line in many countries; avoid in neonates'],
['Acyclovir 3% ointment', '5× daily × 10–14 d', 'HSV epithelial keratitis', 'NO steroids in epithelial stage'],
['Latanoprost 0.005% drops', 'Once nightly', 'POAG, OHT', 'Prostaglandin; increases brown iris pigment'],
['Timolol 0.5% drops', 'BD', 'POAG, OHT', 'Beta-blocker; CONTRAINDICATED in asthma, bradycardia'],
['Pilocarpine 2% drops', 'TID–QID', 'AACG (break pupil block)', 'Ineffective when IOP >40 (ischaemic iris)'],
['Acetazolamide (IV/oral)', '500 mg STAT', 'AACG emergency IOP reduction', 'CAI; CI in sulfa allergy, CKD, hyponatraemia'],
['Mannitol 20% IV', '1–2 g/kg over 45 min', 'AACG if acetazolamide fails', 'Hyperosmotic; monitor renal function, electrolytes'],
['Cyclopentolate 1% drops', '1–2 drops × 2', 'Cycloplegia/mydriasis for pain/exam', 'Duration 24 h; warn patient of blurred vision'],
['Dexamethasone 0.1% drops', 'As directed', 'Anterior uveitis, post-op, HSV stromal', 'NEVER use without diagnosis — can worsen HSV/glaucoma'],
['Olopatadine 0.1% drops', 'BD', 'Allergic conjunctivitis', 'Antihistamine + mast cell stabiliser'],
['Fluorescein 1%/2% strips', 'Diagnostic stain', 'Corneal abrasion, dendritic ulcer, FB', 'View with blue cobalt filter light'],
['Tetracaine (proxymetacaine) 0.5%', '1–2 drops', 'Topical anaesthesia (diagnosis/FB removal)', 'NEVER prescribe for home use — delays healing, masks serious pathology'],
]
drops_hdr_style = ps('dh', fontName='Helvetica-Bold', fontSize=8.5, textColor=WHITE)
drops_cell_style = ps('dc', fontName='Helvetica', fontSize=8.5,
textColor=colors.HexColor('#1A1A1A'), leading=12)
drops_bold_style = ps('db', fontName='Helvetica-Bold', fontSize=8.5,
textColor=ROYAL_BLUE)
drop_rows = [[Paragraph(c, drops_hdr_style) for c in drops_data[0]]]
for i, row in enumerate(drops_data[1:]):
drop_rows.append([
Paragraph(row[0], drops_bold_style),
Paragraph(row[1], drops_cell_style),
Paragraph(row[2], drops_cell_style),
Paragraph(row[3], drops_cell_style),
])
drops_tbl = Table(drop_rows, colWidths=[3.8*cm, 2.2*cm, 4.5*cm, 5.5*cm])
drops_style_list = [
('BACKGROUND', (0,0), (-1,0), ROYAL_BLUE),
('GRID', (0,0), (-1,-1), 0.5, colors.HexColor('#BBDEFB')),
('TOPPADDING', (0,0), (-1,-1), 5),
('BOTTOMPADDING', (0,0), (-1,-1), 5),
('LEFTPADDING', (0,0), (-1,-1), 5),
('RIGHTPADDING', (0,0), (-1,-1), 5),
('VALIGN', (0,0), (-1,-1), 'TOP'),
]
for i in range(1, len(drop_rows)):
bg = SKY_BLUE if i % 2 == 0 else WHITE
drops_style_list.append(('BACKGROUND', (0,i), (-1,i), bg))
drops_tbl.setStyle(TableStyle(drops_style_list))
story.append(drops_tbl)
doc.build(story)
print(f'PDF saved: {out}')
return out
if __name__ == '__main__':
build_pdf()
cd /tmp/workspace/medical-handbook && python3 create_ophthalmology_handbook.py 2>&1
~/medical-handbook/create_ophthalmology_handbook.py
Successfully replaced 1 instance(s) of the string in '/tmp/workspace/medical-handbook/create_ophthalmology_handbook.py'
render_question is called — they use story.append() but now it can return a list. Let me fix the whole render_question and its call pattern:~/medical-handbook/create_ophthalmology_handbook.py
Successfully replaced 1 instance(s) of the string in '/tmp/workspace/medical-handbook/create_ophthalmology_handbook.py'
story.append(render_question(...)) to story.extend(render_question(...)):cd /tmp/workspace/medical-handbook && sed -i 's/story\.append(render_question(/story.extend(render_question(/g' create_ophthalmology_handbook.py && grep -n "story.*render_question" create_ophthalmology_handbook.py
cd /tmp/workspace/medical-handbook && python3 create_ophthalmology_handbook.py 2>&1
python3 -c " from pypdf import PdfReader r = PdfReader('/tmp/workspace/medical-handbook/Ophthalmology_Intern_Handbook.pdf') print(f'Pages: {len(r.pages)}') import os; print(f'Size: {os.path.getsize(\"/tmp/workspace/medical-handbook/Ophthalmology_Intern_Handbook.pdf\")/1024:.1f} KB') "
Ophthalmology Intern Handbook
PDF Document · PDF
| Question | Topic | Color |
|---|---|---|
| Q 97 | Inflammatory Diseases of the Outer & Middle Ear (Otitis Externa + Otitis Media) | Teal |
| Q 102a | Inflammatory Diseases of the Conjunctiva & Cornea (Conjunctivitis + Keratitis) | Teal |
| Q 102b | Inflammatory Diseases of the Eyelids & Lacrimal Ducts (Blepharitis, Chalazion, Hordeolum, Dacryocystitis, Canaliculitis) | Purple |
| Q 103 | Glaucoma — POAG, Acute Angle-Closure (AACG), Normal Tension Glaucoma | Crimson |
| Q 104 | Eye Trauma — Chemical Burns, Corneal FB/Abrasion, Blunt Trauma, Penetrating Injury, UV Burns | Amber |