@classmethod
    def case_create_onvalidation(cls, form):
        """
            Make sure that there's only one case per person and disease
        """

        formvars = form.vars
        try:
            case_id = formvars.id
            person_id = formvars.person_id
        except AttributeError, e:
            return

        if "disease_id" not in formvars:
            disease_id = current.s3db.disease_case.disease_id.default
        else:
            disease_id = formvars.disease_id

        record = cls.get_case(person_id, disease_id)
        if record and record.id != case_id:
            error = current.T("This case is already registered")
            link = A(record.case_number,
                     _href=URL(f="case", args=[record.id]))
            form.errors.person_id = XML("%s: %s" % (error, link))
        return

    # -------------------------------------------------------------------------
dataset/ETHPy150Open sahana/eden/modules/s3db/disease.py/CaseTrackingModel.case_create_onvalidation/original