import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
import { ClinicalNotesService } from './clinical-notes.service';
import { ClinicalNote } from './entities/clinical-note.entity';
import { ApiOperation, ApiProperty, ApiResponse, ApiTags } from '@nestjs/swagger';
import { ErrorResponse400, ErrorResponse500 } from 'src/appointment/entities/appointment.entity';


export class CreateClinicalNotesResponseDto {
  @ApiProperty({ example: 'success', description: 'The status of the response' })
  status: string;

  @ApiProperty({ example: 'Prescription added successfully', description: 'The message describing the result' })
  message: string;
}


export class GetclinicalNotesResponseDto {
  @ApiProperty({ example: 'Prescription....', description: 'The name of the record' })
  record_name: string;

  @ApiProperty({ example: '_6f07dad7-34e8-4c8f-b564-d27c69e218cf.jpeg_1709716024863', description: 'File name associated with the prescription' })
  files: string;

  @ApiProperty({ example: null, description: 'Tags associated with the prescription, can be null', nullable: true })
  tags: string | null;

  @ApiProperty({ example: 405, description: 'Hospital outpatient department ID' })
  hos_opd_id: number;

  @ApiProperty({ example: null, description: 'Doctor’s name, can be null', nullable: true })
  doctorName: string | null;

  @ApiProperty({ example: '12th Jul 2024,09:00 AM', description: 'The appointment date and time' })
  appointDate: string;
}

@ApiTags('clinical-notes')
@Controller('clinical_notes')
export class ClinicalNotesController {
  constructor(private readonly clinicalNotesService: ClinicalNotesService) {}

  @Post('/post')
  @ApiOperation({ summary: 'Create a new prescription' })
  @ApiResponse({
    status: 201,
    description: 'The prescription has been successfully created.',
    type: CreateClinicalNotesResponseDto,
  })
  @ApiResponse({
    status: 500,
    description: 'Internal server error',
    type: ErrorResponse500,
  })
  @ApiResponse({
    status: 400,
    description: 'Internal server error',
    type: ErrorResponse400,
  })
  create(@Body() createClinicalNoteDto: ClinicalNote) {
    return this.clinicalNotesService.create(createClinicalNoteDto);
  }

  @Post('/get')
  @ApiOperation({ summary: 'Retrieve all prescriptions' })
  @ApiResponse({
    status: 200,
    description: 'List of all prescriptions retrieved successfully.',
    type: [GetclinicalNotesResponseDto], // Indicates that the response is an array of Prescription objects
  })
  @ApiResponse({
    status: 500,
    description: 'Internal server error',
    type: ErrorResponse500,
  })
  @ApiResponse({
    status: 400,
    description: 'Internal server error',
    type: ErrorResponse400,
  })
  findAll(@Body() createClinicalNoteDto: ClinicalNote) {
    return this.clinicalNotesService.findAll(createClinicalNoteDto);
  }

}
