update
This commit is contained in:
@ -22,7 +22,7 @@
|
|||||||
"database": {
|
"database": {
|
||||||
"engine": "postgres",
|
"engine": "postgres",
|
||||||
"host": "127.0.0.1",
|
"host": "127.0.0.1",
|
||||||
"port": "15432",
|
"port": "1520",
|
||||||
"username": "saude_stag",
|
"username": "saude_stag",
|
||||||
"password": "gM*#o>3W4&5X",
|
"password": "gM*#o>3W4&5X",
|
||||||
"database": "saude_stag",
|
"database": "saude_stag",
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { QueueMonitoring, Paging } from "entity";
|
import { QueueMonitoring, Paging, QueueMonitoringRooms, Status } 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";
|
||||||
@ -86,13 +86,10 @@ export class QueueMonitoringController {
|
|||||||
|
|
||||||
const param: any = await schema.validateAsync(req.params);
|
const param: any = await schema.validateAsync(req.params);
|
||||||
|
|
||||||
const queueMonitoring = await QueueMonitoringModel.list({ "QueueMonitoring.slug": param.slug }).then((q) =>
|
const queueMonitoring = await QueueMonitoringModel.list({ "QueueMonitoring.slug": param.slug }).then((q) => q.leftJoinAndSelect("QueueMonitoring.rooms", "rooms").leftJoinAndSelect("rooms.department", "department").getOne());
|
||||||
q.leftJoinAndSelect("QueueMonitoring.rooms", "rooms").leftJoinAndSelect("rooms.department", "department").getOne()
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!queueMonitoring) throw { message: "Queue Monitoring Not Found" };
|
if (!queueMonitoring) throw { message: "Queue Monitoring Not Found" };
|
||||||
|
|
||||||
|
|
||||||
if (queueMonitoring.rooms && queueMonitoring.rooms.length > 0) {
|
if (queueMonitoring.rooms && queueMonitoring.rooms.length > 0) {
|
||||||
try {
|
try {
|
||||||
const roomIds = queueMonitoring.rooms.map((room: any) => room.id);
|
const roomIds = queueMonitoring.rooms.map((room: any) => room.id);
|
||||||
@ -136,7 +133,7 @@ export class QueueMonitoringController {
|
|||||||
id: queue.id,
|
id: queue.id,
|
||||||
qeue_number: queue.qeue_number,
|
qeue_number: queue.qeue_number,
|
||||||
registration_status: queue.registration_status,
|
registration_status: queue.registration_status,
|
||||||
fullname_patient: queue.fullname_patient
|
fullname_patient: queue.fullname_patient,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -149,11 +146,11 @@ export class QueueMonitoringController {
|
|||||||
|
|
||||||
queueMonitoring.rooms = queueMonitoring.rooms.map((room: any) => ({
|
queueMonitoring.rooms = queueMonitoring.rooms.map((room: any) => ({
|
||||||
...room,
|
...room,
|
||||||
queues: queuesByRoom[room.id] || []
|
queues: queuesByRoom[room.id] || [],
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const latestOnGoing = allQueues
|
const latestOnGoing = allQueues
|
||||||
.filter((q: any) => q.registration_status === 'ON GOING')
|
.filter((q: any) => q.registration_status === "ON GOING")
|
||||||
.reduce((latest: any, current: any) => {
|
.reduce((latest: any, current: any) => {
|
||||||
const latestDate = new Date(latest?.updated_at || latest?.updatedAt || 0);
|
const latestDate = new Date(latest?.updated_at || latest?.updatedAt || 0);
|
||||||
const currentDate = new Date(current?.updated_at || current?.updatedAt || 0);
|
const currentDate = new Date(current?.updated_at || current?.updatedAt || 0);
|
||||||
@ -173,14 +170,14 @@ export class QueueMonitoringController {
|
|||||||
log.warn(`Failed to fetch queue data from emr.emr_registration_outpatient: ${queryError.message}`);
|
log.warn(`Failed to fetch queue data from emr.emr_registration_outpatient: ${queryError.message}`);
|
||||||
queueMonitoring.rooms = queueMonitoring.rooms.map((room: any) => ({
|
queueMonitoring.rooms = queueMonitoring.rooms.map((room: any) => ({
|
||||||
...room,
|
...room,
|
||||||
queues: []
|
queues: [],
|
||||||
}));
|
}));
|
||||||
(queueMonitoring as any).currentQueue = null;
|
(queueMonitoring as any).currentQueue = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const responseData = {
|
const responseData = {
|
||||||
...queueMonitoring
|
...queueMonitoring,
|
||||||
};
|
};
|
||||||
|
|
||||||
return ReturnHelper.successResponseAny(res, 200, Language.lang.success_view, responseData);
|
return ReturnHelper.successResponseAny(res, 200, Language.lang.success_view, responseData);
|
||||||
@ -209,24 +206,29 @@ export class QueueMonitoringController {
|
|||||||
|
|
||||||
let param: any = await schema.validateAsync(req.body);
|
let param: any = await schema.validateAsync(req.body);
|
||||||
|
|
||||||
let rooms: any[] = [];
|
|
||||||
if (param.room_ids && param.room_ids.length > 0) {
|
|
||||||
for (const roomId of param.room_ids) {
|
|
||||||
const room = await RoomModel.list({ id: roomId }).then((q) => q.getOne());
|
|
||||||
if (!room) throw { message: `Room with id ${roomId} not found` };
|
|
||||||
rooms.push(room);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let queueMonitoring = new QueueMonitoring();
|
let queueMonitoring = new QueueMonitoring();
|
||||||
queueMonitoring.slug = param.slug;
|
queueMonitoring.slug = param.slug;
|
||||||
queueMonitoring.name = param.name;
|
queueMonitoring.name = param.name;
|
||||||
queueMonitoring.rooms = rooms;
|
|
||||||
queueMonitoring.status = param.status;
|
queueMonitoring.status = param.status;
|
||||||
queueMonitoring.created_by = req.auth.data.name;
|
queueMonitoring.created_by = req.auth.data.name;
|
||||||
queueMonitoring.updated_by = req.auth.data.name;
|
queueMonitoring.updated_by = req.auth.data.name;
|
||||||
await queryRunner.manager.save(queueMonitoring);
|
await queryRunner.manager.save(queueMonitoring);
|
||||||
|
|
||||||
|
if (param.room_ids && param.room_ids.length > 0) {
|
||||||
|
for (const roomId of param.room_ids) {
|
||||||
|
const room = await RoomModel.list({ id: roomId }).then((q) => q.getOne());
|
||||||
|
if (!room) throw { message: `Room with id ${roomId} not found` };
|
||||||
|
|
||||||
|
let queueMonitoringRooms = new QueueMonitoringRooms();
|
||||||
|
queueMonitoringRooms.queue_monitoring = queueMonitoring;
|
||||||
|
queueMonitoringRooms.room = room;
|
||||||
|
queueMonitoringRooms.status = param.status;
|
||||||
|
queueMonitoringRooms.created_by = req.auth.data.name;
|
||||||
|
queueMonitoringRooms.updated_by = req.auth.data.name;
|
||||||
|
await queryRunner.manager.save(queueMonitoringRooms);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await queryRunner.commitTransaction();
|
await queryRunner.commitTransaction();
|
||||||
|
|
||||||
return ReturnHelper.successResponseAny(res, 200, Language.lang.success_insert, queueMonitoring);
|
return ReturnHelper.successResponseAny(res, 200, Language.lang.success_insert, queueMonitoring);
|
||||||
@ -253,8 +255,7 @@ export class QueueMonitoringController {
|
|||||||
|
|
||||||
let param: any = await schema.validateAsync(req.params);
|
let param: any = await schema.validateAsync(req.params);
|
||||||
|
|
||||||
let queueMonitoring = await QueueMonitoringModel.list({ "QueueMonitoring.id": param.id })
|
let queueMonitoring = await QueueMonitoringModel.list({ "QueueMonitoring.id": param.id }).then((q) => q.leftJoinAndSelect("QueueMonitoring.rooms", "rooms").leftJoinAndSelect("rooms.department", "department").getOne());
|
||||||
.then((q) => q.leftJoinAndSelect("QueueMonitoring.rooms", "rooms").leftJoinAndSelect("rooms.department", "department").getOne());
|
|
||||||
|
|
||||||
if (!queueMonitoring) throw { message: "Queue Monitoring Not Found" };
|
if (!queueMonitoring) throw { message: "Queue Monitoring Not Found" };
|
||||||
|
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
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 { ResponsiblePartyConsent,Province,City,Subdistrict,Ward, RefferalHospital,RegistrationFee,FareType, RoomStock, Administrativu, Aldeia, District, Menu, Munisipo, Suco, Application, Nationality, Diagnosis, DiagnosticProcedure, Room, ServiceType, ServiceClass, Service, ServiceFare, ServicePackage, Department, DoctorSchedule, MeasurementUnit, ReferenceRange, QueueMonitoring, ExaminationDetail, ExaminationType, User, UserRole, HrmsEmployee, HrmsDepartment, HrmsPosition, HrmsShift, HospitalInformation, ItemOrigin, ItemType, ItemTypeDetail, Unit, ItemCategory, ItemStatus, UsageInstructions, UsageTime, ItemClass, ItemClassDetail, GenericName, Factory, Supplier, FactoryToSupplier, ItemMaster, ItemGroup, PharmacyInfo, ItemPrice, SellingPricePercentage, PatientGroup, PatientGuarantor, InitialStock, DoctorItem, DoctorItemPackage, UserToRoom, RoomToPharmacy, PlanningVerificator, ScheduleSeries, ScheduleException, CardType, PaymentMethod } from 'entity'
|
import { ResponsiblePartyConsent, Province, City, Subdistrict, Ward, RefferalHospital, RegistrationFee, FareType, RoomStock, Administrativu, Aldeia, District, Menu, Munisipo, Suco, Application, Nationality, Diagnosis, DiagnosticProcedure, Room, ServiceType, ServiceClass, Service, ServiceFare, ServicePackage, Department, DoctorSchedule, MeasurementUnit, ReferenceRange, QueueMonitoring, QueueMonitoringRooms, ExaminationDetail, ExaminationType, User, UserRole, HrmsEmployee, HrmsDepartment, HrmsPosition, HrmsShift, HospitalInformation, ItemOrigin, ItemType, ItemTypeDetail, Unit, ItemCategory, ItemStatus, UsageInstructions, UsageTime, ItemClass, ItemClassDetail, GenericName, Factory, Supplier, FactoryToSupplier, ItemMaster, ItemGroup, PharmacyInfo, ItemPrice, SellingPricePercentage, PatientGroup, PatientGuarantor, InitialStock, DoctorItem, DoctorItemPackage, UserToRoom, RoomToPharmacy, PlanningVerificator, ScheduleSeries, ScheduleException, CardType, PaymentMethod } from "entity";
|
||||||
|
|
||||||
export class OrmHelper {
|
export class OrmHelper {
|
||||||
static DB: DataSource = null
|
static DB: DataSource = null;
|
||||||
|
|
||||||
static setup() {
|
static setup() {
|
||||||
const log: Logger<ILogObj> = new Logger({ name: '[OrmHelper]', type: 'pretty' });
|
const log: Logger<ILogObj> = new Logger({ name: "[OrmHelper]", type: "pretty" });
|
||||||
|
|
||||||
const engine: 'mysql' | 'postgres' = config.get("database.engine")
|
const engine: "mysql" | "postgres" = config.get("database.engine");
|
||||||
|
|
||||||
OrmHelper.DB = new DataSource({
|
OrmHelper.DB = new DataSource({
|
||||||
type: engine,
|
type: engine,
|
||||||
@ -19,8 +19,41 @@ export class OrmHelper {
|
|||||||
password: String(config.get("database.password")),
|
password: String(config.get("database.password")),
|
||||||
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, MeasurementUnit, ReferenceRange, QueueMonitoring, ExaminationDetail, ExaminationType, User, UserRole, HrmsEmployee, HrmsDepartment, HrmsPosition, HrmsShift, HospitalInformation, ItemGroup,
|
entities: [
|
||||||
|
//
|
||||||
|
Menu,
|
||||||
|
Administrativu,
|
||||||
|
Aldeia,
|
||||||
|
District,
|
||||||
|
Munisipo,
|
||||||
|
Suco,
|
||||||
|
Application,
|
||||||
|
Nationality,
|
||||||
|
Diagnosis,
|
||||||
|
DiagnosticProcedure,
|
||||||
|
Room,
|
||||||
|
ServiceType,
|
||||||
|
ServiceClass,
|
||||||
|
Service,
|
||||||
|
ServiceFare,
|
||||||
|
ServicePackage,
|
||||||
|
Department,
|
||||||
|
DoctorSchedule,
|
||||||
|
MeasurementUnit,
|
||||||
|
ReferenceRange,
|
||||||
|
QueueMonitoring,
|
||||||
|
QueueMonitoringRooms,
|
||||||
|
ExaminationDetail,
|
||||||
|
ExaminationType,
|
||||||
|
User,
|
||||||
|
UserRole,
|
||||||
|
HrmsEmployee,
|
||||||
|
HrmsDepartment,
|
||||||
|
HrmsPosition,
|
||||||
|
HrmsShift,
|
||||||
|
HospitalInformation,
|
||||||
|
ItemGroup,
|
||||||
ItemOrigin,
|
ItemOrigin,
|
||||||
ItemType,
|
ItemType,
|
||||||
ItemTypeDetail,
|
ItemTypeDetail,
|
||||||
@ -54,17 +87,21 @@ export class OrmHelper {
|
|||||||
CardType,
|
CardType,
|
||||||
PaymentMethod,
|
PaymentMethod,
|
||||||
RegistrationFee,
|
RegistrationFee,
|
||||||
RefferalHospital,Province,City,Subdistrict,Ward,
|
RefferalHospital,
|
||||||
ResponsiblePartyConsent
|
Province,
|
||||||
|
City,
|
||||||
|
Subdistrict,
|
||||||
|
Ward,
|
||||||
|
ResponsiblePartyConsent,
|
||||||
],
|
],
|
||||||
subscribers: [],
|
subscribers: [],
|
||||||
migrations: [],
|
migrations: [],
|
||||||
})
|
});
|
||||||
|
|
||||||
OrmHelper.DB.initialize()
|
OrmHelper.DB.initialize()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// here you can start to work with your database
|
// here you can start to work with your database
|
||||||
})
|
})
|
||||||
.catch((error: any) => log.error(error))
|
.catch((error: any) => log.error(error));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user