public Boolean updatePASAllergies(PatientRefVo patient,IfPatientAllergyVoCollection allergiesFromMsg) throws StaleObjectException { DomainFactory factory = getDomainFactory(); if(patient==null||allergiesFromMsg==null) //http://jira/browse/WDEV-17335 return null; List<PatientAllergy> currentAllergies = listPatientAllergies(patient, false); if(allergiesFromMsg.size()==0) //set all allergies that have PAS as sourrce of information set them to be not currently active { inactivatePASAllergies(currentAllergies,factory); } else { for (IfPatientAllergyVo msgAllergy : allergiesFromMsg) { PatientAllergy alle = getFromList(currentAllergies,msgAllergy); if(alle==null) { alle = IfPatientAllergyVoAssembler.extractPatientAllergy(factory, msgAllergy); alle.setPatient((Patient)factory.getDomainObject(Patient.class, patient.getID_Patient())); alle.setAllergenDescription(alle.getAllergen().getAllergenName()); factory.save(alle); } else if(alle.isIsCurrentlyActiveAllergy()==null //if it is null or different in the BO ||(alle.isIsCurrentlyActiveAllergy()!=null &&msgAllergy.getIsCurrentlyActiveAllergyIsNotNull() &&(!alle.isIsCurrentlyActiveAllergy().equals(msgAllergy.getIsCurrentlyActiveAllergy())))) { alle.setIsCurrentlyActiveAllergy(msgAllergy.getIsCurrentlyActiveAllergy()); factory.save(alle); } } updatePatientNoAllergyInfo(patient); //http://jira/browse/WDEV-17262 } return null; }