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 { export class FosterCareHistoryController {
static async list(req: Request, res: Response, next: NextFunction): Promise<void | Response> { static async list(req: Request, res: Response, next: NextFunction): Promise<void | Response> {
/* /*
#swagger.tags = ['Foster Care History'] #swagger.tags = ['Foster Care History']
#swagger.security = [{ #swagger.security = [{
"bearerAuth": [] "bearerAuth": []
}] }]
#swagger.parameters['filter'] = { #swagger.parameters['filter'] = {
description: 'Filter: JSON object; FosterCareHistory.code and FosterCareHistory.diagnosis are combined with OR; other fields use AND.', description: 'Filter: JSON object; FosterCareHistory.code and FosterCareHistory.diagnosis are combined with OR; other fields use AND.',
in: 'query', in: 'query',
type: 'string', type: 'string',
} }
#swagger.parameters['limit'] = { #swagger.parameters['limit'] = {
in: 'query', in: 'query',
required: true, required: true,
type: 'number' type: 'number'
} }
#swagger.parameters['page'] = { #swagger.parameters['page'] = {
in: 'query', in: 'query',
required: true, required: true,
type: 'number' type: 'number'
} }
#swagger.parameters['with_deleted'] = { #swagger.parameters['with_deleted'] = {
in: 'query', in: 'query',
required: true, required: true,
type: 'boolean' type: 'boolean'
} }
#swagger.parameters['order_field'] = { #swagger.parameters['order_field'] = {
in: 'query', in: 'query',
required: true, required: true,
type: 'string' type: 'string'
} }
#swagger.parameters['order_direction'] = { #swagger.parameters['order_direction'] = {
in: 'query', in: 'query',
required: true, required: true,
schema: { schema: {
'@enum': ['ASC', 'DESC'] '@enum': ['ASC', 'DESC']
} }
} }
*/ */
try { try {
const schema = Joi.object().keys({ const schema = Joi.object().keys({
@ -144,21 +144,21 @@ export class FosterCareHistoryController {
static async create(req: Request, res: Response, next: NextFunction): Promise<void | Response> { static async create(req: Request, res: Response, next: NextFunction): Promise<void | Response> {
/* /*
#swagger.tags = ['Foster Care History'] #swagger.tags = ['Foster Care History']
#swagger.security = [{ #swagger.security = [{
"bearerAuth": [] "bearerAuth": []
}] }]
#swagger.requestBody = { #swagger.requestBody = {
required: true, required: true,
content: { content: {
"application/json": { "application/json": {
schema: { schema: {
$ref: "#/components/schemas/diagnosis" $ref: "#/components/schemas/fostercarehistory"
} }
} }
} }
} }
*/ */
const queryRunner = OrmHelper.DB.createQueryRunner(); const queryRunner = OrmHelper.DB.createQueryRunner();
await queryRunner.startTransaction(); await queryRunner.startTransaction();
try { try {
@ -166,6 +166,71 @@ export class FosterCareHistoryController {
diagnosis: Joi.string().max(256).required().label("Diagnosis"), diagnosis: Joi.string().max(256).required().label("Diagnosis"),
code: Joi.string().max(128).required().label("Code"), code: Joi.string().max(128).required().label("Code"),
status: Joi.string().required().label("Status"), 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); let param: any = await schema.validateAsync(req.body);
@ -180,6 +245,21 @@ export class FosterCareHistoryController {
fostercarehistory.diagnosis = param.diagnosis; fostercarehistory.diagnosis = param.diagnosis;
fostercarehistory.code = param.code; fostercarehistory.code = param.code;
fostercarehistory.status = param.status; 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.created_by = req.auth?.data.name;
fostercarehistory.updated_by = req.auth?.data.name; fostercarehistory.updated_by = req.auth?.data.name;
await queryRunner.manager.save(fostercarehistory); await queryRunner.manager.save(fostercarehistory);
@ -199,16 +279,16 @@ export class FosterCareHistoryController {
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 = ['Foster Care History'] #swagger.tags = ['Foster Care History']
#swagger.security = [{ #swagger.security = [{
"bearerAuth": [] "bearerAuth": []
}] }]
#swagger.parameters['id'] = { #swagger.parameters['id'] = {
description:'', description:'',
in: 'path', in: 'path',
type: 'string' type: 'string'
} }
*/ */
try { try {
const schema = Joi.object().keys({ const schema = Joi.object().keys({
@ -234,26 +314,26 @@ export class FosterCareHistoryController {
static async update(req: Request, res: Response, next: NextFunction): Promise<void | Response> { static async update(req: Request, res: Response, next: NextFunction): Promise<void | Response> {
/* /*
#swagger.tags = ['Foster Care History'] #swagger.tags = ['Foster Care History']
#swagger.security = [{ #swagger.security = [{
"bearerAuth": [] "bearerAuth": []
}] }]
#swagger.parameters['id'] = { #swagger.parameters['id'] = {
description:'', description:'',
in: 'path', in: 'path',
type: 'string' type: 'string'
} }
#swagger.requestBody = { #swagger.requestBody = {
required: true, required: true,
content: { content: {
"application/json": { "application/json": {
schema: { schema: {
$ref: "#/components/schemas/diagnosis" $ref: "#/components/schemas/fostercarehistory"
} }
} }
} }
} }
*/ */
const queryRunner = OrmHelper.DB.createQueryRunner(); const queryRunner = OrmHelper.DB.createQueryRunner();
await queryRunner.startTransaction(); await queryRunner.startTransaction();
@ -266,6 +346,71 @@ export class FosterCareHistoryController {
diagnosis: Joi.string().max(256).required().label("Diagnosis"), diagnosis: Joi.string().max(256).required().label("Diagnosis"),
code: Joi.string().max(128).required().label("Code"), code: Joi.string().max(128).required().label("Code"),
status: Joi.string().required().label("Status"), 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); let param: any = await schema.validateAsync(req.body);
@ -285,6 +430,21 @@ export class FosterCareHistoryController {
fostercarehistory.diagnosis = param.diagnosis; fostercarehistory.diagnosis = param.diagnosis;
fostercarehistory.code = param.code; fostercarehistory.code = param.code;
fostercarehistory.status = param.status; 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; fostercarehistory.updated_by = req.auth?.data.name;
await queryRunner.manager.save(fostercarehistory); await queryRunner.manager.save(fostercarehistory);
@ -303,23 +463,23 @@ export class FosterCareHistoryController {
static async delete(req: Request, res: Response, next: NextFunction): Promise<Response> { static async delete(req: Request, res: Response, next: NextFunction): Promise<Response> {
/* /*
#swagger.tags = ['Foster Care History'] #swagger.tags = ['Foster Care History']
#swagger.security = [{ #swagger.security = [{
"bearerAuth": [] "bearerAuth": []
}] }]
#swagger.parameters['id'] = { #swagger.parameters['id'] = {
in: 'path', in: 'path',
description: 'Foster Care History ID.', description: 'Foster Care History ID.',
required: true, required: true,
type: 'string' type: 'string'
} }
#swagger.parameters['hard'] = { #swagger.parameters['hard'] = {
in: 'path', in: 'path',
description: 'Is Hard Delete', description: 'Is Hard Delete',
required: false, required: false,
type: 'boolean' type: 'boolean'
} }
*/ */
try { try {
const schema = Joi.object().keys({ const schema = Joi.object().keys({
id: Joi.string().uuid().required().label("ID"), 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> { static async restore(req: Request, res: Response, next: NextFunction): Promise<Response> {
/* /*
#swagger.tags = ['Foster Care History'] #swagger.tags = ['Foster Care History']
#swagger.security = [{ #swagger.security = [{
"bearerAuth": [] "bearerAuth": []
}] }]
#swagger.parameters['id'] = { #swagger.parameters['id'] = {
in: 'path', in: 'path',
description: 'Foster Care History ID.', description: 'Foster Care History ID.',
required: true, required: true,
type: 'string' type: 'string'
} }
*/ */
try { try {
const schema = Joi.object().keys({ const schema = Joi.object().keys({
id: Joi.string().uuid().required().label("ID"), id: Joi.string().uuid().required().label("ID"),

View File

@ -509,6 +509,165 @@ const doc = {
$bodytext: "string", $bodytext: "string",
$type: "responsible-party-consent | patient-education | inpatient-admission-consent | provision-of-information | ward-class-upgrade-entitlement", $type: "responsible-party-consent | patient-education | inpatient-admission-consent | provision-of-information | ward-class-upgrade-entitlement",
}, },
fostercarehistory: {
type: "object",
properties: {
diagnosis: {
type: "string",
maxLength: 256,
example: "Gangguan Pertukaran Gas"
},
code: {
type: "string",
maxLength: 128,
example: "D.0003"
},
status: {
type: "string",
example: "active"
},
category: {
type: "string",
maxLength: 128,
nullable: true,
example: "Fisiologis"
},
subcategory: {
type: "string",
maxLength: 128,
nullable: true,
example: "Respirasi"
},
definition: {
type: "string",
maxLength: 128,
nullable: true,
example: "Kelebihan atau kekurangan oksigenasi"
},
objective: {
type: "string",
maxLength: 128,
nullable: true,
example: "Meningkatkan pertukaran gas"
},
result_criteria: {
type: "array",
nullable: true,
items: {
type: "object",
properties: {
group: { type: "number", example: 1 },
name: { type: "string", example: "Saturasi oksigen membaik" }
}
}
},
causes: {
type: "array",
nullable: true,
items: {
type: "object",
properties: {
group: { type: "string", example: "Fisiologis" },
name: { type: "string", example: "Ketidakseimbangan ventilasi-perfusi" }
}
}
},
related_clinical_condition: {
type: "array",
nullable: true,
items: {
type: "object",
properties: {
name: { type: "string", example: "Penyakit Paru Obstruktif Kronis (PPOK)" }
}
}
},
subjective_major: {
type: "array",
nullable: true,
items: {
type: "object",
properties: {
group: { type: "string", example: "Mayor" },
name: { type: "string", example: "Dispnea" }
}
}
},
objectitve_major: {
type: "array",
nullable: true,
items: {
type: "object",
properties: {
group: { type: "string", example: "Mayor" },
name: { type: "string", example: "PCO2 meningkat/menurun" }
}
}
},
subjective_minor: {
type: "array",
nullable: true,
items: {
type: "object",
properties: {
group: { type: "string", example: "Minor" },
name: { type: "string", example: "Pusing" }
}
}
},
objective_minor: {
type: "array",
nullable: true,
items: {
type: "object",
properties: {
group: { type: "string", example: "Minor" },
name: { type: "string", example: "Napas cuping hidung" }
}
}
},
observation: {
type: "array",
nullable: true,
items: {
type: "object",
properties: {
name: { type: "string", example: "Monitor frekuensi, irama, kedalaman napas" }
}
}
},
therapeutic: {
type: "array",
nullable: true,
items: {
type: "object",
properties: {
name: { type: "string", example: "Berikan posisi semi-Fowler" }
}
}
},
education: {
type: "array",
nullable: true,
items: {
type: "object",
properties: {
name: { type: "string", example: "Anjurkan teknik batuk efektif" }
}
}
},
colaboration: {
type: "array",
nullable: true,
items: {
type: "object",
properties: {
name: { type: "string", example: "Kolaborasi pemberian bronkodilator" }
}
}
},
}
},
}, },
parameters: {}, parameters: {},
securitySchemes: { securitySchemes: {