From b3be4f84374fdded5aa19c3b971d5089ce9550e8 Mon Sep 17 00:00:00 2001 From: wayanrivan Date: Tue, 5 May 2026 10:55:12 +0700 Subject: [PATCH] update --- src/controllers/fostercarehistory.ts | 380 +++++++++++++++++++-------- src/swagger/builder.js | 159 +++++++++++ 2 files changed, 429 insertions(+), 110 deletions(-) diff --git a/src/controllers/fostercarehistory.ts b/src/controllers/fostercarehistory.ts index e15712d..0e227e2 100644 --- a/src/controllers/fostercarehistory.ts +++ b/src/controllers/fostercarehistory.ts @@ -20,43 +20,43 @@ const log: Logger = new Logger({ export class FosterCareHistoryController { static async list(req: Request, res: Response, next: NextFunction): Promise { /* - #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 { /* - #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 { /* - #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 { /* - #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 { /* - #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 { /* - #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"), diff --git a/src/swagger/builder.js b/src/swagger/builder.js index 8b1934d..358e58d 100644 --- a/src/swagger/builder.js +++ b/src/swagger/builder.js @@ -509,6 +509,165 @@ const doc = { $bodytext: "string", $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: {}, securitySchemes: {