feat: rename DDMA to ClaimMD across selenium service, remove MH/CMSP eligibility feature
Rename ddma_browser_manager/helpers/worker files to claimmd_* naming in SeleniumService. Remove the MassHealth (MH) and CMSP eligibility-check feature end to end: buttons and dead placeholder buttons on the insurance eligibility page, their handlers and auto-trigger wiring, the chatbot's MassHealth-only manual paste flow, backend routes/queue job types/processors, and the corresponding Python Selenium worker endpoints. Multi-provider eligibility checking (DDMA, Delta, Tufts SCO, United SCO, CCA, BCBS MA) and the Twilio SMS eligibility flow are untouched. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
00fd213291
commit
a3d2960c98
@@ -7,7 +7,6 @@
|
||||
*/
|
||||
import { InProcessQueue } from "./inProcessQueue";
|
||||
import { io } from "../socket";
|
||||
import { runEligibilityProcessor } from "./processors/eligibilityProcessor";
|
||||
import { runClaimStatusProcessor } from "./processors/claimStatusProcessor";
|
||||
import { runClaimSubmitProcessor } from "./processors/claimSubmitProcessor";
|
||||
import { runOcrProcessor } from "./processors/ocrProcessor";
|
||||
@@ -23,8 +22,6 @@ import { runUnitedDHClaimProcessor } from "./processors/unitedDHClaimProcessor";
|
||||
import { runUnitedDHPreAuthProcessor } from "./processors/unitedDHPreAuthProcessor";
|
||||
import { runTuftsSCOPreAuthProcessor } from "./processors/tuftsSCOPreAuthProcessor";
|
||||
import { runTuftsSCOClaimProcessor } from "./processors/tuftsSCOClaimProcessor";
|
||||
import { runEligibilityHistoryProcessor } from "./processors/eligibilityHistoryProcessor";
|
||||
import { runCmspEligibilityHistoryRemainingProcessor } from "./processors/cmspEligibilityHistoryRemainingProcessor";
|
||||
import { runBcbsMaEligibilityProcessor } from "./processors/bcbsMaEligibilityProcessor";
|
||||
import type { SeleniumJobData, OcrJobData } from "./queues";
|
||||
|
||||
@@ -59,16 +56,6 @@ export function enqueueSeleniumJob(data: SeleniumJobData): string {
|
||||
message: "Selenium browser starting…",
|
||||
});
|
||||
|
||||
if (jobType === "eligibility-check") {
|
||||
return runEligibilityProcessor({
|
||||
enrichedPayload: data.enrichedPayload,
|
||||
userId: data.userId,
|
||||
insuranceId: data.insuranceId!,
|
||||
formFirstName: data.formFirstName,
|
||||
formLastName: data.formLastName,
|
||||
formDob: data.formDob,
|
||||
});
|
||||
}
|
||||
if (jobType === "claim-status-check") {
|
||||
return runClaimStatusProcessor({
|
||||
enrichedPayload: data.enrichedPayload,
|
||||
@@ -231,26 +218,6 @@ export function enqueueSeleniumJob(data: SeleniumJobData): string {
|
||||
job.id
|
||||
);
|
||||
}
|
||||
if (jobType === "cmsp-eligibility-history-remaining-check") {
|
||||
return runCmspEligibilityHistoryRemainingProcessor({
|
||||
enrichedPayload: data.enrichedPayload,
|
||||
userId: data.userId,
|
||||
insuranceId: data.insuranceId!,
|
||||
formFirstName: data.formFirstName,
|
||||
formLastName: data.formLastName,
|
||||
formDob: data.formDob,
|
||||
});
|
||||
}
|
||||
if (jobType === "mh-eligibility-history-check") {
|
||||
return runEligibilityHistoryProcessor({
|
||||
enrichedPayload: data.enrichedPayload,
|
||||
userId: data.userId,
|
||||
insuranceId: data.insuranceId!,
|
||||
formFirstName: data.formFirstName,
|
||||
formLastName: data.formLastName,
|
||||
formDob: data.formDob,
|
||||
});
|
||||
}
|
||||
if (jobType === "bcbs-ma-eligibility-check") {
|
||||
return runBcbsMaEligibilityProcessor(
|
||||
{
|
||||
|
||||
@@ -1,169 +0,0 @@
|
||||
/**
|
||||
* Processor for "cmsp-eligibility-history-remaining-check" jobs.
|
||||
* Saves eligibility PDF, service history PDF, and accumulator PDF
|
||||
* to the patient's ELIGIBILITY_STATUS document group.
|
||||
*/
|
||||
import fs from "fs/promises";
|
||||
import path from "path";
|
||||
import { storage } from "../../storage";
|
||||
import { emptyFolderContainingFile } from "../../utils/emptyTempFolder";
|
||||
import forwardToPatientDataExtractorService from "../../services/patientDataExtractorService";
|
||||
import {
|
||||
callPythonSync,
|
||||
splitName,
|
||||
createOrUpdatePatientByInsuranceId,
|
||||
} from "./_shared";
|
||||
|
||||
export interface CmspEligibilityHistoryRemainingProcessorInput {
|
||||
enrichedPayload: any;
|
||||
userId: number;
|
||||
insuranceId: string;
|
||||
formFirstName?: string;
|
||||
formLastName?: string;
|
||||
formDob?: string;
|
||||
}
|
||||
|
||||
export interface CmspEligibilityHistoryRemainingProcessorResult {
|
||||
patientUpdateStatus?: string;
|
||||
pdfUploadStatus?: string;
|
||||
pdfFileId?: number | null;
|
||||
pdfFilename?: string | null;
|
||||
memberDetailsPdfFileId?: number | null;
|
||||
memberDetailsPdfFilename?: string | null;
|
||||
historyPdfFileId?: number | null;
|
||||
historyPdfFilename?: string | null;
|
||||
accumulatorPdfFileId?: number | null;
|
||||
accumulatorPdfFilename?: string | null;
|
||||
}
|
||||
|
||||
export async function runCmspEligibilityHistoryRemainingProcessor(
|
||||
input: CmspEligibilityHistoryRemainingProcessorInput
|
||||
): Promise<CmspEligibilityHistoryRemainingProcessorResult> {
|
||||
const { enrichedPayload, userId, insuranceId, formFirstName, formLastName, formDob } = input;
|
||||
|
||||
const seleniumResult = await callPythonSync("/cmsp-eligibility-history-remaining-check", {
|
||||
data: enrichedPayload,
|
||||
});
|
||||
|
||||
const outputResult: CmspEligibilityHistoryRemainingProcessorResult = {};
|
||||
|
||||
// Extract patient name
|
||||
const seleniumFirst = seleniumResult.firstName?.trim() || null;
|
||||
const seleniumLast = seleniumResult.lastName?.trim() || null;
|
||||
const seleniumName = seleniumResult.name?.trim() || null;
|
||||
const seleniumInsurance = seleniumResult.insurance?.trim() || null;
|
||||
|
||||
const extracted: { firstName?: string | null; lastName?: string | null } = {};
|
||||
|
||||
if (seleniumFirst || seleniumLast) {
|
||||
extracted.firstName = seleniumFirst;
|
||||
extracted.lastName = seleniumLast;
|
||||
} else if (seleniumName) {
|
||||
const parts = splitName(seleniumName);
|
||||
extracted.firstName = parts.firstName || null;
|
||||
extracted.lastName = parts.lastName || null;
|
||||
}
|
||||
|
||||
if (!extracted.firstName && !extracted.lastName && seleniumResult?.pdf_path?.endsWith(".pdf")) {
|
||||
try {
|
||||
const pdfBuffer = await fs.readFile(seleniumResult.pdf_path);
|
||||
const extraction = await forwardToPatientDataExtractorService({
|
||||
buffer: pdfBuffer,
|
||||
originalname: path.basename(seleniumResult.pdf_path),
|
||||
mimetype: "application/pdf",
|
||||
} as any);
|
||||
if (extraction.name) {
|
||||
const parts = splitName(extraction.name);
|
||||
extracted.firstName = parts.firstName || null;
|
||||
extracted.lastName = parts.lastName || null;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("[cmspProcessor] PDF name extraction failed:", e);
|
||||
}
|
||||
}
|
||||
|
||||
const preferFirst = extracted.firstName || formFirstName || null;
|
||||
const preferLast = extracted.lastName || formLastName || null;
|
||||
|
||||
let patient;
|
||||
try {
|
||||
patient = await createOrUpdatePatientByInsuranceId({
|
||||
insuranceId,
|
||||
firstName: preferFirst,
|
||||
lastName: preferLast,
|
||||
dob: formDob,
|
||||
userId,
|
||||
});
|
||||
} catch (e: any) {
|
||||
throw new Error(`Failed to create/update patient: ${e.message}`);
|
||||
}
|
||||
|
||||
if (patient && patient.id !== undefined) {
|
||||
let newStatus = "UNKNOWN";
|
||||
if (seleniumResult.eligibility === "Y") newStatus = "ACTIVE";
|
||||
else if (seleniumResult.eligibility === "N") newStatus = "INACTIVE";
|
||||
|
||||
const updates: any = { status: newStatus };
|
||||
if (seleniumInsurance) updates.insuranceProvider = seleniumInsurance;
|
||||
await storage.updatePatient(patient.id, updates);
|
||||
outputResult.patientUpdateStatus = `Patient status updated to ${newStatus}`;
|
||||
|
||||
// Helper: save a single PDF to the patient's ELIGIBILITY_STATUS group
|
||||
const saveToGroup = async (pdfPath: string): Promise<number | null> => {
|
||||
try {
|
||||
const buffer = await fs.readFile(pdfPath);
|
||||
const groupTitleKey = "ELIGIBILITY_STATUS";
|
||||
const groupTitle = "Eligibility Status";
|
||||
let group = await storage.findPdfGroupByPatientTitleKey(patient!.id, groupTitleKey);
|
||||
if (!group) group = await storage.createPdfGroup(patient!.id, groupTitle, groupTitleKey);
|
||||
if (!group?.id) throw new Error("PDF group creation failed");
|
||||
const created = await storage.createPdfFile(group.id, path.basename(pdfPath), buffer);
|
||||
if (created && typeof created === "object" && "id" in created) {
|
||||
return Number(created.id);
|
||||
}
|
||||
return null;
|
||||
} catch (e: any) {
|
||||
console.error("[cmspProcessor] saveToGroup failed:", e.message);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
// Save eligibility PDF
|
||||
if (seleniumResult.pdf_path?.endsWith(".pdf")) {
|
||||
outputResult.pdfFileId = await saveToGroup(seleniumResult.pdf_path);
|
||||
outputResult.pdfFilename = path.basename(seleniumResult.pdf_path);
|
||||
outputResult.pdfUploadStatus = outputResult.pdfFileId ? "Eligibility PDF saved" : "Eligibility PDF upload failed";
|
||||
} else {
|
||||
outputResult.pdfUploadStatus = "No eligibility PDF returned by Selenium";
|
||||
}
|
||||
|
||||
// Save member details PDF
|
||||
if (seleniumResult.member_details_pdf_path?.endsWith(".pdf")) {
|
||||
outputResult.memberDetailsPdfFileId = await saveToGroup(seleniumResult.member_details_pdf_path);
|
||||
outputResult.memberDetailsPdfFilename = path.basename(seleniumResult.member_details_pdf_path);
|
||||
}
|
||||
|
||||
// Save history PDF
|
||||
if (seleniumResult.history_pdf_path?.endsWith(".pdf")) {
|
||||
outputResult.historyPdfFileId = await saveToGroup(seleniumResult.history_pdf_path);
|
||||
outputResult.historyPdfFilename = path.basename(seleniumResult.history_pdf_path);
|
||||
}
|
||||
|
||||
// Save accumulator PDF
|
||||
if (seleniumResult.accumulator_pdf_path?.endsWith(".pdf")) {
|
||||
outputResult.accumulatorPdfFileId = await saveToGroup(seleniumResult.accumulator_pdf_path);
|
||||
outputResult.accumulatorPdfFilename = path.basename(seleniumResult.accumulator_pdf_path);
|
||||
}
|
||||
} else {
|
||||
outputResult.patientUpdateStatus = "Patient not found or missing ID; no update performed";
|
||||
}
|
||||
|
||||
// Cleanup temp files
|
||||
try {
|
||||
if (seleniumResult.pdf_path) await emptyFolderContainingFile(seleniumResult.pdf_path);
|
||||
} catch (e) {
|
||||
console.error("[cmspProcessor] cleanup failed:", e);
|
||||
}
|
||||
|
||||
return outputResult;
|
||||
}
|
||||
@@ -1,167 +0,0 @@
|
||||
/**
|
||||
* Processor for "mh-eligibility-history-check" jobs.
|
||||
* Runs MH eligibility + service history selenium flow and saves both PDFs
|
||||
* to the patient's ELIGIBILITY_STATUS document group.
|
||||
*/
|
||||
import fs from "fs/promises";
|
||||
import path from "path";
|
||||
import { storage } from "../../storage";
|
||||
import { emptyFolderContainingFile } from "../../utils/emptyTempFolder";
|
||||
import forwardToPatientDataExtractorService from "../../services/patientDataExtractorService";
|
||||
import {
|
||||
callPythonSync,
|
||||
splitName,
|
||||
createOrUpdatePatientByInsuranceId,
|
||||
} from "./_shared";
|
||||
|
||||
export interface EligibilityHistoryProcessorInput {
|
||||
enrichedPayload: any;
|
||||
userId: number;
|
||||
insuranceId: string;
|
||||
formFirstName?: string;
|
||||
formLastName?: string;
|
||||
formDob?: string;
|
||||
}
|
||||
|
||||
export interface EligibilityHistoryProcessorResult {
|
||||
patientUpdateStatus?: string;
|
||||
pdfUploadStatus?: string;
|
||||
pdfFileId?: number | null;
|
||||
pdfFilename?: string | null;
|
||||
memberDetailsPdfFileId?: number | null;
|
||||
memberDetailsPdfFilename?: string | null;
|
||||
historyPdfFileId?: number | null;
|
||||
historyPdfFilename?: string | null;
|
||||
}
|
||||
|
||||
export async function runEligibilityHistoryProcessor(
|
||||
input: EligibilityHistoryProcessorInput
|
||||
): Promise<EligibilityHistoryProcessorResult> {
|
||||
const { enrichedPayload, userId, insuranceId, formFirstName, formLastName, formDob } = input;
|
||||
|
||||
const seleniumResult = await callPythonSync("/mh-eligibility-history-check", {
|
||||
data: enrichedPayload,
|
||||
});
|
||||
|
||||
const outputResult: EligibilityHistoryProcessorResult = {};
|
||||
|
||||
// Extract patient name
|
||||
const seleniumFirst = seleniumResult.firstName?.trim() || null;
|
||||
const seleniumLast = seleniumResult.lastName?.trim() || null;
|
||||
const seleniumName = seleniumResult.name?.trim() || null;
|
||||
const seleniumInsurance = seleniumResult.insurance?.trim() || null;
|
||||
|
||||
const extracted: { firstName?: string | null; lastName?: string | null } = {};
|
||||
|
||||
if (seleniumFirst || seleniumLast) {
|
||||
extracted.firstName = seleniumFirst;
|
||||
extracted.lastName = seleniumLast;
|
||||
} else if (seleniumName) {
|
||||
const parts = splitName(seleniumName);
|
||||
extracted.firstName = parts.firstName || null;
|
||||
extracted.lastName = parts.lastName || null;
|
||||
}
|
||||
|
||||
if (!extracted.firstName && !extracted.lastName && seleniumResult?.pdf_path?.endsWith(".pdf")) {
|
||||
try {
|
||||
const pdfBuffer = await fs.readFile(seleniumResult.pdf_path);
|
||||
const extraction = await forwardToPatientDataExtractorService({
|
||||
buffer: pdfBuffer,
|
||||
originalname: path.basename(seleniumResult.pdf_path),
|
||||
mimetype: "application/pdf",
|
||||
} as any);
|
||||
if (extraction.name) {
|
||||
const parts = splitName(extraction.name);
|
||||
extracted.firstName = parts.firstName || null;
|
||||
extracted.lastName = parts.lastName || null;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("[eligibilityHistoryProcessor] PDF name extraction failed:", e);
|
||||
}
|
||||
}
|
||||
|
||||
const preferFirst = extracted.firstName || formFirstName || null;
|
||||
const preferLast = extracted.lastName || formLastName || null;
|
||||
|
||||
let patient;
|
||||
try {
|
||||
patient = await createOrUpdatePatientByInsuranceId({
|
||||
insuranceId,
|
||||
firstName: preferFirst,
|
||||
lastName: preferLast,
|
||||
dob: formDob,
|
||||
userId,
|
||||
});
|
||||
} catch (e: any) {
|
||||
throw new Error(`Failed to create/update patient: ${e.message}`);
|
||||
}
|
||||
|
||||
if (patient && patient.id !== undefined) {
|
||||
let newStatus = "UNKNOWN";
|
||||
if (seleniumResult.eligibility === "Y") newStatus = "ACTIVE";
|
||||
else if (seleniumResult.eligibility === "N") newStatus = "INACTIVE";
|
||||
|
||||
const updates: any = { status: newStatus };
|
||||
if (seleniumInsurance) updates.insuranceProvider = seleniumInsurance;
|
||||
await storage.updatePatient(patient.id, updates);
|
||||
outputResult.patientUpdateStatus = `Patient status updated to ${newStatus}`;
|
||||
|
||||
// Helper: save a PDF buffer to the patient's ELIGIBILITY_STATUS group
|
||||
const saveToGroup = async (pdfPath: string): Promise<number | null> => {
|
||||
try {
|
||||
const buffer = await fs.readFile(pdfPath);
|
||||
const groupTitleKey = "ELIGIBILITY_STATUS";
|
||||
const groupTitle = "Eligibility Status";
|
||||
let group = await storage.findPdfGroupByPatientTitleKey(patient!.id, groupTitleKey);
|
||||
if (!group) group = await storage.createPdfGroup(patient!.id, groupTitle, groupTitleKey);
|
||||
if (!group?.id) throw new Error("PDF group creation failed");
|
||||
const created = await storage.createPdfFile(group.id, path.basename(pdfPath), buffer);
|
||||
if (created && typeof created === "object" && "id" in created) {
|
||||
return Number(created.id);
|
||||
}
|
||||
return null;
|
||||
} catch (e: any) {
|
||||
console.error("[eligibilityHistoryProcessor] saveToGroup failed:", e.message);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
// Save eligibility PDF
|
||||
let eligibilityPdfFileId: number | null = null;
|
||||
if (seleniumResult.pdf_path?.endsWith(".pdf")) {
|
||||
eligibilityPdfFileId = await saveToGroup(seleniumResult.pdf_path);
|
||||
outputResult.pdfUploadStatus = eligibilityPdfFileId
|
||||
? "Eligibility PDF saved"
|
||||
: "Eligibility PDF upload failed";
|
||||
outputResult.pdfFilename = path.basename(seleniumResult.pdf_path);
|
||||
} else {
|
||||
outputResult.pdfUploadStatus = "No eligibility PDF returned by Selenium";
|
||||
}
|
||||
outputResult.pdfFileId = eligibilityPdfFileId;
|
||||
|
||||
// Save member details PDF
|
||||
if (seleniumResult.member_details_pdf_path?.endsWith(".pdf")) {
|
||||
outputResult.memberDetailsPdfFileId = await saveToGroup(seleniumResult.member_details_pdf_path);
|
||||
outputResult.memberDetailsPdfFilename = path.basename(seleniumResult.member_details_pdf_path);
|
||||
}
|
||||
|
||||
// Save history PDF
|
||||
let historyPdfFileId: number | null = null;
|
||||
if (seleniumResult.history_pdf_path?.endsWith(".pdf")) {
|
||||
historyPdfFileId = await saveToGroup(seleniumResult.history_pdf_path);
|
||||
outputResult.historyPdfFilename = path.basename(seleniumResult.history_pdf_path);
|
||||
}
|
||||
outputResult.historyPdfFileId = historyPdfFileId;
|
||||
} else {
|
||||
outputResult.patientUpdateStatus = "Patient not found or missing ID; no update performed";
|
||||
}
|
||||
|
||||
// Cleanup temp files
|
||||
try {
|
||||
if (seleniumResult.pdf_path) await emptyFolderContainingFile(seleniumResult.pdf_path);
|
||||
} catch (e) {
|
||||
console.error("[eligibilityHistoryProcessor] cleanup failed:", e);
|
||||
}
|
||||
|
||||
return outputResult;
|
||||
}
|
||||
@@ -3,7 +3,6 @@ import { redisConnection } from "./connection";
|
||||
|
||||
/** Job types dispatched to the selenium Python worker. */
|
||||
export type SeleniumJobType =
|
||||
| "eligibility-check"
|
||||
| "claim-status-check"
|
||||
| "claim-submit"
|
||||
| "claim-pre-auth"
|
||||
@@ -19,8 +18,6 @@ export type SeleniumJobType =
|
||||
| "uniteddh-preauth-submit"
|
||||
| "tuftssco-preauth-submit"
|
||||
| "tuftssco-eligibility-check"
|
||||
| "mh-eligibility-history-check"
|
||||
| "cmsp-eligibility-history-remaining-check"
|
||||
| "bcbs-ma-eligibility-check";
|
||||
|
||||
export interface SeleniumJobData {
|
||||
|
||||
@@ -2,7 +2,6 @@ import { Worker, Job } from "bullmq";
|
||||
import { redisConnection } from "../connection";
|
||||
import { SeleniumJobData } from "../queues";
|
||||
import { io } from "../../socket";
|
||||
import { runEligibilityProcessor } from "../processors/eligibilityProcessor";
|
||||
import { runClaimStatusProcessor } from "../processors/claimStatusProcessor";
|
||||
import { runClaimSubmitProcessor } from "../processors/claimSubmitProcessor";
|
||||
|
||||
@@ -27,7 +26,7 @@ function emitJobUpdate(
|
||||
}
|
||||
|
||||
async function processSeleniumJob(job: Job<SeleniumJobData>) {
|
||||
const { jobType, userId, socketId, enrichedPayload } = job.data;
|
||||
const { jobType, socketId, enrichedPayload } = job.data;
|
||||
const jobId = job.id ?? job.name;
|
||||
|
||||
emitJobUpdate(socketId, jobId, jobType, "active", {
|
||||
@@ -37,16 +36,7 @@ async function processSeleniumJob(job: Job<SeleniumJobData>) {
|
||||
try {
|
||||
let result: any;
|
||||
|
||||
if (jobType === "eligibility-check") {
|
||||
result = await runEligibilityProcessor({
|
||||
enrichedPayload,
|
||||
userId,
|
||||
insuranceId: job.data.insuranceId!,
|
||||
formFirstName: job.data.formFirstName,
|
||||
formLastName: job.data.formLastName,
|
||||
formDob: job.data.formDob,
|
||||
});
|
||||
} else if (jobType === "claim-status-check") {
|
||||
if (jobType === "claim-status-check") {
|
||||
result = await runClaimStatusProcessor({
|
||||
enrichedPayload,
|
||||
insuranceId: job.data.insuranceId!,
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
} from "../../../../packages/db/types/patient-types";
|
||||
import { formatDobForAgent } from "../utils/dateUtils";
|
||||
import { seleniumQueue } from "../queue/queues";
|
||||
import { enqueueSeleniumJob, getSeleniumJobStatus } from "../queue/jobRunner";
|
||||
import { getSeleniumJobStatus } from "../queue/jobRunner";
|
||||
|
||||
const router = Router();
|
||||
|
||||
@@ -113,160 +113,6 @@ async function createOrUpdatePatientByInsuranceId(options: {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* /eligibility-check
|
||||
* - run selenium
|
||||
* - if pdf created -> call extractor -> get name
|
||||
* - create or update patient (by memberId)
|
||||
* - attach PDF to patient (create pdf group/file)
|
||||
* - return { patient, pdfFileId, extractedName ... }
|
||||
*/
|
||||
router.post(
|
||||
"/eligibility-check",
|
||||
async (req: Request, res: Response): Promise<any> => {
|
||||
if (!req.body.data) {
|
||||
return res
|
||||
.status(400)
|
||||
.json({ error: "Missing Insurance Eligibility data for selenium" });
|
||||
}
|
||||
if (!req.user || !req.user.id) {
|
||||
return res.status(401).json({ error: "Unauthorized: user info missing" });
|
||||
}
|
||||
|
||||
const insuranceEligibilityData =
|
||||
typeof req.body.data === "string"
|
||||
? JSON.parse(req.body.data)
|
||||
: req.body.data;
|
||||
|
||||
const credentials = await storage.getInsuranceCredentialByUserAndSiteKey(
|
||||
req.user.id,
|
||||
insuranceEligibilityData.insuranceSiteKey
|
||||
);
|
||||
if (!credentials) {
|
||||
return res.status(404).json({
|
||||
error:
|
||||
"No insurance credentials found for this provider, Kindly Update this at Settings Page.",
|
||||
});
|
||||
}
|
||||
|
||||
const insuranceId = String(insuranceEligibilityData.memberId ?? "").trim();
|
||||
if (!insuranceId) {
|
||||
return res.status(400).json({ error: "Missing memberId" });
|
||||
}
|
||||
|
||||
const enrichedData = {
|
||||
...insuranceEligibilityData,
|
||||
massdhpUsername: credentials.username,
|
||||
massdhpPassword: credentials.password,
|
||||
};
|
||||
|
||||
const job = await seleniumQueue.add("eligibility-check", {
|
||||
jobType: "eligibility-check",
|
||||
userId: req.user.id,
|
||||
socketId: req.body.socketId,
|
||||
enrichedPayload: enrichedData,
|
||||
insuranceId,
|
||||
formFirstName: insuranceEligibilityData.firstName,
|
||||
formLastName: insuranceEligibilityData.lastName,
|
||||
formDob: insuranceEligibilityData.dateOfBirth,
|
||||
});
|
||||
|
||||
return res.json({ jobId: job.id, status: "queued" });
|
||||
}
|
||||
);
|
||||
|
||||
router.post(
|
||||
"/eligibility-history-check",
|
||||
async (req: Request, res: Response): Promise<any> => {
|
||||
if (!req.body.data) {
|
||||
return res.status(400).json({ error: "Missing Insurance Eligibility data for selenium" });
|
||||
}
|
||||
if (!req.user || !req.user.id) {
|
||||
return res.status(401).json({ error: "Unauthorized: user info missing" });
|
||||
}
|
||||
|
||||
const data =
|
||||
typeof req.body.data === "string" ? JSON.parse(req.body.data) : req.body.data;
|
||||
|
||||
const credentials = await storage.getInsuranceCredentialByUserAndSiteKey(req.user.id, "MH");
|
||||
if (!credentials) {
|
||||
return res.status(404).json({
|
||||
error: "No MassHealth credentials found. Please update them in Settings.",
|
||||
});
|
||||
}
|
||||
|
||||
const insuranceId = String(data.memberId ?? "").trim();
|
||||
if (!insuranceId) {
|
||||
return res.status(400).json({ error: "Missing memberId" });
|
||||
}
|
||||
|
||||
const enrichedData = {
|
||||
...data,
|
||||
massdhpUsername: credentials.username,
|
||||
massdhpPassword: credentials.password,
|
||||
};
|
||||
|
||||
const jobId = enqueueSeleniumJob({
|
||||
jobType: "mh-eligibility-history-check",
|
||||
userId: req.user.id,
|
||||
socketId: req.body.socketId,
|
||||
enrichedPayload: enrichedData,
|
||||
insuranceId,
|
||||
formFirstName: data.firstName,
|
||||
formLastName: data.lastName,
|
||||
formDob: data.dateOfBirth,
|
||||
});
|
||||
|
||||
return res.json({ jobId, status: "queued" });
|
||||
}
|
||||
);
|
||||
|
||||
router.post(
|
||||
"/cmsp-eligibility-history-remaining-check",
|
||||
async (req: Request, res: Response): Promise<any> => {
|
||||
if (!req.body.data) {
|
||||
return res.status(400).json({ error: "Missing data for selenium" });
|
||||
}
|
||||
if (!req.user || !req.user.id) {
|
||||
return res.status(401).json({ error: "Unauthorized: user info missing" });
|
||||
}
|
||||
|
||||
const data =
|
||||
typeof req.body.data === "string" ? JSON.parse(req.body.data) : req.body.data;
|
||||
|
||||
const credentials = await storage.getInsuranceCredentialByUserAndSiteKey(req.user.id, "MH");
|
||||
if (!credentials) {
|
||||
return res.status(404).json({
|
||||
error: "No MassHealth credentials found. Please update them in Settings.",
|
||||
});
|
||||
}
|
||||
|
||||
const insuranceId = String(data.memberId ?? "").trim();
|
||||
if (!insuranceId) {
|
||||
return res.status(400).json({ error: "Missing memberId" });
|
||||
}
|
||||
|
||||
const enrichedData = {
|
||||
...data,
|
||||
massdhpUsername: credentials.username,
|
||||
massdhpPassword: credentials.password,
|
||||
};
|
||||
|
||||
const jobId = enqueueSeleniumJob({
|
||||
jobType: "cmsp-eligibility-history-remaining-check",
|
||||
userId: req.user.id,
|
||||
socketId: req.body.socketId,
|
||||
enrichedPayload: enrichedData,
|
||||
insuranceId,
|
||||
formFirstName: data.firstName,
|
||||
formLastName: data.lastName,
|
||||
formDob: data.dateOfBirth,
|
||||
});
|
||||
|
||||
return res.json({ jobId, status: "queued" });
|
||||
}
|
||||
);
|
||||
|
||||
router.post(
|
||||
"/claim-status-check",
|
||||
async (req: Request, res: Response): Promise<any> => {
|
||||
|
||||
Reference in New Issue
Block a user