Skip to content

Commit

Permalink
Added More Template
Browse files Browse the repository at this point in the history
  • Loading branch information
sayeedajmal committed Feb 9, 2024
1 parent 936705d commit 8462543
Show file tree
Hide file tree
Showing 17 changed files with 302 additions and 76 deletions.
Binary file removed BloodDonation-1.0.0.jar
Binary file not shown.
3 changes: 1 addition & 2 deletions Web/Appointment.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
</head>

<body>
<h1 style="text-align: center;">Appointment Creation</h1>
<form action="http://localhost:8080/api/v1/appointment/createAppointment?donorId=2" method="post" style="
font-size: 2.5rem;
text-align: center;
align-items: center;
align-content: center;
">

<!-- Other fields for the Appointment object -->
<input type="date" placeholder="appointmentDate" name="appointmentDate" /><br />
<input type="time" placeholder="appointmentTime" name="appointmentTime" /><br />

Expand Down
1 change: 1 addition & 0 deletions Web/Staff.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
</head>

<body>
<h1 style="text-align: center;">Staff SignUp</h1>
<form action="https://localhost:443/api/v1/Staff/createStaff" method="post"
style="font-size: 2.5rem; text-align: center; align-items: center; align-content: center;">
<input type="text" placeholder="staffName" name="staffName"><br>
Expand Down
6 changes: 4 additions & 2 deletions Web/donation.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
</head>

<body>
<h1 style="text-align: center;">Donor Status</h1>
<form id="donationForm" style="
font-size: 2.5rem;
text-align: center;
Expand All @@ -17,8 +18,9 @@
">
<label for="donationStatus">Donation Status:</label>
<select id="donationStatus" name="donationStatus" required><br>
<option value="PENDING">Pending</option>
<option value="COMPLETED">Completed</option>
<option value="COMPLETED">COMPLETED</option>
<option value="CANCELED">CANCELED</option>
<option value="PENDING">PENDING</option>
</select><br>


Expand Down
1 change: 1 addition & 0 deletions Web/donor.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
</head>

<body>
<h1 style="text-align: center;">Donor SignUp</h1>
<form style="font-size: 2.5rem; text-align: center; align-items: center; align-content: center;">
<input type="text" placeholder="firstName" id="firstName"><br>
<input type="text" placeholder="lastName" id="lastName"><br>
Expand Down
1 change: 1 addition & 0 deletions Web/medicalHistory.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
</head>

<body>
<h1 style="text-align: center;">History Creattion</h1>
<form action="http://localhost:8080/api/v1/medicalHistory/createHistory?donorId=102" method="post" style="
font-size: 2.5rem;
text-align: center;
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>com.strong</groupId>
<artifactId>blooddonation</artifactId>
<version>1.0</version>
<version>2.0</version>
<name>Blood Donation</name>
<description>Blood Donation Restful API</description>
<properties>
Expand Down
40 changes: 32 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
# Setup MySql
# Blood Donation RestFul API With Email Notification Integration

- Developed A Robust Restful API For Blood Donation Management.
- Having Main & Security Branches
- Implemented Email Notification Interation
- Implemented A Comprehensive System For Tracking Donor Information, Appointments, And Medical History.
- Utilized Java And Relevant Frameworks To Build The API, Ensuring Scalability And Performance.
- Designed Entities/Models For Donor, BloodBank, Staff, Appointment, MedicalHistory, And Donation.
- Incorporated Features Such As Donor Registration, Appointment Scheduling, And Medical History Recording.
- Established Relationships Between Entities To Maintain Data Integrity And Consistency.
- Implemented Security Measures To Protect Sensitive Information And Ensure Data Privacy.
- Created Endpoints For CRUD Operations On Various Entities, Providing A User-Friendly Interface For Interactions.
- Ensured Proper Error Handling And Response Messages For A Smooth User Experience.
- Optimized Database Interactions For Efficient Data Retrieval And Storage.
- Conducted Thorough Testing To Validate Functionality, Security, And Overall System Stability.
- Documented The API For Easy Integration And Future Maintenance.
- Addressed Challenges With Innovative Problem-Solving And Continuous Improvement.
- Excited To Contribute To The Healthcare Ecosystem With The Blood Donation API? Download This Project And Start Running Setup .

- db name : BloodBank
- username : BloodBank
- password : BlookBank
### Swagger API URL `http://localhost:8080/swagger-ui.html`

sudo mysql -u root
create database BloodBank;
CREATE USER 'BloodBank'@'localhost' IDENTIFIED BY 'BloodBank';
## POSITION OF STAFF

