'Disease import update detection
@param item: the import item'

@staticmethod
def disease_duplicate(item):

    data = item.data
    code = data.get('code')
    name = data.get('name')
    table = item.table
    queries = []
    if code:
        queries.append((table.code == code))
    if name:
        queries.append((table.name == name))
    if queries:
        query = reduce((lambda x, y: (x | y)), queries)
    else:
        return
    rows = current.db(query).select(table.id, table.code, table.name)
    duplicate = None
    for row in rows:
        if (code and (row.code == code)):
            duplicate = row.id
            break
        if (name and (row.name == name)):
            duplicate = row.id
    if duplicate:
        item.id = duplicate
        item.method = item.METHOD.UPDATE
    return
