Apply clinic lab workflow feedback

This commit is contained in:
egecankomur
2026-07-15 22:13:01 +03:00
parent ac42681f7e
commit f44e07f378
9 changed files with 478 additions and 119 deletions
@@ -28,6 +28,7 @@ class LabJobsRepository {
perPage: limit,
filter: filterParts.join(' && '),
expand: _listExpand,
sort: '-created',
);
return (result.items.map((r) => Job.fromJson(r.toJson())).toList()
..sort((a, b) => b.dateCreated.compareTo(a.dateCreated)));
@@ -44,6 +45,7 @@ class LabJobsRepository {
perPage: limit,
filter: filterParts.join(' && '),
expand: _listExpand,
sort: location == null ? '-created' : null,
);
return (result.items.map((r) => Job.fromJson(r.toJson())).toList()
..sort((a, b) {
@@ -89,9 +91,12 @@ class LabJobsRepository {
final isFinal = currentStep == JobStep.cilaBitim;
final nextStep = job.nextStep;
final shouldStayAtLabAfterMeasure = !job.provaRequired &&
currentStep == JobStep.olcuKontrol &&
nextStep == JobStep.cilaBitim;
final patch = isFinal
? {'status': 'sent', 'location': 'at_clinic'}
: currentStep.requiresClinicApproval
: currentStep.requiresClinicApproval && !shouldStayAtLabAfterMeasure
? {'location': 'at_clinic'}
: {
'current_step': nextStep?.value,
@@ -104,7 +109,9 @@ class LabJobsRepository {
jobId: jobId,
clinicTenantId: job.clinicTenantId,
labTenantId: job.labTenantId,
action: currentStep.requiresClinicApproval || isFinal
action: (currentStep.requiresClinicApproval &&
!shouldStayAtLabAfterMeasure) ||
isFinal
? JobHistoryAction.handedToClinic
: JobHistoryAction.stepCompleted,
step: currentStep,