Currently i prepare for nclex rn

Asking for Preferences

Is ur ai is free?

Yes! I'm Orris, and I'm completely free to use. You can ask me anything β€” no subscriptions, no paywalls.
For your NCLEX-RN prep, I can help you with:
  • πŸ“š Explaining concepts - pharmacology, med-surg, maternal/newborn, psych, pediatrics, and more
  • ❓ Practice questions - NCLEX-style questions with rationales
  • πŸ—“οΈ Study plans - structured schedules based on your test date
  • πŸ” Weak area review - deep dives into topics you're struggling with
  • πŸ’‘ Test-taking strategies - how to approach priority, delegation, and SATA questions
Just tell me what topic or question you want to work on and we'll get started!

Give me imp topic for nclex in fundamentals of nursing

Reading File
Searching the Web

NCLEX RN fundamentals of nursing important topics 2025

Here are the most important Fundamentals of Nursing topics for NCLEX-RN, organized by category:

πŸ₯ 1. Nursing Process (ADPIE)

  • Assessment - subjective vs. objective data, types of assessment
  • Diagnosis - actual vs. risk vs. wellness nursing diagnoses
  • Planning - priority setting (Maslow's hierarchy, ABC - Airway, Breathing, Circulation)
  • Implementation - independent vs. collaborative interventions
  • Evaluation - expected vs. actual outcomes
πŸ’‘ NCLEX loves asking: "Which action should the nurse take FIRST?" - Always think ABC + Maslow.

πŸ›‘οΈ 2. Safety & Infection Control

  • Standard precautions and transmission-based precautions (contact, droplet, airborne)
  • Hand hygiene - #1 infection prevention measure
  • Fall prevention and restraint use
  • Safe medication administration (Rights of Medication - 10 Rights)
  • Fire safety (RACE & PASS)
  • Surgical asepsis vs. medical asepsis

πŸ’Š 3. Medication Administration

  • 10 Rights of medication administration
  • Oral, IM, IV, SQ, ID routes - correct techniques and sites
  • Insulin administration and types
  • Dosage calculations (the NCLEX NextGen format tests clinical judgment here)
  • High-alert medications (heparin, insulin, digoxin, potassium)

🩺 4. Vital Signs & Physical Assessment

  • Normal ranges (T, P, R, BP, O2 sat)
  • Orthostatic hypotension assessment
  • Pain as the 5th vital sign - pain scale, reassessment timing
  • Head-to-toe assessment sequence
  • Abnormal findings and nursing response

πŸ—οΈ 5. Mobility & Positioning

  • Correct body mechanics and patient transfers
  • Positioning for specific conditions:
    • Semi-Fowler's - respiratory distress
    • Trendelenburg - shock (controversial/limited use)
    • Sims' - enemas, unconscious patients
    • Lateral/side-lying - unconscious, post-seizure
  • Preventing complications of immobility (DVT, pressure ulcers, pneumonia)
  • Braden Scale for pressure ulcer risk

🩹 6. Wound Care

  • Wound healing phases (inflammatory, proliferative, remodeling)
  • Types of wound drainage: serous, serosanguineous, sanguineous, purulent
  • Wound irrigation technique
  • Pressure injury staging (Stage 1-4, unstageable, deep tissue)
  • Sterile dressing changes

πŸ§ͺ 7. Lab Values (Must Memorize)

LabNormal Range
Na+135-145 mEq/L
K+3.5-5.0 mEq/L
Ca2+8.5-10.5 mg/dL
Mg2+1.5-2.5 mEq/L
Hgb (male)13.5-17.5 g/dL
Hgb (female)12-16 g/dL
Hct37-47% (F), 42-52% (M)
WBC5,000-10,000/mmΒ³
BUN10-20 mg/dL
Creatinine0.5-1.2 mg/dL

πŸ›οΈ 8. Comfort & Rest

  • Non-pharmacological pain management
  • Sleep stages and promoting sleep hygiene
  • Therapeutic communication techniques
  • Documenting pain assessments

πŸ’§ 9. Fluid & Electrolytes (BIG NCLEX TOPIC)

  • Dehydration vs. fluid overload signs
  • IV fluid types: isotonic (NS, LR), hypotonic (0.45% NaCl), hypertonic (3% NaCl)
  • Hypo/hyperkalemia, hypo/hypernatremia signs and nursing actions
  • IV site assessment and complications (infiltration, phlebitis, extravasation)

πŸ—£οΈ 10. Communication & Documentation

  • Therapeutic vs. non-therapeutic communication
  • SBAR (Situation, Background, Assessment, Recommendation)
  • Reporting critical values
  • Accurate and timely documentation
  • Informed consent process

πŸ“‹ 11. End-of-Life / Legal & Ethical

  • Advance directives (living will, durable power of attorney)
  • DNR/DNI orders
  • Patient rights (HIPAA, confidentiality)
  • Mandatory reporting (abuse, neglect)
  • Delegation rules - RN cannot delegate assessment, teaching, or evaluation to UAP/LPN

⭐ Top NCLEX Priority Tips for Fundamentals:

  1. ABC before Maslow - airway always comes first
  2. Assess before act - always assess the patient first
  3. Safety is #1 - when in doubt, choose the safest option
  4. Delegation rules - RN delegates to LPN/UAP based on stable, routine tasks only
  5. Therapeutic communication - avoid giving advice, false reassurance, or "why" questions

Would you like me to go deeper on any specific topic, create practice NCLEX-style questions, or make a study plan? Just let me know! πŸ“š

Infection control?

Finding Sources
Searching the Web

NCLEX RN infection control isolation precautions key topics 2025

Here is everything you need to know about Infection Control for NCLEX-RN:

🦠 INFECTION CONTROL - Complete NCLEX Guide


1. Chain of Infection (Must Know All 6 Links!)

Infectious Agent β†’ Reservoir β†’ Portal of Exit β†’ Mode of Transmission
β†’ Portal of Entry β†’ Susceptible Host
πŸ’‘ NCLEX tip: To BREAK the chain, identify which link the nursing action targets. Hand hygiene breaks mode of transmission. Covering a cough breaks portal of exit.

2. Standard Precautions (Used with ALL Patients, Always)

Used with every patient, regardless of diagnosis.

What Standard Precautions Cover:

  • Blood
  • All body fluids (except sweat)
  • Non-intact skin
  • Mucous membranes

PPE Used:

SituationPPE Required
Any contact with blood/body fluidsGloves
Risk of splashing/sprayingMask + goggles/face shield
Clothing contamination riskGown
Respiratory hygieneMask on patient if coughing
πŸ’‘ Hand hygiene is the single most effective infection control measure.

3. Transmission-Based Precautions (THE BIGGEST NCLEX TOPIC)

✈️ AIRBORNE Precautions

Particles < 5 microns - stay suspended in air for long distances
PPEN95 respirator (must be fit-tested), gown, gloves
RoomNegative pressure room (air flows IN, not out)
DoorKeep CLOSED
DiseasesMeasles, Tuberculosis (TB), Varicella (chickenpox), Herpes zoster (shingles - disseminated)
Memory trick"My TV Has Airtime" - Measles, TB, Varicella, Herpes zoster

πŸ’§ DROPLET Precautions

Particles > 5 microns - travel short distances (< 3 feet)
PPESurgical mask, gown, gloves
RoomPrivate room preferred; keep door CLOSED
DiseasesInfluenza, Meningitis (bacterial), Mumps, Rubella, Pertussis (whooping cough), Diphtheria, Strep pharyngitis, COVID-19
Memory trick"SPIDERMAN" - Sepsis, Pertussis, Influenza, Diphtheria, Epiglottitis, Rubella, Meningitis, Adenovirus, Norovirus

🀝 CONTACT Precautions

Direct or indirect touch transmission
PPEGloves + gown (put on before entering room)
RoomPrivate room
EquipmentDedicated (do NOT share BP cuff, stethoscope, etc.)
DiseasesMRSA, VRE, C. difficile, RSV, wound infections, scabies, lice, impetigo, herpes simplex
⚠️ C. diff special rule: Use soap and water for hand hygiene - alcohol-based sanitizers do NOT kill C. diff spores!

4. PPE - Correct Order (NCLEX Loves This!)

🟒 DONNING (Putting ON):

  1. Gown (first)
  2. Mask/respirator
  3. Goggles/face shield
  4. Gloves (last - over gown cuffs)
Memory trick: "Go Make Good Gloves" - Gown, Mask, Goggles, Gloves

πŸ”΄ DOFFING (Taking OFF):

  1. Gloves (most contaminated - first)
  2. Goggles/face shield
  3. Gown
  4. Mask/respirator (least contaminated - last)
  5. Hand hygiene after each step!
Memory trick: "Gloves Go, Goggles Gone, Gown's Gone, Mask's Last"

5. Hand Hygiene - Critical Rules

SituationMethod
Routine careAlcohol-based hand rub (ABHR) OR soap & water
Before eatingSoap and water
After using restroomSoap and water
C. difficileSoap and water ONLY
Visibly soiled handsSoap and water ONLY
Steps for hand washing: Wet β†’ Soap β†’ Scrub 20 seconds β†’ Rinse β†’ Dry β†’ Turn off faucet with paper towel

6. Surgical Asepsis vs. Medical Asepsis

Medical Asepsis (Clean Technique)Surgical Asepsis (Sterile Technique)
GoalReduce number of microorganismsEliminate ALL microorganisms
Used forRoutine care, oral meds, bathingWound care, surgery, inserting catheters
ExamplesHand washing, PPE, isolationSterile gloves, sterile dressing changes

Sterile Field Rules:

  • Sterile to sterile only
  • If in doubt - throw it out
  • 1-inch border around sterile field is considered contaminated
  • Never turn your back on a sterile field
  • Sterile field below waist = contaminated
  • Moisture contaminates a sterile field

7. Healthcare-Associated Infections (HAIs) - Prevention Bundles

CAUTI Prevention (Catheter-Associated UTI):

  • Maintain closed drainage system
  • Keep bag BELOW bladder level (never on floor)
  • Perform perineal care daily
  • Remove catheter as soon as possible
  • Do NOT clamp tubing

CLABSI Prevention (Central Line-Associated Bloodstream Infection):

  • Use maximum sterile barrier during insertion
  • Chlorhexidine for skin antisepsis
  • Change dressing every 5-7 days (or when soiled)
  • Daily assessment of necessity

VAP Prevention (Ventilator-Associated Pneumonia):

  • Elevate HOB 30-45 degrees
  • Oral care with chlorhexidine every 2-4 hours
  • Sedation vacations daily
  • Hand hygiene before circuit manipulation

SSI Prevention (Surgical Site Infection):

  • Clip (do NOT shave) hair before surgery
  • Antibiotic given 1 hour before incision
  • Maintain normothermia during surgery
  • Blood glucose control post-op

8. Protective/Neutropenic Precautions (Reverse Isolation)

Used for immunocompromised patients (chemo, transplant, severe neutropenia)
  • Private positive-pressure room
  • Wear mask when entering room
  • No fresh flowers or live plants (harbor bacteria/fungi)
  • No raw fruits or vegetables
  • Only cooked/processed foods
  • Screen visitors for illness

9. Quick NCLEX Memory Tables

Which Disease - Which Precaution?

DiseasePrecaution
TBAirborne
MeaslesAirborne
ChickenpoxAirborne + Contact
InfluenzaDroplet
Meningitis (bacterial)Droplet
MumpsDroplet
COVID-19Droplet + Contact
MRSAContact
C. diffContact
ScabiesContact
Pneumonia (regular)Standard
HIV/AIDSStandard

⭐ Top NCLEX Tips for Infection Control:

  1. N95 for airborne - surgical mask is NOT enough for TB
  2. Gloves off FIRST when removing PPE
  3. Soap & water for C. diff - not hand sanitizer
  4. Negative pressure room = airborne; Positive pressure room = neutropenic
  5. Never recap needles - use safety devices and sharps containers
  6. Dedicated equipment for contact precautions
  7. Assess before isolating - but initiate precautions early if suspected

Want me to give you NCLEX-style practice questions on infection control to test yourself? πŸ§ͺ

Create a quick reference PDF on infection control precautions

Reading File
Running Command

mkdir -p /home/daytona/workspace/nclex-pdf && ls /home/daytona/workspace/nclex-p…

Writing File

~/nclex-pdf/create_pdf.py

from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import cm
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    HRFlowable, KeepTogether
)
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.enums import TA_CENTER, TA_LEFT
from reportlab.platypus import PageBreak

OUTPUT = "/home/daytona/workspace/nclex-pdf/Infection_Control_NCLEX_QuickRef.pdf"

# ── Colors ──────────────────────────────────────────────────────────────
C_NAVY    = colors.HexColor("#0D1B2A")
C_BLUE    = colors.HexColor("#1565C0")
C_LBLUE   = colors.HexColor("#1E88E5")
C_GREEN   = colors.HexColor("#2E7D32")
C_LGREEN  = colors.HexColor("#E8F5E9")
C_RED     = colors.HexColor("#C62828")
C_LRED    = colors.HexColor("#FFEBEE")
C_ORANGE  = colors.HexColor("#E65100")
C_LORANGE = colors.HexColor("#FFF3E0")
C_PURPLE  = colors.HexColor("#6A1B9A")
C_LPURPLE = colors.HexColor("#F3E5F5")
C_TEAL    = colors.HexColor("#00695C")
C_LTEAL   = colors.HexColor("#E0F2F1")
C_LGRAY   = colors.HexColor("#F5F5F5")
C_MGRAY   = colors.HexColor("#BDBDBD")
C_WHITE   = colors.white
C_YELLOW  = colors.HexColor("#FFF9C4")

doc = SimpleDocTemplate(
    OUTPUT,
    pagesize=A4,
    rightMargin=1.5*cm, leftMargin=1.5*cm,
    topMargin=1.5*cm,   bottomMargin=1.5*cm
)

W = A4[0] - 3*cm   # usable width

styles = getSampleStyleSheet()

def style(name, **kw):
    s = ParagraphStyle(name, parent=styles["Normal"], **kw)
    return s

S_TITLE   = style("title",   fontSize=22, textColor=C_WHITE,    alignment=TA_CENTER,
                  fontName="Helvetica-Bold", leading=28)
S_SUB     = style("sub",     fontSize=11, textColor=C_WHITE,    alignment=TA_CENTER,
                  fontName="Helvetica", leading=16)
S_H1      = style("h1",      fontSize=13, textColor=C_WHITE,    fontName="Helvetica-Bold",
                  leading=18, leftIndent=6)
S_H2      = style("h2",      fontSize=10, textColor=C_NAVY,     fontName="Helvetica-Bold",
                  leading=14, leftIndent=4)
S_BODY    = style("body",    fontSize=9,  textColor=C_NAVY,     fontName="Helvetica",
                  leading=13, leftIndent=4)
