HL7 Timestamp (ts) to XML Datetime (dtm)

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf HL7 Timestamp (ts) to XML Datetime (dtm)

  • Creator
    Topic
  • #52790
    Kent Geisler
    Participant

      How do I copy a HL7 timestamp-field to a XML datetime-field?

      I use a tcl in my xlate to format the timestamp from YYYMMDDHHMM to YYYY-MM-DDTHH:MM:SS

      The seconds (SS) are always set to “00” in the tcl.

      When I run the xlate in the Testin Tool I get the following error:

      MESSAGE 1

      [0:TEST] Warning: The format of source value ‘2011-09-08T16:47:00’ is inconsistent with its type: ‘ts’

      [0:TEST] Message encode warnings: Error generated during parsing. – Element ‘datotid’ got Datatype error, Type:SchemaDateTimeException, Message:buffer not initialized yet!. – Line 1, Col 130

      Output validation errors: Error generated during parsing. – Element ‘datotid’ got Datatype error, Type:SchemaDateTimeException, Message:buffer not initialized yet!. – Line 1, Col 130

      [0:TEST] Error generated during parsing. – Element ‘datotid’ got Datatype error, Type:SchemaDateTimeException, Message:buffer not initialized yet!. – Line 1, Col 172

      If I then “Hardcode” the value “2011-09-08T16:47:00” in the xlate instead of taking it from the HL7-message there is no problem parsing it to the xml datetime-field.

      MESSAGE 1

      testDatoTid.datotid.#text:   >2011-09-08T16:47:00< If I get the timestamp from a text-field in the HL7-message I can also format and parse it to the xml datetime-field without problems.

    Viewing 9 reply threads
    • Author
      Replies
      • #75481
        Jim Kosloskey
        Participant

          Kent,

          without seeing the Tcl code I am guessing you may not be treating xlateOutVals as a list so what you think you have formatted is not what the Xlate is presenting.

          email: jim.kosloskey@jim-kosloskey.com 30+ years Cloverleaf, 60 years IT – old fart.

        • #75482
          Levy Lazarre
          Participant

            Kent,

            The TS (TimeStamp) data type in HL7 only allows a numeric value in the field.

            The “T” format character in your converted date may be causing the issue since you are inserting a string in a strict TS field.

            I would try to modify the HL7 variant and change the data type for this date field from TS to ST.

            I hope this helps.

          • #75483
            Kent Geisler
            Participant

              Jim and Levy,

              Below is my tcl and xlate

              I have previously tried to display the datetime returned from the xlate, and it has the right value.

              I have considered making a HL7 variant and change the data type from TS to ST. Maybe it’s the easiest way to solve the problem.

              ######################################################################

              # Name: xlt_convert_tid

              # Purpose: Transform timestamps

              # UPoC type: xltp

              # Args: input_timestamp

              # input_format

              # output_format

              # Return: output_timestamp

              #

              proc xlt_convert_tid {} {

              upvar xlateId xlateId

              xlateInList   xlateInList

              xlateInTypes  xlateInTypes

              xlateInVals   xlateInVals

              xlateOutList  xlateOutList

              xlateOutTypes xlateOutTypes  

              xlateOutVals  xlateOutVals

              set tid  [ lindex $xlateInVals 0 ]

              set in_fmt  [ lindex $xlateInVals 1 ]

              set out_fmt  [ lindex $xlateInVals 2 ]

              set cen “”

              set year “”

              set mon “”

              set day “”

              set hour “00”

              set min “00”

              set sec “00”

              set sec1 “0”

              if { $in_fmt == “YYMMDD” } {

              set year [string range $tid 0 1 ]

              set mon [string range $tid 2 3 ]

              set day [string range $tid 4 5]

              # Fjern foranstillet 0, s

            • #75484
              Levy Lazarre
              Participant

                Quote:

                I have considered making a HL7 variant and change the data type from TS to ST. Maybe it’s the easiest way to solve the problem.

                I had a similar issue in the past. I did exactly that and the parser did not complain anymore. It worked fine.

                Your code looks good to me. Perhaps Jim has another suggestion.

              • #75485
                Jim Kosloskey
                Participant

                  Kent,

                  My guess is the error is related to your outbound (XML) field not the inbound HL/7 field).

                  To try and narrow this down, try doing this in your Xlate (instead of calling your proc):

                  set out “2011-09-08T16:47:00”

                  lvarpop xlateOutVals 0 $out

                  If the problem persists, then leave the codeabove in place and remove all of the inbound fields other than the MH-7 reference (so there is only one inbound field). Try again.

                  Let us know what happens.

                  You can email me directly if you like – my email is on all my posts – don’t use PM I hardly ever look at that.

                  email: jim.kosloskey@jim-kosloskey.com 30+ years Cloverleaf, 60 years IT – old fart.

                • #75486
                  Kent Geisler
                  Participant

                    Jim,

                    Below my tries and the results:

                    First try with no input except the hardcoded datetime

                    prologue

                       type: xlt

                       version: 7.0

                    end_prologue

                    { { OP COPY }

                       { ERR 0 }

                       { PRE {

                           set out “2011-09-08T16:47:00”

                           set xlateOutVals $out

                       }}

                       { IN {} }

                       { OUT testDatoTid.datotid.#text }

                    }

                    Result in TestTool where I can parse the date to the xml-field:

                    Command output:

                    MESSAGE 1

                    testDatoTid.datotid.#text:   >2011-09-08T16:47:00<

                    Second try with MSH-7 as input field, but not used:

                    prologue

                       type: xlt

                       version: 7.0

                    end_prologue

                    { { OP COPY }

                       { ERR 0 }

                       { PRE {

                           set out “2011-09-08T16:47:00”

                           set xlateOutVals $out

                       }}

                       { IN {{0(0).MSH(0).#7(0).[0]}} }

                       { OUT testDatoTid.datotid.#text }

                    }

                    Result in TestTool where I get the error:

                    MESSAGE 1

                    [0:TEST] Warning: The format of source value ‘2011-09-08T16:47:00’ is inconsistent with its type: ‘ts’

                    [0:TEST] Message encode warnings: Error generated during parsing. – Element ‘datotid’ got Datatype error, Type:SchemaDateTimeException, Message:buffer not initialized yet!. – Line 1, Col 130

                    Output validation errors: Error generated during parsing. – Element ‘datotid’ got Datatype error, Type:SchemaDateTimeException, Message:buffer not initialized yet!. – Line 1, Col 130

                    [0:TEST] Error generated during parsing. – Element ‘datotid’ got Datatype error, Type:SchemaDateTimeException, Message:buffer not initialized yet!. – Line 1, Col 172

                  • #75487
                    Jim Kosloskey
                    Participant

                      Kent,

                      What release of Cloverleaf are you running?

                      I am on 5.6R2.

                      Although I don’t have your XML schema, I did a quick test using a schema I do have witha text field.

                      I did a COPY with the same MSH-7 address path you used, the same Tcl snippet and my #text XML output field.

                      I got no error when running the tester and the result is as expected.

                      email: jim.kosloskey@jim-kosloskey.com 30+ years Cloverleaf, 60 years IT – old fart.

                    • #75488
                      Kent Geisler
                      Participant

                        Jim,

                        We are running 5.7P

                        Below the test-schema I am using (also attached) where the type of the datotid-field is “dateTime”.

                        It’s right, if I change the type of datotid to: ENGINE=”s.string” it runs without errors.

                        <s:schema xmlns:s="http://www.w3.org/2001/XMLSchema”&gt;

                         

                           

                             

                               

                             

                           

                         

                        If I make a HL7-variant where the type of MSH.7 is changed from TS to ST it also runs without errors.

                      • #75489
                        Mike Keys
                        Participant

                          So, is the solution to this to make a variant and convert the field type from TS to ST?

                          Having the exact same issue right now.

                        • #75490
                          Kent Geisler
                          Participant

                            It was the solution I chose

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