update : add region in master data
This commit is contained in:
@ -79,28 +79,28 @@ export class PharmacyInfoController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async detail(req: Request, res: Response, next: NextFunction): Promise<void | Response> {
|
static async detail(req: Request, res: Response, next: NextFunction): Promise<void | Response> {
|
||||||
/*
|
/*
|
||||||
#swagger.tags = ['Pharmacy - PharmacyInfo']
|
#swagger.tags = ['Pharmacy - PharmacyInfo']
|
||||||
#swagger.security = [{ "bearerAuth": [] }]
|
#swagger.security = [{ "bearerAuth": [] }]
|
||||||
#swagger.parameters['id'] = { description: '', in: 'path', type: 'string' }
|
#swagger.parameters['id'] = { description: '', in: 'path', type: 'string' }
|
||||||
*/
|
*/
|
||||||
try {
|
try {
|
||||||
const schema = Joi.object().keys({
|
const schema = Joi.object().keys({
|
||||||
id: Joi.string().uuid().required().label("Pharmacy Info Id"),
|
id: Joi.string().uuid().required().label("Pharmacy Info Id"),
|
||||||
});
|
});
|
||||||
|
|
||||||
let param: any = await schema.validateAsync(req.params);
|
let param: any = await schema.validateAsync(req.params);
|
||||||
|
|
||||||
let data = await PharmacyInfoModel.list({ "id": param.id }).then((q) => q.getOne());
|
let data = await PharmacyInfoModel.list({ "id": param.id }).then((q) => q.getOne());
|
||||||
if (!data) throw { message: "Pharmacy Info Not Found" };
|
if (!data) throw { message: "Pharmacy Info Not Found" };
|
||||||
|
|
||||||
return ReturnHelper.successResponseAny(res, 200, Language.lang.success_view, data);
|
return ReturnHelper.successResponseAny(res, 200, Language.lang.success_view, data);
|
||||||
} catch (e: unknown) {
|
} catch (e: unknown) {
|
||||||
log.error(e);
|
log.error(e);
|
||||||
const err = e as Error;
|
const err = e as Error;
|
||||||
return ReturnHelper.errorResponse(res, 400, 401, Language.lang.failed_not_found, err.message);
|
return ReturnHelper.errorResponse(res, 400, 401, Language.lang.failed_not_found, 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> {
|
||||||
/*
|
/*
|
||||||
@ -144,7 +144,7 @@ export class PharmacyInfoController {
|
|||||||
|
|
||||||
var query = await PharmacyInfoModel.list(filter);
|
var query = await PharmacyInfoModel.list(filter);
|
||||||
const data = await query.getMany();
|
const data = await query.getMany();
|
||||||
|
|
||||||
const filename = "pharmacy_info.csv";
|
const filename = "pharmacy_info.csv";
|
||||||
|
|
||||||
res.setHeader('Content-Type', 'text/csv');
|
res.setHeader('Content-Type', 'text/csv');
|
||||||
@ -250,6 +250,11 @@ export class PharmacyInfoController {
|
|||||||
.uuid()
|
.uuid()
|
||||||
.required()
|
.required()
|
||||||
.label('Default Room'),
|
.label('Default Room'),
|
||||||
|
|
||||||
|
province: Joi.string().allow("").optional().label("Province Code"),
|
||||||
|
city: Joi.string().allow("").optional().label("City Code"),
|
||||||
|
subdistrict: Joi.string().allow("").optional().label("Subdistrict Code"),
|
||||||
|
ward: Joi.string().allow("").optional().label("Ward Code"),
|
||||||
});
|
});
|
||||||
|
|
||||||
const param: any = await schema.validateAsync(req.body);
|
const param: any = await schema.validateAsync(req.body);
|
||||||
@ -264,7 +269,11 @@ export class PharmacyInfoController {
|
|||||||
data.phone = param.phone
|
data.phone = param.phone
|
||||||
data.default_room = param.default_room_id
|
data.default_room = param.default_room_id
|
||||||
data.logo = param.logo
|
data.logo = param.logo
|
||||||
data.created_by = req.auth.data.name;
|
data.province = param.province
|
||||||
|
data.city = param.city
|
||||||
|
data.subdistrict = param.subdistrict
|
||||||
|
data.ward = param.ward
|
||||||
|
data.created_by = req.auth?.data.name;
|
||||||
|
|
||||||
await OrmHelper.DB.manager.save(data);
|
await OrmHelper.DB.manager.save(data);
|
||||||
|
|
||||||
@ -369,7 +378,11 @@ export class PharmacyInfoController {
|
|||||||
data.phone = param.phone
|
data.phone = param.phone
|
||||||
data.default_room = param.default_room_id
|
data.default_room = param.default_room_id
|
||||||
data.logo = param.logo
|
data.logo = param.logo
|
||||||
data.updated_by = req.auth.data.name;
|
data.province = param.province
|
||||||
|
data.city = param.city
|
||||||
|
data.subdistrict = param.subdistrict
|
||||||
|
data.ward = param.ward
|
||||||
|
data.updated_by = req.auth?.data.name;
|
||||||
|
|
||||||
await repo.save(data);
|
await repo.save(data);
|
||||||
|
|
||||||
@ -416,7 +429,7 @@ export class PharmacyInfoController {
|
|||||||
|
|
||||||
const existData = await repo.findOne({ where: { id: param.id } });
|
const existData = await repo.findOne({ where: { id: param.id } });
|
||||||
if (existData && !param.hard) {
|
if (existData && !param.hard) {
|
||||||
existData.deleted_by = req.auth.data.name;
|
existData.deleted_by = req.auth?.data.name;
|
||||||
await OrmHelper.DB.manager.save(existData);
|
await OrmHelper.DB.manager.save(existData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -625,33 +638,33 @@ export class PharmacyInfoController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async view(req: Request, res: Response, next: NextFunction): Promise<void | Response> {
|
static async view(req: Request, res: Response, next: NextFunction): Promise<void | Response> {
|
||||||
/*
|
/*
|
||||||
#swagger.tags = ['Pharmacy - PharmacyInfo']
|
#swagger.tags = ['Pharmacy - PharmacyInfo']
|
||||||
#swagger.security = [{ "bearerAuth": [] }]
|
#swagger.security = [{ "bearerAuth": [] }]
|
||||||
*/
|
*/
|
||||||
try {
|
try {
|
||||||
const data = await OrmHelper.DB
|
const data = await OrmHelper.DB
|
||||||
.getRepository(PharmacyInfo)
|
.getRepository(PharmacyInfo)
|
||||||
.findOne({
|
.findOne({
|
||||||
where: {}
|
where: {}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!data) return ReturnHelper.errorResponse(res, 404, 404, Language.lang.failed_view, "data not found");
|
if (!data) return ReturnHelper.errorResponse(res, 404, 404, Language.lang.failed_view, "data not found");
|
||||||
|
|
||||||
const result = {
|
const result = {
|
||||||
id: data.id,
|
id: data.id,
|
||||||
name: data.name,
|
name: data.name,
|
||||||
address: data.address,
|
address: data.address,
|
||||||
phone: data.phone,
|
phone: data.phone,
|
||||||
logo: 'http://his.shiblysolution.id:3011/service-master-data/uploads/hospital-logo/' + data.logo
|
logo: 'http://his.shiblysolution.id:3011/service-master-data/uploads/hospital-logo/' + data.logo
|
||||||
};
|
};
|
||||||
|
|
||||||
return ReturnHelper.successResponseAny(res, 200, Language.lang.success_view, result);
|
return ReturnHelper.successResponseAny(res, 200, Language.lang.success_view, result);
|
||||||
|
|
||||||
} catch (e: unknown) {
|
} catch (e: unknown) {
|
||||||
log.error(e);
|
log.error(e);
|
||||||
const err = e as Error;
|
const err = e as Error;
|
||||||
return ReturnHelper.errorResponse(res,400,401,Language.lang.failed_view,err.message);
|
return ReturnHelper.errorResponse(res, 400, 401, Language.lang.failed_view, err.message);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -82,7 +82,7 @@ export class RegionController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static async subdistric(req: Request, res: Response, next: NextFunction): Promise<Response> {
|
static async subdistrict(req: Request, res: Response, next: NextFunction): Promise<Response> {
|
||||||
/*
|
/*
|
||||||
#swagger.tags = ['Region']
|
#swagger.tags = ['Region']
|
||||||
#swagger.security = [{
|
#swagger.security = [{
|
||||||
|
|||||||
@ -18,7 +18,11 @@ export class PharmacyInfoModel {
|
|||||||
.leftJoinAndSelect("pharmacy_info.munisipiu", "munisipiu")
|
.leftJoinAndSelect("pharmacy_info.munisipiu", "munisipiu")
|
||||||
.leftJoinAndSelect("pharmacy_info.postu_admin", "postu_admin")
|
.leftJoinAndSelect("pharmacy_info.postu_admin", "postu_admin")
|
||||||
.leftJoinAndSelect("pharmacy_info.suco", "suco")
|
.leftJoinAndSelect("pharmacy_info.suco", "suco")
|
||||||
.leftJoinAndSelect("pharmacy_info.aldeia", "aldeia");
|
.leftJoinAndSelect("pharmacy_info.aldeia", "aldeia")
|
||||||
|
.leftJoinAndSelect("pharmacy_info.province", "province")
|
||||||
|
.leftJoinAndSelect("pharmacy_info.city", "city")
|
||||||
|
.leftJoinAndSelect("pharmacy_info.subdistrict", "subdistrict")
|
||||||
|
.leftJoinAndSelect("pharmacy_info.ward", "ward");
|
||||||
if (whereAttr.length != 0) {
|
if (whereAttr.length != 0) {
|
||||||
query = query.where(whereAttr.join(" and "), whereVal);
|
query = query.where(whereAttr.join(" and "), whereVal);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -488,7 +488,7 @@ export class RoutePrivate {
|
|||||||
|
|
||||||
app.get('/api/region/province', RegionController.province)
|
app.get('/api/region/province', RegionController.province)
|
||||||
app.get('/api/region/city/:province_code', RegionController.city)
|
app.get('/api/region/city/:province_code', RegionController.city)
|
||||||
app.get('/api/region/subdistrict/:city_code', RegionController.subdistric)
|
app.get('/api/region/subdistrict/:city_code', RegionController.subdistrict)
|
||||||
app.get('/api/region/ward/:subdistric_code', RegionController.ward)
|
app.get('/api/region/ward/:subdistric_code', RegionController.ward)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -319,6 +319,10 @@ const doc = {
|
|||||||
$aldeia: "Aldeia ID (UUID)",
|
$aldeia: "Aldeia ID (UUID)",
|
||||||
$phone: "Phone (string, max 30, optional)",
|
$phone: "Phone (string, max 30, optional)",
|
||||||
$default_room_id: "Default Room ID (UUID)",
|
$default_room_id: "Default Room ID (UUID)",
|
||||||
|
$province: "Province Code",
|
||||||
|
$city: "City Code",
|
||||||
|
$subdistrict: "Subdistrict Code",
|
||||||
|
$ward: "Ward Code",
|
||||||
},
|
},
|
||||||
item_price: {
|
item_price: {
|
||||||
$item_master_id: "Item Master ID (required, UUID)",
|
$item_master_id: "Item Master ID (required, UUID)",
|
||||||
|
|||||||
Reference in New Issue
Block a user