import { param, get, getModelSchemaRef, requestBody, patch, } from '@loopback/rest'; import { CONTENT_TYPE, ErrorCodes, STATUS_CODE, SuccessResponse, } from '@sourcefuse-npm/alivio-lib'; import {authenticate, STRATEGY} from 'loopback4-authentication'; import {authorize} from 'loopback4-authorization'; import {MoodFactorLogsService} from '../services'; import {inject} from '@loopback/core'; import {PendingTaksAlerts} from '../models'; const pedingTasksPath='pending-tasks'; export class PendingTasksController { constructor( @inject('services.MoodFactorLogsService') protected patientService: MoodFactorLogsService, ) {} @authenticate(STRATEGY.BEARER, { passReqToCallback: true, }) @authorize({permissions: ['*']}) @get(`${pedingTasksPath}`, { responses: { [STATUS_CODE.NO_CONTENT]: { description: 'Get Follow up alerts', content: { [CONTENT_TYPE.JSON]: {schema: getModelSchemaRef(PendingTaksAlerts)}, }, }, ...ErrorCodes, }, }) async getFollowupAlerts( @param.header.string('Authorization') token?: string, ): Promise { return this.patientService.getPendingTasksAlerts(token); } @authenticate(STRATEGY.BEARER, { passReqToCallback: true, }) @authorize({permissions: ['*']}) @patch(`${pedingTasksPath}/{id}/status`, { responses: { [STATUS_CODE.NO_CONTENT]: { description: 'update Followup Alerts', content: { [CONTENT_TYPE.JSON]: {schema: getModelSchemaRef(PendingTaksAlerts)}, }, }, ...ErrorCodes, }, }) async updateFollowupAlerts( @param.path.number('id') id: number, @requestBody({ content: { [CONTENT_TYPE.JSON]: { schema: getModelSchemaRef(PendingTaksAlerts), }, }, }) pendingTasks: Omit, @param.header.string('Authorization') token?: string, ): Promise { this.patientService.updatePendingTasksAlerts(id, pendingTasks,token); return new SuccessResponse({ success: true, }); } }