update
This commit is contained in:
@ -61,22 +61,22 @@ export class ResponsiblePartyConsentController {
|
||||
const queryRunner = OrmHelper.DB.createQueryRunner();
|
||||
await queryRunner.startTransaction();
|
||||
try {
|
||||
const typeEnum = [
|
||||
"responsible-party-consent",
|
||||
"patient-education",
|
||||
"inpatient-admission-consent",
|
||||
"provision-of-information",
|
||||
"ward-class-upgrade-entitlement",
|
||||
];
|
||||
|
||||
// create
|
||||
const schema = Joi.object().keys({
|
||||
bodytext: Joi.string().required().label("Body Text"),
|
||||
type: Joi.string().required().label("Type"),
|
||||
type: Joi.string().valid(...typeEnum).required().label("Type"),
|
||||
});
|
||||
|
||||
let param: any = await schema.validateAsync(req.body);
|
||||
|
||||
const existing = await OrmHelper.DB.getRepository(ResponsiblePartyConsent)
|
||||
.createQueryBuilder("ResponsiblePartyConsent")
|
||||
.getOne();
|
||||
|
||||
if (existing) {
|
||||
await queryRunner.rollbackTransaction();
|
||||
return ReturnHelper.errorResponse(res, 400, 400, "Data already exists", "Responsible Party Consent already exists");
|
||||
}
|
||||
|
||||
let responsiblepartyconsent = new ResponsiblePartyConsent();
|
||||
responsiblepartyconsent.body = param.bodytext;
|
||||
responsiblepartyconsent.type = param.type;
|
||||
@ -107,10 +107,17 @@ export class ResponsiblePartyConsentController {
|
||||
await queryRunner.startTransaction();
|
||||
try {
|
||||
req.body.id = req.params["id"];
|
||||
const typeEnum = [
|
||||
"responsible-party-consent",
|
||||
"patient-education",
|
||||
"inpatient-admission-consent",
|
||||
"provision-of-information",
|
||||
"ward-class-upgrade-entitlement",
|
||||
];
|
||||
const schema = Joi.object().keys({
|
||||
id: Joi.string().uuid().required().label("Room ID"),
|
||||
bodytext: Joi.string().required().label("Body Text"),
|
||||
type: Joi.string().required().label("Type"),
|
||||
type: Joi.string().valid(...typeEnum).required().label("Type"),
|
||||
});
|
||||
let param: any = await schema.validateAsync(req.body);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user