forked from Yara724/api
Added case type for all GET APIs
This commit is contained in:
@@ -10797,16 +10797,41 @@ export class ClaimRequestManagementService {
|
||||
}
|
||||
claims = [...byId.values()];
|
||||
}
|
||||
const list = (claims as any[]).map((c) => ({
|
||||
claimRequestId: c._id.toString(),
|
||||
publicId: c.publicId,
|
||||
requestNo: c.requestNo,
|
||||
status: c.status,
|
||||
claimStatus: c.claimStatus || "PENDING",
|
||||
currentStep: c.workflow?.currentStep || "",
|
||||
createdAt: c.createdAt,
|
||||
blameRequestId: c.blameRequestId?.toString(),
|
||||
})) as ClaimListItemV2Dto[];
|
||||
const blameIdsForList = [
|
||||
...new Set(
|
||||
(claims as any[])
|
||||
.map((c) => c.blameRequestId?.toString())
|
||||
.filter((id): id is string => !!id),
|
||||
),
|
||||
];
|
||||
const blamesForList =
|
||||
blameIdsForList.length > 0
|
||||
? ((await this.blameRequestDbService.find(
|
||||
{ _id: { $in: blameIdsForList.map((id) => new Types.ObjectId(id)) } },
|
||||
{ lean: true, select: "type creationMethod" },
|
||||
)) as any[])
|
||||
: [];
|
||||
const blameByIdForList = new Map<string, any>(
|
||||
blamesForList.map((b) => [String(b._id), b]),
|
||||
);
|
||||
|
||||
const list = (claims as any[]).map((c) => {
|
||||
const blameForItem = c.blameRequestId
|
||||
? blameByIdForList.get(c.blameRequestId.toString())
|
||||
: undefined;
|
||||
return {
|
||||
claimRequestId: c._id.toString(),
|
||||
publicId: c.publicId,
|
||||
requestNo: c.requestNo,
|
||||
status: c.status,
|
||||
claimStatus: c.claimStatus || "PENDING",
|
||||
currentStep: c.workflow?.currentStep || "",
|
||||
createdAt: c.createdAt,
|
||||
blameRequestId: c.blameRequestId?.toString(),
|
||||
blameType: blameForItem?.type ?? undefined,
|
||||
creationMethod: blameForItem?.creationMethod ?? undefined,
|
||||
};
|
||||
}) as ClaimListItemV2Dto[];
|
||||
|
||||
const paged = applyListQueryV2(
|
||||
list,
|
||||
@@ -10856,6 +10881,15 @@ export class ClaimRequestManagementService {
|
||||
}
|
||||
await this.assertActorCanViewClaimV2(claim, currentUserId, actor);
|
||||
|
||||
const blameForDetail = claim.blameRequestId
|
||||
? ((
|
||||
await this.blameRequestDbService.find(
|
||||
{ _id: new Types.ObjectId(claim.blameRequestId.toString()) },
|
||||
{ lean: true, select: "type creationMethod" },
|
||||
)
|
||||
)[0] ?? null)
|
||||
: null;
|
||||
|
||||
const hasCapture = (data: any, key: string) =>
|
||||
data && (data instanceof Map ? data.get(key) : data[key]);
|
||||
|
||||
@@ -11011,6 +11045,8 @@ export class ClaimRequestManagementService {
|
||||
nextStep: claim.workflow?.nextStep,
|
||||
blameRequestId: claim.blameRequestId?.toString(),
|
||||
blameRequestNo: claim.blameRequestNo,
|
||||
blameType: (blameForDetail as any)?.type ?? undefined,
|
||||
creationMethod: (blameForDetail as any)?.creationMethod ?? undefined,
|
||||
...(ownerData ? { owner: ownerData } : {}),
|
||||
vehicle: claim.vehicle,
|
||||
selectedParts: selectedNormDetails,
|
||||
|
||||
@@ -122,6 +122,18 @@ export class ClaimDetailsV2ResponseDto {
|
||||
@ApiPropertyOptional({ description: 'Blame request number' })
|
||||
blameRequestNo?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description: 'Blame file type: THIRD_PARTY or CAR_BODY',
|
||||
example: 'THIRD_PARTY',
|
||||
})
|
||||
blameType?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description: 'How the blame file was initiated: IN_PERSON or LINK',
|
||||
example: 'IN_PERSON',
|
||||
})
|
||||
creationMethod?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description: 'Claim owner (damaged party): ids for the user and their insurer client scope',
|
||||
})
|
||||
|
||||
@@ -28,6 +28,18 @@ export class ClaimListItemV2Dto {
|
||||
|
||||
@ApiProperty({ description: 'Blame request ID this claim originated from' })
|
||||
blameRequestId?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description: 'Blame file type: THIRD_PARTY or CAR_BODY',
|
||||
example: 'THIRD_PARTY',
|
||||
})
|
||||
blameType?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description: 'How the blame file was initiated: IN_PERSON or LINK',
|
||||
example: 'IN_PERSON',
|
||||
})
|
||||
creationMethod?: string;
|
||||
}
|
||||
|
||||
export class GetMyClaimsV2ResponseDto {
|
||||
|
||||
@@ -116,6 +116,8 @@ export class AllRequestDtoV2 {
|
||||
lockFile: boolean;
|
||||
lockTime: string | null;
|
||||
type: string;
|
||||
/** IN_PERSON or LINK — how the blame file was created */
|
||||
creationMethod?: string;
|
||||
blameStatus: string;
|
||||
/** Calculated blame + linked claim lifecycle status */
|
||||
unifiedFileStatus?: string;
|
||||
|
||||
@@ -762,6 +762,7 @@ export class ExpertBlameService {
|
||||
? new Date(workflow.lockedAt as string).toISOString()
|
||||
: null,
|
||||
type: String(doc.type ?? "THIRD_PARTY"),
|
||||
creationMethod: doc.creationMethod ? String(doc.creationMethod) : undefined,
|
||||
blameStatus: String(doc.blameStatus ?? ""),
|
||||
partiesInitialForms: {
|
||||
firstParty: statementToFormKey(firstParty?.statement) ?? "",
|
||||
|
||||
@@ -52,6 +52,12 @@ export class ClaimDetailV2ResponseDto {
|
||||
})
|
||||
blameRequestType?: BlameRequestType;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description: "How the blame file was initiated: IN_PERSON or LINK",
|
||||
example: "IN_PERSON",
|
||||
})
|
||||
creationMethod?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description:
|
||||
"CAR_BODY only: first-step flags — another car (`car`) and/or object (`object`)",
|
||||
|
||||
@@ -49,6 +49,12 @@ export class ClaimListItemV2Dto {
|
||||
})
|
||||
blameRequestType?: BlameRequestType;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description: 'How the blame file was initiated: IN_PERSON or LINK',
|
||||
example: 'IN_PERSON',
|
||||
})
|
||||
creationMethod?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description:
|
||||
'CAR_BODY only: first-step flags — accident involved another car (`car`) and/or fixed object (`object`)',
|
||||
|
||||
@@ -629,6 +629,7 @@ export class ExpertClaimService {
|
||||
*/
|
||||
private blameFileContextForExpert(blame: any): {
|
||||
blameRequestType?: BlameRequestType;
|
||||
creationMethod?: string;
|
||||
carBodyFirstForm?: { car?: boolean; object?: boolean };
|
||||
blameStatus?: string;
|
||||
} {
|
||||
@@ -636,9 +637,11 @@ export class ExpertClaimService {
|
||||
const blameRequestType = blame.type as BlameRequestType;
|
||||
const out: {
|
||||
blameRequestType?: BlameRequestType;
|
||||
creationMethod?: string;
|
||||
carBodyFirstForm?: { car?: boolean; object?: boolean };
|
||||
blameStatus?: string;
|
||||
} = { blameRequestType };
|
||||
if (blame.creationMethod) out.creationMethod = blame.creationMethod;
|
||||
out.blameStatus = blame.blameStatus;
|
||||
if (blameRequestType !== BlameRequestType.CAR_BODY) return out;
|
||||
|
||||
@@ -4017,7 +4020,7 @@ export class ExpertClaimService {
|
||||
blameIds.length > 0
|
||||
? ((await this.blameRequestDbService.find(
|
||||
{ _id: { $in: blameIds.map((id) => new Types.ObjectId(id)) } },
|
||||
{ lean: true, select: "type parties expert.decision blameStatus status isMadeByFileMaker" },
|
||||
{ lean: true, select: "type creationMethod parties expert.decision blameStatus status isMadeByFileMaker" },
|
||||
)) as any[])
|
||||
: [];
|
||||
const blameById = new Map<string, any>(
|
||||
@@ -4117,7 +4120,7 @@ export class ExpertClaimService {
|
||||
blameIds.length > 0
|
||||
? ((await this.blameRequestDbService.find(
|
||||
{ _id: { $in: blameIds.map((id) => new Types.ObjectId(id)) } },
|
||||
{ lean: true, select: "type parties expert.decision blameStatus status" },
|
||||
{ lean: true, select: "type creationMethod parties expert.decision blameStatus status" },
|
||||
)) as any[])
|
||||
: [];
|
||||
const blameById = new Map<string, any>(
|
||||
@@ -4212,7 +4215,7 @@ export class ExpertClaimService {
|
||||
{
|
||||
lean: true,
|
||||
select:
|
||||
"_id type parties blameStatus status expert.decision assignedFileReviewerId requiresFileMakerApproval",
|
||||
"_id type creationMethod parties blameStatus status expert.decision assignedFileReviewerId requiresFileMakerApproval",
|
||||
},
|
||||
)) as any[];
|
||||
|
||||
@@ -4303,7 +4306,7 @@ export class ExpertClaimService {
|
||||
|
||||
const makerBlames = (await this.blameRequestDbService.find(
|
||||
{ isMadeByFileMaker: true, initiatedByFieldExpertId: makerOid },
|
||||
{ lean: true, select: "_id type parties blameStatus status expert.decision assignedFileReviewerId requiresFileMakerApproval" },
|
||||
{ lean: true, select: "_id type creationMethod parties blameStatus status expert.decision assignedFileReviewerId requiresFileMakerApproval" },
|
||||
)) as any[];
|
||||
|
||||
if (makerBlames.length === 0) {
|
||||
|
||||
@@ -1498,6 +1498,8 @@ export class ExpertInsurerService {
|
||||
(blame as any)?.requestNumber ||
|
||||
(claim as any)?.requestNumber,
|
||||
type: (blame as any)?.type ?? (blameFull as any)?.type,
|
||||
creationMethod:
|
||||
(blame as any)?.creationMethod ?? (blameFull as any)?.creationMethod,
|
||||
hasClaim: !!claim,
|
||||
blameStatus: (blame as any)?.status ?? (blameFull as any)?.status,
|
||||
claimStatus: (claim as any)?.status,
|
||||
|
||||
@@ -6116,6 +6116,7 @@ export class RequestManagementService {
|
||||
requestNo: plain.requestNo,
|
||||
publicId: plain.publicId,
|
||||
type: plain.type,
|
||||
creationMethod: plain.creationMethod,
|
||||
status: plain.status,
|
||||
blameStatus: plain.blameStatus,
|
||||
workflow: plain.workflow,
|
||||
|
||||
Reference in New Issue
Block a user