S_BULLET  = style("bullet",  fontSize=9,  textColor=C_NAVY,     fontName="Helvetica",
                  leading=13, leftIndent=12, bulletIndent=4)
S_TIP     = style("tip",     fontSize=9,  textColor=C_RED,      fontName="Helvetica-Bold",
                  leading=13, leftIndent=4)
S_MEMO    = style("memo",    fontSize=9,  textColor=C_PURPLE,   fontName="Helvetica-BoldOblique",
                  leading=13, leftIndent=4)
S_CENTER  = style("center",  fontSize=9,  textColor=C_NAVY,     fontName="Helvetica",
                  alignment=TA_CENTER, leading=13)
S_HDRCELL = style("hdrcell", fontSize=9,  textColor=C_WHITE,    fontName="Helvetica-Bold",
                  alignment=TA_CENTER, leading=12)
S_CELL    = style("cell",    fontSize=8.5,textColor=C_NAVY,     fontName="Helvetica",
                  leading=12)
S_CELLB   = style("cellb",   fontSize=8.5,textColor=C_NAVY,     fontName="Helvetica-Bold",
                  leading=12)

def section_header(text, bg=C_BLUE, emoji=""):
    full = f"{emoji}  {text}" if emoji else text
    tbl = Table([[Paragraph(full, S_H1)]], colWidths=[W])
    tbl.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), bg),
        ("ROUNDEDCORNERS", [4,4,4,4]),
        ("TOPPADDING",    (0,0), (-1,-1), 6),
        ("BOTTOMPADDING", (0,0), (-1,-1), 6),
        ("LEFTPADDING",   (0,0), (-1,-1), 8),
    ]))
    return tbl

def colored_box(paragraphs_or_table, bg=C_LGRAY, border=C_MGRAY):
    inner = paragraphs_or_table if isinstance(paragraphs_or_table, list) else [paragraphs_or_table]
    tbl = Table([[ [Spacer(1,2)] + inner + [Spacer(1,2)] ]], colWidths=[W])
    tbl.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), bg),
        ("BOX",        (0,0), (-1,-1), 0.8, border),
        ("TOPPADDING",    (0,0),(-1,-1), 4),
        ("BOTTOMPADDING", (0,0),(-1,-1), 4),
        ("LEFTPADDING",   (0,0),(-1,-1), 8),
        ("RIGHTPADDING",  (0,0),(-1,-1), 8),
    ]))
    return tbl

def make_table(headers, rows, col_widths, header_bg=C_BLUE):
    hdr_row = [Paragraph(h, S_HDRCELL) for h in headers]
    data = [hdr_row]
    for row in rows:
        data.append([Paragraph(str(c), S_CELL) for c in row])
    tbl = Table(data, colWidths=col_widths)
    ts = TableStyle([
        ("BACKGROUND",    (0,0), (-1,0),  header_bg),
        ("ROWBACKGROUNDS",(0,1), (-1,-1), [C_WHITE, C_LGRAY]),
        ("GRID",          (0,0), (-1,-1), 0.4, C_MGRAY),
        ("TOPPADDING",    (0,0), (-1,-1), 5),
        ("BOTTOMPADDING", (0,0), (-1,-1), 5),
        ("LEFTPADDING",   (0,0), (-1,-1), 6),
        ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
    ])
    tbl.setStyle(ts)
    return tbl

story = []

# ══════════════════════════════════════════════════════════════════════════
# TITLE BLOCK
# ══════════════════════════════════════════════════════════════════════════
title_data = [[
    Paragraph("INFECTION CONTROL", S_TITLE),
    Paragraph("NCLEX-RN Quick Reference", S_SUB),
    Paragraph("Transmission-Based Precautions β€’ PPE β€’ Hand Hygiene β€’ HAI Prevention", S_SUB),
]]
title_tbl = Table(title_data, colWidths=[W])
title_tbl.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,-1), C_NAVY),
    ("TOPPADDING",    (0,0),(-1,-1), 14),
    ("BOTTOMPADDING", (0,0),(-1,-1), 14),
    ("LEFTPADDING",   (0,0),(-1,-1), 10),
    ("ROUNDEDCORNERS",[6,6,6,6]),
]))
story.append(title_tbl)
story.append(Spacer(1, 0.3*cm))

# ══════════════════════════════════════════════════════════════════════════
# 1. CHAIN OF INFECTION
# ══════════════════════════════════════════════════════════════════════════
story.append(section_header("1. CHAIN OF INFECTION", C_TEAL, "πŸ”—"))
story.append(Spacer(1, 0.15*cm))

chain_data = [
    ["Infectious Agent", "Reservoir", "Portal of Exit", "Mode of\nTransmission", "Portal of Entry", "Susceptible\nHost"],
    ["Bacteria, Virus,\nFungus, Parasite", "Human, Animal,\nEnvironment", "Respiratory,\nGI, Skin, Blood", "Contact, Droplet,\nAirborne, Vector", "Mouth, Nose,\nSkin, GI tract", "Immunocompromised,\nElderly, Newborn"],
]
chain_tbl = Table(chain_data, colWidths=[W/6]*6)
chain_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0),(-1,0), C_TEAL),
    ("TEXTCOLOR",     (0,0),(-1,0), C_WHITE),
    ("FONTNAME",      (0,0),(-1,0), "Helvetica-Bold"),
    ("FONTSIZE",      (0,0),(-1,-1), 8),
    ("BACKGROUND",    (0,1),(-1,1), C_LTEAL),
    ("GRID",          (0,0),(-1,-1), 0.4, C_MGRAY),
    ("ALIGN",         (0,0),(-1,-1), "CENTER"),
    ("VALIGN",        (0,0),(-1,-1), "MIDDLE"),
    ("TOPPADDING",    (0,0),(-1,-1), 5),
    ("BOTTOMPADDING", (0,0),(-1,-1), 5),
]))
story.append(chain_tbl)
story.append(colored_box([
    Paragraph("πŸ’‘ NCLEX TIP: Hand hygiene breaks the <b>Mode of Transmission</b>. Covering a cough breaks the <b>Portal of Exit</b>. Identify which link each nursing action targets!", S_TIP)
], bg=C_YELLOW, border=C_ORANGE))
story.append(Spacer(1, 0.3*cm))

# ══════════════════════════════════════════════════════════════════════════
# 2. STANDARD PRECAUTIONS
# ══════════════════════════════════════════════════════════════════════════
story.append(section_header("2. STANDARD PRECAUTIONS  (Used with EVERY Patient)", C_GREEN, "πŸ›‘"))
story.append(Spacer(1, 0.15*cm))

sp_data = [
    ["What It Covers", "PPE Required"],
    ["Blood, ALL body fluids (except sweat),\nnon-intact skin, mucous membranes", "Gloves for any contact with blood/body fluids\nMask + goggles if splash/spray risk\nGown if clothing contamination risk"],
]
sp_tbl = Table(sp_data, colWidths=[W*0.45, W*0.55])
sp_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0),(-1,0), C_GREEN),
    ("TEXTCOLOR",     (0,0),(-1,0), C_WHITE),
    ("FONTNAME",      (0,0),(-1,0), "Helvetica-Bold"),
    ("FONTSIZE",      (0,0),(-1,-1), 8.5),
    ("BACKGROUND",    (0,1),(-1,1), C_LGREEN),
    ("GRID",          (0,0),(-1,-1), 0.4, C_MGRAY),
    ("VALIGN",        (0,0),(-1,-1), "MIDDLE"),
    ("TOPPADDING",    (0,0),(-1,-1), 6),
    ("BOTTOMPADDING", (0,0),(-1,-1), 6),
    ("LEFTPADDING",   (0,0),(-1,-1), 6),
]))
story.append(sp_tbl)
story.append(colored_box([
    Paragraph("⭐ Hand hygiene is the SINGLE MOST EFFECTIVE infection control measure!", S_TIP)
], bg=C_LGREEN, border=C_GREEN))
story.append(Spacer(1, 0.3*cm))

# ══════════════════════════════════════════════════════════════════════════
# 3. TRANSMISSION-BASED PRECAUTIONS
# ══════════════════════════════════════════════════════════════════════════
story.append(section_header("3. TRANSMISSION-BASED PRECAUTIONS", C_RED, "⚠"))
story.append(Spacer(1, 0.15*cm))

# AIRBORNE
ab_hdr = Table([[Paragraph("✈  AIRBORNE PRECAUTIONS  (Particles < 5 microns)", S_H1)]],
               colWidths=[W])
ab_hdr.setStyle(TableStyle([
    ("BACKGROUND",(0,0),(-1,-1), C_RED),
    ("TOPPADDING",(0,0),(-1,-1),5), ("BOTTOMPADDING",(0,0),(-1,-1),5),
    ("LEFTPADDING",(0,0),(-1,-1),8),
]))
story.append(ab_hdr)

ab_rows = [
    ["PPE", "N95 Respirator (fit-tested), Gown, Gloves"],
    ["Room", "NEGATIVE PRESSURE room - door must stay CLOSED"],
    ["Diseases", "Measles | Tuberculosis (TB) | Varicella (Chickenpox) | Herpes Zoster (disseminated)"],
    ["Memory Trick", '"My TV Has Airtime" - Measles, TB, Varicella, Herpes Zoster'],
]
ab_tbl = Table(ab_rows, colWidths=[W*0.22, W*0.78])
ab_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0),(0,-1), C_LRED),
    ("FONTNAME",      (0,0),(0,-1), "Helvetica-Bold"),
    ("FONTSIZE",      (0,0),(-1,-1), 8.5),
    ("ROWBACKGROUNDS",(1,0),(1,-1), [C_WHITE, C_LGRAY, C_WHITE, C_LGRAY]),
    ("GRID",          (0,0),(-1,-1), 0.4, C_MGRAY),
    ("VALIGN",        (0,0),(-1,-1), "MIDDLE"),
    ("TOPPADDING",    (0,0),(-1,-1), 5),
    ("BOTTOMPADDING", (0,0),(-1,-1), 5),
    ("LEFTPADDING",   (0,0),(-1,-1), 6),
]))
story.append(ab_tbl)
story.append(Spacer(1, 0.2*cm))

# DROPLET
dr_hdr = Table([[Paragraph("πŸ’§  DROPLET PRECAUTIONS  (Particles > 5 microns, travel < 3 ft)", S_H1)]],
               colWidths=[W])
dr_hdr.setStyle(TableStyle([
    ("BACKGROUND",(0,0),(-1,-1), C_LBLUE),
    ("TOPPADDING",(0,0),(-1,-1),5), ("BOTTOMPADDING",(0,0),(-1,-1),5),
    ("LEFTPADDING",(0,0),(-1,-1),8),
]))
story.append(dr_hdr)

dr_rows = [
    ["PPE", "Surgical Mask, Gown, Gloves"],
    ["Room", "Private room preferred - door CLOSED"],
    ["Diseases", "Influenza | Meningitis (bacterial) | Mumps | Rubella | Pertussis | Diphtheria | COVID-19 | Strep pharyngitis"],
    ["Memory Trick", '"SPIDERMAN" - Sepsis, Pertussis, Influenza, Diphtheria, Epiglottitis, Rubella, Meningitis, Adenovirus, Norovirus'],
]
dr_tbl = Table(dr_rows, colWidths=[W*0.22, W*0.78])
dr_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0),(0,-1), colors.HexColor("#E3F2FD")),
    ("FONTNAME",      (0,0),(0,-1), "Helvetica-Bold"),
    ("FONTSIZE",      (0,0),(-1,-1), 8.5),
    ("ROWBACKGROUNDS",(1,0),(1,-1), [C_WHITE, C_LGRAY, C_WHITE, C_LGRAY]),
    ("GRID",          (0,0),(-1,-1), 0.4, C_MGRAY),
    ("VALIGN",        (0,0),(-1,-1), "MIDDLE"),
    ("TOPPADDING",    (0,0),(-1,-1), 5),
    ("BOTTOMPADDING", (0,0),(-1,-1), 5),
    ("LEFTPADDING",   (0,0),(-1,-1), 6),
]))
story.append(dr_tbl)
story.append(Spacer(1, 0.2*cm))

# CONTACT
ct_hdr = Table([[Paragraph("🀝  CONTACT PRECAUTIONS  (Direct or indirect touch)", S_H1)]],
               colWidths=[W])
ct_hdr.setStyle(TableStyle([
    ("BACKGROUND",(0,0),(-1,-1), C_ORANGE),
    ("TOPPADDING",(0,0),(-1,-1),5), ("BOTTOMPADDING",(0,0),(-1,-1),5),
    ("LEFTPADDING",(0,0),(-1,-1),8),
]))
story.append(ct_hdr)

ct_rows = [
    ["PPE", "Gloves + Gown (don BEFORE entering room)"],
    ["Room", "Private room - dedicated equipment (no sharing)"],
    ["Diseases", "MRSA | VRE | C. difficile | RSV | Scabies | Impetigo | Wound infections | Lice | Herpes simplex"],
    ["Special Rule", "C. diff: Use SOAP & WATER only - alcohol hand sanitizer does NOT kill spores!"],
]
ct_tbl = Table(ct_rows, colWidths=[W*0.22, W*0.78])
ct_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0),(0,-1), C_LORANGE),
    ("FONTNAME",      (0,0),(0,-1), "Helvetica-Bold"),
    ("FONTSIZE",      (0,0),(-1,-1), 8.5),
    ("ROWBACKGROUNDS",(1,0),(1,-1), [C_WHITE, C_LGRAY, C_WHITE, C_LGRAY]),
    ("BACKGROUND",    (1,3),(-1,3), C_LRED),
    ("GRID",          (0,0),(-1,-1), 0.4, C_MGRAY),
    ("VALIGN",        (0,0),(-1,-1), "MIDDLE"),
    ("TOPPADDING",    (0,0),(-1,-1), 5),
    ("BOTTOMPADDING", (0,0),(-1,-1), 5),
    ("LEFTPADDING",   (0,0),(-1,-1), 6),
]))
story.append(ct_tbl)
story.append(Spacer(1, 0.3*cm))

# ══════════════════════════════════════════════════════════════════════════
# 4. PPE DONNING & DOFFING
# ══════════════════════════════════════════════════════════════════════════
story.append(section_header("4. PPE β€” DONNING & DOFFING ORDER", C_PURPLE, "πŸ₯Ό"))
story.append(Spacer(1, 0.15*cm))

