def addFollowupInfo(allClinDict):

    print " "
    print " in addFollowupInfo ... "

    # ------------------------------------------------------------------------
    # FIRST: if there is a days_to_last_known_alive, then check that it is
    # used consistently, otherwise create it

    zKey = findProperKey (allClinDict, "bcr_patient_barcode")
    aKey = findProperKey (allClinDict, "days_to_last_known_alive")
    bKey = findProperKey (allClinDict, "days_to_last_followup")
    cKey = findProperKey (allClinDict, "days_to_death")

    haveA = (aKey in allClinDict.keys())
    haveB = (bKey in allClinDict.keys())
    haveC = (cKey in allClinDict.keys())

    print " "
    print " STEP #1 "
    print " have flags A, B, and C : ", haveA, haveB, haveC

    ## print " allClinDict.keys() : "
    ## print allClinDict.keys()

    if (haveA):

        # if we have the "days_to_last_known_alive" field, check that it
        # is consistent with the other two fields ...
        numClin = getNumPatients(allClinDict)
        numNotNA = 0
        for kk in range(numClin):

            ## if we have a 'days_to_death' field and it is not NA, then set 'days_to_last_known_alive' to that value
            if (haveC):
                if (str(allClinDict[cKey][kk]).upper() != "NA"):
                    allClinDict[aKey][kk] = allClinDict[cKey][kk]

            ## if we have a 'days_to_last_followup' field and it is not NA, then ...
            if (haveB):
                if (str(allClinDict[bKey][kk]).upper() != "NA"):
                    if (str(allClinDict[aKey][kk]).upper() == "NA"):
                        allClinDict[aKey][kk] = allClinDict[bKey][kk]

            if (str(allClinDict[aKey][kk]).upper() != "NA"):
                numNotNA += 1

        print " UPDATED days_to_last_known_alive (%d) : " % numNotNA
        print allClinDict[aKey]

    else:

        # create it ...
        if ( aKey == "NO KEY" ): aKey = "N:CLIN:days_to_last_known_alive:::::"
        numClin = getNumPatients(allClinDict)

        newVec = [0] * numClin
        numNotNA = 0

        for kk in range(numClin):
            newVec[kk] = "NA"

            if (haveC):
                if (str(allClinDict[cKey][kk]).upper() != "NA"):
                    newVec[kk] = allClinDict[cKey][kk]

            if (haveB):
                if (str(allClinDict[bKey][kk]).upper() != "NA"):
                    if (str(newVec[kk]).upper() == "NA"):
                        newVec[kk] = allClinDict[bKey][kk]

            if (str(newVec[kk]).upper() != "NA"):
                numNotNA += 1

        print " NEW days_to_last_known_alive (%d) : " % numNotNA
        ## print newVec
        allClinDict[aKey] = newVec

    # ------------------------------------------------------------------------
    # SECOND: if there is a "days_to_submitted_specimen_dx", then create
    # a set of "days_to_" features that instead of being relative
    # to "initial_pathologic_diagnosis" are relative to "submitted_specimen"

    print " "
    print " STEP #2 "
    aKey = findProperKey (allClinDict, "days_to_submitted_specimen_dx")
    tKey = findProperKey (allClinDict, "days_to_initial_pathologic_diagnosis")

    if (aKey in allClinDict.keys()):
        haveA = 1
    else:
        print " do not have [days_to_submitted_specimen_dx] in allClinDict " 
        haveA = 0

    if (tKey in allClinDict.keys()):
        haveT = 1
    else:
        print " do not have [days_to_initial_pathologic_diagnosis] in allClinDict "
        haveT = 0

    try:
        numClin = getNumPatients(allClinDict)
        for bKey in allClinDict.keys():
            if (haveA == 0): continue
            if (bKey == aKey): continue

            if (bKey.find("days_to_") >= 0):
                newKey = addTag2Key ( bKey, "relSS" )
                print " --> making newKey <%s> from bKey <%s> [%d] " % (newKey, bKey, numClin)
                newVec = [0] * numClin
                numNotNA = 0
                for kk in range(numClin):

                    ## initialize to NA
                    newVec[kk] = "NA"

                    ## skip if an important value is NA
                    if (str(allClinDict[aKey][kk]).upper() == "NA"): continue
                    if (str(allClinDict[bKey][kk]).upper() == "NA"): continue
                    if (haveT):
                        if (str(allClinDict[tKey][kk]).upper() == "NA"): continue

                    ## deltaDays is either (days_to_submitted_specimen_dx) - (days_to_initial_pathologic_diagnosis)
                    ##             or just (days_to_submitted_specimen_dx)
                    if (haveT): 
                        deltaDays = allClinDict[aKey][kk] - allClinDict[tKey][kk]
                    else:
                        deltaDays = allClinDict[aKey][kk]

                    ## and then we subtract 'delta days' from the original key to make the new relative key
                    newVec[kk] = allClinDict[bKey][kk] - deltaDays

                    print " STEP2a ", kk, allClinDict[zKey][kk], allClinDict[bKey][kk], allClinDict[aKey][kk], deltaDays, newVec[kk]

                    numNotNA += 1

                if ( numNotNA > 30 ):
                    print " adding new key (%d) : " % numNotNA, newKey
                    ## print newVec[:5]
                    ## print newVec[-5:]
                    allClinDict[newKey] = newVec
                else:
                    print " NOT adding new key (%d) : ", numNotNA, newKey

            if (bKey.find("age_at_") >= 0):
                ## make sure that this is not a "stage_at_" feature !!!
                if ( bKey.find("stage_at_") >= 0 ): continue

                newKey = addTag2Key ( bKey, "relSS" )
                print " --> making newKey <%s> from bKey <%s> [%d] " % (newKey, bKey, numClin)
                newVec = [0] * numClin
                numNotNA = 0
                for kk in range(numClin):

                    ## initialize to NA
                    newVec[kk] = "NA"

                    ## skip if an important value is NA
                    if (str(allClinDict[aKey][kk]).upper() == "NA"): continue
                    if (str(allClinDict[bKey][kk]).upper() == "NA"): continue
                    if (haveT):
                        if (str(allClinDict[tKey][kk]).upper() == "NA"): continue

                    ## deltaDays is either (days_to_submitted_specimen_dx) - (days_to_initial_pathologic_diagnosis)
                    ##             or just (days_to_submitted_specimen_dx)
                    if (haveT): 
                        deltaDays = allClinDict[aKey][kk] - allClinDict[tKey][kk]
                    else:
                        deltaDays = allClinDict[aKey][kk]

                    ## and then we subtract 'delta days' from the original key to make the new relative key
                    ## 04mar14 : actually we need to ADD here because "age" should go UP with deltaDays ...
                    newVec[kk] = allClinDict[bKey][kk] + ( float(deltaDays) / DAYS_PER_YEAR )

                    print " STEP2b ", kk, allClinDict[zKey][kk], allClinDict[bKey][kk], allClinDict[aKey][kk], deltaDays, newVec[kk]

                    numNotNA += 1

                if ( numNotNA > 30 ):
                    print " adding new key (%d) : " % numNotNA, newKey
                    ## print newVec[:5]
                    ## print newVec[-5:]
                    allClinDict[newKey] = newVec
                else:
                    print " NOT adding new key (%d) : ", numNotNA, newKey

    except:
        print " --> failed in this try (x) "
        doNothing = 1

    # ------------------------------------------------------------------------
    # THIRD: if there is a "days_to_sample_procurement", then create
    # a set of "days_to_" features that instead of being relative
    # to "initial_pathologic_diagnosis" are relative to "sample_procurement

    print " "
    print " STEP #3 "
    aKey = findProperKey (allClinDict, "days_to_sample_procurement")
    tKey = findProperKey (allClinDict, "days_to_initial_pathologic_diagnosis")

    if (aKey in allClinDict.keys()):
        haveA = 1
    else:
        print " do not have [days_to_sample_procurement] in allClinDict " 
        haveA = 0

    if (tKey in allClinDict.keys()):
        haveT = 1
    else:
        haveT = 0
        print " do not have a [days_to_initial_pathologic_diagnosis] key "

    try:
        numClin = getNumPatients(allClinDict)
        for bKey in allClinDict.keys():
            if (haveA == 0): continue
            if (bKey == aKey): continue

            if (bKey.find("days_to_") >= 0):
                ## make sure that this is not one of the relSS features just added !!!
                if ( bKey.find("relSS") >= 0 ): continue

                newKey = addTag2Key ( bKey, "relSP" )
                print " --> making newKey <%s> from bKey <%s> [%d] " % (newKey, bKey, numClin)
                newVec = [0] * numClin
                numNotNA = 0
                for kk in range(numClin):

                    ## initialize to NA
                    newVec[kk] = "NA"

                    ## skip if an important value is NA
                    if (str(allClinDict[aKey][kk]).upper() == "NA"): continue
                    if (str(allClinDict[bKey][kk]).upper() == "NA"): continue
                    if (haveT):
                        if (str(allClinDict[tKey][kk]).upper() == "NA"): continue

                    ## deltaDays is either (days_to_sample_procurement) - (days_to_initial_pathologic_diagnosis)
                    ##             or just (days_to_sample_procurement)
                    if (haveT): 
                        deltaDays = allClinDict[aKey][kk] - allClinDict[tKey][kk]
                    else:
                        deltaDays = allClinDict[aKey][kk]

                    ## and then we subtract 'delta days' from the original key to make the new relative key
                    newVec[kk] = allClinDict[bKey][kk] - deltaDays

                    print " STEP3a ", kk, allClinDict[zKey][kk], allClinDict[bKey][kk], allClinDict[aKey][kk], deltaDays, newVec[kk]

                    numNotNA += 1

                if ( numNotNA > 30 ):
                    print " adding new key (%d) : " % numNotNA, newKey
                    ## print newVec[:5]
                    ## print newVec[-5:]
                    allClinDict[newKey] = newVec
                else:
                    print " NOT adding new key (%d) : ", numNotNA, newKey

            if (bKey.find("age_at_") >= 0):
                ## make sure that this is not one of the relSS features just added !!!
                if ( bKey.find("relSS") >= 0 ): continue
                ## make sure that this is not a "stage_at_" feature !!!
                if ( bKey.find("stage_at_") >= 0 ): continue

                newKey = addTag2Key ( bKey, "relSP" )
                print " --> making newKey <%s> from bKey <%s> [%d] " % (newKey, bKey, numClin)
                newVec = [0] * numClin
                numNotNA = 0
                for kk in range(numClin):

                    ## initialize to NA
                    newVec[kk] = "NA"

                    ## skip if an important value is NA
                    print " checking for important information ... ", aKey, bKey, tKey
                    print allClinDict[aKey][kk]
                    print allClinDict[bKey][kk]
                    if (str(allClinDict[aKey][kk]).upper() == "NA"): continue
                    if (str(allClinDict[bKey][kk]).upper() == "NA"): continue
                    if (haveT): 
                        print allClinDict[tKey][kk]
                        if (str(allClinDict[tKey][kk]).upper() == "NA"): continue

                    ## deltaDays is either (days_to_sample_procurement) - (days_to_initial_pathologic_diagnosis)
                    ##             or just (days_to_sample_procurement)
                    if (haveT): 
                        deltaDays = allClinDict[aKey][kk] - allClinDict[tKey][kk]
                    else:
                        deltaDays = allClinDict[aKey][kk]
                    print " computed deltaDays : ", deltaDays

                    ## and then we subtract 'delta days', scaled to years ...
                    ## 03mar14 : actually we need to ADD here ...
                    newVec[kk] = allClinDict[bKey][kk] + ( float(deltaDays) / DAYS_PER_YEAR )

                    print " STEP3b ", kk, allClinDict[zKey][kk], allClinDict[bKey][kk], allClinDict[aKey][kk], deltaDays, newVec[kk]

                    numNotNA += 1

                if ( numNotNA > 30 ):
                    print " adding new key (%d) : " % numNotNA, newKey
                    ## print newVec[:5]
                    ## print newVec[-5:]
                    allClinDict[newKey] = newVec
                else:
                    print " NOT adding new key (%d) : ", numNotNA, newKey

    except:
        print " --> failed in this try (y) "
        doNothing = 1


    return (allClinDict)