Formatting data in a different way

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Formatting data in a different way

  • Creator
    Topic
  • #51008
    Ariba Jones
    Participant

      First I must apologize for my subject line.  I couldn’t think of any other way to state what I need. 🙂

      I am trying to find out if it is possible for me to reformat data in a certain format on Cloverleaf before sending to the receiving system.

      Here is what I need to have happen….

      I need to capture the date and time in  the OBX segment and format it to look like the date and time in the OBR segment.

      I need to take this date and time (which is 04/02/09 1029) from this format:

      OBX:5:TX:REPORT42;REPORT:25:     Released Date Time- 04/02/09 1029::::::F:

      and make it look like this…….

      200904021015

      Is this something that can be done on Cloverleaf (version 5.2)?  If so, how do I accomplish that?

      Thanks in advance.

      Ariba

    Viewing 10 reply threads
    • Author
      Replies
      • #68413
        Tom Rioux
        Participant

          Hi Ariba,

          You could try this and see if it helps:

          hcitcl>set dt_time “04/02/09 1029”

          04/02/09 1029

          hcitcl>set new_date [clock format [clock scan $dt_time] -format %Y%m%d%H%M]

          200904021029

          Hope this helps!

          Tom Rioux

        • #68414
          Ariba Jones
          Participant

            Hi Tom,

            Thanks for responding to my post.  

            Where would I put the code that you suggest?  Can I put that in an xlate or does it need to be in a TCL?

            Do I have to put the specific date and time in the command as you have done or were you just demonstrating (your first line of code)?  I am asking because the date/time will always change.

            Thanks,

            Ariba

          • #68415
            Tom Rioux
            Participant

              You can put it in an xlate.  Just add it as a tcl fragment and change it like the first line to be:

              set dt_time [lindex $xlateInVals 0]

            • #68416
              Anonymous
              Participant

                If I’m looking at this correctly.

                The xlateInvals will have a complete line of text in it.

                So you will need to find the date time in the text line.

                You can do this it is  just a little more complex then you may think.

                If the line will always have the same format.

                It may be easier to replace the entire line and grab the raw date time from another field. This may or may not work depending on your setup.

                If you know for sure the date in your inbound line will always start at character position  25.  You could grab it with a string range command. But again if it changes that will become and issue.

                There are several options. Each with it’s own set of unique opportunities.

                Hope one of these two methods can get you what you need.

              • #68417
                Tom Rioux
                Participant

                  You may certainly be correct John.   I was assumming that she had already pulled the date out of the string.   Since Ariba didn’t specifically mention having to pull the date out as well, I figured that xlateInVals would be the date.

                  Later…Tom

                • #68418
                  Ariba Jones
                  Participant

                    John,

                    You are correct.  I will need to pull the date and time from the line of text.  I have looked at several messages and the field seems to be formatted the same each time.  

                    I apologize for not stating that.  I was trying to make sure I showed you exactly what the field looks like now (in the OBX segment example) and then what I need to make it look like (in the OBR segment example).

                    I am not sure what you mean by “replace the entire line and then grab the raw date time from another field”.  Can you describe that more?

                    This does sound like something more than what I expected.  Actually, I was starting to think that maybe this would be complex.  I am just not sure how to do what you are saying.  

                    Thanks,

                    Ariba

                  • #68419
                    Tom Rioux
                    Participant

                      Ariba,

                      You can grab the field pretty easily by doing the following:

                      set obxfld [lindex $xlateInVals 0]  ; grabs the entire string

                      set dt_time [string range $obxfld end-13 end]  :grabs the date/time

                      set xlateOutVals [clock format [clock scan $dt_time] -format %Y%m%d%H%M]

                      Make sure the “end-13” is all together with no spaces on either side of the dash.

                      Hope this helps….

                      Tom Rioux

                    • #68420
                      Charlie Bursell
                      Participant

                        Won’t work Tom.  There must be a space between date and time

                        tcl>clock scan 20090630140505

                        Error: unable to convert date-time string “20090630140505”

                        tcl>clock scan “20090630 140505”

                        1246388705

                        Try:

                        set dt_time [string range $obxfld end-13 end]  :grabs the date/time

                        regsub — {(d{8})(.*$)} $dt_time {1 2} dt_time

                        set xlateOutVals [clock format [clock scan $dt_time] -format %Y%m%d%H%M]

                        Note space between 1 2

                      • #68421
                        Tom Rioux
                        Participant

                          Charlie,

                          Ariba said the date/time is formatted like “04/02/09 1029” and is looking to change it to the 200904021029 format.

                        • #68422
                          Charlie Bursell
                          Participant

                            Sorry.  I thought of standard HL7 date

                          • #68423
                            Ariba Jones
                            Participant

                              Tom,

                              Yes.  That is what I am looking for.  So, it looks like I can try your solution to see if it works.

                              I’ll also try Charlie’s solution.

                              Thanks to both of you for the suggestions.  I will let you all know what happens.

                              Ariba

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