Enumerate the indications, describe the surgical principals and management of hepatic transplantation

Reading File
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Finding Sources
Reading File
Finding Sources
Reading File
Reading File
Finding Sources
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
I now have comprehensive material from multiple authoritative surgical textbooks. Let me compile the full answer.

Hepatic Transplantation: Indications, Surgical Principles, and Management


1. HISTORY AND BACKGROUND

Liver transplantation represents one of surgery's defining achievements. The first attempted human liver transplant was performed by Dr. Thomas Starzl in 1963 but failed, as did subsequent attempts in Berlin, Boston, and Paris. Starzl himself imposed a 3-year moratorium to return to laboratory research. The modern era began with the discovery that cyclosporine had immunosuppressive properties by Jean Borel in the 1970s, which transformed outcomes from 1-year survival rates of ~30% to the current figures of more than 90% at 1 year and ~88% at 3 years. - Sabiston Textbook of Surgery, p. 1070

2. INDICATIONS

The indications fall into four broad groups:

A. Chronic Liver Disease (Decompensated Cirrhosis)

This is the most common indication. A patient is referred when portal hypertension complications arise or liver synthetic function deteriorates. Key triggers include:
  • Variceal hemorrhage refractory to endoscopic and pharmacological therapy
  • Refractory ascites
  • Spontaneous bacterial peritonitis
  • Hepatic encephalopathy (grade 2 or above, refractory)
  • Hepatorenal syndrome
  • Progressive jaundice
  • Hepatopulmonary syndrome or portopulmonary hypertension
The common etiologies, in approximate order of frequency in Western practice:
EtiologyNotes
Alcohol-related liver disease (ALD)Most common; requires documented abstinence (generally 6 months) and psychosocial evaluation
Non-alcoholic fatty liver disease / NASHProjected to become the leading indication as obesity rises and HCV therapy improves
Chronic HCVTransformed by direct-acting antivirals; now declining as indication
Chronic HBVUniversal vaccination has reduced incidence
Primary biliary cholangitis (PBC)Indicated for decompensation, intractable pruritus, disabling fatigue, rising bilirubin even without cirrhosis
Primary sclerosing cholangitis (PSC)4th most common indication in the US (5-10%); recurrent cholangitis and cholangiocarcinoma are specific concerns
Autoimmune hepatitisWhen chronic liver failure develops despite therapy
Wilson's diseaseAcute liver failure form may present as Status 1 emergency
Cryptogenic cirrhosisLikely represents burned-out NASH in most cases
  • Bailey and Love's Short Practice of Surgery 28th Edition, p. 1631; Sabiston Textbook of Surgery, p. 1070-1071

B. Acute Liver Failure (ALF)

ALF accounts for approximately 10% of liver transplant activity. It requires urgent listing (Status 1 - expected death within days). Common causes:
  • Drug-induced - paracetamol (acetaminophen) overdose is the leading cause in the UK/US
  • Viral hepatitis - Hepatitis A, B, E; herpes simplex; EBV; CMV
  • Autoimmune hepatitis - acute presentation
  • Wilson's disease - acute presentation (Kayser-Fleischer rings may be absent acutely)
  • Budd-Chiari syndrome - acute, fulminant form
  • Indeterminate/seronegative hepatitis
Patient selection uses the King's College Criteria as the primary prognostic tool:
  • For acetaminophen: Arterial pH <7.3 after resuscitation, OR all three of: INR >6.5, creatinine >300 µmol/L, grade III-IV encephalopathy
  • For non-acetaminophen: INR >6.5 alone, OR any three of: age <10 or >40 years, non-A non-B hepatitis/drug/Wilson's etiology, jaundice-to-encephalopathy interval >7 days, bilirubin >300 µmol/L, INR >3.5
Outcomes: 1-year survival after transplantation for ALF exceeds 70%, compared to <20% in the pre-transplant era. - Sleisenger and Fordtran's Gastrointestinal and Liver Disease, p. 1753-1754

C. Metabolic Liver Disease and Inborn Errors of Metabolism

Transplantation can be curative for liver-based metabolic defects even when the liver is not cirrhotic ("metabolic indication"):
  • Wilson's disease (copper metabolism)
  • Alpha-1 antitrypsin deficiency (Z/Z phenotype)
  • Hereditary hemochromatosis (advanced iron overload with cirrhosis)
  • Glycogen storage diseases (Types I, III, IV)
  • Familial hypercholesterolaemia (homozygous)
  • Primary hyperoxaluria type 1 (requires combined liver-kidney transplant to eliminate the enzyme defect in the liver)
  • Urea cycle defects - including ornithine transcarbamylase deficiency
  • Organic acidemias - methylmalonic acidemia
  • Familial amyloid polyneuropathy (transthyretin - removes the source of misfolded protein)
  • Crigler-Najjar syndrome type I (bilirubin conjugation defect)
In children, biliary atresia is the single most common indication, accounting for the majority of pediatric transplants. The 5-year survival ranges from 75% to 94.4%. - Mulholland and Greenfield's Surgery, p. 5603

D. Hepatic Malignancy

  • Hepatocellular carcinoma (HCC) within the Milan Criteria (single tumor ≤5 cm, or up to 3 tumors each ≤3 cm, no vascular invasion, no extrahepatic disease) - 5-year recurrence-free survival ~70%
  • Extended criteria (e.g., UCSF criteria) are used in some centres
  • Hepatoblastoma in children - when unresectable
  • Perihilar cholangiocarcinoma (Klatskin tumor) at selected centers: the Mayo Clinic protocol requires neoadjuvant chemoradiation followed by transplantation; overall 5-year survival ~65% at experienced centers
  • Hemangioendothelioma - when extensive
HCC patients with preserved liver function and low MELD scores receive exception points to reflect their mortality risk from tumor progression. - Sabiston Textbook of Surgery, p. 1071

3. CONTRAINDICATIONS

Absolute ContraindicationsRelative Contraindications
Active extrahepatic malignancy (non-skin)Age >65-70 years
Uncontrolled systemic infection / sepsisSevere cardiopulmonary disease
Active alcohol or substance use (most programs)Morbid obesity (BMI >40)
Irreversible neurological injury (e.g., raised ICP, brain death in ALF)HIV (now considered relative at experienced centers)
Advanced cardiopulmonary disease not amenable to treatmentThrombosis of portal, splenic, and superior mesenteric veins (technically challenging but not absolute)
AIDSPrior TIPS, splenorenal shunt (increases technical difficulty but does not preclude transplantation)
Previous Eck fistula (portacaval end-to-side - makes transplantation significantly more difficult)
  • Sabiston Textbook of Surgery, p. 1071; Schwartz's Principles of Surgery, p. 1395

4. ALLOCATION: THE MELD SCORE

The MELD score (Model for End-Stage Liver Disease) determines listing priority:
MELD 3.0 formula:
MELD = 1.33(female sex) + 4.56 × ln(bilirubin) + 0.82 × (137 - Na) - 0.24 × (137 - Na) × ln(bilirubin) + 9.09 × ln(INR) + 11.14 × ln(creatinine) + 1.85 × (3.5 - albumin) - 1.83 × (3.5 - albumin) × ln(creatinine) + 6
Key features:
  • Higher MELD = higher 3-month mortality on waiting list = higher priority
  • Status 1A: Fulminant liver failure with expected death within <1 week - supersedes all MELD scores
  • Exception points: Awarded for HCC (within Milan), hepatopulmonary syndrome, portopulmonary hypertension (mean PAP maintainable <35 mmHg), familial amyloid polyneuropathy, primary hyperoxaluria, cystic fibrosis, hilar cholangiocarcinoma
  • 2020 allocation change: From donation service areas to "acuity circles" of 150-500 nautical miles around the donor hospital to reduce geographic disparity
  • Sabiston Textbook of Surgery, p. 1072

5. DONOR SELECTION AND ORGAN PRESERVATION

Deceased Donor Types

  1. Donation after brain death (DBD) - the conventional standard
  2. Donation after circulatory death (DCD) - "non-heart-beating" donors; higher rates of primary non-function and ischemic cholangiopathy; acceptable at experienced centers
  3. Extended criteria donors - age >60, steatosis <30-40%, moderate preservation injury; careful case-by-case matching required

Donor Requirements

  • ABO blood group compatibility (ABO-identical preferred; ABO-compatible acceptable; ABO-incompatible used in exceptional urgent circumstances with desensitization protocols)
  • HLA matching is not routinely required for liver transplantation (unlike kidney) - the liver is immunologically privileged due to its size and tolerogenic properties
  • Liver must not have significant steatosis (>30% macrovesicular steatosis substantially increases primary non-function risk)

Preservation

  • Cold ischemia time should ideally be kept under 12 hours (maximum 24 hours)
  • University of Wisconsin (UW) solution is the standard cold preservation flush
  • Machine perfusion (hypothermic, normothermic) is an emerging technique that extends preservation time and allows viability assessment of marginal grafts
  • Warm ischemia time (during implantation, after reperfusion of portal vein) is minimized by surgical efficiency

