Update Rules Patient Identity Update
This commit is contained in:
parent
2b81732086
commit
c388c03749
@ -107,6 +107,26 @@ class Patient extends Controller {
|
|||||||
|
|
||||||
public function update() {
|
public function update() {
|
||||||
$input = $this->request->getJSON(true);
|
$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()); }
|
if (!$this->validateData($input, $this->rules)) { return $this->failValidationErrors($this->validator->getErrors()); }
|
||||||
try {
|
try {
|
||||||
$InternalPID = $this->model->updatePatient($input);
|
$InternalPID = $this->model->updatePatient($input);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user