xlate copy embedded space

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf xlate copy embedded space

  • Creator
    Topic
  • #53531
    Peter Heggie
    Participant

      I need to copy an input PID5 firstname and middle initial into the output PID5 firstname.

      If the input PID5 is SMITH^JOHN^K, then the output PID5 must be SMITH^JOHN K

      I’ve tried a bunch of code to get that to work, like sending the combination to an intermediate variable, or making a list out of the two items and joining the list into xlateOutVals, and nothing seems to work – it just truncates at the embedded space. All I get is SMITH^JOHN

      Any suggestions?

      Peter

      Peter Heggie

    Viewing 15 reply threads
    • Author
      Replies
      • #78017
        Jim Kosloskey
        Participant

          Peter,

          I would use the Xlate CONCAT.

          CONCAT …PID#5.[1] …PID#5.[2] –> …PID#5.[1]

          With space as the Separator specified in the CONCAT properties or you can add it to the Source list using ‘= ‘ (no quotes).

          No Tcl should be needed.

          However, in your Tcl I suspect you are not treating XlateOutVals as a list.

          email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

        • #78018
          Peter Heggie
          Participant

            Jim, that worked great – thank you.

            Peter Heggie

          • #78019
            David Harrison
            Participant

              You need to be aware that if there is no middle intial the you will still get a space after the forename.

            • #78020
              Russ Ross
              Participant

                Give this a try that worked for me.

                By the way there is a space after the equal sign on the input side in the screen shot below.

                I see Jim already posted in the time it took to create the screen shot because I got itnerupted with a phone call but posted since I already did the work, pus it is more visual.

                It is interesting that you are making it non-HL7 compliant becuase I typicaly have to take “Russ K” and make it “Russ^K”.

                This is the first time I had to break it on purpose which I learend much easier to convert descrete data to non descreate than the other way around.

                Russ Ross
                RussRoss318@gmail.com

              • #78021
                Peter Heggie
                Participant

                  I will have to code for that. The source system used to send the first name and middle initial together in one field. If there was no middle initial, there was no trailing space. Now that we are converting the source system to HL7, we are getting the normal PID5, but the receiving system expects the old format.

                  Peter Heggie

                • #78022
                  Jim Kosloskey
                  Participant

                    Peter,

                    Easy enough to check the Middle name component for @null using Xlate IF and with an else have one COPY and one CONCAT.

                    email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

                  • #78023
                    Peter Heggie
                    Participant

                      that was great! you responded before I went off into another coding nightmare. yes thats the better way. thank you

                      Peter Heggie

                    • #78024
                      Jo Ellen Laansma
                      Participant

                        I am trying something just like this, but I want to combine PID.5[1-5] into one field with spaces separating and no trailing spaces.

                        When I do so, my source is: 1(0).0(0).PID(0).#5(0).[1,2,3,4,5] and I am CONCAT with a separator of (just a space) and the output is 1(0).0(0).PID(0).#5(0).[1].  I am using a Post Proc to get rid of the trailing spaces and it works until it assigns it to the destination.

                        Here is my Post Proc:

                        echo out

                        set nospace [string trimright [lindex $xlateInVals 0]]

                        echo

                        set xlateOutVals

                          echo

                          Here is my output:

                          out

                          You can see that what is being assigned to xlateOutVals indeed has the space truncated and was verified by echo’ing out the value.  Yet the ouput of my message shows:

                          |PPID^TESTFOUR MI JR MR |

                          I have the trailing space because I don’t have all 5 fields valued.  The degree is missing.  And if I only have first and middle initial valued, I get 3 spaces.

                          What am I missing?

                      • #78025
                        Jo Ellen Laansma
                        Participant

                          Here are snippets

                        • #78026
                          Jo Ellen Laansma
                          Participant

                            I put this all in the post proc so that I could utilize the output of the concatenation as my input.  But apparently, it would not change the value of the output after my post proc.

                            I ended up having to do this in two steps:

                            1) use the post proc to have the concat feature work and assign to a temporary variable.

                            2) added a new step of the temporary variable that trimmed the trailing space.

                          • #78027
                            Jim Kosloskey
                            Participant

                              CONCAT

                              Source:

                              1(0).0(0).PID(0).#5(0).[1]

                              =

                              email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

                            • #78028
                              Jo Ellen Laansma
                              Participant

                                I did see that post, but that gives a trailing space if the last field is not valued and I do not want trailing spaces.

                              • #78029
                                Jim Kosloskey
                                Participant

                                  Then you will need Tcl unless on release later than 6.0.0 where some of the string functions are now built in.

                                  email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

                                • #78030
                                  Steve Williams
                                  Participant

                                    Quote:

                                    Here is my Post Proc:

                                    echo out

                                    set nospace [string trimright [lindex $xlateInVals 0]]

                                    echo

                                    set xlateOutVals

                                      echo

                                    Cloverleaf does not honor/allow the use of set xlateOutVals in a Xlate Pros-Proc snippet. As I recall, the post proc is called after the xlate assignment to the destination path(s). That is why your echo statements show the expected output but your HL7 message does not.

                                  • #78031
                                    Steve Williams
                                    Participant

                                      To perform the concatenation in TCL (pre-proc snippet), use the TCL join command to turn a list (xlateInVals) into a space separated string.

                                      Formatting names is a messy business which is why PID:5 is coded to separate names into many discrete elements.

                                      The real trick is determining if any of the list elements in xlateInVals is blank or null. I like to sidestep that problem by using a simple regular expression to substitute a single space for two or more adjoining spaces found in the output string and nix the trailing space at the same time.

                                      Regex and regsub are more CPU demanding than a series of if statements, but a simple substitution is easier much on my brain.

                                      Don’t forget to include comments in your TCL snippet to explain what you are doing and why.

                                    • #78032
                                      Jo Ellen Laansma
                                      Participant

                                        Thank you for the clarification, Steve!  That is the part that had me baffled.

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