ppe_data = [
    ["Step", "🟒 DONNING (Putting ON)", "Step", "πŸ”΄ DOFFING (Taking OFF)"],
    ["1", "GOWN (first)", "1", "GLOVES (most contaminated β€” first)"],
    ["2", "MASK / N95 Respirator", "2", "GOGGLES / Face Shield"],
    ["3", "GOGGLES / Face Shield", "3", "GOWN"],
    ["4", "GLOVES (last β€” over gown cuffs)", "4", "MASK / Respirator (last)"],
    ["", "", "βœ‹", "Hand hygiene after EACH step!"],
]
ppe_tbl = Table(ppe_data, colWidths=[W*0.07, W*0.38, W*0.07, W*0.48])
ppe_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0),(-1,0), C_PURPLE),
    ("TEXTCOLOR",     (0,0),(-1,0), C_WHITE),
    ("FONTNAME",      (0,0),(-1,0), "Helvetica-Bold"),
    ("FONTSIZE",      (0,0),(-1,-1), 8.5),
    ("BACKGROUND",    (0,1),(1,-1), colors.HexColor("#F0FFF0")),
    ("BACKGROUND",    (2,1),(3,-1), colors.HexColor("#FFF0F0")),
    ("BACKGROUND",    (2,5),(3,5), C_LRED),
    ("GRID",          (0,0),(-1,-1), 0.4, C_MGRAY),
    ("VALIGN",        (0,0),(-1,-1), "MIDDLE"),
    ("ALIGN",         (0,0),(0,-1), "CENTER"),
    ("ALIGN",         (2,0),(2,-1), "CENTER"),
    ("FONTNAME",      (0,1),(0,-1), "Helvetica-Bold"),
    ("FONTNAME",      (2,1),(2,-1), "Helvetica-Bold"),
    ("TOPPADDING",    (0,0),(-1,-1), 5),
    ("BOTTOMPADDING", (0,0),(-1,-1), 5),
    ("LEFTPADDING",   (0,0),(-1,-1), 6),
]))
story.append(ppe_tbl)
story.append(colored_box([
    Paragraph('πŸ’œ Memory: <b>DONNING</b> = "Go Make Good Gloves" (Gown, Mask, Goggles, Gloves)', S_MEMO),
    Paragraph('πŸ’œ Memory: <b>DOFFING</b> = Gloves first (most dirty) β†’ Mask last (cleanest)', S_MEMO),
], bg=C_LPURPLE, border=C_PURPLE))
story.append(Spacer(1, 0.3*cm))

# ══════════════════════════════════════════════════════════════════════════
# 5. HAND HYGIENE
# ══════════════════════════════════════════════════════════════════════════
story.append(section_header("5. HAND HYGIENE", C_TEAL, "πŸ™Œ"))
story.append(Spacer(1, 0.15*cm))

hh_rows = [
    ["Situation", "Method"],
    ["Routine patient care", "Alcohol-Based Hand Rub (ABHR) OR soap & water"],
    ["Before eating", "Soap and water only"],
    ["After using restroom", "Soap and water only"],
    ["C. difficile patient", "SOAP AND WATER ONLY (alcohol does NOT kill spores)"],
    ["Visibly soiled hands", "Soap and water only"],
]
hh_tbl = Table(hh_rows, colWidths=[W*0.45, W*0.55])
hh_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0),(-1,0), C_TEAL),
    ("TEXTCOLOR",     (0,0),(-1,0), C_WHITE),
    ("FONTNAME",      (0,0),(-1,0), "Helvetica-Bold"),
    ("FONTSIZE",      (0,0),(-1,-1), 8.5),
    ("ROWBACKGROUNDS",(0,1),(-1,-1), [C_WHITE, C_LTEAL]),
    ("BACKGROUND",    (0,4),(-1,4), C_LRED),
    ("GRID",          (0,0),(-1,-1), 0.4, C_MGRAY),
    ("VALIGN",        (0,0),(-1,-1), "MIDDLE"),
    ("TOPPADDING",    (0,0),(-1,-1), 5),
    ("BOTTOMPADDING", (0,0),(-1,-1), 5),
    ("LEFTPADDING",   (0,0),(-1,-1), 6),
]))
story.append(hh_tbl)
story.append(colored_box([
    Paragraph("Steps: Wet β†’ Apply soap β†’ Scrub <b>20 seconds</b> (sing Happy Birthday twice) β†’ Rinse β†’ Dry β†’ Turn off faucet with paper towel", S_BODY)
], bg=C_LTEAL, border=C_TEAL))
story.append(Spacer(1, 0.3*cm))

# ══════════════════════════════════════════════════════════════════════════
# 6. DISEASE QUICK REFERENCE TABLE
# ══════════════════════════════════════════════════════════════════════════
story.append(section_header("6. DISEASE β†’ PRECAUTION QUICK REFERENCE", C_NAVY, "πŸ“‹"))
story.append(Spacer(1, 0.15*cm))

disease_rows = [
    ["Disease/Condition",       "Precaution Type",    "Key Notes"],
    ["Tuberculosis (TB)",       "AIRBORNE",           "N95, negative pressure room"],
    ["Measles",                 "AIRBORNE",           "N95, negative pressure room"],
    ["Varicella (Chickenpox)",  "AIRBORNE + CONTACT", "N95 + gown + gloves"],
    ["Herpes Zoster (dissem.)", "AIRBORNE + CONTACT", "Localized = Standard only"],
    ["Influenza",               "DROPLET",            "Surgical mask"],
    ["COVID-19",                "DROPLET + CONTACT",  "Mask + gown + gloves"],
    ["Bacterial Meningitis",    "DROPLET",            "Until 24 hrs on antibiotics"],
    ["Mumps / Rubella",         "DROPLET",            "Surgical mask"],
    ["Pertussis",               "DROPLET",            "Until 5 days on antibiotics"],
    ["MRSA",                    "CONTACT",            "Gown + gloves; dedicated equipment"],
    ["VRE",                     "CONTACT",            "Gown + gloves; dedicated equipment"],
    ["C. difficile",            "CONTACT",            "SOAP & WATER only for hand hygiene!"],
    ["RSV",                     "CONTACT",            "Gown + gloves"],
    ["Scabies / Lice",          "CONTACT",            "Gown + gloves"],
    ["HIV / AIDS",              "STANDARD",           "No isolation unless other infection"],
    ["Hepatitis B / C",         "STANDARD",           "No isolation unless other infection"],
    ["Pneumonia (community)",   "STANDARD",           "No isolation"],
]

col_w = [W*0.38, W*0.26, W*0.36]
d_data = [[Paragraph(h, S_HDRCELL) for h in disease_rows[0]]]
for row in disease_rows[1:]:
    prec = row[1]
    if "AIRBORNE" in prec:
        bg = C_LRED
    elif "DROPLET" in prec:
        bg = colors.HexColor("#E3F2FD")
    elif "CONTACT" in prec:
        bg = C_LORANGE
    else:
        bg = C_LGREEN
    d_data.append([Paragraph(row[0], S_CELL), Paragraph(f"<b>{row[1]}</b>", S_CELLB), Paragraph(row[2], S_CELL)])

d_tbl = Table(d_data, colWidths=col_w)
ts = TableStyle([
    ("BACKGROUND",    (0,0),(-1,0), C_NAVY),
    ("GRID",          (0,0),(-1,-1), 0.4, C_MGRAY),
    ("VALIGN",        (0,0),(-1,-1), "MIDDLE"),
    ("TOPPADDING",    (0,0),(-1,-1), 4),
    ("BOTTOMPADDING", (0,0),(-1,-1), 4),
    ("LEFTPADDING",   (0,0),(-1,-1), 6),
])
for i, row in enumerate(disease_rows[1:], 1):
    prec = row[1]
    if "AIRBORNE" in prec:
        bg = C_LRED
    elif "DROPLET" in prec:
        bg = colors.HexColor("#E3F2FD")
    elif "CONTACT" in prec:
        bg = C_LORANGE
    else:
        bg = C_LGREEN
    ts.add("BACKGROUND", (1,i), (1,i), bg)
d_tbl.setStyle(ts)
story.append(d_tbl)
story.append(Spacer(1, 0.3*cm))

# ══════════════════════════════════════════════════════════════════════════
# 7. MEDICAL vs SURGICAL ASEPSIS
# ══════════════════════════════════════════════════════════════════════════
story.append(section_header("7. MEDICAL vs SURGICAL ASEPSIS", C_GREEN, "🧀"))
story.append(Spacer(1, 0.15*cm))

asep_rows = [
    ["", "Medical Asepsis (Clean)", "Surgical Asepsis (Sterile)"],
    ["Goal",     "Reduce microorganisms",          "Eliminate ALL microorganisms"],
    ["Used For", "Routine care, oral meds, bathing","Wound care, surgery, catheters, IV insertion"],
    ["Examples", "Hand washing, PPE, isolation",   "Sterile gloves, sterile dressing changes, ORs"],
]
asep_tbl = Table(asep_rows, colWidths=[W*0.18, W*0.41, W*0.41])
asep_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0),(-1,0), C_GREEN),
    ("TEXTCOLOR",     (0,0),(-1,0), C_WHITE),
    ("FONTNAME",      (0,0),(-1,0), "Helvetica-Bold"),
    ("BACKGROUND",    (0,0),(0,-1), colors.HexColor("#E8F5E9")),
    ("FONTNAME",      (0,0),(0,-1), "Helvetica-Bold"),
    ("FONTSIZE",      (0,0),(-1,-1), 8.5),
    ("ROWBACKGROUNDS",(0,1),(-1,-1), [C_WHITE, C_LGRAY, C_WHITE]),
    ("GRID",          (0,0),(-1,-1), 0.4, C_MGRAY),
    ("VALIGN",        (0,0),(-1,-1), "MIDDLE"),
    ("TOPPADDING",    (0,0),(-1,-1), 5),
    ("BOTTOMPADDING", (0,0),(-1,-1), 5),
    ("LEFTPADDING",   (0,0),(-1,-1), 6),
]))
story.append(asep_tbl)
story.append(colored_box([
    Paragraph("<b>Sterile Field Rules:</b> Sterile-to-sterile only  |  1-inch border = contaminated  |  Below waist = contaminated  |  Moisture = contaminated  |  If in doubt β€” throw it out!", S_BODY)
], bg=C_LGREEN, border=C_GREEN))
story.append(Spacer(1, 0.3*cm))

# ══════════════════════════════════════════════════════════════════════════
# 8. HAI PREVENTION BUNDLES
# ══════════════════════════════════════════════════════════════════════════
story.append(section_header("8. HAI PREVENTION BUNDLES", C_LBLUE, "πŸ₯"))
story.append(Spacer(1, 0.15*cm))

hai_data = [
    ["CAUTI\n(Catheter UTI)", "CLABSI\n(Central Line)", "VAP\n(Ventilator)", "SSI\n(Surgical Site)"],
    [
        "β€’ Maintain closed drainage\nβ€’ Bag BELOW bladder\nβ€’ Never on floor\nβ€’ Perineal care daily\nβ€’ Remove ASAP\nβ€’ Do NOT clamp tubing",
        "β€’ Max sterile barrier on insertion\nβ€’ Chlorhexidine skin prep\nβ€’ Change dressing q5-7 days\nβ€’ Daily necessity assessment",
        "β€’ HOB 30-45 degrees\nβ€’ Oral care q2-4h (chlorhexidine)\nβ€’ Daily sedation vacations\nβ€’ Hand hygiene before circuit",
        "β€’ Clip (don't shave) hair\nβ€’ Antibiotics 1h before incision\nβ€’ Maintain normothermia\nβ€’ Blood glucose control post-op"
    ],
]
hai_tbl = Table(hai_data, colWidths=[W*0.25]*4)
hai_tbl.setStyle(TableStyle([
    ("BACKGROUND",    (0,0),(-1,0), C_LBLUE),
    ("TEXTCOLOR",     (0,0),(-1,0), C_WHITE),
    ("FONTNAME",      (0,0),(-1,0), "Helvetica-Bold"),
    ("FONTSIZE",      (0,0),(-1,-1), 8),
    ("BACKGROUND",    (0,1),(-1,1), colors.HexColor("#E3F2FD")),
    ("GRID",          (0,0),(-1,-1), 0.4, C_MGRAY),
    ("VALIGN",        (0,0),(-1,-1), "TOP"),
    ("ALIGN",         (0,0),(-1,0), "CENTER"),
    ("TOPPADDING",    (0,0),(-1,-1), 5),
    ("BOTTOMPADDING", (0,0),(-1,-1), 5),
    ("LEFTPADDING",   (0,0),(-1,-1), 6),
]))
story.append(hai_tbl)
story.append(Spacer(1, 0.3*cm))

# ══════════════════════════════════════════════════════════════════════════
# 9. PROTECTIVE / NEUTROPENIC PRECAUTIONS
# ══════════════════════════════════════════════════════════════════════════
story.append(section_header("9. PROTECTIVE / NEUTROPENIC PRECAUTIONS (Reverse Isolation)", C_PURPLE, "πŸ”΅"))
story.append(Spacer(1, 0.15*cm))

np_items = [
    "Used for: Immunocompromised patients (chemotherapy, organ transplant, severe neutropenia)",
    "Room: POSITIVE pressure (air flows OUT - keeps pathogens away from patient)",
    "Wear a mask when entering the room",
    "No fresh flowers or live plants (harbor bacteria and fungi)",
    "No raw fruits or vegetables β€” cooked/processed foods only",
    "Screen all visitors for signs of illness before allowing entry",
    "Strict hand hygiene by all staff and visitors",
]
np_tbl = Table([[Paragraph("β€’ " + item, S_BODY)] for item in np_items], colWidths=[W])
np_tbl.setStyle(TableStyle([
    ("ROWBACKGROUNDS", (0,0),(-1,-1), [C_LPURPLE, C_WHITE]),
    ("GRID",           (0,0),(-1,-1), 0.3, C_MGRAY),
    ("TOPPADDING",     (0,0),(-1,-1), 4),
    ("BOTTOMPADDING",  (0,0),(-1,-1), 4),
    ("LEFTPADDING",    (0,0),(-1,-1), 8),
]))
story.append(np_tbl)
story.append(Spacer(1, 0.3*cm))

# ══════════════════════════════════════════════════════════════════════════
# 10. TOP NCLEX TIPS
# ══════════════════════════════════════════════════════════════════════════
story.append(section_header("10. TOP NCLEX EXAM TIPS", C_RED, "⭐"))
story.append(Spacer(1, 0.15*cm))

