Hospital Management System Complex Structures
Hospital Management System Complex Structures
PROGRAM
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Patient {
int patientID;
char name[100];
int age;
char gender[10];
char diagnosis[200];
float totalBill;
};
struct Appointment {
char doctorName[100];
};
struct Hospital {
};
// Function to create a new appointment node
strcpy(newAppointment->doctorName, doctorName);
strcpy(newAppointment->date, date);
strcpy(newAppointment->time, time);
newAppointment->next = NULL;
return newAppointment;
struct Patient* createPatient(int patientID, char* name, int age, char* gender, char* diagnosis) {
newPatient->patientID = patientID;
strcpy(newPatient->name, name);
newPatient->age = age;
strcpy(newPatient->gender, gender);
strcpy(newPatient->diagnosis, diagnosis);
newPatient->next = NULL;
return newPatient;
void addPatient(struct Hospital *hospital, int patientID, char* name, int age, char* gender, char*
diagnosis) {
if (hospital->patientList == NULL) {
hospital->patientList = newPatient;
} else {
temp = temp->next;
temp->next = newPatient;
if (hospital->patientList == NULL) {
return;
printf("Patient Details:\n");
printf("ID\tName\tAge\tGender\tDiagnosis\n");
temp = temp->next;
if (temp->patientID == patientID) {
scanf("%f", &consultationFee);
scanf("%f", &treatmentFee);
scanf("%f", &medicationFee);
scanf("%f", &roomCharges);
return;
temp = temp->next;
if (temp->patientID == patientID) {
if (temp->appointments == NULL) {
temp->appointments = newAppointment;
} else {
appointmentTemp = appointmentTemp->next;
}
appointmentTemp->next = newAppointment;
return;
temp = temp->next;
if (temp->patientID == patientID) {
if (temp->appointments == NULL) {
return;
printf("Doctor Name\tDate\tTime\n");
appointmentTemp = appointmentTemp->next;
return;
temp = temp->next;
}
int main() {
while (1) {
printf("6. Exit\n");
scanf("%d", &choice);
switch (choice) {
case 1:
// Adding a patient
scanf("%d", &patientID);
scanf("%d", &age);
break;
case 2:
displayPatients(&hospital);
break;
case 3:
scanf("%d", &patientID);
generateBill(&hospital, patientID);
break;
case 4:
scanf("%d", &patientID);
scheduleAppointment(&hospital, patientID);
break;
case 5:
scanf("%d", &patientID);
displayAppointments(&hospital, patientID);
break;
case 6:
exit(0);
break;
default:
return 0;
}
OUTPUT
1. Add Patient
2. Display Patients
4. Schedule Appointment
5. Display Appointments
6. Exit
Enter Age: 18
1. Add Patient
2. Display Patients
4. Schedule Appointment
5. Display Appointments
6. Exit
Enter Age: 18
1. Add Patient
2. Display Patients
4. Schedule Appointment
5. Display Appointments
6. Exit
Patient Details:
1. Add Patient
2. Display Patients
4. Schedule Appointment
5. Display Appointments
6. Exit
1. Add Patient
2. Display Patients
4. Schedule Appointment
5. Display Appointments
6. Exit
1. Add Patient
2. Display Patients
4. Schedule Appointment
5. Display Appointments
6. Exit
1. Add Patient
1. Add Patient
2. Display Patients
2. Display Patients
4. Schedule Appointment
5. Display Appointments
6. Exit
o Add Patient
o Display Patients
o Exit
o Prompt the user to enter patient details (ID, name, age, gender, diagnosis).
o If found, ask for fee details (consultation, treatment, medication, room charges) and
calculate the total bill.
o Create a new appointment node and add it to the patient's list of appointments.
9. Option 6: Exit:
10. End.
PSEUDOCODE
START
WHILE true
1. Add Patient
2. Display Patients
3. Generate Bill
4. Schedule Appointment
5. Display Appointments
6. Exit
Read choice
SWITCH choice:
CASE 1:
CASE 2:
CASE 3:
IF patient found
ELSE
CASE 4:
IF patient found
ELSE
CASE 5:
IF patient found
ELSE
CASE 6:
END WHILE
END
FLOWCHART