Skip to content

Repository files navigation

Hospital Project

The idea of this project was to create a program that can be used by a hospital. In it, different nurses can register, log in, or perform various interactions with the database generated by Doctrine. It includes a set of basic functions that interact with the database through Doctrine:

Function Description
getAllNurses Connects to the database and displays all nurse data as a JSON response
nurseLogin Allows a nurse to attempt login using their credentials stored in the database
findByName Searches for a nurse in the database by name and returns all their details

These were the first ones to be developed. Once finished, we implemented CRUD technology, adding five more functions:

Function Description
Index Similar to "getAllNurses"; retrieves and displays all nurse records
New Allows you to add a new nurse to the database
Show Searches for a nurse by their ID and displays their information
Edit Enables modification of any nurse's data in the database
Delete Deletes a nurse from the database using their ID

Installation

To install the program click the green "Code" button you can either use the download ZIP method or cloning using the URL

Donwloading ZIP

Click the "download ZIP option and extract it. Open the folder using Visual Studio Code which contains all the files

Install dependencies

Our program requires composer in order to work
Execute the following command using either the VSC terminal or Windows Power Shell Note: This requires composer to be installed previously
Also make sure to be executing the command at the folder which contains all the files

composer install

Install doctrine

Doctrine is a library that allows connection with databases, which we used it to manage our CRUD and its installation is required in order to make our code functional Execute the following command using either VSC terminal or Windows Power Shell

composer require symfony/orm-pack

Configure .env file

.env files contains the link to the connection of your database, make sure to uncomment the database version that you are using and change to your own values

Create the database

Execute the following command to create a database

php bin/console doctrine:database:create

Execute the migration

Execute the following command to create the table and its fields

php bin/console doctrine:migrations:migrate

After this step you can add as many nurses as you like.

Download Postman

Our project has not front-end, so we need a software which sends requests, in our case, we used Postman. You have two ways to download Postman
1: As a software, for this installation check Postman oficial site
2: As a VSC extension search "Postman.postman-for-vscode" at VSC extensions and it will show you After the installation you are asked to create an account

Usage


Running the Application

Run the Symfony development server to access the application:

    symfony server:start

The application should now be accessible at `http://localhost:8000`.

API Functionalities and Examples

The application includes key functionalities accessible through API endpoints. Here are examples of the main functionalities:

Retrieve All Nurses

Endpoint: /api/nurses
Method: GET
Description: Returns a list of all nurses in JSON format.

Example Request:

curl -X GET http://localhost:8000/api/nurses

Nurse Login

Endpoint: /api/nurses/login
Method: POST
Description: Allows a nurse to log in with email and password.

Example Request:

curl -X POST http://localhost:8000/api/nurses/login -d "email=nurse@example.com&password=yourpassword"

Find Nurse by Name

Endpoint: /api/nurses/find/{name}
Method: GET
Description: Searches for a nurse by name and returns their details.

Example Request:

curl -X GET http://localhost:8000/api/nurses/find/JaneDoe

Create a New Nurse

Endpoint: /api/nurses/new
Method: POST
Description: Creates a new nurse with the provided details.

Example Request:

curl -X POST http://localhost:8000/api/nurses/new -d "name=Jane Doe&email=jane.doe@example.com&password=123456"

Update Nurse Information

Endpoint: /api/nurses/{id}/edit
Method: PUT
Description: Updates the information of a specific nurse by ID.

Example Request:

curl -X PUT http://localhost:8000/api/nurses/1/edit -d "email=newemail@example.com"

Delete a Nurse

Endpoint: /api/nurses/{id}/delete
Method: DELETE
Description: Deletes a nurse record by ID.

Example Request:

curl -X DELETE http://localhost:8000/api/nurses/1/delete

Notes

  • Ensure the Symfony server is running before making API requests.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages