web stats
Skip to end of metadata
Go to start of metadata

This example will show how to configure a channel to read data from a database, form an HL7 v2.x message using the data, and send it over an LLP connection.
This example will demonstrate:

  • Using the Database Reader
  • Generating an HL7 v2.x message from a template


Step 1: Create a new channel.


Step 2: Set to Source connector type to Database Reader and enter the connection information. In this example, the connector is set to poll the database every 5 seconds and execute the specified SELECT query. Columns entered in the FROM clause are automatically added as available variables. Note that the On-Update SQL statement that is executed immediately after the query can make use of variables returned from the initial query.


Step 3: Edit the transformer for the Source connector and click on the Message Templates tab to paste in an example Outbound Message Template, making sure to set the Data Type to HL7 v2.x. This template will be used as the base for new outbound HL7 messages generated by the channel.
The Inbound Message Template is an example of what an inbound message resulting from the database query will look like. This shows how the XML has been generated using the columns selected.


Step 4: Click on the Message Trees tab to view the trees for both the Inbound and Outbound message templates.


Step 5: In order to map data from the database to the message template, click on a node in the Inbound tree and drag-and-drop it over the node in the Outbound tree which should be replaced. This example shows replacing the "PID.5.1 (Family Name)" field in the message template with the "last_name" variable from the database. The auto-generated name of the transformer step reflects this mapping.


Step 6: Add a new destination connector of type LLP Sender. The Template is the data that will be sent over the LLP connection to the host address and by default is set to the Encoded Data, which in this example is an HL7 v2.x message.


  • No labels

6 Comments

  1. I am asuming I'll have to insert a JavaScript statement or something to modify the outbound template.  For example I am getting  just changes from inbound to outbound right now .

      The "if" statements I need to create would either exclude or include certain segments of the outbound file. Is that the best way to go about building the destination file?  In other words the destination file can be pretty dynamic depending on loop variables.  so one segment might need to be included...and I guess while writing the code i would need to "use segment x"  "Exclude segment y"  from template. Am I on the right track here? 

  2. The picture for step 3 should probably be changed; it shows a full HL7 message (with fields/components populated) being put into the outbound template. This can definitely be misleading because outbound templates generally should only be message "skeletons", perhaps with only a few hard-coded values that shouldn't change from message to message. Following this example, everything in the outbound message (except for PID.5.1, PID.5.2, PID.7.1, PID.8.1, and PID.13.1) would be copied over to the encoded data verbatim. That's probably not the intended behaviour, especially when PHI is involved.

  3. I have stored multiple DG1 segement into one mysql table.

    Actually I have three tables. 

    1 for PID Segement (PID_Data).

    2 for PV1 Segemnt (PV1_Data).

    3 for DG1 Segment (DG1_Data).

    Now I want to generate BAR P01 Message, It will contains MSH,EVN,PID,PV1,{DG1} segments.

    What will I have to do in source part and transformer part.

    How to get multiple DG1 segment field values using select query for particular visit and map into transformer.

     

    pls help me..... any thing you can do.......

     

     

     

     

     

    1. Any solution to this?  I see a lot of posts about something I'm struggling with but never any solution replies.....

  4. Hi all,

    I am facing the same problem...... Can any one tell me how to handle loops and optional segments based on dynamic conditions

     

    thanks in advance

  5. Hi,

     

    Iam trying to generate hl7 messages (database reader as source connector)

    when i deploy, im getting an error that has

     

    [2016-04-15 17:05:29,051] ERROR (com.mirth.connect.server.util.javascript.JavaScriptUtil:502): Error executing defac383-4939-4fc5-9b82-9c91a7a86752_Deploy script from channel: defac383-4939-4fc5-9b82-9c91a7a86752
    com.mirth.connect.server.MirthJavascriptTransformerException: CHANNEL:
    verify connSOURCE CODE:
    41: }42: }43: function doScript() {44: // This script executes once when the channel is deployed45: // You only have access to the globalMap and globalChannelMap here to persist data46: SerializerFactory.getSerializer('HL7V2').fromXML(message);47: return; 48: }LINE NUMBER:
    46DETAILS:
    ReferenceError: "message" is not defined.
    at defac383-4939-4fc5-9b82-9c91a7a86752_Deploy:46 (doScript)
    at defac383-4939-4fc5-9b82-9c91a7a86752_Deploy:49
    at com.mirth.connect.server.util.javascript.JavaScriptUtil.executeScript(JavaScriptUtil.java:527)
    at com.mirth.connect.server.util.javascript.JavaScriptUtil$2.call(JavaScriptUtil.java:359)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

     

    Could somebody help me on this. I am actually blocked and also dont know if the section "Scripts" should have some code...