upd
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
import { DoctorSchedule, Room, Paging } from "entity";
|
import { DoctorSchedule, Room, User, Paging } from "entity";
|
||||||
import { NextFunction, Response } from "express";
|
import { NextFunction, Response } from "express";
|
||||||
import { Request } from "express-jwt";
|
import { Request } from "express-jwt";
|
||||||
import Joi from "joi";
|
import Joi from "joi";
|
||||||
@ -94,11 +94,14 @@ export class DoctorScheduleController {
|
|||||||
let room = await OrmHelper.DB.getRepository(Room).findOne({ where: { id: param.room_id } });
|
let room = await OrmHelper.DB.getRepository(Room).findOne({ where: { id: param.room_id } });
|
||||||
if (!room) throw { message: "Room " + Language.lang.failed_not_found };
|
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();
|
let doctorSchedule = new DoctorSchedule();
|
||||||
doctorSchedule.day = param.day;
|
doctorSchedule.day = param.day;
|
||||||
doctorSchedule.start_time = param.start_time;
|
doctorSchedule.start_time = param.start_time;
|
||||||
doctorSchedule.end_time = param.end_time;
|
doctorSchedule.end_time = param.end_time;
|
||||||
doctorSchedule.doctor_id = param.doctor_id;
|
doctorSchedule.doctor = doctor;
|
||||||
doctorSchedule.room = room;
|
doctorSchedule.room = room;
|
||||||
doctorSchedule.quota = param.quota || null;
|
doctorSchedule.quota = param.quota || null;
|
||||||
doctorSchedule.status = param.status;
|
doctorSchedule.status = param.status;
|
||||||
@ -173,6 +176,9 @@ export class DoctorScheduleController {
|
|||||||
let room = await OrmHelper.DB.getRepository(Room).findOne({ where: { id: param.room_id } });
|
let room = await OrmHelper.DB.getRepository(Room).findOne({ where: { id: param.room_id } });
|
||||||
if (!room) throw { message: "Room " + Language.lang.failed_not_found };
|
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());
|
let doctorSchedule = await DoctorScheduleModel.list({ id: param.id }).then((q) => q.getOne());
|
||||||
|
|
||||||
if (!doctorSchedule) throw { message: "Doctor Schedule " + Language.lang.failed_not_found };
|
if (!doctorSchedule) throw { message: "Doctor Schedule " + Language.lang.failed_not_found };
|
||||||
@ -180,7 +186,7 @@ export class DoctorScheduleController {
|
|||||||
doctorSchedule.day = param.day;
|
doctorSchedule.day = param.day;
|
||||||
doctorSchedule.start_time = param.start_time;
|
doctorSchedule.start_time = param.start_time;
|
||||||
doctorSchedule.end_time = param.end_time;
|
doctorSchedule.end_time = param.end_time;
|
||||||
doctorSchedule.doctor_id = param.doctor_id;
|
doctorSchedule.doctor = doctor;
|
||||||
doctorSchedule.room = room;
|
doctorSchedule.room = room;
|
||||||
doctorSchedule.quota = param.quota || null;
|
doctorSchedule.quota = param.quota || null;
|
||||||
doctorSchedule.status = param.status;
|
doctorSchedule.status = param.status;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import config from 'config';
|
import config from 'config';
|
||||||
import { DataSource } from "typeorm";
|
import { DataSource } from "typeorm";
|
||||||
import { ILogObj, Logger } from 'tslog';
|
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 {
|
export class OrmHelper {
|
||||||
static DB: DataSource = null
|
static DB: DataSource = null
|
||||||
@ -20,7 +20,7 @@ export class OrmHelper {
|
|||||||
database: String(config.get("database.database")),
|
database: String(config.get("database.database")),
|
||||||
synchronize: true,
|
synchronize: true,
|
||||||
logging: config.get('database.logging'),
|
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: [],
|
subscribers: [],
|
||||||
migrations: [],
|
migrations: [],
|
||||||
})
|
})
|
||||||
|
|||||||
@ -13,7 +13,9 @@ export class DoctorScheduleModel {
|
|||||||
whereVal = { ...whereVal, ...CommonHelper.handleQueryFilter(filter).whereVal };
|
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) {
|
if (whereAttr.length != 0) {
|
||||||
query = query.where(whereAttr.join(" and "), whereVal);
|
query = query.where(whereAttr.join(" and "), whereVal);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user