Ingest CDA R2
Submits CDA R2 documents as XML. Post one document as the request body with Content-Type: application/cda+xml, or several as multipart/form-data with one documents part per document.
The response is a receipt: ingestion continues after it is returned, so poll the ingestion to follow it. intake comes back index-aligned with the documents you sent, so it stays clear which document held what — and if any document cannot be parsed the whole request is rejected and nothing is stored.
Usage
With the body as application/cda+xml:
import { ContextEngineClient } from "@clinia/context-engine-js";
// Initialize the client
const client = new ContextEngineClient({
baseUrl: process.env.CLINIA_WORKSPACE,
auth: {
clientId: process.env.CLINIA_CLIENT_ID,
clientSecret: process.env.CLINIA_CLIENT_SECRET,
},
});
// Call the API, with the request body the API reference documents
const { data, error } = await client.ingest.ingestCdaR2("<patient-id>", body);
// Print the response
console.log(data ?? error);With the body as multipart/form-data:
import { ContextEngineClient } from "@clinia/context-engine-js";
// Initialize the client
const client = new ContextEngineClient({
baseUrl: process.env.CLINIA_WORKSPACE,
auth: {
clientId: process.env.CLINIA_CLIENT_ID,
clientSecret: process.env.CLINIA_CLIENT_SECRET,
},
});
// Call the API, with the request body the API reference documents
const { data, error } = await client.ingest.ingestCdaR2Multipart("<patient-id>", body);
// Print the response
console.log(data ?? error);The environment variables are set in Install and authenticate, for JavaScript or Python.
API reference
POST /v1/patients/{patientId}/ingestions/cda/r2 documents the parameters, the request body and the responses.