My virtual vaccination program

Sezen de Bruijn
ITNEXT
Published in
8 min readJan 29, 2021

--

Three months ago I created a zombie-free state machine that allows you to create Concerned Citizens and help them survive in a Pandemic society. (What a buck-wild sentence to start off with. 0-O.)

I shared the link to the application in an article called “No Zombies in State Machines”, and a surprising amount of people started creating and caring for virtual concerned citizens. Not sure why. Did anyone ask for an application that simulates the current hell-scape we live in?

But such is life, and now I have a virtual population of Concerned Citizens to care for. I’m surprisingly concerned about those Concerned Citizens too. So, I think it is time to start vaccinating my citizenry.

(Unrelated note: as of today, nobody decided to kill a Concerned Citizen, while everyone is able to do so. Have faith in humanity, people!)

Our Mission today is:

  1. Invite people for vaccination
  2. Enable citizens to get or refuse their vaccin (using a subcase)
  3. Keep track of our populace health through a dashboard (are we hitting herd immunity yet?)

Let’s get my people vaccinated!

Section 1: the draft

I had a lot of internal discussions about what to call the invitation process for the vaccin. In principal I would love to be invited for the vaccin, although I do understand that other people would have some reservations. So I wanted a term that reflected that. Being Cordially Invited, for instance. But on the other hand…. this is not something you do for yourself alone. It is a contribution you make to the welfare of your society and that sense of duty should be reflected as well.

So in the end I decided that the mechanism for determining who gets vaccinated is called ‘the Draft’, but each citizen receives ‘an invitation’. Which they can refuse, obviously.

In this section, we will build the mechanism of the draft. In real-life the determination as to who gets vaccinated first is complex and dependent on many variables. In my world things are less complicated.

There are three properties of my citizens that I will use in the draft:

  • IsAlive
  • IsVulnerable
  • IsDrafted

Obviously only living people qualify for vaccination. We will only draft those that aren’t yet drafted. And those who are vulnerable (IsVulnerable=True) are prioritized. When people are drafted, two vaccins are set aside for them, which is different from how many real-world countries do it, but this is my personal preference.

We will receive vaccins every week, a random amount in fact, between 2 and 8. And when we do, we will go and draft the amount of citizens that we can give 2 vaccins based on that number + stock. So, if we have 6 vaccins, that is three citizens. If we have 3 vaccins, one citizen will be drafted, and one vaccin will go into stock.

Let’s implement!

I set up a timer that will make sure we get our vaccins each week:

And in the associated action I called the Draft process giving it a random number as input, using the Randomizer Number Generator from the Forge to create that input.

Getting the vaccins delivered

The Draft process is easy to understand. I first calculate how many people I can draft, then I fetch that amount of citizens from the database, and create Vaccin subcases for them. Here are some pictures to illustrate.

The Draft process
Calculating the amount of people to draft and the stock

I was a bit worried that my math wasn’t completely correct here, so I quickly built a data driven unit test to check, using the BDD framework. My algorithm led to the right result in 15 different examples, so I am trusting it :-) Feel like testing it yourself? Run my test set here.
(Note: there is one test that will fail because I incorrectly entered my test data. -\_(-_-)_/-)

My automated test set, using BDD framework.

After determining the amount of vaccins I’m selecting the right amount of citizens and inviting them to get vaccinated.

The actual drafting logic

With that my summoning logic is complete. My vaccination program is up and running!
Unfortunately, right now, people might get invited for vaccination, but are unable to actually get the vaccin. We do not yet have that subcase in place. The Vaccin_create is an empty action at the moment. So let’s start building our vaccination subcase!

Section 2: virtual vaccines

So how do you vaccinate a virtual person, who only exists as a Case in a State Machine? Through a subcase of course!

A subcase will allow me to have a separate set of data with its own statuses. This will help us organize vaccines, without disrupting the day-to-day life of our Citizens. In the meantime the subcases are connected to the citizens, so we never lose track of who we are vaccinating.

In general, setting up a subcase is a lot like setting up a case. That is to say: we create a Business Entity, Case Definition, a set of Statuses, and because this subcase is a State Machine, list out the State Transitions.

What makes a subcase different from the case is simply the initialization. To create a record into a business entity for a case you need to have a crud-wrapper around your create_BusinessEntity record action. After all, the entity has the CaseIdentifier as an Identifier, so you need to initialize the case before you create the record. And this is where the magical sub-casing happens: You initialize the case using the parent case as a parent id.

That’s all you need to do to link your subcase to its parent. And once you have done this, you can easily access your subcase from anywhere you already have your main case. In theory I could make as many subcases as I wanted, starting a mask wearing subcase for instance if someone goes outside. This could easily exist next to each other.

But for now, lets focus on vaccins. (Spoken as a true world-leader, I would say :-D)

My vaccination state machine (not pictured: the Not Alive state. It really cluttered up the schema)

So my vaccination State Machine is in essence quite easy to understand. When a person gets drafted they get invited for vaccine 1, they can either accept or refuse. If they accept, they will get the vaccin and then be invited for vaccine 2. They once again have the chance to accept or refuse. After accepting the second vaccine they will live blissfully immunized against Covid19.

If they refuse the vaccin they get into another track: we will assume that they are refusing the vaccine because they have concerns about it and will proceed to educate them on the vaccine in the hopes of removing those concerns.
After that they get invited to partake in the vaccination process again. The vaccines we reserved for them stay reserved. As you can see there is a certain circulair motion in the refusal path. I have no end point in this model where the person does not get the vaccine.

Or actually, there is… In the code I also modelled in death. But I left it out of the picture because it really made my drawing quite confusing. And depressing. I think that this Zombies project might be the worlds first momento mori State Machine.

The rest of the implementation was not much work, because I used a lot of functions already available to me from the Case Management framework. I added a vaccination block into the screens:

Our new Citizen Screen with Vaccination Capabilities

I added some automatic state transitions:

Automated state transitions

And I set a timer to wait three weeks between vaccins.

Set Timer between vaccinations

I even built some logic to stop the vaccin in the event of the death of a participant (updating the subcase based on changes in the parent):

And with that I have my Vaccination program up and running! Now if only I knew how successful my vaccination program was…

Section 3: A dashboard

To keep a check on my population vaccination I created this little dashboard. It shows some metadata on the population program.

You also see that I had to kill some citizens to check if my NotAlive mechanisms synched well from parent to child case. No progress without sacrifice, I suppose!

(Please note that I’m kidding! Progress without sacrifice is not only possible, it is accomplished on a daily basis. Have faith in humanity, people! Just not in me.)

Section 4: Final thoughts

So there we have it. My testament to the crazy times we live in. First I created a civilian population that was trying to avoid being infected/infecting others, while avoiding to become zombies. Now I added a more positive societal development by adding vaccins as we are slowly moving towards the aftertimes.

I’m not naïve enough to think that this path will be easy. That there will be no final hurdles, or sudden dramatic developments to throw us for a loop. But still I am pensively optimistic. In march 2020 the Dutch Prime Minister indicated which phase of the Corona Crisis we were in by saying: “We have passed the start, but are not yet at the end of the beginning.”

As prime-minister of my own virtual community, let me now say in januari 2021: “We have passed the end of the beginning and are now at the start of the beginning of the end.”.

--

--

Low-Code Solution Architect ★ helping you build IT Fast, Right and for the Future ★ Let’s just have some fun :-)