From c388c037499f074afad5091dec20b5764edf2185 Mon Sep 17 00:00:00 2001 From: mikael-zakaria Date: Mon, 24 Nov 2025 14:14:44 +0700 Subject: [PATCH] Update Rules Patient Identity Update --- app/Controllers/Patient/Patient.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/Controllers/Patient/Patient.php b/app/Controllers/Patient/Patient.php index c8aa828..75d5475 100644 --- a/app/Controllers/Patient/Patient.php +++ b/app/Controllers/Patient/Patient.php @@ -107,6 +107,26 @@ class Patient extends Controller { public function update() { $input = $this->request->getJSON(true); + + // Khusus untuk Override PATIDT + $type = $input['PatIdt']['IdentifierType'] ?? null; + $identifierRulesMap = [ + 'KTP' => 'required|regex_match[/^[0-9]{16}$/]', + 'PASS' => 'required|regex_match[/^[A-Za-z0-9]{6,9}$/]', + 'SSN' => 'required|regex_match[/^[0-9]{3}-[0-9]{2}-[0-9]{4}$/]', + 'SIM' => 'required|regex_match[/^[A-Za-z0-9]{12,14}$/]', + 'KTAS' => 'required|regex_match[/^[A-Za-z0-9]{12,15}$/]', + ]; + if ($type === null || $type === '') { + $identifierRule = 'permit_empty|max_length[255]'; + $this->rules['PatIdt.IdentifierType'] = 'permit_empty'; + $this->rules['PatIdt.Identifier'] = $identifierRule; + } else { + $identifierRule = $identifierRulesMap[$type] ?? 'permit_empty|max_length[255]'; + $this->rules['PatIdt.IdentifierType'] = 'required'; + $this->rules['PatIdt.Identifier'] = $identifierRule; + } + if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); } try { $InternalPID = $this->model->updatePatient($input);