feat(patient): implement record number pattern management
- Add RecordNumberSettingsController for managing patient record number patterns. - Create RecordNumberPattern entity to represent the pattern configuration. - Implement RecordNumberPatternRepository for database interactions. - Develop RecordNumberGenerator service for generating and validating record numbers. - Add tests for record number generation, backfilling, and API interactions. - Ensure proper access control for viewing and updating patterns based on user roles.
This commit is contained in:
@@ -94,6 +94,24 @@ class EntityContextResolver
|
||||
return $clinic !== null ? EntityContext::forClinic($clinic) : EntityContext::unknown();
|
||||
}
|
||||
|
||||
/**
|
||||
* آیا این کاربر **صاحبِ** همین محیط است؟ (ادمین همیشه بله.)
|
||||
*
|
||||
* «صاحب» با «میتواند در آن بایستد» فرق دارد: پزشکِ مهمانِ یک کلینیک در محیط آن
|
||||
* میایستد ولی صاحبش نیست. تصمیمهایی که قراردادِ کلِ مجموعه را عوض میکنند —
|
||||
* مثل الگوی شمارهٔ پرونده — به این پرسش وصلاند، نه به مجوزهای per-resource.
|
||||
*/
|
||||
public function owns(User $user, string $entityType, ?int $entityId): bool
|
||||
{
|
||||
if ($user->hasRole('ROLE_ADMIN')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
[$ownedType, $ownedId] = $this->ownedEntity($user)->toEntityPair();
|
||||
|
||||
return $ownedId !== null && $ownedType === $entityType && $ownedId === $entityId;
|
||||
}
|
||||
|
||||
/**
|
||||
* مالک کلینیک، ادمین، پزشکِ عضو همان کلینیک، منشیِ دارای رابطهٔ فعال در آن، یا
|
||||
* پرسنلِ فعالِ همان کلینیک.
|
||||
|
||||
Reference in New Issue
Block a user