Added AI damage helper

This commit is contained in:
SepehrYahyaee
2026-10-03 16:38:48 +03:30
parent 18ccfa81e4
commit 2f92766689
22 changed files with 1085 additions and 442 deletions
+27
View File
@@ -1,3 +1,6 @@
import { AiService } from "src/ai/ai.service";
import { currentAiCaptures } from "src/ai/ai-captures";
import { ClaimCaseDbService } from "src/claim-request-management/entites/db-service/claim-case.db.service";
import {
BadRequestException,
Body,
@@ -64,6 +67,8 @@ export class SuperAdminController {
private readonly superAdminService: SuperAdminService,
private readonly systemSettingsService: SystemSettingsService,
private readonly expertInsurerService: ExpertInsurerService,
private readonly aiService: AiService,
private readonly claimCaseDbService: ClaimCaseDbService,
) {}
// ── Super-admin account management ───────────────────────────────────────
@@ -428,6 +433,28 @@ export class SuperAdminController {
return this.expertInsurerService.getFileTimeline(clientId, publicId);
}
@Get("insurer/files/:publicId/ai-analysis")
@ApiOperation({ summary: "AI analysis for a file of the selected client" })
@ApiQuery({ name: "clientId", required: true, type: String })
async getAiAnalysis(@Query("clientId") clientId: string, @Param("publicId") publicId: string) {
const detail = await this.expertInsurerService.retrieveFileDetailsByPublicId(clientId, publicId);
const id = typeof detail.claim?.claimRequestId === "string" ? detail.claim.claimRequestId : undefined;
if (!id) return { enabled: this.aiService.enabled, images: [] };
const claim = await this.claimCaseDbService.findById(id);
return this.aiService.list(id, currentAiCaptures(claim));
}
@Post("insurer/files/:publicId/ai-analysis/retry")
@ApiOperation({ summary: "Retry failed AI analyses for the selected client's file" })
@ApiQuery({ name: "clientId", required: true, type: String })
async retryAiAnalysis(@Query("clientId") clientId: string, @Param("publicId") publicId: string) {
const detail = await this.expertInsurerService.retrieveFileDetailsByPublicId(clientId, publicId);
const id = typeof detail.claim?.claimRequestId === "string" ? detail.claim.claimRequestId : undefined;
if (!id) return { enabled: this.aiService.enabled, images: [] };
const claim = await this.claimCaseDbService.findById(id);
return this.aiService.retry(id, currentAiCaptures(claim));
}
@Get("insurer/files/:publicId")
@ApiOperation({ summary: "File details by publicId for a given client" })
@ApiParam({ name: "publicId" })