3 namespace OpenEMR\Validators
;
5 use Particle\Validator\Validator
;
6 use Particle\Validator\Exception\InvalidValueException
;
9 * Supports Encounter Record Validation.
11 class EncounterValidator
extends BaseValidator
15 * Configures validations for the Encounter DB Insert and Update use-case.
16 * The update use-case is comprised of the same fields as the insert use-case.
17 * The update use-case differs from the insert use-case in that fields other than pid are not required.
19 protected function configureValidator()
21 parent
::configureValidator();
24 $this->validator
->context(
25 self
::DATABASE_INSERT_CONTEXT
,
26 function (Validator
$context) {
27 $context->required('pc_catid');
28 $context->required('class_code')->callback(
30 return $this->validateCode($value, "list_options", "_ActEncounterCode");
33 $context->required("puuid", "Patient UUID")->callback(
35 return $this->validateId('uuid', "patient_data", $value, true);
41 // update validations copied from insert
42 $this->validator
->context(
43 self
::DATABASE_UPDATE_CONTEXT
,
44 function (Validator
$context) {
45 $context->copyContext(
46 self
::DATABASE_INSERT_CONTEXT
,
48 foreach ($rules as $key => $chain) {
49 $chain->required(false);
53 // additional euuid validation
54 $context->required("euuid", "Encounter UUID")->callback(function ($value) {
55 return $this->validateId("uuid", "form_encounter", $value, true);
57 // additional puuid validation
58 $context->required("puuid", "Patient UUID")->callback(function ($value) {
59 return $this->validateId('uuid', "patient_data", $value, true);
61 $context->optional('class_code')->callback(
63 return $this->validateCode($value, "list_options", "_ActEncounterCode");