AutomationFlowsAI & RAG › Medical Records Automation with Mistral OCR & Google Sheets

Medical Records Automation with Mistral OCR & Google Sheets

ByDavid Olusola @dae221 on n8n.io

This plug-and-play n8n workflow automates medical record digitization using Mistral’s OCR API and stores clean, structured data in Google Sheets. Whether you run a clinic or healthtech product, this no-code solution simplifies data entry from scanned or uploaded medical…

Event trigger★★★★☆ complexity7 nodesForm TriggerHTTP RequestGoogle Sheets
AI & RAG Trigger: Event Nodes: 7 Complexity: ★★★★☆ Added:

This workflow corresponds to n8n.io template #5083 — we link there as the canonical source.

This workflow follows the Form Trigger → Google Sheets recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "rLpjED4GqjXQcQvP",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Medical Records OCR Automation V1",
  "tags": [],
  "nodes": [
    {
      "id": "b3717627-b305-46f3-9a5a-e818738743da",
      "name": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -740,
        140
      ],
      "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": "Upload to 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": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "ff551a26-b470-45e7-87e4-7165994783aa",
      "name": "Get Signed 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": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "95ca0fc3-1430-4196-809a-a1de7fa28b86",
      "name": "Get OCR Results",
      "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": {
          "name": "<your credential>"
        }
      },
      "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": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "1e38c3a0-d0d8-457c-93e9-f038df571790",
      "name": "Data cleaning",
      "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\", \"\ud83e\uddfe Patient Record 2\", etc.\n  const recordSections = allText.split(/(?:\ud83e\uddfe\\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(/\u25cf/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": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1320,
        -360
      ],
      "parameters": {
        "width": 1820,
        "height": 1060,
        "content": "## \ud83c\udfe5 Medical Records OCR Automation (n8n)\n**\ud83e\udde0 Sticky Node Setup Guide**\n\n##  Author :  [David Olusola](https://www.daexai.com)\n\n\n1. \ud83d\udce5 On form submission\nType: Form Trigger\nPurpose: Captures uploaded documents from users.\nLabel: \u201cDocument OCR\u201d\nWhat to Stick:\n\n\u201cReceives uploaded document from user to begin OCR processing.\u201d\n2. \u2b06\ufe0f Upload to Mistral\nType: HTTP Request\nMethod: POST to https://api.mistral.ai/v1/files\nAuth: HTTP Header Auth\nWhat to Stick:\n\n\u201cSends uploaded document to Mistral for OCR file hosting.\u201d\n3. \ud83d\udd17 Get Signed URL\nType: HTTP Request\nPurpose: Retrieves a temporary signed URL from Mistral to access the uploaded file.\nWhat to Stick:\n\n\u201cGets secure download URL from Mistral for the uploaded document.\u201d\n4. \ud83e\udde0 Get OCR Results\nType: HTTP Request\nPurpose: Sends signed URL to Mistral OCR API to extract text content.\nWhat to Stick:\n\n\u201cCalls Mistral OCR with signed document URL to extract data.\u201d\n5. \ud83e\uddf9 Data cleaning\nType: Code Node (JavaScript)\nPurpose:\n\nParses OCR text\nExtracts structured fields like Patient Name, Diagnosis, Medications, etc.\nHandles multi-record documents.\nWhat to Stick:\n\u201cProcesses raw OCR text into structured patient records for sheet entry.\u201d\n6. \ud83d\udcc4 Google Sheets\nType: Google Sheets Append\nTarget: Medical Records \u2192 \u201cPatients\u201d sheet\nPurpose: Writes cleaned data into the spreadsheet.\nWhat to Stick:\nMake a copy [Google sheet](https://docs.google.com/spreadsheets/d/1jRNGNrHAFnvNAAnCHW0vM2784GxIPolzT4x_rFWZRvU/edit?usp=sharing)\n\n\u201cAppends cleaned patient data to the Google Sheet.\u201d\n\u2705 General Notes:\n\nWebhook ID: f9d60b5f-0a09-4654-a840-84a0f745321e (for testing or routing webhooks)\nFile Field: Named Document in form\nImportant Fields Extracted:\nName, DOB, Patient ID, Diagnosis, Medications, Lab Results, Notes, etc."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "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
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This plug-and-play n8n workflow automates medical record digitization using Mistral’s OCR API and stores clean, structured data in Google Sheets. Whether you run a clinic or healthtech product, this no-code solution simplifies data entry from scanned or uploaded medical…

Source: https://n8n.io/workflows/5083/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

Generate realistic, high-quality images from text prompts using the Flux AI Text-to-Image Generator API via RapidAPI, and seamlessly store the results in Google Drive and log them in Google Sheets — a

Form Trigger, HTTP Request, Google Sheets +1
AI & RAG

Note: Now includes an Apify alternative for Rapid API (Some users can't create new accounts on Rapid API, so I have added an alternative for you. But immediately you are able to get access to Rapid AP

Form Trigger, Google Sheets Trigger, OpenAI +2
AI & RAG

This system automates LinkedIn lead generation and enrichment in six clear stages: Lead Collection (via Apollo.io) Automatically pulls leads based on keywords, roles, or industries using Apollo’s API.

Form Trigger, OpenAI, Google Sheets Trigger +2
AI & RAG

Understand your customers before you build for them. This workflow, Market Segmentation: Buyer Persona Pain Point Report, automates the grueling process of primary market research. By scraping real-wo

Form Trigger, Google Gemini, N8N Nodes Olostep +3
AI & RAG

The competitive edge, delivered. This Customer Intelligence Engine simultaneously analyzes the web, Reddit, and X/Twitter to generate a professional, actionable executive briefing.

Reddit, N8N Nodes Serpapi, HTTP Request +4