Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assessment values update #792

Merged
merged 16 commits into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions hawc/apps/assessment/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

from .permissions import AssessmentPermissions

ADAF_FOOTNOTE = (
"Age-dependent ajustment factors (ADAFs) have not been applied to the value shown. "
"Application of ADAFs is recommended in combination with appropriate exposure data when "
"assessing risk associated with early-life exposure. More information is available in the "
"comments field for this value."
)


class AssessmentViewPermissions(models.IntegerChoices):
PROJECT_MANAGER = 1
Expand Down
30 changes: 18 additions & 12 deletions hawc/apps/assessment/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
from hawc.apps.study.models import Study
from hawc.services.epa.dsstox import DssSubstance

from ..common.autocomplete import (
AutocompleteSelectMultipleWidget,
AutocompleteSelectWidget,
AutocompleteTextWidget,
)
from ..common.autocomplete import AutocompleteSelectMultipleWidget, AutocompleteTextWidget
from ..common.forms import (
BaseFormHelper,
QuillField,
Expand All @@ -44,6 +40,10 @@ class AssessmentForm(forms.ModelForm):
class Meta:
exclude = (
"creator",
"noel_name",
"rob_name",
"vocabulary",
"modify_uncontrolled_vocabulary",
"enable_literature_review",
"enable_project_management",
"enable_data_extraction",
Expand Down Expand Up @@ -119,7 +119,6 @@ def helper(self):
helper.add_row("project_manager", 3, "col-md-4")
helper.add_row("editable", 3, "col-md-4")
helper.add_row("conflicts_of_interest", 2, "col-md-6")
helper.add_row("noel_name", 4, "col-md-3")
helper.add_create_btn("dtxsids", reverse("assessment:dtxsid_create"), "Add new DTXSID")
helper.attrs["novalidate"] = ""
return helper
Expand Down Expand Up @@ -190,6 +189,9 @@ class Meta:
"system": AutocompleteTextWidget(
autocomplete_class=autocomplete.AssessmentValueAutocomplete, field="system"
),
"species_studied": AutocompleteTextWidget(
autocomplete_class=autocomplete.AssessmentValueAutocomplete, field="species_studied"
),
"duration": AutocompleteTextWidget(
autocomplete_class=autocomplete.AssessmentValueAutocomplete, field="duration"
),
Expand All @@ -209,9 +211,6 @@ class Meta:
"pod_unit": AutocompleteTextWidget(
autocomplete_class=autocomplete.AssessmentValueAutocomplete, field="pod_unit"
),
"species_studied": AutocompleteSelectWidget(
autocomplete_class=autocomplete.SpeciesAutocomplete
),
"pod_type": AutocompleteTextWidget(
autocomplete_class=autocomplete.AssessmentValueAutocomplete, field="pod_type"
),
Expand Down Expand Up @@ -265,11 +264,11 @@ def helper(self):
cancel_url=self.instance.assessment.get_absolute_url(),
)
helper.add_row("evaluation_type", 2, "col-md-6")
helper.add_row("value_type", 3, "col-md-4")
helper.add_row("value_type", 4, "col-md-3")
helper.add_row("confidence", 3, "col-md-4")
helper.add_row("pod_type", 4, "col-md-3")
helper.add_row("species_studied", 3, "col-md-4")
helper.add_row("tumor_type", 4, "col-md-3")
helper.add_row("tumor_type", 2, "col-md-6")
helper.add_row("comments", 2, "col-md-6")

return helper
Expand Down Expand Up @@ -342,6 +341,9 @@ class Meta:
"enable_risk_of_bias",
"enable_bmd",
"enable_summary_text",
"noel_name",
"rob_name",
"vocabulary",
"epi_version",
)
model = models.Assessment
Expand All @@ -356,7 +358,7 @@ def __init__(self, *args, **kwargs):
def helper(self):
helper = BaseFormHelper(
self,
legend_text="Update enabled modules",
legend_text="Update modules",
help_text="""
HAWC is composed of multiple modules, each designed
to capture data and decisions related to specific components of a
Expand All @@ -367,6 +369,10 @@ def helper(self):
""",
cancel_url=self.instance.get_absolute_url(),
)
helper.add_row("enable_literature_review", 3, "col-lg-4")
helper.add_row("enable_risk_of_bias", 3, "col-lg-4")
helper.add_row("noel_name", 3, "col-lg-4")
helper.add_row("epi_version", 1, "col-lg-4")
return helper


