def model(self):

        T = current.T
        db = current.db

        crud_strings = current.response.s3.crud_strings
        define_table = self.define_table

        case_id = self.disease_case_id

        # =====================================================================
        # Tracing Information: when/where did a case pose risk for exposure?
        #

        # Processing Status
        contact_tracing_status = {
            "OPEN": T("Open"),         # not all contacts identified yet
            "COMPLETE": T("Complete"), # all contacts identified, closed
        }

        tablename = "disease_tracing"
        define_table(tablename,
                     case_id(),
                     s3_datetime("start_date",
                                 label = T("From"),
                                 set_min="#disease_tracing_end_date",
                                 ),
                     s3_datetime("end_date",
                                 label = T("To"),
                                 set_max="#disease_tracing_start_date",
                                 ),
                     # @todo: add site_id?
                     self.gis_location_id(),
                     Field("circumstances", "text",
                           ),
                     Field("status",
                           default = "OPEN",
                           label = T("Tracing Status"),
                           requires = IS_IN_SET(contact_tracing_status, zero=None),
                           represent = S3Represent(options=contact_tracing_status),
                           ),
                     s3_comments(),
                     *s3_meta_fields())

        # @todo: implement specific S3Represent class
        represent = S3Represent(lookup=tablename, fields=["case_id"])
        tracing_id = S3ReusableField("tracing_id", "reference %s" % tablename,
                                     label = T("Tracing Record"),
                                     represent = represent,
                                     requires = IS_EMPTY_OR(
                                                    IS_ONE_OF(db, "disease_tracing.id",
                                                              represent,
                                                              )),
                                     sortby = "date",
                                     comment = S3PopupLink(f = "tracing",
                                                           tooltip = T("Add a new contact tracing information"),
                                                           ),
                                     )

        self.add_components(tablename,
                            disease_exposure = "tracing_id",
                            )

        # CRUD strings
        crud_strings[tablename] = Storage(
            label_create = T("Add Tracing Record"),
            title_display = T("Tracing Details"),
            title_list = T("Contact Tracings"),
            title_update = T("Edit Tracing Information"),
            title_upload = T("Import Tracing Information"),
            label_list_button = T("List Tracing Record"),
            label_delete_button = T("Delete Tracing Record"),
            msg_record_created = T("Tracing Record added"),
            msg_record_modified = T("Tracing Record updated"),
            msg_record_deleted = T("Tracing Record deleted"),
            msg_list_empty = T("No Contact Tracings currently registered"))

        # =====================================================================
        # Protection
        #
        protection_level = {"NONE": T("Unknown"),
                            "PARTIAL": T("Partial"),
                            "FULL": T("Full"),
                            }
        protection_level_represent = S3Represent(options = protection_level)

        # =====================================================================
        # Exposure Type
        #
        exposure_type = {"UNKNOWN": T("Unknown"),
                         "DIRECT": T("Direct"),
                         "INDIRECT": T("Indirect"),
                         }
        exposure_type_represent = S3Represent(options = exposure_type)

        # =====================================================================
        # Exposure Risk Level
        #
        exposure_risk = {"UNKNOWN": T("Unknown"),
                         "NONE": T("No known exposure"),
                         "LOW": T("Low risk exposure"),
                         "HIGH": T("High risk exposure"),
                         }
        exposure_risk_represent = S3Represent(options = exposure_risk)

        # =====================================================================
        # Exposure: when and how was a person exposed to the disease?
        #
        tablename = "disease_exposure"
        define_table(tablename,
                     case_id(),
                     tracing_id(),
                     self.pr_person_id(requires = IS_ADD_PERSON_WIDGET2(),
                                       widget = S3AddPersonWidget2(controller="pr"),
                                       ),
                     s3_datetime(),
                     #self.gis_location_id(),
                     Field("exposure_type",
                           default = "UNKNOWN",
                           represent = exposure_type_represent,
                           requires = IS_IN_SET(exposure_type, zero=None),
                           ),
                     Field("protection_level",
                           default = "NONE",
                           represent = protection_level_represent,
                           requires = IS_IN_SET(protection_level, zero=None),
                           ),
                     Field("exposure_risk",
                           default = "LOW",
                           represent = exposure_risk_represent,
                           requires = IS_IN_SET(exposure_risk, zero=None),
                           ),
                     Field("circumstances", "text"),
                     *s3_meta_fields())

        self.configure(tablename,
                       onaccept = self.exposure_onaccept,
                       )

        crud_strings[tablename] = Storage(
            label_create = T("Add Exposure Information"),
            title_display = T("Exposure Details"),
            title_list = T("Exposure Information"),
            title_update = T("Edit Exposure Information"),
            title_upload = T("Import Exposure Information"),
            label_list_button = T("List Exposures"),
            label_delete_button = T("Delete Exposure Information"),
            msg_record_created = T("Exposure Information added"),
            msg_record_modified = T("Exposure Information updated"),
            msg_record_deleted = T("Exposure Information deleted"),
            msg_list_empty = T("No Exposure Information currently registered"))

        # Pass names back to global scope (s3.*)
        return {}

    # -------------------------------------------------------------------------
dataset/ETHPy150Open sahana/eden/modules/s3db/disease.py/ContactTracingModel.model/original