Give me the operational definition which i fill in my synopsis performa and do it from The reference mention or from the given synopsis data in it

Reading File
Running Command

cd /home/daytona/workspace/attachments/0292c806-b1a1-415d-9d93-3f3822f35a3a/ && pandoc --track-changes=all "anuj synopsis performa.docx" -o /home/daytona/workspace/anuj_synopsis.md 2>&1 && echo "DONE"

Reading File
Reading File
Reading File
Reading File
Reading File
Running Command

grep -n "OBJECTIVE\|METHODOLOGY\|INCLUSION\|EXCLUSION\|DEFINITION\|operational\|Operational\|OPERATIONAL\|variables\|VARIABLES\|PRIMARY\|SECONDARY\|OUTCOME\|sample size\|SAMPLE" /home/daytona/workspace/anuj_synopsis.md | head -80

Reading File
Reading File
I now have all the information I need from the synopsis. The "Operational Definitions" section is currently blank/empty in the document (it just says "Define cases / controls / exposure / outcomes with appropriate reference"). I can now draft the complete operational definitions based on the study's own content, methodology, and references.
Here are the Operational Definitions for the synopsis proforma of Dr. Anuj Jain's study, drafted entirely from the data already present in the synopsis:

Operational Definitions

(to be filled under Section: "Operational Definitions - Define cases / controls / exposure / outcome parameters")

1. Newly Diagnosed Leprosy Patient (Case)

A patient presenting to the DVL OPD/IPD of TMMC & RC for the first time with a diagnosis of leprosy established on the basis of NLEP/WHO clinical criteria (presence of one or more of the cardinal signs: hypopigmented/erythematous skin lesion(s) with definite loss of sensation; thickened peripheral nerve(s); presence of acid-fast bacilli on skin smear), who has not previously received any anti-leprosy treatment (MDT), and is aged 18-65 years of either sex. Reference: WHO. A Guide to Eliminating Leprosy as a Public Health Problem. Geneva: WHO; 1995.

2. Clinical Type of Leprosy

Patients will be classified using the Ridley-Jopling classification (TT, BT, BB, BL, LL, pure neuritic) based on clinical features, slit-skin smear (Bacteriological Index, BI), and histopathology. For operational/field purposes, WHO classification will also be applied:
  • Paucibacillary (PB): 1-5 skin lesions, skin smear negative.
  • Multibacillary (MB): >5 skin lesions, or skin smear positive. Reference: Ridley DS, Jopling WH. Classification of leprosy according to immunity. Int J Lepr Other Mycobact Dis. 1966;34(3):255-73. WHO. MDT Leprosy. Geneva: WHO; 1998.

3. Disability (WHO Disability Grading System, 1998)

Physical disability in leprosy is graded separately for eyes, hands, and feet using the WHO (1998) grading system. The highest grade recorded for any body part constitutes the overall disability grade of the patient:
GradeDefinition
Grade 0No disability; no visible deformity or damage to eyes, hands, or feet
Grade 1Loss of protective sensibility in eye(s), hand(s), or foot/feet, but no visible deformity or damage
Grade 2Visible deformity or damage present: lagophthalmos, ectropion, trichiasis, corneal opacity, or visual acuity <6/60 (eyes); ulceration, traumatic or resorptive changes, claw hand/toes, foot drop (hands/feet)
Reference: WHO. WHO Expert Committee on Leprosy - Seventh Report. WHO Technical Report Series, No. 874. Geneva: WHO; 1998.

4. Deformity

A visible alteration in the form, shape, or appearance of the body resulting from impairment produced by the leprosy disease process (e.g., claw hand, loss of eyebrow, foot drop). Reference: As stated in the synopsis introduction.

5. Nerve Function Impairment (NFI)

Impairment of a peripheral nerve (motor, sensory, or autonomic) attributable to leprosy, assessed by:
  • Sensory testing: using a standard ballpoint pen/monofilament to test protective sensibility.
  • Motor testing: voluntary muscle testing (VMT) of key muscles (e.g., intrinsics of hand, dorsiflexors of foot, orbicularis oculi).
  • Autonomic: anhidrosis / dry skin over the affected area. NFI is classified as sensory NFI (loss of protective sensation only) or motor NFI (weakness/paralysis of muscle), corresponding to Grade 1 and Grade 2 disability respectively. Reference: Van Brakel WH. Measuring leprosy disability: A review of major instruments. Int J Lepr Other Mycobact Dis. 2000;68(4):421-37.

6. Delay in Diagnosis / Registration Delay

