package com.gnx.telemedicine.mappers;

import com.gnx.telemedicine.dto.patient_safety.CriticalResultResponseDto;
import com.gnx.telemedicine.model.CriticalResult;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

@Mapper(componentModel = "spring")
public interface CriticalResultMapper {
    
    @Mapping(target = "labResultId", source = "labResult.id")
    @Mapping(target = "patientId", source = "patient.id")
    @Mapping(target = "patientName", expression = "java(result.getPatient().getUser().getFirstName() + \" \" + result.getPatient().getUser().getLastName())")
    @Mapping(target = "doctorId", source = "doctor.id")
    @Mapping(target = "doctorName", expression = "java(result.getDoctor().getUser().getFirstName() + \" \" + result.getDoctor().getUser().getLastName())")
    @Mapping(target = "acknowledgedById", source = "acknowledgedBy.id")
    @Mapping(target = "acknowledgedByName", expression = "java(result.getAcknowledgedBy() != null ? result.getAcknowledgedBy().getFirstName() + \" \" + result.getAcknowledgedBy().getLastName() : null)")
    CriticalResultResponseDto toCriticalResultResponseDto(CriticalResult result);
}