Expand Down
4 changes: 2 additions & 2 deletions hawc/apps/assessment/migrations/0030_assessment_part1.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class Migration(migrations.Migration):
name="authors",
field=models.TextField(
default="",
verbose_name="Assessment authors",
verbose_name="Assessment authors/organization",
help_text="""A publicly visible description of the assessment authors (if the assessment is made public). This could be an organization, a group, or the individual scientists involved.""",
),
preserve_default=False,
Expand All @@ -149,7 +149,7 @@ class Migration(migrations.Migration):
model_name="assessment",
name="assessment_objective",
field=models.TextField(
help_text="Describe the assessment objective(s), research questions, or clarification on the purpose of the assessment."
help_text="Describe the assessment objective(s), research questions, and purpose of this HAWC assessment. If a related peer-reviewed paper or journal article is available describing this work, please add a citation and hyperlink.",
),
),
migrations.AddField(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class Migration(migrations.Migration):
field=models.PositiveSmallIntegerField(
choices=[(1, "v1"), (2, "v2")],
default=2,
help_text="Data extraction schema used for epidemiology studies",
verbose_name="Epidemiology schema version",
help_text="Data extraction schema version used for epidemiology studies",
),
),
migrations.RunPython(set_epi_version, RunPython.noop),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Migration(migrations.Migration):
(
"confidence",
models.CharField(
blank=True, help_text="Overall confidence for the value.", max_length=64
blank=True, help_text="Confidence in the toxicity value", max_length=64
),
),
(
Expand Down Expand Up @@ -163,15 +163,21 @@ class Migration(migrations.Migration):
verbose_name="Non-ADAF adjusted value",
),
),
("comments", models.TextField(blank=True)),
(
"comments",
models.TextField(
blank=True,
help_text="General comments related to the derivation of this value",
),
),
(
"extra",
models.JSONField(
blank=True,
default=dict,
help_text='Any additional custom attributes; A <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON">JSON</a> object where keys are strings and values are strings or numbers. For example, <code>{"My Custom Field Name": "The Custom Value", "Extra ID": 12345}</code>.',
help_text='Any additional custom fields; A <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON">JSON</a> object where keys are strings and values are strings or numbers. For example, <code>{"Player": "Michael Jordan", "Number": 23}</code>.',
validators=[hawc.apps.common.validators.FlatJSON.validate],
verbose_name="Additional attributes",
verbose_name="Additional fields",
),
),
("created", models.DateTimeField(auto_now_add=True)),
Expand Down Expand Up @@ -289,8 +295,8 @@ class Migration(migrations.Migration):
"report_id",
models.CharField(
blank=True,
help_text="A external report number or identifier, if any",
max_length=16,
help_text="A external report number or identifier (e.g., a DOI, publication number)",
max_length=64,
verbose_name="Report identifier",
),
),
Expand All @@ -308,9 +314,9 @@ class Migration(migrations.Migration):
models.JSONField(
blank=True,
default=dict,
help_text='Any additional custom attributes; A <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON">JSON</a> object where keys are strings and values are strings or numbers. For example, <code>{"My Custom Field Name": "The Custom Value", "Extra ID": 12345}</code>.',
help_text='Any additional custom fields; A <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON">JSON</a> object where keys are strings and values are strings or numbers. For example, <code>{"Player": "Michael Jordan", "Number": 23}</code>.',
validators=[hawc.apps.common.validators.FlatJSON.validate],
verbose_name="Additional attributes",
verbose_name="Additional fields",
),
),
("created", models.DateTimeField(auto_now_add=True)),
Expand Down
69 changes: 69 additions & 0 deletions hawc/apps/assessment/migrations/0035_update_assessmentvalue.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Generated by Django 3.2.18 on 2023-02-27 20:55


from django.db import migrations, models


def get_species_name(apps, schema_editor):
AssessmentValue = apps.get_model("assessment", "AssessmentValue")
Species = apps.get_model("assessment", "Species")
updates = []
for obj in AssessmentValue.objects.exclude(species_studied=""):
obj.species_studied = Species.objects.get(pk=int(obj.species_studied)).name
updates.append(obj)
if updates:
AssessmentValue.objects.bulk_update(updates, ["species_studied"])


class Migration(migrations.Migration):
dependencies = [
("assessment", "0034_assessmentdetail_assessmentvalue"),
]