Defined as the duration (in months) from the onset of first symptom(s) attributable to leprosy to the date of first registration at the leprosy clinic/DVL OPD. A delay of >6 months is operationally considered as "delayed presentation," consistent with the referenced literature (Rathod SP et al., 2020; Ishore K et al., 2019). Reference: Rathod SP et al. An Bras Dermatol. 2020;95(1):52-56. Ishore K et al. Indian J Lepr. 2019;91:207-215.

7. Lepra Reaction

An acute inflammatory episode occurring in the course of leprosy, classified as:
  • Type 1 Reaction (Reversal Reaction): Sudden upgrading or downgrading reaction, seen in borderline leprosy (BT, BB, BL); characterized by erythematous, edematous skin patches and/or acute NFI.
  • Type 2 Reaction (Erythema Nodosum Leprosum - ENL): Systemic immune complex-mediated reaction occurring in BL/LL patients; characterized by tender erythematous nodules, fever, and systemic involvement. Reference: Standard dermatology/leprology references as cited in the synopsis.

8. Sociodemographic Variables

  • Age: Age in completed years at the time of enrolment (continuous variable; grouped into <30, 30-50, >50 years for analysis).
  • Sex: Male / Female (as per self-report and clinical records).
  • Occupation: Classified as manual labourer vs. non-manual worker, as occupational exposure is a known predictor of disability (Sarkar J et al., 2012).
  • Literacy Status: Illiterate (no formal schooling) vs. literate (any formal education). Reference: Sarkar J et al. Indian J Dermatol Venereol Leprol. 2012;78(3):328-334.

9. Exposure Variable

The primary exposure variable in this study is the clinical type of leprosy (PB vs. MB; Ridley-Jopling classification), with secondary exposure variables being nerve involvement (number and type of nerves affected), registration delay, and lepra reaction.

10. Outcome Variable

The primary outcome is the WHO disability grade (0, 1, or 2) at the time of diagnosis. For regression analysis, disability will be dichotomized as: No/minimal disability (Grade 0) vs. Significant disability (Grade 1 or 2).

All definitions are grounded in the WHO Disability Grading System (1998), NLEP criteria, and the references already cited in the synopsis (Van Brakel 2000; Sarkar J et al. 2012; Rathod SP et al. 2020; Ishore K et al. 2019).

You can directly copy the relevant definitions into the two "Operational Definitions" blanks in your proforma (one appearing after "Equipment Utilized" and one appearing just before "Detailed Methodology"). Both locations expect the same content - the case definition, exposure, and outcome parameters as listed above.

Generate a Word document with all operational definitions formatted professionally

Reading File
Running Command

ls /home/daytona/workspace/ && ls /home/daytona/skills/docx/

Running Command

mkdir -p /home/daytona/workspace/anuj-opdefs && node --version && which node

Running Command

cd /home/daytona/workspace/anuj-opdefs && npm install docx 2>&1 | tail -5

Running Command

find /home/daytona/skills/docx -name "*.js" | head -10; ls /home/daytona/skills/docx/scripts/ 2>/dev/null; find /usr/local/lib/node_modules -maxdepth 1 -name "docx" 2>/dev/null; find /home/daytona -maxdepth 4 -name "docx" -type d 2>/dev/null | head -5

Running Command

ls /home/daytona/skills/docx/scripts/office/ && ls /home/daytona/skills/docx/templates/ 2>/dev/null

Running Command

python3 -c "import docx; print('python-docx available:', docx.__version__)"

Running Command

python3 -c "import docutils; print('ok')" 2>/dev/null; python3 -c "import odf; print('odf ok')" 2>/dev/null; pandoc --version | head -2; python3 -c "from docx import Document; print('ok')" 2>/dev/null; python3 -m pip list 2>/dev/null | grep -i "docx\|oxml\|python-doc"

Writing File

~/anuj-opdefs/operational_definitions.md

---
title: "Operational Definitions"
subtitle: "Clinico-Epidemiological Correlation of Disability Among Newly Diagnosed Leprosy Patients: A Cross-Sectional Study at a Tertiary Care Centre in Moradabad"
author: "Dr. Anuj Jain, PG Resident, Department of Dermatology, Venereology & Leprosy, TMMC & RC, Moradabad"
date: "2025–2028 Batch | M.D. (Dermatology, Venereology & Leprosy)"
---

# Operational Definitions

*(Define cases / controls / exposure / outcome parameters with appropriate references)*

---

## 1. Newly Diagnosed Leprosy Patient (Case Definition)

A patient presenting to the DVL OPD/IPD of TMMC & RC **for the first time** with a diagnosis of leprosy established on the basis of **NLEP/WHO clinical criteria**, defined by the presence of one or more of the following cardinal signs:

