A Long Time Ago…

When I first started Somnus, I barely knew anything about coding let alone creating an app.

I had some prior experience by creating a Swim training app for a friend of mine back in 2016, which gave me the confidence to create the very first version of Somnus in March 2018 after several months of work.

I was very proud of it and if I could sum up the first version in one word, it would be…

Terrible!

I wasn’t too concerned as it was free and I’d really only made it known to a few of my registrars/residents and some Consultant colleagues. They were positive about it, but I think they were just being diplomatic because they didn’t seem to use it much!

Here is what the main list of Cases looked like back then - what eventually became the Dashboard. The other image shows the Reports screen, which evolved into the All Data screen.

On this page I’ll be mentioning the occasional technical term so apologies if I lose you.

Somnus’ First Icon

Limited Data Entry

Data entry was very basic and the information displayed was cramped. I had been storing all data added to each Case as an array of strings, and the Case itself as a basic object, stored locally on the device in UserDefaults - no security, no encryption. Of course all the data was ‘on device’ and there was no syncing or exporting so it was still safe for the most part. There was also no way to record actual patient information.

Every time a user renamed an item (eg. Comorbidity) I would scan all the Cases with that Comorbidity, rename the Comorbidity in each array of Comorbidity Strings within each Case, then save the Case. The process was clearly extremely CPU intensive & inefficient.

The database - if you can call it that - was rudimentary, and it soon became unwieldy & slow as more cases were added. I was clearly out of my depth.

It wasn’t as easy back then to get answers to questions and while I did lurk on Stack Overflow and learned a few things, much of the discussion was like a foreign language to me. Sometimes the ‘solutions’ were very much incorrect (just like some AI ‘solutions’ today).

I didn’t know anyone that could code so I was largely flying blind, relying on my e-books and online tutorials.

In early 2018, I entered the lottery to visit Apple Headquarters for their annual Worldwide Developer Conference. The odds of actually getting an invite were very low but it was still worth a shot.

WWDC18

My first attempt at winning the lottery, and my first invitation to WWDC - I couldn’t believe it!

With very little notice I booked flights & accomodation and planned my trip to San Jose. I was so jet-lagged and wide awake in the middle of the night, I decided to head to the queue for the Keynote.

It was live at 10am but people were out queuing well before I arrived - at 3am!

I stood in that queue for 7 hours and had a great time, met some fabulous people, one of whom I’m good friends with to this day. Despite queueing that early, we were still 10 rows back from the stage!

And after a long morning, it finally started. I was very fortunate to experience this before COVID-19 killed the live events and Apple started producing slick, error-free presentation videos.

I miss those times. Human interaction is important.

Meeting Experts

One of the things you learn when starting any new subject is how very little you know and nothing highlights this more than when you’re surrounded by experts in the field.

But if you want to fly, you need to hang out with eagles, not chickens.

I rubbed shoulders with coders from major corporations, and big names in the app world, some of whom are basically celebrities in the nerd-world - people who create software and hardware and everything in between - and chatted to as many people as I could (not easy for an introvert!)

I was able to have a few one-on-one sessions with Apple experts too - firstly a design session which told me what I needed to know. That my UI was awful and stale.

The second session was far more helpful. I’d shown a Data engineer what I’d done & how my database was sluggish. Then he simply asked, “Why don’t you just use Core Data?”

I embarrassingly had no idea what he was talking about… but in short, Core Data is Apple’s way of implementing & interfacing with a relational database. He took the time to show me how it works and some web sites to help learn more.

This was the critical piece needed to make Somnus work - a proper relational database where objects are distinct, where renaming one updates it everywhere instantly, and where they can be linked to other objects.

So Cases are objects, as are Comorbidities. A Case can have multiple Comorbidities, and a Comorbidity can be linked to multiple Cases. This is what’s known as a many-to-many relationship.

There are other relationship types in Somnus too, like one-to-many (ie. Specialties -> Operations) as an example. A Specialty can have many Operations but an Operation can only have one Specialty.

