From 173494e23391a0339f1e6da66542ccccaa7c386c Mon Sep 17 00:00:00 2001 From: Anand Suthar Date: Fri, 7 Jun 2024 18:57:11 +0530 Subject: [PATCH] novu in-app notification integrated in appointment request and minor changes to payment history of patient --- app/api/patient/appointment/route.ts | 6 +++++- app/api/patient/{payment => paymenthistory}/route.ts | 8 +++++--- 2 files changed, 10 insertions(+), 4 deletions(-) rename app/api/patient/{payment => paymenthistory}/route.ts (92%) diff --git a/app/api/patient/appointment/route.ts b/app/api/patient/appointment/route.ts index 2907ecf1..b032774b 100644 --- a/app/api/patient/appointment/route.ts +++ b/app/api/patient/appointment/route.ts @@ -167,7 +167,11 @@ export async function POST(req: Request) { }); // notifying patient - await sendNotification(patient._id.toString()); + await sendNotification( + patient._id.toString(), + "Your appointment request has been successfully received.", + "appointment-request" + ); return Response.json( { diff --git a/app/api/patient/payment/route.ts b/app/api/patient/paymenthistory/route.ts similarity index 92% rename from app/api/patient/payment/route.ts rename to app/api/patient/paymenthistory/route.ts index 9efdc86d..240335d4 100644 --- a/app/api/patient/payment/route.ts +++ b/app/api/patient/paymenthistory/route.ts @@ -32,16 +32,18 @@ export async function GET(request: Request) { return Response.json({ error: "Patient not found" }, { status: 404 }); } - const transactionsCollection = db.collection("transactions"); // Specify Transaction type - const transactionProjection = { _id: 0, transaction_id: 0, patient: 0 }; + // get all transactions where patient id matches + const transactionsCollection = db.collection("transactions"); const transactions = await transactionsCollection .find({ patient: patient._id }) .toArray(); + // get hospital id's from transactions const hospitalIds = transactions.map((transaction) => transaction.hospital); - const hospitalCollection = db.collection("hospital"); // Specify Hospital type + const hospitalCollection = db.collection("hospital"); + // hospitals whos id is in transactions const hospitals = await hospitalCollection .find({ _id: { $in: hospitalIds } }) .toArray();