This project uses C#, ADO.net and its ODBC connector and adapters, Winforms, MySQL Connector/ODBC, and MariaDB hosted via XAMPP Apache. Using WinForms, we create a Form that has a TabControl element, with 5 tabs. Each tab has a BasicControl class which inherits from UserControl, a type of WinForms component. This Form will be added to each tab, creating 5 separate screens to manage the hospital. This project is x64, 64 bit.
This program is linked to a MariaDB database, which stores some information about a hospital. It can store the wards of the hospital, the rooms in those wards, and the beds in each room. The database stores patients, medical staff, and the medical procedures performed at the hospital, either a surgical operation or simply caregiving by the staff. Consult the ERD diagrams in the UMLERD.pdf file to learn more about the attributes and relations in this database.
- The window is a Winforms Form class. Inside is a TabControl component, with many tabs that have screens.
- These screens are BasicControl classes. The screens have many components, some of which are filled with an OdbcAdapter that connects to MariaDB. The user interacts with the components.- Event handlers tied to these components use OdbcSingleton which manages an OdbcConnection that connects to MariaDB using a connection string saved by .NET as a variable.
- This OdbcSingleton uses statements and queries to update or search for data, while also protecting the program from SQL injection.
- There are various model classes to aid in the management and display of values, and use inheritance in a way that they can be expanded further to implement methods that would help in hospital management.
Each screen is a type of UserControl. Each screen has many more UserControl components inside. Data is presented and interacted with using TextBox, DataGridView, and ComboBox components. Text boxes simply capture text. ComboBox and DataGridView components can display from our database via DataSet classes or defined model classes meant to represent database entries. It does this by having a DataSource property, which can be bound to a DataSet or a data structure.
The database is MariaDB hosted on a XAMPP Apache server hosted at localhost on port 3306. Using the data configurator wizard and the ODBC data sources tool from the MySQL Connector/ODBC 8.3.0 x64 from Oracle, we can retrieve tables from MariaDB and enter them into the DataSet class. A DataSet instance is generated by the data wizard, and has tables that correspond to each table in MariaDB. These tables have rows and columns. We can use the OdbcAdapter class's Fill method to use a SELECT * query and fill our DataSet. Winforms then fills the ComboBox or DataGridView from the DataSet.
Depending on the type of data, we use classes to represent the data and display it better. For example, we use the DataSet to create a Doctor class, which has special attributes to display data, such as their staff id and their full name together. Some of these classes inherit from a base class, structured in a way so that future methods specific to certain classes can be implemented. For example, a doctor could have a special method to fill a prescription. Currently, no such classes are implemented and they are used as ways to store and return data.
Users can interact with the components, which will trigger event handlers from each screen. The information will be validated, and then a query will be made to the database using my class OdbcSingleton, which connects to the database using an OdbcConnection instance that takes a connection string. The .NET data adapter has the string stored as a variable. The inputs will be validated with WinForms own exceptions and with exceptions the screens throw when data fails to meet the required format. Once the data has been entered and validated, the OdbcSingleton uses a string with parameters, which will be supplied and then the statement will be executed.
The program consists of 5 screens. Whenever a datagridview entry is modified, the user must click off onto a different to trigger WinForms to validate the row. It will then be sent to the database via an insert or update statement. Rows can be deleted by clicking on the leftmost empty cell and hitting the DEL key. More details about each can be found in the comments of their respective .cs files.
- Patient Management
- Patients are added to the database, with an admission date automatically set as today's date. They will need a first name, last name, and a phone number supplied. Patient IDs are randomly generated. If a patient is deleted from this screen, they will be discharged with today's date and hidden from this screen.
- Room Management
- The most complicated screen. Users select a ward and a room number. The program will only display rooms marked as for patients, as surgical rooms cannot have beds with patients. Once a room is selected, the user can add more beds or assign existing patients to beds. A patient can only have one bed per room and having multiple instances of a patient will give an error. If a patient has been discharged, they will automatically be removed from the room.
- Schedule Procedure
- Here, a user can schedule a surgery or routine care for a patient. Only doctors can perform surgery procedures and only nurses can perform care procedures. The user enters a name for the procedure, a date, and selects which patient, staff member, and room will be used.
- Patient Operations
- The user can select a patient from a dropdown and edit their date of admission or discharge. If they have not been discharged, the user must press the discharge patient button. The admission date cannot be after the discharge date. You can also view a patient's procedures and mark them as completed here.
- Manage Staff
- Similar to patient management, we can add staff members, who will have their first and last name entered, along with a job title. A staff member can either be a nurse or doctor. Their phone number and email will need to be added. A random staff ID will be generated and they will be added to the database.
- Install XAMPP 8.0.30
- Install MySQL Connector/ODBC 8.3.0 64-bit. (For some reason, the page mislabels it as x86, but the file should correctly say x64.
- Run an Apache server and run MariaDB.
- Open PHPMyAdmin and create a database named hospital.
- Click on the hospital database. Click Import. Import the hospital.sql file included with this repo.
- Open ODBC data sources 64-bit.
- Add a User DSN with the MySQL ODBC 8.3.0 ANSI driver.
- Name the data source whatever you want. Set the TCP/IP server to be 127.0.0.1 and set the port to match XAMPP. It should be 3306 by default.
- Enter the username as root and select hospital for the database.
- Open the .csproj in Visual Studio. Click the project tab at the top and click add data source. Select the MariaDB DSN you just created.
- Build and run!
Harry Jung, 2024