widgets

πŸ₯ LocumTele Medical Form Generator System

A complete Python-based medical form generation system for GHL white-label healthcare businesses. Generates dynamic, responsive medical screening forms from JSON data with advanced conditional logic, BMI calculation, and comprehensive API integration.

πŸš€ Quick Start

Installation

cd python-forms
pip install -r requirements.txt

Generate a Complete Medical Form

python3 regenerate_complete_form.py

This will generate surveys/weightloss/GLP1-screener-live.html - a complete medical screening form ready for testing.

πŸ“ Project Structure

python-forms/
β”œβ”€β”€ enhanced_form_generator.py       # Core medical form generation engine
β”œβ”€β”€ form_data_loader.py             # JSON data loader from local directories
β”œβ”€β”€ regenerate_complete_form.py     # Form regeneration script
β”œβ”€β”€ ../surveys/all-forms/           # Shared sections (Patient Profile, Medical History, etc.)
β”‚   β”œβ”€β”€ patient-profile.json
β”‚   β”œβ”€β”€ medical-history.json
β”‚   └── verification.json
β”œβ”€β”€ SHOW_CONDITION_PATTERNS.md      # Conditional logic documentation
└── README.md                      # This file

πŸ”§ Core Components

1. Enhanced Form Generator (enhanced_form_generator.py)

Advanced medical form generator with complete healthcare-specific functionality.

Key Features:

Usage:

from enhanced_form_generator import EnhancedFormGenerator
from form_data_loader import FormDataLoader

# Load form data from JSON files
loader = FormDataLoader()
form_data = loader.generate_complete_form_data("Weightloss", "GLP1", "async")

# Generate complete form
generator = EnhancedFormGenerator()
html = generator.generate_notion_form(form_data)

# Save to file
with open("medical_form.html", "w") as f:
    f.write(html)

2. Form Data Loader (form_data_loader.py)

Intelligent JSON parser that combines general sections with form-specific assessments.

Features:

Supported Sections:

3. Conditional Logic System

Advanced conditional logic for medical forms with comprehensive patterns.

Available Conditions:

Implementation:

// Example: Pregnancy question only for females
{
  "property_show_condition": "if_gender_female",
  "property_question_text": "Are you currently pregnant or breastfeeding?"
}

🌐 Generated Form Features

Form Functionality

Medical-Specific Features

API Integration

Data Structure Sent to API

{
  "contact": {
    "name": "Patient Name",
    "email": "patient@email.com",
    "phone": "(555) 123-4567",
    "address": "123 Main St",
    "address2": "Apt 1",
    "city": "City",
    "state": "CA",
    "postalCode": "12345",
    "type": "patient"
  },
  "patient": {
    "rxRequested": "GLP1",
    "height": "5'10\"",
    "weight": "180",
    "BMI": "25.8"
  },
  "form": {
    "formType": "screener",
    "category": "Weightloss",
    "screener": "GLP1",
    "timestamp": "2025-01-21T...",
    "formVersion": "1.0",
    "answers": {
      "What is your exercise level?": "moderate",
      "Do you have any allergies?": "no",
      "Do you currently use tobacco or vape?": "no"
    },
    "consultType": "async"
  },
  "clinic": {
    "name": "",
    "id": "",
    "type": "healthcare"
  }
}

🎯 Current Implementation Status

βœ… Completed Features

πŸ“Š Form Statistics

πŸ§ͺ Testing Checklist

  1. βœ… Phone number formatting and validation
  2. βœ… Female gender β†’ pregnancy question appears
  3. βœ… Height/weight β†’ BMI calculates automatically
  4. βœ… BMI under 25 β†’ can proceed to see value in Assessment
  5. βœ… Tobacco β€œyes” β†’ follow-up question appears
  6. βœ… Disqualifying answers β†’ modern styled messages appear
  7. βœ… Form submission β†’ complete data sent to webhook
  8. βœ… State selection β†’ proper async/sync routing
  9. βœ… File uploads β†’ validation and visual feedback
  10. βœ… Form persistence β†’ remembers progress across sessions

πŸ”„ Development Workflow

Making Changes

  1. Update JSON data: Modify files in ../surveys/all-forms/ or ../surveys/{category}/
  2. Update generator: Modify enhanced_form_generator.py for UI/logic changes
  3. Regenerate form: Run python3 regenerate_complete_form.py
  4. Test: Open generated HTML file in browser

Adding New Conditional Logic

  1. Update JSON: Add property_show_condition to question
  2. Update JavaScript: Add condition to checkQuestionVisibility() function
  3. Document: Update SHOW_CONDITION_PATTERNS.md

Adding New Forms

  1. Create JSON: Add new file to ../surveys/{category}/ directory
  2. Update loader: Modify form_data_loader.py if needed
  3. Generate: Use existing generation system

πŸš€ Deployment

For GHL Integration

  1. Generate form: python3 regenerate_complete_form.py
  2. Extract HTML: Copy content from generated .html file
  3. Embed in GHL: Use as custom HTML widget
  4. Test webhook: Verify data reaches n8n endpoint
  1. Open Forms Dashboard: forms-dashboard.html
  2. Navigate to Dashboard tab: Embed Code Library
  3. Copy embed code: Click β€œπŸ“‹ Copy” button for desired form
  4. Paste in client website: Embed code is ready for deployment

Local Development

# Generate and test form
python3 regenerate_complete_form.py
open surveys/weightloss/GLP1-screener-live.html

# Monitor changes
# Edit files β†’ regenerate β†’ test β†’ repeat

πŸ“ Documentation Files

πŸ”§ Configuration

Key Settings

Customization Points

🀝 Maintenance

Regular Tasks

Troubleshooting

πŸ“„ License

This project is part of the LocumTele GHL widget system for white-label healthcare businesses.