XLT Copy woes

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf XLT Copy woes

  • Creator
    Topic
  • #54458
    Seth Jackson
    Participant

      Hey everybody,

      I’m working on a HL7 translation that has me stumped.  Here’s a pseudo code of, what I’m attempting to accomplish:

      Copy all components starting from the source’s OBX.#5.[1] to the destination, starting at the destination’s OBX.#5.[0]

      Here are examples of how that should look:

      |=^20.2| would copy as |20.2|

      |=^1^+| would copy as |1^+|

      |=^20^:^06| would copy as |20^:^06|

      In other words, I don’t want to erase or @null the data in OBX.#5.[0], rather I need to shift the data… So OBX.#5.[1] becomes .[0], .[2] becomes .[1], .[3] becomes .[2], and so on.

      The issue I’m struggling against is, I don’t necessarily know how many components will be in the source field. But since xlateOutVals is a list, I have to specify multiple destinations, right? Do I just guess by putting .[0] through .[99] in the destination, and hope for the best? 😆

      It just feels like there should be a more efficient and reliable way of doing this.

      Any help or suggestions are greatly appreciated.

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

          Try a straight copy in Xlate with the following TCL fragment

          COPY OBX.#5 OBX.#5

          Code:

          set numItms [llength $xlateInVals]
          set xlateOutVals “”
          for {set x 1} {$x<$numItms} {incr x} {lappend xlateOutVals [lindex $xlateInVals $x]}

          Oh, and if your using PATHCOPY of OBX segment before this, remember to null out the OBX-5 field before this copy.  I would use:

          PATHCOPY @null OBX.#5

          Hope this helps,

          Robert Milfajt
          Northwestern Medicine
          Chicago, IL

        • #81575
          Seth Jackson
          Participant

            Hey Robert,

            Thanks for the reply. I gave your TCL fragment a try but, unfortunately, it doesn’t work. If you echo $xlateOutVals, the list is built correctly, but only the first element of the list appears in the message.

            Command output:

            4.29

            12.4 12345

            2(0).0(0).1(0).0(1).OBX(0)  :  >|1|NM|RBC^RBC|1|4.29|10*6/uL^million per microliter^L||N|||F|||201411110936<

            2(0).0(0).1(0).0(2).OBX(0)  :  >|2|NM|HGB^HGB|2|12.4|g/dL^gram per deciliter^L||N|||F|||201411110936<

            (The second value should be 12.4^12345)

          • #81576
            Shane Farney
            Participant

              Double check your translate, and make sure you aren’t copying just a single subfield.  It definitely works (tried it myself).

            • #81577
              Seth Jackson
              Participant

                Quadruple-checked 😆

                Source

                6(%g1).0(0).OBX(0).#5(0)

                Destination

                2(0).0(0).1(0).0(%g1).OBX(0).#5(0)

                Very odd… The fact that this all takes place inside an iterate shouldn’t effect anything, should it?

              • #81578
                Seth Jackson
                Participant

                  Oh wait… tried the code on a different field and it worked.

                  The TCL fragment doesn’t work on OBX.#5 because the variant only has one component (0 String Data).  If you put the code in a field with multiple components, it works.

                  Well that makes things even more complicated.

                • #81579
                  Shane Farney
                  Participant

                    Instead of using “lappend”, maybe just create a string delimited by your separator carets?

                  • #81580
                    Tom Rioux
                    Participant

                      Maybe I don’t understand what you are asking or am just thinking too simply about this, but couldn’t you just do a simple copy statement on the field and put this as your tcl fragment:

                      set xlateOutVals [lrange $xlateInVals 1 end]

                      I’m sure that I am missing something here….

                      Thanks….

                    • #81581
                      Seth Jackson
                      Participant

                        Thomas,

                        That was actually the original code I used.  Technically it works (just like Robert’s code suggestion) but it ultimately gets truncated down to a single component due to the way the variant is built.

                        I’m going to try Shane’s suggestion, but I suspect that may encounter issues if the lab ever sends sub-components in OBX.#5

                        I wish Cloverleaf had something like xlateRawVals… something that would allow me to perform TCL fragment code against an un-parsed field, in its entirety.

                      • #81582
                        Jim Kosloskey
                        Participant

                          You mean the vendor cannot tell you how many components it willl send in OBX-5?

                          They certainly should know the limit.

                          Moreover what’s with the unpopulated first component.

                          Additionally the varisntt reflects the HL/7 standard for OBX-5.

                          If you want to you can create a new variant with the only difference being the data type you assign to the OBX-5 field.

                          Personally I would wrangle a little with the source system.

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

                        • #81583
                          Charlie Bursell
                          Participant

                            If I know Jim he will come up with a no Tcl way  ðŸ˜€

                            However if it were me, and it is not, I would use a CALL since I want to absolutely control the output

                            Within the iterate I would first null out all my OBX.5 subfields like:

                            { { OP PATHCOPY }

                               { ERR 0 }

                               { IN @null }

                               { OUT 2(0).1(0).1(0).0(%g1).OBX.#5 }

                            }

                            ( Your addressing may be different )

                            Then I would implement a CALL with Tcl like:

                            { { OP CALL }

                               { ERR 0 }

                               { IN 2(0).1(0).1(0).0(%g1).OBX.#5 }

                               { OUT 2(0).1(0).1(0).0(%g1).OBX.#5 }

                               { TCL {

                                   set outAddr [lindex $xlateOutList]

                                   lvarpop xlateInVals

                                   set cnt 0

                                   foreach el $xlateInVals {

                                       set addr $outAddr.[$cnt]

                                       xpmstore $xlateId $addr c $el -type st

                                       incr cnt

                                   }

                               }}

                            }

                            Note each time we pop off the first element of xlateInVals.  We then get the outbound address and for each remaining element in xlateInVals we change the outbound address to end with .[0], .[1]. etc

                            “There may be better ways I am sure but this is what came to my mind.

                            There are only two people that write decent code, you and me, and sometimes I wonder about you”   😆

                          • #81584
                            Robert Milfajt
                            Participant

                              For my way to work, you might have to do CONCAT instead of COPY and ^ as delimeter with same TCL code.

                              Bob

                              Robert Milfajt
                              Northwestern Medicine
                              Chicago, IL

                            • #81585
                              Seth Jackson
                              Participant

                                Hey Charlie,

                                This is… AWESOME! I’m fairly new to Cloverleaf development so I didn’t know about the XPM commands. Looks like I’ve got some reading to do 😆 I think these will solve a lot of the problems we’ve been struggling against with our e*Gate conversions.

                                Thank you so much!! 😀

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