From 2d0438535a048de09ab2aa83e075c3dd7c82ff60 Mon Sep 17 00:00:00 2001 From: avicenan Date: Mon, 20 Apr 2026 11:59:58 +0700 Subject: [PATCH 1/3] fix(schedule): calendar add doctor filter --- src/model/schedule.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/model/schedule.ts b/src/model/schedule.ts index d028bcd..323c429 100644 --- a/src/model/schedule.ts +++ b/src/model/schedule.ts @@ -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(); From 1e5895ded0ffb658e7b0f7f9f2d84e6a585446e2 Mon Sep 17 00:00:00 2001 From: "fazri.is" Date: Tue, 21 Apr 2026 11:21:39 +0700 Subject: [PATCH 2/3] update --- src/controllers/inpatient_room.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/inpatient_room.ts b/src/controllers/inpatient_room.ts index 9ba4d20..e7b445f 100644 --- a/src/controllers/inpatient_room.ts +++ b/src/controllers/inpatient_room.ts @@ -166,7 +166,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(), From 030b819417d45fd7e42c3a14bdf35acd27a3bf1d Mon Sep 17 00:00:00 2001 From: "fazri.is" Date: Tue, 21 Apr 2026 11:39:13 +0700 Subject: [PATCH 3/3] update --- src/controllers/inpatient_room.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/controllers/inpatient_room.ts b/src/controllers/inpatient_room.ts index e7b445f..461c5c6 100644 --- a/src/controllers/inpatient_room.ts +++ b/src/controllers/inpatient_room.ts @@ -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);