Spaces:
Running
Running
| import { | |
| Controller, | |
| Get, | |
| Post, | |
| Patch, | |
| Param, | |
| Body, | |
| UseGuards, | |
| Req, | |
| SetMetadata, | |
| } from "@nestjs/common"; | |
| import { Request } from "express"; | |
| import { ReferralsService, UpdateReferralDto } from "./referral.service"; | |
| import { CreateReferralDto } from "./dto/create-referral-dto"; | |
| import { JwtAuthGuard } from "../auth/guards/jwt-auth.guard"; | |
| import { RolesGuard } from "src/auth/guards/roles.guard"; | |
| const Roles = (...roles: string[]) => SetMetadata("roles", roles); | |
| ("health-worker/referrals") | |
| (JwtAuthGuard, RolesGuard) | |
| export class ReferralsController { | |
| constructor(private readonly referralsService: ReferralsService) {} | |
| /** POST /health-worker/referrals */ | |
| () | |
| ("FACILITY_ADMIN", "FACILITY_STAFF") | |
| create(() dto: CreateReferralDto, () req: Request & { user: any }) { | |
| const facilityId = req.user.healthcareWorker?.facilityId; | |
| return this.referralsService.create(dto, facilityId); | |
| } | |
| /** GET /health-worker/referrals */ | |
| () | |
| ("FACILITY_ADMIN", "FACILITY_STAFF") | |
| findAll(() req: Request & { user: any }) { | |
| const facilityId = req.user.healthcareWorker?.facilityId; | |
| return this.referralsService.findAll(facilityId); | |
| } | |
| /** GET /health-worker/referrals/stats */ | |
| ("stats") | |
| ("FACILITY_ADMIN", "FACILITY_STAFF") | |
| getStats(() req: Request & { user: any }) { | |
| const facilityId = req.user.healthcareWorker?.facilityId; | |
| return this.referralsService.getReferralStats(facilityId); | |
| } | |
| (":id") | |
| ("FACILITY_ADMIN", "FACILITY_STAFF") | |
| findOne(("id") id: string, () req: Request & { user: any }) { | |
| const facilityId = req.user.healthcareWorker?.facilityId; | |
| return this.referralsService.findOne(id, facilityId); | |
| } | |
| (":id/status") | |
| ("FACILITY_ADMIN", "FACILITY_STAFF") | |
| updateStatus(("id") id: string, () dto: UpdateReferralDto, () req: Request & { user: any }) { | |
| const facilityId = req.user.healthcareWorker?.facilityId; | |
| return this.referralsService.updateStatus(id, dto, facilityId); | |
| } | |
| } |