A MuleSoft IDP (Einstein LLM) prompt that classifies the pages of a multi-page referral packet into document types (insurance card, statement of medical necessity, chart notes, fax cover sheet, lab results, etc.) with page ranges, so downstream extraction can target each sub-document correctly.
Tags: healthcare, intelligent-document-processing, ai, referral-management, document-management
IDP Prompt — Referral Packet Page Classification
Objective: Incoming patient referral packets arrive as a single scanned PDF containing several distinct documents stapled together (insurance card, statement of medical necessity, chart notes, fax cover sheet, etc.). Before any field can be extracted, the packet has to be split into its component documents with page ranges. This prompt does that split as the first stage of an IDP document action.
Prerequisites
- MuleSoft IDP (Einstein) enabled in the org; a
GENERIC document action created in Anypoint IDP.
- IDP Connector (per-action generated
mule-plugin) wired into the Mule app that calls this action.
- The document-action prompt configured with
source: "llm" (not "document") so the model reasons over the packet rather than doing verbatim search.
The prompt
Identify and classify the different document types within this multi-page PDF packet. Common document types: "Insurance Card", "Statement of Medical Necessity", "Chart Notes / Progress Notes", "Fax Cover Sheet", "Lab Results", "Ketone Action Plan", "Document Request Letter", "Dosing Chart".
IMPORTANT: You MUST respond with ONLY a valid JSON array. No markdown, no explanation, no code fences.
Output format (JSON array):
[{"document_type": "string", "start_page": number, "end_page": number}]
Example:
[{"document_type": "Insurance Card", "start_page": 1, "end_page": 1}, {"document_type": "Statement of Medical Necessity", "start_page": 2, "end_page": 4}]
Sample payload — classification output
[
{ "document_type": "Insurance Card", "start_page": 1, "end_page": 1 },
{ "document_type": "Statement of Medical Necessity", "start_page": 2, "end_page": 4 },
{ "document_type": "Chart Notes / Progress Notes", "start_page": 5, "end_page": 7 }
]
Testing and validation
- Happy path: run against a 3-in-1 packet (card + SMN + notes) and confirm every page number appears in exactly one range.
- Edge case: a packet where the fax cover sheet is a single unclassifiable page — confirm it still lands in one of the listed types rather than being dropped or causing a parse failure.
- Because
source: "llm" answers arrive as JSON-encoded strings on the prompts.<key>.answer.value path, unwrap with read(raw, "application/json") before iterating the array downstream.
Deliverable: A drop-in classification prompt that turns one referral-packet PDF into a page-range map of its component documents, ready to feed page-scoped extraction prompts.