- Hypopigmented or erythematous skin lesion(s) with definite loss of sensation
- Thickened peripheral nerve(s) with or without associated loss of sensation / muscle weakness
- Presence of acid-fast bacilli (AFB) on skin slit-smear examination

The patient must be aged **18–65 years**, of either sex, and must **not have previously received any anti-leprosy treatment (MDT)**.

> **Reference:** WHO. *A Guide to Eliminating Leprosy as a Public Health Problem.* Geneva: WHO; 1995. NLEP operational guidelines.

---

## 2. Clinical Type of Leprosy

### 2a. Ridley-Jopling Classification (Histopathological/Clinical)

Patients will be classified into the following spectrum based on clinical features, bacteriological index (BI) on slit-skin smear, and histopathology:

| Type | Description |
|:-----|:------------|
| **TT** (Tuberculoid) | Single well-defined lesion, high cell-mediated immunity, BI = 0 |
| **BT** (Borderline Tuberculoid) | 2–3 lesions, near-normal immunity, BI = 0 |
| **BB** (Mid-Borderline) | Multiple irregular lesions, unstable immunity |
| **BL** (Borderline Lepromatous) | Multiple lesions, weakened immunity, BI positive |
| **LL** (Lepromatous) | Diffuse involvement, low immunity, BI high |
| **Pure Neuritic** | Nerve involvement only, no skin lesion |

> **Reference:** Ridley DS, Jopling WH. Classification of leprosy according to immunity. *Int J Lepr Other Mycobact Dis.* 1966;34(3):255–273.

### 2b. WHO Operational Classification (Field/MDT Use)

| Type | Criteria |
|:-----|:---------|
| **Paucibacillary (PB)** | 1–5 skin lesions; slit-skin smear negative |
| **Multibacillary (MB)** | >5 skin lesions; OR slit-skin smear positive |

> **Reference:** WHO. *MDT for Leprosy.* Geneva: WHO; 1998.

---

## 3. Disability — WHO Disability Grading System (1998)

Physical disability in leprosy is graded **separately for eyes, hands, and feet**. The **highest grade** recorded across any body part is taken as the overall disability grade of the patient.

| Grade | Definition |
|:-----:|:-----------|
| **Grade 0** | No disability; no loss of sensation; no visible deformity or damage to eyes, hands, or feet |
| **Grade 1** | Loss of protective sensibility in eye(s), hand(s), or foot/feet, but **no** visible deformity or damage |
| **Grade 2** | Visible deformity or damage present: lagophthalmos, ectropion, trichiasis, corneal opacity, or visual acuity <6/60 (eyes); ulceration, traumatic or resorptive changes, claw hand/toes, foot drop (hands/feet) |

For regression analysis, disability will be **dichotomised** as:

- **No/minimal disability:** Grade 0
- **Significant disability:** Grade 1 or 2

> **Reference:** WHO Expert Committee on Leprosy — Seventh Report. *WHO Technical Report Series, No. 874.* Geneva: WHO; 1998.

---

## 4. Deformity

A **visible alteration in the form, shape, or appearance of the body** resulting from structural impairment produced by the leprosy disease process. Examples include claw hand, foot drop, claw toes, lagophthalmos, gynecomastia, saddle-nose deformity, and loss of eyebrows (madarosis). Deformity corresponds to **WHO Disability Grade 2**.

> **Reference:** Van Brakel WH. Measuring leprosy disability: A review of major instruments. *Int J Lepr Other Mycobact Dis.* 2000;68(4):421–437.

---

## 5. Nerve Function Impairment (NFI)

Impairment of a peripheral nerve (motor, sensory, or autonomic) attributable to the leprosy disease process, assessed by standardised examination:

- **Sensory NFI:** Loss of protective sensation tested with a standard ballpoint pen or Semmes-Weinstein monofilament over mapped sensory fields of the hand, foot, and cornea — corresponds to **Grade 1 disability**
- **Motor NFI:** Weakness or paralysis of key muscles tested by Voluntary Muscle Testing (VMT): intrinsic muscles of the hand (ulnar/median), dorsiflexors of the foot (peroneal), and orbicularis oculi (facial nerve) — corresponds to **Grade 2 disability**
- **Autonomic NFI:** Anhidrosis or dry/cracked skin over the affected limb segment

Number of nerves involved (single vs. multiple) and specific nerve trunks affected (ulnar, median, radial, common peroneal, posterior tibial, facial, great auricular) will be recorded.

> **Reference:** Van Brakel WH. *Int J Lepr Other Mycobact Dis.* 2000;68(4):421–437. Ishore K, Das DK, Banerjee S. *Indian J Lepr.* 2019;91:207–215.

---

## 6. Delay in Diagnosis / Registration Delay

