# SetPrimaryContactPerson

## Permission Scope

contactPerson

## Overview

setPrimaryContactPerson designates a contact person as the primary contact for their organization partner. The previous primary contact person for the same organization is automatically unset. Only ACTIVE contact persons can be designated as primary. This ensures that each organization partner has at most one primary contact person at any time.

## Business Rules

- Contact person must exist in the system
- Contact person must be in ACTIVE status
- The previous primary contact person for the same organization is automatically unset
- Each organization partner can have at most one primary contact person

## Process Flow

```mermaid
flowchart TD
    A[Receive set primary request] --> B{Contact person exists?}
    B -->|No| C[Return error: contact person not found]
    B -->|Yes| D{Status is ACTIVE?}
    D -->|No| E[Return error: invalid state transition]
    D -->|Yes| F{Organization has existing primary?}
    F -->|Yes| G[Unset previous primary]
    G --> H[Set new primary contact person]
    F -->|No| H
    H --> I[Return updated contact person]
```

## External Dependencies

- None

## Error Scenarios

- **CONTACT_PERSON_NOT_FOUND**: Specified contact person ID does not exist
- **INVALID_STATE_TRANSITION**: Requested state transition is not allowed from the current status

## Test Cases

- sets contact as primary
- unsets previous primary contact
- returns error when contact not found
- returns error when contact is inactive
