This commit is contained in:
wayanrivan
2026-04-21 13:38:29 +07:00
2 changed files with 6 additions and 5 deletions

View File

@ -75,6 +75,7 @@ export class InpatientRoomController {
const res_count = query;
const res_list = query
.leftJoinAndSelect("InpatientRoom.room", "room")
.leftJoinAndSelect("room.serviceclass", "service_class")
.orderBy("InpatientRoom." + param.order_field, param.order_direction)
.offset(offset)
.limit(limit);
@ -166,7 +167,7 @@ export class InpatientRoomController {
let param: any = await schema.validateAsync(req.params);
let data = await InpatientRoomModel.list({ id: param.id }).then((q) =>
let data = await InpatientRoomModel.list({ "InpatientRoom.id": param.id }).then((q) =>
q //
.leftJoinAndSelect("InpatientRoom.room", "room")
.getOne(),

View File

@ -74,6 +74,7 @@ export class ScheduleModel {
}
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 limit = options.limit ?? 10;
@ -83,10 +84,8 @@ export class ScheduleModel {
const roomQuery = query
.select(["Room.id", "Room.room", "Room.code", "Room.picture", "Room.location", "Room.status", "Department.name"])
.leftJoin("Room.department", "Department")
.where("Department.name = :departmentName", { departmentName: "Outpatient" });
if (filterRoomId !== "") {
roomQuery.andWhere("Room.id = :roomId", { roomId: filterRoomId });
}
.where("Department.name = :departmentName", { departmentName: "Outpatient" })
.andWhere(filterRoomId !== "" ? "Room.id = :roomId" : "1=1", { roomId: filterRoomId });
const roomTotalCount = await roomQuery
.getCount();
@ -103,6 +102,7 @@ export class ScheduleModel {
.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.deleted_at IS NULL")
.andWhere(filterDoctorId !== "" ? "ScheduleSeries.doctor_id = :doctorId" : "1=1", { doctorId: filterDoctorId })
.orderBy("ScheduleSeries.start_time", "ASC")
.getMany();