> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/appertafoundation/openeyes/llms.txt
> Use this file to discover all available pages before exploring further.

# OphCoCorrespondence Module

> Letter generation and clinical correspondence in OpenEyes

# OphCoCorrespondence - Letters

The **OphCoCorrespondence** module provides robust letter generation and clinical correspondence capabilities, enabling efficient communication with GPs, patients, and other healthcare providers.

## Overview

OphCoCorrespondence handles all clinical correspondence needs:

* GP clinic letters
* Patient letters
* Internal referral letters
* Discharge summaries
* Investigation result notifications
* Specialist-to-specialist correspondence

<Note>
  The module supports both printed and electronic letter distribution, with template-based content generation and digital signature capabilities.
</Note>

## Core Element - ElementLetter

The primary model for correspondence:

```php theme={null}
ElementLetter
```

### Key Properties

**Header Information:**

* `use_nickname`: Whether to use patient's preferred name
* `date`: Letter date
* `site_id`: Sending hospital site
* `direct_line`: Contact phone number
* `fax`: Fax number (where applicable)
* `clinic_date`: Date of clinic visit referenced

**Recipient Details:**

* `address`: Recipient address (GP, consultant, patient)
* `to_subspecialty_id`: Destination subspecialty for internal referrals
* `to_firm_id`: Destination team/firm for internal referrals
* `to_location_id`: Destination location

**Content Fields:**

* `introduction`: Opening paragraph
* `re`: Subject line (patient details)
* `body`: Main letter content
* `footer`: Closing paragraph and sign-off
* `cc`: Carbon copy recipients

**Status & Workflow:**

* `draft`: Draft status (not finalized)
* `print`: Marked for printing
* `print_all`: Print all attachments with letter
* `locked`: Letter finalized and locked from editing
* `is_signed_off`: Electronic signature applied
* `letter_type_id`: Type of letter (GP, patient, etc.)

**Urgency & Clinical Flags:**

* `is_urgent`: Urgent correspondence flag
* `is_same_condition`: Referral for same condition

**Supersession:**

* `supersession_id`: Links to letter this replaces (for corrections/addenda)

## Letter Types

Configurable letter types for different correspondence needs:

<CardGroup cols={2}>
  <Card title="GP Letter" icon="user-doctor">
    Standard clinic letter to general practitioner documenting examination and management
  </Card>

  <Card title="Patient Letter" icon="person">
    Letter to patient explaining diagnosis, treatment plan, or test results
  </Card>

  <Card title="Internal Referral" icon="hospital">
    Referral to another subspecialty within the same organization
  </Card>

  <Card title="External Referral" icon="share">
    Referral to another hospital or specialist service
  </Card>

  <Card title="Discharge Summary" icon="file-export">
    Summary letter on discharge from service
  </Card>

  <Card title="Results Letter" icon="vial">
    Notification of investigation results
  </Card>
</CardGroup>

## Letter Templates

The correspondence module uses powerful templating to auto-populate letter content from clinical data.

### Template Structure

Letters consist of modular sections:

<Accordion title="Introduction Section">
  **Purpose:** Opening paragraph establishing context

  **Common Content:**

  * Thank you for referring this patient
  * I reviewed this patient in clinic on \[date]
  * This patient attended for \[appointment type]
  * Re-referral regarding \[condition]

  **Macros Available:**

  * `[clinic_date]` - Date of appointment
  * `[appointment_type]` - Type of visit
  * `[referring_doctor]` - Name of referring clinician
</Accordion>

<Accordion title="Body Section">
  **Purpose:** Main clinical content

  **Typical Structure:**

  1. Presenting complaint/reason for visit
  2. Relevant history
  3. Examination findings
  4. Investigation results
  5. Diagnosis
  6. Management plan
  7. Follow-up arrangements

  **Auto-Population:**
  Content can be automatically inserted from:

  * OphCiExamination elements
  * Operation notes
  * Investigation results
  * Medication changes
  * Diagnostic codes
</Accordion>

<Accordion title="Footer Section">
  **Purpose:** Closing and action points

  **Common Content:**

  * Follow-up arrangements
  * Ongoing treatment plan
  * When to seek further help
  * Contact information for queries
  * Sign-off (Yours sincerely, etc.)
</Accordion>

### Macro System

Powerful macro/snippet system for dynamic content:

