I can imagine that there are some of you who saw the headline and came here to chew me out because mixing LIVE and TEST data is a mortal sin and should never be done!
I agree that it shouldn’t be done, but, at least in healthcare, it happens and as an integration analyst or programmer you should be prepared to handle it.
Here’s the situation I found myself in.
A client is upgrading their Meditech Magic HIS from 5.66 to 5.67.
Their middleware is MDI Solutions MD-Link. MD-Link uses Jython as its scripting language.
That means we are working with both a 5.66 and a 5.67 Test Ring.
If there’s interest I can talk about the challenges of running a dual test environment in another article, but today I want to talk about my solution for testing a Point of Care interface where the vendor did not have a test environment.
The POC devices are glucometers that allow the user to pull in patient information from the vendor’s ADT server.
The vendor does not have a test ADT server. When my client implemented, they purged test data before going live.
After verifying with vendor support that they could purge specific patients I opted to prepend facility mnemonics (initials) to both the MRN from PID.3 and the visit number from PID.18 for a specific list of test patients.
The tricky part with this comes when dealing with results for these patients as all that occurs in LIVE!
I say tricky because the MRN and Visit numbers in our test system will be used in our Live system as well.
While Meditech NMI (Non-Meditech Interfaces) Module will fail messages where different identifiers don’t match the Master Patient Index we still don’t want the wrong messages going to LIVE just in case the wrong message passes validation and ends up as part of someone’s record.
Fortunately our Lab Analyst only asked for four test patients, one for each of our facilities.
Here’s the code for the various steps. Explanations are included in comments.
ADT from TEST to Vendor LIVE
# test patient mrns (PID.3) allowed = ["G0000043","F0000006","M0000003","D0000002"] # test patient visit numbers (PID.18) visits = ["IN000026/17","IF0000004/17","IM0000002/17","ID0000001/17"] # text to prepend to identifiers prepend = ["GGH","GM","LM","PD"] #this creates the message object in the custom task hl7msg = util.makeHL7MessageFromXMLDocument(engine.inputDom) mrn = hl7msg.getField('PID',3) vn = hl7msg.getField('PID',18) # check to see if both MRN and Visit are in the filter lists if mrn in allowed and vn in visits: idx = allowed.index(mrn) # the position of facility initials in the prepend array # match that of the facility test pt in allowed hl7msg.setField(prepend[idx] + mrn,"PID",3) # changes the value of the mrn hl7msg.setField(prepend[idx] + vn,"PID",18) # changes the value of the visit else: engine.cancel() #prevents the message from passing to the next component # this creates the outbound object and sends it to the next component. engine.outputDom = util.makeXMLDocumentFromHL7Message('TaskData', hl7msg)<span data-mce-type="bookmark" id="mce_SELREST_start" data-mce-style="overflow:hidden;line-height:0" style="overflow:hidden;line-height:0" ></span>
Vendor Results to Meditech TEST
The first 3 lines are the same so I left them out
# mrns have a set length of 8 chars, visit numbers 12 mrn = hl7msg.getField('PID',3)[-8:] vn = hl7msg.getField('PID',18)[-12:] print vn if mrn in allowed: idx = allowed.index(mrn) # as there is a chance that an MRN in Live might match a visit number in # the list I want to check that the Test Patient MRN matches that # patients visit no. if vn == visits[idx]: hl7msg.setField(mrn,"PID",3) hl7msg.setField(vn,"PID",18) else: engine.cancel() else: engine.cancel() engine.outputDom = util.makeXMLDocumentFromHL7Message('TaskData', hl7msg)