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

@staticmethod
def case_duplicate(item):

    data = item.data
    case_number = data.get('case_number')
    person_id = data.get('person_id')
    table = item.table
    if case_number:
        query = ((table.case_number == case_number) & (table.deleted != True))
    else:
        disease_id = data.get('disease_id')
        if (person_id and disease_id):
            query = (((table.disease_id == disease_id) & (table.person_id == person_id)) & (table.deleted != True))
        else:
            return
    duplicate = current.db(query).select(table.id, table.person_id, limitby=(0, 1)).first()
    if duplicate:
        item.data.person_id = duplicate.person_id
        item.id = duplicate.id
        item.method = item.METHOD.UPDATE
    return
