MH creds now being retreive from db
This commit is contained in:
@@ -48,11 +48,26 @@ router.post("/selenium", upload.array("pdfs"), async (req: Request, res: Respons
|
|||||||
return res.status(400).json({ error: "Missing files or claim data for selenium" });
|
return res.status(400).json({ error: "Missing files or claim data for selenium" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!req.user || !req.user.id) {
|
||||||
|
return res.status(401).json({ error: "Unauthorized: user info missing" });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const claimData = JSON.parse(req.body.data);
|
const claimData = JSON.parse(req.body.data);
|
||||||
const files = req.files as Express.Multer.File[];
|
const files = req.files as Express.Multer.File[];
|
||||||
|
|
||||||
const result = await forwardToSeleniumAgent(claimData, files);
|
const credentials = await storage.getInsuranceCredentialByUserAndSiteKey(req.user.id, claimData.insuranceSiteKey);
|
||||||
|
if (!credentials) {
|
||||||
|
return res.status(404).json({ error: "No insurance credentials found for this provider." });
|
||||||
|
}
|
||||||
|
|
||||||
|
const enrichedData = {
|
||||||
|
...claimData,
|
||||||
|
massdhpUsername: credentials.username,
|
||||||
|
massdhpPassword: credentials.password,
|
||||||
|
};
|
||||||
|
const result = await forwardToSeleniumAgent(enrichedData, files);
|
||||||
|
|
||||||
res.json({ success: true, data: result });
|
res.json({ success: true, data: result });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -185,6 +185,7 @@ export interface IStorage {
|
|||||||
updates: Partial<InsuranceCredential>
|
updates: Partial<InsuranceCredential>
|
||||||
): Promise<InsuranceCredential>;
|
): Promise<InsuranceCredential>;
|
||||||
deleteInsuranceCredential(id: number): Promise<void>;
|
deleteInsuranceCredential(id: number): Promise<void>;
|
||||||
|
getInsuranceCredentialByUserAndSiteKey(userId: number, siteKey: string): Promise<InsuranceCredential | null>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const storage: IStorage = {
|
export const storage: IStorage = {
|
||||||
@@ -404,4 +405,10 @@ export const storage: IStorage = {
|
|||||||
async deleteInsuranceCredential(id: number) {
|
async deleteInsuranceCredential(id: number) {
|
||||||
await db.insuranceCredential.delete({ where: { id } });
|
await db.insuranceCredential.delete({ where: { id } });
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async getInsuranceCredentialByUserAndSiteKey(userId: number, siteKey: string) {
|
||||||
|
return await db.insuranceCredential.findFirst({
|
||||||
|
where: { userId, siteKey },
|
||||||
|
});
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -90,9 +90,8 @@ interface ClaimFormData {
|
|||||||
remarks: string;
|
remarks: string;
|
||||||
serviceDate: string; // YYYY-MM-DD
|
serviceDate: string; // YYYY-MM-DD
|
||||||
insuranceProvider: string;
|
insuranceProvider: string;
|
||||||
|
insuranceSiteKey?:string;
|
||||||
status: string; // default "pending"
|
status: string; // default "pending"
|
||||||
massdhp_username?: string;
|
|
||||||
massdhp_password?: string;
|
|
||||||
serviceLines: ServiceLine[];
|
serviceLines: ServiceLine[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,7 +211,7 @@ export function ClaimForm({
|
|||||||
// MAIN FORM INITIAL STATE
|
// MAIN FORM INITIAL STATE
|
||||||
const [form, setForm] = useState<ClaimFormData & { uploadedFiles: File[] }>({
|
const [form, setForm] = useState<ClaimFormData & { uploadedFiles: File[] }>({
|
||||||
patientId: patientId || 0,
|
patientId: patientId || 0,
|
||||||
appointmentId: 0, //need to update
|
appointmentId: 0,
|
||||||
userId: Number(user?.id),
|
userId: Number(user?.id),
|
||||||
staffId: Number(staff?.id),
|
staffId: Number(staff?.id),
|
||||||
patientName: `${patient?.firstName} ${patient?.lastName}`.trim(),
|
patientName: `${patient?.firstName} ${patient?.lastName}`.trim(),
|
||||||
@@ -221,9 +220,8 @@ export function ClaimForm({
|
|||||||
remarks: "",
|
remarks: "",
|
||||||
serviceDate: serviceDate,
|
serviceDate: serviceDate,
|
||||||
insuranceProvider: "",
|
insuranceProvider: "",
|
||||||
|
insuranceSiteKey:"",
|
||||||
status: "pending",
|
status: "pending",
|
||||||
massdhp_username: "",
|
|
||||||
massdhp_password: "",
|
|
||||||
serviceLines: [
|
serviceLines: [
|
||||||
{
|
{
|
||||||
procedureCode: "",
|
procedureCode: "",
|
||||||
@@ -366,8 +364,7 @@ export function ClaimForm({
|
|||||||
// 3. Create Claim(if not)
|
// 3. Create Claim(if not)
|
||||||
const {
|
const {
|
||||||
uploadedFiles,
|
uploadedFiles,
|
||||||
massdhp_username,
|
insuranceSiteKey,
|
||||||
massdhp_password,
|
|
||||||
...formToCreateClaim
|
...formToCreateClaim
|
||||||
} = form;
|
} = form;
|
||||||
onSubmit({
|
onSubmit({
|
||||||
@@ -385,8 +382,7 @@ export function ClaimForm({
|
|||||||
patientId: patientId,
|
patientId: patientId,
|
||||||
insuranceProvider: "Mass Health",
|
insuranceProvider: "Mass Health",
|
||||||
appointmentId: appointmentId!,
|
appointmentId: appointmentId!,
|
||||||
massdhp_username: "kqkgaox@yahoo.com",
|
insuranceSiteKey:"MH",
|
||||||
massdhp_password: "Lex123456", //fetch this from db, by call
|
|
||||||
});
|
});
|
||||||
// 4. Close form
|
// 4. Close form
|
||||||
onClose();
|
onClose();
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ class AutomationMassDHP:
|
|||||||
self.memberId = self.claim.get("memberId", "")
|
self.memberId = self.claim.get("memberId", "")
|
||||||
self.dateOfBirth = self.claim.get("dateOfBirth", "")
|
self.dateOfBirth = self.claim.get("dateOfBirth", "")
|
||||||
self.remarks = self.claim.get("remarks", "")
|
self.remarks = self.claim.get("remarks", "")
|
||||||
self.massdhp_username = self.claim.get("massdhp_username", "")
|
self.massdhp_username = self.claim.get("massdhpUsername", "")
|
||||||
self.massdhp_password = self.claim.get("massdhp_password", "")
|
self.massdhp_password = self.claim.get("massdhpPassword", "")
|
||||||
self.serviceLines = self.claim.get("serviceLines", [])
|
self.serviceLines = self.claim.get("serviceLines", [])
|
||||||
self.missingTeethStatus = self.claim.get("missingTeethStatus", "")
|
self.missingTeethStatus = self.claim.get("missingTeethStatus", "")
|
||||||
self.missingTeeth = self.claim.get("missingTeeth", {})
|
self.missingTeeth = self.claim.get("missingTeeth", {})
|
||||||
|
|||||||
Reference in New Issue
Block a user