Trying to convert HL7 TS to human readable date

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Trying to convert HL7 TS to human readable date

  • Creator
    Topic
  • #52876
    Dan Drury
    Participant

      I am trying to convert an HL7 TS to a human readable date in a preproc.

      I am using:

      set newDate [regsub — {(d{8})(d{2})(d{2})(d{2})} $xlateInVals {1 2:3:4} ]

      set xlateOutVals [clock format [clock scan $newDate] -f {%m/%d/%Y %l:%M:%S %p}]

      But all is seem to get in the output is the Date portion.  Any idea what I am doing wrong?

    Viewing 3 reply threads
    • Author
      Replies
      • #75756
        Robert Milfajt
        Participant

          The TCL looks sound, so I would attempt to find out what is being passed in via the Xlate.  Put in an echo before the set newDate to see what is in xlateInVals, i.e.:

          Code:

          echo “xlateInVals=>$xlateInVals<"

          I put in the >< to help visualize any white space. Hope this helps,

          Robert Milfajt
          Northwestern Medicine
          Chicago, IL

        • #75757
          Jim Kosloskey
          Participant

            Dan,

            OK when referencing the xlateInxxx and xlateOutxxx remember they are lists and need to be treated as such.

            So for at least the portion of your code that produces the xlateOutVals since you ar not treating it as a list it is looking like thes (the > and < ar mine):

            >MM/DD/YYYY HH:MM:SS AM<

            Note the spaces. Since the Xlate treats xlateOutVals as a list and white space (a space is white space) delimits ele4ments in the list you have provided a list with threee elements (date, time, AM/PM) and the Xlate will select the firs – hence you ar only getting the first element out of the Xlate.

            If you were to use something like:

            lreplace xlateOutVals 0 0 [clock format [clock scan $newDate] -f {%m/%d/%Y %l:%M:%S %p}]

            Then you would give this back to the Xlate:

            >{MM/DD/YYYY HH:MM:SS AM}<

            Note the curly braces – now this is a single element list and should work fine (assuming none of your input has any white spaces).

            To be sure you handle the xlateInVals properly do something like an lindex against it.

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

          • #75758
            Dan Drury
            Participant

              Jim,

              Thank  you for pointing out that xlateOutVals is a list.  with my original tcl I now have a 1 X 3 array of xlateOutVals to play with.  0 = date portion 1 = time portion 2 = AM/PM  (wonder what hat is called in time nomenclature).  I have three variables listed in my destination now, one for each list element and can then use those variables that contain the date, time and day/night portion as needed.

              Thank you for pointing me in the correct direction.

              I now have a source of TS with a tcl preproc of:

              set newDate [regsub — {(d{8})(d{2})(d{2})(d{2})} $xlateInVals {1 2:3:4} ]

              set xlateOutVals [clock format [clock scan $newDate] -f {%m/%d/%Y %H:%M %p}]

              and three variables on the destination to “catch” the date, time and day/night output for use later.

              Thank You,

              Dan Drury

            • #75759
              Jim Kosloskey
              Participant

                Dan,

                If you want these all in one, simply use something like the lreplace I showed you and now your single destination will have your entire time string.

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

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