import sys, os
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from lib import build_and_save

references = [
 {"title": "Cover", "author": "Vitalsource Download", "pages": [3504, 5030]},
 {"title": "Diagnostic Imaging: Pediatrics", "author": "A. Carlson Merrow Jr. MD", "pages": [1186]},
 {"title": "2021_Fleisher_&_Ludwig's_Textbook_of_Pediatric_Emergency_Medicine.epub", "author": None, "pages": []},
 {"title": "Kliegman R. Nelson Textbook of Pediatrics 2-Volume Set 22ed 2024", "author": None, "pages": [4193]},
 {"title": "Challenging Cases in Pediatric Diagnosis", "author": "Deepak M. Kamat", "pages": [323]},
 {"title": "The febrile infant (29 to 90 days of age): Outpatient evaluation - UpToDate", "author": None, "pages": [5]},
 {"title": "Zitelli and Davis' Atlas of Pediatric Physical Diagnosis: Expert Consult - Online", "author": None, "pages": [518]},
 {"title": "Netters Pediatrics (Florin Т., Ludwig St.)", "author": None, "pages": [588]},
]

short_md = """## In short

- Cellulitis is an acute infection of the dermis/subcutaneous tissue causing erythema, edema, warmth, and pain, with poorly defined borders (unlike erysipelas, a more superficial infection with well-demarcated, raised, beefy-red borders, usually from group A strep).
- The most common causes overall are Staphylococcus aureus (including MRSA) and Streptococcus pyogenes (GAS); the lower extremities and feet are the most frequently affected sites.
- Only 10-20% of children with cellulitis develop fever; regional adenopathy is common, but blood cultures are rarely positive in well-appearing, immunocompetent hosts.
- Exposure-specific pathogens: cat/dog bites - Pasteurella species, Capnocytophaga canimorsus; penetrating trauma - S. aureus; freshwater immersion - Aeromonas hydrophila; saltwater immersion - Vibrio species; fish exposure - Streptococcus iniae; swine/poultry/fish - Erysipelothrix rhusiopathiae; periorbital/facial - H. influenzae, S. pneumoniae; neutropenia - Pseudomonas aeruginosa; acute varicella - S. pyogenes.
- Infants under 3 months are at risk from group B strep, which can cause bacteremia and meningitis; cellulitis in a neonate should prompt full evaluation for invasive infection including blood culture (and usually lumbar puncture).
- Buccal cellulitis from H. influenzae classically shows a blue-red, dusky skin discoloration.
- Outpatient oral treatment for mild-to-moderate cellulitis in infants/children over 2 months (without fever, lymphadenopathy, or other constitutional signs): dicloxacillin or a first-generation cephalosporin (cephalexin); use clindamycin if MRSA is suspected. Trimethoprim-sulfamethoxazole is an option but does not reliably cover S. pyogenes.
- Consider initial parenteral therapy for: immunocompromised patients, toxic appearance, rapidly progressive lesions, facial or circumferential involvement, or crepitance/violaceous skin.
- Needle aspirate from the center of a cellulitic lesion yields a pathogen in only 5-40% of cases (punch biopsy has a higher yield); bedside ultrasound can help distinguish abscess from simple cellulitis.
"""

