GI bleeding (upper and lower) detailed PowerPoint presentation for postgraduate internal medicine students

Reading File
Reading File
Reading File
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Reading File
Finding Sources
Finding Sources
Searching Images

upper gastrointestinal bleeding endoscopy peptic ulcer

This composite educational image features two frames (A and B) from an upper gastrointestinal endoscopy, illustrating the diagnosis and treatment of acute peptic ulcer bleeding in the duodenal bulb. Frame A demonstrates clinical findings of hematemesis and melena, showing two cratered, oozing ulcers located in the duodenum. Significant active hemorrhage is visible as bright red blood pooling over the mucosal surface. The largest ulcer measures approximately 10 mm in diameter with a visible base. Frame B shows the immediate post-intervention state following the administration of 1:10,000 epinephrine (4cc) and the deployment of metallic hemostatic clips. A hemostatic clip is clearly visible, mechanically compressing the ulcerated site to achieve primary hemostasis. The surrounding mucosa appears altered in color, showing a reddish-orange hue with reduced active bleeding compared to the initial diagnostic view. This sequence serves as a clinical teaching tool for endoscopic management of gastroduodenal artery-related bleeding and the utilization of endoscopic markers to guide subsequent angiographic interventions.

This composite educational image features two frames (A and B) from an upper gastrointestinal endoscopy, illustrating the diagnosis and treatment of acute peptic ulcer bleeding in the duodenal bulb. Frame A demonstrates clinical findings of hematemesis and melena, showing two cratered, oozing ulcers located in the duodenum. Significant active hemorrhage is visible as bright red blood pooling over the mucosal surface. The largest ulcer measures approximately 10 mm in diameter with a visible base. Frame B shows the immediate post-intervention state following the administration of 1:10,000 epinephrine (4cc) and the deployment of metallic hemostatic clips. A hemostatic clip is clearly visible, mechanically compressing the ulcerated site to achieve primary hemostasis. The surrounding mucosa appears altered in color, showing a reddish-orange hue with reduced active bleeding compared to the initial diagnostic view. This sequence serves as a clinical teaching tool for endoscopic management of gastroduodenal artery-related bleeding and the utilization of endoscopic markers to guide subsequent angiographic interventions.

Content Type: Clinical Photograph (Endoscopy). Medical Specialty: Gastroenterology. Target Audience: Intermediate/Advanced. This figure presents three endoscopic views of the upper gastrointestinal tract, specifically capturing the pylorus and the first two segments of the duodenum. The images reveal multiple peptic ulcers characterized as non-bleeding mucosal defects. These lesions demonstrate clean bases (Forrest Class III), meaning they lack stigmata of recent hemorrhage such as adherent clots, visible vessels, or active oozing. The surrounding duodenal and pyloric mucosa appears generally healthy, with a normal pink hue and smooth texture, showing no signs of diffuse inflammation, nodularity, or secondary lesions. The images provide clinical evidence of peptic ulcer disease (PUD) located in the duodenal bulb and sweep, serving as an educational resource for identifying low-risk ulcer morphology during esophagogastroduodenoscopy (EGD) in the context of gastrointestinal bleeding evaluation.

Content Type: Clinical Photograph (Endoscopy). Medical Specialty: Gastroenterology. Target Audience: Intermediate/Advanced. This figure presents three endoscopic views of the upper gastrointestinal tract, specifically capturing the pylorus and the first two segments of the duodenum. The images reveal multiple peptic ulcers characterized as non-bleeding mucosal defects. These lesions demonstrate clean bases (Forrest Class III), meaning they lack stigmata of recent hemorrhage such as adherent clots, visible vessels, or active oozing. The surrounding duodenal and pyloric mucosa appears generally healthy, with a normal pink hue and smooth texture, showing no signs of diffuse inflammation, nodularity, or secondary lesions. The images provide clinical evidence of peptic ulcer disease (PUD) located in the duodenal bulb and sweep, serving as an educational resource for identifying low-risk ulcer morphology during esophagogastroduodenoscopy (EGD) in the context of gastrointestinal bleeding evaluation.

This clinical photograph shows an upper gastrointestinal endoscopy (EGD) of the gastric mucosa. The image displays a non-bleeding, cratered gastric ulcer located at the incisura angularis. The ulcer is characterized by a central depression with a pale base, surrounded by significantly inflamed gastric tissue. The surrounding mucosa demonstrates diffuse moderate gastritis, marked by erythema (redness), vascular congestion, and a friable texture. An endoscopic instrument, likely a polypectomy snare or retrieval device, is visible in the foreground, indicating an active interventional procedure. This image illustrates gastric mucosal injury and ulceration, which in this clinical context is secondary to chemical irritation from a foreign body (cigarette lighter fluid). It serves as an educational example of corrosive-induced peptic ulcer disease and the endoscopic appearance of acute gastric inflammation.

This clinical photograph shows an upper gastrointestinal endoscopy (EGD) of the gastric mucosa. The image displays a non-bleeding, cratered gastric ulcer located at the incisura angularis. The ulcer is characterized by a central depression with a pale base, surrounded by significantly inflamed gastric tissue. The surrounding mucosa demonstrates diffuse moderate gastritis, marked by erythema (redness), vascular congestion, and a friable texture. An endoscopic instrument, likely a polypectomy snare or retrieval device, is visible in the foreground, indicating an active interventional procedure. This image illustrates gastric mucosal injury and ulceration, which in this clinical context is secondary to chemical irritation from a foreign body (cigarette lighter fluid). It serves as an educational example of corrosive-induced peptic ulcer disease and the endoscopic appearance of acute gastric inflammation.

This clinical photograph shows a high-definition endoscopic view of the duodenal bulb during an upper gastrointestinal endoscopy. The primary finding is a deep, excavated peptic ulcer with a heterogeneous base containing whitish-yellow fibrin and areas of darker, necrotic tissue or adherent clot. The lumen is extensively occupied by fresh, bright red blood (hematinic fluid), indicating severe active hemorrhage. The blood is seen pooling and obscuring much of the surrounding mucosal architecture. In the bottom left foreground, a blue-tipped endoscopic instrument is visible, indicating an active attempt at hemostasis or assessment. The visual findings are consistent with a high-risk Forrest classification (likely FIa or FIb) ulcer, where the brisk rate of bleeding suggests arterial involvement. This image is used to teach endoscopic recognition of life-threatening gastrointestinal bleeding and the challenges of visualizing a source in a field filled with fresh blood.

This clinical photograph shows a high-definition endoscopic view of the duodenal bulb during an upper gastrointestinal endoscopy. The primary finding is a deep, excavated peptic ulcer with a heterogeneous base containing whitish-yellow fibrin and areas of darker, necrotic tissue or adherent clot. The lumen is extensively occupied by fresh, bright red blood (hematinic fluid), indicating severe active hemorrhage. The blood is seen pooling and obscuring much of the surrounding mucosal architecture. In the bottom left foreground, a blue-tipped endoscopic instrument is visible, indicating an active attempt at hemostasis or assessment. The visual findings are consistent with a high-risk Forrest classification (likely FIa or FIb) ulcer, where the brisk rate of bleeding suggests arterial involvement. This image is used to teach endoscopic recognition of life-threatening gastrointestinal bleeding and the challenges of visualizing a source in a field filled with fresh blood.

Reading File
Finding Sources
Finding Sources
Searching Images

lower GI bleeding colonoscopy diverticular hemorrhage

This clinical photograph consists of two endoscopic images (A and B) showing the findings of a bedside colonoscopy in a patient with lower gastrointestinal bleeding. Image A depicts the colonic lumen filled with fresh, dark-red blood coating the mucosal surface, which obscures fine vascular details and gives the lining a glistening, wet appearance. Image B shows a close-up of a colonic diverticulum, appearing as a dark, circular outpouching or orifice within the bowel wall. The surrounding mucosa is intensely erythematous and friable, with visible streaks of fresh blood and inflammatory changes. These images illustrate acute diverticular bleeding, a common cause of hematochezia. The clinical context involves a COVID-19 patient on high-dose corticosteroids, suggesting a potential relationship between severe systemic illness, medication-induced mucosal stress, and gastrointestinal complications. The visual evidence supports a diagnosis of lower GI hemorrhage originating from diverticulosis.

This clinical photograph consists of two endoscopic images (A and B) showing the findings of a bedside colonoscopy in a patient with lower gastrointestinal bleeding. Image A depicts the colonic lumen filled with fresh, dark-red blood coating the mucosal surface, which obscures fine vascular details and gives the lining a glistening, wet appearance. Image B shows a close-up of a colonic diverticulum, appearing as a dark, circular outpouching or orifice within the bowel wall. The surrounding mucosa is intensely erythematous and friable, with visible streaks of fresh blood and inflammatory changes. These images illustrate acute diverticular bleeding, a common cause of hematochezia. The clinical context involves a COVID-19 patient on high-dose corticosteroids, suggesting a potential relationship between severe systemic illness, medication-induced mucosal stress, and gastrointestinal complications. The visual evidence supports a diagnosis of lower GI hemorrhage originating from diverticulosis.

Two side-by-side endoscopic images (colonoscopy) demonstrating colonic diverticular bleeding and subsequent intervention. Image (a) shows a focal point of active hemorrhage originating from a diverticulum in the transverse colon. The mucosa appears erythematous and edematous, with a pool of fresh, bright red blood collecting on the dependent wall. Image (b) captures a recurrent bleeding episode at the same site, viewed through an endoscopic ligation cap. A stream of active bleeding is visible within the center of the field. A blue elastic band is visible, positioned for endoscopic band ligation (EBL). The mucosal tissue within the ligation device appears blanched due to mechanical compression. These images illustrate the diagnostic visualization of lower gastrointestinal bleeding and the application of mechanical hemostasis when initial clip placement has failed. This content is intended for intermediate to advanced medical learners studying gastroenterology and emergency endoscopic procedures.

