@Override public IPatient createNewPatient(IPatient patient) { Origin patientOrigin = (Origin) originService.getOriginById(patient.getOriginId()); Patient newPatient = PatientBuilder.builder() .name(patient.getName()) .surname(patient.getSurname()) .birthday(patient.getBirthday()) .phone(patient.getPhone()) .email(patient.getEmail()) .origin(patientOrigin) .build(); return patientDao.save(newPatient); }
private Patient getPatient(final Long id) { return patientDao.get(id); }
@Override public IPatient updatePatient(final Long id, IPatient patient) { Patient patientToUpdate = this.getPatient(id); BeanUtils.copyProperties(patient, patientToUpdate, "id"); return patientDao.save(patientToUpdate); }