Thank you guys… For now I have settled to use Mirth Connect as a Middleware. The other EMR accepts HL7 v 2.4 message via MLLP. I created 4 channels. Channel 1 polls the postgresql databases if there are newly registered clients using DHIS 2. It then converts the XML message to HL 7 v2.4 ADT04 message and pass the it to the EMR via TCP MLLP. Channel 2 listens for client registration responses from the EMR. The responses have the Account /Patient Number that I need to store in DHIS 2 for subsequent calls. Channels 3 polls DHIS 2 postgresql database for any new lab orders. Basically when the client clicks complete on the lab order program stage, the order is ready to be sent to the EMR. The channel transforms the xml into HL 7 OBR message and sent it to the EMR. Channel 4… Listens for the lab results. Converts the HL 7 and pass the data to DHIS 2. So far it working fine.
I have come up with an additional table that holds the interested transactions. When the user clicks the new button to add the lab order stage, a trigger creates a record with the demographic data into the table. As the user captures the lab order, another trigger will be populating data into the transactions table. When the user clicks the click button, the record status changes. Mirth will be polling that table to see if it can pick the data and send it to the EMR.