# Triage emergency patients with OpenAI: n8n workflow template

> Started by someone opening a chat with it, and works across Postgres. It puts OpenAI behind a retrieval step, so answers are drawn from documents you supply...

Source: https://millionrounds.com/workflow/triage-emergency-patients-with-openai (Millionrounds; every figure on the page links to its filing or article)

[Automation library](https://millionrounds.com/workflows) · [Data collection](https://millionrounds.com/workflows?category=Data+collection#library)

# Triage emergency patients with OpenAI

Started by someone opening a chat with it, and works across Postgres. It puts OpenAI behind a retrieval step, so answers are drawn from documents you supply rather than from the model alone. 20 steps, 3 branches: a working afternoon to understand properly.

Medium Calls a model: OpenAI Retrieval

[Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Ftriage-emergency-patients-with-openai)

**20 steps** Medium: a working afternoon

**3** Branches: places the flow splits

**0** Loops or waits

**1** Service it connects to

## The flow

Starts it 1 Model 6 Logic 8 Service 5

The steps in the order they run, from what starts it.

- 1 **OpenAI Chat Model** Lm Chat Open Ai *Model*
- 2 **Conversation Memory** Memory Buffer Window *Model*
- 3 **Structured JSON Output Parser** Output Parser Structured *Model*
- 4 **Department Availability Checker Tool** Tool Code *Model*
- 5 **Patient Consent Validator Tool** Tool Code *Model*
- 6 **Hospital Triage Agent** Agent *Model*
- 7 **Patient Chat Interface** Chat trigger *Starts it*
- 8 **Check Confidence Threshold** If *Logic*
- 9 **Retrieve Patient History** Postgres *Service*
- 10 **Prepare Escalation Data** Set *Logic*
- 11 **Enrich with Patient Context** Set *Logic*
- 12 **Format Response to Patient** Set *Logic*
- 13 **Validate Business Rules** Code *Logic*
- 14 **Route by Intent Type** Switch *Logic*
- 15 **Check Patient Eligibility** Postgres *Service*
- 16 **Log Interaction to Audit DB** Postgres *Service*
- 17 **Calculate Priority Score** Code *Logic*
- 18 **Check Action Required** If *Logic*
- 19 **Execute Appointment Action** Http Request *Service*
- 20 **Send Notification** Http Request *Service*

## How it's built

- **Starts on:** Someone opening a chat with it
- **Steps:** 20, with 3 branches
- **Size:** Medium: a working afternoon
- **Connects to:** Postgres
- **Model:** OpenAI
- **Retrieval:** Answers are drawn from documents you supply, not from the model alone

## Questions

What does it need to run?

An n8n account, plus your own Postgres account, and a key for OpenAI. You connect your own accounts after importing it; none are included.

What starts it?

It starts on someone opening a chat with it.

Does it use AI?

Yes. It calls OpenAI. Its answers draw on documents you give it, not on the model alone. Model calls are billed by the provider, not by n8n.

How long does it take to set up?

Plan an afternoon. 20 steps is enough that you should read each one before running it.

How do I import it?

Copy the workflow, open a new workflow in n8n and paste. The steps appear on the canvas, ready for your own accounts.

**Before you run it**

Nothing here has been tested by us. It is somebody's working automation, read and described from its own steps. Treat the connections it wants as a list of accounts it will touch, and read the 20 steps before you point it at anything that matters.

## Run it in n8n

- **Create your n8n account** Free to start. n8n is where the workflow runs. [Create an n8n account ↗](https://millionrounds.com/n8n)
- **Download the workflow** Free with a Millionrounds account. [Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Ftriage-emergency-patients-with-openai)
- **Paste it into n8n** Open a new workflow in n8n and paste. Then connect your own accounts.

Stored with the author's traces removed: canvas notes, instance identifiers, saved credential names and any live document they had left behind.

## Connects to

Each opens the other workflows that use it.

[Postgres](https://millionrounds.com/workflows?service=Postgres#library)

## Workflows like it

Also data collection, with the same services where possible, closest in size first.

- [**Generate Complete Database Schemas with Claude** 20 steps · calls a model · Postgres](https://millionrounds.com/workflow/generate-complete-database-schemas-with-claude)
- [**Automate customer retention with Stripe** 22 steps · calls a model · Gmail, Google Sheets](https://millionrounds.com/workflow/automate-customer-retention-with-stripe)
- [**Automatic service with Gemini and Postgres** 22 steps · calls a model · Postgres, Redis](https://millionrounds.com/workflow/automatic-service-with-gemini-and-postgres)
- [**AI study assistant with RAG and Drive** 17 steps · calls a model · Google Drive, Postgres](https://millionrounds.com/workflow/ai-study-assistant-with-rag-and-drive)
- [**Serve a RAG chat backend for Next.js with OpenAI and Redis** 23 steps · calls a model · Pinecone, Postgres](https://millionrounds.com/workflow/serve-a-rag-chat-backend-for-next-js-with-openai-and-redis)
- [**Product concept to 3D showcase with DALL-E** 16 steps · calls a model · Postgres](https://millionrounds.com/workflow/product-concept-to-3d-showcase-with-dall-e)
