improvement: notify counter badge added to treatment and tasks tabs for upadted and edited cases.

This commit is contained in:
2026-07-13 17:44:44 +03:30
parent 547457d637
commit 2ad572f4c8
33 changed files with 908 additions and 31 deletions

View File

@@ -3,11 +3,12 @@ import { PrismaService } from '../../../prisma/prisma.service';
import { ClinicOrgGuard } from '../../common/guards/clinic-org.guard';
import { ProsthesisCatalogModule } from '../prosthesis-catalog/prosthesis-catalog.module';
import { LabCaseCommentsModule } from '../lab-case-comments/lab-case-comments.module';
import { NotificationsModule } from '../notifications/notifications.module';
import { TreatmentsController } from './treatments.controller';
import { TreatmentsService } from './treatments.service';
@Module({
imports: [ProsthesisCatalogModule, LabCaseCommentsModule],
imports: [ProsthesisCatalogModule, LabCaseCommentsModule, NotificationsModule],
controllers: [TreatmentsController],
providers: [TreatmentsService, PrismaService, ClinicOrgGuard],
})

View File

@@ -4,7 +4,7 @@ import {
Injectable,
NotFoundException,
} from '@nestjs/common';
import { LabTaskStatus, LinkStatus, Prisma } from '@prisma/client';
import { LabCaseActivityType, LabTaskStatus, LinkStatus, Prisma } from '@prisma/client';
import { createReadStream, existsSync, mkdirSync } from 'fs';
import { join } from 'path';
import { randomUUID } from 'crypto';
@@ -21,6 +21,7 @@ import {
isLabCaseFullyCompleted,
parseDueDateInput,
} from '../../common/lab-case-due-date';
import { LabCaseActivityService } from '../notifications/lab-case-activity.service';
import {
generateTreatmentTitle,
normalizeTeeth,
@@ -83,6 +84,7 @@ export class TreatmentsService {
private readonly prisma: PrismaService,
private readonly treatmentCatalog: TreatmentCatalogService,
private readonly prosthesisCatalog: ProsthesisCatalogService,
private readonly labCaseActivity: LabCaseActivityService,
) {}
getOrganizationIdFromUser(user: { organizationId?: string }) {
@@ -558,6 +560,7 @@ export class TreatmentsService {
}
const now = new Date();
const isFirstSend = !labCase.sentAt;
await this.prisma.$transaction(async (tx) => {
await tx.labCaseSend.create({
@@ -575,6 +578,17 @@ export class TreatmentsService {
}
await generateLabCaseTasks(tx, labCaseId, actorLanguage);
if (isFirstSend) {
await this.labCaseActivity.record(
{
labCaseId,
type: LabCaseActivityType.CASE_SENT,
actorUserId,
},
tx,
);
}
});
const refreshed = await this.prisma.labCase.findUniqueOrThrow({