long_md = """## Definition

Cellulitis is an acute, localized bacterial infection of the skin involving the dermis and subcutaneous (loose connective) tissue, with relative sparing of the epidermis and poorly defined borders. It is often used somewhat interchangeably with erysipelas, though erysipelas more precisely refers to infection confined to the more superficial dermal lymphatics, producing beefy-red, raised lesions with sharply demarcated ("step-off") borders, most often caused by group A streptococcus.

## Etiology

Gram-positive organisms - primarily Staphylococcus aureus (including MRSA) and Streptococcus pyogenes (GAS) - account for the majority of cellulitis cases. Certain exposures point to specific pathogens: cat or dog bites (Pasteurella species, Capnocytophaga canimorsus), penetrating trauma (S. aureus), freshwater immersion (Aeromonas hydrophila), saltwater immersion (Vibrio species), exposure to freshwater or saltwater fish (Streptococcus iniae), exposure to swine, poultry, or fish (Erysipelothrix rhusiopathiae), periorbital or facial cellulitis (Haemophilus influenzae, Streptococcus pneumoniae), neutropenia (Pseudomonas aeruginosa and other gram-negative bacilli), HIV infection (Helicobacter cinaedi), acute varicella (S. pyogenes), and immunosuppression (Cryptococcus neoformans). In infants under 3 months of age, group B streptococcus is an important cause and can be accompanied by bacteremia and meningitis. In toddlers with facial cellulitis, H. influenzae type b and S. pneumoniae should be considered, particularly if the child is unvaccinated; buccal cellulitis from H. influenzae characteristically has a blue-red, dusky skin appearance.

## Risk Factors

A breach in skin integrity - trauma, insect bite, surgery, burns, an underlying skin lesion, folliculitis/furuncles/carbuncles, or a predisposing dermatosis such as atopic dermatitis or dermatophyte infection - is a common predisposing factor, since the infection generally spreads beneath an initial break in the skin barrier. Lymphatic disruption (postsurgical or congenital), diabetes mellitus, and immunosuppression also raise risk, as does chronic liver or kidney disease and poorly controlled diabetes for more severe or recurrent infection. Extremities are frequently affected in part because they are more subject to minor, sometimes unnoticed, trauma. Hematogenous seeding is an additional route of cellulitis, particularly in infants and young children: young infants may show sudden sepsis followed shortly by cellulitis, while older infants and toddlers often have an antecedent upper respiratory prodrome followed by sudden high fever and a nondescript area of swelling (often periorbital, but also possibly over the neck or an extremity) that becomes pink, red, or violaceous and indurated, with irritability, anorexia, and signs of toxicity.

## Clinical Features

Cellulitis presents as erythema, edema, warmth, and pain, with borders that are less well defined than erysipelas. Only 10-20% of affected children develop fever, though regional adenopathy is common. Cellulitis in certain locations suggests an underlying process, such as buccal cellulitis from an odontogenic infection or postauricular cellulitis as a feature of mastoiditis. Warning signs that should raise concern include rapid progression, lymphatic streaking, abscess formation, pain out of proportion to examination findings, and systemic illness. Periorbital and orbital cellulitis are more common in children than adults and present with fever plus periorbital erythema, pain, and swelling; any such presentation warrants careful examination to exclude orbital cellulitis, watching specifically for visual disturbance, altered mental status, or sepsis suggesting spread of infection. Sinusitis (usually via ethmoiditis) is the most common cause of periorbital/orbital cellulitis, complicating up to 3% of sinusitis cases and sometimes preceding overt sinusitis symptoms.

## Diagnostics

Because the infection lies within the skin, culturing the causative organism is difficult; leading-edge cultures have low yield, so most cases are treated empirically. Needle aspiration from the center of the cellulitic area yields a pathogen in only 5-40% of cases, with punch biopsy offering a somewhat higher yield. Blood cultures are rarely positive in well-appearing, immunocompetent children, except in those with pneumococcal, H. influenzae, or group B streptococcal disease - who are usually not well-appearing when bacteremic. Bedside ultrasound can help distinguish a drainable abscess from simple cellulitis. Cellulitis in a neonate should prompt a full evaluation for invasive bacterial infection, including blood culture, with lumbar puncture usually indicated as well.

## Differential Diagnosis

Contact dermatitis is an important mimic, typically multifocal and itchy rather than a single localized area of pain and warmth. Erysipelas is distinguished from deeper cellulitis by its more superficial, sharply demarcated, raised, beefy-red presentation.

## Treatment

Treatment targets S. aureus and GAS, with the choice of empiric agent guided by local MRSA prevalence and any prior culture results. In infants and children older than 2 months with mild-to-moderate infection - particularly without fever, lymphadenopathy, or other constitutional signs - oral outpatient treatment is appropriate: a penicillinase-resistant penicillin such as dicloxacillin, or a first-generation cephalosporin such as cephalexin; clindamycin is used if MRSA is suspected. Trimethoprim-sulfamethoxazole is sometimes recommended but does not reliably cover S. pyogenes, a cause of cellulitis without abscess. Initial parenteral therapy should be considered for children who are immunocompromised, toxic-appearing, have rapidly progressive lesions, facial or circumferential involvement, or crepitance/violaceous skin change - findings that suggest a more severe or necrotizing process.
"""

clinical_md = """## Evaluating a Child with Suspected Cellulitis

Assess for the exposure history that narrows the likely pathogen: recent animal bite (Pasteurella, Capnocytophaga), penetrating trauma (S. aureus), fresh or saltwater exposure (Aeromonas or Vibrio, respectively), fish/swine/poultry contact (Streptococcus iniae or Erysipelothrix), neutropenia (consider Pseudomonas and other gram-negatives), or acute varicella (S. pyogenes superinfection). In an infant under 3 months with cellulitis, evaluate fully for invasive infection - blood culture and, usually, lumbar puncture - given the risk of group B streptococcal bacteremia and meningitis at this age. In toddlers with facial or buccal cellulitis, especially if unvaccinated, consider H. influenzae type b and S. pneumoniae; a blue-red, dusky appearance to the skin is characteristic of H. influenzae buccal cellulitis. Do not expect fever to be present - only 10-20% of children with cellulitis are febrile - and recognize that blood cultures are usually unrevealing in a well-appearing, immunocompetent child. Use bedside ultrasound when an abscess is suspected clinically, since distinguishing a drainable collection from simple cellulitis changes management.

## Choosing Outpatient versus Parenteral Therapy

For a child over 2 months with mild-to-moderate cellulitis and no fever, lymphadenopathy, or other constitutional signs, start oral therapy: dicloxacillin or cephalexin, switching to clindamycin if MRSA is a concern based on local prevalence or prior cultures; avoid relying on trimethoprim-sulfamethoxazole alone if S. pyogenes without abscess is a realistic possibility, since it does not reliably cover this organism. Escalate to initial parenteral treatment for an immunocompromised child, a toxic-appearing child, rapidly progressive lesions, facial or circumferential involvement, or crepitance/violaceous skin change - any of these should prompt admission-level management rather than outpatient oral therapy. For any pediatric patient with periorbital erythema, pain, and swelling with fever, examine carefully to exclude orbital cellulitis, and watch specifically for visual disturbance, altered mental status, or signs of sepsis that would indicate spread beyond the orbit.
"""

build_and_save(
    topic="Cellulitis",
    slug="cellulitis",
    category_id=14927,
    summary="Pediatric cellulitis: exposure-based pathogen clues, distinguishing it from erysipelas, red flags for parenteral therapy, and first-line oral antibiotic choices.",
    references=references,
    short_md=short_md,
    long_md=long_md,
    clinical_md=clinical_md,
)
