add internalpvid to pv creation

This commit is contained in:
mahdahar 2025-10-13 13:59:52 +07:00
parent 28d0d8cddd
commit 51c369ebe5
5 changed files with 18 additions and 19 deletions

View File

@ -11,18 +11,19 @@ class Contact extends Controller {
use ResponseTrait;
protected $db;
protected $contactRule;
protected $model;
protected $rule;
public function __construct() {
$this->db = \Config\Database::connect();
$this->contactRule = [ 'NameFirst' => 'required' ];
$this->model = new ContactModel();
$this->rule = [ 'NameFirst' => 'required' ];
}
public function index() {
$ContactName = $this->request->getVar('ContactName');
$Specialty = $this->request->getVar('Specialty');
$model = new ContactModel();
$rows = $model->getContacts($ContactName, $Specialty);
$rows = $this->model->getContacts($ContactName, $Specialty);
//$rows = $model->getContacts();
if (empty($rows)) {

View File

@ -8,6 +8,8 @@ use CodeIgniter\Database\RawSql;
class Counter extends Controller {
use ResponseTrait;
protected $db;
protected $model;
public function __construct() {
$this->db = \Config\Database::connect();
}
@ -85,7 +87,7 @@ class Counter extends Controller {
$dataCounter = $this->prepareCounterData($input);
$this->db->transStart();
$this->db->table('counter')->where('CounterID', $dataCounter["CounterID"])->update($dataCounterID);
$this->db->table('counter')->where('CounterID', $dataCounter["CounterID"])->update($dataCounter);
$this->db->transComplete();
if ($this->db->transStatus() === false) {
@ -115,7 +117,7 @@ class Counter extends Controller {
$input = $this->request->getJSON(true);
$CounterID = $input["CounterID"];
if (!$CounterID) {
return $this->failValidationError('CounterID is required.');
return $this->failValidationErrors('CounterID is required.');
}

View File

@ -47,7 +47,7 @@ class PatVisit extends Controller {
$input = $this->request->getJSON(true);
try {
$data = $this->model->createPatVisit($input);
return $this->respond(['status' => 'success', 'message' => 'Data updated successfully', 'data' => $data], 201);
return $this->respond(['status' => 'success', 'message' => 'Data created successfully', 'data' => $data], 201);
} catch (\Exception $e) {
return $this->failServerError('Something went wrong: ' . $e->getMessage());
}

View File

@ -51,7 +51,8 @@ class PatVisitModel extends BaseUtcModel {
$this->db->transStart();
$this->insert($input);
/*
$InternalPVID = $this->getInsertID();
if(!empty($input['PatDiag'])) {
$input['PatDiag']['InternalPVID'] = $InternalPVID;
$this->db->table('patdiag')->insert($input['PatDiag']);
@ -60,9 +61,10 @@ class PatVisitModel extends BaseUtcModel {
$input['PatVisitADT']['InternalPVID'] = $InternalPVID;
$this->db->table('patvisitadt')->insert($input['PatVisitADT']);
}
*/
$this->db->transComplete();
return $input['PVID'];
$data = [ "PVID"=>$input['PVID'], "InternalPVID"=>$InternalPVID ];
return $data;
} catch (\Exception $e) {
$this->db->transRollback();

View File

@ -6,18 +6,12 @@ use CodeIgniter\Database\RawSql;
class PatientModel extends BaseUtcModel {
protected $table = 'patient';
protected $primaryKey = 'InternalPID';
protected $useTimestamps = true;
protected $allowedFields = ['PatientID', 'AlternatePID', 'Prefix', 'NameFirst', 'NameMiddle', 'NameMaiden', 'NameLast', 'Suffix', 'NameAlias', 'Gender', 'Birthdate', 'PlaceOfBirth', 'Street_1', 'Street_2', 'Street_3',
'City', 'Province', 'ZIP', 'EmailAddress1', 'EmailAddress2', 'Phone', 'MobilePhone', 'Custodian', 'AccountNumber', 'Country', 'Race', 'MaritalStatus', 'Religion', 'Ethnic', 'Citizenship',
'DeathIndicator', 'DeathDateTime', 'LinkTo', 'CreateDate', 'DelDate' ];
protected $useTimestamps = true;
protected $createdField = 'CreateDate';
protected $updatedField = '';
protected $beforeInsert = ['normalizeDatesToUTC'];
protected $beforeUpdate = ['normalizeDatesToUTC'];
protected $afterFind = ['convertDatesToUTCISO'];
protected $afterInsert = ['convertDatesToUTCISO'];
protected $afterUpdate = ['convertDatesToUTCISO'];
public function getPatients($filters = []) {
$qname = "LOWER(CONCAT_WS(' ', IFNULL(Prefix,''), IFNULL(NameFirst,''), IFNULL(NameMiddle,''), IFNULL(NameLast,''), IFNULL(NameMaiden,''), IFNULL(Suffix,'')))";