import {
  Controller,
  Get,
  Post,
  Body,
  Param,
  Delete,
  Patch,
  Query,
} from '@nestjs/common';
import { PhrAppointmentService } from './phr-appointment.service';
import {
  PhrAppointment,
  phrupdatepaymentdetails,
} from './entities/phr-appointment.entity';

@Controller('phr-appointment')
export class PhrAppointmentController {
  constructor(private readonly phrAppointmentService: PhrAppointmentService) {}

  @Post()
  create(@Body() createPhrAppointmentDto: PhrAppointment) {
    return this.phrAppointmentService.create(createPhrAppointmentDto);
  }

  @Get()
  findAll() {
    return this.phrAppointmentService.findAll();
  }

  @Get('/getOne/:id')
  findOne(@Param('id') id: string) {
    return this.phrAppointmentService.findOne(+id);
  }
  @Get('/getQR/:id')
  findQr(@Param('id') id: string) {
    return this.phrAppointmentService.findOneQR(id);
  }

  @Post(':id')
  update(
    @Param('id') id: string,
    @Body() updatePhrAppointmentDto: PhrAppointment,
  ) {
    return this.phrAppointmentService.update(+id, updatePhrAppointmentDto);
  }

  @Patch('/cancelAppointment/:id')
  updateCancelApp(
    @Param('id') id: string,
    @Body() updatePhrAppointmentDto: PhrAppointment,
  ) {
    return this.phrAppointmentService.updateCancelApp(
      +id,
      updatePhrAppointmentDto,
    );
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.phrAppointmentService.remove(+id);
  }

  @Post('/update/paymentdata')
  updatepaymentdetails(
    @Query('transaction_id') transaction_id: string,
    @Query('hospital_id') hospital_id: number,
    @Body() updatePhrAppointmentDto: phrupdatepaymentdetails,
  ) {
    return this.phrAppointmentService.updatepaymentdetails(
      transaction_id,
      hospital_id,
      updatePhrAppointmentDto,
    );
  }
}
