Calculation Patient’s Age

Clovertech Forums Cloverleaf Calculation Patient’s Age

  • Creator
    Topic
  • #118538
    Mike Itani
    Participant

      Hello Folks,

      I have an application that wants me to look at  DOB (PID-7) if it is less than 18 years old (minor) I need to set a flag in the message.

      I have an Xlate in between and can use TCL.

       

      Thoughts on the leanest way to slide it in the Xlate

       

      Thank you

    Viewing 2 reply threads
    • Author
      Replies
      • #118539
        James Nelson
        Participant

          This is how I’ve done it in the past.  It may not be THE leanest way, but it’s pretty lean and works.
          <pre>set DOB CCYYMMDD ;# Set DOB to the date of birth from the message
          if {[clock scan “today -18 years”] < [clock scan $DOB -format “%Y%m%d”] {
          # put your actions here
          }</pre>
           

        • #118540
          Keith McLeod
          Participant

            Can you use something like

            if {[expr ([clock scan today] – [clock scan “YYYYmmdd 000000”])/86400/365] < 18} {

            set flag here

            }

          • #118543
            Paul Bishop
            Participant

              I’ve done it were I calculate the date n number of years ago (11 years in my example) and then just compare the DOB in the message to that calculated date to set a flag.

              input is the PID-7 field, output is a variable used as a flag (@underage_flag in my case)

              lassign $xlateInVals dob_date
              # get yr, m and day only
              set temp_date [string range $dob_date 0 7]
              # todays date minus 11 years
              set todays_date [clock format [clock scan ” – 11 years”] -format “%Y%m%d”]
              # compare dates – if birthdate less than calculated todays date, use patient
              if {$dob_date < $todays_date} {
              set out_flag N
              } else {
              set out_flag Y
              }
              set xlateOutVals

                Paul Bishop
                Carle Foundation Hospital
                Urbana, IL

            Viewing 2 reply threads
            • You must be logged in to reply to this topic.