String clinicType = UserInfo.get().getCollaborator().getLpu().getClinicType().getExtKey().trim();
ArrayList<DirectoryCollaboratorFunctionsItem> availableFunctions = new ArrayList<DirectoryCollaboratorFunctionsItem>();
DirectoryCollaboratorItem collaborator = UserInfo.get().getCollaborator();
DirectoryCollaboratorFunctions dcf = DirectoryLocator.getDirectory(DirectoryCollaboratorFunctions.class);
Selector<DirectoryCollaboratorFunctionsItem> functions = dcf.getFilteredItems(collaborator);
DirectorySpecialityItem spec = serRenLocal.getSpeciality();
DirectoryReceptionTypeItem recType = null;
if (serRenLocal.getContractService() != null
&& serRenLocal.getContractService().getReceptionType() != null
&& !serRenLocal.getContractService().getReceptionType().isNullItem()) {
recType = serRenLocal.getContractService().getReceptionType();
}
for (int i = 0; i < functions.size(); i++) {
boolean validRecType = recType == null || recType.getID() == 0 || functions.get(i).getReceptionType().equals(recType);
boolean validSpec = spec == null || spec.getID() == 0 || functions.get(i).getSpeciality().equals(spec);
if (validRecType && validSpec) {
if (functions.get(i).getReceptionType().getExtKey().trim().startsWith(clinicType)) {
availableFunctions.add(functions.get(i));
}
}