# Find or Create Facility

> Perform Find or Create Facility through Brightree.

Source: [https://genhealth.ai/docs/workflows/integrations/brightree/brightree_ensure_facility](https://genhealth.ai/docs/workflows/integrations/brightree/brightree_ensure_facility)

Integration: [Brightree](https://genhealth.ai/docs/workflows/integrations/brightree.md)

- Handler: `brightree_ensure_facility`

- Connection type: `brightree`

## Inputs

- `patient_key` — Patient Key (expression, required)
  Required literal value or workflow expression.
- `facility_name` — Facility Name (expression, required)
  Required literal value or workflow expression.
- `address_1` — Address 1 (expression)
  Optional literal value or workflow expression.
- `city` — City (expression)
  Optional literal value or workflow expression.
- `state` — State (expression)
  Optional literal value or workflow expression.
- `postal_code` — Postal Code (expression)
  Optional literal value or workflow expression.
- `match_address_1` — Match Address 1 (expression)
  Optional literal value or workflow expression.
- `match_city` — Match City (expression)
  Optional literal value or workflow expression.
- `match_state` — Match State (expression)
  Optional literal value or workflow expression.
- `match_postal_code` — Match Postal Code (expression)
  Optional literal value or workflow expression.
- `match_address_source` — Match Address Source (expression)
  Optional literal value or workflow expression.
- `phone` — Phone (expression)
  Optional literal value or workflow expression.
- `fax` — Fax (expression)
  Optional literal value or workflow expression.
- `create_if_missing` — Create If Missing (boolean)
  Optional true-or-false value.
  Default: `true`
- `require_address` — Require Address (boolean)
  Optional true-or-false value.
  Default: `true`

## Outputs

- `success` — Success
- `message` — Message
- `facility` — Facility
- `facility_text` — Facility Text
- `facility_value` — Facility Value
- `facility_key` — Facility Key
- `created` — Created
- `found` — Found
- `skipped` — Skipped
- `action_required` — Action Required
- `action_required_message` — Action Required Message
- `selection_reason` — Selection Reason
- `missing_fields` — Missing Fields
- `error` — Error

Output schema completeness: `best_effort_declared`

## Safety

- External effect: `write`
- Confirmation recommended: no
- Retry safe: no
- Dry run supported: no

## Schemas

These schemas are first-pass authoring guidance. Runtime validation remains authoritative.

### Input schema

```json
{
  "type": "object",
  "required": [
    "patient_key",
    "facility_name"
  ],
  "properties": {
    "fax": {
      "description": "Optional literal value or workflow expression.",
      "x-workflow-field-type": "expression"
    },
    "city": {
      "description": "Optional literal value or workflow expression.",
      "x-workflow-field-type": "expression"
    },
    "phone": {
      "description": "Optional literal value or workflow expression.",
      "x-workflow-field-type": "expression"
    },
    "state": {
      "description": "Optional literal value or workflow expression.",
      "x-workflow-field-type": "expression"
    },
    "address_1": {
      "description": "Optional literal value or workflow expression.",
      "x-workflow-field-type": "expression"
    },
    "match_city": {
      "description": "Optional literal value or workflow expression.",
      "x-workflow-field-type": "expression"
    },
    "match_state": {
      "description": "Optional literal value or workflow expression.",
      "x-workflow-field-type": "expression"
    },
    "patient_key": {
      "description": "Required literal value or workflow expression.",
      "x-workflow-field-type": "expression"
    },
    "postal_code": {
      "description": "Optional literal value or workflow expression.",
      "x-workflow-field-type": "expression"
    },
    "facility_name": {
      "description": "Required literal value or workflow expression.",
      "x-workflow-field-type": "expression"
    },
    "match_address_1": {
      "description": "Optional literal value or workflow expression.",
      "x-workflow-field-type": "expression"
    },
    "require_address": {
      "type": "boolean",
      "default": true,
      "description": "Optional true-or-false value.",
      "x-workflow-field-type": "boolean"
    },
    "create_if_missing": {
      "type": "boolean",
      "default": true,
      "description": "Optional true-or-false value.",
      "x-workflow-field-type": "boolean"
    },
    "match_postal_code": {
      "description": "Optional literal value or workflow expression.",
      "x-workflow-field-type": "expression"
    },
    "match_address_source": {
      "description": "Optional literal value or workflow expression.",
      "x-workflow-field-type": "expression"
    }
  },
  "additionalProperties": false
}
```

### Output schema

```json
{
  "type": "object",
  "properties": {
    "error": {},
    "found": {},
    "created": {},
    "message": {},
    "skipped": {},
    "success": {},
    "facility": {},
    "facility_key": {},
    "facility_text": {},
    "facility_value": {},
    "missing_fields": {},
    "action_required": {},
    "selection_reason": {},
    "action_required_message": {}
  },
  "additionalProperties": true
}
```