tips = [
    ("N95 for airborne ONLY", "A surgical mask is NOT enough for TB, measles, or varicella."),
    ("Gloves off FIRST", "When doffing PPE, gloves come off first (most contaminated)."),
    ("Soap & water for C. diff", "Alcohol-based sanitizer does NOT kill C. diff spores."),
    ("Negative vs. Positive pressure", "Airborne = Negative pressure | Neutropenic = Positive pressure"),
    ("Never recap needles", "Use safety devices and sharps containers immediately after use."),
    ("Assess before isolating", "Initiate precautions early when infection is suspected, don't wait for confirmation."),
    ("Dedicated equipment", "Contact precautions require dedicated BP cuff, stethoscope, thermometer."),
    ("Remove mask last", "Mask is the last item removed when doffing β€” it protects your face."),
]
tips_tbl = Table(
    [[Paragraph(f"βœ…  {t}", S_TIP), Paragraph(d, S_BODY)] for t, d in tips],
    colWidths=[W*0.35, W*0.65]
)
tips_tbl.setStyle(TableStyle([
    ("ROWBACKGROUNDS", (0,0),(-1,-1), [C_LRED, C_WHITE]),
    ("GRID",           (0,0),(-1,-1), 0.3, C_MGRAY),
    ("VALIGN",         (0,0),(-1,-1), "MIDDLE"),
    ("TOPPADDING",     (0,0),(-1,-1), 5),
    ("BOTTOMPADDING",  (0,0),(-1,-1), 5),
    ("LEFTPADDING",    (0,0),(-1,-1), 6),
]))
story.append(tips_tbl)
story.append(Spacer(1, 0.3*cm))

# ── Footer ───────────────────────────────────────────────────────────────
story.append(HRFlowable(width=W, color=C_MGRAY))
story.append(Spacer(1, 0.1*cm))
story.append(Paragraph(
    "NCLEX-RN Infection Control Quick Reference  |  Prepared for NCLEX-RN Exam Preparation  |  July 2026",
    style("footer", fontSize=7.5, textColor=C_MGRAY, alignment=TA_CENTER)
))

# ── Build ────────────────────────────────────────────────────────────────
doc.build(story)
print("PDF created:", OUTPUT)
Running Command

cd /home/daytona/workspace/nclex-pdf && python create_pdf.py

Your PDF is ready! πŸŽ‰

Infection Control NCLEX QuickRef

PDF Document Β· PDF


Here's what's included in the PDF:
SectionContent
πŸ”— Chain of InfectionAll 6 links with nursing interventions
πŸ›‘ Standard PrecautionsWhat they cover + PPE guide
⚠ Transmission-Based PrecautionsAirborne, Droplet, Contact - color-coded with memory tricks
πŸ₯Ό PPE Donning & DoffingStep-by-step order table
πŸ™Œ Hand HygieneWhen to use soap vs. sanitizer
πŸ“‹ Disease Quick Reference17 diseases mapped to precaution type
🧀 Medical vs Surgical AsepsisComparison + sterile field rules
πŸ₯ HAI Prevention BundlesCAUTI, CLABSI, VAP, SSI
πŸ”΅ Neutropenic PrecautionsReverse isolation rules
⭐ Top NCLEX Tips8 high-yield exam reminders

Would you like me to create a similar quick-reference PDF for another NCLEX topic - like Fluids & Electrolytes, Medications, or Vital Signs? πŸ“š

Wow thats Soo amezing

Thank you! Glad you love it! 😊
I can make quick-reference PDFs for any NCLEX topic you need. Here are some popular ones:

πŸ“„ Suggested PDFs I can create for you:
TopicWhat's Inside
πŸ’Š Fluids & ElectrolytesHypo/hyperkalemia, IV fluids, signs & symptoms
🩺 Vital SignsNormal ranges, abnormal findings, nursing actions
πŸ’‰ Medications (High-Alert)Insulin, heparin, digoxin, potassium rules
🧠 Maslow + Nursing ProcessPriority setting, ADPIE, delegation rules
πŸ«€ Cardiac BasicsHeart rhythms, MI signs, medications
🀰 Maternity / OBLabor stages, fetal monitoring, postpartum care
πŸ‘Ά PediatricsGrowth milestones, common illnesses, immunizations
🧬 Lab ValuesComplete reference with normal ranges + significance

Just say which topic you want next and I'll build it for you right away! πŸš€

Electrolytes pdf proper explain woth memory tricks

Writing File

~/nclex-pdf/create_electrolytes_pdf.py

from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import cm
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    HRFlowable, PageBreak
)
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.enums import TA_CENTER, TA_LEFT

OUTPUT = "/home/daytona/workspace/nclex-pdf/Electrolytes_NCLEX_QuickRef.pdf"

# ── Colors ─────────────────────────────────────────────────────────────
C_NAVY    = colors.HexColor("#0D1B2A")
C_BLUE    = colors.HexColor("#1565C0")
C_LBLUE   = colors.HexColor("#1E88E5")
C_ELBLUE  = colors.HexColor("#E3F2FD")
C_GREEN   = colors.HexColor("#2E7D32")
C_LGREEN  = colors.HexColor("#E8F5E9")
C_RED     = colors.HexColor("#C62828")
C_LRED    = colors.HexColor("#FFEBEE")
C_ORANGE  = colors.HexColor("#E65100")
C_LORANGE = colors.HexColor("#FFF3E0")
C_PURPLE  = colors.HexColor("#6A1B9A")
C_LPURPLE = colors.HexColor("#F3E5F5")
C_TEAL    = colors.HexColor("#00695C")
C_LTEAL   = colors.HexColor("#E0F2F1")
C_YELLOW  = colors.HexColor("#FFF9C4")
C_DYELLOW = colors.HexColor("#F9A825")
C_LGRAY   = colors.HexColor("#F5F5F5")
C_MGRAY   = colors.HexColor("#BDBDBD")
C_WHITE   = colors.white
C_PINK    = colors.HexColor("#FCE4EC")
C_DPINK   = colors.HexColor("#AD1457")
C_BROWN   = colors.HexColor("#4E342E")
C_LBROWN  = colors.HexColor("#EFEBE9")
C_INDIGO  = colors.HexColor("#283593")
C_LINDIGO = colors.HexColor("#E8EAF6")

doc = SimpleDocTemplate(
    OUTPUT, pagesize=A4,
    rightMargin=1.4*cm, leftMargin=1.4*cm,
    topMargin=1.4*cm,   bottomMargin=1.4*cm
)
W = A4[0] - 2.8*cm

styles = getSampleStyleSheet()

def S(name, **kw):
    return ParagraphStyle(name, parent=styles["Normal"], **kw)

S_TITLE  = S("t",  fontSize=22, textColor=C_WHITE, alignment=TA_CENTER, fontName="Helvetica-Bold", leading=28)
S_SUB    = S("s",  fontSize=10, textColor=colors.HexColor("#B3E5FC"), alignment=TA_CENTER, fontName="Helvetica", leading=14)
S_H1     = S("h1", fontSize=12, textColor=C_WHITE, fontName="Helvetica-Bold", leading=16, leftIndent=6)
S_H2     = S("h2", fontSize=10, textColor=C_NAVY,  fontName="Helvetica-Bold", leading=14)
S_BODY   = S("b",  fontSize=8.5,textColor=C_NAVY,  fontName="Helvetica", leading=12)
S_BOLD   = S("bb", fontSize=8.5,textColor=C_NAVY,  fontName="Helvetica-Bold", leading=12)
S_TRICK  = S("tr", fontSize=9,  textColor=C_PURPLE, fontName="Helvetica-BoldOblique", leading=13, leftIndent=4)
S_WARN   = S("w",  fontSize=9,  textColor=C_RED,    fontName="Helvetica-Bold", leading=13, leftIndent=4)
S_TIP    = S("tp", fontSize=9,  textColor=C_GREEN,  fontName="Helvetica-Bold", leading=13, leftIndent=4)
S_HDR    = S("hd", fontSize=9,  textColor=C_WHITE,  fontName="Helvetica-Bold", alignment=TA_CENTER, leading=12)
S_CELL   = S("c",  fontSize=8.5,textColor=C_NAVY,   fontName="Helvetica", leading=12)
S_CELLB  = S("cb", fontSize=8.5,textColor=C_NAVY,   fontName="Helvetica-Bold", leading=12)
S_CTR    = S("ct", fontSize=8.5,textColor=C_NAVY,   fontName="Helvetica", alignment=TA_CENTER, leading=12)
S_FOOTER = S("f",  fontSize=7.5,textColor=C_MGRAY,  fontName="Helvetica", alignment=TA_CENTER)

def sec_hdr(text, bg=C_BLUE):
    t = Table([[Paragraph(text, S_H1)]], colWidths=[W])
    t.setStyle(TableStyle([
        ("BACKGROUND",(0,0),(-1,-1), bg),
        ("TOPPADDING",(0,0),(-1,-1),6), ("BOTTOMPADDING",(0,0),(-1,-1),6),
        ("LEFTPADDING",(0,0),(-1,-1),10),
    ]))
    return t

def box(items, bg=C_LGRAY, border=C_MGRAY):
    if not isinstance(items, list): items = [items]
    t = Table([[items]], colWidths=[W])
    t.setStyle(TableStyle([
        ("BACKGROUND",(0,0),(-1,-1), bg),
        ("BOX",(0,0),(-1,-1),0.8,border),
        ("TOPPADDING",(0,0),(-1,-1),5), ("BOTTOMPADDING",(0,0),(-1,-1),5),
        ("LEFTPADDING",(0,0),(-1,-1),8), ("RIGHTPADDING",(0,0),(-1,-1),8),
    ]))
    return t

def two_col(left_items, right_items, lbg=C_LRED, rbg=C_LGREEN, lborder=C_RED, rborder=C_GREEN):
    lw, rw = W*0.495, W*0.495
    lt = Table([[left_items]],  colWidths=[lw])
    rt = Table([[right_items]], colWidths=[rw])
    lt.setStyle(TableStyle([("BACKGROUND",(0,0),(-1,-1),lbg),("BOX",(0,0),(-1,-1),0.8,lborder),
                             ("TOPPADDING",(0,0),(-1,-1),5),("BOTTOMPADDING",(0,0),(-1,-1),5),
                             ("LEFTPADDING",(0,0),(-1,-1),7)]))
    rt.setStyle(TableStyle([("BACKGROUND",(0,0),(-1,-1),rbg),("BOX",(0,0),(-1,-1),0.8,rborder),
                             ("TOPPADDING",(0,0),(-1,-1),5),("BOTTOMPADDING",(0,0),(-1,-1),5),
                             ("LEFTPADDING",(0,0),(-1,-1),7)]))
    outer = Table([[lt, Spacer(W*0.01,1), rt]], colWidths=[lw, W*0.01, rw])
    outer.setStyle(TableStyle([("VALIGN",(0,0),(-1,-1),"TOP")]))
    return outer

def elec_block(name, normal, fun, hypo_name, hypo_causes, hypo_sx, hypo_tx,
               hyper_name, hyper_causes, hyper_sx, hyper_tx,
               memory, nclex_tips, accent):
    story = []
    # Header
    hdr = Table([[Paragraph(f"⚑  {name}   |   Normal: {normal}", S_H1)]], colWidths=[W])
    hdr.setStyle(TableStyle([("BACKGROUND",(0,0),(-1,-1),accent),
                              ("TOPPADDING",(0,0),(-1,-1),7),("BOTTOMPADDING",(0,0),(-1,-1),7),
                              ("LEFTPADDING",(0,0),(-1,-1),10)]))
    story.append(hdr)

    # Function box
    story.append(box([Paragraph(f"<b>Function:</b> {fun}", S_BODY)], bg=C_LGRAY, border=accent))

    # Memory trick
    story.append(box([Paragraph(f"🧠 Memory Trick:  {memory}", S_TRICK)], bg=C_LPURPLE, border=C_PURPLE))

    # Hypo vs Hyper side by side
    def make_side(title, causes, sx, tx, bg, border, title_bg):
        hdr_t = Table([[Paragraph(title, S_H1)]], colWidths=[W*0.495])
        hdr_t.setStyle(TableStyle([("BACKGROUND",(0,0),(-1,-1),title_bg),
                                    ("TOPPADDING",(0,0),(-1,-1),4),("BOTTOMPADDING",(0,0),(-1,-1),4),
                                    ("LEFTPADDING",(0,0),(-1,-1),6)]))
        rows = [
            [Paragraph("<b>Causes:</b>", S_BOLD)],
        ]
        for c in causes:
            rows.append([Paragraph(f"  β€’ {c}", S_CELL)])
        rows.append([Paragraph("<b>Signs & Symptoms:</b>", S_BOLD)])
        for s in sx:
            rows.append([Paragraph(f"  β€’ {s}", S_CELL)])
        rows.append([Paragraph("<b>Nursing Interventions:</b>", S_BOLD)])
        for t in tx:
            rows.append([Paragraph(f"  β€’ {t}", S_CELL)])
        content_tbl = Table(rows, colWidths=[W*0.495])
        content_tbl.setStyle(TableStyle([
            ("BACKGROUND",(0,0),(-1,-1),bg),
            ("ROWBACKGROUNDS",(0,0),(-1,-1),[bg, colors.HexColor(bg.hexval().replace("#","#")+"10") if hasattr(bg,"hexval") else bg]),
            ("TOPPADDING",(0,0),(-1,-1),3),("BOTTOMPADDING",(0,0),(-1,-1),3),
            ("LEFTPADDING",(0,0),(-1,-1),6),
        ]))
        return [hdr_t, content_tbl]

    left_items  = make_side(hypo_name,  hypo_causes,  hypo_sx,  hypo_tx,  C_LRED,    C_RED,   C_RED)
    right_items = make_side(hyper_name, hyper_causes, hyper_sx, hyper_tx, C_LGREEN, C_GREEN, C_GREEN)

    lw = rw = W*0.495
    combo = Table([[left_items, Spacer(W*0.01,1), right_items]], colWidths=[lw, W*0.01, rw])
    combo.setStyle(TableStyle([("VALIGN",(0,0),(-1,-1),"TOP")]))
    story.append(combo)

    # NCLEX tips
    tip_rows = [[Paragraph(f"βœ…  {t}", S_TIP)] for t in nclex_tips]
    tip_tbl = Table(tip_rows, colWidths=[W])
    tip_tbl.setStyle(TableStyle([
        ("ROWBACKGROUNDS",(0,0),(-1,-1),[C_LGREEN, C_WHITE]),
        ("GRID",(0,0),(-1,-1),0.3,C_MGRAY),
        ("TOPPADDING",(0,0),(-1,-1),4),("BOTTOMPADDING",(0,0),(-1,-1),4),
        ("LEFTPADDING",(0,0),(-1,-1),6),
    ]))
    story.append(tip_tbl)
    story.append(Spacer(1, 0.3*cm))
    return story

story = []

# ══════ TITLE ══════════════════════════════════════════════════════════
title_tbl = Table([
    [Paragraph("⚑ ELECTROLYTES", S_TITLE)],
    [Paragraph("NCLEX-RN Complete Quick Reference", S_SUB)],
    [Paragraph("Na β€’ K β€’ Ca β€’ Mg β€’ Phosphorus β€’ Chloride  |  Normal Values β€’ Causes β€’ Signs & Symptoms β€’ Nursing Actions β€’ Memory Tricks", S_SUB)],
], colWidths=[W])
title_tbl.setStyle(TableStyle([
    ("BACKGROUND",(0,0),(-1,-1),C_NAVY),
    ("TOPPADDING",(0,0),(-1,-1),4),("BOTTOMPADDING",(0,0),(-1,-1),4),
    ("LEFTPADDING",(0,0),(-1,-1),10),
    ("ROWBACKGROUNDS",(0,0),(-1,-1),[C_NAVY]),
]))
story.append(title_tbl)
story.append(Spacer(1,0.25*cm))

