Hypothyroidism Focus on Clinical features,investigations and management For me mokshit Panwar roll no 68

Your credits are exhausted. You can purchase a top-up or subscribe to a plan to continue using Orris. If you're already subscribed, your daily credits will reset tomorrow.

Hypothyroidism Focus on Clinical features,investigations and management For me mokshit Panwar roll no 68 Colour ful diagrams and best ppt

Reading File
Reading File
Reading File
Finding Sources
Searching Images

hypothyroidism clinical features symptoms signs

This clinical photograph shows a front-view extraoral assessment of a 38-year-old female patient exhibiting classic signs of facial myxedema and weight gain associated with uncontrolled hypothyroidism. The facial contour is noticeably rounded, presenting a 'moon face' appearance with generalized fullness and obscuration of the underlying bony jawline and malar landmarks. Key visible features include bilateral periorbital puffiness, prominent soft tissue swelling in the cheeks (buccal fat pad region), and increased subcutaneous adipose tissue in the submental and cervical areas, leading to a less defined neck-to-jaw transition. The skin appears somewhat thickened with diffuse hyperpigmentation, particularly across the malar regions. These findings are characteristic clinical manifestations of thyroid dysfunction, reflecting the systemic metabolic effects and mucopolysaccharide deposition in dermal tissues. This visual material serves as an educational reference for identifying secondary systemic symptoms during a dental or general medical examination, specifically in patients with comorbid diabetes mellitus and hypothyroidism.

This clinical photograph shows a front-view extraoral assessment of a 38-year-old female patient exhibiting classic signs of facial myxedema and weight gain associated with uncontrolled hypothyroidism. The facial contour is noticeably rounded, presenting a 'moon face' appearance with generalized fullness and obscuration of the underlying bony jawline and malar landmarks. Key visible features include bilateral periorbital puffiness, prominent soft tissue swelling in the cheeks (buccal fat pad region), and increased subcutaneous adipose tissue in the submental and cervical areas, leading to a less defined neck-to-jaw transition. The skin appears somewhat thickened with diffuse hyperpigmentation, particularly across the malar regions. These findings are characteristic clinical manifestations of thyroid dysfunction, reflecting the systemic metabolic effects and mucopolysaccharide deposition in dermal tissues. This visual material serves as an educational reference for identifying secondary systemic symptoms during a dental or general medical examination, specifically in patients with comorbid diabetes mellitus and hypothyroidism.

A series of four clinical photographs (a–d) documenting the progression of a pediatric patient with primary congenital hypothyroidism before and after treatment. Images (a) and (b) represent the patient at admission, exhibiting classic symptoms of untreated hypothyroidism: severe abdominal distension (pseudo-obstruction secondary to constipation), an umbilical hernia, generalized myxedema, and visible irritability. Facial features in (b) show macroglossia (enlarged tongue), rarefied eyebrows, and brittle, sparse hair. Images (c) and (d) depict the same patient six months after initiating levothyroxine sodium replacement therapy. These images demonstrate significant clinical improvement, including the complete resolution of abdominal distension (c) and achievement of developmental milestones, such as sitting without support (d). The comparison illustrates the systemic effects of thyroid hormone deficiency on metabolism, gastrointestinal motility, and neurodevelopmental progress in infants, as well as the efficacy of hormonal replacement.

A series of four clinical photographs (a–d) documenting the progression of a pediatric patient with primary congenital hypothyroidism before and after treatment. Images (a) and (b) represent the patient at admission, exhibiting classic symptoms of untreated hypothyroidism: severe abdominal distension (pseudo-obstruction secondary to constipation), an umbilical hernia, generalized myxedema, and visible irritability. Facial features in (b) show macroglossia (enlarged tongue), rarefied eyebrows, and brittle, sparse hair. Images (c) and (d) depict the same patient six months after initiating levothyroxine sodium replacement therapy. These images demonstrate significant clinical improvement, including the complete resolution of abdominal distension (c) and achievement of developmental milestones, such as sitting without support (d). The comparison illustrates the systemic effects of thyroid hormone deficiency on metabolism, gastrointestinal motility, and neurodevelopmental progress in infants, as well as the efficacy of hormonal replacement.

A clinical photograph displaying the frontal view of a 58-year-old male exhibiting classic signs of myxedematous facies associated with primary hypothyroidism. Notable features include bilateral periorbital edema, most pronounced in the right lower eyelid, which appears as a soft, fluid-filled swelling. The patient presents with generalized facial puffiness, particularly around the mid-face and jawline, contributing to a characteristic 'moon-like' facial contour. The skin demonstrates a yellowish, pale tonality (pallor) and a dry texture consistent with xeroderma. Additional visible findings include deep forehead wrinkling, significant skin laxity in the lower facial region, and sparse lateral eyebrows. This image serves as a clinical illustration of the cutaneous and soft tissue manifestations of severe thyroid hormone deficiency, illustrating the accumulation of glycosaminoglycans in the dermis.

A clinical photograph displaying the frontal view of a 58-year-old male exhibiting classic signs of myxedematous facies associated with primary hypothyroidism. Notable features include bilateral periorbital edema, most pronounced in the right lower eyelid, which appears as a soft, fluid-filled swelling. The patient presents with generalized facial puffiness, particularly around the mid-face and jawline, contributing to a characteristic 'moon-like' facial contour. The skin demonstrates a yellowish, pale tonality (pallor) and a dry texture consistent with xeroderma. Additional visible findings include deep forehead wrinkling, significant skin laxity in the lower facial region, and sparse lateral eyebrows. This image serves as a clinical illustration of the cutaneous and soft tissue manifestations of severe thyroid hormone deficiency, illustrating the accumulation of glycosaminoglycans in the dermis.

This clinical photograph displays a three-panel series of infants illustrating classic physical manifestations of untreated congenital primary hypothyroidism at three months of age. The first two panels focus on facial features, showing coarse facial features, puffy eyelids (periorbital edema), and a characteristic 'myxedematous' facies. Notably, the infants exhibit a flat nasal bridge, macroglossia (an enlarged, protruding tongue), and thickened skin with prominent forehead wrinkling. The third panel shows an infant with a markedly distended abdomen and a prominent umbilical hernia, another hallmark sign of the condition. Additional visible indicators include sparse hair and an overall lethargic or dull appearance. These images serve as a pedagogical example of the clinical progression of hypothyroidism in infants who missed neonatal screening, highlighting the multisystemic physical signs that accompany developmental delay and metabolic insufficiency in early infancy.

This clinical photograph displays a three-panel series of infants illustrating classic physical manifestations of untreated congenital primary hypothyroidism at three months of age. The first two panels focus on facial features, showing coarse facial features, puffy eyelids (periorbital edema), and a characteristic 'myxedematous' facies. Notably, the infants exhibit a flat nasal bridge, macroglossia (an enlarged, protruding tongue), and thickened skin with prominent forehead wrinkling. The third panel shows an infant with a markedly distended abdomen and a prominent umbilical hernia, another hallmark sign of the condition. Additional visible indicators include sparse hair and an overall lethargic or dull appearance. These images serve as a pedagogical example of the clinical progression of hypothyroidism in infants who missed neonatal screening, highlighting the multisystemic physical signs that accompany developmental delay and metabolic insufficiency in early infancy.

Reading File
Finding Sources
Reading File
Reading File
Searching Images

thyroid gland anatomy TSH T3 T4 hormone pathway diagram

This pathophysiology diagram illustrates the Hypothalamic-Pituitary-Thyroid (HPT) axis, comparing normal physiological conditions with the alterations observed during prolonged critical illness. The 'Normal conditions' section shows the standard cascade: the Hypothalamus secretes TRH, which stimulates the Pituitary to release TSH, leading the Thyroid gland to produce T4 and T3. These hormones reach target cells via TH binding globulins for hormone conversion and uptake, with a negative feedback loop inhibiting TRH and TSH secretion. In contrast, the 'Prolonged critical illness' section details the central and peripheral suppression of the axis. Key pathological features include: upregulation of T4 to T3 conversion in the hypothalamus (inhibiting TRH release), suppression of pulsatile TSH secretion by the pituitary, reduced thyroid hormone secretion, and depression of thyroid function at the tissue level. Peripheral mechanisms shown include increased conversion to inactive rT3 and altered hormone uptake. This comparison illustrates the endocrine maladaptation typical of Non-Thyroidal Illness Syndrome (NTIS) in intensive care settings.

This pathophysiology diagram illustrates the Hypothalamic-Pituitary-Thyroid (HPT) axis, comparing normal physiological conditions with the alterations observed during prolonged critical illness. The 'Normal conditions' section shows the standard cascade: the Hypothalamus secretes TRH, which stimulates the Pituitary to release TSH, leading the Thyroid gland to produce T4 and T3. These hormones reach target cells via TH binding globulins for hormone conversion and uptake, with a negative feedback loop inhibiting TRH and TSH secretion. In contrast, the 'Prolonged critical illness' section details the central and peripheral suppression of the axis. Key pathological features include: upregulation of T4 to T3 conversion in the hypothalamus (inhibiting TRH release), suppression of pulsatile TSH secretion by the pituitary, reduced thyroid hormone secretion, and depression of thyroid function at the tissue level. Peripheral mechanisms shown include increased conversion to inactive rT3 and altered hormone uptake. This comparison illustrates the endocrine maladaptation typical of Non-Thyroidal Illness Syndrome (NTIS) in intensive care settings.

This pathophysiology diagram illustrates the regulatory role of Myo-inositol (MYO-INS) in thyroid function and its protective mechanisms against thyroid cancer. The diagram maps two primary pathways: first, MYO-INS serves as a precursor to phosphoinositide second messengers (PIP2 and IP3), which facilitate thyroid hormone synthesis. Increased T3 and T4 levels then exert negative feedback on TSH secretion, thereby inhibiting TSH-driven thyrocyte proliferation. Second, MYO-INS is shown to downregulate the PI3K/Akt proliferative pathway, which is typically overactive in follicular (FTC), anaplastic (ATC), and papillary thyroid cancer (PTC). A clinical component includes ultrasound elastography images showing a thyroid nodule with high stiffness (Elasticity score 4); the diagram indicates that MYO-INS reduces the size and stiffness of such nodules, ultimately leading to a reduced risk of thyroid cancer. Key molecular elements include TSHR signaling, cAMP, and IGF1-mediated proliferation, highlighting the transition from benign nodules to malignancy.

This pathophysiology diagram illustrates the regulatory role of Myo-inositol (MYO-INS) in thyroid function and its protective mechanisms against thyroid cancer. The diagram maps two primary pathways: first, MYO-INS serves as a precursor to phosphoinositide second messengers (PIP2 and IP3), which facilitate thyroid hormone synthesis. Increased T3 and T4 levels then exert negative feedback on TSH secretion, thereby inhibiting TSH-driven thyrocyte proliferation. Second, MYO-INS is shown to downregulate the PI3K/Akt proliferative pathway, which is typically overactive in follicular (FTC), anaplastic (ATC), and papillary thyroid cancer (PTC). A clinical component includes ultrasound elastography images showing a thyroid nodule with high stiffness (Elasticity score 4); the diagram indicates that MYO-INS reduces the size and stiffness of such nodules, ultimately leading to a reduced risk of thyroid cancer. Key molecular elements include TSHR signaling, cAMP, and IGF1-mediated proliferation, highlighting the transition from benign nodules to malignancy.

A two-part medical illustration depicting the pathophysiology of the Hypothalamic-Pituitary-Thyroid (HPT) axis and cellular thyroid hormone action. Section (a) shows the systemic HPT axis, beginning with the cerebral cortex and hypothalamus. The hypothalamus releases thyrotropin-releasing hormone (TRH), which stimulates the pituitary gland to secrete thyroid-stimulating hormone (TSH). TSH subsequently acts on the thyroid gland to stimulate the production of T4 and T3 hormones, which exert negative feedback on the hypothalamus and pituitary. Section (b) details the intracellular mechanism of action within a target cell. T4 and T3 enter the cell via thyroid hormone transporters. In the cytoplasm, deiodinases (D1/D2) convert T4 to T3, while D3 converts T4 to inactive reverse T3 (rT3). T3 enters the nucleus, binding to the thyroid hormone receptor (TR) which heterodimerizes with the retinoid X receptor (RXR). This complex binds to the thyroid hormone response element (TRE) on DNA, displacing corepressors and recruiting coactivators to initiate gene transcription (mRNA) and subsequent protein synthesis. The diagram also highlights potential sites of endocrine disruption (e.g., by Tributyltin/TBT), including receptor inhibition and deiodinase interference.

A two-part medical illustration depicting the pathophysiology of the Hypothalamic-Pituitary-Thyroid (HPT) axis and cellular thyroid hormone action. Section (a) shows the systemic HPT axis, beginning with the cerebral cortex and hypothalamus. The hypothalamus releases thyrotropin-releasing hormone (TRH), which stimulates the pituitary gland to secrete thyroid-stimulating hormone (TSH). TSH subsequently acts on the thyroid gland to stimulate the production of T4 and T3 hormones, which exert negative feedback on the hypothalamus and pituitary. Section (b) details the intracellular mechanism of action within a target cell. T4 and T3 enter the cell via thyroid hormone transporters. In the cytoplasm, deiodinases (D1/D2) convert T4 to T3, while D3 converts T4 to inactive reverse T3 (rT3). T3 enters the nucleus, binding to the thyroid hormone receptor (TR) which heterodimerizes with the retinoid X receptor (RXR). This complex binds to the thyroid hormone response element (TRE) on DNA, displacing corepressors and recruiting coactivators to initiate gene transcription (mRNA) and subsequent protein synthesis. The diagram also highlights potential sites of endocrine disruption (e.g., by Tributyltin/TBT), including receptor inhibition and deiodinase interference.

Reading File
Searching Images

myxedema pretibial edema hypothyroidism skin

Clinical photograph of the bilateral feet and ankles of a patient with primary hypothyroidism. The image demonstrates significant dermatological and soft tissue manifestations associated with myxedema. Both ankles and the pretibial regions show non-pitting edema (malleolar edema), characterized by swelling and a thickened, pale, and waxy skin appearance with prominent transverse skin creases. The hallux (big toe) on both feet displays advanced nail dystrophy, including thickening of the nail plate, rough texture, and marked discoloration with yellowish and dark-pigmented areas. The skin appears thin and fragile with evidence of xeroderma (dry skin). These visual findings are classic clinical indicators of endocrine-related cutaneous changes, specifically reflecting the systemic effects of thyroid hormone deficiency on connective tissue and integumentary health. The photograph serves as an educational example of how systemic metabolic diseases can present with localized distal extremity findings like myxedematous edema and onychodystrophy.

Clinical photograph of the bilateral feet and ankles of a patient with primary hypothyroidism. The image demonstrates significant dermatological and soft tissue manifestations associated with myxedema. Both ankles and the pretibial regions show non-pitting edema (malleolar edema), characterized by swelling and a thickened, pale, and waxy skin appearance with prominent transverse skin creases. The hallux (big toe) on both feet displays advanced nail dystrophy, including thickening of the nail plate, rough texture, and marked discoloration with yellowish and dark-pigmented areas. The skin appears thin and fragile with evidence of xeroderma (dry skin). These visual findings are classic clinical indicators of endocrine-related cutaneous changes, specifically reflecting the systemic effects of thyroid hormone deficiency on connective tissue and integumentary health. The photograph serves as an educational example of how systemic metabolic diseases can present with localized distal extremity findings like myxedematous edema and onychodystrophy.

