Save lab results as FHIR LOINC Observations with optional Slack alerts
Quick overview Receives lab results by webhook, validates them, maps each test to a LOINC-coded FHIR R4 Observation, and saves it with duplicate protection. Critical results can trigger a Slack alert without patient identifiers. Reference and panic ranges are configurable demo examples.
How it works Receives a POST request on the /lab-result webhook containing a JSON lab result payload. Loads template settings, validates required fields and formats (including ISO timestamps), and normalizes the test identifier. Maps the test to a supported LOINC code and expected unit, and enriches it with configurable reference and panic ranges. Checks for duplicates using an idempotency key and stops early with a duplicate response if the result was already processed. Builds a FHIR R4 Observation linked to Patient/{patient_id} and creates it on the target FHIR server using an If-None-Exist header to prevent duplicates. If the result is in the configured panic range and Slack alerts are enabled, posts a critical alert to Slack without patient identifiers, then returns the final status and Observation details to the webhook caller.
Setup Provide a reachable FHIR R4 base URL and ensure Patient/{patient_id} resources already exist on that server. If your FHIR server requires authentication, configure a Bearer token (or other auth method) on the HTTP request that posts the Observation. In the workflow settings node, review and replace the demo reference/panic ranges for each supported test with your lab-validated ranges. To enable critical alerts, create a Slack Incoming Webhook, paste its URL into the settings, and keep critical alerts turned on. Activate the workflow and send test requests to the /lab-result webhook URL from your lab system or integration source.
Requirements n8n (self-hosted or Cloud) A FHIR R4 server (the public HAPI test server works for demos) Existing Patient resources on that server Bearer token credential if your FHIR server requires authentication Slack Incoming Webhook URL (optional, for critical alerts) A lab system or source able to POST JSON to a webhook
Customization Edit reference and panic ranges per test in the Settings node, with no code changes Add a new test by adding its LOINC code, accepted unit and ranges in the "Map Test + Ranges" node Replace the Slack alert node with Teams, email, SMS or another channel Change the idempotency key to match your source system's unique result ID Add unit conversion if your lab sends different units Add a Patient lookup or create step if patients may not exist yet
Additional info The reference and panic ranges are demo examples only and vary by laboratory, method and population; replace them before any clinical use. The optional patient_name field is accepted but never written to the Observation or sent to Slack. Treat your Slack webhook URL as a secret.
For more on integrating n8n with FHIR APIs, see Ciphernutz's guide: https://ciphernutz.com/blog/fhir-api-integration-using-n8n
Related Templates
Transform Gmail Newsletters into Insightful LinkedIn Posts Using OpenAI
Who Is This For? This workflow is perfect for content creators, marketers, and business professionals who receive regu...
Subscribe to new releases of a Github repository via Gmail
This is a very simple workflow that lets you subscribe to any github repository for the latest release (using n8n as ex...
AI Email Classifier & Auto-Delete for Gmail (SPAM/OFFER Cleaner)
This workflow is designed for freelancers, solopreneurs, and business owners who receive a high volume of irrelevant mes...
π Please log in to import templates to n8n and favorite templates
Workflow Visualization
Loading...
Preparing workflow renderer
Comments (0)
Login to post comments