SMTP Destination
Send messages as email notifications via SMTP for alerts and clinical communication.
Overview
The SMTP destination sends processed messages as emails using the Simple Mail Transfer Protocol. This is commonly used in healthcare for sending alert notifications (critical lab results, ADT events), delivering formatted reports to clinical staff, or routing processed data summaries to administrative recipients. The destination supports TLS encryption and SMTP authentication.
Configuration
Define an SMTP destination in your root intu.yaml under the destinations key:
# intu.yaml
destinations:
critical-alerts:
type: smtp
smtp:
host: smtp.hospital.org
port: 587
from: intu-alerts@hospital.org
to:
- lab-oncall@hospital.org
- chief-pathologist@hospital.org
subject: "Critical Lab Result Alert - ${patientId}"
auth:
username: ${SMTP_USER}
password: ${SMTP_PASS}
tls:
enabled: true
Properties
25 (unencrypted), 465 (implicit TLS), 587 (STARTTLS). Defaults to 587.${VAR} interpolation from message headers and environment variables.text/plain, text/html. Defaults to text/plain.Authentication
${VAR} to reference environment variables.TLS
true.false.Full Example
Monitor HL7v2 ORU messages for critical lab results and send email alerts to the on-call laboratory team.
Root Configuration
# intu.yaml
destinations:
critical-lab-alert:
type: smtp
smtp:
host: smtp.hospital.org
port: 587
from: intu-critical-alerts@hospital.org
to:
- lab-oncall@hospital.org
- pathology-team@hospital.org
cc:
- lab-supervisor@hospital.org
subject: "CRITICAL: Abnormal Lab Result - Patient ${patientId}"
content_type: text/html
auth:
username: ${SMTP_USER}
password: ${SMTP_PASS}
tls:
enabled: true
Channel Configuration
# channels/critical-alerts/channel.yaml
name: critical-alerts
description: Email alerts for critical lab results
source:
type: tcp
tcp:
port: 6665
mode: mllp
destinations:
- critical-lab-alert
Destination Transformer
// channels/critical-alerts/transformer.ts
import { Message, Context } from "@intu/sdk";
export default function transform(msg: Message, ctx: Context): Message | null {
const hl7 = msg.body;
const pid = hl7.segments?.find((s: any) => s.name === "PID");
const obxSegments = hl7.segments?.filter((s: any) => s.name === "OBX") ?? [];
const criticalResults = obxSegments.filter(
(obx: any) => obx.fields[8]?.components[0] === "C"
);
if (criticalResults.length === 0) {
ctx.logger.info("No critical results found, skipping alert");
return null;
}
const patientId = pid?.fields[3]?.components[0] ?? "UNKNOWN";
const patientName = `${pid?.fields[5]?.components[1] ?? ""} ${pid?.fields[5]?.components[0] ?? ""}`.trim();
const resultsHtml = criticalResults
.map((obx: any) => {
const testName = obx.fields[3]?.components[1] ?? "Unknown Test";
const value = obx.fields[5]?.components[0] ?? "";
const units = obx.fields[6]?.components[0] ?? "";
const refRange = obx.fields[7]?.components[0] ?? "";
return `
${testName}
${value} ${units}
${refRange}
`;
})
.join("\n");
const emailBody = `
Critical Lab Result Alert
Patient: ${patientName} (MRN: ${patientId})
Time: ${new Date().toISOString()}
Test
Result
Reference Range
${resultsHtml}
This is an automated alert from the intu integration engine. Please review immediately.
`;
return {
...msg,
body: emailBody,
headers: {
...msg.headers,
patientId,
},
};
}
null to suppress the email for non-critical results.
Only messages that pass through the transformer with a non-null return value are delivered
to the SMTP destination.