Two side-by-side endoscopic images (colonoscopy) demonstrating colonic diverticular bleeding and subsequent intervention. Image (a) shows a focal point of active hemorrhage originating from a diverticulum in the transverse colon. The mucosa appears erythematous and edematous, with a pool of fresh, bright red blood collecting on the dependent wall. Image (b) captures a recurrent bleeding episode at the same site, viewed through an endoscopic ligation cap. A stream of active bleeding is visible within the center of the field. A blue elastic band is visible, positioned for endoscopic band ligation (EBL). The mucosal tissue within the ligation device appears blanched due to mechanical compression. These images illustrate the diagnostic visualization of lower gastrointestinal bleeding and the application of mechanical hemostasis when initial clip placement has failed. This content is intended for intermediate to advanced medical learners studying gastroenterology and emergency endoscopic procedures.

This clinical photograph shows an endoscopic view of the right colon during a colonoscopy procedure for diverticular bleeding. The image highlights a colonic diverticulum being managed with a short-armed hemostatic clip. The metallic clip is seen applied directly to a visible vessel within the mucosal pocket to achieve pinpoint hemostasis. The surrounding mucosa appears erythematous and irregular, with visible red patches consistent with recent hemorrhage or local inflammation. A transparent hood attached to the colonoscope tip is visible in the foreground, utilized to stabilize the working space and facilitate water inflation to open the diverticulum for better visualization. This image demonstrates the technical application of endoscopic clipping for the treatment of lower gastrointestinal bleeding associated with colonic diverticulosis.

This clinical photograph shows an endoscopic view of the right colon during a colonoscopy procedure for diverticular bleeding. The image highlights a colonic diverticulum being managed with a short-armed hemostatic clip. The metallic clip is seen applied directly to a visible vessel within the mucosal pocket to achieve pinpoint hemostasis. The surrounding mucosa appears erythematous and irregular, with visible red patches consistent with recent hemorrhage or local inflammation. A transparent hood attached to the colonoscope tip is visible in the foreground, utilized to stabilize the working space and facilitate water inflation to open the diverticulum for better visualization. This image demonstrates the technical application of endoscopic clipping for the treatment of lower gastrointestinal bleeding associated with colonic diverticulosis.

Reading File
Reading File
Reading File
Searching Images

esophageal varices portal hypertension bleeding endoscopy

A composite of eight endoscopic images (A-H) illustrating portal hypertension-related pathologies and Upper Gastrointestinal (UGI) endoscopy findings. (A-C) show the progression and severity of esophageal varices; A demonstrates grade 3 varices in the mid-esophagus, while B and C depict high-grade (grade 3-4) varices at the gastroesophageal junction with visible 'red signs' (cherry red spots), indicating a high risk of imminent hemorrhage. (D-F) focus on gastric findings related to variceal bleeding; D shows the gastric body with altered 'old' blood, E provides a view through an endoscopic band ligator during a therapeutic procedure, and F shows clotted blood within the gastric fundus in a retroflexed view. (G-H) represent duodenal involvement, with G showing erythema and mucosal changes characteristic of duodenopathy in the duodenal cap, and H illustrating congested, edematous mucosa in the descending duodenum. This series serves as a clinical reference for diagnosing and managing esophageal varices, portal hypertensive gastropathy, and duodenopathy in the context of acute gastrointestinal bleeding.

A composite of eight endoscopic images (A-H) illustrating portal hypertension-related pathologies and Upper Gastrointestinal (UGI) endoscopy findings. (A-C) show the progression and severity of esophageal varices; A demonstrates grade 3 varices in the mid-esophagus, while B and C depict high-grade (grade 3-4) varices at the gastroesophageal junction with visible 'red signs' (cherry red spots), indicating a high risk of imminent hemorrhage. (D-F) focus on gastric findings related to variceal bleeding; D shows the gastric body with altered 'old' blood, E provides a view through an endoscopic band ligator during a therapeutic procedure, and F shows clotted blood within the gastric fundus in a retroflexed view. (G-H) represent duodenal involvement, with G showing erythema and mucosal changes characteristic of duodenopathy in the duodenal cap, and H illustrating congested, edematous mucosa in the descending duodenum. This series serves as a clinical reference for diagnosing and managing esophageal varices, portal hypertensive gastropathy, and duodenopathy in the context of acute gastrointestinal bleeding.

A pair of endoscopic clinical photographs illustrating the esophagus before and after endoscopic variceal ligation (EVL). Image A shows moderately enlarged, beads-like (F2) esophageal varices protruding into the esophageal lumen. The varices appear as dilated, tortuous, and nodular-shaped venous structures with an irregular surface, typical of severe portal hypertension. Image B demonstrates the immediate post-EVL state, characterized by significant oozing hemorrhage and fresh blood pooling within the lumen, which obscures the underlying mucosal details. This side-by-side comparison highlights the clinical presentation of esophageal varices and the potential complication of immediate post-procedural bleeding during or after band ligation. The educational focus is on identifying variceal morphology and recognizing complications of therapeutic endoscopy in the management of portal hypertension.

A pair of endoscopic clinical photographs illustrating the esophagus before and after endoscopic variceal ligation (EVL). Image A shows moderately enlarged, beads-like (F2) esophageal varices protruding into the esophageal lumen. The varices appear as dilated, tortuous, and nodular-shaped venous structures with an irregular surface, typical of severe portal hypertension. Image B demonstrates the immediate post-EVL state, characterized by significant oozing hemorrhage and fresh blood pooling within the lumen, which obscures the underlying mucosal details. This side-by-side comparison highlights the clinical presentation of esophageal varices and the potential complication of immediate post-procedural bleeding during or after band ligation. The educational focus is on identifying variceal morphology and recognizing complications of therapeutic endoscopy in the management of portal hypertension.

Reading File
Reading File
Searching Images

Forrest classification endoscopic stigmata peptic ulcer bleeding

This composite educational clinical image demonstrates the Forrest classification for peptic ulcer bleeding (PUB) via six gastroscopic panels. Top row (Active Bleeding): Forrest Ia shows 'spurting hemorrhage' with an arterial jet; Forrest Ib shows 'oozing hemorrhage' without a visible vessel. Middle and bottom rows (Recent Hemorrhage Signs): Forrest IIa depicts a 'non-bleeding visible vessel' as a protuberant lesion; Forrest IIb shows an 'adherent clot' covering the ulcer base; Forrest IIc presents 'flat pigmented spots' (hematin) indicating recent stasis; and Forrest III displays a 'clean-based ulcer' with a white fibrin base and no stigmata of hemorrhage. This classification system is essential for gastroenterologists to assess rebleeding risk and determine the necessity of endoscopic hemostasis therapy during emergency esophagogastroduodenoscopy (EGD).

This composite educational clinical image demonstrates the Forrest classification for peptic ulcer bleeding (PUB) via six gastroscopic panels. Top row (Active Bleeding): Forrest Ia shows 'spurting hemorrhage' with an arterial jet; Forrest Ib shows 'oozing hemorrhage' without a visible vessel. Middle and bottom rows (Recent Hemorrhage Signs): Forrest IIa depicts a 'non-bleeding visible vessel' as a protuberant lesion; Forrest IIb shows an 'adherent clot' covering the ulcer base; Forrest IIc presents 'flat pigmented spots' (hematin) indicating recent stasis; and Forrest III displays a 'clean-based ulcer' with a white fibrin base and no stigmata of hemorrhage. This classification system is essential for gastroenterologists to assess rebleeding risk and determine the necessity of endoscopic hemostasis therapy during emergency esophagogastroduodenoscopy (EGD).

A composite clinical comparison chart displaying six endoscopic images of gastric or duodenal ulcers, classified according to the Forrest (F) criteria for stigmata of recent hemorrhage (SRH). The images illustrate the visual spectrum of peptic ulcer bleeding severity. Forrest IA (Arterial Bleed) shows active, bright red spurting blood. Forrest IB (Oozing) demonstrates a slower, continuous seepage of blood over the ulcer base. Forrest IIA (Non-bleeding visible vessel) reveals a prominent, dark, raised protuberance within the ulcer without active hemorrhage. Forrest IIB (Adherent clot) depicts a large, dark, gelatinous blood clot firmly attached to the ulcer base. Forrest IIC (Flat spot) shows a non-raised, pigmented (red or brown) speckle representing a resolving hematin. Forrest III (Clean Ulcer Base) displays a smooth, whitish, fibrin-covered ulcer bed with no evidence of vascular stigmata. This infographic serves as a diagnostic tool for gastroenterologists to assess rebleeding risk and determine the necessity for endoscopic hemostatic intervention.

A composite clinical comparison chart displaying six endoscopic images of gastric or duodenal ulcers, classified according to the Forrest (F) criteria for stigmata of recent hemorrhage (SRH). The images illustrate the visual spectrum of peptic ulcer bleeding severity. Forrest IA (Arterial Bleed) shows active, bright red spurting blood. Forrest IB (Oozing) demonstrates a slower, continuous seepage of blood over the ulcer base. Forrest IIA (Non-bleeding visible vessel) reveals a prominent, dark, raised protuberance within the ulcer without active hemorrhage. Forrest IIB (Adherent clot) depicts a large, dark, gelatinous blood clot firmly attached to the ulcer base. Forrest IIC (Flat spot) shows a non-raised, pigmented (red or brown) speckle representing a resolving hematin. Forrest III (Clean Ulcer Base) displays a smooth, whitish, fibrin-covered ulcer bed with no evidence of vascular stigmata. This infographic serves as a diagnostic tool for gastroenterologists to assess rebleeding risk and determine the necessity for endoscopic hemostatic intervention.

