Hospital management system project
that runs, with an ER diagram and viva prep
Patients, doctors, appointments, prescriptions, admissions and bills, with a login for each role. Generate a working version from one prompt, read its code, then make it your own.
What the project does
Generated from the prompt below, so yours can differ: read it before you present it.
Patient registration
A unique patient number, contact details, age, blood group and the full visit history on one page, searchable by name, phone or number.Appointments without clashes
Doctors' consulting hours become free slots. A slot can be booked once; the database refuses a second booking for the same time.Consultation and prescription
The doctor opens the appointment, writes the diagnosis and adds medicines with dose and number of days. The patient can print it.Wards, beds and admissions
Beds per ward with their status, admission to a free bed and discharge with a summary, so occupancy is always current.Billing and payments
A bill per visit or stay that adds consultation, bed days and medicines, with part payments and the balance due.Dashboard
Today's appointments per doctor, beds free per ward, and money collected this month.Who uses it
- Admin
- Adds departments, doctors, wards and charges; sees every report.
- Receptionist
- Registers patients, books and cancels appointments, admits and discharges, takes payments.
- Doctor
- Sees their own appointments, writes diagnoses and prescriptions, discharges their patients.
- Patient
- Signs in to see only their own appointments, prescriptions and bills.
ER diagram
Nine entities. A patient has many appointments; an appointment can lead to one prescription with many lines; an admission puts a patient in one bed. Generate the app and compare its tables with this: a difference is a good viva answer.
patient
| id | uuid | PK |
| patient_no | text | UK |
| name | text | |
| date_of_birth | date | |
| gender | text | |
| blood_group | text | |
| phone | text |
department
| id | uuid | PK |
| name | text |
doctor
| id | uuid | PK |
| department_id | uuid | FK |
| name | text | |
| specialisation | text | |
| consultation_fee | numeric |
appointment
| id | uuid | PK |
| patient_id | uuid | FK |
| doctor_id | uuid | FK |
| starts_at | timestamp | |
| status | text | |
| diagnosis | text |
prescription
| id | uuid | PK |
| appointment_id | uuid | FK |
| notes | text |
prescription_line
| id | uuid | PK |
| prescription_id | uuid | FK |
| medicine | text | |
| dose | text | |
| days | int |
bed
| id | uuid | PK |
| ward | text | |
| bed_no | text | |
| daily_charge | numeric |
admission
| id | uuid | PK |
| patient_id | uuid | FK |
| bed_id | uuid | FK |
| admitted_at | timestamp | |
| discharged_at | timestamp |
bill
| id | uuid | PK |
| patient_id | uuid | FK |
| admission_id | uuid | FK |
| total | numeric | |
| paid | numeric | |
| issued_on | date |
Relationships
- department employs doctor (one to many)
- patient books appointment (one to many)
- doctor attends appointment (one to many)
- appointment results in prescription (one to one)
- prescription lists prescription_line (one to many)
- patient is admitted in admission (one to many)
- bed holds admission (one to many)
- patient pays bill (one to many)
- admission is charged on bill (zero or one to many)
Mermaid source
Paste it into mermaid.live, draw.io (Arrange, Insert, Advanced, Mermaid) or any Markdown editor that draws Mermaid to get the diagram for your report.
erDiagram
DEPARTMENT ||--o{ DOCTOR : "employs"
PATIENT ||--o{ APPOINTMENT : "books"
DOCTOR ||--o{ APPOINTMENT : "attends"
APPOINTMENT ||--|| PRESCRIPTION : "results in"
PRESCRIPTION ||--o{ PRESCRIPTION_LINE : "lists"
PATIENT ||--o{ ADMISSION : "is admitted in"
BED ||--o{ ADMISSION : "holds"
PATIENT ||--o{ BILL : "pays"
ADMISSION |o--o{ BILL : "is charged on"
PATIENT {
uuid id PK
text patient_no UK
text name
date date_of_birth
text gender
text blood_group
text phone
}
DEPARTMENT {
uuid id PK
text name
}
DOCTOR {
uuid id PK
uuid department_id FK
text name
text specialisation
numeric consultation_fee
}
APPOINTMENT {
uuid id PK
uuid patient_id FK
uuid doctor_id FK
timestamp starts_at
text status
text diagnosis
}
PRESCRIPTION {
uuid id PK
uuid appointment_id FK
text notes
}
PRESCRIPTION_LINE {
uuid id PK
uuid prescription_id FK
text medicine
text dose
int days
}
BED {
uuid id PK
text ward
text bed_no
numeric daily_charge
}
ADMISSION {
uuid id PK
uuid patient_id FK
uuid bed_id FK
timestamp admitted_at
timestamp discharged_at
}
BILL {
uuid id PK
uuid patient_id FK
uuid admission_id FK
numeric total
numeric paid
date issued_on
}Generate yours and get the code
This builds on Refinar's booking starting point, because appointments in time slots are the heart of the project. Everything else, from prescriptions to wards and bills, comes from the prompt.
The button opens Refinar with the project described in the first message, ready to edit. About a minute later there is a running app with sign-in, the pages above and a PostgreSQL database, in a live preview you can click through and change by asking.
It is real code: Next.js and React in TypeScript, PostgreSQL with the Drizzle ORM, and Better Auth for sign-in. When you press Go live, the GitHub repository moves to your own GitHub account and the database to your own Neon account, so you can read it, run it and present it. Building uses credits and going live needs a Refinar plan; the details are on the pricing page.
If your syllabus asks for PHP and MySQL, Java or Python, ask your guide before you start: the generated code will not be in those languages. The ER diagram and the checklist on this page work for any stack.
The prompt it starts with
A hospital management system for a final-year project, in English: patients with a unique patient number; doctors with department and weekly consulting hours; appointments in free slots that cannot be double-booked; a visit record where the doctor writes the diagnosis and a prescription of medicines with dose and days; wards and beds with admission and discharge; a bill per visit or admission with consultation, bed and medicine charges, and payments. Roles: admin, receptionist, doctor and patient, where a patient sees only their own appointments, prescriptions and bills.
Report and viva checklist
Report checklist
- Abstract: the problem, who uses the system and what it does, in one paragraph.
- Existing system and its problems, then the proposed system.
- Objectives and scope, including what is out of scope.
- Requirements: functional and non-functional, per role.
- Technology used and why: Next.js, TypeScript, PostgreSQL, Drizzle ORM.
- ER diagram and table design, normalised to third normal form.
- DFD level 0 and level 1, and a use case diagram.
- Module description with a screenshot of each screen.
- Testing: test cases with input, expected result and actual result.
- Conclusion, limitations and future scope.
- References, and a statement of the tools you used, AI included.
Make the report about this project
- Explain how double booking is prevented: a unique constraint on doctor and start time, not only a check in the form.
- Draw the appointment life cycle: booked, checked in, completed, cancelled, no-show.
- Show how a bill total is worked out from consultation, bed days and medicines, with one worked example.
- Test cases: booking a taken slot, discharging a patient twice, a patient opening another patient's bill.
Viva questions to prepare
- Why is prescription_line a separate table and not a text field on the prescription?
- How do you know which beds are free right now? Write the query.
- What happens to a patient's appointments if their doctor is deleted?
- Where would you add a lab test module, and which tables would it touch?
- What is a primary key and a foreign key? Point to one of each in your tables.
- Which normal form are your tables in, and what would break if they were not?
- How does sign-in work, and how are passwords stored?
- How does the app stop one user from seeing another user's data?
- Why PostgreSQL, and not MySQL or MongoDB?
- What did you change or add yourself, and why?
Build it, understand it, then submit it
Many universities allow tools, AI included, as long as you say so and can explain every part of what you submit. Read your university's rules and ask your guide before you start, and name Refinar in the tools section of your report.
Treat the generated app as a starting point, not a submission. Read every table and every page, change something yourself, add one feature that is your own, and write the test cases by hand. If you cannot say why a table has a foreign key, an examiner will find out in a minute.
Submitting work you did not do and do not understand as your own is academic misconduct, whoever or whatever wrote it. These pages are here to help you build a project you can defend.
Take it further
- A lab module: tests ordered by the doctor, results entered by the lab, shown to the patient.
- A pharmacy stock that reduces when a prescription is dispensed.
- A queue screen for the waiting room, showing the token being seen by each doctor.
- Reports: patients per department per month, average stay, revenue by service.
Questions
Which modules should a hospital management system project have?
At least patient registration, doctors and departments, appointments, consultation with prescriptions, admissions with wards and beds, and billing, with a login per role. Lab and pharmacy are the usual extensions.
Is this suitable for a BCA, MCA or B.Tech final-year project?
The scope fits a final-year web project. What makes it yours is what you change and add, and how well you explain it. Check the expected stack and size with your guide first.
Can I use the ER diagram in my report?
Yes. Paste the Mermaid source into mermaid.live or draw.io to draw it, then adjust it to match your own tables. A diagram that matches your code is worth more than a perfect one that does not.
Is it a real hospital system?
No. It is a learning project with made-up data. Real hospital software has to meet medical record and privacy rules that a student project does not.
More project ideas
- Library management systemCatalogue, copies, issue and return with due dates, fines and reservations.
- Student management systemStudents, courses, attendance, marks and results, fees and a student login.
- Hostel management systemRooms and beds, allocation, fees, out-passes, visitors and complaints.
- Pharmacy management systemMedicines, batches and expiry, purchases, sales bills and stock alerts.
- E-commerce websiteStorefront, cart, checkout, orders with status, customer accounts and a stock admin.
- Event management systemEvents with ticket types, registration, QR check-in at the door and feedback.