At the end of the conference, after a concert with Panic at the Disco headlining, we all went home to our corners of the world…

Database Freedom

Now that I understood more about relational databases and Apple’s APIs controlling it all (Core Data), I was able to finally create the sort of dynamic, fast app I needed.

Each item (Case, Patient, Comorbidity, etc) was a unique Entity in the database, with each Entity having a range of Attributes depending on what it was. For example, a Comorbidity has several Attributes including a unique identifier, name, favourite status. And Entities are linked by Relationships - some are many-to-many, some are one-to-many and some are one-to-one.

By mid-July 2018 I was well underway and about to release Version 3.0 of Somnus (released 14 September 2018) and it was a far better experience.

You can see the origins of my current Case Card & Dashboard design starting to take shape. Back then the Cards were not interactive in any way. You could tap them to edit a Case, but that was about it.

There was still no iCloud syncing and I hadn’t yet worked out how to integrate any sort of label scanner, but I was well on my way to creating something I could be proud of.

Version 3 Icon

Milestones

Over the following years I added many new features to Somnus. Some notable examples from the various versions include:

Version 4.x (4 December 2018)

  • Booked Cases

  • Ability to add Surgeons

  • Advanced Searches

Version 5.x (25 February 2019)

  • ID Labels

  • Biometrics & BMI Calculations

  • Built-in RVG

  • Full backup & restore support

  • Dashboard Statistics

Version 6.x (pictured) (27 October 2019)

  • iCloud syncing

  • ID Label & Document scanning

  • Multiple Personal List support

  • Improved Case Card Design

  • Drag & Drop

  • Context Menus

Version 7.x (21 September 2020)

  • BSA calculations & Biometric checks

  • Efficiency Chart (Mini-Map)

Design & Development

The only coding I’ve ever done has been for products in the Apple ecosystem.

I use Apple’s Xcode for development, seen here viewed through my visionOS headset which allows me to have several massive displays going at the same time in virtual space.

The language used by Apple is based on C++ but it has evolved dramatically over the past 10 years, first to Swift and now with SwifUI.

SwiftUI is a declarative framework built on the Swift language where the user interface is also built in code rather than constructed visually with a design tool.

I started implementing elements of SwiftUI from version 7 of Somnus but it wasn’t until I rolled out version 10 that the migration to a fully SwiftUI based app was complete.

While it still has some limitations, it is a very solid foundation to build for the future.

I do all the coding, design & website work for Somnus - as well as all tech support - even down to icon design.

Further Improvements

Version 8 of Somnus, released 13 December 2021, introduced more refinements and added proper multi-window support from iPad & macOS. It also added:

  • More charts

  • Ability to copy & paste Case details

  • Auto-start for quick starting the next case

SwiftUI was starting to be incorporated into the app but it was not visible to the end user at this point.

Version 9 introduced some of the first SwiftUI interface elements to Somnus 11 December 2023 - most notably in the list views for categories viewed from the All Data screen. It also included the use of Swift Charts for the first time in these lists.

Other updates added in Version 9 included:

  • Folders for Searches & Templates

  • Ability to enter actual ages for Generic Patients

  • Personal Lists for Patients, separated to Personal List for Cases

  • Biometric Z-Scores & Percentiles (weight, height & BMI in children)

  • Timezone Support

  • ‘Quick Search’ creation

  • Template sort order in lists

Fully SwiftUI

It was becoming apparent that the user interface, while OK, was starting to look a bit stale and screens like All Data were difficult to navigate and didn’t show much information, nor did it allow any customisation other than chart visibility.

I also wanted to create far more detailed charts with Swift Charts throughout Somnus, not just in list views.

Version 10 was by far the biggest overhaul of Somnus with pretty much every line of code being rewritten. All but the underlying data model was new.

I tried to keep much of the user interface and user experience (UI/UX) so as to not be too jarring for existing users, while still adding some great enhancements.