import json, pathlib

sources = json.loads(pathlib.Path("/tmp/claude-0/-home-danvics-docker-quiz/c1e0577a-e42c-4a3d-b1ea-3edd61103a4e/scratchpad/articles/cervicitis.sources.json").read_text())

article = {
    "topic": "Cervicitis",
    "slug": "cervicitis",
    "category_id": 14956,
    "summary": "Inflammation of the cervix in the postpubertal adolescent, most often sexually transmitted, frequently asymptomatic, and important to recognize before it ascends to pelvic inflammatory disease.",
    "written_by": "claude-sonnet",
    "references": sources["references"],
    "short": [{
        "title": "In short",
        "content": """- Cervicitis is inflammation of the cervix involving the deeper mucosal structures of the cervix uteri; it can be acute or chronic.
- Acute cervicitis is most often infectious — Neisseria gonorrhoeae and Chlamydia trachomatis are the pathogens identified most frequently, with Mycoplasma genitalium also implicated — though no specific pathogen is identified in most cases; herpes simplex virus is a less common cause.
- Noninfectious causes include mechanical irritation (tampon, IUD, intercourse) and chemical irritation (contraceptive cream, douche); chronic cervicitis is more often noninfectious. In a postpubertal female, cervicitis (with or without urethritis and involvement of the Skene and Bartholin glands) can also result from Candida, Trichomonas, or a foreign body (usually a contraceptive device), and leukorrhea can accompany birth control pill use.
- Cervicitis is frequently asymptomatic and may be diagnosed incidentally; when symptomatic, presentation is nonspecific — purulent vaginal discharge, intermenstrual or postcoital bleeding, and dyspareunia — sometimes with dysuria or urinary frequency from concomitant urethritis.
- Patients with isolated cervicitis are unlikely to have fever or significant pain; the presence of either should raise concern for pelvic inflammatory disease (PID) or HSV infection instead.
- Two major diagnostic signs define cervicitis: a purulent or mucopurulent endocervical exudate visible in the canal or on a swab ("mucopurulent cervicitis"), and sustained endocervical bleeding easily induced by gentle passage of a cotton swab through the cervical os (friability).
- Cervical changes of cervicitis must be distinguished from cervical ectopy in the younger adolescent, to avoid overdiagnosing inflammation.
- Sexually active patients with cervicitis should be treated empirically for gonorrhea and chlamydia while confirmatory test results are pending, screened for other sexually transmitted infections, evaluated for PID, and counseled on safe sexual practices.
- Left untreated, cervical infection can ascend the genitourinary tract to cause PID, which carries risk of infertility, chronic pelvic pain, and ectopic pregnancy, and can also be transmitted to sexual partners and increase the risk of acquiring HIV if exposed."""
    }],
    "long": [
        {"title": "Definition",
         "content": "Cervicitis is inflammation of the cervix, involving the deeper structures of the cervical mucous membrane. It can be acute or chronic in nature."},
        {"title": "Etiology",
         "content": "Acute cervicitis is most often infectious, with Neisseria gonorrhoeae and Chlamydia trachomatis identified most frequently and Mycoplasma genitalium also implicated, though no specific pathogen is found in most cases; herpes simplex virus is a less common cause. In a postpubertal female, cervicitis — alone or with urethritis and involvement of the Skene and Bartholin glands — may also result from Candida or Trichomonas infection, or from discharge due to inflammation from a foreign body, usually some form of contraceptive device; leukorrhea can be associated with birth control pill use. Noninfectious causes of acute cervicitis include mechanical irritation (tampon, IUD, sexual intercourse) and chemical irritation (contraceptive cream, douche). Chronic cervicitis is more often due to a noninfectious cause than acute cervicitis is."},
        {"title": "Clinical features",
         "content": "Cervicitis is frequently asymptomatic and can be diagnosed incidentally in asymptomatic patients. When symptomatic, presentation is variable and nonspecific: purulent vaginal discharge, intermenstrual bleeding, postcoital bleeding, and dyspareunia are typical; less often, patients present with dysuria or urinary frequency from a concomitant urethritis. Patients with isolated cervicitis are unlikely to have fever or significant pain — the presence of either should prompt consideration of pelvic inflammatory disease (PID) or herpes simplex virus infection rather than uncomplicated cervicitis."},
        {"title": "Diagnostics",
         "content": "Two major signs characterize cervicitis: a purulent or mucopurulent endocervical exudate visible in the endocervical canal or on an endocervical swab specimen (mucopurulent cervicitis), and sustained endocervical bleeding easily induced by gentle passage of a cotton swab through the cervical os, signifying friability. Cervical changes of cervicitis must be carefully distinguished from cervical ectopy in the younger adolescent, to avoid overdiagnosing inflammation where none is present."},
        {"title": "Differential diagnosis",
         "content": "Symptoms attributed to cervicitis, and to associated conditions such as salpingitis, must be differentiated from appendicitis, urinary tract infection, ectopic pregnancy, endometriosis, and ovarian cyst or torsion, all of which can present with overlapping lower abdominal or pelvic symptoms."},
        {"title": "Treatment",
         "content": "Management aims to identify the causative agent and treat with appropriate antibiotics, or remove the offending mechanical or chemical agent when relevant. Sexually active patients with cervicitis should be treated empirically for gonorrhea and chlamydia while confirmatory test results are pending, screened for other sexually transmitted infections, evaluated for PID, and counseled on safe sexual practices."},
        {"title": "Complications",
         "content": "If untreated, cervical infection can ascend the genitourinary tract and cause pelvic inflammatory disease, which can lead to infertility, chronic pelvic pain, and an increased risk of ectopic pregnancy. Cervical infections can also be transmitted to sexual partners, and infection increases the risk of acquiring HIV if exposed."},
    ],
    "clinical": [
        {"title": "Bedside recognition and workup",
         "content": "Consider cervicitis in any sexually active adolescent with purulent vaginal discharge, intermenstrual or postcoital bleeding, or dyspareunia — but also remember that cervicitis is frequently asymptomatic and can be found incidentally on exam. Look for the two defining signs: a purulent or mucopurulent endocervical exudate, and endocervical friability with sustained bleeding after gentle swab passage through the cervical os. In a younger adolescent, be careful to distinguish these findings from normal cervical ectopy so inflammation is not overdiagnosed. The absence of fever or significant pain is typical of isolated cervicitis; if either is present, evaluate for PID or HSV infection instead. Keep noninfectious causes in mind too — a retained tampon, IUD, or irritation from contraceptive cream or douching can all produce a similar picture."},
        {"title": "Empiric treatment and counseling",
         "content": "In a sexually active patient with findings consistent with cervicitis, start empiric treatment for gonorrhea and chlamydia while confirmatory testing is pending, since these are the most frequently identified pathogens. Screen for other sexually transmitted infections at the same visit, evaluate for pelvic inflammatory disease if there is fever, significant pain, or other concerning features, and counsel on safe sexual practices given the risks of ascending infection (PID, infertility, chronic pelvic pain, ectopic pregnancy), transmission to partners, and increased HIV acquisition risk with exposure. If a foreign body or irritant (tampon, IUD, contraceptive cream, douche) is identified as the likely cause, remove or discontinue it as part of management."},
    ],
}

for v in ("short", "long", "clinical"):
    for s in article[v]:
        assert s["title"].strip() and s["content"].strip()

out = pathlib.Path("/tmp/claude-0/-home-danvics-docker-quiz/c1e0577a-e42c-4a3d-b1ea-3edd61103a4e/scratchpad/articles/cervicitis.article.json")
out.write_text(json.dumps(article, indent=1))
print(out)
