diff --git a/src/controllers/patient_group.ts b/src/controllers/patient_group.ts index b55397e..8929a3e 100644 --- a/src/controllers/patient_group.ts +++ b/src/controllers/patient_group.ts @@ -336,4 +336,28 @@ export class PatientGroupController { return ReturnHelper.errorResponse(res, 500, 402, Language.lang.failed_restore, err.message); } } + + static async detail(req: Request, res: Response, next: NextFunction): Promise { + /* + #swagger.tags = ['PatientGroup'] + #swagger.security = [{ "bearerAuth": [] }] + #swagger.parameters['id'] = { description: '', in: 'path', type: 'string' } + */ + try { + const schema = Joi.object().keys({ + id: Joi.string().uuid().required().label("Patient Group Id"), + }); + + let param: any = await schema.validateAsync(req.params); + + let data = await PatientGroupModel.list({ "id": param.id }).then((q) => q.getOne()); + if (!data) throw { message: "Patient Group Not Found" }; + + return ReturnHelper.successResponseAny(res, 200, Language.lang.success_view, data); + } catch (e: unknown) { + log.error(e); + const err = e as Error; + return ReturnHelper.errorResponse(res, 400, 401, Language.lang.failed_not_found, err.message); + } + } } \ No newline at end of file diff --git a/src/controllers/patient_guarantor.ts b/src/controllers/patient_guarantor.ts index c4c0ffe..091d656 100644 --- a/src/controllers/patient_guarantor.ts +++ b/src/controllers/patient_guarantor.ts @@ -371,4 +371,28 @@ export class PatientGuarantorController { return ReturnHelper.errorResponse(res, 500, 402, Language.lang.failed_restore, err.message); } } + + static async detail(req: Request, res: Response, next: NextFunction): Promise { + /* + #swagger.tags = ['PatientGuarantor'] + #swagger.security = [{ "bearerAuth": [] }] + #swagger.parameters['id'] = { description: '', in: 'path', type: 'string' } + */ + try { + const schema = Joi.object().keys({ + id: Joi.string().uuid().required().label("Patient Guarantor Id"), + }); + + let param: any = await schema.validateAsync(req.params); + + let data = await PatientGuarantorModel.list({ "id": param.id }).then((q) => q.getOne()); + if (!data) throw { message: "Patient Guarantor Not Found" }; + + return ReturnHelper.successResponseAny(res, 200, Language.lang.success_view, data); + } catch (e: unknown) { + log.error(e); + const err = e as Error; + return ReturnHelper.errorResponse(res, 400, 401, Language.lang.failed_not_found, err.message); + } + } } \ No newline at end of file diff --git a/src/routes/private.ts b/src/routes/private.ts index a23a1aa..19230f2 100644 --- a/src/routes/private.ts +++ b/src/routes/private.ts @@ -403,6 +403,7 @@ export class RoutePrivate { app.put('/api/patient-group/update/:id', PatientGroupController.update) app.delete('/api/patient-group/delete/:id/:hard', PatientGroupController.delete) app.put('/api/patient-group/restore/:id', PatientGroupController.restore) + app.get('/api/patient-group/view/:id', PatientGuarantorController.detail) app.get('/api/patient-guarantor/list', PatientGuarantorController.list) app.get('/api/patient-guarantor/export', PatientGuarantorController.export) @@ -410,6 +411,7 @@ export class RoutePrivate { app.put('/api/patient-guarantor/update/:id', PatientGuarantorController.update) app.delete('/api/patient-guarantor/delete/:id/:hard', PatientGuarantorController.delete) app.put('/api/patient-guarantor/restore/:id', PatientGuarantorController.restore) + app.get('/api/patient-guarantor/view/:id', PatientGuarantorController.detail) app.get('/api/refferal-hospital/list', RefferalHospitalController.list) app.get('/api/refferal-hospital/export', RefferalHospitalController.export)