Files
yara724api/src/expert-insurer/helper/insurer.helper.ts
SepehrYahyaee 0b47e8789b YARA-977
2026-06-03 12:23:30 +03:30

43 lines
1.2 KiB
TypeScript

export function extractExpertNamesFromBlame(b: any): string[] {
const names = new Set<string>();
const add = (v: unknown) => {
if (typeof v === "string" && v.trim()) names.add(v.trim());
};
add(b?.workflow?.assignedForReviewBy?.actorName);
add(b?.workflow?.lockedBy?.actorName);
// History entries from expert actions
for (const h of b?.history ?? []) {
if (
h?.actor?.actorType === "field_expert" ||
h?.actor?.actorType === "damage_expert"
) {
add(h?.actor?.actorName);
}
}
return [...names];
}
export function extractExpertNamesFromClaim(c: any): string[] {
const names = new Set<string>();
const add = (v: unknown) => {
if (typeof v === "string" && v.trim()) names.add(v.trim());
};
add(c?.workflow?.assignedForReviewBy?.actorName);
add(c?.workflow?.lockedBy?.actorName);
// Evaluation snapshots
add(c?.evaluation?.damageExpertResend?.expertProfileSnapshot?.fullName);
add(c?.evaluation?.damageExpertReply?.expertProfileSnapshot?.fullName);
add(c?.evaluation?.damageExpertReplyFinal?.expertProfileSnapshot?.fullName);
add(c?.evaluation?.factorValidationExpertProfileSnapshot?.fullName);
add(c?.evaluation?.inPersonVisitExpertProfileSnapshot?.fullName);
return [...names];
}