protected void onUpdate(Lpu entity, EntityDetails details,
AuditDoc auditDoc, List<AuditDoc> auditDocList)
throws ClipsServerException {
LpuDetails d = (LpuDetails) details;
Lpu lpu = entity;
if (details.getId() != 0) {
//Проверка на модификацию только своей клиники
Collaborator collab = findEntity(Collaborator.class, getCollaboratorId());
if (collab.getLpu().getId() != lpu.getId()
&& RightPresence(UserRightsSet.WRITE_REGION_ADMIN_DIRECTORY.id) < 0) {
throw new ESecurity(SecurityChecker.getClientHasNoRightMsg(UserRightsSet.WRITE_REGION_ADMIN_DIRECTORY.id));
}
}
lpu.setTitle(d.title);
lpu.setTitleShort(d.title_short);
if (d.lpuCode == null) {
throw new ClipsServerException("Не указан код ЛПУ в кодировке ТФОМС");
}
lpu.setLpuCode(d.lpuCode);
if (d.ogrn == null) {
throw new ClipsServerException("Не указан ОГРН код ЛПУ");
}
lpu.setOgrn(d.ogrn);
if (d.chiefDoctor == 0) {
throw new ClipsServerException("Не указан главврач ЛПУ");
}
lpu.setChiefDoctor(findEntity(Collaborator.class, d.chiefDoctor));
if (d.accountant == 0) {
throw new ClipsServerException("Не указан бухгалтер ЛПУ");
}
lpu.setAccountant(findEntity(Collaborator.class, d.accountant));
if (d.clinicType == 0) {
throw new ClipsServerException("Не указан тип ЛПУ");
}
if (d.insurer == 0) {
throw new ClipsServerException("Не указана страховая компания по умолчанию");
}
if (d.subdivisionCode == null) {
throw new ClipsServerException("Не указан код подразделение ЛПУ");
}
if (d.branch == null) {
throw new ClipsServerException("Не указан код филиала РФОМС");
}
lpu.setPhone(d.phone == null ? "" : d.phone);
lpu.setFax(d.fax == null ? "" : d.fax);
lpu.setEmail(d.email == null ? "" : d.email);
lpu.setOkpo(d.okpo == null ? "" : d.okpo);
lpu.setOkonh(d.okonh == null ? "" : d.okonh);
lpu.setOkved(d.okved == null ? "" : d.okved);
lpu.setOkogu(d.okogu == null ? "" : d.okogu);
lpu.setOkopf(d.okopf == null ? "" : d.okopf);
lpu.setOkfc(d.okfc == null ? "" : d.okfc);
lpu.setClinicType(findEntity(ClinicType.class, d.clinicType));
lpu.setInsurer(findEntity(Insurer.class, d.insurer));
lpu.setSubdivisionCode(d.subdivisionCode);
lpu.setBranch(d.branch);
Address address = lpu.getAddress();
AddressDetails ad = d.addressDetails;
if (ad != null && ad.objectId != 0) {
if (address == null){
address = new Address();
}
address.setAddressObject(findEntity(AddressObject.class, ad.objectId));
address.setBuilding(ad.building);
address.setFlat(ad.flat);
saveEntity(address);
lpu.setAddress(address);
}else{
throw new EDataIntegrity("Не указан адрес");
}
}