Merge branch 'main' of https://github.com/mahdahar/clqms-be
This commit is contained in:
commit
88e0de78ba
@ -30,6 +30,7 @@ $routes->get('/api/patient/check', 'Patient::patientCheck');
|
|||||||
//$routes->get('/api/patvisit', 'Patient::index');
|
//$routes->get('/api/patvisit', 'Patient::index');
|
||||||
$routes->post('/api/patvisit', 'PatVisit::create');
|
$routes->post('/api/patvisit', 'PatVisit::create');
|
||||||
$routes->get('/api/patvisit/(:num)', 'PatVisit::show/$1');
|
$routes->get('/api/patvisit/(:num)', 'PatVisit::show/$1');
|
||||||
|
$routes->get('/api/patvisit/patient/(:num)', 'PatVisit::showByPatient/$1');
|
||||||
$routes->delete('/api/patvisit', 'PatVisit::delete');
|
$routes->delete('/api/patvisit', 'PatVisit::delete');
|
||||||
$routes->patch('/api/patvisit', 'PatVisit::update');
|
$routes->patch('/api/patvisit', 'PatVisit::update');
|
||||||
|
|
||||||
|
|||||||
@ -87,12 +87,10 @@ class Auth extends Controller {
|
|||||||
|
|
||||||
$sql = "SELECT * FROM users WHERE username=" . $this->db->escape($username);
|
$sql = "SELECT * FROM users WHERE username=" . $this->db->escape($username);
|
||||||
$query = $this->db->query($sql);
|
$query = $this->db->query($sql);
|
||||||
$row = $query->getRowArray();
|
$row = $query->getResultArray();
|
||||||
|
|
||||||
if (!$row) {
|
|
||||||
return $this->fail('User not found.', 401);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (!$row) { return $this->fail('User not found.', 401); }
|
||||||
|
$row = $row[0];
|
||||||
if (!password_verify($password, $row['password'])) {
|
if (!password_verify($password, $row['password'])) {
|
||||||
return $this->fail('Invalid password.', 401);
|
return $this->fail('Invalid password.', 401);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,7 @@ class Contact extends Controller {
|
|||||||
$sql->select("*")
|
$sql->select("*")
|
||||||
->join("contactdetail", "contact.ContactID=contactdetail.ContactID", "left")
|
->join("contactdetail", "contact.ContactID=contactdetail.ContactID", "left")
|
||||||
->join("occupation","contactdetail.OccupationID=occupation.OccupationID", "left");
|
->join("occupation","contactdetail.OccupationID=occupation.OccupationID", "left");
|
||||||
$rows = $sql->get()->getRowArray();
|
$rows = $sql->get()->getResultArray();
|
||||||
|
|
||||||
if (empty($rows)) {
|
if (empty($rows)) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
@ -43,7 +43,7 @@ class Contact extends Controller {
|
|||||||
->join("contactdetail", "contact.ContactID=contactdetail.ContactID", "left")
|
->join("contactdetail", "contact.ContactID=contactdetail.ContactID", "left")
|
||||||
->join("occupation","occupation.OccupationID=contactdetail.OccupationID", "left")
|
->join("occupation","occupation.OccupationID=contactdetail.OccupationID", "left")
|
||||||
->where('contact.ContactID', (int) $ContactID)
|
->where('contact.ContactID', (int) $ContactID)
|
||||||
->get()->getRowArray();
|
->get()->getResultArray();
|
||||||
|
|
||||||
if (empty($rows)) {
|
if (empty($rows)) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
@ -208,7 +208,7 @@ class Contact extends Controller {
|
|||||||
|
|
||||||
private function prepareContactDetailData(array $input): array {
|
private function prepareContactDetailData(array $input): array {
|
||||||
$data = [
|
$data = [
|
||||||
"Code" => $input['Code'] ?? null,
|
"ContactCode" => $input['ContactCode'] ?? null,
|
||||||
"ContactEmail" => $input['ContactEmail'] ?? null,
|
"ContactEmail" => $input['ContactEmail'] ?? null,
|
||||||
"OccupationID" => $input['OccupationID'] ?? null,
|
"OccupationID" => $input['OccupationID'] ?? null,
|
||||||
"JobTitle" => $input['JobTitle'] ?? null,
|
"JobTitle" => $input['JobTitle'] ?? null,
|
||||||
|
|||||||
@ -19,8 +19,8 @@ class Location extends Controller {
|
|||||||
public function index() {
|
public function index() {
|
||||||
$rows = $this->db->table('location l')
|
$rows = $this->db->table('location l')
|
||||||
->select("l.LocationID, LocCode, Parent, LocFull, LocType, v.VDesc ")
|
->select("l.LocationID, LocCode, Parent, LocFull, LocType, v.VDesc ")
|
||||||
->join("locationaddress la", "l.LocationID=la.LocationID")
|
->join("locationaddress la", "l.LocationID=la.LocationID", 'left')
|
||||||
->join("valueset v", "v.VSetID=12 and v.VValue=l.LocType")
|
->join("valueset v", "v.VSetID=12 and v.VValue=l.loctype", 'left')
|
||||||
->get()->getResultArray();
|
->get()->getResultArray();
|
||||||
|
|
||||||
if (empty($rows)) {
|
if (empty($rows)) {
|
||||||
@ -41,8 +41,8 @@ class Location extends Controller {
|
|||||||
public function show($LocationID = null) {
|
public function show($LocationID = null) {
|
||||||
$rows = $this->db->table('location l')
|
$rows = $this->db->table('location l')
|
||||||
->select("l.*, la.*, v.*")
|
->select("l.*, la.*, v.*")
|
||||||
->join("locationaddress la", "l.LocationID=la.LocationID")
|
->join("locationaddress la", "l.LocationID=la.LocationID", "left")
|
||||||
->join("valueset v", "v.VSetID=12 and v.VValue=l.loctype")
|
->join("valueset v", "v.VSetID=12 and v.VValue=l.loctype", "left")
|
||||||
->where('l.LocationID', (int) $LocationID)
|
->where('l.LocationID', (int) $LocationID)
|
||||||
->get()->getResultArray();
|
->get()->getResultArray();
|
||||||
|
|
||||||
@ -62,31 +62,22 @@ class Location extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function create() {
|
public function create() {
|
||||||
|
$input = $this->request->getJSON(true);
|
||||||
|
$dataLocation = $this->prepareLocationData($input);
|
||||||
|
$dataLocationAddress = $this->prepareLocationAddressData($input);
|
||||||
|
if (!$this->validateData($dataLocation, $this->rules)) {
|
||||||
|
return $this->failValidationErrors($this->validator->getErrors());
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$input = $this->request->getJSON(true);
|
|
||||||
|
|
||||||
// Prepare data
|
|
||||||
$dataLocation = $this->prepareLocationData($input);
|
|
||||||
$dataLocationAddress = $this->prepareLocationAddressData($input);
|
|
||||||
|
|
||||||
if (!$this->validateData($dataLocation, $this->rules)) {
|
|
||||||
return $this->failValidationErrors($this->validator->getErrors());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start transaction
|
|
||||||
$this->db->transStart();
|
$this->db->transStart();
|
||||||
|
|
||||||
// Insert location
|
|
||||||
$this->db->table('location')->insert($dataLocation);
|
$this->db->table('location')->insert($dataLocation);
|
||||||
$newLocationID = $this->db->insertID();
|
$newLocationID = $this->db->insertID();
|
||||||
|
|
||||||
// Insert address if available
|
|
||||||
if (!empty($dataLocationAddress)) {
|
if (!empty($dataLocationAddress)) {
|
||||||
$dataLocationAddress['LocationID'] = $newLocationID;
|
$dataLocationAddress['LocationID'] = $newLocationID;
|
||||||
$this->db->table('locationaddress')->insert($dataLocationAddress);
|
$this->db->table('locationaddress')->insert($dataLocationAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Complete transaction
|
|
||||||
$this->db->transComplete();
|
$this->db->transComplete();
|
||||||
|
|
||||||
if ($this->db->transStatus() === false) {
|
if ($this->db->transStatus() === false) {
|
||||||
@ -201,6 +192,7 @@ class Location extends Controller {
|
|||||||
"LocCode" => $input['LocCode'] ?? null,
|
"LocCode" => $input['LocCode'] ?? null,
|
||||||
"Parent" => $input['Parent'] ?? null,
|
"Parent" => $input['Parent'] ?? null,
|
||||||
"LocFull" => $input['LocFull'] ?? null,
|
"LocFull" => $input['LocFull'] ?? null,
|
||||||
|
"LocType" => $input['LocType'] ?? null,
|
||||||
"Description" => $input['Description'] ?? null,
|
"Description" => $input['Description'] ?? null,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@ class OrderTest extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
$rows = $this->db->table('ordertest')->select("*")->get()->getRowArray();
|
$rows = $this->db->table('ordertest')->select("*")->get()->getResultArray();
|
||||||
|
|
||||||
if (empty($rows)) {
|
if (empty($rows)) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
@ -34,7 +34,7 @@ class OrderTest extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function show($OrderID = null) {
|
public function show($OrderID = null) {
|
||||||
$row=$this->db->table('ordertest')->select("*")->where('OrderID=', $OrderID)->get()->getRowArray();
|
$row=$this->db->table('ordertest')->select("*")->where('OrderID=', $OrderID)->get()->getResultArray();
|
||||||
|
|
||||||
if (empty($row)) {
|
if (empty($row)) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
|
|||||||
@ -12,48 +12,27 @@ class PatVisit extends Controller {
|
|||||||
$this->db = \Config\Database::connect();
|
$this->db = \Config\Database::connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function preparePatVisitData(array $input): array {
|
|
||||||
$data = [
|
|
||||||
"PVID" => $input['PVID'] ?? null,
|
|
||||||
"InternalPID" => $input['InternalPID'] ?? null,
|
|
||||||
"EpisodeID" => $input['EpisodeID'] ?? null
|
|
||||||
];
|
|
||||||
|
|
||||||
if(!empty($input['InternalPVID'])) { $data["InternalPVID"] = $input["InternalPVID"]; }
|
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function preparePatDiagData(array $input): array {
|
|
||||||
$data = [
|
|
||||||
"InternalPVID" => $input['InternalPVID'] ?? null,
|
|
||||||
"InternalPID" => $input['InternalPID'] ?? null,
|
|
||||||
"DiagCode" => $input['DiagCode'] ?? null,
|
|
||||||
"Diagnosis" => $input['Diagnosis'] ?? null
|
|
||||||
];
|
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function preparePatVisitAdtData(array $input): array {
|
|
||||||
$data = [
|
|
||||||
"InternalPVID" => $input['InternalPVID'] ?? null,
|
|
||||||
"InternalPID" => $input['InternalPID'] ?? null,
|
|
||||||
"ADTCode" => $input['ADTCode'] ?? null,
|
|
||||||
"LocationID" => $input['LocationID'] ?? null,
|
|
||||||
"AttDoc" => $input['AttDoc'] ?? null,
|
|
||||||
"RefDoc" => $input['RefDoc'] ?? null,
|
|
||||||
"AdmDoc" => $input['AdmDoc'] ?? null,
|
|
||||||
"CnsDoc" => $input['CnsDoc'] ?? null
|
|
||||||
];
|
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function show($PVID = null) {
|
public function show($PVID = null) {
|
||||||
try {
|
try {
|
||||||
$row = $this->db->table('patvisit pv')
|
$row = $this->db->table('patvisit pv')
|
||||||
->join('patdiag pd', 'pd.InternalPVID=pv.Internal.PVID', 'left')
|
->join('patdiag pd', 'pd.InternalPVID=pv.InternalPVID', 'left')
|
||||||
|
->join('patvisitadt pva', 'pd.InternalPVID=pva.InternalPVID', 'left')
|
||||||
|
->get()->getResultArray();
|
||||||
|
|
||||||
|
return $this->respond([
|
||||||
|
'status' => 'success',
|
||||||
|
'message'=> "data found",
|
||||||
|
'data' => $row,
|
||||||
|
], 200);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return $this->failServerError('Something went wrong '.$e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showByPatient($InternalPID = null) {
|
||||||
|
try {
|
||||||
|
$row = $this->db->table('patvisit pv')
|
||||||
|
->join('patdiag pd', 'pd.InternalPVID=pv.InternalPVID', 'left')
|
||||||
->join('patvisitadt pva', 'pd.InternalPVID=pva.InternalPVID', 'left')
|
->join('patvisitadt pva', 'pd.InternalPVID=pva.InternalPVID', 'left')
|
||||||
->get()->getResultArray();
|
->get()->getResultArray();
|
||||||
|
|
||||||
@ -74,9 +53,9 @@ class PatVisit extends Controller {
|
|||||||
|
|
||||||
if (!$input["InternalPVID"] || !is_numeric($input["InternalPVID"])) { return $this->respond(['status' => 'error', 'message' => 'Invalid or missing ID'], 400); }
|
if (!$input["InternalPVID"] || !is_numeric($input["InternalPVID"])) { return $this->respond(['status' => 'error', 'message' => 'Invalid or missing ID'], 400); }
|
||||||
$InternalPVID = $input["InternalPVID"];
|
$InternalPVID = $input["InternalPVID"];
|
||||||
$dataPatVisit = preparePatVisitData($input);
|
$dataPatVisit = $this->preparePatVisitData($input);
|
||||||
$dataPatDiag = preparePatDiagData($input);
|
$dataPatDiag = $this->preparePatDiagData($input);
|
||||||
$dataPatVisitAdt = preparePatVisitAdtData($input);
|
$dataPatVisitAdt = $this->preparePatVisitAdtData($input);
|
||||||
|
|
||||||
$this->db->transStart();
|
$this->db->transStart();
|
||||||
$this->db->table('patvisit')->where('InternalPVID', $InternalPVID)->update($dataPatVisit);
|
$this->db->table('patvisit')->where('InternalPVID', $InternalPVID)->update($dataPatVisit);
|
||||||
@ -115,15 +94,21 @@ class PatVisit extends Controller {
|
|||||||
$input = $this->request->getJSON(true);
|
$input = $this->request->getJSON(true);
|
||||||
if (!$input) { return $this->respond(['status' => 'error', 'message' => 'Invalid JSON input'], 400); }
|
if (!$input) { return $this->respond(['status' => 'error', 'message' => 'Invalid JSON input'], 400); }
|
||||||
|
|
||||||
$InternalPVID = $input["InternalPVID"];
|
$dataPatVisit = $this->preparePatVisitData($input);
|
||||||
$dataPatVisit = preparePatVisitData($input);
|
$dataPatDiag = $this->preparePatDiagData($input);
|
||||||
$dataPatDiag = preparePatDiagData($input);
|
$dataPatVisitAdt = $this->preparePatVisitAdtData($input);
|
||||||
$dataPatVisitAdt = preparePatVisitAdtData($input);
|
|
||||||
|
|
||||||
$this->db->transStart();
|
$this->db->transStart();
|
||||||
$this->db->table('patvisit')->insert($dataPatVisit);
|
$this->db->table('patvisit')->insert($dataPatVisit);
|
||||||
if(!empty($dataPatDiag)) { $this->db->table('patdiag')->insert($dataPatDiag); }
|
$newInternalPVID = $this->db->insertID();
|
||||||
if(!empty($dataPatVisitAdt)) {$this->db->table('patvisitadt')->insert($dataPatVisitAdt); }
|
if(!empty($dataPatDiag)) {
|
||||||
|
$dataPatDiag['InternalPVID'] = $newInternalPVID;
|
||||||
|
$this->db->table('patdiag')->insert($dataPatDiag);
|
||||||
|
}
|
||||||
|
if(!empty($dataPatVisitAdt)) {
|
||||||
|
$dataPatVisitAdt['InternalPVID'] = $newInternalPVID;
|
||||||
|
$this->db->table('patvisitadt')->insert($dataPatVisitAdt);
|
||||||
|
}
|
||||||
|
|
||||||
$dbError = $this->db->error();
|
$dbError = $this->db->error();
|
||||||
|
|
||||||
@ -131,7 +116,7 @@ class PatVisit extends Controller {
|
|||||||
|
|
||||||
if (!empty($dbError['message'])) {
|
if (!empty($dbError['message'])) {
|
||||||
$this->db->transRollback();
|
$this->db->transRollback();
|
||||||
return $this->failServerError('Update failed: ' . $dbError['message']);
|
return $this->failServerError('create failed: ' . $dbError['message']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -151,4 +136,41 @@ class PatVisit extends Controller {
|
|||||||
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
return $this->failServerError('Something went wrong: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function preparePatVisitData(array $input): array {
|
||||||
|
$data = [
|
||||||
|
"PVID" => $input['PVID'] ?? null,
|
||||||
|
"InternalPID" => $input['InternalPID'] ?? null,
|
||||||
|
"EpisodeID" => $input['EpisodeID'] ?? null
|
||||||
|
];
|
||||||
|
|
||||||
|
if(!empty($input['InternalPVID'])) { $data["InternalPVID"] = $input["InternalPVID"]; }
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function preparePatDiagData(array $input): array {
|
||||||
|
$data = [
|
||||||
|
"InternalPVID" => $input['InternalPVID'] ?? null,
|
||||||
|
"InternalPID" => $input['InternalPID'] ?? null,
|
||||||
|
"DiagCode" => $input['DiagCode'] ?? null,
|
||||||
|
"Diagnosis" => $input['Diagnosis'] ?? null
|
||||||
|
];
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function preparePatVisitAdtData(array $input): array {
|
||||||
|
$data = [
|
||||||
|
"InternalPVID" => $input['InternalPVID'] ?? null,
|
||||||
|
"ADTCode" => $input['ADTCode'] ?? null,
|
||||||
|
"LocationID" => $input['LocationID'] ?? null,
|
||||||
|
"AttDoc" => $input['AttDoc'] ?? null,
|
||||||
|
"RefDoc" => $input['RefDoc'] ?? null,
|
||||||
|
"AdmDoc" => $input['AdmDoc'] ?? null,
|
||||||
|
"CnsDoc" => $input['CnsDoc'] ?? null
|
||||||
|
];
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -169,7 +169,7 @@ class Patient extends Controller {
|
|||||||
->select('InternalPID, PatientID')
|
->select('InternalPID, PatientID')
|
||||||
->where('InternalPID', (int) $custodianId)
|
->where('InternalPID', (int) $custodianId)
|
||||||
->get()
|
->get()
|
||||||
->getRowArray() ?: null;
|
->getResultArray() ?: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -344,7 +344,7 @@ class Patient extends Controller {
|
|||||||
if (!$input["InternalPID"] || !is_numeric($input["InternalPID"])) { return $this->respond(['status' => 'error', 'message' => 'Invalid or missing InternalPID'], 400); }
|
if (!$input["InternalPID"] || !is_numeric($input["InternalPID"])) { return $this->respond(['status' => 'error', 'message' => 'Invalid or missing InternalPID'], 400); }
|
||||||
|
|
||||||
$InternalPID = $input["InternalPID"];
|
$InternalPID = $input["InternalPID"];
|
||||||
$patient = $this->db->table('patient')->where('InternalPID', $InternalPID)->get()->getRowArray();
|
$patient = $this->db->table('patient')->where('InternalPID', $InternalPID)->get()->getResultArray();
|
||||||
if (!$patient) { return $this->respond(['status' => 'error', 'message' => 'Patient not found'], 404); }
|
if (!$patient) { return $this->respond(['status' => 'error', 'message' => 'Patient not found'], 404); }
|
||||||
|
|
||||||
$dataPatient = $this->preparePatientData($input);
|
$dataPatient = $this->preparePatientData($input);
|
||||||
@ -466,7 +466,7 @@ class Patient extends Controller {
|
|||||||
$patient = $this->db->table('patient')
|
$patient = $this->db->table('patient')
|
||||||
->where($tableName, $searchName)
|
->where($tableName, $searchName)
|
||||||
->get()
|
->get()
|
||||||
->getRowArray();
|
->getResultArray();
|
||||||
|
|
||||||
if (!$patient) {
|
if (!$patient) {
|
||||||
return $this->respond([
|
return $this->respond([
|
||||||
|
|||||||
@ -12,7 +12,7 @@ class CreatePVTables extends Migration {
|
|||||||
'InternalPVID'=> ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
|
'InternalPVID'=> ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
|
||||||
'PVID' => ['type' => 'VARCHAR', 'constraint' => 20, 'null' => true],
|
'PVID' => ['type' => 'VARCHAR', 'constraint' => 20, 'null' => true],
|
||||||
'InternalPID' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
|
'InternalPID' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
|
||||||
'Episode' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
'EpisodeID' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||||
'EndDate' => ['type' => 'DATETIME', 'null' => true],
|
'EndDate' => ['type' => 'DATETIME', 'null' => true],
|
||||||
'ArchivedDate'=> ['type' => 'DATETIME', 'null' => true],
|
'ArchivedDate'=> ['type' => 'DATETIME', 'null' => true],
|
||||||
'DelDate' => ['type' => 'DATETIME', 'null' => true],
|
'DelDate' => ['type' => 'DATETIME', 'null' => true],
|
||||||
@ -42,7 +42,7 @@ class CreatePVTables extends Migration {
|
|||||||
'ADTCode' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
'ADTCode' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||||
'LocationID' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
|
'LocationID' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
|
||||||
'AttDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
|
'AttDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
|
||||||
'ReffDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
|
'RefDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
|
||||||
'AdmDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
|
'AdmDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
|
||||||
'CnsDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
|
'CnsDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
|
||||||
'EndDate' => ['type' => 'DATETIME', 'null' => true],
|
'EndDate' => ['type' => 'DATETIME', 'null' => true],
|
||||||
@ -29,16 +29,16 @@ class CreateContactTable extends Migration {
|
|||||||
|
|
||||||
// ContactDetail
|
// ContactDetail
|
||||||
$this->forge->addField([
|
$this->forge->addField([
|
||||||
'ContactDetID' => [ 'type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true ],
|
'ContactDetID' => [ 'type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true ],
|
||||||
'ContactID' => [ 'type' => 'INT', 'constraint' => 11 ],
|
'ContactID' => [ 'type' => 'INT', 'constraint' => 11 ],
|
||||||
'SiteID' => [ 'type' => 'INT', 'constraint' => 11, 'null' => true ],
|
'SiteID' => [ 'type' => 'INT', 'constraint' => 11, 'null' => true ],
|
||||||
'Code' => [ 'type' => 'varchar', 'constraint' => 11, 'null' => false ],
|
'ContactCode' => [ 'type' => 'varchar', 'constraint' => 11, 'null' => false ],
|
||||||
'ContactEmail' => [ 'type' => 'VARCHAR', 'constraint' => 150, 'null' => true ],
|
'ContactEmail' => [ 'type' => 'VARCHAR', 'constraint' => 150, 'null' => true ],
|
||||||
'OccupationID' => [ 'type' => 'VARCHAR', 'constraint' => 50, 'null' => true ],
|
'OccupationID' => [ 'type' => 'VARCHAR', 'constraint' => 50, 'null' => true ],
|
||||||
'JobTitle' => [ 'type' => 'VARCHAR', 'constraint' => 100, 'null' => true ],
|
'JobTitle' => [ 'type' => 'VARCHAR', 'constraint' => 100, 'null' => true ],
|
||||||
'Department' => [ 'type' => 'VARCHAR', 'constraint' => 100, 'null' => true ],
|
'Department' => [ 'type' => 'VARCHAR', 'constraint' => 100, 'null' => true ],
|
||||||
'ContactStartDate' => [ 'type' => 'DATE', 'null' => true ],
|
'ContactStartDate' => [ 'type' => 'DATE', 'null' => true ],
|
||||||
'ContactEndDate' => [ 'type' => 'DATE', 'null' => true ],
|
'ContactEndDate' => [ 'type' => 'DATE', 'null' => true ],
|
||||||
]);
|
]);
|
||||||
$this->forge->addKey('ContactDetID', true);
|
$this->forge->addKey('ContactDetID', true);
|
||||||
$this->forge->createTable('contactdetail');
|
$this->forge->createTable('contactdetail');
|
||||||
|
|||||||
27
app/Database/Migrations/2025-09-22-155700_Counter.php
Normal file
27
app/Database/Migrations/2025-09-22-155700_Counter.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Database\Migrations;
|
||||||
|
|
||||||
|
use CodeIgniter\Database\Migration;
|
||||||
|
|
||||||
|
class CreateCounterTable extends Migration {
|
||||||
|
public function up() {
|
||||||
|
|
||||||
|
$this->forge->addField([
|
||||||
|
'CounterID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
||||||
|
'CounterValue' => ['type' => 'INT', 'null' => false],
|
||||||
|
'CounterStart' => ['type' => 'INT', 'null' => false],
|
||||||
|
'CounterEnd' => ['type' => 'INT', 'null' => false],
|
||||||
|
'CounterDesc' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
|
||||||
|
'CounterReset' => ['type' => 'varchar', 'constraint' => 1, 'null' => true],
|
||||||
|
'EndDate' => ['type' => 'DATETIME', 'null' => true]
|
||||||
|
]);
|
||||||
|
$this->forge->addField('CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP');
|
||||||
|
$this->forge->addKey('CounterID', true);
|
||||||
|
$this->forge->createTable('counter');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down() {
|
||||||
|
$this->forge->dropTable('counter');
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -11,13 +11,23 @@ class DummySeeder extends Seeder {
|
|||||||
['LocationID'=>1, 'LocCode'=>'QLOC', 'LocFull'=>'Dummy Location', 'LocType'=>'ROOM', 'Description'=>'Location made for dummy testing' ]
|
['LocationID'=>1, 'LocCode'=>'QLOC', 'LocFull'=>'Dummy Location', 'LocType'=>'ROOM', 'Description'=>'Location made for dummy testing' ]
|
||||||
];
|
];
|
||||||
$this->db->table('location')->insertBatch($data);
|
$this->db->table('location')->insertBatch($data);
|
||||||
|
|
||||||
// locationAddress
|
|
||||||
$data = [
|
$data = [
|
||||||
['LocationID'=>1, 'Street1'=>'Jalan Nginden', 'Street2'=>'Intan Raya', 'City'=>'Surabaya', 'Province'=>'East Java', 'PostCode'=>'60222']
|
['LocationID'=>1, 'Street1'=>'Jalan Nginden', 'Street2'=>'Intan Raya', 'City'=>'Surabaya', 'Province'=>'East Java', 'PostCode'=>'60222']
|
||||||
];
|
];
|
||||||
$this->db->table('locationaddress')->insertBatch($data);
|
$this->db->table('locationaddress')->insertBatch($data);
|
||||||
|
|
||||||
|
// contact
|
||||||
|
$data = [
|
||||||
|
['ContactID'=>1, 'NameFirst'=>'Default', 'NameLast'=>'Doctor', 'Title'=>'', 'Initial'=>'DEFDOC', 'Birthdate'=>'', 'EmailAddress1'=>'', 'EmailAddress2'=>'',
|
||||||
|
'Phone'=>'', 'MobilePhone1'=>'', 'MobilePhone2'=>'', 'Specialty'=>'', 'SubSpecialty'=>'' ]
|
||||||
|
];
|
||||||
|
$this->db->table('contact')->insertBatch($data);
|
||||||
|
$data = [
|
||||||
|
['ContactID'=>1, 'ContactCode'=>'QDOC', 'ContactEmail'=>'qdoc@email.com', 'OccupationID'=>'',
|
||||||
|
'JobTitle'=>'', 'Department'=>'', 'ContactStartDate'=>'', 'ContactEndDate'=>'' ]
|
||||||
|
];
|
||||||
|
$this->db->table('contactdetail')->insertBatch($data);
|
||||||
|
|
||||||
// patient
|
// patient
|
||||||
$data = [
|
$data = [
|
||||||
[ 'InternalPID'=>1, 'PatientID'=>'SMAJ1', 'NameFirst'=>'Dummy', 'NameLast' => 'Patient M', 'Gender'=>'1', 'BirthDate'=>'1991-09-09', 'Street_1'=>'Makati', 'IntCountryID'=>'105', 'EmailAddress1'=>'smaj1@5panda.id',
|
[ 'InternalPID'=>1, 'PatientID'=>'SMAJ1', 'NameFirst'=>'Dummy', 'NameLast' => 'Patient M', 'Gender'=>'1', 'BirthDate'=>'1991-09-09', 'Street_1'=>'Makati', 'IntCountryID'=>'105', 'EmailAddress1'=>'smaj1@5panda.id',
|
||||||
@ -26,8 +36,6 @@ class DummySeeder extends Seeder {
|
|||||||
'RaceID'=>'1', 'ReligionID'=>'1', 'EthnicID'=>'1', 'DeathIndicator' => '0']
|
'RaceID'=>'1', 'ReligionID'=>'1', 'EthnicID'=>'1', 'DeathIndicator' => '0']
|
||||||
];
|
];
|
||||||
$this->db->table('patient')->insertBatch($data);
|
$this->db->table('patient')->insertBatch($data);
|
||||||
|
|
||||||
// patidt
|
|
||||||
$data = [
|
$data = [
|
||||||
[ 'InternalPID'=>1, 'IdentifierType'=>'KTP', 'Identifier'=>'9901' ],
|
[ 'InternalPID'=>1, 'IdentifierType'=>'KTP', 'Identifier'=>'9901' ],
|
||||||
[ 'InternalPID'=>2, 'IdentifierType'=>'KTP', 'Identifier'=>'9902' ]
|
[ 'InternalPID'=>2, 'IdentifierType'=>'KTP', 'Identifier'=>'9902' ]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user