0% found this document useful (0 votes)
9 views18 pages

Centralized Hospital Locator System

The document outlines a mini project for a centralized hospital locator and appointment management system developed by a group of BTech students. The system aims to improve healthcare access by allowing users to find nearby hospitals based on location and emergency severity, as well as manage appointments with doctors. The project includes software requirements, a problem statement, and Java code implementing data structures such as linked lists and hash maps for efficient data handling.

Uploaded by

eva106731
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views18 pages

Centralized Hospital Locator System

The document outlines a mini project for a centralized hospital locator and appointment management system developed by a group of BTech students. The system aims to improve healthcare access by allowing users to find nearby hospitals based on location and emergency severity, as well as manage appointments with doctors. The project includes software requirements, a problem statement, and Java code implementing data structures such as linked lists and hash maps for efficient data handling.

Uploaded by

eva106731
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

DATA STRUCTURES MINI PROJECT

OPEN ENDED ASSIGNMENT 9


Group Members- SY BTECH COMP A(A3)

454: Rucha Phadke


458: Rutuja Kale
474: Vishnupriya Lappasi

Rubrics: Create a small applica on using appropriate data structures


showcasing proficiency in problem defini on, requirement gathering, modular
solu on design with dis nct separa on of abstract data types and their
u liza on, cra ing clear func on prototypes, and effec vely distribu ng tasks
among func ons.

Problem Statement: Create a centralized hospital locator and appointment


management system to assist users in finding nearby hospitals based on
loca on and emergency severity. The system allows users to pre-register for
appointments with age-range considera on, select from available doctors by
specialty, and view or update previous appointments. This streamlined solu on
improves access to healthcare by providing mely and relevant hospital and
doctor informa on, helping users efficiently navigate healthcare needs in both
rou ne and urgent situa ons.

Relevance and Proficieny: In modern healthcare systems, accessing nearby


hospitals and securing mely appointments, especially in emergencies, is
essen al yet o en bulky. Currently, pa ents face significant challenges in
iden fying hospitals within specific areas and securing appointments with
appropriate healthcare providers. This issue is exacerbated by a lack of
centralized systems that address emergency needs based on the urgency level
and age appropriateness of care, limi ng pa ent access to suitable facili es
and mely interven ons.
To address these challenges, the Crimson Compass is designed as an intelligent,
centralized pla orm to streamline hospital search and pa ent appointment
processes.
Software Requirements and Code:
1. Programming Language: Java
2. Development Environment: Eclispe
3. Libraries: [Link]
4. File Management: [Link] file

DEVELOPMENT TOOL DOWNLOAD: h ps://[Link]/stleary/JSON-


java?tab=readme-ov-file

PLATFORM URL: h ps://[Link]/

CODE:
[out:json];
area["name"="Pune"]->.searchArea;
(
node["amenity"="hospital"]([Link]);
way["amenity"="hospital"]([Link]);
rela on["amenity"="hospital"]([Link]);
);
out body;
>;
out skel qt;
JAVA CODE:

package HospitalFinder; //java package

//importing necessary java in-built packages


import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link].*;
import [Link];
import [Link];

class LinkedList<K, V> //generic linked list class


{
class Node<K, V> {
K key;
V value;
Node<K, V> next;

Node(K key, V value) {


[Link] = key;
[Link] = value;
[Link] = null;
}
}

private Node<K, V> head; // Add a new entry to the linked list

public void add(K key, V value) {


//add node method
Node<K, V> newNode = new Node<>(key, value);
[Link] = head;
head = newNode;
}

// Get the value by key


public V get(K key) {
Node<K, V> current = head; //traverse linked list with input key
while (current != null) {
if ([Link](key)) {
return [Link]; //return searched matching value
}
current = [Link]; //current pointer stepped ahead
}
return null; // Return null if not found
}

// Remove an entry by key


public boolean remove(K key) {
if (head == null) return false; // List is empty
if ([Link](key)) {
head = [Link]; // Remove head
return true;
}
Node<K, V> current = head;
while ([Link] != null) {
if ([Link](key)) {
[Link] = [Link]; // Remove the node
return true;
}
current = [Link];
}
return false; // Key not found, return false
}

public boolean containsKey(K key) { //check if key exists


Node<K, V> current = head;
while (current != null) {
if ([Link](key)) {
return true; // Key found
}
current = [Link];
}
return false; // Key not found
}

public ArrayList<K> getKeys() {


ArrayList<K> keys = new ArrayList<>();
Node<K, V> current = head;
while (current != null) { //traverse linked list
[Link]([Link]); // Add key to the list
current = [Link];
}
return keys; // Return the array list of keys
}
}

