clqms-be/app/Database/Seeds/AreaGeoSeeder.php
mahdahar 5fb572c122 feat(routes): add container alias endpoint for ContainerDefController
Added an alternative route alias 'container' that points to ContainerDefController,
providing backward compatibility and flexibility in API endpoint naming.

- Routes '/api/specimen/container' to ContainerDefController methods
- Supports GET, GET with ID, POST, and PATCH operations
- Existing '/api/specimen/containerdef' routes remain unchanged

File: app/Config/Routes.php (+7 lines)

---

refactor(seeds): update and standardize seed data across multiple seeders

Improved data consistency and coverage in database seeds:

AreaGeoSeeder.php:
- Updated geographic area data for better regional coverage
- Standardized data format and field values

DummySeeder.php:
- Refactored dummy data generation for test environments
- Improved data integrity and relationships

PatientSeeder.php:
- Enhanced patient test data with more realistic scenarios
- Updated patient demographic information
- Improved test result distributions

Total: 111 lines changed across seed files

---

docs: add CLQMS project documentation

- Added project documentation file: "prj_clinical laboratory quality management system_3a.docx"
- Comprehensive project specification and requirements document

---

test: remove deprecated TestDefSiteTest.php

- Removed obsolete test file that is no longer needed
- Test coverage consolidated into other test classes

File: tests/feature/TestDef/TestDefSiteTest.php (-374 lines)

---

Summary:
- +58 lines added (routes, seeds, docs)
- -434 lines removed (deprecated test file)
- 6 files affected
2026-01-07 16:55:25 +07:00

56 lines
1.3 KiB
PHP

<?php
namespace App\Database\Seeds;
use CodeIgniter\Database\Seeder;
use CodeIgniter\HTTP\CURLRequest;
class AreaGeoSeeder extends Seeder
{
/**
* API configuration for fetching zones data
*/
protected string $apiUrl = 'https://your-api-domain.com/api/zones';
public function run()
{
// Fetch data from external API
$options = [
'baseURI' => $this->apiUrl,
'timeout' => 30,
];
$client = new CURLRequest($options);
$response = $client->get('');
if ($response->getStatusCode() !== 200) {
echo "Failed to fetch data from API. Status: " . $response->getStatusCode() . "\n";
return;
}
$externalData = $response->getJSON(true);
if (empty($externalData)) {
echo "No data found from API.\n";
return;
}
// Prepare data for insertion (exclude AreaGeoID to allow auto-increment)
$data = [];
foreach ($externalData as $row) {
$data[] = [
'AreaCode' => $row['zonecode'] ?? null,
'Class' => $row['zoneclass'] ?? null,
'AreaName' => str_replace('_', ' ', $row['zonename'] ?? ''),
'Parent' => $row['parentzoneid'] ?? null,
];
}
// Insert into local database
$this->db->table('areageo')->insertBatch($data);
echo "Successfully seeded " . count($data) . " area geo records.\n";
}
}