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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file sarscov2-0.1.8-py3-none-any.whl
.
File metadata
- Download URL: sarscov2-0.1.8-py3-none-any.whl
- Upload date:
- Size: 41.7 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a1dc3f3ca47242bfe7415a6d3d54654856b600fb65e651061e3c25cca1b5a6a |
|
MD5 | ef5ebef9996e1d718295f8eba2375fe9 |
|
BLAKE2b-256 | 234afe9fb92b3389a295cd457cff7ca9d61cefd7002246964faf5966e125d347 |