feat(secretary): implement grouping of secretaries by doctor and sync profile data across links
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user