Skip to main content

SARS-COV-2 related models, etc

Project description

Add to an EDC

In this example we add the new model to the meta_subject app of the meta_edc project.

Add sarscov2 to your settings INSTALLED_APPS

INSTALLED_APPS = [
    ...
    "sarscov2.apps.AppConfig",
    ...
]

Use the model mixin to create the model in your app

from edc_crf.model_mixins import CrfModelMixin
from edc_model import models as edc_models

from sarscov2.model_mixins import CoronaKapModelMixin


class CoronaKap(CrfModelMixin, CoronaKapModelMixin, edc_models.BaseUuidModel):
    class Meta:
        verbose_name = "Corona Knowledge, Attitudes, and Practices"
        verbose_name_plural = "Corona Knowledge, Attitudes, and Practices"

Create a form using the CoronaKapFormValidator

from django import forms
from edc_crf.modelform_mixins import CrfModelFormMixin
from sarscov2.forms import CoronaKapFormValidator

from ..models import CoronaKap


class CoronaKapForm(CrfModelFormMixin, forms.ModelForm):

    form_validator_cls = CoronaKapFormValidator

    class Meta:
        model = CoronaKap
        fields = "__all__"

Create an admin class with your new model and form. In this case the new model is a CRF model.

from django.contrib import admin
from edc_form_label import FormLabelModelAdminMixin
from edc_model_admin import SimpleHistoryAdmin
from sarscov2.admin import CoronaKapModelAdminMixin

from ..admin_site import meta_subject_admin
from ..forms import CoronaKapForm
from ..models import CoronaKap
from .modeladmin import CrfModelAdminMixin


@admin.register(CoronaKap, site=meta_subject_admin)
class CoronaKapAdmin(
    CrfModelAdminMixin,
    CoronaKapModelAdminMixin,
    FormLabelModelAdminMixin,
    SimpleHistoryAdmin,
):
    form = CoronaKapForm

Add the model to your auth codenames. For example, to the clinic group of meta_subject we added

# clinic group of codenames
# ...
"meta_subject.add_coronakap",
"meta_subject.change_coronakap",
"meta_subject.delete_coronakap",
"meta_subject.view_coronakap",
"meta_subject.view_historicalcoronakap",
"sarscov2.view_coronakapinformationsources",
# ...
# auditor group of codenames
# ...
"meta_subject.view_coronakap",
"meta_subject.view_historicalcoronakap",
# ...

Add the CRF to the visit schedule

Since the model is being added after the trial started, we add it to both the DAY1 visit CRFs and the PRN CRFs.

crfs_prn = FormsCollection(
    ...
    Crf(show_order=70, model="meta_subject.coronakap"),
    name="prn",
)

crfs_d1 = FormsCollection(
    ...
    Crf(show_order=70, model="meta_subject.coronakap"),
    name="day1",
)

If you are using the list model, add to urls

from sarscov2.admin_site import sarscov2_admin

...
path("admin/", sarscov2_admin.urls),
path("sarscov2/", include("sarscov2.urls")),
...

run makemigrations and migrate.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

sarscov2-0.1.4-py3-none-any.whl (26.8 kB view details)

Uploaded Python 3

File details

Details for the file sarscov2-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: sarscov2-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 26.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

File hashes

Hashes for sarscov2-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 30de5ddbb30f5448dea1c4cb195554e0fd885d13a70faf57774d63bf35fc6f53
MD5 b15646ac9ca850fac55d019374b50bb7
BLAKE2b-256 3bbe2b014bd092da06d71a8bf6d02b5b3e9c5f7516383799299ad38fc40d6372

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page