regsub for x0d0a

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf regsub for x0d0a

  • Creator
    Topic
  • #49327
    Mark Perschbacher
    Participant

      I am writing an xlate for an ORU, and from one of our vendors we are getting xodoa at the beginning of each new line in a single NTE segment.  I have never dealt with this before, but it looks like this is not that uncommon.  What I would like to do is break each of these into a separate NTE, and was trying to do it with a regsub.

      regsub -all {X0D0A} $segment NTE| segment.

      I have this set as a pre-proc with a COPY command for the NTE’s, but in testing I am getting a

      0:TEST] Unable to load XLT ‘ChCon_test.xlt’: EOF in list element

      Any suggestions?

    Viewing 12 reply threads
    • Author
      Replies
      • #61525
        Gary Atkinson
        Participant

          Try this:

          Code:

          regsub -all {[rn]+} $x { } x

        • #61526
          Mark Perschbacher
          Participant

            Gary, so to use this, I am assuming that I need to set the variable x to some value, which would be the x0d0a?

          • #61527
            Gary Atkinson
            Participant

              Replace $x with $xlateInVals and x with xlateOutVals.  I made up a dumby string and tested it in activetcl; seems to works.  I haven’t used regular expression with regsub before, so I’m sort of guessing here   😉

            • #61528
              Mark Perschbacher
              Participant

                Gary, using that string I get no change.  I am begining to think that what I need to do is write an iterate for the NTE that includes in IF statement looking for the x0d0a.   Here is the NTE string that I am running through test for the expression.

                NTE|1||Low Risk:    <1.0X0D0AAverage Risk: 1.0 to 3.0X0D0AHigh Risk:   >3.0X0D0ARelative risk categories follow the recommendations of the American

              • #61529
                Gary Atkinson
                Participant

                  Umm thought it would work.  Are you using pathcopy in your iterate?  Try using regsub on one componet like a dash or () ands see if you can replace with a zero.  Sorry I’m a tcl noobie.  ðŸ˜³

                • #61530
                  Michael Hertel
                  Participant

                    Mark,

                    Are you referring to the actual characters X0D0A or are you

                    referring to carrage returns and line feeds?

                    You can use:

                    set segment [string map {X0D0A NTE|} $segment]

                    But I don’t think this is really what you want to do especially while inside an Xlate as the message is already parsed at that point.

                    -mh

                  • #61531
                    Chris Williams
                    Participant

                      You have a literal string of seven characters: X0D0A. This follows the HL7 standard for escaping characters (see HL7 2.7.1). It is telling you that the source system encoded a crlf pair before sending so it could pass through the engine without being acted upon, and that the destination system should decode this into an actual carriage-return and line-feed.

                      The HL7 message’s escape character (often the “”) is used to bracket the item to be escaped, unlike in other contexts where a single character to be escaped is usually preceeded by a single “”. E.g., if the caret is the component separator and you need a literal caret in the text, you represent it with the three-character string S. It’s up to the receiving system to decode it.

                      Chris

                    • #61532
                      Mark Perschbacher
                      Participant

                        The system I am passing these messages is not interpreting the x0d0a unfortunately.  Thinking that what I need to do is write an iterate that will look for this string, and create a new NTE with the data following it the string.  Sounds like  writing a proc would be the easiest way to do this.

                      • #61533
                        Michael Hertel
                        Participant

                          Some systems are capable of using ~ as linefeeds.

                          Have you tried that?

                          set segment [string map {X0D0A ~} $segment]

                          This is used in OBX’s a lot.

                          Then you should get:

                          NTE|1||Low Risk:    <1.0~Average Risk: 1.0 to 3.0~High Risk:   >3.0~Relative risk categories follow the recommendations of the American

                          You may need to use double escapes, i.e. set segment [string map {\X0D0A\ ~} $segment]

                        • #61534
                          John Mercogliano
                          Participant

                            Mark,

                               If I understand you correctly, the source system sends one NTE segment with the X0D0A escape sequence to indicate a new line in the document and  the receiving systems wants to receive an NTE segment for each line.  If that is the case you will want to use a tps before the translation. I tested a similiar  message using these commands.  This assumes that only the NTE segment will have X0D0A.  This should do the trick for you.

                            set msg [msgget $mh]

                            set msg [string map {\X0D0A\ rNTE|} $msg]

                            msgset $mh $msg

                            John Mercogliano
                            Sentara Healthcare
                            Hampton Roads, VA

                          • #61535
                            Chris Williams
                            Participant

                              If you take Michael’s suggestion of substituting “~” characters (assuming that is your repetition separator) you can then easily iterate through the repetitions and write out an individual NTE segment for each rep. Don’t forget you will need to increment the Set ID (NTE-1) in each output segment.

                              Chris

                            • #61536
                              Mark Perschbacher
                              Participant

                                I think I’ll try the iterate method.   I have substituted a ~ for the xodoa string.    So would I iterate on the group?

                              • #61537
                                Chris Williams
                                Participant

                                  If you have the message coming into the xlate with the tildes in place (using John’s suggestion above for modifying the message), then you would want to iterate on the field so it would look something like: …NTE.#3(%f1)  

                                  The path specifics depend on how your variant is set up. You may have multiple iterations going on. In one lab system I work with it looks like this: 1(%g1).0(0).NTE(%s2).#3(%f2)

                                  Chris

                              Viewing 12 reply threads
                              • The forum ‘Cloverleaf’ is closed to new topics and replies.