Defined as the **duration (in months) from the onset of first symptom(s) attributable to leprosy** (skin patch, numbness, nerve pain) **to the date of first registration** at the DVL OPD/IPD of TMMC & RC.

- **No delay:** ≤6 months from symptom onset to registration
- **Delayed presentation:** >6 months from symptom onset to registration

Delayed presentation is associated with higher disability grades and is a key predictor variable in this study.

> **Reference:** Rathod SP, Jagati A, Chowdhary P. Disabilities in leprosy: an open, retrospective analyses of institutional records. *An Bras Dermatol.* 2020;95(1):52–56. Ishore K et al. *Indian J Lepr.* 2019;91:207–215. Sarkar J, Dasgupta A, Dutt D. *Indian J Dermatol Venereol Leprol.* 2012;78(3):328–334.

---

## 7. Lepra Reaction

An acute immunologically mediated inflammatory episode occurring in the course of leprosy, classified as:

| Type | Description |
|:-----|:------------|
| **Type 1 (Reversal Reaction)** | Sudden upgrading or downgrading immunological response seen in borderline leprosy (BT, BB, BL); characterised by acute erythema/oedema of existing skin lesions, tender nerve enlargement, and/or acute NFI |
| **Type 2 (Erythema Nodosum Leprosum — ENL)** | Immune complex-mediated systemic reaction in BL/LL patients; characterised by tender erythematous nodules, fever, malaise, and multi-organ involvement (iridocyclitis, orchitis, arthritis) |

Lepra reaction at the time of diagnosis or prior to enrolment will be documented and correlated with disability grade.

> **Reference:** Standard leprosy management guidelines. WHO; 1998.

---

## 8. Sociodemographic Variables

| Variable | Operational Definition |
|:---------|:----------------------|
| **Age** | Age in completed years at enrolment; grouped as <30, 30–50, >50 years for analysis |
| **Sex** | Male / Female as per self-report and clinical records |
| **Occupation** | **Manual labourer** (agriculture, construction, daily wage labour) vs. **Non-manual worker** (clerical, homemaker, student, unemployed); manual labour is a recognised risk factor for Grade 2 disability due to repeated unperceived trauma |
| **Literacy Status** | **Illiterate** (no formal schooling) vs. **Literate** (any formal schooling completed) |

> **Reference:** Sarkar J, Dasgupta A, Dutt D. Disability among new leprosy patients, an issue of concern: an institution based study in an endemic district for leprosy in the state of West Bengal, India. *Indian J Dermatol Venereol Leprol.* 2012;78(3):328–334.

---

## 9. Exposure Variables

| Exposure Variable | Description |
|:------------------|:------------|
| **Clinical type of leprosy** | PB vs. MB (WHO); TT/BT vs. BB/BL/LL/pure neuritic (Ridley-Jopling) — primary exposure variable |
| **Nerve involvement** | Single nerve vs. multiple nerves (≥2); specific nerve trunks affected |
| **Registration delay** | ≤6 months vs. >6 months from symptom onset |
| **Lepra reaction** | Presence (Type 1 or Type 2) vs. absence at diagnosis |
| **Sociodemographic factors** | Age, sex, occupation, literacy status |

---

## 10. Outcome Variable

| Outcome | Description |
|:--------|:------------|
| **Primary outcome** | WHO Disability Grade (0, 1, or 2) at the time of diagnosis, assessed separately for eyes, hands, and feet |
| **For regression analysis** | Dichotomised as Grade 0 (no disability) vs. Grade 1 or 2 (any disability) |

The **proportion of disability** among newly diagnosed leprosy patients is the primary endpoint, calculated as the number of patients with Grade 1 or Grade 2 disability divided by the total enrolled patients, expressed as a percentage.

> **Reference:** WHO Expert Committee on Leprosy — Seventh Report. *WHO Technical Report Series, No. 874.* Geneva: WHO; 1998. Van Brakel WH. *Int J Lepr Other Mycobact Dis.* 2000;68(4):421–437.

---

*All operational definitions are in accordance with WHO (1998) Disability Grading System, NLEP operational guidelines, and the references cited in the synopsis.*
Running Command

# First generate a default reference doc to customize pandoc --print-default-data-file reference.docx > /home/daytona/workspace/anuj-opdefs/reference.docx 2>&1 echo "exit: $?"

Running Command

cd /home/daytona/workspace/anuj-opdefs && pandoc operational_definitions.md \ --reference-doc=reference.docx \ --from markdown \ --to docx \ --toc \ --toc-depth=2 \ -V geometry:margin=1in \ --metadata title="Operational Definitions" \ -o "Operational_Definitions_Dr_Anuj_Jain.docx" 2>&1 echo "exit: $?"

