public PatientWs generateRemotePatient(Patient patient) throws ExceptionDAO {
if (patient == null) {
return null;
}
PatientWs patientWs = new PatientWs();
patientWs.setName(patient.getName());
patientWs.setSurname(patient.getSurname());
patientWs.setAddress(patient.getAddress());
patientWs.setCellphone(patient.getCellphone());
patientWs.setCity(patient.getCity());
patientWs.setEmail(patient.getEmail());
patientWs.setTelephone(patient.getTelephone());
patientWs.setSex(("M".equals(patient.getSex()) || "m".equals(patient.getSex())));
patientWs.setBirthdate(this.dateToXMLGregorianCalendar(patient.getBirthdate()));
patientWs.setIdentityCard(this.convertToRemoteIdentityCard(patient.getIdentityCard()));
patientWs.setHabits(this.convertToRemoteHabits(patient.getHabitPatient()));
patientWs.setProfessionId(this.convertToRemoteProfession(patient.getProfession()));
if (patient.getSportsPatient() != null) {
Iterator<SportPatient> sports = patient.getSportsPatient().iterator();
while (sports.hasNext()) {
PatientSportWs patientSportWs = this.convertToRemoteSportPatient(sports.next());
if (patientSportWs != null) {
patientWs.getSports().add(patientSportWs);
}
}
}
if (patient.getMedicinesPatient() != null) {
Iterator<MedicinePatient> medicines = patient.getMedicinesPatient().iterator();
while (medicines.hasNext()) {
PatientMedicineWs patientMedicineWs = this.convertToRemoteMedicinePatient(medicines.next());
if (patientMedicineWs != null) {
patientWs.getMedicines().add(patientMedicineWs);
}
}
}
if (patient.getFamilyPatientBackgrounds() != null) {
Iterator<FamilyPatientBackground> backgrounds = patient.getFamilyPatientBackgrounds().iterator();
while (backgrounds.hasNext()) {
PatientFamilyWs patientFamilyWs = this.convertToRemoteFamilyPatient(backgrounds.next());
if (patientFamilyWs != null) {
patientWs.getFamilyBackground().add(patientFamilyWs);
}
}
}
if (patient.getPathologiesPatient() != null) {
Iterator<PathologyPatient> patholiges = patient.getPathologiesPatient().iterator();
while (patholiges.hasNext()) {
PatientPathologyWs pathologyWs = this.convertToRemotePathologyPatient(patholiges.next());
if (pathologyWs != null) {
patientWs.getPathologies().add(pathologyWs);
}
}
}
if (patient.getSurgeriesPatient() != null) {
Iterator<SurgeryPatient> surgeries = patient.getSurgeriesPatient().iterator();
while (surgeries.hasNext()) {
PatientSurgeryWs patientSurgeryWs = this.convertToRemoteSurgeryPatient(surgeries.next());
if (patientSurgeryWs != null) {
patientWs.getSurgeries().add(patientSurgeryWs);
}
}
}
return patientWs;
}