Skip to content

Commit

Permalink
fix(CC-119): fix controller output of appointment registry
Browse files Browse the repository at this point in the history
  • Loading branch information
luana-v-santos committed Apr 25, 2024
1 parent 6f92fd0 commit db4f78d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { IsString } from 'class-validator';
import { IsObject, IsString } from 'class-validator';
import { PatientAppointmentRegistryEntity } from '../../../../../core/domains/patient-appointment-registry/entities/registry/entity';

class UpdatedPatientAppointmentRegistryInfoOutputDto extends PatientAppointmentRegistryEntity{};
export class UpdatePatientAppointmentRegistryControllerOutputDto {
@IsString()
message!: string;

@IsObject({ each: true })
updatedPatientAppointmentRegistry!: UpdatedPatientAppointmentRegistryInfoOutputDto
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ export class UpdatePatientAppointmentRegistryController {
registry: Registry,
): Promise<UpdatePatientAppointmentRegistryControllerOutputDto> {
try {
await this.updatePatientAppointmentRegistryService.execute({ id, registry });
const updatedPatientAppointmentRegistry = await this.updatePatientAppointmentRegistryService.execute({ id, registry });

return { message: 'Appointment registry updated successfully' };
return { message: 'Appointment registry updated successfully', updatedPatientAppointmentRegistry };
} catch (error: unknown) {
throw new GlobalAppHttpException(error);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { plainToInstance } from 'class-transformer';
import { PATIENT_APPOINTMENT_REGISTRY_ERROR_MESSAGES } from '../../../../../shared/errors/error-messages';
import { applicationValidateOrReject } from '../../../../../shared/validators/validate-or-reject';
import { DataEncrypterService } from '../../../../shared/cryptography/use-cases/data-encrypter.service';
import { PatientAppointmentRegistryEntity } from '../../entities/registry/entity';
import { PatientAppointmentRegistryDatabaseRepository } from '../../repositories/database-repository';
import { UpdatePatientAppointmentRegistryInputDto } from './update-appointment-registry-dto';

Expand All @@ -15,7 +16,7 @@ export class UpdatePatientAppointmentRegistryService {

async execute(
updatePatientAppointmentRegistryDto: UpdatePatientAppointmentRegistryInputDto,
): Promise<void> {
): Promise<PatientAppointmentRegistryEntity> {
// Validate
const DeletePatientAppointmentRegistryDtoInstance = plainToInstance(
UpdatePatientAppointmentRegistryInputDto,
Expand All @@ -38,7 +39,7 @@ export class UpdatePatientAppointmentRegistryService {
updatePatientAppointmentRegistryDto.registry['observations'],
);

await this.patientAppointmentRegistryDatabaseRepository.updatePatientAppointmentRegistry(
return await this.patientAppointmentRegistryDatabaseRepository.updatePatientAppointmentRegistry(
{
...updatePatientAppointmentRegistryDto,
registry: {
Expand Down

0 comments on commit db4f78d

Please sign in to comment.