/*
* ClientLocal.java
*
* Created on 28 Ноябрь 2007 г., 10:51
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package clips.delegate.client;
import beans.cec.entity.CommitteeDetails;
import cli_fmw.delegate.cache.ExtraDataManager;
import cli_fmw.delegate.directory.complex.DirectoryKladrItem;
import clips.doctor.newEMC.init.generic.ChildrenCacheListener;
import clips.delegate.doctor.EmcLocal;
import beans.service.create.CreateServiceBean;
import beans.service.create.CreateServiceBeanRemote;
import beans.service.create.NewServicesChunk;
import beans.service.create.ServiceContractPriceChunk;
import beans.user.client.ClientBeanRemote;
import clips.delegate.contract.PolisData;
import clips.delegate.contract.ServiceContractPriceData;
import cli_fmw.delegate.directory.complex.DirectoryLocator;
import clips.delegate.directory.complex.DirectoryPacketTemplateItem;
import clips.delegate.directory.complex.DirectoryVidalItem;
import clips.delegate.directory.filtered.DirectoryMatter;
import clips.delegate.directory.filtered.DirectoryMatterItem;
import clips.delegate.directory.filtered.DirectoryService;
import clips.delegate.directory.filtered.DirectoryServiceItem;
import clips.delegate.doctor.RecommendationLocal;
import clips.delegate.doctor.certificate.CertificateLocal;
import clips.delegate.doctor.contraindication.ContraindicationLocal;
import clips.delegate.doctor.diagnosis.DiagnosisLocal;
import clips.delegate.doctor.direction.DirectionLocal;
import clips.delegate.doctor.prescription.PrescriptionLocal;
import clips.delegate.doctor.sicklist.SicklistLocal;
import cli_fmw.delegate.SharedBean;
import cli_fmw.delegate.cache.DelegateSecondaryCacheDgt;
import cli_fmw.delegate.cache.DelegateExtraDataRO;
import cli_fmw.delegate.cache.DelegateExtraData;
import cli_fmw.delegate.client.ClientLocalAbstract;
import clips.delegate.job.JobLocal;
import clips.delegate.service.SerRenLocal;
import clips.delegate.service.discount.DiscountCardLocal;
import framework.beans.ModificationInfo;
import framework.generic.ClipsServerException;
import framework.utils.Converter;
import cli_fmw.utils.SelectorEditable;
import beans.contract.entity.PolisDetails;
import beans.discount.entity.DiscountCardDetails;
import cli_fmw.delegate.cache.SecondaryCacheManager;
import cli_fmw.delegate.client.Address;
import cli_fmw.delegate.utils.TimeLocal;
import beans.doctor.certificate.CertificateDetails;
import beans.doctor.contraindication.ContraindicationDetails;
import beans.doctor.diagnosis.DiagnosisDetails;
import beans.doctor.direction.DirectionDetails;
import beans.doctor.prescription.PrescriptionDetails;
import beans.service.ServiceRenderDetails;
import beans.doctor.sicklist.entity.SicklistDetails;
import beans.user.job.entity.JobDetails;
import cli_fmw.main.ClipsException;
import cli_fmw.main.DirectoryItemReplacedException;
import cli_fmw.report.CombinedReportCreator;
import cli_fmw.report.FormReportCreator;
import cli_fmw.utils.SelectorEditableExceptional;
import clips.delegate.contract.ContractLocal;
import clips.delegate.directory.complex.DirectoryEnterprise;
import clips.delegate.directory.complex.DirectoryEnterpriseItem;
import clips.delegate.directory.complex.DirectoryMKB10Item;
import clips.delegate.directory.simple.appointment.DirectoryAppointmentItem;
import clips.delegate.directory.simple.bloodGroup.DirectoryBloodGroup;
import clips.delegate.directory.simple.bloodGroup.DirectoryBloodGroupItem;
import clips.delegate.directory.simple.diagnosisEncounter.DirectoryDiagnosisEncounter;
import clips.delegate.directory.simple.diagnosisEncounter.DirectoryDiagnosisEncounterItem;
import clips.delegate.directory.complex.DirectoryDistrict;
import clips.delegate.directory.complex.DirectoryDistrictItem;
import clips.delegate.directory.simple.name.DirectoryNameItem;
import clips.delegate.directory.simple.pathron.DirectoryPathronItem;
import clips.delegate.directory.simple.profession.DirectoryProfessionItem;
import clips.delegate.directory.simple.sex.DirectorySexItem;
import clips.delegate.directory.simple.socialStatus.DirectorySocialStatus;
import clips.delegate.directory.simple.socialStatus.DirectorySocialStatusItem;
import clips.delegate.directory.simple.surname.DirectorySurnameItem;
import clips.delegate.directory.simple.userGroup.DirectoryUserGroup;
import clips.delegate.directory.simple.userGroup.DirectoryUserGroupItem;
import clips.doctor.newEMC.init.generic.ChildrenListStateless;
import clips.doctor.newEMC.init.generic.DelegateNodeInterface;
import clips.login.UserInfo;
import beans.doctor.diagnosis.Diagnosis;
import beans.doctor.prescriptiondlo.PrescriptionDloDetails;
import beans.doctor.recommendation.RecommendationDetails;
import beans.user.client.ClientBean;
import beans.user.client.entity.ClientDetails;
import beans.user.client.facilityClient.FacilityClientChunk;
import cli_fmw.delegate.AuditListener;
import clips.delegate.directory.simple.exemptionType.DirectoryExcemptionItem;
import clips.delegate.directory.simple.representativeStatus.DirectoryRepresentativeStatus;
import clips.delegate.directory.simple.representativeStatus.DirectoryRepresentativeStatusItem;
import clips.delegate.doctor.prescriptiondlo.PrescriptionDloLocal;
import clips.delegate.kek.CommitteeLocal;
import framework.beans.client.clientDocument.ClientDocumentDetails;
import framework.beans.directory.simple.entities.Sex;
import framework.utils.DateTimeUtils;
import framework.utils.ROList;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Делегат - клиент (персона) включая его адрес
* @author Администратор
*/
public class ClientLocal extends
ClientLocalAbstract<ClientBeanRemote, ClientDetails,
DirectorySurnameItem,
DirectoryNameItem,
DirectoryPathronItem,
DirectorySexItem>
implements DelegateNodeInterface<EmcLocal>{
private JobCache jobs = new JobCache(getEDM());
private DiscountCardCache discountCards = new DiscountCardCache(getEDM());
private EMCCache emc = new EMCCache(getEDM());
private PolisOMS polisOMS = new PolisOMS(getEDM());
private PolisListCache polisList = new PolisListCache(getEDM());
private ServiceRenderNotInDiseaseCache resultSetOutofDisease = new ServiceRenderNotInDiseaseCache(getEDM());
private ClientDocumentCache documentInfo = new ClientDocumentCache(getEDM());
private SharedBean<CreateServiceBeanRemote> createServiceBean =
new SharedBean<CreateServiceBeanRemote>(CreateServiceBean.class.getSimpleName());
private CertificateCache certificateList = new CertificateCache(getEDM());
private SicklistCache sicklistList = new SicklistCache(getEDM());
private ExemptionCache exemption = new ExemptionCache(getEDM());
private MotherCache motherInfo = new MotherCache(getSCM()); //мать
private FatherCache fatherInfo = new FatherCache(getSCM()); //отец
private RepresentativeCache representativeInfo = new RepresentativeCache(getSCM()); //представитель
@Override
public void addChild(EmcLocal child) throws ClipsException {
}
@Override
public void addChildrenListener(ChildrenCacheListener listener) {
}
@Override
public int getChildCount() throws ClipsException {
return getEMC() != null ? 1 : 0;
}
@Override
public void removeChild(EmcLocal child) throws ClipsException {
}
@Override
public void removeChildrenListener(ChildrenCacheListener listener) {
}
@Override
public ROList<EmcLocal> getChildren() throws ClipsException {
ArrayList<EmcLocal> list = new ArrayList<EmcLocal>();
if (getChildCount() > 0){
list.add(getEMC());
}
return new ROList<EmcLocal>(list);
}
private class CertificateCache extends ChildrenListStateless<CertificateLocal, CertificateDetails>{
public CertificateCache(ExtraDataManager contaner) {
super(contaner);
}
@Override
protected CertificateLocal createDelegate(CertificateDetails d) throws Exception {
return new CertificateLocal(d, ClientLocal.this, getAuditListener());
}
@Override
protected List<CertificateDetails> initDetails() throws Exception {
return getBean().getCertificateList();
}
}
class SicklistCache extends ChildrenListStateless<SicklistLocal, SicklistDetails>{
public SicklistCache(ExtraDataManager contaner) {
super(contaner);
}
@Override
protected SicklistLocal createDelegate(SicklistDetails d) throws Exception {
return new SicklistLocal(d, ClientLocal.this, getAuditListener());
}
@Override
protected List<SicklistDetails> initDetails() throws Exception {
return getBean().getSicklistList();
}
}
/**
* Кеш матери
*/
private class MotherCache extends DelegateSecondaryCacheDgt<ClientLocal> {
public MotherCache(SecondaryCacheManager contaner) throws ClipsException {
super(contaner, true, "информацию о матери");
}
@Override
protected ClientLocal init() throws Exception {
if(getDetails().motherId != 0) {
return new ClientLocal(getDetails().motherId, getAuditListener());
}
return null;
}
@Override
protected void setPrimary(ClientLocal type) throws ClipsException {
if(type == null) {
getDetails().motherId = 0;
} else {
getDetails().motherId = type.getID();
}
}
}
/**
* Кеш отца
*/
private class FatherCache extends DelegateSecondaryCacheDgt<ClientLocal> {
public FatherCache(SecondaryCacheManager contaner) throws ClipsException {
super(contaner, true, "информацию об отце");
}
@Override
protected ClientLocal init() throws Exception {
if(getDetails().fatherId != 0) {
return new ClientLocal(getDetails().fatherId, getAuditListener());
}
return null;
}
@Override
protected void setPrimary(ClientLocal type) throws ClipsException {
if(type == null) {
getDetails().fatherId = 0;
} else {
getDetails().fatherId = type.getID();
}
}
}
/**
* Кеш представителя пациента
*/
private class RepresentativeCache extends DelegateSecondaryCacheDgt<ClientLocal> {
public RepresentativeCache(SecondaryCacheManager contaner) throws ClipsException {
super(contaner, true, "информацию о представителе пациента");
}
@Override
protected ClientLocal init() throws Exception {
if(getDetails().representativeId != 0) {
return new ClientLocal(getDetails().representativeId, getAuditListener());
}
return null;
}
@Override
protected void setPrimary(ClientLocal representative) throws ClipsException {
if(representative == null) {
getDetails().representativeId = 0;
} else {
getDetails().representativeId = representative.getID();
}
}
}
/**
* Кеш полиса
*/
private class PolisOMS extends DelegateExtraData<PolisData> {
public PolisOMS(ExtraDataManager contaner) {
super(contaner);
}
@Override
protected PolisData init() throws Exception {
PolisDetails polisOMI = getBean().getPolisOMI();
if (polisOMI != null) {
ContractLocal contract = new ContractLocal(polisOMI.contractID, getAuditListener());
return new PolisData(contract, ClientLocal.this, polisOMI);
} else {
return null;
}
}
@Override
protected void saveDB() throws Exception {
ModificationInfo info = getBean().setPolisOMI(polisOMS.get() != null ? polisOMS.get().getDetails() : null);
auditDetailsList.addAll(info.getAudit());
fireAuditEvent();
clearCache();
}
@Override
protected PolisData initNew() {
return null;
}
}
/**
* Кеш ЕМС
*/
private class EMCCache extends DelegateExtraDataRO<EmcLocal> {
public EMCCache(ExtraDataManager contaner) {
super(contaner);
}
@Override
protected EmcLocal init() throws Exception {
return new EmcLocal(ClientLocal.this, getBean().getEmc(), getAuditListener());
}
@Override
protected EmcLocal initNew() {
return null;
}
}
/**
* Кеш работ
*/
class JobCache extends DelegateExtraDataRO<List<JobLocal>> {
public JobCache(ExtraDataManager contaner) {
super(contaner);
}
@Override
protected List<JobLocal> init() throws Exception {
List<JobLocal> jobList = new ArrayList<JobLocal>();
for(JobDetails d : getBean().getJobList()) {
jobList.add(new JobLocal(d, getAuditListener()));
}
return jobList;
}
@Override
protected List<JobLocal> initNew() {
return new ArrayList<JobLocal>();
}
}
/**
* Кеш дисконтных карт
*/
class DiscountCardCache extends DelegateExtraDataRO<List<DiscountCardLocal>> {
public DiscountCardCache(ExtraDataManager contaner) {
super(contaner);
}
@Override
protected List<DiscountCardLocal> init() throws Exception {
List<DiscountCardDetails> cards = getBean().getDiscountCards();
List<DiscountCardLocal> tempList = new ArrayList<DiscountCardLocal>();
for (int i = 0; i < cards.size(); i++) {
DiscountCardLocal card = new DiscountCardLocal(cards.get(i), getAuditListener());
tempList.add(card);
}
return tempList;
}
@Override
protected List<DiscountCardLocal> initNew() {
return new ArrayList<DiscountCardLocal>();
}
}
class ClientDocumentCache extends DelegateExtraData<ClientDocumentData> {
public ClientDocumentCache(ExtraDataManager contaner) {
super(contaner);
}
@Override
protected ClientDocumentData init() throws Exception {
return new ClientDocumentData(ClientLocal.this, getBean().getClientDocument());
}
@Override
protected void saveDB() throws Exception {
ModificationInfo mi = getBean().setClientDocument(get().getDetails());
auditDetailsList.addAll(mi.getAudit());
fireAuditEvent();
if (inCache()){
get().commit();
}
}
@Override
public boolean isDirty() {
if (inCache()){
try{
return get().isDirty();
}catch(Exception ex){
ex.printStackTrace();
return false;
}
}else{
return super.isDirty();
}
}
@Override
public void restore() {
clearCache();
}
@Override
protected ClientDocumentData initNew() {
return new ClientDocumentData(getEDM(), new ClientDocumentDetails());
}
}
/**
* Дефолтовый конструктор для создания новых клиентов.
* Инициализируются детали и кеши
*/
public ClientLocal(AuditListener al) throws ClipsException {
super(al);
}
/**
* Конструктор для инициализации по идентификтатору.
* Загрузка деталей отложенная.
* @param id идентифкатор клиента
*/
public ClientLocal(int id, AuditListener al) throws ClipsException {
super(id, al);
}
/**
* @param details детали клиента
*/
public ClientLocal(ClientDetails details, AuditListener al) throws ClipsException {
super(details, al);
}
@Override
protected ClientDetails getNewDetails() {
return new ClientDetails();
}
public String getKeyword() throws ClipsException {
return getDetails().keyword;
}
public void setKeyword(String password) throws ClipsException {
if (password == null || password.trim().equals("")) {
getDetails().keyword = null;
} else {
getDetails().keyword = password;
}
fireContentStateEvent();
}
public String getSocialСardCode() throws ClipsException {
return getDetails().socialCardCode;
}
public void setSocialСardCode(String socialCardCode) throws ClipsException {
if (socialCardCode == null || socialCardCode.trim().equals("")) {
getDetails().socialCardCode = null;
} else {
getDetails().socialCardCode = socialCardCode;
}
fireContentStateEvent();
}
public DirectoryUserGroupItem getUsergroup() throws ClipsException {
DirectoryUserGroup groupList = DirectoryLocator.getDirectory(DirectoryUserGroup.class);
try {
return groupList.getItemFromID(getDetails().userGroupId);
} catch (DirectoryItemReplacedException ex) {
reload();
return groupList.getItemFromID(getDetails().userGroupId);
}
}
public void setUsergroup(DirectoryUserGroupItem userGroup) throws ClipsException {
getDetails().userGroupId = userGroup.getID();
fireContentStateEvent();
}
public DirectoryBloodGroupItem getBloodGroup() throws ClipsException {
DirectoryBloodGroup groupList = DirectoryLocator.getDirectory(DirectoryBloodGroup.class);
return groupList.getItemFromID(getDetails().bloodGroupId);
}
public void setRepresStatus(DirectoryRepresentativeStatusItem item) throws ClipsException {
getDetails().representativeStatusId = item.getID();
fireContentStateEvent();
}
public DirectoryRepresentativeStatusItem getRepresStatus() throws ClipsException {
DirectoryRepresentativeStatus dir =
DirectoryLocator.getDirectory(DirectoryRepresentativeStatus.class);
return dir.getItemFromID(getDetails().representativeStatusId);
}
public void setBloodGroup(DirectoryBloodGroupItem bloodGroup) throws ClipsException {
getDetails().bloodGroupId = bloodGroup.getID();
fireContentStateEvent();
}
public DirectorySocialStatusItem getSocialStatus() throws ClipsException {
DirectorySocialStatus statusList = DirectoryLocator.getDirectory(DirectorySocialStatus.class);
try {
return statusList.getItemFromID(getDetails().socialStatusId);
} catch (DirectoryItemReplacedException ex) {
reload();
return statusList.getItemFromID(getDetails().socialStatusId);
}
}
public void setSocialStatus(DirectorySocialStatusItem socialStatus) throws ClipsException {
getDetails().socialStatusId = socialStatus.getID();
fireContentStateEvent();
}
public void setFather(ClientLocal father) throws ClipsException {
fatherInfo.set(father);
fireContentStateEvent();
}
public ClientLocal getFather() throws ClipsException {
return fatherInfo.get();
}
public ClientLocal getMother() throws ClipsException {
return motherInfo.get();
}
public void setMother(ClientLocal mother) throws ClipsException {
motherInfo.set(mother);
fireContentStateEvent();
}
public ClientLocal getRepresentative() throws ClipsException {
return representativeInfo.get();
}
public void setRepresentative(ClientLocal mother) throws ClipsException {
representativeInfo.set(mother);
fireContentStateEvent();
}
public void addDiscountCardToCache(DiscountCardLocal card) throws ClipsException{
discountCards.get().add(card);
}
public List<DiscountCardLocal> getDiscountCards() throws ClipsException {
return discountCards.get();
}
public DirectoryDistrictItem getDistrict() throws ClipsException {
DirectoryDistrict districts = DirectoryLocator.getDirectory(DirectoryDistrict.class);
return districts.getItemFromID(getDetails().districtId);
}
public void setDistrict(DirectoryDistrictItem district) throws ClipsException {
getDetails().districtId = district.getID();
fireContentStateEvent();
}
public ClientDocumentData getClientDocument() throws ClipsException {
return documentInfo.get();
}
public void setClientDocument(ClientDocumentData doc) throws ClipsException {
documentInfo.set(doc);
fireContentStateEvent();
}
/**
* @return список направлений клиента
* @throws ClipsException
*/
public List<DirectionLocal> getDirectionList() throws ClipsException {
List<DirectionLocal> directionLocals = new ArrayList<DirectionLocal>();
try {
List<DirectionDetails> list = getBean().getDirectionList();
for(DirectionDetails d : list) {
SerRenLocal serRen = new SerRenLocal(d.serviceRenderID, getAuditListener());
DirectionLocal dir = new DirectionLocal(d, serRen, getAuditListener());
directionLocals.add(dir);
}
} catch (Exception ex) {
clearBean();
throw new ClipsException("Не удалось загрузить список направлений пациента",ex);
}
return directionLocals;
}
/**
* @return список справок клиента
* @throws ClipsException
*/
public List<CertificateLocal> getCertificateList() throws ClipsException {
return certificateList.get();
}
/**
* @return список непереносимостей клиента
* @throws ClipsException
*/
public List<ContraindicationLocal> getContraindicationList() throws ClipsException {
List<ContraindicationLocal> res = new ArrayList<ContraindicationLocal>();
try {
List<ContraindicationDetails> list = getBean().getContraindicationList();
for(ContraindicationDetails d : list) {
SerRenLocal serRen = new SerRenLocal(d.serviceRenderID, getAuditListener());
res.add(new ContraindicationLocal(d, serRen, getAuditListener()));
}
} catch (Exception ex) {
clearBean();
throw new ClipsException("Не удалось загрузить список диагнозов",ex);
}
return res;
}
/**
* @return список диагнозов клиента (исключая сопутствующие)
* @throws ClipsException
*/
public List<DiagnosisLocal> getDiagnosisList() throws ClipsException {
List<DiagnosisLocal> diagnosisLocals = new ArrayList<DiagnosisLocal>();
try {
List<DiagnosisDetails> list = getBean().getDiagnosisList();
for(DiagnosisDetails d : list) {
SerRenLocal serRen = new SerRenLocal(d.serviceRenderID, getAuditListener());
DiagnosisLocal diagnosisLocal = new DiagnosisLocal(d, serRen, getAuditListener());
diagnosisLocals.add(diagnosisLocal);
}
} catch (Exception ex) {
clearBean();
throw new ClipsException("Не удалось загрузить список диагнозов",ex);
}
return diagnosisLocals;
}
/**
* @return список диагнозов клиента (включая сопутствующие)
* Если diseaseID != 0 то вернет только диагнозы из заболевания
* @throws ClipsException
*/
public List<DiagnosisLocal> getFullDiagnosisList(int diseaseID) throws ClipsException {
List<DiagnosisLocal> res = new ArrayList<DiagnosisLocal>();
try {
List<DiagnosisDetails> list = getBean().getFullDiagnosisList(diseaseID);
for (int i = 0; i < list.size(); i++) {
DiagnosisDetails dd = list.get(i);
SerRenLocal serren = new SerRenLocal(dd.serviceRenderID, getAuditListener());
DiagnosisLocal diagnosisLocal = new DiagnosisLocal(dd, serren, getAuditListener());
res.add(diagnosisLocal);
}
} catch (ClipsServerException ex) {
clearBean();
throw new ClipsException("Не удалось загрузить список диагнозов",ex);
}
return res;
}
/**
* @return список назначений клиента
*/
public List<PrescriptionLocal> getPrescriptionList() throws ClipsException {
List<PrescriptionLocal> prescriptionLocals = new ArrayList<PrescriptionLocal>();
try {
List<PrescriptionDetails> list = getBean().getPrescriptionList();
for(PrescriptionDetails d : list) {
SerRenLocal serRen = new SerRenLocal(d.serviceRenderID, getAuditListener());
PrescriptionLocal prescriptionLocal = new PrescriptionLocal(d, serRen, getAuditListener());
prescriptionLocals.add(prescriptionLocal);
}
} catch (Exception ex) {
clearBean();
throw new ClipsException("Не удалось загрузить список выписанных назначений",ex);
}
return prescriptionLocals;
}
/**
* @return список льготных рецептов
*/
public List<PrescriptionDloLocal> getPrescriptionDloList() throws ClipsException {
List<PrescriptionDloLocal> prescriptions = new ArrayList<PrescriptionDloLocal>();
try {
List<PrescriptionDloDetails> list = getBean().getPrescriptionDloList();
for(PrescriptionDloDetails d : list) {
SerRenLocal serRen = new SerRenLocal(d.serviceRenderID, getAuditListener());
PrescriptionDloLocal prescription = new PrescriptionDloLocal(d, serRen, getAuditListener());
prescriptions.add(prescription);
}
} catch (Exception ex) {
clearBean();
throw new ClipsException("Не удалось загрузить список выписанных льготных рецептов",ex);
}
return prescriptions;
}
/**
* @return список рекомендаций
* @throws cli_fmw.main.ClipsException
*/
public List<RecommendationLocal> getRecommedationList() throws ClipsException {
List<RecommendationLocal> recommendationLocals = new ArrayList<RecommendationLocal>();
try {
List<RecommendationDetails> list = getBean().getRecommedationList();
for(RecommendationDetails d : list) {
SerRenLocal serRen = new SerRenLocal(d.serviceRenderID, getAuditListener());
RecommendationLocal recommendationLocal = new RecommendationLocal(d, serRen, getAuditListener());
recommendationLocals.add(recommendationLocal);
}
} catch (Exception ex) {
clearBean();
throw new ClipsException("Не удалось загрузить список рекомендаций",ex);
}
return recommendationLocals;
}
/**
* @return список больничных клиента
* @throws ClipsException
*/
public List<SicklistLocal> getSicklistList() throws ClipsException {
return sicklistList.get();
}
/**
* @return список больничных клиента в текущем году
* @throws ClipsException
*/
public ArrayList<SicklistLocal> getSicklistsInCurrentYear() throws ClipsException {
ArrayList<SicklistLocal> sicklistLocals = new ArrayList<SicklistLocal>();
try {
List<SicklistDetails> list = getBean().getSicklistsInCurrentYear();
for(SicklistDetails d : list) {
SicklistLocal sicklistLocal = new SicklistLocal(d, this, getAuditListener());
sicklistLocals.add(sicklistLocal);
}
} catch (Exception ex) {
clearBean();
throw new ClipsException("Не удалось загрузить список больничных листов",ex);
}
return sicklistLocals;
}
/**
* Выдает Фамилию �?мя Отчество
* @return
*/
@Override
public String toString() {
try {
return getSurname() + " " + getName() + " " + getPathron();
} catch (ClipsException ex) {
ex.printStackTrace();
return "Не найдено в справочнике";
}
}
/**
* Конвертирует данные в формат Html
* @return
*/
public String toHtml() throws ClipsException {
String html = "<HTML>";
html += String.format("<P><FONT COLOR=BLUE SIZE=+1>%s %s %s</FONT></P>", getSurname(), getName(), getPathron());
html += String.format("<P><FONT COLOR=BLACK ><U>номер ЭМК:</U> <FONT COLOR=GREEN>%s</FONT></P>", getNumberEmc());
if (hasRightNSU()) {
html += "<P><FONT COLOR=BLACK ><U>Пациент обладает правом на ДЛО</U></P>";
}
try {
List<ContraindicationLocal> contraindicationList = getContraindicationList();
if (contraindicationList.size() > 0) {
html += "<P><FONT COLOR=RED> <u>Непереносимость действующих веществ</u></FONT>";
html += "<ul COLOR=RED>";
for (int i = 0; i < contraindicationList.size(); i++) {
ContraindicationLocal contraindicationLocal = contraindicationList.get(i);
html += "<li><FONT COLOR=RED >"+ contraindicationLocal.getMatter().getTitle() +"</FONT></li>";
}
html += "</ul></P>";
}
} catch (ClipsException ex) {
html += "<P><FONT COLOR=BLACK>Не доступна информация о противопоказаниях пациента</FONT></P>";
}
if (getUsergroup().getID() != 0) {
html += String.format("<P><FONT COLOR=BLACK SIZE=+0><U>группа:</U> <FONT COLOR=GREEN>%s</FONT></P>", getUsergroup());
}
html += String.format("<P><FONT COLOR=BLACK ><U>пол:</U> <FONT COLOR=GREEN>%s</FONT></P>", getSex());
if (getBorn() != null) {
html += "<P><FONT COLOR=BLACK ><U>дата рождения:</U> <FONT COLOR=GREEN>" +
Converter.dateToString(getDetails().born) + "</FONT></P>";
}
ClientDocumentData docData = getClientDocument();
String docDataS = docData.toString();
html += String.format("<P><FONT COLOR=BLACK ><U>документ:</U> <FONT COLOR=GREEN>%s</FONT></P>", docDataS);
PolisData polis = getPolisOMS();
String sPolis;
if (polis != null) {
sPolis = polis.getSeries() + " " + polis.getNumber();
} else {
sPolis = "отсутствует";
}
html += String.format("<P><FONT COLOR=BLACK ><U>полис ОМС:</U> <FONT COLOR=GREEN>%s</FONT></P>", sPolis);
html += String.format("<P><FONT COLOR=BLACK ><U>СНИЛС:</U> <FONT COLOR=GREEN>%s</FONT></P>", getSnils());
if (getMother() != null) {
html += String.format("<P><FONT COLOR=BLACK ><U>мать:</U> <FONT COLOR=GREEN>%s</FONT></P>", getMother().toString());
}
if (getFather() != null) {
html += String.format("<P><FONT COLOR=BLACK <U>отец:</U> <FONT COLOR=GREEN>%s</FONT></P>", getFather().toString());
}
if (getAddress() != null) {
html += String.format("<P><FONT COLOR=BLACK ><U>адрес</U><BR><FONT COLOR=GREEN>%s</FONT></P>", getAddress());
}
if (getDetails().remarks != null &&
!getDetails().remarks.equals("")) {
html += String.format("<P><FONT COLOR=BLACK ><U>примечания</U><BR><FONT COLOR=GREEN>%s</FONT></P>", getDetails().remarks);
}
if (getDetails().email != null &&
!getDetails().email.equals("")) {
html += String.format("<P><FONT COLOR=BLACK ><U>e-mail:</U> <FONT COLOR=GREEN>%s</FONT></P>", getDetails().email);
}
if (getDetails().telephones != null &&
!getDetails().telephones.equals("")) {
html += String.format("<P><FONT COLOR=BLACK ><U>телефоны:</U> <FONT COLOR=GREEN>%s</FONT></P>", getDetails().telephones);
}
return html + "</HTML>";
}
/**
* Возвращает ЕМЦ, соответствующую персоне. Связь 1:1
* @return
* @throws ClipsException
*/
public EmcLocal getEMC() throws ClipsException {
return emc.get();
}
public void print(CombinedReportCreator cCreator) throws ClipsException {
FormReportCreator creater = cCreator.createFormReporter(getClass(), 1);
HashMap<String, Object> extraFields = getPrintFields();
creater.createReport(null, null, extraFields.entrySet(), null);
creater.finish();
}
public HashMap<String, Object> getPrintFields() throws ClipsException {
HashMap<String, Object> extraFields = new HashMap<String, Object>();
if (getNumberEmc() != null) {
extraFields.put("emc_code", getNumberEmc());
}
PolisData polis = getPolisOMS();
if (polis != null) {
String insurer = getPolisOMS().getInsurer().getTitle();
String number = getPolisOMS().getSeries() + " " + getPolisOMS().getNumber();
extraFields.put("insurer_title", insurer);
extraFields.put("polis_number", number);
}
ClientExemptionData exempData = getExemption();
if (exempData != null) {
DirectoryExcemptionItem exemp = exempData.getExemption();
if (exemp != null && exemp.getID() != 0) {
extraFields.put("exemption_code", exemp.getExtKey());
}
extraFields.put("exemption_document", exempData.docDataToString());
}
String snils = getSnils();
if (snils != null) {
extraFields.put("pacient_snils", snils);
}
extraFields.put("pacient_surname", getSurname().getTitle());
extraFields.put("pacient_name", getName().getTitle());
extraFields.put("pacient_pathron", getPathron().getTitle());
extraFields.put("pacient_sex", getSex().getID() == Sex.CLIENT_SEX_MALE ? 1 : 2);
extraFields.put("pacient_BD", BornToString());
Address address = getAddress();
if (address != null) {
extraFields.put("address_region", address.getRegionTitle());
extraFields.put("address_district", address.getMunicipalityTitle());
extraFields.put("address_city", address.getCityTitle());
extraFields.put("address_street", address.getStreetTitle());
extraFields.put("building_number", Converter.getBuildingNumber(address.getBuilding()));
extraFields.put("building_corps", Converter.getBuildingCorpus(address.getBuilding()));
extraFields.put("flat_number", address.getFlat() == null ? "" : address.getFlat());
}
if (getTelephones() != null) {
extraFields.put("pacient_phones", getTelephones());
}
ArrayList<String> jobDates = new ArrayList<String>();
ArrayList<String> jobEnterprises = new ArrayList<String>();
DirectoryEnterpriseItem ent;
Date date;
String entData;
for (JobLocal job : getJobList()) {
ent = job.getEnterprise();
entData = "";
if (ent != null && ent.getID() != 0) {
entData += ent.getTitle();
Address ad = ent.getAddress();
if (address != null) {
entData += " " + ad.toStringShort();
}
}
jobEnterprises.add(entData);
date = job.getBegin();
jobDates.add(Converter.dateToString(date, "dd.MM.yy"));
}
extraFields.put("job_dates", jobDates);
extraFields.put("job_enterprises", jobEnterprises);
JobLocal jobLocal = getLastJob();
if (jobLocal != null) {
DirectoryEnterpriseItem enter = jobLocal.getEnterprise();
DirectoryProfessionItem prof = jobLocal.getProfession();
DirectoryAppointmentItem app = jobLocal.getAppointment();
extraFields.put("job_enterprise", enter != null && enter.getID() != 0 ? enter.getTitle() : "");
extraFields.put("job_profession", prof != null && prof.getID() != 0 ? prof.getTitle() : "");
extraFields.put("job_appointment", app != null && app.getID() != 0 ? app.getTitle() : "");
//todo поле иждивенец откуда брать?
}
extraFields.put("followups", getEMC().getFollowUps());
DirectoryBloodGroupItem bloodGroup = getBloodGroup();
if (bloodGroup != null && bloodGroup.getID() != 0) {
extraFields.put("blood_group", bloodGroup.getTitle());
}
List<ContraindicationLocal> cls = getContraindicationList();
if (!cls.isEmpty()) {
extraFields.put("contraindication_0", cls.get(0).getMatter().getTitle());
if(cls.size() > 1) {
extraFields.put("contraindication_1", cls.get(1).getMatter().getTitle());
if(cls.size() > 2) {
extraFields.put("contraindication_2", cls.get(2).getMatter().getTitle());
}
}
}
return extraFields;
}
public List<SerRenLocal> getSerRenListByToday() throws ClipsException {
GregorianCalendar currentTime = TimeLocal.getCurrentTime();
Date begin = DateTimeUtils.getDateOnly(currentTime.getTime());
currentTime.add(Calendar.DAY_OF_YEAR, 1);
Date end = DateTimeUtils.getDateOnly(currentTime.getTime());
return getSerRenList(begin, end, null);
}
/**
* Возвращает итератор списка услуг из указанного диапазона дат
* и закрепленных и не закрепленных, назначенных в заданном промежутке дат.
* Присутствует фильтр по контракту
* если contract == null то по любому контракту
* @param begin
* @param end
* @param contract
* @return
* @throws ClipsException
*/
public List<SerRenLocal> getSerRenList(Date begin, Date end, ContractLocal contract) throws ClipsException {
try {
int contractID = contract == null ? 0 : contract.getID();
List<ServiceRenderDetails> renderDetailsList = getBean().getServiceRenders(begin, end, contractID);
List<SerRenLocal> items = new ArrayList<SerRenLocal>();
for (int i = 0; i < renderDetailsList.size(); i++) {
SerRenLocal serRen = new SerRenLocal(renderDetailsList.get(i), getAuditListener());
items.add(serRen);
}
return items;
} catch (Exception ex) {
clearBean();
throw new ClipsException("Не удалось загрузить список услуг",ex);
}
}
class ResultSetByDate implements SelectorEditable<SerRenLocal> {
ArrayList<SerRenLocal> items;
public ResultSetByDate(Date begin, Date end) throws ClipsException {
}
@Override
public void remove(int index) {
items.remove(index);
}
@Override
public void append(SerRenLocal newItem) {
items.add(newItem);
}
@Override
public int size() {
return items.size();
}
@Override
public SerRenLocal get(int index) {
return items.get(index);
}
@Override
public void remove(SerRenLocal element) {
throw new UnsupportedOperationException("Not supported yet.");
}
}
/**
* Возвращает список услуг, которые еще не оказаны, но и не отменены
* @return список услуг, возможно пустой
* @throws ClipsException
*/
public List<SerRenLocal> getSerRenListToRender() throws ClipsException {
List<SerRenLocal> items = new ArrayList<SerRenLocal>();
try {
List<ServiceRenderDetails> renderDetailsList = getBean().getServiceRendersToRender();
for (int i = 0; i < renderDetailsList.size(); i++) {
SerRenLocal serRen = new SerRenLocal(renderDetailsList.get(i), getAuditListener());
items.add(serRen);
}
} catch (Exception ex) {
clearBean();
throw new ClipsException("Не удалось загрузить список услуг",ex);
}
return items;
}
/**
* Возвращает итератор списка услуг не в заболевании
* @return
* @throws ClipsException
*/
public List<SerRenLocal> getSerRenListOutofDisease() throws ClipsException {
return resultSetOutofDisease.get();
}
public void clearSerRenListOutofDiseaseCache() {
resultSetOutofDisease.clearCache();
}
/**
* Возвращает список всех работ клиента и текущих и прошлых
* @return
* @throws ClipsException
*/
public List<JobLocal> getJobList() throws ClipsException {
return jobs.get();
}
/**
* Возвращает последнюю по дате приема работу клиента
* @return
* @throws ClipsException
*/
public JobLocal getLastJob() throws ClipsException {
try {
JobDetails jobDetails = getBean().getLastJob();
return (jobDetails != null ? new JobLocal(jobDetails, getAuditListener()) : null);
} catch (Exception ex) {
clearBean();
throw new ClipsException("Не удалось получить последнее место работы клиента",ex);
}
}
/**
* Возвращает полный список договормемберов клиента (в которых он фигурирует)
* @return
* @throws ClipsException
*/
public List<PolisData> getPolisList() throws ClipsException {
return polisList.get();
}
/**
* Номер полиса обязательного медицинского страхования
* @return
* @throws ClipsException
*/
public PolisData getPolisOMS() throws ClipsException {
return polisOMS.get();
}
/**
* Номер полиса обязательного медицинского страхования
* @param value
* @throws ClipsException
*/
public void setPolisOMS(PolisData value) throws ClipsException {
polisOMS.set(value);
}
public String getNumberEmc() throws ClipsException {
return getDetails().numberEmc;
}
public void setNumberEmc(String number) throws ClipsException {
if (number == null || number.equals("")) {
getDetails().numberEmc = null;
} else {
getDetails().numberEmc = number;
}
fireContentStateEvent();
}
/**
* На входе: список услуг которые собираются оказать клиенту и дисконтная карта
* На выходе: список возможных договоров, содержащих информацию о договоре, договормембере и
* о ценах и скидках на услуги, соответствующие данному договормемберу и дисконтной карте
* @param serviceList
* @param discountCard
* @param packetService
* @param speciality не нул, возможно нулевой итем
* @return не нул, возможно пустой список
* @throws ClipsException
*/
public ArrayList<ServiceContractPriceData> getServiceContractPriceDataList(
ArrayList<DirectoryServiceItem> serviceList, DiscountCardLocal discountCard,
DirectoryPacketTemplateItem packetService) throws ClipsException {
// получить чанк
ArrayList<Integer> services = new ArrayList<Integer>();
for (int i = 0; i < serviceList.size(); i++) {
services.add(serviceList.get(i).getID());
}
int discountCardID = discountCard == null ? 0 : discountCard.getID();
int packetServiceID = packetService == null ? 0 : packetService.getID();
ArrayList<ServiceContractPriceData> dataList = new ArrayList<ServiceContractPriceData>();
DirectoryEnterprise directoryEnterprise = DirectoryLocator.getDirectory(DirectoryEnterprise.class, false);
DirectoryService directoryService = DirectoryLocator.getDirectory(DirectoryService.class, false);
List<ServiceContractPriceChunk> chunkList;
try {
chunkList = createServiceBean.get().getServiceContractPriceInfo(getID(), services, discountCardID, packetServiceID);
} catch (Exception ex) {
try {
createServiceBean.clear();
chunkList = createServiceBean.get().getServiceContractPriceInfo(getID(), services, discountCardID, packetServiceID);
} catch (ClipsServerException ex1) {
throw new ClipsException("Не удалось загрузить цены по договору", ex1);
}
}
// преобразование чанка пришедшего с сервера в данные
//Log.printlnAnsPos("Получен ArrayList<ServiceContractPriceChunk>");
for (int i = 0; i < chunkList.size(); i++) {
ServiceContractPriceChunk chunk = chunkList.get(i);
String index = chunk.index;
String type = chunk.contractType;
String enterprise = directoryEnterprise.getItemFromID(chunk.enterpriseID).getTitle();
PolisDetails polisID = chunk.polisDetails;
HashMap<DirectoryServiceItem, Integer> priceMap = new HashMap<DirectoryServiceItem, Integer>();
HashMap<DirectoryServiceItem, Integer> moneyMap = new HashMap<DirectoryServiceItem, Integer>();
HashMap<DirectoryServiceItem, Integer> discountMap = new HashMap<DirectoryServiceItem, Integer>();
Iterator<Integer> it;
it = chunk.priceMap.keySet().iterator();
while (it.hasNext()) {
Integer serviseID = it.next();
DirectoryServiceItem service = directoryService.getItemFromID(serviseID);
priceMap.put(service, chunk.priceMap.get(serviseID));
moneyMap.put(service, chunk.moneyMap.get(serviseID));
discountMap.put(service, chunk.discountMap.get(serviseID));
}
ServiceContractPriceData scpd = new ServiceContractPriceData(index, type, enterprise, polisID, priceMap, moneyMap, discountMap);
dataList.add(scpd);
}
return dataList;
}
/**
* Назначение новых услуг
* @param chunk
* @param parentSerRen если не нул то назначение связанных услуг
* @return
* @throws cli_fmw.main.ClipsException
*/
public ModificationInfo directNewSerren(NewServicesChunk chunk, SerRenLocal parentSerRen) throws ClipsException {
try {
ModificationInfo mi;
if (parentSerRen == null) {
mi = createServiceBean.get().createNewServices(chunk);
} else {
mi = createServiceBean.get().createNewServices(chunk, parentSerRen.getID());
}
return mi;
} catch (Exception ex) {
createServiceBean.clear();
throw new ClipsException("Не удалось назначить услугу", ex);
}
}
public boolean isVidalBad(DirectoryVidalItem vidal) throws ClipsException{
DirectoryMatter directoryMatter = DirectoryLocator.getDirectory(DirectoryMatter.class, false);
List<ContraindicationLocal> contraList = getContraindicationList();
Set<Integer> matterIDSet = new HashSet<Integer>();
for (int i = 0; i < contraList.size(); i++) {
matterIDSet.add(contraList.get(i).getMatter().getID());
}
HashMap<DirectoryVidalItem, SelectorEditableExceptional<DirectoryMatterItem>> mapFiltered;
mapFiltered = new HashMap<DirectoryVidalItem, SelectorEditableExceptional<DirectoryMatterItem>>();
SelectorEditableExceptional<DirectoryMatterItem> s;
if (mapFiltered.get(vidal) == null) {
s = directoryMatter.getFilteredItems(vidal);
mapFiltered.put(vidal,s);
} else {
s = mapFiltered.get(vidal);
}
boolean contraFounded = false;
for (int i = 0; i < s.size(); i++) {
DirectoryMatterItem vMatterItem = s.get(i);
if (matterIDSet.contains(vMatterItem.getID())) {
contraFounded = true;
}
}
return contraFounded;
}
/**
* Вычисляет характер диагноза с данным заболеванием, на основе всех
* диагнозов данного пациента, исключая текущий диагноз (т.к. он в данный
* момент изменён)
* @param item
* @return
* @throws cli_fmw.main.ClipsException
*/
public DirectoryDiagnosisEncounterItem getAutocalculatedEncounter(DirectoryMKB10Item currentMKB, int currentDiseaseID) throws ClipsException {
/*
* Первый раз в жизни если дата последнего нулл
* Первый раз за год если дата последнего раньше текущего года
* Повторно за год если дата последнего позже текущего года
* Хронический если был хотя бы 1 хронический
*/
DirectoryDiagnosisEncounter directoryEncounter = DirectoryLocator.getDirectory(DirectoryDiagnosisEncounter.class);
return directoryEncounter.getItemFromID(0);
//TODO ПОКА УБРАЛ ТАК КАК ПЕРЕПИСАЛИ СПРАВОЧНИК
// DirectoryDiagnosisEncounter directoryEncounter = DirectoryLocator.getDirectory(DirectoryDiagnosisEncounter.class);
// if (currentMKB == null) {
// return directoryEncounter.getItemFromID(0);
// }
// List<DiseaseLocal> diseaseList = getEMC().getDiseaseList();
// Date lastDate = null;
// for (int i = 0; i < diseaseList.size(); i++) {
// DiseaseLocal diseaseLocal = diseaseList.get(i);
// if (diseaseLocal.getID() != currentDiseaseID) {
// //Пришлось очистить кеш диагноза, из-за проблем с кешированием
// diseaseLocal.clearDiagnosisCache();
// DiagnosisLocal specificDiagnosis = diseaseLocal.getSpecificDiagnosis();
// if (specificDiagnosis != null) {
// DirectoryMKB10Item mkb = specificDiagnosis.getMkb();
// if (mkb.getID() == currentMKB.getID() || mkb.isChild(currentMKB)) {
// //выявление хронического
// /*Если был хотя бы один хронический диагноз то он остается хроническим*/
// if (specificDiagnosis.getEncounter().getID() == DiagnosisEncounter.DIAGNOSIS_ENCOUNTER_CHRONIC) {
// return directoryEncounter.getItemFromID(DiagnosisEncounter.DIAGNOSIS_ENCOUNTER_CHRONIC);
// }
// //запоминать последнюю дату
// Date date = specificDiagnosis.getDate();
// if (lastDate == null || date.after(lastDate)) {
// lastDate = date;
// }
// }
// }
// }
// }
// //первый раз в жизни
// if (lastDate == null) {
// return directoryEncounter.getItemFromID(DiagnosisEncounter.DIAGNOSIS_ENCOUNTER_FIRST_TIME_IN_LIFE);
// }
//
// GregorianCalendar currentYear = TimeLocal.getCurrentTime();
// currentYear = new GregorianCalendar(currentYear.get(GregorianCalendar.YEAR), 0, 1);
// if (lastDate.before(currentYear.getTime())) {
// //первый раз за год
// return directoryEncounter.getItemFromID(DiagnosisEncounter.DIAGNOSIS_ENCOUNTER_FIRST_TIME_IN_YEAR);
// } else {
// //повторно в течение года
// return directoryEncounter.getItemFromID(DiagnosisEncounter.DIAGNOSIS_ENCOUNTER_REPEATEDLY_IN_YEAR);
// }
};
public Integer getDiagnosisCharacter(DirectoryMKB10Item curMkb, Date curDate) throws ClipsException {
List<DiagnosisLocal> fullList = getFullDiagnosisList(0);
Date lastDate = null;
for (DiagnosisLocal diag : fullList) {
DirectoryMKB10Item mkb = diag.getMkb();
if (mkb.getID() == curMkb.getID() || mkb.isChild(curMkb)) {
if (lastDate == null || lastDate.after(diag.getDate())) {
lastDate = diag.getDate();
}
}
}
GregorianCalendar currentYear = TimeLocal.getCurrentTime();
currentYear = new GregorianCalendar(currentYear.get(GregorianCalendar.YEAR), 0, 1);
if (lastDate == null || lastDate.after(currentYear.getTime())) {
return Diagnosis.DIAGNOSIS_CHARACTER_ACUTE;
}
else {
return Diagnosis.DIAGNOSIS_CHARACTER_EARLIER_SET;
}
}
@Override
public String getBeanName() {
return ClientBean.class.getSimpleName();
}
/**
* Кеш договор мемберов
*/
private class PolisListCache extends DelegateExtraDataRO<List<PolisData>> {
public PolisListCache(ExtraDataManager contaner) {
super(contaner);
}
@Override
protected List<PolisData> init() throws Exception {
boolean superUser = UserInfo.get().isSuperUser();
List<PolisData> list = new ArrayList<PolisData>();
for (PolisDetails d: getBean().getPolisList()) {
if (superUser || !d.trash) {
PolisData data = new PolisData(null, ClientLocal.this, d);
list.add(data);
}
}
return list;
}
@Override
protected List<PolisData> initNew() {
return new ArrayList<PolisData>();
}
}
private class ServiceRenderNotInDiseaseCache extends DelegateExtraDataRO<List<SerRenLocal>> {
public ServiceRenderNotInDiseaseCache(ExtraDataManager contaner) {
super(contaner);
}
@Override
protected List<SerRenLocal> init() throws Exception {
List<SerRenLocal> items = new ArrayList<SerRenLocal>();
for (ServiceRenderDetails d: getBean().getServiceRendersNotInDisease()) {
items.add(new SerRenLocal(d, getAuditListener()));
}
return items;
}
@Override
protected List<SerRenLocal> initNew() {
return new ArrayList<SerRenLocal>();
}
}
@Override
public void save1() throws ClipsException {
super.save1();
emc.clearCache();
}
/**
* Злая функция.
* Этот костыль следует пользовать осторожно
* при дополнительном кешировании емц, т.к. возможна подмена
*/
// public void clearEMCCache() {
// emc.clearCache();
// }
@Override
public boolean isDirty() {
return super.isDirty();
}
/**
* Возвращает список диагнозов, поставленных пациенту
* если в заболевании имеется заключительный диагноз, то предварительные диагнозы
* из этого заболевания в список не попадают
* @return
* @throws cli_fmw.main.ClipsException
*/
public ArrayList<DiagnosisLocal> getLastDiagnosis() throws ClipsException {
try {
ArrayList<DiagnosisDetails> dList = getBean().getLastDiagnosis();
ArrayList<DiagnosisLocal> target = new ArrayList<DiagnosisLocal>(dList.size());
for (DiagnosisDetails dd : dList) {
target.add(new DiagnosisLocal(dd, new SerRenLocal(dd.getServiceRenderID(), getAuditListener()), getAuditListener()));
}
return target;
} catch (Exception ex) {
clearBean();
throw new ClipsException("Не удалось получить список диагнозов", ex);
}
}
/**
* Возвращает список диагнозов, поставленных пациенту
* если в заболевании имеется заключительный диагноз, то предварительные диагнозы
* из этого заболевания в список не попадают
* @return
* @throws cli_fmw.main.ClipsException
*/
public ArrayList<CommitteeLocal> getCommittees() throws ClipsException {
try {
ArrayList<CommitteeDetails> cList = getBean().getClientCommittees();
ArrayList<CommitteeLocal> target = new ArrayList<CommitteeLocal>(cList.size());
for (CommitteeDetails cd : cList) {
target.add(new CommitteeLocal(cd, getAuditListener()));
}
return target;
} catch (Exception ex) {
clearBean();
throw new ClipsException("Не удалось получить список диагнозов", ex);
}
}
private class ExemptionCache extends DelegateExtraDataRO<ClientExemptionData> {
public ExemptionCache(ExtraDataManager contaner) {
super(contaner);
}
@Override
protected ClientExemptionData init() throws Exception {
FacilityClientChunk chunk = getBean().getClientExemption();
return chunk != null ? new ClientExemptionData(chunk) : null;
}
@Override
protected ClientExemptionData initNew() {
return null;
}
}
public ClientExemptionData getExemption() throws ClipsException {
return exemption.get();
}
public boolean hasRightNSU() throws ClipsException {
ClientExemptionData exemp = getExemption();
if (exemp == null) {
return false;
}
return exemp.hasRightNSU();
}
public DirectoryDistrictItem getDefaultDistrict(Address address) throws ClipsException {
try {
DirectoryKladrItem street = address.getStreet();
DirectoryDistrict dir = DirectoryLocator.getDirectory(DirectoryDistrict.class);
if (street != null && street.getID() != 0) {
int id = getBean().getDefaultDistrict(street.getID(), address.getBuilding());
if (id != 0) {
return dir.getItemFromID(id);
}
}
return dir.getNullItem();
} catch (ClipsServerException ex) {
clearBean();
throw new ClipsException("Ну удалось найти терапевтический участок", ex);
}
}
}