Skip to content

Commit

Permalink
Merge branch 'release/0.1.15' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed Oct 10, 2023
2 parents da87395 + 3b0c47c commit c576496
Show file tree
Hide file tree
Showing 12 changed files with 209 additions and 72 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.10', '3.11']
django-version: ['4.1', '4.2', 'dev']
exclude:
- python-version: '3.10'
django-version: 'dev'
python-version: ['3.11']
django-version: ['4.2', 'dev']
services:
mysql:
image: mysql:latest
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ repos:
- "-x *test*.py"

- repo: https://github.com/psf/black
rev: 23.3.0
rev: 23.9.1
hooks:
- id: black
language_version: python3.10

- repo: https://github.com/pycqa/flake8
rev: 6.0.0
rev: 6.1.0
hooks:
- id: flake8
args:
Expand All @@ -42,7 +42,7 @@ repos:
- id: detect-private-key

- repo: https://github.com/adrienverge/yamllint
rev: v1.31.0
rev: v1.32.0
hooks:
- id: yamllint
args:
Expand Down
31 changes: 0 additions & 31 deletions edc_microbiology/tests/models.py

This file was deleted.

46 changes: 28 additions & 18 deletions edc_microbiology/tests/tests/test_form.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
from decimal import Decimal

from django import forms
from django.core.exceptions import ValidationError
from django.test import TestCase
from edc_appointment.models import Appointment
from edc_appointment.tests.helper import Helper
from edc_constants.constants import NO, NOT_APPLICABLE, OTHER, POS, YES
from edc_crf.crf_form_validator_mixins import BaseFormValidatorMixin
from edc_form_validators import FormValidator
from edc_registration.models import RegisteredSubject
from edc_reference import site_reference_configs
from edc_utils import get_utcnow
from edc_visit_schedule.constants import DAY1
from edc_visit_schedule.site_visit_schedules import site_visit_schedules
from edc_visit_tracking.constants import SCHEDULED
from edc_visit_tracking.models import SubjectVisit

from edc_microbiology.constants import (
BACTERIA,
Expand All @@ -17,8 +19,7 @@
NO_GROWTH,
)
from edc_microbiology.form_validators import MicrobiologyFormValidatorMixin

from ..models import Appointment, SubjectVisit
from microbiology_app.visit_schedule import visit_schedule


