Skip to navigation

Prep and NLP API output

Summarizing documents you have already processed with other emtelligent APIs

If you already use the Prep API or the NLP API, you can send what they produced straight to the Summarization API, without reshaping it.

Prep API output: prep_documents

The Prep API can produce a JSONL file with one document per line: its text, its document type and its metadata. Parse each line and send the objects as an array:

{
"prep_documents": [
{"id": "c9753dce15074d719c30ca4727721fa6-0001", "text": "…",
"category": "Cardiology", "subcategory": "ECG", "chartdate": "2022-03-04",
"subject_id": "11110001", "subject_name": "…", "subject_dob": "1966-08-01 04:10:48"},
…
],
"prompt": "…"
}

Each line becomes a document:

From the lineUsed as
textThe document. Required
idThe document id, which citations point to (when it is 1–64 of A–Z a–z 0–9 _ . : -; otherwise the line’s position)
category, subcategoryThe document type
chartdateIts date (the date part)
subject_id, subject_name, subject_dob, subject_genderThe patient check

Other fields are ignored.

Remove the pdf field first. Each line also carries the original document as a base64 PDF. It is not used — the text is — and it makes the request around a hundred times larger. A line with a PDF and no text is refused with unsupported_document.

import json
with open("bundle.jsonl") as f:
lines = [json.loads(line) for line in f if line.strip()]
for line in lines:
line.pop("pdf", None)
body = {"prep_documents": lines, "prompt": "Summarize the cardiac history for a referral."}

NLP API results: nlp_results

If you have already run the documents through the NLP API, send its result files as they are — emtellipro-json-2, including the documents’ text (the NLP API’s text feature). Several files are fine:

{"nlp_results": [{"format": "emtellipro-json-2", "version": "2.37.0",
"documents": [ … ]}],
"prompt": "…"}

Each document’s id, category and subcategory come from the file. Documents whose processing_status is not success are summarized too.

NLP results are large — many times the size of their text — so these requests can be up to 16 MiB.

Adding dates and patient details: document_metadata

NLP results carry no dates or patient details. Add them by document id with document_metadata, which works for any of a job’s documents:

"document_metadata": {
"c9753dce15074d719c30ca4727721fa6-0001": {"chart_date": "2022-03-04",
"subject": {"dob": "1966-08-01"}}
}

A key that matches no document is refused with unknown_document_id.

If you have both the Prep JSONL and the NLP results for the same documents, their ids match: send the NLP results, and build document_metadata from the Prep lines’ chartdate and subject_* fields.

Combining

documents, prep_documents and nlp_results can all be sent in one job. Ids must be unique across them; documents without an id are numbered by their position across all of them, in that order.