SFTP Destination
Upload processed files to a remote SFTP server for secure file exchange.
Overview
The SFTP destination uploads processed messages as files to a remote SFTP server. SFTP (SSH File Transfer Protocol) is widely used in healthcare for secure batch file exchange between organizations, such as sending claims to payers, delivering lab reports to referring physicians, or exchanging CDA documents with health information exchanges. This destination supports password and private key authentication.
Configuration
Define an SFTP destination in your root intu.yaml under the destinations key:
# intu.yaml
destinations:
report-sftp:
type: sftp
sftp:
host: sftp.partner-lab.org
port: 22
directory: /incoming/reports
filename_pattern: "report_${date}_${messageId}.pdf"
auth:
type: private_key
username: intu-service
private_key: /etc/ssh/intu_rsa
passphrase: ${SFTP_KEY_PASSPHRASE}
Properties
22.${messageId}, ${timestamp}, ${channelId},
${date}, ${time}. Defaults to ${messageId}.dat.
.tmp_.
Authentication
password, private_key.auth.type is password. Use ${VAR} to reference environment variables.auth.type is private_key.Full Example
Receive CDA documents via HTTP, transform them to a standardized format, and upload to a health information exchange SFTP drop zone.
Root Configuration
# intu.yaml
destinations:
hie-sftp-drop:
type: sftp
sftp:
host: sftp.hie-network.org
port: 22
directory: /drop/cda-documents
filename_pattern: "CDA_${timestamp}_${messageId}.xml"
temp_prefix: ".uploading_"
auth:
type: private_key
username: hospital-intu
private_key: /etc/ssh/hie_rsa
passphrase: ${HIE_KEY_PASSPHRASE}
Channel Configuration
# channels/cda-export/channel.yaml
name: cda-export
description: Export CDA clinical documents to HIE SFTP server
source:
type: http
http:
port: 8081
path: /cda/submit
destinations:
- hie-sftp-drop
Destination Transformer
// channels/cda-export/transformer.ts
import { Message, Context } from "@intu/sdk";
export default function transform(msg: Message, ctx: Context): Message {
const doc = msg.body;
const patientName = doc.recordTarget?.patientRole?.patient?.name;
const familyName = patientName?.family ?? "Unknown";
const givenName = patientName?.given ?? "Unknown";
ctx.logger.info(`Processing CDA for patient: ${givenName} ${familyName}`);
const header = ``;
const cdaXml = buildCdaDocument({
id: msg.id,
patientId: doc.recordTarget?.patientRole?.id?.extension ?? "",
patientFamily: familyName,
patientGiven: givenName,
authorOrg: doc.author?.assignedAuthor?.representedOrganization?.name ?? "",
sections: doc.component?.structuredBody?.sections ?? [],
});
return {
...msg,
body: `${header}\n${cdaXml}`,
};
}
function buildCdaDocument(data: {
id: string;
patientId: string;
patientFamily: string;
patientGiven: string;
authorOrg: string;
sections: any[];
}): string {
const sectionXml = data.sections
.map(
(s: any) =>
`${s.title ?? ""} ${s.text ?? ""} `
)
.join("\n");
return `
${data.patientGiven} ${data.patientFamily}
${data.authorOrg}
${sectionXml}
`;
}
temp_prefix option to prevent downstream systems from reading
partially uploaded files. The file is first written with the temporary prefix, then
atomically renamed once the upload completes.