Living Donor Liver Transplantation (LDLT)

  • Right lobe donation (segments V-VIII) for adult-to-adult LDLT, providing 60-70% of total liver volume
  • Left lateral segment (segments II-III) for pediatric recipients
  • Graft-to-recipient weight ratio (GRWR) must be >0.8% and/or graft volume/standard liver volume >35% to prevent small-for-size syndrome
  • Donor remnant liver must be >30% of total liver volume to prevent hepatic insufficiency in the donor
  • Dominant in the East (>90% of LT in some countries); <10% in the West
  • "Dual graft" LDLT from two donors is practised in selected Korean centers
  • Bailey and Love's Short Practice of Surgery 28th Edition, p. 1633-1634

6. PREOPERATIVE EVALUATION AND PREPARATION

Recipient Work-up

  • Cardiac: ECG, echocardiography, stress test (cirrhotic cardiomyopathy is common; dobutamine stress echocardiography or cardiac catheterisation where indicated)
  • Pulmonary: PFTs, ABG - screen for hepatopulmonary syndrome (PaO₂ <60 mmHg) and portopulmonary hypertension
  • Renal: creatinine, GFR (determines need for simultaneous liver-kidney transplant if eGFR <30)
  • Cross-sectional imaging: CT or MRI of abdomen to assess vascular anatomy, portal vein patency, hepatic masses
  • Endoscopy: to assess esophageal varices, prior to listing
  • Nutritional status: Sarcopenia is a strong predictor of post-transplant outcome; nutritional rehabilitation is initiated early
  • Psychosocial evaluation (especially for alcohol-related disease): mandatory at most centers

7. SURGICAL PRINCIPLES

A. Recipient Hepatectomy

This is the most technically demanding part of the operation, especially in patients with portal hypertension, coagulopathy, dense adhesions (from prior surgery), and hepatosplenomegaly. Two techniques exist:
  1. Classic (Conventional) Technique: Recipient native IVC is removed en bloc with the liver (total hepatectomy); venovenous bypass (VVB) from femoral and portal veins to axillary vein is used to decompress the splanchnic and systemic circulations during the anhepatic phase
  2. Piggyback (Caval Sparing) Technique - now preferred at most centres:
    • Recipient native IVC is preserved
    • Liver is mobilized off the IVC by ligating the small hepatic veins
    • The three major hepatic veins of the recipient are united into a common cuff and anastomosed end-to-side to the donor IVC
    • Advantages: Eliminates VVB requirement, reduces blood loss, maintains cardiac preload, shorter operative time, fewer systemic complications
    • Disadvantage: More demanding hepatic dissection

B. The Five Anastomoses (Vascular + Biliary)

The implantation involves reconstruction of:
  1. Suprahepatic IVC (or hepatic vein cuff in piggyback)
  2. Infrahepatic IVC (in classic technique)
  3. Portal vein - end-to-end anastomosis; jump grafts (donor iliac vein) may be needed if recipient portal vein is thrombosed
  4. Hepatic artery - microsurgical precision required; common hepatic to common hepatic end-to-end is standard; complex reconstructions using aortic jump grafts may be needed for variant anatomy, prior surgery, or in CCA patients (irradiated vessels)
  5. Biliary reconstruction - two options:
    • Choledochocholedochostomy (duct-to-duct): preferred when recipient CBD is normal; allows subsequent ERCP access
    • Roux-en-Y hepaticojejunostomy: used for PSC (CBD divided as low as possible), biliary atresia (Kasai failure), size mismatch, re-transplantation, or any duct abnormality; a short Roux limb (10-20 cm) is preferred to maintain endoscopic access

C. Reperfusion

  • Portal vein is unclamped first (followed by arterial); the moment of reperfusion is the highest-risk phase
  • Reperfusion syndrome: systemic hypotension, bradycardia, hyperkalaemia, and acidosis from release of cold, hyperkalaemic preservation solution; managed with calcium, bicarbonate, vasopressors, and surgical technique (flushing the graft with blood before unclamping)

D. Haemostasis

  • Portal hypertension, coagulopathy (low platelets, low fibrinogen, elevated INR), and fibrinolysis make haemostasis challenging
  • Extensive use of argon beam coagulation, haemostatic agents, and packed cell replacement
  • Viscoelastic testing (TEG/ROTEM) guides intraoperative transfusion strategy
  • Sabiston Textbook of Surgery, p. 1073-1474; Bailey and Love's Short Practice of Surgery 28th Edition, p. 1632-1634; Fischer's Mastery of Surgery 8th Ed, p. 4692

8. POSTOPERATIVE MANAGEMENT

Immunosuppression

Standard triple therapy is the norm at most centers:
AgentClassMechanism
Tacrolimus (FK506)Calcineurin inhibitorInhibits IL-2 transcription; mainstay of maintenance therapy
Mycophenolate mofetil (MMF)AntimetaboliteInhibits purine synthesis; blocks lymphocyte proliferation
CorticosteroidsSteroidBroad anti-inflammatory; tapered and often withdrawn by 3-12 months
  • Cyclosporine is an alternative calcineurin inhibitor but used less frequently
  • mTOR inhibitors (sirolimus, everolimus) - used in specific settings (HCC to reduce recurrence risk, renal-sparing regimens)
  • Tacrolimus levels require close monitoring (target whole blood trough: 10-15 ng/mL in the first month, 5-10 ng/mL thereafter)
  • Calcineurin inhibitor nephrotoxicity is a major long-term concern

Rejection

Acute cellular rejection (ACR):
  • Most common in the first 6 weeks
  • Presents with rising transaminases, alkaline phosphatase, bilirubin, and fever
  • Diagnosis requires liver biopsy: portal inflammation, bile duct damage, and endotheliitis (Banff criteria)
  • Treatment: high-dose IV methylprednisolone 500-1000 mg/day for 3 days, then taper; steroid-refractory rejection treated with anti-thymocyte globulin (ATG) or OKT3
Chronic ductopenic rejection ("vanishing bile duct syndrome"):
  • Occurs months to years post-transplant
  • Progressive loss of bile ducts; rising alkaline phosphatase and bilirubin
  • Often irreversible; may require retransplantation
  • Risk factors: multiple ACR episodes, inadequate immunosuppression, CMV infection

9. COMPLICATIONS AND THEIR MANAGEMENT

Vascular

ComplicationIncidenceManagement
Hepatic artery thrombosis (HAT)5-9% in adults (higher in children)Early: urgent thrombectomy or re-transplantation; Biliary tree loses its entire arterial supply → bile duct necrosis, intrahepatic bilomas
Hepatic artery stenosis2-5%Radiological angioplasty ± stenting
Portal vein thrombosis (PVT)Up to 12%Early: surgical thrombectomy; Late: TIPS or re-transplantation if severe portal hypertension
IVC/hepatic vein stenosisRareEndovascular stenting

Biliary (Most common cause of morbidity, 5-30%)

ComplicationNotes
Anastomotic strictures80% of stricturing disease; present 2-6 months post-OLT; duct-to-duct anastomoses amenable to ERCP and stenting; choledochojejunostomies require percutaneous or surgical correction
Bile leakUsually from anastomosis or cut surface (LDLT/split); managed by ERCP ± stent or surgery
Non-anastomotic strictures (ischemic cholangiopathy)Suggests HAT or DCD-related ischemic injury; often requires retransplantation
Biliary castsUp to 18% in first year; treated endoscopically (70% success); mortality 10-30%

Infectious (Most common cause of morbidity AND mortality, seen in up to 75%)

  • 0-1 month: Bacterial (wound, abdominal, urinary) and fungal infections dominate
  • 1-6 months: Opportunistic infections: CMV (treated with ganciclovir/valganciclovir), Pneumocystis jirovecii (prophylaxis with TMP-SMX), fungal (aspergillosis), EBV (linked to PTLD)
  • >6 months: Community-acquired infections and late opportunistic infections in over-immunosuppressed patients

Other

  • Primary non-function (PNF): Graft fails to function after transplant; requires urgent re-listing (Status 1A) and retransplantation; 5-7% of cases
  • Post-transplant lymphoproliferative disorder (PTLD): EBV-driven B-cell proliferation; treated by reducing immunosuppression ± rituximab ± chemotherapy
  • Disease recurrence: HCV virtually all recur (though now treated with DAAs pre/post-transplant); HBV recurrence prevented by HBIg + antivirals; PBC recurs in 0-35% (usually mild); PSC can recur; autoimmune hepatitis recurs in ~20-30%; HCC recurrence in 10-15% if within Milan criteria
  • Metabolic syndrome/cardiovascular disease: Major late cause of death; driven by calcineurin inhibitor-induced hypertension, diabetes, dyslipidaemia, and weight gain
  • Chronic kidney disease: Due to calcineurin inhibitor nephrotoxicity; affects 20-50% at 5 years

10. OUTCOMES

  • 1-year patient survival: >90% at experienced centers
  • 3-year survival: ~88%
  • 5-year survival: 75-80% for CLD; >90% for PBC; ~70% for HCC within Milan criteria; <50% for ALF (worse prognosis)
  • Retransplantation accounts for 10-15% of all transplants; outcomes are generally inferior to primary transplant

11. SPECIAL TOPICS

Pediatric Liver Transplantation

  • Biliary atresia accounts for the majority of pediatric transplants
  • Timing: after failed Kasai portoenterostomy, with signs of progressive hepatic failure, growth retardation, or complications of portal hypertension
  • Technical variants: reduced-size grafts (left lateral segment from deceased donor) and LDLT dramatically reduced waiting list mortality
  • Immunosuppression protocols are similar but dosing is weight-adjusted; EBV-related PTLD is a particular concern in seronegative children receiving seropositive grafts

