feat(treatment): per-case operators, shown on the list and searchable
A treatment case said which doctor supervised it but never who actually did the work, so the list could not answer the first question a manager asks about a course: who performed it. Two separate things now travel with the case. `performed_by` is history — derived from the sessions' performedBy, so it only ever reports what happened. `assigned_staff` is plan — a new treatment_case_staff table, editable from the modal, saying who is meant to handle this patient's course. The card shows the first and falls back to the second while nothing has been performed yet. Search matches both. A manager typing an operator's name wants that person's work, and work already done is part of it. Assignment also narrows the operator queue: a case with assigned staff shows its sessions only to those people, because a patient who started a multi-session course with one operator should keep them. An unassigned case keeps the existing protocol rule, and an empty list means "anyone the protocol allows" rather than "nobody" — the same "no rows is not a restriction" convention used elsewhere. Unlike areas, removing an operator erases nothing: a finished session carries its real operator on itself and never consults this list. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -74,12 +74,34 @@ class TreatmentCaseRepository extends ServiceEntityRepository
|
||||
}
|
||||
|
||||
if ($q !== null && $q !== '') {
|
||||
/**
|
||||
* پرسنل از دو راه میآید: کسی که به پرونده اختصاص یافته، و کسی که واقعاً
|
||||
* جلسهای از آن را انجام داده. مدیر که نام اپراتور را میزند هر دو را
|
||||
* میخواهد — «کارهای این نفر» شامل کارِ انجامشده هم هست.
|
||||
*/
|
||||
$assignedStaff = <<<'DQL'
|
||||
EXISTS (
|
||||
SELECT 1 FROM App\Treatment\Entity\TreatmentCaseStaff cs
|
||||
JOIN cs.staff cst
|
||||
WHERE cs.treatmentCase = c AND cst.fullName LIKE :q
|
||||
)
|
||||
DQL;
|
||||
|
||||
$performingStaff = <<<'DQL'
|
||||
EXISTS (
|
||||
SELECT 1 FROM App\Treatment\Entity\TreatmentSession ts
|
||||
JOIN ts.performedBy tsp
|
||||
WHERE ts.treatmentCase = c AND tsp.fullName LIKE :q
|
||||
)
|
||||
DQL;
|
||||
|
||||
$qb->join('c.patientRecord', 'pr')
|
||||
->join('pr.user', 'u')
|
||||
->join('c.serviceItem', 'si')
|
||||
->andWhere(
|
||||
'u.realName LIKE :q OR u.mobileNumber LIKE :q OR u.nationalCode LIKE :q'
|
||||
. ' OR pr.recordNumber LIKE :q OR si.name LIKE :q',
|
||||
. ' OR pr.recordNumber LIKE :q OR si.name LIKE :q'
|
||||
. ' OR ' . $assignedStaff . ' OR ' . $performingStaff,
|
||||
)
|
||||
->setParameter('q', '%' . $q . '%');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user