# ══════ NORMAL VALUES OVERVIEW ══════════════════════════════════════════
story.append(sec_hdr("πŸ“Š  NORMAL ELECTROLYTE VALUES β€” Quick Glance", C_NAVY))
story.append(Spacer(1,0.1*cm))

nv_rows = [
    ["Electrolyte", "Normal Range", "Critical Low", "Critical High", "Primary Function"],
    ["Sodium (Na⁺)",      "135–145 mEq/L", "< 120 mEq/L", "> 160 mEq/L", "Fluid balance, nerve/muscle function"],
    ["Potassium (K⁺)",    "3.5–5.0 mEq/L", "< 2.5 mEq/L", "> 6.5 mEq/L", "Heart rhythm, muscle contraction"],
    ["Calcium (Ca²⁺)",    "8.5–10.5 mg/dL","< 7.0 mg/dL",  "> 13.0 mg/dL","Bone/teeth, clotting, nerve/muscle"],
    ["Magnesium (Mg²⁺)",  "1.5–2.5 mEq/L", "< 1.0 mEq/L",  "> 4.0 mEq/L", "Enzyme reactions, nerve/muscle"],
    ["Phosphorus (PO₄³⁻)","2.5–4.5 mg/dL", "< 1.0 mg/dL",  "> 8.0 mg/dL", "Bone formation, energy (ATP)"],
    ["Chloride (Cl⁻)",    "96–106 mEq/L",  "< 80 mEq/L",   "> 115 mEq/L", "Acid-base balance, fluid balance"],
]
nv_tbl = Table(
    [[Paragraph(c, S_HDR if i==0 else (S_CELLB if j==0 else S_CELL))
      for j,c in enumerate(row)] for i,row in enumerate(nv_rows)],
    colWidths=[W*0.19, W*0.17, W*0.14, W*0.14, W*0.36]
)
nv_tbl.setStyle(TableStyle([
    ("BACKGROUND",(0,0),(-1,0),C_NAVY),
    ("ROWBACKGROUNDS",(0,1),(-1,-1),[C_WHITE, C_LGRAY]),
    ("GRID",(0,0),(-1,-1),0.4,C_MGRAY),
    ("VALIGN",(0,0),(-1,-1),"MIDDLE"),
    ("TOPPADDING",(0,0),(-1,-1),5),("BOTTOMPADDING",(0,0),(-1,-1),5),
    ("LEFTPADDING",(0,0),(-1,-1),5),
]))
story.append(nv_tbl)
story.append(box([Paragraph(
    "🧠 Memory: <b>\"Sally Keeps Calcium Manageable Physically with Chloride\"</b>  β†’  Na, K, Ca, Mg, POβ‚„, Cl", S_TRICK)],
    bg=C_LPURPLE, border=C_PURPLE))
story.append(Spacer(1,0.25*cm))

# ══════════════════════════════════════════════════════════════════════
# SODIUM
# ══════════════════════════════════════════════════════════════════════
story += elec_block(
    name="SODIUM (Na⁺)", normal="135–145 mEq/L",
    fun="Controls fluid balance (where sodium goes, water follows); nerve impulse transmission; blood pressure regulation.",
    hypo_name="πŸ”΅ HYPONATREMIA  (Na⁺ < 135)",
    hypo_causes=["Excessive water intake (SIADH)","Prolonged vomiting/diarrhea","Heart failure, cirrhosis, renal failure","Excessive hypotonic IV fluids","Diuretic use"],
    hypo_sx=["Headache, confusion, lethargy","Nausea & vomiting","Muscle cramps, weakness","Seizures (severe < 120)","Cerebral edema β†’ ↑ ICP"],
    hypo_tx=["Restrict fluid intake","Hypertonic saline (3% NaCl) for severe","Monitor neuro status q1-2h","Correct SLOWLY (risk: osmotic demyelination)","Daily weights, strict I&O"],
    hyper_name="πŸ”΄ HYPERNATREMIA  (Na⁺ > 145)",
    hyper_causes=["Inadequate water intake","Excessive sodium intake","Diabetes insipidus","Watery diarrhea","Excessive sweating"],
    hyper_sx=["Thirst (earliest sign)","Dry sticky mucous membranes","Restlessness, agitation","Decreased LOC (severe)","Seizures, coma (severe)"],
    hyper_tx=["Increase water intake (oral or IV)","Hypotonic IV fluids (0.45% NaCl)","Correct SLOWLY (risk: cerebral edema)","Monitor fluid status, daily weights","Treat underlying cause"],
    memory="πŸ§‚ Sodium = SALT = THIRST. HIGH Na β†’ THIRST (dry), LOW Na β†’ BRAIN SWELLS (neuro sx). Water follows sodium β€” low sodium = water flooding brain!",
    nclex_tips=[
        "Thirst is the EARLIEST sign of hypernatremia",
        "Correct sodium SLOWLY β€” rapid correction of hyponatremia β†’ osmotic demyelination; hypernatremia β†’ cerebral edema",
        "SIADH causes hyponatremia β€” treat with fluid restriction",
        "Seizure precautions for Na⁺ < 120 mEq/L",
    ],
    accent=C_LBLUE
)

# ══════════════════════════════════════════════════════════════════════
# POTASSIUM
# ══════════════════════════════════════════════════════════════════════
story += elec_block(
    name="POTASSIUM (K⁺)", normal="3.5–5.0 mEq/L",
    fun="Maintains resting membrane potential; regulates heart rhythm and muscle contraction; acid-base balance.",
    hypo_name="πŸ”΅ HYPOKALEMIA  (K⁺ < 3.5)",
    hypo_causes=["Diuretics (loop/thiazide β€” #1 cause)","Vomiting, diarrhea, NG suction","Insufficient dietary intake","Alkalosis (K⁺ shifts into cells)","Insulin administration"],
    hypo_sx=["Muscle weakness, fatigue (legs first)","Leg cramps","Constipation, paralytic ileus","Cardiac dysrhythmias (PVCs, V-fib)","ECG: Flat/inverted T-waves, U-waves"],
    hypo_tx=["KCl oral supplement (preferred)","IV KCl β€” NEVER give IV push (fatal!)","Max IV rate: 10–20 mEq/hr","Increase dietary K⁺ (bananas, oranges)","Monitor cardiac rhythm continuously"],
    hyper_name="πŸ”΄ HYPERKALEMIA  (K⁺ > 5.0)",
    hyper_causes=["Renal failure (#1 cause)","Potassium-sparing diuretics","ACE inhibitors","Acidosis (K⁺ shifts out of cells)","Excessive IV potassium","Massive cell destruction (burns, trauma)"],
    hyper_sx=["Muscle weakness, fatigue","Nausea, diarrhea","Peaked (tall) T-waves on ECG","Widened QRS, sine wave pattern","Ventricular fibrillation β†’ cardiac arrest"],
    hyper_tx=["Calcium gluconate (stabilizes heart β€” FIRST)","Sodium bicarbonate (shifts K⁺ into cells)","Insulin + dextrose (shifts K⁺ into cells)","Kayexalate (removes K⁺ from body)","Dialysis (severe/renal failure)","Restrict dietary potassium"],
    memory="πŸ’ͺ K⁺ = MUSCLES & HEART. LOW K = WEAK (muscles), FLAT T-wave, U-wave. HIGH K = PEAKED T-wave β†’ CARDIAC ARREST. Think: Low K = U see a U-wave!",
    nclex_tips=[
        "NEVER give IV potassium as IV push or bolus β€” it is fatal!",
        "Max IV KCl rate: 10–20 mEq/hr, always diluted",
        "Loop diuretics (furosemide) cause hypoKALEMIA β€” give K⁺ supplements",
        "Peaked T-waves = hyperkalemia; Flat T-wave + U-wave = hypokalemia",
        "Calcium gluconate is the FIRST treatment for dangerous hyperkalemia (stabilizes cardiac membrane)",
    ],
    accent=C_GREEN
)

# ══════════════════════════════════════════════════════════════════════
# CALCIUM
# ══════════════════════════════════════════════════════════════════════
story += elec_block(
    name="CALCIUM (Ca²⁺)", normal="8.5–10.5 mg/dL  (Ionized: 4.5–5.1 mg/dL)",
    fun="Bone and teeth formation; muscle contraction and relaxation; blood clotting; nerve transmission.",
    hypo_name="πŸ”΅ HYPOCALCEMIA  (Ca²⁺ < 8.5)",
    hypo_causes=["Hypoparathyroidism (post thyroid/parathyroid surgery)","Vitamin D deficiency","Chronic renal failure","Hypomagnesemia","Alkalosis","Pancreatitis"],
    hypo_sx=["Trousseau's sign (carpopedal spasm with BP cuff)","Chvostek's sign (facial twitch when tapping CN VII)","Tetany, muscle cramps","Numbness/tingling (perioral, fingers, toes)","Seizures","Prolonged QT interval on ECG"],
    hypo_tx=["IV calcium gluconate (emergency)","Oral calcium supplements with Vitamin D","High-calcium diet (dairy, green leafy veggies)","Correct hypomagnesemia","Seizure and safety precautions"],
    hyper_name="πŸ”΄ HYPERCALCEMIA  (Ca²⁺ > 10.5)",
    hyper_causes=["Hyperparathyroidism (#1 cause)","Malignancy (bone metastases)","Prolonged immobility","Excess Vitamin D","Thiazide diuretics","Paget's disease"],
    hyper_sx=["'Bones, Groans, Moans, Psychic Overtones'","Bone pain, fractures","Nausea, vomiting, constipation","Fatigue, muscle weakness","Confusion, depression, psychosis","Kidney stones, polyuria"],
    hyper_tx=["IV normal saline (dilutes calcium β€” FIRST)","Loop diuretics (furosemide) to excrete Ca²⁺","Bisphosphonates (long-term)","Calcitonin","Corticosteroids","Mobilize patient if possible"],
    memory="🦴 Ca = BONES, CLOTS, CONTRACTS. LOW Ca = TWITCHY (Trousseau + Chvostek). HIGH Ca = 'BONES, GROANS, MOANS & PSYCHIC OVERTONES' (bone pain, GI upset, psych sx). TROUSSEAU'S = BP cuff. CHVOSTEK'S = Cheek tap.",
    nclex_tips=[
        "Check Trousseau's: inflate BP cuff 20 mmHg above systolic for 3 min β†’ carpopedal spasm = positive",
        "Check Chvostek's: tap facial nerve in front of ear β†’ facial muscle twitch = positive",
        "Post thyroid surgery: monitor for hypocalcemia (removed/damaged parathyroid glands)",
        "'Bones, Groans, Moans, Psychic Overtones' = classic hypercalcemia mnemonic",
        "First treatment for hypercalcemia = IV Normal Saline (hydration)",
    ],
    accent=C_ORANGE
)

# ══════════════════════════════════════════════════════════════════════
# MAGNESIUM
# ══════════════════════════════════════════════════════════════════════
story += elec_block(
    name="MAGNESIUM (Mg²⁺)", normal="1.5–2.5 mEq/L",
    fun="Enzyme co-factor for 300+ reactions; nerve/muscle function; regulates calcium and potassium levels; cardiac rhythm.",
    hypo_name="πŸ”΅ HYPOMAGNESEMIA  (Mg²⁺ < 1.5)",
    hypo_causes=["Alcoholism (#1 cause)","Prolonged malnutrition/malabsorption","Diarrhea, vomiting, NG suction","Diuretics (loop/thiazide)","Diabetic ketoacidosis (DKA)"],
    hypo_sx=["Tremors, muscle twitching","Hyperreflexia (↑ deep tendon reflexes)","Positive Trousseau's & Chvostek's","Cardiac dysrhythmias (torsades de pointes)","Confusion, agitation","Dysphagia"],
    hypo_tx=["IV magnesium sulfate (MgSOβ‚„) for severe","Oral magnesium supplements (mild)","High-Mg diet (nuts, whole grains, green veggies)","Correct hypokalemia and hypocalcemia (often coexist)","Monitor DTRs during IV replacement"],
    hyper_name="πŸ”΄ HYPERMAGNESEMIA  (Mg²⁺ > 2.5)",
    hyper_causes=["Renal failure (#1 cause)","Excessive Mg antacids or laxatives","Excessive IV magnesium (eclampsia tx)","Adrenal insufficiency"],
    hyper_sx=["Flushing, feeling of warmth","Nausea, vomiting","LOSS of deep tendon reflexes (DTRs) β€” FIRST sign","Hypotension","Respiratory depression","Cardiac arrest (severe)"],
    hyper_tx=["Calcium gluconate (antidote β€” antagonizes Mg)","Stop all Mg-containing medications","IV fluids + diuretics","Dialysis (severe)","Respiratory support if needed"],
    memory="🍺 LOW Mg = SHAKY & HYPERACTIVE (tremors, ↑DTRs) β€” alcoholics! HIGH Mg = EVERYTHING SLOWS DOWN (↓DTRs β†’ resp depression β†’ cardiac arrest). CALCIUM GLUCONATE = antidote for Mg toxicity!",
    nclex_tips=[
        "Monitor DTRs during IV magnesium β€” LOSS of DTRs is the FIRST sign of toxicity",
        "Calcium gluconate is the antidote for magnesium sulfate toxicity",
        "Keep calcium gluconate at bedside when giving IV MgSOβ‚„ (e.g., preeclampsia patients)",
        "Hypomagnesemia often coexists with hypokalemia and hypocalcemia β€” treat all three",
        "Normal respiratory rate must be > 12/min before each IV Mg dose",
    ],
    accent=C_TEAL
)