Split Liver Transplantation

  • One deceased donor liver is surgically divided (usually right lobe + left lateral segment) to provide two grafts for two recipients, typically one adult and one child
  • Requires careful preoperative imaging to assess vascular and biliary anatomy

Machine Perfusion

  • Hypothermic machine perfusion (HMP) and normothermic machine perfusion (NMP) are now entering clinical practice
  • Allow assessment of marginal grafts (DCD, steatotic) before commitment to transplantation
  • NMP maintains the liver at physiological temperature with oxygenated blood; allows function testing (bile production, lactate clearance) and potential reconditioning

SUMMARY TABLE

DomainKey Points
Most common indicationDecompensated cirrhosis (ALD, NAFLD/NASH, viral hepatitis)
PediatricBiliary atresia
Urgent (Status 1)ALF (acetaminophen, viral, Wilson's, seronegative)
Allocation toolMELD 3.0 score
Key contraindicationActive extrahepatic malignancy, uncontrolled sepsis, active substance use
HCC criterionMilan Criteria (single ≤5 cm or 3 tumors ≤3 cm)
Preferred surgical techniquePiggyback (caval-sparing) hepatectomy
Biliary reconstructionDuct-to-duct (preferred) or Roux-en-Y hepaticojejunostomy
Immunosuppression backboneTacrolimus + MMF ± steroids
Most common complicationBiliary (5-30%); infection (up to 75%)
Most feared vascular complicationHepatic artery thrombosis (5-9%)
1-year survival>90%
Sources:
  • Sabiston Textbook of Surgery (Biological Basis of Modern Surgical Practice), Chapter 53
  • Bailey and Love's Short Practice of Surgery 28th Ed, Chapter 89
  • Fischer's Mastery of Surgery 8th Ed, Chapter on Liver Transplantation
  • Sleisenger and Fordtran's Gastrointestinal and Liver Disease, Chapters 36 and 97
  • Schwartz's Principles of Surgery 11th Ed, Chapter 31
  • Mulholland and Greenfield's Surgery 7th Ed, Chapter 101

Make all of this into a power point presentation type

Reading File
Reading File
Reading File
Running Command

mkdir -p /tmp/workspace/hepatic-transplant-ppt && ls /tmp/workspace/hepatic-transplant-ppt/

Writing File

~/hepatic-transplant-ppt/build_pptx.py

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.util import Inches, Pt
from io import BytesIO

# ── Colour palette ───────────────────────────────────────────────────────────
NAVY       = RGBColor(0x0A, 0x2A, 0x5E)   # deep navy – header bars
TEAL       = RGBColor(0x00, 0x7A, 0x87)   # teal accent
LIGHT_BLUE = RGBColor(0xD6, 0xEA, 0xF8)   # light-blue content bg
WHITE      = RGBColor(0xFF, 0xFF, 0xFF)
DARK_GREY  = RGBColor(0x2C, 0x2C, 0x2C)
MID_GREY   = RGBColor(0x55, 0x55, 0x55)
ORANGE     = RGBColor(0xE8, 0x6A, 0x10)   # highlight/accent 2
LIGHT_TEAL = RGBColor(0xE0, 0xF4, 0xF6)

prs = Presentation()
prs.slide_width  = Inches(13.333)
prs.slide_height = Inches(7.5)

blank = prs.slide_layouts[6]   # fully blank layout

# ─────────────────────────────────────────────────────────────────────────────
# Helper utilities
# ─────────────────────────────────────────────────────────────────────────────

def add_rect(slide, x, y, w, h, fill_color, line_color=None, line_width=None):
    from pptx.enum.shapes import MSO_SHAPE_TYPE
    shp = slide.shapes.add_shape(1, Inches(x), Inches(y), Inches(w), Inches(h))  # 1 = rectangle
    shp.fill.solid()
    shp.fill.fore_color.rgb = fill_color
    if line_color:
        shp.line.color.rgb = line_color
        if line_width:
            shp.line.width = Pt(line_width)
    else:
        shp.line.fill.background()
    shp.shadow.inherit = False
    return shp

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

def add_textbox_multiline(slide, lines, x, y, w, h,
                          font_size=14, bold_first=False,
                          color=DARK_GREY, font_name="Calibri",
                          line_spacing=None, v_anchor=MSO_ANCHOR.TOP):
    """lines: list of (text, bold, indent_level, font_size_override)"""
    tb = slide.shapes.add_textbox(Inches(x), Inches(y), Inches(w), Inches(h))
    tf = tb.text_frame
    tf.word_wrap = True
    tf.vertical_anchor = v_anchor
    tf.margin_left   = Pt(6)
    tf.margin_right  = Pt(4)
    tf.margin_top    = Pt(4)
    tf.margin_bottom = Pt(4)
    for i, item in enumerate(lines):
        if isinstance(item, str):
            text, bold, level, fsize = item, False, 0, font_size
        elif len(item) == 2:
            text, bold = item; level = 0; fsize = font_size
        elif len(item) == 3:
            text, bold, level = item; fsize = font_size
        else:
            text, bold, level, fsize = item
        if i == 0:
            p = tf.paragraphs[0]
        else:
            p = tf.add_paragraph()
        p.level = level
        if line_spacing:
            from pptx.oxml.ns import qn
            from lxml import etree
            pPr = p._pPr
            if pPr is None:
                pPr = p._p.get_or_add_pPr()
            lnSpc = etree.SubElement(pPr, qn('a:lnSpc'))
            spcPct = etree.SubElement(lnSpc, qn('a:spcPct'))
            spcPct.set('val', str(int(line_spacing * 1000)))
        run = p.add_run()
        run.text = text
        run.font.name  = font_name
        run.font.size  = Pt(fsize)
        run.font.bold  = (bold_first and i == 0) or bold
        run.font.color.rgb = color
    return tb

def slide_header(slide, title, subtitle=None):
    """Draw the top navy bar with white title."""
    add_rect(slide, 0, 0, 13.333, 1.1, NAVY)
    add_rect(slide, 0, 1.1, 13.333, 0.06, TEAL)  # thin accent line
    add_text(slide, title, 0.3, 0.05, 12.5, 0.9,
             font_size=28, bold=True, color=WHITE, align=PP_ALIGN.LEFT,
             v_anchor=MSO_ANCHOR.MIDDLE)
    if subtitle:
        add_text(slide, subtitle, 0.3, 0.75, 12.5, 0.4,
                 font_size=14, bold=False, color=RGBColor(0xB0, 0xD4, 0xE8),
                 align=PP_ALIGN.LEFT)

def slide_footer(slide, text="Hepatic Transplantation | Surgical Principles & Management"):
    add_rect(slide, 0, 7.25, 13.333, 0.25, NAVY)
    add_text(slide, text, 0.3, 7.26, 12.0, 0.22,
             font_size=9, color=RGBColor(0xB0, 0xD4, 0xE8),
             align=PP_ALIGN.LEFT, v_anchor=MSO_ANCHOR.MIDDLE)

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 1 – Title Slide
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
# Full background
add_rect(slide, 0, 0, 13.333, 7.5, NAVY)
# Teal accent band
add_rect(slide, 0, 3.9, 13.333, 0.08, TEAL)
# Left accent bar
add_rect(slide, 0, 0, 0.18, 7.5, TEAL)
# Title
add_text(slide, "HEPATIC TRANSPLANTATION", 0.5, 1.5, 12.5, 1.3,
         font_size=44, bold=True, color=WHITE, align=PP_ALIGN.LEFT)
add_text(slide, "Indications  ·  Surgical Principles  ·  Management", 0.5, 2.9, 12.5, 0.7,
         font_size=22, bold=False, color=TEAL, align=PP_ALIGN.LEFT)
add_text(slide, "A Comprehensive Surgical Review", 0.5, 4.2, 12.0, 0.6,
         font_size=16, bold=False, italic=True,
         color=RGBColor(0xB0, 0xD4, 0xE8), align=PP_ALIGN.LEFT)
add_text(slide, "Sources: Sabiston · Bailey & Love · Fischer's Mastery · Sleisenger & Fordtran · Schwartz's",
         0.5, 6.7, 12.5, 0.5, font_size=10,
         color=RGBColor(0x80, 0xA8, 0xC8), align=PP_ALIGN.LEFT)

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 2 – Table of Contents
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, 13.333, 7.5, WHITE)
slide_header(slide, "Contents")
slide_footer(slide)

topics = [
    ("1", "History & Background"),
    ("2", "Indications"),
    ("3", "Contraindications"),
    ("4", "Organ Allocation – MELD Score"),
    ("5", "Donor Selection & Organ Preservation"),
    ("6", "Preoperative Evaluation"),
    ("7", "Surgical Principles & Technique"),
    ("8", "Postoperative Management & Immunosuppression"),
    ("9", "Complications & Their Management"),
    ("10", "Outcomes & Special Topics"),
]
col1 = topics[:5]
col2 = topics[5:]

for i, (num, topic) in enumerate(col1):
    y = 1.4 + i * 0.95
    add_rect(slide, 0.4, y, 0.55, 0.62, TEAL)
    add_text(slide, num, 0.4, y, 0.55, 0.62, font_size=20, bold=True,
             color=WHITE, align=PP_ALIGN.CENTER, v_anchor=MSO_ANCHOR.MIDDLE)
    add_text(slide, topic, 1.05, y + 0.08, 5.3, 0.5, font_size=16,
             color=DARK_GREY)

