The common view of an "order" is a medication, test, or other task to be given to or performed on the patient. For example, the doctor orders penicillin for the patient, changes the dose a few days later, and eventually discontinues the penicillin. For an order entry system, this is not a single "pencillin order"; rather, there are three orders (start, revise, and discontinue) for the orderable penicillin. Each of the three orders -- (1) the request to begin, (2) the request to revise, and (3) the request to discontinue pencillin – needs to be issued and tracked through a workflow that may include printing or sending to external systems; so, every order (request) needs a unique order number.

We do not rely on the orderable (in our example, the penicillin concept) to link related orders (the starting, changes to, and discontinuation of pencillin); rather, we create a linked array using the previous order number. This allow for the possibility of someone changing the orderable (e.g., changing from penicillin pills to intravenous pencillin).

Eventually, we will get to a world where multiple people may be simultaneously writing orders and/or saving orders in a draft or pending state for a while, meaning that we could have something similar to branching; however, since orders only get an order number when activated (i.e., "committed") and we will have to perform conflict resolution on cases where conflicting orders have been activated (effectively re-basing the orders to continue the git analogy), I think it's okay to treat our linked list (previous order number) as a linear. For example, if the patient has been prescribed penicillin with order 123 and you start to discontinue it (i.e., you are about to activate a "discontinue penicillin" order that would become order number 124 with a "previous order number" of 123), but I sneak in and change the dose of pencillin before you sign your orders, my order with a new dose of penicillin would get order number 124 + previous order number 123 and you would be forced to review the change before you completed your orders. Most importantly, if you decide to still discontinue penicillin despite my change to it, your "discontinue penicillin" order would become order number 125 with a previous order number 124 (i.e., linked to my change, not the original order number 123).

Class diagram