Errors while Formatting a Date inside an Xlate

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Errors while Formatting a Date inside an Xlate

  • Creator
    Topic
  • #49168
    Ricci Graham
    Participant

      I have written the following code inside my Xlate to reformat the the date

      from YYYYMMDDhhmmss to MMDDYYYY.

      CODE INSIDE XLATE:

      lassign $xlateInVals dt

      set dtcter 0

      set dtcter [string length $dt]

      if {$dtcter < 5} {  set dtcter 0 } else {  regsub — {(d{8})(d*)} $dt {1 2} dt  set dt [clock format [clock scan $dt] -format “%m%d%Y”]  set xlateOutVals

         set dtcter 0

        }

        My problem is when the date field contains only four digits in the time (i.e.

        200703250028) then it raises the following error:

      ERROR:

      Tcl callout error

      erroCode: NONE

      errorInfo:

      unable to convert date-time string “20070325 0028”

         while executing

      “clock scan $dt”

         invoked from within

      “if {$dtcter < 5} {  set dtcter 0 } else {  regsub — {(d{8})(d*)} $dt {1 2} dt  set dt [clock format [clock scan $dt] -format “%m%d%Y”]  set x…”

      It also raises an error if the field contains something like 99999999 or

      00000000.

      How can I get around these issues?

      Any ideas or suggestions will be greatly appreciated.

      Thanks,

      Ricci

    Viewing 3 reply threads
    • Author
      Replies
      • #60956
        Robert Kersemakers
        Participant

          Hi Ricci,

          I only read the first line of your message and I would solve your problem in a completely different way:

          Code:

          lassign $xlateInVals date
          set datenew “[string range $date 4 5][string range $date 6 7][string range $date 0 3]”
          set xlateOutVals [list $datenew]


          This way you don’t need to use the ‘clock scan’.

          Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

        • #60957
          James Cobane
          Participant

            Are the fields defined as ‘date’ fields on your inbound and outbound record definitions that the translate is using?  If so, you should be able to do a simple ‘COPY’ and let the engine do the reformatting.

            Jim Cobane

            Henry Ford Health

          • #60958
            Michael Hertel
            Participant

              There may be an issue with the time starting with 00 and clock scan.

              Try a time like 1327 and see if you have the same error.

              I’ll look into this more in a bit, but I agree with Robert on this one.

              Use string logic, not clock scan logic.

              -mh

            • #60959
              Ricci Graham
              Participant

                James,

                These are both HL7 files, I wasn’t aware there was a place to reformat the

                date when it runs through the engine if you are using HL7 on both sides.

                I know you can do this with FRL’s, but I didn’t know you can do this with HLR? Where is that?

                Thanks,

                Ricci

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