This commit is contained in:
Narul Hidayah
2026-02-11 14:51:06 +07:00
parent bc4cb35f54
commit fdbab38b37
3 changed files with 14 additions and 6 deletions

View File

@ -1,4 +1,4 @@
import { DoctorSchedule, Room, Paging } from "entity";
import { DoctorSchedule, Room, User, Paging } from "entity";
import { NextFunction, Response } from "express";
import { Request } from "express-jwt";
import Joi from "joi";
@ -94,11 +94,14 @@ export class DoctorScheduleController {
let room = await OrmHelper.DB.getRepository(Room).findOne({ where: { id: param.room_id } });
if (!room) throw { message: "Room " + Language.lang.failed_not_found };
let doctor = await OrmHelper.DB.getRepository(User).findOne({ where: { id: param.doctor_id } });
if (!doctor) throw { message: "Doctor (User) " + Language.lang.failed_not_found };
let doctorSchedule = new DoctorSchedule();
doctorSchedule.day = param.day;
doctorSchedule.start_time = param.start_time;
doctorSchedule.end_time = param.end_time;
doctorSchedule.doctor_id = param.doctor_id;
doctorSchedule.doctor = doctor;
doctorSchedule.room = room;
doctorSchedule.quota = param.quota || null;
doctorSchedule.status = param.status;
@ -173,6 +176,9 @@ export class DoctorScheduleController {
let room = await OrmHelper.DB.getRepository(Room).findOne({ where: { id: param.room_id } });
if (!room) throw { message: "Room " + Language.lang.failed_not_found };
let doctor = await OrmHelper.DB.getRepository(User).findOne({ where: { id: param.doctor_id } });
if (!doctor) throw { message: "Doctor (User) " + Language.lang.failed_not_found };
let doctorSchedule = await DoctorScheduleModel.list({ id: param.id }).then((q) => q.getOne());
if (!doctorSchedule) throw { message: "Doctor Schedule " + Language.lang.failed_not_found };
@ -180,7 +186,7 @@ export class DoctorScheduleController {
doctorSchedule.day = param.day;
doctorSchedule.start_time = param.start_time;
doctorSchedule.end_time = param.end_time;
doctorSchedule.doctor_id = param.doctor_id;
doctorSchedule.doctor = doctor;
doctorSchedule.room = room;
doctorSchedule.quota = param.quota || null;
doctorSchedule.status = param.status;

View File

@ -1,7 +1,7 @@
import config from 'config';
import { DataSource } from "typeorm";
import { ILogObj, Logger } from 'tslog';
import { Administrativu, Aldeia, District, Menu, Munisipo, Suco, Application, Nationality, Diagnosis, DiagnosticProcedure, Room, ServiceType, ServiceClass, Service, ServiceFare, ServicePackage, Department, DoctorSchedule } from 'entity'
import { Administrativu, Aldeia, District, Menu, Munisipo, Suco, Application, Nationality, Diagnosis, DiagnosticProcedure, Room, ServiceType, ServiceClass, Service, ServiceFare, ServicePackage, Department, DoctorSchedule, User, UserRole, HrmsEmployee } from 'entity'
export class OrmHelper {
static DB: DataSource = null
@ -20,7 +20,7 @@ export class OrmHelper {
database: String(config.get("database.database")),
synchronize: true,
logging: config.get('database.logging'),
entities: [Menu, Administrativu, Aldeia, District, Munisipo, Suco, Application, Nationality, Diagnosis, DiagnosticProcedure, Room, ServiceType, ServiceClass, Service, ServiceFare, ServicePackage, Department, DoctorSchedule],
entities: [Menu, Administrativu, Aldeia, District, Munisipo, Suco, Application, Nationality, Diagnosis, DiagnosticProcedure, Room, ServiceType, ServiceClass, Service, ServiceFare, ServicePackage, Department, DoctorSchedule, User, UserRole, HrmsEmployee],
subscribers: [],
migrations: [],
})

View File

@ -13,7 +13,9 @@ export class DoctorScheduleModel {
whereVal = { ...whereVal, ...CommonHelper.handleQueryFilter(filter).whereVal };
}
var query = repo.createQueryBuilder("DoctorSchedule").leftJoinAndSelect("DoctorSchedule.room", "Room");
var query = repo.createQueryBuilder("DoctorSchedule")
.leftJoinAndSelect("DoctorSchedule.doctor", "doctor")
.leftJoinAndSelect("DoctorSchedule.room", "Room");
if (whereAttr.length != 0) {
query = query.where(whereAttr.join(" and "), whereVal);
}