operations = [
migrations.RemoveField(
model_name="assessmentvalue",
name="non_adaf_value",
),
migrations.AlterField(
model_name="assessmentvalue",
name="adaf",
field=models.BooleanField(
default=False,
help_text="When checked, the ADAF note will appear as a footnote for the value. Add supporting information about ADAF in the comments.",
verbose_name="Apply ADAF?",
),
),
migrations.AlterField(
model_name="assessmentvalue",
name="duration",
field=models.CharField(
blank=True,
help_text="Duration associated with the value (e.g., Chronic, Subchronic)",
max_length=128,
verbose_name="Value duration",
),
),
migrations.AlterField(
model_name="assessmentvalue",
name="species_studied",
field=models.TextField(
blank=True,
default="",
help_text="Provide information about the animal(s) studied, including species and strain information",
verbose_name="Species and strain",
),
preserve_default=False,
),
migrations.RunPython(get_species_name, migrations.RunPython.noop),
migrations.AlterField(
model_name="assessmentdetail",
name="report_id",
field=models.CharField(
blank=True,
help_text="A external report number or identifier (e.g., a DOI, publication number)",
max_length=128,
verbose_name="Report identifier",
),
),
]
49 changes: 24 additions & 25 deletions hawc/apps/assessment/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,10 @@ def get_rob_name_default():
""",
)
assessment_objective = models.TextField(
help_text="Describe the assessment objective(s), research questions, "
"or clarification on the purpose of the assessment.",
help_text="Describe the assessment objective(s), research questions, and purpose of this HAWC assessment. If a related peer-reviewed paper or journal article is available describing this work, please add a citation and hyperlink.",
)
authors = models.TextField(
verbose_name="Assessment authors",
verbose_name="Assessment authors/organization",
help_text="""A publicly visible description of the assessment authors (if the assessment is made public). This could be an organization, a group, or the individual scientists involved.""",
)
creator = models.ForeignKey(
Expand Down Expand Up @@ -274,7 +273,8 @@ def get_rob_name_default():
epi_version = models.PositiveSmallIntegerField(
choices=constants.EpiVersion.choices,
default=constants.EpiVersion.V2,
help_text="Data extraction schema used for epidemiology studies",
verbose_name="Epidemiology schema version",
help_text="Data extraction schema version used for epidemiology studies",
)
admin_notes = models.TextField(
blank=True,
Expand Down Expand Up @@ -525,10 +525,10 @@ class AssessmentDetail(models.Model):
validators=[validate_hyperlink],
)
report_id = models.CharField(
max_length=16,
max_length=128,
blank=True,
verbose_name="Report identifier",
help_text="A external report number or identifier, if any",
help_text="A external report number or identifier (e.g., a DOI, publication number)",
)
report_url = models.URLField(
blank=True,
Expand All @@ -540,8 +540,8 @@ class AssessmentDetail(models.Model):
default=dict,
validators=[FlatJSON.validate],
blank=True,
verbose_name="Additional attributes",
help_text="Any additional custom attributes; " + FlatJSON.HELP_TEXT,
verbose_name="Additional fields",
help_text="Any additional custom fields; " + FlatJSON.HELP_TEXT,
)
created = models.DateTimeField(auto_now_add=True)
last_updated = models.DateTimeField(auto_now=True)
Expand Down Expand Up @@ -580,15 +580,21 @@ class AssessmentValue(models.Model):
help_text="The derived value",
)
value_unit = models.CharField(verbose_name="Value units", max_length=32)
adaf = models.BooleanField(
verbose_name="Apply ADAF?",
default=False,
help_text="When checked, the ADAF note will appear as a footnote for the value. Add supporting information about ADAF in the comments.",
)
confidence = models.CharField(
max_length=64,
blank=True,
help_text="Overall confidence for the value.",
help_text="Confidence in the toxicity value",
)
duration = models.CharField(
max_length=128,
blank=True,
help_text="Duration of value",
verbose_name="Value duration",
help_text="Duration associated with the value (e.g., Chronic, Subchronic)",
)
basis = models.TextField(
blank=True,
Expand Down Expand Up @@ -619,8 +625,10 @@ class AssessmentValue(models.Model):
verbose_name="Uncertainty factor",
help_text="Composite uncertainty factor applied to POD to derive the final value",
)
species_studied = models.ForeignKey(
"assessment.Species", on_delete=models.SET_NULL, blank=True, null=True
species_studied = models.TextField(
blank=True,
verbose_name="Species and strain",
help_text="Provide information about the animal(s) studied, including species and strain information",
)
study = models.ForeignKey(
"study.Study",
Expand All @@ -645,24 +653,15 @@ class AssessmentValue(models.Model):
blank=True,
help_text="Describe the statistical method(s) used to derive the cancer toxicity values (e.g., Time-to-tumor dose-response model with linear extrapolation from the POD (BMDL10(HED)) associated with 10% extra cancer risk)",
)
adaf = models.BooleanField(
verbose_name="ADAF applied?",
default=False,
help_text="Has an Age Dependent Adjustment Factor (ADAF) been applied?",
)
non_adaf_value = models.FloatField(
verbose_name="Non-ADAF adjusted value",
blank=True,
null=True,
help_text="Value without ADAF adjustment (units the same as Value above)",
comments = models.TextField(
blank=True, help_text="General comments related to the derivation of this value"
)
comments = models.TextField(blank=True)
extra = models.JSONField(
default=dict,
blank=True,
validators=[FlatJSON.validate],
verbose_name="Additional attributes",
help_text="Any additional custom attributes; " + FlatJSON.HELP_TEXT,
verbose_name="Additional fields",
help_text="Any additional custom fields; " + FlatJSON.HELP_TEXT,
)
created = models.DateTimeField(auto_now_add=True)
last_updated = models.DateTimeField(auto_now=True)
Expand Down
Loading