Announcement

Collapse
No announcement yet.

Mirth Connect HL7 to XML, multiple MSH problem

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

  • Mirth Connect HL7 to XML, multiple MSH problem

    I am a beginner of Mirth Connect and recently learning how to use Mirth Connect in our project.

    We have a case that hospital could send multiple MSH in one file. We must transfer to one XML file.

    MSH|^~\&|xxx|PHARM|3M|HL7GATE|20170811100757|1/865308|RDE^O01|20170811100757108;5061618|P|2.2
    PID|||0001195409||James||19530908|M
    PV1|||0417^^007^^575302_100646^^^^Dept1
    ORC|NW|496882750
    RXE|^^^201708110000^201708112359^6^^^^0800|Y000000 12567|||||^10.0mg&P.O|||1|||||||||||||||||||UD
    MSH|^~\&|xxx|PHARM|3M|HL7GATE|20170811100834|3/865309|RDE^O01|20170811100834470;5061621|P|2.2
    PID|||0001195045||Smith||19730211|M
    PV1|||0407^^045^^575303_100724^^^^Dept1
    ORC|NW|496887639
    RXE|^^^201708110000^201708112359^6^^^^0800|Y000000 01531|||||^1.0g&P.O|||2|||||||||||||||||||UD

    We need to transfer the above message into one XML output.
    <MSH>
    xxxxx
    </MSH>
    <MSH>
    xxxxx
    </MSH>

    I tried to use batch in Mirth Connect, however, it seems that Mirth Connect will transfer to 2 different XML outputs.

    Is it possible to realize? If so, how to deal with it?

    Thank you.

  • #2
    Couldn't you process as batch on the source and have it build a single appended file on the outbound destination?

    Comment


    • #3
      Originally posted by mcalKno View Post
      Couldn't you process as batch on the source and have it build a single appended file on the outbound destination?
      Yes, I can use 'append' to make a single XML file. Nevertheless, I also have another channel, same source with webservice destination. Our scenario is Mirth Connect calls webservice only once for multiple MSH message.

      Is it feasible?

      Comment


      • #4
        Can anyone help me?

        Comment


        • #5
          Not sure if I understand your problem.

          If you pass a message with 2 MSH segments, Mirth will parse it as one single message if you disable "batch process" from source controller :

          <HL7Message>
          <MSH> <!-- 1st MSH-->
          ......
          </MSH>
          <EVN>
          ...
          </EVN>
          <PID>
          ...
          </PID>
          and so on

          <MSH><!-- 2nd MSH>
          <EVN>
          ...
          </EVN>
          and so on
          </HL7Message>

          It seems that it's what you are looking for.

          Now if your problem is you cannot handle each message individually while keeping the whole message, you can use getSegmentsAfter() function on each MSH segment and build your own atomic message; code would look like this (I haven't tested it!):

          Code:
          var mshArray = msg['MSH'];
          for each (var msh in mshArray) {
             var singleMsg = <HL7Message/>;
             var segmentArray = getSegmentsAfter(msg, msh, /.*/, true, "MSH"); // here you should get all segments that are part of that MSH segment
             for each (var segment in segmentArray) {
               singleMsg.appendChild(segment);
             }
             // now you should have a atomic message you can handle as you need
          }
          You have to import that function in your code templates, it's available here : http://www.mirthcorp.com/community/f...4608#post24608
          Tom

          Comment


          • #6
            Originally posted by aTom View Post
            Not sure if I understand your problem.

            If you pass a message with 2 MSH segments, Mirth will parse it as one single message if you disable "batch process" from source controller :

            <HL7Message>
            <MSH> <!-- 1st MSH-->
            ......
            </MSH>
            <EVN>
            ...
            </EVN>
            <PID>
            ...
            </PID>
            and so on

            <MSH><!-- 2nd MSH>
            <EVN>
            ...
            </EVN>
            and so on
            </HL7Message>

            It seems that it's what you are looking for.

            Now if your problem is you cannot handle each message individually while keeping the whole message, you can use getSegmentsAfter() function on each MSH segment and build your own atomic message; code would look like this (I haven't tested it!):

            Code:
            var mshArray = msg['MSH'];
            for each (var msh in mshArray) {
               var singleMsg = <HL7Message/>;
               var segmentArray = getSegmentsAfter(msg, msh, /.*/, true, "MSH"); // here you should get all segments that are part of that MSH segment
               for each (var segment in segmentArray) {
                 singleMsg.appendChild(segment);
               }
               // now you should have a atomic message you can handle as you need
            }
            You have to import that function in your code templates, it's available here : http://www.mirthcorp.com/community/f...4608#post24608
            Thank you so much for the suggestion.

            I will check whether it is suitable for us.

            Comment

            Working...
            X