✨ Introduction
Hospitals require efficient systems to manage patients, staff, billing, notifications, and communication. Manual systems are error‑prone and inefficient. The HospitalManagement project demonstrates how to implement these modules using ASP.NET Core MVC with Razor Views, Controllers, and Services.
This first part covers project setup, architecture, database schema, and Razor screens. You can follow along with the code directly from the HospitalManagement repo HospitalManagement.
⚙️ Project Architecture
The repo follows the MVC pattern:
Models → Define entities like
Patient,Staff,Invoice,Notification.Controllers → Handle requests and route data.
Services → Business logic for each module.
Razor Views → UI templates (
.cshtml) for screens.Chat Module → JavaScript + CSS for real‑time communication.
📊 Database Schema
We'll use Entity Framework Core to define tables:
| Table | Columns |
|---|---|
| Patients | Id, Name, Age, Disease |
| Staff | Id, Name, Role, Department |
| Invoices | Id, PatientId, Amount, Date |
| Notifications | Id, Message, Date |
Model Example – Patient.cs
csharp
public class Patient{
public int Id { get; set; }
public string Name { get; set; }
public int Age { get; set; }
public string Disease { get; set; }
}
🧩 Razor Screens
Patient Screen – Views/Patient/Index.cshtml
cshtml
@model IEnumerable<HospitalManagement.Models.Patient>
<h2>Patient Records</h2>
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
<th>Disease</th>
</tr>
</thead>
<tbody>
@foreach (var p in Model)
{
<tr>
<td>@p.Name</td>
<td>@p.Age</td>
<td>@p.Disease</td>
</tr>
}
</tbody>
</table>
<form asp-action="Create" method="post">
<input asp-for="Name" placeholder="Patient Name" />
<input asp-for="Age" placeholder="Age" />
<input asp-for="Disease" placeholder="Disease" />
<button type="submit">Add Patient</button>
</form>
Staff Screen – Views/Staff/Index.cshtml
cshtml
@model IEnumerable<HospitalManagement.Models.Staff>
<h2>Staff Management</h2>
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>Role</th>
<th>Department</th>
</tr>
</thead>
<tbody>
@foreach (var s in Model)
{
<tr>
<td>@s.Name</td>
<td>@s.Role</td>
<td>@s.Department</td>
</tr>
}
</tbody>
</table>
<form asp-action="Create" method="post">
<input asp-for="Name" placeholder="Staff Name" />
<input asp-for="Role" placeholder="Role" />
<input asp-for="Department" placeholder="Department" />
<button type="submit">Add Staff</button>
</form>
Finance Screen – Views/Finance/Index.cshtml
cshtml
@model IEnumerable<HospitalManagement.Models.Invoice>
<h2>Invoices</h2>
<table class="table">
<thead>
<tr>
<th>Patient</th>
<th>Amount</th>
<th>Date</th>
</tr>
</thead>
<tbody>
@foreach (var inv in Model)
{
<tr>
<td>@inv.PatientId</td>
<td>@inv.Amount</td>
<td>@inv.Date.ToShortDateString()</td>
</tr>
}
</tbody>
</table>
<form asp-action="Create" method="post">
<input asp-for="PatientId" placeholder="Patient ID" />
<input asp-for="Amount" placeholder="Amount" />
<button type="submit">Generate Invoice</button>
</form>
Notifications Screen – Views/Notification/Index.cshtml
cshtml
@model IEnumerable<HospitalManagement.Models.Notification>
<h2>Notifications</h2>
<ul>
@foreach (var n in Model)
{
<li>@n.Date.ToShortDateString() - @n.Message</li>
}
</ul>
<form asp-action="Create" method="post">
<input asp-for="Message" placeholder="Notification Message" />
<button type="submit">Send Notification</button>
</form>
Chat Screen – Views/Chat/Index.cshtml
html
<div id="chatBox"></div><input id="chatInput" type="text" placeholder="Type a message..." /><button onclick="sendMessage()">Send</button>javascript
function sendMessage() {
const message = document.getElementById("chatInput").value;
const chatBox = document.getElementById("chatBox");
chatBox.innerHTML += `<p>${new Date().toLocaleTimeString()}: ${message}</p>`;
document.getElementById("chatInput").value = "";
}
📌 Conclusion (Part 1)
In this first part, we covered:
The MVC architecture of HospitalManagement.
The database schema for Patients, Staff, Invoices, Notifications.
Razor screens for Patient, Staff, Finance, Notifications, and Chat modules.
This sets up the UI and data foundation of the system. You can explore the full implementation in the HospitalManagement GitHub repo

Join the conversation! Your thoughts help the community grow.