{
  "name": "Extract medical reports & generate AI health advice with Mistral AI & GPT-4",
  "nodes": [
    {
      "id": "a6a3e84a-be97-4579-ae73-8e3f1f26f4cf",
      "name": "Download file",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1024,
        464
      ]
    },
    {
      "id": "057e8d68-e51d-45fb-96c3-6aa45e2a2690",
      "name": "Combine page Markdown",
      "type": "n8n-nodes-base.code",
      "position": [
        1840,
        304
      ]
    },
    {
      "id": "d6af767c-c86e-4778-b604-122b48e91231",
      "name": "Parse AI output to one-per-row",
      "type": "n8n-nodes-base.code",
      "position": [
        2192,
        288
      ]
    },
    {
      "id": "280f592d-9b76-4653-8a5c-2292004bda36",
      "name": "Out-of-Range Detection & Advice Fields",
      "type": "n8n-nodes-base.code",
      "position": [
        2416,
        288
      ]
    },
    {
      "id": "3e152598-d727-482a-99ca-a38d658dee9c",
      "name": "Merge AI Response Back",
      "type": "n8n-nodes-base.code",
      "position": [
        2768,
        288
      ]
    },
    {
      "id": "a62dfcf0-a9b0-443d-bf87-51c58e34662b",
      "name": "Upload pdf/jpeg file to Google drive",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        1008,
        176
      ]
    },
    {
      "id": "31350988-e198-493d-83c6-4cb3e6a832f7",
      "name": "Extract from Image",
      "type": "n8n-nodes-base.mistralAi",
      "position": [
        1584,
        368
      ]
    },
    {
      "id": "1addfa9f-7104-4da5-a78b-a4dd98e40843",
      "name": "Check if PDF or Image",
      "type": "n8n-nodes-base.if",
      "position": [
        1296,
        272
      ]
    },
    {
      "id": "8fa34cb4-3775-49a7-9276-497c11988a6c",
      "name": "Extract from PDF",
      "type": "n8n-nodes-base.mistralAi",
      "position": [
        1584,
        176
      ]
    },
    {
      "id": "39376374-069f-4566-b06d-683154afe334",
      "name": "Extract Medical Data (AI)",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        1952,
        64
      ]
    },
    {
      "id": "395f545b-2c39-4fe5-824c-56196d5c5b19",
      "name": "General Health Advice(AI)",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        2528,
        80
      ]
    },
    {
      "id": "2e4e4a02-0492-4a27-bcd5-d22090a7e210",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        912,
        -80
      ],
      "parameters": {
        "width": 288,
        "height": 448,
        "content": "## Google Drive Trigger\n\n## Upload file (Pdf/Image)\n\nMonitors a specific Google Drive folder for newly uploaded medical reports (PDF/image files). Triggers the workflow when a new file is detected (ch"
      }
    },
    {
      "id": "7077505f-39be-426e-bb8c-f39235900794",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        944,
        384
      ],
      "parameters": {
        "width": null,
        "height": 448,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Download File\n\nDownloads the detected medical report file from Google Drive for processing."
      }
    },
    {
      "id": "713f9373-6461-4a1d-838a-e94b90e72e97",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1216,
        48
      ],
      "parameters": {
        "width": 256,
        "height": 544,
        "content": "## Check if PDF/Image\n\nDetermines whether the uploaded file is a PDF or an image, routing to the appropriate extraction node."
      }
    },
    {
      "id": "79fb1da0-1c7a-4e9e-8588-a606227b02b7",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1488,
        -80
      ],
      "parameters": {
        "width": 288,
        "height": 896,
        "content": "## Extract from PDF\n\nUses Mistral AI to extract text and structure from PDF medical reports using OCR capabilities.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Extract from Image\n\nUses Mistral AI to "
      }
    },
    {
      "id": "c53123e0-f5a3-4e8e-af19-0838a3393c0a",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1792,
        -80
      ],
      "parameters": {
        "width": 560,
        "height": 896,
        "content": "## Extract Medical Data (AI)\n\nUses GPT-4 to intelligently extract structured data from the medical report: patient details, test names, results, units, and reference ranges. Outputs pure JSON.\n\n\n\n\n\n\n\n"
      }
    },
    {
      "id": "83ee4286-c175-45a0-86b4-e8b997c72f6a",
      "name": "Save Out-of-Range Results",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        3024,
        288
      ]
    },
    {
      "id": "50454400-4968-4e6e-adb5-4afe3cea01ec",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2368,
        -80
      ],
      "parameters": {
        "width": 560,
        "height": 896,
        "content": "## Generate Health Advice (AI) \n\nUses GPT-4 to generate personalized dietary, lifestyle, and exercise recommendations for each out-of-range test result, considering patient age and gender.\n\n\n\n\n\n\n\n\n\n\n\n"
      }
    },
    {
      "id": "edbfa3ba-e4de-41d0-8e73-3026a882033f",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2944,
        -80
      ],
      "parameters": {
        "width": 288,
        "height": 928,
        "content": "\n\n\n## Save Out-of-Range Results\n\nSaves abnormal test results along with personalized health advice to the \"Out of Range Values\" sheet in Google Sheets for priority review.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
      }
    },
    {
      "id": "49a1f385-e91e-4047-808d-5b9134050339",
      "name": "Save All Test Results",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        3040,
        512
      ]
    },
    {
      "id": "e7472172-098d-4a68-811b-89c593545003",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        256,
        -80
      ],
      "parameters": {
        "width": 640,
        "height": 912,
        "content": "## Try It Out!\n\nUse n8n to extract medical test data from diagnostic reports uploaded to Google Drive, automatically detect abnormal values, and generate personalized health advice.\n\n### How it works\n"
      }
    }
  ],
  "connections": {
    "Download file": {
      "main": [
        [
          {
            "node": "Check if PDF or Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from PDF": {
      "main": [
        [
          {
            "node": "Combine page Markdown",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from Image": {
      "main": [
        [
          {
            "node": "Combine page Markdown",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if PDF or Image": {
      "main": [
        [
          {
            "node": "Extract from PDF",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract from Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Combine page Markdown": {
      "main": [
        [
          {
            "node": "Extract Medical Data (AI)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge AI Response Back": {
      "main": [
        [
          {
            "node": "Save Out-of-Range Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Medical Data (AI)": {
      "main": [
        [
          {
            "node": "Parse AI output to one-per-row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "General Health Advice(AI)": {
      "main": [
        [
          {
            "node": "Merge AI Response Back",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse AI output to one-per-row": {
      "main": [
        [
          {
            "node": "Out-of-Range Detection & Advice Fields",
            "type": "main",
            "index": 0
          },
          {
            "node": "Save All Test Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload pdf/jpeg file to Google drive": {
      "main": [
        [
          {
            "node": "Download file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Out-of-Range Detection & Advice Fields": {
      "main": [
        [
          {
            "node": "General Health Advice(AI)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}