### Swagger API URL `http://localhost:8080/swagger-ui.html`
- Appoint: Manages donor appointments, schedules, and confirms donation appointments.

- Donor: Responsible for collecting and maintaining donor medical histories, including any relevant conditions, medications, and allergies.

- Phlebotomist/Nurse: Draws blood from donors safely and efficiently during donation events.

- Manager: Oversees the overall operations of the blood donation camp or organization, ensuring smooth coordination among staff, volunteers, and donors, and handling any issues that may arise.

# Documentation Of End Points

Expand Down Expand Up @@ -122,6 +141,11 @@
- @Return HttpStatus

- **PATCH** `updateStaff`

- @Require Staff
- @Return HttpStatus

- **PATCH** `updateStaffPosition`
- @Require Staff
- @Return HttpStatus

Expand Down
5 changes: 3 additions & 2 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@ CREATE TABLE IF NOT EXISTS staff (
position VARCHAR(255),
contact_number VARCHAR(255) NOT NULL,
email VARCHAR(255) UNIQUE NOT NULL,
address VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
enabled BOOLEAN NOT NULL,
created_at DATETIME NOT NULL,
updated_at DATETIME
);
-- Insert an initial admin into the staff table
INSERT INTO staff (staff_id, staff_name, position, contact_number, email, password, enabled, created_at, updated_at)
VALUES (3,'test','Manager','0000000000','test@gmail.com','$2a$12$zn5nIdsS5llI26.vwXSJne27fqC9AkJhgrBPtkkT5Q3gFXfYiJMlu', true, NOW(), null);
INSERT INTO staff (staff_id, staff_name, position, contact_number, email, address, password, enabled, created_at, updated_at)
VALUES (3,'test','Manager','0000000000','test@gmail.com','AdminAddress','$2a$12$zn5nIdsS5llI26.vwXSJne27fqC9AkJhgrBPtkkT5Q3gFXfYiJMlu', true, NOW(), null);
END_SQL

