> ## Documentation Index
> Fetch the complete documentation index at: https://docs.medwrite.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Send HL7 Message

> Send ADT messages to the HL7 Receiver over MLLP TCP

The HL7 Receiver accepts ADT (Admit, Discharge, Transfer) messages over an MLLP (Minimum Lower Layer Protocol) TCP connection. The service listens for inbound HL7 v2.4 messages, processes them, and returns an acknowledgment on the same connection.

## Connection

```
MLLP {{host}}:{{port}}
```

## Authentication

| Credential     | Type | Required | Description                |
| -------------- | ---- | -------- | -------------------------- |
| Network Access | IP   | Yes      | Authorised network access. |

## Message format

The message must be framed using the MLLP protocol. The receiver also accepts messages with missing start or end blocks.

| Component   | Required | Description                                                        |
| ----------- | -------- | ------------------------------------------------------------------ |
| Start Block | No       | MLLP start-of-message marker. Recommended for standard compliance. |
| HL7 Content | Yes      | A valid HL7 v2.4 message with pipe-delimited segments.             |
| End Block   | No       | MLLP end-of-message marker. Recommended for standard compliance.   |

## Message segments

The receiver processes the following HL7 segments from each inbound message.

| Segment          | Description                                                               |
| ---------------- | ------------------------------------------------------------------------- |
| Message Header   | Identifies sending and receiving applications, message type, and version. |
| Event            | Describes the event (e.g. admission, discharge).                          |
| Patient Identity | Patient demographics: name, DOB, gender, address.                         |
| Patient Visit    | Visit details: location, attending doctor, admission/discharge times.     |
| Visit Additional | Supplementary visit information (e.g. expected discharge date).           |
| Next of Kin      | Emergency contacts and relationship to patient.                           |
| Insurance        | Insurance plan and policy information.                                    |

## Response

The receiver returns an HL7 acknowledgment (ACK) over the same TCP connection. The ACK always indicates acceptance to avoid retry loops from the sending system.

```
MSH|...|ACK|{Control ID}|P|2.4
MSA|AA|{Control ID}
```

<Note>
  The receiver always returns an accept acknowledgment. Processing failures are tracked internally and do not produce a negative ACK to the sender.
</Note>

## Error handling

| Condition                         | Acknowledgment Sent | Internal Status |
| --------------------------------- | ------------------- | --------------- |
| Message processed successfully    | Accept              | Processed       |
| Invalid or missing clinic service | Accept              | Clinic Rejected |
| Invalid patient identifier format | Accept              | Partial         |
| Malformed or unparseable message  | Accept              | Failed          |
| Message decode failure            | Accept              | Failed          |
| Empty or zero-length message      | Accept              | Health Check    |

<Note>
  For authentication credentials and access setup, contact the **medWrite team**.
</Note>

## Next steps

<Columns cols={2}>
  <Card title="HL7 Phases" icon="layer-group" href="/hl-7-phases">
    ADT event types: A01, A02, A03, A04, A08, A11–A13.
  </Card>

  <Card title="Get Approved Outputs" icon="file-check" href="/get-approved-outputs">
    Retrieve approved letters via API.
  </Card>
</Columns>