for i, (num, topic) in enumerate(col2):
    y = 1.4 + i * 0.95
    add_rect(slide, 7.0, y, 0.55, 0.62, NAVY)
    add_text(slide, num, 7.0, y, 0.55, 0.62, font_size=20, bold=True,
             color=WHITE, align=PP_ALIGN.CENTER, v_anchor=MSO_ANCHOR.MIDDLE)
    add_text(slide, topic, 7.65, y + 0.08, 5.3, 0.5, font_size=16,
             color=DARK_GREY)

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 3 – History & Background
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, 13.333, 7.5, WHITE)
slide_header(slide, "History & Background")
slide_footer(slide)

timeline = [
    ("1963", "First attempted human liver transplant by Dr. Thomas Starzl – failed; subsequent attempts in Berlin, Boston, Paris also failed. 3-year moratorium imposed."),
    ("1970s", "Limited success achieved. 1-year survival ~30%. Cyclosporine discovered by Jean Borel (initially investigated as antifungal) – ushered in the modern era."),
    ("1989", "Living-donor liver transplantation (LDLT) first described in pediatric recipients."),
    ("1994", "First successful adult LDLT reported (Hashikura et al., Lancet)."),
    ("Today", ">90% 1-year survival; ~88% 3-year survival. Over 9,000 liver transplants/year in the US."),
]

for i, (year, desc) in enumerate(timeline):
    y = 1.35 + i * 1.05
    add_rect(slide, 0.35, y, 1.5, 0.7, NAVY)
    add_text(slide, year, 0.35, y, 1.5, 0.7, font_size=18, bold=True,
             color=WHITE, align=PP_ALIGN.CENTER, v_anchor=MSO_ANCHOR.MIDDLE)
    # Connector line
    add_rect(slide, 1.85, y + 0.3, 0.25, 0.08, TEAL)
    add_textbox_multiline(slide, [(desc, False, 0, 13)],
                          2.15, y, 10.7, 0.75,
                          color=MID_GREY, v_anchor=MSO_ANCHOR.MIDDLE)

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 4 – Indications Overview
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, 13.333, 7.5, WHITE)
slide_header(slide, "Indications for Liver Transplantation", "Four principal categories")
slide_footer(slide)

boxes = [
    (NAVY,  "1\nChronic Liver\nDisease",       0.35, 1.35, 2.8, 2.8,
     "Most common indication\n- Alcoholic liver disease (ALD)\n- NAFLD / NASH\n- Chronic HCV / HBV\n- PBC, PSC, AIH\n- Wilson's disease, A1AT"),
    (TEAL,  "2\nAcute Liver\nFailure",          3.35, 1.35, 2.8, 2.8,
     "~10% of LT activity\n- Acetaminophen overdose\n- Viral hepatitis A/B/E\n- Drug-induced (non-acetaminophen)\n- Seronegative / autoimmune\n- Wilson's (acute)"),
    (ORANGE,"3\nMetabolic /\nInborn Errors",    6.35, 1.35, 2.8, 2.8,
     "Curative even without cirrhosis\n- Primary hyperoxaluria\n- Urea cycle defects\n- Familial amyloid polyneuropathy\n- Familial hypercholesterolaemia\n- Crigler-Najjar type I"),
    (RGBColor(0x14, 0x5A, 0x32), "4\nHepatic\nMalignancy", 9.35, 1.35, 3.6, 2.8,
     "- HCC within Milan Criteria\n- Hilar cholangiocarcinoma\n  (neoadjuvant protocol)\n- Hepatoblastoma (children)\n- Haemangioendothelioma"),
]

for (col, label, bx, by, bw, bh, desc) in boxes:
    add_rect(slide, bx, by, bw, 1.1, col)
    add_text(slide, label, bx + 0.1, by, bw - 0.2, 1.1,
             font_size=15, bold=True, color=WHITE,
             align=PP_ALIGN.CENTER, v_anchor=MSO_ANCHOR.MIDDLE)
    add_rect(slide, bx, by + 1.1, bw, bh - 1.1, LIGHT_BLUE)
    desc_lines = [(ln, False, 0, 12) for ln in desc.split("\n")]
    add_textbox_multiline(slide, desc_lines,
                          bx + 0.1, by + 1.15, bw - 0.2, bh - 1.2,
                          color=DARK_GREY)

# Paediatric note
add_rect(slide, 0.35, 4.35, 12.6, 0.55, LIGHT_TEAL)
add_text(slide, "Paediatric: Biliary atresia is the single most common indication in children (10-15% of all LT). 5-year survival after LT: 75-94%.",
         0.5, 4.38, 12.2, 0.48, font_size=12, color=NAVY)

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 5 – Chronic Liver Disease: Detailed Indications
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, 13.333, 7.5, WHITE)
slide_header(slide, "Chronic Liver Disease – Indications in Detail")
slide_footer(slide)

add_text(slide, "Triggers for transplant listing (any complication of decompensation):",
         0.35, 1.25, 12.5, 0.45, font_size=14, bold=True, color=NAVY)

triggers = [
    ("Variceal Haemorrhage", "Refractory to endoscopic + pharmacological therapy"),
    ("Refractory Ascites",   "Unresponsive to diuretics; SBP episodes"),
    ("Hepatic Encephalopathy", "Grade ≥2, refractory or recurrent"),
    ("Hepatorenal Syndrome", "Type 1 (acute) or Type 2 (chronic)"),
    ("Progressive Jaundice",  "Especially with cholestatic diseases (PBC/PSC)"),
    ("Hepatopulmonary Syndrome", "PaO₂ <60 mmHg on room air"),
    ("Portopulmonary HTN",   "Mean PAP maintainable <35 mmHg with treatment"),
]

for i, (trig, detail) in enumerate(triggers):
    row = i % 4
    col = i // 4
    x = 0.35 + col * 6.6
    y = 1.8 + row * 1.25
    add_rect(slide, x, y, 6.2, 1.1, LIGHT_BLUE)
    add_rect(slide, x, y, 6.2, 0.36, TEAL)
    add_text(slide, trig, x + 0.1, y, 6.0, 0.36,
             font_size=13, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
    add_text(slide, detail, x + 0.1, y + 0.38, 6.0, 0.68,
             font_size=12, color=DARK_GREY)

# HCC Milan Criteria box
add_rect(slide, 0.35, 6.75, 12.6, 0.55, LIGHT_TEAL)
add_text(slide, "Milan Criteria for HCC: Single tumor ≤5 cm  OR  up to 3 tumors each ≤3 cm  |  No vascular invasion  |  No extrahepatic disease  →  5-year recurrence-free survival ~70%",
         0.5, 6.77, 12.2, 0.48, font_size=11, color=NAVY)

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 6 – Acute Liver Failure & King's College Criteria
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, 13.333, 7.5, WHITE)
slide_header(slide, "Acute Liver Failure (ALF)", "Status 1A – Priority listing above all MELD scores")
slide_footer(slide)

