package com.gnx.telemedicine.mappers;

import com.gnx.telemedicine.dto.appointment.AppointmentRequestDto;
import com.gnx.telemedicine.dto.appointment.AppointmentResponseDto;
import com.gnx.telemedicine.model.Appointment;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

@Mapper(componentModel = "spring")
public interface AppointmentMapper {
    Appointment toAppointment(AppointmentRequestDto appointmentRequestDto);

    @Mapping(target = "id", source = "id")
    @Mapping(target = "patientId", source = "patient.id", nullValuePropertyMappingStrategy = org.mapstruct.NullValuePropertyMappingStrategy.IGNORE)
    @Mapping(target = "patientFirstName", source = "patient.user.firstName")
    @Mapping(target = "patientLastName", source = "patient.user.lastName")
    @Mapping(target = "doctorId", source = "doctor.id", nullValuePropertyMappingStrategy = org.mapstruct.NullValuePropertyMappingStrategy.IGNORE)
    @Mapping(target = "doctorFirstName", source = "doctor.user.firstName")
    @Mapping(target = "doctorLastName", source = "doctor.user.lastName")
    AppointmentResponseDto toAppointmentResponseDto(Appointment appointment);
}