Running Command

ls -lh /home/daytona/workspace/anuj-opdefs/Operational_Definitions_Dr_Anuj_Jain.docx && python3 /home/daytona/skills/docx/scripts/office/validate.py /home/daytona/workspace/anuj-opdefs/Operational_Definitions_Dr_Anuj_Jain.docx 2>&1

Running Command

cd /tmp && cp /home/daytona/workspace/anuj-opdefs/Operational_Definitions_Dr_Anuj_Jain.docx test_check.docx && unzip -t test_check.docx 2>&1 | tail -5

The file is valid. Here is your download link:

Operational Definitions Dr Anuj Jain

Word Document · DOCX


The Word document includes:
  • Title page header with your full study title, name, batch, and degree
  • Table of Contents (auto-generated, 2 levels deep)
  • 10 numbered sections, each with:
    • A bold definition heading
    • Formatted tables (for WHO grading, Ridley-Jopling classification, exposure/outcome variables, sociodemographic variables)
    • Bullet points for multi-part definitions (NFI, cardinal signs)
    • Block-quoted references at the end of each section
  • A closing note confirming alignment with WHO 1998, NLEP guidelines, and synopsis references
You can open it in MS Word or Google Docs, adjust fonts/margins to match your institution's proforma style, and copy-paste the relevant sections directly into the two "Operational Definitions" blanks in the synopsis proforma.

Insert operational definitions into the synopsis proforma blanks

Running Command

mkdir -p /home/daytona/workspace/anuj-opdefs/unpacked && python3 /home/daytona/skills/docx/scripts/office/unpack.py "/home/daytona/workspace/attachments/0292c806-b1a1-415d-9d93-3f3822f35a3a/anuj synopsis performa.docx" /home/daytona/workspace/anuj-opdefs/unpacked/ 2>&1 && echo "DONE" && ls /home/daytona/workspace/anuj-opdefs/unpacked/

Running Command

cp "/home/daytona/workspace/attachments/0292c806-b1a1-415d-9d93-3f3822f35a3a/anuj synopsis performa.docx" /home/daytona/workspace/anuj-opdefs/synopsis_orig.docx && unzip -o /home/daytona/workspace/anuj-opdefs/synopsis_orig.docx -d /home/daytona/workspace/anuj-opdefs/unpacked/ 2>&1 | tail -5 && echo "DONE"

Running Command

ls -lh "/home/daytona/workspace/attachments/0292c806-b1a1-415d-9d93-3f3822f35a3a/"

Running Command

cp "/home/daytona/workspace/attachments/0292c806-b1a1-415d-9d93-3f3822f35a3a/anuj synopsis performa.docx" /tmp/synopsis_orig.docx && echo "copied"

Running Command

mkdir -p /tmp/unpacked && unzip -o /tmp/synopsis_orig.docx -d /tmp/unpacked/ > /tmp/unzip_log.txt 2>&1 && echo "DONE" && ls /tmp/unpacked/

Running Command

grep -n "Operational\|operational\|OPERATIONAL\|Define cases\|define cases" /tmp/unpacked/word/document.xml | head -20

Running Command

ls /tmp/unpacked/word/ 2>/dev/null && echo "---EXISTS---" || echo "---MISSING---"

Writing File

/tmp/insert_opdefs.py

#!/usr/bin/env python3
"""
Insert 10 Operational Definitions into both placeholder locations
in /tmp/unpacked/word/document.xml.
"""

import re

XML_PATH = "/tmp/unpacked/word/document.xml"

# ── helpers ──────────────────────────────────────────────────────────────────

def body_para(text, para_id):
    """Plain (non-bold) BodyA paragraph."""
    return (
        f'<w:p w14:paraId="{para_id}" w14:textId="77777777" '
        f'w:rsidR="00AB0001" w:rsidRDefault="00AB0001">'
        f'<w:pPr>'
        f'<w:pStyle w:val="BodyA"/>'
        f'<w:spacing w:after="0" w:line="360" w:lineRule="auto"/>'
        f'<w:jc w:val="both"/>'
        f'<w:rPr>'
        f'<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman" w:cs="Times New Roman"/>'
        f'<w:sz w:val="26"/><w:szCs w:val="26"/>'
        f'<w:lang w:val="en-US"/>'
        f'</w:rPr>'
        f'</w:pPr>'
        f'<w:r>'
        f'<w:rPr>'
        f'<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman" w:cs="Times New Roman"/>'
        f'<w:sz w:val="26"/><w:szCs w:val="26"/>'
        f'<w:lang w:val="en-US"/>'
        f'</w:rPr>'
        f'<w:t xml:space="preserve">{text}</w:t>'
        f'</w:r>'
        f'</w:p>'
    )


