fix(referral-hospital): add new column of type
This commit is contained in:
@ -5,7 +5,7 @@ import { OrmHelper } from "../helpers/orm";
|
|||||||
import Joi from "joi";
|
import Joi from "joi";
|
||||||
import { ILogObj, Logger } from "tslog";
|
import { ILogObj, Logger } from "tslog";
|
||||||
import { Language } from "../langs/lang";
|
import { Language } from "../langs/lang";
|
||||||
import { RefferalHospital, Paging } from "entity";
|
import { RefferalHospital, Paging, RefferalHospitalType } from "entity";
|
||||||
import CommonHelper from "../helpers/common";
|
import CommonHelper from "../helpers/common";
|
||||||
import * as fastcsv from 'fast-csv';
|
import * as fastcsv from 'fast-csv';
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
@ -197,6 +197,7 @@ export class RefferalHospitalController {
|
|||||||
try {
|
try {
|
||||||
const schema = Joi.object().keys({
|
const schema = Joi.object().keys({
|
||||||
refferal_hospital_name: Joi.string().max(256).required().label('Name'),
|
refferal_hospital_name: Joi.string().max(256).required().label('Name'),
|
||||||
|
type: Joi.string().valid(...Object.values(RefferalHospitalType)).optional().allow(null, "").label('Type'),
|
||||||
});
|
});
|
||||||
|
|
||||||
const param: any = await schema.validateAsync(req.body);
|
const param: any = await schema.validateAsync(req.body);
|
||||||
@ -210,6 +211,7 @@ export class RefferalHospitalController {
|
|||||||
|
|
||||||
const data = new RefferalHospital()
|
const data = new RefferalHospital()
|
||||||
data.refferal_hospital_name = param.refferal_hospital_name
|
data.refferal_hospital_name = param.refferal_hospital_name
|
||||||
|
data.type = param.type || null;
|
||||||
data.order_number = lastRow && lastRow.order_number ? String(Number(lastRow.order_number) + 1) : "1";
|
data.order_number = lastRow && lastRow.order_number ? String(Number(lastRow.order_number) + 1) : "1";
|
||||||
data.created_by = req.auth.data.name;
|
data.created_by = req.auth.data.name;
|
||||||
|
|
||||||
@ -253,6 +255,7 @@ export class RefferalHospitalController {
|
|||||||
const schema = Joi.object().keys({
|
const schema = Joi.object().keys({
|
||||||
id: Joi.string().uuid().required().label('ID'),
|
id: Joi.string().uuid().required().label('ID'),
|
||||||
refferal_hospital_name: Joi.string().max(256).required().label('Name'),
|
refferal_hospital_name: Joi.string().max(256).required().label('Name'),
|
||||||
|
type: Joi.string().valid(...Object.values(RefferalHospitalType)).optional().allow(null, "").label('Type'),
|
||||||
});
|
});
|
||||||
|
|
||||||
req.body.id = req.params['id'];
|
req.body.id = req.params['id'];
|
||||||
@ -265,6 +268,7 @@ export class RefferalHospitalController {
|
|||||||
|
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
data.refferal_hospital_name = param.refferal_hospital_name
|
data.refferal_hospital_name = param.refferal_hospital_name
|
||||||
|
data.type = param.type || null;
|
||||||
data.updated_by = req.auth.data.name;
|
data.updated_by = req.auth.data.name;
|
||||||
|
|
||||||
await repo.save(data);
|
await repo.save(data);
|
||||||
|
|||||||
Reference in New Issue
Block a user