AI 驱动的化验报告简化器(含注意事项)
这是一个Document Extraction, Multimodal AI领域的自动化工作流,包含 8 个节点。主要使用 Code, EmailSend, EmailReadImap, Agent, LmChatOllama 等节点。 使用 Ollama AI 简化医学化验报告并通过邮件发送
- •无特殊前置要求,导入即可使用
{
"id": "1PvO16aHWZcyFf6B",
"meta": {
"instanceId": "dd69efaf8212c74ad206700d104739d3329588a6f3f8381a46a481f34c9cc281",
"templateCredsSetupCompleted": true
},
"name": "AI 驱动的化验报告简化器(含注意事项)",
"tags": [],
"nodes": [
{
"id": "b8e80d8b-5f75-48a6-adda-3dc1a39e8f3f",
"name": "化验报告邮件触发器",
"type": "n8n-nodes-base.emailReadImap",
"position": [
-600,
360
],
"parameters": {
"options": {}
},
"credentials": {
"imap": {
"id": "zTEGYssr7MSVeCs3",
"name": "IMAP-test"
}
},
"typeVersion": 2
},
{
"id": "09a54768-7021-4d1e-abe8-2d4dd57920f5",
"name": "医疗 AI 模型",
"type": "@n8n/n8n-nodes-langchain.lmChatOllama",
"position": [
-72,
580
],
"parameters": {
"model": "llama3.2-16000:latest",
"options": {}
},
"credentials": {
"ollamaApi": {
"id": "vDhjHnEfhHheDgd6",
"name": "Ollama-vrushti"
}
},
"typeVersion": 1
},
{
"id": "3745178a-53d2-4b9d-a871-e4a78ce5a495",
"name": "提取 PDF 内容",
"type": "n8n-nodes-base.code",
"position": [
-380,
360
],
"parameters": {
"jsCode": "// Extract PDF content and prepare for AI analysis\nconst emailData = items[0].json;\nlet pdfContent = '';\n\n// Check for attachments\nif (emailData.attachments && emailData.attachments.length > 0) {\n const pdfAttachment = emailData.attachments.find(att => \n att.contentType === 'application/pdf' || \n att.filename?.toLowerCase().includes('.pdf')\n );\n \n if (pdfAttachment) {\n // In a real scenario, you'd use a PDF parser here\n // For now, we'll use the email text content as a fallback\n pdfContent = emailData.textPlain || emailData.html || 'PDF content extraction needed';\n }\n} else {\n pdfContent = emailData.textPlain || emailData.html || '';\n}\n\n// Extract patient email from sender\nconst patientEmail = emailData.from?.value?.[0]?.address || emailData.from;\n\nreturn [{\n json: {\n patient_email: patientEmail,\n report_content: pdfContent,\n subject: emailData.subject,\n received_date: new Date().toISOString()\n }\n}];"
},
"typeVersion": 2
},
{
"id": "2012adee-2fef-4b29-adf3-d8e34db7ccfa",
"name": "AI 报告简化器",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
-160,
360
],
"parameters": {
"text": "={{ $json.report_content }}",
"options": {
"systemMessage": "You are a medical AI that simplifies lab reports for patients. Convert complex medical terminology into easy-to-understand language.\n\nAnalyze the lab report and provide:\n\n1. **SIMPLE SUMMARY**: Explain what tests were done in plain English\n2. **RESULTS EXPLANATION**: \n - Normal results: \"✅ Normal - This is good!\"\n - Abnormal results: \"⚠️ Outside normal range - Here's what it means...\"\n3. **KEY FINDINGS**: Highlight the most important results\n4. **PRECAUTIONS & ADVICE**:\n - Dietary recommendations\n - Lifestyle changes\n - When to follow up with doctor\n - Warning signs to watch for\n\nUse simple words, avoid medical jargon, and be reassuring but honest.\n\nLab Report Content:\n{{ $json.report_content }}\n\nIMPORTANT: Always end with: \"⚠️ This is a simplified explanation. Always discuss your results with your healthcare provider for proper medical advice.\""
},
"promptType": "define"
},
"typeVersion": 2
},
{
"id": "fad3a39a-9138-403b-9a4f-e7702e4029f6",
"name": "格式化报告响应",
"type": "n8n-nodes-base.code",
"position": [
216,
360
],
"parameters": {
"jsCode": "// Format the simplified report with proper styling\nconst originalData = $node[\"Extract PDF Content\"].json;\nconst simplifiedReport = items[0].json.output;\n\n// Create formatted email content\nconst emailContent = `\n<div style=\"font-family: Arial, sans-serif; max-width: 600px; margin: 0 auto; padding: 20px; background-color: #f9f9f9;\">\n <div style=\"background-color: white; padding: 30px; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,0.1);\">\n \n <h2 style=\"color: #2c5aa0; text-align: center; margin-bottom: 30px;\">\n 🩺 Your Lab Report - Simplified\n </h2>\n \n <div style=\"background-color: #e3f2fd; padding: 15px; border-radius: 5px; margin-bottom: 20px;\">\n <p style=\"margin: 0; font-size: 14px; color: #1565c0;\">\n <strong>Report Date:</strong> ${new Date().toLocaleDateString()}<br>\n <strong>Original Subject:</strong> ${originalData.subject}\n </p>\n </div>\n \n <div style=\"line-height: 1.6; color: #333;\">\n ${simplifiedReport.replace(/\\n/g, '<br>').replace(/\\*\\*(.*?)\\*\\*/g, '<strong>$1</strong>')}\n </div>\n \n <div style=\"background-color: #fff3e0; padding: 15px; border-radius: 5px; margin-top: 20px; border-left: 4px solid #ff9800;\">\n <h4 style=\"color: #e65100; margin-top: 0;\">📋 Next Steps:</h4>\n <ul style=\"margin-bottom: 0;\">\n <li>Save this report for your records</li>\n <li>Schedule a follow-up with your doctor if recommended</li>\n <li>Ask questions during your next appointment</li>\n <li>Share any concerns with your healthcare provider</li>\n </ul>\n </div>\n \n <div style=\"text-align: center; margin-top: 30px; padding-top: 20px; border-top: 1px solid #ddd;\">\n <p style=\"font-size: 12px; color: #666; margin: 0;\">\n This simplified report was generated by AI for educational purposes only.<br>\n Always consult your healthcare provider for medical advice.\n </p>\n </div>\n \n </div>\n</div>\n`;\n\n// Create WhatsApp-friendly plain text version\nconst whatsappMessage = `🩺 *Your Lab Report - Simplified*\\n\\n` +\n `📅 *Report Date:* ${new Date().toLocaleDateString()}\\n` +\n `📋 *Subject:* ${originalData.subject}\\n\\n` +\n `${simplifiedReport.replace(/\\*\\*/g, '*')}\\n\\n` +\n `📱 *Tip:* Check your email for the full formatted report with more details.`;\n\nreturn [{\n json: {\n patient_email: originalData.patient_email,\n html_content: emailContent,\n plain_content: simplifiedReport,\n whatsapp_message: whatsappMessage,\n subject: `Your Simplified Lab Report - ${originalData.subject}`,\n original_subject: originalData.subject\n }\n}];"
},
"typeVersion": 2
},
{
"id": "effef8f1-d484-48cc-afdd-0b9938aeecc0",
"name": "发送简化报告",
"type": "n8n-nodes-base.emailSend",
"position": [
436,
360
],
"parameters": {
"html": "={{ $json.html_content }}",
"text": "={{ $json.plain_content }}",
"options": {},
"subject": "={{ $json.subject }}",
"toEmail": "={{ $json.patient_email }}",
"fromEmail": "lab-reports@yourmedical.com"
},
"credentials": {
"smtp": {
"id": "G1kyF8cSWTZ4vouN",
"name": "SMTP -test"
}
},
"typeVersion": 1
},
{
"id": "32e59442-4970-44b4-bbd4-bd611b1cef0b",
"name": "工作流概览",
"type": "n8n-nodes-base.stickyNote",
"position": [
-700,
-300
],
"parameters": {
"color": 5,
"width": 500,
"height": 340,
"content": "## 🩺 AI 化验报告简化器"
},
"typeVersion": 1
},
{
"id": "2bb12d8c-8719-4c2f-99b3-6341c0a44112",
"name": "设置说明",
"type": "n8n-nodes-base.stickyNote",
"position": [
-160,
-300
],
"parameters": {
"color": 7,
"width": 460,
"height": 360,
"content": "## ⚙️ 设置指南:"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "7cb3f37a-003e-4cd0-8524-aba548330baa",
"connections": {
"Medical AI Model": {
"ai_languageModel": [
[
{
"node": "AI Report Simplifier",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Extract PDF Content": {
"main": [
[
{
"node": "AI Report Simplifier",
"type": "main",
"index": 0
}
]
]
},
"AI Report Simplifier": {
"main": [
[
{
"node": "Format Report Response",
"type": "main",
"index": 0
}
]
]
},
"Format Report Response": {
"main": [
[
{
"node": "Send Simplified Report",
"type": "main",
"index": 0
}
]
]
},
"Lab Report Email Trigger": {
"main": [
[
{
"node": "Extract PDF Content",
"type": "main",
"index": 0
}
]
]
}
}
}如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 文档提取, 多模态 AI
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
Oneclick AI Squad
@oneclick-aiThe AI Squad Initiative is a pioneering effort to build, automate and scale AI-powered workflows using n8n.io. Our mission is to help individuals and businesses integrate AI agents seamlessly into their daily operations from automating tasks and enhancing productivity to creating innovative, intelligent solutions. We design modular, reusable AI workflow templates that empower creators, developers and teams to supercharge their automation with minimal effort and maximum impact.
分享此工作流