Update Rules Patient Identity
This commit is contained in:
parent
cac46552f6
commit
2b81732086
@ -17,13 +17,34 @@ class Patient extends Controller {
|
||||
$this->db = \Config\Database::connect();
|
||||
$this->model = new PatientModel();
|
||||
$this->rules = [
|
||||
'PatientID' => 'required|max_length[50]',
|
||||
'AlternatePID' => 'permit_empty|max_length[50]',
|
||||
'NameFirst' => 'required|min_length[1]|max_length[255]',
|
||||
'EmailAddress1' => 'required',
|
||||
'PatientID' => 'required|regex_match[/^[A-Za-z0-9]+$/]|max_length[30]',
|
||||
'AlternatePID' => 'permit_empty|regex_match[/^[A-Za-z0-9]+$/]|max_length[30]',
|
||||
'Prefix' => 'permit_empty|regex_match[/^[A-Za-z\'\. ]+$/]|max_length[10]',
|
||||
'Gender' => 'required',
|
||||
'Birthdate' => 'required',
|
||||
"PatIdt.Identifier" => 'max_length[255]'
|
||||
|
||||
'NameFirst' => 'required|regex_match[/^[A-Za-z\'\. ]+$/]|min_length[1]|max_length[60]',
|
||||
'NameMiddle' => 'permit_empty|regex_match[/^[A-Za-z\'\. ]+$/]|min_length[1]|max_length[60]',
|
||||
'NameMaiden' => 'permit_empty|regex_match[/^[A-Za-z\'\. ]+$/]|min_length[1]|max_length[60]',
|
||||
'NameLast' => 'permit_empty|regex_match[/^[A-Za-z\'\. ]+$/]|min_length[1]|max_length[60]',
|
||||
|
||||
'Suffix' => 'permit_empty|regex_match[/^[A-Za-z\'\. ]+$/]|max_length[10]',
|
||||
'PlaceOfBirth' => 'permit_empty|regex_match[/^[A-Za-z\'\. ]+$/]|max_length[100]',
|
||||
'Citizenship' => 'permit_empty|regex_match[/^[A-Za-z\'\. ]+$/]|max_length[100]',
|
||||
|
||||
'Street_1' => 'permit_empty|regex_match[/^[A-Za-z0-9\'.,\/\- ]+$/]|max_length[255]',
|
||||
'Street_2' => 'permit_empty|regex_match[/^[A-Za-z0-9\'.,\/\- ]+$/]|max_length[255]',
|
||||
'Street_3' => 'permit_empty|regex_match[/^[A-Za-z0-9\'.,\/\- ]+$/]|max_length[255]',
|
||||
|
||||
'EmailAddress1' => 'permit_empty|valid_email|max_length[100]',
|
||||
'EmailAddress2' => 'permit_empty|valid_email|max_length[100]',
|
||||
|
||||
'Birthdate' => 'required',
|
||||
'PatIdt.IdentifierType' => 'permit_empty',
|
||||
'PatIdt.Identifier' => 'permit_empty|max_length[255]',
|
||||
|
||||
'ZIP' => 'permit_empty|is_natural|max_length[10]',
|
||||
'Phone' => 'permit_empty|regex_match[/^\\+?[0-9]{8,15}$/]',
|
||||
'MobilePhone' => 'permit_empty|regex_match[/^\\+?[0-9]{8,15}$/]'
|
||||
];
|
||||
}
|
||||
|
||||
@ -55,6 +76,26 @@ class Patient extends Controller {
|
||||
|
||||
public function create() {
|
||||
$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->createPatient($input);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user