CCDA server fixups (#4356)
[openemr.git] / src / Validators / ProcessingResult.php
blob66b7540beb19d1513dfdd1fbe862f101e15b64d1
1 <?php
3 namespace OpenEMR\Validators;
5 /**
6 * OpenEMR Service Processing Result
8 * Data contained within a processing result includes:
9 * - isValid: indicates if the data provided to the service was valid
10 * - validatiomMessages: validation errors, if any, which occurred during processing
11 * - internalErrors: system related errors, if any, which occured during processing
12 * - data: the return value of the operation/process (array)
14 * @package OpenEMR
15 * @link http://www.open-emr.org
16 * @author Dixon Whitmire <dixonwh@gmail.com>
17 * @copyright Copyright (c) 2020 Dixon Whitmire <dixonwh@gmail.com>
18 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
21 class ProcessingResult
23 private $validationMessages;
24 private $internalErrors;
25 private $data;
27 /**
28 * Initializes internal data structures to an internal array.
30 public function __construct()
32 $this->validationMessages = [];
33 $this->internalErrors = [];
34 $this->data = [];
37 /**
38 * @return true if the instance does not contain validation messages/errors
40 public function isValid()
42 return count($this->validationMessages) == 0;
45 public function getValidationMessages()
47 return $this->validationMessages;
50 public function setValidationMessages($validationMessages)
52 $this->validationMessages = $validationMessages;
55 public function getInternalErrors()
57 return $this->internalErrors;
60 public function setInternalErrors($internalErrors)
62 $this->internalErrors = $internalErrors;
65 /**
66 * Appends an internal error to the current instance.
67 * @param $internalError - The internal error to append.
69 public function addInternalError($internalError)
71 array_push($this->internalErrors, $internalError);
74 public function getData()
76 return $this->data;
79 public function setData($data)
81 $this->data = $data;
84 /**
85 * Appends a new data item to the current instance.
86 * @param $newData The new data item.
88 public function addData($newData)
90 array_push($this->data, $newData);
93 /**
94 * @return true if the instance has 1 or more internal errors.
96 public function hasInternalErrors()
98 return count($this->internalErrors) > 0;
102 * @return true if the instance contains either validation or internal errors.
104 public function hasErrors()
106 return !$this->isValid() || $this->hasInternalErrors();