...
Validate request using schema. Return 422 with the list of validation errors in case validation fails. In addition, check following:
Validate
...
location
Validate value in the field $.location, Reference on division resource, required.
Check that division exists
in case of error - return 409 ("Division not found")
Check that division is active
in case of error - return 409 ("Division is not active")
Validate $. division belongs to user's legal entity (client_id from token)
in case of error - return 409 ("Division does not belong to user's legal entity")
If chart parameter DEVICE_DISPENSE_DIVISION_DLS_VERIFY is on, then validate division is DLS verified (dls_verified=true)
in case of error - return 409 "Division is not verified in DLS"
Validate Medical programs
...