feat: refine subject visits and project workflows
Add early termination visit workflow with ordering, non-applicable visit handling, visit window display, and medication adherence support. Extend monitoring visit issue template fields, site scoping, setup draft project info handling, login security UI, attachment behavior, and related tests/migrations.
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
from datetime import datetime
|
||||
from types import SimpleNamespace
|
||||
import uuid
|
||||
|
||||
from app.crud.subject import _validate_actual_medication_count
|
||||
from app.schemas.subject import SubjectRead, SubjectUpdate
|
||||
|
||||
|
||||
def test_subject_update_accepts_actual_medication_count():
|
||||
payload = SubjectUpdate(actual_medication_count=12)
|
||||
|
||||
assert payload.actual_medication_count == 12
|
||||
|
||||
|
||||
def test_subject_read_includes_actual_medication_count():
|
||||
subject = SimpleNamespace(
|
||||
id=uuid.UUID("00000000-0000-0000-0000-000000000001"),
|
||||
study_id=uuid.UUID("00000000-0000-0000-0000-000000000002"),
|
||||
site_id=uuid.UUID("00000000-0000-0000-0000-000000000003"),
|
||||
subject_no="S001",
|
||||
status="ENROLLED",
|
||||
screening_date=None,
|
||||
consent_date=None,
|
||||
enrollment_date=None,
|
||||
baseline_date=None,
|
||||
completion_date=None,
|
||||
actual_medication_count=10,
|
||||
drop_reason=None,
|
||||
created_at=datetime(2026, 5, 9, 0, 0, 0),
|
||||
updated_at=datetime(2026, 5, 9, 0, 0, 0),
|
||||
)
|
||||
|
||||
data = SubjectRead.model_validate(subject)
|
||||
|
||||
assert data.actual_medication_count == 10
|
||||
|
||||
|
||||
def test_actual_medication_count_cannot_be_negative():
|
||||
try:
|
||||
_validate_actual_medication_count(-1)
|
||||
except ValueError as exc:
|
||||
assert "实际用药次数不能小于0" in str(exc)
|
||||
else:
|
||||
raise AssertionError("negative actual medication count should be rejected")
|
||||
Reference in New Issue
Block a user