<AccordionGroup>
  <Accordion title="Patient Macros">
    * `[patient_name]` - Full name
    * `[patient_firstname]` - First name
    * `[patient_lastname]` - Surname
    * `[patient_title]` - Title (Mr, Mrs, etc.)
    * `[patient_dob]` - Date of birth
    * `[patient_age]` - Current age
    * `[patient_NHS_number]` - NHS number
    * `[patient_hospital_number]` - Hospital MRN
    * `[patient_address]` - Full address
  </Accordion>

  <Accordion title="Clinical Macros">
    * `[diagnosis_left]` - Left eye diagnosis
    * `[diagnosis_right]` - Right eye diagnosis
    * `[visual_acuity_left]` - Left VA
    * `[visual_acuity_right]` - Right VA
    * `[iop_left]` - Left eye pressure
    * `[iop_right]` - Right eye pressure
    * `[current_medications]` - Medication list
    * `[allergies]` - Patient allergies
    * `[management_plan]` - Treatment plan
  </Accordion>

  <Accordion title="Appointment Macros">
    * `[clinic_date]` - Date of appointment
    * `[clinic_time]` - Appointment time
    * `[clinic_location]` - Clinic location
    * `[consultant]` - Seeing consultant
    * `[next_appointment]` - Follow-up date
    * `[follow_up_period]` - Interval to next visit
  </Accordion>

  <Accordion title="Correspondence Macros">
    * `[gp_name]` - GP name
    * `[gp_address]` - GP address
    * `[letter_date]` - Date of letter
    * `[site_name]` - Hospital name
    * `[site_address]` - Hospital address
    * `[direct_line]` - Contact phone number
  </Accordion>
</AccordionGroup>

### Custom Snippets

Users can create reusable text snippets for:

* Common clinical findings
* Standard management plans
* Procedure explanations
* Patient advice paragraphs
* Discharge instructions

**Example Snippets:**

```
Snippet: "diabetic_retinopathy_background"
Text: "Retinal examination revealed background diabetic retinopathy 
with scattered microaneurysms and dot hemorrhages. The macula 
appears healthy with no evidence of macular edema."

Snippet: "cataract_post_op"
Text: "The patient has made an excellent recovery from cataract surgery. 
The eye is quiet with the IOL well positioned. I have advised to 
continue the drops for a further 2 weeks and then stop."
```

## Letter Generation Workflow

<Steps>
  <Step title="Create Correspondence Event">
    From patient record, create new correspondence event
  </Step>

  <Step title="Select Letter Type">
    Choose appropriate letter type (GP, patient, referral, etc.)
  </Step>

  <Step title="Select Recipient">
    Choose or enter recipient details (auto-populated for GP letters)
  </Step>

  <Step title="Select Template">
    Choose from available templates for letter type
  </Step>

  <Step title="Review Auto-Population">
    Template fills with data from recent examination/event
  </Step>

  <Step title="Edit Content">
    Customize letter content, add snippets, modify auto-populated text
  </Step>

  <Step title="Add CC Recipients">
    Specify carbon copy recipients (patient, consultants, etc.)
  </Step>

  <Step title="Review">
    Check letter content, formatting, and recipient details
  </Step>

  <Step title="Save or Finalize">
    Save as draft or finalize and lock letter
  </Step>

  <Step title="Sign and Distribute">
    Apply signature and send via print or electronic channels
  </Step>
</Steps>

## Letter Workflow States

### Draft Mode

Letters start in draft mode:

* Can be edited and revised
* Not visible to recipients
* Not printed
* Can be deleted

**Draft Indicators:**

```php theme={null}
$draft = true
$locked = false
```

### Locked/Finalized

Once finalized:

* Content locked from editing
* Available for printing
* Visible in patient record
* Cannot be deleted (only superseded)

**Finalized Indicators:**

```php theme={null}
$draft = false
$locked = true
```

### Signed

Electronic signature applied:

* Digital signature captured or credential-based signing
* Timestamp recorded
* Signing clinician identified
* Letter authenticated for legal purposes

**Signature Properties:**

```php theme={null}
$is_signed_off = true
```

### Superseded

Corrections or addenda:

* Original letter remains in record
* New letter created with `supersession_id` linking to original
* Both versions available for audit trail
* Clear indication that newer version supersedes

**Supersession Link:**

```php theme={null}
$supersession_id = [original_letter_id]
```

## Distribution Methods

### Printing

<Accordion title="Print Queue Management">
  **Batch Printing:**

  * Letters marked for printing added to queue
  * Bulk printing by date, clinic, or user
  * Print all attachments option
  * Print count tracking

  **Print Formats:**

  * Standard letter on headed paper
  * Patient-friendly format
  * Prescription-style for medication changes
  * Fax cover sheet option

  **Print Tracking:**

  * Printed by user recorded
  * Print timestamp captured
  * Reprint audit trail
</Accordion>

### Electronic Distribution

<CardGroup cols={2}>
  <Card title="GP System Integration" icon="network-wired">
    Direct messaging to GP clinical system via NHS mail or spine integration
  </Card>

  <Card title="Patient Portal" icon="computer">
    Secure patient access to letters via online portal
  </Card>

  <Card title="Email" icon="envelope">
    Secure email with encryption for appropriate recipients
  </Card>

  <Card title="Fax" icon="fax">
    Legacy fax transmission where required
  </Card>
</CardGroup>

## Internal Referrals

Special handling for internal referrals between subspecialties:

### Referral Properties

```php theme={null}
$to_subspecialty_id  // Destination subspecialty
$to_firm_id          // Destination team
$to_location_id      // Destination clinic location
$is_same_condition   // Whether same condition as current care
$is_urgent           // Urgency flag
```

### Referral Workflow

