def model(self):

        # @todo: add treatment component?

        T = current.T
        db = current.db

        crud_strings = current.response.s3.crud_strings

        define_table = self.define_table
        configure = self.configure
        add_components = self.add_components

        person_id = self.pr_person_id

        # =====================================================================
        # Diagnosis Status
        #
        diagnosis_status = {"UNKNOWN": T("Unknown"),
                            "RISK": T("At Risk"),
                            "PROBABLE": T("Probable"),
                            "CONFIRMED-POS": T("Confirmed Positive"),
                            "CONFIRMED-NEG": T("Confirmed Negative"),
                            }
        diagnosis_status_represent = S3Represent(options = diagnosis_status)

        # =====================================================================
        # Monitoring Levels
        #
        monitoring_levels = {"NONE": T("No Monitoring"),
                             # Clinical observation required:
                             "OBSERVATION": T("Observation"),
                             # Targeted diagnostics required:
                             "DIAGNOSTICS": T("Diagnostics"),
                             # Quarantine required:
                             "QUARANTINE": T("Quarantine"),
                             # Follow-up after recovery:
                             "FOLLOW-UP": T("Post-Recovery Follow-Up"),
                             }
        monitoring_level_represent = S3Represent(options = monitoring_levels)
        # =====================================================================
        # Illness status
        #
        illness_status = {"UNKNOWN": T("Unknown, Not Checked"),
                          "ASYMPTOMATIC": T("Asymptomatic, Clinical Signs Negative"),
                          "SYMPTOMATIC": T("Symptomatic, Clinical Signs Positive"),
                          "SEVERE": T("Severely Ill, Clinical Signs Positive"),
                          "DECEASED": T("Deceased, Clinical Signs Positive"),
                          "RECOVERED": T("Recovered"),
                          }
        illness_status_represent = S3Represent(options = illness_status)

        # =====================================================================
        # Case
        #
        tablename = "disease_case"
        define_table(tablename,
                     Field("case_number", length=64,
                           requires = IS_EMPTY_OR(
                                        IS_NOT_IN_DB(db, "disease_case.case_number")),
                           ),
                     person_id(empty = False,
                               ondelete = "CASCADE",
                               ),
                     self.disease_disease_id(),
                     #s3_date(), # date registered == created_on?
                     self.gis_location_id(),
                     # @todo: add site ID for registering site?

                     # Current illness status and symptom debut
                     Field("illness_status",
                           label = T("Current Illness Status"),
                           represent = illness_status_represent,
                           requires = IS_IN_SET(illness_status),
                           default = "UNKNOWN",
                           ),
                     s3_date("symptom_debut",
                             label = T("Symptom Debut"),
                             ),

                     # Current diagnosis status and date of last status update
                     Field("diagnosis_status",
                           label = T("Diagnosis Status"),
                           represent = diagnosis_status_represent,
                           requires = IS_IN_SET(diagnosis_status),
                           default = "UNKNOWN",
                           ),
                     s3_date("diagnosis_date",
                             default = "now",
                             label = T("Diagnosis Date"),
                             ),

                     # Current monitoring level and end date
                     Field("monitoring_level",
                           label = T("Current Monitoring Level"),
                           represent = monitoring_level_represent,
                           requires = IS_IN_SET(monitoring_levels),
                           default = "NONE",
                           ),
                     s3_date("monitoring_until",
                             label = T("Monitoring required until"),
                             ),
                     *s3_meta_fields())

        # Reusable Field
        represent = disease_CaseRepresent()
        case_id = S3ReusableField("case_id", tablename % "reference %s",
                                  label = T("Case"),
                                  represent = represent,
                                  requires = IS_ONE_OF(db, "disease_case.id",
                                                       represent,
                                                       ),
                                  comment = S3PopupLink(f = "case",
                                                        tooltip = T("Add a new case"),
                                                        ),
                                  )

        # Components
        add_components(tablename,
                       disease_case_monitoring = "case_id",
                       disease_case_diagnostics = "case_id",
                       disease_tracing = "case_id",
                       disease_exposure = ({"name": "exposure",
                                            "joinby": "person_id",
                                            "pkey": "person_id",
                                            },
                                            {"name": "contact",
                                             "joinby": "case_id",
                                             },
                                            ),
                       )

        report_fields = ["disease_id",
                         "location_id",
                         "illness_status",
                         "monitoring_level",
                         "diagnosis_status",
                         ]
        report_options = {"rows": report_fields,
                          "cols": report_fields,
                          "fact": [(T("Number of Cases"), "count(id)"),
                                   ],
                          "defaults": {"rows": "location_id",
                                       "cols": "diagnosis_status",
                                       "fact": "count(id)",
                                       "totals": True,
                                       },
                          }

        filter_widgets = [S3TextFilter(["case_number",
                                        "person_id$first_name",
                                        "person_id$middle_name",
                                        "person_id$last_name",
                                        ],
                                        label = T("Search"),
                                        comment = T("Enter Case Number or Name"),
                                        ),
                          S3OptionsFilter("monitoring_level",
                                          options = monitoring_levels,
                                          ),
                          S3OptionsFilter("diagnosis_status",
                                          options = diagnosis_status,
                                          ),
                          S3LocationFilter("location_id",
                                           ),
                          ]

        configure(tablename,
                  create_onvalidation = self.case_create_onvalidation,
                  deduplicate = self.case_duplicate,
                  delete_next = URL(f="case", args=["summary"]),
                  filter_widgets = filter_widgets,
                  onaccept = self.case_onaccept,
                  report_options = report_options,
                  )

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

        # =====================================================================
        # Monitoring
        #
        tablename = "disease_case_monitoring"
        define_table(tablename,
                     case_id(),
                     s3_datetime(default="now"),
                     Field("illness_status",
                           represent = illness_status_represent,
                           requires = IS_IN_SET(illness_status),
                           ),
                     s3_comments(),
                     *s3_meta_fields())

        # Reusable Field
        represent = S3Represent(lookup=tablename, fields=["case_id"])
        status_id = S3ReusableField("status_id", "reference %s" % tablename,
                                    label = T("Case"),
                                    represent = represent,
                                    requires = IS_ONE_OF(db, "disease_case.id",
                                                         represent,
                                                         ),
                                    comment = S3PopupLink(f = "case",
                                                          tooltip = T("Add a new case"),
                                                          ),
                                    )

        # Components
        add_components(tablename,
                       disease_symptom = {"link": "disease_case_monitoring_symptom",
                                          "joinby": "status_id",
                                          "key": "symptom_id",
                                          }
                       )

        # Custom CRUD form
        crud_fields = ["case_id",
                       "date",
                       "illness_status",
                       S3SQLInlineLink("symptom",
                                       field = "symptom_id",
                                       label = T("Symptoms"),
                                       multiple = True,
                                       ),
                       "comments",
                       ]

        configure(tablename,
                  crud_form = S3SQLCustomForm(*crud_fields),
                  list_fields = ["date",
                                 "illness_status",
                                 (T("Symptoms"), "symptom.name"),
                                 "comments",
                                 ],
                  onaccept = self.monitoring_onaccept,
                  )

        # CRUD strings
        crud_strings[tablename] = Storage(
            label_create = T("Add Monitoring Update"),
            title_display = T("Monitoring Update"),
            title_list = T("Monitoring Updates"),
            title_update = T("Edit Monitoring Update"),
            title_upload = T("Import Monitoring Updates"),
            label_list_button = T("List Monitoring Updates"),
            label_delete_button = T("Delete Monitoring Update"),
            msg_record_created = T("Monitoring Update added"),
            msg_record_modified = T("Monitoring Update updated"),
            msg_record_deleted = T("Monitoring Update deleted"),
            msg_list_empty = T("No Monitoring Information currently available"))

        # =====================================================================
        # Monitoring <=> Symptom
        #
        tablename = "disease_case_monitoring_symptom"
        define_table(tablename,
                     Field("status_id", "reference disease_case_monitoring",
                           requires = IS_ONE_OF(db, "disease_case_monitoring.id"),
                           ),
                     self.disease_symptom_id(),
                     *s3_meta_fields())

        # =====================================================================
        # Diagnostics
        #
        probe_status = {"PENDING": T("Pending"),
                        "PROCESSED": T("Processed"),
                        "VALIDATED": T("Validated"),
                        "INVALID": T("Invalid"),
                        "LOST": T("Lost"),
                        }
        tablename = "disease_case_diagnostics"
        define_table(tablename,
                     case_id(),
                     # @todo: make a lookup table in DiseaseDataModel:
                     Field("probe_type"),
                     Field("probe_number", length = 64, unique = True,
                           ),
                     s3_date("probe_date",
                             default = "now",
                             label = T("Probe Date"),
                             ),
                     Field("probe_status",
                           represent = S3Represent(options = probe_status),
                           requires = IS_IN_SET(probe_status),
                           default = "PENDING",
                           ),
                     # @todo: make a lookup table in DiseaseDataModel:
                     Field("test_type"),
                     Field("result"),
                     s3_date("result_date",
                             label = T("Result Date"),
                             ),
                     Field("conclusion",
                           represent = diagnosis_status_represent,
                           requires = IS_EMPTY_OR(
                                        IS_IN_SET(diagnosis_status)),
                           ),
                     s3_comments(),
                     *s3_meta_fields())

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

        # =====================================================================

        # Pass names back to global scope (s3.*)
        return dict(disease_case_id = case_id)

    # -------------------------------------------------------------------------
dataset/ETHPy150Open sahana/eden/modules/s3db/disease.py/CaseTrackingModel.model/swapped operands of `%`