Running Command

mkdir -p /tmp/workspace/gi-bleeding-ppt && ls /tmp/workspace/gi-bleeding-ppt

Writing File

~/gi-bleeding-ppt/build_ppt.py


import json, subprocess, 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

# ── colour palette ──────────────────────────────────────────────────────────
DARK_BLUE   = RGBColor(0x0A, 0x2A, 0x5E)   # title bars, headers
MID_BLUE    = RGBColor(0x1A, 0x5C, 0x96)   # section accent
LIGHT_BLUE  = RGBColor(0xD6, 0xE9, 0xF8)   # content bg tint
RED_ACCENT  = RGBColor(0xC0, 0x00, 0x00)   # danger / UGIB accent
GREEN_ACC   = RGBColor(0x1A, 0x7A, 0x3C)   # LGIB accent
GOLD        = RGBColor(0xF5, 0xA6, 0x23)   # highlight bullets
WHITE       = RGBColor(0xFF, 0xFF, 0xFF)
LIGHT_GRAY  = RGBColor(0xF2, 0xF2, 0xF2)
DARK_GRAY   = RGBColor(0x33, 0x33, 0x33)
ORANGE      = RGBColor(0xE6, 0x72, 0x20)

W = Inches(13.333)
H = Inches(7.5)

prs = Presentation()
prs.slide_width  = W
prs.slide_height = H

blank = prs.slide_layouts[6]

# ── helpers ─────────────────────────────────────────────────────────────────
def add_rect(slide, x, y, w, h, fill_rgb, alpha=None):
    shape = slide.shapes.add_shape(1, x, y, w, h)   # MSO_SHAPE_TYPE.RECTANGLE=1
    shape.line.fill.background()
    if fill_rgb is None:
        shape.fill.background()
    else:
        shape.fill.solid()
        shape.fill.fore_color.rgb = fill_rgb
    shape.line.color.rgb = fill_rgb if fill_rgb else WHITE
    return shape

def add_tb(slide, x, y, w, h,
           text="", size=18, bold=False, italic=False,
           color=DARK_GRAY, align=PP_ALIGN.LEFT,
           wrap=True, v_anchor=MSO_ANCHOR.TOP,
           margins=(0,0,0,0)):
    tb = slide.shapes.add_textbox(x, y, w, h)
    tf = tb.text_frame
    tf.word_wrap = wrap
    tf.vertical_anchor = v_anchor
    tf.margin_left   = margins[0]
    tf.margin_right  = margins[1]
    tf.margin_top    = margins[2]
    tf.margin_bottom = margins[3]
    p = tf.paragraphs[0]
    p.alignment = align
    r = p.add_run()
    r.text = text
    r.font.name  = "Calibri"
    r.font.size  = Pt(size)
    r.font.bold  = bold
    r.font.italic = italic
    r.font.color.rgb = color
    return tb, tf

def add_bullets(slide, x, y, w, h, items, size=16, color=DARK_GRAY,
                bullet_color=None, indent=Inches(0.25), bold_first=False,
                line_spacing=1.15):
    """items: list of str  OR  list of (str, sub-list)"""
    from pptx.util import Pt as _Pt
    from pptx.oxml.ns import qn as _qn
    from lxml import etree as _et

    tb = slide.shapes.add_textbox(x, y, w, h)
    tf = tb.text_frame
    tf.word_wrap = True
    tf.margin_left = Inches(0.08)
    tf.margin_top  = Inches(0.05)
    tf.margin_right= 0
    tf.margin_bottom=0

    first = True
    for item in items:
        if isinstance(item, tuple):
            main_text, subs = item
        else:
            main_text, subs = item, []

        p = tf.add_paragraph() if not first else tf.paragraphs[0]
        first = False
        p.alignment = PP_ALIGN.LEFT

        # bullet via XML
        pPr = p._p.get_or_add_pPr()
        buChar = _et.SubElement(pPr, _qn('a:buChar'))
        buChar.set('char', '•')
        buFont = _et.SubElement(pPr, _qn('a:buFont'))
        buFont.set('typeface', 'Arial')
        buClr = _et.SubElement(pPr, _qn('a:buClr'))
        srgb  = _et.SubElement(buClr, _qn('a:srgbClr'))
        bc = bullet_color or GOLD
        srgb.set('val', f'{bc.rgb:06X}')
        indEl = pPr.get_or_add_ind()
        indEl.set('marL', str(int(indent)))
        indEl.set('indent', str(-int(indent)))
        lnSpc = _et.SubElement(pPr, _qn('a:lnSpc'))
        spcPct = _et.SubElement(lnSpc, _qn('a:spcPct'))
        spcPct.set('val', str(int(line_spacing * 100000)))

        r = p.add_run()
        r.text = main_text
        r.font.name = "Calibri"
        r.font.size = _Pt(size)
        r.font.color.rgb = color
        r.font.bold = bold_first and (items.index(item) == 0)

        for sub in subs:
            sp = tf.add_paragraph()
            sp.alignment = PP_ALIGN.LEFT
            spPr = sp._p.get_or_add_pPr()
            buChar2 = _et.SubElement(spPr, _qn('a:buChar'))
            buChar2.set('char', '–')
            buFont2 = _et.SubElement(spPr, _qn('a:buFont'))
            buFont2.set('typeface', 'Arial')
            buClr2 = _et.SubElement(spPr, _qn('a:buClr'))
            srgb2  = _et.SubElement(buClr2, _qn('a:srgbClr'))
            srgb2.set('val', f'{MID_BLUE.rgb:06X}')
            indEl2 = spPr.get_or_add_ind()
            indEl2.set('marL', str(int(indent * 1.9)))
            indEl2.set('indent', str(-int(indent * 0.9)))
            rs = sp.add_run()
            rs.text = sub
            rs.font.name = "Calibri"
            rs.font.size = _Pt(size - 1.5)
            rs.font.color.rgb = DARK_GRAY
    return tb

def add_table_slide(slide, headers, rows, x, y, w, h, hdr_fill=DARK_BLUE, row_fills=None):
    from pptx.util import Inches as _In, Pt as _Pt
    cols = len(headers)
    nrows = len(rows)
    tbl = slide.shapes.add_table(nrows + 1, cols, x, y, w, h).table
    tbl.first_row = True

    col_w = w // cols
    for ci in range(cols):
        tbl.columns[ci].width = col_w

    # header row
    for ci, hdr in enumerate(headers):
        cell = tbl.cell(0, ci)
        cell.fill.solid()
        cell.fill.fore_color.rgb = hdr_fill
        p = cell.text_frame.paragraphs[0]
        p.alignment = PP_ALIGN.CENTER
        r = p.add_run()
        r.text = hdr
        r.font.name = "Calibri"
        r.font.bold = True
        r.font.size = _Pt(13)
        r.font.color.rgb = WHITE

    alt_fills = [LIGHT_GRAY, WHITE]
    for ri, row in enumerate(rows):
        rf = row_fills[ri] if row_fills else alt_fills[ri % 2]
        for ci, val in enumerate(row):
            cell = tbl.cell(ri + 1, ci)
            cell.fill.solid()
            cell.fill.fore_color.rgb = rf
            p = cell.text_frame.paragraphs[0]
            p.alignment = PP_ALIGN.CENTER
            r = p.add_run()
            r.text = str(val)
            r.font.name  = "Calibri"
            r.font.size  = _Pt(12.5)
            r.font.color.rgb = DARK_GRAY
    return tbl

def gradient_bar(slide, y=0, h=Inches(0.85)):
    """Simple two-tone header bar using two overlapping shapes."""
    add_rect(slide, 0, y, W, h, DARK_BLUE)
    add_rect(slide, W * 0.65, y, W * 0.35, h, MID_BLUE)

def slide_header(slide, title, subtitle=None, accent_color=DARK_BLUE):
    """Standard header band + title text used on all content slides."""
    add_rect(slide, 0, 0, W, Inches(0.85), accent_color)
    add_rect(slide, 0, Inches(0.85), W, Inches(0.05), GOLD)
    add_tb(slide, Inches(0.3), Inches(0.07), W - Inches(0.6), Inches(0.72),
           text=title, size=26, bold=True, color=WHITE,
           align=PP_ALIGN.LEFT, v_anchor=MSO_ANCHOR.MIDDLE)
    if subtitle:
        add_tb(slide, Inches(0.3), Inches(0.88), W - Inches(0.6), Inches(0.35),
               text=subtitle, size=13, italic=True, color=MID_BLUE)

def footer(slide, text="GI Bleeding | Postgraduate Internal Medicine"):
    add_rect(slide, 0, H - Inches(0.28), W, Inches(0.28), DARK_BLUE)
    add_tb(slide, Inches(0.3), H - Inches(0.26), W - Inches(0.6), Inches(0.26),
           text=text, size=9, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)

def embed_image(slide, url, x, y, w, h):
    result = json.loads(subprocess.check_output(
        ["python", "/tmp/skills/shared/scripts/fetch_images.py", url]
    ))
    img = result[0]
    if img.get("base64"):
        raw = base64.b64decode(img["base64"].split(",", 1)[-1])
        slide.shapes.add_picture(BytesIO(raw), x, y, w, h)
        return True
    return False

