fix(schedule): calendar
This commit is contained in:
@ -96,7 +96,7 @@ export class ScheduleController {
|
||||
/*
|
||||
#swagger.tags = ['Schedule']
|
||||
#swagger.security = [{ "bearerAuth": [] }]
|
||||
#swagger.parameters['filter'] = { in: 'query', required: false, type: 'string' }
|
||||
#swagger.parameters['filter'] = { in: 'query', required: false, type: 'string', description: 'Filter by room id (optional)' }
|
||||
#swagger.responses[200] = {
|
||||
description: 'Schedule options',
|
||||
schema: {
|
||||
|
||||
@ -4,6 +4,7 @@ import CommonHelper from "../helpers/common";
|
||||
import { OrmHelper } from "../helpers/orm";
|
||||
import dayjs from "dayjs";
|
||||
import { RoomModel } from "./room";
|
||||
import { filter } from "compression";
|
||||
|
||||
type RecurrenceInput = {
|
||||
type: "daily" | "weekly" | "monthly";
|
||||
@ -59,7 +60,7 @@ export class ScheduleModel {
|
||||
return query;
|
||||
}
|
||||
|
||||
static async getScheduleCalendarRange(start: string, end: string, filterObj = {}, options: CalendarQueryOptions = {}): Promise<any> {
|
||||
static async getScheduleCalendarRange(start: string, end: string, filterObj: any, options: CalendarQueryOptions = {}): Promise<any> {
|
||||
const startDate = dayjs(start);
|
||||
const endDate = dayjs(end);
|
||||
if (!startDate.isValid() || !endDate.isValid()) {
|
||||
@ -72,6 +73,8 @@ export class ScheduleModel {
|
||||
throw new Error("Start date must be before end date");
|
||||
}
|
||||
|
||||
const filterRoomId = filterObj && filterObj.roomId !== "" && filterObj.roomId !== null && filterObj.roomId !== undefined ? String(filterObj.roomId) : "";
|
||||
|
||||
const page = options.page ?? 1;
|
||||
const limit = options.limit ?? 10;
|
||||
const offset = (page - 1) * limit;
|
||||
@ -81,6 +84,10 @@ export class ScheduleModel {
|
||||
.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 });
|
||||
}
|
||||
|
||||
const roomTotalCount = await roomQuery
|
||||
.getCount();
|
||||
const rooms = await roomQuery
|
||||
|
||||
Reference in New Issue
Block a user