Validate a patient event and return the generated HL7 message

Validate a patient event, generate its HL7 v2.x message, and send it. The body is validated as a :class:`PatientEvent`; a malformed payload is rejected by the framework with a 422 (the standard validation-error envelope). The HL7 version is taken from the event's ``configuration_data.version`` and is required. On success returns ``{"data": ..., "version": ..., "hl7_message": ..., "segments": [...], "rules_applied": [...], "delivery": {...}}``. When ``integration_configs`` selects TCP/IP delivery (``connection_type`` ``TCP/IP`` with a ``host``/``port``), the generated message is also delivered over a plain TCP socket. Delivery is best-effort — an unreachable receiver or missing transport config is reported under ``delivery`` without failing the response. An optional ``integration_payload`` on the event (not part of the canonical HL7 content) is forwarded to the delivery layer so the Fusion worker receives the full integration context / the Mirth receiver gets LABID/LOGID.

Authentication

AuthorizationBearer

Static shared-secret token for internal service-to-service calls.

Request

This endpoint expects an object.
event_typeenumRequired
Type of patient lifecycle event
event_timestampdatetimeRequired

UTC timestamp when the event occurred (ISO 8601)

event_idintegerRequired
Unique monotonic event identifier
patientobjectRequired
Full patient record
organization_detailsobject or nullOptional

Organisation context (absent when the event has no org)

referral_detailsobject or nullOptional

Referral source context (absent when there is no referral)

laboratory_informationobject or nullOptional

Laboratory context (absent when not supplied)

rule_templateslist of objectsOptional

Rule templates attached to the event (applied downstream)

integration_configsobject or nullOptional
Integration configuration used to build the outbound message
integration_payloadmap from strings to any or nullOptional

Transport/logging metadata (log_id, lab_id, callback context). Not part of the canonical event; forwarded to the delivery layer so the Fusion worker receives full context / the Mirth receiver gets LABID/LOGID segments.

Response

Successful Response
versionstring
HL7 version of the rendered message, e.g. '2.5'
segment_countinteger
Number of segments in the message
hl7_messagestring

Rendered HL7 message (‘\r’-joined)

datamap from strings to any
The validated canonical event
segmentslist of strings
The message split into segments
deliveryobject

Delivery outcome (best-effort)

rules_appliedlist of objectsOptional

Per-rule execution log

Errors

422
Unprocessable Entity Error