Skip to content

Commit

Permalink
Merge pull request #46 from ShubhaMahobia/shubham_dev
Browse files Browse the repository at this point in the history
Shubham dev
  • Loading branch information
ShubhaMahobia authored May 8, 2024
2 parents b98fcfb + 45c4f6f commit 178b7bd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
8 changes: 3 additions & 5 deletions controller/authenticationController.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,15 @@ exports.test = (req, res) => {
};

//This is the API to check if the user is already registered or not in our system.
exports.isNewUser = async (req, res) => {
exports.isPatientExist = async (req, res) => {
try {
const isUserExist = await userPatient.findOne({
firebaseUserId: req.body.firebaseUserId,
});
if (isUserExist) {
return res
.status(400)
.json({ success: false, message: "User is Present in Database" });
return res.status(400).json({ success: true, isPresent: true });
} else {
return res.status(200).json({ success: true, message: "User is new" });
return res.status(200).json({ success: true, isPresent: false });
}
} catch (error) {
return res
Expand Down
18 changes: 18 additions & 0 deletions controller/doctorController.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@ exports.fetchAllDoctors = async (req, res) => {
}
};

exports.isDoctorExisit = async (req, res) => {
try {
const isUserExist = await userDoctor.findOne({
firebaseUserId: req.body.firebaseUserId,
});
if (isUserExist) {
return res.status(400).json({ success: true, isPresent: true });
} else {
return res.status(200).json({ success: true, isPresent: false });
}
} catch (error) {
return res
.status(400)
.json({ success: false, message: "Internal Server Error" });
}
};


// Function to fetch a doctor by ID (firebaseId)
exports.fetchDoctorById = async (req, res) => {
try {
Expand Down
5 changes: 4 additions & 1 deletion routes/authenticationRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ const {
loginUser,
fetchUserDetails,
fetchDoctorDetails,
isPatientExist,
} = require("../controller/authenticationController");

const {
fetchAllDoctors,
fetchDoctorById,
updateDoctorProfile,
isDoctorExisit,
} = require("../controller/doctorController");

const { updatePatientProfile } = require("../controller/patientController");
Expand Down Expand Up @@ -43,7 +45,8 @@ const router = express.Router();

router.get("/", test);
router.post("/registerPatient", signUpPatient);
router.post("/checkNewUser", isNewUser);
router.post("/isPatientExist", isPatientExist);
router.post("/isDoctorExist", isDoctorExisit);
router.post("/registerDoctor", signUpDoctor);
router.post("/getUser", fetchUserDetails);
router.post("/getDoctor", fetchDoctorDetails);
Expand Down

0 comments on commit 178b7bd

Please sign in to comment.