clqms-be/app/Models/Patient/PatIdtModel.php
OpenCode Bot 9946978487 chore: refresh CLQMS backend baseline
Re-synced controllers, configs, libraries, seeds, and docs with the latest API expectations and response helpers.
2026-04-08 16:07:19 +07:00

52 lines
1.8 KiB
PHP
Executable File

<?php
namespace App\Models\Patient;
use App\Models\BaseModel;
use App\Models\BaseUtcModel;
class PatIdtModel extends BaseModel {
protected $table = 'patidt';
protected $primaryKey = 'PatIdtID';
protected $allowedFields = ['InternalPID', 'IdentifierType', 'Identifier', 'EffectiveDate', 'ExpirationDate', 'CreateDate', 'DelDate'];
protected $useTimestamps = true;
protected $createdField = 'CreateDate';
protected $updatedField = '';
protected $useSoftDeletes = true;
protected $deletedField = 'DelDate';
protected $beforeInsert = ['normalizeDatesToUTC'];
protected $beforeUpdate = ['normalizeDatesToUTC'];
protected $afterFind = ['convertDatesToUTCISO'];
protected $afterInsert = ['convertDatesToUTCISO'];
protected $afterUpdate = ['convertDatesToUTCISO'];
public function createPatIdt($patidt, string $newInternalPID) {
$this->insert(["InternalPID" => $newInternalPID, "IdentifierType" => $patidt['IdentifierType'], 'Identifier' => $patidt['Identifier']]);
}
public function updatePatIdt($patidt, string $InternalPID) {
$exists = $this->where('InternalPID', $InternalPID)->first();
// $exists = $db->table('patidt')->where('InternalPID', $InternalPID)->get()->getRowArray();
if ($exists) {
// Update
$this->where('InternalPID', $InternalPID)->set($patidt)->update();
// $db->table('patidt')->where('InternalPID', $InternalPID)->update($patidt);
} else {
// Insert
$patidt['InternalPID'] = $InternalPID;
$this->insert($patidt);
// $patidt['InternalPID'] = $InternalPID;
// $db->table('patidt')->insert($patidt);
}
}
public function deletePatIdt(string $InternalPID) {
$this->where('InternalPID', $InternalPID)->delete();
}
}