Announcement

Collapse
No announcement yet.

Replacing a sequence of hex characters in preprocessor

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

  • Replacing a sequence of hex characters in preprocessor

    Hi All;

    I'm working with a kludgy delimited file and am having fits getting it parsed out properly.

    Here's a snippet

    Code:
    {
    "unitNumber": "H153734",
    "accountNumber": "MA000715/11",
    "name": "O'DWARF,ONE 00/100",
    "filed by": "NUCAMC",
    "filed by name": "CAMERON,CHRISTINE",
    "OCANC.|8|": "20121001",
    "OCANC11|20|": "Sandra James",
    "OCANC25|15|": "8422182918",
    "OCANC17|2|": "ON",
    "OCANC127|1|": "Y",
    "OCANC163|1|": "Y",
    }
    Looks like json doesn't it?

    When I receive the file the actual delimiting sequence between fields is \x2C\x0D\x0A or ,\r\n

    My issue is that Mirth will break on commas, even in a string that's wrapped with quotes.

    My thinking is that this is because its in a second set of quotes on each line.

    Has anyone encountered this issue before or have any suggestions as to how to solve it?

    Thanks
    I can be reached through gmail and Google Talk using davidrothbauer at gmail dot com
    http://www.linkedin.com/pub/david-rothbauer/5/923/518
    codeismydrug.wordpress.com
    hl7coders.wordpress.com

    Test all my code suggestions prior to implementation

  • #2
    Funny how immediately after I post I stumble across the solution.

    I put this in my pre-processor

    Code:
    var pattern = RegExp(",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)","g");
    
    
    
    message = message.replace(pattern,'~');
    Then I use ~ as a column delimiter.

    Seems to work great!
    I can be reached through gmail and Google Talk using davidrothbauer at gmail dot com
    http://www.linkedin.com/pub/david-rothbauer/5/923/518
    codeismydrug.wordpress.com
    hl7coders.wordpress.com

    Test all my code suggestions prior to implementation

    Comment


    • #3
      Just as an aside for anyone else who comes across this, here's another example of how to use Delimited Text to parse JSON: http://www.mirthcorp.com/community/f...23&postcount=6

      Also, there's an open issue for adding JSON as a data type as well, so hopefully we'll be able to add that in the near future: MIRTH-2276
      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

      Working...
      X