Skip to main content

Vectorize Medical Procedures for Semantic Search with TUSS, Gemini & pgVector

Workflow preview

Workflow preview
100%
Vectorize Medical Procedures for Semantic Search with TUSS, Gemini & pgVector preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

Description This workflow vectorizes the TUSS (Terminologia Unificada da Saúde Suplementar) table by transforming medical procedures into vector embeddings ready for semantic search. It automates t...

Best for

  • Engineering automation workflows
  • AI RAG automation workflows
  • intermediate n8n builders looking for reusable templates

Tools used

@n8n/n8n-nodes-langchain.vectorstorepgvector, @n8n/n8n-nodes-langchain.textsplittertokensplitter, @n8n/n8n-nodes-langchain.embeddingsgooglegemini, n8n-nodes-base.stickynote, n8n-nodes-base.manualtrigger, n8n-nodes-oracle-database-parameterization.oracle database with parameterization, n8n-nodes-base.code, n8n-nodes-base.splitinbatches

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Thiago Vazzoler Loureiro.

Original n8n.io source

1.1 Workflow description

Title
Vectorize Medical Procedures for Semantic Search with TUSS, Gemini & pgVector
Workflow name
Vectorize Medical Procedures for Semantic Search with TUSS, Gemini & pgVector

Description

This workflow vectorizes the TUSS (Terminologia Unificada da Saúde Suplementar) table by transforming medical procedures into vector embeddings ready for semantic search.

It automates the import of TUSS data, performs text preprocessing, and uses Google Gemini to generate vector embeddings. The resulting vectors can be stored in a vector database, such as PostgreSQL with pgvector, enabling efficient semantic queries across healthcare data.

What Problem Does This Solve?

Searching for medical procedures using traditional keyword matching is often imprecise. This workflow enhances the search experience by enabling semantic similarity search, which can retrieve more relevant results based on the meaning of the query instead of exact word matches.

How It Works

  1. Import TUSS data: Load medical procedure entries from the TUSS table.
  2. Preprocess text: Clean and prepare the text for embedding.
  3. Generate embeddings: Use Google Gemini to convert each procedure into a semantic vector.
  4. Store vectors: Save the output in a PostgreSQL database with the pgvector extension.

Prerequisites

  1. An n8n instance (self-hosted).
  2. A PostgreSQL database with the pgvector extension enabled.
  3. Access to the Google Gemini API.
  4. TUSS data in a structured format (CSV, database, or API source).

Customization Tips

You can adapt the preprocessing logic to your own language or domain-specific terms.

Swap Google Gemini with another embedding model, such as OpenAI or Cohere.

Adjust the chunking logic to control the granularity of semantic representation.

Setup Instructions

Prepare a source (database or CSV) with TUSS data. You need at least two fields:

  • CD_ITEM (Medical procedure code)

  • DS_ITEM (Medical procedure description)

Configure your Oracle or PostgreSQL database credentials in the Credentials section of n8n.

Make sure your PostgreSQL database has pgVector installed.

Replace the placeholder table and column names with your actual TUSS table.

Connect your Google Gemini credentials (via OpenAI proxy or official connector).

Run the workflow to vectorize all medical procedure descriptions.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Postgres PGVector Store2

Type / Role
@n8n/n8n-nodes-langchain.vectorStorePGVector - vectorStorePGVector
Config choices
Version 1.1

Block 2 - Token Splitter

Type / Role
@n8n/n8n-nodes-langchain.textSplitterTokenSplitter - textSplitterTokenSplitter
Config choices
Version 1

Block 3 - Embeddings Google Gemini

Type / Role
@n8n/n8n-nodes-langchain.embeddingsGoogleGemini - embeddingsGoogleGemini
Config choices
Version 1

Block 4 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 5 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 6 - VECTORIZE TUSS TABLE

Type / Role
n8n-nodes-base.manualTrigger - manualTrigger
Config choices
Version 1

Block 7 - ORACLE DATABASE CONNECTION

Type / Role
n8n-nodes-oracle-database-parameterization.Oracle Database with Parameterization - Oracle Database with Parameterization
Config choices
Version 1

Block 8 - COLLECTION OF MEDICAL PROCEDURES

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 9 - FOR - MEDICAL PROCEDURES

Type / Role
n8n-nodes-base.splitInBatches - splitInBatches
Config choices
Version 3

Block 10 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 11 - Data Loader

Type / Role
@n8n/n8n-nodes-langchain.documentDefaultDataLoader - documentDefaultDataLoader
Config choices
Version 1

3. Summary Table

Workflow Vectorize Medical Procedures for Semantic Search with TUSS, Gemini & pgVector
Complexity intermediate
Nodes 11
Categories Engineering, AI RAG
Author Thiago Vazzoler Loureiro
Published 27 Jul 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/6543/6543.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Vectorize Medical Procedures for Semantic Search with TUSS, Gemini & pgVector do?

Description This workflow vectorizes the TUSS (Terminologia Unificada da Saúde Suplementar) table by transforming medical procedures into vector embeddings ready for semantic search. It automates t...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Engineering, AI RAG use case.