For patient safety reasons, we want to prevent overlapping drug orders for the same drug formulation – i.e., to prevent someone from inadvertently ordering a duplicate dose of the same drug, and having the patient receive an overdose through a downstream process.
However, as a platform, we do need to allow overlapping drug orders for the same drug formulation if the orderer is explicitly aware of what is going on, and acknowledges what they are doing – e.g., ordering paracetamol 200 mg tab twice daily and paracetamol 200 mg tab Q6H PRN as two separate, concurrent orders.
We need to modify OrderService.saveOrder(Order, OrderContext) so it is possible for the caller, when saving/update a drug order, to pass in (via OrderContext) a list of "parallel" orders known to overlap with the given Order. Currently, the only use case for this will be for callers to explicitly acknowledge awareness of parallel orders for the same drug formation. We could also provide an OrderService.saveOrder(Order, OrderContext, Order) method for a caller to explicitly identify known parallel orders. If a caller tries to add or update a drug order for which there are parallel orders (i.e., one or more other overlapping drug orders for the same drug formulation) without referencing those parallel orders, then the API should throw an AmbiguousOrderException. For example, if paracetamol 200 mg tab twice daily is an active drug order and the caller tries to add paracetamol 200 mg tab Q6H PRN as a new drug order without acknowledging the existing parallel order for the same drug formulation, then the API should thrown an exception.
Overlap checking (e.g. this) should be suppressed against the orders explicitly passed in.
We will also need to support this same functionality via REST. Once this ticket is implemented, please create a ticket in the RESTWS project for that.