+ "AND c1.pathronymic.id = c2.pathronymic.id "
+ "AND c1.born = c2.born ";
Query query = manager.createQuery(sql);
List<Client> res = query.getResultList();
for (int i = 0; i < res.size(); i++) {
Client c1 = res.get(i);
pacients.put(c1.getId(), c1);
}
ArrayList<Client> pacientsA = new ArrayList<Client>(pacients.values());
HashMap<ClientUniq, ArrayList<Client>> pacientsMap = new HashMap<ClientUniq, ArrayList<Client>>();
for (int i = 0; i < pacientsA.size(); i++) {
Client c = pacientsA.get(i);
ClientDetails det = c.getDetails(this);
ClientUniq p =
new ClientUniq(det.surnameId, det.nameId, det.pathronId, det.born);
ArrayList<Client> clA = pacientsMap.get(p);
if (clA == null) {
clA = new ArrayList<Client>();
}
clA.add(c);
pacientsMap.put(p, clA);
}
ArrayList<AuditDetails> auditDetailsList = new ArrayList<AuditDetails>();
Iterator<ArrayList<Client>> pacientsI = pacientsMap.values().iterator();
while (pacientsI.hasNext()) {
ArrayList<Client> array = pacientsI.next();
Client dst = array.get(0);
System.out.println("***************************************************************************");
System.out.println("ПАЦИЕНТ ГЛАВНЫЙ " + dst.getId() + " " + dst.getFio());
for (int i = 1; i < array.size(); i++) {
Client src = array.get(i);
System.out.println(" ПАЦИЕНТ " + src.getId() + " " + src.getFio());
AuditDetails unionCollab = unionCollab(dst, src);
if (unionCollab != null) {
auditDetailsList.add(unionCollab);
}
auditDetailsList.addAll(unionEMC(dst, src));