def bold_run(text):
    """A bold run fragment (no paragraph tags)."""
    return (
        f'<w:r>'
        f'<w:rPr>'
        f'<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman" w:cs="Times New Roman"/>'
        f'<w:b/><w:bCs/>'
        f'<w:sz w:val="26"/><w:szCs w:val="26"/>'
        f'<w:lang w:val="en-US"/>'
        f'</w:rPr>'
        f'<w:t xml:space="preserve">{text}</w:t>'
        f'</w:r>'
    )


def normal_run(text):
    """A normal (non-bold) run fragment."""
    return (
        f'<w:r>'
        f'<w:rPr>'
        f'<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman" w:cs="Times New Roman"/>'
        f'<w:sz w:val="26"/><w:szCs w:val="26"/>'
        f'<w:lang w:val="en-US"/>'
        f'</w:rPr>'
        f'<w:t xml:space="preserve">{text}</w:t>'
        f'</w:r>'
    )


def mixed_para(bold_label, rest_text, para_id):
    """Paragraph with a bold label followed by normal text."""
    return (
        f'<w:p w14:paraId="{para_id}" w14:textId="77777777" '
        f'w:rsidR="00AB0001" w:rsidRDefault="00AB0001">'
        f'<w:pPr>'
        f'<w:pStyle w:val="BodyA"/>'
        f'<w:spacing w:after="0" w:line="360" w:lineRule="auto"/>'
        f'<w:jc w:val="both"/>'
        f'<w:rPr>'
        f'<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman" w:cs="Times New Roman"/>'
        f'<w:sz w:val="26"/><w:szCs w:val="26"/>'
        f'<w:lang w:val="en-US"/>'
        f'</w:rPr>'
        f'</w:pPr>'
        + bold_run(bold_label)
        + normal_run(rest_text)
        + f'</w:p>'
    )

# ── 10 operational definition paragraphs ─────────────────────────────────────
# Each definition: bold label, then the rest of the text as a normal run.
# para_id values are arbitrary unique hex strings (8 chars).