//linked list class ends here

//HashMap implementation using the linked list

class HashMap<K, V> { //HashMap class


private LinkedList<K, V>[] slots;
//linked list class object slots array creation
private int size; // Number of slots (pre-defined)
private int entries; // Number of entries in the HashMap

public HashMap(int capacity) { //class constructor


[Link] = capacity;
[Link] = 0;
slots = new LinkedList[size];
for (int i = 0; i < size; i++) {
slots[i] = new LinkedList<>();
}
}

//chaining method implemented


private int hash(K key) {
return [Link]([Link]()) % size; // In-built modulo hash function
}

public void put(K key, V value) { //add functionality


int keyIndex = hash(key);
LinkedList<K, V> singleSlot = slots[keyIndex];

// Check if the key already exists and update its value


if ([Link](key) != null) {
[Link](key); // Remove old value
}
[Link](key, value); // Add new entry
entries++;
}

public V get(K key) { //provides linked list on that key


int keyIndex = hash(key);
LinkedList<K, V> singleSlot = slots[keyIndex];
return [Link](key); // Get the value from the slot
}

public void remove(K key) { //delete functionality


int keyIndex = hash(key);
LinkedList<K, V> singleSlot = slots[keyIndex];
if ([Link](key)) {
entries--; // Decrease size if removal was successful
}
}

public int current_size() { //number of entries filled currently


return entries;
}

public boolean isEmpty() { //method to check whether hashmap is empty


return size == 0;
}

public boolean containsKey(K key) {


int keyIndex = hash(key); // Get the index for the key
LinkedList<K, V> singleSlot = slots[keyIndex];
// Access the corresponding slots
//key as an argument passed
return [Link](key); //belongs to linked list class
}

public ArrayList<K> keySet() {


ArrayList<K> keys = new ArrayList<>();
for (LinkedList<K, V> slot : slots) {
[Link]([Link]()); // Gather keys from each slots
}
return keys; // Return the list of keys
}
}

class Hospital { //class Hospital


String name; //instance variables declaration
double lat;
double lon;
String area;

//paramterized class constructor


public Hospital(String name, double lat, double lon, String area) {
[Link] = name;
[Link] = lat;
[Link] = lon;
[Link] = area;
}

@Override
public String toString() {
return "Hospital{" +
"name='" + name + '\'' +
", lat=" + lat +
", lon=" + lon +
", area='" + area + '\'' +
'}';
}
}

class Appointment { //Appointment class


String patientName;
String hospitalName;
String appointmentDate;
String ageRange;
String appointmentTime;

//paramaterized class constructor


public Appointment(String patientName, String hospitalName, String
appointmentDate, String ageRange, String appointmentTime) {
[Link] = patientName;
[Link] = hospitalName;
[Link] = appointmentDate;
[Link] = ageRange;
[Link] = appointmentTime;
}

@Override
public String toString() {
return "Appointment{" +
"patientName='" + patientName + '\'' +
", hospitalName='" + hospitalName + '\'' +
", appointmentDate='" + appointmentDate + '\'' +
", ageRange='" + ageRange + '\'' +
", appointmentTime='" + appointmentTime + '\'' +
'}';
}
}

