feat(secretary): implement grouping of secretaries by doctor and sync profile data across links

This commit is contained in:
hamed
2026-07-18 10:54:37 +03:30
parent 00cb9aaa1a
commit b659b84a7f
5 changed files with 273 additions and 51 deletions
@@ -142,6 +142,9 @@ class SecretaryService
}
$added = $removed = $skippedLimit = $skippedNotInClinic = [];
// New links inherit the person's existing profile/permissions so that a
// multi-doctor secretary stays a single consistent record.
$template = $existing[0] ?? null;
foreach ($wanted as $doctorUuid) {
$doctor = $this->doctorRepo->findByUuid($doctorUuid);
@@ -162,6 +165,11 @@ class SecretaryService
continue;
}
$row = new DoctorSecretary($doctor, $secretary, DoctorSecretary::OWNER_CLINIC, $clinic);
if ($template !== null) {
$row->setNationalCode($template->getNationalCode())
->setAddress($template->getAddress())
->setPermissions($template->getPermissions());
}
$this->secretaryRepo->save($row, false);
$added[] = $row;
}