# ══════════════════════════════════════════════════════════════════════
# PHOSPHORUS
# ══════════════════════════════════════════════════════════════════════
story += elec_block(
    name="PHOSPHORUS (PO₄³⁻)", normal="2.5–4.5 mg/dL",
    fun="Bone and teeth formation; energy production (ATP); cell membrane structure; acid-base balance.",
    hypo_name="πŸ”΅ HYPOPHOSPHATEMIA  (PO₄³⁻ < 2.5)",
    hypo_causes=["Malnutrition, anorexia","Refeeding syndrome","Antacid overuse (binds phosphorus)","Hyperparathyroidism","Chronic alcoholism","Respiratory alkalosis"],
    hypo_sx=["Muscle weakness (including respiratory muscles)","Fatigue","Confusion, irritability","Bone pain, fractures","Hemolytic anemia","Difficulty weaning from ventilator"],
    hypo_tx=["Oral phosphate supplements","IV sodium or potassium phosphate (severe)","Phosphate-rich diet (dairy, meat, nuts)","Stop phosphate-binding antacids","Correct underlying cause"],
    hyper_name="πŸ”΄ HYPERPHOSPHATEMIA  (PO₄³⁻ > 4.5)",
    hyper_causes=["Chronic renal failure (#1 cause)","Hypoparathyroidism","Excessive phosphate laxatives/enemas","Tumor lysis syndrome","Rhabdomyolysis"],
    hyper_sx=["Hypocalcemia symptoms (calcium-phosphate inverse relationship)","Tetany, muscle cramps","Chvostek's/Trousseau's signs","Calcification of soft tissues","Pruritus (itching)","Bone pain"],
    hyper_tx=["Phosphate-restricted diet","Phosphate binders with meals (calcium carbonate, sevelamer)","Dialysis (renal failure)","Correct hypocalcemia","Increase fluid intake"],
    memory="⚑ P = POWER (ATP/Energy). LOW P = NO ENERGY (weak muscles, can't breathe). HIGH P = STEALS CALCIUM β†’ tetany. Ca & P are INVERSELY related: ↑P = ↓Ca!",
    nclex_tips=[
        "Calcium and phosphorus have an INVERSE relationship β€” high phosphorus causes low calcium symptoms",
        "Refeeding syndrome causes dangerous hypophosphatemia β€” monitor carefully when restarting nutrition",
        "Phosphate binders (calcium carbonate) must be given WITH meals to work",
        "Chronic renal failure patients are at high risk for hyperphosphatemia",
    ],
    accent=C_DPINK
)

# ══════════════════════════════════════════════════════════════════════
# IV FLUIDS REFERENCE
# ══════════════════════════════════════════════════════════════════════
story.append(sec_hdr("πŸ’‰  IV FLUID TYPES β€” NCLEX Quick Reference", C_INDIGO))
story.append(Spacer(1,0.1*cm))

iv_rows = [
    ["Type", "Examples", "Tonicity", "Effect on Cells", "NCLEX Use"],
    ["Isotonic","0.9% NaCl (NS)\nLactated Ringer's (LR)\nD5W (acts isotonic in bag)","Same as blood (275–295 mOsm/L)","No shift β€” cells stay same size","Fluid replacement, hypovolemia, pre/post-op, blood transfusion"],
    ["Hypotonic","0.45% NaCl (Β½NS)\n0.33% NaCl\nD2.5W","Lower than blood (< 275 mOsm/L)","Water moves INTO cells β†’ cells SWELL","Cellular dehydration, hypernatremia, DKA maintenance"],
    ["Hypertonic","3% NaCl\nD5NS\nD5Β½NS\nD10W","Higher than blood (> 295 mOsm/L)","Water moves OUT of cells β†’ cells SHRINK","Severe hyponatremia, cerebral edema, SIADH"],
]
iv_tbl = Table(
    [[Paragraph(c, S_HDR if i==0 else (S_CELLB if j==0 else S_CELL))
      for j,c in enumerate(row)] for i,row in enumerate(iv_rows)],
    colWidths=[W*0.14, W*0.22, W*0.18, W*0.18, W*0.28]
)
iv_tbl.setStyle(TableStyle([
    ("BACKGROUND",(0,0),(-1,0),C_INDIGO),
    ("BACKGROUND",(0,1),(-1,1),C_LGREEN),
    ("BACKGROUND",(0,2),(-1,2),C_ELBLUE),
    ("BACKGROUND",(0,3),(-1,3),C_LRED),
    ("GRID",(0,0),(-1,-1),0.4,C_MGRAY),
    ("VALIGN",(0,0),(-1,-1),"MIDDLE"),
    ("TOPPADDING",(0,0),(-1,-1),5),("BOTTOMPADDING",(0,0),(-1,-1),5),
    ("LEFTPADDING",(0,0),(-1,-1),5),
]))
story.append(iv_tbl)
story.append(box([
    Paragraph("🧠 Memory: <b>ISO = same, HYPO = cells swell (water in), HYPER = cells shrink (water out)</b>", S_TRICK),
    Paragraph("⚠ Do NOT give hypotonic fluids to head injury patients (increases cerebral edema). Do NOT give hypertonic fluids fast (causes cell dehydration).", S_WARN),
], bg=C_YELLOW, border=C_DYELLOW))
story.append(Spacer(1,0.25*cm))

# ══════════════════════════════════════════════════════════════════════
# ELECTROLYTE INTERACTIONS
# ══════════════════════════════════════════════════════════════════════
story.append(sec_hdr("πŸ”„  KEY ELECTROLYTE INTERACTIONS & RELATIONSHIPS", C_BROWN))
story.append(Spacer(1,0.1*cm))

int_rows = [
    ["Relationship", "Clinical Significance"],
    ["Ca²⁺ ↑ ↔ PO₄³⁻ ↓  (Inverse)",     "When phosphorus goes up, calcium goes down and vice versa. Seen in renal failure."],
    ["Mg²⁺ ↓ β†’ K⁺ ↓ and Ca²⁺ ↓",        "Hypomagnesemia causes refractory hypokalemia and hypocalcemia. Must correct Mg first!"],
    ["Acidosis β†’ K⁺ ↑ (Hyperkalemia)",    "H⁺ ions move into cells, K⁺ moves out. Every 0.1 pH drop ↑ K⁺ by ~0.5 mEq/L."],
    ["Alkalosis β†’ K⁺ ↓ (Hypokalemia)",   "H⁺ ions move out of cells, K⁺ moves in. Vomiting (alkalosis) causes hypokalemia."],
    ["Insulin β†’ K⁺ ↓ (shifts into cells)","Used therapeutically in hyperkalemia (insulin + dextrose drives K⁺ into cells)."],
    ["Loop diuretics β†’ K⁺ ↓, Mg²⁺ ↓",   "Furosemide wastes both potassium and magnesium. Monitor both electrolytes."],
]
int_tbl = Table(
    [[Paragraph(c, S_HDR if i==0 else (S_CELLB if j==0 else S_CELL))
      for j,c in enumerate(row)] for i,row in enumerate(int_rows)],
    colWidths=[W*0.38, W*0.62]
)
int_tbl.setStyle(TableStyle([
    ("BACKGROUND",(0,0),(-1,0),C_BROWN),
    ("ROWBACKGROUNDS",(0,1),(-1,-1),[C_LBROWN, C_WHITE]),
    ("GRID",(0,0),(-1,-1),0.4,C_MGRAY),
    ("VALIGN",(0,0),(-1,-1),"MIDDLE"),
    ("TOPPADDING",(0,0),(-1,-1),5),("BOTTOMPADDING",(0,0),(-1,-1),5),
    ("LEFTPADDING",(0,0),(-1,-1),6),
]))
story.append(int_tbl)
story.append(Spacer(1,0.25*cm))

# ══════════════════════════════════════════════════════════════════════
# TOP NCLEX TIPS SUMMARY
# ══════════════════════════════════════════════════════════════════════
story.append(sec_hdr("⭐  TOP NCLEX EXAM TIPS β€” Electrolytes", C_RED))
story.append(Spacer(1,0.1*cm))

top_tips = [
    ("NEVER give IV K⁺ push", "Always dilute, max rate 10–20 mEq/hr. IV push = fatal cardiac arrest."),
    ("Calcium gluconate = universal antidote", "For hyperkalemia (stabilizes heart) AND hypermagnesemia (antagonizes Mg)."),
    ("Assess DTRs with IV MgSOβ‚„", "Loss of DTRs is the first sign of magnesium toxicity β€” hold Mg if absent."),
    ("Keep Ca gluconate at bedside", "Any patient on IV magnesium sulfate (eclampsia/preeclampsia) needs this nearby."),
    ("Correct electrolytes SLOWLY", "Rapid sodium correction β†’ osmotic demyelination (hypo) or cerebral edema (hyper)."),
    ("Trousseau's + Chvostek's = low Ca (or Mg)", "Both signs indicate neuromuscular irritability from low calcium or magnesium."),
    ("Renal failure β†’ high K, high P, low Ca", "Classic triad of chronic renal failure electrolyte imbalances."),
    ("Diuretics: Loop = wastes K, Mg | Thiazide = wastes K | K-sparing = saves K", "Know which diuretic causes which imbalance."),
    ("Peaked T-wave on ECG = HYPERKALEMIA", "Flat/inverted T-wave + U-wave = hypokalemia. ECG is key for K⁺ imbalances."),
    ("Thirst = earliest sign of hypernatremia", "Always assess for thirst and mucous membrane dryness."),
]
tip_data = [[Paragraph(f"βœ…  {t}", S_WARN), Paragraph(d, S_BODY)] for t,d in top_tips]
tip_tbl = Table(tip_data, colWidths=[W*0.35, W*0.65])
tip_tbl.setStyle(TableStyle([
    ("ROWBACKGROUNDS",(0,0),(-1,-1),[C_LRED, C_WHITE]),
    ("GRID",(0,0),(-1,-1),0.3,C_MGRAY),
    ("VALIGN",(0,0),(-1,-1),"MIDDLE"),
    ("TOPPADDING",(0,0),(-1,-1),5),("BOTTOMPADDING",(0,0),(-1,-1),5),
    ("LEFTPADDING",(0,0),(-1,-1),6),
]))
story.append(tip_tbl)
story.append(Spacer(1,0.2*cm))

# ── Footer ─────────────────────────────────────────────────────────────
story.append(HRFlowable(width=W, color=C_MGRAY))
story.append(Spacer(1,0.1*cm))
story.append(Paragraph(
    "NCLEX-RN Electrolytes Quick Reference  |  Prepared for NCLEX-RN Exam Preparation  |  July 2026  |  Na β€’ K β€’ Ca β€’ Mg β€’ POβ‚„ β€’ Cl",
    S_FOOTER
))

doc.build(story)
print("PDF created:", OUTPUT)
Running Command

cd /home/daytona/workspace/nclex-pdf && python create_electrolytes_pdf.py

Editing File

~/nclex-pdf/create_electrolytes_pdf.py

Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/nclex-pdf/create_electrolytes_pdf.py'
Editing File

~/nclex-pdf/create_electrolytes_pdf.py

Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/nclex-pdf/create_electrolytes_pdf.py'
Running Command

cd /home/daytona/workspace/nclex-pdf && python create_electrolytes_pdf.py

Writing File

~/nclex-pdf/create_electrolytes_pdf.py

from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import cm
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, HRFlowable
)
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.enums import TA_CENTER, TA_LEFT

OUTPUT = "/home/daytona/workspace/nclex-pdf/Electrolytes_NCLEX_QuickRef.pdf"

# ── Colors ─────────────────────────────────────────────────────────────
C_NAVY    = colors.HexColor("#0D1B2A")
C_BLUE    = colors.HexColor("#1565C0")
C_LBLUE   = colors.HexColor("#1E88E5")
C_ELBLUE  = colors.HexColor("#E3F2FD")
C_GREEN   = colors.HexColor("#2E7D32")
C_LGREEN  = colors.HexColor("#E8F5E9")
C_RED     = colors.HexColor("#C62828")
C_LRED    = colors.HexColor("#FFEBEE")
C_ORANGE  = colors.HexColor("#E65100")
C_LORANGE = colors.HexColor("#FFF3E0")
C_PURPLE  = colors.HexColor("#6A1B9A")
C_LPURPLE = colors.HexColor("#F3E5F5")
C_TEAL    = colors.HexColor("#00695C")
C_LTEAL   = colors.HexColor("#E0F2F1")
C_YELLOW  = colors.HexColor("#FFF9C4")
C_DYELLOW = colors.HexColor("#F9A825")
C_LGRAY   = colors.HexColor("#F5F5F5")
C_MGRAY   = colors.HexColor("#BDBDBD")
C_WHITE   = colors.white
C_DPINK   = colors.HexColor("#AD1457")
C_LPINK   = colors.HexColor("#FCE4EC")
C_BROWN   = colors.HexColor("#4E342E")
C_LBROWN  = colors.HexColor("#EFEBE9")
C_INDIGO  = colors.HexColor("#283593")
C_LINDIGO = colors.HexColor("#E8EAF6")

doc = SimpleDocTemplate(
    OUTPUT, pagesize=A4,
    rightMargin=1.4*cm, leftMargin=1.4*cm,
    topMargin=1.4*cm,   bottomMargin=1.4*cm
)
W = A4[0] - 2.8*cm

styles = getSampleStyleSheet()

def S(name, **kw):
    return ParagraphStyle(name, parent=styles["Normal"], **kw)

S_TITLE  = S("t",  fontSize=22, textColor=C_WHITE,  alignment=TA_CENTER, fontName="Helvetica-Bold", leading=28)
S_SUB    = S("s",  fontSize=10, textColor=colors.HexColor("#B3E5FC"), alignment=TA_CENTER, fontName="Helvetica", leading=14)
S_H1     = S("h1", fontSize=12, textColor=C_WHITE,  fontName="Helvetica-Bold", leading=16, leftIndent=4)
S_BODY   = S("b",  fontSize=8.5,textColor=C_NAVY,   fontName="Helvetica", leading=12)
S_BOLD   = S("bb", fontSize=8.5,textColor=C_NAVY,   fontName="Helvetica-Bold", leading=12)
S_TRICK  = S("tr", fontSize=9,  textColor=C_PURPLE, fontName="Helvetica-BoldOblique", leading=13)
S_WARN   = S("w",  fontSize=9,  textColor=C_RED,    fontName="Helvetica-Bold", leading=13)
S_TIP    = S("tp", fontSize=9,  textColor=C_GREEN,  fontName="Helvetica-Bold", leading=13)
S_HDR    = S("hd", fontSize=9,  textColor=C_WHITE,  fontName="Helvetica-Bold", alignment=TA_CENTER, leading=12)
S_CELL   = S("c",  fontSize=8.5,textColor=C_NAVY,   fontName="Helvetica", leading=12)
S_CELLB  = S("cb", fontSize=8.5,textColor=C_NAVY,   fontName="Helvetica-Bold", leading=12)
S_FOOTER = S("f",  fontSize=7.5,textColor=C_MGRAY,  fontName="Helvetica", alignment=TA_CENTER)

def sec_hdr(text, bg=C_BLUE):
    t = Table([[Paragraph(text, S_H1)]], colWidths=[W])
    t.setStyle(TableStyle([
        ("BACKGROUND",(0,0),(-1,-1), bg),
        ("TOPPADDING",(0,0),(-1,-1),7),("BOTTOMPADDING",(0,0),(-1,-1),7),
        ("LEFTPADDING",(0,0),(-1,-1),10),
    ]))
    return t