class MicrobiologyFormValidator(
Expand All @@ -32,22 +33,31 @@ class MicrobiologyFormValidator(


class TestMicrobiologyFormValidator(TestCase):
helper_cls = Helper

def setUp(self):
self.subject_identifier = "1234"
RegisteredSubject.objects.create(
subject_identifier=self.subject_identifier,
randomization_datetime=get_utcnow(),
self.subject_identifier = "1235"
self.helper = self.helper_cls(subject_identifier=self.subject_identifier)
self.visit_schedule_name = "visit_schedule"
self.schedule_name = "schedule"

site_visit_schedules._registry = {}
site_visit_schedules.loaded = False
site_visit_schedules.register(visit_schedule)

site_reference_configs.registry = {}
site_reference_configs.register_from_visit_schedule(
visit_models={"edc_appointment.appointment": "edc_visit_tracking.subjectvisit"}
)
appointment = Appointment.objects.create(
subject_identifier=self.subject_identifier,
appt_datetime=get_utcnow(),
visit_code=DAY1,
visit_schedule_name="visit_schedule",
schedule_name="schedule",
timepoint=Decimal("0.0"),

self.helper.consent_and_put_on_schedule(
visit_schedule_name="visit_schedule", schedule_name="schedule"
)
appointment = Appointment.objects.all().order_by("timepoint_datetime")[0]
self.subject_visit = SubjectVisit.objects.create(
appointment=appointment, subject_identifier=self.subject_identifier
appointment=appointment,
subject_identifier=self.subject_identifier,
reason=SCHEDULED,
)

def test_urine_culture_performed_yes_require_urine_culture_result(self):
Expand Down
Empty file added microbiology_app/__init__.py
Empty file.
5 changes: 5 additions & 0 deletions microbiology_app/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig as DjangoAppConfig


class AppConfig(DjangoAppConfig):
name = "microbiology_app"
61 changes: 61 additions & 0 deletions microbiology_app/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
from datetime import date

from django.db import models
from django.db.models import PROTECT
from edc_crf.model_mixins import CrfModelMixin
from edc_identifier.managers import SubjectIdentifierManager
from edc_identifier.model_mixins import NonUniqueSubjectIdentifierFieldMixin
from edc_model.models import BaseUuidModel
from edc_registration.model_mixins import UpdatesOrCreatesRegistrationModelMixin
from edc_screening.model_mixins import ScreeningModelMixin
from edc_sites.models import SiteModelMixin
from edc_utils import get_utcnow
from edc_visit_schedule.model_mixins import OffScheduleModelMixin, OnScheduleModelMixin
from edc_visit_tracking.models import SubjectVisit


class SubjectScreening(ScreeningModelMixin, BaseUuidModel):
objects = SubjectIdentifierManager()


class SubjectConsent(
SiteModelMixin,
NonUniqueSubjectIdentifierFieldMixin,
UpdatesOrCreatesRegistrationModelMixin,
BaseUuidModel,
):
report_datetime = models.DateTimeField(default=get_utcnow)

consent_datetime = models.DateTimeField(default=get_utcnow)

version = models.CharField(max_length=25, default="1")

identity = models.CharField(max_length=25)

confirm_identity = models.CharField(max_length=25)

dob = models.DateField(default=date(1995, 1, 1))


class OnSchedule(SiteModelMixin, OnScheduleModelMixin, BaseUuidModel):
pass


class OffSchedule(SiteModelMixin, OffScheduleModelMixin, BaseUuidModel):
pass


class CrfOne(CrfModelMixin, BaseUuidModel):
subject_visit = models.ForeignKey(SubjectVisit, on_delete=PROTECT)

report_datetime = models.DateTimeField(default=get_utcnow)

f1 = models.CharField(max_length=50, null=True, blank=True)

f2 = models.CharField(max_length=50, null=True, blank=True)

f3 = models.CharField(max_length=50, null=True, blank=True)

next_appt_date = models.DateField(null=True, blank=True)

next_visit_code = models.CharField(max_length=50, null=True, blank=True)
15 changes: 15 additions & 0 deletions microbiology_app/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from django.contrib import admin
from django.urls import include, path
from django.views.generic import RedirectView

app_name = "microbiology_app"


urlpatterns = []


urlpatterns += [
path("admin/", admin.site.urls),
path("i18n/", include("django.conf.urls.i18n")),
path("", RedirectView.as_view(url="admin/"), name="logout"),
]
67 changes: 67 additions & 0 deletions microbiology_app/visit_schedule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
from dateutil.relativedelta import relativedelta
from edc_visit_schedule.schedule import Schedule
from edc_visit_schedule.visit import Crf, FormsCollection, Visit
from edc_visit_schedule.visit_schedule import VisitSchedule

crfs = FormsCollection(Crf(show_order=1, model="microbiology_app.crfone", required=True))

visit0 = Visit(
code="1000",
title="Day 1",
timepoint=0,
rbase=relativedelta(days=0),
rlower=relativedelta(days=0),
rupper=relativedelta(days=6),
crfs=crfs,
)

visit1 = Visit(
code="2000",
title="Day 2",
timepoint=1,
rbase=relativedelta(days=1),
rlower=relativedelta(days=0),
rupper=relativedelta(days=6),
crfs=crfs,
)

visit2 = Visit(
code="3000",
title="Day 3",
timepoint=2,
rbase=relativedelta(days=2),
rlower=relativedelta(days=0),
rupper=relativedelta(days=6),
crfs=crfs,
)

visit3 = Visit(
code="4000",
title="Day 4",
timepoint=3,
rbase=relativedelta(days=3),
rlower=relativedelta(days=0),
rupper=relativedelta(days=6),
crfs=crfs,
)

schedule = Schedule(
name="schedule",
onschedule_model="microbiology_app.onschedule",
offschedule_model="microbiology_app.offschedule",
appointment_model="edc_appointment.appointment",
consent_model="microbiology_app.subjectconsent",
)

schedule.add_visit(visit0)
schedule.add_visit(visit1)
schedule.add_visit(visit2)
schedule.add_visit(visit3)

visit_schedule = VisitSchedule(
name="visit_schedule",
offstudy_model="edc_offstudy.subjectoffstudy",
death_report_model="edc_adverse_event.deathreport",
)

visit_schedule.add_schedule(schedule)
11 changes: 4 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
[build-system]
requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"]
build-backend = "setuptools.build_meta"
requires = ["setuptools>=60", "setuptools-scm>=8.0"]

[tool.setuptools_scm]
write_to = "_version.py"
version_file="_version.py"

[tool.black]
line-length = 95
target-version = ["py310"]
target-version = ["py311"]
extend-exclude = '''^(.*\/)*\b(migrations)\b($|\/.*$)'''

[tool.isort]
profile = "black"
py_version = "310"
py_version = "311"
skip = [".tox", ".eggs", "migrations"]

[tool.coverage.run]
Expand All @@ -36,15 +35,13 @@ exclude_lines = [
legacy_tox_ini = """
[tox]
envlist =
py{310}-dj{41,42},
py{311}-dj{41,42,dev},
lint
isolated_build = true
[gh-actions]
python =
3.10: py310
3.11: py311, lint
[gh-actions:env]
Expand Down
25 changes: 21 additions & 4 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,26 @@
import django
from django.conf import settings
from django.test.runner import DiscoverRunner
from edc_constants.constants import IGNORE
from edc_test_utils import DefaultTestSettings

app_name = "edc_microbiology"
base_dir = dirname(abspath(__file__))

DEFAULT_SETTINGS = DefaultTestSettings(
calling_file=__file__,
template_dirs=[os.path.join(base_dir, app_name, "tests", "templates")],
BASE_DIR=base_dir,
APP_NAME=app_name,
ETC_DIR=os.path.join(base_dir, app_name, "tests", "etc"),
SUBJECT_VISIT_MODEL="edc_microbiology.subjectvisit",
SUBJECT_VISIT_MISSED_MODEL="edc_appointment.subjectvisitmissed",
ETC_DIR=os.path.join(base_dir, "edc_microbiology", "tests", "etc"),
SUBJECT_VISIT_MODEL="edc_visit_tracking.subjectvisit",
SUBJECT_VISIT_MISSED_MODEL="edc_visit_tracking.subjectvisitmissed",
SUBJECT_SCREENING_MODEL="microbiology_app.subjectscreening",
SUBJECT_CONSENT_MODEL="microbiology_app.subjectconsent",
SUBJECT_REQUISITION_MODEL="microbiology_app.subjectrequisition",
SUBJECT_APP_LABEL="microbiology_app",
EDC_NAVBAR_DEFAULT=app_name,
EDC_NAVBAR_VERIFY_ON_LOAD=IGNORE,
EDC_AUTH_SKIP_SITE_AUTHS=True,
INSTALLED_APPS=[
"django.contrib.admin",
"django.contrib.auth",
Expand All @@ -32,17 +39,27 @@
"multisite",
"django_crypto_fields.apps.AppConfig",
"edc_auth.apps.AppConfig",
"edc_action_item.apps.AppConfig",
"edc_appointment.apps.AppConfig",
"edc_notification.apps.AppConfig",
"edc_export.apps.AppConfig",
"edc_crf.apps.AppConfig",
"edc_device.apps.AppConfig",
"edc_identifier.apps.AppConfig",
"edc_timepoint.apps.AppConfig",
"edc_registration.apps.AppConfig",
"edc_metadata.apps.AppConfig",
"edc_facility.apps.AppConfig",
"edc_offstudy.apps.AppConfig",
"edc_reference.apps.AppConfig",
"edc_sites.apps.AppConfig",
"edc_visit_schedule.apps.AppConfig",
"edc_visit_tracking.apps.AppConfig",
"edc_microbiology.apps.AppConfig",
"microbiology_app.apps.AppConfig",
],
add_dashboard_middleware=True,
use_test_urls=False,
).settings


Expand Down
Loading

0 comments on commit c576496

Please sign in to comment.