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" });
|
||||
}
|
||||
|
||||
if (!req.user || !req.user.id) {
|
||||
return res.status(401).json({ error: "Unauthorized: user info missing" });
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
const claimData = JSON.parse(req.body.data);
|
||||
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 });
|
||||
} catch (err) {
|
||||
|
||||
@@ -185,6 +185,7 @@ export interface IStorage {
|
||||
updates: Partial<InsuranceCredential>
|
||||
): Promise<InsuranceCredential>;
|
||||
deleteInsuranceCredential(id: number): Promise<void>;
|
||||
getInsuranceCredentialByUserAndSiteKey(userId: number, siteKey: string): Promise<InsuranceCredential | null>;
|
||||
}
|
||||
|
||||
export const storage: IStorage = {
|
||||
@@ -404,4 +405,10 @@ export const storage: IStorage = {
|
||||
async deleteInsuranceCredential(id: number) {
|
||||
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;
|
||||
serviceDate: string; // YYYY-MM-DD
|
||||
insuranceProvider: string;
|
||||
insuranceSiteKey?:string;
|
||||
status: string; // default "pending"
|
||||
massdhp_username?: string;
|
||||
massdhp_password?: string;
|
||||
serviceLines: ServiceLine[];
|
||||
}
|
||||
|
||||
@@ -212,7 +211,7 @@ export function ClaimForm({
|
||||
// MAIN FORM INITIAL STATE
|
||||
const [form, setForm] = useState<ClaimFormData & { uploadedFiles: File[] }>({
|
||||
patientId: patientId || 0,
|
||||
appointmentId: 0, //need to update
|
||||
appointmentId: 0,
|
||||
userId: Number(user?.id),
|
||||
staffId: Number(staff?.id),
|
||||
patientName: `${patient?.firstName} ${patient?.lastName}`.trim(),
|
||||
@@ -221,9 +220,8 @@ export function ClaimForm({
|
||||
remarks: "",
|
||||
serviceDate: serviceDate,
|
||||
insuranceProvider: "",
|
||||
insuranceSiteKey:"",
|
||||
status: "pending",
|
||||
massdhp_username: "",
|
||||
massdhp_password: "",
|
||||
serviceLines: [
|
||||
{
|
||||
procedureCode: "",
|
||||
@@ -366,8 +364,7 @@ export function ClaimForm({
|
||||
// 3. Create Claim(if not)
|
||||
const {
|
||||
uploadedFiles,
|
||||
massdhp_username,
|
||||
massdhp_password,
|
||||
insuranceSiteKey,
|
||||
...formToCreateClaim
|
||||
} = form;
|
||||
onSubmit({
|
||||
@@ -385,8 +382,7 @@ export function ClaimForm({
|
||||
patientId: patientId,
|
||||
insuranceProvider: "Mass Health",
|
||||
appointmentId: appointmentId!,
|
||||
massdhp_username: "kqkgaox@yahoo.com",
|
||||
massdhp_password: "Lex123456", //fetch this from db, by call
|
||||
insuranceSiteKey:"MH",
|
||||
});
|
||||
// 4. Close form
|
||||
onClose();
|
||||
|
||||
@@ -26,8 +26,8 @@ class AutomationMassDHP:
|
||||
self.memberId = self.claim.get("memberId", "")
|
||||
self.dateOfBirth = self.claim.get("dateOfBirth", "")
|
||||
self.remarks = self.claim.get("remarks", "")
|
||||
self.massdhp_username = self.claim.get("massdhp_username", "")
|
||||
self.massdhp_password = self.claim.get("massdhp_password", "")
|
||||
self.massdhp_username = self.claim.get("massdhpUsername", "")
|
||||
self.massdhp_password = self.claim.get("massdhpPassword", "")
|
||||
self.serviceLines = self.claim.get("serviceLines", [])
|
||||
self.missingTeethStatus = self.claim.get("missingTeethStatus", "")
|
||||
self.missingTeeth = self.claim.get("missingTeeth", {})
|
||||
|
||||
Reference in New Issue
Block a user