# ════════════════════════════════════════════════════════════════════════════
# SLIDE 1 – TITLE SLIDE
# ════════════════════════════════════════════════════════════════════════════
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, W, H, DARK_BLUE)
add_rect(slide, 0, 0, W * 0.55, H, MID_BLUE)
add_rect(slide, W * 0.55, 0, Inches(0.04), H, GOLD)
add_rect(slide, 0, H * 0.72, W, Inches(0.04), GOLD)

add_tb(slide, Inches(0.5), Inches(1.2), Inches(6.5), Inches(1.6),
       text="GASTROINTESTINAL\nBLEEDING", size=44, bold=True, color=WHITE,
       align=PP_ALIGN.LEFT, v_anchor=MSO_ANCHOR.MIDDLE, wrap=True)
add_tb(slide, Inches(0.5), Inches(2.9), Inches(6.5), Inches(0.6),
       text="Upper & Lower GI Bleeding", size=24, bold=False, italic=True,
       color=GOLD, align=PP_ALIGN.LEFT)
add_tb(slide, Inches(0.5), Inches(3.7), Inches(6.5), Inches(0.45),
       text="A Comprehensive Review for Postgraduate Internal Medicine", size=15,
       color=LIGHT_BLUE, align=PP_ALIGN.LEFT)
add_tb(slide, Inches(0.5), Inches(5.5), Inches(5.0), Inches(0.38),
       text="Dept. of Internal Medicine  |  Postgraduate Education", size=12,
       color=LIGHT_BLUE, align=PP_ALIGN.LEFT)
add_tb(slide, Inches(0.5), Inches(5.9), Inches(5.0), Inches(0.35),
       text="Sources: Sabiston Surgery, Goldman-Cecil Medicine, Maingot's Operations, Yamada's Gastroenterology",
       size=10, italic=True, color=LIGHT_BLUE)

# right panel – key stats
for i, (val, lbl) in enumerate([
    ("~85%", "UGIB stops\nspontaneously"),
    ("~80-85%", "LGIB stops\nspontaneously"),
    ("5-10%", "UGIB in-hospital\nmortality"),
]):
    yy = Inches(1.5) + i * Inches(1.7)
    add_rect(slide, Inches(8.0), yy, Inches(4.7), Inches(1.4), DARK_BLUE)
    add_rect(slide, Inches(8.0), yy, Inches(0.12), Inches(1.4), GOLD)
    add_tb(slide, Inches(8.25), yy + Inches(0.1), Inches(4.2), Inches(0.65),
           text=val, size=34, bold=True, color=GOLD, v_anchor=MSO_ANCHOR.TOP)
    add_tb(slide, Inches(8.25), yy + Inches(0.65), Inches(4.2), Inches(0.6),
           text=lbl, size=13, color=WHITE)
footer(slide)

# ════════════════════════════════════════════════════════════════════════════
# SLIDE 2 – OVERVIEW & DEFINITIONS
# ════════════════════════════════════════════════════════════════════════════
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, W, H, LIGHT_GRAY)
slide_header(slide, "Overview & Definitions")
footer(slide)

boxes = [
    ("UGIB", "Upper GI Bleeding", RED_ACCENT,
     ["Source proximal to Ligament of Treitz",
      "3× more common than LGIB",
      "Presents: hematemesis, coffee-ground emesis, melena",
      "Melena visible with as little as 50 mL blood loss"]),
    ("LGIB", "Lower GI Bleeding", GREEN_ACC,
     ["Source distal to Ligament of Treitz",
      "~95% from colon; ~5% small bowel",
      "Presents: hematochezia (maroon/bright-red blood PR)",
      "Spontaneous cessation in 80-85% of cases"]),
]
for ci, (abbr, title, col, pts) in enumerate(boxes):
    bx = Inches(0.35) + ci * Inches(6.45)
    add_rect(slide, bx, Inches(0.95), Inches(6.15), Inches(5.8), WHITE)
    add_rect(slide, bx, Inches(0.95), Inches(6.15), Inches(0.55), col)
    add_tb(slide, bx + Inches(0.15), Inches(0.97), Inches(5.8), Inches(0.52),
           text=f"{abbr} – {title}", size=17, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
    for i, pt in enumerate(pts):
        yy = Inches(1.62) + i * Inches(0.62)
        add_rect(slide, bx + Inches(0.12), yy + Inches(0.14), Inches(0.1), Inches(0.22), col)
        add_tb(slide, bx + Inches(0.32), yy, Inches(5.6), Inches(0.58),
               text=pt, size=14, color=DARK_GRAY, wrap=True)

add_rect(slide, Inches(0.35), Inches(6.88), W - Inches(0.7), Inches(0.4), LIGHT_BLUE)
add_tb(slide, Inches(0.5), Inches(6.88), W - Inches(0.9), Inches(0.4),
       text="Key: Ligament of Treitz (distal duodenum) = anatomical dividing line between UGIB and LGIB",
       size=12, italic=True, color=DARK_BLUE, v_anchor=MSO_ANCHOR.MIDDLE)

# ════════════════════════════════════════════════════════════════════════════
# SLIDE 3 – EPIDEMIOLOGY & ETIOLOGY
# ════════════════════════════════════════════════════════════════════════════
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, W, H, LIGHT_GRAY)
slide_header(slide, "Epidemiology & Etiology of GI Bleeding")
footer(slide)

