fix(schedule): calendar add doctor filter
This commit is contained in:
@ -74,6 +74,7 @@ export class ScheduleModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const filterRoomId = filterObj && filterObj.roomId !== "" && filterObj.roomId !== null && filterObj.roomId !== undefined ? String(filterObj.roomId) : "";
|
const filterRoomId = filterObj && filterObj.roomId !== "" && filterObj.roomId !== null && filterObj.roomId !== undefined ? String(filterObj.roomId) : "";
|
||||||
|
const filterDoctorId = filterObj && filterObj.doctorId !== "" && filterObj.doctorId !== null && filterObj.doctorId !== undefined ? String(filterObj.doctorId) : "";
|
||||||
|
|
||||||
const page = options.page ?? 1;
|
const page = options.page ?? 1;
|
||||||
const limit = options.limit ?? 10;
|
const limit = options.limit ?? 10;
|
||||||
@ -83,10 +84,8 @@ export class ScheduleModel {
|
|||||||
const roomQuery = query
|
const roomQuery = query
|
||||||
.select(["Room.id", "Room.room", "Room.code", "Room.picture", "Room.location", "Room.status", "Department.name"])
|
.select(["Room.id", "Room.room", "Room.code", "Room.picture", "Room.location", "Room.status", "Department.name"])
|
||||||
.leftJoin("Room.department", "Department")
|
.leftJoin("Room.department", "Department")
|
||||||
.where("Department.name = :departmentName", { departmentName: "Outpatient" });
|
.where("Department.name = :departmentName", { departmentName: "Outpatient" })
|
||||||
if (filterRoomId !== "") {
|
.andWhere(filterRoomId !== "" ? "Room.id = :roomId" : "1=1", { roomId: filterRoomId });
|
||||||
roomQuery.andWhere("Room.id = :roomId", { roomId: filterRoomId });
|
|
||||||
}
|
|
||||||
|
|
||||||
const roomTotalCount = await roomQuery
|
const roomTotalCount = await roomQuery
|
||||||
.getCount();
|
.getCount();
|
||||||
@ -103,6 +102,7 @@ export class ScheduleModel {
|
|||||||
.andWhere("ScheduleSeries.start_date <= :rangeEndDate", { rangeEndDate: dayjs(rangeEnd).format("YYYY-MM-DD") })
|
.andWhere("ScheduleSeries.start_date <= :rangeEndDate", { rangeEndDate: dayjs(rangeEnd).format("YYYY-MM-DD") })
|
||||||
.andWhere("(ScheduleSeries.until_date IS NULL OR ScheduleSeries.until_date >= :rangeStartDate)", { rangeStartDate: dayjs(rangeStart).format("YYYY-MM-DD") })
|
.andWhere("(ScheduleSeries.until_date IS NULL OR ScheduleSeries.until_date >= :rangeStartDate)", { rangeStartDate: dayjs(rangeStart).format("YYYY-MM-DD") })
|
||||||
.andWhere("ScheduleSeries.deleted_at IS NULL")
|
.andWhere("ScheduleSeries.deleted_at IS NULL")
|
||||||
|
.andWhere(filterDoctorId !== "" ? "ScheduleSeries.doctor_id = :doctorId" : "1=1", { doctorId: filterDoctorId })
|
||||||
.orderBy("ScheduleSeries.start_time", "ASC")
|
.orderBy("ScheduleSeries.start_time", "ASC")
|
||||||
.getMany();
|
.getMany();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user