Generador de informes médicos con IA

Avanzado

Este es unDocument Extraction, AI Summarizationflujo de automatización del dominio deautomatización que contiene 21 nodos.Utiliza principalmente nodos como Set, Code, Gmail, GoogleDocs, GoogleDrive. Usar Gemini AI y Google Workspace para generar informes médicos a partir de correos electrónicos

Requisitos previos
  • Cuenta de Google y credenciales de API de Gmail
  • Credenciales de API de Google Drive
  • Pueden requerirse credenciales de autenticación para la API de destino
  • Credenciales de API de Google Sheets
  • Clave de API de Google Gemini
Vista previa del flujo de trabajo
Visualización de las conexiones entre nodos, con soporte para zoom y panorámica
Exportar flujo de trabajo
Copie la siguiente configuración JSON en n8n para importar y usar este flujo de trabajo
{
  "id": "iKLz8kl2wKbZDjdk",
  "meta": {
    "instanceId": "7f1a0694161455be3a7e71f1e0dea04908b0376a1a81e3a0c1e5ac879d48f83a"
  },
  "name": "AI Medical Report Generator",
  "tags": [],
  "nodes": [
    {
      "id": "91a19c78-df6d-42b2-85d7-abc7869b8942",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -528,
        96
      ],
      "parameters": {
        "simple": false,
        "filters": {
          "sender": "your-doctor-email@example.com"
        },
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyHour"
            }
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "OVQrwg5oLZomwQcs",
          "name": "Gmail account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "baa74409-0c1a-4bc9-8f84-a4af654509ff",
      "name": "Editar campos",
      "type": "n8n-nodes-base.set",
      "notes": "🛠 *Extracts the raw email content* into a new field called `content` for AI processing.",
      "position": [
        -240,
        96
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "d4b7d4b4-3daa-4804-bf99-fadfed1b7bb2",
              "name": "content",
              "type": "string",
              "value": "={{ $json.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "f4b76891-0cbe-4dab-a1f2-f2ce347f6d73",
      "name": "Agregar fila en hoja",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        656,
        0
      ],
      "parameters": {
        "columns": {
          "value": {
            "Date": "={{ $json.date }}",
            "Diagnoses": "={{ $json.diagnosis }}",
            "Patient Name": "={{ $json.patient_name }}",
            "Doctor's Name": "={{ $json.doctor_name }}",
            "Patient Phone Num.": "={{ $json.phone_number }}"
          },
          "schema": [
            {
              "id": "Date",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Patient Name",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Patient Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Patient Phone Num.",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Patient Phone Num.",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Doctor's Name",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Doctor's Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Diagnoses",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Diagnoses",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Description ",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Description ",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Attachments",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Attachments",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 12488983,
          "cachedResultUrl": "https://your-google-sheet-url/d/1EZgjpZ2B1umVImyMItfaHRn7Gi2T-y9etYmUNQZNiRw/edit#gid=12488983",
          "cachedResultName": "Sheet2"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1EZgjpZ2B1umVImyMItfaHRn7Gi2T-y9etYmUNQZNiRw",
          "cachedResultUrl": "https://your-google-sheet-url/d/1EZgjpZ2B1umVImyMItfaHRn7Gi2T-y9etYmUNQZNiRw/edit?usp=drivesdk",
          "cachedResultName": "your-sheet-name"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "f5DnmArZjB6jGZsb",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "f64e9b78-dc5d-4556-8322-1175a33dd062",
      "name": "Agente de IA",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        0,
        0
      ],
      "parameters": {
        "text": "=Extract the following details from the input below and return them in raw JSON format:\n\n- patient_name  \n- doctor_name (if not found, return null)  \n- diagnosis  \n- phone_number (must start with 0111)  \n- date (use today’s date in YYYY-MM-DD format)\n\nINPUT:\n{{ $json.content }}\n\nRespond ONLY with JSON like this:\n{\n  \"patient_name\": \"john doe\",\n  \"doctor_name\": null,\n  \"diagnosis\": \"diaria\",\n  \"phone_number\": \"0111xxxxxxx\",\n  \"date\": \"2025-07-21\"\n}\n",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.1
    },
    {
      "id": "d0efc2af-649e-40b8-8dd9-eeeecdfaf488",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "notes": "⚙️ *Specifies the AI model* (Gemini) used by the AI Agent for text understanding.",
      "position": [
        -48,
        288
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.0-flash-lite"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "sveFXq4gBIkY17aH",
          "name": "Google Gemini(PaLM) Api account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "63c7245b-1c50-45ad-a136-075e92eec522",
      "name": "Código",
      "type": "n8n-nodes-base.code",
      "position": [
        352,
        0
      ],
      "parameters": {
        "jsCode": "const rawOutput = $json[\"output\"];\n\n// Remove ```json ... ``` if it exists\nconst cleaned = rawOutput.replace(/```json\\n?|```/g, \"\").trim();\n\nconst parsed = JSON.parse(cleaned);\n\nreturn [\n  {\n    json: parsed\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "8d11f752-f45c-4b55-b586-d16ad75ae194",
      "name": "Actualizar documento1",
      "type": "n8n-nodes-base.googleDocs",
      "position": [
        1216,
        0
      ],
      "parameters": {
        "actionsUi": {
          "actionFields": [
            {
              "rows": 2,
              "action": "insert",
              "object": "table",
              "columns": 2
            },
            {
              "text": "{{date}}",
              "action": "replaceAll",
              "replaceText": "={{ $('Append row in sheet').item.json.Date }}"
            },
            {
              "rows": 3,
              "action": "insert",
              "object": "table",
              "columns": 3
            },
            {
              "text": "{{patient_name}}",
              "action": "replaceAll",
              "replaceText": "={{ $('Append row in sheet').item.json['Patient Name'] }}"
            }
          ]
        },
        "operation": "update",
        "documentURL": "https://your-google-doc-url/d/1UzqfWelQRYC_i9Q_7snYJ8h67b3-qfLK9YxGiKgl25k/edit?tab=t.0"
      },
      "credentials": {
        "googleDocsOAuth2Api": {
          "id": "rV6dJKMg47R7CTiD",
          "name": "Google Docs account"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "ed90c89e-c092-4e07-95ae-a2a229bb994a",
      "name": "Copiar archivo",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        960,
        0
      ],
      "parameters": {
        "name": "=your-doc-template-name -  {{ $json['Patient Name'] }}",
        "fileId": {
          "__rl": true,
          "mode": "list",
          "value": "1UzqfWelQRYC_i9Q_7snYJ8h67b3-qfLK9YxGiKgl25k",
          "cachedResultUrl": "https://your-google-doc-url/d/1UzqfWelQRYC_i9Q_7snYJ8h67b3-qfLK9YxGiKgl25k/edit?usp=drivesdk",
          "cachedResultName": "your-doc-template-name"
        },
        "options": {},
        "operation": "copy"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "0BHskfXCrCwPuBL0",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "472e8004-5605-4275-9975-e2bfe105a517",
      "name": "Enviar mensaje",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2016,
        0
      ],
      "webhookId": "16e8b9db-f57a-4f9b-80d8-1300f57fcdc3",
      "parameters": {
        "sendTo": "recipient@example.com",
        "message": "Please find the your-doc-template-name attached",
        "options": {
          "attachmentsUi": {
            "attachmentsBinary": [
              {}
            ]
          }
        },
        "subject": "=your-doc-template-name -  {{ $('Code').item.json.patient_name }}",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "OVQrwg5oLZomwQcs",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "52c9ce22-4874-4d5b-a75f-e620a4c0c6e0",
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1504,
        0
      ],
      "parameters": {
        "url": "=https://www.googleapis.com/drive/v3/files/{{ $node[\"Copy file\"].json[\"id\"] }}/export?mimeType=application/pdf\n",
        "options": {},
        "sendQuery": true,
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {}
          ]
        },
        "nodeCredentialType": "googleDriveOAuth2Api"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "0BHskfXCrCwPuBL0",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "6ac43c97-8545-4811-b304-44e053b61071",
      "name": "Código1",
      "type": "n8n-nodes-base.code",
      "position": [
        1760,
        0
      ],
      "parameters": {
        "jsCode": "const patientName = $node[\"HTTP Request\"].json.patientName;\nconst dateStr = new Date().toISOString().split('T')[0];  // e.g. \"2025-07-21\"\nitems[0].binary.data.fileName = `${$('Append row in sheet').first().json['Patient Name']}_${dateStr}.pdf`;\nitems[0].binary.data.mimeType = 'application/pdf';\nreturn items;"
      },
      "typeVersion": 2
    },
    {
      "id": "6aa03f0e-dff0-4f33-943b-064c499863a9",
      "name": "Nota adhesiva",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -560,
        -160
      ],
      "parameters": {
        "color": 3,
        "content": "🔔 *Triggers* the workflow when a new email is received from a specific sender (e.g. a doctor)."
      },
      "typeVersion": 1
    },
    {
      "id": "14165e9d-eff7-40a6-b035-390de5c430b2",
      "name": "Nota adhesiva1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -304,
        -160
      ],
      "parameters": {
        "color": 5,
        "content": "🛠 *Extracts the raw email content* into a new field called `content` for AI processing."
      },
      "typeVersion": 1
    },
    {
      "id": "f2adb4f2-1fd2-4e91-99cc-929f3b158dcb",
      "name": "Nota adhesiva2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        -176
      ],
      "parameters": {
        "color": 4,
        "content": "🤖 *Processes the text using AI* to extract structured information like patient name, doctor name, etc."
      },
      "typeVersion": 1
    },
    {
      "id": "6f55af2f-ac25-4462-be9e-6284fd1fdbf6",
      "name": "Nota adhesiva3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        288,
        -176
      ],
      "parameters": {
        "color": 3,
        "content": "🧹 *Cleans and parses* the AI response by removing markdown code formatting and turning it into usable JSON."
      },
      "typeVersion": 1
    },
    {
      "id": "d93463fb-9399-4c51-bec9-26d29bd161b0",
      "name": "Nota adhesiva4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        576,
        -176
      ],
      "parameters": {
        "color": 5,
        "content": "📄 *Adds the extracted data* (patient info, diagnosis, etc.) to a specific Google Sheet row."
      },
      "typeVersion": 1
    },
    {
      "id": "c8176919-4a09-4330-a481-6de25440845f",
      "name": "Nota adhesiva5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        880,
        -176
      ],
      "parameters": {
        "color": 3,
        "content": "📁 *Makes a copy* of the Google Docs medical report template for the current patient."
      },
      "typeVersion": 1
    },
    {
      "id": "28dd3b51-feba-4981-8b4b-156f3dedbb07",
      "name": "Nota adhesiva6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1152,
        -176
      ],
      "parameters": {
        "color": 5,
        "content": "📝 *Replaces placeholders* (like patient name/date) in the copied Google Doc with real data."
      },
      "typeVersion": 1
    },
    {
      "id": "a966576b-0bfe-4d03-acbe-8475c93c3a9e",
      "name": "Nota adhesiva7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1424,
        -176
      ],
      "parameters": {
        "color": 3,
        "content": "📤 *Exports the updated Google Doc* as a PDF via Google Drive API."
      },
      "typeVersion": 1
    },
    {
      "id": "7853e5d4-27e0-4b7e-beed-a85704f5fd4e",
      "name": "Nota adhesiva8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1680,
        -176
      ],
      "parameters": {
        "color": 5,
        "content": "📛 *Renames the PDF file* using patient name and date, and attaches metadata."
      },
      "typeVersion": 1
    },
    {
      "id": "f9504b84-ce1a-4dca-8378-fc8bf4183bfa",
      "name": "Nota adhesiva9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1936,
        -176
      ],
      "parameters": {
        "content": "✉️ *Sends the final PDF* (medical report) to the recipient via Gmail."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "389f4f89-16fb-4cce-8d2e-e4f031b7fdfc",
  "connections": {
    "63c7245b-1c50-45ad-a136-075e92eec522": {
      "main": [
        [
          {
            "node": "f4b76891-0cbe-4dab-a1f2-f2ce347f6d73",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "6ac43c97-8545-4811-b304-44e053b61071": {
      "main": [
        [
          {
            "node": "472e8004-5605-4275-9975-e2bfe105a517",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "f64e9b78-dc5d-4556-8322-1175a33dd062": {
      "main": [
        [
          {
            "node": "63c7245b-1c50-45ad-a136-075e92eec522",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ed90c89e-c092-4e07-95ae-a2a229bb994a": {
      "main": [
        [
          {
            "node": "8d11f752-f45c-4b55-b586-d16ad75ae194",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "baa74409-0c1a-4bc9-8f84-a4af654509ff": {
      "main": [
        [
          {
            "node": "f64e9b78-dc5d-4556-8322-1175a33dd062",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "52c9ce22-4874-4d5b-a75f-e620a4c0c6e0": {
      "main": [
        [
          {
            "node": "6ac43c97-8545-4811-b304-44e053b61071",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "91a19c78-df6d-42b2-85d7-abc7869b8942": {
      "main": [
        [
          {
            "node": "baa74409-0c1a-4bc9-8f84-a4af654509ff",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "8d11f752-f45c-4b55-b586-d16ad75ae194": {
      "main": [
        [
          {
            "node": "52c9ce22-4874-4d5b-a75f-e620a4c0c6e0",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "f4b76891-0cbe-4dab-a1f2-f2ce347f6d73": {
      "main": [
        [
          {
            "node": "ed90c89e-c092-4e07-95ae-a2a229bb994a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d0efc2af-649e-40b8-8dd9-eeeecdfaf488": {
      "ai_languageModel": [
        [
          {
            "node": "f64e9b78-dc5d-4556-8322-1175a33dd062",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  }
}
Preguntas frecuentes

¿Cómo usar este flujo de trabajo?

Copie el código de configuración JSON de arriba, cree un nuevo flujo de trabajo en su instancia de n8n y seleccione "Importar desde JSON", pegue la configuración y luego modifique la configuración de credenciales según sea necesario.

¿En qué escenarios es adecuado este flujo de trabajo?

Avanzado - Extracción de documentos, Resumen de IA

¿Es de pago?

Este flujo de trabajo es completamente gratuito, puede importarlo y usarlo directamente. Sin embargo, tenga en cuenta que los servicios de terceros utilizados en el flujo de trabajo (como la API de OpenAI) pueden requerir un pago por su cuenta.

Información del flujo de trabajo
Nivel de dificultad
Avanzado
Número de nodos21
Categoría2
Tipos de nodos11
Descripción de la dificultad

Adecuado para usuarios avanzados, flujos de trabajo complejos con 16+ nodos

Autor
Abdullah Alshiekh

Abdullah Alshiekh

@abdullah01

🚀 Automation pro building AI-powered workflows with n8n. 💼 Special focus on real use cases 🔧 Love clean, flexible, and business-ready automations.

Enlaces externos
Ver en n8n.io

Compartir este flujo de trabajo

Categorías

Categorías: 34