# UGIB causes column
add_rect(slide, Inches(0.3), Inches(1.0), Inches(6.1), Inches(5.75), WHITE)
add_rect(slide, Inches(0.3), Inches(1.0), Inches(6.1), Inches(0.42), RED_ACCENT)
add_tb(slide, Inches(0.45), Inches(1.0), Inches(5.8), Inches(0.42),
       text="UPPER GI BLEEDING – Causes", size=15, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
ugib_causes = [
    ("Peptic Ulcer Disease (40%)", ["H. pylori, NSAIDs, stress; most common"]),
    ("Gastritis / Erosive Esophagitis", ["NSAIDs, alcohol, stress ulcers"]),
    ("Esophageal / Gastric Varices (10-20%)", ["Portal hypertension; high mortality"]),
    ("Mallory-Weiss Tear (5-10%)", ["Mucosal tear at GEJ after retching"]),
    ("Dieulafoy Lesion", ["Submucosal artery eroding through mucosa"]),
    ("GAVE (Watermelon Stomach)", ["Gastric antral vascular ectasia"]),
    ("Aortoenteric Fistula", ["Prior aortic graft – consider in any UGIB"]),
    ("Neoplasms / Cameron Lesions", ["Hiatal hernia ulcers"]),
]
for i, (main, subs) in enumerate(ugib_causes):
    yy = Inches(1.52) + i * Inches(0.55)
    add_rect(slide, Inches(0.42), yy + Inches(0.15), Inches(0.08), Inches(0.22), RED_ACCENT)
    add_tb(slide, Inches(0.58), yy, Inches(5.6), Inches(0.35),
           text=main, size=13, bold=True, color=DARK_GRAY, wrap=True)
    for j, sub in enumerate(subs):
        add_tb(slide, Inches(0.75), yy + Inches(0.33), Inches(5.2), Inches(0.24),
               text=f"  – {sub}", size=11, italic=True, color=MID_BLUE, wrap=True)

# LGIB causes column
add_rect(slide, Inches(6.7), Inches(1.0), Inches(6.3), Inches(5.75), WHITE)
add_rect(slide, Inches(6.7), Inches(1.0), Inches(6.3), Inches(0.42), GREEN_ACC)
add_tb(slide, Inches(6.85), Inches(1.0), Inches(6.0), Inches(0.42),
       text="LOWER GI BLEEDING – Causes", size=15, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
lgib_causes = [
    ("Diverticulosis (30-40%)", ["Most common; painless; often right-sided"]),
    ("Angiodysplasia / AVM (40%)", ["Elderly + CKD; cecum & right colon"]),
    ("Ischemic Colitis (6-18%)", ["Watershed areas: splenic flexure, sigmoid"]),
    ("Colorectal Neoplasm", ["Change in bowel habits, weight loss"]),
    ("IBD (Crohn's, UC)", ["Younger patients; diarrhea + blood"]),
    ("Hemorrhoids / Anal Fissure", ["Painless bright-red blood on tissue"]),
    ("Infectious Colitis", ["CMV, C. diff, Shigella, Campylobacter"]),
    ("Post-polypectomy Bleed", ["Delayed 1-14 days after procedure"]),
]
for i, (main, subs) in enumerate(lgib_causes):
    yy = Inches(1.52) + i * Inches(0.55)
    add_rect(slide, Inches(6.82), yy + Inches(0.15), Inches(0.08), Inches(0.22), GREEN_ACC)
    add_tb(slide, Inches(6.98), yy, Inches(5.8), Inches(0.35),
           text=main, size=13, bold=True, color=DARK_GRAY, wrap=True)
    for j, sub in enumerate(subs):
        add_tb(slide, Inches(7.15), yy + Inches(0.33), Inches(5.5), Inches(0.24),
               text=f"  – {sub}", size=11, italic=True, color=MID_BLUE, wrap=True)

# ════════════════════════════════════════════════════════════════════════════
# SLIDE 4 – CLINICAL PRESENTATION
# ════════════════════════════════════════════════════════════════════════════
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, W, H, LIGHT_GRAY)
slide_header(slide, "Clinical Presentation & Initial Assessment")
footer(slide)

# Symptoms table
symptoms = [
    ("Hematemesis", "Bright red / coffee-ground", "Proximal to ligament of Treitz", "UGIB"),
    ("Melena", "Black, tarry, foul-smelling stool", "UGIB (>90%); small bowel; rarely colon", "UGIB >> LGIB"),
    ("Hematochezia", "Maroon/bright-red blood per rectum", "Colon, rectum; massive UGIB (10-15%)", "LGIB (mostly)"),
    ("Occult bleed", "Iron-deficiency anemia, +FOBT", "Anywhere; look for neoplasm, erosions", "Any"),
]
add_table_slide(slide,
    ["Symptom", "Description", "Source Implication", "Origin"],
    symptoms,
    Inches(0.3), Inches(1.05), W - Inches(0.6), Inches(1.95),
    hdr_fill=DARK_BLUE)

# Haemodynamic assessment
add_rect(slide, Inches(0.3), Inches(3.15), W - Inches(0.6), Inches(0.38), MID_BLUE)
add_tb(slide, Inches(0.45), Inches(3.15), W - Inches(0.9), Inches(0.38),
       text="Haemodynamic Assessment – ATLS Classification of Blood Loss", size=14,
       bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
hemo = [
    ("Class I", "<750 mL (<15%)", "Normal", "Normal", "Normal"),
    ("Class II", "750-1500 mL (15-30%)", ">100 bpm; widened PP", "Normal/↓", "<30 mL/h"),
    ("Class III", "1500-2000 mL (30-40%)", ">120 bpm; hypotension", "↓↓", "<20 mL/h"),
    ("Class IV", ">2000 mL (>40%)", ">140 bpm; severe hypotension", "↓↓↓", "Negligible"),
]
add_table_slide(slide,
    ["Class", "Blood Loss", "Pulse/BP", "Mental Status", "Urine Output"],
    hemo, Inches(0.3), Inches(3.55), W - Inches(0.6), Inches(2.05),
    hdr_fill=MID_BLUE,
    row_fills=[LIGHT_GRAY, WHITE, RGBColor(0xFF,0xEB,0xEB), RGBColor(0xFF,0xCC,0xCC)])

# History pearls
add_rect(slide, Inches(0.3), Inches(5.72), W - Inches(0.6), Inches(1.45), WHITE)
add_rect(slide, Inches(0.3), Inches(5.72), Inches(3.0), Inches(1.45), LIGHT_BLUE)
add_tb(slide, Inches(0.45), Inches(5.78), Inches(2.7), Inches(1.35),
       text="History Pearls\n(Critical to ask)", size=14, bold=True,
       color=DARK_BLUE, v_anchor=MSO_ANCHOR.MIDDLE, wrap=True)
history_pts = [
    "Prior UGIB/LGIB – 60% bleed from same lesion",
    "NSAIDs/aspirin/anticoagulants – increase risk",
    "Retching before hematemesis – Mallory-Weiss",
    "Liver disease / ascites – variceal source",
    "Prior aortic surgery – aortoenteric fistula",
    "Weight loss / obstruction – malignancy",
]
for i, pt in enumerate(history_pts[:3]):
    add_tb(slide, Inches(3.45), Inches(5.76) + i * Inches(0.43),
           Inches(4.6), Inches(0.42), text=f"• {pt}", size=12, color=DARK_GRAY, wrap=True)
for i, pt in enumerate(history_pts[3:]):
    add_tb(slide, Inches(8.2), Inches(5.76) + i * Inches(0.43),
           Inches(4.85), Inches(0.42), text=f"• {pt}", size=12, color=DARK_GRAY, wrap=True)

# ════════════════════════════════════════════════════════════════════════════
# SLIDE 5 – RISK STRATIFICATION (Rockall / Blatchford)
# ════════════════════════════════════════════════════════════════════════════
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, W, H, LIGHT_GRAY)
slide_header(slide, "Risk Stratification Scores for Upper GI Bleeding")
footer(slide)

# Blatchford
add_rect(slide, Inches(0.3), Inches(1.0), Inches(6.1), Inches(5.9), WHITE)
add_rect(slide, Inches(0.3), Inches(1.0), Inches(6.1), Inches(0.42), RED_ACCENT)
add_tb(slide, Inches(0.45), Inches(1.0), Inches(5.8), Inches(0.42),
       text="Glasgow-Blatchford Score (Pre-Endoscopy)", size=15, bold=True,
       color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)

blatchford_rows = [
    ("BUN ≥25 mmol/L", "+6"), ("BUN 10-24.9", "+3"), ("BUN 8-9.9", "+2"),
    ("Hgb <10 g/dL (M)", "+6"), ("Hgb 10-11.9 g/dL (M)", "+3"), ("Hgb 10-11.9 (F)", "+1"),
    ("SBP 90-99 mmHg", "+2"), ("SBP <90 mmHg", "+3"),
    ("HR ≥100", "+1"), ("Melena", "+1"), ("Syncope", "+2"),
    ("Hepatic disease", "+2"), ("Cardiac failure", "+2"),
]
add_table_slide(slide,
    ["Variable", "Points"],
    blatchford_rows,
    Inches(0.35), Inches(1.48), Inches(5.95), Inches(4.6),
    hdr_fill=RED_ACCENT)
add_rect(slide, Inches(0.35), Inches(6.12), Inches(5.95), Inches(0.58), RGBColor(0xFF,0xEB,0xEB))
add_tb(slide, Inches(0.5), Inches(6.12), Inches(5.75), Inches(0.58),
       text="Score 0 = low risk (outpatient). Max score = 23. Higher score → higher need for intervention (transfusion, endoscopy, surgery).",
       size=12, color=RED_ACCENT, wrap=True, v_anchor=MSO_ANCHOR.MIDDLE)

# Rockall
add_rect(slide, Inches(6.7), Inches(1.0), Inches(6.3), Inches(5.9), WHITE)
add_rect(slide, Inches(6.7), Inches(1.0), Inches(6.3), Inches(0.42), DARK_BLUE)
add_tb(slide, Inches(6.85), Inches(1.0), Inches(6.0), Inches(0.42),
       text="Rockall Score (Post-Endoscopy)", size=15, bold=True,
       color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)

rockall_rows = [
    ("Age <60", "0"), ("Age 60-79", "1"), ("Age ≥80", "2"),
    ("No shock", "0"), ("HR >100, SBP ≥100", "1"), ("SBP <100", "2"),
    ("No comorbidity", "0"), ("IHD/CCF/major illness", "2"), ("Renal/liver failure/malignancy", "3"),
    ("No lesion / MW tear", "0"), ("All other diagnoses", "1"), ("Malignancy", "2"),
    ("No SRH / black spot", "0"), ("Blood / adherent clot / vessel", "2"),
]
add_table_slide(slide,
    ["Variable", "Points"],
    rockall_rows,
    Inches(6.75), Inches(1.48), Inches(6.2), Inches(4.6),
    hdr_fill=DARK_BLUE)
add_rect(slide, Inches(6.75), Inches(6.12), Inches(6.2), Inches(0.58), LIGHT_BLUE)
add_tb(slide, Inches(6.9), Inches(6.12), Inches(6.0), Inches(0.58),
       text="Score 0-2 = low risk (rebleed <5%). Score ≥5 = high risk. Max = 11. Predicts rebleeding AND mortality.",
       size=12, color=DARK_BLUE, wrap=True, v_anchor=MSO_ANCHOR.MIDDLE)

# ════════════════════════════════════════════════════════════════════════════
# SLIDE 6 – FORREST CLASSIFICATION  (with endoscopy image)
# ════════════════════════════════════════════════════════════════════════════
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, W, H, LIGHT_GRAY)
slide_header(slide, "Forrest Classification – Endoscopic Stigmata of Recent Hemorrhage")
footer(slide)

forrest_rows = [
    ("Ia",  "Active pulsatile (arterial) bleeding",  "55%",  "HIGH",  "Yes"),
    ("Ib",  "Active oozing (non-pulsatile)",          "55%",  "HIGH",  "Yes"),
    ("IIa", "Non-bleeding visible vessel",            "43%",  "HIGH",  "Yes"),
    ("IIb", "Adherent clot",                          "22%",  "INTERMEDIATE","Yes (wash clot)"),
    ("IIc", "Flat pigmented spot (hematin)",          "10%",  "LOW",   "No"),
    ("III", "Clean ulcer base",                       "5%",   "LOW",   "No"),
]
add_table_slide(slide,
    ["Grade", "Finding", "Rebleed Risk", "Risk Category", "Endoscopic Tx?"],
    forrest_rows,
    Inches(0.3), Inches(1.0), Inches(7.3), Inches(3.6),
    hdr_fill=RED_ACCENT,
    row_fills=[
        RGBColor(0xFF,0xCC,0xCC), RGBColor(0xFF,0xCC,0xCC),
        RGBColor(0xFF,0xE0,0xCC), RGBColor(0xFF,0xF0,0xCC),
        LIGHT_GRAY, LIGHT_GRAY,
    ])

# image of Forrest
img_url = "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_d60411a0527213dbdb70cd10c2cb4c1c8d2e999d3064d643aa8dcaa51be010aa.jpg"
try:
    embed_image(slide, img_url, Inches(7.75), Inches(1.0), Inches(5.25), Inches(3.5))
except Exception:
    pass

