HL7 translation question regarding building field

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf HL7 translation question regarding building field

  • Creator
    Topic
  • #52282
    Doug Stelley
    Participant

    I need to customize PID(3) Patient ID

    Specifically I have to add to what is coming in. and zero fill to to a length of 15

    I have take the incoming value (say 8251), I have to add “16931” to the first 5 characters and zero fill to 8251 to make a new value.

    8251 becomes

    169310000008251

    i wont always know the length of the original value but it has to come to 15 when done. HELP!

    I will have to find the final value  of the left digits (16931) but that is for a different day….

Viewing 3 reply threads
  • Author
    Replies
    • #73680
      Steve Carter
      Participant

      hcitcl>set x 16931

      16931

      hcitcl>set y 8251

      8251

      hcitcl>set totalChars [expr [string length $x] + [string length $y]]

      9

      hcitcl>set padCnt [expr 15 – $totalChars]

      6

      hcitcl>set padValue [replicate 0 $padCnt]

      000000

      hcitcl>set newValue $x$padValue$y

      169310000008251

    • #73681
      Keith McLeod
      Participant

      Assuming input using Xlate:

      Source

      =16831

      pid:3.0

      These 2 lines would go into preproc:

      set total_input_length [expr [string length [lindex $xlateInVals 0]] +[string length [lindex $xlateInVals 1]]]

      set xlateOutVals “[lindex $xlateInVals 0][string repeat 0 [expr 15 – $total_input_length]][lindex $xlateInVals 1]”

      Destination

      169310000008251

      This is just one of many ways to accomplish this….

    • #73682
      Scott Folley
      Participant

      Based on your post I am assuming that the 16391 is based in some way on the value in PID.3.  Is that accurate?

      How about this, derive the second number in whatever way that you need to (lets call that X).  Pad that value to the right with either a replicate command as Steve describes or with a format command.  Then add the value of the first number to it:

      set outstring [ format “%-015s” 16931 ]

      set outstring [ expr $outstring + 8251 ]

      As Keith points out, there are a myriad of different ways to do this, it is just a matter of choosing the one that you like the best.

    • #73683
      Chris Williams
      Participant

      Format is your friend. You can also include your hard-coded value inside the format-string:

      Code:

      set xlateOutVals [list [format “16931%010s” [lindex $xlateInVals 0]]]

      You want to pad the incoming value with zeros to a total of 10 characters and then tack the “16931” onto the front of it giving you your total of 15. It is easier if you think of this as manipulating strings of characters rather than numeric values.

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

Forum Statistics

Registered Users
5,117
Forums
28
Topics
9,293
Replies
34,435
Topic Tags
286
Empty Topic Tags
10