Skip to content

Commit

Permalink
mapper problem solved
Browse files Browse the repository at this point in the history
  • Loading branch information
lizzmedina committed Sep 17, 2024
1 parent ff24897 commit e3b0cc4
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ public ComplementaryStudy toEntity(StudyRequest dto){
study.setStudyCost(dto.studyCost());

if (dto.consultationId() != null) {
ConsultationEntity consultation = consultationRepository.findById(dto.consultationId().get())
ConsultationEntity consultation = consultationRepository.findById(dto.consultationId())
.orElseThrow(() -> new EntityNotFoundException("Consulta no encontrada con ID: " + dto.consultationId()));
study.setConsultation(consultation);
}

if (dto.diagnosisId() != null) {
DiagnosticEntity diagnosis = diagnosticEntityRepository.findById(dto.diagnosisId().get())
DiagnosticEntity diagnosis = diagnosticEntityRepository.findById(dto.diagnosisId())
.orElseThrow(() -> new EntityNotFoundException("Diagnóstico no encontrado con ID: " + dto.diagnosisId()));
study.setDiagnosis(diagnosis);
}

if (dto.hospitalizationId() != null) {
Hospitalization hospitalization = hospitalizationRepository.findById(dto.hospitalizationId().get())
Hospitalization hospitalization = hospitalizationRepository.findById(dto.hospitalizationId())
.orElseThrow(() -> new EntityNotFoundException("Hospitalización no encontrada con ID: " + dto.hospitalizationId()));
study.setHospitalization(hospitalization);
}
Expand All @@ -56,11 +56,11 @@ public StudyRequest toDto(ComplementaryStudy entity) {
entity.getStudyType(),
Optional.ofNullable(entity.getStudyResult()),
entity.getStudyState(),
Optional.ofNullable(entity.getStudyFile()),
entity.getStudyFile(),
entity.getStudyCost(),
Optional.ofNullable(entity.getDiagnosis() != null ? entity.getDiagnosis().getId() : null),
Optional.ofNullable(entity.getConsultation() != null ? entity.getConsultation().getId() : null),
Optional.ofNullable(entity.getHospitalization() != null ? entity.getHospitalization().getId() : null)
entity.getDiagnosis().getId(),
entity.getConsultation().getId(),
entity.getHospitalization().getId()
);
}

Expand Down

0 comments on commit e3b0cc4

Please sign in to comment.