# Below the table – treatment note
add_rect(slide, Inches(0.3), Inches(4.75), Inches(7.3), Inches(2.45), WHITE)
add_rect(slide, Inches(0.3), Inches(4.75), Inches(7.3), Inches(0.38), MID_BLUE)
add_tb(slide, Inches(0.45), Inches(4.75), Inches(7.0), Inches(0.38),
       text="Endoscopic Hemostasis Options", size=14, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
hemo_pts = [
    "Injection therapy: 1:10,000 epinephrine (4 mL) – adrenaline alone not sufficient",
    "Thermal: Argon plasma coagulation (APC), heater probe, bipolar electrocoagulation",
    "Mechanical: Endoclips (hemostatic clips) – preferred for visible vessels",
    "Combined therapy (injection + clip/thermal) shown to reduce rebleeding vs monotherapy",
    "Hemostatic powder (TC-325) – rescue for refractory or diffuse bleeding",
    "Over-the-scope clip (OTSC) – refractory / large vessel bleeding",
]
for i, pt in enumerate(hemo_pts):
    add_rect(slide, Inches(0.42), Inches(5.22) + i * Inches(0.36), Inches(0.08), Inches(0.20), GOLD)
    add_tb(slide, Inches(0.58), Inches(5.15) + i * Inches(0.36), Inches(6.85), Inches(0.36),
           text=pt, size=12, color=DARK_GRAY, wrap=True)

# ════════════════════════════════════════════════════════════════════════════
# SLIDE 7 – MANAGEMENT OF UGIB (non-variceal)
# ════════════════════════════════════════════════════════════════════════════
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, W, H, LIGHT_GRAY)
slide_header(slide, "Management of Non-Variceal Upper GI Bleeding", accent_color=RED_ACCENT)
footer(slide)

# Algorithm flowchart drawn as rectangles + arrows
steps = [
    (Inches(0.3),  Inches(1.0),  Inches(12.7), Inches(0.52), DARK_BLUE,
     "1. INITIAL RESUSCITATION: 2 large-bore IVs (≥18G) or central cordis · IV fluid bolus · supplemental O₂ · correct coagulopathy · type & cross"),
    (Inches(0.3),  Inches(1.62), Inches(12.7), Inches(0.52), MID_BLUE,
     "2. LABS: CBC · BMP · LFTs · coags · BUN:Cr ratio (>30:1 suggests UGIB) · ECG/troponin if cardiac risk"),
    (Inches(0.3),  Inches(2.24), Inches(12.7), Inches(0.52), RGBColor(0x6A,0x1A,0x1A),
     "3. RISK STRATIFY: Glasgow-Blatchford score · Rockall score · ICU vs ward decision"),
    (Inches(0.3),  Inches(2.86), Inches(12.7), Inches(0.52), RED_ACCENT,
     "4. PHARMACOTHERAPY: IV PPI (pantoprazole 80 mg bolus → 8 mg/h infusion) · Erythromycin 250 mg IV 30 min pre-scope (improves visualisation) · Octreotide if variceal suspected"),
    (Inches(0.3),  Inches(3.48), Inches(12.7), Inches(0.52), ORANGE,
     "5. ENDOSCOPY (EGD): Within 24 h (within 12 h if haemodynamically unstable) · Elective intubation only if aspiration risk/altered mental status"),
    (Inches(0.3),  Inches(4.10), Inches(12.7), Inches(0.52), MID_BLUE,
     "6. TRANSFUSION THRESHOLD: Restrictive strategy (Hgb <7 g/dL) reduces mortality vs liberal. Active bleed → transfuse on haemodynamic parameters, not Hgb."),
    (Inches(0.3),  Inches(4.72), Inches(12.7), Inches(0.52), GREEN_ACC,
     "7. POST-ENDOSCOPY: Continue IV PPI 72 h → switch to oral PPI · H. pylori test & treat (reduces rebleed) · Stop NSAIDs/antiplatelet if feasible"),
]
for bx, by, bw, bh, col, txt in steps:
    add_rect(slide, bx, by, bw, bh, col)
    add_tb(slide, bx + Inches(0.1), by, bw - Inches(0.2), bh,
           text=txt, size=12.5, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE, wrap=True)

# Refractory / re-bleeding management
add_rect(slide, Inches(0.3), Inches(5.38), Inches(12.7), Inches(0.38), DARK_GRAY)
add_tb(slide, Inches(0.45), Inches(5.38), Inches(12.4), Inches(0.38),
       text="REFRACTORY / RE-BLEEDING MANAGEMENT", size=13, bold=True,
       color=GOLD, v_anchor=MSO_ANCHOR.MIDDLE)
refractory_cols = [
    ("Second endoscopy", ["Repeat EGD for rebleed\nafter initial hemostasis"]),
    ("Interventional Radiology", ["Transcatheter arterial\nembolisation (TAE)"]),
    ("Surgery", ["Vagotomy + pyloroplasty\nor distal gastrectomy\n(if all else fails)"]),
    ("TIPS / TIPSs", ["For portal HTN bleeding\nnot controlled by EBL\nor pharmacotherapy"]),
]
for ci, (title, pts) in enumerate(refractory_cols):
    bx = Inches(0.35) + ci * Inches(3.23)
    add_rect(slide, bx, Inches(5.82), Inches(3.1), Inches(1.32), WHITE)
    add_rect(slide, bx, Inches(5.82), Inches(3.1), Inches(0.32), MID_BLUE)
    add_tb(slide, bx + Inches(0.08), Inches(5.82), Inches(2.95), Inches(0.32),
           text=title, size=12, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
    add_tb(slide, bx + Inches(0.1), Inches(6.16), Inches(2.9), Inches(0.95),
           text="\n".join(pts), size=11, color=DARK_GRAY, wrap=True)

# ════════════════════════════════════════════════════════════════════════════
# SLIDE 8 – VARICEAL BLEEDING
# ════════════════════════════════════════════════════════════════════════════
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, W, H, LIGHT_GRAY)
slide_header(slide, "Variceal Upper GI Bleeding – Portal Hypertension", accent_color=RGBColor(0x5C,0x1A,0x8A))
footer(slide)

