Merge branch 'main' of https://git.shiblysolution.id/SAUDE-TL/service-master-data
This commit is contained in:
@ -14,11 +14,10 @@ import { FactoryToSupplierModel } from "../../model/factory_to_supplier";
|
|||||||
const log: Logger<ILogObj> = new Logger({ name: '[FactorytoSupplierController]', type: 'pretty' });
|
const log: Logger<ILogObj> = new Logger({ name: '[FactorytoSupplierController]', type: 'pretty' });
|
||||||
|
|
||||||
export class FactorytoSupplierController {
|
export class FactorytoSupplierController {
|
||||||
static async listFactorybySupplier(req: Request, res: Response, next: NextFunction): Promise<void | Response> {
|
static async list(req: Request, res: Response, next: NextFunction): Promise<void | Response> {
|
||||||
/*
|
/*
|
||||||
#swagger.tags = ['Pharmacy - FactoryToSupplier']
|
#swagger.tags = ['Pharmacy - FactoryToSupplier']
|
||||||
#swagger.security = [{ "bearerAuth": [] }]
|
#swagger.security = [{ "bearerAuth": [] }]
|
||||||
#swagger.parameters['supplier_id'] = { in: 'query', required: true, type: 'string' }
|
|
||||||
#swagger.parameters['filter'] = { description: '', in: 'query', type: 'string' }
|
#swagger.parameters['filter'] = { description: '', in: 'query', type: 'string' }
|
||||||
#swagger.parameters['limit'] = { in: 'query', required: true, type: 'number' }
|
#swagger.parameters['limit'] = { in: 'query', required: true, type: 'number' }
|
||||||
#swagger.parameters['page'] = { in: 'query', required: true, type: 'number' }
|
#swagger.parameters['page'] = { in: 'query', required: true, type: 'number' }
|
||||||
@ -28,7 +27,6 @@ export class FactorytoSupplierController {
|
|||||||
*/
|
*/
|
||||||
try {
|
try {
|
||||||
const schema = Joi.object().keys({
|
const schema = Joi.object().keys({
|
||||||
supplier_id: Joi.string().uuid().required().label("Supplier ID"),
|
|
||||||
filter: Joi.string().allow("").optional().label("Filter"),
|
filter: Joi.string().allow("").optional().label("Filter"),
|
||||||
page: Joi.number().required().min(1).label("Page"),
|
page: Joi.number().required().min(1).label("Page"),
|
||||||
limit: Joi.number().required().min(1).label("Limit"),
|
limit: Joi.number().required().min(1).label("Limit"),
|
||||||
@ -41,7 +39,7 @@ export class FactorytoSupplierController {
|
|||||||
|
|
||||||
let filter = param.filter && param.filter !== "" ? JSON.parse(param.filter) : {};
|
let filter = param.filter && param.filter !== "" ? JSON.parse(param.filter) : {};
|
||||||
|
|
||||||
var query = await FactoryToSupplierModel.listFactorybySupplier(param.supplier_id, filter);
|
var query = await FactoryToSupplierModel.list(filter);
|
||||||
|
|
||||||
const offset = (param.page - 1) * param.limit;
|
const offset = (param.page - 1) * param.limit;
|
||||||
let limit = param.limit;
|
let limit = param.limit;
|
||||||
@ -76,7 +74,6 @@ export class FactorytoSupplierController {
|
|||||||
#swagger.security = [{
|
#swagger.security = [{
|
||||||
"bearerAuth": []
|
"bearerAuth": []
|
||||||
}]
|
}]
|
||||||
#swagger.parameters['supplier_id'] = { in: 'query', required: true, type: 'string' }
|
|
||||||
#swagger.parameters['filter'] = {
|
#swagger.parameters['filter'] = {
|
||||||
description: 'Filter with 2 format : <ul><li>Simple format use text plaint will filter eq:code or like %name%</li><li>Advance format using field existing {status:\'Y\', any:\'SAME AS PLAINT LOGIC\', etc...}</li></ul>',
|
description: 'Filter with 2 format : <ul><li>Simple format use text plaint will filter eq:code or like %name%</li><li>Advance format using field existing {status:\'Y\', any:\'SAME AS PLAINT LOGIC\', etc...}</li></ul>',
|
||||||
in: 'query',
|
in: 'query',
|
||||||
@ -102,7 +99,6 @@ export class FactorytoSupplierController {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const schema = Joi.object().keys({
|
const schema = Joi.object().keys({
|
||||||
supplier_id: Joi.string().uuid().required().label("Supplier ID"),
|
|
||||||
filter: Joi.string().allow('').optional().label('Filter'),
|
filter: Joi.string().allow('').optional().label('Filter'),
|
||||||
order_field: Joi.string().required().label('Order Field'),
|
order_field: Joi.string().required().label('Order Field'),
|
||||||
order_direction: Joi.string().allow('asc', 'desc').required().label('Order Direction'),
|
order_direction: Joi.string().allow('asc', 'desc').required().label('Order Direction'),
|
||||||
@ -112,7 +108,7 @@ export class FactorytoSupplierController {
|
|||||||
|
|
||||||
let filter = param.filter && param.filter !== "" ? JSON.parse(param.filter) : {};
|
let filter = param.filter && param.filter !== "" ? JSON.parse(param.filter) : {};
|
||||||
|
|
||||||
var query = await FactoryToSupplierModel.listFactorybySupplier(filter);
|
var query = await FactoryToSupplierModel.list(filter);
|
||||||
const data = await query.getMany();
|
const data = await query.getMany();
|
||||||
|
|
||||||
const filename = "factory_to_supplier.csv";
|
const filename = "factory_to_supplier.csv";
|
||||||
@ -194,6 +190,13 @@ export class FactorytoSupplierController {
|
|||||||
const factoryRepo = OrmHelper.DB.getRepository(Factory);
|
const factoryRepo = OrmHelper.DB.getRepository(Factory);
|
||||||
const supplierRepo = OrmHelper.DB.getRepository(Supplier);
|
const supplierRepo = OrmHelper.DB.getRepository(Supplier);
|
||||||
|
|
||||||
|
await factoryToSupplierRepo
|
||||||
|
.createQueryBuilder()
|
||||||
|
.delete()
|
||||||
|
.from(FactoryToSupplier)
|
||||||
|
.where("supplier_id = :supplierId", { supplierId: param.supplier_id })
|
||||||
|
.execute();
|
||||||
|
|
||||||
let relation : FactoryToSupplier;
|
let relation : FactoryToSupplier;
|
||||||
for (const factoryId of param.factory_ids) {
|
for (const factoryId of param.factory_ids) {
|
||||||
relation = new FactoryToSupplier();
|
relation = new FactoryToSupplier();
|
||||||
|
|||||||
141
src/controllers/pharmacy/initial_stock.ts
Normal file
141
src/controllers/pharmacy/initial_stock.ts
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
import { Response, NextFunction, Application } from "express";
|
||||||
|
import { Request } from "express-jwt";
|
||||||
|
import { ReturnHelper } from "../../helpers/express/return";
|
||||||
|
import { OrmHelper } from "../../helpers/orm";
|
||||||
|
import Joi from "joi";
|
||||||
|
import { ILogObj, Logger } from "tslog";
|
||||||
|
import { Language } from "../../langs/lang";
|
||||||
|
import { InitialStock, ItemMaster, Room, ItemOrigin, Paging } from "entity";
|
||||||
|
import CommonHelper from "../../helpers/common";
|
||||||
|
import * as fastcsv from 'fast-csv';
|
||||||
|
import dayjs from "dayjs";
|
||||||
|
import { InitialStockModel } from "../../model/initial_stock";
|
||||||
|
|
||||||
|
const log: Logger<ILogObj> = new Logger({ name: '[InitialStockController]', type: 'pretty' });
|
||||||
|
|
||||||
|
export class InitialStockController {
|
||||||
|
static async list(req: Request, res: Response, next: NextFunction): Promise<void | Response> {
|
||||||
|
/*
|
||||||
|
#swagger.tags = ['Pharmacy - InitialStock']
|
||||||
|
#swagger.security = [{ "bearerAuth": [] }]
|
||||||
|
#swagger.parameters['filter'] = { description: '', in: 'query', type: 'string' }
|
||||||
|
#swagger.parameters['limit'] = { in: 'query', required: true, type: 'number' }
|
||||||
|
#swagger.parameters['page'] = { in: 'query', required: true, type: 'number' }
|
||||||
|
#swagger.parameters['with_deleted'] = { in: 'query', required: true, type: 'boolean' }
|
||||||
|
#swagger.parameters['order_field'] = { in: 'query', required: true, type: 'string' }
|
||||||
|
#swagger.parameters['order_direction'] = { in: 'query', required: true, schema: { '@enum': ['ASC', 'DESC'] } }
|
||||||
|
*/
|
||||||
|
try {
|
||||||
|
const schema = Joi.object().keys({
|
||||||
|
filter: Joi.string().allow("").optional().label("Filter"),
|
||||||
|
page: Joi.number().required().min(1).label("Page"),
|
||||||
|
limit: Joi.number().required().min(1).label("Limit"),
|
||||||
|
with_deleted: Joi.bool().required().label("With Deleted"),
|
||||||
|
order_field: Joi.string().required().label("Order Field"),
|
||||||
|
order_direction: Joi.string().allow("asc", "desc").required().label("Order Direction"),
|
||||||
|
});
|
||||||
|
|
||||||
|
let param: any = await schema.validateAsync(req.query);
|
||||||
|
|
||||||
|
let filter = param.filter && param.filter !== "" ? JSON.parse(param.filter) : {};
|
||||||
|
|
||||||
|
var query = await InitialStockModel.list(filter);
|
||||||
|
|
||||||
|
const offset = (param.page - 1) * param.limit;
|
||||||
|
let limit = param.limit;
|
||||||
|
|
||||||
|
const res_count = query;
|
||||||
|
const res_list = query.select([
|
||||||
|
'InitialStock.id',
|
||||||
|
'InitialStock.exp_date',
|
||||||
|
'InitialStock.stock',
|
||||||
|
'ItemMaster.item_name',
|
||||||
|
'Room.room',
|
||||||
|
'ItemOrigin.origin_name',
|
||||||
|
])
|
||||||
|
.leftJoin("InitialStock.itemmaster", "ItemMaster")
|
||||||
|
.leftJoin("InitialStock.room", "Room")
|
||||||
|
.leftJoin("InitialStock.itemorigin", "ItemOrigin")
|
||||||
|
.orderBy("InitialStock." + param.order_field, param.order_direction)
|
||||||
|
.offset(offset)
|
||||||
|
.limit(limit);
|
||||||
|
|
||||||
|
if (param.with_deleted) {
|
||||||
|
res_count.withDeleted();
|
||||||
|
res_list.withDeleted();
|
||||||
|
}
|
||||||
|
|
||||||
|
const current_page = param.page;
|
||||||
|
const total_count_data = await res_count.getCount();
|
||||||
|
const list_data = await res_list.getMany();
|
||||||
|
const count_data = CommonHelper.countObject(list_data);
|
||||||
|
|
||||||
|
return ReturnHelper.successResponselist(res, 200, Language.lang.success_view, count_data, current_page, total_count_data, list_data);
|
||||||
|
} catch (e: unknown) {
|
||||||
|
log.error(e);
|
||||||
|
const err = e as Error;
|
||||||
|
return ReturnHelper.errorResponse(res, 400, 401, Language.lang.failed_view, err.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static async create(req: Request, res: Response, next: NextFunction): Promise<Response> {
|
||||||
|
/*
|
||||||
|
#swagger.tags = ['Pharmacy - InitialStock']
|
||||||
|
#swagger.security = [{
|
||||||
|
"bearerAuth": []
|
||||||
|
}]
|
||||||
|
|
||||||
|
#swagger.requestBody = {
|
||||||
|
required: true,
|
||||||
|
content: {
|
||||||
|
"application/json": {
|
||||||
|
schema: {
|
||||||
|
$ref: "#/components/schemas/initial_stock"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
const queryRunner = OrmHelper.DB.createQueryRunner();
|
||||||
|
await queryRunner.startTransaction();
|
||||||
|
try {
|
||||||
|
const schema = Joi.object().keys({
|
||||||
|
itemmaster: Joi.string().uuid().required().label("Item Master ID"),
|
||||||
|
room: Joi.string().uuid().required().label("Room ID"),
|
||||||
|
itemorigin: Joi.string().uuid().required().label("Item Origin ID"),
|
||||||
|
batch: Joi.string().label("Batch"),
|
||||||
|
exp_date: Joi.date().required().label("Exp Date"),
|
||||||
|
stock: Joi.number().required().label("Stock"),
|
||||||
|
});
|
||||||
|
|
||||||
|
const param: any = await schema.validateAsync(req.body);
|
||||||
|
|
||||||
|
const itemmaster = OrmHelper.DB.getRepository(ItemMaster).findOneBy({ id: param.itemmaster });
|
||||||
|
const room = OrmHelper.DB.getRepository(Room).findOneBy({ id: param.room })
|
||||||
|
const itemorigin = OrmHelper.DB.getRepository(ItemOrigin).findOneBy({ id: param.itemorigin });
|
||||||
|
|
||||||
|
if (!itemmaster) throw { message: "Item Master not found" };
|
||||||
|
if (!room) throw { message: "Room not found" };
|
||||||
|
if (!itemorigin) throw { message: "Item Origin not found" };
|
||||||
|
|
||||||
|
const initial_stock = new InitialStock();
|
||||||
|
initial_stock.itemmaster = param.itemmaster;
|
||||||
|
initial_stock.room = param.room;
|
||||||
|
initial_stock.itemorigin = param.itemorigin;
|
||||||
|
initial_stock.batch = param.batch;
|
||||||
|
initial_stock.exp_date = param.exp_date;
|
||||||
|
initial_stock.stock = param.stock;
|
||||||
|
|
||||||
|
await queryRunner.manager.save(initial_stock);
|
||||||
|
await queryRunner.commitTransaction();
|
||||||
|
|
||||||
|
return ReturnHelper.successResponseAny(res, 200, Language.lang.success_insert, initial_stock);
|
||||||
|
|
||||||
|
} catch (e: unknown) {
|
||||||
|
log.error(e);
|
||||||
|
const err = e as Error;
|
||||||
|
|
||||||
|
return ReturnHelper.errorResponse(res, 500, 401, Language.lang.failed_insert, err.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -68,6 +68,35 @@ export class ItemMasterController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static async option(req: Request, res: Response, next: NextFunction): Promise<void | Response> {
|
||||||
|
/*
|
||||||
|
#swagger.tags = ['Pharmacy - ItemMaster']
|
||||||
|
#swagger.security = [{ "bearerAuth": [] }]
|
||||||
|
*/
|
||||||
|
try {
|
||||||
|
const query = await ItemMasterModel.list();
|
||||||
|
|
||||||
|
query.select([
|
||||||
|
"item_master.id",
|
||||||
|
"item_master.item_name",
|
||||||
|
"unit.large_unit",
|
||||||
|
"unit.small_unit",
|
||||||
|
"item_master.pack_size",
|
||||||
|
]);
|
||||||
|
|
||||||
|
const total_count_data = await query.getCount();
|
||||||
|
const list_data = await query.getMany();
|
||||||
|
const count_data = CommonHelper.countObject(list_data);
|
||||||
|
|
||||||
|
return ReturnHelper.successResponselist(res, 200, Language.lang.success_view, count_data, 1, total_count_data, list_data);
|
||||||
|
} catch (e: unknown) {
|
||||||
|
log.error(e);
|
||||||
|
const err = e as Error;
|
||||||
|
return ReturnHelper.errorResponse(res, 400, 401, Language.lang.failed_view, err.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static async export(req: Request, res: Response, next: NextFunction): Promise<void | Response> {
|
static async export(req: Request, res: Response, next: NextFunction): Promise<void | Response> {
|
||||||
/*
|
/*
|
||||||
#swagger.tags = ['Pharmacy - ItemMaster']
|
#swagger.tags = ['Pharmacy - ItemMaster']
|
||||||
@ -177,6 +206,7 @@ export class ItemMasterController {
|
|||||||
item_type_detail_id: Joi.string().uuid().required().label('Item Type Detail ID'),
|
item_type_detail_id: Joi.string().uuid().required().label('Item Type Detail ID'),
|
||||||
item_category_id: Joi.string().uuid().required().label('Item Category ID'),
|
item_category_id: Joi.string().uuid().required().label('Item Category ID'),
|
||||||
item_class_id: Joi.string().uuid().required().label('Item Class ID'),
|
item_class_id: Joi.string().uuid().required().label('Item Class ID'),
|
||||||
|
item_class_detail_id: Joi.string().uuid().required().label('Item Class Detail ID'),
|
||||||
item_status_id: Joi.string().uuid().required().label('Item Status ID'),
|
item_status_id: Joi.string().uuid().required().label('Item Status ID'),
|
||||||
factory_id: Joi.string().uuid().required().label('Factory ID'),
|
factory_id: Joi.string().uuid().required().label('Factory ID'),
|
||||||
unit_id: Joi.string().uuid().required().label('Unit ID'),
|
unit_id: Joi.string().uuid().required().label('Unit ID'),
|
||||||
@ -191,18 +221,19 @@ export class ItemMasterController {
|
|||||||
|
|
||||||
const data = new ItemMaster()
|
const data = new ItemMaster()
|
||||||
data.item_name = param.item_name,
|
data.item_name = param.item_name,
|
||||||
data.generic_name = param.generic_name_id,
|
data.generic_name = param.generic_name_id,
|
||||||
data.type_detail = param.item_type_detail_id,
|
data.type_detail = param.item_type_detail_id,
|
||||||
data.category = param.item_category_id,
|
data.category = param.item_category_id,
|
||||||
data.item_class = param.item_class_id,
|
data.item_class = param.item_class_id,
|
||||||
data.status = param.item_status_id,
|
data.item_class_detail = param.item_class_detail_id,
|
||||||
data.factory = param.factory_id,
|
data.status = param.item_status_id,
|
||||||
data.unit = param.unit_id,
|
data.factory = param.factory_id,
|
||||||
data.pack_size = param.pack_size,
|
data.unit = param.unit_id,
|
||||||
data.minimum_quantity = param.minimum_quantity,
|
data.pack_size = param.pack_size,
|
||||||
data.minimum_sales_quantity = param.minimum_sales_quantity,
|
data.minimum_quantity = param.minimum_quantity,
|
||||||
data.strength = param.strength,
|
data.minimum_sales_quantity = param.minimum_sales_quantity,
|
||||||
data.active = param.active
|
data.strength = param.strength,
|
||||||
|
data.active = param.active
|
||||||
data.created_by = req.auth.data.name;
|
data.created_by = req.auth.data.name;
|
||||||
|
|
||||||
await OrmHelper.DB.manager.save(data);
|
await OrmHelper.DB.manager.save(data);
|
||||||
@ -249,6 +280,7 @@ export class ItemMasterController {
|
|||||||
item_type_detail_id: Joi.string().uuid().required().label('Item Type Detail ID'),
|
item_type_detail_id: Joi.string().uuid().required().label('Item Type Detail ID'),
|
||||||
item_category_id: Joi.string().uuid().required().label('Item Category ID'),
|
item_category_id: Joi.string().uuid().required().label('Item Category ID'),
|
||||||
item_class_id: Joi.string().uuid().required().label('Item Class ID'),
|
item_class_id: Joi.string().uuid().required().label('Item Class ID'),
|
||||||
|
item_class_detail_id: Joi.string().uuid().required().label('Item Class Detail ID'),
|
||||||
item_status_id: Joi.string().uuid().required().label('Item Status ID'),
|
item_status_id: Joi.string().uuid().required().label('Item Status ID'),
|
||||||
factory_id: Joi.string().uuid().required().label('Factory ID'),
|
factory_id: Joi.string().uuid().required().label('Factory ID'),
|
||||||
unit_id: Joi.string().uuid().required().label('Unit ID'),
|
unit_id: Joi.string().uuid().required().label('Unit ID'),
|
||||||
@ -269,18 +301,19 @@ export class ItemMasterController {
|
|||||||
|
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
data.item_name = param.item_name,
|
data.item_name = param.item_name,
|
||||||
data.generic_name = param.generic_name_id,
|
data.generic_name = param.generic_name_id,
|
||||||
data.type_detail = param.item_type_detail_id,
|
data.type_detail = param.item_type_detail_id,
|
||||||
data.category = param.item_category_id,
|
data.category = param.item_category_id,
|
||||||
data.item_class = param.item_class_id,
|
data.item_class = param.item_class_id,
|
||||||
data.status = param.item_status_id,
|
data.item_class_detail = param.item_class_detail_id,
|
||||||
data.factory = param.factory_id,
|
data.status = param.item_status_id,
|
||||||
data.unit = param.unit_id,
|
data.factory = param.factory_id,
|
||||||
data.pack_size = param.pack_size,
|
data.unit = param.unit_id,
|
||||||
data.minimum_quantity = param.minimum_quantity,
|
data.pack_size = param.pack_size,
|
||||||
data.minimum_sales_quantity = param.minimum_sales_quantity,
|
data.minimum_quantity = param.minimum_quantity,
|
||||||
data.strength = param.strength,
|
data.minimum_sales_quantity = param.minimum_sales_quantity,
|
||||||
data.active = param.active
|
data.strength = param.strength,
|
||||||
|
data.active = param.active
|
||||||
data.updated_by = req.auth.data.name;
|
data.updated_by = req.auth.data.name;
|
||||||
|
|
||||||
await repo.save(data);
|
await repo.save(data);
|
||||||
|
|||||||
@ -68,6 +68,31 @@ export class ItemOriginController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static async option(req: Request, res: Response, next: NextFunction): Promise<void | Response> {
|
||||||
|
/*
|
||||||
|
#swagger.tags = ['Pharmacy - ItemOrigin']
|
||||||
|
#swagger.security = [{ "bearerAuth": [] }]
|
||||||
|
*/
|
||||||
|
try {
|
||||||
|
const query = await ItemOriginModel.list();
|
||||||
|
|
||||||
|
query.select([
|
||||||
|
"item_origin.id",
|
||||||
|
"item_origin.origin_name",
|
||||||
|
]);
|
||||||
|
|
||||||
|
const total_count_data = await query.getCount();
|
||||||
|
const list_data = await query.getMany();
|
||||||
|
const count_data = CommonHelper.countObject(list_data);
|
||||||
|
|
||||||
|
return ReturnHelper.successResponselist(res, 200, Language.lang.success_view, count_data, 1, total_count_data, list_data);
|
||||||
|
} catch (e: unknown) {
|
||||||
|
log.error(e);
|
||||||
|
const err = e as Error;
|
||||||
|
return ReturnHelper.errorResponse(res, 400, 401, Language.lang.failed_view, err.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static async export(req: Request, res: Response, next: NextFunction): Promise<void | Response> {
|
static async export(req: Request, res: Response, next: NextFunction): Promise<void | Response> {
|
||||||
/*
|
/*
|
||||||
#swagger.tags = ['Pharmacy - ItemOrigin']
|
#swagger.tags = ['Pharmacy - ItemOrigin']
|
||||||
|
|||||||
@ -68,6 +68,31 @@ export class SupplierController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static async option(req: Request, res: Response, next: NextFunction): Promise<void | Response> {
|
||||||
|
/*
|
||||||
|
#swagger.tags = ['Pharmacy - Supplier']
|
||||||
|
#swagger.security = [{ "bearerAuth": [] }]
|
||||||
|
*/
|
||||||
|
try {
|
||||||
|
const query = await SupplierModel.list();
|
||||||
|
|
||||||
|
query.select([
|
||||||
|
"supplier.id",
|
||||||
|
"supplier.supplier_name",
|
||||||
|
]);
|
||||||
|
|
||||||
|
const total_count_data = await query.getCount();
|
||||||
|
const list_data = await query.getMany();
|
||||||
|
const count_data = CommonHelper.countObject(list_data);
|
||||||
|
|
||||||
|
return ReturnHelper.successResponselist(res, 200, Language.lang.success_view, count_data, 1, total_count_data, list_data);
|
||||||
|
} catch (e: unknown) {
|
||||||
|
log.error(e);
|
||||||
|
const err = e as Error;
|
||||||
|
return ReturnHelper.errorResponse(res, 400, 401, Language.lang.failed_view, err.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static async export(req: Request, res: Response, next: NextFunction): Promise<void | Response> {
|
static async export(req: Request, res: Response, next: NextFunction): Promise<void | Response> {
|
||||||
/*
|
/*
|
||||||
#swagger.tags = ['Pharmacy - Supplier']
|
#swagger.tags = ['Pharmacy - Supplier']
|
||||||
|
|||||||
@ -173,12 +173,16 @@ export class UnitController {
|
|||||||
try {
|
try {
|
||||||
const schema = Joi.object().keys({
|
const schema = Joi.object().keys({
|
||||||
unit_name: Joi.string().max(256).required().label('Name'),
|
unit_name: Joi.string().max(256).required().label('Name'),
|
||||||
|
small_unit: Joi.string().max(256).optional().allow('').label('Small Unit'),
|
||||||
|
large_unit: Joi.string().max(256).optional().allow('').label('Large Unit'),
|
||||||
});
|
});
|
||||||
|
|
||||||
const param: any = await schema.validateAsync(req.body);
|
const param: any = await schema.validateAsync(req.body);
|
||||||
|
|
||||||
const data = new Unit()
|
const data = new Unit()
|
||||||
data.unit_name = param.unit_name
|
data.unit_name = param.unit_name
|
||||||
|
data.small_unit = param.small_unit
|
||||||
|
data.large_unit = param.large_unit
|
||||||
data.created_by = req.auth.data.name
|
data.created_by = req.auth.data.name
|
||||||
|
|
||||||
await OrmHelper.DB.manager.save(data);
|
await OrmHelper.DB.manager.save(data);
|
||||||
@ -221,6 +225,8 @@ export class UnitController {
|
|||||||
const schema = Joi.object().keys({
|
const schema = Joi.object().keys({
|
||||||
id: Joi.string().uuid().required().label('ID'),
|
id: Joi.string().uuid().required().label('ID'),
|
||||||
unit_name: Joi.string().max(256).required().label('Name'),
|
unit_name: Joi.string().max(256).required().label('Name'),
|
||||||
|
small_unit: Joi.string().max(256).optional().allow('').label('Small Unit'),
|
||||||
|
large_unit: Joi.string().max(256).optional().allow('').label('Large Unit'),
|
||||||
});
|
});
|
||||||
|
|
||||||
req.body.id = req.params['id'];
|
req.body.id = req.params['id'];
|
||||||
@ -233,6 +239,8 @@ export class UnitController {
|
|||||||
|
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
data.unit_name = param.unit_name
|
data.unit_name = param.unit_name
|
||||||
|
data.small_unit = param.small_unit
|
||||||
|
data.large_unit = param.large_unit
|
||||||
data.updated_by = req.auth.data.name
|
data.updated_by = req.auth.data.name
|
||||||
|
|
||||||
await repo.save(data);
|
await repo.save(data);
|
||||||
|
|||||||
@ -180,7 +180,7 @@ export class UsageInstructionsController {
|
|||||||
|
|
||||||
const data = new UsageInstructions()
|
const data = new UsageInstructions()
|
||||||
data.usage_instructions_name = param.usage_instructions_name
|
data.usage_instructions_name = param.usage_instructions_name
|
||||||
data.usage_abbreviation = param.usage_instructions_abbreviation
|
data.usage_instructions_abbreviation = param.usage_instructions_abbreviation
|
||||||
data.created_by = req.auth.data.name;
|
data.created_by = req.auth.data.name;
|
||||||
|
|
||||||
await OrmHelper.DB.manager.save(data);
|
await OrmHelper.DB.manager.save(data);
|
||||||
@ -236,7 +236,7 @@ export class UsageInstructionsController {
|
|||||||
|
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
data.usage_instructions_name = param.usage_instructions_name
|
data.usage_instructions_name = param.usage_instructions_name
|
||||||
data.usage_abbreviation = param.usage_instructions_abbreviation
|
data.usage_instructions_abbreviation = param.usage_instructions_abbreviation
|
||||||
data.updated_by = req.auth.data.name;
|
data.updated_by = req.auth.data.name;
|
||||||
|
|
||||||
await repo.save(data);
|
await repo.save(data);
|
||||||
|
|||||||
@ -71,14 +71,39 @@ export class RoomController {
|
|||||||
const total_count_data = await res_count.getCount();
|
const total_count_data = await res_count.getCount();
|
||||||
const list_data = await res_list.getMany();
|
const list_data = await res_list.getMany();
|
||||||
const mapped_data = list_data.map((item: any) => ({
|
const mapped_data = list_data.map((item: any) => ({
|
||||||
...item,
|
...item,
|
||||||
picture: item.picture
|
picture: item.picture
|
||||||
? photoBaseUrl + item.picture
|
? photoBaseUrl + item.picture
|
||||||
: null
|
: null
|
||||||
}));
|
}));
|
||||||
const count_data = CommonHelper.countObject(list_data);
|
const count_data = CommonHelper.countObject(list_data);
|
||||||
|
|
||||||
return ReturnHelper.successResponselist(res, 200, Language.lang.success_view, count_data, current_page, total_count_data, mapped_data);
|
return ReturnHelper.successResponselist(res, 200, Language.lang.success_view, count_data, current_page, total_count_data, mapped_data);
|
||||||
|
} catch (e: unknown) {
|
||||||
|
log.error(e);
|
||||||
|
const err = e as Error;
|
||||||
|
return ReturnHelper.errorResponse(res, 400, 401, Language.lang.failed_view, err.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static async option(req: Request, res: Response, next: NextFunction): Promise<void | Response> {
|
||||||
|
/*
|
||||||
|
#swagger.tags = ['Room']
|
||||||
|
#swagger.security = [{ "bearerAuth": [] }]
|
||||||
|
*/
|
||||||
|
try {
|
||||||
|
const query = await RoomModel.list();
|
||||||
|
|
||||||
|
query.select([
|
||||||
|
"Room.id",
|
||||||
|
"Room.room",
|
||||||
|
]);
|
||||||
|
|
||||||
|
const total_count_data = await query.getCount();
|
||||||
|
const list_data = await query.getMany();
|
||||||
|
const count_data = CommonHelper.countObject(list_data);
|
||||||
|
|
||||||
|
return ReturnHelper.successResponselist(res, 200, Language.lang.success_view, count_data, 1, total_count_data, list_data);
|
||||||
} catch (e: unknown) {
|
} catch (e: unknown) {
|
||||||
log.error(e);
|
log.error(e);
|
||||||
const err = e as Error;
|
const err = e as Error;
|
||||||
|
|||||||
@ -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, 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 } from 'entity'
|
import { 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 } from 'entity'
|
||||||
|
|
||||||
export class OrmHelper {
|
export class OrmHelper {
|
||||||
static DB: DataSource = null
|
static DB: DataSource = null
|
||||||
@ -40,7 +40,8 @@ export class OrmHelper {
|
|||||||
ItemPrice,
|
ItemPrice,
|
||||||
SellingPricePercentage,
|
SellingPricePercentage,
|
||||||
PatientGroup,
|
PatientGroup,
|
||||||
PatientGuarantor
|
PatientGuarantor,
|
||||||
|
InitialStock
|
||||||
],
|
],
|
||||||
subscribers: [],
|
subscribers: [],
|
||||||
migrations: [],
|
migrations: [],
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { OrmHelper } from "../helpers/orm";
|
|||||||
import { FactoryToSupplier } from "entity";
|
import { FactoryToSupplier } from "entity";
|
||||||
|
|
||||||
export class FactoryToSupplierModel {
|
export class FactoryToSupplierModel {
|
||||||
static async listFactorybySupplier(supplier_id: string, filter = {}): Promise<SelectQueryBuilder<any>> {
|
static async list(filter = {}): Promise<SelectQueryBuilder<any>> {
|
||||||
const repo = OrmHelper.DB.getRepository(FactoryToSupplier);
|
const repo = OrmHelper.DB.getRepository(FactoryToSupplier);
|
||||||
let whereAttr: string[] = [];
|
let whereAttr: string[] = [];
|
||||||
let whereVal: any = {};
|
let whereVal: any = {};
|
||||||
@ -16,7 +16,6 @@ export class FactoryToSupplierModel {
|
|||||||
var query = repo.createQueryBuilder("factory_to_supplier")
|
var query = repo.createQueryBuilder("factory_to_supplier")
|
||||||
.leftJoinAndSelect("factory_to_supplier.factory", "factory")
|
.leftJoinAndSelect("factory_to_supplier.factory", "factory")
|
||||||
.leftJoinAndSelect("factory_to_supplier.supplier", "supplier")
|
.leftJoinAndSelect("factory_to_supplier.supplier", "supplier")
|
||||||
.where("factory_to_supplier.supplier_id = :supplierId", { supplierId: supplier_id });
|
|
||||||
if (whereAttr.length != 0) {
|
if (whereAttr.length != 0) {
|
||||||
query = query.where(whereAttr.join(" and "), whereVal);
|
query = query.where(whereAttr.join(" and "), whereVal);
|
||||||
}
|
}
|
||||||
|
|||||||
23
src/model/initial_stock.ts
Normal file
23
src/model/initial_stock.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import { InitialStock } from "entity";
|
||||||
|
import { SelectQueryBuilder } from "typeorm";
|
||||||
|
import CommonHelper from "../helpers/common";
|
||||||
|
import { OrmHelper } from "../helpers/orm";
|
||||||
|
|
||||||
|
export class InitialStockModel {
|
||||||
|
static async list(filter = {}): Promise<SelectQueryBuilder<any>> {
|
||||||
|
const repo = OrmHelper.DB.getRepository(InitialStock);
|
||||||
|
let whereAttr: string[] = [];
|
||||||
|
let whereVal: any = {};
|
||||||
|
if (filter && Object.keys(filter).length > 0) {
|
||||||
|
whereAttr = [...whereAttr, ...CommonHelper.handleQueryFilter(filter, "InitialStock").whereAttr];
|
||||||
|
whereVal = { ...whereVal, ...CommonHelper.handleQueryFilter(filter, "InitialStock").whereVal };
|
||||||
|
}
|
||||||
|
|
||||||
|
var query = repo.createQueryBuilder("InitialStock");
|
||||||
|
if (whereAttr.length != 0) {
|
||||||
|
query = query.where(whereAttr.join(" and "), whereVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -19,7 +19,7 @@ export class ItemMasterModel {
|
|||||||
.leftJoinAndSelect("item_master.type_detail", "type_detail")
|
.leftJoinAndSelect("item_master.type_detail", "type_detail")
|
||||||
.leftJoinAndSelect("item_master.category", "category")
|
.leftJoinAndSelect("item_master.category", "category")
|
||||||
.leftJoinAndSelect("item_master.item_class", "item_class")
|
.leftJoinAndSelect("item_master.item_class", "item_class")
|
||||||
.leftJoinAndSelect("item_master.class_detail", "class_detail")
|
.leftJoinAndSelect("item_master.item_class_detail", "item_class_detail")
|
||||||
.leftJoinAndSelect("item_master.status", "status")
|
.leftJoinAndSelect("item_master.status", "status")
|
||||||
.leftJoinAndSelect("item_master.factory", "factory")
|
.leftJoinAndSelect("item_master.factory", "factory")
|
||||||
.leftJoinAndSelect("item_master.unit", "unit")
|
.leftJoinAndSelect("item_master.unit", "unit")
|
||||||
|
|||||||
@ -51,6 +51,7 @@ import { PatientGuarantorController } from '../controllers/patient_guarantor';
|
|||||||
import { GenericNameController } from '../controllers/pharmacy/generic_name';
|
import { GenericNameController } from '../controllers/pharmacy/generic_name';
|
||||||
import { RefferalHospital } from 'entity';
|
import { RefferalHospital } from 'entity';
|
||||||
import { RefferalHospitalController } from '../controllers/refferal_hospital';
|
import { RefferalHospitalController } from '../controllers/refferal_hospital';
|
||||||
|
import { InitialStockController } from '../controllers/pharmacy/initial_stock';
|
||||||
|
|
||||||
export class RoutePrivate {
|
export class RoutePrivate {
|
||||||
static setup(app: express.Application) {
|
static setup(app: express.Application) {
|
||||||
@ -130,6 +131,7 @@ export class RoutePrivate {
|
|||||||
app.put('/api/diagnostic-procedure/restore/:id', DiagnosticProcedureController.restore)
|
app.put('/api/diagnostic-procedure/restore/:id', DiagnosticProcedureController.restore)
|
||||||
|
|
||||||
app.get('/api/room/list', RoomController.list)
|
app.get('/api/room/list', RoomController.list)
|
||||||
|
app.get('/api/room/option', RoomController.option)
|
||||||
app.post('/api/room/create', RoomController.create)
|
app.post('/api/room/create', RoomController.create)
|
||||||
app.get('/api/room/detail/:id', RoomController.detail)
|
app.get('/api/room/detail/:id', RoomController.detail)
|
||||||
app.put('/api/room/update/:id', RoomController.update)
|
app.put('/api/room/update/:id', RoomController.update)
|
||||||
@ -247,6 +249,7 @@ export class RoutePrivate {
|
|||||||
app.put('/api/pharmacy/item-group/restore/:id', ItemGroupController.restore)
|
app.put('/api/pharmacy/item-group/restore/:id', ItemGroupController.restore)
|
||||||
|
|
||||||
app.get('/api/pharmacy/item-origin/list', ItemOriginController.list)
|
app.get('/api/pharmacy/item-origin/list', ItemOriginController.list)
|
||||||
|
app.get('/api/pharmacy/item-origin/option', ItemOriginController.option)
|
||||||
app.get('/api/pharmacy/item-origin/export', ItemOriginController.export)
|
app.get('/api/pharmacy/item-origin/export', ItemOriginController.export)
|
||||||
app.post('/api/pharmacy/item-origin/create', ItemOriginController.create)
|
app.post('/api/pharmacy/item-origin/create', ItemOriginController.create)
|
||||||
app.put('/api/pharmacy/item-origin/update/:id', ItemOriginController.update)
|
app.put('/api/pharmacy/item-origin/update/:id', ItemOriginController.update)
|
||||||
@ -331,20 +334,22 @@ export class RoutePrivate {
|
|||||||
app.put('/api/pharmacy/factory/restore/:id', FactoryController.restore)
|
app.put('/api/pharmacy/factory/restore/:id', FactoryController.restore)
|
||||||
|
|
||||||
app.get('/api/pharmacy/supplier/list', SupplierController.list)
|
app.get('/api/pharmacy/supplier/list', SupplierController.list)
|
||||||
|
app.get('/api/pharmacy/supplier/option', SupplierController.option)
|
||||||
app.get('/api/pharmacy/supplier/export', SupplierController.export)
|
app.get('/api/pharmacy/supplier/export', SupplierController.export)
|
||||||
app.post('/api/pharmacy/supplier/create', SupplierController.create)
|
app.post('/api/pharmacy/supplier/create', SupplierController.create)
|
||||||
app.put('/api/pharmacy/supplier/update/:id', SupplierController.update)
|
app.put('/api/pharmacy/supplier/update/:id', SupplierController.update)
|
||||||
app.delete('/api/pharmacy/supplier/delete/:id/:hard', SupplierController.delete)
|
app.delete('/api/pharmacy/supplier/delete/:id/:hard', SupplierController.delete)
|
||||||
app.put('/api/pharmacy/supplier/restore/:id', SupplierController.restore)
|
app.put('/api/pharmacy/supplier/restore/:id', SupplierController.restore)
|
||||||
|
|
||||||
app.get('/api/pharmacy/factory-to-supplier/list-factory-by-supplier', FactorytoSupplierController.listFactorybySupplier)
|
app.get('/api/pharmacy/factory-to-supplier/list', FactorytoSupplierController.list)
|
||||||
app.get('/api/pharmacy/factory-to-supplier/export', FactorytoSupplierController.export)
|
app.get('/api/pharmacy/factory-to-supplier/export', FactorytoSupplierController.export)
|
||||||
app.post('/api/pharmacy/factory-to-supplier/create', FactorytoSupplierController.create)
|
app.post('/api/pharmacy/factory-to-supplier/create', FactorytoSupplierController.create)
|
||||||
app.put('/api/pharmacy/factory-to-supplier/update/:supplier_id', FactorytoSupplierController.update)
|
// app.put('/api/pharmacy/factory-to-supplier/update/:supplier_id', FactorytoSupplierController.update)
|
||||||
// app.delete('/api/pharmacy/factory-to-supplier/delete/:supplier_id/:hard', FactorytoSupplierController.delete)
|
// app.delete('/api/pharmacy/factory-to-supplier/delete/:supplier_id/:hard', FactorytoSupplierController.delete)
|
||||||
// app.put('/api/pharmacy/factory-to-supplier/restore/:supplier_id', FactorytoSupplierController.restore)
|
// app.put('/api/pharmacy/factory-to-supplier/restore/:supplier_id', FactorytoSupplierController.restore)
|
||||||
|
|
||||||
app.get('/api/pharmacy/item-master/list', ItemMasterController.list)
|
app.get('/api/pharmacy/item-master/list', ItemMasterController.list)
|
||||||
|
app.get('/api/pharmacy/item-master/option', ItemMasterController.option)
|
||||||
app.get('/api/pharmacy/item-master/export', ItemMasterController.export)
|
app.get('/api/pharmacy/item-master/export', ItemMasterController.export)
|
||||||
app.post('/api/pharmacy/item-master/create', ItemMasterController.create)
|
app.post('/api/pharmacy/item-master/create', ItemMasterController.create)
|
||||||
app.put('/api/pharmacy/item-master/update/:id', ItemMasterController.update)
|
app.put('/api/pharmacy/item-master/update/:id', ItemMasterController.update)
|
||||||
@ -395,5 +400,8 @@ export class RoutePrivate {
|
|||||||
app.put('/api/refferal-hospital/update/:id', RefferalHospitalController.update)
|
app.put('/api/refferal-hospital/update/:id', RefferalHospitalController.update)
|
||||||
app.delete('/api/refferal-hospital/delete/:id/:hard', RefferalHospitalController.delete)
|
app.delete('/api/refferal-hospital/delete/:id/:hard', RefferalHospitalController.delete)
|
||||||
app.put('/api/refferal-hospital/restore/:id', RefferalHospitalController.restore)
|
app.put('/api/refferal-hospital/restore/:id', RefferalHospitalController.restore)
|
||||||
|
|
||||||
|
app.get('/api/initial-stock/list', InitialStockController.list)
|
||||||
|
app.post('/api/initial-stock/create', InitialStockController.create)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -222,6 +222,8 @@ const doc = {
|
|||||||
},
|
},
|
||||||
unit: {
|
unit: {
|
||||||
$unit_name: 'Unit name',
|
$unit_name: 'Unit name',
|
||||||
|
$small_unit: 'Small unit name',
|
||||||
|
$large_unit: 'Large unit name'
|
||||||
},
|
},
|
||||||
item_category: {
|
item_category: {
|
||||||
$category_name: 'ItemCategory name',
|
$category_name: 'ItemCategory name',
|
||||||
@ -269,6 +271,7 @@ const doc = {
|
|||||||
$item_type_detail_id: 'Item type detail ID (UUID)',
|
$item_type_detail_id: 'Item type detail ID (UUID)',
|
||||||
$item_category_id: 'Item category ID (UUID)',
|
$item_category_id: 'Item category ID (UUID)',
|
||||||
$item_class_id: 'Item class ID (UUID)',
|
$item_class_id: 'Item class ID (UUID)',
|
||||||
|
$item_class_detail_id: 'Item class Detail ID (UUID)',
|
||||||
$item_status_id: 'Item status ID (UUID)',
|
$item_status_id: 'Item status ID (UUID)',
|
||||||
$factory_id: 'Factory ID (UUID)',
|
$factory_id: 'Factory ID (UUID)',
|
||||||
$unit_id: 'Unit ID (UUID)',
|
$unit_id: 'Unit ID (UUID)',
|
||||||
@ -295,6 +298,14 @@ const doc = {
|
|||||||
$selling_price: 'Selling Price (required, number, minimum 0)',
|
$selling_price: 'Selling Price (required, number, minimum 0)',
|
||||||
$expired_date: 'Expired Date (required, date)'
|
$expired_date: 'Expired Date (required, date)'
|
||||||
},
|
},
|
||||||
|
initial_stock: {
|
||||||
|
$itemmaster: 'Item Master uuid',
|
||||||
|
$room: 'Room uuid',
|
||||||
|
$itemorigin: 'Item Origin uuid',
|
||||||
|
$batch: 'Batch',
|
||||||
|
$exp_date: 'Exp Date',
|
||||||
|
$stock: 'Stock'
|
||||||
|
},
|
||||||
selling_price_percentage: {
|
selling_price_percentage: {
|
||||||
$item_master_id: 'Item Master ID (required, UUID)',
|
$item_master_id: 'Item Master ID (required, UUID)',
|
||||||
$item_origin_id: 'Item Origin ID (required, UUID)',
|
$item_origin_id: 'Item Origin ID (required, UUID)',
|
||||||
|
|||||||
Reference in New Issue
Block a user