Announcement

Collapse
No announcement yet.

Splitting on the carriage return "\r"

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

  • Splitting on the carriage return "\r"

    Mirth doesn't seem to like the fact that I am splitting based on a carriage return.

    Here is an example OBX (where the splitting should occur):

    OBX|1|FT|Radiology Report^Radiology Rpt||***FINAL REPORT***

    Portable crosstable lateral x-rays of the lumbar spine

    HISTORY: Intraoperative views

    COMPARISON: None

    FINDINGS: The images show placement of bilateral pedicle screws
    with interlocking bars in the lowest lumbar vertebrae and upper
    sacrum. There is mild anterolisthesis of the lowest lumbar

    Converting this into a document type with the following code:

    var obxText = msg['OBX']['OBX.5']['OBX.5.1'].toString().split("\r");
    for (i=0; i < obxtext.length; i++) {
    var obxseg = <OBX/>;
    obxseg['OBX.1']['OBX.1.1'] = (cOBX+1);
    obxseg['OBX.2']['OBX.2.1'] = "TX";
    obxseg['OBX.3']['OBX.3.1'] = testCode;
    obxseg['OBX.3']['OBX.3.2'] = test;
    obxseg['OBX.5']['OBX.5.1'] = obxText[i];
    obsseg['OBX.11']['OBX.11.1'] = res;
    obsseg['OBX.14']['OBX.14.1'] = msgTime;
    tmp.appendChild(obxseg); cOBX++;
    }

    As mentioned Mirth doesn't seem to split on the carriage return. Is there an easy way around this or will I have to dive into an OBX wrapper object code template?

  • #2
    I believe it is a newline carriage return

    var obxText = msg['OBX']['OBX.5']['OBX.5.1'].toString().split("\n\r");

    Comment


    • #3
      Thanks Cory! I was thinking the same, but haven't had any luck with that option as well. In other words, is there anyway I can have Mirth recognize the invisible carriage return or maybe .trim at these points instead?

      Comment


      • #4
        I ran some tests and looked at the transformed message. The issue that you are having is that Mirth converts the message into an xml to parse. It is reading the carriage returns as new segments. There for there technically is no carriage return at the transformer step. You will have to make your adjustments at the preprocessor script before it is converted. At this point is will be just a normal string and the msg['OBX'] notation will not work.

        Comment


        • #5
          Thanks again Cory! Here is what I did to work around this issue after noticing that the incoming message actually comes in with the \r carriage return after every segment except the obx segment which comes in with the \n carriage return.

          Turned off the convert lf to cr data setting for both the inbound and outbound connectors on the summary tab.

          Set the preprocessor to: return message.split("\n");

          At this point the OBX group was joined with a , as a separator. Then I had to split based on this new character:
          var obxText = msg['OBX']['OBX.5']['OBX.5.1'].toString().split(",");
          for (i=0; i < obxText.length; i++) {
          var obxseg = <OBX/>;
          obxseg['OBX.1']['OBX.1.1'] = (cOBX+1);
          obxseg['OBX.2']['OBX.2.1'] = "TX";
          obxseg['OBX.3']['OBX.3.1'] = testCode;
          obxseg['OBX.3']['OBX.3.2'] = test;
          obxseg['OBX.5']['OBX.5.1'] = obxText[i];
          obxseg['OBX.11']['OBX.11.1'] = res;
          obxseg['OBX.14']['OBX.14.1'] = msgTime;
          tmp.appendChild(obxseg); cOBX++;
          }

          Luckily, I haven't seen this client sending any punctuation in the obx.5.1 field besides sometimes when they use the date ex. April 10, 2012. This should be okay, but if I have a chance I will update this thread with the better solution.

          Comment


          • #6
            FYI - Here is how I fixed this issue. It still seems a little silly to me, but it works!

            Inserted the preprocessor:
            return message.replace(/\n/g,"MAKETHISWORK");

            Then utilized this for the segment for which originally had the new line feed character \n
            obxseg['OBX.5']['OBX.5.1'] = msg['OBX']['OBX.5']['OBX.5.1'].toString().replace(/MAKETHISWORK/g,"~");

            Comment


            • #7
              Originally posted by eslingerc View Post
              FYI - Here is how I fixed this issue. It still seems a little silly to me, but it works!

              Inserted the preprocessor:
              return message.replace(/\n/g,"MAKETHISWORK");

              Then utilized this for the segment for which originally had the new line feed character \n
              obxseg['OBX.5']['OBX.5.1'] = msg['OBX']['OBX.5']['OBX.5.1'].toString().replace(/MAKETHISWORK/g,"~");
              Hi eslingerc, I know it's been 2 years from your last post in this threads, but I'm having a similar issue. I am trying to insert a radiology report from mssql to OBX segments. But I end up with hl7 messages with a single OBX segment with the whole report. I need multiple OBX segments. Can you please explain how did you resolve this problem?

              Thanks!

              Comment

              Working...
              X