# Left: pathophysiology box
add_rect(slide, Inches(0.3), Inches(1.05), Inches(4.2), Inches(5.8), WHITE)
add_rect(slide, Inches(0.3), Inches(1.05), Inches(4.2), Inches(0.38), RGBColor(0x5C,0x1A,0x8A))
add_tb(slide, Inches(0.45), Inches(1.05), Inches(3.95), Inches(0.38),
       text="Pathophysiology", size=14, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
path_pts = [
    "Portal HTN → HVPG >12 mmHg → varices form",
    "Risk of bleeding: size (large), red signs, HVPG >20",
    "Mortality: 15-25% per episode (cirrhosis-dependent)",
    "50% rebleed within 6 weeks without prophylaxis",
]
for i, pt in enumerate(path_pts):
    add_rect(slide, Inches(0.42), Inches(1.52) + i*Inches(0.58), Inches(0.08), Inches(0.22), RGBColor(0x5C,0x1A,0x8A))
    add_tb(slide, Inches(0.58), Inches(1.48) + i*Inches(0.58), Inches(3.75), Inches(0.55),
           text=pt, size=13, color=DARK_GRAY, wrap=True)

# Image
img_url2 = "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_f6fccc315d3087500475eb1b07939390fe56bd3370d27c1e0f36a4c4e338afeb.jpg"
try:
    embed_image(slide, img_url2, Inches(0.35), Inches(3.92), Inches(4.1), Inches(2.85))
except Exception:
    pass

# Management column
add_rect(slide, Inches(4.7), Inches(1.05), Inches(8.3), Inches(5.8), WHITE)
add_rect(slide, Inches(4.7), Inches(1.05), Inches(8.3), Inches(0.38), RGBColor(0x5C,0x1A,0x8A))
add_tb(slide, Inches(4.85), Inches(1.05), Inches(8.0), Inches(0.38),
       text="Management of Acute Variceal Haemorrhage", size=14, bold=True,
       color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
variceal_mgmt = [
    ("Pharmacotherapy (start immediately)",
     ["Terlipressin 2 mg IV q4-6h OR octreotide 50 µg bolus + 50 µg/h infusion",
      "Prophylactic antibiotics: IV ceftriaxone 1g/day × 7 days (reduces SBP + rebleed)"]),
    ("Endoscopic Band Ligation (EBL)",
     ["Within 12 h of presentation; preferred over sclerotherapy",
      "Band every 4-8 weeks until varices eradicated"]),
    ("Balloon Tamponade",
     ["Sengstaken-Blakemore tube – bridge to definitive therapy",
      "Only if EBL unavailable; max 24 h; rebleed on deflation in 50%"]),
    ("TIPS (Transjugular Intrahepatic Portosystemic Shunt)",
     ["Refractory varices; Child-Pugh A/B preferred",
      "Early TIPS (within 72 h) in high-risk patients (Child-Pugh C/B + active bleed)"]),
    ("Secondary Prophylaxis",
     ["Non-selective β-blocker (propranolol/carvedilol) + repeat EBL",
      "NSBB reduces HVPG; target HR 55-60 bpm"]),
]
for i, (title, pts) in enumerate(variceal_mgmt):
    yy = Inches(1.53) + i * Inches(1.08)
    add_rect(slide, Inches(4.75), yy, Inches(8.2), Inches(0.3), LIGHT_BLUE)
    add_tb(slide, Inches(4.9), yy, Inches(8.0), Inches(0.3),
           text=title, size=13, bold=True, color=DARK_BLUE, v_anchor=MSO_ANCHOR.MIDDLE)
    for j, pt in enumerate(pts):
        add_tb(slide, Inches(5.05), yy + Inches(0.32) + j*Inches(0.37),
               Inches(7.85), Inches(0.36),
               text=f"• {pt}", size=12, color=DARK_GRAY, wrap=True)

# ════════════════════════════════════════════════════════════════════════════
# SLIDE 9 – LOWER GI BLEEDING: MANAGEMENT
# ════════════════════════════════════════════════════════════════════════════
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, W, H, LIGHT_GRAY)
slide_header(slide, "Management of Lower GI Bleeding", accent_color=GREEN_ACC)
footer(slide)

# Left panel: initial approach
add_rect(slide, Inches(0.3), Inches(1.05), Inches(6.0), Inches(5.8), WHITE)
add_rect(slide, Inches(0.3), Inches(1.05), Inches(6.0), Inches(0.38), GREEN_ACC)
add_tb(slide, Inches(0.45), Inches(1.05), Inches(5.75), Inches(0.38),
       text="Initial Assessment & Resuscitation", size=15, bold=True,
       color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
lgib_initial = [
    ("Exclude UGIB first",
     ["NG tube lavage (if hematochezia + haemodynamic instability)",
      "Upper GI source in 10-15% of massive hematochezia"]),
    ("Resuscitation",
     ["IV access, fluid, blood transfusion; Hgb <7 g/dL threshold",
      "Reverse anticoagulation if needed; hold antiplatelets"]),
    ("Labs & Imaging",
     ["CBC, BMP, coags; CT angiography if active bleed >0.3 mL/min"]),
    ("Risk factors",
     ["Age >50, diverticulosis, previous lower GIB, anticoagulants",
      "Painless = diverticular/AVM; pain = ischemia/IBD/infectious"]),
]
for i, (title, pts) in enumerate(lgib_initial):
    yy = Inches(1.52) + i * Inches(1.06)
    add_rect(slide, Inches(0.35), yy, Inches(5.9), Inches(0.3), LIGHT_BLUE)
    add_tb(slide, Inches(0.5), yy, Inches(5.7), Inches(0.3),
           text=title, size=13, bold=True, color=DARK_BLUE, v_anchor=MSO_ANCHOR.MIDDLE)
    for j, pt in enumerate(pts):
        add_tb(slide, Inches(0.52), yy + Inches(0.33) + j*Inches(0.36),
               Inches(5.65), Inches(0.36),
               text=f"• {pt}", size=12, color=DARK_GRAY, wrap=True)

# Right panel: diagnostic & therapeutic options
add_rect(slide, Inches(6.55), Inches(1.05), Inches(6.45), Inches(5.8), WHITE)
add_rect(slide, Inches(6.55), Inches(1.05), Inches(6.45), Inches(0.38), GREEN_ACC)
add_tb(slide, Inches(6.7), Inches(1.05), Inches(6.2), Inches(0.38),
       text="Diagnosis & Intervention", size=15, bold=True,
       color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)

# image – diverticular colonoscopy
img_url3 = "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_3a6b4d42640469de70eca11df4d7a7fde3d919c344d96c6be70906f87b03b3e.jpg"
try:
    embed_image(slide, img_url3, Inches(6.6), Inches(1.48), Inches(3.2), Inches(2.2))
except Exception:
    pass

diag_pts = [
    ("Colonoscopy (gold standard)", "Within 24 h after adequate prep"),
    ("CT Angiography", "Active bleed >0.3 mL/min; localises source"),
    ("Nuclear Scan (RBC scan)", "Detects bleed >0.1 mL/min; localises"),
    ("Mesenteric Angiography", "Therapeutic: embolisation if positive"),
    ("Endoscopic Haemostasis", "Clips, APC, band ligation, injection"),
    ("Surgery", "Segmental colectomy if localised; last resort"),
]
for i, (label, detail) in enumerate(diag_pts):
    yy = Inches(3.78) + i * Inches(0.52)
    add_rect(slide, Inches(6.6), yy + Inches(0.06), Inches(0.08), Inches(0.22), GREEN_ACC)
    add_tb(slide, Inches(6.76), yy, Inches(2.8), Inches(0.3),
           text=label, size=12.5, bold=True, color=DARK_GRAY)
    add_tb(slide, Inches(6.76), yy + Inches(0.28), Inches(6.0), Inches(0.24),
           text=detail, size=11, italic=True, color=MID_BLUE, wrap=True)

# ════════════════════════════════════════════════════════════════════════════
# SLIDE 10 – SPECIAL CAUSES: ANGIODYSPLASIA & DIVERTICULAR BLEEDING
# ════════════════════════════════════════════════════════════════════════════
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, W, H, LIGHT_GRAY)
slide_header(slide, "Special Causes – Angiodysplasia & Diverticular Bleeding")
footer(slide)

panels = [
    ("Angiodysplasia (Vascular Ectasia)", MID_BLUE, [
        "Most common vascular malformation of GI tract",
        "Degenerative: acquired dilation of submucosal veins + capillaries",
        "Cecum & right colon (most common site)",
        "Risk: Age >60, CKD, aortic stenosis (Heyde syndrome)",
        "Heyde syndrome: AS + angiodysplasia + acquired vWD (proteolysis of vWF by shear stress)",
        "Tx: APC (argon plasma coagulation) – treatment of choice",
        "Thalidomide and octreotide for refractory cases",
        "Treat underlying condition (AVR for Heyde syndrome)",
    ]),
    ("Diverticular Bleeding", GREEN_ACC, [
        "Most common cause of major LGIB overall (30-40%)",
        "Pseudodiverticula: mucosal outpouching at vasa recta entry",
        "Predominantly left-sided (sigmoid) in Western countries",
        "Right-sided diverticula more common in Asian populations",
        "Bleeding: erosion of artery at dome or neck of diverticulum",
        "80% stop spontaneously; 10% rebleed within 1 year",
        "Endoscopic: clips, band ligation, epinephrine injection",
        "Surgery: segmental colectomy only if bleeding uncontrolled",
    ]),
]
for ci, (title, col, pts) in enumerate(panels):
    bx = Inches(0.3) + ci * Inches(6.55)
    add_rect(slide, bx, Inches(1.0), Inches(6.25), Inches(5.85), WHITE)
    add_rect(slide, bx, Inches(1.0), Inches(6.25), Inches(0.42), col)
    add_tb(slide, bx + Inches(0.1), Inches(1.0), Inches(6.05), Inches(0.42),
           text=title, size=15, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
    for i, pt in enumerate(pts):
        add_rect(slide, bx + Inches(0.12), Inches(1.55) + i*Inches(0.62),
                 Inches(0.08), Inches(0.22), col)
        add_tb(slide, bx + Inches(0.28), Inches(1.48) + i*Inches(0.62),
               Inches(5.8), Inches(0.55), text=pt, size=13, color=DARK_GRAY, wrap=True)

# ════════════════════════════════════════════════════════════════════════════
# SLIDE 11 – OCCULT GI BLEEDING & OBSCURE GI BLEEDING
# ════════════════════════════════════════════════════════════════════════════
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, W, H, LIGHT_GRAY)
slide_header(slide, "Occult & Obscure GI Bleeding")
footer(slide)

# Three columns
col_data = [
    ("Occult GI Bleeding", DARK_BLUE, [
        "Blood loss not visible to patient",
        "Detected by fecal occult blood test (FOBT) or iron-deficiency anaemia",
        "Guaiac-based FOBT (gFOBT): dietary restriction needed",
        "FIT (fecal immunochemical test): more specific; no dietary restriction",
        "Both upper AND lower endoscopy indicated",
        "Common sources: erosive esophagitis, gastric ulcer, CRC, polyps, vascular ectasia",
        "If both scopes negative → video capsule endoscopy (VCE)",
    ]),
    ("Obscure GI Bleeding", MID_BLUE, [
        "Definition: persists/recurs after negative EGD + colonoscopy",
        "Subdivided: Obscure-overt vs. Obscure-occult",
        "Small bowel source in majority (~75%)",
        "Most common: angiodysplasia, NSAID ulcers, Crohn's, tumours",
        "Video Capsule Endoscopy (VCE): 60-70% diagnostic yield",
        "Double-balloon enteroscopy: diagnostic AND therapeutic",
        "CT enterography / enteroclysis: alternative imaging",
        "Meckel's scan (Tc99m pertechnetate): in young patients",
    ]),
    ("Approach to Unexplained IDA", GREEN_ACC, [
        "Step 1: Exclude haematological cause of IDA",
        "Step 2: EGD + Colonoscopy simultaneously or sequentially",
        "Step 3: If negative → VCE first (non-invasive, comfortable)",
        "Step 4: If VCE positive → double-balloon enteroscopy",
        "Step 5: If VCE negative + ongoing bleed → Scintigraphy",
        "Step 6: Mesenteric angiography if active bleeding",
        "Consider: coeliac disease screen (tTG-IgA) in all patients",
    ]),
]
for ci, (title, col, pts) in enumerate(col_data):
    bx = Inches(0.28) + ci * Inches(4.35)
    add_rect(slide, bx, Inches(1.0), Inches(4.15), Inches(5.85), WHITE)
    add_rect(slide, bx, Inches(1.0), Inches(4.15), Inches(0.42), col)
    add_tb(slide, bx + Inches(0.1), Inches(1.0), Inches(3.95), Inches(0.42),
           text=title, size=14, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
    for i, pt in enumerate(pts):
        add_rect(slide, bx + Inches(0.1), Inches(1.54) + i*Inches(0.7),
                 Inches(0.07), Inches(0.2), col)
        add_tb(slide, bx + Inches(0.24), Inches(1.48) + i*Inches(0.7),
               Inches(3.75), Inches(0.65), text=pt, size=12, color=DARK_GRAY, wrap=True)

# ════════════════════════════════════════════════════════════════════════════
# SLIDE 12 – ANTICOAGULATED PATIENTS & SPECIAL POPULATIONS
# ════════════════════════════════════════════════════════════════════════════
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, W, H, LIGHT_GRAY)
slide_header(slide, "GI Bleeding in Anticoagulated Patients & Special Populations")
footer(slide)

anticoag_data = [
    ("Warfarin (VKA)", ORANGE, [
        "Hold warfarin; check INR",
        "Reverse: Vitamin K IV (10 mg) + 4-factor PCC (25-50 IU/kg) for urgent reversal",
        "Fresh frozen plasma if PCC unavailable",
        "Resume: Reassess thrombotic risk; usually restart 4-7 days after haemostasis",
    ]),
    ("DOAC (Apixaban, Rivaroxaban,\nDabigatran, Edoxaban)", RED_ACCENT, [
        "Hold DOAC; short half-life (12-24 h)",
        "Dabigatran → Idarucizumab (Praxbind) 5g IV",
        "Factor Xa inhibitors → Andexanet alfa 400-800 mg IV",
        "Consider activated charcoal if <2 h from last dose",
    ]),
    ("Antiplatelet Agents\n(Aspirin, Clopidogrel, Ticagrelor)", MID_BLUE, [
        "If GI bleed: hold P2Y12 inhibitor; aspirin for high CV risk may continue",
        "After hemostasis: restart dual antiplatelet ASAP (especially post-ACS/PCI)",
        "Add PPI co-prescription in all high-risk patients on antiplatelet agents",
        "Discuss with cardiology before stopping any antiplatelet post-stent",
    ]),
    ("Cirrhosis & Portal HTN", RGBColor(0x5C,0x1A,0x8A), [
        "Coagulopathy ≠ always protective; thromboembolic risk still present",
        "INR unreliable – use thromboelastography (TEG) to guide FFP/PCC use",
        "Low transfusion threshold (Hgb <7); over-transfusion increases portal pressure",
        "Prophylactic antibiotics + terlipressin/octreotide mandatory",
    ]),
]
for ci, (title, col, pts) in enumerate(anticoag_data):
    bx = Inches(0.25) + ci * Inches(3.27)
    add_rect(slide, bx, Inches(1.0), Inches(3.1), Inches(5.85), WHITE)
    add_rect(slide, bx, Inches(1.0), Inches(3.1), Inches(0.7), col)
    add_tb(slide, bx + Inches(0.08), Inches(1.02), Inches(2.95), Inches(0.66),
           text=title, size=12.5, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE, wrap=True)
    for i, pt in enumerate(pts):
        add_rect(slide, bx + Inches(0.1), Inches(1.79) + i*Inches(1.0),
                 Inches(0.07), Inches(0.2), col)
        add_tb(slide, bx + Inches(0.25), Inches(1.72) + i*Inches(1.0),
               Inches(2.75), Inches(0.92), text=pt, size=11.5, color=DARK_GRAY, wrap=True)

# ════════════════════════════════════════════════════════════════════════════
# SLIDE 13 – KEY TAKEAWAYS & SUMMARY
# ════════════════════════════════════════════════════════════════════════════
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, W, H, DARK_BLUE)
add_rect(slide, 0, 0, Inches(0.25), H, GOLD)
add_rect(slide, 0, H - Inches(0.25), W, Inches(0.25), GOLD)
slide_header(slide, "Key Takeaways & Clinical Pearls", accent_color=DARK_BLUE)
footer(slide)

