How Medicine Can Learn From Javascript Callbacks

By Dr. Kevin Maloy, April 2015

mobile-health-02-smallDid you just execute a callback?

Chances are … yes.  If you use browsers (which you obviously do if you are reading this), chances are you are using “javascript.”  Javascript goes hand in hand with the modern web.  You are using it right now.  And javascript is full of callbacks.

These are not HCAHPS callbacks for patient satisfaction.  Those are important, but for other reasons.

Rather, these callbacks in programming languages like javascript are things that happen when something else happens.  As a real world example of a callback, imagine a doctor in… an Emergency Department (ED).  A patient comes to the ED for chest pain.  The doctor orders some lab work and tells the patient, “Once your labs are back, we are going to contact your primary doctor.”  Contacting the primary doctor is the callback.  Something has to happen (i.e. all the lab work is back) and then something else happens (i.e. the primary doctor is contacted).

If a computer was seeing the patient instead of the doctor, without callbacks, it would be happy to do nothing else but wait and wait for the labs to come back and then call the primary doctor.  It wouldn’t see the next patient, it would just wait forever.  This is referred to as “blocking the UI.”  You know when your UI is blocked, as nothing else can happen and your computer cursor turns into some crazy spinning circle of death.  However, the human ED doctor must continue on and see other patients or the whole flow of the ED would be blocked.  Mentally, the doctor stores a callback (“When I realize that the labs are back I will call the primary doctor”) for execution and moves on.  Callbacks allow asynchronous processes to occur, and the ED is heavily asynchronous.

Let’s go back to our example.  All the lab work is back.  The computer seeing the patient stops “blocking the UI” and now calls the primary doctor almost as soon as the result is back.  The doctor seeing the patient, however, might have seen three other patients in the mean time.  The doctor might have forgotten temporarily about checking to see if the labs were back.

Most doctors cope with these lapses in processing callbacks by “running the board” or “running the list.”  In doing so, they check the status of where each patient is and see if there are callbacks can now execute.  This is very inefficient though, as results are often back long before one “runs the board.”  The problem is that the callback and the condition it is waiting for are not connected.  One is inside a person’s head, and the other is in the computer.

[Kevin Maloy is an Emergency Medicine physician, a Clinical Infomaticist and Coder.  He teaches the Hacking Healthcare course at Georgetown University School of Medicine.  Learn more about Kevin here:]

Thanks! You've already liked this