Announcement

Collapse
No announcement yet.

Create multiple HL7 messages out of raw data through JavaScript

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Create multiple HL7 messages out of raw data through JavaScript

    I am trying to create multiple HL7 messages (ORU, RDE and so on....) out of raw data retrieved from a database through JS reader but I don't how to create a new HL7 message in Javascript (not through template). Does anyone know how can I build multiple HL7 messages from scratch in Javascript?

    I found this post :http://stackoverflow.com/questions/2...age-with-mirth

    It shows how to create new HL7 segments but how do I get the "msg" variable where segements are added using "createSegment"?

  • #2
    That's easy. In the JavaScript Reader, you can just declare msg as a new variable:

    Code:
    var msg = <HL7Message/>;
    Then create segments as needed:

    Code:
    createSegment('MSH', msg);
    msg.MSH['MSH.1'] = '|';
    msg.MSH['MSH.2'] = '^~\\&';
    msg.MSH['MSH.3']['MSH.3.1'] = 'Sending Application';
    msg.MSH['MSH.4']['MSH.4.1'] = 'Sending Facility';
    // etc...
    Then at the end serialize it to ER7:

    Code:
    var message = SerializerFactory.getSerializer('HL7V2').fromXML(msg);
    And dispatch it to the channel:

    Code:
    return message;
    You can dispatch multiple messages if you want:

    Code:
    var messages = new java.util.ArrayList();
    messages.add(message1);
    messages.add(message2);
    return messages;
    Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

    Nicholas Rupley
    Work: 949-237-6069
    Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


    - How do I foo?
    - You just bar.

    Comment


    • #3
      Thank you for such quick reply. I'll try the specified code.
      Also, one more thing. I wanted to build the messages in transformer, while returning the raw data from JS reader. How will the transformer receive the raw data. Shall I change the response to "Auto generated (after source transformer)" and "return messages" in transformer script?
      Last edited by arpitgoel; 05-04-2015, 10:17 AM. Reason: typo

      Comment


      • #4
        Originally posted by arpitgoel View Post
        Thank you for such quick reply. I'll try the specified code.
        Also, one more thing. I wanted to build the messages in transformer, while returning the raw data from JS reader. How will the transformer receive the raw data. Shall I change the response to "Auto generated (after source transformer)"? and "return messages" in transformer script?
        That... doesn't make any sense. I think you're using different terms in incorrect ways, so I don't really know what you're trying to do from those sentences.

        If you return an ER7 HL7 v2.x message from the JavaScript Reader, and your inbound data type is HL7 v2.x, then in a transformer it will automatically serialize that message into XML for you.

        The response you select on the source connector is completely different, and typically only applies when you're actually sending a response to an originating system, like a connecting client to a TCP Listener. It could also apply when dispatching via a Channel Writer from some other channel.
        Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

        Nicholas Rupley
        Work: 949-237-6069
        Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


        - How do I foo?
        - You just bar.

        Comment


        • #5
          It seems I got things jumbled up.
          I meant to say that I want my JS reader to only retrieve data from the database and use the source transformer for creating HL7 messages from the raw data. Is that plausible in this scenario?

          Comment


          • #6
            Originally posted by arpitgoel View Post
            It seem I got things jumbled up.
            I meant to say that I want my JS reader to only retrieve data from the database and source transformer for creating HL7 messages from the raw data. Is that plausible in my situation?
            In that case, you should use a Database Reader source connector instead. Then your source transformer would do the job of converting the result set XML to HL7 v2.x.
            Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

            Nicholas Rupley
            Work: 949-237-6069
            Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


            - How do I foo?
            - You just bar.

            Comment


            • #7
              I'll stick to JS reader for transforming data as I find using javascript easier.
              Thanks for your help

              Comment


              • #8
                Helpful

                Wow! Three years down the line, this post is still as helpful. Thanks, guys!

                Comment


                • #9
                  hi friend

                  Comment

                  Working...
                  X