collabList = new ArrayList<CollaboratorLocal>();
DirectoryCollaborator dir = DirectoryLocator.getDirectory(DirectoryCollaborator.class);
DirectoryLpuItem lpu = UserInfo.get().getCollaborator().getLpu();
List<DirectoryCollaboratorItem> items = dir.getItemsFiltered(lpu, true, false, false);
for (int i = 0; i < items.size(); i++) {
CollaboratorLocal collab = new CollaboratorLocal(items.get(i).getID(), null);//NULL AL
collabList.add(collab);
}
}
for (int i = 0; i < collabList.size(); i++) {
CollaboratorLocal collab = collabList.get(i);
SelectorEditable<CollaboratorFunctionsChunk> functions = collab.getFunctions();
CollaboratorFunctionsChunk foundedByExtKey = null;
for (int j = 0; j < functions.size(); j++) {
CollaboratorFunctionsChunk cfc = functions.get(j);
if (cfc.getExtKey() != null && cfc.getExtKey().equals(extkey)) {
foundedByExtKey = cfc;
}
if (foundedByExtKey != null
&& foundedByExtKey.getFirstMedicalAid() != null
&& foundedByExtKey.getFirstMedicalAid().getExtKey() != null
&& foundedByExtKey.getFirstMedicalAid().getExtKey().equals(vmu)) {
return foundedByExtKey;
}
}
if (foundedByExtKey != null) {
//По внешнему ключу нашли, по типу первичной помощи надо создать
CollaboratorFunctionsDetails d = new CollaboratorFunctionsDetails();
d.collaboratorID = collab.getID();
d.dvrID = foundedByExtKey.getDvr().getID();
d.firstMedicalAidID = dirVmu.getItemFromExtKey(vmu).getID();
d.receptionTypeID = foundedByExtKey.getReceptionType().getID();
d.specialityID = foundedByExtKey.getSpeciality().getID();
d.external_key = foundedByExtKey.getExtKey();
CollaboratorFunctionsChunk collFunc = new CollaboratorFunctionsChunk(collab, d);
collab.getFunctions().append(collFunc);
try {
collab.save1();
} catch (ClipsException ex) {
collab.clearBean();
collab.save1();
}
return collFunc;
}
}
return null;