def box(paras, bg=C_LGRAY, border=C_MGRAY):
    if not isinstance(paras, list): paras = [paras]
    rows = [[p] for p in paras]
    t = Table(rows, colWidths=[W])
    t.setStyle(TableStyle([
        ("BACKGROUND",(0,0),(-1,-1), bg),
        ("BOX",(0,0),(-1,-1),0.8,border),
        ("TOPPADDING",(0,0),(-1,-1),4),("BOTTOMPADDING",(0,0),(-1,-1),4),
        ("LEFTPADDING",(0,0),(-1,-1),8),("RIGHTPADDING",(0,0),(-1,-1),8),
    ]))
    return t

# Core electrolyte block: flat table with two columns
def elec_block(name, normal, fun, hypo_name, hypo_causes, hypo_sx, hypo_tx,
               hyper_name, hyper_causes, hyper_sx, hyper_tx,
               memory, nclex_tips, accent):
    story = []

    # Title header
    hdr = Table([[Paragraph(f"⚑  {name}   |   Normal: {normal}", S_H1)]], colWidths=[W])
    hdr.setStyle(TableStyle([
        ("BACKGROUND",(0,0),(-1,-1),accent),
        ("TOPPADDING",(0,0),(-1,-1),7),("BOTTOMPADDING",(0,0),(-1,-1),7),
        ("LEFTPADDING",(0,0),(-1,-1),10),
    ]))
    story.append(hdr)

    # Function
    story.append(box(Paragraph(f"<b>Function:</b> {fun}", S_BODY), bg=C_LGRAY, border=accent))

    # Memory trick
    story.append(box(Paragraph(f"🧠 Memory Trick:  {memory}", S_TRICK), bg=C_LPURPLE, border=C_PURPLE))

    # Build two-column table manually: each section header + items as rows
    lw = W * 0.495
    rw = W - lw

    def col_rows(title, causes, sx, tx, title_bg, row_bg):
        rows = []
        rows.append((Paragraph(title, S_H1), title_bg, True))
        rows.append((Paragraph("<b>Causes:</b>", S_BOLD), row_bg, False))
        for c in causes:
            rows.append((Paragraph(f"  \u2022 {c}", S_CELL), row_bg, False))
        rows.append((Paragraph("<b>Signs &amp; Symptoms:</b>", S_BOLD), row_bg, False))
        for s in sx:
            rows.append((Paragraph(f"  \u2022 {s}", S_CELL), row_bg, False))
        rows.append((Paragraph("<b>Nursing Interventions:</b>", S_BOLD), row_bg, False))
        for t in tx:
            rows.append((Paragraph(f"  \u2022 {t}", S_CELL), row_bg, False))
        return rows

    left_rows  = col_rows(hypo_name,  hypo_causes,  hypo_sx,  hypo_tx,  C_RED,   C_LRED)
    right_rows = col_rows(hyper_name, hyper_causes, hyper_sx, hyper_tx, C_GREEN, C_LGREEN)

    # Pad shorter side
    max_len = max(len(left_rows), len(right_rows))
    while len(left_rows)  < max_len: left_rows.append((Paragraph("", S_CELL), C_LRED, False))
    while len(right_rows) < max_len: right_rows.append((Paragraph("", S_CELL), C_LGREEN, False))

    data = [[l[0], r[0]] for l, r in zip(left_rows, right_rows)]
    combo = Table(data, colWidths=[lw, rw])
    ts = TableStyle([
        ("GRID",(0,0),(-1,-1),0.3,C_MGRAY),
        ("VALIGN",(0,0),(-1,-1),"MIDDLE"),
        ("TOPPADDING",(0,0),(-1,-1),3),("BOTTOMPADDING",(0,0),(-1,-1),3),
        ("LEFTPADDING",(0,0),(-1,-1),6),("RIGHTPADDING",(0,0),(-1,-1),4),
    ])
    for i, (l, r) in enumerate(zip(left_rows, right_rows)):
        ts.add("BACKGROUND", (0,i),(0,i), l[1])
        ts.add("BACKGROUND", (1,i),(1,i), r[1])
        if l[2]:  # title row
            ts.add("FONTNAME",(0,i),(0,i),"Helvetica-Bold")
        if r[2]:
            ts.add("FONTNAME",(1,i),(1,i),"Helvetica-Bold")
    combo.setStyle(ts)
    story.append(combo)

    # NCLEX tips
    tip_rows = [[Paragraph(f"βœ…  {t}", S_TIP)] for t in nclex_tips]
    tip_tbl = Table(tip_rows, colWidths=[W])
    tip_tbl.setStyle(TableStyle([
        ("ROWBACKGROUNDS",(0,0),(-1,-1),[C_LGREEN, C_WHITE]),
        ("GRID",(0,0),(-1,-1),0.3,C_MGRAY),
        ("TOPPADDING",(0,0),(-1,-1),4),("BOTTOMPADDING",(0,0),(-1,-1),4),
        ("LEFTPADDING",(0,0),(-1,-1),6),
    ]))
    story.append(tip_tbl)
    story.append(Spacer(1, 0.3*cm))
    return story

story = []

# ══════ TITLE ══════════════════════════════════════════════════════════
title_data = [
    [Paragraph("⚑ ELECTROLYTES", S_TITLE)],
    [Paragraph("NCLEX-RN Complete Quick Reference", S_SUB)],
    [Paragraph("Na \u2022 K \u2022 Ca \u2022 Mg \u2022 Phosphorus \u2022 Chloride  |  Normal Values \u2022 Causes \u2022 Signs & Symptoms \u2022 Nursing Actions \u2022 Memory Tricks", S_SUB)],
]
title_tbl = Table(title_data, colWidths=[W])
title_tbl.setStyle(TableStyle([
    ("BACKGROUND",(0,0),(-1,-1),C_NAVY),
    ("TOPPADDING",(0,0),(-1,-1),5),("BOTTOMPADDING",(0,0),(-1,-1),5),
    ("LEFTPADDING",(0,0),(-1,-1),10),
]))
story.append(title_tbl)
story.append(Spacer(1,0.25*cm))

# ══════ NORMAL VALUES ══════════════════════════════════════════════════
story.append(sec_hdr("πŸ“Š  NORMAL ELECTROLYTE VALUES β€” Quick Glance", C_NAVY))
story.append(Spacer(1,0.1*cm))

nv_rows = [
    ["Electrolyte", "Normal Range", "Critical Low", "Critical High", "Primary Function"],
    ["Sodium (Na\u207a)",       "135–145 mEq/L","< 120 mEq/L","  > 160 mEq/L","Fluid balance, nerve/muscle function"],
    ["Potassium (K\u207a)",     "3.5–5.0 mEq/L","< 2.5 mEq/L",  "> 6.5 mEq/L",  "Heart rhythm, muscle contraction"],
    ["Calcium (Ca\u00b2\u207a)","8.5–10.5 mg/dL","< 7.0 mg/dL",  "> 13.0 mg/dL", "Bone/teeth, clotting, nerve/muscle"],
    ["Magnesium (Mg\u00b2\u207a)","1.5–2.5 mEq/L","< 1.0 mEq/L","> 4.0 mEq/L",  "Enzyme reactions, nerve/muscle"],
    ["Phosphorus (PO4)", "2.5–4.5 mg/dL","< 1.0 mg/dL",  "> 8.0 mg/dL",  "Bone formation, energy (ATP)"],
    ["Chloride (Cl\u207b)",     "96–106 mEq/L", "< 80 mEq/L",   "> 115 mEq/L",  "Acid-base balance, fluid balance"],
]
nv_tbl = Table(
    [[Paragraph(c, S_HDR if i==0 else (S_CELLB if j==0 else S_CELL))
      for j,c in enumerate(row)] for i,row in enumerate(nv_rows)],
    colWidths=[W*0.20, W*0.16, W*0.14, W*0.14, W*0.36]
)
nv_tbl.setStyle(TableStyle([
    ("BACKGROUND",(0,0),(-1,0),C_NAVY),
    ("ROWBACKGROUNDS",(0,1),(-1,-1),[C_WHITE, C_LGRAY]),
    ("GRID",(0,0),(-1,-1),0.4,C_MGRAY),
    ("VALIGN",(0,0),(-1,-1),"MIDDLE"),
    ("TOPPADDING",(0,0),(-1,-1),5),("BOTTOMPADDING",(0,0),(-1,-1),5),
    ("LEFTPADDING",(0,0),(-1,-1),5),
]))
story.append(nv_tbl)
story.append(box(Paragraph(
    '🧠 Memory: <b>"Sally Keeps Calcium Manageable Physically with Chloride"</b>  β†’  Na, K, Ca, Mg, PO4, Cl', S_TRICK),
    bg=C_LPURPLE, border=C_PURPLE))
story.append(Spacer(1,0.25*cm))

# ══════ SODIUM ═════════════════════════════════════════════════════════
story += elec_block(
    name="SODIUM (Na+)", normal="135–145 mEq/L",
    fun="Controls fluid balance (where sodium goes, water follows); nerve impulse transmission; blood pressure regulation.",
    hypo_name="HYPONATREMIA  (Na+ < 135)",
    hypo_causes=["Excessive water intake / SIADH","Prolonged vomiting / diarrhea","Heart failure, cirrhosis, renal failure","Excessive hypotonic IV fluids","Diuretic use"],
    hypo_sx=["Headache, confusion, lethargy","Nausea and vomiting","Muscle cramps, weakness","Seizures (severe β€” Na+ < 120)","Cerebral edema β€” increased ICP"],
    hypo_tx=["Restrict fluid intake","3% NaCl (hypertonic) for severe","Monitor neuro status q1-2h","Correct SLOWLY (risk: osmotic demyelination)","Daily weights, strict I&O"],
    hyper_name="HYPERNATREMIA  (Na+ > 145)",
    hyper_causes=["Inadequate water intake (main cause)","Excessive sodium intake","Diabetes insipidus","Watery diarrhea","Excessive sweating"],
    hyper_sx=["Thirst (EARLIEST sign)","Dry sticky mucous membranes","Restlessness, agitation","Decreased LOC (severe)","Seizures, coma (severe)"],
    hyper_tx=["Increase water intake (oral or IV)","Hypotonic IV fluids (0.45% NaCl)","Correct SLOWLY (risk: cerebral edema)","Monitor fluid status + daily weights","Treat underlying cause"],
    memory="SALT = THIRST. HIGH Na = THIRST (dry). LOW Na = BRAIN SWELLS (neuro sx). Water follows sodium β€” low sodium = water floods the brain = headache + seizures!",
    nclex_tips=[
        "Thirst is the EARLIEST sign of hypernatremia",
        "Correct sodium SLOWLY β€” rapid correction of hyponatremia causes osmotic demyelination syndrome",
        "SIADH causes hyponatremia β€” primary treatment is fluid restriction",
        "Place on seizure precautions when Na+ < 120 mEq/L",
    ],
    accent=C_LBLUE
)

# ══════ POTASSIUM ══════════════════════════════════════════════════════
story += elec_block(
    name="POTASSIUM (K+)", normal="3.5–5.0 mEq/L",
    fun="Maintains resting membrane potential; regulates heart rhythm and muscle contraction; acid-base balance.",
    hypo_name="HYPOKALEMIA  (K+ < 3.5)",
    hypo_causes=["Diuretics (loop/thiazide β€” #1 cause)","Vomiting, diarrhea, NG suction","Insufficient dietary intake","Alkalosis (K+ shifts into cells)","Insulin administration"],
    hypo_sx=["Muscle weakness, fatigue (legs first)","Leg cramps","Constipation, paralytic ileus","Cardiac dysrhythmias (PVCs, V-fib)","ECG: Flat/inverted T-waves + U-waves"],
    hypo_tx=["KCl oral supplement (preferred)","IV KCl β€” NEVER give IV push (fatal!)","Max IV rate: 10–20 mEq/hr, always diluted","Increase dietary K+ (bananas, oranges, potatoes)","Continuous cardiac monitoring"],
    hyper_name="HYPERKALEMIA  (K+ > 5.0)",
    hyper_causes=["Renal failure (#1 cause)","Potassium-sparing diuretics","ACE inhibitors","Acidosis (K+ shifts out of cells)","Massive cell destruction (burns, trauma)"],
    hyper_sx=["Muscle weakness, fatigue","Nausea, diarrhea, abdominal cramps","ECG: Peaked (tall, narrow) T-waves","Widened QRS, sine wave pattern","Ventricular fibrillation / cardiac arrest"],
    hyper_tx=["Calcium gluconate IV (stabilizes heart β€” FIRST)","Sodium bicarbonate (shifts K+ into cells)","Insulin + dextrose (shifts K+ into cells)","Kayexalate (removes K+ from body)","Dialysis (severe / renal failure)"],
    memory="K = MUSCLES & HEART. LOW K = WEAK + FLAT T-wave + U-wave (you SEE a U!). HIGH K = PEAKED T-wave = DANGER. LOW K ladder goes DOWN, HIGH K tent goes UP!",
    nclex_tips=[
        "NEVER give IV potassium as IV push or bolus β€” it causes fatal cardiac arrest",
        "Max IV KCl rate = 10–20 mEq/hr, always diluted in IV fluid β€” never run undiluted",
        "Loop diuretics (furosemide) cause hypokalemia β€” always give K+ supplements",
        "Peaked T-waves = hyperkalemia | Flat T-wave + U-wave = hypokalemia",
        "Calcium gluconate is FIRST treatment in dangerous hyperkalemia (protects the heart)",
    ],
    accent=C_GREEN
)

# ══════ CALCIUM ════════════════════════════════════════════════════════
story += elec_block(
    name="CALCIUM (Ca2+)", normal="8.5–10.5 mg/dL",
    fun="Bone and teeth formation; muscle contraction and relaxation; blood clotting; nerve transmission.",
    hypo_name="HYPOCALCEMIA  (Ca2+ < 8.5)",
    hypo_causes=["Hypoparathyroidism (post thyroid/parathyroid surgery)","Vitamin D deficiency","Chronic renal failure","Hypomagnesemia","Alkalosis (Ca2+ binds to albumin)","Pancreatitis"],
    hypo_sx=["Trousseau's sign (carpopedal spasm with BP cuff)","Chvostek's sign (facial twitch β€” tap CN VII)","Tetany, muscle cramps","Numbness/tingling (perioral, fingers, toes)","Seizures","Prolonged QT interval on ECG"],
    hypo_tx=["IV calcium gluconate (emergency)","Oral calcium supplements + Vitamin D","High-calcium diet (dairy, leafy greens)","Correct hypomagnesemia first","Seizure precautions + padded side rails"],
    hyper_name="HYPERCALCEMIA  (Ca2+ > 10.5)",
    hyper_causes=["Hyperparathyroidism (#1 cause)","Malignancy (bone metastases)","Prolonged immobility","Excess Vitamin D intake","Thiazide diuretics","Paget's disease"],
    hyper_sx=["Bone pain, pathologic fractures","Nausea, vomiting, constipation","Fatigue, muscle weakness, flaccidity","Confusion, depression, psychosis","Kidney stones, polyuria, polydipsia","Shortened QT interval on ECG"],
    hyper_tx=["IV Normal Saline (dilutes Ca2+ β€” FIRST)","Loop diuretics (furosemide) to excrete Ca2+","Bisphosphonates (chronic management)","Calcitonin","Limit calcium/Vitamin D intake","Encourage weight-bearing activity"],
    memory="LOW Ca = TWITCHY (Trousseau + Chvostek = neuromuscular IRRITABILITY). HIGH Ca = BONES GROANS MOANS & PSYCHIC OVERTONES (bone pain, GI upset, confusion). TROUSSEAU = BP cuff. CHVOSTEK = Cheek tap.",
    nclex_tips=[
        "Trousseau's sign: inflate BP cuff 20 mmHg above systolic x 3 min β€” carpopedal spasm = positive (low Ca)",
        "Chvostek's sign: tap facial nerve anterior to ear β€” facial twitch = positive (low Ca)",
        "Post thyroid/parathyroid surgery: monitor closely for hypocalcemia (accidental parathyroid removal)",
        "'Bones, Groans, Moans, Psychic Overtones' = classic hypercalcemia mnemonic",
        "First treatment for hypercalcemia = IV Normal Saline hydration",
    ],
    accent=C_ORANGE
)

