# Read Outgoing Referral Detail

> Purpose: Read one eClinicalWorks Outgoing referral popup and return its parsed referral record. Use when: A specific referral is already identified and both referral_id and patient_id are available; this reads one popup, not referral search or edits. Inputs: referral_id:string and patient_id:string are required; referral_id should come from ecw_list_outgoing_referrals. encounter_id and request_id are optional strings; blank values are omitted. query_params is an optional JSON object, JSON-encoded object, or blank, with only these case-sensitive keys: ptName, referral360id, extNHXRefTxId, nhxMsgTxId, isReferralDeclined, recType, referralType, callingFrom, refSubType. Values must be strings, numbers, or booleans. The action maps IDs to refId/patientId and, when present, refEncId/nNhxReqId. Outputs: JSON object with success:boolean, error:string|null, notes/clinical_notes/to_facility_name/to_provider_name/status/sub_status_id:string|null, record:flat tag-to-string map|null, and duplicate_tags:string[]. On success the six convenience fields are strings (possibly empty), record contains the selected record's leaf tags, and duplicate tag names appear once while record keeps the first value. On failure the six fields and record are null and duplicate_tags is []. Success: success=true and error=null means ECW returned one parsable referral record; empty convenience strings mean their tags were absent or blank. Failure: success=false and error contains a fixed safe message for invalid input or organization, or an ECW read/parse failure. No record is established. Missing/blank required IDs and invalid query_params are rejected before ECW traffic; read failures can happen after the request. Correct input or organization/session issues before retrying. Effects: Read-only ECW popup GET through the existing authorized organization session; no write occurs. query_params (including ptName) and returned notes/clinical text may contain PHI. Inputs are trace-redacted; PHI values and exception text are not logged. Route outputs only to an authorized caller. Examples: {"referral_id":"r1","patient_id":"p1"} -> {"success":true,"error":null,"notes":"","clinical_notes":"","to_facility_name":"","to_provider_name":"","status":"","sub_status_id":"","record":{"referralId":"r1"},"duplicate_tags":[]}; missing referral_id -> {"success":false,"error":"referral_id is required","notes":null,"clinical_notes":null,"to_facility_name":null,"to_provider_name":null,"status":null,"sub_status_id":null,"record":null,"duplicate_tags":[]}.

Source: [https://genhealth.ai/docs/workflows/integrations/eclinicalworks/ecw_read_outgoing_referral_detail](https://genhealth.ai/docs/workflows/integrations/eclinicalworks/ecw_read_outgoing_referral_detail)

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

- Handler: `ecw_read_outgoing_referral_detail`

- Connection type: `eclinicalworks`

## Use in a workflow

Copy this discovered node config, fill params from the input contract, and validate the complete graph. Integration results are available as {{node_id.default.field}}. Check business success before dependent writes; completion alone does not prove business success.

```json

{
  "_group": "eClinicalWorks",
  "params": {},
  "handler": "ecw_read_outgoing_referral_detail"
}

```

[Action contracts](https://genhealth.ai/docs/workflows/action-contracts.md) · [Run recovery](https://genhealth.ai/docs/workflows/operations.md)

## Inputs

- `referral_id` — Referral Id (text, required)
  Required text value.
- `patient_id` — Patient Id (text, required)
  Required text value.
- `encounter_id` — Encounter Id (text)
  Optional text value.
- `request_id` — Request Id (text)
  Optional text value.
- `query_params` — Query Params (json)
  Optional. Omit it, pass null, or pass a blank string for no extra popup parameters. Otherwise pass an object or a JSON-encoded string that parses to an object. Allowed case-sensitive keys: callingFrom, extNHXRefTxId, isReferralDeclined, nhxMsgTxId, ptName, recType, refSubType, referral360id, referralType. Each value must be a string, number, or boolean; null values, arrays, nested objects, unknown keys, malformed JSON, and JSON strings that decode to non-objects are rejected before ECW traffic. The encoded form is parsed and checked against the same key and scalar-value rules.

## Outputs

- `success` — Success
- `error` — Error
- `notes` — Notes
- `clinical_notes` — Clinical Notes
- `to_facility_name` — To Facility Name
- `to_provider_name` — To Provider Name
- `status` — Status
- `sub_status_id` — Sub Status Id
- `record` — Record
- `duplicate_tags` — Duplicate Tags

Output schema completeness: `reviewed_partial`

## Safety

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

## Schemas

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

### Input schema

```json
{
  "type": "object",
  "required": [
    "referral_id",
    "patient_id"
  ],
  "properties": {
    "patient_id": {
      "type": "string",
      "description": "Required text value.",
      "x-workflow-field-type": "text"
    },
    "request_id": {
      "type": "string",
      "description": "Optional text value.",
      "x-workflow-field-type": "text"
    },
    "referral_id": {
      "type": "string",
      "description": "Required text value.",
      "x-workflow-field-type": "text"
    },
    "encounter_id": {
      "type": "string",
      "description": "Optional text value.",
      "x-workflow-field-type": "text"
    },
    "query_params": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "ptName": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "recType": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "nhxMsgTxId": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "refSubType": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "callingFrom": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "referralType": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "extNHXRefTxId": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "referral360id": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "isReferralDeclined": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            }
          },
          "additionalProperties": false
        },
        {
          "type": "string",
          "anyOf": [
            {
              "pattern": "^\\s*$"
            },
            {
              "contentSchema": {
                "type": "object",
                "properties": {
                  "ptName": {
                    "type": [
                      "string",
                      "number",
                      "boolean"
                    ]
                  },
                  "recType": {
                    "type": [
                      "string",
                      "number",
                      "boolean"
                    ]
                  },
                  "nhxMsgTxId": {
                    "type": [
                      "string",
                      "number",
                      "boolean"
                    ]
                  },
                  "refSubType": {
                    "type": [
                      "string",
                      "number",
                      "boolean"
                    ]
                  },
                  "callingFrom": {
                    "type": [
                      "string",
                      "number",
                      "boolean"
                    ]
                  },
                  "referralType": {
                    "type": [
                      "string",
                      "number",
                      "boolean"
                    ]
                  },
                  "extNHXRefTxId": {
                    "type": [
                      "string",
                      "number",
                      "boolean"
                    ]
                  },
                  "referral360id": {
                    "type": [
                      "string",
                      "number",
                      "boolean"
                    ]
                  },
                  "isReferralDeclined": {
                    "type": [
                      "string",
                      "number",
                      "boolean"
                    ]
                  }
                },
                "additionalProperties": false
              },
              "contentMediaType": "application/json"
            }
          ]
        },
        {
          "type": "null"
        }
      ],
      "description": "Optional. Omit it, pass null, or pass a blank string for no extra popup parameters. Otherwise pass an object or a JSON-encoded string that parses to an object. Allowed case-sensitive keys: callingFrom, extNHXRefTxId, isReferralDeclined, nhxMsgTxId, ptName, recType, refSubType, referral360id, referralType. Each value must be a string, number, or boolean; null values, arrays, nested objects, unknown keys, malformed JSON, and JSON strings that decode to non-objects are rejected before ECW traffic. The encoded form is parsed and checked against the same key and scalar-value rules.",
      "x-workflow-field-type": "json"
    }
  },
  "additionalProperties": false
}
```

### Output schema

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": [
        "string",
        "null"
      ]
    },
    "notes": {},
    "record": {},
    "status": {},
    "success": {
      "type": "boolean"
    },
    "sub_status_id": {},
    "clinical_notes": {},
    "duplicate_tags": {},
    "to_facility_name": {},
    "to_provider_name": {}
  },
  "additionalProperties": true
}
```
