This commit is contained in:
wayanrivan
2026-05-05 10:55:12 +07:00
parent eb8598bfb5
commit b3be4f8437
2 changed files with 429 additions and 110 deletions

View File

@ -20,43 +20,43 @@ const log: Logger<ILogObj> = new Logger({
export class FosterCareHistoryController {
static async list(req: Request, res: Response, next: NextFunction): Promise<void | Response> {
/*
#swagger.tags = ['Foster Care History']
#swagger.security = [{
"bearerAuth": []
}]
#swagger.parameters['filter'] = {
description: 'Filter: JSON object; FosterCareHistory.code and FosterCareHistory.diagnosis are combined with OR; other fields use AND.',
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']
}
}
*/
#swagger.tags = ['Foster Care History']
#swagger.security = [{
"bearerAuth": []
}]
#swagger.parameters['filter'] = {
description: 'Filter: JSON object; FosterCareHistory.code and FosterCareHistory.diagnosis are combined with OR; other fields use AND.',
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({
@ -144,21 +144,21 @@ export class FosterCareHistoryController {
static async create(req: Request, res: Response, next: NextFunction): Promise<void | Response> {
/*
#swagger.tags = ['Foster Care History']
#swagger.security = [{
"bearerAuth": []
}]
#swagger.requestBody = {
required: true,
content: {
"application/json": {
schema: {
$ref: "#/components/schemas/diagnosis"
}
}
}
}
*/
#swagger.tags = ['Foster Care History']
#swagger.security = [{
"bearerAuth": []
}]
#swagger.requestBody = {
required: true,
content: {
"application/json": {
schema: {
$ref: "#/components/schemas/fostercarehistory"
}
}
}
}
*/
const queryRunner = OrmHelper.DB.createQueryRunner();
await queryRunner.startTransaction();
try {
@ -166,6 +166,71 @@ export class FosterCareHistoryController {
diagnosis: Joi.string().max(256).required().label("Diagnosis"),
code: Joi.string().max(128).required().label("Code"),
status: Joi.string().required().label("Status"),
category: Joi.string().max(128).allow(null, "").label("Category"),
subcategory: Joi.string().max(128).allow(null, "").label("Subcategory"),
definition: Joi.string().max(128).allow(null, "").label("Definition"),
objective: Joi.string().max(128).allow(null, "").label("Objective"),
result_criteria: Joi.array().items(
Joi.object({
group: Joi.number().allow(null),
name: Joi.string().allow(null, ""),
})
).allow(null).label("Result Criteria"),
causes: Joi.array().items(
Joi.object({
group: Joi.string().allow(null, ""),
name: Joi.string().allow(null, ""),
})
).allow(null).label("Causes"),
related_clinical_condition: Joi.array().items(
Joi.object({
name: Joi.string().allow(null, ""),
})
).allow(null).label("Related Clinical Condition"),
subjective_major: Joi.array().items(
Joi.object({
group: Joi.string().allow(null, ""),
name: Joi.string().allow(null, ""),
})
).allow(null).label("Subjective Major"),
objectitve_major: Joi.array().items(
Joi.object({
group: Joi.string().allow(null, ""),
name: Joi.string().allow(null, ""),
})
).allow(null).label("Objective Major"),
subjective_minor: Joi.array().items(
Joi.object({
group: Joi.string().allow(null, ""),
name: Joi.string().allow(null, ""),
})
).allow(null).label("Subjective Minor"),
objective_minor: Joi.array().items(
Joi.object({
group: Joi.string().allow(null, ""),
name: Joi.string().allow(null, ""),
})
).allow(null).label("Objective Minor"),
observation: Joi.array().items(
Joi.object({
name: Joi.string().allow(null, ""),
})
).allow(null).label("Observation"),
therapeutic: Joi.array().items(
Joi.object({
name: Joi.string().allow(null, ""),
})
).allow(null).label("Therapeutic"),
education: Joi.array().items(
Joi.object({
name: Joi.string().allow(null, ""),
})
).allow(null).label("Education"),
colaboration: Joi.array().items(
Joi.object({
name: Joi.string().allow(null, ""),
})
).allow(null).label("Colaboration"),
});
let param: any = await schema.validateAsync(req.body);
@ -180,6 +245,21 @@ export class FosterCareHistoryController {
fostercarehistory.diagnosis = param.diagnosis;
fostercarehistory.code = param.code;
fostercarehistory.status = param.status;
fostercarehistory.category = param.category;
fostercarehistory.subcategory = param.subcategory;
fostercarehistory.definition = param.definition;
fostercarehistory.objective = param.objective;
fostercarehistory.result_criteria = param.result_criteria ?? [];
fostercarehistory.causes = param.causes ?? [];
fostercarehistory.related_clinical_condition = param.related_clinical_condition ?? [];
fostercarehistory.subjective_major = param.subjective_major ?? [];
fostercarehistory.objectitve_major = param.objectitve_major ?? [];
fostercarehistory.subjective_minor = param.subjective_minor ?? [];
fostercarehistory.objective_minor = param.objective_minor ?? [];
fostercarehistory.observation = param.observation ?? [];
fostercarehistory.therapeutic = param.therapeutic ?? [];
fostercarehistory.education = param.education ?? [];
fostercarehistory.colaboration = param.colaboration ?? [];
fostercarehistory.created_by = req.auth?.data.name;
fostercarehistory.updated_by = req.auth?.data.name;
await queryRunner.manager.save(fostercarehistory);
@ -199,16 +279,16 @@ export class FosterCareHistoryController {
static async detail(req: Request, res: Response, next: NextFunction): Promise<void | Response> {
/*
#swagger.tags = ['Foster Care History']
#swagger.security = [{
"bearerAuth": []
}]
#swagger.parameters['id'] = {
description:'',
in: 'path',
type: 'string'
}
*/
#swagger.tags = ['Foster Care History']
#swagger.security = [{
"bearerAuth": []
}]
#swagger.parameters['id'] = {
description:'',
in: 'path',
type: 'string'
}
*/
try {
const schema = Joi.object().keys({
@ -234,26 +314,26 @@ export class FosterCareHistoryController {
static async update(req: Request, res: Response, next: NextFunction): Promise<void | Response> {
/*
#swagger.tags = ['Foster Care History']
#swagger.security = [{
"bearerAuth": []
}]
#swagger.parameters['id'] = {
description:'',
in: 'path',
type: 'string'
}
#swagger.requestBody = {
required: true,
content: {
"application/json": {
schema: {
$ref: "#/components/schemas/diagnosis"
}
}
}
}
*/
#swagger.tags = ['Foster Care History']
#swagger.security = [{
"bearerAuth": []
}]
#swagger.parameters['id'] = {
description:'',
in: 'path',
type: 'string'
}
#swagger.requestBody = {
required: true,
content: {
"application/json": {
schema: {
$ref: "#/components/schemas/fostercarehistory"
}
}
}
}
*/
const queryRunner = OrmHelper.DB.createQueryRunner();
await queryRunner.startTransaction();
@ -266,6 +346,71 @@ export class FosterCareHistoryController {
diagnosis: Joi.string().max(256).required().label("Diagnosis"),
code: Joi.string().max(128).required().label("Code"),
status: Joi.string().required().label("Status"),
category: Joi.string().max(128).allow(null, "").label("Category"),
subcategory: Joi.string().max(128).allow(null, "").label("Subcategory"),
definition: Joi.string().max(128).allow(null, "").label("Definition"),
objective: Joi.string().max(128).allow(null, "").label("Objective"),
result_criteria: Joi.array().items(
Joi.object({
group: Joi.number().allow(null),
name: Joi.string().allow(null, ""),
})
).allow(null).label("Result Criteria"),
causes: Joi.array().items(
Joi.object({
group: Joi.string().allow(null, ""),
name: Joi.string().allow(null, ""),
})
).allow(null).label("Causes"),
related_clinical_condition: Joi.array().items(
Joi.object({
name: Joi.string().allow(null, ""),
})
).allow(null).label("Related Clinical Condition"),
subjective_major: Joi.array().items(
Joi.object({
group: Joi.string().allow(null, ""),
name: Joi.string().allow(null, ""),
})
).allow(null).label("Subjective Major"),
objectitve_major: Joi.array().items(
Joi.object({
group: Joi.string().allow(null, ""),
name: Joi.string().allow(null, ""),
})
).allow(null).label("Objective Major"),
subjective_minor: Joi.array().items(
Joi.object({
group: Joi.string().allow(null, ""),
name: Joi.string().allow(null, ""),
})
).allow(null).label("Subjective Minor"),
objective_minor: Joi.array().items(
Joi.object({
group: Joi.string().allow(null, ""),
name: Joi.string().allow(null, ""),
})
).allow(null).label("Objective Minor"),
observation: Joi.array().items(
Joi.object({
name: Joi.string().allow(null, ""),
})
).allow(null).label("Observation"),
therapeutic: Joi.array().items(
Joi.object({
name: Joi.string().allow(null, ""),
})
).allow(null).label("Therapeutic"),
education: Joi.array().items(
Joi.object({
name: Joi.string().allow(null, ""),
})
).allow(null).label("Education"),
colaboration: Joi.array().items(
Joi.object({
name: Joi.string().allow(null, ""),
})
).allow(null).label("Colaboration"),
});
let param: any = await schema.validateAsync(req.body);
@ -285,6 +430,21 @@ export class FosterCareHistoryController {
fostercarehistory.diagnosis = param.diagnosis;
fostercarehistory.code = param.code;
fostercarehistory.status = param.status;
fostercarehistory.category = param.category;
fostercarehistory.subcategory = param.subcategory;
fostercarehistory.definition = param.definition;
fostercarehistory.objective = param.objective;
fostercarehistory.result_criteria = param.result_criteria ?? fostercarehistory.result_criteria;
fostercarehistory.causes = param.causes ?? fostercarehistory.causes;
fostercarehistory.related_clinical_condition = param.related_clinical_condition ?? fostercarehistory.related_clinical_condition;
fostercarehistory.subjective_major = param.subjective_major ?? fostercarehistory.subjective_major;
fostercarehistory.objectitve_major = param.objectitve_major ?? fostercarehistory.objectitve_major;
fostercarehistory.subjective_minor = param.subjective_minor ?? fostercarehistory.subjective_minor;
fostercarehistory.objective_minor = param.objective_minor ?? fostercarehistory.objective_minor;
fostercarehistory.observation = param.observation ?? fostercarehistory.observation;
fostercarehistory.therapeutic = param.therapeutic ?? fostercarehistory.therapeutic;
fostercarehistory.education = param.education ?? fostercarehistory.education;
fostercarehistory.colaboration = param.colaboration ?? fostercarehistory.colaboration;
fostercarehistory.updated_by = req.auth?.data.name;
await queryRunner.manager.save(fostercarehistory);
@ -303,23 +463,23 @@ export class FosterCareHistoryController {
static async delete(req: Request, res: Response, next: NextFunction): Promise<Response> {
/*
#swagger.tags = ['Foster Care History']
#swagger.security = [{
"bearerAuth": []
}]
#swagger.parameters['id'] = {
in: 'path',
description: 'Foster Care History ID.',
required: true,
type: 'string'
}
#swagger.parameters['hard'] = {
in: 'path',
description: 'Is Hard Delete',
required: false,
type: 'boolean'
}
*/
#swagger.tags = ['Foster Care History']
#swagger.security = [{
"bearerAuth": []
}]
#swagger.parameters['id'] = {
in: 'path',
description: 'Foster Care History ID.',
required: true,
type: 'string'
}
#swagger.parameters['hard'] = {
in: 'path',
description: 'Is Hard Delete',
required: false,
type: 'boolean'
}
*/
try {
const schema = Joi.object().keys({
id: Joi.string().uuid().required().label("ID"),
@ -360,17 +520,17 @@ export class FosterCareHistoryController {
static async restore(req: Request, res: Response, next: NextFunction): Promise<Response> {
/*
#swagger.tags = ['Foster Care History']
#swagger.security = [{
"bearerAuth": []
}]
#swagger.parameters['id'] = {
in: 'path',
description: 'Foster Care History ID.',
required: true,
type: 'string'
}
*/
#swagger.tags = ['Foster Care History']
#swagger.security = [{
"bearerAuth": []
}]
#swagger.parameters['id'] = {
in: 'path',
description: 'Foster Care History ID.',
required: true,
type: 'string'
}
*/
try {
const schema = Joi.object().keys({
id: Joi.string().uuid().required().label("ID"),