diff --git a/.gitignore b/.gitignore index be05392..00a5c71 100644 --- a/.gitignore +++ b/.gitignore @@ -125,8 +125,3 @@ _modules/* /results/ /phpunit*.xml /public/.htaccess - -#------------------------- -# Claude -#------------------------- -.claude \ No newline at end of file diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 2a83766..0dd5622 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -51,7 +51,10 @@ $routes->group('v2', ['filter' => 'auth'], function ($routes) { // Master Data - Tests & ValueSets $routes->get('master/tests', 'PagesController::masterTests'); - $routes->get('master/valuesets', 'PagesController::masterValueSets'); + + $routes->get('valueset', 'PagesController::valueSetLibrary'); + $routes->get('result/valueset', 'PagesController::resultValueSet'); + $routes->get('result/valuesetdef', 'PagesController::resultValueSetDef'); }); // Faker @@ -158,12 +161,22 @@ $routes->group('api', function ($routes) { $routes->delete('items/(:num)', 'ValueSetController::deleteItem/$1'); }); - $routes->group('valuesetdef', function ($routes) { - $routes->get('/', 'ValueSetDefController::index'); - $routes->get('(:num)', 'ValueSetDefController::show/$1'); - $routes->post('/', 'ValueSetDefController::create'); - $routes->put('(:num)', 'ValueSetDefController::update/$1'); - $routes->delete('(:num)', 'ValueSetDefController::delete/$1'); + $routes->group('result', function ($routes) { + $routes->group('valueset', function ($routes) { + $routes->get('/', 'Result\ResultValueSetController::index'); + $routes->get('(:num)', 'Result\ResultValueSetController::show/$1'); + $routes->post('/', 'Result\ResultValueSetController::create'); + $routes->put('(:num)', 'Result\ResultValueSetController::update/$1'); + $routes->delete('(:num)', 'Result\ResultValueSetController::delete/$1'); + }); + + $routes->group('valuesetdef', function ($routes) { + $routes->get('/', 'ValueSetDefController::index'); + $routes->get('(:num)', 'ValueSetDefController::show/$1'); + $routes->post('/', 'ValueSetDefController::create'); + $routes->put('(:num)', 'ValueSetDefController::update/$1'); + $routes->delete('(:num)', 'ValueSetDefController::delete/$1'); + }); }); // Counter diff --git a/app/Controllers/PagesController.php b/app/Controllers/PagesController.php index e930108..f24e59d 100644 --- a/app/Controllers/PagesController.php +++ b/app/Controllers/PagesController.php @@ -155,13 +155,35 @@ class PagesController extends BaseController } /** - * Master Data - Value Sets + * Value Set Library - Read-only */ - public function masterValueSets() + public function valueSetLibrary() { - return view('v2/master/valuesets/valuesets_index', [ - 'pageTitle' => 'Value Sets', - 'activePage' => 'master-valuesets' + return view('v2/valueset/valueset_index', [ + 'pageTitle' => 'Value Set Library', + 'activePage' => 'valueset-library' + ]); + } + + /** + * Result Valueset - CRUD for valueset table + */ + public function resultValueSet() + { + return view('v2/result/valueset/resultvalueset_index', [ + 'pageTitle' => 'Result Valuesets', + 'activePage' => 'result-valueset' + ]); + } + + /** + * Result Valueset Definition - CRUD for valuesetdef table + */ + public function resultValueSetDef() + { + return view('v2/result/valuesetdef/resultvaluesetdef_index', [ + 'pageTitle' => 'Valueset Definitions', + 'activePage' => 'result-valuesetdef' ]); } diff --git a/app/Controllers/Result/ResultValueSetController.php b/app/Controllers/Result/ResultValueSetController.php new file mode 100644 index 0000000..21555f0 --- /dev/null +++ b/app/Controllers/Result/ResultValueSetController.php @@ -0,0 +1,144 @@ +dbModel = new ValueSetModel(); + } + + public function index() + { + $search = $this->request->getGet('search') ?? $this->request->getGet('param') ?? null; + $VSetID = $this->request->getGet('VSetID') ?? null; + + $rows = $this->dbModel->getValueSets($search, $VSetID); + + return $this->respond([ + 'status' => 'success', + 'data' => $rows + ], 200); + } + + public function show($id = null) + { + $row = $this->dbModel->getValueSet($id); + if (!$row) { + return $this->failNotFound("ValueSet item not found: $id"); + } + + return $this->respond([ + 'status' => 'success', + 'data' => $row + ], 200); + } + + public function create() + { + $input = $this->request->getJSON(true); + if (!$input) { + return $this->failValidationErrors(['Invalid JSON input']); + } + + $data = [ + 'SiteID' => $input['SiteID'] ?? 1, + 'VSetID' => $input['VSetID'] ?? null, + 'VOrder' => $input['VOrder'] ?? 0, + 'VValue' => $input['VValue'] ?? '', + 'VDesc' => $input['VDesc'] ?? '', + 'VCategory' => $input['VCategory'] ?? null + ]; + + if ($data['VSetID'] === null) { + return $this->failValidationErrors(['VSetID is required']); + } + + try { + $id = $this->dbModel->insert($data, true); + if (!$id) { + return $this->failValidationErrors($this->dbModel->errors()); + } + + $newRow = $this->dbModel->getValueSet($id); + return $this->respondCreated([ + 'status' => 'success', + 'message' => 'ValueSet item created', + 'data' => $newRow + ]); + } catch (\Exception $e) { + return $this->failServerError('Failed to create: ' . $e->getMessage()); + } + } + + public function update($id = null) + { + $input = $this->request->getJSON(true); + if (!$input) { + return $this->failValidationErrors(['Invalid JSON input']); + } + + $existing = $this->dbModel->getValueSet($id); + if (!$existing) { + return $this->failNotFound("ValueSet item not found: $id"); + } + + $data = []; + if (isset($input['VSetID'])) $data['VSetID'] = $input['VSetID']; + if (isset($input['VOrder'])) $data['VOrder'] = $input['VOrder']; + if (isset($input['VValue'])) $data['VValue'] = $input['VValue']; + if (isset($input['VDesc'])) $data['VDesc'] = $input['VDesc']; + if (isset($input['SiteID'])) $data['SiteID'] = $input['SiteID']; + if (isset($input['VCategory'])) $data['VCategory'] = $input['VCategory']; + + if (empty($data)) { + return $this->respond([ + 'status' => 'success', + 'message' => 'No changes to update', + 'data' => $existing + ], 200); + } + + try { + $updated = $this->dbModel->update($id, $data); + if (!$updated) { + return $this->failValidationErrors($this->dbModel->errors()); + } + + $newRow = $this->dbModel->getValueSet($id); + return $this->respond([ + 'status' => 'success', + 'message' => 'ValueSet item updated', + 'data' => $newRow + ], 200); + } catch (\Exception $e) { + return $this->failServerError('Failed to update: ' . $e->getMessage()); + } + } + + public function delete($id = null) + { + $existing = $this->dbModel->getValueSet($id); + if (!$existing) { + return $this->failNotFound("ValueSet item not found: $id"); + } + + try { + $this->dbModel->delete($id); + return $this->respond([ + 'status' => 'success', + 'message' => 'ValueSet item deleted' + ], 200); + } catch (\Exception $e) { + return $this->failServerError('Failed to delete: ' . $e->getMessage()); + } + } +} diff --git a/app/Controllers/ValueSetController.php b/app/Controllers/ValueSetController.php index 94a54a8..972476d 100644 --- a/app/Controllers/ValueSetController.php +++ b/app/Controllers/ValueSetController.php @@ -19,10 +19,19 @@ class ValueSetController extends \CodeIgniter\Controller public function index(?string $lookupName = null) { + $search = $this->request->getGet('search') ?? null; + if ($lookupName === null) { $all = ValueSet::getAll(); $result = []; foreach ($all as $name => $entry) { + if ($search) { + $nameLower = strtolower($name); + $searchLower = strtolower($search); + if (strpos($nameLower, $searchLower) === false) { + continue; + } + } $count = count($entry['values'] ?? []); $result[$name] = $count; } diff --git a/app/Views/v2/layout/main_layout.php b/app/Views/v2/layout/main_layout.php index de86511..ba41b14 100644 --- a/app/Views/v2/layout/main_layout.php +++ b/app/Views/v2/layout/main_layout.php @@ -173,14 +173,39 @@ - +
  • - - - Value Sets - +
    + + +
  • @@ -319,6 +344,7 @@ lightMode: localStorage.getItem('theme') !== 'dark', orgOpen: false, specimenOpen: false, + valuesetOpen: false, currentPath: window.location.pathname, init() { @@ -333,6 +359,7 @@ // Auto-expand menus based on active path this.orgOpen = this.currentPath.includes('organization'); this.specimenOpen = this.currentPath.includes('specimen'); + this.valuesetOpen = this.currentPath.includes('valueset'); // Watch sidebar state to persist this.$watch('sidebarOpen', val => localStorage.setItem('sidebarOpen', val)); diff --git a/app/Views/v2/master/valuesets/valueset_nested_crud.php b/app/Views/v2/master/valuesets/valueset_nested_crud.php deleted file mode 100644 index f1f4152..0000000 --- a/app/Views/v2/master/valuesets/valueset_nested_crud.php +++ /dev/null @@ -1,363 +0,0 @@ - - - - diff --git a/app/Views/v2/master/valuesets/valuesets_index.php b/app/Views/v2/master/valuesets/valuesets_index.php deleted file mode 100644 index 6761013..0000000 --- a/app/Views/v2/master/valuesets/valuesets_index.php +++ /dev/null @@ -1,678 +0,0 @@ -extend("v2/layout/main_layout"); ?> - -section("content") ?> -
    - - -
    -
    -
    - -
    -
    -

    Value Set Manager

    -

    Manage value set categories and their items

    -
    -
    -
    - - -
    - - -
    - -
    -
    -
    - -
    -
    -

    Categories

    -

    Value Set Definitions

    -
    -
    - -
    - - -
    -
    - - -
    -
    - - -
    -
    -

    Loading categories...

    -
    - - -
    - - - - - - - - - - - - - - -
    IDCategory NameItemsActions
    -
    - - -
    - -
    -
    - - -
    - -
    -
    -
    - -
    -
    -

    Items

    -

    - - -

    -
    -
    - -
    - - -
    -
    - - -
    -
    - - -
    -
    - -

    Select a category

    -

    Click on a category from the left panel to view and manage its items

    -
    -
    - - -
    -
    -

    Loading items...

    -
    - - -
    - - - - - - - - - - - - - - - -
    IDValueDescriptionOrderActions
    -
    - - -
    - -
    -
    -
    - - - include('v2/master/valuesets/valuesetdef_dialog') ?> - - - include('v2/master/valuesets/valueset_dialog') ?> - - - - - - - -
    -endSection() ?> - -section("script") ?> - -endSection() ?> diff --git a/app/Views/v2/master/valuesets/valueset_dialog.php b/app/Views/v2/result/valueset/resultvalueset_dialog.php similarity index 94% rename from app/Views/v2/master/valuesets/valueset_dialog.php rename to app/Views/v2/result/valueset/resultvalueset_dialog.php index 6e23069..440392c 100644 --- a/app/Views/v2/master/valuesets/valueset_dialog.php +++ b/app/Views/v2/result/valueset/resultvalueset_dialog.php @@ -1,4 +1,4 @@ - +
    -

    @@ -32,10 +31,8 @@

    -
    - - -
    +

    Category Assignment

    @@ -63,7 +59,6 @@
    -

    Item Details

    @@ -109,7 +104,6 @@
    -

    System Information

    @@ -143,7 +137,6 @@
    -
    +
    + +
    +
    + + +
    +
    +
    +

    Loading valuesets...

    +
    + +
    + + + + + + + + + + + + + + + + +
    IDCategoryValueDescriptionOrderActions
    +
    +
    + + include('v2/result/valueset/resultvalueset_dialog') ?> + + + + +endSection() ?> + +section("script") ?> + +endSection() ?> diff --git a/app/Views/v2/master/valuesets/valuesetdef_dialog.php b/app/Views/v2/result/valuesetdef/resultvaluesetdef_dialog.php similarity index 95% rename from app/Views/v2/master/valuesets/valuesetdef_dialog.php rename to app/Views/v2/result/valuesetdef/resultvaluesetdef_dialog.php index 6723c51..c191efd 100644 --- a/app/Views/v2/master/valuesets/valuesetdef_dialog.php +++ b/app/Views/v2/result/valuesetdef/resultvaluesetdef_dialog.php @@ -1,4 +1,4 @@ - +
    -

    @@ -32,10 +31,8 @@

    -
    - -

    Basic Information

    @@ -75,7 +71,6 @@
    -

    System Information

    @@ -109,7 +104,6 @@
    -
    +
    + +
    + + + +
    +
    +
    +

    Loading definitions...

    +
    + +
    + + + + + + + + + + + + + + + +
    IDCategory NameDescriptionItemsActions
    +
    +
    + + include('v2/result/valuesetdef/resultvaluesetdef_dialog') ?> + + + + +endSection() ?> + +section("script") ?> + +endSection() ?> diff --git a/app/Views/v2/valueset/valueset_index.php b/app/Views/v2/valueset/valueset_index.php new file mode 100644 index 0000000..f32b003 --- /dev/null +++ b/app/Views/v2/valueset/valueset_index.php @@ -0,0 +1,371 @@ +extend("v2/layout/main_layout"); ?> + +section("content") ?> +
    + + +
    +
    +
    +
    + +
    +
    +

    Value Set Library

    +

    Browse predefined value sets from library

    +
    +
    + +
    +
    +

    +

    Value Sets

    +
    +
    +
    +

    +

    Total Items

    +
    +
    +
    +
    + + +
    + + +
    + +
    +

    Categories

    +
    + + + +
    +
    + + +
    + +
    + +
    + + +
    + +

    No categories found

    +
    + + +
    + +
    +
    + + +
    + categories +
    +
    + + +
    + +
    +
    +
    +
    + +
    +
    +

    +

    +
    +
    +
    + + +
    +
    + + +
    +
    +
    + + +
    + +
    + +

    Select a category from the left to view values

    +
    + + +
    +
    +

    Loading items...

    +
    + + +
    + + + + + + +
    +
    + + +
    + Showing of items +
    +
    + +
    + +
    +endSection() ?> + +section("script") ?> + +endSection() ?> diff --git a/app/Views/v2/welcome_message.php b/app/Views/v2/welcome_message.php deleted file mode 100644 index 90abad7..0000000 --- a/app/Views/v2/welcome_message.php +++ /dev/null @@ -1,12 +0,0 @@ - - - - Hello World Page - - - -

    Hello World!

    -

    This is a simple HTML page.

    - - - \ No newline at end of file diff --git a/app/Views/welcome_message.php b/app/Views/welcome_message.php deleted file mode 100644 index 90abad7..0000000 --- a/app/Views/welcome_message.php +++ /dev/null @@ -1,12 +0,0 @@ - - - - Hello World Page - - - -

    Hello World!

    -

    This is a simple HTML page.

    - - - \ No newline at end of file