# ══════ MAGNESIUM ══════════════════════════════════════════════════════
story += elec_block(
    name="MAGNESIUM (Mg2+)", normal="1.5–2.5 mEq/L",
    fun="Enzyme co-factor for 300+ reactions; nerve/muscle function; regulates calcium and potassium levels; cardiac rhythm.",
    hypo_name="HYPOMAGNESEMIA  (Mg2+ < 1.5)",
    hypo_causes=["Alcoholism (#1 cause in adults)","Prolonged malnutrition / malabsorption","Diarrhea, vomiting, NG suction","Diuretics (loop / thiazide)","Diabetic ketoacidosis (DKA)"],
    hypo_sx=["Tremors, muscle twitching","Hyperreflexia (increased DTRs)","Positive Trousseau's and Chvostek's signs","Cardiac dysrhythmias (torsades de pointes)","Confusion, agitation, insomnia","Dysphagia (difficulty swallowing)"],
    hypo_tx=["IV magnesium sulfate (MgSO4) for severe","Oral Mg supplements (mild)","High-Mg diet: nuts, whole grains, green veggies","Correct coexisting hypokalemia and hypocalcemia","Monitor DTRs and respiratory rate during IV replacement"],
    hyper_name="HYPERMAGNESEMIA  (Mg2+ > 2.5)",
    hyper_causes=["Renal failure (#1 cause)","Excessive Mg antacids or laxatives (Milk of Magnesia)","Excessive IV MgSO4 (eclampsia treatment)","Adrenal insufficiency"],
    hyper_sx=["Flushing, feeling of warmth (early)","Nausea, vomiting","LOSS of deep tendon reflexes β€” FIRST SIGN","Hypotension, bradycardia","Respiratory depression β€” LIFE-THREATENING","Cardiac arrest (very high levels)"],
    hyper_tx=["STOP all Mg-containing medications immediately","Calcium gluconate IV (antidote β€” reverses Mg effects)","IV fluids + loop diuretics to excrete Mg","Dialysis (severe / renal failure)","Respiratory support / mechanical ventilation if needed"],
    memory="LOW Mg = SHAKY & HYPERACTIVE (tremors, increased DTRs) β€” think ALCOHOLICS. HIGH Mg = EVERYTHING SLOWS (DTRs disappear first, then breathing stops). CALCIUM GLUCONATE = ANTIDOTE for Mg toxicity!",
    nclex_tips=[
        "Monitor DTRs before each IV Mg dose β€” absent DTRs = HOLD magnesium immediately (toxicity)",
        "Calcium gluconate is the antidote for magnesium sulfate toxicity",
        "Keep calcium gluconate at the bedside for ALL patients receiving IV MgSO4 (preeclampsia)",
        "Respiratory rate must be > 12/min and urine output > 25–30 mL/hr before giving IV Mg",
        "Hypomagnesemia causes refractory hypokalemia β€” treat Mg first, then K+",
    ],
    accent=C_TEAL
)

# ══════ PHOSPHORUS ═════════════════════════════════════════════════════
story += elec_block(
    name="PHOSPHORUS (PO4)", normal="2.5–4.5 mg/dL",
    fun="Bone and teeth formation; energy production (ATP); cell membrane structure; acid-base balance.",
    hypo_name="HYPOPHOSPHATEMIA  (PO4 < 2.5)",
    hypo_causes=["Malnutrition, anorexia nervosa","Refeeding syndrome (restarting nutrition)","Antacid overuse (aluminum-based binds PO4)","Hyperparathyroidism","Chronic alcoholism","Respiratory alkalosis"],
    hypo_sx=["Profound muscle weakness (including respiratory muscles)","Fatigue, bone pain","Confusion, irritability","Hemolytic anemia","Difficulty weaning from ventilator (resp. muscle weakness)","Pathologic fractures"],
    hypo_tx=["Oral phosphate supplements (mild)","IV sodium or potassium phosphate (severe)","Phosphate-rich diet: dairy, meat, nuts, legumes","Discontinue phosphate-binding antacids","Monitor for refeeding syndrome when restarting nutrition"],
    hyper_name="HYPERPHOSPHATEMIA  (PO4 > 4.5)",
    hyper_causes=["Chronic renal failure (#1 cause)","Hypoparathyroidism","Excessive phosphate laxatives/enemas","Tumor lysis syndrome","Rhabdomyolysis"],
    hyper_sx=["Hypocalcemia symptoms (inverse relationship)","Tetany, muscle cramps","Positive Trousseau's / Chvostek's signs","Soft tissue / vascular calcifications","Pruritus (itching from calcium-phosphate deposits)","Bone pain and joint pain"],
    hyper_tx=["Phosphate-restricted diet","Phosphate binders WITH meals (calcium carbonate, sevelamer)","Increase fluid intake","Dialysis for renal failure patients","Correct hypocalcemia as needed"],
    memory="P = POWER (ATP = Energy). LOW P = NO ENERGY (weak muscles, can't breathe off vent). HIGH P STEALS CALCIUM (inverse relationship) = tetany + twitching. Ca and P are like a SEESAW: one goes up, the other goes down!",
    nclex_tips=[
        "Calcium and phosphorus are INVERSELY related β€” high phosphorus = low calcium signs (tetany, twitching)",
        "Refeeding syndrome causes dangerous hypophosphatemia β€” monitor carefully when restarting nutrition in malnourished patients",
        "Phosphate binders must be given WITH meals (not between meals) to be effective",
        "Chronic renal failure patients: high phosphorus, low calcium, high PTH β€” the classic triad",
    ],
    accent=C_DPINK
)

# ══════ IV FLUIDS ══════════════════════════════════════════════════════
story.append(sec_hdr("πŸ’‰  IV FLUID TYPES β€” NCLEX Quick Reference", C_INDIGO))
story.append(Spacer(1,0.1*cm))

iv_rows = [
    ["Type", "Examples", "Tonicity", "Cell Effect", "NCLEX Use"],
    ["ISOTONIC",   "0.9% NaCl (NS)\nLactated Ringer's\nD5W (isotonic in bag)", "275–295 mOsm/L\n(same as blood)",   "Cells stay\nSAME SIZE",       "Fluid replacement\nHypovolemia\nPre/post-op\nBlood transfusion compatible"],
    ["HYPOTONIC",  "0.45% NaCl (1/2 NS)\n0.33% NaCl\nD2.5W",                   "< 275 mOsm/L\n(less than blood)",  "Water moves IN\ncells SWELL",     "Cellular dehydration\nHypernatremia\nDKA maintenance"],
    ["HYPERTONIC", "3% NaCl\nD5NS\nD5 1/2NS\nD10W",                             "> 295 mOsm/L\n(more than blood)", "Water moves OUT\ncells SHRINK",    "Severe hyponatremia\nCerebral edema\nSIADH"],
]
iv_tbl = Table(
    [[Paragraph(c, S_HDR if i==0 else (S_CELLB if j==0 else S_CELL))
      for j,c in enumerate(row)] for i,row in enumerate(iv_rows)],
    colWidths=[W*0.14, W*0.25, W*0.18, W*0.16, W*0.27]
)
iv_ts = TableStyle([
    ("BACKGROUND",(0,0),(-1,0),C_INDIGO),
    ("BACKGROUND",(0,1),(-1,1),C_LGREEN),
    ("BACKGROUND",(0,2),(-1,2),C_ELBLUE),
    ("BACKGROUND",(0,3),(-1,3),C_LRED),
    ("GRID",(0,0),(-1,-1),0.4,C_MGRAY),
    ("VALIGN",(0,0),(-1,-1),"MIDDLE"),
    ("TOPPADDING",(0,0),(-1,-1),5),("BOTTOMPADDING",(0,0),(-1,-1),5),
    ("LEFTPADDING",(0,0),(-1,-1),5),
])
iv_tbl.setStyle(iv_ts)
story.append(iv_tbl)
story.append(box([
    Paragraph("🧠 Memory: <b>ISO = same size, HYPO = cells swell (water rushes in), HYPER = cells shrink (water pulled out)</b>", S_TRICK),
    Paragraph("⚠ Do NOT give hypotonic fluids to head-injury patients (worsens cerebral edema). Do NOT infuse hypertonic saline rapidly.", S_WARN),
], bg=C_YELLOW, border=C_DYELLOW))
story.append(Spacer(1,0.25*cm))

# ══════ ELECTROLYTE INTERACTIONS ═══════════════════════════════════════
story.append(sec_hdr("πŸ”„  KEY ELECTROLYTE INTERACTIONS", C_BROWN))
story.append(Spacer(1,0.1*cm))

int_rows = [
    ["Relationship", "Clinical Significance"],
    ["Ca2+ UP  <-->  PO4 DOWN  (Inverse)", "When phosphorus rises, calcium falls. Classic in chronic renal failure."],
    ["Mg2+ LOW causes K+ LOW and Ca2+ LOW", "Hypomagnesemia makes hypokalemia and hypocalcemia resistant to treatment. Fix Mg first!"],
    ["Acidosis (pH down) --> K+ UP", "H+ ions shift into cells, K+ shifts out. Every 0.1 pH drop raises K+ ~0.5 mEq/L."],
    ["Alkalosis (pH up) --> K+ DOWN", "H+ shifts out of cells, K+ shifts in. Vomiting causes alkalosis and hypokalemia."],
    ["Insulin --> K+ DOWN (shifts into cells)", "Used therapeutically in hyperkalemia. Insulin + dextrose drives K+ into cells."],
    ["Loop diuretics --> K+ DOWN + Mg2+ DOWN", "Furosemide wastes both potassium AND magnesium. Monitor both levels."],
]
int_tbl = Table(
    [[Paragraph(c, S_HDR if i==0 else (S_CELLB if j==0 else S_CELL))
      for j,c in enumerate(row)] for i,row in enumerate(int_rows)],
    colWidths=[W*0.40, W*0.60]
)
int_tbl.setStyle(TableStyle([
    ("BACKGROUND",(0,0),(-1,0),C_BROWN),
    ("ROWBACKGROUNDS",(0,1),(-1,-1),[C_LBROWN, C_WHITE]),
    ("GRID",(0,0),(-1,-1),0.4,C_MGRAY),
    ("VALIGN",(0,0),(-1,-1),"MIDDLE"),
    ("TOPPADDING",(0,0),(-1,-1),5),("BOTTOMPADDING",(0,0),(-1,-1),5),
    ("LEFTPADDING",(0,0),(-1,-1),6),
]))
story.append(int_tbl)
story.append(Spacer(1,0.25*cm))

# ══════ TOP NCLEX TIPS ═════════════════════════════════════════════════
story.append(sec_hdr("⭐  TOP NCLEX EXAM TIPS β€” Electrolytes", C_RED))
story.append(Spacer(1,0.1*cm))

top_tips = [
    ("NEVER IV push potassium",         "IV K+ push = fatal cardiac arrest. Always dilute, max 10–20 mEq/hr."),
    ("Calcium gluconate = antidote x2", "Treats both hyperkalemia (heart protection) AND hypermagnesemia (Mg reversal)."),
    ("DTRs = Mg toxicity warning",      "Loss of DTRs is the FIRST sign of Mg toxicity β€” hold Mg, give calcium gluconate."),
    ("Keep Ca gluconate at bedside",    "Mandatory for ALL patients on IV MgSO4 (preeclampsia, eclampsia)."),
    ("Correct electrolytes SLOWLY",     "Rapid Na+ correction = osmotic demyelination (hypo) or cerebral edema (hyper)."),
    ("Trousseau + Chvostek = low Ca/Mg","Both signs = neuromuscular irritability from low calcium OR low magnesium."),
    ("Renal failure triad",             "Chronic renal failure = HIGH K+, HIGH PO4, LOW Ca2+. Always expect these."),
    ("Know your diuretics",             "Loop = wastes K+, Mg2+ | Thiazide = wastes K+ | K-sparing = saves K+ (raises it)."),
    ("ECG + K+ go together",            "Peaked T-wave = hyperkalemia. Flat T-wave + U-wave = hypokalemia."),
    ("Thirst = earliest hypernatremia", "Ask about thirst + check mucous membranes for dryness first."),
]
tip_data = [[Paragraph(f"βœ…  {t}", S_WARN), Paragraph(d, S_BODY)] for t,d in top_tips]
tip_tbl = Table(tip_data, colWidths=[W*0.35, W*0.65])
tip_tbl.setStyle(TableStyle([
    ("ROWBACKGROUNDS",(0,0),(-1,-1),[C_LRED, C_WHITE]),
    ("GRID",(0,0),(-1,-1),0.3,C_MGRAY),
    ("VALIGN",(0,0),(-1,-1),"MIDDLE"),
    ("TOPPADDING",(0,0),(-1,-1),5),("BOTTOMPADDING",(0,0),(-1,-1),5),
    ("LEFTPADDING",(0,0),(-1,-1),6),
]))
story.append(tip_tbl)
story.append(Spacer(1,0.2*cm))

# ── Footer ─────────────────────────────────────────────────────────────
story.append(HRFlowable(width=W, color=C_MGRAY))
story.append(Spacer(1,0.1*cm))
story.append(Paragraph(
    "NCLEX-RN Electrolytes Quick Reference  |  NCLEX-RN Exam Preparation  |  July 2026  |  Na \u2022 K \u2022 Ca \u2022 Mg \u2022 PO4 \u2022 Cl",
    S_FOOTER
))

doc.build(story)
print("PDF created:", OUTPUT)
Running Command

cat > /home/daytona/workspace/nclex-pdf/create_electrolytes_pdf.py << 'PYEOF' fr…

This is a shared conversation. Sign in to Orris to start your own chat.