Section 5.3 of our sample project report is called “the appointment engine”. It holds a short code listing and, under it, one paragraph that most hospital management system projects have no equivalent of. I wrote that report as a PDF generator script and committed it on 30 October 2026, and that paragraph is the reason I think this project is worth building properly, so this is the story of it.
The student’s problem, in plain words
Search for a hospital management system project and you get GitHub repos, PDFs and a few company pages. Nearly all of them stop at the same place: a login page, a table of patients, a form to add a doctor. It runs. It looks like a hospital. And then in the viva the examiner asks one question the project cannot answer: “What happens if two patients book the same doctor at the same time?”
Picture a BCA student who has built exactly that project. This is a made-up student, not a real one, but the situation is common. The demo works because she tests it alone, on one laptop, one click at a time. The panel does not test it alone.
Chapter one: start with the schema, not the screens
The hospital project page lists six collections: users (with a role), doctors, patients, appointments, prescriptions and bills. The choice that matters is that an appointment sits in the middle. It references a doctor, a patient and a slot start time. A prescription references the appointment, not the patient directly. A bill is created when the appointment is marked completed.
That one decision answers a whole group of viva questions in advance: “How is a prescription linked to the patient?” Through the appointment, which references both doctor and patient. If you draw the ER diagram first, the screens almost design themselves. If you draw the screens first, the ER diagram becomes something you invent the night before the report is due, and it will not match your tables. The report format guide explains why that mismatch is the fastest way to lose a panel.
Chapter two: three roles, one login
The project has patient, doctor and admin portals behind a single login. The JWT carries the role. React decides which portal to render, but that is only convenience. The real protection is Express middleware that checks the role from the verified token on every API route, and a filter that uses the logged-in user’s id on the server, never an id sent from the browser.
You can test this yourself in two minutes. Log in as a patient, copy the token, and call an admin endpoint from Postman. If it answers, your role system is a costume. Our question bank lists the same test in its security category: “What stops a normal user from calling an admin endpoint?” It exists because the answer is so often “the button is hidden”.
The turning point: one index instead of one if statement
Now back to booking. The natural way to write it is to look for an existing appointment for that doctor and slot, and if none exists, insert one. It reads correctly and it passes every demo. It also leaves a gap between the check and the insert, and two requests that arrive together can both pass the check.
The project page describes the fix. A unique compound index on doctor and slot start time, so the database itself rejects the second insert. The API catches the duplicate-key error and answers with a 409 and the message “That slot has just been taken”. The listing in the sample report is about a dozen lines. The idea is that the check and the write become one operation, so there is no gap.
Then comes the paragraph I mentioned. A cancelled appointment keeps its row with status “cancelled”, so the unique index would block anyone from re-booking that slot. The report says how the project handles it: the slot generator treats cancelled appointments as free, and cancelling deletes the row, with the cancellation recorded on the patient’s record. Whether you choose that or a partial index, the point is the same. You noticed that your own fix has a side effect and you wrote down what you did about it. That is the sentence examiners remember, because it shows you ran the system in your head past the happy path.
Chapter three: prescriptions and billing
Marking a visit completed is one endpoint that does two things in order: it sets the status, then creates a bill with the consultation fee copied from the doctor’s record at that moment. Copying the fee matters. If the bill only pointed at the doctor, raising a fee next month would quietly change last month’s invoices. The model also refuses a prescription for an appointment that is still only booked.
One more detail from the project page: slots are stored in UTC and displayed in IST. A server hosted in another region will otherwise shift every appointment by five and a half hours, and you will not notice until you deploy it.
What I would do again
- Draw the six-collection ER diagram before any React component.
- Put the role inside the JWT and enforce it in middleware on every route.
- Make the database reject a double booking with a unique index.
- Write down what your fix breaks, such as cancelled slots, and how you handled it.
- Copy the fee into the bill instead of referencing the doctor.
- Store time in UTC, show it in IST.
- Use the finished system to write the report. Do not write the report from memory.
The viva answers to have ready
From the project page: for double booking, a unique compound index, which rejects the second insert atomically, unlike a check in application code. For roles on the server, anyone can call the API directly, so middleware on the verified token is the real protection. For passwords, bcrypt with a per-password salt. For why MongoDB, the records are document-shaped, and a relational database would be a reasonable choice for heavy cross-record reporting, a trade-off worth stating before you are asked. More like these are in the viva question bank, and the report side is laid out in the free sample report, which is this very project.
If you want to build this project together as a project class (a design document and a starter repository, review of every module you write on Guided, and on Mentored live classes where we build it together, one module per class), the full listing, with stack, seven classes and prices, is on the hospital management system (MERN) page. You take part in every module and write the report yourself, and I review it. If you would rather go it alone, the free report and synopsis templates are a good place to begin.