Get rid of double space

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Get rid of double space

  • Creator
    Topic
  • #53697
    Aaron Oxenreider
    Participant

      I get a lot of great help, just by reading through the post here, but I’m stumped.

      I have the following OBX segments: (small group of about 20/message)

      OBX|11|TX|71020|| ||||||F|||20130530153358||nmiller^^^^^^52

      OBX|12|TX|71020|| ||||||F|||20130530153358||nmiller^^^^^^52

      OBX|13|TX|71020|| ||||||F|||20130530153358||nmiller^^^^^^52

      OBX|14|TX|71020|| ||||||F|||20130530153358||nmiller^^^^^^52

      OBX|15|TX|71020||Patient Name:  Summer K TestLake MPI #:            0000415561 ||||||F|||20130530153358||nmiller^^^^^^52

      OBX|16|TX|71020||Age:              50Years Sex:                 Female ||||||F|||20130530153358||nmiller^^^^^^52

      OBX|17|TX|71020||Date of Birth:   1963/05/09 Accession #:   3000005837 ||||||F|||20130530153358||nmiller^^^^^^52

      OBX|18|TX|71020||PCP:                  CC:MICHAEL

      I need to get the double spaces out from OBX5 when that’s all that is in it, or just remove the entire line.

      I’ve tried the following regsub script, with no luck, trying to use hex code:

      set var $xlateInVals

      regsub -all — {x20x20} $var “” var1

      set xlateOutVals $var1

      I know this should be simple, but I’m just not experienced enough to know of other options.

      Anyone got suggestions?

      Thanks.

    Viewing 11 reply threads
    • Author
      Replies
      • #78592
        Robert Milfajt
        Participant

          Did you just try using spaces instead of x20?

          Code:

          regsub -all — {  } $var “” var1

          Worked for me from TCL shell.

          Hope this helps,

          Robert Milfajt
          Northwestern Medicine
          Chicago, IL

        • #78593
          Levy Lazarre
          Participant

            Robert,

            This would actually destroy all the whitespace in the string, which is not what Aaron is trying to achieve.

            His goal is to collapse multiple spaces into one. I see two issues in the code:

            1. xlateInVals and xlateOutVals are lists and need to be treated as such.

            2. There may be more than two consecutive white spaces, so he should not hard code for only two.

            I would suggest the following snippet:

            Code:


            set var [lindex $xlateInVals 0]
            regsub -all — ” +” $var ” ” var1
            set xlateOutVals [list $var1]

            (In the above regex, please note the single space before the + sign and the single space inside the quotes after $var. This indicates that we are changing multiple spaces into a single one).

            Aaron, this should work for you. Give it a try and see what happens.

          • #78594
            Aaron Oxenreider
            Participant

              I tried both of the suggestions, and I believe I even tried the {  } in the regsub when I was first developing the script.

              Neither seems to work, so I suspect there is further processes at work stopping it from working correctly.

              This is all being done within a second iterate, with the first having settings as follows: Type: Group, Basis: 2, Variable %g1  and then I have the second iterate set as: Type: Group, Basis: 2(%g1).1(0).1, Variable %g2.  Usually when I screw up the iterates, I see my xlate only correct the first line of the OBX, but in this case, I see no changes.

              Screenshot is most of the xlate, with most data not being shown is just correcting/changing values at the end.

              Hoping someone can see where my configuration is not working correctly.

            • #78595
              Levy Lazarre
              Participant

                I don’t think the problem is with the regsubs.

                I would put an echo $var in the tcl fragment to see if you even have data in @obxdata. If not, you have a problem with the iterate and the previous copy statement did not populate the variable.

              • #78596
                Levy Lazarre
                Participant

                  Something doesn’t seem to be right in the Xlate. The screenshot only shows two group level iterates (%g1 and %g2), yet the copy statement to @obxdata shows that you are iterating on the OBX segments at the segment level (%s1). Where is that third iteration (%s1) set up?

                • #78597
                  Aaron Oxenreider
                  Participant

                    Oh. That’s right. I didn’t set that up or use it.

                    I’ll take it out and see if it works, and I still need to insert the echo.

                    When I insert the echo, can I see that in the testing tool?  I use that the most as it allows quick changes and refreshes easily.

                  • #78598
                    Levy Lazarre
                    Participant

                      Yes, you will see the echo value in the test tool output.

                    • #78599
                      Aaron Oxenreider
                      Participant

                        I like the echo ability.

                      • #78600
                        Aaron Oxenreider
                        Participant

                          Well that worked, but a little too good.  the ” +” is taking all of the spaces out of the OBX5 field, and smashes all the data together.  Great for SMS, but not so good for the nice reporting (cough, cough, that was a joke) that Centricity is trying to do.

                          Can I use the regsub with an If statement?  If @obxdata eq =”  ” then regsub….   then copy that back to OBX5?

                        • #78601

                          Try it like this.

                          Code:

                          lappend obx “OBX|11|TX|71020|| ||||||F|||20130530153358||nmiller^^^^^^52”
                          lappend obx “OBX|12|TX|71020|| ||||||F|||20130530153358||nmiller^^^^^^52”
                          lappend obx “OBX|13|TX|71020|| ||||||F|||20130530153358||nmiller^^^^^^52”
                          lappend obx “OBX|14|TX|71020|| ||||||F|||20130530153358||nmiller^^^^^^52”
                          lappend obx “OBX|15|TX|71020||Patient Name:  Summer K TestLake MPI #:            0000415561 ||||||F|||20130530153358||nmiller^^^^^^52”
                          lappend obx “OBX|16|TX|71020||Age:              50Years Sex:                 Female ||||||F|||20130530153358||nmiller^^^^^^52”
                          lappend obx “OBX|17|TX|71020||Date of Birth:   1963/05/09 Accession #:   3000005837 ||||||F|||20130530153358||nmiller^^^^^^52”
                          lappend obx “OBX|18|TX|71020||PCP:                  CC:MICHAEL”

                          foreach seg $obx {
                             set seg [split $seg |]
                             set obx05 [lindex $seg 5]
                             set obx05 [string trim $obx05]
                             echo obx05
                             regsub -all — {s+} $obx05 ” ” obx05
                             echo obx05
                          #    set xlateOutVals [list $obx05]
                          }

                          For an xlate:

                          Code:

                          regsub -all — {s+} [string trim [lindex $xlateInVals 0]] ” ” obx05
                          set xlateOutVals [list $obx05]

                          You can play around testing this xlate code like this:

                          Code:

                          lappend xlateInVals “Patient Name:  Summer K TestLake MPI #:            0000415561″

                          regsub -all — {s+} [string trim [lindex $xlateInVals 0]] ” ” obx05
                          set xlateOutVals [list $obx05]

                          echo

                          -- Max Drown (Infor)

                        • #78602
                          Levy Lazarre
                          Participant

                            Aaron,

                            Did you include a blank space in the replacement string (” ” not “”)? The regex should not take out all spaces.

                          • #78603
                            Aaron Oxenreider
                            Participant

                              Thanks Max and Levy.  That last code set worked great.  I still have to tweak the format, but overall, it greatly reduces the spaces, and clears out the OBX5 with just the double spaces.

                              Again, thank you for the help, and everyone who posted suggestions too.

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