Article
· Dec 12, 2024 2m read

Lookup Data Tables with TTL per entry and Purge Cleanup Task

Like many others probably find themselves, we were stuck doing live data mapping in our Interface Engine that we really didn't want to do, but had no good alternative choice. We want to only keep mappings for as long as possibly needed and then purge expired rows based upon a TTL value. We actually had 4 use cases for it ourselves before we built this. Use cases:

1. First ORU result with unique OBR-21 gets converted to a MDM^T02 event, any later ORU with the same OBR-21 value within 30 days (max workflow possible) gets sent as MDM^T08 to replace the existing document link.
2. CPOE ORM gets generated from an ORU result. The resulting vendor does not accept Filler Order Numbers, and the Interface Engine must clear the field. The CPOE interface must have the Filler Order Number. Cannot replace Placer Order Number with Filler Order Number as Clinician techs need to reference the Placer Order Number inside the vendor devices. Interface Engine then needs to map Placer Order Numbers to Filler Order Numbers to add in the missing values required for CPOE
3. Resulting vendor cannot change procedure after exam begun, and results filing back must be for the latest procedure. To avoid manually working these every time they happen, the Interface Engine needs to create a map for any new procedures after Exam Begun notification and map results to the new procedure. Max time to keep these procedure mappings is 72 hours.
4. Vendor cannot handle XO order update for change procedure ORM message. Instead they expect a cancel (CA) for the old procedure and a new (NW) or update (XO) for the new procedure. To create the cancel message, the Interface Engine needs to persist a map of the order number to procedure. When a procedure update message comes through, the Engine will lookup the previous procedure, send out the cancel order, then update the persisted mapping and send out the order update with the new procedure. There will be a max time that should usually be possible between the new order, and a change procedure later.

Since these scenarios will maintain live dynamic keys and values, we want to only keep mappings for as long as possibly needed and then purge expired rows. I looked at the LookupTable class, but it does not provide any kind of TTL functionality. So we wrote our own class dubbed LookupData.

https://codefile.io/f/vEgnWzafOx

This is my first class I developed from a blank slate. I am open to constructive criticism on how this can be made better. I am sure there are better ways to do some of the methods, so I welcome your feedback.

Discussion (0)1
Log in or sign up to continue