Announcement

Collapse

NextGen (Mirth) Connect 3.11.0 Released!

NextGen (Mirth) Connect 3.11.0 is now available as an appliance update and on our GitHub page. This release contains improvements to licensing and the NCPDP data type. It also includes various security fixes, general bug fixes, and improvements to commercial extensions. See the release notes for the complete list of fixes and improvements.

Download | See What's New | Upgrade Guide | Release Notes

For discussion on this release, see this thread.
See more
See less

Replacing characters in the OBX segments

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

  • Replacing characters in the OBX segments

    I have this code to replace the values below when they are in the OBX segment. I am seeing the error below.

    Starting data - OBX|7|NUM|R1000605^Neutrophils# Auto||5.4|x10^3/mcL^x10^3/mcL||NA||? Unknown|F|||20210324134626|||^^^INKC H XE
    Expected data result - OBX|7|NUM|R1000605^Neutrophils# Auto||5.4|x10E3/mcL^x10E3/mcL||NA||? Unknown|F|||20210324134626|||^^^INKC H XE

    Starting data - OBX|7|NUM|R1000605^Neutrophils# Auto||5.4|x10^6/mcL^x10^6/mcL||NA||? Unknown|F|||20210324134626|||^^^INKC H XE
    Expected data result - OBX|7|NUM|R1000605^Neutrophils# Auto||5.4|x10E6/mcL^x10E6/mcL||NA||? Unknown|F|||20210324134626|||^^^INKC H XE

    tmp.replace('^x10^3', '^x10E3');
    tmp.replace('x10^6', 'x10E6');

    SOURCE CODE:
    4584:
    4585: tmp['MSH']['MSH.5']['MSH.5.1'] = 'IHIE';
    4586:
    4587: tmp.replace('^x10^3', '^x10E3');
    4588: tmp.replace('x10^6', 'x10E6');
    4589: if ('xml' === typeof msg) {
    4590: if (msg.hasSimpleContent()) {
    4591: msg = msg.toXMLString();
    4592: }
    4593: } else if ('undefined' !== typeof msg && msg !== null) {
    LINE NUMBER: 4589
    DETAILS: TypeError: INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified.



  • #2
    tmp is an xml objects, not a string, and the replace method works differently to do xml node replacement rather than string replacement.

    Comment


    • #3
      You could use string methods in an attachment script, where the message is a string. Manipulating the message once it is parsed into an xml object is different - especially when the character you want to replace is a separator (^ = component separator).
      In your OBX.6 field you have 4 components: OBX.6.1=x10, OBX.6.2=3/mcL, OBX.6.3=x10, OBX.6.4=3/mcL
      I can only offer you a very very nasty hack:
      Code:
      for each (var seg in msg.children()) {[INDENT]if (seg.name().toString() == "OBX") {[/INDENT][INDENT=2]if(seg["OBX.6"]["OBX.6.1"].toString()=="x10") {[/INDENT][INDENT=3]var obx6=new XML("<OBX.6><OBX.6.1>" + seg["OBX.6"]["OBX.6.1"].toString() + "E" + seg["OBX.6"]["OBX.6.2"].toString() + "</OBX.6.1><OBX.6.2>" + seg["OBX.6"]["OBX.6.3"].toString() + "E" + seg["OBX.6"]["OBX.6.4"].toString() + "</OBX.6.2></OBX.6>");[/INDENT][INDENT=3]seg["OBX.6"]=obx6.copy();[/INDENT][INDENT=2]}[/INDENT][INDENT]}[/INDENT]
       }
      This makes a new OBX.6 if OBX.6.1="x10"

      Comment


      • #4
        I hadn't noticed that the component separator was part of the replacement string. schillert is correct that it makes the problem even more difficult in a transformer. String replacement is probably the way to go. I think the most appropriate place to do this would be in the pre-processor script. Should be a simple 1-liner:
        Code:
        return message.replace(/x10\^(\d)/g, 'x10E$1');

        Comment


        • #5
          What are my options to do this in a transformer since I have multiple destinations on this thread?

          Comment


          • #6
            Originally posted by math1964 View Post
            What are my options to do this in a transformer since I have multiple destinations on this thread?
            Once it is fixed, it is fixed, what do you mean?
            Diridium Technologies, Inc.
            https://diridium.com

            Comment


            • #7
              I made this change message=message.replace(/x10\^(\d)/g, 'x10E$1');
              return message; in the preprocessor

              Here is the result =OBX|1|NUM|R1000810^WBC||5.50|x10(3)/mcL^x10E3/mcL

              What change is needed to get to this, OBX|1|NUM|R1000810^WBC||5.50|x10E3/mcL^x10E3/mcL?

              Comment


              • #8
                Using
                Code:
                return message.replace(/x10\^(\d)/g, 'x10E$1')
                against (constructing from the sample OBX in your original post)
                Code:
                OBX|1|NUM|R1000810^WBC||5.50|x10^3/mcL^x10^3/mcL||NA||? Unknown|F|||20210324134626|||^^^INKC H XE
                translates to
                Code:
                OBX|1|NUM|R1000810^WBC||5.50|x10E3/mcL^x10E3/mcL||NA||? Unknown|F|||20210324134626|||^^^INKC H XE
                which appears to be what you're looking for.
                Last edited by jkrebs; Today, 08:55 AM.

                Comment


                • #9
                  Jkrebs,

                  That is what I am looking for. I made your change. See result below.

                  OBX|1|NUM|R1000810^WBC||5.50|x10(3)/mcL^x10E3/mcL|3.60-11.10^3.60^11.10|||? Unknown|F|||20200427205200|||^^^INLH WAM GEN LAB SS\.br\

                  Comment


                  • #10
                    Must be something about the source message b/c when I copy the OBX from your original post, it seems to work. Can you upload the specific source message you ran to get that result?

                    Comment


                    • #11
                      OBX|1|NUM|R1000810^WBC||5.50|x10(3)/mcL^x10^3/mcL|3.60-11.10^3.60^11.10|||? Unknown|F|||20200427205200|||^^^INLH WAM GEN LAB SS\.br\

                      Comment


                      • #12
                        MSH|^~\&|CERNER_LAB|INLH|ENGINE|INLH|2020042720525 7||ORU^R01|Q1850385777T2042950536|T|2.3||||||8859/1 PID|1|148682^^^LHN_MRN^MRN|148682^^^LHN_MRN^Accoun t Number~40616755^^^CHS_CMRN^Community Medical Record Number~148682^^^LHN_MRN^MRN~40616754^^^CHS_CMRN^Co mmunity Medical Record Number|148682^^^LHN_MRN^Account Number~148844^^^LHN_MRN^Account Number|ZZTEST^NATALIE^^^^^Current||19880103|F||W|1 4719 DEERBERRY CT^^FORT WAYNE^IN^468149053^USA^Home^^Allen|Allen|||E|M|N|4 000070741^^^INLH_FIN^FIN NBR|326513265|||N|||0|||N PD1|||^^0|748^KING^MARK^A^^D0^^^LHN_ORG_DOC^Person nel^^^ORGANIZATION DOCTOR|||N PV1|1|I|INLH CIC^553^01^IN Lutheran Hospital^^Bed(s)^IN Lutheran Hospital|3||||||MIP||||6||||I||H|||||||||||||||||| |IN Lutheran Hospital||Active|||20191202165800||||||1171856 OBR|1|4093758715^HNAM_ORDERID||Complete Blood Count w/Diff Manual MW^CBCWDMMW|||20200427204800|||001525138443232000^ Meihls^Tracy^^^Lab Infor Systems Coord^^^VitalsLink Badge ID^Personnel^^^Personnel Badge ID||||20200427204800|Blood&Blood^^^^^Venous Draw Chg|||||007002020118000007^HNA_ACCN~30571401^HNA_A CCNID||20200427205202||General Lab|F||1^^^20200427204800^^RT~^^^^^RT - Routine|||||||||20200427204800 OBX|1|NUM|R1000810^WBC||5.50|x10(3)/mcL^x10^3/mcL|3.60-11.10^3.60^11.10|||? Unknown|F|||20200427205200|||^^^INLH WAM GEN LAB SS\.br\ OBX|2|NUM|R1000808^RBC||4.00|x10(6)/mcL^x10^6/mcL|3.69-4.88^3.69^4.88|||? Unknown|F|||20200427205200|||^^^INLH WAM GEN LAB SS\.br\ OBX|3|NUM|R1000802^Hgb||14.0|g/dL^g/dL|12.0-15.0^12.0^15.0|||? Unknown|F|||20200427205200|||^^^INLH WAM GEN LAB SS\.br\ OBX|4|NUM|R1000801^HCT||42.0|%^%|33.3-41.1^33.3^41.1|HI||? Unknown|F|||20200427205200|||^^^INLH WAM GEN LAB SS\.br\ OBX|5|NUM|R1000805^MCV||88.0|fL^fL|79.3-94.8^79.3^94.8|||? Unknown|F|||20200427205200|||^^^INLH WAM GEN LAB SS\.br\ OBX|6|NUM|R1000803^MCH||35.0|pg^pg|26.8-33.2^26.8^33.2|HI||? Unknown|F|||20200427205200|||^^^INLH WAM GEN LAB SS\.br\ OBX|7|NUM|R1000804^MCHC||33.0|g/dL^g/dL|33.5-37.0^33.5^37.0|LOW||? Unknown|F|||20200427205200|||^^^INLH WAM GEN LAB SS\.br\ OBX|8|NUM|R1000811^Plt Cnt||250|x10(3)/mcL^x10^3/mcL|140-450^140^450|||? Unknown|F|||20200427205200|||^^^INLH WAM GEN LAB SS\.br\ OBX|9|NUM|R1000806^MPV||10.0|fL^fL|9.4-11.9^9.4^11.9|||? Unknown|F|||20200427205200|||^^^INLH WAM GEN LAB SS\.br\ OBX|10|NUM|R1000722^Neutrophils Man||55|%^%||NA||? Unknown|F|||20200427205200|||^^^INLH WAM GEN LAB SS\.br\ OBX|11|NUM|R1000724^Lymphocytes Man||30|%^%||NA||? Unknown|F|||20200427205200|||^^^INLH WAM GEN LAB SS\.br\ OBX|12|NUM|R1000726^Monocytes Man||15|%^%||NA||? Unknown|F|||20200427205200|||^^^INLH WAM GEN LAB SS\.br\ OBX|13|NUM|R1000738^Neutrophils Absolute Man||3.02|x10(3)/mcL^x10^3/mcL||NA||? Unknown|F|||20200427205200|||^^^INLH WAM GEN LAB SS\.br\ OBX|14|NUM|R1000739^Lymphocytes Absolute Man||1.65|x10(3)/mcL^x10^3/mcL||NA||? Unknown|F|||20200427205200|||^^^INLH WAM GEN LAB SS\.br\ OBX|15|NUM|R1000729^Monocytes Absolute Man||0.82|x10(3)/mcL^x10^3/mcL||NA||? Unknown|F|||20200427205200|||^^^INLH WAM GEN LAB SS\.br\ OBX|16|NUM|R1012890^RDW CV||15.0|%^%|12.0-15.1^12.0^15.1|||? Unknown|F|||20200427205200|||^^^INLH WAM GEN LAB SS\.br\

                        Comment


                        • #13
                          math1964 I think jkrebs means upload the message as an attachment. This way we see the EXACT message as it in Mirth rather than this forum messing it up.

                          Also, use https://regex101 to sort the regex phrasing if you are not doing that already, see screenshot.

                          forM.png
                          Last edited by pacmano; Today, 11:53 AM.
                          Diridium Technologies, Inc.
                          https://diridium.com

                          Comment


                          • #14
                            Thanks pacmano!

                            math1964 copy/paste can produce erroneous data. I stripped the message clean and added appropriate segment delimiters but that's not to say it's the exact message you're testing.

                            It contained parenthesis that aren't in the OBXs from your original post. The below worked but I didn't check the whole message and I'd suggest working on a better regex.
                            Code:
                            return message.replace(/x10\W/g, 'x10E').replace(/\)\//g,'\/')
                            It produced the below result. Hope this helps!
                            Code:
                            OBX|1|NUM|R1000810^WBC||5.50|x10E3/mcL^x10E3/mcL|3.60-11.10^3.60^11.10|||? Unknown|F|||20200427205200|||^^^INLH WAM GEN LAB SS
                            Last edited by jkrebs; Today, 01:13 PM.

                            Comment

                            Working...
                            X