public AnalysisWs generateRemoteAnalysis(Analysis analysis) throws ExceptionDAO {
if (analysis == null) {
return null;
}
AnalysisWs analysisWs = new AnalysisWs();
PatientRemote patientRemote = FacadeDB.getInstance().getPatientSyncBroker().getPatientRemoteByPatient(analysis.getPatient());
if (patientRemote == null) {
return null;
}
analysisWs.setPatientId(patientRemote.getRemoteId());
if (analysis.getMedic() != null) {
MedicRemote medicRemote = FacadeDB.getInstance().getMedicSyncBroker().getMedicRemoteByMedic(analysis.getMedic());
analysisWs.setMedicId(medicRemote.getRemoteId());
}
SignalFrequencyRemote frequencyRemote = FacadeDB.getInstance().getSignalFrequencySyncBroker().getFrequencyRemoteBySignalFrequency(analysis.getSignalFrequency());
if (frequencyRemote == null) {
return null;
}
analysisWs.setSignalFrequencyId(frequencyRemote.getRemoteId());
ClinicalInfoRemote clinicalInfoRemote = FacadeDB.getInstance().getClinicalInfoSyncBroker().getClinicalInfoRemoteByClinicalInfo(analysis.getClinicalInformation());
if (clinicalInfoRemote == null) {
return null;
}
analysisWs.setClinicalInfoId(clinicalInfoRemote.getRemoteId());
analysisWs.setDate(this.dateToXMLGregorianCalendar(analysis.getAnalysisDay()));
analysisWs.setRawSignal(this.convertToRemoteRawSignal(analysis.getRawSignal(), analysis));
analysisWs.setReport(this.convertToRemoteReport(analysis.getReport()));
analysisWs.setResult(this.convetToRemoteAnalysisResult(analysis.getAnalysisResult()));
analysisWs.setFinalSignal(this.convertToRemoteFinalSignal(analysis.getFinalSegment()));
Iterator<SelectedSegment> segments = analysis.getSelectedSegments().iterator();
while (segments.hasNext()) {
SelectedSegmentWs selectedSegmentWs = this.convetToRemoteSelectedSegments(segments.next());
if (selectedSegmentWs != null) {
analysisWs.getSelectedSegments().add(selectedSegmentWs);
}
}
return analysisWs;
}