Complete overhaul of the valueset system to use human-readable names
instead of numeric IDs for improved maintainability and API consistency.
- PatientController: Renamed 'Gender' field to 'Sex' in validation rules
- ValuesetController: Changed API endpoints from ID-based (/:num) to name-based (/:any)
- TestsController: Refactored to use ValueSet library instead of direct valueset queries
- Added ValueSet library (app/Libraries/ValueSet.php) with static lookup methods:
- getOptions() - returns dropdown format [{value, label}]
- getLabel(, ) - returns label for a value
- transformLabels(, ) - batch transform records
- get() and getRaw() for Lookups compatibility
- Added ValueSetApiController for public valueset API endpoints
- Added ValueSet refresh endpoint (POST /api/valueset/refresh)
- Added DemoOrderController for testing order creation without auth
- 2026-01-12-000001: Convert valueset references from VID to VValue
- 2026-01-12-000002: Rename patient.Gender column to Sex
- OrderTestController: Now uses OrderTestModel with proper model pattern
- TestsController: Uses ValueSet library for all lookup operations
- ValueSetController: Simplified to use name-based lookups
- Updated all organization (account/site/workstation) dialogs and index views
- Updated specimen container dialogs and index views
- Updated tests_index.php with ValueSet integration
- Updated patient dialog form and index views
- Removed .factory/config.json and CLAUDE.md (replaced by AGENTS.md)
- Consolidated lookups in Lookups.php (removed inline valueset constants)
- Updated all test files to match new field names
- 32 modified files, 17 new files, 2 deleted files
- Net: +661 insertions, -1443 deletions (significant cleanup)
101 lines
4.5 KiB
PHP
101 lines
4.5 KiB
PHP
<?php
|
|
namespace App\Database\Seeds;
|
|
|
|
use CodeIgniter\Database\Seeder;
|
|
|
|
class MinimalMasterDataSeeder extends Seeder {
|
|
public function run() {
|
|
$db = \Config\Database::connect();
|
|
|
|
$orderStatuses = [
|
|
['VID' => 1, 'VSetID' => 11, 'VValue' => 'ORD', 'VDesc' => 'Ordered', 'VOrder' => 1],
|
|
['VID' => 2, 'VSetID' => 11, 'VValue' => 'SCH', 'VDesc' => 'Scheduled', 'VOrder' => 2],
|
|
['VID' => 3, 'VSetID' => 11, 'VValue' => 'ANA', 'VDesc' => 'Analysis', 'VOrder' => 3],
|
|
['VID' => 4, 'VSetID' => 11, 'VValue' => 'VER', 'VDesc' => 'Verified', 'VOrder' => 4],
|
|
['VID' => 5, 'VSetID' => 11, 'VValue' => 'REV', 'VDesc' => 'Reviewed', 'VOrder' => 5],
|
|
['VID' => 6, 'VSetID' => 11, 'VValue' => 'REP', 'VDesc' => 'Reported', 'VOrder' => 6],
|
|
];
|
|
|
|
$priorities = [
|
|
['VID' => 1, 'VSetID' => 10, 'VValue' => 'S', 'VDesc' => 'Stat', 'VOrder' => 1],
|
|
['VID' => 2, 'VSetID' => 10, 'VValue' => 'A', 'VDesc' => 'ASAP', 'VOrder' => 2],
|
|
['VID' => 3, 'VSetID' => 10, 'VValue' => 'R', 'VDesc' => 'Routine', 'VOrder' => 3],
|
|
['VID' => 4, 'VSetID' => 10, 'VValue' => 'P', 'VDesc' => 'Preop', 'VOrder' => 4],
|
|
];
|
|
|
|
$specimenTypes = [
|
|
['VID' => 1, 'VSetID' => 29, 'VValue' => 'BLD', 'VDesc' => 'Blood', 'VOrder' => 1],
|
|
['VID' => 2, 'VSetID' => 29, 'VValue' => 'SER', 'VDesc' => 'Serum', 'VOrder' => 2],
|
|
['VID' => 3, 'VSetID' => 29, 'VValue' => 'PLAS', 'VDesc' => 'Plasma', 'VOrder' => 3],
|
|
['VID' => 4, 'VSetID' => 29, 'VValue' => 'UR', 'VDesc' => 'Urine', 'VOrder' => 4],
|
|
['VID' => 5, 'VSetID' => 29, 'VValue' => 'CSF', 'VDesc' => 'Cerebrospinal Fluid', 'VOrder' => 5],
|
|
];
|
|
|
|
$testTypes = [
|
|
['VID' => 1, 'VSetID' => 27, 'VValue' => 'TEST', 'VDesc' => 'Test', 'VOrder' => 1],
|
|
['VID' => 2, 'VSetID' => 27, 'VValue' => 'PARAM', 'VDesc' => 'Parameter', 'VOrder' => 2],
|
|
['VID' => 3, 'VSetID' => 27, 'VValue' => 'CALC', 'VDesc' => 'Calculated Test', 'VOrder' => 3],
|
|
['VID' => 4, 'VSetID' => 27, 'VValue' => 'GROUP', 'VDesc' => 'Group Test', 'VOrder' => 4],
|
|
['VID' => 5, 'VSetID' => 27, 'VValue' => 'TITLE', 'VDesc' => 'Title', 'VOrder' => 5],
|
|
];
|
|
|
|
$genders = [
|
|
['VID' => 1, 'VSetID' => 3, 'VValue' => '1', 'VDesc' => 'Female', 'VOrder' => 1],
|
|
['VID' => 2, 'VSetID' => 3, 'VValue' => '2', 'VDesc' => 'Male', 'VOrder' => 2],
|
|
['VID' => 3, 'VSetID' => 3, 'VValue' => '3', 'VDesc' => 'Unknown', 'VOrder' => 3],
|
|
];
|
|
|
|
foreach ($orderStatuses as $row) {
|
|
$exists = $db->table('valueset')->where('VSetID', $row['VSetID'])->where('VValue', $row['VValue'])->get()->getRow();
|
|
if (!$exists) {
|
|
$db->table('valueset')->insert($row);
|
|
}
|
|
}
|
|
|
|
foreach ($priorities as $row) {
|
|
$exists = $db->table('valueset')->where('VSetID', $row['VSetID'])->where('VValue', $row['VValue'])->get()->getRow();
|
|
if (!$exists) {
|
|
$db->table('valueset')->insert($row);
|
|
}
|
|
}
|
|
|
|
foreach ($specimenTypes as $row) {
|
|
$exists = $db->table('valueset')->where('VSetID', $row['VSetID'])->where('VValue', $row['VValue'])->get()->getRow();
|
|
if (!$exists) {
|
|
$db->table('valueset')->insert($row);
|
|
}
|
|
}
|
|
|
|
foreach ($testTypes as $row) {
|
|
$exists = $db->table('valueset')->where('VSetID', $row['VSetID'])->where('VValue', $row['VValue'])->get()->getRow();
|
|
if (!$exists) {
|
|
$db->table('valueset')->insert($row);
|
|
}
|
|
}
|
|
|
|
foreach ($genders as $row) {
|
|
$exists = $db->table('valueset')->where('VSetID', $row['VSetID'])->where('VValue', $row['VValue'])->get()->getRow();
|
|
if (!$exists) {
|
|
$db->table('valueset')->insert($row);
|
|
}
|
|
}
|
|
|
|
$counterExists = $db->table('counter')->where('CounterName', 'ORDER')->get()->getRow();
|
|
if (!$counterExists) {
|
|
$db->table('counter')->insert(['CounterName' => 'ORDER', 'CounterValue' => 1]);
|
|
}
|
|
|
|
$siteExists = $db->table('site')->where('SiteCode', '00')->get()->getRow();
|
|
if (!$siteExists) {
|
|
$db->table('site')->insert([
|
|
'SiteCode' => '00',
|
|
'SiteName' => 'Main Laboratory',
|
|
'SiteType' => 'PHL',
|
|
'CreateDate' => date('Y-m-d H:i:s')
|
|
]);
|
|
}
|
|
|
|
echo "Minimal master data seeded successfully.\n";
|
|
}
|
|
}
|