This commit is contained in:
mikael-zakaria 2025-11-20 09:35:46 +07:00
commit eae096a37c
4 changed files with 56 additions and 11 deletions

View File

@ -15,6 +15,11 @@ class TestDefSite extends BaseController {
public function __construct() {
$this->db = \Config\Database::connect();
$this->model = new TestDefSiteModel;
$this->rules = [
"TestSiteCode" => "required",
"TestSiteName" => "required",
"Type" => "required",
];
}
public function index() {

View File

@ -41,7 +41,6 @@ class CreatePVTables extends Migration {
$this->forge->addField([
'PVADTID' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
'InternalPVID'=> ['type' => 'INT', 'null' => true],
'Sequence' => ['type' => 'INT', 'null' => true],
'ADTCode' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'LocationID' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
'AttDoc' => ['type' => 'INT', 'constraint' => 11, 'null' => true],

View File

@ -3,6 +3,7 @@
namespace App\Database\Seeds;
use CodeIgniter\Database\Seeder;
use App\Models\ValueSet\ValueSetModel;
class DummySeeder extends Seeder {
@ -10,6 +11,12 @@ class DummySeeder extends Seeder {
public function run() {
$now = date('Y-m-d H:i:s');
$vsModel = new ValueSetModel();
$rows = $vsModel->select("VID, VSetID, VValue")->findAll();
$vs = [];
foreach ($rows as $row) {
$vs[$row['VSetID']][$row['VValue']] = $row['VID'];
}
// location
$data = [
@ -83,14 +90,14 @@ class DummySeeder extends Seeder {
$this->db->table('patvisit')->insertBatch($data);
$data = [
['InternalPVID'=>1, "Sequence"=>1, "ADTCode"=>"X01", "LocationID"=>1, "AttDoc"=>null, "CreateDate"=>"$now"],
['InternalPVID'=>1, "Sequence"=>2, "ADTCode"=>"X02", "LocationID"=>null, "AttDoc"=>1, "CreateDate"=>"$now"],
['InternalPVID'=>1, "Sequence"=>3, "ADTCode"=>"X01", "LocationID"=>2, "AttDoc"=>null, "CreateDate"=>"$now"],
['InternalPVID'=>1, "Sequence"=>4, "ADTCode"=>"X02", "LocationID"=>null, "AttDoc"=>2, "CreateDate"=>"$now"],
['InternalPVID'=>2, "Sequence"=>1, "ADTCode"=>"X01", "LocationID"=>1, "AttDoc"=>null, "CreateDate"=>"$now"],
['InternalPVID'=>2, "Sequence"=>2, "ADTCode"=>"X02", "LocationID"=>null, "AttDoc"=>1, "CreateDate"=>"$now"],
['InternalPVID'=>2, "Sequence"=>3, "ADTCode"=>"X01", "LocationID"=>2, "AttDoc"=>null, "CreateDate"=>"$now"],
['InternalPVID'=>2, "Sequence"=>4, "ADTCode"=>"X02", "LocationID"=>null, "AttDoc"=>2, "CreateDate"=>"$now"],
['InternalPVID'=>1, "ADTCode"=>"X01", "LocationID"=>1, "AttDoc"=>null, "CreateDate"=>"$now"],
['InternalPVID'=>1, "ADTCode"=>"X02", "LocationID"=>null, "AttDoc"=>1, "CreateDate"=>"$now"],
['InternalPVID'=>1, "ADTCode"=>"X01", "LocationID"=>2, "AttDoc"=>null, "CreateDate"=>"$now"],
['InternalPVID'=>1, "ADTCode"=>"X02", "LocationID"=>null, "AttDoc"=>2, "CreateDate"=>"$now"],
['InternalPVID'=>2, "ADTCode"=>"X01", "LocationID"=>1, "AttDoc"=>null, "CreateDate"=>"$now"],
['InternalPVID'=>2, "ADTCode"=>"X02", "LocationID"=>null, "AttDoc"=>1, "CreateDate"=>"$now"],
['InternalPVID'=>2, "ADTCode"=>"X01", "LocationID"=>2, "AttDoc"=>null, "CreateDate"=>"$now"],
['InternalPVID'=>2, "ADTCode"=>"X02", "LocationID"=>null, "AttDoc"=>2, "CreateDate"=>"$now"],
];
$this->db->table('patvisitadt')->insertBatch($data);
@ -114,8 +121,42 @@ class DummySeeder extends Seeder {
$this->db->table('department')->insertBatch($data);
$data = [
[ 'WorkstationID' => 1, 'DepartmentID' => 1, 'WorkstationCode' => 'QWST', 'WorkstationName'=>'Dummy Workstation', 'Type'=>null, 'LinkTo'=> null, 'Enable'=>1,'CreateDate' => "$now" ],
[ 'WorkstationID' => 1, 'DepartmentID' => 1, 'WorkstationCode' => 'QWST', 'WorkstationName'=>'Dummy Workstation', 'Type'=>null, 'LinkTo'=> null, 'Enable'=>$vs[2][1],'CreateDate' => "$now" ],
];
$this->db->table('workstation')->insertBatch($data);
// Test
// TNUM
$data = [ "TestSiteCode" => "QTNUM1", "TestSiteName" => "Dummy Test Numeric", "Type" => $vs[27]['TNum'], "Description" => "Dum Dum Numeric", "SeqScr" => "10", "SeqRpt" => "10", "IndentLeft" => "0",
"VisibleScr" => $vs[2][1], "VisibleRpt" => $vs[2][1], "CountStat" => $vs[2][1], "CreateDate" => "$now" ];
$id = $this->db->table('testdefsite')->insert($data);
$data = [ "DisciplineID" => 1, "DepartmentID" => 1, "VSet"=>'', "SpcType" => $vs[15]["BLD"], "ReqQty"=>"5", "ReqQtyUnit"=>$vs[16]['mL'], "Unit1"=>$vs[28]["mg/L"],
"Decimal"=>2, "Method"=>"DIY", "ExpectedTAT"=>"200Y", "CreateDate"=> "$now" ];
$data['TestSiteID']= $id;
$id = $this->db->table('testdeftech')->insert($data);
$data = [ "TestSiteCode" => "QTNUM2", "TestSiteName" => "Dummy Test Numeric", "Type" => $vs[27]['TNum'], "Description" => "Dum Dum Numeric", "SeqScr" => "20", "SeqRpt" => "20", "IndentLeft" => "0",
"VisibleScr" => $vs[2][1], "VisibleRpt" => $vs[2][1], "CountStat" => $vs[2][1], "CreateDate" => "$now" ];
$id = $this->db->table('testdefsite')->insert($data);
$data = [ "DisciplineID" => 1, "DepartmentID" => 1, "VSet"=>'', "SpcType" => $vs[15]["BLD"], "ReqQty"=>"50", "ReqQtyUnit"=>$vs[16]['mL'], "Unit1"=>$vs[28]["g/L"],
"Decimal"=>1, "Method"=>"YOLO", "ExpectedTAT"=>"1000Y", "CreateDate"=> "$now" ];
$data['TestSiteID']= $id;
$id = $this->db->table('testdeftech')->insert($data);
// PNum
$data = [ "TestSiteCode" => "QPNUM1", "TestSiteName" => "Dummy Test Param", "Type" => $vs[27]['PNum'], "Description" => "Dum Dum Param", "SeqScr" => "40", "SeqRpt" => "40", "IndentLeft" => "0",
"VisibleScr" => $vs[2][1], "VisibleRpt" => $vs[2][1], "CountStat" => $vs[2][1], "CreateDate" => "$now" ];
$id = $this->db->table('testdefsite')->insert($data);
$data = [ "DisciplineID" => 1, "DepartmentID" => 1, "Decimal"=>2, "CreateDate"=> "$now" ];
$data['TestSiteID']= $id;
$id = $this->db->table('testdeftech')->insert($data);
$data = [ "TestSiteCode" => "QPNUM2", "TestSiteName" => "Dummy Test Param", "Type" => $vs[27]['PNum'], "Description" => "Dum Dum Param", "SeqScr" => "50", "SeqRpt" => "50", "IndentLeft" => "0",
"VisibleScr" => $vs[2][1], "VisibleRpt" => $vs[2][1], "CountStat" => $vs[2][1], "CreateDate" => "$now" ];
$id = $this->db->table('testdefsite')->insert($data);
$data = [ "DisciplineID" => 1, "DepartmentID" => 1, "Decimal"=>3, "CreateDate"=> "$now" ];
$data['TestSiteID']= $id;
$id = $this->db->table('testdeftech')->insert($data);
}
}

View File

@ -6,7 +6,7 @@ use App\Models\BaseModel;
class PatVisitADTModel extends BaseModel {
protected $table = 'patvisitadt';
protected $primaryKey = 'PVADTID';
protected $allowedFields = ['InternalPVID', 'Sequence', 'ADTCode', 'LocationID', 'AttDoc', 'RefDoc', 'AdmDoc', 'CnsDoc',
protected $allowedFields = ['InternalPVID', 'ADTCode', 'LocationID', 'AttDoc', 'RefDoc', 'AdmDoc', 'CnsDoc',
'CreateDate', 'EndDate', 'ArchivedDate', 'DelDate'];
protected $visnum_prefix;