In this tutorial, i am going to explain how to create an HL7 message by reading data values from database using Database Reader. I have used a simple table to demonstrate the worflow . Add more queries based on your requirements.
I am going to use the following database schema and data values in this tutorial
Choose any Channel Name as you wish. Set the Datatypes here or you can do it inside transformer. Store the messages or prune it after specified period of time as you wish.
In the Sorce Connector, select Connector Type as Database Reader. Provide the Driver info and insert the URL template. Modify the URL template configuring the host, port and Database name. Provide the Database credentials and choose the polling ype.
Interval: Polls the database repeatedly after the specified polling frequency.
Time: Polls the database at the specified time.
Write your custom code in the transformer. I have written the following code to create a simple HL7 messsage with single OBR Segment. You can create any number of Segments as per your requirements. Since your output to the desitnation is an HL7 message choose your Outbound Message Template Datatype to HL7 v2.x.
//Adding data to MSH Fields
//Adding data to PID Fields
//Adding data to ORC and OBR Fields
I have mapped the pid in order to create a HL7 message with pid as a file name in destination. The code highlighted in red is the data values retrieved from database and other values are hard coded for simplicity. You can retrieve data from database and replace the hardcoded values.
Choose the Destination Connector Type as per your requirements. Here i have used File Writer in order to write the HL7 message. Choose Test Write to validate the existance of directory being selected. Choose any File Name as you wish. I have used the pid(patient id) as the file name. The file will be saved with an extension(.hl7). Enable Append to File if you wish to create a batch file and choose File Type as ASCII, if you like to store the data values as ASCII characters. In the Template choose Encoded data.