defs = [
    mixed_para(
        "1. Newly Diagnosed Leprosy Patient (Case Definition): ",
        "A patient presenting for the first time to the DVL OPD/IPD at TMMC &amp; RC, Moradabad, "
        "who fulfils \u22651 of the NLEP/WHO cardinal signs of leprosy "
        "(hypopigmented/erythematous skin lesion(s) with loss of sensation; thickening of peripheral "
        "nerve(s) with sensory/motor impairment; positive slit-skin smear for AFB), is aged 18\u201365 years, "
        "and has not previously received MDT for leprosy. "
        "[Ref: NLEP Operational Guidelines 2020; WHO Technical Guide 2018]",
        "AA000001"
    ),
    mixed_para(
        "2. Clinical Type of Leprosy: ",
        "Classified by the Ridley-Jopling (R-J) histopathological spectrum as TT (tuberculoid), "
        "BT (borderline tuberculoid), BB (mid-borderline), BL (borderline lepromatous), "
        "LL (lepromatous leprosy), or Pure Neuritic (PN). For operational/treatment purposes, the "
        "WHO/NLEP field classification is used: Paucibacillary (PB) = 1\u20135 skin lesions and \u22641 nerve "
        "involved; Multibacillary (MB) = >5 skin lesions or >1 nerve involved. "
        "[Ref: Ridley DS &amp; Jopling WH 1966; WHO 2018]",
        "AA000002"
    ),
    mixed_para(
        "3. WHO Disability Grade: ",
        "Assessed separately for eyes, hands and feet using the WHO Disability Grading System (1998): "
        "Grade 0 \u2013 no disability, no anaesthesia, no visible deformity or damage; "
        "Grade 1 \u2013 loss of protective sensation (anaesthesia) in hand/foot, or reduced visual acuity, "
        "but no visible deformity; "
        "Grade 2 \u2013 visible deformity or damage present (lagophthalmos, corneal opacity, visual acuity "
        "&lt;6/60 in eyes; ulceration, resorption, claw hand/toes, wrist/foot drop in hands/feet). "
        "The overall (highest) disability grade across all six sites is recorded as the patient\u2019s "
        "disability grade. [Ref: WHO 1998; Van Brakel et al. 2011]",
        "AA000003"
    ),
    mixed_para(
        "4. Deformity: ",
        "A visible alteration in the form, shape, or appearance of the body resulting from "
        "disease-related impairment, corresponding to WHO Disability Grade 2. In leprosy, deformities "
        "include: for the face \u2013 madarosis, saddle nose, lagophthalmos; for the hands \u2013 claw hand, "
        "wrist drop, trophic ulcer, resorption of digits; for the feet \u2013 claw toes, foot drop, "
        "trophic ulcer, plantar ulcer. [Ref: ILEP Learning Guide 2002; WHO 1998]",
        "AA000004"
    ),
    mixed_para(
        "5. Nerve Function Impairment (NFI): ",
        "Impairment of the sensory and/or motor function of a peripheral nerve trunk affected by "
        "leprosy. Sensory NFI corresponds to WHO Disability Grade 1 (loss of protective sensation "
        "demonstrated by inability to feel a ballpoint pen touch or failure to detect "
        "Semmes\u2013Weinstein 2-g monofilament). Motor NFI corresponds to Grade 2 (weakness or "
        "paralysis detected on Voluntary Muscle Testing [VMT]: Strong [S] = full power, "
        "Weak [W] = reduced power, Paralysed [P] = no movement). Autonomic NFI manifests as "
        "anhidrosis and dry skin. [Ref: ILEP Technical Guide 2001; WHO 1998]",
        "AA000005"
    ),
    mixed_para(
        "6. Delay in Diagnosis (Registration Delay): ",
        "The interval in months between the onset of the patient\u2019s first leprosy-related symptom "
        "(skin lesion, numbness, tingling, or nerve thickening as reported by the patient) and the "
        "date of first registration at the DVL OPD/IPD of TMMC &amp; RC. A delay of >6 months from "
        "symptom onset to registration is classified as \u201cdelayed diagnosis/registration.\u201d "
        "[Ref: Sarkar J et al. IJDVL 2012; Ishore K et al. Indian J Lepr 2019]",
        "AA000006"
    ),
    mixed_para(
        "7. Lepra Reaction: ",
        "An acute immunological episode occurring in the course of leprosy. "
        "Type 1 Reaction (Reversal Reaction \u2013 RR): Characterised by acute inflammation of existing "
        "skin lesions (becoming erythematous, oedematous, raised) and/or acute neuritis, occurring in "
        "borderline (BT/BB/BL) leprosy due to a cell-mediated immune upgrading reaction. "
        "Type 2 Reaction (Erythema Nodosum Leprosum \u2013 ENL): Characterised by the appearance of "
        "tender erythematous cutaneous/subcutaneous nodules, often with systemic features (fever, "
        "malaise, neuritis, iritis), occurring in BL/LL leprosy due to immune complex deposition. "
        "[Ref: ILEP Learning Guide 2002; Lockwood DNJ 2004]",
        "AA000007"
    ),
    mixed_para(
        "8. Sociodemographic Variables: ",
        "Age (recorded in completed years, grouped as 18\u201330, 31\u201345, 46\u201365); "
        "Sex (male/female); Occupation (categorised as manual labourer [farmer, construction worker, "
        "daily wage labourer] versus non-manual [housewife, student, skilled/service worker]); "
        "Literacy status (illiterate = cannot read or write; literate = can read and write at least "
        "in the local language).",
        "AA000008"
    ),
    mixed_para(
        "9. Exposure Variables: ",
        "Variables recorded at the time of diagnosis to examine their association with disability. "
        "Include: clinical type of leprosy (R-J classification; WHO PB/MB classification); number "
        "and type of nerves involved; registration delay (\u22646 months vs >6 months); presence and "
        "type of lepra reaction (none/Type 1/Type 2/both).",
        "AA000009"
    ),
    mixed_para(
        "10. Outcome Variable: ",
        "WHO Disability Grade (0, 1, or 2) assessed at first registration. For descriptive analysis, "
        "all three grades are reported. For binary logistic regression to identify predictors of "
        "disability, the outcome is dichotomised as: No disability (Grade 0) vs Any disability "
        "(Grade 1 or Grade 2). [Ref: WHO 1998; Sarkar J et al. IJDVL 2012]",
        "AA000010"
    ),
]

# Join all 10 definition paragraphs into one block
OPDEFS_XML = "".join(defs)

# ── read document.xml ─────────────────────────────────────────────────────────
with open(XML_PATH, "r", encoding="utf-8") as f:
    xml = f.read()

original_len = len(xml)

# ── Location 1 ────────────────────────────────────────────────────────────────
# The placeholder paragraph (paraId 30A82DA8) contains the italic hint text:
#   "(Define cases / controls / exposure / outcomes) with appropriate reference"
# We find the END of that paragraph (</w:p>) and append op-defs after it.

ANCHOR1 = "(Define cases / controls / exposure / outcomes) with appropriate reference"

idx1 = xml.find(ANCHOR1)
if idx1 == -1:
    raise ValueError("ANCHOR1 not found in document.xml")

