def findProperKey(allClinDict, aString):

    keyList = allClinDict.keys()
    foundList = []

    for aKey in keyList:
        if ( aKey.lower().find(aString.lower()) >=0 ):
            foundList += [ aKey ]

    if ( len(foundList) == 0 ):
        return ( "NO KEY" )
    elif ( len(foundList) == 1 ):
        return ( foundList[0] )
    else:

        ## look for a perfect match ...
        for mString in foundList:
            mTokens = mString.split(':')
            if ( len(mTokens) == 1 ):
                if ( mTokens[0].lower() == aString.lower() ):
                    return ( mString )
            elif ( len(mTokens) > 2 ):
                try:
                    if ( mTokens[2].lower() == aString.lower() ):
                        return ( mString )
                except:
                    print " findProperKey: ERROR in try ??? ", mString
                    print foundList

        print " "
        print " ERROR in findProperKey ??? multiple matches "
        print " but none of them are perfect matches ... "
        print aString
        print foundList
        print " "
        sys.exit(-1)