This composite of three clinical photographs displays the systemic physical manifestations of severe hypothyroidism, specifically myxedema. Image (a) is a facial photograph showing generalized periorbital and facial puffiness (myxedematous facies) and thinning of the lateral eyebrows (Queen Anne's sign). The patient is intubated, with medical stabilization equipment and digital obscuration of the eyes and mouth present. Images (b) and (c) illustrate the lower extremities, demonstrating severe, systemic non-pitting edema. The skin on the legs and feet appears thickened, doughy, and markedly wrinkled with deep cutaneous folds around the ankles, characteristic of mucopolysaccharide deposition in the dermis. There is noticeable erythema of the feet, scattered petechiae or small blemishes, and a localized hypopigmented patch on the right pretibial region. These findings are clinically diagnostic of myxedema coma presentation in an endocrine emergency context.

This composite of three clinical photographs displays the systemic physical manifestations of severe hypothyroidism, specifically myxedema. Image (a) is a facial photograph showing generalized periorbital and facial puffiness (myxedematous facies) and thinning of the lateral eyebrows (Queen Anne's sign). The patient is intubated, with medical stabilization equipment and digital obscuration of the eyes and mouth present. Images (b) and (c) illustrate the lower extremities, demonstrating severe, systemic non-pitting edema. The skin on the legs and feet appears thickened, doughy, and markedly wrinkled with deep cutaneous folds around the ankles, characteristic of mucopolysaccharide deposition in the dermis. There is noticeable erythema of the feet, scattered petechiae or small blemishes, and a localized hypopigmented patch on the right pretibial region. These findings are clinically diagnostic of myxedema coma presentation in an endocrine emergency context.

Loading Image
Reading File
Running Command

mkdir -p /tmp/workspace/hypothyroidism-ppt && ls /tmp/workspace/

Writing File

~/hypothyroidism-ppt/create_ppt.py

import subprocess, json, base64
from io import BytesIO
from pptx import Presentation
from pptx.util import Inches, Pt, Emu
from pptx.dml.color import RGBColor
from pptx.enum.text import PP_ALIGN, MSO_ANCHOR
from pptx.oxml.ns import qn
from lxml import etree

# ── Palette ──────────────────────────────────────────────────────────────
DARK_BLUE   = RGBColor(0x0D, 0x47, 0xA1)   # deep royal blue
MID_BLUE    = RGBColor(0x15, 0x65, 0xC0)
TEAL        = RGBColor(0x00, 0x89, 0x7B)
AMBER       = RGBColor(0xFF, 0x8F, 0x00)
RED         = RGBColor(0xC6, 0x28, 0x28)
ORANGE      = RGBColor(0xE6, 0x51, 0x00)
PURPLE      = RGBColor(0x6A, 0x1B, 0x9A)
GREEN       = RGBColor(0x2E, 0x7D, 0x32)
WHITE       = RGBColor(0xFF, 0xFF, 0xFF)
LIGHT_GRAY  = RGBColor(0xF5, 0xF7, 0xFA)
DARK_TEXT   = RGBColor(0x21, 0x21, 0x21)
YELLOW_ACC  = RGBColor(0xFF, 0xD6, 0x00)

def hex_to_rgb(h):
    h = h.lstrip('#')
    return RGBColor(int(h[0:2],16), int(h[2:4],16), int(h[4:6],16))

# ── Helper: fill shape background ────────────────────────────────────────
def fill_shape(shape, color: RGBColor):
    sp = shape._element
    spPr = sp.find(qn('p:spPr'))
    if spPr is None:
        spPr = etree.SubElement(sp, qn('p:spPr'))
    solidFill = etree.SubElement(spPr, qn('a:solidFill'))
    srgbClr = etree.SubElement(solidFill, qn('a:srgbClr'))
    srgbClr.set('val', f'{color[0]:02X}{color[1]:02X}{color[2]:02X}')

def add_rect(slide, x, y, w, h, color: RGBColor, radius=0):
    shape = slide.shapes.add_shape(1, Inches(x), Inches(y), Inches(w), Inches(h))
    shape.line.fill.background()
    fill_shape(shape, color)
    return shape

def add_textbox(slide, x, y, w, h, text, font_size=16, bold=False,
                color=DARK_TEXT, align=PP_ALIGN.LEFT, wrap=True, italic=False):
    tb = slide.shapes.add_textbox(Inches(x), Inches(y), Inches(w), Inches(h))
    tf = tb.text_frame
    tf.word_wrap = wrap
    tf.margin_left = Pt(2)
    tf.margin_right = Pt(2)
    tf.margin_top = Pt(1)
    tf.margin_bottom = Pt(1)
    p = tf.paragraphs[0]
    p.alignment = align
    run = p.add_run()
    run.text = text
    run.font.size = Pt(font_size)
    run.font.bold = bold
    run.font.italic = italic
    run.font.color.rgb = color
    run.font.name = "Calibri"
    return tb

def add_bullet_textbox(slide, x, y, w, h, items, font_size=13, bullet_color=DARK_BLUE,
                        text_color=DARK_TEXT, title=None, title_size=15, title_color=DARK_BLUE):
    tb = slide.shapes.add_textbox(Inches(x), Inches(y), Inches(w), Inches(h))
    tf = tb.text_frame
    tf.word_wrap = True
    tf.margin_left = Pt(4)
    tf.margin_right = Pt(2)
    tf.margin_top = Pt(2)
    tf.margin_bottom = Pt(2)
    first = True
    if title:
        p = tf.paragraphs[0] if first else tf.add_paragraph()
        first = False
        run = p.add_run()
        run.text = title
        run.font.size = Pt(title_size)
        run.font.bold = True
        run.font.color.rgb = title_color
        run.font.name = "Calibri"
    for item in items:
        p = tf.paragraphs[0] if (first and not title) else tf.add_paragraph()
        first = False
        run = p.add_run()
        run.text = f"  \u2022  {item}"
        run.font.size = Pt(font_size)
        run.font.color.rgb = text_color
        run.font.name = "Calibri"
    return tb

# ── Download images ───────────────────────────────────────────────────────
IMAGE_URLS = {
    "signs_diagram": "https://cdn.orris.care/cdss_images/053b9bb265b63714c4a536636d315c8c10972d68fe82e00691f22c7acff56972.png",
    "hpt_axis":      "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_6f82970f9f7319e651f853444406dd2b35b7feffc3334ebb3c549f9b030a044f.jpg",
    "myxedema_face": "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_004376e56882f1544f2c61db75df95bbb940d303665f105b602921ddef336433.jpg",
    "congenital":    "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_21eff5b66b62dfc0c59899e9eba5d20699765566b7e304af716c2a545b1b97ff.jpg",
    "myxedema_legs": "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_5ca4d51c24fef39d7592d3972d48133127a4ef92b28178dcc0aec50ff6784604.jpg",
}

result = json.loads(subprocess.check_output(
    ["python", "/tmp/skills/shared/scripts/fetch_images.py"] + list(IMAGE_URLS.values())
))
img_data = {}
for key, res in zip(IMAGE_URLS.keys(), result):
    if res.get("base64"):
        raw_b64 = res["base64"]
        if "," in raw_b64:
            raw_b64 = raw_b64.split(",",1)[1]
        img_data[key] = base64.b64decode(raw_b64)
    else:
        img_data[key] = None
print("Images fetched:", {k: (v is not None) for k, v in img_data.items()})

def add_image_from_bytes(slide, img_bytes, x, y, w, h=None):
    if img_bytes is None:
        return
    buf = BytesIO(img_bytes)
    if h:
        slide.shapes.add_picture(buf, Inches(x), Inches(y), Inches(w), Inches(h))
    else:
        slide.shapes.add_picture(buf, Inches(x), Inches(y), Inches(w))

# ── Build presentation ────────────────────────────────────────────────────
prs = Presentation()
prs.slide_width  = Inches(13.333)
prs.slide_height = Inches(7.5)
blank = prs.slide_layouts[6]

# ═══════════════════════════════════════════════════════
# SLIDE 1 — Title Slide
# ═══════════════════════════════════════════════════════
s = prs.slides.add_slide(blank)

# Full background
add_rect(s, 0, 0, 13.333, 7.5, DARK_BLUE)

# Decorative accent stripe
add_rect(s, 0, 5.8, 13.333, 0.08, AMBER)
add_rect(s, 0, 5.88, 13.333, 0.04, WHITE)

# Title
add_textbox(s, 0.5, 1.0, 12.333, 1.5, "HYPOTHYROIDISM",
            font_size=58, bold=True, color=WHITE, align=PP_ALIGN.CENTER)
add_textbox(s, 0.5, 2.6, 12.333, 0.8,
            "Clinical Features  |  Investigations  |  Management",
            font_size=22, bold=False, color=YELLOW_ACC, align=PP_ALIGN.CENTER)

# Divider
add_rect(s, 3.5, 3.55, 6.3, 0.05, AMBER)

# Subtitle block
add_textbox(s, 0.5, 3.75, 12.333, 0.5,
            "An Underactive Thyroid — A Hypometabolic State",
            font_size=17, bold=False, color=RGBColor(0xBB, 0xDE, 0xFB),
            align=PP_ALIGN.CENTER, italic=True)

# Student info
add_textbox(s, 0.5, 4.6, 12.333, 0.5,
            "Presented by: Mokshit Panwar   |   Roll No. 68",
            font_size=16, bold=True, color=WHITE, align=PP_ALIGN.CENTER)
add_textbox(s, 0.5, 5.1, 12.333, 0.4,
            "Reference: Tintinalli's Emergency Medicine  |  Textbook of Family Medicine 9e",
            font_size=12, color=RGBColor(0xBB, 0xDE, 0xFB), align=PP_ALIGN.CENTER)

# ═══════════════════════════════════════════════════════
# SLIDE 2 — Definition & Classification
# ═══════════════════════════════════════════════════════
s = prs.slides.add_slide(blank)
add_rect(s, 0, 0, 13.333, 7.5, LIGHT_GRAY)
add_rect(s, 0, 0, 13.333, 1.0, DARK_BLUE)
add_rect(s, 0, 0.97, 13.333, 0.055, AMBER)

add_textbox(s, 0.3, 0.1, 12, 0.75, "Definition & Classification",
            font_size=30, bold=True, color=WHITE)

# Definition box
add_rect(s, 0.3, 1.2, 12.7, 1.3, MID_BLUE)
add_textbox(s, 0.4, 1.25, 12.5, 1.2,
            "Hypothyroidism is a hypometabolic state resulting from insufficient levels of circulating thyroid hormone to meet body requirements. "
            "Serum TSH > 10 mIU/L (overt); 4-10 mIU/L with normal T4 = Subclinical. "
            "Prevalence: 0.3-3.7% in USA. 10x more common in females.",
            font_size=13.5, color=WHITE, wrap=True)

# Three columns
cols = [
    ("PRIMARY\nHypothyroidism", TEAL,
     ["Hashimoto's thyroiditis (MC in developed world)",
      "Iodine deficiency (MC worldwide)",
      "Post-thyroidectomy / Radioiodine ablation",
      "Drugs: Lithium, Amiodarone, Sunitinib",
      "Infiltrative: Lymphoma, Sarcoidosis, TB",
      "Thyroiditis (postpartum, subacute)"]),
    ("SECONDARY\nHypothyroidism", PURPLE,
     ["Pituitary adenoma / Panhypopituitarism",
      "Hypothalamic tumor",
      "CNS infection / irradiation",
      "Infiltrative (hemochromatosis, sarcoidosis)",
      "Low/absent TSH with low FT4",
      "(Also called Central Hypothyroidism)"]),
    ("SPECIAL FORMS", ORANGE,
     ["Congenital hypothyroidism (Cretinism)",
      "Subclinical hypothyroidism",
      "Myxedema coma (severe decompensation)",
      "Euthyroid sick syndrome",
      "Drug-induced hypothyroidism",
      "Transient (postpartum thyroiditis)"]),
]
col_x = [0.3, 4.55, 8.8]
for i, (title, color, items) in enumerate(cols):
    add_rect(s, col_x[i], 2.6, 4.1, 4.5, color)
    add_textbox(s, col_x[i]+0.1, 2.65, 3.9, 0.7, title,
                font_size=14, bold=True, color=WHITE, align=PP_ALIGN.CENTER)
    add_bullet_textbox(s, col_x[i]+0.1, 3.35, 3.85, 3.5, items,
                       font_size=11.5, text_color=WHITE, bullet_color=WHITE)

# ═══════════════════════════════════════════════════════
# SLIDE 3 — Pathophysiology (HPT axis)
# ═══════════════════════════════════════════════════════
s = prs.slides.add_slide(blank)
add_rect(s, 0, 0, 13.333, 7.5, LIGHT_GRAY)
add_rect(s, 0, 0, 13.333, 1.0, TEAL)
add_rect(s, 0, 0.97, 13.333, 0.055, AMBER)
add_textbox(s, 0.3, 0.1, 12, 0.75, "Pathophysiology — HPT Axis",
            font_size=30, bold=True, color=WHITE)

# HPT axis image on the right
if img_data.get("hpt_axis"):
    add_image_from_bytes(s, img_data["hpt_axis"], 7.2, 1.1, 5.8, 5.9)

# Pathway boxes on the left
steps = [
    (DARK_BLUE, "HYPOTHALAMUS", "Releases TRH (Thyrotropin-Releasing Hormone)"),
    (MID_BLUE,  "PITUITARY",    "TRH stimulates TSH secretion"),
    (TEAL,      "THYROID GLAND","TSH stimulates T4 (90%) & T3 (10%) production"),
    (GREEN,     "PERIPHERY",    "T4 → T3 (active form, 3-4x more potent) via deiodinase"),
    (RED,       "FEEDBACK",     "T3/T4 inhibit TRH & TSH (negative feedback loop)"),
    (ORANGE,    "IN HYPOTHYROIDISM", "↓T4/T3 → ↑TSH (Primary) or ↓TSH (Secondary/Central)"),
]
y = 1.1
for color, title, text in steps:
    add_rect(s, 0.3, y, 6.5, 0.78, color)
    add_textbox(s, 0.4, y+0.02, 2.0, 0.7, title, font_size=11, bold=True, color=WHITE)
    add_textbox(s, 2.45, y+0.05, 4.3, 0.68, text, font_size=11.5, color=WHITE, wrap=True)
    y += 0.85

# ═══════════════════════════════════════════════════════
# SLIDE 4 — Clinical Features (with body diagram)
# ═══════════════════════════════════════════════════════
s = prs.slides.add_slide(blank)
add_rect(s, 0, 0, 13.333, 7.5, LIGHT_GRAY)
add_rect(s, 0, 0, 13.333, 1.0, RED)
add_rect(s, 0, 0.97, 13.333, 0.055, AMBER)
add_textbox(s, 0.3, 0.1, 12, 0.75, "Clinical Features of Hypothyroidism",
            font_size=30, bold=True, color=WHITE)

# Body diagram (signs & symptoms) image
if img_data.get("signs_diagram"):
    add_image_from_bytes(s, img_data["signs_diagram"], 4.5, 1.05, 4.3, 5.8)

# Left panel — Symptoms
add_rect(s, 0.2, 1.1, 4.0, 5.8, DARK_BLUE)
add_textbox(s, 0.3, 1.15, 3.8, 0.45, "SYMPTOMS", font_size=16, bold=True,
            color=YELLOW_ACC, align=PP_ALIGN.CENTER)
symptoms = [
    "Fatigue & lethargy",
    "Weight gain",
    "Cold intolerance",
    "Depression",
    "Hair loss / coarse hair",
    "Constipation",
    "Menstrual irregularities",
    "Infertility",
    "Muscle cramps",
    "Joint pain",
    "Shortness of breath",
    "Memory impairment",
    "Dry skin",
]
add_bullet_textbox(s, 0.25, 1.62, 3.85, 5.0, symptoms, font_size=11.5, text_color=WHITE)

# Right panel — Signs
add_rect(s, 9.0, 1.1, 4.1, 5.8, PURPLE)
add_textbox(s, 9.1, 1.15, 3.9, 0.45, "SIGNS", font_size=16, bold=True,
            color=YELLOW_ACC, align=PP_ALIGN.CENTER)
signs = [
    "Periorbital puffiness",
    "Loss of outer 1/3 eyebrow",
    "Macroglossia",
    "Hoarseness of voice",
    "Goitre (in Hashimoto's)",
    "Bradycardia",
    "Non-pitting edema (myxedema)",
    "Delayed ankle jerks",
    "Pallor / carotenemia",
    "Dry, rough, cool skin",
    "Peripheral neuropathy",
    "Hypoventilation",
    "Hypothermia",
]
add_bullet_textbox(s, 9.05, 1.62, 3.95, 5.0, signs, font_size=11.5, text_color=WHITE)

# ═══════════════════════════════════════════════════════
# SLIDE 5 — Clinical Photos
# ═══════════════════════════════════════════════════════
s = prs.slides.add_slide(blank)
add_rect(s, 0, 0, 13.333, 7.5, LIGHT_GRAY)
add_rect(s, 0, 0, 13.333, 1.0, ORANGE)
add_rect(s, 0, 0.97, 13.333, 0.055, DARK_BLUE)
add_textbox(s, 0.3, 0.1, 12, 0.75, "Clinical Photographs",
            font_size=30, bold=True, color=WHITE)

# 3 photos
photos = [
    ("myxedema_face", "Myxedematous Facies\nPeriorbital puffiness, pallor,\nsparse lateral eyebrows", 0.3),
    ("congenital",    "Congenital Hypothyroidism\nMacroglossia, abdominal distension,\numbilical hernia. Before vs After Rx", 4.6),
    ("myxedema_legs", "Pretibial Myxedema\nNon-pitting edema, waxy skin,\nankle swelling & nail dystrophy", 8.9),
]
for key, caption, x in photos:
    if img_data.get(key):
        add_image_from_bytes(s, img_data[key], x, 1.1, 4.1, 4.6)
    add_rect(s, x, 5.75, 4.1, 1.5, DARK_BLUE)
    add_textbox(s, x+0.05, 5.78, 4.0, 1.4, caption, font_size=11, color=WHITE,
                align=PP_ALIGN.CENTER, wrap=True)

# ═══════════════════════════════════════════════════════
# SLIDE 6 — Investigations
# ═══════════════════════════════════════════════════════
s = prs.slides.add_slide(blank)
add_rect(s, 0, 0, 13.333, 7.5, LIGHT_GRAY)
add_rect(s, 0, 0, 13.333, 1.0, GREEN)
add_rect(s, 0, 0.97, 13.333, 0.055, AMBER)
add_textbox(s, 0.3, 0.1, 12, 0.75, "Investigations",
            font_size=30, bold=True, color=WHITE)

inv_sections = [
    (MID_BLUE, "THYROID FUNCTION TESTS (1st Line)", [
        "Serum TSH — MOST SENSITIVE; >10 mIU/L = Overt Hypothyroidism",
        "Free T4 (FT4) — Low in primary hypothyroidism",
        "Free T3 (FT3) — Low; less commonly used",
        "TSH + FT4 together confirm primary vs secondary",
        "Subclinical: TSH 4-10 mIU/L + Normal FT4",
    ]),
    (TEAL, "AUTOIMMUNE MARKERS", [
        "TPO Antibodies (Anti-thyroid peroxidase) — Elevated in Hashimoto's",
        "Anti-thyroglobulin Antibodies (Tg Abs) — Also elevated",
        "ANA — May be positive in autoimmune thyroiditis",
    ]),
    (PURPLE, "HAEMATOLOGY & BIOCHEMISTRY", [
        "CBC — Normocytic / macrocytic anaemia",
        "Serum cholesterol & triglycerides — Elevated (hyperlipidaemia)",
        "CK (creatine kinase) — Elevated (myopathy)",
        "Serum sodium — Hyponatraemia (↑ADH)",
        "Blood glucose — Hypoglycaemia possible",
        "ABG — Hypoxaemia, hypercapnia, respiratory acidosis",
    ]),
    (ORANGE, "IMAGING & SPECIAL TESTS", [
        "Thyroid Ultrasound — Assess gland size; echogenicity in Hashimoto's",
        "Radioiodine (¹²³I) scan — Hot vs cold nodule evaluation",
        "ECG — Low voltage, bradycardia, prolonged QT",
        "CXR / Echo — Pericardial / pleural effusion, cardiomegaly",
        "Newborn Screening — TSH on day 3-5 (heel-prick test)",
    ]),
]

x_pos = [0.2, 6.75, 0.2, 6.75]
y_pos = [1.1, 1.1, 4.3, 4.3]
widths = [6.3, 6.3, 6.3, 6.3]
heights = [2.9, 2.9, 2.9, 2.9]

for i, (color, title, items) in enumerate(inv_sections):
    add_rect(s, x_pos[i], y_pos[i], widths[i], heights[i], color)
    add_textbox(s, x_pos[i]+0.1, y_pos[i]+0.05, widths[i]-0.2, 0.45,
                title, font_size=13, bold=True, color=YELLOW_ACC)
    add_bullet_textbox(s, x_pos[i]+0.1, y_pos[i]+0.5, widths[i]-0.2, heights[i]-0.55,
                       items, font_size=11.5, text_color=WHITE)

# ═══════════════════════════════════════════════════════
# SLIDE 7 — Management
# ═══════════════════════════════════════════════════════
s = prs.slides.add_slide(blank)
add_rect(s, 0, 0, 13.333, 7.5, LIGHT_GRAY)
add_rect(s, 0, 0, 13.333, 1.0, DARK_BLUE)
add_rect(s, 0, 0.97, 13.333, 0.055, AMBER)
add_textbox(s, 0.3, 0.1, 12, 0.75, "Management",
            font_size=30, bold=True, color=WHITE)

mgmt_sections = [
    (TEAL, "LEVOTHYROXINE (T4) — Drug of Choice", [
        "Average replacement dose: 1.6 µg/kg/day orally",
        "Start low (25-50 µg/day) — especially elderly & cardiac patients",
        "Titrate every 6-8 weeks based on TSH levels",
        "Therapeutic target: TSH 0.5-2.5 mIU/L",
        "Take on empty stomach (30 min before meals)",
        "Interactions: antacids, iron, calcium reduce absorption",
    ]),
    (MID_BLUE, "MONITORING & TARGETS", [
        "Check TSH every 6-8 weeks after dose change",
        "Once stable, annual TSH monitoring",
        "Maintain TSH > 1.0 mIU/L to prevent iatrogenic hyperthyroidism",
        "T4 + T3 combination if T4 resistant (controversial)",
        "Liothyronine (T3): less preferred due to cardiac risks",
    ]),
    (GREEN, "SPECIAL POPULATIONS", [
        "Pregnancy: Increase dose by 30-50%; TSH target <2.5 mIU/L",
        "Elderly / cardiac disease: Start 12.5-25 µg/day, increase slowly",
        "Congenital hypothyroidism: Start within 2 weeks (prevent cretinism)",
        "Subclinical: Treat if TSH >10, or symptomatic / pregnant",
        "Central hypothyroidism: Replace corticosteroids FIRST, then T4",
    ]),
    (RED, "MYXEDEMA CRISIS / COMA — EMERGENCY", [
        "ICU admission, airway control, cardiac monitoring",
        "IV Levothyroxine: 200-400 µg loading dose, then 100 µg/day",
        "IV Hydrocortisone 100-200 mg (adrenal insufficiency)",
        "Passive rewarming for hypothermia",
        "Correct hypoglycemia (IV dextrose), hyponatraemia (water restrict)",
        "Mortality 30-60% — Identify and treat precipitating cause",
    ]),
]

x_pos2 = [0.2, 6.75, 0.2, 6.75]
y_pos2 = [1.1, 1.1, 4.3, 4.3]

for i, (color, title, items) in enumerate(mgmt_sections):
    add_rect(s, x_pos2[i], y_pos2[i], 6.3, 2.9, color)
    add_textbox(s, x_pos2[i]+0.1, y_pos2[i]+0.05, 6.1, 0.45,
                title, font_size=13, bold=True, color=YELLOW_ACC)
    add_bullet_textbox(s, x_pos2[i]+0.1, y_pos2[i]+0.5, 6.1, 2.35,
                       items, font_size=11.5, text_color=WHITE)

# ═══════════════════════════════════════════════════════
# SLIDE 8 — Subclinical & Congenital Hypothyroidism
# ═══════════════════════════════════════════════════════
s = prs.slides.add_slide(blank)
add_rect(s, 0, 0, 13.333, 7.5, LIGHT_GRAY)
add_rect(s, 0, 0, 13.333, 1.0, PURPLE)
add_rect(s, 0, 0.97, 13.333, 0.055, AMBER)
add_textbox(s, 0.3, 0.1, 12, 0.75, "Subclinical & Congenital Hypothyroidism",
            font_size=28, bold=True, color=WHITE)

# Left — Subclinical
add_rect(s, 0.2, 1.15, 6.3, 5.9, DARK_BLUE)
add_textbox(s, 0.3, 1.2, 6.1, 0.5, "SUBCLINICAL HYPOTHYROIDISM",
            font_size=15, bold=True, color=YELLOW_ACC)
sub_items = [
    "Definition: TSH 4-10 mIU/L + Normal FT4, minimal or no symptoms",
    "Prevalence: 4-15% women (higher in elderly)",
    "Risk of progression to overt: ~2-5% per year",
    "TREAT if: TSH >10, symptoms present, pregnant, or with dyslipidaemia",
    "Monitor annually if TSH 4-10 mIU/L + asymptomatic",
    "Associated with: hyperlipidaemia, atherosclerosis risk",
    "Dose: Low-dose levothyroxine, target TSH 1-2.5 mIU/L",
]
add_bullet_textbox(s, 0.3, 1.75, 6.1, 5.0, sub_items, font_size=12, text_color=WHITE)

# Right — Congenital
add_rect(s, 6.75, 1.15, 6.35, 5.9, TEAL)
add_textbox(s, 6.85, 1.2, 6.15, 0.5, "CONGENITAL HYPOTHYROIDISM (Cretinism)",
            font_size=15, bold=True, color=YELLOW_ACC)
cong_items = [
    "Most common preventable cause of intellectual disability",
    "Incidence: 1 in 3,000-4,000 live births",
    "Cause: Thyroid dysgenesis (MC), iodine deficiency, enzyme defects",
    "Screened at birth: TSH heel-prick on day 3-5",
    "Features: Coarse facies, macroglossia, umbilical hernia, jaundice",
    "   Hypotonia, feeding difficulties, abdominal distension",
    "   Hoarse cry, cold/mottled skin, large posterior fontanelle",
    "Bone: Delayed ossification, short stature if untreated",
    "TREATMENT: Levothyroxine ASAP (within 2 weeks of birth)",
    "Target: TSH <5 mIU/L; FT4 upper half of normal range",
    "Prognosis: Excellent if treated early",
]
add_bullet_textbox(s, 6.85, 1.75, 6.1, 5.0, cong_items, font_size=12, text_color=WHITE)

# ═══════════════════════════════════════════════════════
# SLIDE 9 — Summary / Key Points
# ═══════════════════════════════════════════════════════
s = prs.slides.add_slide(blank)
add_rect(s, 0, 0, 13.333, 7.5, DARK_BLUE)
add_rect(s, 0, 0.97, 13.333, 0.055, AMBER)
add_textbox(s, 0.3, 0.1, 12, 0.75, "Key Points — Remember This!",
            font_size=30, bold=True, color=WHITE)

keypoints = [
    (AMBER,  "MC Cause",       "Hashimoto's thyroiditis (autoimmune) in developed world\nIodine deficiency — worldwide MC cause"),
    (TEAL,   "Best Test",      "Serum TSH — Most sensitive screening test\nFT4 — Confirms and classifies severity"),
    (GREEN,  "Cardinal Signs", "Periorbital puffiness, delayed ankle jerk,\nnon-pitting edema, loss of outer 1/3 eyebrow"),
    (RED,    "Emergency",      "Myxedema coma: IV Levothyroxine 200-400 µg\n+ Hydrocortisone 100-200 mg IV — Mortality 30-60%"),
    (PURPLE, "Treatment",      "Levothyroxine 1.6 µg/kg/day\nMonitor TSH every 6-8 weeks until stable, then annually"),
    (ORANGE, "Avoid",          "Don't miss congenital hypothyroidism — screen day 3-5!\nDon't treat central hypothyroidism without replacing steroids first"),
]

x_pos3 = [0.2, 4.55, 8.9, 0.2, 4.55, 8.9]
y_pos3 = [1.1, 1.1, 1.1, 4.3, 4.3, 4.3]

for i, (color, title, text) in enumerate(keypoints):
    add_rect(s, x_pos3[i], y_pos3[i], 4.1, 2.9, color)
    add_textbox(s, x_pos3[i]+0.1, y_pos3[i]+0.05, 3.9, 0.5,
                title, font_size=14, bold=True, color=WHITE)
    add_textbox(s, x_pos3[i]+0.1, y_pos3[i]+0.6, 3.9, 2.1,
                text, font_size=12.5, color=WHITE, wrap=True)

# ── Save ──────────────────────────────────────────────────────────────────
out_path = "/tmp/workspace/hypothyroidism-ppt/Hypothyroidism_Mokshit_Panwar_Roll68.pptx"
prs.save(out_path)
print(f"Saved: {out_path}")
Running Command

cd /tmp/workspace/hypothyroidism-ppt && python create_ppt.py 2>&1

Finding Files

**/fetch_images.py in /tmp/skills

Running Command

python /tmp/skills/shared/scripts/fetch_images.py "https://cdn.orris.care/cdss_images/053b9bb265b63714c4a536636d315c8c10972d68fe82e00691f22c7acff56972.png" 2>&1 | head -5

Running Command

ls /tmp/skills/shared/scripts/

Running Command

ls /tmp/workspace/hypothyroidism-ppt/

Running Command

cd /tmp/workspace/hypothyroidism-ppt && python create_ppt.py 2>&1

All 5 images fetched successfully and the file is saved. Here's your download link:

Hypothyroidism Mokshit Panwar Roll68

Presentation · PPTX


What's inside the 9-slide deck:
SlideContent
1Title slide - Mokshit Panwar, Roll No. 68
2Definition & Classification (Primary / Secondary / Special forms)
3Pathophysiology with HPT axis diagram
4Clinical Features with the full-body signs diagram
5Clinical Photographs (myxedematous face, pretibial myxedema, congenital hypothyroidism)
6Investigations (4 colour-coded boxes: TFTs, Autoimmune, Biochemistry, Imaging)
7Management (Levothyroxine dosing, monitoring, special populations, myxedema crisis)
8Subclinical & Congenital Hypothyroidism
9Key Points summary

Make a pdf but more suitable for class presentation

Reading File
Reading File
Reading File
Reading File
Reading File
Writing File

~/hypothyroidism-ppt/create_pdf.py

"""
Hypothyroidism - Presentation-style PDF
Landscape A4, colorful, large fonts, one topic per page.
Uses ReportLab + fetched images.
"""
import subprocess, json, base64
from io import BytesIO
from reportlab.lib.pagesizes import A4, landscape
from reportlab.lib import colors
from reportlab.lib.units import cm, mm
from reportlab.pdfgen import canvas
from reportlab.platypus import Paragraph, SimpleDocTemplate, Table, TableStyle, Spacer, Image as RLImage
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_RIGHT
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
from PIL import Image as PILImage

PAGE_W, PAGE_H = landscape(A4)   # 841.9 x 595.3 pt

# ── Palette ─────────────────────────────────────────────
DARK_BLUE   = colors.HexColor("#0D47A1")
MID_BLUE    = colors.HexColor("#1565C0")
TEAL        = colors.HexColor("#00897B")
AMBER       = colors.HexColor("#FF8F00")
RED         = colors.HexColor("#C62828")
ORANGE      = colors.HexColor("#E65100")
PURPLE      = colors.HexColor("#6A1B9A")
GREEN       = colors.HexColor("#2E7D32")
WHITE       = colors.white
LIGHT_GRAY  = colors.HexColor("#F5F7FA")
DARK_TEXT   = colors.HexColor("#212121")
YELLOW_ACC  = colors.HexColor("#FFD600")
INDIGO      = colors.HexColor("#283593")
CYAN        = colors.HexColor("#006064")

# ── Fetch images ─────────────────────────────────────────
IMAGE_URLS = {
    "signs_diagram": "https://cdn.orris.care/cdss_images/053b9bb265b63714c4a536636d315c8c10972d68fe82e00691f22c7acff56972.png",
    "hpt_axis":      "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_6f82970f9f7319e651f853444406dd2b35b7feffc3334ebb3c549f9b030a044f.jpg",
    "myxedema_face": "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_004376e56882f1544f2c61db75df95bbb940d303665f105b602921ddef336433.jpg",
    "congenital":    "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_21eff5b66b62dfc0c59899e9eba5d20699765566b7e304af716c2a545b1b97ff.jpg",
    "myxedema_legs": "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_5ca4d51c24fef39d7592d3972d48133127a4ef92b28178dcc0aec50ff6784604.jpg",
}

result = json.loads(subprocess.check_output(
    ["python", "/tmp/skills/shared/scripts/fetch_images.py"] + list(IMAGE_URLS.values())
))
img_data = {}
for key, res in zip(IMAGE_URLS.keys(), result):
    if res.get("base64"):
        raw = res["base64"]
        if "," in raw:
            raw = raw.split(",", 1)[1]
        img_data[key] = base64.b64decode(raw)
    else:
        img_data[key] = None
print("Images fetched:", {k: (v is not None) for k, v in img_data.items()})

def img_buf(key):
    """Return a BytesIO for the image, or None."""
    return BytesIO(img_data[key]) if img_data.get(key) else None

# ── Canvas helpers ────────────────────────────────────────
def full_bg(c, color):
    c.setFillColor(color)
    c.rect(0, 0, PAGE_W, PAGE_H, fill=1, stroke=0)

def header_bar(c, color, height_pt=62, accent=AMBER, accent_h=4):
    c.setFillColor(color)
    c.rect(0, PAGE_H - height_pt, PAGE_W, height_pt, fill=1, stroke=0)
    c.setFillColor(accent)
    c.rect(0, PAGE_H - height_pt - accent_h, PAGE_W, accent_h, fill=1, stroke=0)

def slide_title(c, text, color=WHITE, y_top=None, font_size=30):
    if y_top is None:
        y_top = PAGE_H - 50
    c.setFillColor(color)
    c.setFont("Helvetica-Bold", font_size)
    c.drawString(18, y_top, text)

def footer_bar(c, text="Hypothyroidism  |  Mokshit Panwar  |  Roll No. 68",
               bg=DARK_BLUE, fg=WHITE):
    c.setFillColor(bg)
    c.rect(0, 0, PAGE_W, 22, fill=1, stroke=0)
    c.setFillColor(fg)
    c.setFont("Helvetica", 8)
    c.drawCentredString(PAGE_W/2, 7, text)

def colored_box(c, x, y, w, h, bg, radius=6):
    c.setFillColor(bg)
    c.roundRect(x, y, w, h, radius, fill=1, stroke=0)

def box_title(c, x, y_top, w, text, bg, font_size=13, fg=WHITE):
    c.setFillColor(bg)
    c.rect(x, y_top - 22, w, 22, fill=1, stroke=0)
    c.setFillColor(fg)
    c.setFont("Helvetica-Bold", font_size)
    c.drawString(x + 6, y_top - 16, text)

def bullet_lines(c, x, y, w, lines, font_size=10.5, color=DARK_TEXT, line_h=15):
    c.setFont("Helvetica", font_size)
    c.setFillColor(color)
    for line in lines:
        if y < 30:
            break
        c.drawString(x, y, line)
        y -= line_h
    return y

def draw_image(c, key, x, y, max_w, max_h):
    buf = img_buf(key)
    if buf is None:
        return
    try:
        pil = PILImage.open(buf)
        iw, ih = pil.size
        buf.seek(0)
        scale = min(max_w / iw, max_h / ih)
        dw, dh = iw * scale, ih * scale
        # centre within allocation
        ox = x + (max_w - dw) / 2
        oy = y + (max_h - dh) / 2
        c.drawImage(
            pil_to_rl(buf, pil.format or "PNG"),
            ox, oy, dw, dh,
            preserveAspectRatio=True, mask='auto'
        )
    except Exception as e:
        print(f"Image draw error ({key}): {e}")

def pil_to_rl(buf, fmt):
    """Return a ReportLab ImageReader from a BytesIO."""
    from reportlab.lib.utils import ImageReader
    buf.seek(0)
    return ImageReader(buf)

OUT = "/tmp/workspace/hypothyroidism-ppt/Hypothyroidism_Mokshit_Panwar_Roll68.pdf"
c = canvas.Canvas(OUT, pagesize=landscape(A4))
c.setTitle("Hypothyroidism – Mokshit Panwar Roll 68")
c.setAuthor("Mokshit Panwar")

CONTENT_TOP    = PAGE_H - 70   # just below header bar
CONTENT_BOTTOM = 26            # just above footer

# ═══════════════════════════════════════════════════════
# PAGE 1 — TITLE
# ═══════════════════════════════════════════════════════
full_bg(c, DARK_BLUE)

# Decorative stripes
c.setFillColor(AMBER)
c.rect(0, PAGE_H * 0.32, PAGE_W, 5, fill=1, stroke=0)
c.setFillColor(WHITE)
c.rect(0, PAGE_H * 0.32 + 5, PAGE_W, 2, fill=1, stroke=0)

# Big title
c.setFillColor(WHITE)
c.setFont("Helvetica-Bold", 68)
c.drawCentredString(PAGE_W/2, PAGE_H * 0.55, "HYPOTHYROIDISM")

# Subtitle
c.setFillColor(YELLOW_ACC)
c.setFont("Helvetica-Bold", 20)
c.drawCentredString(PAGE_W/2, PAGE_H * 0.44, "Clinical Features  |  Investigations  |  Management")

# Tagline
c.setFillColor(colors.HexColor("#BBDEFB"))
c.setFont("Helvetica-Oblique", 15)
c.drawCentredString(PAGE_W/2, PAGE_H * 0.37, "An Underactive Thyroid — A Hypometabolic State")

# Student box
c.setFillColor(colors.HexColor("#1A237E"))
c.roundRect(PAGE_W/2 - 220, PAGE_H * 0.17, 440, 55, 8, fill=1, stroke=0)
c.setFillColor(WHITE)
c.setFont("Helvetica-Bold", 15)
c.drawCentredString(PAGE_W/2, PAGE_H * 0.24, "Presented by: Mokshit Panwar   |   Roll No. 68")
c.setFont("Helvetica", 11)
c.setFillColor(colors.HexColor("#90CAF9"))
c.drawCentredString(PAGE_W/2, PAGE_H * 0.19, "Reference: Tintinalli's Emergency Medicine  |  Textbook of Family Medicine 9e")

c.showPage()

# ═══════════════════════════════════════════════════════
# PAGE 2 — DEFINITION & CLASSIFICATION
# ═══════════════════════════════════════════════════════
full_bg(c, LIGHT_GRAY)
header_bar(c, DARK_BLUE, height_pt=62, accent=AMBER)
slide_title(c, "Definition & Classification")
footer_bar(c)

# Definition box (top full width)
def_y = CONTENT_TOP - 10
colored_box(c, 14, def_y - 54, PAGE_W - 28, 54, INDIGO)
c.setFillColor(WHITE)
c.setFont("Helvetica-Bold", 12)
c.drawString(22, def_y - 16, "DEFINITION")
c.setFont("Helvetica", 11)
c.drawString(22, def_y - 32,
    "Hypothyroidism is a hypometabolic state resulting from insufficient thyroid hormone production or action.")
c.drawString(22, def_y - 46,
    "TSH >10 mIU/L + low FT4 = Overt Hypothyroidism    |    TSH 4–10 mIU/L + normal FT4 = Subclinical Hypothyroidism")

# Three classification boxes
BOX_Y  = def_y - 62
BOX_H  = CONTENT_TOP - 62 - CONTENT_BOTTOM - 10
BOX_W  = (PAGE_W - 28 - 16) / 3   # 3 equal cols with 8pt gaps
cols   = [14, 14 + BOX_W + 8, 14 + 2*(BOX_W + 8)]
titles = ["PRIMARY  (Most Common)", "SECONDARY / TERTIARY", "SPECIAL FORMS"]
bgs    = [MID_BLUE, TEAL, PURPLE]
bullets = [
    [
        "• Intrinsic thyroid gland failure",
        "• TSH elevated, FT4 low",
        "• MC Cause (Developed world):",
        "   Hashimoto's Thyroiditis",
        "   (Autoimmune – TPO antibodies)",
        "• MC Cause (Worldwide):",
        "   Iodine deficiency",
        "• Others: post-radioiodine,",
        "   post-surgical, drugs",
    ],
    [
        "• Pituitary (2°) or Hypothalamic (3°)",
        "   failure → ↓ TSH → ↓ T4",
        "• TSH low/normal + FT4 low",
        "• Causes:",
        "   – Sheehan's syndrome",
        "   – Pituitary tumours",
        "   – Cranial irradiation",
        "   – Head trauma",
        "• TRH stimulation test helps",
        "   distinguish 2° from 3°",
    ],
    [
        "• Congenital Hypothyroidism",
        "   1:3000–4000 births",
        "   Screen day 3–5 after birth",
        "   Treat within 2 weeks",
        "• Drug-induced:",
        "   Lithium, Amiodarone (14%),",
        "   Sunitinib, α-Interferon,",
        "   IL-2, Valproate",
        "• Transient: post-partum,",
        "   subacute thyroiditis",
    ],
]
for i in range(3):
    colored_box(c, cols[i], CONTENT_BOTTOM + 2, BOX_W, BOX_H - 4, bgs[i])
    # title bar
    c.setFillColor(colors.HexColor("#00000040"))
    c.rect(cols[i], CONTENT_BOTTOM + 2 + BOX_H - 26, BOX_W, 24, fill=1, stroke=0)
    c.setFillColor(WHITE)
    c.setFont("Helvetica-Bold", 11)
    c.drawString(cols[i]+6, CONTENT_BOTTOM + 2 + BOX_H - 18, titles[i])
    # bullets
    by = CONTENT_BOTTOM + 2 + BOX_H - 42
    c.setFont("Helvetica", 10)
    for line in bullets[i]:
        c.drawString(cols[i]+6, by, line)
        by -= 14

c.showPage()

# ═══════════════════════════════════════════════════════
# PAGE 3 — PATHOPHYSIOLOGY
# ═══════════════════════════════════════════════════════
full_bg(c, LIGHT_GRAY)
header_bar(c, TEAL, accent=AMBER)
slide_title(c, "Pathophysiology – HPT Axis")
footer_bar(c)

# Left: text boxes
lx = 14
lw = PAGE_W * 0.44
top_y = CONTENT_TOP - 8

boxes_path = [
    (DARK_BLUE, "HPT AXIS FEEDBACK LOOP", [
        "Hypothalamus → TRH → Pituitary → TSH → Thyroid → T4 / T3",
        "T4 : T3 ratio = 10 : 1  (T4 is the main secretory product)",
        "80% of T3 formed by peripheral deiodination of T4",
        "T4 half-life = 7 days   |   T3 half-life = 1 day",
        "In hypothyroidism: ↓ T4 / T3 → ↑ TRH → ↑ TSH (negative feedback broken)",
    ]),
    (TEAL, "METABOLIC CONSEQUENCES", [
        "• ↓ Basal metabolic rate → weight gain, cold intolerance, fatigue",
        "• ↓ Na+/K+ ATPase → reduced heat generation",
        "• Accumulation of glycosaminoglycans → myxedema (non-pitting)",
        "• ↓ Cardiac output → bradycardia, pericardial effusion",
        "• ↓ Gut motility → constipation, ileus",
        "• ↓ Nerve conduction → peripheral neuropathy, delayed reflexes",
    ]),
    (PURPLE, "HASHIMOTO'S (MC in Developed World)", [
        "• Autoimmune lymphocytic infiltration of thyroid",
        "• TPO antibodies (Anti-TPO) – most sensitive marker",
        "• Anti-thyroglobulin antibodies also elevated",
        "• HLA-DR3, DR5 association",
        "• Goitre (firm, rubbery) in early stage",
        "• Atrophic variant in late stage → gland destroyed",
    ]),
]

cur_y = top_y
bh = (CONTENT_TOP - CONTENT_BOTTOM - 14) / 3

for bg, title, lines in boxes_path:
    colored_box(c, lx, cur_y - bh + 2, lw, bh - 4, bg)
    c.setFillColor(colors.HexColor("#00000050"))
    c.rect(lx, cur_y - 22, lw, 21, fill=1, stroke=0)
    c.setFillColor(WHITE)
    c.setFont("Helvetica-Bold", 11)
    c.drawString(lx + 6, cur_y - 16, title)
    by = cur_y - 35
    c.setFont("Helvetica", 10)
    for line in lines:
        c.drawString(lx + 6, by, line)
        by -= 13
    cur_y -= bh

# Right: HPT axis image
rx = PAGE_W * 0.46
rw = PAGE_W - rx - 14
ry = CONTENT_BOTTOM + 2
rh = CONTENT_TOP - CONTENT_BOTTOM - 10

buf = img_buf("hpt_axis")
if buf:
    from reportlab.lib.utils import ImageReader
    buf.seek(0)
    ir = ImageReader(buf)
    iw, ih = ir.getSize()
    scale = min(rw / iw, rh / ih)
    dw, dh = iw * scale, ih * scale
    ox = rx + (rw - dw) / 2
    oy = ry + (rh - dh) / 2
    buf.seek(0)
    c.drawImage(ImageReader(buf), ox, oy, dw, dh, preserveAspectRatio=True, mask='auto')

c.showPage()

# ═══════════════════════════════════════════════════════
# PAGE 4 — CLINICAL FEATURES (symptoms + body diagram)
# ═══════════════════════════════════════════════════════
full_bg(c, LIGHT_GRAY)
header_bar(c, ORANGE, accent=DARK_BLUE)
slide_title(c, "Clinical Features")
footer_bar(c)

# image on right
from reportlab.lib.utils import ImageReader
rx = PAGE_W * 0.56
rw = PAGE_W - rx - 14
ry = CONTENT_BOTTOM + 2
rh = CONTENT_TOP - CONTENT_BOTTOM - 10
buf = img_buf("signs_diagram")
if buf:
    buf.seek(0)
    ir = ImageReader(buf)
    iw, ih = ir.getSize()
    scale = min(rw / iw, rh / ih)
    dw, dh = iw * scale, ih * scale
    ox = rx + (rw - dw) / 2
    oy = ry + (rh - dh) / 2
    buf.seek(0)
    c.drawImage(ImageReader(buf), ox, oy, dw, dh, preserveAspectRatio=True, mask='auto')

# 2 col on left
lw2 = PAGE_W * 0.54 - 20
sym_h = (CONTENT_TOP - CONTENT_BOTTOM - 10) / 2

symp_col = [
    (RED, "SYMPTOMS (What patient reports)", [
        "• Weight gain  |  Fatigue & lethargy",
        "• Cold intolerance  |  Constipation",
        "• Depression / psychosis ("myxedema madness")",
        "• Menstrual irregularity (menorrhagia)",
        "• Decreased libido  |  Infertility",
        "• Muscle cramps, aches (myopathy)",
        "• Bradycardia-related: exertional dyspnoea",
        "• Hoarseness of voice  |  Carpal tunnel syndrome",
        "• Impaired memory, slow mentation",
    ]),
    (DARK_BLUE, "SIGNS (Examination findings)", [
        "• Dry, coarse skin  |  Brittle nails",
        "• Loss of outer 1/3 of eyebrows (Hertoghe's sign)",
        "• Periorbital puffiness  |  Macroglossia",
        "• Non-pitting edema (myxedema)",
        "• Bradycardia  |  Hypertension",
        "• Slow relaxing deep tendon reflexes",
        "• Pericardial / pleural effusion",
        "• Goitre (in Hashimoto's – rubbery, firm)",
        "• Carotenemia (yellowish skin)",
    ]),
]
cur_y = CONTENT_TOP - 6
for bg, title, lines in symp_col:
    colored_box(c, 14, cur_y - sym_h + 2, lw2, sym_h - 4, bg)
    c.setFillColor(colors.HexColor("#00000050"))
    c.rect(14, cur_y - 22, lw2, 21, fill=1, stroke=0)
    c.setFillColor(WHITE)
    c.setFont("Helvetica-Bold", 11)
    c.drawString(20, cur_y - 16, title)
    by = cur_y - 36
    c.setFont("Helvetica", 10)
    for line in lines:
        c.drawString(20, by, line)
        by -= 13.5
    cur_y -= sym_h

c.showPage()

# ═══════════════════════════════════════════════════════
# PAGE 5 — CLINICAL PHOTOGRAPHS
# ═══════════════════════════════════════════════════════
full_bg(c, LIGHT_GRAY)
header_bar(c, PURPLE, accent=AMBER)
slide_title(c, "Clinical Photographs")
footer_bar(c)

photo_keys     = ["myxedema_face", "congenital", "myxedema_legs"]
photo_captions = [
    "Myxedematous Facies\nPeriorbital puffiness, pallor,\nsparse lateral eyebrows",
    "Congenital Hypothyroidism\nMacroglossia, abdominal distension,\numbilical hernia — Before & After Rx",
    "Pretibial Myxedema\nNon-pitting edema, waxy skin,\nankle swelling & nail dystrophy",
]
photo_bgs = [DARK_BLUE, TEAL, ORANGE]

n = len(photo_keys)
gap = 10
total_gap = gap * (n + 1)
box_w = (PAGE_W - total_gap) / n
img_h = CONTENT_TOP - CONTENT_BOTTOM - 50 - 10  # leave room for caption

for i, (key, cap, bg) in enumerate(zip(photo_keys, photo_captions, photo_bgs)):
    bx = gap + i * (box_w + gap)
    # image area
    img_y = CONTENT_BOTTOM + 48
    buf = img_buf(key)
    if buf:
        buf.seek(0)
        ir = ImageReader(buf)
        iw, ih = ir.getSize()
        scale = min(box_w / iw, img_h / ih)
        dw, dh = iw * scale, ih * scale
        ox = bx + (box_w - dw) / 2
        oy = img_y + (img_h - dh) / 2
        buf.seek(0)
        c.drawImage(ImageReader(buf), ox, oy, dw, dh, preserveAspectRatio=True, mask='auto')
    # caption bar
    colored_box(c, bx, CONTENT_BOTTOM + 2, box_w, 44, bg)
    c.setFillColor(WHITE)
    lines = cap.split("\n")
    c.setFont("Helvetica-Bold", 9.5)
    c.drawCentredString(bx + box_w/2, CONTENT_BOTTOM + 33, lines[0])
    c.setFont("Helvetica", 8.5)
    for j, line in enumerate(lines[1:], 1):
        c.drawCentredString(bx + box_w/2, CONTENT_BOTTOM + 33 - j*11, line)

c.showPage()

# ═══════════════════════════════════════════════════════
# PAGE 6 — INVESTIGATIONS
# ═══════════════════════════════════════════════════════
full_bg(c, LIGHT_GRAY)
header_bar(c, GREEN, accent=AMBER)
slide_title(c, "Investigations")
footer_bar(c)

inv_data = [
    (MID_BLUE, "🔬 THYROID FUNCTION TESTS (1st Line)", [
        "• Serum TSH — MOST SENSITIVE test; >10 mIU/L = Overt",
        "• Free T4 (FT4) — Low in primary; normal in subclinical",
        "• Free T3 (FT3) — Low; less commonly measured",
        "• TSH + FT4 together confirm primary vs secondary",
        "• Always do TSH first (single best screening test)",
        "• Subclinical: TSH 4–10 mIU/L + Normal FT4",
    ]),
    (TEAL, "🧬 AUTOIMMUNE MARKERS", [
        "• TPO Antibodies — Elevated in Hashimoto's thyroiditis",
        "• Anti-Thyroglobulin Antibodies — Also elevated",
        "• ANA — May be positive in autoimmune disease",
        "• Important for etiology, prognosis, family counselling",
        "• High TPO Ab + subclinical hypothyroidism →",
        "   risk of progression to overt disease",
    ]),
    (ORANGE, "🩸 BIOCHEMISTRY & SPECIAL TESTS", [
        "• Lipid profile: ↑ LDL, ↑ Total cholesterol",
        "• Serum CK: elevated (myopathy)",
        "• CBC: normocytic / macrocytic anaemia",
        "• Hyponatraemia (SIADH-like picture)",
        "• Uric acid, LFT may be abnormal",
        "• TRH stimulation test (2° vs 3° distinction)",
    ]),
    (PURPLE, "🖼️ IMAGING & OTHER", [
        "• Ultrasound thyroid: texture, goitre, nodules",
        "• Scintigraphy (Tc-99m): rarely needed",
        "• ECG: bradycardia, flat/inverted T waves,",
        "   prolonged QT, low voltage complexes",
        "• X-ray chest: cardiomegaly, pericardial effusion",
        "• ECHO if cardiac involvement suspected",
    ]),
]

n = 2  # 2 cols × 2 rows
gap2 = 10
bw2 = (PAGE_W - 3 * gap2) / 2
bh2 = (CONTENT_TOP - CONTENT_BOTTOM - 2 * gap2) / 2

positions = [
    (gap2,            CONTENT_BOTTOM + gap2 + bh2),
    (gap2*2 + bw2,    CONTENT_BOTTOM + gap2 + bh2),
    (gap2,            CONTENT_BOTTOM + gap2),
    (gap2*2 + bw2,    CONTENT_BOTTOM + gap2),
]

for i, (bg, title, lines) in enumerate(inv_data):
    bx, by = positions[i]
    colored_box(c, bx, by, bw2, bh2, bg)
    # title strip
    c.setFillColor(colors.HexColor("#00000055"))
    c.rect(bx, by + bh2 - 23, bw2, 23, fill=1, stroke=0)
    c.setFillColor(WHITE)
    c.setFont("Helvetica-Bold", 11)
    c.drawString(bx + 6, by + bh2 - 16, title)
    c.setFont("Helvetica", 10)
    ty = by + bh2 - 37
    for line in lines:
        c.drawString(bx + 6, ty, line)
        ty -= 14

c.showPage()

# ═══════════════════════════════════════════════════════
# PAGE 7 — MANAGEMENT
# ═══════════════════════════════════════════════════════
full_bg(c, LIGHT_GRAY)
header_bar(c, RED, accent=YELLOW_ACC)
slide_title(c, "Management")
footer_bar(c)

mgmt_data = [
    (DARK_BLUE, "💊 LEVOTHYROXINE (L-T4) — Mainstay", [
        "• Drug of choice: Synthetic T4 (Levothyroxine)",
        "• Dose: 1.6 µg/kg/day (average adult ~100 µg/day)",
        "• Start low, go slow — especially elderly & cardiac",
        "   Elderly: start 25–50 µg/day",
        "• Take on empty stomach, 30–60 min before food",
        "• Do NOT take with Ca²⁺, Fe, antacids, cholestyramine",
        "• Half-life 7 days → steady state in 4–6 weeks",
    ]),
    (GREEN, "📈 MONITORING & DOSE ADJUSTMENT", [
        "• Check TSH 4–6 weeks after starting / dose change",
        "• Target TSH: 0.5–2.5 mIU/L (lower end for young)",
        "• Elderly target: 1–4 mIU/L",
        "• Annual TSH once stable",
        "• Over-replacement risk: AF, osteoporosis",
        "• Under-replacement: persistent symptoms",
        "• Symptoms improve before TSH normalises",
    ]),
    (TEAL, "🤰 SPECIAL POPULATIONS", [
        "• Pregnancy: Increase dose by 25–30%",
        "   Target TSH <2.5 mIU/L (1st trimester)",
        "   TSH <3.0 mIU/L (2nd–3rd trimester)",
        "• Congenital: Start within 2 weeks of birth",
        "   Dose 10–15 µg/kg/day",
        "• Cardiac disease: Start 12.5–25 µg, titrate slowly",
        "• Subclinical: Treat if TSH >10 or symptomatic",
    ]),
    (RED, "🚨 MYXEDEMA CRISIS (Coma)", [
        "• Medical emergency — Mortality 30–60%",
        "• Precipitants: cold, infection, drugs, surgery",
        "• Features: hypothermia, hypotension,",
        "   hypoventilation, coma, seizures",
        "• Rx: IV Levothyroxine 200–400 µg loading dose",
        "   Then 100 µg IV daily",
        "• IV Hydrocortisone 100–200 mg (rule out adrenal",
        "   insufficiency before thyroid Rx)",
        "• Warm slowly, O₂, supportive ICU care",
    ]),
]

for i, (bg, title, lines) in enumerate(mgmt_data):
    bx, by = positions[i]
    colored_box(c, bx, by, bw2, bh2, bg)
    c.setFillColor(colors.HexColor("#00000055"))
    c.rect(bx, by + bh2 - 23, bw2, 23, fill=1, stroke=0)
    c.setFillColor(WHITE)
    c.setFont("Helvetica-Bold", 11)
    c.drawString(bx + 6, by + bh2 - 16, title)
    c.setFont("Helvetica", 10)
    ty = by + bh2 - 37
    for line in lines:
        c.drawString(bx + 6, ty, line)
        ty -= 13.5

c.showPage()

# ═══════════════════════════════════════════════════════
# PAGE 8 — SUBCLINICAL & CONGENITAL
# ═══════════════════════════════════════════════════════
full_bg(c, LIGHT_GRAY)
header_bar(c, CYAN, accent=AMBER)
slide_title(c, "Subclinical & Congenital Hypothyroidism")
footer_bar(c)

# Left half: Subclinical
lx = 14
lw3 = PAGE_W / 2 - 20

sub_sects = [
    (MID_BLUE, "Definition", [
        "TSH 4–10 mIU/L with normal FT4 and FT3",
        "Prevalence: 4–15% in women; 3% in men",
        "Most patients are asymptomatic",
    ]),
    (TEAL, "When to Treat", [
        "• TSH consistently >10 mIU/L",
        "• Symptomatic (fatigue, weight gain, depression)",
        "• Pregnant or planning pregnancy",
        "• TPO Ab positive (higher risk of progression)",
        "• Children & young adults",
    ]),
    (ORANGE, "Natural History", [
        "• 2–5% per year progress to overt hypothyroidism",
        "• Higher risk if TPO Ab positive",
        "• May spontaneously resolve (especially if post-viral)",
        "• Repeat TFTs in 3–6 months if not treating",
    ]),
]
cur_y2 = CONTENT_TOP - 6
row_h = (CONTENT_TOP - CONTENT_BOTTOM - 10) / 3
for bg, title, lines in sub_sects:
    colored_box(c, lx, cur_y2 - row_h + 2, lw3, row_h - 4, bg)
    c.setFillColor(colors.HexColor("#00000055"))
    c.rect(lx, cur_y2 - 22, lw3, 21, fill=1, stroke=0)
    c.setFillColor(WHITE)
    c.setFont("Helvetica-Bold", 11)
    c.drawString(lx + 6, cur_y2 - 16, "SUBCLINICAL HYPOTHYROIDISM — " + title)
    c.setFont("Helvetica", 10.5)
    by2 = cur_y2 - 36
    for line in lines:
        c.drawString(lx + 6, by2, line)
        by2 -= 14
    cur_y2 -= row_h

# Right half: Congenital
rx2 = PAGE_W / 2 + 8
rw2 = PAGE_W / 2 - 22

cong_sects = [
    (PURPLE, "Epidemiology & Screening", [
        "• Incidence: 1:3000–4000 live births",
        "• Most common preventable cause of mental retardation",
        "• Newborn screening: heel prick on day 3–5",
        "• TSH filter paper method",
    ]),
    (RED, "Clinical Features", [
        "• Prolonged neonatal jaundice (earliest sign)",
        "• Hypotonia, large fontanelle, macroglossia",
        "• Umbilical hernia, constipation",
        "• Abdominal distension, poor feeding",
        "• Hoarse cry  |  Bradycardia  |  Hypothermia",
    ]),
    (DARK_BLUE, "Treatment & Outcome", [
        "• Start L-Thyroxine within 2 weeks of birth",
        "• Dose: 10–15 µg/kg/day initially",
        "• Normal intellect if treated early",
        "• Cretinism if untreated: mental retardation,",
        "   short stature, deafness, spasticity",
        "• Monitor TSH every 3 months (0–3 yrs)",
    ]),
]
# image on far right
img_x = rx2 + rw2 * 0.58
img_w = rw2 * 0.38
img_y2 = CONTENT_BOTTOM + 4
img_h2 = CONTENT_TOP - CONTENT_BOTTOM - 60
buf = img_buf("congenital")
if buf:
    buf.seek(0)
    ir = ImageReader(buf)
    iw, ih = ir.getSize()
    scale = min(img_w / iw, img_h2 / ih)
    dw, dh = iw * scale, ih * scale
    ox = img_x + (img_w - dw) / 2
    oy = img_y2 + (img_h2 - dh) / 2
    buf.seek(0)
    c.drawImage(ImageReader(buf), ox, oy, dw, dh, preserveAspectRatio=True, mask='auto')

text_w = rw2 * 0.56
cur_y3 = CONTENT_TOP - 6
for bg, title, lines in cong_sects:
    colored_box(c, rx2, cur_y3 - row_h + 2, text_w, row_h - 4, bg)
    c.setFillColor(colors.HexColor("#00000055"))
    c.rect(rx2, cur_y3 - 22, text_w, 21, fill=1, stroke=0)
    c.setFillColor(WHITE)
    c.setFont("Helvetica-Bold", 11)
    c.drawString(rx2 + 6, cur_y3 - 16, "CONGENITAL — " + title)
    c.setFont("Helvetica", 10.5)
    by3 = cur_y3 - 36
    for line in lines:
        c.drawString(rx2 + 6, by3, line)
        by3 -= 13.5
    cur_y3 -= row_h

c.showPage()

# ═══════════════════════════════════════════════════════
# PAGE 9 — KEY POINTS SUMMARY
# ═══════════════════════════════════════════════════════
full_bg(c, DARK_BLUE)

# Top stripe
c.setFillColor(AMBER)
c.rect(0, PAGE_H - 65, PAGE_W, 65, fill=1, stroke=0)
c.setFillColor(DARK_BLUE)
c.setFont("Helvetica-Bold", 28)
c.drawCentredString(PAGE_W/2, PAGE_H - 40, "KEY POINTS  —  HYPOTHYROIDISM")

footer_bar(c, bg=colors.HexColor("#0A2472"))

key_points = [
    ("1", "MC cause (developed world) = Hashimoto's Thyroiditis (TPO Ab +ve)  |  MC worldwide = Iodine deficiency"),
    ("2", "Best screening test = Serum TSH. Overt: TSH >10 + ↓FT4. Subclinical: TSH 4–10 + normal FT4"),
    ("3", "Treatment of choice = L-Thyroxine 1.6 µg/kg/day on empty stomach"),
    ("4", "Monitor TSH at 4–6 weeks after dose change; target TSH 0.5–2.5 mIU/L"),
    ("5", "Drugs causing hypothyroidism: Lithium, Amiodarone (14%), Sunitinib, α-IFN, IL-2, Valproate"),
    ("6", "Pregnancy: Increase L-T4 dose by 25–30%; target TSH <2.5 mIU/L (1st trimester)"),
    ("7", "Congenital: Screen day 3–5; treat within 2 weeks to prevent cretinism (irreversible if delayed)"),
    ("8", "Myxedema crisis: IV L-T4 200–400 µg loading + IV Hydrocortisone 100–200 mg. Mortality 30–60%"),
    ("9", "Hertoghe's sign = loss of outer 1/3 of eyebrow; Woltman sign = slow-relaxing DTR"),
]

KP_W  = PAGE_W - 28
KP_H  = (CONTENT_TOP - CONTENT_BOTTOM - 10) / len(key_points)
cur_y = CONTENT_TOP - 8

for num, text in key_points:
    # number circle
    c.setFillColor(AMBER)
    c.circle(28, cur_y - KP_H/2, 10, fill=1, stroke=0)
    c.setFillColor(DARK_BLUE)
    c.setFont("Helvetica-Bold", 11)
    c.drawCentredString(28, cur_y - KP_H/2 - 4, num)
    # text
    c.setFillColor(colors.HexColor("#FFFFFF22"))
    c.roundRect(42, cur_y - KP_H + 2, KP_W - 42, KP_H - 4, 4, fill=1, stroke=0)
    c.setFillColor(WHITE)
    c.setFont("Helvetica", 11)
    c.drawString(50, cur_y - KP_H/2 - 4, text)
    cur_y -= KP_H

c.showPage()

# ── Save ─────────────────────────────────────────────────
c.save()
print(f"PDF saved: {OUT}")
Running Command

cd /tmp/workspace/hypothyroidism-ppt && python create_pdf.py 2>&1

Running Command

grep -n '"\|"' /tmp/workspace/hypothyroidism-ppt/create_pdf.py | head -30

Editing File

~/hypothyroidism-ppt/create_pdf.py

Successfully replaced 1 instance(s) of the string in '/tmp/workspace/hypothyroidism-ppt/create_pdf.py'
Running Command

cd /tmp/workspace/hypothyroidism-ppt && python create_pdf.py 2>&1

Editing File

~/hypothyroidism-ppt/create_pdf.py

Successfully replaced 1 instance(s) of the string in '/tmp/workspace/hypothyroidism-ppt/create_pdf.py'
Editing File

~/hypothyroidism-ppt/create_pdf.py

Successfully replaced 1 instance(s) of the string in '/tmp/workspace/hypothyroidism-ppt/create_pdf.py'
Running Command

cd /tmp/workspace/hypothyroidism-ppt && python create_pdf.py 2>&1

Your credits are exhausted. You can purchase a top-up or subscribe to a plan to continue using Orris. If you're already subscribed, your daily credits will reset tomorrow.

Hypothyroidism Focus on Clinical features,investigations and management For me mokshit Panwar roll no 68 Colour ful diagrams and best ppt. And Make a pdf but more suitable for class presentation

Running Command

ls -lh /tmp/workspace/hypothyroidism-ppt/ 2>&1

Both files are ready, Mokshit! Here are your downloads:

PowerPoint Presentation

Hypothyroidism Mokshit Panwar Roll68

Presentation · PPTX

Presentation-Style PDF

Hypothyroidism Mokshit Panwar Roll68

PDF Document · PDF


Both files are landscape, colorful, and class-presentation ready. Here's what's inside:
Page/SlideContent
1Title slide - Mokshit Panwar, Roll No. 68
2Definition & Classification (Primary / Secondary / Special)
3Pathophysiology + HPT Axis diagram
4Clinical Features - Symptoms & Signs + body diagram
5Clinical Photographs (myxedematous face, pretibial myxedema, congenital hypothyroidism)
6Investigations - TFTs, Autoimmune markers, Biochemistry, Imaging
7Management - L-Thyroxine dosing, monitoring, special populations, myxedema crisis
8Subclinical & Congenital Hypothyroidism
9Key Points Summary (9 high-yield exam points)

Make it as for class presentation

Asking for Preferences
Writing File

~/hypothyroidism-ppt/create_ppt_v2.py

"""
Hypothyroidism - Class Presentation PPT v2
Clean lecture style: fewer bullets per slide, larger text, speaker notes on every slide.
15 slides for proper pacing.
"""
import requests
from io import BytesIO
from pptx import Presentation
from pptx.util import Inches, Pt, Emu
from pptx.dml.color import RGBColor
from pptx.enum.text import PP_ALIGN, MSO_ANCHOR
from pptx.oxml.ns import qn
from lxml import etree

# ── Palette ──────────────────────────────────────────────
DARK_BLUE  = RGBColor(0x0D, 0x47, 0xA1)
MID_BLUE   = RGBColor(0x15, 0x65, 0xC0)
TEAL       = RGBColor(0x00, 0x89, 0x7B)
AMBER      = RGBColor(0xFF, 0x8F, 0x00)
RED        = RGBColor(0xC6, 0x28, 0x28)
ORANGE     = RGBColor(0xE6, 0x51, 0x00)
PURPLE     = RGBColor(0x6A, 0x1B, 0x9A)
GREEN      = RGBColor(0x2E, 0x7D, 0x32)
WHITE      = RGBColor(0xFF, 0xFF, 0xFF)
LIGHT_GRAY = RGBColor(0xF0, 0xF4, 0xFF)
DARK_TEXT  = RGBColor(0x1A, 0x1A, 0x2E)
YELLOW_ACC = RGBColor(0xFF, 0xD6, 0x00)
INDIGO     = RGBColor(0x28, 0x35, 0x93)
NAVY       = RGBColor(0x0A, 0x24, 0x72)
SOFT_BLUE  = RGBColor(0xBB, 0xDE, 0xFB)

IMAGE_URLS = {
    "signs_diagram": "https://cdn.orris.care/cdss_images/053b9bb265b63714c4a536636d315c8c10972d68fe82e00691f22c7acff56972.png",
    "hpt_axis":      "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_6f82970f9f7319e651f853444406dd2b35b7feffc3334ebb3c549f9b030a044f.jpg",
    "myxedema_face": "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_004376e56882f1544f2c61db75df95bbb940d303665f105b602921ddef336433.jpg",
    "congenital":    "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_21eff5b66b62dfc0c59899e9eba5d20699765566b7e304af716c2a545b1b97ff.jpg",
    "myxedema_legs": "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_5ca4d51c24fef39d7592d3972d48133127a4ef92b28178dcc0aec50ff6784604.jpg",
}

img_data = {}
for key, url in IMAGE_URLS.items():
    try:
        resp = requests.get(url, timeout=15)
        resp.raise_for_status()
        img_data[key] = resp.content
    except Exception as e:
        print(f"Failed {key}: {e}")
        img_data[key] = None
print("Images:", {k: v is not None for k, v in img_data.items()})

# ── XML helpers ──────────────────────────────────────────
def fill_shape(shape, color: RGBColor):
    sp = shape._element
    spPr = sp.find(qn('p:spPr'))
    if spPr is None:
        spPr = etree.SubElement(sp, qn('p:spPr'))
    solidFill = etree.SubElement(spPr, qn('a:solidFill'))
    srgbClr   = etree.SubElement(solidFill, qn('a:srgbClr'))
    srgbClr.set('val', f'{color[0]:02X}{color[1]:02X}{color[2]:02X}')

def add_rect(slide, x, y, w, h, color: RGBColor):
    shape = slide.shapes.add_shape(1, Inches(x), Inches(y), Inches(w), Inches(h))
    shape.line.fill.background()
    fill_shape(shape, color)
    return shape

def add_textbox(slide, x, y, w, h, text, font_size=18, bold=False,
                color=DARK_TEXT, align=PP_ALIGN.LEFT, italic=False, wrap=True):
    tb = slide.shapes.add_textbox(Inches(x), Inches(y), Inches(w), Inches(h))
    tf = tb.text_frame
    tf.word_wrap = wrap
    tf.margin_left  = Pt(4)
    tf.margin_right = Pt(4)
    tf.margin_top   = Pt(2)
    p = tf.paragraphs[0]
    p.alignment = align
    run = p.add_run()
    run.text = text
    run.font.size   = Pt(font_size)
    run.font.bold   = bold
    run.font.italic = italic
    run.font.color.rgb = color
    run.font.name   = "Calibri"
    return tb

def add_bullets(slide, x, y, w, h, items, font_size=18, color=DARK_TEXT,
                line_spacing=1.4, indent_bullet="  "):
    tb = slide.shapes.add_textbox(Inches(x), Inches(y), Inches(w), Inches(h))
    tf = tb.text_frame
    tf.word_wrap = True
    tf.margin_left  = Pt(6)
    tf.margin_right = Pt(6)
    tf.margin_top   = Pt(4)
    first = True
    for item in items:
        if first:
            p = tf.paragraphs[0]
            first = False
        else:
            p = tf.add_paragraph()
        p.space_before = Pt(4)
        p.space_after  = Pt(0)
        run = p.add_run()
        run.text = item
        run.font.size = Pt(font_size)
        run.font.color.rgb = color
        run.font.name = "Calibri"
    return tb

def add_speaker_note(slide, note_text):
    notes_slide = slide.notes_slide
    tf = notes_slide.notes_text_frame
    tf.text = note_text

def add_image(slide, key, x, y, w, h=None):
    d = img_data.get(key)
    if d is None:
        return
    buf = BytesIO(d)
    if h:
        slide.shapes.add_picture(buf, Inches(x), Inches(y), Inches(w), Inches(h))
    else:
        slide.shapes.add_picture(buf, Inches(x), Inches(y), Inches(w))

# ── Slide factory ─────────────────────────────────────────
prs = Presentation()
prs.slide_width  = Inches(13.333)
prs.slide_height = Inches(7.5)
blank = prs.slide_layouts[6]

W = 13.333
H = 7.5

def new_slide(header_color=DARK_BLUE, title="", accent=AMBER):
    s = prs.slides.add_slide(blank)
    # Light background
    add_rect(s, 0, 0, W, H, LIGHT_GRAY)
    # Header bar
    add_rect(s, 0, 0, W, 1.0, header_color)
    # Accent stripe
    add_rect(s, 0, 1.0, W, 0.07, accent)
    # Footer
    add_rect(s, 0, H - 0.32, W, 0.32, header_color)
    add_textbox(s, 0, H - 0.30, W, 0.28,
                "Hypothyroidism  |  Mokshit Panwar  |  Roll No. 68",
                font_size=9, color=WHITE, align=PP_ALIGN.CENTER)
    if title:
        add_textbox(s, 0.3, 0.08, W - 0.6, 0.85, title,
                    font_size=28, bold=True, color=WHITE)
    return s

# ════════════════════════════════════════════════════════
# SLIDE 1 — TITLE
# ════════════════════════════════════════════════════════
s = prs.slides.add_slide(blank)
add_rect(s, 0, 0, W, H, DARK_BLUE)
add_rect(s, 0, H * 0.42, W, 0.07, AMBER)

add_textbox(s, 0.5, 0.9, W - 1, 1.6, "HYPOTHYROIDISM",
            font_size=64, bold=True, color=WHITE, align=PP_ALIGN.CENTER)
add_textbox(s, 0.5, 2.6, W - 1, 0.7,
            "Clinical Features  |  Investigations  |  Management",
            font_size=22, color=YELLOW_ACC, align=PP_ALIGN.CENTER)
add_textbox(s, 0.5, 3.35, W - 1, 0.5,
            "An Underactive Thyroid — A Hypometabolic State",
            font_size=16, italic=True, color=SOFT_BLUE, align=PP_ALIGN.CENTER)

# Student card
add_rect(s, 3.8, 4.15, 5.7, 1.1, NAVY)
add_rect(s, 3.8, 4.15, 5.7, 0.05, AMBER)
add_textbox(s, 3.85, 4.22, 5.6, 0.55,
            "Presented by: Mokshit Panwar  |  Roll No. 68",
            font_size=17, bold=True, color=WHITE, align=PP_ALIGN.CENTER)
add_textbox(s, 3.85, 4.78, 5.6, 0.38,
            "Tintinalli's Emergency Medicine  |  Family Medicine 9e",
            font_size=11, italic=True, color=SOFT_BLUE, align=PP_ALIGN.CENTER)

add_speaker_note(s,
    "Welcome everyone. Today I will be presenting on Hypothyroidism — focusing on its clinical features, "
    "investigations, and management. My name is Mokshit Panwar, Roll No. 68.")

# ════════════════════════════════════════════════════════
# SLIDE 2 — DEFINITION & OVERVIEW
# ════════════════════════════════════════════════════════
s = new_slide(DARK_BLUE, "What is Hypothyroidism?")

add_rect(s, 0.4, 1.2, W - 0.8, 1.05, INDIGO)
add_textbox(s, 0.5, 1.25, W - 1, 0.4,
            "DEFINITION",
            font_size=13, bold=True, color=YELLOW_ACC)
add_textbox(s, 0.5, 1.62, W - 1, 0.5,
            "A hypometabolic state resulting from insufficient production or action of thyroid hormones.",
            font_size=16, color=WHITE)

# Two columns: TSH levels | Epidemiology
add_rect(s, 0.4, 2.42, 6.1, 4.6, MID_BLUE)
add_rect(s, 6.8, 2.42, 6.1, 4.6, TEAL)

add_textbox(s, 0.5, 2.48, 5.9, 0.5, "TSH CLASSIFICATION", font_size=14, bold=True, color=YELLOW_ACC)
add_bullets(s, 0.5, 2.95, 5.9, 3.8, [
    "Overt Hypothyroidism:",
    "   TSH > 10 mIU/L + Low FT4",
    "   Symptomatic, needs treatment",
    "",
    "Subclinical Hypothyroidism:",
    "   TSH 4-10 mIU/L + Normal FT4",
    "   Often asymptomatic",
    "",
    "Secondary / Tertiary:",
    "   TSH low/normal + Low FT4",
    "   Pituitary or hypothalamic cause",
], font_size=15, color=WHITE)

add_textbox(s, 6.9, 2.48, 5.9, 0.5, "EPIDEMIOLOGY", font_size=14, bold=True, color=YELLOW_ACC)
add_bullets(s, 6.9, 2.95, 5.9, 3.8, [
    "Prevalence: 4-10% of adults",
    "Women > Men (5-8x more common)",
    "",
    "Most Common Cause (Developed):",
    "   Hashimoto's Thyroiditis",
    "   (Autoimmune — TPO Ab+)",
    "",
    "Most Common Cause (Worldwide):",
    "   Iodine Deficiency",
    "",
    "Congenital: 1 in 3,000-4,000 births",
], font_size=15, color=WHITE)

add_speaker_note(s,
    "Hypothyroidism is simply an underactive thyroid. The key diagnostic test is serum TSH. "
    "TSH above 10 with a low FT4 = overt hypothyroidism. TSH between 4 and 10 with normal FT4 = subclinical. "
    "In developed countries the commonest cause is Hashimoto's thyroiditis, an autoimmune condition. "
    "Worldwide, iodine deficiency remains the leading cause.")

# ════════════════════════════════════════════════════════
# SLIDE 3 — CAUSES (AETIOLOGY)
# ════════════════════════════════════════════════════════
s = new_slide(TEAL, "Aetiology — Causes of Hypothyroidism")

boxes = [
    (0.4,  1.2,  6.1, 2.8, GREEN,  "PRIMARY (Thyroid Gland Failure)", [
        "• Hashimoto's thyroiditis (MC in developed world)",
        "• Iodine deficiency (MC worldwide)",
        "• Post-radioiodine ablation",
        "• Post-thyroidectomy (surgical)",
        "• Congenital (aplasia/dyshormonogenesis)",
    ]),
    (6.7,  1.2,  6.2, 2.8, PURPLE, "SECONDARY / TERTIARY", [
        "• Pituitary failure (Sheehan's syndrome, tumour)",
        "• Hypothalamic failure (TRH deficiency)",
        "• Cranial irradiation",
        "• Head trauma",
    ]),
    (0.4,  4.2,  6.1, 2.7, RED,    "DRUG-INDUCED", [
        "• Lithium (inhibits thyroid hormone release)",
        "• Amiodarone (up to 14% incidence)",
        "• Sunitinib, Sorafenib (tyrosine kinase inhibitors)",
        "• Alpha-Interferon, Interleukin-2",
        "• Valproate, Carbamazepine",
    ]),
    (6.7,  4.2,  6.2, 2.7, AMBER,  "TRANSIENT / SPECIAL FORMS", [
        "• Post-partum thyroiditis",
        "• Subacute (de Quervain's) thyroiditis",
        "• Riedel's thyroiditis (fibrous)",
        "• Silent (painless) thyroiditis",
        "• Thyroid infiltration: amyloid, sarcoid, lymphoma",
    ]),
]
for bx, by, bw, bh, bg, title, items in boxes:
    add_rect(s, bx, by, bw, bh, bg)
    add_rect(s, bx, by, bw, 0.42, NAVY)
    add_textbox(s, bx + 0.1, by + 0.04, bw - 0.2, 0.35, title,
                font_size=13, bold=True, color=WHITE)
    add_bullets(s, bx + 0.1, by + 0.48, bw - 0.2, bh - 0.55, items,
                font_size=13.5, color=WHITE)

add_speaker_note(s,
    "There are many causes. For exam purposes, always remember: "
    "Hashimoto's is the MC cause in developed countries, iodine deficiency worldwide. "
    "Drug-induced is increasingly important — Amiodarone causes hypothyroidism in up to 14% of patients. "
    "Lithium is another high-yield drug to remember. "
    "Transient forms like post-partum thyroiditis are common in young women after delivery.")

# ════════════════════════════════════════════════════════
# SLIDE 4 — PATHOPHYSIOLOGY
# ════════════════════════════════════════════════════════
s = new_slide(INDIGO, "Pathophysiology — HPT Axis")

# Left text
add_bullets(s, 0.4, 1.15, 6.0, 5.9, [
    "Normal HPT Axis:",
    "  Hypothalamus  TRH  Pituitary  TSH  Thyroid  T4/T3",
    "",
    "Key Facts:",
    "  T4 : T3 secretion ratio = 10 : 1",
    "  80% of T3 comes from peripheral T4 deiodination",
    "  T4 half-life = 7 days   |   T3 half-life = 1 day",
    "",
    "In Hypothyroidism:",
    "  T4/T3 falls  TRH rises  TSH rises (negative feedback broken)",
    "  TSH is the MOST SENSITIVE marker of thyroid status",
    "",
    "Metabolic Effects of T3/T4 Deficiency:",
    "  BMR  weight gain, cold intolerance, fatigue",
    "  Na/K ATPase  reduced thermogenesis",
    "  Glycosaminoglycan accumulation  myxedema",
    "  Cardiac output  bradycardia, effusion",
    "  Gut motility  constipation",
], font_size=14, color=DARK_TEXT)

# Right image
add_image(s, "hpt_axis", 6.7, 1.15, 6.2, 5.9)

add_speaker_note(s,
    "The HPT (Hypothalamus-Pituitary-Thyroid) axis works through negative feedback. "
    "When thyroid hormone falls, TRH rises, which stimulates TSH, which drives the thyroid to produce more T4 and T3. "
    "In primary hypothyroidism this feedback is broken — TSH keeps rising but the gland cannot respond. "
    "T4 is the main secretory product (10:1 ratio over T3), but T3 is the active form. "
    "Deficiency of T3 reduces the metabolic rate — this explains weight gain, cold intolerance, bradycardia, and constipation.")

# ════════════════════════════════════════════════════════
# SLIDE 5 — CLINICAL FEATURES: SYMPTOMS
# ════════════════════════════════════════════════════════
s = new_slide(RED, "Clinical Features — Symptoms")

# Central bold heading
add_rect(s, 0.4, 1.15, W - 0.8, 0.5, NAVY)
add_textbox(s, 0.5, 1.18, W - 1, 0.42,
            "What the patient complains of  (Symptoms are often insidious — diagnosis delayed by months to years)",
            font_size=13, italic=True, color=YELLOW_ACC)

# 3 columns
col_data = [
    ("GENERAL", [
        "Weight gain despite poor appetite",
        "Fatigue and lethargy",
        "Cold intolerance",
        "Puffiness of face",
        "Hair thinning / hair loss",
        "Dry skin",
    ], RED),
    ("SYSTEM-SPECIFIC", [
        "Constipation (GI)",
        "Menorrhagia / infertility (Gynae)",
        "Decreased libido",
        "Muscle cramps, weakness",
        "Hoarseness of voice",
        "Carpal tunnel syndrome",
    ], PURPLE),
    ("NEUROPSYCHIATRIC", [
        "Depression",
        'Psychosis ("Myxedema madness")',
        "Impaired memory, slow thinking",
        "Exertional dyspnoea",
        "Bradycardia symptoms",
        "Deafness (severe/congenital)",
    ], DARK_BLUE),
]
col_w = (W - 1.2) / 3
for i, (title, items, bg) in enumerate(col_data):
    cx = 0.4 + i * (col_w + 0.2)
    add_rect(s, cx, 1.8, col_w, 4.95, bg)
    add_rect(s, cx, 1.8, col_w, 0.45, NAVY)
    add_textbox(s, cx + 0.1, 1.83, col_w - 0.2, 0.38,
                title, font_size=13, bold=True, color=YELLOW_ACC)
    add_bullets(s, cx + 0.1, 2.3, col_w - 0.2, 4.2,
                ["• " + it for it in items], font_size=14, color=WHITE)

add_speaker_note(s,
    "Symptoms of hypothyroidism are non-specific and develop slowly, which is why patients often present late. "
    "The classic triad to remember is: weight gain, fatigue, and cold intolerance. "
    "Menorrhagia is the key gynaecological symptom. "
    "Neuropsychiatric symptoms include depression and memory impairment. "
    "Myxedema madness is a rare but important psychiatric manifestation.")

# ════════════════════════════════════════════════════════
# SLIDE 6 — CLINICAL FEATURES: SIGNS
# ════════════════════════════════════════════════════════
s = new_slide(ORANGE, "Clinical Features — Signs")

# Image on right
add_image(s, "signs_diagram", 6.9, 1.15, 6.0, 5.9)

# Signs list on left
add_rect(s, 0.4, 1.15, 6.2, 5.9, DARK_BLUE)
add_rect(s, 0.4, 1.15, 6.2, 0.45, NAVY)
add_textbox(s, 0.5, 1.18, 6.0, 0.38,
            "EXAMINATION FINDINGS", font_size=14, bold=True, color=YELLOW_ACC)

signs = [
    ("FACE & HAIR", [
        "Periorbital puffiness",
        "Loss of outer 1/3 of eyebrow (Hertoghe's sign)",
        "Dry, coarse skin — carotenemia (yellow tinge)",
        "Macroglossia (enlarged tongue)",
        "Hoarse voice",
    ]),
    ("CARDIOVASCULAR", [
        "Bradycardia",
        "Hypertension (diastolic)",
        "Pericardial effusion",
    ]),
    ("NEUROMUSCULAR", [
        "Slow-relaxing deep tendon reflexes (Woltman sign)",
        "Hyporeflexia",
        "Proximal myopathy",
    ]),
    ("OTHER", [
        "Non-pitting oedema (myxedema)",
        "Goitre (rubbery, firm in Hashimoto's)",
        "Pleural / ascitic effusion",
    ]),
]
ty = 1.72
for section, items in signs:
    add_textbox(s, 0.55, ty, 5.9, 0.35,
                section, font_size=12, bold=True, color=YELLOW_ACC)
    ty += 0.33
    for item in items:
        add_textbox(s, 0.65, ty, 5.7, 0.3,
                    "• " + item, font_size=13, color=WHITE)
        ty += 0.285

add_speaker_note(s,
    "Key signs to demonstrate in OSPE/clinical exams: "
    "Hertoghe's sign = loss of outer third of eyebrow. "
    "Woltman sign = slow-relaxing ankle jerks — this is pathognomonic. "
    "Periorbital puffiness is due to glycosaminoglycan deposition. "
    "Bradycardia and pericardial effusion can cause low-voltage ECG complexes. "
    "The diagram on the right summarises all body system findings — memorise it.")

# ════════════════════════════════════════════════════════
# SLIDE 7 — CLINICAL PHOTOGRAPHS
# ════════════════════════════════════════════════════════
s = new_slide(PURPLE, "Clinical Photographs")

photo_info = [
    ("myxedema_face",
     "Myxedematous Facies",
     "Periorbital puffiness, pallor, sparse eyebrows, dull expression"),
    ("myxedema_legs",
     "Pretibial Myxedema",
     "Non-pitting oedema, waxy thickened skin, ankle swelling"),
    ("congenital",
     "Congenital Hypothyroidism",
     "Macroglossia, umbilical hernia, abdominal distension — Before & After Rx"),
]
n = len(photo_info)
gap = 0.25
bw = (W - (n + 1) * gap) / n
for i, (key, title, caption) in enumerate(photo_info):
    bx = gap + i * (bw + gap)
    add_image(s, key, bx, 1.15, bw, 4.5)
    add_rect(s, bx, 5.7, bw, 1.25, NAVY)
    add_textbox(s, bx + 0.07, 5.73, bw - 0.14, 0.38,
                title, font_size=13, bold=True, color=YELLOW_ACC, align=PP_ALIGN.CENTER)
    add_textbox(s, bx + 0.07, 6.1, bw - 0.14, 0.82,
                caption, font_size=11, color=WHITE, align=PP_ALIGN.CENTER)

add_speaker_note(s,
    "Left: Classic myxedematous face — note periorbital puffiness, dull expression, sparse eyebrows. "
    "Middle: Pretibial myxedema — non-pitting, waxy oedema of the legs due to glycosaminoglycan deposition. "
    "Right: Congenital hypothyroidism — marked by macroglossia, umbilical hernia, abdominal distension. "
    "The right image shows before and after treatment — dramatic improvement with early L-thyroxine.")

# ════════════════════════════════════════════════════════
# SLIDE 8 — INVESTIGATIONS: TFTs & AUTOIMMUNE
# ════════════════════════════════════════════════════════
s = new_slide(GREEN, "Investigations — Part 1: TFTs & Autoimmune")

# Left: TFTs
add_rect(s, 0.4, 1.15, 6.1, 5.9, MID_BLUE)
add_rect(s, 0.4, 1.15, 6.1, 0.5, NAVY)
add_textbox(s, 0.5, 1.19, 5.9, 0.42,
            "THYROID FUNCTION TESTS (1st Line)", font_size=14, bold=True, color=YELLOW_ACC)
add_bullets(s, 0.5, 1.75, 5.9, 5.1, [
    "Serum TSH  — MOST SENSITIVE test",
    "   Normal: 0.4 - 4.0 mIU/L",
    "   Subclinical: 4 - 10 mIU/L",
    "   Overt: > 10 mIU/L",
    "",
    "Free T4 (FT4)",
    "   Low in primary hypothyroidism",
    "   Normal in subclinical",
    "",
    "Free T3 (FT3)",
    "   Low in overt disease",
    "   Not routinely measured",
    "",
    "Pattern in Primary: TSH  +  FT4 ",
    "Pattern in Secondary: TSH N/ + FT4 ",
    "",
    "Always do TSH FIRST (best single test)",
], font_size=14, color=WHITE)

# Right: Autoimmune
add_rect(s, 6.8, 1.15, 6.1, 5.9, TEAL)
add_rect(s, 6.8, 1.15, 6.1, 0.5, NAVY)
add_textbox(s, 6.9, 1.19, 5.9, 0.42,
            "AUTOIMMUNE MARKERS", font_size=14, bold=True, color=YELLOW_ACC)
add_bullets(s, 6.9, 1.75, 5.9, 5.1, [
    "Anti-TPO Antibodies",
    "   Most sensitive marker for Hashimoto's",
    "   Present in 90% of Hashimoto's cases",
    "   Also positive in Graves' disease",
    "",
    "Anti-Thyroglobulin Antibodies",
    "   Less specific than Anti-TPO",
    "   Used when Anti-TPO negative",
    "",
    "ANA (Antinuclear Antibody)",
    "   May be positive in autoimmune thyroiditis",
    "",
    "Clinical use:",
    "   Subclinical + TPO Ab +ve",
    "    higher risk of progression",
    "   Guides treatment decision",
    "   Useful for family counselling",
], font_size=14, color=WHITE)

add_speaker_note(s,
    "Always start with TSH — it is the most sensitive test and the best screening test. "
    "If TSH is elevated, follow up with FT4. "
    "Anti-TPO antibodies confirm Hashimoto's thyroiditis — they are present in 90% of cases. "
    "If a patient has subclinical hypothyroidism AND is Anti-TPO positive, they have a 2-5% per year risk of "
    "progressing to overt hypothyroidism — this influences the treatment decision.")

# ════════════════════════════════════════════════════════
# SLIDE 9 — INVESTIGATIONS: BIOCHEMISTRY & IMAGING
# ════════════════════════════════════════════════════════
s = new_slide(GREEN, "Investigations — Part 2: Biochemistry & Imaging")

# Left: Biochemistry
add_rect(s, 0.4, 1.15, 6.1, 5.9, ORANGE)
add_rect(s, 0.4, 1.15, 6.1, 0.5, NAVY)
add_textbox(s, 0.5, 1.19, 5.9, 0.42,
            "BIOCHEMISTRY", font_size=14, bold=True, color=WHITE)
add_bullets(s, 0.5, 1.75, 5.9, 5.1, [
    "Lipid Profile:",
    "   Total cholesterol  (cardiovascular risk)",
    "   LDL  |  Triglycerides ",
    "",
    "Serum Creatine Kinase (CK):",
    "   Elevated in hypothyroid myopathy",
    "",
    "Complete Blood Count:",
    "   Normocytic or macrocytic anaemia",
    "   (Also check B12, folate, iron)",
    "",
    "Serum Sodium:",
    "   Hyponatraemia (SIADH-like picture)",
    "",
    "Liver Function Tests:",
    "   Mild elevation of AST, ALT",
    "",
    "Serum Uric Acid: may be raised",
], font_size=14, color=WHITE)

# Right: Imaging & Other
add_rect(s, 6.8, 1.15, 6.1, 5.9, PURPLE)
add_rect(s, 6.8, 1.15, 6.1, 0.5, NAVY)
add_textbox(s, 6.9, 1.19, 5.9, 0.42,
            "IMAGING & SPECIAL TESTS", font_size=14, bold=True, color=YELLOW_ACC)
add_bullets(s, 6.9, 1.75, 5.9, 5.1, [
    "Ultrasound Thyroid:",
    "   Heterogeneous texture in Hashimoto's",
    "   Assess goitre size, nodules",
    "   Doppler: vascularity",
    "",
    "ECG Findings:",
    "   Sinus bradycardia",
    "   Low voltage complexes",
    "   Flat / inverted T waves",
    "   Prolonged QT interval",
    "",
    "Chest X-Ray:",
    "   Cardiomegaly (pericardial effusion)",
    "   Pleural effusion",
    "",
    "Echocardiography:",
    "   Confirm pericardial effusion",
    "",
    "Thyroid Scintigraphy: rarely needed",
    "TRH Stimulation Test: 2* vs 3* distinction",
], font_size=13.5, color=WHITE)

add_speaker_note(s,
    "Hypercholesterolaemia is a very important metabolic consequence — hypothyroidism is a reversible cause of "
    "secondary hyperlipidaemia. Always check TFTs in a patient with unexplained high cholesterol. "
    "ECG shows bradycardia and low-voltage complexes when there is a pericardial effusion. "
    "Ultrasound of the thyroid helps assess the gland in Hashimoto's — the texture becomes heterogeneous and echogenic.")

# ════════════════════════════════════════════════════════
# SLIDE 10 — MANAGEMENT: LEVOTHYROXINE
# ════════════════════════════════════════════════════════
s = new_slide(DARK_BLUE, "Management — Levothyroxine (L-T4)")

add_rect(s, 0.4, 1.15, W - 0.8, 0.55, INDIGO)
add_textbox(s, 0.5, 1.19, W - 1, 0.45,
            "Drug of Choice: Synthetic Levothyroxine (L-T4, Thyroxine) — Oral once daily",
            font_size=15, bold=True, color=YELLOW_ACC)

# Dosing box
add_rect(s, 0.4, 1.82, 6.1, 2.5, MID_BLUE)
add_rect(s, 0.4, 1.82, 6.1, 0.42, NAVY)
add_textbox(s, 0.5, 1.85, 5.9, 0.35, "DOSING", font_size=13, bold=True, color=YELLOW_ACC)
add_bullets(s, 0.5, 2.3, 5.9, 1.85, [
    "Average adult: 1.6 mcg/kg/day (~100 mcg/day)",
    "Young healthy adults: start at full dose",
    "Elderly: start at 25-50 mcg/day, titrate up",
    "Cardiac disease: start at 12.5-25 mcg/day",
    "Target TSH: 0.5-2.5 mIU/L",
], font_size=14.5, color=WHITE)

# Timing box
add_rect(s, 6.8, 1.82, 6.1, 2.5, TEAL)
add_rect(s, 6.8, 1.82, 6.1, 0.42, NAVY)
add_textbox(s, 6.9, 1.85, 5.9, 0.35, "ADMINISTRATION", font_size=13, bold=True, color=YELLOW_ACC)
add_bullets(s, 6.9, 2.3, 5.9, 1.85, [
    "Take on EMPTY STOMACH",
    "30-60 minutes before breakfast",
    "Same time every day (consistency key)",
    "Half-life = 7 days  steady state in 4-6 weeks",
    "Recheck TSH 4-6 weeks after dose change",
], font_size=14.5, color=WHITE)

# Drug interactions
add_rect(s, 0.4, 4.45, 6.1, 2.5, RED)
add_rect(s, 0.4, 4.45, 6.1, 0.42, NAVY)
add_textbox(s, 0.5, 4.48, 5.9, 0.35, "DRUG INTERACTIONS (reduce absorption)", font_size=13, bold=True, color=WHITE)
add_bullets(s, 0.5, 4.95, 5.9, 1.85, [
    "Calcium, Iron, Antacids (Al/Mg)",
    "Cholestyramine, Colestipol",
    "Proton pump inhibitors",
    "Separate by at least 4 hours",
], font_size=14.5, color=WHITE)

# Monitoring
add_rect(s, 6.8, 4.45, 6.1, 2.5, GREEN)
add_rect(s, 6.8, 4.45, 6.1, 0.42, NAVY)
add_textbox(s, 6.9, 4.48, 5.9, 0.35, "MONITORING", font_size=13, bold=True, color=YELLOW_ACC)
add_bullets(s, 6.9, 4.95, 5.9, 1.85, [
    "Check TSH at 4-6 weeks",
    "Annual TSH once stable",
    "Over-replacement: atrial fibrillation, osteoporosis",
    "Under-replacement: persistent symptoms",
    "Symptoms improve BEFORE TSH normalises",
], font_size=14.5, color=WHITE)

add_speaker_note(s,
    "Levothyroxine is the treatment of choice. The standard dose is 1.6 mcg/kg/day. "
    "Very important: always take on an empty stomach — calcium, iron, and antacids interfere with absorption. "
    "Because the half-life is 7 days, steady state is not reached for 4-6 weeks — so do NOT recheck TSH earlier than that. "
    "Over-treatment with L-T4 can cause atrial fibrillation and osteoporosis — key adverse effects to know.")

# ════════════════════════════════════════════════════════
# SLIDE 11 — MANAGEMENT: SPECIAL POPULATIONS
# ════════════════════════════════════════════════════════
s = new_slide(TEAL, "Management — Special Populations")

sp_boxes = [
    (0.4, 1.15, 6.1, 3.0, PURPLE,
     "PREGNANCY", [
        "Increase L-T4 dose by 25-30%",
        "as soon as pregnancy is confirmed",
        "",
        "Target TSH:",
        "  1st trimester: < 2.5 mIU/L",
        "  2nd-3rd trimester: < 3.0 mIU/L",
        "",
        "Untreated: miscarriage, preterm birth,",
        "  impaired fetal neurodevelopment",
        "",
        "Screen all pregnant women with TSH",
    ]),
    (6.8, 1.15, 6.1, 3.0, DARK_BLUE,
     "CONGENITAL HYPOTHYROIDISM", [
        "Screen on day 3-5 (heel prick TSH)",
        "Start L-T4 within 2 weeks of birth",
        "Dose: 10-15 mcg/kg/day initially",
        "",
        "If untreated: CRETINISM",
        "  Irreversible mental retardation",
        "  Short stature, deafness, spasticity",
        "",
        "If treated early: NORMAL development",
        "Monitor TSH every 3 months (0-3 yrs)",
    ]),
    (0.4, 4.3, 6.1, 2.7, RED,
     "SUBCLINICAL HYPOTHYROIDISM", [
        "Treat if TSH consistently > 10 mIU/L",
        "Treat if symptomatic",
        "Treat if pregnant/planning pregnancy",
        "Treat if Anti-TPO Ab positive",
        "Treat children and young adults",
        "",
        "Observe if TSH 4-10 + asymptomatic",
        "Recheck TFTs in 3-6 months",
    ]),
    (6.8, 4.3, 6.1, 2.7, GREEN,
     "ELDERLY & CARDIAC PATIENTS", [
        "Start very low: 12.5-25 mcg/day",
        "Increase by 12.5-25 mcg every 4-6 wks",
        "Target TSH: 1-4 mIU/L (slightly higher)",
        "",
        "Risk of angina/MI if started at full dose",
        "Risk of AF with over-replacement",
        "",
        "Reassess need every 6-12 months",
    ]),
]
for bx, by, bw, bh, bg, title, items in sp_boxes:
    add_rect(s, bx, by, bw, bh, bg)
    add_rect(s, bx, by, bw, 0.42, NAVY)
    add_textbox(s, bx + 0.1, by + 0.05, bw - 0.2, 0.35,
                title, font_size=13, bold=True, color=YELLOW_ACC)
    add_bullets(s, bx + 0.1, by + 0.5, bw - 0.2, bh - 0.6,
                items, font_size=13.5, color=WHITE)

add_speaker_note(s,
    "Four high-yield special populations: "
    "1. Pregnancy — increase the dose by 25-30% immediately, the fetus depends entirely on maternal T4 in the first trimester. "
    "2. Congenital — screen at day 3-5, treat within 2 weeks to prevent cretinism — this is irreversible. "
    "3. Subclinical — treat if TSH >10 or if the patient is symptomatic, pregnant, or Anti-TPO positive. "
    "4. Elderly/cardiac — start very low and titrate slowly to avoid precipitating angina or arrhythmia.")

# ════════════════════════════════════════════════════════
# SLIDE 12 — MYXEDEMA CRISIS
# ════════════════════════════════════════════════════════
s = new_slide(RED, "Myxedema Crisis (Myxedema Coma)")

add_rect(s, 0.4, 1.15, W - 0.8, 0.55, NAVY)
add_textbox(s, 0.5, 1.19, W - 1, 0.45,
            "Medical Emergency  |  Mortality: 30-60%  |  ICU admission mandatory",
            font_size=16, bold=True, color=RED)

boxes_mc = [
    (0.4,  1.82, 4.0, 5.2, DARK_BLUE, "PRECIPITANTS", [
        "Cold exposure",
        "Infection / sepsis",
        "Surgery / anaesthesia",
        "Trauma",
        "Drugs: opioids, sedatives",
        "Stopping L-T4 abruptly",
        "Stroke / MI",
    ]),
    (4.6,  1.82, 4.0, 5.2, PURPLE,    "CLINICAL FEATURES", [
        "Hypothermia (core temp < 35 C)",
        "Bradycardia",
        "Hypotension",
        "Hypoventilation / CO2 retention",
        "Altered consciousness / coma",
        "Seizures",
        "Profound myxedema",
        "Hyponatraemia, hypoglycaemia",
    ]),
    (8.8,  1.82, 4.1, 5.2, GREEN,     "TREATMENT", [
        "IV L-Thyroxine:",
        "  Loading: 200-400 mcg IV",
        "  Maintenance: 100 mcg IV daily",
        "",
        "IV Hydrocortisone:",
        "  100-200 mg IV",
        "  (Before thyroid Rx — rule out",
        "  co-existent adrenal insufficiency)",
        "",
        "Supportive ICU care:",
        "  Passive rewarming (active = vasodilation)",
        "  Oxygen / ventilator if needed",
        "  IV dextrose (hypoglycaemia)",
        "  Correct hyponatraemia slowly",
    ]),
]
for bx, by, bw, bh, bg, title, items in boxes_mc:
    add_rect(s, bx, by, bw, bh, bg)
    add_rect(s, bx, by, bw, 0.42, NAVY)
    add_textbox(s, bx + 0.1, by + 0.05, bw - 0.2, 0.35,
                title, font_size=13, bold=True, color=YELLOW_ACC)
    add_bullets(s, bx + 0.1, by + 0.5, bw - 0.2, bh - 0.6,
                items, font_size=13, color=WHITE)

add_speaker_note(s,
    "Myxedema crisis is a life-threatening emergency with 30-60% mortality. "
    "It is usually precipitated by cold, infection, or drugs in a patient with known or undiagnosed hypothyroidism. "
    "The classic picture is hypothermia, bradycardia, hypotension, and altered consciousness. "
    "Treatment: IV levothyroxine 200-400 mcg loading dose, then 100 mcg daily. "
    "Crucially, give IV hydrocortisone BEFORE the thyroid hormone — this prevents adrenal crisis "
    "which can be precipitated when thyroid hormone suddenly increases metabolic rate in an adrenally insufficient patient. "
    "Rewarm PASSIVELY — active external rewarming causes peripheral vasodilation and cardiovascular collapse.")

# ════════════════════════════════════════════════════════
# SLIDE 13 — CONGENITAL HYPOTHYROIDISM IN DETAIL
# ════════════════════════════════════════════════════════
s = new_slide(INDIGO, "Congenital Hypothyroidism — In Detail")

# Photo on left
add_image(s, "congenital", 0.4, 1.15, 5.0, 5.9)

# Text on right
add_rect(s, 5.8, 1.15, 7.1, 2.7, DARK_BLUE)
add_rect(s, 5.8, 1.15, 7.1, 0.42, NAVY)
add_textbox(s, 5.9, 1.18, 6.9, 0.35, "FEATURES", font_size=13, bold=True, color=YELLOW_ACC)
add_bullets(s, 5.9, 1.65, 6.9, 2.1, [
    "Prolonged neonatal jaundice (EARLIEST sign)",
    "Umbilical hernia, abdominal distension",
    "Macroglossia (enlarged tongue)",
    "Hypotonia, poor feeding, constipation",
    "Large fontanelles, coarse facies",
    "Hoarse cry, bradycardia, hypothermia",
], font_size=13.5, color=WHITE)

add_rect(s, 5.8, 4.0, 7.1, 3.0, TEAL)
add_rect(s, 5.8, 4.0, 7.1, 0.42, NAVY)
add_textbox(s, 5.9, 4.04, 6.9, 0.35, "SCREENING & TREATMENT", font_size=13, bold=True, color=YELLOW_ACC)
add_bullets(s, 5.9, 4.5, 6.9, 2.35, [
    "Incidence: 1 in 3,000-4,000 live births",
    "Most common PREVENTABLE cause of mental retardation",
    "Heel prick TSH screen: day 3-5 of life",
    "Treatment: L-T4 10-15 mcg/kg/day within 2 weeks",
    "Outcome: Normal intellect if treated early",
    "If untreated: Cretinism (irreversible)",
    "   Mental retardation, short stature, deafness",
], font_size=13.5, color=WHITE)

add_speaker_note(s,
    "Congenital hypothyroidism is the most common preventable cause of mental retardation worldwide. "
    "Newborn screening (heel prick TSH) on day 3-5 is now standard in most countries. "
    "The earliest clinical sign is prolonged neonatal jaundice. "
    "Treatment must be started within 2 weeks — delay beyond this causes irreversible brain damage. "
    "The photograph shows classic features: macroglossia, pot belly from abdominal distension and umbilical hernia. "
    "With early treatment, the child can develop completely normally.")

# ════════════════════════════════════════════════════════
# SLIDE 14 — SUMMARY TABLE
# ════════════════════════════════════════════════════════
s = new_slide(DARK_BLUE, "Summary — At a Glance")

# Table grid
rows = [
    ("PARAMETER",         "PRIMARY",               "SECONDARY",              "SUBCLINICAL"),
    ("TSH",               "High (>10)",             "Low / Normal",           "4-10 mIU/L"),
    ("FT4",               "Low",                    "Low",                    "Normal"),
    ("Cause",             "Hashimoto's / Iodine",   "Pituitary failure",      "Autoimmune / Drug"),
    ("Symptoms",          "Present, obvious",       "Often mild",             "Absent / vague"),
    ("Treatment",         "L-T4 1.6 mcg/kg/day",   "L-T4 + treat cause",     "If TSH>10, symptomatic"),
    ("Anti-TPO",          "Often +ve",              "Usually -ve",            "+ve = treat"),
]
col_ws = [3.2, 3.3, 3.3, 3.2]
col_xs = [0.4, 3.7, 7.1, 10.5]
row_h = 0.72
row_bgs = [NAVY, MID_BLUE, INDIGO, MID_BLUE, INDIGO, MID_BLUE, INDIGO]
header_fg = YELLOW_ACC

for ri, row in enumerate(rows):
    by = 1.2 + ri * row_h
    bg = row_bgs[ri % len(row_bgs)]
    for ci, (cell, cx, cw) in enumerate(zip(row, col_xs, col_ws)):
        add_rect(s, cx, by, cw - 0.06, row_h - 0.04, bg)
        fsize = 13 if ri > 0 else 14
        bold  = (ri == 0 or ci == 0)
        fc    = YELLOW_ACC if (ri == 0 or ci == 0) else WHITE
        add_textbox(s, cx + 0.1, by + 0.1, cw - 0.26, row_h - 0.14,
                    cell, font_size=fsize, bold=bold, color=fc)

add_speaker_note(s,
    "This summary table is excellent for quick exam revision. "
    "Key pattern: In primary hypothyroidism TSH is HIGH and FT4 is LOW. "
    "In secondary (pituitary), TSH is low or normal despite low FT4. "
    "In subclinical, FT4 is normal. "
    "Anti-TPO positivity in subclinical disease is a reason to treat.")

# ════════════════════════════════════════════════════════
# SLIDE 15 — KEY TAKEAWAYS
# ════════════════════════════════════════════════════════
s = prs.slides.add_slide(blank)
add_rect(s, 0, 0, W, H, DARK_BLUE)
add_rect(s, 0, H - 0.32, W, 0.32, NAVY)
add_textbox(s, 0, H - 0.30, W, 0.28,
            "Hypothyroidism  |  Mokshit Panwar  |  Roll No. 68",
            font_size=9, color=WHITE, align=PP_ALIGN.CENTER)

add_rect(s, 0, 0, W, 0.95, AMBER)
add_textbox(s, 0.3, 0.07, W - 0.6, 0.82,
            "KEY TAKEAWAYS  —  HYPOTHYROIDISM",
            font_size=28, bold=True, color=DARK_BLUE, align=PP_ALIGN.CENTER)

key_pts = [
    ("1", "MC cause (developed world) = Hashimoto's Thyroiditis (Anti-TPO +ve)  |  MC worldwide = Iodine Deficiency"),
    ("2", "Best screening test = Serum TSH.  Overt: TSH >10 + low FT4.  Subclinical: TSH 4-10 + normal FT4"),
    ("3", "Hertoghe's sign (loss of outer 1/3 eyebrow)  |  Woltman sign (slow-relaxing ankle jerks) — high yield"),
    ("4", "Hypothyroidism = reversible cause of secondary hypercholesterolaemia — always check TFTs"),
    ("5", "Drug of choice = L-Thyroxine 1.6 mcg/kg/day on empty stomach; recheck TSH at 4-6 weeks"),
    ("6", "Pregnancy: Increase dose by 25-30%; Target TSH < 2.5 mIU/L (1st trimester)"),
    ("7", "Congenital: Screen day 3-5; Treat within 2 weeks to prevent irreversible cretinism"),
    ("8", "Myxedema Crisis: IV L-T4 200-400 mcg loading + IV Hydrocortisone 100-200 mg; mortality 30-60%"),
    ("9", "Drugs causing hypothyroidism: Lithium, Amiodarone (14%), Sunitinib, alpha-IFN, IL-2, Valproate"),
]

KH = (H - 1.02 - 0.38) / len(key_pts)
for i, (num, text) in enumerate(key_pts):
    by = H - 1.02 - (i + 1) * KH
    # Alternating row shades
    bg_col = RGBColor(0x1A, 0x23, 0x7E) if i % 2 == 0 else RGBColor(0x28, 0x35, 0x93)
    add_rect(s, 0.3, by, W - 0.6, KH - 0.03, bg_col)
    # Number circle background
    add_rect(s, 0.32, by + 0.02, 0.42, KH - 0.07, AMBER)
    add_textbox(s, 0.32, by + 0.04, 0.42, KH - 0.1,
                num, font_size=14, bold=True, color=DARK_BLUE, align=PP_ALIGN.CENTER)
    add_textbox(s, 0.82, by + 0.05, W - 1.2, KH - 0.1,
                text, font_size=12.5, color=WHITE)

add_speaker_note(s,
    "These are the 9 most high-yield points for exams and viva. "
    "Particularly important: Woltman sign (slow-relaxing reflexes) is pathognomonic. "
    "Hypothyroidism causing hypercholesterolaemia is a classic secondary cause of dyslipidaemia. "
    "Myxedema crisis management — always give steroids first. "
    "Drug-induced: Amiodarone is the most frequently tested drug. Thank you!")

# ── Save ─────────────────────────────────────────────────
out = "/tmp/workspace/hypothyroidism-ppt/Hypothyroidism_Mokshit_Panwar_v2.pptx"
prs.save(out)
print(f"Saved: {out}")
Running Command

cd /tmp/workspace/hypothyroidism-ppt && python create_ppt_v2.py 2>&1

Writing File

~/hypothyroidism-ppt/create_pdf_v2.py

"""
Hypothyroidism - Class Presentation PDF v2
Landscape A4, clean lecture style, large fonts, speaker notes as footnote captions.
Mirrors the PPT v2 structure: 15 pages.
"""
import requests
from io import BytesIO
from PIL import Image as PILImage
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import A4, landscape
from reportlab.lib import colors
from reportlab.lib.utils import ImageReader

PAGE_W, PAGE_H = landscape(A4)

# ── Palette ──────────────────────────────────────────────
C = {
    "dark_blue":  colors.HexColor("#0D47A1"),
    "mid_blue":   colors.HexColor("#1565C0"),
    "teal":       colors.HexColor("#00897B"),
    "amber":      colors.HexColor("#FF8F00"),
    "red":        colors.HexColor("#C62828"),
    "orange":     colors.HexColor("#E65100"),
    "purple":     colors.HexColor("#6A1B9A"),
    "green":      colors.HexColor("#2E7D32"),
    "white":      colors.white,
    "light_gray": colors.HexColor("#EEF2FF"),
    "dark_text":  colors.HexColor("#1A1A2E"),
    "yellow":     colors.HexColor("#FFD600"),
    "indigo":     colors.HexColor("#283593"),
    "navy":       colors.HexColor("#0A2472"),
    "soft_blue":  colors.HexColor("#BBDEFB"),
    "cyan":       colors.HexColor("#006064"),
}

IMAGE_URLS = {
    "signs_diagram": "https://cdn.orris.care/cdss_images/053b9bb265b63714c4a536636d315c8c10972d68fe82e00691f22c7acff56972.png",
    "hpt_axis":      "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_6f82970f9f7319e651f853444406dd2b35b7feffc3334ebb3c549f9b030a044f.jpg",
    "myxedema_face": "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_004376e56882f1544f2c61db75df95bbb940d303665f105b602921ddef336433.jpg",
    "congenital":    "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_21eff5b66b62dfc0c59899e9eba5d20699765566b7e304af716c2a545b1b97ff.jpg",
    "myxedema_legs": "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_5ca4d51c24fef39d7592d3972d48133127a4ef92b28178dcc0aec50ff6784604.jpg",
}

img_data = {}
for key, url in IMAGE_URLS.items():
    try:
        r = requests.get(url, timeout=15); r.raise_for_status()
        img_data[key] = r.content
    except Exception as e:
        print(f"Failed {key}: {e}"); img_data[key] = None
print("Images:", {k: v is not None for k, v in img_data.items()})

def ir(key):
    d = img_data.get(key)
    if d is None: return None, 0, 0
    buf = BytesIO(d)
    pil = PILImage.open(buf)
    iw, ih = pil.size
    buf.seek(0)
    return ImageReader(buf), iw, ih

# ── Drawing helpers ───────────────────────────────────────
FOOTER_H = 22
HEADER_H = 60
ACCENT_H = 5
MARGIN   = 12

CT  = PAGE_H - HEADER_H - ACCENT_H - 4   # content top y
CB  = FOOTER_H + 4                        # content bottom y
CW  = PAGE_W - 2 * MARGIN                # content width

def bg(c, col): c.setFillColor(col); c.rect(0,0,PAGE_W,PAGE_H,fill=1,stroke=0)
def header(c, col, title, accent_col=None):
    ac = accent_col or C["amber"]
    c.setFillColor(col); c.rect(0, PAGE_H-HEADER_H, PAGE_W, HEADER_H, fill=1, stroke=0)
    c.setFillColor(ac);  c.rect(0, PAGE_H-HEADER_H-ACCENT_H, PAGE_W, ACCENT_H, fill=1, stroke=0)
    c.setFillColor(C["white"]); c.setFont("Helvetica-Bold", 26)
    c.drawString(MARGIN+4, PAGE_H-HEADER_H+16, title)
def footer(c, pg_num=None):
    c.setFillColor(C["navy"]); c.rect(0,0,PAGE_W,FOOTER_H,fill=1,stroke=0)
    c.setFillColor(C["white"]); c.setFont("Helvetica", 8)
    c.drawCentredString(PAGE_W/2, 7, "Hypothyroidism  |  Mokshit Panwar  |  Roll No. 68")
    if pg_num:
        c.drawRightString(PAGE_W-10, 7, str(pg_num))
def cbox(c, x, y, w, h, col, radius=5):
    c.setFillColor(col); c.roundRect(x, y, w, h, radius, fill=1, stroke=0)
def title_strip(c, x, y_top, w, text, bg_col, fg_col=None, fs=12):
    fg = fg_col or C["yellow"]
    c.setFillColor(colors.HexColor("#00000055")); c.rect(x, y_top-22, w, 22, fill=1, stroke=0)
    c.setFillColor(fg); c.setFont("Helvetica-Bold", fs); c.drawString(x+6, y_top-16, text)
def text_lines(c, x, y, lines, fs=11, col=None, lh=14):
    col = col or C["white"]
    c.setFont("Helvetica", fs); c.setFillColor(col)
    for line in lines:
        if y < CB: break
        c.drawString(x, y, line); y -= lh
    return y
def draw_img(c, key, x, y, max_w, max_h):
    reader, iw, ih = ir(key)
    if reader is None: return
    scale = min(max_w/iw, max_h/ih)
    dw, dh = iw*scale, ih*scale
    ox, oy = x+(max_w-dw)/2, y+(max_h-dh)/2
    c.drawImage(reader, ox, oy, dw, dh, preserveAspectRatio=True, mask='auto')
def note_box(c, text):
    c.setFillColor(colors.HexColor("#F0F4FF"))
    # speaker note at bottom above footer
    c.roundRect(MARGIN, CB, CW, 18, 3, fill=1, stroke=0)
    c.setFillColor(C["dark_text"]); c.setFont("Helvetica-Oblique", 7.5)
    c.drawString(MARGIN+5, CB+5, text[:200])

OUT = "/tmp/workspace/hypothyroidism-ppt/Hypothyroidism_Mokshit_Panwar_v2.pdf"
c = canvas.Canvas(OUT, pagesize=landscape(A4))
c.setTitle("Hypothyroidism – Mokshit Panwar Roll 68")

pg = [0]
def new_page():
    pg[0] += 1
    if pg[0] > 1: c.showPage()

# ══════════════════════════════════════════
# PAGE 1 — TITLE
# ══════════════════════════════════════════
new_page()
bg(c, C["dark_blue"])
c.setFillColor(C["amber"]); c.rect(0, PAGE_H*0.42, PAGE_W, 5, fill=1, stroke=0)
c.setFillColor(C["white"]); c.setFont("Helvetica-Bold", 66)
c.drawCentredString(PAGE_W/2, PAGE_H*0.56, "HYPOTHYROIDISM")
c.setFillColor(C["yellow"]); c.setFont("Helvetica-Bold", 20)
c.drawCentredString(PAGE_W/2, PAGE_H*0.44, "Clinical Features  |  Investigations  |  Management")
c.setFillColor(C["soft_blue"]); c.setFont("Helvetica-Oblique", 14)
c.drawCentredString(PAGE_W/2, PAGE_H*0.37, "An Underactive Thyroid — A Hypometabolic State")
# Student card
c.setFillColor(C["navy"]); c.roundRect(PAGE_W/2-200, PAGE_H*0.17, 400, 54, 8, fill=1, stroke=0)
c.setFillColor(C["amber"]);  c.rect(PAGE_W/2-200, PAGE_H*0.17+50, 400, 4, fill=1, stroke=0)
c.setFillColor(C["white"]); c.setFont("Helvetica-Bold", 15)
c.drawCentredString(PAGE_W/2, PAGE_H*0.24, "Presented by: Mokshit Panwar   |   Roll No. 68")
c.setFillColor(C["soft_blue"]); c.setFont("Helvetica-Oblique", 10)
c.drawCentredString(PAGE_W/2, PAGE_H*0.19, "Reference: Tintinalli's Emergency Medicine  |  Family Medicine 9e")
footer(c, 1)

# ══════════════════════════════════════════
# PAGE 2 — DEFINITION & OVERVIEW
# ══════════════════════════════════════════
new_page()
bg(c, C["light_gray"]); header(c, C["dark_blue"], "What is Hypothyroidism?")
footer(c, 2)
# Definition strip
cbox(c, MARGIN, CT-50, CW, 50, C["indigo"])
c.setFillColor(C["yellow"]); c.setFont("Helvetica-Bold", 11); c.drawString(MARGIN+8, CT-18, "DEFINITION")
c.setFillColor(C["white"]); c.setFont("Helvetica", 12.5)
c.drawString(MARGIN+8, CT-34, "A hypometabolic state from insufficient thyroid hormone production or action.")
c.drawString(MARGIN+8, CT-48, "TSH >10 mIU/L + low FT4 = Overt  |  TSH 4-10 + normal FT4 = Subclinical  |  Low TSH + low FT4 = Secondary")
# Two columns
col_w2 = (CW - 10) / 2
bh2 = CT - 50 - CB - 25
cbox(c, MARGIN, CB+24, col_w2, bh2, C["mid_blue"])
title_strip(c, MARGIN, CB+24+bh2, col_w2, "TSH CLASSIFICATION")
text_lines(c, MARGIN+6, CB+24+bh2-30, [
    "Overt Hypothyroidism:",
    "  TSH > 10 mIU/L + Low FT4",
    "  Symptomatic, needs treatment",
    "",
    "Subclinical Hypothyroidism:",
    "  TSH 4-10 mIU/L + Normal FT4",
    "  Often asymptomatic",
    "",
    "Secondary / Tertiary:",
    "  TSH low/normal + Low FT4",
    "  Pituitary or hypothalamic cause",
], fs=12, lh=15)
cbox(c, MARGIN+col_w2+10, CB+24, col_w2, bh2, C["teal"])
title_strip(c, MARGIN+col_w2+10, CB+24+bh2, col_w2, "EPIDEMIOLOGY")
text_lines(c, MARGIN+col_w2+16, CB+24+bh2-30, [
    "Prevalence: 4-10% of adults",
    "Women > Men (5-8x more common)",
    "",
    "Most Common Cause (Developed world):",
    "  Hashimoto's Thyroiditis (Auto-immune)",
    "  Anti-TPO antibodies positive",
    "",
    "Most Common Cause (Worldwide):",
    "  Iodine Deficiency",
    "",
    "Congenital: 1 in 3,000-4,000 births",
], fs=12, lh=15)
note_box(c, "SPEAKER NOTE: TSH is the most sensitive test. Primary = TSH HIGH. Secondary = TSH low/normal. Hashimoto's = MC in developed countries. Iodine deficiency = MC worldwide.")

# ══════════════════════════════════════════
# PAGE 3 — AETIOLOGY
# ══════════════════════════════════════════
new_page()
bg(c, C["light_gray"]); header(c, C["teal"], "Aetiology — Causes of Hypothyroidism")
footer(c, 3)
bw3 = (CW - 10) / 2
bh3 = (CT - CB - 30) / 2

boxes3 = [
    (MARGIN,         CB+26+bh3, C["green"],  "PRIMARY (Thyroid Gland Failure)", [
        "Hashimoto's thyroiditis (MC — developed world)",
        "Iodine deficiency (MC worldwide)",
        "Post-radioiodine ablation",
        "Post-thyroidectomy (surgical)",
        "Congenital (aplasia / dyshormonogenesis)",
    ]),
    (MARGIN+bw3+10,  CB+26+bh3, C["purple"], "SECONDARY / TERTIARY", [
        "Pituitary failure (Sheehan's, tumour)",
        "Hypothalamic failure (TRH deficiency)",
        "Cranial irradiation",
        "Head trauma",
    ]),
    (MARGIN,         CB+24,     C["red"],    "DRUG-INDUCED", [
        "Lithium (inhibits hormone release)",
        "Amiodarone (up to 14% incidence)",
        "Sunitinib / Sorafenib (TKIs)",
        "Alpha-Interferon, Interleukin-2",
        "Valproate, Carbamazepine",
    ]),
    (MARGIN+bw3+10,  CB+24,     C["amber"],  "TRANSIENT / SPECIAL FORMS", [
        "Post-partum thyroiditis",
        "Subacute (de Quervain's) thyroiditis",
        "Riedel's (fibrous) thyroiditis",
        "Thyroid infiltration: amyloid, sarcoid, lymphoma",
    ]),
]
for bx3, by3, bg3, title3, items3 in boxes3:
    cbox(c, bx3, by3, bw3, bh3-2, bg3)
    title_strip(c, bx3, by3+bh3-2, bw3, title3, fs=12)
    text_lines(c, bx3+6, by3+bh3-30, ["• "+l for l in items3], fs=12, lh=15)
note_box(c, "SPEAKER NOTE: Drug-induced: Amiodarone is most tested. Lithium is high-yield. Post-partum thyroiditis is common in young women after delivery.")

# ══════════════════════════════════════════
# PAGE 4 — PATHOPHYSIOLOGY
# ══════════════════════════════════════════
new_page()
bg(c, C["light_gray"]); header(c, C["indigo"], "Pathophysiology — HPT Axis")
footer(c, 4)
# Left text blocks
lw4 = PAGE_W * 0.44 - MARGIN
bh4 = (CT - CB - 26) / 3
blocks4 = [
    (C["dark_blue"], "HPT AXIS FEEDBACK LOOP", [
        "Hypothalamus  TRH  Pituitary  TSH  Thyroid  T4/T3",
        "T4 : T3 secretion ratio = 10 : 1",
        "80% of T3 comes from peripheral T4 deiodination",
        "T4 half-life = 7 days   |   T3 half-life = 1 day",
        "In hypothyroidism: T4/T3  TRH  TSH (feedback broken)",
    ]),
    (C["teal"],      "METABOLIC CONSEQUENCES", [
        "BMR  weight gain, cold intolerance, fatigue",
        "Na/K ATPase  reduced thermogenesis",
        "Glycosaminoglycan accumulation  myxedema",
        "Cardiac output  bradycardia, effusion",
        "Gut motility  constipation, ileus",
    ]),
    (C["purple"],    "HASHIMOTO'S (MC — Developed World)", [
        "Autoimmune lymphocytic infiltration",
        "Anti-TPO antibodies — most sensitive marker",
        "HLA-DR3, DR5 association",
        "Goitre (firm, rubbery) in early stage",
        "Atrophic variant in late stage",
    ]),
]
cy4 = CT - 4
for bgc4, t4, ls4 in blocks4:
    cbox(c, MARGIN, cy4-bh4+2, lw4, bh4-4, bgc4)
    title_strip(c, MARGIN, cy4, lw4, t4)
    text_lines(c, MARGIN+6, cy4-28, ["• "+l for l in ls4], fs=11.5, lh=14)
    cy4 -= bh4
# Right image
rx4 = PAGE_W*0.46; rw4 = PAGE_W-rx4-MARGIN; ry4 = CB+24; rh4 = CT-CB-28
draw_img(c, "hpt_axis", rx4, ry4, rw4, rh4)
note_box(c, "SPEAKER NOTE: TSH is the most sensitive marker. T4 is the main secretory product. T3 is the active form (from peripheral conversion). In primary hypothyroidism TSH keeps rising.")

# ══════════════════════════════════════════
# PAGE 5 — SYMPTOMS
# ══════════════════════════════════════════
new_page()
bg(c, C["light_gray"]); header(c, C["red"], "Clinical Features — Symptoms")
footer(c, 5)
cbox(c, MARGIN, CT-36, CW, 36, C["navy"])
c.setFillColor(C["yellow"]); c.setFont("Helvetica-Oblique", 12)
c.drawString(MARGIN+8, CT-14, "Symptoms are insidious — diagnosis often delayed months to years")
c.setFillColor(C["white"]); c.setFont("Helvetica", 11.5)
c.drawString(MARGIN+8, CT-28, "What the patient complains of:")
bw5 = (CW-16) / 3; bh5 = CT-36-CB-24
cols5 = [
    (MARGIN,              C["red"],       "GENERAL", [
        "Weight gain (despite poor appetite)",
        "Fatigue and lethargy",
        "Cold intolerance",
        "Puffiness of face / eyelids",
        "Hair thinning / diffuse hair loss",
        "Dry, coarse skin",
    ]),
    (MARGIN+bw5+8,        C["purple"],    "SYSTEM-SPECIFIC", [
        "Constipation (GI)",
        "Menorrhagia / infertility (Gynae)",
        "Decreased libido",
        "Muscle cramps and weakness",
        "Hoarseness of voice",
        "Carpal tunnel syndrome",
    ]),
    (MARGIN+2*(bw5+8),    C["dark_blue"], "NEUROPSYCHIATRIC", [
        "Depression",
        'Psychosis ("Myxedema madness")',
        "Impaired memory, slow thinking",
        "Exertional dyspnoea",
        "Bradycardia-related symptoms",
        "Deafness (severe/congenital cases)",
    ]),
]
for bx5, bg5, t5, ls5 in cols5:
    cbox(c, bx5, CB+22, bw5, bh5, bg5)
    title_strip(c, bx5, CB+22+bh5, bw5, t5)
    text_lines(c, bx5+6, CB+22+bh5-28, ["• "+l for l in ls5], fs=12, lh=15)
note_box(c, "SPEAKER NOTE: Classic triad = Weight gain + Fatigue + Cold intolerance. Menorrhagia is key gynaecological symptom. Myxedema madness = rare psychiatric form.")

# ══════════════════════════════════════════
# PAGE 6 — SIGNS
# ══════════════════════════════════════════
new_page()
bg(c, C["light_gray"]); header(c, C["orange"], "Clinical Features — Signs")
footer(c, 6)
# Left: signs
lw6 = PAGE_W*0.44 - MARGIN
cbox(c, MARGIN, CB+22, lw6, CT-CB-26, C["dark_blue"])
title_strip(c, MARGIN, CT-4, lw6, "EXAMINATION FINDINGS")
signs6 = [
    "FACE & HAIR:",
    "  Periorbital puffiness",
    "  Loss of outer 1/3 eyebrow (Hertoghe's sign)",
    "  Macroglossia  |  Hoarse voice",
    "  Dry, coarse skin, carotenemia",
    "",
    "CARDIOVASCULAR:",
    "  Bradycardia  |  Diastolic hypertension",
    "  Pericardial effusion (low voltage ECG)",
    "",
    "NEUROMUSCULAR:",
    "  Slow-relaxing deep tendon reflexes (Woltman sign)",
    "  Hyporeflexia  |  Proximal myopathy",
    "",
    "OTHER:",
    "  Non-pitting oedema (myxedema)",
    "  Goitre (rubbery, firm — Hashimoto's)",
    "  Pleural / ascitic effusion",
]
text_lines(c, MARGIN+6, CT-28, signs6, fs=12, col=C["white"], lh=15)
# Right: image
rx6 = PAGE_W*0.47; rw6 = PAGE_W-rx6-MARGIN; ry6 = CB+22; rh6 = CT-CB-26
draw_img(c, "signs_diagram", rx6, ry6, rw6, rh6)
note_box(c, "SPEAKER NOTE: Hertoghe's sign = loss of outer 1/3 eyebrow. Woltman sign = slow-relaxing ankle jerks — pathognomonic. Periorbital puffiness from glycosaminoglycan deposition.")

# ══════════════════════════════════════════
# PAGE 7 — CLINICAL PHOTOGRAPHS
# ══════════════════════════════════════════
new_page()
bg(c, C["light_gray"]); header(c, C["purple"], "Clinical Photographs")
footer(c, 7)
photos7 = [
    ("myxedema_face", "Myxedematous Facies", "Periorbital puffiness, pallor, sparse eyebrows"),
    ("myxedema_legs", "Pretibial Myxedema",  "Non-pitting oedema, waxy skin, ankle swelling"),
    ("congenital",    "Congenital Hypothyroidism", "Macroglossia, umbilical hernia — Before & After Rx"),
]
n7 = len(photos7); gap7 = 10
bw7 = (PAGE_W - (n7+1)*gap7) / n7
img_h7 = CT - CB - 50
for i7, (key7, title7, cap7) in enumerate(photos7):
    bx7 = gap7 + i7*(bw7+gap7)
    draw_img(c, key7, bx7, CB+46, bw7, img_h7)
    cbox(c, bx7, CB+22, bw7, 44, C["navy"])
    c.setFillColor(C["yellow"]); c.setFont("Helvetica-Bold", 10.5)
    c.drawCentredString(bx7+bw7/2, CB+55, title7)
    c.setFillColor(C["white"]); c.setFont("Helvetica", 9)
    c.drawCentredString(bx7+bw7/2, CB+42, cap7)
note_box(c, "SPEAKER NOTE: Left = myxedematous face. Middle = pretibial myxedema (non-pitting). Right = congenital hypothyroidism before and after L-T4 treatment.")

# ══════════════════════════════════════════
# PAGE 8 — INVESTIGATIONS: TFTs & AUTOIMMUNE
# ══════════════════════════════════════════
new_page()
bg(c, C["light_gray"]); header(c, C["green"], "Investigations — TFTs & Autoimmune Markers")
footer(c, 8)
bw8 = (CW - 10) / 2; bh8 = CT - CB - 26
# Left TFTs
cbox(c, MARGIN, CB+24, bw8, bh8, C["mid_blue"])
title_strip(c, MARGIN, CB+24+bh8, bw8, "THYROID FUNCTION TESTS (1st Line)")
text_lines(c, MARGIN+6, CB+24+bh8-28, [
    "Serum TSH  — MOST SENSITIVE test",
    "  Normal: 0.4-4.0 mIU/L",
    "  Subclinical: 4-10 mIU/L",
    "  Overt: > 10 mIU/L",
    "",
    "Free T4 (FT4)",
    "  Low in primary | Normal in subclinical",
    "",
    "Free T3 (FT3)",
    "  Low in overt disease",
    "",
    "Primary pattern: TSH HIGH + FT4 LOW",
    "Secondary: TSH low/normal + FT4 LOW",
    "",
    "ALWAYS start with TSH first",
], fs=12, lh=15)
# Right Autoimmune
cbox(c, MARGIN+bw8+10, CB+24, bw8, bh8, C["teal"])
title_strip(c, MARGIN+bw8+10, CB+24+bh8, bw8, "AUTOIMMUNE MARKERS")
text_lines(c, MARGIN+bw8+16, CB+24+bh8-28, [
    "Anti-TPO Antibodies",
    "  Most sensitive for Hashimoto's",
    "  Present in 90% of cases",
    "",
    "Anti-Thyroglobulin Antibodies",
    "  Less specific, used if TPO negative",
    "",
    "ANA — may be positive",
    "",
    "Clinical significance:",
    "  Subclinical + TPO Ab positive",
    "   higher risk of progression",
    "  Guides treatment decision",
    "  Important for family counselling",
], fs=12, lh=15)
note_box(c, "SPEAKER NOTE: TSH is the single best test. Anti-TPO present in 90% of Hashimoto's. TPO Ab positivity in subclinical disease = 2-5%/yr progression risk.")

# ══════════════════════════════════════════
# PAGE 9 — INVESTIGATIONS: BIOCHEM & IMAGING
# ══════════════════════════════════════════
new_page()
bg(c, C["light_gray"]); header(c, C["green"], "Investigations — Biochemistry & Imaging")
footer(c, 9)
bw9 = (CW - 10) / 2; bh9 = CT - CB - 26
# Left
cbox(c, MARGIN, CB+24, bw9, bh9, C["orange"])
title_strip(c, MARGIN, CB+24+bh9, bw9, "BIOCHEMISTRY", fg_col=C["white"])
text_lines(c, MARGIN+6, CB+24+bh9-28, [
    "Lipid profile:",
    "  Total cholesterol raised (LDL, TGs)",
    "  Reversible cause of hyperlipidaemia",
    "",
    "Serum CK: elevated (myopathy)",
    "",
    "CBC: normocytic / macrocytic anaemia",
    "(Check B12, folate, iron)",
    "",
    "Hyponatraemia (SIADH-like picture)",
    "",
    "LFTs: mild AST/ALT elevation",
    "",
    "Uric acid: may be raised",
], fs=12, lh=15)
# Right
cbox(c, MARGIN+bw9+10, CB+24, bw9, bh9, C["purple"])
title_strip(c, MARGIN+bw9+10, CB+24+bh9, bw9, "IMAGING & SPECIAL TESTS")
text_lines(c, MARGIN+bw9+16, CB+24+bh9-28, [
    "Ultrasound thyroid:",
    "  Heterogeneous texture (Hashimoto's)",
    "  Goitre size, nodule assessment",
    "",
    "ECG:",
    "  Sinus bradycardia",
    "  Low voltage complexes",
    "  Flat/inverted T waves, long QT",
    "",
    "Chest X-ray:",
    "  Cardiomegaly (pericardial effusion)",
    "  Pleural effusion",
    "",
    "Echo: confirm pericardial effusion",
    "TRH test: distinguish 2* from 3* hypothyroidism",
], fs=12, lh=15)
note_box(c, "SPEAKER NOTE: Hypothyroidism = reversible secondary hyperlipidaemia — always check TFTs in unexplained high cholesterol. ECG shows bradycardia and low voltage in effusion.")

# ══════════════════════════════════════════
# PAGE 10 — MANAGEMENT: LEVOTHYROXINE
# ══════════════════════════════════════════
new_page()
bg(c, C["light_gray"]); header(c, C["dark_blue"], "Management — Levothyroxine (L-T4)")
footer(c, 10)
# Intro banner
cbox(c, MARGIN, CT-38, CW, 38, C["indigo"])
c.setFillColor(C["yellow"]); c.setFont("Helvetica-Bold", 13)
c.drawString(MARGIN+8, CT-16, "Drug of Choice: Synthetic Levothyroxine (L-T4)  —  Oral, Once Daily")
c.setFillColor(C["white"]); c.setFont("Helvetica", 12)
c.drawString(MARGIN+8, CT-32, "Average dose: 1.6 mcg/kg/day (~100 mcg/day in adults)")

bw10 = (CW-10)/2; bh10 = (CT-38-CB-28)/2
positions10 = [
    (MARGIN,       CB+26+bh10, C["mid_blue"],  "DOSING",          [
        "Full dose in young healthy adults",
        "Elderly: start 25-50 mcg, titrate slowly",
        "Cardiac: start 12.5-25 mcg/day",
        "Target TSH: 0.5-2.5 mIU/L",
        "Elderly target: 1-4 mIU/L",
    ]),
    (MARGIN+bw10+10, CB+26+bh10, C["teal"],   "ADMINISTRATION",  [
        "Take on EMPTY STOMACH",
        "30-60 min before breakfast",
        "Half-life = 7 days",
        "Steady state in 4-6 weeks",
        "Same time every day",
    ]),
    (MARGIN,       CB+24,       C["red"],      "DRUG INTERACTIONS (reduce absorption)", [
        "Calcium, Iron, Antacids (Al/Mg)",
        "Cholestyramine, Colestipol",
        "Proton pump inhibitors",
        "Separate by at least 4 hours",
    ]),
    (MARGIN+bw10+10, CB+24,     C["green"],   "MONITORING",      [
        "Check TSH at 4-6 weeks",
        "Annual TSH once stable",
        "Over-Rx: AF, osteoporosis",
        "Under-Rx: persistent symptoms",
        "Symptoms improve before TSH normalises",
    ]),
]
for bx10, by10, bg10, t10, ls10 in positions10:
    cbox(c, bx10, by10, bw10, bh10-2, bg10)
    title_strip(c, bx10, by10+bh10-2, bw10, t10)
    text_lines(c, bx10+6, by10+bh10-28, ["• "+l for l in ls10], fs=12, lh=15)
note_box(c, "SPEAKER NOTE: Always take on empty stomach — Ca/Fe/antacids reduce absorption. Recheck TSH at 4-6 weeks only (not earlier — 7-day half-life). Over-treatment causes AF and osteoporosis.")

# ══════════════════════════════════════════
# PAGE 11 — SPECIAL POPULATIONS
# ══════════════════════════════════════════
new_page()
bg(c, C["light_gray"]); header(c, C["teal"], "Management — Special Populations")
footer(c, 11)
bw11 = (CW-10)/2; bh11 = (CT-CB-28)/2
sp11 = [
    (MARGIN,       CB+26+bh11, C["purple"],    "PREGNANCY", [
        "Increase dose by 25-30% immediately",
        "Target TSH: < 2.5 mIU/L (1st trimester)",
        "Target TSH: < 3.0 mIU/L (2nd-3rd trimester)",
        "Untreated: miscarriage, preterm birth,",
        "  impaired fetal neurodevelopment",
        "Screen ALL pregnant women with TSH",
    ]),
    (MARGIN+bw11+10, CB+26+bh11, C["dark_blue"], "CONGENITAL HYPOTHYROIDISM", [
        "Screen: heel prick TSH on day 3-5",
        "Treat within 2 weeks of birth",
        "Dose: 10-15 mcg/kg/day",
        "Untreated: CRETINISM (irreversible)",
        "Treated early: NORMAL development",
        "Monitor TSH every 3 months (0-3 yrs)",
    ]),
    (MARGIN,       CB+24,       C["red"],       "SUBCLINICAL HYPOTHYROIDISM", [
        "Treat if TSH consistently > 10 mIU/L",
        "Treat if symptomatic",
        "Treat if pregnant / planning pregnancy",
        "Treat if Anti-TPO Ab positive",
        "Observe if TSH 4-10, asymptomatic",
        "Recheck TFTs in 3-6 months",
    ]),
    (MARGIN+bw11+10, CB+24,     C["green"],    "ELDERLY & CARDIAC", [
        "Start very low: 12.5-25 mcg/day",
        "Increase 12.5-25 mcg every 4-6 weeks",
        "Target TSH: 1-4 mIU/L",
        "Risk of angina/MI at full dose",
        "Risk of AF with over-replacement",
        "Reassess every 6-12 months",
    ]),
]
for bx11, by11, bg11, t11, ls11 in sp11:
    cbox(c, bx11, by11, bw11, bh11-2, bg11)
    title_strip(c, bx11, by11+bh11-2, bw11, t11)
    text_lines(c, bx11+6, by11+bh11-28, ["• "+l for l in ls11], fs=12, lh=15)
note_box(c, "SPEAKER NOTE: Pregnancy: increase dose immediately. Congenital: treat within 2 weeks — delay = irreversible cretinism. Elderly: start low, go slow.")

# ══════════════════════════════════════════
# PAGE 12 — MYXEDEMA CRISIS
# ══════════════════════════════════════════
new_page()
bg(c, C["light_gray"]); header(c, C["red"], "Myxedema Crisis — Medical Emergency")
footer(c, 12)
# Banner
cbox(c, MARGIN, CT-38, CW, 38, C["navy"])
c.setFillColor(C["red"]); c.setFont("Helvetica-Bold", 14)
c.drawString(MARGIN+8, CT-16, "Medical Emergency  |  Mortality: 30-60%  |  Mandatory ICU Admission")
c.setFillColor(C["white"]); c.setFont("Helvetica", 12)
c.drawString(MARGIN+8, CT-32, "Severe, life-threatening decompensated hypothyroidism")
bw12 = (CW-16)/3; bh12 = CT-38-CB-28
mc12 = [
    (MARGIN,           C["dark_blue"], "PRECIPITANTS", [
        "Cold exposure",
        "Infection / sepsis",
        "Surgery / anaesthesia",
        "Trauma",
        "Opioids / sedatives",
        "Stopping L-T4 abruptly",
        "Stroke / MI",
    ]),
    (MARGIN+bw12+8,    C["purple"],    "CLINICAL FEATURES", [
        "Hypothermia (core temp < 35°C)",
        "Bradycardia",
        "Hypotension",
        "Hypoventilation / CO2 retention",
        "Altered consciousness / coma",
        "Seizures",
        "Profound myxedema",
        "Hyponatraemia, hypoglycaemia",
    ]),
    (MARGIN+2*(bw12+8), C["green"],   "TREATMENT", [
        "IV L-Thyroxine:",
        "  Loading: 200-400 mcg IV",
        "  Maintenance: 100 mcg IV daily",
        "",
        "IV Hydrocortisone 100-200 mg",
        "  Give BEFORE thyroid Rx",
        "  (Rule out adrenal insufficiency)",
        "",
        "ICU Supportive Care:",
        "  Passive rewarming only",
        "  Oxygen / ventilation",
        "  IV dextrose (hypoglycaemia)",
        "  Correct hyponatraemia slowly",
    ]),
]
for bx12, bg12, t12, ls12 in mc12:
    cbox(c, bx12, CB+24, bw12, bh12, bg12)
    title_strip(c, bx12, CB+24+bh12, bw12, t12)
    text_lines(c, bx12+6, CB+24+bh12-28, ["• " + l if not l.startswith(" ") and l else l for l in ls12], fs=11.5, lh=14)
note_box(c, "SPEAKER NOTE: Give IV hydrocortisone BEFORE L-T4 to prevent adrenal crisis. Passive rewarming only — active rewarming causes vasodilation and cardiovascular collapse.")

# ══════════════════════════════════════════
# PAGE 13 — CONGENITAL IN DETAIL
# ══════════════════════════════════════════
new_page()
bg(c, C["light_gray"]); header(c, C["indigo"], "Congenital Hypothyroidism — In Detail")
footer(c, 13)
# Left: photo
draw_img(c, "congenital", MARGIN, CB+24, PAGE_W*0.36-MARGIN, CT-CB-28)
# Right text blocks
rx13 = PAGE_W*0.38; rw13 = PAGE_W-rx13-MARGIN; bh13 = (CT-CB-28)/2
cbox(c, rx13, CB+26+bh13, rw13, bh13-2, C["dark_blue"])
title_strip(c, rx13, CB+26+bh13+bh13-2, rw13, "CLINICAL FEATURES")
text_lines(c, rx13+6, CB+26+bh13+bh13-28, [
    "• Prolonged neonatal jaundice (EARLIEST sign)",
    "• Umbilical hernia, abdominal distension",
    "• Macroglossia (enlarged tongue)",
    "• Hypotonia, poor feeding, constipation",
    "• Large fontanelles, coarse facies",
    "• Hoarse cry, bradycardia, hypothermia",
], fs=12, lh=16)
cbox(c, rx13, CB+24, rw13, bh13-2, C["teal"])
title_strip(c, rx13, CB+24+bh13-2, rw13, "SCREENING & MANAGEMENT")
text_lines(c, rx13+6, CB+24+bh13-28, [
    "• Incidence: 1 in 3,000-4,000 births",
    "• MC PREVENTABLE cause of mental retardation",
    "• Heel prick TSH screen: day 3-5 of life",
    "• L-T4 10-15 mcg/kg/day within 2 WEEKS",
    "• Normal intellect if treated early",
    "• Cretinism if untreated (IRREVERSIBLE):",
    "   Mental retardation, short stature, deafness",
], fs=12, lh=16)
note_box(c, "SPEAKER NOTE: Most common preventable cause of mental retardation. Earliest sign = prolonged jaundice. Must treat within 2 weeks — delay = irreversible cretinism.")

# ══════════════════════════════════════════
# PAGE 14 — SUMMARY TABLE
# ══════════════════════════════════════════
new_page()
bg(c, C["light_gray"]); header(c, C["dark_blue"], "Summary — Comparison at a Glance")
footer(c, 14)
rows14 = [
    ("PARAMETER",        "PRIMARY",                "SECONDARY",             "SUBCLINICAL"),
    ("TSH",              "HIGH (>10 mIU/L)",       "Low / Normal",          "4-10 mIU/L"),
    ("FT4",              "LOW",                    "LOW",                   "NORMAL"),
    ("Main Cause",       "Hashimoto's / Iodine",   "Pituitary failure",     "Autoimmune / Drug"),
    ("Symptoms",         "Present, obvious",       "Often mild",            "Absent / vague"),
    ("Treatment",        "L-T4 1.6 mcg/kg/day",   "L-T4 + treat cause",    "TSH>10, symptomatic"),
    ("Anti-TPO Ab",      "Often positive",         "Usually negative",      "+ve = reason to treat"),
    ("Goitre",           "May be present",         "May be present",        "May be present"),
]
col_ws14 = [180, 160, 160, 160]; col_xs14 = []
cx14 = MARGIN + 5
for w in col_ws14:
    col_xs14.append(cx14); cx14 += w + 4
rh14 = (CT - CB - 28) / len(rows14)
row_bgs14 = [C["navy"], C["mid_blue"], C["indigo"], C["mid_blue"], C["indigo"],
             C["mid_blue"], C["indigo"], C["mid_blue"]]
for ri14, row14 in enumerate(rows14):
    by14 = CT - 4 - (ri14+1)*rh14
    for ci14, (cell14, cx14_, cw14) in enumerate(zip(row14, col_xs14, col_ws14)):
        cbox(c, cx14_, by14, cw14, rh14-2, row_bgs14[ri14])
        is_h = ri14 == 0 or ci14 == 0
        fc14 = C["yellow"] if is_h else C["white"]
        c.setFillColor(fc14)
        c.setFont("Helvetica-Bold" if is_h else "Helvetica", 11 if ri14>0 else 12)
        c.drawString(cx14_+5, by14+rh14/2-5, cell14)
note_box(c, "SPEAKER NOTE: Primary = TSH HIGH + FT4 LOW. Secondary = TSH low + FT4 LOW. Subclinical = TSH 4-10 + FT4 NORMAL. Anti-TPO positivity in subclinical = treat.")

# ══════════════════════════════════════════
# PAGE 15 — KEY TAKEAWAYS
# ══════════════════════════════════════════
new_page()
bg(c, C["dark_blue"])
c.setFillColor(C["amber"]); c.rect(0, PAGE_H-62, PAGE_W, 62, fill=1, stroke=0)
c.setFillColor(C["dark_blue"]); c.setFont("Helvetica-Bold", 26)
c.drawCentredString(PAGE_W/2, PAGE_H-38, "KEY TAKEAWAYS  —  HYPOTHYROIDISM")
footer(c, 15)

key15 = [
    ("1", "MC cause (developed) = Hashimoto's Thyroiditis (Anti-TPO +ve)  |  MC worldwide = Iodine Deficiency"),
    ("2", "Best screening test = Serum TSH.  Overt: TSH >10 + low FT4.  Subclinical: TSH 4-10 + normal FT4"),
    ("3", "Hertoghe's sign (loss of outer 1/3 eyebrow)  |  Woltman sign (slow-relaxing ankle jerks)"),
    ("4", "Hypothyroidism = reversible cause of secondary hypercholesterolaemia — always check TFTs"),
    ("5", "L-Thyroxine 1.6 mcg/kg/day on empty stomach; recheck TSH at 4-6 weeks only"),
    ("6", "Pregnancy: increase dose 25-30%; Target TSH < 2.5 mIU/L in 1st trimester"),
    ("7", "Congenital: screen day 3-5; treat within 2 weeks to prevent irreversible cretinism"),
    ("8", "Myxedema crisis: IV L-T4 200-400 mcg + IV Hydrocortisone 100-200 mg; mortality 30-60%"),
    ("9", "Drug causes: Lithium, Amiodarone (14%), Sunitinib, alpha-IFN, IL-2, Valproate"),
]
kh15 = (PAGE_H - 62 - FOOTER_H - 8) / len(key15)
for i15, (num15, text15) in enumerate(key15):
    by15 = PAGE_H - 62 - 2 - (i15+1)*kh15
    bgc15 = colors.HexColor("#1A237E") if i15%2==0 else colors.HexColor("#283593")
    c.setFillColor(bgc15); c.roundRect(MARGIN, by15, CW, kh15-2, 3, fill=1, stroke=0)
    c.setFillColor(C["amber"]); c.roundRect(MARGIN+2, by15+2, 28, kh15-6, 3, fill=1, stroke=0)
    c.setFillColor(C["dark_blue"]); c.setFont("Helvetica-Bold", 12)
    c.drawCentredString(MARGIN+16, by15+kh15/2-5, num15)
    c.setFillColor(C["white"]); c.setFont("Helvetica", 11)
    c.drawString(MARGIN+36, by15+kh15/2-5, text15)

c.save()
print(f"PDF saved: {OUT}")
Running Command

cd /tmp/workspace/hypothyroidism-ppt && python create_pdf_v2.py 2>&1

Editing File

~/hypothyroidism-ppt/create_pdf_v2.py

Successfully replaced 1 instance(s) of the string in '/tmp/workspace/hypothyroidism-ppt/create_pdf_v2.py'
Running Command

cd /tmp/workspace/hypothyroidism-ppt && python create_pdf_v2.py 2>&1

Running Command

ls -lh /tmp/workspace/hypothyroidism-ppt/Hypothyroidism_Mokshit_Panwar_v2.* 2>&1

Both files are ready, Mokshit! Here are your downloads:

PowerPoint (Class Presentation)

Hypothyroidism Mokshit Panwar v2

Presentation · PPTX

PDF (Class Presentation)

Hypothyroidism Mokshit Panwar v2

PDF Document · PDF


Here's what's been upgraded compared to the previous version:
FeaturePreviousNew (v2)
Slides / Pages915
Text per slideDense, smallFewer bullets, larger font
LayoutCramped 4-boxClean 2-column lecture style
Speaker notesNoneEvery slide has detailed notes
Causes slideMixed into definitionSeparate dedicated slide
Investigations1 slide2 slides (TFTs+Autoimmune / Biochem+Imaging)
Management1 slide2 slides (L-T4 / Special populations)
CongenitalCombinedDedicated full slide with photo
Summary tableNoneFull comparison table (Primary/Secondary/Subclinical)
Speaker notes include what to say for each slide - perfect for practising your presentation before class.

The slide is overlapping on headings Fix the issue

Reading File
Writing File

~/hypothyroidism-ppt/create_ppt_v3.py

"""
Hypothyroidism - Class Presentation PPT v3
FIXED: No heading overlaps. Header bar = 1.1 in, content starts at 1.3 in, footer at bottom 0.35 in.
15 slides, clean lecture style, speaker notes on every slide.
"""
import requests
from io import BytesIO
from pptx import Presentation
from pptx.util import Inches, Pt
from pptx.dml.color import RGBColor
from pptx.enum.text import PP_ALIGN
from pptx.oxml.ns import qn
from lxml import etree

# ── Palette ──────────────────────────────────────────────────────────────
DARK_BLUE  = RGBColor(0x0D, 0x47, 0xA1)
MID_BLUE   = RGBColor(0x15, 0x65, 0xC0)
TEAL       = RGBColor(0x00, 0x89, 0x7B)
AMBER      = RGBColor(0xFF, 0x8F, 0x00)
RED        = RGBColor(0xC6, 0x28, 0x28)
ORANGE     = RGBColor(0xE6, 0x51, 0x00)
PURPLE     = RGBColor(0x6A, 0x1B, 0x9A)
GREEN      = RGBColor(0x2E, 0x7D, 0x32)
WHITE      = RGBColor(0xFF, 0xFF, 0xFF)
LIGHT_GRAY = RGBColor(0xF0, 0xF4, 0xFF)
DARK_TEXT  = RGBColor(0x1A, 0x1A, 0x2E)
YELLOW_ACC = RGBColor(0xFF, 0xD6, 0x00)
INDIGO     = RGBColor(0x28, 0x35, 0x93)
NAVY       = RGBColor(0x0A, 0x24, 0x72)
SOFT_BLUE  = RGBColor(0xBB, 0xDE, 0xFB)

# ── Layout constants (in inches) ─────────────────────────────────────────
W       = 13.333   # slide width
H       = 7.5      # slide height
HEADER  = 1.15     # header bar height  ← increased so title has room
CT      = HEADER + 0.15   # content top  = 1.30 in below top-left origin
FOOTER  = 0.38     # footer height
CB      = H - FOOTER      # content bottom y = 7.12 in from top
MARGIN  = 0.25     # left/right margin
CW      = W - 2 * MARGIN  # usable content width = 12.83 in

# ── Fetch images ─────────────────────────────────────────────────────────
IMAGE_URLS = {
    "signs_diagram": "https://cdn.orris.care/cdss_images/053b9bb265b63714c4a536636d315c8c10972d68fe82e00691f22c7acff56972.png",
    "hpt_axis":      "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_6f82970f9f7319e651f853444406dd2b35b7feffc3334ebb3c549f9b030a044f.jpg",
    "myxedema_face": "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_004376e56882f1544f2c61db75df95bbb940d303665f105b602921ddef336433.jpg",
    "congenital":    "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_21eff5b66b62dfc0c59899e9eba5d20699765566b7e304af716c2a545b1b97ff.jpg",
    "myxedema_legs": "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_5ca4d51c24fef39d7592d3972d48133127a4ef92b28178dcc0aec50ff6784604.jpg",
}
img_data = {}
for key, url in IMAGE_URLS.items():
    try:
        r = requests.get(url, timeout=15); r.raise_for_status()
        img_data[key] = r.content
    except Exception as e:
        print(f"Failed {key}: {e}"); img_data[key] = None
print("Images:", {k: v is not None for k, v in img_data.items()})

# ── Drawing helpers ───────────────────────────────────────────────────────
def fill_shape(shape, color):
    sp   = shape._element
    spPr = sp.find(qn('p:spPr'))
    if spPr is None:
        spPr = etree.SubElement(sp, qn('p:spPr'))
    sf  = etree.SubElement(spPr, qn('a:solidFill'))
    rgb = etree.SubElement(sf, qn('a:srgbClr'))
    rgb.set('val', f'{color[0]:02X}{color[1]:02X}{color[2]:02X}')

def rect(s, x, y, w, h, color):
    sh = s.shapes.add_shape(1, Inches(x), Inches(y), Inches(w), Inches(h))
    sh.line.fill.background()
    fill_shape(sh, color)
    return sh

def tb(s, x, y, w, h, text, fs=16, bold=False, color=DARK_TEXT,
        align=PP_ALIGN.LEFT, italic=False):
    box = s.shapes.add_textbox(Inches(x), Inches(y), Inches(w), Inches(h))
    tf  = box.text_frame
    tf.word_wrap = True
    tf.margin_left  = Pt(3)
    tf.margin_right = Pt(3)
    tf.margin_top   = Pt(2)
    p   = tf.paragraphs[0]
    p.alignment = align
    run = p.add_run()
    run.text            = text
    run.font.size       = Pt(fs)
    run.font.bold       = bold
    run.font.italic     = italic
    run.font.color.rgb  = color
    run.font.name       = "Calibri"
    return box

def bullets(s, x, y, w, h, items, fs=16, color=WHITE):
    box = s.shapes.add_textbox(Inches(x), Inches(y), Inches(w), Inches(h))
    tf  = box.text_frame
    tf.word_wrap = True
    tf.margin_left  = Pt(5)
    tf.margin_right = Pt(4)
    tf.margin_top   = Pt(3)
    first = True
    for item in items:
        if first:
            p = tf.paragraphs[0]; first = False
        else:
            p = tf.add_paragraph()
        p.space_before = Pt(3)
        run = p.add_run()
        run.text           = item
        run.font.size      = Pt(fs)
        run.font.color.rgb = color
        run.font.name      = "Calibri"

def img(s, key, x, y, w, h=None):
    d = img_data.get(key)
    if not d: return
    buf = BytesIO(d)
    if h:
        s.shapes.add_picture(buf, Inches(x), Inches(y), Inches(w), Inches(h))
    else:
        s.shapes.add_picture(buf, Inches(x), Inches(y), Inches(w))

def note(s, text):
    s.notes_slide.notes_text_frame.text = text

def color_box(s, x, y, w, h, bg, title, title_fs=12.5):
    """A colored box with a dark title strip at the top."""
    rect(s, x, y, w, h, bg)
    rect(s, x, y, w, 0.38, NAVY)   # title strip
    tb(s, x+0.08, y+0.04, w-0.16, 0.32, title,
       fs=title_fs, bold=True, color=YELLOW_ACC)

def speaker_note(s, text):
    s.notes_slide.notes_text_frame.text = text

# Content height (space between header and footer)
CH = CB - CT   # 7.12 - 1.30 = 5.82 in

prs = Presentation()
prs.slide_width  = Inches(W)
prs.slide_height = Inches(H)
blank = prs.slide_layouts[6]

# ── Standard slide template ────────────────────────────────────────────────
def new_slide(hdr_color=DARK_BLUE, title="", accent=AMBER):
    s = prs.slides.add_slide(blank)
    rect(s, 0, 0, W, H, LIGHT_GRAY)          # background
    rect(s, 0, 0, W, HEADER, hdr_color)       # header bar
    rect(s, 0, HEADER, W, 0.06, accent)        # accent stripe
    rect(s, 0, H - FOOTER, W, FOOTER, hdr_color)  # footer
    tb(s, 0, H - FOOTER + 0.04, W, FOOTER - 0.04,
       "Hypothyroidism  |  Mokshit Panwar  |  Roll No. 68",
       fs=9, color=WHITE, align=PP_ALIGN.CENTER)
    if title:
        tb(s, MARGIN, 0.14, W - 2*MARGIN, HEADER - 0.14,
           title, fs=28, bold=True, color=WHITE)
    return s

# ═══════════════════════════════════════════════════════════════
# SLIDE 1 — TITLE
# ═══════════════════════════════════════════════════════════════
s = prs.slides.add_slide(blank)
rect(s, 0, 0, W, H, DARK_BLUE)
rect(s, 0, H * 0.42, W, 0.07, AMBER)
tb(s, 0.5, 0.85, W-1, 1.5, "HYPOTHYROIDISM",
   fs=66, bold=True, color=WHITE, align=PP_ALIGN.CENTER)
tb(s, 0.5, 2.55, W-1, 0.65,
   "Clinical Features  |  Investigations  |  Management",
   fs=22, color=YELLOW_ACC, align=PP_ALIGN.CENTER)
tb(s, 0.5, 3.3, W-1, 0.5,
   "An Underactive Thyroid — A Hypometabolic State",
   fs=16, italic=True, color=SOFT_BLUE, align=PP_ALIGN.CENTER)
rect(s, 3.9, 4.1, 5.5, 1.05, NAVY)
rect(s, 3.9, 4.1, 5.5, 0.05, AMBER)
tb(s, 3.95, 4.2, 5.4, 0.52,
   "Presented by: Mokshit Panwar  |  Roll No. 68",
   fs=17, bold=True, color=WHITE, align=PP_ALIGN.CENTER)
tb(s, 3.95, 4.72, 5.4, 0.36,
   "Tintinalli's Emergency Medicine  |  Family Medicine 9e",
   fs=10.5, italic=True, color=SOFT_BLUE, align=PP_ALIGN.CENTER)
rect(s, 0, H - 0.3, W, 0.3, NAVY)
tb(s, 0, H - 0.28, W, 0.26,
   "Hypothyroidism  |  Mokshit Panwar  |  Roll No. 68",
   fs=9, color=WHITE, align=PP_ALIGN.CENTER)
speaker_note(s, "Welcome. Today I'll present Hypothyroidism — clinical features, investigations, and management. Mokshit Panwar, Roll No. 68.")

# ═══════════════════════════════════════════════════════════════
# SLIDE 2 — DEFINITION & OVERVIEW
# ═══════════════════════════════════════════════════════════════
s = new_slide(DARK_BLUE, "What is Hypothyroidism?")

# Definition banner just below header
rect(s, MARGIN, CT, CW, 0.62, INDIGO)
tb(s, MARGIN+0.1, CT+0.04, CW-0.2, 0.25, "DEFINITION",
   fs=12, bold=True, color=YELLOW_ACC)
tb(s, MARGIN+0.1, CT+0.28, CW-0.2, 0.3,
   "A hypometabolic state from insufficient thyroid hormone production or action.",
   fs=13.5, color=WHITE)

# Two columns below definition banner
col_top = CT + 0.72       # top of the two boxes
col_h   = CB - col_top - 0.08
bw2 = (CW - 0.15) / 2

color_box(s, MARGIN,           col_top, bw2, col_h, MID_BLUE, "TSH CLASSIFICATION")
bullets(s, MARGIN+0.1,         col_top+0.42, bw2-0.2, col_h-0.45, [
    "Overt Hypothyroidism:",
    "  TSH > 10 mIU/L  +  Low FT4",
    "  Symptomatic — treatment mandatory",
    "",
    "Subclinical Hypothyroidism:",
    "  TSH 4–10 mIU/L  +  Normal FT4",
    "  Often asymptomatic",
    "",
    "Secondary / Tertiary:",
    "  TSH low or normal  +  Low FT4",
    "  Pituitary or hypothalamic failure",
], fs=14)

color_box(s, MARGIN+bw2+0.15,  col_top, bw2, col_h, TEAL,     "EPIDEMIOLOGY")
bullets(s, MARGIN+bw2+0.25,    col_top+0.42, bw2-0.2, col_h-0.45, [
    "Prevalence: 4–10% of adults",
    "Women > Men  (5–8× more common)",
    "",
    "Most Common Cause — Developed world:",
    "  Hashimoto's Thyroiditis (Auto-immune)",
    "  Anti-TPO antibodies positive",
    "",
    "Most Common Cause — Worldwide:",
    "  Iodine Deficiency",
    "",
    "Congenital: 1 in 3,000–4,000 births",
], fs=14)

speaker_note(s, "TSH is the single best screening test. Primary hypothyroidism = TSH HIGH. Secondary (pituitary) = TSH low despite low FT4. Hashimoto's is MC in developed nations; iodine deficiency MC worldwide.")

# ═══════════════════════════════════════════════════════════════
# SLIDE 3 — AETIOLOGY
# ═══════════════════════════════════════════════════════════════
s = new_slide(TEAL, "Aetiology — Causes of Hypothyroidism")

bw3 = (CW - 0.15) / 2
bh3 = (CH - 0.08) / 2

# Row 1
color_box(s, MARGIN,           CT,        bw3, bh3-0.05, GREEN,  "PRIMARY (Thyroid Gland Failure)")
bullets(s, MARGIN+0.1,         CT+0.42,   bw3-0.2, bh3-0.5, [
    "• Hashimoto's thyroiditis (MC — developed world)",
    "• Iodine deficiency (MC worldwide)",
    "• Post-radioiodine ablation",
    "• Post-thyroidectomy (surgical)",
    "• Congenital (aplasia / dyshormonogenesis)",
], fs=14)

color_box(s, MARGIN+bw3+0.15,  CT,        bw3, bh3-0.05, PURPLE, "SECONDARY / TERTIARY")
bullets(s, MARGIN+bw3+0.25,    CT+0.42,   bw3-0.2, bh3-0.5, [
    "• Pituitary failure (Sheehan's, tumour)",
    "• Hypothalamic failure (TRH deficiency)",
    "• Cranial irradiation",
    "• Head trauma",
    "• Infiltrative disease (sarcoid, haemochromatosis)",
], fs=14)

# Row 2
color_box(s, MARGIN,           CT+bh3+0.05, bw3, bh3-0.05, RED,    "DRUG-INDUCED")
bullets(s, MARGIN+0.1,         CT+bh3+0.47, bw3-0.2, bh3-0.5, [
    "• Lithium (inhibits hormone release)",
    "• Amiodarone (up to 14% incidence)",
    "• Sunitinib / Sorafenib (tyrosine kinase inhibitors)",
    "• Alpha-Interferon  |  Interleukin-2",
    "• Valproate  |  Carbamazepine",
], fs=14)

color_box(s, MARGIN+bw3+0.15,  CT+bh3+0.05, bw3, bh3-0.05, AMBER,  "TRANSIENT / SPECIAL FORMS")
bullets(s, MARGIN+bw3+0.25,    CT+bh3+0.47, bw3-0.2, bh3-0.5, [
    "• Post-partum thyroiditis",
    "• Subacute (de Quervain's) thyroiditis",
    "• Riedel's fibrous thyroiditis",
    "• Silent / painless thyroiditis",
    "• Thyroid infiltration: amyloid, lymphoma",
], fs=14)

speaker_note(s, "Drug-induced: Amiodarone is most frequently tested — up to 14% incidence. Lithium inhibits hormone release. Post-partum thyroiditis is common in young women. Sheehan's syndrome = pituitary infarction post-partum.")

# ═══════════════════════════════════════════════════════════════
# SLIDE 4 — PATHOPHYSIOLOGY
# ═══════════════════════════════════════════════════════════════
s = new_slide(INDIGO, "Pathophysiology — HPT Axis")

lw4 = CW * 0.46
bh4 = (CH - 0.1) / 3

# Three stacked boxes on left
for i4, (bg4, title4, ls4) in enumerate([
    (DARK_BLUE, "HPT AXIS FEEDBACK LOOP", [
        "Hypothalamus → TRH → Pituitary → TSH → Thyroid → T4 / T3",
        "T4 : T3 secretion ratio = 10 : 1",
        "80% of circulating T3 = peripheral T4 deiodination",
        "T4 half-life = 7 days   |   T3 half-life = 1 day",
        "In hypothyroidism: ↓T4/T3 → ↑TRH → ↑TSH (feedback broken)",
    ]),
    (TEAL, "METABOLIC CONSEQUENCES", [
        "↓ BMR → weight gain, cold intolerance, fatigue",
        "↓ Na⁺/K⁺ ATPase → reduced thermogenesis",
        "Glycosaminoglycan deposition → myxedema (non-pitting)",
        "↓ Cardiac output → bradycardia, pericardial effusion",
        "↓ Gut motility → constipation, ileus",
    ]),
    (PURPLE, "HASHIMOTO'S (MC — Developed World)", [
        "Autoimmune lymphocytic infiltration of thyroid",
        "Anti-TPO antibodies — 90% sensitivity",
        "HLA-DR3 / DR5 association",
        "Early: firm rubbery goitre",
        "Late: atrophic variant (gland destroyed)",
    ]),
]):
    y4 = CT + i4 * (bh4 + 0.05)
    color_box(s, MARGIN, y4, lw4, bh4, bg4, title4)
    bullets(s, MARGIN+0.1, y4+0.42, lw4-0.2, bh4-0.48, ["• "+l for l in ls4], fs=13.5)

# HPT axis image on right
rx4 = MARGIN + lw4 + 0.2
rw4 = CW - lw4 - 0.2
img(s, "hpt_axis", rx4, CT, rw4, CH)

speaker_note(s, "T4 is the main secretory product; T3 is the active form (converted peripherally). TSH is the most sensitive marker. In primary hypothyroidism, negative feedback is broken so TSH rises. Glycosaminoglycan deposition explains the non-pitting myxedema.")

# ═══════════════════════════════════════════════════════════════
# SLIDE 5 — CLINICAL FEATURES: SYMPTOMS
# ═══════════════════════════════════════════════════════════════
s = new_slide(RED, "Clinical Features — Symptoms")

rect(s, MARGIN, CT, CW, 0.52, NAVY)
tb(s, MARGIN+0.1, CT+0.06, CW-0.2, 0.22, "SYMPTOMS  —  What the patient complains of",
   fs=14, bold=True, color=YELLOW_ACC)
tb(s, MARGIN+0.1, CT+0.28, CW-0.2, 0.22,
   "Symptoms are insidious — onset over months to years. Diagnosis is frequently delayed.",
   fs=12, italic=True, color=SOFT_BLUE)

bw5 = (CW - 0.2) / 3
col_top5 = CT + 0.6
col_h5   = CB - col_top5 - 0.05

for i5, (title5, bg5, ls5) in enumerate([
    ("GENERAL", RED, [
        "Weight gain (poor appetite)",
        "Fatigue and lethargy",
        "Cold intolerance",
        "Puffiness of face / eyelids",
        "Hair thinning / diffuse loss",
        "Dry, coarse skin",
    ]),
    ("SYSTEM-SPECIFIC", PURPLE, [
        "Constipation (GI)",
        "Menorrhagia / infertility (Gynae)",
        "Decreased libido",
        "Muscle cramps and weakness",
        "Hoarseness of voice",
        "Carpal tunnel syndrome",
    ]),
    ("NEUROPSYCHIATRIC", DARK_BLUE, [
        "Depression",
        "Psychosis (myxedema madness)",
        "Impaired memory, slow thinking",
        "Exertional dyspnoea",
        "Bradycardia-related symptoms",
        "Deafness (severe / congenital)",
    ]),
]):
    cx5 = MARGIN + i5 * (bw5 + 0.1)
    color_box(s, cx5, col_top5, bw5, col_h5, bg5, title5)
    bullets(s, cx5+0.1, col_top5+0.42, bw5-0.2, col_h5-0.48,
            ["• "+l for l in ls5], fs=14)

speaker_note(s, "Classic triad: Weight gain + Fatigue + Cold intolerance. Menorrhagia = key gynae symptom. Myxedema madness = rare psychiatric manifestation. Carpal tunnel syndrome from glycosaminoglycan deposition.")

# ═══════════════════════════════════════════════════════════════
# SLIDE 6 — CLINICAL FEATURES: SIGNS
# ═══════════════════════════════════════════════════════════════
s = new_slide(ORANGE, "Clinical Features — Signs")

lw6 = CW * 0.47
color_box(s, MARGIN, CT, lw6, CH, DARK_BLUE, "EXAMINATION FINDINGS")

sign_items = [
    "FACE & HAIR:",
    "  Periorbital puffiness",
    "  Loss of outer 1/3 eyebrow  (Hertoghe's sign) ★",
    "  Macroglossia  |  Hoarse voice",
    "  Dry coarse skin  |  Carotenemia (yellow tinge)",
    "",
    "CARDIOVASCULAR:",
    "  Bradycardia  |  Diastolic hypertension",
    "  Pericardial effusion → low-voltage ECG",
    "",
    "NEUROMUSCULAR:",
    "  Slow-relaxing DTRs  (Woltman sign) ★",
    "  Hyporeflexia  |  Proximal myopathy",
    "",
    "OTHER:",
    "  Non-pitting oedema (myxedema)",
    "  Goitre — rubbery & firm (Hashimoto's)",
    "  Pleural / ascitic effusion",
]
bullets(s, MARGIN+0.1, CT+0.42, lw6-0.2, CH-0.48, sign_items, fs=13.5)

# Body diagram on right
rx6 = MARGIN + lw6 + 0.2
rw6 = CW - lw6 - 0.2
img(s, "signs_diagram", rx6, CT, rw6, CH)

speaker_note(s, "★ High-yield exam signs: Hertoghe's sign = loss of outer 1/3 eyebrow. Woltman sign = slow-relaxing ankle jerks — pathognomonic of hypothyroidism. Periorbital puffiness from glycosaminoglycan accumulation. Low-voltage ECG from pericardial effusion.")

# ═══════════════════════════════════════════════════════════════
# SLIDE 7 — CLINICAL PHOTOGRAPHS
# ═══════════════════════════════════════════════════════════════
s = new_slide(PURPLE, "Clinical Photographs")

photo_info = [
    ("myxedema_face",
     "Myxedematous Facies",
     "Periorbital puffiness, pallor, sparse eyebrows"),
    ("myxedema_legs",
     "Pretibial Myxedema",
     "Non-pitting oedema, waxy skin, ankle swelling"),
    ("congenital",
     "Congenital Hypothyroidism",
     "Macroglossia, abdominal distension — Before & After Rx"),
]
n7  = 3
gap7 = 0.2
bw7 = (CW - (n7-1)*gap7) / n7
cap_h = 0.72
img_h7 = CH - cap_h - 0.05

for i7, (key7, title7, cap7) in enumerate(photo_info):
    bx7 = MARGIN + i7 * (bw7 + gap7)
    img(s, key7, bx7, CT, bw7, img_h7)
    rect(s, bx7, CT + img_h7 + 0.02, bw7, cap_h, NAVY)
    tb(s, bx7+0.06, CT + img_h7 + 0.06, bw7-0.12, 0.3,
       title7, fs=12.5, bold=True, color=YELLOW_ACC, align=PP_ALIGN.CENTER)
    tb(s, bx7+0.06, CT + img_h7 + 0.36, bw7-0.12, 0.34,
       cap7, fs=11, color=WHITE, align=PP_ALIGN.CENTER)

speaker_note(s, "Left: Myxedematous face — periorbital puffiness, dull expression, sparse eyebrows. Middle: Pretibial myxedema — non-pitting, waxy oedema. Right: Congenital hypothyroidism — macroglossia, pot belly, umbilical hernia. Dramatic improvement after L-thyroxine treatment.")

# ═══════════════════════════════════════════════════════════════
# SLIDE 8 — INVESTIGATIONS: TFTs & AUTOIMMUNE
# ═══════════════════════════════════════════════════════════════
s = new_slide(GREEN, "Investigations — TFTs & Autoimmune Markers")

bw8 = (CW - 0.15) / 2

color_box(s, MARGIN,           CT, bw8, CH, MID_BLUE, "THYROID FUNCTION TESTS  (1st Line)")
bullets(s, MARGIN+0.1,         CT+0.42, bw8-0.2, CH-0.48, [
    "Serum TSH  — MOST SENSITIVE test",
    "  Normal:      0.4–4.0 mIU/L",
    "  Subclinical: 4–10 mIU/L",
    "  Overt:        > 10 mIU/L",
    "",
    "Free T4 (FT4)",
    "  Low in primary hypothyroidism",
    "  Normal in subclinical",
    "",
    "Free T3 (FT3)  — rarely used alone",
    "",
    "Primary pattern:   TSH ↑  +  FT4 ↓",
    "Secondary pattern: TSH ↓/N  +  FT4 ↓",
    "",
    "★  Always do TSH first",
], fs=14.5)

color_box(s, MARGIN+bw8+0.15,  CT, bw8, CH, TEAL,     "AUTOIMMUNE MARKERS")
bullets(s, MARGIN+bw8+0.25,    CT+0.42, bw8-0.2, CH-0.48, [
    "Anti-TPO Antibodies",
    "  Most sensitive for Hashimoto's",
    "  Present in ~90% of cases",
    "  Also elevated in Graves' disease",
    "",
    "Anti-Thyroglobulin Antibodies",
    "  Less specific — used if TPO negative",
    "",
    "ANA — may be positive",
    "",
    "Clinical significance:",
    "  Subclinical + TPO Ab +ve",
    "   → higher risk of progression",
    "  Guides treatment decision",
    "  Important for family counselling",
], fs=14.5)

speaker_note(s, "TSH is the single best test. Anti-TPO present in 90% of Hashimoto's. Subclinical + Anti-TPO positive = 2–5% per year risk of progression to overt hypothyroidism — this is a reason to treat even in subclinical disease.")

# ═══════════════════════════════════════════════════════════════
# SLIDE 9 — INVESTIGATIONS: BIOCHEM & IMAGING
# ═══════════════════════════════════════════════════════════════
s = new_slide(GREEN, "Investigations — Biochemistry & Imaging")

bw9 = (CW - 0.15) / 2

color_box(s, MARGIN,          CT, bw9, CH, ORANGE, "BIOCHEMISTRY")
bullets(s, MARGIN+0.1,        CT+0.42, bw9-0.2, CH-0.48, [
    "Lipid Profile:",
    "  ↑ Total cholesterol  |  ↑ LDL",
    "  Reversible secondary hyperlipidaemia",
    "",
    "Serum Creatine Kinase (CK):",
    "  Elevated in hypothyroid myopathy",
    "",
    "CBC:",
    "  Normocytic or macrocytic anaemia",
    "  Check B12, folate, iron",
    "",
    "Hyponatraemia (SIADH-like picture)",
    "",
    "LFTs: mild ↑ AST / ALT",
    "Uric acid: may be raised",
], fs=14.5)

color_box(s, MARGIN+bw9+0.15, CT, bw9, CH, PURPLE, "IMAGING & SPECIAL TESTS")
bullets(s, MARGIN+bw9+0.25,   CT+0.42, bw9-0.2, CH-0.48, [
    "Ultrasound Thyroid:",
    "  Heterogeneous texture (Hashimoto's)",
    "  Goitre size, nodule assessment",
    "",
    "ECG:",
    "  Sinus bradycardia",
    "  Low-voltage complexes",
    "  Flat / inverted T waves",
    "  Prolonged QT interval",
    "",
    "Chest X-ray:",
    "  Cardiomegaly (pericardial effusion)",
    "  Pleural effusion",
    "",
    "Echocardiography: confirm effusion",
    "TRH stimulation: 2° vs 3° distinction",
], fs=14.5)

speaker_note(s, "★ Hypothyroidism = reversible cause of secondary hyperlipidaemia — always check TFTs in unexplained high cholesterol. ECG shows bradycardia and low voltage in pericardial effusion. Ultrasound: heterogeneous texture is classic for Hashimoto's.")

# ═══════════════════════════════════════════════════════════════
# SLIDE 10 — MANAGEMENT: LEVOTHYROXINE
# ═══════════════════════════════════════════════════════════════
s = new_slide(DARK_BLUE, "Management — Levothyroxine (L-T4)")

# Intro banner
rect(s, MARGIN, CT, CW, 0.52, INDIGO)
tb(s, MARGIN+0.1, CT+0.06, CW-0.2, 0.22,
   "Drug of Choice: Synthetic Levothyroxine (L-T4)  —  Oral, Once Daily",
   fs=14, bold=True, color=YELLOW_ACC)
tb(s, MARGIN+0.1, CT+0.28, CW-0.2, 0.22,
   "Average adult dose: 1.6 mcg/kg/day (~100 mcg/day)",
   fs=13, color=WHITE)

bw10 = (CW - 0.15) / 2
bh10 = (CH - 0.52 - 0.1) / 2
row2_top = CT + 0.52 + 0.06 + bh10 + 0.06

for (x10, y10, bg10, t10, ls10) in [
    (MARGIN,          CT+0.62,  MID_BLUE, "DOSING", [
        "Full dose in young healthy adults",
        "Elderly: start 25–50 mcg, titrate slowly",
        "Cardiac disease: start 12.5–25 mcg/day",
        "Target TSH: 0.5–2.5 mIU/L",
        "Elderly target TSH: 1–4 mIU/L",
    ]),
    (MARGIN+bw10+0.15, CT+0.62, TEAL,    "ADMINISTRATION", [
        "Take on EMPTY STOMACH",
        "30–60 min before breakfast",
        "Half-life = 7 days",
        "Steady state reached in 4–6 weeks",
        "Same time every day — consistency key",
    ]),
    (MARGIN,           row2_top, RED,     "DRUG INTERACTIONS  (reduce absorption)", [
        "Calcium supplements",
        "Iron tablets",
        "Antacids (Al / Mg)",
        "Cholestyramine  |  Colestipol",
        "Separate by at least 4 hours",
    ]),
    (MARGIN+bw10+0.15, row2_top, GREEN,  "MONITORING", [
        "Recheck TSH at 4–6 weeks",
        "Annual TSH once stable",
        "Over-treatment: AF, osteoporosis",
        "Under-treatment: persistent symptoms",
        "Symptoms improve before TSH normalises",
    ]),
]:
    color_box(s, x10, y10, bw10, bh10, bg10, t10)
    bullets(s, x10+0.1, y10+0.42, bw10-0.2, bh10-0.48,
            ["• "+l for l in ls10], fs=14)

speaker_note(s, "Always take L-T4 on an empty stomach. Ca / Fe / antacids reduce absorption by up to 40%. Do NOT recheck TSH before 4 weeks — half-life is 7 days and steady state takes 4–6 weeks. Over-treatment causes AF and osteoporosis.")

# ═══════════════════════════════════════════════════════════════
# SLIDE 11 — SPECIAL POPULATIONS
# ═══════════════════════════════════════════════════════════════
s = new_slide(TEAL, "Management — Special Populations")

bw11 = (CW - 0.15) / 2
bh11 = (CH - 0.05) / 2

for (x11, y11, bg11, t11, ls11) in [
    (MARGIN,           CT,          PURPLE,    "PREGNANCY", [
        "Increase dose by 25–30% immediately",
        "Target TSH < 2.5 mIU/L  (1st trimester)",
        "Target TSH < 3.0 mIU/L  (2nd–3rd trimester)",
        "Untreated: miscarriage, preterm birth,",
        "  impaired fetal neurodevelopment",
        "Screen ALL pregnant women with TSH",
    ]),
    (MARGIN+bw11+0.15, CT,          DARK_BLUE, "CONGENITAL HYPOTHYROIDISM", [
        "Screen: heel prick TSH on day 3–5",
        "Treat within 2 WEEKS of birth",
        "Dose: 10–15 mcg/kg/day",
        "Untreated: CRETINISM (irreversible)",
        "  Mental retardation, short stature, deafness",
        "Treated early: NORMAL development",
    ]),
    (MARGIN,           CT+bh11+0.06, RED,       "SUBCLINICAL HYPOTHYROIDISM", [
        "Treat if TSH consistently > 10 mIU/L",
        "Treat if symptomatic",
        "Treat if pregnant / planning pregnancy",
        "Treat if Anti-TPO Ab positive",
        "Observe if asymptomatic TSH 4–10",
        "Recheck TFTs in 3–6 months",
    ]),
    (MARGIN+bw11+0.15, CT+bh11+0.06, GREEN,    "ELDERLY & CARDIAC", [
        "Start very low: 12.5–25 mcg/day",
        "Increase 12.5–25 mcg every 4–6 weeks",
        "Target TSH: 1–4 mIU/L",
        "Risk of angina / MI at full dose",
        "Risk of AF with over-replacement",
        "Reassess every 6–12 months",
    ]),
]:
    color_box(s, x11, y11, bw11, bh11, bg11, t11)
    bullets(s, x11+0.1, y11+0.42, bw11-0.2, bh11-0.48,
            ["• "+l for l in ls11], fs=14)

speaker_note(s, "Pregnancy: increase dose as soon as pregnancy confirmed — fetus depends entirely on maternal T4 in 1st trimester. Congenital: treat within 2 weeks — delay = irreversible cretinism. Elderly/cardiac: start low, go very slow.")

# ═══════════════════════════════════════════════════════════════
# SLIDE 12 — MYXEDEMA CRISIS
# ═══════════════════════════════════════════════════════════════
s = new_slide(RED, "Myxedema Crisis — Medical Emergency")

rect(s, MARGIN, CT, CW, 0.52, NAVY)
tb(s, MARGIN+0.1, CT+0.06, CW-0.2, 0.22,
   "Medical Emergency  |  Mortality: 30–60%  |  Mandatory ICU Admission",
   fs=14, bold=True, color=RED)
tb(s, MARGIN+0.1, CT+0.28, CW-0.2, 0.22,
   "Severe, life-threatening decompensated hypothyroidism",
   fs=12.5, color=WHITE)

bw12 = (CW - 0.2) / 3
box_top12 = CT + 0.6
bh12 = CB - box_top12 - 0.05

for i12, (bg12, t12, ls12) in enumerate([
    (DARK_BLUE, "PRECIPITANTS", [
        "Cold exposure",
        "Infection / sepsis",
        "Surgery / anaesthesia",
        "Trauma",
        "Opioids / sedatives",
        "Stopping L-T4 abruptly",
        "Stroke / MI",
    ]),
    (PURPLE, "CLINICAL FEATURES", [
        "Hypothermia  (core temp < 35°C)",
        "Bradycardia  |  Hypotension",
        "Hypoventilation / CO₂ retention",
        "Altered consciousness / coma",
        "Seizures",
        "Profound myxedema",
        "Hyponatraemia  |  Hypoglycaemia",
    ]),
    (GREEN, "TREATMENT", [
        "IV L-Thyroxine:",
        "  Loading:      200–400 mcg IV",
        "  Maintenance: 100 mcg IV daily",
        "",
        "IV Hydrocortisone  100–200 mg",
        "  ★ Give BEFORE thyroid Rx",
        "  (Rule out adrenal insufficiency)",
        "",
        "ICU Supportive:",
        "  Passive rewarming only",
        "  O₂ / ventilation as needed",
        "  IV dextrose (hypoglycaemia)",
    ]),
]):
    x12 = MARGIN + i12 * (bw12 + 0.1)
    color_box(s, x12, box_top12, bw12, bh12, bg12, t12)
    bullets(s, x12+0.1, box_top12+0.42, bw12-0.2, bh12-0.48,
            ls12, fs=13)

speaker_note(s, "★ Give IV hydrocortisone BEFORE L-T4. Rationale: if there is co-existent adrenal insufficiency, starting thyroid hormone increases metabolic rate and can precipitate acute adrenal crisis. Passive rewarming only — active external rewarming causes peripheral vasodilation and cardiovascular collapse.")

# ═══════════════════════════════════════════════════════════════
# SLIDE 13 — CONGENITAL IN DETAIL
# ═══════════════════════════════════════════════════════════════
s = new_slide(INDIGO, "Congenital Hypothyroidism — In Detail")

lw13 = CW * 0.38
img(s, "congenital", MARGIN, CT, lw13, CH)

rw13 = CW - lw13 - 0.2
rx13 = MARGIN + lw13 + 0.2
bh13 = (CH - 0.05) / 2

color_box(s, rx13, CT, rw13, bh13, DARK_BLUE, "CLINICAL FEATURES")
bullets(s, rx13+0.1, CT+0.42, rw13-0.2, bh13-0.48, [
    "• Prolonged neonatal jaundice  (EARLIEST sign)",
    "• Umbilical hernia  |  Abdominal distension",
    "• Macroglossia (enlarged tongue)",
    "• Hypotonia  |  Poor feeding  |  Constipation",
    "• Large fontanelles  |  Coarse facies",
    "• Hoarse cry  |  Bradycardia  |  Hypothermia",
], fs=14)

color_box(s, rx13, CT+bh13+0.06, rw13, bh13-0.06, TEAL, "SCREENING & MANAGEMENT")
bullets(s, rx13+0.1, CT+bh13+0.48, rw13-0.2, bh13-0.52, [
    "• Incidence: 1 in 3,000–4,000 births",
    "• MC PREVENTABLE cause of mental retardation",
    "• Heel prick TSH screen: day 3–5 of life",
    "• Start L-T4 within 2 weeks — dose 10–15 mcg/kg/day",
    "• Normal intellect if treated early",
    "• Cretinism if untreated (IRREVERSIBLE):",
    "   Mental retardation, short stature, deafness",
], fs=14)

speaker_note(s, "Most common preventable cause of mental retardation. Earliest clinical sign = prolonged neonatal jaundice. Heel prick screen on day 3-5. Treatment within 2 weeks is mandatory — delay beyond this causes irreversible neurological damage (cretinism).")

# ═══════════════════════════════════════════════════════════════
# SLIDE 14 — SUMMARY TABLE
# ═══════════════════════════════════════════════════════════════
s = new_slide(DARK_BLUE, "Summary — Comparison at a Glance")

rows14 = [
    ("PARAMETER",     "PRIMARY",                 "SECONDARY",            "SUBCLINICAL"),
    ("TSH",           "HIGH  (> 10 mIU/L)",      "Low / Normal",         "4–10 mIU/L"),
    ("FT4",           "LOW",                     "LOW",                  "NORMAL"),
    ("Main Cause",    "Hashimoto's / Iodine",    "Pituitary failure",    "Autoimmune / Drug"),
    ("Symptoms",      "Present, obvious",        "Often mild",           "Absent / vague"),
    ("Treatment",     "L-T4 1.6 mcg/kg/day",    "L-T4 + treat cause",   "TSH>10, symptomatic"),
    ("Anti-TPO Ab",   "Often positive",          "Usually negative",     "+ve = treat"),
    ("Goitre",        "May be present",          "Uncommon",             "May be present"),
]
n_cols = 4
col_ws = [2.6, 3.3, 3.3, 3.3]
total_w = sum(col_ws) + 0.3 * (n_cols-1)
start_x = MARGIN + (CW - total_w) / 2

row_h14 = CH / len(rows14)
col_bgs = [INDIGO, MID_BLUE, TEAL, PURPLE]

for ri, row in enumerate(rows14):
    for ci, (cell, cw14) in enumerate(zip(row, col_ws)):
        cx14 = start_x + sum(col_ws[:ci]) + ci * 0.3
        by14 = CT + ri * row_h14
        bg14 = NAVY if ri == 0 else (col_bgs[ci] if ci > 0 else INDIGO)
        rect(s, cx14, by14, cw14, row_h14-0.03, bg14)
        is_hdr = ri == 0 or ci == 0
        tb(s, cx14+0.07, by14+0.06, cw14-0.14, row_h14-0.1,
           cell, fs=13 if ri>0 else 13.5,
           bold=is_hdr,
           color=YELLOW_ACC if is_hdr else WHITE)

speaker_note(s, "Primary = TSH HIGH + FT4 LOW. Secondary (pituitary) = TSH low/normal + FT4 LOW. Subclinical = TSH 4-10 + FT4 NORMAL. Anti-TPO positivity in subclinical disease = reason to treat. This table is excellent for exam revision.")

# ═══════════════════════════════════════════════════════════════
# SLIDE 15 — KEY TAKEAWAYS
# ═══════════════════════════════════════════════════════════════
s = prs.slides.add_slide(blank)
rect(s, 0, 0, W, H, DARK_BLUE)
rect(s, 0, 0, W, 0.85, AMBER)
tb(s, MARGIN, 0.08, CW, 0.72, "KEY TAKEAWAYS  —  HYPOTHYROIDISM",
   fs=28, bold=True, color=DARK_BLUE, align=PP_ALIGN.CENTER)
rect(s, 0, H-0.32, W, 0.32, NAVY)
tb(s, 0, H-0.30, W, 0.28,
   "Hypothyroidism  |  Mokshit Panwar  |  Roll No. 68",
   fs=9, color=WHITE, align=PP_ALIGN.CENTER)

key_pts = [
    ("1", "MC cause (developed) = Hashimoto's (Anti-TPO +ve)  |  MC worldwide = Iodine Deficiency"),
    ("2", "Best test = Serum TSH.  Overt: TSH >10 + ↓FT4.  Subclinical: TSH 4–10 + normal FT4"),
    ("3", "Hertoghe's sign = loss outer 1/3 eyebrow  |  Woltman sign = slow-relaxing ankle jerks"),
    ("4", "Hypothyroidism = reversible secondary hypercholesterolaemia — always screen TFTs"),
    ("5", "L-Thyroxine 1.6 mcg/kg/day on empty stomach  |  Recheck TSH only at 4–6 weeks"),
    ("6", "Pregnancy: increase dose 25–30%;  Target TSH < 2.5 mIU/L in 1st trimester"),
    ("7", "Congenital: screen day 3–5; treat within 2 weeks to prevent irreversible cretinism"),
    ("8", "Myxedema crisis: IV L-T4 200–400 mcg + IV Hydrocortisone 100–200 mg; mortality 30–60%"),
    ("9", "Drug causes: Lithium, Amiodarone (14%), Sunitinib, alpha-IFN, IL-2, Valproate"),
]

kp_top = 0.9
kp_h = (H - kp_top - 0.36) / len(key_pts)

for i, (num, text) in enumerate(key_pts):
    by = kp_top + i * kp_h
    bg_kp = RGBColor(0x1A, 0x23, 0x7E) if i%2==0 else INDIGO
    rect(s, MARGIN, by, CW, kp_h-0.03, bg_kp)
    rect(s, MARGIN, by, 0.4, kp_h-0.03, AMBER)
    tb(s, MARGIN+0.01, by+0.04, 0.38, kp_h-0.1,
       num, fs=13, bold=True, color=DARK_BLUE, align=PP_ALIGN.CENTER)
    tb(s, MARGIN+0.45, by+0.04, CW-0.5, kp_h-0.1,
       text, fs=12.5, color=WHITE)

speaker_note(s, "These 9 points are the highest-yield facts for exams and viva. Woltman sign is pathognomonic. Hypothyroidism causing hypercholesterolaemia is a classic reversible secondary dyslipidaemia. Steroids before L-T4 in myxedema crisis. Amiodarone is the most tested drug-induced cause. Thank you!")

# ── Save ─────────────────────────────────────────────────────────────────
out = "/tmp/workspace/hypothyroidism-ppt/Hypothyroidism_Mokshit_Panwar_v3.pptx"
prs.save(out)
print(f"Saved: {out}")
Running Command

cd /tmp/workspace/hypothyroidism-ppt && python create_ppt_v3.py 2>&1

Writing File

~/hypothyroidism-ppt/create_pdf_v3.py

"""
Hypothyroidism – Class Presentation PDF v3
FIXED: No heading overlaps.
Landscape A4. Header 72 pt, content starts 82 pt from top, footer 26 pt.
"""
import requests
from io import BytesIO
from PIL import Image as PILImage
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import A4, landscape
from reportlab.lib import colors
from reportlab.lib.utils import ImageReader

PW, PH = landscape(A4)   # 841.9 × 595.3 pt

# ── Palette ──────────────────────────────────────────────
C = {
    "dark_blue":  colors.HexColor("#0D47A1"),
    "mid_blue":   colors.HexColor("#1565C0"),
    "teal":       colors.HexColor("#00897B"),
    "amber":      colors.HexColor("#FF8F00"),
    "red":        colors.HexColor("#C62828"),
    "orange":     colors.HexColor("#E65100"),
    "purple":     colors.HexColor("#6A1B9A"),
    "green":      colors.HexColor("#2E7D32"),
    "white":      colors.white,
    "lg":         colors.HexColor("#EEF2FF"),  # light gray background
    "dt":         colors.HexColor("#1A1A2E"),  # dark text
    "yellow":     colors.HexColor("#FFD600"),
    "indigo":     colors.HexColor("#283593"),
    "navy":       colors.HexColor("#0A2472"),
    "soft_blue":  colors.HexColor("#BBDEFB"),
}

# ── Layout constants (points) ─────────────────────────────
HDR_H  = 72    # header bar height
ACC_H  = 5     # accent stripe
FTR_H  = 26    # footer height
M      = 14    # left/right margin
CT     = PH - HDR_H - ACC_H - 6   # content top y  (ReportLab y=0 is bottom-left)
CB     = FTR_H + 4                 # content bottom y
CW     = PW - 2 * M               # content width
CH     = CT - CB                   # content height available

# ── Image fetch ───────────────────────────────────────────
IMAGE_URLS = {
    "signs_diagram": "https://cdn.orris.care/cdss_images/053b9bb265b63714c4a536636d315c8c10972d68fe82e00691f22c7acff56972.png",
    "hpt_axis":      "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_6f82970f9f7319e651f853444406dd2b35b7feffc3334ebb3c549f9b030a044f.jpg",
    "myxedema_face": "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_004376e56882f1544f2c61db75df95bbb940d303665f105b602921ddef336433.jpg",
    "congenital":    "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_21eff5b66b62dfc0c59899e9eba5d20699765566b7e304af716c2a545b1b97ff.jpg",
    "myxedema_legs": "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_5ca4d51c24fef39d7592d3972d48133127a4ef92b28178dcc0aec50ff6784604.jpg",
}
img_data = {}
for k, u in IMAGE_URLS.items():
    try:
        r = requests.get(u, timeout=15); r.raise_for_status()
        img_data[k] = r.content
    except Exception as e:
        print(f"Failed {k}: {e}"); img_data[k] = None
print("Images:", {k: v is not None for k, v in img_data.items()})

def get_ir(key):
    d = img_data.get(key)
    if not d: return None, 0, 0
    buf = BytesIO(d)
    pil = PILImage.open(buf); iw, ih = pil.size
    buf.seek(0); return ImageReader(buf), iw, ih

# ── Drawing primitives ────────────────────────────────────
def bg(c, col):
    c.setFillColor(col); c.rect(0,0,PW,PH,fill=1,stroke=0)

def header(c, col, title, accent=None):
    ac = accent or C["amber"]
    c.setFillColor(col)
    c.rect(0, PH-HDR_H, PW, HDR_H, fill=1, stroke=0)
    c.setFillColor(ac)
    c.rect(0, PH-HDR_H-ACC_H, PW, ACC_H, fill=1, stroke=0)
    c.setFillColor(C["white"]); c.setFont("Helvetica-Bold", 26)
    c.drawString(M+5, PH-HDR_H+20, title)

def footer(c, pg=None):
    c.setFillColor(C["navy"]); c.rect(0,0,PW,FTR_H,fill=1,stroke=0)
    c.setFillColor(C["white"]); c.setFont("Helvetica", 8)
    c.drawCentredString(PW/2, 8, "Hypothyroidism  |  Mokshit Panwar  |  Roll No. 68")
    if pg: c.drawRightString(PW-10, 8, f"Slide {pg}")

def cbox(c, x, y, w, h, col, radius=4):
    c.setFillColor(col); c.roundRect(x,y,w,h,radius,fill=1,stroke=0)

def title_strip(c, x, y, w, text, fg=None, fs=11.5):
    """Dark strip at the TOP of a box. y = bottom-left of the box."""
    strip_h = 22
    fg = fg or C["yellow"]
    c.setFillColor(colors.HexColor("#00000060"))
    c.rect(x, y+h-strip_h, w, strip_h, fill=1, stroke=0)
    c.setFillColor(fg); c.setFont("Helvetica-Bold", fs)
    c.drawString(x+6, y+h-strip_h+6, text)

def draw_lines(c, x, y, lines, fs=11, col=None, lh=14):
    col = col or C["white"]
    c.setFont("Helvetica", fs); c.setFillColor(col)
    for line in lines:
        if y < CB+2: break
        c.drawString(x, y, line); y -= lh
    return y

def draw_bold(c, x, y, text, fs=11, col=None):
    c.setFont("Helvetica-Bold", fs)
    c.setFillColor(col or C["yellow"])
    c.drawString(x, y, text)

def draw_img(c, key, x, y, max_w, max_h):
    ir, iw, ih = get_ir(key)
    if not ir: return
    scale = min(max_w/iw, max_h/ih)
    dw, dh = iw*scale, ih*scale
    ox, oy = x+(max_w-dw)/2, y+(max_h-dh)/2
    c.drawImage(ir, ox, oy, dw, dh, preserveAspectRatio=True, mask='auto')

def colored_block(c, x, y, w, h, bg_col, title, lines, fs=11.5, lh=14, title_fg=None):
    """Full colored box with title strip and bullet lines."""
    cbox(c, x, y, w, h, bg_col)
    title_strip(c, x, y, w, title, fg=title_fg, fs=min(fs+0.5, 12))
    draw_lines(c, x+6, y+h-26, lines, fs=fs, lh=lh)

# ── Canvas ────────────────────────────────────────────────
OUT = "/tmp/workspace/hypothyroidism-ppt/Hypothyroidism_Mokshit_Panwar_v3.pdf"
c = canvas.Canvas(OUT, pagesize=landscape(A4))
c.setTitle("Hypothyroidism – Mokshit Panwar Roll 68")
pg = [0]

def new_page(hdr_col, title, accent=None):
    if pg[0] > 0: c.showPage()
    pg[0] += 1
    bg(c, C["lg"])
    header(c, hdr_col, title, accent)
    footer(c, pg[0])

# ══════════════════════════════════════════════
# PAGE 1 — TITLE
# ══════════════════════════════════════════════
pg[0] += 1
bg(c, C["dark_blue"])
c.setFillColor(C["amber"]); c.rect(0, PH*0.42, PW, 5, fill=1, stroke=0)
c.setFillColor(C["white"]); c.setFont("Helvetica-Bold", 66)
c.drawCentredString(PW/2, PH*0.56, "HYPOTHYROIDISM")
c.setFillColor(C["yellow"]); c.setFont("Helvetica-Bold", 20)
c.drawCentredString(PW/2, PH*0.45, "Clinical Features  |  Investigations  |  Management")
c.setFillColor(C["soft_blue"]); c.setFont("Helvetica-Oblique", 14)
c.drawCentredString(PW/2, PH*0.38, "An Underactive Thyroid — A Hypometabolic State")
c.setFillColor(C["navy"]); c.roundRect(PW/2-190, PH*0.18, 380, 52, 8, fill=1, stroke=0)
c.setFillColor(C["amber"]);  c.rect(PW/2-190, PH*0.18+48, 380, 4, fill=1, stroke=0)
c.setFillColor(C["white"]); c.setFont("Helvetica-Bold", 15)
c.drawCentredString(PW/2, PH*0.25, "Presented by: Mokshit Panwar   |   Roll No. 68")
c.setFillColor(C["soft_blue"]); c.setFont("Helvetica-Oblique", 10)
c.drawCentredString(PW/2, PH*0.20, "Tintinalli's Emergency Medicine  |  Family Medicine 9e")
footer(c, 1)

# ══════════════════════════════════════════════
# PAGE 2 — DEFINITION
# ══════════════════════════════════════════════
new_page(C["dark_blue"], "What is Hypothyroidism?")
# Definition banner
cbox(c, M, CT-48, CW, 48, C["indigo"])
draw_bold(c, M+8, CT-16, "DEFINITION", fs=12)
c.setFillColor(C["white"]); c.setFont("Helvetica", 12)
c.drawString(M+8, CT-32, "A hypometabolic state from insufficient thyroid hormone production or action.")
c.drawString(M+8, CT-46, "TSH >10 + low FT4 = Overt  |  TSH 4–10 + normal FT4 = Subclinical  |  Low TSH + low FT4 = Secondary")

col_top2 = CT - 56
bw2 = (CW - 10) / 2
bh2 = col_top2 - CB - 4
colored_block(c, M,         col_top2-bh2, bw2, bh2, C["mid_blue"], "TSH CLASSIFICATION", [
    "Overt Hypothyroidism:",
    "  TSH > 10 mIU/L  +  Low FT4",
    "  Symptomatic — treatment mandatory",
    "",
    "Subclinical Hypothyroidism:",
    "  TSH 4–10 mIU/L  +  Normal FT4",
    "  Often asymptomatic",
    "",
    "Secondary / Tertiary:",
    "  TSH low/normal  +  Low FT4",
    "  Pituitary or hypothalamic cause",
], fs=12, lh=15)
colored_block(c, M+bw2+10,  col_top2-bh2, bw2, bh2, C["teal"],     "EPIDEMIOLOGY", [
    "Prevalence: 4–10% of adults",
    "Women > Men  (5–8× more common)",
    "",
    "Most Common (Developed world):",
    "  Hashimoto's Thyroiditis — TPO Ab +ve",
    "",
    "Most Common (Worldwide):",
    "  Iodine Deficiency",
    "",
    "Congenital: 1 in 3,000–4,000 births",
], fs=12, lh=15)

# ══════════════════════════════════════════════
# PAGE 3 — AETIOLOGY
# ══════════════════════════════════════════════
new_page(C["teal"], "Aetiology — Causes of Hypothyroidism")
bw3 = (CW - 10) / 2
bh3 = (CH - 8) / 2
colored_block(c, M,          CT-bh3,      bw3, bh3, C["green"],  "PRIMARY (Thyroid Gland Failure)", [
    "• Hashimoto's thyroiditis (MC — developed world)",
    "• Iodine deficiency (MC worldwide)",
    "• Post-radioiodine ablation",
    "• Post-thyroidectomy (surgical)",
    "• Congenital (aplasia / dyshormonogenesis)",
], fs=12, lh=16)
colored_block(c, M+bw3+10,   CT-bh3,      bw3, bh3, C["purple"], "SECONDARY / TERTIARY", [
    "• Pituitary failure (Sheehan's, tumour)",
    "• Hypothalamic failure (TRH deficiency)",
    "• Cranial irradiation",
    "• Head trauma",
    "• Infiltrative: sarcoid, haemochromatosis",
], fs=12, lh=16)
colored_block(c, M,          CB+4,        bw3, bh3, C["red"],    "DRUG-INDUCED", [
    "• Lithium (inhibits thyroid hormone release)",
    "• Amiodarone (up to 14% incidence)",
    "• Sunitinib / Sorafenib (TKIs)",
    "• Alpha-Interferon  |  Interleukin-2",
    "• Valproate  |  Carbamazepine",
], fs=12, lh=16)
colored_block(c, M+bw3+10,   CB+4,        bw3, bh3, C["amber"],  "TRANSIENT / SPECIAL FORMS", [
    "• Post-partum thyroiditis",
    "• Subacute (de Quervain's) thyroiditis",
    "• Riedel's fibrous thyroiditis",
    "• Silent / painless thyroiditis",
    "• Thyroid infiltration: amyloid, lymphoma",
], fs=12, lh=16)

# ══════════════════════════════════════════════
# PAGE 4 — PATHOPHYSIOLOGY
# ══════════════════════════════════════════════
new_page(C["indigo"], "Pathophysiology — HPT Axis")
lw4 = CW * 0.46; bh4 = (CH - 8) / 3
for i4, (bgc4, t4, ls4) in enumerate([
    (C["dark_blue"], "HPT AXIS FEEDBACK LOOP", [
        "Hypothalamus → TRH → Pituitary → TSH → Thyroid → T4/T3",
        "T4 : T3 secretion ratio = 10 : 1",
        "80% of T3 from peripheral deiodination of T4",
        "T4 half-life = 7 days   |   T3 half-life = 1 day",
        "In hypo: ↓T4/T3 → ↑TRH → ↑TSH (feedback broken)",
    ]),
    (C["teal"], "METABOLIC CONSEQUENCES", [
        "↓ BMR → weight gain, cold intolerance, fatigue",
        "↓ Na⁺/K⁺ ATPase → reduced thermogenesis",
        "Glycosaminoglycan deposition → myxedema",
        "↓ Cardiac output → bradycardia, effusion",
        "↓ Gut motility → constipation",
    ]),
    (C["purple"], "HASHIMOTO'S (MC — Developed World)", [
        "Autoimmune lymphocytic infiltration",
        "Anti-TPO antibodies — 90% sensitivity",
        "HLA-DR3 / DR5 association",
        "Early: firm rubbery goitre",
        "Late: atrophic variant (gland destroyed)",
    ]),
]):
    y4 = CT - (i4+1)*bh4 - i4*4
    colored_block(c, M, y4, lw4, bh4, bgc4, t4, ["• "+l for l in ls4], fs=11.5, lh=14)

# Image on right
rx4 = M + lw4 + 12; rw4 = CW - lw4 - 12
draw_img(c, "hpt_axis", rx4, CB, rw4, CH)

# ══════════════════════════════════════════════
# PAGE 5 — SYMPTOMS
# ══════════════════════════════════════════════
new_page(C["red"], "Clinical Features — Symptoms")
cbox(c, M, CT-46, CW, 46, C["navy"])
draw_bold(c, M+8, CT-16, "SYMPTOMS — What the patient complains of", fs=13)
c.setFillColor(C["soft_blue"]); c.setFont("Helvetica-Oblique", 11)
c.drawString(M+8, CT-34, "Symptoms are insidious — onset over months to years. Diagnosis is frequently delayed.")

col_top5 = CT - 52; bw5 = (CW - 16) / 3; bh5 = col_top5 - CB - 4
for i5, (t5, bg5, ls5) in enumerate([
    ("GENERAL", C["red"], [
        "Weight gain (poor appetite)",
        "Fatigue and lethargy",
        "Cold intolerance",
        "Puffiness of face / eyelids",
        "Hair thinning / diffuse loss",
        "Dry, coarse skin",
    ]),
    ("SYSTEM-SPECIFIC", C["purple"], [
        "Constipation (GI)",
        "Menorrhagia / infertility",
        "Decreased libido",
        "Muscle cramps and weakness",
        "Hoarseness of voice",
        "Carpal tunnel syndrome",
    ]),
    ("NEUROPSYCHIATRIC", C["dark_blue"], [
        "Depression",
        'Psychosis ("Myxedema madness")',
        "Impaired memory, slow thinking",
        "Exertional dyspnoea",
        "Bradycardia-related symptoms",
        "Deafness (severe / congenital)",
    ]),
]):
    cx5 = M + i5*(bw5+8)
    colored_block(c, cx5, col_top5-bh5, bw5, bh5, bg5, t5, ["• "+l for l in ls5], fs=12, lh=15)

# ══════════════════════════════════════════════
# PAGE 6 — SIGNS
# ══════════════════════════════════════════════
new_page(C["orange"], "Clinical Features — Signs")
lw6 = CW * 0.47
colored_block(c, M, CB, lw6, CH, C["dark_blue"], "EXAMINATION FINDINGS", [
    "FACE & HAIR:",
    "  Periorbital puffiness",
    "  Loss of outer 1/3 eyebrow (Hertoghe's sign) ★",
    "  Macroglossia  |  Hoarse voice",
    "  Dry coarse skin  |  Carotenemia",
    "",
    "CARDIOVASCULAR:",
    "  Bradycardia  |  Diastolic hypertension",
    "  Pericardial effusion → low-voltage ECG",
    "",
    "NEUROMUSCULAR:",
    "  Slow-relaxing DTRs  (Woltman sign) ★",
    "  Hyporeflexia  |  Proximal myopathy",
    "",
    "OTHER:",
    "  Non-pitting oedema (myxedema)",
    "  Goitre — rubbery & firm (Hashimoto's)",
    "  Pleural / ascitic effusion",
], fs=12, lh=15)
rx6 = M + lw6 + 12; rw6 = CW - lw6 - 12
draw_img(c, "signs_diagram", rx6, CB, rw6, CH)

# ══════════════════════════════════════════════
# PAGE 7 — CLINICAL PHOTOGRAPHS
# ══════════════════════════════════════════════
new_page(C["purple"], "Clinical Photographs")
photos7 = [
    ("myxedema_face", "Myxedematous Facies",       "Periorbital puffiness, pallor, sparse eyebrows"),
    ("myxedema_legs", "Pretibial Myxedema",         "Non-pitting oedema, waxy skin, ankle swelling"),
    ("congenital",    "Congenital Hypothyroidism",  "Macroglossia, umbilical hernia — Before & After Rx"),
]
n7 = 3; gap7 = 10; bw7 = (PW - (n7+1)*gap7) / n7
cap_h7 = 46; img_h7 = CH - cap_h7 - 6
for i7, (k7, t7, cap7) in enumerate(photos7):
    bx7 = gap7 + i7*(bw7+gap7)
    draw_img(c, k7, bx7, CB+cap_h7+4, bw7, img_h7)
    cbox(c, bx7, CB, bw7, cap_h7, C["navy"])
    c.setFillColor(C["yellow"]); c.setFont("Helvetica-Bold", 10.5)
    c.drawCentredString(bx7+bw7/2, CB+30, t7)
    c.setFillColor(C["white"]); c.setFont("Helvetica", 9)
    c.drawCentredString(bx7+bw7/2, CB+16, cap7)

# ══════════════════════════════════════════════
# PAGE 8 — INVESTIGATIONS: TFTs & AUTOIMMUNE
# ══════════════════════════════════════════════
new_page(C["green"], "Investigations — TFTs & Autoimmune Markers")
bw8 = (CW - 10) / 2
colored_block(c, M,        CB, bw8, CH, C["mid_blue"], "THYROID FUNCTION TESTS  (1st Line)", [
    "Serum TSH — MOST SENSITIVE test",
    "  Normal:       0.4–4.0 mIU/L",
    "  Subclinical:  4–10 mIU/L",
    "  Overt:         > 10 mIU/L",
    "",
    "Free T4 (FT4)",
    "  Low in primary | Normal in subclinical",
    "",
    "Free T3 (FT3) — rarely used alone",
    "",
    "Primary:   TSH ↑  +  FT4 ↓",
    "Secondary: TSH ↓/N  +  FT4 ↓",
    "",
    "★  Always do TSH first",
], fs=12, lh=15)
colored_block(c, M+bw8+10, CB, bw8, CH, C["teal"],     "AUTOIMMUNE MARKERS", [
    "Anti-TPO Antibodies",
    "  Most sensitive for Hashimoto's",
    "  Present in ~90% of cases",
    "  Also elevated in Graves' disease",
    "",
    "Anti-Thyroglobulin Antibodies",
    "  Less specific; used if TPO negative",
    "",
    "ANA — may be positive",
    "",
    "Clinical use:",
    "  Subclinical + TPO Ab +ve",
    "   → higher risk of progression",
    "  Guides treatment decision",
    "  Important for family counselling",
], fs=12, lh=15)

# ══════════════════════════════════════════════
# PAGE 9 — BIOCHEMISTRY & IMAGING
# ══════════════════════════════════════════════
new_page(C["green"], "Investigations — Biochemistry & Imaging")
bw9 = (CW - 10) / 2
colored_block(c, M,        CB, bw9, CH, C["orange"], "BIOCHEMISTRY", [
    "Lipid Profile:",
    "  ↑ Total cholesterol  |  ↑ LDL",
    "  Reversible secondary hyperlipidaemia",
    "",
    "Serum CK: elevated (myopathy)",
    "",
    "CBC: normocytic / macrocytic anaemia",
    "  Check B12, folate, iron",
    "",
    "Hyponatraemia (SIADH-like picture)",
    "",
    "LFTs: mild ↑ AST / ALT",
    "Uric acid: may be raised",
], fs=12, lh=15)
colored_block(c, M+bw9+10, CB, bw9, CH, C["purple"], "IMAGING & SPECIAL TESTS", [
    "Ultrasound Thyroid:",
    "  Heterogeneous texture (Hashimoto's)",
    "  Goitre size, nodule assessment",
    "",
    "ECG:",
    "  Sinus bradycardia",
    "  Low-voltage complexes",
    "  Flat / inverted T waves  |  Long QT",
    "",
    "Chest X-ray:",
    "  Cardiomegaly (pericardial effusion)",
    "  Pleural effusion",
    "",
    "Echo: confirm pericardial effusion",
    "TRH test: 2° vs 3° distinction",
], fs=12, lh=15)

# ══════════════════════════════════════════════
# PAGE 10 — MANAGEMENT: LEVOTHYROXINE
# ══════════════════════════════════════════════
new_page(C["dark_blue"], "Management — Levothyroxine (L-T4)")
cbox(c, M, CT-46, CW, 46, C["indigo"])
draw_bold(c, M+8, CT-16, "Drug of Choice: Synthetic Levothyroxine (L-T4) — Oral, Once Daily", fs=13)
c.setFillColor(C["white"]); c.setFont("Helvetica", 12)
c.drawString(M+8, CT-34, "Average adult dose: 1.6 mcg/kg/day (~100 mcg/day)")

bw10 = (CW - 10) / 2; row_top10 = CT - 52; bh10 = (row_top10 - CB - 8) / 2
for (x10, y10, bg10, t10, ls10) in [
    (M,          row_top10-bh10, C["mid_blue"], "DOSING", [
        "Full dose in young healthy adults",
        "Elderly: start 25–50 mcg, titrate slowly",
        "Cardiac: start 12.5–25 mcg/day",
        "Target TSH: 0.5–2.5 mIU/L",
        "Elderly target: 1–4 mIU/L",
    ]),
    (M+bw10+10,  row_top10-bh10, C["teal"],    "ADMINISTRATION", [
        "Take on EMPTY STOMACH",
        "30–60 min before breakfast",
        "Half-life = 7 days",
        "Steady state in 4–6 weeks",
        "Same time every day",
    ]),
    (M,          CB+4,           C["red"],     "DRUG INTERACTIONS  (reduce absorption)", [
        "Calcium supplements",
        "Iron tablets  |  Antacids (Al/Mg)",
        "Cholestyramine  |  Colestipol",
        "Separate by at least 4 hours",
    ]),
    (M+bw10+10,  CB+4,           C["green"],  "MONITORING", [
        "Recheck TSH at 4–6 weeks",
        "Annual TSH once stable",
        "Over-treatment: AF, osteoporosis",
        "Under-treatment: persistent symptoms",
    ]),
]:
    colored_block(c, x10, y10, bw10, bh10, bg10, t10, ["• "+l for l in ls10], fs=12, lh=15)

# ══════════════════════════════════════════════
# PAGE 11 — SPECIAL POPULATIONS
# ══════════════════════════════════════════════
new_page(C["teal"], "Management — Special Populations")
bw11 = (CW - 10) / 2; bh11 = (CH - 8) / 2
for (x11, y11, bg11, t11, ls11) in [
    (M,          CT-bh11,      C["purple"],   "PREGNANCY", [
        "Increase dose by 25–30% immediately",
        "Target TSH < 2.5 mIU/L  (1st trimester)",
        "Target TSH < 3.0 mIU/L  (2nd–3rd trimester)",
        "Untreated: miscarriage, preterm birth,",
        "  impaired fetal neurodevelopment",
        "Screen ALL pregnant women with TSH",
    ]),
    (M+bw11+10,  CT-bh11,      C["dark_blue"],"CONGENITAL HYPOTHYROIDISM", [
        "Heel prick TSH screen: day 3–5",
        "Treat within 2 WEEKS of birth",
        "Dose: 10–15 mcg/kg/day",
        "Untreated: CRETINISM (irreversible)",
        "  Mental retardation, short stature",
        "Treated early: NORMAL development",
    ]),
    (M,          CB+4,          C["red"],      "SUBCLINICAL HYPOTHYROIDISM", [
        "Treat if TSH consistently > 10 mIU/L",
        "Treat if symptomatic",
        "Treat if pregnant / planning pregnancy",
        "Treat if Anti-TPO Ab positive",
        "Observe if TSH 4–10, asymptomatic",
        "Recheck TFTs in 3–6 months",
    ]),
    (M+bw11+10,  CB+4,          C["green"],   "ELDERLY & CARDIAC", [
        "Start very low: 12.5–25 mcg/day",
        "Increase 12.5–25 mcg every 4–6 weeks",
        "Target TSH: 1–4 mIU/L",
        "Risk of angina / MI at full dose",
        "Risk of AF with over-replacement",
    ]),
]:
    colored_block(c, x11, y11, bw11, bh11, bg11, t11, ["• "+l for l in ls11], fs=12, lh=16)

# ══════════════════════════════════════════════
# PAGE 12 — MYXEDEMA CRISIS
# ══════════════════════════════════════════════
new_page(C["red"], "Myxedema Crisis — Medical Emergency")
cbox(c, M, CT-44, CW, 44, C["navy"])
draw_bold(c, M+8, CT-16, "Medical Emergency  |  Mortality: 30–60%  |  Mandatory ICU", fs=13, col=C["red"])
c.setFillColor(C["white"]); c.setFont("Helvetica", 12)
c.drawString(M+8, CT-32, "Severe life-threatening decompensated hypothyroidism.")

bw12 = (CW - 16) / 3; box_top12 = CT - 50; bh12 = box_top12 - CB - 4
for i12, (bg12, t12, ls12) in enumerate([
    (C["dark_blue"], "PRECIPITANTS", [
        "Cold exposure",
        "Infection / sepsis",
        "Surgery / anaesthesia",
        "Trauma",
        "Opioids / sedatives",
        "Stopping L-T4 abruptly",
        "Stroke / MI",
    ]),
    (C["purple"], "CLINICAL FEATURES", [
        "Hypothermia  (core < 35°C)",
        "Bradycardia  |  Hypotension",
        "Hypoventilation / CO₂ retention",
        "Altered consciousness / coma",
        "Seizures",
        "Profound myxedema",
        "Hyponatraemia  |  Hypoglycaemia",
    ]),
    (C["green"], "TREATMENT", [
        "IV L-Thyroxine:",
        "  Loading: 200–400 mcg IV",
        "  Maintenance: 100 mcg IV daily",
        "",
        "IV Hydrocortisone 100–200 mg",
        "  ★ Give BEFORE thyroid Rx",
        "",
        "ICU Supportive:",
        "  Passive rewarming only",
        "  O₂ / ventilation as needed",
        "  IV dextrose  |  Correct Na⁺",
    ]),
]):
    x12 = M + i12*(bw12+8)
    colored_block(c, x12, CB, bw12, bh12, bg12, t12, ls12, fs=11.5, lh=14)

# ══════════════════════════════════════════════
# PAGE 13 — CONGENITAL IN DETAIL
# ══════════════════════════════════════════════
new_page(C["indigo"], "Congenital Hypothyroidism — In Detail")
lw13 = CW * 0.38
draw_img(c, "congenital", M, CB, lw13, CH)
rw13 = CW - lw13 - 12; rx13 = M + lw13 + 12; bh13 = (CH - 8) / 2
colored_block(c, rx13, CB+bh13+8, rw13, bh13, C["dark_blue"], "CLINICAL FEATURES", [
    "• Prolonged neonatal jaundice  (EARLIEST)",
    "• Umbilical hernia  |  Abdominal distension",
    "• Macroglossia (enlarged tongue)",
    "• Hypotonia  |  Poor feeding  |  Constipation",
    "• Large fontanelles  |  Coarse facies",
    "• Hoarse cry  |  Bradycardia  |  Hypothermia",
], fs=12, lh=15)
colored_block(c, rx13, CB, rw13, bh13, C["teal"], "SCREENING & MANAGEMENT", [
    "• Incidence: 1 in 3,000–4,000 births",
    "• MC PREVENTABLE cause of mental retardation",
    "• Heel prick TSH screen: day 3–5 of life",
    "• L-T4 10–15 mcg/kg/day within 2 WEEKS",
    "• Normal intellect if treated early",
    "• Cretinism if untreated (IRREVERSIBLE):",
    "   Mental retardation, short stature, deafness",
], fs=12, lh=15)

# ══════════════════════════════════════════════
# PAGE 14 — SUMMARY TABLE
# ══════════════════════════════════════════════
new_page(C["dark_blue"], "Summary — Comparison at a Glance")
rows14 = [
    ("PARAMETER",     "PRIMARY",                 "SECONDARY",            "SUBCLINICAL"),
    ("TSH",           "HIGH  (> 10 mIU/L)",      "Low / Normal",         "4–10 mIU/L"),
    ("FT4",           "LOW",                     "LOW",                  "NORMAL"),
    ("Main Cause",    "Hashimoto's / Iodine",    "Pituitary failure",    "Autoimmune / Drug"),
    ("Symptoms",      "Present, obvious",        "Often mild",           "Absent / vague"),
    ("Treatment",     "L-T4 1.6 mcg/kg/day",    "L-T4 + treat cause",   "TSH>10, symptomatic"),
    ("Anti-TPO Ab",   "Often positive",          "Usually negative",     "+ve = treat"),
    ("Goitre",        "May be present",          "Uncommon",             "May be present"),
]
col_ws14 = [158, 148, 148, 148]; col_x0 = M + 5
col_xs14 = []
cx14 = col_x0
for w in col_ws14:
    col_xs14.append(cx14); cx14 += w + 4
rh14 = CH / len(rows14)
col_bgs14 = [C["indigo"], C["mid_blue"], C["teal"], C["purple"]]
hdr_bgs   = [C["navy"], C["navy"], C["navy"], C["navy"]]
for ri14, row14 in enumerate(rows14):
    by14 = CT - (ri14+1)*rh14
    for ci14, (cell14, cx14_, cw14) in enumerate(zip(row14, col_xs14, col_ws14)):
        bg14 = hdr_bgs[ci14] if ri14==0 else (C["indigo"] if ci14==0 else col_bgs14[ci14])
        cbox(c, cx14_, by14, cw14, rh14-2, bg14)
        is_h = ri14==0 or ci14==0
        c.setFillColor(C["yellow"] if is_h else C["white"])
        c.setFont("Helvetica-Bold" if is_h else "Helvetica", 11)
        c.drawString(cx14_+5, by14+rh14/2-5, cell14)

# ══════════════════════════════════════════════
# PAGE 15 — KEY TAKEAWAYS
# ══════════════════════════════════════════════
c.showPage(); pg[0] += 1
bg(c, C["dark_blue"])
c.setFillColor(C["amber"]); c.rect(0, PH-62, PW, 62, fill=1, stroke=0)
c.setFillColor(C["dark_blue"]); c.setFont("Helvetica-Bold", 25)
c.drawCentredString(PW/2, PH-38, "KEY TAKEAWAYS  —  HYPOTHYROIDISM")
footer(c, 15)

key15 = [
    ("1", "MC cause (developed) = Hashimoto's (Anti-TPO +ve)  |  MC worldwide = Iodine Deficiency"),
    ("2", "Best test = Serum TSH.  Overt: TSH >10 + ↓FT4.  Subclinical: TSH 4–10 + normal FT4"),
    ("3", "Hertoghe's sign = loss of outer 1/3 eyebrow  |  Woltman sign = slow-relaxing ankle jerks"),
    ("4", "Hypothyroidism = reversible secondary hypercholesterolaemia — always screen TFTs"),
    ("5", "L-Thyroxine 1.6 mcg/kg/day on empty stomach  |  Recheck TSH only at 4–6 weeks"),
    ("6", "Pregnancy: increase dose 25–30%;  Target TSH < 2.5 mIU/L in 1st trimester"),
    ("7", "Congenital: screen day 3–5; treat within 2 weeks to prevent irreversible cretinism"),
    ("8", "Myxedema crisis: IV L-T4 200–400 mcg + IV Hydrocortisone 100–200 mg; mortality 30–60%"),
    ("9", "Drug causes: Lithium, Amiodarone (14%), Sunitinib, alpha-IFN, IL-2, Valproate"),
]
kh15 = (PH - 64 - FTR_H - 4) / len(key15)
for i15, (n15, t15) in enumerate(key15):
    by15 = PH - 64 - 2 - (i15+1)*kh15
    bgc15 = colors.HexColor("#1A237E") if i15%2==0 else colors.HexColor("#283593")
    c.setFillColor(bgc15); c.roundRect(M, by15, CW, kh15-2, 3, fill=1, stroke=0)
    c.setFillColor(C["amber"]); c.roundRect(M+2, by15+2, 26, kh15-6, 3, fill=1, stroke=0)
    c.setFillColor(C["dark_blue"]); c.setFont("Helvetica-Bold", 11)
    c.drawCentredString(M+15, by15+kh15/2-4, n15)
    c.setFillColor(C["white"]); c.setFont("Helvetica", 10.5)
    c.drawString(M+34, by15+kh15/2-4, t15)

c.save()
print(f"PDF saved: {OUT}")
Running Command

cd /tmp/workspace/hypothyroidism-ppt && python create_pdf_v3.py 2>&1

Editing File

~/hypothyroidism-ppt/create_pdf_v3.py

Successfully replaced 1 instance(s) of the string in '/tmp/workspace/hypothyroidism-ppt/create_pdf_v3.py'
Editing File

~/hypothyroidism-ppt/create_pdf_v3.py

Successfully replaced 1 instance(s) of the string in '/tmp/workspace/hypothyroidism-ppt/create_pdf_v3.py'
Running Command

cd /tmp/workspace/hypothyroidism-ppt && python create_pdf_v3.py 2>&1

Running Command

ls -lh /tmp/workspace/hypothyroidism-ppt/Hypothyroidism_Mokshit_Panwar_v3.* 2>&1

Both files are fixed and ready. Here are your downloads:

PowerPoint (v3 — Fixed)

Hypothyroidism Mokshit Panwar v3

Presentation · PPTX

PDF (v3 — Fixed)

Hypothyroidism Mokshit Panwar v3

PDF Document · PDF


What was fixed:
ProblemFix Applied
Header bar too thin (0.92 in)Increased to 1.15 in with clear internal padding
Title text touching the accent stripeMoved slide title to y = 0.14 in, giving full vertical room at 28pt
Content boxes starting too close to headerContent now strictly starts at CT = 1.30 in from top
PDF: title_strip() missing h parameterCorrected function signature — box height passed explicitly
All boxes had fixed spacing that caused crowdingComputed box heights dynamically from available CH (content height)
No text, heading, or box should overlap anywhere across all 15 slides now.
This is a shared conversation. Sign in to Orris to start your own chat.