医疗记录OCR自动化V1
中级
这是一个AI领域的自动化工作流,包含 7 个节点。主要使用 Code、FormTrigger、HttpRequest、GoogleSheets 等节点,结合人工智能技术实现智能自动化。 使用Mistral OCR和Google表格的医疗记录自动化
前置要求
- •可能需要目标 API 的认证凭证
- •Google Sheets API 凭证
分类
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "rLpjED4GqjXQcQvP",
"meta": {
"instanceId": "2000c64071c20843606b95c63795bb0797c41036047055a6586498e855b96efc",
"templateCredsSetupCompleted": true
},
"name": "医疗记录 OCR 自动化 V1",
"tags": [],
"nodes": [
{
"id": "b3717627-b305-46f3-9a5a-e818738743da",
"name": "表单提交时",
"type": "n8n-nodes-base.formTrigger",
"position": [
-740,
140
],
"webhookId": "f9d60b5f-0a09-4654-a840-84a0f745321e",
"parameters": {
"options": {},
"formTitle": "Document OCR",
"formFields": {
"values": [
{
"fieldType": "file",
"fieldLabel": "Document",
"multipleFiles": false,
"requiredField": true
}
]
},
"formDescription": "Please upload your document for processing."
},
"typeVersion": 2.2
},
{
"id": "b3605b38-3157-4ffe-9064-72b29dcb6df8",
"name": "上传到 Mistral",
"type": "n8n-nodes-base.httpRequest",
"position": [
-500,
140
],
"parameters": {
"url": "https://api.mistral.ai/v1/files",
"method": "POST",
"options": {},
"sendBody": true,
"contentType": "multipart-form-data",
"authentication": "genericCredentialType",
"bodyParameters": {
"parameters": [
{
"name": "purpose",
"value": "ocr"
},
{
"name": "file",
"parameterType": "formBinaryData",
"inputDataFieldName": "Document"
}
]
},
"genericAuthType": "httpHeaderAuth"
},
"credentials": {
"httpHeaderAuth": {
"id": "NwRlovJbDMXbMWOj",
"name": "Header Auth account 2"
}
},
"typeVersion": 4.2
},
{
"id": "ff551a26-b470-45e7-87e4-7165994783aa",
"name": "获取签名 URL",
"type": "n8n-nodes-base.httpRequest",
"position": [
-340,
140
],
"parameters": {
"url": "=https://api.mistral.ai/v1/files/{{ $json.id }}/url",
"options": {},
"sendQuery": true,
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"queryParameters": {
"parameters": [
{
"name": "expiry",
"value": "24"
}
]
}
},
"credentials": {
"httpHeaderAuth": {
"id": "NwRlovJbDMXbMWOj",
"name": "Header Auth account 2"
}
},
"typeVersion": 4.2
},
{
"id": "95ca0fc3-1430-4196-809a-a1de7fa28b86",
"name": "获取 OCR 结果",
"type": "n8n-nodes-base.httpRequest",
"position": [
-180,
140
],
"parameters": {
"url": "https://api.mistral.ai/v1/ocr",
"method": "POST",
"options": {},
"jsonBody": "={\n \"model\": \"mistral-ocr-latest\",\n \"document\": {\n \"type\": \"document_url\",\n \"document_url\": \"{{ $json.url }}\"\n },\n \"include_image_base64\": true\n}",
"sendBody": true,
"sendHeaders": true,
"specifyBody": "json",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"headerParameters": {
"parameters": [
{}
]
}
},
"credentials": {
"httpHeaderAuth": {
"id": "NwRlovJbDMXbMWOj",
"name": "Header Auth account 2"
}
},
"typeVersion": 4.2
},
{
"id": "99f6bf3f-365f-4119-a71a-0b46a8b1fa90",
"name": "Google Sheets",
"type": "n8n-nodes-base.googleSheets",
"position": [
180,
140
],
"parameters": {
"columns": {
"value": {
"Name": "={{ $('Data cleaning').item.json.Name }}",
"Notes": "={{ $('Data cleaning').item.json.Notes }}"
},
"schema": [
{
"id": "Name",
"type": "string",
"display": true,
"required": false,
"displayName": "Name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Date of Birth",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Date of Birth",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Patient ID",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Patient ID",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Date of Visit",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Date of Visit",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Referring Physician",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Referring Physician",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Department",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Department",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Symptoms",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Symptoms",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Blood Pressure",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Blood Pressure",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Heart Rate",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Heart Rate",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Temperature",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Temperature",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Lab Results",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Lab Results",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Diagnosis",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Diagnosis",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Medications",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Medications",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Next Appointment",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "Next Appointment",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Notes",
"type": "string",
"display": true,
"required": false,
"displayName": "Notes",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "pages",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "pages",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "model",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "model",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "usage_info",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "usage_info",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "myNewField",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "myNewField",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "markdown",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "markdown",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "autoMapInputData",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "list",
"value": 1417843853,
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1jRNGNrHAFnvNAAnCHW0vM2784GxIPolzT4x_rFWZRvU/edit#gid=1417843853",
"cachedResultName": "Patients"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1jRNGNrHAFnvNAAnCHW0vM2784GxIPolzT4x_rFWZRvU",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1jRNGNrHAFnvNAAnCHW0vM2784GxIPolzT4x_rFWZRvU/edit?usp=drivesdk",
"cachedResultName": "Medical Records - Extracted"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "b0RUCwZZREhRN85o",
"name": "Google Sheets account"
}
},
"typeVersion": 4.5
},
{
"id": "1e38c3a0-d0d8-457c-93e9-f038df571790",
"name": "数据清理",
"type": "n8n-nodes-base.code",
"position": [
-20,
140
],
"parameters": {
"jsCode": "// Get OCR results from the input\nconst ocrResults = $input.all().map((item) => item.json);\n\n// Define fields to extract\nconst fields = [\n \"Name\",\n \"Date of Birth\",\n \"Patient ID\",\n \"Date of Visit\",\n \"Referring Physician\",\n \"Department\",\n \"Symptoms\",\n \"Blood Pressure\",\n \"Heart Rate\",\n \"Temperature\",\n \"Lab Results\",\n \"Diagnosis\",\n \"Medications\",\n \"Next Appointment\",\n \"Notes\",\n];\n\nconst allPatientRecords = [];\n\n// Process each OCR result\nocrResults.forEach((result) => {\n // Combine all pages into a single text for processing\n let allText = \"\";\n if (result.pages && Array.isArray(result.pages)) {\n result.pages.forEach((page) => {\n if (page.markdown) {\n allText += page.markdown + \"\\n\";\n }\n });\n }\n \n // Split the text into patient record sections\n // Look for patterns like \"Patient Record 1\", \"🧾 Patient Record 2\", etc.\n const recordSections = allText.split(/(?:🧾\\s*)?Patient Record\\s*\\d+/g).filter(section => section.trim().length > 0);\n console.log(`Found ${recordSections.length} potential patient record sections`);\n \n // Process each patient record section\n recordSections.forEach((section, index) => {\n // Create a new patient record object\n const patientRecord = {};\n \n // Add Patient Name which has a different pattern than other fields\n const nameMatch = section.match(/Patient Name:\\s*([^\\n]+)/);\n if (nameMatch) {\n patientRecord[\"Name\"] = nameMatch[1].trim();\n }\n \n // Extract all other fields\n fields.forEach((field) => {\n if (field === \"Name\") return; // Already handled above\n \n // Create a regex pattern for the field\n const pattern = new RegExp(`${field}:\\\\s*([^\\\\n]+)`, 'i');\n const match = section.match(pattern);\n \n if (match) {\n patientRecord[field] = match[1].trim();\n }\n \n // Special handling for Lab Results which might span multiple lines\n if (field === \"Lab Results\" && !patientRecord[field]) {\n const labStartIndex = section.indexOf(\"Lab Results:\");\n if (labStartIndex !== -1) {\n let labEndIndex = -1;\n \n // Find where lab results end (before Diagnosis or next field)\n for (const nextField of [\"Diagnosis\", \"Medications\", \"Next Appointment\"]) {\n const nextFieldIndex = section.indexOf(`${nextField}:`, labStartIndex);\n if (nextFieldIndex !== -1 && (labEndIndex === -1 || nextFieldIndex < labEndIndex)) {\n labEndIndex = nextFieldIndex;\n }\n }\n \n if (labEndIndex !== -1) {\n let labResults = section.substring(labStartIndex + \"Lab Results:\".length, labEndIndex).trim();\n // Clean up lab results\n labResults = labResults.replace(/●/g, '').replace(/\\n\\s*/g, ', ').trim();\n patientRecord[field] = labResults;\n }\n }\n }\n });\n \n // Only add records that have at least a name or patient ID\n if (patientRecord[\"Name\"] || patientRecord[\"Patient ID\"]) {\n console.log(`Extracted data for patient ${index + 1}: ${patientRecord[\"Name\"] || patientRecord[\"Patient ID\"]}`);\n allPatientRecords.push(patientRecord);\n }\n });\n});\n\nconsole.log(`Total patient records extracted: ${allPatientRecords.length}`);\n\n// Return all extracted patient records\nreturn allPatientRecords;"
},
"typeVersion": 2
},
{
"id": "c02eba73-56cc-4757-b010-cba7d7f34e04",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1320,
-360
],
"parameters": {
"width": 1820,
"height": 1060,
"content": "## 🏥 医疗记录 OCR 自动化 (n8n)"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "63643d00-01e0-4533-8ddc-0537590f8408",
"connections": {
"Data cleaning": {
"main": [
[
{
"node": "Google Sheets",
"type": "main",
"index": 0
}
]
]
},
"Get Signed URL": {
"main": [
[
{
"node": "Get OCR Results",
"type": "main",
"index": 0
}
]
]
},
"Get OCR Results": {
"main": [
[
{
"node": "Data cleaning",
"type": "main",
"index": 0
}
]
]
},
"Upload to Mistral": {
"main": [
[
{
"node": "Get Signed URL",
"type": "main",
"index": 0
}
]
]
},
"On form submission": {
"main": [
[
{
"node": "Upload to Mistral",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
这是一个中级难度的工作流,适用于AI等场景。适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
自动化潜在客户采集器:Apify到Google Sheets
通过数据清洗自动化从Apify到Google Sheets的商业线索采集
Set
Code
Http Request
+3
6 节点David Olusola
Sales
AI潜在客户机器专业版:Google地图→Slack→HubSpot→$$$
使用Google地图、GPT-4和HubSpot的自动化潜在客户生成与资格认证
If
Set
Code
+7
16 节点David Olusola
Sales
基于AI的新闻转视频生成器(使用Heygen和GPT4o)
使用Heygen和GPT-4o将RSS新闻转换为AI虚拟形象视频
Set
Code
Wait
+9
18 节点David Olusola
Design
智能客户支持系统(集成GPT-4o、Gmail、Slack和Drive知识库)
集成GPT-4o、Gmail、Slack和Drive知识库的智能客户支持系统
If
Code
Gmail Tool
+13
19 节点David Olusola
Support
医疗账单自动化模板
使用Google Sheets和Gmail自动化医疗账单处理
If
Set
Code
+5
11 节点David Olusola
Finance
图像生成器
通过Google云端硬盘和表格实现AI图像生成与Telegram交付的自动化流程
Telegram
Google Drive
Http Request
+6
11 节点David Olusola
Design
工作流信息
难度等级
中级
节点数量7
分类1
节点类型5
作者
David Olusola
@dae221AI automation consultant working with ambitious businesses on their most complex operational challenges. For project inquiries, reach me at david@daexai.com
外部链接
在 n8n.io 上查看 →
分享此工作流