Skip to content

Using AI to Convert Legacy Forms

Overview

You can use Large Language Models (LLMs) like Claude, ChatGPT, or GitHub Copilot to assist with the conversion of Legacy Task forms to Task Manager protocol format. This approach has been tested on a few forms and has worked reasonably well, potentially reducing conversion time from 2-4 hours to approximately 10-15 minutes per form.

Experimental Approach

This LLM-assisted conversion process is a suggested approach, not a guaranteed method. It may not work for all forms, particularly those with complex conditional logic or unusual structures. Always thoroughly review and test the converted output before using in production.

Prerequisites

Before starting a conversion, gather these required files:

Technical Specification Documents

These documents define the conversion rules and output format:

  • Form Conversion Specification: legacy-to-task-manager-form-conversion.md
  • Form Schema Reference: user_protocol_form_technical.md
  • E-signature Reference (optional): user_protocol_esignature_technical.md

Legacy Form File

The source form in Legacy OHIF JSON format that you want to convert (for example, form-retinopathy-grading-v2.json). It is the same example used in the Legacy Form Conversion Example.

Claude (Anthropic) is recommended for form conversion because:

  • Large context window (200K tokens) handles multiple documents easily
  • Excellent at following complex technical specifications
  • Capable of processing multiple files simultaneously

Use Claude Sonnet 4.5 or newer via Claude.ai or API.

Alternative platforms: ChatGPT (GPT-4 Turbo or newer) or GitHub Copilot can also work but may require more careful context management.

Conversion Steps

Step 1: Upload Documents to the LLM

Provide these files to your chosen LLM platform:

Required:

  • legacy-to-task-manager-form-conversion.md (conversion specification)
  • user_protocol_form_technical.md (form schema reference)
  • Your legacy form JSON file (for example, form-retinopathy-grading-v2.json)

Optional:

  • user_protocol_esignature_technical.md (if form requires e-signatures)

Step 2: Request the Conversion

Use this prompt template:

I need to convert a Legacy Task (OHIF) form to Task Manager protocol format.

Context files provided:
1. legacy-to-task-manager-form-conversion.md (technical specification)
2. user_protocol_form_technical.md (form schema reference)
3. [legacy-form-file].json (source form)

Task:
- Convert the legacy form to Task Manager protocol format following the
  technical specification exactly
- Create a protocol JSON file with only `form` and `esignature_config` keys
- Generate conversion notes documenting all changes

Output files:
1. [form-name]-protocol.json
2. [form-name]-conversion-notes.md

Replace [legacy-form-file] and [form-name] with your actual file names.

Step 3: Review the Output

The LLM should create two files:

  1. Protocol JSON File ([form-name]-protocol.json)

    • Contains the converted form in Task Manager format
    • Has only two top-level keys: form and esignature_config
  2. Conversion Notes ([form-name]-conversion-notes.md)

    • Documents all changes made during conversion
    • Provides field-by-field conversion summary
    • Includes testing checklist

Quick Verification Checklist

After receiving the LLM output, verify these essential aspects:

Protocol Structure

Verify the JSON file has the correct top-level structure:

1
2
3
4
5
6
7
8
9
{
  "form": {
    "title": "...",
    "description": "...",
    "defaults": {...},
    "fields": [...]
  },
  "esignature_config": {...} or null
}

Check:

  • [ ] Only two top-level keys: form and esignature_config
  • [ ] No label, group_id, task_type, etc. (those are provided when uploading via API, not in the file)

Key Property Conversions

Spot-check a few fields to verify these conversions were applied:

  • [ ] components[] changed to fields[]
  • [ ] values[] changed to options[]
  • [ ] validate.required changed to requiredWhenVisible
  • [ ] type: "selectboxes" changed to type: "checkbox"
  • [ ] type: "textfield" changed to type: "text"
  • [ ] type: "textarea" changed to type: "text-area"

JsonLogic Operators

If your form uses conditional visibility, verify:

  • [ ] All == operators changed to === (strict equality)
  • [ ] No legacy operator formats remain

Next Steps

After completing the conversion:

  1. Save the output files - Download both the protocol JSON file and conversion notes
  2. Review conversion notes - Read the documentation to understand what changed
  3. Upload to Task Manager - Use the protocol JSON file when creating your protocol
  4. Test in development - Verify the form works correctly before using in production

Common Issues

Issue: Extra Top-Level Keys in JSON

If the output includes keys like label, group_id, or task_type at the top level, ask the LLM to correct this:

1
2
3
4
The protocol JSON file should contain ONLY two keys: `form` and
`esignature_config`. The other properties (label, group_id, task_type,
protocol_config) are provided via API when uploading, not in the file itself.
Please remove these extra keys.

Issue: Test Placeholder Content

If e-signature reasons contain placeholders like "Test Reason 1", request production-appropriate reasons:

1
2
3
E-signature reasons should be production-appropriate and aligned with the
workflow. Please replace test placeholders with meaningful reasons like
"Initial read per protocol", "Quality assurance review", "Consensus review".