# Upsert Patient Case Attachment

> Perform Upsert Patient Case Attachment through athenahealth.

Source: [https://genhealth.ai/docs/workflows/integrations/athenahealth/athena_upsert_patient_case_attachment](https://genhealth.ai/docs/workflows/integrations/athenahealth/athena_upsert_patient_case_attachment)

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

- Handler: `athena_upsert_patient_case_attachment`

## Inputs

- `document_id` — Document Id (expression, required)
  Required literal value or workflow expression.
- `patient_id` — Patient Id (expression, required)
  Required literal value or workflow expression.
- `chart_id` — Chart Id (expression, required)
  Required literal value or workflow expression.
- `file_path` — File Path (expression)
  Optional literal value or workflow expression.
- `s3_path` — S3 Path (expression)
  Optional literal value or workflow expression.
- `source_document_id` — Source Document Id (expression)
  Optional literal value or workflow expression.
- `document_class` — Document Class (expression)
  Optional literal value or workflow expression.
  Default: `"ADMIN"`
- `content_type` — Content Type (expression)
  Optional literal value or workflow expression.
- `idempotency_key` — Idempotency Key (expression, required)
  Required literal value or workflow expression.
- `close_document` — Close Document (boolean)
  Optional true-or-false value.
  Default: `false`
- `max_pdf_pages_per_attachment` — Max Pdf Pages Per Attachment (number)
  Optional numeric value.
  Default: `33`
- `write_enabled` — Write Enabled (boolean)
  Optional true-or-false value.
  Default: `false`

## Outputs

- `success` — Success
- `submitted` — Submitted
- `write_skipped` — Write Skipped
- `skip_reason` — Skip Reason
- `document_id` — Document Id
- `attachment_document_id` — Attachment Document Id
- `attachment_document_ids` — Attachment Document Ids
- `attachment_count` — Attachment Count
- `part_count` — Part Count
- `uploaded` — Uploaded
- `uploaded_count` — Uploaded Count
- `reused` — Reused
- `reused_count` — Reused Count
- `attached` — Attached
- `attached_count` — Attached Count
- `attach_call_count` — Attach Call Count
- `document_complete` — Document Complete
- `match_count` — Match Count
- `failure_phase` — Failure Phase
- `error_code` — Error Code
- `retryable` — Retryable
- `error` — Error
- `error_message` — Error Message

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": [
    "document_id",
    "patient_id",
    "chart_id",
    "idempotency_key"
  ],
  "properties": {
    "s3_path": {
      "description": "Optional literal value or workflow expression.",
      "x-workflow-field-type": "expression"
    },
    "chart_id": {
      "description": "Required literal value or workflow expression.",
      "x-workflow-field-type": "expression"
    },
    "file_path": {
      "description": "Optional literal value or workflow expression.",
      "x-workflow-field-type": "expression"
    },
    "patient_id": {
      "description": "Required literal value or workflow expression.",
      "x-workflow-field-type": "expression"
    },
    "document_id": {
      "description": "Required literal value or workflow expression.",
      "x-workflow-field-type": "expression"
    },
    "content_type": {
      "description": "Optional literal value or workflow expression.",
      "x-workflow-field-type": "expression"
    },
    "write_enabled": {
      "type": "boolean",
      "default": false,
      "description": "Optional true-or-false value.",
      "x-workflow-field-type": "boolean"
    },
    "close_document": {
      "type": "boolean",
      "default": false,
      "description": "Optional true-or-false value.",
      "x-workflow-field-type": "boolean"
    },
    "document_class": {
      "default": "ADMIN",
      "description": "Optional literal value or workflow expression.",
      "x-workflow-field-type": "expression"
    },
    "idempotency_key": {
      "description": "Required literal value or workflow expression.",
      "x-workflow-field-type": "expression"
    },
    "source_document_id": {
      "description": "Optional literal value or workflow expression.",
      "x-workflow-field-type": "expression"
    },
    "max_pdf_pages_per_attachment": {
      "type": "number",
      "default": 33,
      "description": "Optional numeric value.",
      "x-workflow-field-type": "number"
    }
  },
  "additionalProperties": false
}
```

### Output schema

```json
{
  "type": "object",
  "properties": {
    "error": {},
    "reused": {},
    "success": {},
    "attached": {},
    "uploaded": {},
    "retryable": {},
    "submitted": {},
    "error_code": {},
    "part_count": {},
    "document_id": {},
    "match_count": {},
    "skip_reason": {},
    "reused_count": {},
    "error_message": {},
    "failure_phase": {},
    "write_skipped": {},
    "attached_count": {},
    "uploaded_count": {},
    "attachment_count": {},
    "attach_call_count": {},
    "document_complete": {},
    "attachment_document_id": {},
    "attachment_document_ids": {}
  },
  "additionalProperties": true
}
```
