Skip to content

Commit

Permalink
novu in-app notification integrated in appointment request
Browse files Browse the repository at this point in the history
and minor changes to payment history of patient
  • Loading branch information
ad956 committed Jun 7, 2024
1 parent 5676d04 commit 173494e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 5 additions & 1 deletion app/api/patient/appointment/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,18 @@ export async function GET(request: Request) {
return Response.json({ error: "Patient not found" }, { status: 404 });
}

const transactionsCollection = db.collection<Transaction>("transactions"); // Specify Transaction type
const transactionProjection = { _id: 0, transaction_id: 0, patient: 0 };
// get all transactions where patient id matches
const transactionsCollection = db.collection<Transaction>("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>("hospital"); // Specify Hospital type
const hospitalCollection = db.collection<Hospital>("hospital");

// hospitals whos id is in transactions
const hospitals = await hospitalCollection
.find({ _id: { $in: hospitalIds } })
.toArray();
Expand Down

0 comments on commit 173494e

Please sign in to comment.