Skip to content

Commit

Permalink
fixed error on assign case
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronald-pro committed Jan 26, 2024
1 parent 09514ef commit 21b24e7
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions routes/processes/case.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,7 @@ router.post("/assign", async (req, res) => {

let check_client = await Client.findOne({
where: {
clinic_number
}
});
let get_facility = await masterFacility.findOne({
where: {
code: check_client.mfl_code
},
attributes: ["code", "name"]
});
let check_user = await User.findOne({
where: {
phone_no
clinic_number: clinic_number
}
});

Expand All @@ -43,6 +32,17 @@ router.post("/assign", async (req, res) => {
success: false,
message: `Clinic number ${clinic_number} does not exist in the system`
});
let check_user = await User.findOne({
where: {
phone_no
}
});
let get_facility = await masterFacility.findOne({
where: {
code: check_client.mfl_code
},
attributes: ["code", "name"]
});
if (check_client.mfl_code != check_user.facility_id)
return res.json({
success: false,
Expand Down Expand Up @@ -205,7 +205,7 @@ router.get("/search", async (req, res) => {

let client = await Client.findOne({
where: {
clinic_number:clinicNumber
clinic_number: clinicNumber
}
});

Expand Down Expand Up @@ -314,18 +314,16 @@ router.post("/home/visit", async (req, res) => {
let existingVisit = await caseHome.findOne({
where: {
client_id: check_client.id,
[Op.and]: [
Sequelize.literal(`DATE(created_at) = '${today}'`)
]
[Op.and]: [Sequelize.literal(`DATE(created_at) = '${today}'`)]
}
});

if (existingVisit) {
return res.status(400).json({
success: false,
message: `Home Visit details for Client: ${clinic_number} have already been captured today`
});
}else {
return res.status(400).json({
success: false,
message: `Home Visit details for Client: ${clinic_number} have already been captured today`
});
} else {
try {
await caseHome.create({
client_id: check_client.id,
Expand Down

0 comments on commit 21b24e7

Please sign in to comment.