forked from Yara724/api
feat(claims): require optional expert signatures and enrich PDF reports
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import { Injectable, NotFoundException } from "@nestjs/common";
|
||||
import { ExpertInsurerService } from "src/expert-insurer/expert-insurer.service";
|
||||
import { ClaimFactorsImageDbService } from "src/claim-request-management/entites/db-service/factor-image.db.service";
|
||||
import { Types } from "mongoose";
|
||||
import { BlameDocumentDbService } from "src/request-management/entities/db-service/blame-document.db.service";
|
||||
import { buildReportAttachments, buildReportSignatures } from "./report-media";
|
||||
import { buildInsurerFileReport } from "./case-expert-report.builder";
|
||||
import { InsurerFileReportViewModel } from "./case-expert-report.types";
|
||||
|
||||
@@ -7,6 +11,8 @@ import { InsurerFileReportViewModel } from "./case-expert-report.types";
|
||||
export class CaseExpertReportService {
|
||||
constructor(
|
||||
private readonly expertInsurerService: ExpertInsurerService,
|
||||
private readonly blameDocumentDbService: BlameDocumentDbService,
|
||||
private readonly factorImageDbService: ClaimFactorsImageDbService,
|
||||
) {}
|
||||
|
||||
async generateForInsurer(
|
||||
@@ -21,7 +27,28 @@ export class CaseExpertReportService {
|
||||
const file = await this.expertInsurerService.retrieveFileDetailsByPublicId(
|
||||
clientKey,
|
||||
publicId,
|
||||
true,
|
||||
);
|
||||
return buildInsurerFileReport(file);
|
||||
const blame = file.reportBlame ?? file.blame;
|
||||
const blameId = String(blame?._id ?? "");
|
||||
const claimId = String(file.claim?.claimRequestId ?? "");
|
||||
const [blameDocuments, invoices] = await Promise.all([
|
||||
Types.ObjectId.isValid(blameId)
|
||||
? this.blameDocumentDbService.findByRequestId(blameId)
|
||||
: [],
|
||||
Types.ObjectId.isValid(claimId)
|
||||
? this.factorImageDbService.findByClaimId(claimId)
|
||||
: [],
|
||||
]);
|
||||
return {
|
||||
...buildInsurerFileReport({ ...file, blame }),
|
||||
attachments: buildReportAttachments(
|
||||
file.claim,
|
||||
blame,
|
||||
blameDocuments,
|
||||
invoices,
|
||||
),
|
||||
signatures: buildReportSignatures(blame, file.claim),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user