# Find the closing </w:p> after anchor1
close1 = xml.find("</w:p>", idx1)
if close1 == -1:
    raise ValueError("</w:p> not found after ANCHOR1")

insert_pos1 = close1 + len("</w:p>")
xml = xml[:insert_pos1] + OPDEFS_XML + xml[insert_pos1:]
print(f"Location 1: inserted {len(OPDEFS_XML)} chars after position {insert_pos1}")

# ── Location 2 ────────────────────────────────────────────────────────────────
# The placeholder paragraph (paraId 32EF4975) contains:
#   "(Define cases / controls / exposure / outcome parameters"
# (note: no closing parenthesis in the source XML)

ANCHOR2 = "(Define cases / controls / exposure / outcome parameters"

idx2 = xml.find(ANCHOR2)
if idx2 == -1:
    raise ValueError("ANCHOR2 not found in document.xml")

close2 = xml.find("</w:p>", idx2)
if close2 == -1:
    raise ValueError("</w:p> not found after ANCHOR2")

# Use separate para_id suffix "B" to avoid duplicate paraIds
OPDEFS_XML_B = OPDEFS_XML.replace('"AA00000', '"BB00000')
insert_pos2 = close2 + len("</w:p>")
xml = xml[:insert_pos2] + OPDEFS_XML_B + xml[insert_pos2:]
print(f"Location 2: inserted {len(OPDEFS_XML_B)} chars after position {insert_pos2}")

# ── write back ────────────────────────────────────────────────────────────────
with open(XML_PATH, "w", encoding="utf-8") as f:
    f.write(xml)

print(f"Done. Original size: {original_len} chars → New size: {len(xml)} chars")
Running Command

python3 /tmp/insert_opdefs.py

Running Command

cd /tmp && zip -r /home/daytona/workspace/anuj-opdefs/synopsis_with_opdefs.docx unpacked/ 2>&1 | tail -5; echo "EXIT:$?"

Running Command

rm -f /home/daytona/workspace/anuj-opdefs/synopsis_with_opdefs.docx; cd /tmp/unpacked && zip -r /home/daytona/workspace/anuj-opdefs/synopsis_with_opdefs.docx . 2>&1; echo "EXIT:$?"

Running Command

ls -la /tmp/unpacked/ && cat /tmp/unpacked/\[Content_Types\].xml | head -3 2>&1; echo "EXIT:$?"

Running Command

python3 - <<'EOF' import zipfile, os, pathlib src = pathlib.Path("/tmp/unpacked") out = "/home/daytona/workspace/anuj-opdefs/synopsis_with_opdefs.docx" with zipfile.ZipFile(out, "w", compression=zipfile.ZIP_DEFLATED) as zf: for path in sorted(src.rglob("*")): if path.is_file(): arcname = str(path.relative_to(src)) zf.write(str(path), arcname) print("Written:", out) print("Size:", os.path.getsize(out), "bytes") EOF

Running Command

python3 - <<'EOF' import zipfile, os, pathlib, shutil src = pathlib.Path("/tmp/unpacked") tmp_out = "/tmp/synopsis_with_opdefs.docx" final_out = "/home/daytona/workspace/anuj-opdefs/synopsis_with_opdefs.docx" with zipfile.ZipFile(tmp_out, "w", compression=zipfile.ZIP_DEFLATED) as zf: for path in sorted(src.rglob("*")): if path.is_file(): arcname = str(path.relative_to(src)) zf.write(str(path), arcname) print("Zip written:", tmp_out, os.path.getsize(tmp_out), "bytes") shutil.copy2(tmp_out, final_out) print("Copied to:", final_out, os.path.getsize(final_out), "bytes") EOF

Running Command

python3 -c "import shutil, os; shutil.copy('/tmp/synopsis_with_opdefs.docx', '/home/daytona/workspace/anuj-opdefs/synopsis_with_opdefs.docx'); print('OK', os.path.getsize('/home/daytona/workspace/anuj-opdefs/synopsis_with_opdefs.docx'))" && unzip -t /home/daytona/workspace/anuj-opdefs/synopsis_with_opdefs.docx 2>&1 | tail -5

Running Command

python3 - <<'EOF' src = "/tmp/synopsis_with_opdefs.docx" dst = "/home/daytona/workspace/anuj-opdefs/synopsis_with_opdefs.docx" with open(src, "rb") as f: data = f.read() with open(dst, "wb") as f: f.write(data) import os; print("OK", os.path.getsize(dst), "bytes") EOF unzip -t /home/daytona/workspace/anuj-opdefs/synopsis_with_opdefs.docx 2>&1 | tail -4

Model call limits exceeded: run limit (20/20)
This is a shared conversation. Sign in to Orris to start your own chat.