예제 #1
0
def validate_plasmapheresis(errors, obj):
    patient = obj.patient

    run_validators(errors, 'from_date', obj.from_date, [required, after_date_of_birth(patient), not_in_future])
    run_validators(errors, 'to_date', obj.to_date, [optional, after_date_of_birth(patient), not_in_future])
    run_validators(errors, 'no_of_exchanges', obj.no_of_exchanges, [required, min_(0)])
    run_validators(errors, 'response', obj.response, [required])

    if not errors.is_valid():
        return

    if obj.to_date is not None and obj.from_date > obj.to_date:
        errors.add_error('to_date', 'Must be after from date.')
예제 #2
0
def validate_medication(errors, obj):
    patient = obj.patient

    run_validators(errors, 'from_date', obj.from_date, [required, after_date_of_birth(patient), not_in_future])
    run_validators(errors, 'to_date', obj.to_date, [optional, after_date_of_birth(patient), not_in_future])
    run_validators(errors, 'name', obj.name, [not_empty])
    run_validators(errors, 'dose_quantity', obj.dose_quantity, [required, min_(0)])
    run_validators(errors, 'dose_unit', obj.dose_unit, [required])
    run_validators(errors, 'frequency', obj.frequency, [required])
    run_validators(errors, 'route', obj.route, [required])

    if not errors.is_valid():
        return

    if obj.to_date is not None and obj.from_date > obj.to_date:
        errors.add_error('to_date', 'Must be after from date.')
예제 #3
0
def test_min_greater_than():
    min_(10)(11)
예제 #4
0
def test_min_equal():
    min_(10)(10)
예제 #5
0
def test_min_less_than():
    with pytest.raises(ValidationError):
        min_(10)(9)