fix(group title added)

This commit is contained in:
2025-11-12 00:54:02 +05:30
parent e084e0a9f6
commit e32e951dd3

View File

@@ -126,17 +126,28 @@ router.post(
responseType: "arraybuffer", responseType: "arraybuffer",
}); });
const groupTitle = "Claims"; // Allowed keys as a literal tuple to derive a union type
const allowedKeys = [
"INSURANCE_CLAIM",
"INSURANCE_CLAIM_PREAUTH",
] as const;
type GroupKey = (typeof allowedKeys)[number];
const isGroupKey = (v: any): v is GroupKey =>
(allowedKeys as readonly string[]).includes(v);
// allowed keys if (!isGroupKey(groupTitleKey)) {
const allowedKeys = ["INSURANCE_CLAIM", "INSURANCE_CLAIM_PREAUTH"];
if (!allowedKeys.includes(groupTitleKey)) {
return sendError( return sendError(
res, res,
`Invalid groupTitleKey. Must be one of: ${allowedKeys.join(", ")}` `Invalid groupTitleKey. Must be one of: ${allowedKeys.join(", ")}`
); );
} }
const GROUP_TITLES: Record<GroupKey, string> = {
INSURANCE_CLAIM: "Claims",
INSURANCE_CLAIM_PREAUTH: "Claims Preauth",
};
const groupTitle = GROUP_TITLES[groupTitleKey];
// ✅ Find or create PDF group for this claim // ✅ Find or create PDF group for this claim
let group = await storage.findPdfGroupByPatientTitleKey( let group = await storage.findPdfGroupByPatientTitleKey(
parsedPatientId, parsedPatientId,