# Restart MySQL service to apply changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,7 @@ public ResponseEntity<String> createAppointment(@ModelAttribute Appointment appo
appointment.setStatus(AppointmentStatus.SCHEDULED);
appointment.setDonor(donor);
appointService.saveAppointment(appointment);
mailService.sendAppointmentNotification(
appointment.getDonor().getFirstName() + " " + appointment.getDonor().getLastName(),
appointment.getDonor().getEmail(), appointment.getAppointmentDate(),
appointment.getAppointmentTime());
mailService.sendAppointmentNotification(appointment);
return new ResponseEntity<>("Created Successfully", HttpStatus.CREATED);
} else {
throw new BloodException("Can't Find Donor with ID: " + donorId);
Expand Down Expand Up @@ -128,8 +125,8 @@ public ResponseEntity<String> updateAppointment(@RequestBody Appointment updated
existAppoint.setAppointmentDate(updatedAppointment.getAppointmentDate());
existAppoint.setAppointmentTime(updatedAppointment.getAppointmentTime());
existAppoint.setStatus(updatedAppointment.getStatus());

appointService.updateAppointment(existAppoint);
mailService.sendUpdateAppointNotification(updatedAppointment);
return new ResponseEntity<>("Updated Successfully", HttpStatus.ACCEPTED);
}
return new ResponseEntity<>("Appointment not found", HttpStatus.NOT_FOUND);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ public ResponseEntity<String> createDonation(@ModelAttribute Donation donation,
donation.setDonor(byId);
donation.setDonationDate(LocalDate.now());
donationService.saveDonation(donation);
mailService.sendDonationConfirmation(donation.getDonor().getEmail(),
donation.getDonor().getFirstName() + " " + donation.getDonor().getLastName(),
donation.getQuantity(),
byId.getBloodType());
mailService.sendDonationConfirmation(donation);
return new ResponseEntity<>("Created Successfully", HttpStatus.CREATED);
}

Expand Down Expand Up @@ -115,10 +112,13 @@ public ResponseEntity<String> updateDonation(@RequestBody Donation updatedDonati
@RequestParam("donationId") Integer donationId) throws BloodException {
Donation existDonation = donationService.findById(donationId);
if (existDonation != null) {

existDonation.setDonationDate(updatedDonation.getDonationDate());
existDonation.setDonationStatus(updatedDonation.getDonationStatus());
existDonation.setQuantity(updatedDonation.getQuantity());
donationService.updateDonation(existDonation);

mailService.sendDonationUpdateNotification(existDonation);
return new ResponseEntity<>("Updated Successfully", HttpStatus.ACCEPTED);
}
return new ResponseEntity<>("Donation not found", HttpStatus.NOT_FOUND);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ public class DonorController {
@PostMapping("createDonor")
public ResponseEntity<String> createDonor(@RequestBody Donor donor) throws BloodException {
donorService.saveDonor(donor);
mailService.sendDonorSignUpEmail(donor.getEmail(), donor.getFirstName() + " " + donor.getLastName(),
donor.getDonorId());
mailService.sendDonorSignUpEmail(donor);
return new ResponseEntity<String>("Created Successfully", HttpStatus.CREATED);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.strong.BloodDonation.Email.MailService;
import com.strong.BloodDonation.Model.Donor;
import com.strong.BloodDonation.Model.MedicalHistory;
import com.strong.BloodDonation.Service.DonorService;
Expand All @@ -41,6 +42,9 @@ public class MedicalHistController {
@Autowired
private DonorService donorService;

@Autowired
private MailService mailService;

/**
* POST endpoint to create a new medical history.
*
Expand All @@ -56,6 +60,8 @@ public ResponseEntity<String> createHistory(@ModelAttribute MedicalHistory medic
if (donor != null) {
medicalHistory.setDonor(donor);
medicalHistoryService.saveHistory(medicalHistory);

mailService.sendMedicalHistoryNotification(medicalHistory);
return new ResponseEntity<>("Created Successfully", HttpStatus.CREATED);
} else {
throw new BloodException("Can't Find Donor with ID: " + donorId);
Expand Down Expand Up @@ -131,6 +137,8 @@ public ResponseEntity<?> updateHistory(@RequestBody MedicalHistory history) thro
existingHistory.setMedications(history.getMedications());

medicalHistoryService.updateHistory(existingHistory);

mailService.sendMedicalHistoryUpdatedNotification(existingHistory);
return new ResponseEntity<>("Updated Successfully", HttpStatus.ACCEPTED);
}
return new ResponseEntity<>("Medical history not found", HttpStatus.NOT_FOUND);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.strong.BloodDonation.Controller;

import com.strong.BloodDonation.Email.MailService;
import com.strong.BloodDonation.Model.Staff;
import com.strong.BloodDonation.Service.StaffService;
import com.strong.BloodDonation.Utils.BloodException;
Expand All @@ -24,6 +25,9 @@ public class StaffController {
@Autowired
private StaffService staffService;

@Autowired
private MailService mailService;

/**
* POST endpoint to create a new staff member.
*
Expand All @@ -33,6 +37,7 @@ public class StaffController {
@PostMapping("createStaff")
public ResponseEntity<?> createStaff(@RequestBody Staff staff) throws BloodException {
staffService.createStaff(staff);
mailService.sendStaffWelcomeEmail(staff);
return new ResponseEntity<>("Created Successfully", HttpStatus.CREATED);
}

Expand Down Expand Up @@ -81,7 +86,32 @@ public ResponseEntity<String> deleteStaff(@PathVariable Integer staffId) throws
@Transactional
@PatchMapping("updateStaff")
public ResponseEntity<String> updateStaff(@RequestBody Staff updatedStaff) throws BloodException {
Staff staff = staffService.findById(updatedStaff.getStaffId());
staff.setStaffName(updatedStaff.getStaffName());
staff.setEmail(updatedStaff.getEmail());
staff.setContactNumber(updatedStaff.getContactNumber());
staff.setAddress(updatedStaff.getAddress());

staffService.updateStaff(updatedStaff);
return new ResponseEntity<>("Updated Successfully", HttpStatus.OK);
}

/**
* PATCH endpoint to update Position of an existing staff member.
*
* @param updatedStaff The updated staff member object.
* @return A response indicating the success or failure of the operation.
*/
@Transactional
@PatchMapping("updateStaffPosition")
public ResponseEntity<String> positionStaff(@RequestBody Staff updatedStaff) throws BloodException {
Staff byId = staffService.findById(updatedStaff.getStaffId());

byId.setPosition(updatedStaff.getPosition());
byId.setEnabled(updatedStaff.isEnabled());

staffService.updateStaff(updatedStaff);
mailService.sendStaffPositionNotification(updatedStaff);
return new ResponseEntity<>("Updated Successfully", HttpStatus.OK);
}
}
Loading

0 comments on commit 8462543

Please sign in to comment.