}
}
}
PacketService packetService = null;
Medexam medexam = null;
//если присутствует пакет
if (chunk.packetServiceTemplateID != 0) {
packetService = new PacketService();
PacketTemplate packetTemplate = findEntity(PacketTemplate.class, chunk.packetServiceTemplateID);
packetService.setPacketTemplate(packetTemplate);
saveEntity(packetService);
MedexamType medexamType = packetTemplate.getMedexamType();
if (medexamType != null) {
//не просто пакет, а медосмотр
if (chunk.diseaseID != 0) {
throw new EDataIntegrity("Для медосмотра необходимо создать новое заболевание");
}
//создаем заболевание и медосмотр
disease = new Disease();
List<Emc> emcList = findEntityList(Emc.class, "client", polis.getClient());
if (emcList.size() != 1) {
throw new EDataIntegrity("У пациента " + emcList.size() + " ЕМК");
}
disease.setEmc(emcList.get(0));
Date current = new Date();
disease.setCreated(current);
disease.setDateReg(current);
disease.setCollaborator(collaborator);
manager.persist(disease);
manager.flush();
manager.refresh(disease);
chunk.diseaseID = disease.getId();
medexam = new Medexam();
medexam.setDisease(disease);
medexam.setMedexamType(medexamType);
manager.persist(medexam);
}
}
uniqMap = new HashMap<Integer, Set<Integer>>();
for (int i = 0; i < chunk.serviceList.size(); i++) {