Convert a canonical patient event into an HL7 v2.x ADT message

Convert a canonical :class:`PatientEvent` into an HL7 v2.x ADT message. Runs the full build pipeline minus delivery: build the ADT segments, apply the configuration flags, render the message, then apply the event's ``rule_templates`` (as HL7 rules). The payload is the same canonical structure accepted by ``/patient/validate``, including ``integration_configs`` which drives the HL7 version and which optional segments to emit. Returns the HL7 message as both a ``\r``-joined string and a list of segments (reflecting any rule-driven changes), plus the per-rule log.

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)

segmentslist of strings
The message split into segments
rules_appliedlist of objectsOptional

Per-rule execution log

Errors

422
Unprocessable Entity Error