forked from Yara724/api
Added AI damage helper
This commit is contained in:
@@ -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,
|
||||
@@ -58,6 +61,8 @@ export class ExpertInsurerController {
|
||||
constructor(
|
||||
private readonly expertInsurerService: ExpertInsurerService,
|
||||
private readonly reportsService: ReportsService,
|
||||
private readonly aiService: AiService,
|
||||
private readonly claimCaseDbService: ClaimCaseDbService,
|
||||
) {}
|
||||
|
||||
// ─── Branch management ────────────────────────────────────────────────────
|
||||
@@ -403,6 +408,26 @@ export class ExpertInsurerController {
|
||||
return await this.expertInsurerService.getFileTimeline(insurer.clientKey, publicId);
|
||||
}
|
||||
|
||||
@Get("files/:publicId/ai-analysis")
|
||||
@ApiOperation({ summary: "AI damage analysis for an insurer's file" })
|
||||
async getAiAnalysis(@CurrentUser() insurer: any, @Param("publicId") publicId: string) {
|
||||
const detail = await this.expertInsurerService.retrieveFileDetailsByPublicId(insurer.clientKey, 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("files/:publicId/ai-analysis/retry")
|
||||
@ApiOperation({ summary: "Retry failed AI analyses for an insurer's file" })
|
||||
async retryAiAnalysis(@CurrentUser() insurer: any, @Param("publicId") publicId: string) {
|
||||
const detail = await this.expertInsurerService.retrieveFileDetailsByPublicId(insurer.clientKey, 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("files/:publicId")
|
||||
@ApiParam({ name: "publicId" })
|
||||
async getFileDetailsByPublicId(@CurrentUser() insurer, @Param("publicId") publicId: string) {
|
||||
|
||||
Reference in New Issue
Block a user