Announcement

Collapse
No announcement yet.

Carriage Return within Fields

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

  • Carriage Return within Fields

    Hello all,

    We have a system that occasional sends messages into Mirth Connect with a Carriage Return character actually within a field in the OBX so Connect sees this as a segment seperator.

    For example (and I've removed the PID) we get:

    Code:
    MSH|^~\&|PCS|SCM|HL7PRX||20130215202522||ORM^O01|1002158226110001|D|2.3
    ORC|NW|001GRYKHP^PCS|||IP||^^^20130215202400^^Routine||20130215202522|malawson^Lawson^Maureen||MMXL^Lawson^Maureen
    RXO|Pharm1456^Outpatient prescription^Local_Pharm||||||||||||0
    RXR|OTH
    OBX|1|TX|PharmChanges^Summary Information^PCS||Modigraf --> 2mg BD
    2- Mycophenolate Mofetil suspension --> 45mg BD
    3- Magnesium Glycerrophosphate --> 5mmol BD (not prescribed by GP because it is unlicensed)||||||F
    Has anyone got any suggestions as to how to deal with this in Mirth Connect (as we cannot correct it at source)? Would it be something in the preprocessor maybe?

  • #2
    I think I may have answered my own question.
    How about this for a solution?

    In the preprocessor script, put the following:

    Code:
    var newmessage = message;
    
    while (newmessage.match(/(\r\n|\r|\n)([^A-Z]|[A-Z][^A-Z]|[A-Z]{2}[^A-Z\d]|[A-Z]{2}[\d][^|]|[A-Z]{3}[^|])/i)) {
    	var extrabit = newmessage.match(/(\r\n|\r|\n)([^A-Z]|[A-Z][^A-Z]|[A-Z]{2}[^A-Z\d]|[A-Z]{2}[\d][^|]|[A-Z]{3}[^|])/i)[0].substring(1);
    	var newmessage = newmessage.replace(/(\r\n|\r|\n)([^A-Z]|[A-Z][^A-Z]|[A-Z]{2}[^A-Z\d]|[A-Z]{2}[\d][^|]|[A-Z]{3}[^|])/i,'\\.br\\' + extrabit);
    }
    
    return newmessage;
    Simon
    Last edited by seaston; 02-16-2013, 01:42 AM.

    Comment


    • #3
      Thanks!

      FYI, I changed the first line to remove trailing carriage return/line feeds to prevent the last line from being converted.

      var newmessage = message.replace(/[\n\r]$/,"");

      Comment

      Working...
      X