takeaways = [
    ("Anatomy first", "UGIB = proximal to Ligament of Treitz; causes hematemesis + melena. LGIB = distal; causes hematochezia. Massive UGIB can also cause hematochezia."),
    ("Most common causes", "UGIB: Peptic ulcer disease (40%); varices (10-20%). LGIB: Diverticulosis (30-40%); angiodysplasia (40%)."),
    ("BUN:Creatinine ratio", "Ratio >30:1 (SI) or >100:1 suggests UGIB due to absorption of luminal blood + prerenal azotaemia."),
    ("Scoring", "Glasgow-Blatchford score guides discharge (score 0 = safe outpatient). Rockall score predicts rebleed + mortality."),
    ("Transfusion", "Restrictive strategy (Hgb threshold 7 g/dL) is superior in stable patients. Over-transfusion raises portal pressure in cirrhosis."),
    ("PPI timing", "IV PPI before endoscopy down-stages lesions. Post-EBL: IV PPI continuous infusion × 72 h."),
    ("Varices", "Terlipressin + ceftriaxone + early EBL within 12 h. Early TIPS for Child-Pugh B/C high-risk patients."),
    ("Forrest I lesions", "Always treat endoscopically (combined therapy superior to monotherapy). Second-look endoscopy selectively, not routinely."),
    ("Occult / Obscure", "Both scopes negative → Video Capsule Endoscopy. Still negative + ongoing bleed → Double-balloon enteroscopy / scintigraphy."),
    ("Anticoagulation reversal", "Dabigatran: idarucizumab. Xa inhibitors: andexanet alfa. Warfarin: Vitamin K + 4-factor PCC. Restart anticoagulation after risk-benefit discussion."),
]
for i, (title, detail) in enumerate(takeaways):
    col_i = i % 2
    row_i = i // 2
    bx = Inches(0.4) + col_i * Inches(6.45)
    by = Inches(1.0) + row_i * Inches(1.17)
    add_rect(slide, bx, by, Inches(6.2), Inches(1.1), RGBColor(0x0F,0x3A,0x6E))
    add_rect(slide, bx, by, Inches(0.12), Inches(1.1), GOLD)
    add_tb(slide, bx + Inches(0.2), by + Inches(0.04), Inches(5.8), Inches(0.36),
           text=title, size=13, bold=True, color=GOLD)
    add_tb(slide, bx + Inches(0.2), by + Inches(0.38), Inches(5.8), Inches(0.65),
           text=detail, size=11.5, color=WHITE, wrap=True)

# ════════════════════════════════════════════════════════════════════════════
# SAVE
# ════════════════════════════════════════════════════════════════════════════
OUT = "/tmp/workspace/gi-bleeding-ppt/GI_Bleeding_Postgrad_IM.pptx"
prs.save(OUT)
print(f"Saved: {OUT}")
print(f"Slides: {len(prs.slides)}")
Running Command

cd /tmp/workspace/gi-bleeding-ppt && python build_ppt.py 2>&1

Running Command

ls /tmp/skills/shared/scripts/ 2>/dev/null || echo "not found"; ls /tmp/skills/pptx/scripts/ 2>/dev/null || echo "pptx scripts not found"

Running Command

python3 /tmp/skills/shared/scripts/fetch_images.py "https://cdn.orris.care/cdss_images/pmc_clinical_VQA_d60411a0527213dbdb70cd10c2cb4c1c8d2e999d3064d643aa8dcaa51be010aa.jpg" 2>&1 | head -5

Editing File

~/gi-bleeding-ppt/build_ppt.py

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

cd /tmp/workspace/gi-bleeding-ppt && python3 build_ppt.py 2>&1

Running Command

ls -lh /tmp/workspace/gi-bleeding-ppt/GI_Bleeding_Postgrad_IM.pptx

Your presentation is ready for download:

GI Bleeding Postgrad IM

Presentation · PPTX


What's inside - 13 slides, 16:9 widescreen

SlideContent
1Title slide with key epidemiological stats (spontaneous cessation rates, mortality)
2Overview & Definitions - UGIB vs LGIB, anatomical landmark (Ligament of Treitz)
3Etiology - UGIB causes (PUD, varices, Mallory-Weiss, Dieulafoy, GAVE, etc.) + LGIB causes (diverticulosis, angiodysplasia, ischemia, IBD, neoplasm, etc.)
4Clinical Presentation - hematemesis vs melena vs hematochezia table + ATLS haemodynamic classification (Class I-IV) + history pearls
5Risk Stratification - Glasgow-Blatchford Score (full table) + Rockall Score (pre & post-endoscopy)
6Forrest Classification - all 6 grades with rebleed %, risk category, treatment indication + real endoscopy image + haemostasis options
7Non-Variceal UGIB Management - 7-step algorithm (resuscitation → labs → risk stratify → pharmacotherapy → endoscopy → transfusion → post-scope care) + refractory options
8Variceal Bleeding - pathophysiology, endoscopy image, terlipressin/octreotide protocol, EBL, Sengstaken-Blakemore tube, TIPS, secondary prophylaxis
9LGIB Management - exclude UGIB, resuscitation, CT angiography, colonoscopy, scintigraphy, embolisation + colonoscopy image
10Special Causes - Angiodysplasia (Heyde syndrome, APC therapy) + Diverticular Bleeding (mechanism, spontaneous cessation, endoscopic/surgical options)
11Occult & Obscure GI Bleeding - FIT vs gFOBT, VCE, double-balloon enteroscopy, Meckel's scan, stepwise approach to unexplained IDA
12Anticoagulated Patients - Warfarin (PCC), DOACs (idarucizumab, andexanet alfa), antiplatelet agents, cirrhosis-specific considerations
13Key Takeaways - 10 clinical pearls covering anatomy, scoring, transfusion threshold, PPI timing, varices, Forrest lesions, anticoagulation reversal
Sources: Sabiston Textbook of Surgery, Goldman-Cecil Medicine, Maingot's Abdominal Operations, Yamada's Textbook of Gastroenterology - with real clinical endoscopy images embedded.

where is the ppt?

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.
This is a shared conversation. Sign in to Orris to start your own chat.