1. **Create Internal Referral Letter**: Select internal referral letter type
2. **Choose Destination**: Select subspecialty and firm
3. **Indicate Urgency**: Flag urgent referrals
4. **Provide Clinical Details**: Complete referral with reason and relevant information
5. **Submit**: Referral appears in destination subspecialty worklist
6. **Tracking**: Monitor referral status and acceptance

## Letter Contact Rules

```php theme={null}
OphTrOperationbooking_Letter_Contact_Rule
```

Automatic determination of letter recipients based on rules:

* Patient type (new, follow-up, post-op)
* Clinic type
* Diagnosis
* Procedure performed
* Referral source

**Example Rules:**

* Post-operative letters always CC to patient
* Diabetic retinopathy letters CC to diabetes team
* External referrals CC to referring consultant
* New patient letters include full clinical details
* Follow-up letters may be summary format

## Configuration

### Module Setup

```php theme={null}
'modules' => [
    'OphCoCorrespondence' => [
        'class' => 'application.modules.OphCoCorrespondence.OphCoCorrespondenceModule',
    ],
],
```

### Template Management

Administrators can:

* Create letter templates
* Define macros and auto-population rules
* Set default templates per letter type
* Configure template availability by subspecialty
* Manage snippet library

### Site Configuration

Per-site settings:

* Hospital letterhead details
* Contact information
* Digital signature configuration
* Print settings
* Electronic distribution endpoints

## Integration with Clinical Modules

### OphCiExamination Integration

Letters auto-populate from examination data:

* Visual acuity measurements
* IOP readings
* Examination findings (anterior segment, fundus)
* Diagnoses
* Management plan
* Follow-up arrangements
* Clinic outcome

### OphTrOperationnote Integration

Post-operative letters include:

* Procedures performed
* Surgical findings
* Complications (if any)
* IOL details (for cataract surgery)
* Post-operative instructions
* Follow-up plan

### OphDrPrescription Integration

Medication information:

* Current medications
* Medication changes made
* Stopped medications
* Reasons for changes

## Best Practices

<CardGroup cols={2}>
  <Card title="Timely Correspondence" icon="clock">
    Send letters within institutional targets (typically 7-10 days of clinic)
  </Card>

  <Card title="Clear Language" icon="spell-check">
    Use clear, jargon-free language especially for patient letters
  </Card>

  <Card title="Accurate Recipients" icon="address-book">
    Verify GP and patient details before finalizing
  </Card>

  <Card title="Complete Information" icon="list-check">
    Include all relevant clinical information for continuity of care
  </Card>

  <Card title="Action Points" icon="tasks">
    Clearly state any actions required by GP or patient
  </Card>

  <Card title="Appropriate CC" icon="copy">
    Carbon copy relevant parties (patient, other specialists)
  </Card>
</CardGroup>

## Advanced Features

### Bulk Letter Generation

Generate letters for multiple patients:

* Post-clinic batch processing
* Similar content for cohort (e.g., DNA letters)
* Automated result notification

### Letter Analytics

<CardGroup cols={2}>
  <Card title="Turnaround Time" icon="stopwatch">
    Track time from clinic to letter dispatch
  </Card>

  <Card title="Volume Reporting" icon="chart-bar">
    Monitor correspondence volume by clinician/clinic
  </Card>

  <Card title="Template Usage" icon="file-alt">
    Analyze which templates are most used
  </Card>

  <Card title="Compliance" icon="clipboard-check">
    Report on letter completion targets
  </Card>
</CardGroup>

### Version Control

Complete audit trail:

* All letter versions retained
* Modification history
* User attribution
* Timestamp tracking
* Supersession chain

## Troubleshooting

<Accordion title="Macros Not Populating">
  **Possible Causes:**

  * Data not present in source examination/event
  * Incorrect macro name
  * Examination not recent enough
  * Configuration issue with macro definition

  **Solutions:**

  * Verify source data exists
  * Check macro spelling
  * Select specific event to pull data from
  * Review macro configuration
</Accordion>

<Accordion title="Cannot Finalize Letter">
  **Check:**

  * Required fields completed (recipient, date, etc.)
  * User has permission to finalize
  * No validation errors in content
  * Event is saved
</Accordion>

<Accordion title="Recipient Address Missing">
  **Solutions:**

  * Update patient GP details in demographics
  * Manually enter address
  * Check GP database integration
  * Contact PAS/registration team
</Accordion>

## Related Modules

<CardGroup cols={3}>
  <Card title="Examination" icon="eye" href="/modules/examination">
    Clinical data source for letter content
  </Card>

  <Card title="Operations" icon="hospital" href="/modules/operations">
    Surgical documentation for post-op letters
  </Card>

  <Card title="User Guide" icon="book" href="/user-guide">
    Letter generation workflows
  </Card>
</CardGroup>

## Further Information

<CardGroup cols={2}>
  <Card title="Template Design" icon="palette" href="/admin">
    Creating and managing letter templates
  </Card>

  <Card title="Electronic Distribution" icon="share-nodes" href="/admin">
    Configuring electronic correspondence channels
  </Card>
</CardGroup>
