Thanks for the help everyone.  I ended up with the following:

def OBweeks(ptID):
        qry = 'SELECT short_des FROM problems WHERE patient_ID = %s;' %
(ptID)
        results = EMR_utilities.getAllData(qry)
        for items in results:
            r = re.search('\d\d\d\d-\d\d-\d\d', str(items))
            if r:
                edc = datetime.date(*map(int, r.group().split('-')))
                pregnancy = datetime.timedelta(weeks=-40)
                conception = edc + pregnancy
                howfar = datetime.date.today() - conception
                weeks, days = divmod(howfar.days, 7)
                return '%s %s/7 weeks' % (weeks, days)
            else: pass

Mike
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to