Gas Notes Simulation Monitor

Sam Nunn – 31 May 2024

Gas Notes now has a remote-controlled patient monitor to help you run simulations (and OSCEs). And the best thing? It’s free.

You might well be wondering how and why I made such a thing. Well hold on to your hats, because I’d love to tell you more.

Some Context 💁‍♂️

My hospital has a very cool simulation suite equipped with all sorts of clever gear to make our simulations immersive, including a remote-controlled patient monitor that we use to pipe information into the simulation.

An illustration of our expensive simulation suite

But even the world’s cheapest monitor is eye-wateringly expensive which got me thinking… What about folks that don’t have the budget for all this gear? Why shouldn’t they have access to great simulation tools?

So, in a fit of pique, I set about creating my own free simulation monitor.

How hard could it be?

Development 🤖

The first 90% of the work took a weekend. The second 90% has taken about three months. So it goes, in the world of software development.

Architecture

I decided to make a web app because I’m familiar with the tools, they can run on any device with a browser, and almost everyone has access to such devices.

A diagram depicting the client-server architecuture of the app. On the left there is a cartoon control panel, on the right there is a cartoon patient monitor. Above them in the middle there is a cartoon server. Dotted lines join the server to the other two images to indicate that controllers and monitors do not communicate with each other directly.

I used a client-server architecture because this needs to run on locked-down corporate networks where nothing but :80 and :443 are open. I also don’t have to fret about software updates: everyone always gets the latest and greatest.

It was also dearly important that I create lightweight software that respects users’ privacy and doesn’t guzzle their battery power. The single heaviest page on the site weighs only 38.4 kB (minified and gzipped) and it sips power.

Wave Generator

The waveforms on the monitor are generated on-device in real time.

That took some doing.

An illustration of an imaginary device that prints an ECG from a heart in a glass jar

I started by pre-rendering rhythm strips using ECGSYN and downloading them as-needed to the client. It was a good prototype but it wasn’t flexible: it could only do ECGs (in sinus rhythm), it required sending large images (slowly) over the wire, and it couldn’t transition between rhythms in real time.

The “a-ha” moment came when I realised that ECGs never loop back on themselves. They only move from left to right, so it’s possible to describe them as a set of keyframe coordinates:

ECG keyframes with linear interpolation

I hacked together some <canvas> commands to display a time series of keyframes with simple linear interpolation between them. After a brief and unpleasant attempt at hand-rolled polynomial interpolation, I switched to SVG with its built-in commands for drawing silky-smooth cubic Béziers.

ECG keyframes with smooth interpolation

Each keyframe now contains four parameters:

This new system lets me vary the height (y) and duration (x) of each keyframe according to various physiological parameters. For example, I can model dromotropy by shortening the PR interval at higher heart rates.

Open Source 🕊️

This software is proudly provided for free to anyone that wants to use it, including you. Just promise that you’ll use it for good and not for evil.

Give It A Go 🎯

So… What are you waiting for? It’s time to run a simulation!

For the very keen, you can read more about how the simulation monitor was made and check out its source code on GitHub.