update
This commit is contained in:
@ -61,22 +61,22 @@ export class ResponsiblePartyConsentController {
|
|||||||
const queryRunner = OrmHelper.DB.createQueryRunner();
|
const queryRunner = OrmHelper.DB.createQueryRunner();
|
||||||
await queryRunner.startTransaction();
|
await queryRunner.startTransaction();
|
||||||
try {
|
try {
|
||||||
|
const typeEnum = [
|
||||||
|
"responsible-party-consent",
|
||||||
|
"patient-education",
|
||||||
|
"inpatient-admission-consent",
|
||||||
|
"provision-of-information",
|
||||||
|
"ward-class-upgrade-entitlement",
|
||||||
|
];
|
||||||
|
|
||||||
|
// create
|
||||||
const schema = Joi.object().keys({
|
const schema = Joi.object().keys({
|
||||||
bodytext: Joi.string().required().label("Body Text"),
|
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);
|
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();
|
let responsiblepartyconsent = new ResponsiblePartyConsent();
|
||||||
responsiblepartyconsent.body = param.bodytext;
|
responsiblepartyconsent.body = param.bodytext;
|
||||||
responsiblepartyconsent.type = param.type;
|
responsiblepartyconsent.type = param.type;
|
||||||
@ -107,10 +107,17 @@ export class ResponsiblePartyConsentController {
|
|||||||
await queryRunner.startTransaction();
|
await queryRunner.startTransaction();
|
||||||
try {
|
try {
|
||||||
req.body.id = req.params["id"];
|
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({
|
const schema = Joi.object().keys({
|
||||||
id: Joi.string().uuid().required().label("Room ID"),
|
id: Joi.string().uuid().required().label("Room ID"),
|
||||||
bodytext: Joi.string().required().label("Body Text"),
|
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);
|
let param: any = await schema.validateAsync(req.body);
|
||||||
|
|
||||||
|
|||||||
@ -500,7 +500,7 @@ const doc = {
|
|||||||
},
|
},
|
||||||
responsiblepartyconsent: {
|
responsiblepartyconsent: {
|
||||||
$bodytext: "string",
|
$bodytext: "string",
|
||||||
$type: "string",
|
$type: "responsible-party-consent | patient-education | inpatient-admission-consent | provision-of-information | ward-class-upgrade-entitlement",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
parameters: {},
|
parameters: {},
|
||||||
|
|||||||
Reference in New Issue
Block a user