does anyone have a tps to calcuate age

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf does anyone have a tps to calcuate age

  • Creator
    Topic
  • #48257
    Nancy McDaniel
    Participant

      I am trying to produce a report from a HL7 ORU message and I would like to print out a patient’s age.  Does anyone have a tcl that does this and would be willing to send this to me?

      thanks,

      Nancy Hellyer

      The Vancouver Clinic

      nhellyer@thevancouverclinic.com

      (360) 397-3222

    Viewing 6 reply threads
    • Author
      Replies
      • #58184
        Rentian Huang
        Participant

          Nancy,

          Assuming we have 365 days a year, this should give you the age. It’s an Xltp.

          Code:

          proc xltGetAge {} {
             upvar xlateId       xlateId
           xlateInList   xlateInList
           xlateInTypes  xlateInTypes
           xlateInVals   xlateInVals
           xlateOutList  xlateOutList
           xlateOutTypes xlateOutTypes
           xlateOutVals  xlateOutVals

          set dob [lindex $xlateInVals 0]
          set age [expr {([getclock] – [clock scan $dob])/86400/365}]
          set xlateOutVals $age
          }

          Hope this helps,

          Sam   8)

        • #58185
          Jennifer Hardesty
          Participant

            This method is extremely useful, except that I’ve had a problem with infant ages because they are less than 1.  I’ve had to remove the 365 so that I’m now calculating for days rather than years.

            Now, I have a new issue:  When Admitting enters a DOB of 01/01/1901 (don’t ask me why they seem to do this — I think they do this on anon patients as policy), it causes a tcl callout error that says that the date is not calculatable and of course the message fails to be created.

            Any ideas for a fix or work around?

            Thanks in advance,

            Jennifer Hardesty

            Systems Interface Specialist

            Maine Medical Center

            hardej@mmc.org

          • #58186
            Charlie Bursell
            Participant

              Just use the math associated with the clock command

            • #58187
              Jennifer Hardesty
              Participant

                I’m not sure how to use the math with the clock command when “[clock scan $dob]” causes a tcl callout error when the dob is 01/01/1901.

                The error itself reads: ‘unable to convert date-time string “19010101”‘

                This functionality works fine with younger birthdates.

                Jennifer Hardesty

                Systems Interface Specialist

                Maine Medical Center

                hardej@mmc.org

              • #58188
                Jim Kosloskey
                Participant

                  Jennifer,

                  This might work.

                  In Unix (and maybe other Operating Systems as well) apparently Tcl will only calculate back to 12/31/1902.

                  For every year prior to 1902 I guess you could subtract 31536000 seconds from a clock scan of 01/01/1902 (which returns a negative number) to give you additional full years – or just subtract the dob year from the current year if the dob year is less than 1902.

                  Of course that is not sensitive to when in a year someone’s age turns over which might be an issue depending on how accurate this needs to be for folks over a hundred years old.

                  However, if this is truly a bogus date (that is 01/01/1901 ALWAYS represents a bogus date), then I would test for that date and report the age with something that catches the attention of the user to indicate a bogus date was used.

                  BUT – you really could have someone actually born on 01/01/1901 as a patient – what impact does that present?

                  Not much help but some thoughts.

                  Jim Kosloskey

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

                • #58189
                  Cesario Perez
                  Participant

                    Todays date: 20071029 – 19010101 (birth date)= A, then divide A by 10000 giving your age. Do not round your answer. Use the integer result with no decimal result.

                  • #58190
                    Charlie Bursell
                    Participant

                      I agree the date math functions go only back to 1902.  If you *REALLY* want to get into this take a look at this web page:

                      http://wiki.tcl.tk/3189.html

                      I think you will find that age calculation can be much more difficult than it appears at first.

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