3 namespace OpenEMR\Validators
;
5 use Particle\Validator\Validator
;
8 * Supports AllergyIntolerance Record Validation.
11 * @link http://www.open-emr.org
12 * @author Yash Bothra <yashrajbothra786@gmail.com>
13 * @copyright Copyright (c) 2020 Yash Bothra <yashrajbothra786@gmail.com>
14 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
16 class ConditionValidator
extends BaseValidator
19 * Configures validations for the AllergyIntolerance DB Insert and Update use-case.
20 * The update use-case is comprised of the same fields as the insert use-case.
21 * The update use-case differs from the insert use-case in that fields other than uuid are not required.
23 protected function configureValidator()
25 parent
::configureValidator();
28 $this->validator
->context(
29 self
::DATABASE_INSERT_CONTEXT
,
30 function (Validator
$context) {
31 $context->required('title')->lengthBetween(2, 255);
32 $context->required('begdate')->datetime('Y-m-d');
33 $context->optional('diagnosis')->lengthBetween(2, 255);
34 $context->optional('enddate')->datetime('Y-m-d');
35 $context->required("puuid", "Patient UUID")->callback(
37 return $this->validateId("uuid", "patient_data", $value, true);
43 // update validations copied from insert
44 $this->validator
->context(
45 self
::DATABASE_UPDATE_CONTEXT
,
46 function (Validator
$context) {
47 $context->copyContext(
48 self
::DATABASE_INSERT_CONTEXT
,
50 foreach ($rules as $key => $chain) {
51 $chain->required(false);
55 // additional muuid validation
56 $context->required("uuid", "Condition UUID")->callback(function ($value) {
57 return $this->validateId("uuid", "lists", $value, true);