I’ve spent too much time on this…

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf I’ve spent too much time on this…

  • Creator
    Topic
  • #47546
    Bryan Dort
    Participant

    OK…I give up…I don’t understand.  I’m doing a simple xlate tcl and having trouble with it.  From previous listserv messages, I’ve created a tcl to format a field with leading zeros (Thanks Eric).  Here is the problem:

    I’m using this tcl:

    Quote:


    proc xlt_formatsetid {} {

      upvar xlateId       xlateId      

            xlateInList   xlateInList  

            xlateInTypes  xlateInTypes  

            xlateInVals   xlateInVals  

            xlateOutList  xlateOutList  

            xlateOutTypes xlateOutTypes

            xlateOutVals  xlateOutVals

    set xlateOutVals

      ]]

      }

      with the xlate COPY looking like

      PRE

      xlt_formatsetid

      SOURCE

      @dg1setid

      DESTINATION

      0(0).DG1(%s9).00375.[0]

      So, in the testing tool, I get a setid without leading zeros with the above.

      If I change add another SOURCE value so it looks like:

      SOURCE

      =ANYTHING

      @dg1setid

      and change the tcl to look at the second value of the list (index 1), then it formats correctly and I get the leading zeros. What gives?

      3.8.1P Rev 4 on Windows 2000

    Viewing 15 reply threads
    • Author
      Replies
      • #56107
        Rob Abbott
        Keymaster

        What does xlateInVals look like if you echo it, with and without the dummy input field?

        (e.g. echo ‘$xlateInVals’)

        Rob Abbott
        Cloverleaf Emeritus

      • #56108
        Bryan Dort
        Participant

        I added three echo statements to the tcl so now it looks like:

        Quote:


        echo $xlateInVals

        echo [lindex $xlateInVals 1]

        set xlateOutVals

          ]]

          echo $xlateOutVals

          and modified it for each test to get the appropriate list value.

          Here is the output from the Testing Tool:

          With dummy value in SOURCE:

          Quote:


          ANYTHING 3

          3

          0003

          MESSAGE 1

          0(0).MSH(0)  :  >|^~&|MCKESSON|AGH|HNAM|050|20050314150856||ADT^A08|07378|P|2.3|||AL|NE< 0(0).EVN(0)  :  >|A08|20050314150837< …blah…blah…blah… 0(0).DG1(1)  :  >|0003|||THIS IS JUST A TEST – ADMITTING DIAGNOSIS TEXT – IT IS THIS LONG >>>>>>>>>||AD<

          Without dummy value in SOURCE:

          Quote:

          3

          3

          0003

          MESSAGE 1

          0(0).MSH(0)  :  >|^~&|MCKESSON|AGH|HNAM|050|20050314150856||ADT^A08|07378|P|2.3|||AL|NE< 0(0).EVN(0)  :  >|A08|20050314150837< …blah…blah…blah… 0(0).DG1(1)  :  >|3|||THIS IS JUST A TEST – ADMITTING DIAGNOSIS TEXT – IT IS THIS LONG >>>>>>>>>||AD<

          I beginning to think this is a testing tool issue.  I’m going to run this through the engine with noise turned up and see what I get.

          More to come…

          Thanks

        1. #56109
          Bryan Dort
          Participant

          I’ve run it through the engine with and without the dummy value and received the same results as the Testing Tool.  That would lead me to believe that this is NOT a Testing Tool issue.

          😕

        2. #56110
          Scott Lee
          Participant

          Just a wild guess, because you have me stumped – you might try “%04s” for the format.

        3. #56111
          Bryan Dort
          Participant

          I’ve tried formatting both as a (s)tring and a (d)ecimal…no good.  You can see in the output of the Testing Tool that the echo of xlateOutVals is formatted correctly…just not getting to the DESTINATION value.

        4. #56112
          Jodi Agosta2
          Participant

          Bryan,

          This is probably going to be the dumbest idea you get today but if you get really desperate try this..split your grab and format. Get your data and put it in a temp value and then in another line of code format the temp field. You can echo the temp and then echo the format and see the difference….I know, shouldn’t make a difference… I am probably wasting your time.

          Sorry,

          Jodi

        5. #56113
          Bryan Dort
          Participant

          It funny that you should mention that…I tried this also:

          Quote:


          echo $xlateInVals

          set numbertoformat [lindex $xlateInVals 0]

          echo $numbertoformat

          set OutVal [format “%04d” $numbertoformat]

          echo $OutVal

          set OutList

            echo $OutList

            set xlateOutVals $OutList

            echo $xlateOutVals

          with the following results:

          Quote:


          3

          3

          0003

          0003

          0003

          MESSAGE 1

          0(0).MSH(0)  :  >|^~&|MCKESSON|AGH|HNAM|050|20050314150856||ADT^A08|07378|P|2.3|||AL|NE< 0(0).EVN(0)  :  >|A08|20050314150837< blah…blah…blah… 0(0).DG1(1)  :  >|3|||THIS IS JUST A TEST – ADMITTING DIAGNOSIS TEXT – IT IS THIS LONG >>>>>>>>>||AD<

          You can see that the format is working correctly…just not getting to the DESTINATION.

          😕  ðŸ˜•

        6. #56114
          Scott Lee
          Participant

          How is the field defined in the HL7 config?

        7. #56115
          Bryan Dort
          Participant

          Sequence ID (SI) – Length of 4.

        8. #56116
          Jodi Agosta2
          Participant

          Bryan,

          Try this. It worked in my test env. I am on W2K v5.1r1. Make sure your receiving field has enough space.

          set xlatetemp [string range $xlateInVals 0 3]

          set xlateOutVals [format %04d $xlatetemp]

          Let me know,

          Jodi

        9. #56117
          Bryan Dort
          Participant

          No good Jodi.  I added echo statements before and after and still the same results:

          Quote:


          3

          0003

          MESSAGE 1

          0(0).MSH(0)  :  >|^~&|MCKESSON|AGH|HNAM|050|20050314150856||ADT^A08|07378|P|2.3|||AL|NE< 0(0).EVN(0)  :  >|A08|20050314150837< blah…blah…blah… 0(0).DG1(1)  :  >|3|||THIS IS JUST A TEST – ADMITTING DIAGNOSIS TEXT – IT IS THIS LONG >>>>>>>>>||AD<

          Thanks anyway!

        10. #56118
          Jodi Agosta2
          Participant

          Bryan, you have got me stumped. I set up a test. Flat file to HL7 2.1 DG1.1 field 506 (SI length 4) with that code and it worked perfectly. Are you in a position where you could do a reboot and clear memory? I don’t have a clue as to why that wouldn’t work even though we are on different versions.

          Here was my setup for the test

          copy   =3  -> 0(0).DG1.00506

          with the code I gave you above in the pre tcl area.

        11. #56119
          Bryan Dort
          Participant

          Rebooted and same result…BUT WAIT!  You gave me an idea!  

          I hardcoded the “=3” in the SOURCE as you did, and it worked perfectly!  So the answer lies in the temporary variable @dg1setid that I am using. That variable is incremented in the iterate of the DG1s so that I can get the last DG1 setid.   I’ll rethink that logic and get rid of the temporary variable. (Although, I still think that it should work.)

          Thanks Jodi!!

          Bryan

        12. #56120
          Jacques Talbot
          Participant

          I had a similar problem and the only way I found was to use xpmstore:

          xpmstore $xlateId [lindex $xlateOutList 0] c [format “%04d”  [lindex $xlateInVals 0]]

        13. #56121
          Robert Milfajt
          Participant

          Just a crazy idea, but you don’t have another command within the iterate that would wipe out what this command is doing?  I.e., Pathcopy, etc.  Can you show the whole iterate you’re working with?

          Thanks,

          Bob

          Robert Milfajt
          Northwestern Medicine
          Chicago, IL

        14. #56122
          Mark Thompson
          Participant

          Be careful when you use Tcl for operations on numbers with leading zeroes.  Tcl interprets them as an octal (not decimal) number.  That could be why your leading zeroes are disappearing.

          - Mark Thompson
          HealthPartners

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

      Forum Statistics

      Registered Users
      5,127
      Forums
      28
      Topics
      9,299
      Replies
      34,443
      Topic Tags
      288
      Empty Topic Tags
      10