Add industry packages that provision workflow stages on onboarding.
Deploy Ladill Queue / deploy (push) Successful in 1m39s
Deploy Ladill Queue / deploy (push) Successful in 1m39s
Queue Core stays generic; selecting Healthcare, Banking, Restaurant, and other industries installs departments, stages (queues), service points, workflows, terminology, and announcement profiles without code changes per vertical. Care-linked orgs skip stage materialization so Care remains the clinical provisioner. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -5,9 +5,10 @@ namespace App\Http\Controllers\Api;
|
||||
use App\Http\Controllers\Api\Concerns\ScopesApiToAccount;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Branch;
|
||||
use App\Models\Department;
|
||||
use App\Models\Organization;
|
||||
use App\Services\Qms\AuditLogger;
|
||||
use App\Services\Qms\Industry\IndustryPackageInstaller;
|
||||
use App\Services\Qms\Industry\IndustryPackageRegistry;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -36,6 +37,8 @@ class IntegrationController extends Controller
|
||||
'provisioned' => true,
|
||||
'onboarded' => (bool) data_get($organization->settings, 'onboarded', false),
|
||||
'organization_name' => $organization->name,
|
||||
'industry' => data_get($organization->settings, 'industry'),
|
||||
'industry_package' => data_get($organization->settings, 'industry_package.key'),
|
||||
'integrations' => [
|
||||
'care' => (bool) data_get($organization->settings, 'integrations.care_enabled', false),
|
||||
'frontdesk' => (bool) data_get($organization->settings, 'integrations.frontdesk_enabled', false),
|
||||
@@ -48,6 +51,7 @@ class IntegrationController extends Controller
|
||||
{
|
||||
$owner = $this->ownerRef($request);
|
||||
$caller = (string) $request->attributes->get('service_caller', '');
|
||||
$registry = app(IndustryPackageRegistry::class);
|
||||
|
||||
$validated = $request->validate([
|
||||
'organization_name' => ['nullable', 'string', 'max:255'],
|
||||
@@ -56,8 +60,17 @@ class IntegrationController extends Controller
|
||||
'industry' => ['nullable', 'string'],
|
||||
]);
|
||||
|
||||
$defaultIndustry = match ($caller) {
|
||||
'care' => 'healthcare',
|
||||
'frontdesk' => 'visitor',
|
||||
'pos' => 'restaurant',
|
||||
default => 'custom',
|
||||
};
|
||||
$industry = $registry->resolveKey($validated['industry'] ?? $defaultIndustry);
|
||||
|
||||
$organization = Organization::owned($owner)->first();
|
||||
$created = false;
|
||||
$branch = null;
|
||||
|
||||
if (! $organization) {
|
||||
$created = true;
|
||||
@@ -69,7 +82,7 @@ class IntegrationController extends Controller
|
||||
'timezone' => $validated['timezone'] ?? config('app.timezone', 'UTC'),
|
||||
'settings' => [
|
||||
'onboarded' => true,
|
||||
'industry' => $validated['industry'] ?? ($caller === 'care' ? 'healthcare' : 'visitor'),
|
||||
'industry' => $industry,
|
||||
'appointment_mode' => 'hybrid',
|
||||
'integrations' => [
|
||||
'care_enabled' => false,
|
||||
@@ -85,25 +98,47 @@ class IntegrationController extends Controller
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
Department::create([
|
||||
'owner_ref' => $owner,
|
||||
'branch_id' => $branch->id,
|
||||
'name' => 'Reception',
|
||||
'type' => 'reception',
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
AuditLogger::record($owner, 'organization.created', $organization->id, $owner, Organization::class, $organization->id);
|
||||
} else {
|
||||
$branch = Branch::query()
|
||||
->where('organization_id', $organization->id)
|
||||
->where('is_active', true)
|
||||
->orderBy('id')
|
||||
->first();
|
||||
|
||||
if (! $branch) {
|
||||
$branch = Branch::create([
|
||||
'owner_ref' => $owner,
|
||||
'organization_id' => $organization->id,
|
||||
'name' => $validated['branch_name'] ?? 'Main branch',
|
||||
'is_active' => true,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array($caller, ['care', 'frontdesk'], true)) {
|
||||
$this->syncIntegrationFlag($organization->fresh(), $caller, true);
|
||||
$organization = $organization->fresh();
|
||||
}
|
||||
|
||||
// Care owns clinical stage graphs; still apply healthcare terminology/package metadata.
|
||||
$packageResult = app(IndustryPackageInstaller::class)->install(
|
||||
$organization->fresh(),
|
||||
$branch,
|
||||
$industry,
|
||||
[
|
||||
'actor_ref' => $owner,
|
||||
'skip_stages' => $caller === 'care',
|
||||
'include_optional' => true,
|
||||
],
|
||||
);
|
||||
|
||||
return response()->json([
|
||||
'data' => [
|
||||
'provisioned' => true,
|
||||
'organization_name' => $organization->fresh()->name,
|
||||
'industry' => $industry,
|
||||
'industry_package' => $packageResult,
|
||||
'integrations' => [
|
||||
'care' => (bool) data_get($organization->fresh()->settings, 'integrations.care_enabled', false),
|
||||
'frontdesk' => (bool) data_get($organization->fresh()->settings, 'integrations.frontdesk_enabled', false),
|
||||
|
||||
Reference in New Issue
Block a user