# Left panel – causes
add_rect(slide, 0.3, 1.35, 4.0, 5.6, LIGHT_BLUE)
add_rect(slide, 0.3, 1.35, 4.0, 0.5, NAVY)
add_text(slide, "Common Causes of ALF", 0.35, 1.35, 3.9, 0.5,
         font_size=14, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
causes = [
    ("Acetaminophen overdose", True, 0, 13),
    ("(leading cause in UK/US)", False, 0, 11),
    ("", False, 0, 6),
    ("Viral: Hep A, B, E", False, 0, 12),
    ("Herpes simplex, EBV, CMV", False, 0, 12),
    ("", False, 0, 6),
    ("Drug-induced (non-paracetamol)", False, 0, 12),
    ("Autoimmune hepatitis – acute", False, 0, 12),
    ("Wilson's disease – acute", False, 0, 12),
    ("Budd-Chiari syndrome – acute", False, 0, 12),
    ("Indeterminate / seronegative", False, 0, 12),
    ("", False, 0, 6),
    ("Transplant rate:", True, 0, 12),
    ("40% non-acetaminophen cases", False, 0, 12),
    ("8% acetaminophen cases", False, 0, 12),
]
add_textbox_multiline(slide, causes, 0.4, 1.9, 3.8, 4.9, color=DARK_GREY)

# Right panel – King's College Criteria
add_rect(slide, 4.6, 1.35, 8.4, 5.6, WHITE)
add_rect(slide, 4.6, 1.35, 8.4, 0.5, ORANGE)
add_text(slide, "King's College Criteria (Selection for LT in ALF)", 4.65, 1.35, 8.3, 0.5,
         font_size=14, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)

# Acetaminophen box
add_rect(slide, 4.6, 1.9, 4.0, 2.5, RGBColor(0xFD, 0xF2, 0xE8))
add_rect(slide, 4.6, 1.9, 4.0, 0.4, ORANGE)
add_text(slide, "Acetaminophen Aetiology", 4.65, 1.9, 3.9, 0.4,
         font_size=13, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
add_textbox_multiline(slide, [
    ("Arterial pH <7.3 (after resuscitation)", False, 0, 12),
    ("– OR all three of –", True, 0, 11),
    ("INR >6.5", False, 0, 12),
    ("Creatinine >300 µmol/L", False, 0, 12),
    ("Grade III-IV encephalopathy", False, 0, 12),
], 4.7, 2.35, 3.8, 1.95, color=DARK_GREY)

# Non-acetaminophen box
add_rect(slide, 8.8, 1.9, 4.1, 2.5, RGBColor(0xE8, 0xF4, 0xFD))
add_rect(slide, 8.8, 1.9, 4.1, 0.4, TEAL)
add_text(slide, "Non-Acetaminophen Aetiology", 8.85, 1.9, 4.0, 0.4,
         font_size=13, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
add_textbox_multiline(slide, [
    ("INR >6.5  alone", False, 0, 12),
    ("– OR any 3 of –", True, 0, 11),
    ("Age <10 or >40 years", False, 0, 12),
    ("Non-A non-B/drug/Wilson's aetiology", False, 0, 12),
    ("Jaundice→encephalopathy >7 days", False, 0, 12),
    ("Bilirubin >300 µmol/L", False, 0, 12),
    ("INR >3.5", False, 0, 12),
], 8.9, 2.35, 3.9, 1.95, color=DARK_GREY)

# Outcome note
add_rect(slide, 4.6, 4.6, 8.4, 2.2, LIGHT_TEAL)
add_textbox_multiline(slide, [
    ("Outcomes with LT for ALF:", True, 0, 13),
    ("1-year survival >70% (vs <20% without LT in the 1970s)", False, 0, 12),
    ("Wait-list mortality: 19-28%; highest in acetaminophen ALF", False, 0, 12),
    ("Donor organ allocation prioritises ALF – most receive organ within 48-72h", False, 0, 12),
    ("Auxiliary LT: bridge to transplant-free survival; ~70% native liver recovery", False, 0, 12),
], 4.75, 4.65, 8.1, 2.0, color=DARK_GREY)

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 7 – Contraindications
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, 13.333, 7.5, WHITE)
slide_header(slide, "Contraindications to Liver Transplantation")
slide_footer(slide)

# Absolute
add_rect(slide, 0.35, 1.35, 5.9, 5.6, RGBColor(0xFF, 0xEB, 0xEB))
add_rect(slide, 0.35, 1.35, 5.9, 0.55, RGBColor(0xC0, 0x20, 0x20))
add_text(slide, "ABSOLUTE Contraindications", 0.45, 1.35, 5.7, 0.55,
         font_size=16, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
abs_ci = [
    ("Active extrahepatic malignancy (non-skin)", False, 0, 13),
    ("Uncontrolled systemic infection / sepsis", False, 0, 13),
    ("Active alcohol or substance use (most centres)", False, 0, 13),
    ("Irreversible neurological injury / brain death (in ALF)", False, 0, 13),
    ("Advanced cardiopulmonary disease (non-correctable)", False, 0, 13),
    ("AIDS (not HIV-positive alone)", False, 0, 13),
    ("Persistent non-compliance with medical therapy", False, 0, 13),
]
add_textbox_multiline(slide, abs_ci, 0.5, 2.0, 5.6, 4.8, color=DARK_GREY)

# Relative
add_rect(slide, 6.6, 1.35, 6.4, 5.6, RGBColor(0xFF, 0xF5, 0xDB))
add_rect(slide, 6.6, 1.35, 6.4, 0.55, ORANGE)
add_text(slide, "RELATIVE Contraindications", 6.7, 1.35, 6.2, 0.55,
         font_size=16, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
rel_ci = [
    ("Age >65-70 years (case-by-case)", False, 0, 13),
    ("Severe cardiopulmonary disease (assess correctable)", False, 0, 13),
    ("Morbid obesity (BMI >40)", False, 0, 13),
    ("HIV (now relative at experienced centres)", False, 0, 13),
    ("Extensive portal/splenic/SMV thrombosis", False, 0, 13),
    ("Prior TIPS or splenorenal shunt (↑ difficulty)", False, 0, 13),
    ("Previous Eck fistula (portacaval end-to-side) – makes transplant significantly harder", False, 0, 13),
    ("Psychosocial factors (alcohol – requires 6-month abstinence + psychiatric clearance)", False, 0, 13),
]
add_textbox_multiline(slide, rel_ci, 6.75, 2.0, 6.1, 4.8, color=DARK_GREY)

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 8 – MELD Score & Organ Allocation
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, 13.333, 7.5, WHITE)
slide_header(slide, "Organ Allocation – MELD Score", "Model for End-Stage Liver Disease 3.0")
slide_footer(slide)

# MELD formula box
add_rect(slide, 0.35, 1.35, 12.6, 1.55, LIGHT_BLUE)
add_rect(slide, 0.35, 1.35, 12.6, 0.42, NAVY)
add_text(slide, "MELD 3.0 Formula", 0.5, 1.35, 12.3, 0.42,
         font_size=14, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
add_text(slide,
         "MELD = 1.33(female) + 4.56×ln(bilirubin) + 0.82×(137−Na) − 0.24×(137−Na)×ln(bilirubin) + 9.09×ln(INR) + 11.14×ln(creatinine) + 1.85×(3.5−albumin) − 1.83×(3.5−albumin)×ln(creatinine) + 6",
         0.5, 1.83, 12.3, 0.9,
         font_size=12, bold=False, color=DARK_GREY, font_name="Consolas")

# Key points left
add_rect(slide, 0.35, 3.1, 6.0, 3.8, LIGHT_TEAL)
add_rect(slide, 0.35, 3.1, 6.0, 0.4, TEAL)
add_text(slide, "Key MELD Principles", 0.45, 3.1, 5.8, 0.4,
         font_size=13, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
add_textbox_multiline(slide, [
    ("Higher MELD = higher 3-month mortality = higher priority", False, 0, 12),
    ("Status 1A: fulminant failure, death expected <1 week → supersedes all MELD", True, 0, 12),
    ("Variables: bilirubin, creatinine, INR, sodium, albumin, female sex", False, 0, 12),
    ("Replaces Child-Turcotte-Pugh (objective lab values vs. subjective encephalopathy grading)", False, 0, 12),
    ("2020: Acuity circles (150–500 nautical miles) replaced donation service areas to reduce geographic disparity", False, 0, 12),
], 0.5, 3.6, 5.7, 3.2, color=DARK_GREY)

# Exception points
add_rect(slide, 6.65, 3.1, 6.3, 3.8, RGBColor(0xFD, 0xF2, 0xE8))
add_rect(slide, 6.65, 3.1, 6.3, 0.4, ORANGE)
add_text(slide, "Exception Points (MELD upgrade without lab-based score)", 6.75, 3.1, 6.1, 0.4,
         font_size=12, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
exceptions = [
    ("HCC within Milan Criteria", False, 0, 12),
    ("Hepatopulmonary syndrome", False, 0, 12),
    ("Portopulmonary hypertension (PAP maintainable <35 mmHg)", False, 0, 12),
    ("Familial amyloid polyneuropathy", False, 0, 12),
    ("Primary hyperoxaluria type 1", False, 0, 12),
    ("Cystic fibrosis", False, 0, 12),
    ("Hilar cholangiocarcinoma (Mayo protocol)", False, 0, 12),
    ("Refractory ascites, refractory encephalopathy, refractory variceal haemorrhage", False, 0, 12),
]
add_textbox_multiline(slide, exceptions, 6.8, 3.6, 6.0, 3.2, color=DARK_GREY)

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 9 – Donor Selection & Organ Preservation
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, 13.333, 7.5, WHITE)
slide_header(slide, "Donor Selection & Organ Preservation")
slide_footer(slide)

# Donor types
add_rect(slide, 0.35, 1.35, 12.6, 0.42, NAVY)
add_text(slide, "Deceased Donor Types", 0.5, 1.35, 12.3, 0.42,
         font_size=14, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)

types = [
    (NAVY,  "DBD\n(Donation after\nBrain Death)",  "Standard source\n>90% of deceased-donor LT in West"),
    (TEAL,  "DCD\n(Donation after\nCirculatory Death)", "↑ risk of ischemic cholangiopathy\nAcceptable at experienced centres"),
    (ORANGE,"Extended\nCriteria Donors", "Age >60, steatosis <30-40%,\nmoderate preservation injury\nCareful recipient matching"),
]
for i, (col, label, desc) in enumerate(types):
    x = 0.35 + i * 4.25
    add_rect(slide, x, 1.85, 4.0, 1.0, col)
    add_text(slide, label, x + 0.1, 1.85, 3.8, 1.0,
             font_size=14, bold=True, color=WHITE,
             align=PP_ALIGN.CENTER, v_anchor=MSO_ANCHOR.MIDDLE)
    add_rect(slide, x, 2.85, 4.0, 1.1, LIGHT_BLUE)
    desc_lines = [(ln, False, 0, 12) for ln in desc.split("\n")]
    add_textbox_multiline(slide, desc_lines, x + 0.1, 2.9, 3.8, 1.0, color=DARK_GREY)

# Requirements
add_rect(slide, 0.35, 4.1, 6.1, 3.1, LIGHT_TEAL)
add_rect(slide, 0.35, 4.1, 6.1, 0.42, TEAL)
add_text(slide, "Donor Requirements", 0.45, 4.1, 5.9, 0.42,
         font_size=13, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
add_textbox_multiline(slide, [
    ("ABO-compatible (identical preferred; incompatible with desensitisation in emergency)", False, 0, 12),
    ("HLA matching NOT required (liver is immunologically privileged)", True, 0, 12),
    ("Macrovesicular steatosis <30% (>60% = substantially ↑ primary non-function risk)", False, 0, 12),
    ("Cold ischaemia time ideally <12h (max 24h)", False, 0, 12),
    ("UW (University of Wisconsin) solution – standard cold flush", False, 0, 12),
], 0.5, 4.6, 5.8, 2.5, color=DARK_GREY)

# Machine perfusion
add_rect(slide, 6.65, 4.1, 6.3, 3.1, RGBColor(0xFD, 0xF2, 0xE8))
add_rect(slide, 6.65, 4.1, 6.3, 0.42, ORANGE)
add_text(slide, "Machine Perfusion (Emerging Technology)", 6.75, 4.1, 6.1, 0.42,
         font_size=13, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
add_textbox_multiline(slide, [
    ("HMP – Hypothermic Machine Perfusion: 0-10°C oxygenated solution", False, 0, 12),
    ("NMP – Normothermic Machine Perfusion: physiological temperature, oxygenated blood", False, 0, 12),
    ("Allows viability assessment of marginal (DCD, steatotic) grafts before commitment", True, 0, 12),
    ("NMP: test bile production, lactate clearance → graft reconditioning possible", False, 0, 12),
    ("Extends preservation time significantly beyond cold static storage", False, 0, 12),
], 6.8, 4.6, 6.0, 2.5, color=DARK_GREY)

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 10 – Living Donor LT
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, 13.333, 7.5, WHITE)
slide_header(slide, "Living Donor Liver Transplantation (LDLT)")
slide_footer(slide)

add_textbox_multiline(slide, [
    ("Adult-to-Adult LDLT: Right lobe graft (segments V-VIII) = 60-70% of total liver volume", True, 0, 14),
    ("Paediatric LDLT: Left lateral segment (segments II-III) from adult donor", True, 0, 14),
], 0.35, 1.3, 12.6, 0.9, color=NAVY)

cards = [
    (TEAL, "Graft-to-Recipient Weight Ratio",
     "GRWR must be >0.8%\nAND/OR GV/SLV >35%\nPrevents 'small-for-size syndrome'\n(portal overflow + graft dysfunction)"),
    (NAVY, "Donor Safety",
     "Remnant liver must be >30%\nof whole liver volume\nAllows regeneration\nPrevents donor liver insufficiency"),
    (ORANGE, "Assessment Tools",
     "CT volumetry to measure graft\n3D software (e.g. MeVis HepaVision)\nDual-graft LDLT from 2 donors\n(practised in Korea for large recipients)"),
    (RGBColor(0x14, 0x5A, 0x32), "Global Practice",
     ">90% of LT in East Asia = LDLT\n<10% in Western centres\nGraft/patient survival now\ncomparable to deceased-donor LT"),
]

for i, (col, title, desc) in enumerate(cards):
    x = 0.35 + i * 3.22
    y = 2.45
    add_rect(slide, x, y, 3.0, 0.55, col)
    add_text(slide, title, x + 0.1, y, 2.8, 0.55,
             font_size=13, bold=True, color=WHITE,
             align=PP_ALIGN.CENTER, v_anchor=MSO_ANCHOR.MIDDLE)
    add_rect(slide, x, y + 0.55, 3.0, 2.0, LIGHT_BLUE)
    desc_lines = [(ln, False, 0, 12) for ln in desc.split("\n")]
    add_textbox_multiline(slide, desc_lines, x + 0.1, y + 0.6, 2.8, 1.9, color=DARK_GREY)

# Bottom note
add_rect(slide, 0.35, 5.7, 12.6, 1.45, LIGHT_TEAL)
add_textbox_multiline(slide, [
    ("Split-liver transplantation: One deceased-donor liver divided into right lobe + left lateral segment → two grafts for two recipients (typically one adult + one child).", False, 0, 12),
    ("Requires careful preoperative CT to assess vascular and biliary anatomy in both potential recipients.", False, 0, 12),
], 0.5, 5.75, 12.2, 1.35, color=DARK_GREY)

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 11 – Preoperative Evaluation
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, 13.333, 7.5, WHITE)
slide_header(slide, "Preoperative Evaluation of the Recipient")
slide_footer(slide)

systems = [
    (NAVY,  "Cardiac",
     "ECG + Echocardiography\nDobutamine stress echo / cardiac catheterisation if indicated\nScreen for cirrhotic cardiomyopathy\n(hyperdynamic state, diastolic dysfunction)"),
    (TEAL,  "Pulmonary",
     "PFTs + ABG\nScreen for hepatopulmonary syndrome (PaO₂ <60 mmHg)\nScreen for portopulmonary HTN\n(mean PAP >25 mmHg at rest)"),
    (ORANGE,"Renal",
     "Creatinine, eGFR\neGFR <30 mL/min → assess for\nsimultaneous liver-kidney transplant\n(SLKT) eligibility"),
    (RGBColor(0x14, 0x5A, 0x32), "Imaging",
     "CT/MRI abdomen: vascular anatomy, portal vein patency, hepatic masses\nDoppler USS: vascular flow\nBone density (DEXA) – osteoporosis common"),
    (RGBColor(0x7B, 0x10, 0x80), "GI / Biliary",
     "Upper endoscopy: variceal status\nColonoscopy: PSC (IBD) + cancer screening\nERCP/MRCP if biliary disease"),
    (RGBColor(0x8B, 0x45, 0x13), "Nutritional / Other",
     "Nutritional assessment + rehabilitation\nSarcopenia = strong adverse prognostic factor\nDental evaluation\nInfection screen (CMV, EBV, HIV, Hep serologies)\nPsychosocial evaluation (mandatory in ALD)"),
]

for i, (col, sys, desc) in enumerate(systems):
    row = i // 3
    icol = i % 3
    x = 0.35 + icol * 4.33
    y = 1.35 + row * 2.7
    add_rect(slide, x, y, 4.1, 0.5, col)
    add_text(slide, sys, x + 0.1, y, 3.9, 0.5,
             font_size=14, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
    add_rect(slide, x, y + 0.5, 4.1, 2.05, LIGHT_BLUE)
    desc_lines = [(ln, False, 0, 12) for ln in desc.split("\n")]
    add_textbox_multiline(slide, desc_lines, x + 0.1, y + 0.55, 3.9, 1.95, color=DARK_GREY)

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 12 – Surgical Technique Overview
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, 13.333, 7.5, WHITE)
slide_header(slide, "Surgical Principles – The Operation")
slide_footer(slide)

phases = [
    (NAVY,  "Phase 1\nHEPATECTOMY", "Most technically demanding phase\nHazards: portal hypertension, coagulopathy,\nprior surgery adhesions, hepatosplenomegaly"),
    (TEAL,  "Phase 2\nANHEPATIC", "Native liver removed\nVenovenous bypass (classic) or\npiggybacking IVC to maintain haemodynamics\nDuration minimised – target <60 min"),
    (ORANGE,"Phase 3\nNEOHEPATIC", "Graft implanted + reperfused\nFive anastomoses reconstructed\nReperfusion syndrome managed\nHaemostasis achieved"),
]

for i, (col, phase, desc) in enumerate(phases):
    x = 0.35 + i * 4.33
    add_rect(slide, x, 1.35, 4.0, 0.8, col)
    add_text(slide, phase, x + 0.1, 1.35, 3.8, 0.8,
             font_size=15, bold=True, color=WHITE,
             align=PP_ALIGN.CENTER, v_anchor=MSO_ANCHOR.MIDDLE)
    add_rect(slide, x, 2.15, 4.0, 1.4, LIGHT_BLUE)
    desc_lines = [(ln, False, 0, 12) for ln in desc.split("\n")]
    add_textbox_multiline(slide, desc_lines, x + 0.1, 2.2, 3.8, 1.3, color=DARK_GREY)

# Two techniques
add_rect(slide, 0.35, 3.75, 5.9, 3.45, RGBColor(0xE8, 0xF4, 0xFD))
add_rect(slide, 0.35, 3.75, 5.9, 0.5, NAVY)
add_text(slide, "Classic Technique (Conventional)", 0.45, 3.75, 5.7, 0.5,
         font_size=14, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
add_textbox_multiline(slide, [
    ("Recipient native IVC excised en bloc with liver", False, 0, 12),
    ("Venovenous bypass (VVB): femoral + portal → axillary vein", False, 0, 12),
    ("Decompresses splanchnic + systemic circulation during anhepatic phase", False, 0, 12),
    ("Disadvantage: VVB complications (thrombosis, air embolism, lymphocele)", False, 0, 12),
], 0.5, 4.35, 5.6, 2.75, color=DARK_GREY)

add_rect(slide, 6.65, 3.75, 6.3, 3.45, RGBColor(0xFD, 0xF2, 0xE8))
add_rect(slide, 6.65, 3.75, 6.3, 0.5, ORANGE)
add_text(slide, "Piggyback Technique (Caval Sparing) – NOW PREFERRED", 6.75, 3.75, 6.1, 0.5,
         font_size=13, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
add_textbox_multiline(slide, [
    ("Native IVC preserved; liver mobilised off IVC by ligating small hepatic veins", False, 0, 12),
    ("Three major hepatic veins united into cuff → anastomosed end-to-side to donor IVC", False, 0, 12),
    ("Advantages: No VVB required, ↓ blood loss, maintains cardiac preload, shorter OR time", True, 0, 12),
    ("Disadvantage: More demanding hepatic dissection off IVC", False, 0, 12),
], 6.8, 4.35, 6.0, 2.75, color=DARK_GREY)

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 13 – The Five Anastomoses
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, 13.333, 7.5, WHITE)
slide_header(slide, "Surgical Principles – The Five Anastomoses")
slide_footer(slide)

anastomoses = [
    (NAVY,  "1. Suprahepatic IVC",
     "Hepatic vein cuff → donor IVC\n(Piggyback: end-to-side)\nOr donor-to-recipient suprahepatic IVC (classic)"),
    (TEAL,  "2. Infrahepatic IVC",
     "Donor-to-recipient IVC\nEnd-to-end anastomosis\n(Classic technique only;\nomitted in piggyback)"),
    (ORANGE,"3. Portal Vein",
     "End-to-end anastomosis\nInterposition jump graft (donor iliac vein)\nif recipient PV thrombosed\nMust avoid kinking"),
    (RGBColor(0xC0, 0x20, 0x20), "4. Hepatic Artery",
     "Microsurgical precision required\nCommon hepatic to common hepatic (standard)\nAortic jump graft: variant anatomy,\nprior surgery, irradiated vessels (CCA)"),
    (RGBColor(0x14, 0x5A, 0x32), "5. Biliary Reconstruction",
     "Option A: Choledochocholedochostomy\n(duct-to-duct) – preferred if normal CBD\nOption B: Roux-en-Y hepaticojejunostomy\n– PSC, biliary atresia, re-transplant"),
]

for i, (col, title, desc) in enumerate(anastomoses):
    x = 0.35 + (i % 3) * 4.33
    y = 1.35 + (i // 3) * 2.7
    add_rect(slide, x, y, 4.0, 0.5, col)
    add_text(slide, title, x + 0.1, y, 3.8, 0.5,
             font_size=14, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
    add_rect(slide, x, y + 0.5, 4.0, 2.05, LIGHT_BLUE)
    desc_lines = [(ln, False, 0, 12) for ln in desc.split("\n")]
    add_textbox_multiline(slide, desc_lines, x + 0.1, y + 0.55, 3.8, 1.95, color=DARK_GREY)

# Reperfusion note
add_rect(slide, 0.35, 6.65, 12.6, 0.6, LIGHT_TEAL)
add_text(slide,
         "Reperfusion syndrome: systemic hypotension, bradycardia, hyperkalaemia, acidosis on unclamping of portal vein. Managed with calcium gluconate, bicarbonate, vasopressors + surgical flushing of graft before unclamping.",
         0.5, 6.67, 12.2, 0.52, font_size=11, color=NAVY)

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 14 – Immunosuppression
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, 13.333, 7.5, WHITE)
slide_header(slide, "Postoperative Management – Immunosuppression")
slide_footer(slide)

add_text(slide, "Standard Triple Therapy Backbone", 0.35, 1.3, 12.6, 0.45,
         font_size=16, bold=True, color=NAVY)

drugs = [
    (NAVY, "TACROLIMUS\n(FK-506)",
     "Calcineurin inhibitor (CNI)\nInhibits IL-2 transcription\nMainstay of maintenance therapy\nTarget trough:\n  Month 1: 10-15 ng/mL\n  Thereafter: 5-10 ng/mL\nKey toxicities:\n  Nephrotoxicity, neurotoxicity,\n  hypertension, hyperglycaemia"),
    (TEAL, "MYCOPHENOLATE\nMOFETIL (MMF)",
     "Antimetabolite\nInhibits purine synthesis (IMPDH)\nBlocks lymphocyte proliferation\nDose: 1-1.5g BD\nKey toxicities:\n  GI upset, leucopenia,\n  teratogenic (women of\n  childbearing age: caution)"),
    (ORANGE, "CORTICOSTEROIDS\n(Prednisolone)",
     "Broad anti-inflammatory\nBridge immunosuppression\nHigh dose peri-operatively\nTapered and often withdrawn\nby 3-12 months post-transplant\nKey toxicities:\n  Diabetes, osteoporosis,\n  cushingoid features, infection"),
]

for i, (col, drug, info) in enumerate(drugs):
    x = 0.35 + i * 4.33
    add_rect(slide, x, 1.85, 4.0, 0.8, col)
    add_text(slide, drug, x + 0.1, 1.85, 3.8, 0.8,
             font_size=15, bold=True, color=WHITE,
             align=PP_ALIGN.CENTER, v_anchor=MSO_ANCHOR.MIDDLE)
    add_rect(slide, x, 2.65, 4.0, 3.2, LIGHT_BLUE)
    info_lines = [(ln, False, 0, 12) for ln in info.split("\n")]
    add_textbox_multiline(slide, info_lines, x + 0.1, 2.7, 3.8, 3.1, color=DARK_GREY)

# Additional agents
add_rect(slide, 0.35, 6.0, 12.6, 1.2, RGBColor(0xFD, 0xF2, 0xE8))
add_rect(slide, 0.35, 6.0, 12.6, 0.38, ORANGE)
add_text(slide, "Additional / Alternative Agents", 0.5, 6.0, 12.3, 0.38,
         font_size=12, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
add_textbox_multiline(slide, [
    ("Cyclosporine: alternative CNI (less potent than tacrolimus; more cosmetic side effects)", False, 0, 12),
    ("mTOR inhibitors (Sirolimus / Everolimus): used in HCC recipients (↓ recurrence), renal-sparing regimens. Avoid in early post-transplant (impairs wound healing)", False, 0, 12),
    ("Basiliximab (IL-2R antagonist): induction agent to delay or reduce CNI use (renal protection)", False, 0, 12),
], 0.5, 6.43, 12.3, 0.73, color=DARK_GREY)

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 15 – Rejection
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, 13.333, 7.5, WHITE)
slide_header(slide, "Rejection After Liver Transplantation")
slide_footer(slide)

for i, (col, rtype, timing, features, biopsy, tx) in enumerate([
    (TEAL, "ACUTE CELLULAR REJECTION (ACR)",
     "Most common; first 6 weeks",
     "Rising AST/ALT/ALP, bilirubin, fever, malaise",
     "Portal inflammation + bile duct damage + endotheliitis (Banff criteria)",
     "IV methylprednisolone 500-1000mg/day × 3 days then taper\nSteroid-refractory: ATG or OKT3"),
    (RGBColor(0xC0, 0x20, 0x20), "CHRONIC DUCTOPENIC REJECTION\n(Vanishing Bile Duct Syndrome)",
     "Months to years post-transplant",
     "Progressive jaundice, rising ALP\nInsidious onset",
     "Progressive loss of interlobular bile ducts\n>50% ducts absent = ductopenic rejection",
     "Often irreversible\nOptimise immunosuppression\nMay require re-transplantation"),
]):
    x = 0.35 + i * 6.5
    add_rect(slide, x, 1.35, 6.15, 0.55, col)
    add_text(slide, rtype, x + 0.1, 1.35, 5.95, 0.55,
             font_size=14, bold=True, color=WHITE,
             align=PP_ALIGN.CENTER, v_anchor=MSO_ANCHOR.MIDDLE)
    fields = [
        ("Timing:", timing),
        ("Clinical Features:", features),
        ("Biopsy Findings:", biopsy),
        ("Treatment:", tx),
    ]
    y = 2.05
    for label, content in fields:
        add_rect(slide, x, y, 6.15, 0.32, LIGHT_BLUE)
        add_text(slide, label, x + 0.1, y, 6.0, 0.32,
                 font_size=12, bold=True, color=NAVY, v_anchor=MSO_ANCHOR.MIDDLE)
        y += 0.32
        lines = [(ln, False, 0, 12) for ln in content.split("\n")]
        height = 0.3 * len(content.split("\n")) + 0.1
        add_textbox_multiline(slide, lines, x + 0.2, y, 5.8, height, color=DARK_GREY)
        y += height + 0.08

# Risk factors note
add_rect(slide, 0.35, 6.7, 12.6, 0.55, LIGHT_TEAL)
add_text(slide,
         "Risk factors for chronic rejection: multiple ACR episodes, inadequate immunosuppression, CMV infection, tacrolimus under-dosing. Key post-LT infection prophylaxis: TMP-SMX (PJP), valganciclovir (CMV), fluconazole (fungal).",
         0.5, 6.73, 12.2, 0.48, font_size=11, color=NAVY)

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 16 – Complications
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, 13.333, 7.5, WHITE)
slide_header(slide, "Complications After Liver Transplantation")
slide_footer(slide)

# Vascular
add_rect(slide, 0.35, 1.35, 6.15, 0.42, NAVY)
add_text(slide, "Vascular Complications", 0.45, 1.35, 5.95, 0.42,
         font_size=13, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
vasc = [
    ("Hepatic Artery Thrombosis (HAT)", "5-9% adults; higher in children. Entire biliary tree depends on hepatic artery post-LT → bile duct necrosis, bilomas. Early: urgent thrombectomy or re-transplantation."),
    ("Hepatic Artery Stenosis", "2-5%. Managed with radiological angioplasty ± stenting."),
    ("Portal Vein Thrombosis", "Up to 12%. Early: surgical thrombectomy; Late: TIPS or re-transplant for portal HTN."),
    ("IVC / Hepatic Vein Stenosis", "Rare. Endovascular stenting."),
]
y = 1.85
for comp, detail in vasc:
    add_rect(slide, 0.35, y, 6.15, 0.3, LIGHT_BLUE)
    add_text(slide, comp, 0.45, y, 5.95, 0.3, font_size=12, bold=True,
             color=NAVY, v_anchor=MSO_ANCHOR.MIDDLE)
    y += 0.3
    lines = [(ln, False, 0, 11) for ln in detail.split("\n")]
    ht = 0.28 * len(detail.split("\n")) + 0.05
    add_textbox_multiline(slide, lines, 0.5, y, 5.8, ht, color=MID_GREY)
    y += ht + 0.08

# Biliary
add_rect(slide, 6.8, 1.35, 6.15, 0.42, TEAL)
add_text(slide, "Biliary Complications (5-30% – most common morbidity)", 6.9, 1.35, 5.95, 0.42,
         font_size=13, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)
bili = [
    ("Anastomotic Strictures", "80% of strictures. Present 2-6 months post-LT. Duct-to-duct: ERCP + stenting. Roux-en-Y: percutaneous or surgical correction."),
    ("Bile Leaks", "From anastomosis or cut surface. ERCP ± stent, or surgery."),
    ("Non-anastomotic Strictures\n(Ischemic Cholangiopathy)", "Suggests HAT or DCD injury. Often requires re-transplantation."),
    ("Biliary Casts", "Up to 18% in first year. Endoscopic/percutaneous therapy 70% success. Mortality 10-30%."),
]
y = 1.85
for comp, detail in bili:
    add_rect(slide, 6.8, y, 6.15, 0.3, LIGHT_BLUE)
    comp_lines = [(ln, False, 0, 12) for ln in comp.split("\n")]
    add_textbox_multiline(slide, [(comp, True, 0, 12)], 6.9, y, 5.95, 0.3,
                          color=NAVY, v_anchor=MSO_ANCHOR.MIDDLE)
    y += 0.3
    lines = [(ln, False, 0, 11) for ln in detail.split("\n")]
    ht = 0.28 * len(detail.split("\n")) + 0.05
    add_textbox_multiline(slide, lines, 6.9, y, 5.95, ht, color=MID_GREY)
    y += ht + 0.08

# Infection note
add_rect(slide, 0.35, 6.5, 12.6, 0.75, RGBColor(0xFF, 0xEB, 0xEB))
add_textbox_multiline(slide, [
    ("Infection: most common cause of morbidity AND mortality (up to 75% of recipients).", True, 0, 12),
    ("0-1 month: hospital-acquired bacterial + fungal. 1-6 months: CMV, PCP, aspergillosis, EBV/PTLD. >6 months: community-acquired + late opportunistic.", False, 0, 11),
], 0.5, 6.52, 12.2, 0.7, color=DARK_GREY)

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 17 – Outcomes & Disease Recurrence
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, 13.333, 7.5, WHITE)
slide_header(slide, "Outcomes & Disease Recurrence")
slide_footer(slide)

# Survival bar chart-like display
add_rect(slide, 0.35, 1.35, 12.6, 0.42, NAVY)
add_text(slide, "Patient Survival by Indication", 0.5, 1.35, 12.3, 0.42,
         font_size=14, bold=True, color=WHITE, v_anchor=MSO_ANCHOR.MIDDLE)

survivals = [
    ("Overall (1 yr)", 92, TEAL),
    ("Overall (3 yr)", 88, TEAL),
    ("Overall (5 yr)", 78, TEAL),
    ("PBC (5 yr)", 90, NAVY),
    ("HCC within Milan (5 yr)", 70, ORANGE),
    ("ALF (1 yr)", 72, RGBColor(0xC0, 0x20, 0x20)),
    ("Cholangiocarcinoma Mayo (5 yr)", 65, RGBColor(0x14, 0x5A, 0x32)),
]
bar_x = 0.5
bar_y = 1.9
bar_h = 0.55
spacing = 0.65
max_w = 10.0

for i, (label, pct, col) in enumerate(survivals):
    y = bar_y + i * spacing
    bar_w = max_w * pct / 100
    add_rect(slide, bar_x + 2.5, y, bar_w, bar_h, col)
    add_text(slide, label, bar_x, y, 2.4, bar_h,
             font_size=12, color=DARK_GREY, v_anchor=MSO_ANCHOR.MIDDLE)
    add_text(slide, f"{pct}%", bar_x + 2.5 + bar_w + 0.1, y, 0.7, bar_h,
             font_size=12, bold=True, color=col, v_anchor=MSO_ANCHOR.MIDDLE)

# Disease recurrence
add_rect(slide, 0.35, 6.4, 12.6, 0.85, LIGHT_TEAL)
add_text(slide, "Disease Recurrence after LT:", 0.5, 6.42, 2.5, 0.35,
         font_size=12, bold=True, color=NAVY)
add_text(slide, "HCV: virtually all recur (DAAs now used pre/post-LT)  |  HBV: prevented by HBIg + antivirals  |  PBC: 0-35% recurrence (usually mild; UDCA protective)  |  PSC: can recur  |  AIH: ~20-30%  |  HCC: 10-15% within Milan  |  PTLD: EBV-driven; treat with immunosuppression reduction ± rituximab",
         0.5, 6.78, 12.3, 0.42, font_size=10, color=MID_GREY)

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 18 – Summary Table
# ─────────────────────────────────────────────────────────────────────────────
slide = prs.slides.add_slide(blank)
add_rect(slide, 0, 0, 13.333, 7.5, WHITE)
slide_header(slide, "Summary")
slide_footer(slide)

rows = [
    ("Domain",                       "Key Points",                                True),
    ("Most common indication",        "Decompensated cirrhosis (ALD, NAFLD/NASH, viral hepatitis)", False),
    ("Paediatric",                    "Biliary atresia (most common in children)",   False),
    ("Urgent (Status 1A)",            "ALF: acetaminophen, viral, Wilson's, seronegative",          False),
    ("Allocation tool",               "MELD 3.0 score (bilirubin, creatinine, INR, Na, albumin, sex)", False),
    ("Absolute contraindication",     "Active extrahepatic malignancy, uncontrolled sepsis, active substance use", False),
    ("HCC criterion",                 "Milan Criteria: single ≤5 cm or 3 tumors ≤3 cm; no vascular invasion", False),
    ("Preferred surgical technique",  "Piggyback (caval-sparing) hepatectomy – no VVB required",   False),
    ("Biliary reconstruction",        "Duct-to-duct (preferred) or Roux-en-Y hepaticojejunostomy", False),
    ("Immunosuppression",             "Tacrolimus + MMF ± corticosteroids",         False),
    ("Most common complication",      "Biliary (5-30%); infection (up to 75%)",     False),
    ("Feared vascular complication",  "Hepatic artery thrombosis (5-9% adults)",    False),
    ("1-year survival",               ">90%",                                        False),
]

header_printed = False
for i, (domain, key, is_header) in enumerate(rows):
    y = 1.35 + i * 0.44
    bg = NAVY if is_header else (LIGHT_BLUE if i % 2 == 0 else WHITE)
    txt_col = WHITE if is_header else DARK_GREY
    add_rect(slide, 0.35, y, 4.2, 0.42, bg)
    add_rect(slide, 4.6, y, 8.35, 0.42, bg)
    add_text(slide, domain, 0.45, y, 4.0, 0.42,
             font_size=12, bold=is_header, color=txt_col,
             v_anchor=MSO_ANCHOR.MIDDLE)
    add_text(slide, key, 4.7, y, 8.15, 0.42,
             font_size=12, bold=is_header, color=txt_col,
             v_anchor=MSO_ANCHOR.MIDDLE)

# ─────────────────────────────────────────────────────────────────────────────
# Save
# ─────────────────────────────────────────────────────────────────────────────
out_path = "/tmp/workspace/hepatic-transplant-ppt/Hepatic_Transplantation.pptx"
prs.save(out_path)
print(f"Saved: {out_path}")
print(f"Slides: {len(prs.slides)}")
Running Command

cd /tmp/workspace/hepatic-transplant-ppt && python build_pptx.py 2>&1

Running Command

ls -lh /tmp/workspace/hepatic-transplant-ppt/Hepatic_Transplantation.pptx

Your presentation is ready - 18 slides, 16:9 widescreen format, with a professional navy/teal/orange colour scheme.

Hepatic Transplantation

Presentation · PPTX


Here is what's in each slide:
#Slide Title
1Title Slide – Hepatic Transplantation
2Table of Contents
3History & Background (timeline format)
4Indications Overview (4 category boxes)
5Chronic Liver Disease – Detailed Indications
6Acute Liver Failure & King's College Criteria
7Contraindications (Absolute vs. Relative)
8MELD Score & Organ Allocation
9Donor Selection & Organ Preservation
10Living Donor Liver Transplantation
11Preoperative Evaluation of the Recipient
12Surgical Principles – The Three Phases
13The Five Anastomoses
14Immunosuppression (Triple Therapy)
15Rejection (Acute & Chronic)
16Complications (Vascular, Biliary, Infectious)
17Outcomes & Disease Recurrence (bar chart)
18Summary Table
This is a shared conversation. Sign in to Orris to start your own chat.