class Doctor { //Doctor class


String name;
String shiftStart;
String shiftEnd;
String type;

//parameterized class constructor


public Doctor(String name, String shiftStart, String shiftEnd, String type) {
[Link] = name;
[Link] = shiftStart;
[Link] = shiftEnd;
[Link] = type;
}

//boolean method to check the availability of doctor


public boolean isAvailable(String appointmentTime) {
return [Link](shiftStart) >= 0 &&
[Link](shiftEnd) <= 0;
}

@Override
public String toString() {
return "Doctor{" +
"name='" + name + '\'' +
", shiftStart='" + shiftStart + '\'' +
", shiftEnd='" + shiftEnd + '\'' +
", type='" + type + '\'' +
'}';
}
}

public class HospitalFinder {


//Main Class
static HashMap<String, ArrayList<Hospital>> areaMap = new HashMap<>(20);
static ArrayList<Appointment> appointments = new ArrayList<>();
static HashMap<String, ArrayList<Doctor>> hospitalDoctorsMap = new
HashMap<>(20);
public static void main(String[] args) {
//main method
Scanner sc = new Scanner([Link]);
int choice = 0;
[Link]("________________________________________________________");
[Link]("1910 - PUNE CENTRALIZED MEDICAL HELPLINE NUMBER");
[Link]("In case of emergency, we're there for you!");
[Link]("________________________________________________________");
[Link]("########### HOSPITAL AND APPOINTMENT SYSTEM ###########");

//method to detect emergency level and provide functionality accordingly


int emergencyLevel = getValidEmergencyLevel(sc);

while (choice != 5) {
[Link]("\n1. Find hospitals by area and emergency level");
[Link]("2. Make an appointment");
[Link]("3. View previous appointments");
[Link]("4. Update an appointment");
[Link]("5. Exit");
[Link]("Enter your choice: ");
choice = getValidChoice(sc);
//check if entered choice is valid- method call
switch (choice) { //switch case
case 1:
loadHospitalData();
break;
case 2:
makeAppointment(sc, emergencyLevel);
break;
case 3:
viewAppointments();
break;
case 4:
updateAppointment(sc);
break;
case 5:
[Link]("Exiting the system. Stay safe!");
break;
default:
[Link]("Invalid choice! Please try again.");
}
}
[Link]();
}

// Get a valid emergency level (1 to 10)


public static int getValidEmergencyLevel(Scanner sc) {
int emergencyLevel = 0;
while (true) { //create a loop
try { //try block
[Link]("1: Minor--------> 10: Extremely Critical");
[Link]("Rate the emergency: ");
emergencyLevel = [Link]();
[Link](); // Consume newline
if (emergencyLevel < 1 || emergencyLevel > 10) {
[Link]("Invalid emergency level. Please enter a
number between 1 and 10.");
} else {
break;
}
} catch (InputMismatchException e) { //catch block
[Link]("Invalid input! Please enter a valid
number.");
[Link](); // Consume invalid input
}
}
return emergencyLevel; //returns integer
}
// Get a valid menu choice (1 to 5)

public static int getValidChoice(Scanner sc) {


int choice = 0;
while (true) {
try { //try block
choice = [Link]();
[Link](); // Consume newline
if (choice >= 1 && choice <= 5) {
break;
} else {
[Link]("Invalid choice! Please enter a number
between 1 and 5.");
}
} catch (InputMismatchException e) { //catch block
[Link]("Invalid input! Please enter a valid
number.");
[Link](); // Consume invalid input
}
}
return choice; //returns integer
}

// Method to validate the date format (dd/mm/yyyy) and the validity of the date

public static boolean isValidDate(String date) {


// Check if the date matches the format dd/mm/yyyy
String regex = "^(0[1-9]|[12][0-9]|3[01])/(0[1-9]|1[0-2])/(\\d{4})$";
if (![Link](regex)) {
return false;
}
// Further validate the date using SimpleDateFormat
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
[Link](false); // Disallow dates like 31/02/2024
try {
Date parsedDate = [Link](date);
return parsedDate != null;
} catch (ParseException e) {
return false;
}
}

public static void loadHospitalData() {


try {
//JSON file creation and file path is passed.
File jsonFile = new
File("C:\\Users\\Rutuja\\Downloads\\[Link]");
//FileReader class object creation to read the file
FileReader fileReader = new FileReader(jsonFile);
//StringBuilder class object creation to read the file in String format
StringBuilder stringBuilder = new StringBuilder();
int i;
//parsing the file using while loop
while ((i = [Link]()) != -1) {
//reading in character format
[Link]((char) i);
}
//JSON root object- arrays inside the root object
JSONObject rootObject = new JSONObject([Link]());
//defining JSON array of elements
JSONArray elements = [Link]("elements");
//function call to get hospitals
HashMap<String, ArrayList<Hospital>> areaMap =
groupHospitalsByArea(elements);
//Scanner class object creation
Scanner scanner = new Scanner([Link]);
[Link]("Enter area name to get hospitals: ");
String areaName = [Link]().trim();
//ArrayList storage of entered area of user
ArrayList<Hospital> hospitalsInArea = getHospitalsByArea(areaMap,
areaName);
//valid checking of null list
if (hospitalsInArea == null || [Link]() == 0) {
[Link]("No hospitals found in the area: " +
areaName);
} else {
[Link]("Hospitals in " + areaName + ":");
for (Hospital hospital : hospitalsInArea) {
[Link](hospital);
ArrayList<Doctor> doctors =
[Link]([Link]);
if (doctors != null) {
for (Doctor doctor : doctors) {
[Link](doctor);
}
}
}
}
[Link](); //releasing memory of fileReader
} catch (IOException e) { //catch block
[Link]("Error reading hospital data file: " +
[Link]());
} catch ([Link] e) {
[Link]("Error parsing JSON data: " + [Link]());
}
}

public static HashMap<String, ArrayList<Hospital>>


groupHospitalsByArea(JSONArray elements) {
HashMap<String, ArrayList<Hospital>> areaMap = new HashMap<>(20);
// Traverse the JSON array (each element is a hospital)
for (int j = 0; j < [Link](); j++) {
JSONObject element = [Link](j);
// Extract relevant fields: name, lat, lon, area
String name = [Link]("tags") != null &&
[Link]("tags").optString("name", null) != null
? [Link]("tags").optString("name")
: "Unknown";
double lat = [Link]("lat", 0.0);
double lon = [Link]("lon", 0.0);
String area = [Link]("tags") != null &&
[Link]("tags").optString("addr:full", null) != null
? [Link]("tags").optString("addr:full")
: "Unspecified Area";
// Normalize area names for comparison
area = [Link]().toLowerCase();
// Create a Hospital object
Hospital hospital = new Hospital(name, lat, lon, area);
// Add to the area map
if (![Link](area)) {
[Link](area, new ArrayList<>());
}
[Link](area).add(hospital);
}
return areaMap;
}

public static ArrayList<Hospital> getHospitalsByArea(HashMap<String,


ArrayList<Hospital>> areaMap, String areaName) {
//Normalize
areaName = [Link]().toLowerCase();
//new arraylist
ArrayList<Hospital> hospitalsInArea = new ArrayList<>();
try {
//compare
for (String area : [Link]()) {
if ([Link](areaName)) {
//store hospitals in new arraylist
[Link]([Link](area));
}
}
} catch (Exception e) { //catch block
[Link]("Error retrieving hospitals by area: " +
[Link]());
}
//return arraylist of hospitals
return hospitalsInArea;
}

//input validation function


public static String getValidStringInput(Scanner scanner, String prompt) {
String input;
while (true) {
[Link](prompt);
input = [Link]();
//lower case and upper case checking
if ([Link]("[a-zA-Z\\s]+")) {
// Allows only letters and spaces
break;
} else {
[Link]("Invalid input.");
}
}
return input;
}

public static void makeAppointment(Scanner sc, int emergencyLevel) {


try {
[Link]("__________________________________________");
if (emergencyLevel > 5) {
//if high emergency, then skipping details
[Link]("Enter patient's name ");
String patientName = getValidStringInput(sc, " (letters only):
");
[Link]("Enter hospital name ");
String hospitalName = getValidStringInput(sc, " (letters only):
");
[Link]("Enter age range of the patient (e.g., infant,
child, adult, elderly) ");
String ageRange = getValidStringInput(sc, ": ");
[Link](new Appointment(patientName, hospitalName,
"N/A", ageRange, "N/A"));
} else {
//lower emergencies, asking for details
[Link]("Enter patient's name ");
String patientName = getValidStringInput(sc, " (letters only):
");
[Link]("Enter hospital name ");
String hospitalName = getValidStringInput(sc, " (letters only):
");
[Link]("Enter age range of the patient (e.g., infant,
child, adult, elderly) ");
String ageRange = getValidStringInput(sc, ": ");

// Date and Age Range


String appointmentDate = "";
String ageRangee = "";
// Validate appointment date
while (true) {
[Link]("Enter appointment date (dd/mm/yyyy): ");
appointmentDate = [Link]().trim();
if (isValidDate(appointmentDate)) {
break;
} else {
[Link]("Invalid date format! Please enter a
valid date (dd/mm/yyyy)");
}
}
[Link]("Doctors available:");
[Link]("Dr. Vijay Mallya (Orthopedic)");
[Link]("Dr. Kartik Naik (General Physician)");
[Link]("Dr. Sanika Singhaniya (Cardiologist)");
[Link]("Dr. Sakshi Goenka (Pediatrician)");
[Link]("Dr. Namita Thapar (Neurologist)");
[Link]("Dr. Sushma Rathi (Surgeon)");
[Link]("Dr. Neha Dhupia (Orthopedic)");
[Link]("Dr. Kaitlin Dsouza (Cardiologist)");
[Link]("Enter doctor type: ");
String doctorType = [Link]();
[Link]("Enter appointment time (HH:mm): ");
String appointmentTime = [Link]();
[Link](new Appointment(patientName, hospitalName,
appointmentDate, ageRange, appointmentTime));
}
[Link]("Appointment added successfully!");
} catch (Exception e) { //catch block
[Link]("Error while making an appointment: " +
[Link]());
}
}

public static void viewAppointments() {


try {
[Link]("Previous appointments:");
if ([Link]()) { //checking for empty appointments
[Link]("No previous appointments found.");
} else {
for (Appointment appointment : appointments) {
[Link](appointment);
}
}
} catch (Exception e) { //catch block
[Link]("Error while viewing appointments: " +
[Link]());
}
}

public static void updateAppointment(Scanner sc) {


try {
[Link]("Enter the patient's name for the appointment to
update: "); //name for updating appointment
String patientName = [Link]();
boolean found = false;
//for loop to check with all appointments
for (Appointment appointment : appointments) {
if ([Link](patientName)) {
[Link]("Enter new appointment date (dd/mm/yyyy):
");
[Link] = [Link]();
[Link]("Enter new appointment time (HH:mm): ");
[Link] = [Link]();
[Link]("Appointment updated successfully!");
found = true;
break;
}
}
if (!found) { //No appointment
[Link]("No appointment found for this patient!");
}
} catch (Exception e) { //catch block
[Link]("Error while updating the appointment: " +
[Link]());
}
}
}

OUTPUT:

1. Case of Emergency-

________________________________________________________
1910 - PUNE CENTRALIZED MEDICAL HELPLINE NUMBER
In case of emergency, we're there for you!
________________________________________________________
########### HOSPITAL AND APPOINTMENT SYSTEM ###########
1: Minor--------> 10: Extremely Critical
Rate the emergency: 9

1. Find hospitals by area and emergency level


2. Make an appointment
3. View previous appointments
4. Update an appointment
5. Exit
Enter your choice: 1
Enter area name to get hospitals: Baner Road
Hospitals in Baner Road:
Hospital{name='Dhanwantari Hospital', lat=18.5593096, lon=73.7895512,
area='dhanwantari building, baner road, pune'}
Hospital{name='Gupte Hospital Extension Clinic', lat=18.557773, lon=73.793639,
area='shiv shakti complex, 2nd floor, baner road, pune'}

1. Find hospitals by area and emergency level


2. Make an appointment
3. View previous appointments
4. Update an appointment
5. Exit
Enter your choice: 2
__________________________________________
Enter patient's name (letters only): Alex Volkof
Enter hospital name (letters only): Dhanwantari Hospital
Enter age range of the patient (e.g., infant, child, adult, elderly) : adult
Appointment added successfully!

1. Find hospitals by area and emergency level


2. Make an appointment
3. View previous appointments
4. Update an appointment
5. Exit
Enter your choice: 3
Previous appointments:
Appointment{patientName='Alex Volkof', hospitalName='Dhanwantari Hospital',
appointmentDate='N/A', ageRange='adult', appointmentTime='N/A'}

1. Find hospitals by area and emergency level


2. Make an appointment
3. View previous appointments
4. Update an appointment
5. Exit
Enter your choice: 4
Enter the patient's name for the appointment to update: Alex Volkof
Enter new appointment date (dd/mm/yyyy): 12/11/2024
Enter new appointment time (HH:mm): 17:30
Appointment updated successfully!

1. Find hospitals by area and emergency level


2. Make an appointment
3. View previous appointments
4. Update an appointment
5. Exit
Enter your choice: 3
Previous appointments:
Appointment{patientName='Alex Volkof', hospitalName='Dhanwantari Hospital',
appointmentDate='12/11/2024', ageRange='adult', appointmentTime='17:30'}

1. Find hospitals by area and emergency level


2. Make an appointment
3. View previous appointments
4. Update an appointment
5. Exit
Enter your choice: 5
Exiting the system. Stay safe!

2. Case of no Emergency-

________________________________________________________
1910 - PUNE CENTRALIZED MEDICAL HELPLINE NUMBER
In case of emergency, we're there for you!
________________________________________________________
########### HOSPITAL AND APPOINTMENT SYSTEM ###########
1: Minor--------> 10: Extremely Critical
Rate the emergency: 2

1. Find hospitals by area and emergency level


2. Make an appointment
3. View previous appointments
4. Update an appointment
5. Exit
Enter your choice: 1
Enter area name to get hospitals: Kothrud
Hospitals in Kothrud:
Hospital{name='Argade Infertility and Endoscopic Surgery and Icu Center',
lat=18.5017523, lon=73.8102353, area='1st floor, kothrud telephone exchange
building, kothrude'}
Hospital{name='Deoyani Hospital', lat=0.0, lon=0.0, area='dahanukar colony, plot
no. 99, near cummins india ltd., kothrud'}
Hospital{name='Suyash Hospital', lat=18.5001862, lon=73.8124022, area='plot no.1,
kothrud bus stand road, dattachhaya tejas society, kothrud, pune'}
Hospital{name='Ambekar Hospital', lat=18.5054055, lon=73.817541, area='plot no 86,
opposite jog school, bank of maharashtra, mayur colony, kothrud'}
Hospital{name='Bindu Madhav Thakarey Hospital', lat=18.496127, lon=73.817109,
area='paschimanagri, kothrud, pune'}
Hospital{name='PMC - Late. Jayabai Nanasaheb Sutar Maternity Home', lat=0.0,
lon=0.0, area='shastri nagar road, azad nagar, kothrud, pune'}
Hospital{name='Kamal Netra Rugnalaya', lat=18.4949914, lon=73.81219,
area='106,dahanukar colony 3road lane kothrud'}
Hospital{name='Rode Hospital', lat=18.5091812, lon=73.8149589, area='building no
10, anand nagar, ground floor, late ga kulkarni path, kothrud, pune'}
Hospital{name='FPA , Kothrud', lat=18.506552, lon=73.7886402, area='bhusari
colony, kothrud, pune'}
Hospital{name='Subodh Hospital', lat=18.5035234, lon=73.8137605, area='138, shiayi
statue chowk, dp road kothrud, pune'}
Hospital{name='City Hospital', lat=18.5071504, lon=73.7997343, area='motiram
complex, paud road, opp. kachara depot, shastri nagar, kothrud, pune'}
Hospital{name='Shashwat Hospital', lat=18.4948349, lon=73.8135271, area='palavi
prime, 22, happy colony, kothrud'}
Hospital{name='Shashwat Hospital', lat=18.4944973, lon=73.8135873, area='palavi
prime, 22, happy colony, kothrud'}

1. Find hospitals by area and emergency level


2. Make an appointment
3. View previous appointments
4. Update an appointment
5. Exit
Enter your choice: 2
__________________________________________
Enter patient's name (letters only): Akshay Kumar
Enter hospital name (letters only): City Hospital
Enter age range of the patient (e.g., infant, child, adult, elderly) : elderly
Enter appointment date (dd/mm/yyyy): 15/11/2024
Doctors available:
Dr. Vijay Mallya (Orthopedic)
Dr. Kartik Naik (General Physician)
Dr. Sanika Singhaniya (Cardiologist)
Dr. Sakshi Goenka (Pediatrician)
Dr. Namita Thapar (Neurologist)
Dr. Sushma Rathi (Surgeon)
Dr. Neha Dhupia (Orthopedic)
Dr. Kaitlin Dsouza (Cardiologist)
Enter doctor type: Surgeon
Enter appointment time (HH:mm): 12:00
Appointment added successfully!

1. Find hospitals by area and emergency level


2. Make an appointment
3. View previous appointments
4. Update an appointment
5. Exit
Enter your choice: 3
Previous appointments:
Appointment{patientName='Akshay Kumar', hospitalName='City Hospital',
appointmentDate='15/11/2024', ageRange='elderly', appointmentTime='12:00'}

1. Find hospitals by area and emergency level


2. Make an appointment
3. View previous appointments
4. Update an appointment
5. Exit
Enter your choice: 4
Enter the patient's name for the appointment to update: Akshay Kumar
Enter new appointment date (dd/mm/yyyy): 15/11/2024
Enter new appointment time (HH:mm): 13:00
Appointment updated successfully!

1. Find hospitals by area and emergency level


2. Make an appointment
3. View previous appointments
4. Update an appointment
5. Exit
Enter your choice: 3
Previous appointments:
Appointment{patientName='Akshay Kumar', hospitalName='City Hospital',
appointmentDate='15/11/2024', ageRange='elderly', appointmentTime='13:00'}

1. Find hospitals by area and emergency level


2. Make an appointment
3. View previous appointments
4. Update an appointment
5. Exit
Enter your choice: 5
Exiting the system. Stay safe!

3. Output with error handling

________________________________________________________
1910 - PUNE CENTRALIZED MEDICAL HELPLINE NUMBER
In case of emergency, we're there for you!
________________________________________________________
########### HOSPITAL AND APPOINTMENT SYSTEM ###########
1: Minor--------> 10: Extremely Critical
Rate the emergency: 11
Invalid emergency level. Please enter a number between 1 and 10.
1: Minor--------> 10: Extremely Critical
Rate the emergency: 1

1. Find hospitals by area and emergency level


2. Make an appointment
3. View previous appointments
4. Update an appointment
5. Exit
Enter your choice: 8
Invalid choice! Please enter a number between 1 and 5.
1
Enter area name to get hospitals: Karve Nagar
Hospitals in Karve Nagar:
Hospital{name='Khenat Hospital and Maternity Home', lat=18.4891281,
lon=73.8138248, area='sai housing society,karve nagar'}
Hospital{name='Bhagirathi Children's Hospital', lat=18.4947224, lon=73.8229041,
area='plot no 23, raghukul society, girija shankar vihar, karve nagar, pune'}

1. Find hospitals by area and emergency level


2. Make an appointment
3. View previous appointments
4. Update an appointment
5. Exit
Enter your choice: 2
__________________________________________
Enter patient's name (letters only): 1234
Invalid input.
(letters only): Twinkle Khanna
Enter hospital name (letters only): t5
Invalid input.
(letters only): Khenat Hospital
Enter age range of the patient (e.g., infant, child, adult, elderly) : adult
Enter appointment date (dd/mm/yyyy): 32/13/2024
Invalid date format! Please enter a valid date (dd/mm/yyyy)
Enter appointment date (dd/mm/yyyy): 14/11/2024
Doctors available:
Dr. Vijay Mallya (Orthopedic)
Dr. Kartik Naik (General Physician)
Dr. Sanika Singhaniya (Cardiologist)
Dr. Sakshi Goenka (Pediatrician)
Dr. Namita Thapar (Neurologist)
Dr. Sushma Rathi (Surgeon)
Dr. Neha Dhupia (Orthopedic)
Dr. Kaitlin Dsouza (Cardiologist)
Enter doctor type: Cardiologist
Enter appointment time (HH:mm): 19:45
Appointment added successfully!

1. Find hospitals by area and emergency level


2. Make an appointment
3. View previous appointments
4. Update an appointment
5. Exit
Enter your choice: 3
Previous appointments:
Appointment{patientName='Twinkle Khanna', hospitalName='Khenat Hospital',
appointmentDate='14/11/2024', ageRange='adult', appointmentTime='19:45'}

1. Find hospitals by area and emergency level


2. Make an appointment
3. View previous appointments
4. Update an appointment
5. Exit
Enter your choice: 5
Exiting the system. Stay safe!

Common questions

Powered by AI

Upon making an appointment, the system checks the emergency level. For high emergencies (above 5), minimal details are required. Otherwise, it prompts for the patient's name, hospital name, age range, and validates the appointment date against a specified format. After verifying these inputs, the system saves the appointment using the Appointment constructor and adds it to an ArrayList of appointments, displaying a success message upon completion .

Area maps are structured to group hospitals by location, making it easier to find hospitals based on a searched area. Hospital doctors maps link doctors to specific hospitals, allowing the system to showcase available doctors when a hospital is selected. Both serve to enhance data retrieval and organization, offering efficient access to medical resources .

The system uses a numeric rating from 1 to 10 to differentiate the severity of medical emergencies. A lower number indicates a minor emergency, while a higher number reflects more critical needs. This system allows for varying levels of detail and service based on the urgency, adjusting tasks such as appointment scheduling to accommodate .

The system uses a regex pattern to check if the entered date matches the expected format of dd/mm/yyyy. Further validation is performed using SimpleDateFormat with setLenient set to false to ensure dates such as 31/02/2024 are invalid. The date is parsed, and if it doesn't throw an exception, it is deemed valid .

The system loads hospital data by reading a JSON file containing hospital details. It parses the JSON to extract relevant fields such as name, latitude, longitude, and area. Hospitals are then organized in a HashMap, grouped by the normalized area names. Each area serves as a key, storing a list of hospitals as value in ArrayList form. This structure allows for efficient retrieval of hospitals by area .

The system utilizes the `isAvailable` method within the Doctor class to check alignment between doctor availability and appointment timings. This method compares the appointment time against the doctor's shift start and end times, ensuring that appointments are scheduled only when the doctor is available .

The system implements a loop to validate input for the emergency level. If the input is not within the specified range (1 to 10), or if a non-integer is entered, an error message prompts the user to enter a valid number between 1 and 10. InputMismatchException is caught and handled to consume invalid input and allow the user another chance to enter a correct value .

When updating an appointment, the system uses a try-catch block to handle potential exceptions. If no matching record is found, it informs the user, and exceptions within input procedures are caught to prevent crashes. This robust error handling ensures inputs are valid before they can affect stored data, maintaining system integrity .

During user command execution, the system accommodates errors by employing try-catch blocks. InputMismatchException handles non-integer inputs and invalid choices. For each option selected by the user, errors are caught, and friendly error messages prompt corrective actions, allowing users to retry without disruption .

The system uses the `getValidStringInput` function, which ensures that inputs contain only letters and spaces. It repeatedly prompts the user for input until a valid response is provided, thus preventing numeric or special characters from being entered for the patient's or hospital's name .

You might also like