Skip to main content

Feature Demo

Linkiir Demo is a ready-to-run project you import as a zip bundle. It makes HL7 messages, sends them over LLP, turns each one into a database row with a Data Map node, saves the rows to SQLite with a Database node, and serves the patients back through a web page and JSON API.

Import it to see how projects and workflows fit together, and how the core nodes work.

Download Linkiir_Demo.linkiir.zip (121 KB)

One of two Demo Projects. For a healthcare interoperability example, see the HL7 v2 to FHIR Demo.


What's inside​

Four workflows, numbered in the order a message passes through them:

Step 1 Step 2 Step 3 Step 4
Generate HL7 ──► File to LLP ──LLP──► Data Map ──► Database ◄── Patient Lookup API
(to files) (send on) (HL7 → row) (SQLite) (web page + JSON)
WorkflowWhat it does
Step 1: HL7 Message GeneratorMakes a random HL7 ADT message every 10 seconds and writes it to a file
Step 2: HL7 File to LLPReads the files, stamps the sending application, and sends each message over LLP
Step 3: HL7 LLP to DatabaseReceives the messages, maps each one to a Patient row with a Data Map, and saves it with a Database node
Step 4: Patient Lookup APIA web page and JSON API that read the patients back

Import the project​

  1. Open the Linkiir Grid in your browser.
  2. Go to Projects.
  3. Click the chevron on Add Project and choose From zip.
  4. Drop Linkiir_Demo.linkiir.zip on Choose a project bundle, or click to browse for it.
  5. Click Import.

The project appears as Linkiir Demo with 4 workflows. There is nothing to set up: the folders, the database and its table are created the first time the workflows run.


Start the demo​

Click into Linkiir Demo and click Start All.

That's all. The workflows can start in any order: until Step 3 is listening, Step 2's Send LLP node keeps trying to connect, and both Step 3 and Step 4 create the database if it isn't there yet.


See it working​

Within about 20 seconds, patients start to arrive. Open the Patient Lookup page:

http://localhost:8081/lookup

Each new message adds a patient, and the table fills up. On the page you can:

  • search patients by last name
  • click Show All to see the 100 most recently updated patients
  • click Reset DB to delete every patient and watch the table fill again

The JSON API answers on the same route:

URLReturns
http://localhost:8081/lookup?LastName=SmithPatients with that last name
http://localhost:8081/lookup?all=1The 100 most recently updated patients

A tour of the workflows​

Open any node on the Scripting page to see its code or its map. Each node with sample messages can be tried with Run Test, without starting anything.

Step 1: HL7 Message Generator​

NodeTypeWhat it does
Generate HL7Custom sourceEvery 10 seconds, main.lua builds a random ADT message: an admit (A01), registration (A04), update (A08) or discharge (A03)
Save to FileFile destinationWrites each message to demo/messages/

main.lua is one short function. It builds the message with linkiir.data.create, fills fields such as Msg.PID[8] = 'F', and pushes the text on.

Step 2: HL7 File to LLP​

NodeTypeWhat it does
Read HL7 FilesFile sourcePicks up the files in demo/messages/ and deletes each one once it's read
Stamp SenderCustom transformSets the sending application and facility (MSH-3 and MSH-4) to Linkiir Grid and Demo Facility
Send LLPLLP destinationSends each message to localhost:5145, where Step 3 listens

Step 3: HL7 LLP to Database​

NodeTypeWhat it does
Receive LLPLLP sourceListens on port 5145 and acknowledges each message
HL7 to Patient RowData MapTurns each ADT message into a row for the Patient table
Save PatientDatabase destinationUpserts the row into the SQLite database demo/patient.db

The Data Map. Open HL7 to Patient Row on the Scripting page to see its Map view. Each line links an HL7 field to a column:

HL7 fieldColumnHow
PID-3.1IdCopied. A message without one is rejected
PID-5.2, PID-5.1FirstName, LastNameCopied
PID-7BirthDateConverted from 19720809 to 1972-08-09
PID-8GenderLooked up: M becomes Male, F becomes Female, anything else Unknown
PID-11.3, PID-11.4City, StateCopied
MSH-9.2LastEventCopied (A01, A04 or A08)
(none)UpdatedAtThe current date and time

The map takes admits, registrations and updates. A discharge (A03) has no map, and the node's Unknown Messages setting is Skip the message, so the node logs Skipped ADT_A03: no map takes it and moves on.

The node has three samples: an admit, an update and a discharge. Pick one and click Run Test to see the row the map builds, or that the discharge is skipped.

The Database node. Select Save Patient and click Configure to see its settings: Database is SQLite, Database File is demo/patient.db, and Write Mode is Upsert, so a patient who already has a row is updated rather than added twice. Its Tables tab holds the Patient table, with Id as the primary key.

Why there is a create_database.lua. A Database node never creates tables by itself. In your own interfaces you create them once, from the Configure dialog. So that the demo runs as soon as it's imported, the Data Map node's create_database.lua creates demo/patient.db and its Patient table the first time the node starts.

Step 4: Patient Lookup API​

NodeTypeWhat it does
Patient APIHTTP sourceServes the search page and the JSON API on the lookup route

Its code is split across three files: main.lua answers each request, patient_db.lua runs the SQL queries, and patient_page.lua holds the HTML page.


Settings you may want to change​

SettingNodeDefaultNotes
Remote PortStep 2: Send LLP5145Must match Step 3's listen port
Listen PortStep 3: Receive LLP5145Change both if the port is in use
Route PathStep 4: Patient APIlookupChange it if it collides with another endpoint
IntervalStep 1: Generate HL710000 msRaise it for a quieter demo
IntervalStep 2: Read HL7 Files10000 msKeep it close to the generator's

Reset the demo​

  • Clear the patients: click Reset DB on the lookup page. The workflows can keep running, and new messages fill the table again.
  • Start from scratch: click Stop All, delete the demo/ folder in the grid's working directory, then click Start All. The folder, database and table are created again.

What the demo shows​

TechniqueWhere to see it
Building an HL7 message in LuaStep 1: Generate HL7 → main.lua
Reading and changing an HL7 messageStep 2: Stamp Sender → main.lua
Sending and receiving over LLPStep 2: Send LLP, Step 3: Receive LLP
Mapping HL7 to database rows without codeStep 3: HL7 to Patient Row → Map view
Skipping messages a map doesn't takeStep 3: HL7 to Patient Row → Unknown Messages
Writing rows to a database without codeStep 3: Save Patient → Configure
An HTTP endpoint with a JSON APIStep 4: Patient API → main.lua
Splitting a script into modules with requireStep 4: main.lua, patient_db.lua, patient_page.lua

Troubleshooting​

SymptomCauseFix
No patients on the lookup pageThe workflows haven't run long enoughWait 20 seconds, then click Show All
Send LLP logs "Connection refused"Step 3 isn't listening yetMake sure Step 3 is running. Send LLP retries every 10 seconds
Receive LLP won't startPort 5145 is in useChange Listen Port on Receive LLP and Remote Port on Send LLP to a free port
demo/messages/ is emptyStep 2 deletes each file once it's readNothing to fix. The patients on the lookup page show the messages got through
Save Patient stopped with "no such table: Patient"The database was replaced by one without the tableClick Stop All, delete the demo/ folder, and click Start All

Where to go next​

GoalRead
Build your own mapsData Map Nodes
Write to your own databaseDatabase Node
Try the healthcare interoperability demoHL7 v2 to FHIR Demo
Understand the node types the demo usesInterfaces and Core Nodes
Look up the functions the scripts callLinkiir Scripting API
Debug and test scripts the way the demo doesTesting and Debugging