recent claims fixed
This commit is contained in:
@@ -132,9 +132,8 @@ router.post(
|
|||||||
// GET /api/claims?page=1&limit=5
|
// GET /api/claims?page=1&limit=5
|
||||||
router.get("/", async (req: Request, res: Response) => {
|
router.get("/", async (req: Request, res: Response) => {
|
||||||
const userId = req.user!.id;
|
const userId = req.user!.id;
|
||||||
const page = parseInt(req.query.page as string) || 1;
|
const offset = parseInt(req.query.offset as string) || 0;
|
||||||
const limit = parseInt(req.query.limit as string) || 5;
|
const limit = parseInt(req.query.limit as string) || 5;
|
||||||
const offset = (page - 1) * limit;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const [claims, total] = await Promise.all([
|
const [claims, total] = await Promise.all([
|
||||||
@@ -144,7 +143,7 @@ router.get("/", async (req: Request, res: Response) => {
|
|||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
data: claims,
|
data: claims,
|
||||||
page,
|
page: Math.floor(offset / limit) + 1,
|
||||||
limit,
|
limit,
|
||||||
total,
|
total,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -408,6 +408,38 @@ export const storage: IStorage = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async getClaimsPaginated(
|
||||||
|
userId: number,
|
||||||
|
offset: number,
|
||||||
|
limit: number
|
||||||
|
): Promise<ClaimWithServiceLines[]> {
|
||||||
|
return db.claim.findMany({
|
||||||
|
where: { userId },
|
||||||
|
orderBy: { createdAt: "desc" },
|
||||||
|
skip: offset,
|
||||||
|
take: limit,
|
||||||
|
include: { serviceLines: true },
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
async countClaimsByUserId(userId: number): Promise<number> {
|
||||||
|
return db.claim.count({ where: { userId } });
|
||||||
|
},
|
||||||
|
|
||||||
|
async getClaimsMetadataByUser(
|
||||||
|
userId: number
|
||||||
|
): Promise<{ id: number; createdAt: Date; status: string }[]> {
|
||||||
|
return db.claim.findMany({
|
||||||
|
where: { userId },
|
||||||
|
orderBy: { createdAt: "desc" },
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
createdAt: true,
|
||||||
|
status: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
// Insurance Creds
|
// Insurance Creds
|
||||||
async getInsuranceCredentialsByUser(userId: number) {
|
async getInsuranceCredentialsByUser(userId: number) {
|
||||||
return await db.insuranceCredential.findMany({ where: { userId } });
|
return await db.insuranceCredential.findMany({ where: { userId } });
|
||||||
@@ -442,35 +474,5 @@ export const storage: IStorage = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
async getClaimsPaginated(
|
|
||||||
userId: number,
|
|
||||||
offset: number,
|
|
||||||
limit: number
|
|
||||||
): Promise<ClaimWithServiceLines[]> {
|
|
||||||
return db.claim.findMany({
|
|
||||||
where: { userId },
|
|
||||||
orderBy: { createdAt: "desc" },
|
|
||||||
skip: offset,
|
|
||||||
take: limit,
|
|
||||||
include: { serviceLines: true },
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
async countClaimsByUserId(userId: number): Promise<number> {
|
|
||||||
return db.claim.count({ where: { userId } });
|
|
||||||
},
|
|
||||||
|
|
||||||
async getClaimsMetadataByUser(
|
|
||||||
userId: number
|
|
||||||
): Promise<{ id: number; createdAt: Date; status: string }[]> {
|
|
||||||
return db.claim.findMany({
|
|
||||||
where: { userId },
|
|
||||||
orderBy: { createdAt: "desc" },
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
createdAt: true,
|
|
||||||
status: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
from fastapi import FastAPI, Request
|
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
|
||||||
import uvicorn
|
|
||||||
from selenium_worker import AutomationMassDHP
|
|
||||||
|
|
||||||
app = FastAPI()
|
|
||||||
|
|
||||||
app.add_middleware(
|
|
||||||
CORSMiddleware,
|
|
||||||
allow_origins=["*"], # Replace with your frontend domain for security
|
|
||||||
allow_methods=["*"],
|
|
||||||
allow_headers=["*"],
|
|
||||||
)
|
|
||||||
|
|
||||||
@app.post("/run")
|
|
||||||
async def run_bot(request: Request):
|
|
||||||
data = await request.json()
|
|
||||||
try:
|
|
||||||
bot = AutomationMassDHP(data)
|
|
||||||
result = bot.main_workflow("https://providers.massdhp.com/providers_login.asp")
|
|
||||||
return result
|
|
||||||
except Exception as e:
|
|
||||||
return {"status": "error", "message": str(e)}
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
uvicorn.run(app, host="0.0.0.0", port=5002)
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
from fastapi import FastAPI, Request
|
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
|
||||||
import uvicorn
|
|
||||||
from selenium_worker import AutomationMassHealth
|
|
||||||
|
|
||||||
app = FastAPI()
|
|
||||||
|
|
||||||
app.add_middleware(
|
|
||||||
CORSMiddleware,
|
|
||||||
allow_origins=["*"], # Replace with your frontend domain for security
|
|
||||||
allow_methods=["*"],
|
|
||||||
allow_headers=["*"],
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# Endpoint: Step 1 — Start the automation
|
|
||||||
@app.post("/start-workflow")
|
|
||||||
async def start_workflow(request: Request):
|
|
||||||
data = await request.json()
|
|
||||||
try:
|
|
||||||
bot = AutomationMassHealth(data)
|
|
||||||
result = bot.main_workflow_upto_step2("https://abc.com/providers_login.asp")
|
|
||||||
return result
|
|
||||||
except Exception as e:
|
|
||||||
return {"status": "error", "message": str(e)}
|
|
||||||
|
|
||||||
# Endpoint: Step 2 — Extract the PDF content after manual submission
|
|
||||||
@app.post("/fetch-pdf")
|
|
||||||
async def fetch_pdf():
|
|
||||||
try:
|
|
||||||
bot = AutomationMassHealth().get_last_instance()
|
|
||||||
pdf_data = bot.reach_to_pdf()
|
|
||||||
|
|
||||||
if not pdf_data:
|
|
||||||
return {"status": "error", "message": "Failed to fetch PDF"}
|
|
||||||
return {"status": "success", "pdf_data": pdf_data}
|
|
||||||
except Exception as e:
|
|
||||||
return {"status": "error", "message": str(e)}
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
uvicorn.run(app, host="0.0.0.0", port=5002)
|
|
||||||
Reference in New Issue
Block a user