# Margin Scorecard (persist + render)

> Perform Margin Scorecard (persist + render) through Brightree.

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

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

- Handler: `brightree_margin_scorecard`

- Connection type: `brightree`

## Inputs

- `org_label` — Org Label (text, required)
  Required text value.
- `period_days` — Period Days (number)
  Optional numeric value.
  Default: `0`
- `date_from` — Date From (date)
  Optional date in YYYY-MM-DD format.
- `date_to` — Date To (date)
  Optional date in YYYY-MM-DD format.
- `min_claim_age_days` — Min Claim Age Days (number, required)
  Required numeric value.
  Default: `50`
- `min_group_orders` — Min Group Orders (number, required)
  Required numeric value.
  Default: `8`
- `top_n` — Top N (number, required)
  Required numeric value.
  Default: `15`
- `persist_snapshot` — Persist Snapshot (boolean, required)
  Required true-or-false value.
  Default: `true`

## Outputs

- `success` — Success
- `period_start` — Period Start
- `period_end` — Period End
- `line_count` — Line Count
- `paid_line_count` — Paid Line Count
- `unpaid_line_count` — Unpaid Line Count
- `revenue` — Revenue
- `cost` — Cost
- `gp_dollars` — Gp Dollars
- `gp_pct` — Gp Pct
- `has_prior_period` — Has Prior Period
- `prior_gp_pct` — Prior Gp Pct
- `gp_pct_change` — Gp Pct Change
- `comparable_to_prior` — Comparable To Prior
- `snapshot_id` — Snapshot Id
- `snapshot_persisted` — Snapshot Persisted
- `html_body` — Html Body
- `subject` — Subject
- `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": [
    "org_label",
    "min_claim_age_days",
    "min_group_orders",
    "top_n",
    "persist_snapshot"
  ],
  "properties": {
    "top_n": {
      "type": "number",
      "default": 15,
      "description": "Required numeric value.",
      "x-workflow-field-type": "number"
    },
    "date_to": {
      "type": "string",
      "format": "date",
      "description": "Optional date in YYYY-MM-DD format.",
      "x-workflow-field-type": "date"
    },
    "date_from": {
      "type": "string",
      "format": "date",
      "description": "Optional date in YYYY-MM-DD format.",
      "x-workflow-field-type": "date"
    },
    "org_label": {
      "type": "string",
      "description": "Required text value.",
      "x-workflow-field-type": "text"
    },
    "period_days": {
      "type": "number",
      "default": 0,
      "description": "Optional numeric value.",
      "x-workflow-field-type": "number"
    },
    "min_group_orders": {
      "type": "number",
      "default": 8,
      "description": "Required numeric value.",
      "x-workflow-field-type": "number"
    },
    "persist_snapshot": {
      "type": "boolean",
      "default": true,
      "description": "Required true-or-false value.",
      "x-workflow-field-type": "boolean"
    },
    "min_claim_age_days": {
      "type": "number",
      "default": 50,
      "description": "Required numeric value.",
      "x-workflow-field-type": "number"
    }
  },
  "additionalProperties": false
}
```

### Output schema

```json
{
  "type": "object",
  "properties": {
    "cost": {},
    "error": {},
    "gp_pct": {},
    "revenue": {},
    "subject": {},
    "success": {},
    "html_body": {},
    "gp_dollars": {},
    "line_count": {},
    "period_end": {},
    "snapshot_id": {},
    "period_start": {},
    "prior_gp_pct": {},
    "gp_pct_change": {},
    "paid_line_count": {},
    "has_prior_period": {},
    "unpaid_line_count": {},
    "snapshot_persisted": {},
    "comparable_to_prior": {}
  },
  "additionalProperties": true
}
```
