|
|
|
@@ -107,6 +107,10 @@ class DemoTenantSeeder
|
|
|
|
|
$this->upsertOwnerMember($organization, $ownerRef);
|
|
|
|
|
|
|
|
|
|
$branches = $this->seedBranches($organization, $ownerRef, $volumes);
|
|
|
|
|
// Lab catalog early — survives if later clinical seeding fails mid-run.
|
|
|
|
|
$investigationTypes = $volumes['paid_modules']
|
|
|
|
|
? $this->seedInvestigationCatalog($organization, $ownerRef)
|
|
|
|
|
: [];
|
|
|
|
|
$this->seedStaffMembers($organization, $ownerRef, $plan, $branches);
|
|
|
|
|
$departments = $this->seedDepartments($branches, $ownerRef, $volumes);
|
|
|
|
|
if (in_array($plan, ['pro', 'enterprise'], true)) {
|
|
|
|
@@ -138,7 +142,11 @@ class DemoTenantSeeder
|
|
|
|
|
$this->assignAllDemoWaiters($organization, $ownerRef, $branches, $practitioners);
|
|
|
|
|
$this->renumberWaitingQueuePositions($organization, $ownerRef, $branches);
|
|
|
|
|
|
|
|
|
|
// Catalog first so a later lab-request failure never leaves Lab → Catalog empty.
|
|
|
|
|
if ($volumes['paid_modules']) {
|
|
|
|
|
if ($investigationTypes === []) {
|
|
|
|
|
$investigationTypes = $this->seedInvestigationCatalog($organization, $ownerRef);
|
|
|
|
|
}
|
|
|
|
|
$this->seedPaidModules(
|
|
|
|
|
$organization,
|
|
|
|
|
$branches,
|
|
|
|
@@ -146,6 +154,7 @@ class DemoTenantSeeder
|
|
|
|
|
$patients,
|
|
|
|
|
$ownerRef,
|
|
|
|
|
$volumes,
|
|
|
|
|
$investigationTypes,
|
|
|
|
|
);
|
|
|
|
|
$this->seedDevices($organization, $branches, $ownerRef);
|
|
|
|
|
}
|
|
|
|
@@ -434,6 +443,12 @@ class DemoTenantSeeder
|
|
|
|
|
DB::table('care_patients')->where('owner_ref', $ownerRef)->delete();
|
|
|
|
|
|
|
|
|
|
DB::table('care_practitioner_schedules')->where('owner_ref', $ownerRef)->delete();
|
|
|
|
|
if (Schema::hasTable('care_practitioner_branch')) {
|
|
|
|
|
$practitionerIds = DB::table('care_practitioners')->where('owner_ref', $ownerRef)->pluck('id');
|
|
|
|
|
if ($practitionerIds->isNotEmpty()) {
|
|
|
|
|
DB::table('care_practitioner_branch')->whereIn('practitioner_id', $practitionerIds)->delete();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
DB::table('care_practitioners')->where('owner_ref', $ownerRef)->delete();
|
|
|
|
|
|
|
|
|
|
// Keep the owner member + organization so SSO redirects never see
|
|
|
|
@@ -1214,21 +1229,26 @@ class DemoTenantSeeder
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function seedPaidModules(
|
|
|
|
|
Organization $organization,
|
|
|
|
|
array $branches,
|
|
|
|
|
array $practitioners,
|
|
|
|
|
array $patients,
|
|
|
|
|
string $ownerRef,
|
|
|
|
|
array $volumes,
|
|
|
|
|
): void {
|
|
|
|
|
/**
|
|
|
|
|
* @return list<InvestigationType>
|
|
|
|
|
*/
|
|
|
|
|
private function seedInvestigationCatalog(Organization $organization, string $ownerRef): array
|
|
|
|
|
{
|
|
|
|
|
$types = [];
|
|
|
|
|
foreach ([
|
|
|
|
|
['name' => 'Fasting Blood Glucose', 'code' => 'FBG', 'category' => 'blood', 'unit' => 'mmol/L', 'low' => 3.9, 'high' => 6.1, 'price' => 2500],
|
|
|
|
|
['name' => 'Full Blood Count', 'code' => 'FBC', 'category' => 'blood', 'unit' => null, 'low' => null, 'high' => null, 'price' => 4500],
|
|
|
|
|
['name' => 'Malaria Parasite', 'code' => 'MP', 'category' => 'blood', 'unit' => null, 'low' => null, 'high' => null, 'price' => 1500],
|
|
|
|
|
['name' => 'Urinalysis', 'code' => 'UA', 'category' => 'urine', 'unit' => null, 'low' => null, 'high' => null, 'price' => 2000],
|
|
|
|
|
] as $i => $spec) {
|
|
|
|
|
['name' => 'HbA1c', 'code' => 'HBA1C', 'category' => 'blood', 'unit' => '%', 'low' => null, 'high' => 5.7, 'price' => 6000],
|
|
|
|
|
['name' => 'Lipid Profile', 'code' => 'LIPID', 'category' => 'blood', 'unit' => null, 'low' => null, 'high' => null, 'price' => 5500],
|
|
|
|
|
['name' => 'Liver Function Test', 'code' => 'LFT', 'category' => 'blood', 'unit' => null, 'low' => null, 'high' => null, 'price' => 5000],
|
|
|
|
|
['name' => 'Kidney Function Test', 'code' => 'KFT', 'category' => 'blood', 'unit' => null, 'low' => null, 'high' => null, 'price' => 5000],
|
|
|
|
|
['name' => 'Blood Group & Rh', 'code' => 'BGRH', 'category' => 'blood', 'unit' => null, 'low' => null, 'high' => null, 'price' => 1800],
|
|
|
|
|
['name' => 'Pregnancy Test (Urine)', 'code' => 'HCG', 'category' => 'urine', 'unit' => null, 'low' => null, 'high' => null, 'price' => 1200],
|
|
|
|
|
['name' => 'Stool Routine Examination', 'code' => 'SRE', 'category' => 'stool', 'unit' => null, 'low' => null, 'high' => null, 'price' => 2200],
|
|
|
|
|
['name' => 'Chest X-Ray', 'code' => 'CXR', 'category' => 'xray', 'unit' => null, 'low' => null, 'high' => null, 'price' => 8000],
|
|
|
|
|
] as $spec) {
|
|
|
|
|
$types[] = InvestigationType::withTrashed()->updateOrCreate(
|
|
|
|
|
[
|
|
|
|
|
'organization_id' => $organization->id,
|
|
|
|
@@ -1248,6 +1268,28 @@ class DemoTenantSeeder
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $types;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param list<Branch> $branches
|
|
|
|
|
* @param list<Practitioner> $practitioners
|
|
|
|
|
* @param list<Patient> $patients
|
|
|
|
|
* @param list<InvestigationType> $types
|
|
|
|
|
*/
|
|
|
|
|
private function seedPaidModules(
|
|
|
|
|
Organization $organization,
|
|
|
|
|
array $branches,
|
|
|
|
|
array $practitioners,
|
|
|
|
|
array $patients,
|
|
|
|
|
string $ownerRef,
|
|
|
|
|
array $volumes,
|
|
|
|
|
array $types = [],
|
|
|
|
|
): void {
|
|
|
|
|
if ($types === []) {
|
|
|
|
|
$types = $this->seedInvestigationCatalog($organization, $ownerRef);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$drugs = [];
|
|
|
|
|
foreach ([
|
|
|
|
|
['name' => 'Amoxicillin 500mg', 'unit' => 'capsule', 'price' => 1500],
|
|
|
|
@@ -1288,6 +1330,10 @@ class DemoTenantSeeder
|
|
|
|
|
$drugs[] = $drug;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($patients === [] || $practitioners === [] || $types === [] || $branches === []) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for ($i = 0; $i < $volumes['lab_requests']; $i++) {
|
|
|
|
|
$patient = $patients[$i % count($patients)];
|
|
|
|
|
$branch = $branches[$i % count($branches)];
|
|
|
|
|