/*
* PanelClientInfo.java
*
* Created on 6 Декабрь 2007 г., 23:13
*/
package clips.userseach;
import beans.contract.entity.Polis;
import cli_fmw.delegate.directory.DirectoryItemRO;
import clips.userseach.clientExcemption.PanelClientExcemption;
import cli_fmw.address.DialogAddressM;
import clips.delegate.directory.complex.DirectoryDistrictItem;
import clips.delegate.directory.simple.sex.DirectorySexItem;
import clips.delegate.directory.simple.socialStatus.DirectorySocialStatusItem;
import framework.utils.FormatChecker;
import cli_fmw.main.PageContainer;
import clips.delegate.client.ClientLocal;
import cli_fmw.delegate.DelegateLine2;
import cli_fmw.delegate.client.Address;
import cli_fmw.delegate.directory.complex.DirectoryLocator;
import cli_fmw.delegate.utils.TimeLocal;
import clips.job.PanelJobList;
import cli_fmw.utils.EmptyDialog;
import cli_fmw.utils.ModalDialog;
import cli_fmw.main.ClipsException;
import cli_fmw.main.CheckableDocListener;
import cli_fmw.main.ContentStateListener;
import cli_fmw.main.Lockable;
import cli_fmw.main.MainWindow;
import cli_fmw.main.OpenCloseSensitive;
import cli_fmw.main.PageException;
import cli_fmw.main.PageGeneric;
import cli_fmw.main.Persistentable;
import cli_fmw.main.Printable;
import cli_fmw.report.CombinedReportCreator;
import cli_fmw.report.CombinedReportOptions;
import cli_fmw.report.PageOptions.PageOrentation;
import cli_fmw.report.ReporterFactory;
import cli_fmw.report.panels.model.DirectoryObjectComboBoxModel;
import cli_fmw.report.panels.model.ObjectContainer;
import cli_fmw.report.panels.model.delegate.DelegateComboboxModel;
import cli_fmw.report.panels.model.delegate.DelegateTextModel;
import cli_fmw.report.panels.model.delegate.DirectorySimpleFilteredComboBoxModel;
import clips.service.discount.card.PanelClientDiscountCard;
import cli_fmw.utils.MessageBox;
import cli_fmw.utils.delegate_models.DelegateDateModel;
import cli_fmw.utils.table_config_states.StateSaver;
import clips.delegate.config.ConfigLocal;
import clips.delegate.contract.ContractLocal;
import clips.delegate.contract.PolisData;
import clips.delegate.directory.simple.bloodGroup.DirectoryBloodGroup;
import clips.delegate.directory.simple.bloodGroup.DirectoryBloodGroupItem;
import clips.delegate.directory.simple.clientDocumentType.DirectoryDocumentType;
import clips.delegate.directory.simple.clientDocumentType.DirectoryDocumentTypeItem;
import clips.delegate.directory.complex.DirectoryDistrict;
import clips.delegate.directory.ro.DirectoryLpu;
import clips.delegate.directory.ro.DirectoryLpuItem;
import clips.delegate.directory.simple.documentGivenPlace.DirectoryDocumentGivenPlace;
import clips.delegate.directory.simple.documentGivenPlace.DirectoryDocumentGivenPlaceItem;
import clips.delegate.directory.simple.insurer.DirectoryInsurerItem;
import clips.delegate.directory.simple.name.DirectoryName;
import clips.delegate.directory.simple.name.DirectoryNameItem;
import clips.delegate.directory.simple.pathron.DirectoryPathron;
import clips.delegate.directory.simple.pathron.DirectoryPathronItem;
import clips.delegate.directory.simple.representativeStatus.DirectoryRepresentativeStatus;
import clips.delegate.directory.simple.representativeStatus.DirectoryRepresentativeStatusItem;
import clips.delegate.directory.simple.sex.DirectorySex;
import clips.delegate.directory.simple.socialStatus.DirectorySocialStatus;
import clips.delegate.directory.simple.surname.DirectorySurname;
import clips.delegate.directory.simple.surname.DirectorySurnameItem;
import clips.delegate.directory.simple.userGroup.DirectoryUserGroup;
import clips.delegate.directory.simple.userGroup.DirectoryUserGroupItem;
import clips.login.UserInfo;
import clips.main.AppMainWindow;
import clips.main.UserPanelsEnum;
import framework.utils.DateTimeUtils;
import framework.utils.ROList;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import javax.smartcardio.CardException;
import javax.swing.DefaultComboBoxModel;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import org.infotechservice.smartcard.service.SmartCardServer;
import org.infotechservice.smartcard.smartcard.NewSocialCardListener;
/**
*
* @author Администратор
*/
public class PanelClientEdit extends PageGeneric implements OpenCloseSensitive, Persistentable, Lockable, Printable , ContentStateListener {
private ClientLocal clientLocal;
// private ClientDocumentData clDocData;
//запомню все модели, чтоб потом деаттачить листенеры
private ArrayList<ObjectContainer> autoModels = new ArrayList<ObjectContainer>();
private DirectoryRepresentativeStatus dir = DirectoryLocator.getDirectory(DirectoryRepresentativeStatus.class);
private DirectoryLpuItem selectedLpu;
/** Creates new form PanelClientInfo
* @param container
* @param myClientLocal
* @throws ClipsException
*/
public PanelClientEdit(PageContainer container, DelegateLine2 myClientLocal) throws ClipsException {
super(container);
initComponents();
btContract.addActionListener(MainWindow.mainWindow.getPanelListeners(UserPanelsEnum.PANEL_PanelContractList));
btService.addActionListener(MainWindow.mainWindow.getPanelListeners(UserPanelsEnum.PANEL_PanelSerrenList));
this.clientLocal = (ClientLocal) myClientLocal;
this.clientLocal.addContentStateListener(this);
// clDocData = clientLocal.getClientDocument();
//Комбо с фамилиями
DirectorySurname dirSurname = DirectoryLocator.getDirectory(DirectorySurname.class);
autoModels.add( new DirectorySimpleFilteredComboBoxModel<ClientLocal, DirectorySurnameItem> (jComboSurname, clientLocal, dirSurname) {
@Override
public DirectorySurnameItem getSelectedDirectoryItem() throws ClipsException {
return getObject().getSurname();
}
@Override
public void setSelectedDirectoryItem(DirectorySurnameItem item) throws ClipsException {
getObject().setSurname(item);
}
});
//Комбо с именами
DirectoryName dirName = DirectoryLocator.getDirectory(DirectoryName.class);
autoModels.add( new DirectorySimpleFilteredComboBoxModel<ClientLocal, DirectoryNameItem> (jComboName, clientLocal, dirName) {
@Override
public DirectoryNameItem getSelectedDirectoryItem() throws ClipsException {
return getObject().getName();
}
@Override
public void setSelectedDirectoryItem(DirectoryNameItem item) throws ClipsException {
getObject().setName(item);
}
});
//Комбо с отчествами
DirectoryPathron dirPathron = DirectoryLocator.getDirectory(DirectoryPathron.class);
autoModels.add( new DirectorySimpleFilteredComboBoxModel<ClientLocal, DirectoryPathronItem> (jComboPathron, clientLocal, dirPathron) {
@Override
public DirectoryPathronItem getSelectedDirectoryItem() throws ClipsException {
return getObject().getPathron();
}
@Override
public void setSelectedDirectoryItem(DirectoryPathronItem item) throws ClipsException {
getObject().setPathron(item);
}
});
//Комбо с группами
DirectoryUserGroup dirUserGroup = DirectoryLocator.getDirectory(DirectoryUserGroup.class);
autoModels.add(new DirectorySimpleFilteredComboBoxModel<ClientLocal, DirectoryUserGroupItem> (jComboGroup, clientLocal, dirUserGroup) {
@Override
public DirectoryUserGroupItem getSelectedDirectoryItem() throws ClipsException {
return getObject().getUsergroup();
}
@Override
public void setSelectedDirectoryItem(DirectoryUserGroupItem item) throws ClipsException {
getObject().setUsergroup(item);
}
});
autoModels.add(new DelegateTextModel<ClientLocal>(editAddress, clientLocal) {
@Override
protected void setModelTextChecked(String text) throws ClipsException {
throw new ClipsException();
}
@Override
protected String getModelTextChecked() throws ClipsException {
return getObject().getAddress().toString();
}
});
new DelegateDateModel<ClientLocal>(clientLocal, bornChooser) {
@Override
protected Date getDateImp() throws ClipsException {
return getDelegate().getBorn();
}
@Override
protected void setDateImp(Date date) throws ClipsException {
getDelegate().setBorn(date);
}
};
//слушатель для примечания
autoModels.add(new DelegateTextModel<ClientLocal>(editRemark, clientLocal) {
@Override
protected void setModelTextChecked(String text) throws ClipsException, ParseException, NumberFormatException {
if (text != null && text.trim().length() > 255) {
throw new ParseException("Длина примечания не может быть больше 255 символов", 256);
}
getObject().setRemarks(text == null ? null : text.trim());
}
@Override
protected String getModelTextChecked() throws ClipsException {
return getObject().getRemarks();
}
});
//слушатель для почтового ящика
editEmail.getDocument().addDocumentListener(
new CheckableDocListener(editEmail, FormatChecker.EMAIL) {
@Override
public void setField(String doc) {
try {
clientLocal.setEmail(doc);
} catch (ClipsException ex) {
MessageBox.showException(ex);
}
}
});
//слушатель для телефонов
editTelephones.getDocument().addDocumentListener(
new CheckableDocListener(editTelephones, FormatChecker.PHONES) {
@Override
public void setField(String doc) {
try {
clientLocal.setTelephones(doc);
} catch (ClipsException ex) {
MessageBox.showException(ex);
}
}
});
editEmcNumber.setDocument(new DelegateTextModel<ClientLocal>(editEmcNumber, clientLocal) {
@Override
protected void setModelTextChecked(String text) throws ClipsException, ParseException, NumberFormatException {
if (text != null){
FormatChecker.checkEMC(text);
}
getObject().setNumberEmc(text);
getContainer().contentStateChanged();
}
@Override
protected String getModelTextChecked() throws ClipsException {
return getObject().getNumberEmc();
}
});
editSnils.getDocument().addDocumentListener(
new CheckableDocListener(editSnils, FormatChecker.SNILS) {
@Override
public void setField(String doc) {
try {
clientLocal.setSnils(doc);
} catch (ClipsException ex) {
MessageBox.showException(ex);
}
}
});
autoModels.add(new DelegateTextModel<ClientLocal>(editInn, clientLocal) {
@Override
protected void setModelTextChecked(String text) throws ClipsException, ParseException, NumberFormatException {
if (text != null){
FormatChecker.checkINN(text);
}
getObject().setInn(text);
}
@Override
protected String getModelTextChecked() throws ClipsException {
return getObject().getInn();
}
});
//слушатель для ключевой фразы
editKeyword.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent arg0) {
setField(arg0.getDocument());
}
@Override
public void removeUpdate(DocumentEvent arg0) {
setField(arg0.getDocument());
}
@Override
public void changedUpdate(DocumentEvent arg0) {
}
private void setField(Document doc) {
try {
clientLocal.setKeyword(doc.getText(0, doc.getLength()));
} catch (ClipsException ex) {
MessageBox.showException(ex);
} catch (BadLocationException ex) {
MessageBox.showException(ex);
}
}
});
//Комбо с полом
DirectorySex dirSex = DirectoryLocator.getDirectory(DirectorySex.class);
autoModels.add( new DirectorySimpleFilteredComboBoxModel<ClientLocal, DirectorySexItem> (cbSex, clientLocal, dirSex) {
@Override
public DirectorySexItem getSelectedDirectoryItem() throws ClipsException {
return getObject().getSex();
}
@Override
public void setSelectedDirectoryItem(DirectorySexItem item) throws ClipsException {
getObject().setSex(item);
}
});
//Комбо с группами
DirectoryBloodGroup dirBlood = DirectoryLocator.getDirectory(DirectoryBloodGroup.class);
autoModels.add( new DirectorySimpleFilteredComboBoxModel<ClientLocal, DirectoryBloodGroupItem> (cbBloodGroup, clientLocal, dirBlood) {
@Override
public DirectoryBloodGroupItem getSelectedDirectoryItem() throws ClipsException {
return getObject().getBloodGroup();
}
@Override
public void setSelectedDirectoryItem(DirectoryBloodGroupItem item) throws ClipsException {
getObject().setBloodGroup(item);
}
});
//Комбо с клиниками
selectedLpu = clientLocal.getDistrict().getLpu();
DirectoryLpu dirLpu = DirectoryLocator.getDirectory(DirectoryLpu.class);
DirectoryObjectComboBoxModel lpuModel = new DirectoryObjectComboBoxModel(cbLpu, dirLpu) {
@Override
public boolean isSelectionVisible() {
return true;
}
@Override
public DirectoryItemRO getSelectedDirectoryItem() throws ClipsException {
return selectedLpu;
}
@Override
public void setSelectedDirectoryItem(DirectoryItemRO item) throws ClipsException {
selectedLpu = (DirectoryLpuItem) item;
changeModelDistrict(selectedLpu);
}
};
autoModels.add(lpuModel);
//Комбо с участками
changeModelDistrict(selectedLpu);
// autoModels.add( new FilteredComboBoxModel(cbDistrict, true) {
//
// @Override
// public Object addItem(String txt) {
// throw new UnsupportedOperationException("Not supported yet.");
// }
// });
//Социальное положение
DirectorySocialStatus dirSocial = DirectoryLocator.getDirectory(DirectorySocialStatus.class);
autoModels.add( new DirectorySimpleFilteredComboBoxModel<ClientLocal, DirectorySocialStatusItem> (jComboSocial, clientLocal, dirSocial) {
@Override
public DirectorySocialStatusItem getSelectedDirectoryItem() throws ClipsException {
return getObject().getSocialStatus();
}
@Override
public void setSelectedDirectoryItem(DirectorySocialStatusItem item) throws ClipsException {
getObject().setSocialStatus(item);
}
});
tfDocSeries.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent arg0) {
setField(arg0.getDocument());
}
@Override
public void removeUpdate(DocumentEvent arg0) {
setField(arg0.getDocument());
}
@Override
public void changedUpdate(DocumentEvent arg0) {
}
private void setField(Document doc) {
try {
// clDocData.setSeries(doc.getText(0, doc.getLength()));
// clientLocal.setClientDocument(clDocData);
clientLocal.getClientDocument().setSeries(doc.getText(0, doc.getLength()));
} catch (ClipsException ex) {
MessageBox.showException(ex);
} catch (BadLocationException ex) {
MessageBox.showException(ex);
}
}
});
tfDocNumber.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent arg0) {
setField(arg0.getDocument());
}
@Override
public void removeUpdate(DocumentEvent arg0) {
setField(arg0.getDocument());
}
@Override
public void changedUpdate(DocumentEvent arg0) {
}
private void setField(Document doc) {
try {
clientLocal.getClientDocument().setNumber(doc.getText(0, doc.getLength()));
// clientLocal.setClientDocument(clDocData);
} catch (ClipsException ex) {
MessageBox.showException(ex);
} catch (BadLocationException ex) {
MessageBox.showException(ex);
}
}
});
new DelegateDateModel<ClientLocal>(clientLocal, dcDocGivenDate) {
@Override
protected Date getDateImp() throws ClipsException {
return getDelegate().getClientDocument().getDate();
}
@Override
protected void setDateImp(Date date) throws ClipsException {
clientLocal.getClientDocument().setDate(date);
// getDelegate().setClientDocument(clDocData);
}
};
//Комбо место выдачи документа
DirectoryDocumentGivenPlace dirDocPlace = DirectoryLocator.getDirectory(DirectoryDocumentGivenPlace.class, false);
DefaultComboBoxModel model = new DefaultComboBoxModel(dirDocPlace.toArray());
cbDocGivenPlace.setModel(model);
cbDocGivenPlace.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
DirectoryDocumentGivenPlaceItem item =
(DirectoryDocumentGivenPlaceItem) cbDocGivenPlace.getSelectedItem();
clientLocal.getClientDocument().setGivenPlace(item);
// clientLocal.setClientDocument(clDocData);
} catch (ClipsException ex) {
MessageBox.showException(ex);
}
}
});
DirectoryDocumentType dirDocType = DirectoryLocator.getDirectory(DirectoryDocumentType.class);
model = new DefaultComboBoxModel(dirDocType.toArray());
cbDocType.setModel(model);
cbDocType.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
DirectoryDocumentTypeItem item = null;
if (cbDocType.getSelectedItem() != null) {
item = (DirectoryDocumentTypeItem) cbDocType.getSelectedItem();
}
clientLocal.getClientDocument().setType(item);
// clientLocal.setClientDocument(clDocData);
setPassportFields();
} catch (ClipsException ex) {
MessageBox.showException(ex);
}
}
});
//
DirectoryRepresentativeStatus dirRepresStatus =
DirectoryLocator.getDirectory(DirectoryRepresentativeStatus.class, false);
DefaultComboBoxModel modelStatus = new DefaultComboBoxModel(dirRepresStatus.toArray());
cbRepresStatus.setModel(modelStatus);
cbRepresStatus.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
DirectoryRepresentativeStatusItem item =
(DirectoryRepresentativeStatusItem) cbRepresStatus.getSelectedItem();
clientLocal.setRepresStatus(item);
if (item.getID() == 0) {
clientLocal.setRepresentative(null);
editRepresentative.setText("");
cbRepresStatus.setEnabled(clientLocal.getRepresentative() != null);
}
} catch (ClipsException ex) {
MessageBox.showException(ex);
}
}
});
setScreenFields();
StateSaver.attachTo(this);
}
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel3 = new javax.swing.JPanel();
jPanel8 = new javax.swing.JPanel();
jPanel1 = new javax.swing.JPanel();
labSurname = new javax.swing.JLabel();
labName = new javax.swing.JLabel();
labPathron = new javax.swing.JLabel();
jComboSurname = new javax.swing.JComboBox();
jComboName = new javax.swing.JComboBox();
jComboPathron = new javax.swing.JComboBox();
jPanel2 = new javax.swing.JPanel();
jPanel9 = new javax.swing.JPanel();
labSex = new javax.swing.JLabel();
cbSex = new javax.swing.JComboBox();
jPanel15 = new javax.swing.JPanel();
jLabel5 = new javax.swing.JLabel();
cbBloodGroup = new javax.swing.JComboBox();
jPanel10 = new javax.swing.JPanel();
labDateBorn = new javax.swing.JLabel();
bornChooser = new org.infotechservice.ICalendar.components.ICDateChooser();
jPanel14 = new javax.swing.JPanel();
labUserGroup = new javax.swing.JLabel();
jComboGroup = new javax.swing.JComboBox();
jPanel5 = new javax.swing.JPanel();
jPanelEmcNumber = new javax.swing.JPanel();
jLabel12 = new javax.swing.JLabel();
editEmcNumber = new javax.swing.JTextField();
jPanelSnils = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
editSnils = new javax.swing.JTextField();
jPanel22 = new javax.swing.JPanel();
jLabel11 = new javax.swing.JLabel();
editInn = new javax.swing.JTextField();
jPanelOMI = new javax.swing.JPanel();
jLabel3 = new javax.swing.JLabel();
jPanel11 = new javax.swing.JPanel();
tfOMI = new javax.swing.JTextField();
btOMI = new javax.swing.JButton();
jPanel4 = new javax.swing.JPanel();
jPanel19 = new javax.swing.JPanel();
jPanel18 = new javax.swing.JPanel();
jLabel10 = new javax.swing.JLabel();
dcDocGivenDate = new org.infotechservice.ICalendar.components.ICDateChooser();
jPanel17 = new javax.swing.JPanel();
jLabel9 = new javax.swing.JLabel();
cbDocGivenPlace = new javax.swing.JComboBox();
jPanel21 = new javax.swing.JPanel();
jPanel13 = new javax.swing.JPanel();
jLabel8 = new javax.swing.JLabel();
tfDocNumber = new javax.swing.JTextField();
jPanel20 = new javax.swing.JPanel();
jPanel12 = new javax.swing.JPanel();
jLabel6 = new javax.swing.JLabel();
cbDocType = new javax.swing.JComboBox();
jPanel16 = new javax.swing.JPanel();
jLabel7 = new javax.swing.JLabel();
tfDocSeries = new javax.swing.JTextField();
jPanelAddress = new javax.swing.JPanel();
jPanelAdress = new javax.swing.JPanel();
labAddress = new javax.swing.JLabel();
jPanel26 = new javax.swing.JPanel();
editAddress = new javax.swing.JTextField();
btAddress = new javax.swing.JButton();
jPanelSocialKeyword = new javax.swing.JPanel();
jPanelClinic = new javax.swing.JPanel();
jLabelClinic = new javax.swing.JLabel();
cbLpu = new javax.swing.JComboBox();
jPanelDistrict = new javax.swing.JPanel();
jLabel4 = new javax.swing.JLabel();
cbDistrict = new javax.swing.JComboBox();
jPanelSocialCard = new javax.swing.JPanel();
labSocialCardName = new javax.swing.JLabel();
jPanel23 = new javax.swing.JPanel();
btSocialCardLink = new javax.swing.JButton();
editSocialCardNumber = new javax.swing.JTextField();
jPanelMotherFather = new javax.swing.JPanel();
jPanelFather = new javax.swing.JPanel();
labFother = new javax.swing.JLabel();
jPanel24 = new javax.swing.JPanel();
editFather = new javax.swing.JTextField();
btFatherSelect = new javax.swing.JButton();
jPanelMother = new javax.swing.JPanel();
labMother = new javax.swing.JLabel();
jPanel25 = new javax.swing.JPanel();
editMother = new javax.swing.JTextField();
btMotherSelect = new javax.swing.JButton();
jPanel6 = new javax.swing.JPanel();
labFother1 = new javax.swing.JLabel();
jPanel28 = new javax.swing.JPanel();
editRepresentative = new javax.swing.JTextField();
btRepresentativeSelect = new javax.swing.JButton();
jPanel27 = new javax.swing.JPanel();
jLabel13 = new javax.swing.JLabel();
cbRepresStatus = new javax.swing.JComboBox();
jPanelRemark = new javax.swing.JPanel();
labRemark = new javax.swing.JLabel();
editRemark = new javax.swing.JTextField();
jPanelEmailPhone = new javax.swing.JPanel();
jPanelSocial = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
jComboSocial = new javax.swing.JComboBox();
jPanelEmail = new javax.swing.JPanel();
labEmail = new javax.swing.JLabel();
editEmail = new javax.swing.JTextField();
jPanelTelephones = new javax.swing.JPanel();
labTelephones = new javax.swing.JLabel();
editTelephones = new javax.swing.JTextField();
jPanelKeyword = new javax.swing.JPanel();
labKeyword = new javax.swing.JLabel();
editKeyword = new javax.swing.JTextField();
jPanel7 = new javax.swing.JPanel();
btExcemption = new javax.swing.JButton();
btJob = new javax.swing.JButton();
btContract = new javax.swing.JButton();
btService = new javax.swing.JButton();
btDiscount = new javax.swing.JButton();
jPanel8.setLayout(new java.awt.GridLayout(0, 1, 3, 3));
jPanel1.setLayout(new java.awt.GridLayout(2, 0, 20, 0));
labSurname.setText("Фамилия");
jPanel1.add(labSurname);
labName.setText("Имя");
jPanel1.add(labName);
labPathron.setText("Отчество");
jPanel1.add(labPathron);
jComboSurname.setEditable(true);
jComboSurname.setLightWeightPopupEnabled(false);
jComboSurname.setMinimumSize(new java.awt.Dimension(137, 30));
jComboSurname.setPreferredSize(new java.awt.Dimension(137, 30));
jPanel1.add(jComboSurname);
jComboName.setEditable(true);
jPanel1.add(jComboName);
jComboPathron.setEditable(true);
jPanel1.add(jComboPathron);
jPanel8.add(jPanel1);
jPanel2.setLayout(new java.awt.GridLayout(1, 0, 8, 0));
jPanel9.setLayout(new java.awt.GridLayout(2, 1));
labSex.setText("Пол");
jPanel9.add(labSex);
cbSex.setEditable(true);
jPanel9.add(cbSex);
jPanel2.add(jPanel9);
jPanel15.setLayout(new java.awt.GridLayout(2, 1));
jLabel5.setText("Группа крови");
jPanel15.add(jLabel5);
cbBloodGroup.setEditable(true);
jPanel15.add(cbBloodGroup);
jPanel2.add(jPanel15);
jPanel10.setLayout(new java.awt.GridLayout(2, 1));
labDateBorn.setText("Дата рождения");
jPanel10.add(labDateBorn);
bornChooser.setMinSelectableDate(new java.util.Date(-2208995919000L));
bornChooser.setPreferredSize(new java.awt.Dimension(136, 24));
jPanel10.add(bornChooser);
jPanel2.add(jPanel10);
jPanel14.setLayout(new java.awt.GridLayout(2, 1));
labUserGroup.setText("Особая отметка");
jPanel14.add(labUserGroup);
jComboGroup.setEditable(true);
jPanel14.add(jComboGroup);
jPanel2.add(jPanel14);
jPanel8.add(jPanel2);
jPanel5.setLayout(new java.awt.GridLayout(1, 0, 5, 0));
jPanelEmcNumber.setLayout(new java.awt.GridLayout(0, 1));
jLabel12.setText("№ медицинской карты");
jPanelEmcNumber.add(jLabel12);
editEmcNumber.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED));
jPanelEmcNumber.add(editEmcNumber);
jPanel5.add(jPanelEmcNumber);
jPanelSnils.setLayout(new java.awt.GridLayout(0, 1));
jLabel1.setText("СНИЛС");
jPanelSnils.add(jLabel1);
editSnils.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED));
jPanelSnils.add(editSnils);
jPanel5.add(jPanelSnils);
jPanel22.setLayout(new java.awt.GridLayout(0, 1));
jLabel11.setText("ИНН");
jPanel22.add(jLabel11);
editInn.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED));
jPanel22.add(editInn);
jPanel5.add(jPanel22);
jPanelOMI.setLayout(new java.awt.GridLayout(0, 1));
jLabel3.setText("ОМС");
jPanelOMI.add(jLabel3);
jPanel11.setLayout(new java.awt.BorderLayout());
tfOMI.setEditable(false);
tfOMI.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED));
jPanel11.add(tfOMI, java.awt.BorderLayout.CENTER);
btOMI.setText("...");
btOMI.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btOMIActionPerformed(evt);
}
});
jPanel11.add(btOMI, java.awt.BorderLayout.LINE_END);
jPanelOMI.add(jPanel11);
jPanel5.add(jPanelOMI);
jPanel8.add(jPanel5);
jPanel4.setLayout(new java.awt.BorderLayout(5, 0));
jPanel19.setLayout(new java.awt.BorderLayout(5, 0));
jPanel18.setPreferredSize(new java.awt.Dimension(125, 54));
jPanel18.setLayout(new java.awt.GridLayout(2, 1));
jLabel10.setText("Дата выдачи");
jPanel18.add(jLabel10);
dcDocGivenDate.setMinSelectableDate(new java.util.Date(-2208995919000L));
jPanel18.add(dcDocGivenDate);
jPanel19.add(jPanel18, java.awt.BorderLayout.LINE_END);
jPanel17.setPreferredSize(new java.awt.Dimension(250, 54));
jPanel17.setLayout(new java.awt.GridLayout(2, 1));
jLabel9.setText("Место выдачи");
jPanel17.add(jLabel9);
jPanel17.add(cbDocGivenPlace);
jPanel19.add(jPanel17, java.awt.BorderLayout.CENTER);
jPanel4.add(jPanel19, java.awt.BorderLayout.LINE_END);
jPanel21.setLayout(new java.awt.BorderLayout(5, 0));
jPanel13.setPreferredSize(new java.awt.Dimension(80, 51));
jPanel13.setLayout(new java.awt.GridLayout(2, 1));
jLabel8.setText("Номер");
jPanel13.add(jLabel8);
tfDocNumber.setColumns(15);
tfDocNumber.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED));
jPanel13.add(tfDocNumber);
jPanel21.add(jPanel13, java.awt.BorderLayout.LINE_END);
jPanel20.setLayout(new java.awt.BorderLayout(5, 0));
jPanel12.setPreferredSize(new java.awt.Dimension(250, 88));
jPanel12.setLayout(new java.awt.GridLayout(2, 1));
jLabel6.setText("Документ, удостоверяющий личность");
jPanel12.add(jLabel6);
jPanel12.add(cbDocType);
jPanel20.add(jPanel12, java.awt.BorderLayout.CENTER);
jPanel16.setPreferredSize(new java.awt.Dimension(80, 54));
jPanel16.setLayout(new java.awt.GridLayout(2, 1));
jLabel7.setText("Серия");
jPanel16.add(jLabel7);
tfDocSeries.setColumns(15);
tfDocSeries.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED));
jPanel16.add(tfDocSeries);
jPanel20.add(jPanel16, java.awt.BorderLayout.LINE_END);
jPanel21.add(jPanel20, java.awt.BorderLayout.CENTER);
jPanel4.add(jPanel21, java.awt.BorderLayout.CENTER);
jPanel8.add(jPanel4);
jPanelAddress.setLayout(new java.awt.BorderLayout(10, 0));
jPanelAdress.setPreferredSize(new java.awt.Dimension(700, 41));
jPanelAdress.setLayout(new java.awt.GridLayout(0, 1));
labAddress.setText("Адрес");
jPanelAdress.add(labAddress);
jPanel26.setLayout(new java.awt.BorderLayout());
editAddress.setEditable(false);
editAddress.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED));
editAddress.setPreferredSize(new java.awt.Dimension(700, 20));
jPanel26.add(editAddress, java.awt.BorderLayout.CENTER);
btAddress.setText("...");
btAddress.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btAddressActionPerformed(evt);
}
});
jPanel26.add(btAddress, java.awt.BorderLayout.EAST);
jPanelAdress.add(jPanel26);
jPanelAddress.add(jPanelAdress, java.awt.BorderLayout.CENTER);
jPanel8.add(jPanelAddress);
jPanelClinic.setPreferredSize(new java.awt.Dimension(230, 43));
jPanelClinic.setLayout(new java.awt.GridLayout(0, 1));
jLabelClinic.setText("Поликлиника");
jPanelClinic.add(jLabelClinic);
cbLpu.setPreferredSize(new java.awt.Dimension(200, 19));
jPanelClinic.add(cbLpu);
jPanelDistrict.setPreferredSize(new java.awt.Dimension(230, 43));
jPanelDistrict.setLayout(new java.awt.GridLayout(0, 1));
jLabel4.setText("№ врачебного участка");
jPanelDistrict.add(jLabel4);
jPanelDistrict.add(cbDistrict);
jPanelSocialCard.setLayout(new java.awt.GridLayout(0, 1));
labSocialCardName.setText("Номер социальной карты");
jPanelSocialCard.add(labSocialCardName);
jPanel23.setLayout(new java.awt.BorderLayout());
btSocialCardLink.setText("Связать");
btSocialCardLink.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btSocialCardLinkActionPerformed(evt);
}
});
jPanel23.add(btSocialCardLink, java.awt.BorderLayout.EAST);
editSocialCardNumber.setEnabled(false);
jPanel23.add(editSocialCardNumber, java.awt.BorderLayout.CENTER);
jPanelSocialCard.add(jPanel23);
javax.swing.GroupLayout jPanelSocialKeywordLayout = new javax.swing.GroupLayout(jPanelSocialKeyword);
jPanelSocialKeyword.setLayout(jPanelSocialKeywordLayout);
jPanelSocialKeywordLayout.setHorizontalGroup(
jPanelSocialKeywordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelSocialKeywordLayout.createSequentialGroup()
.addComponent(jPanelClinic, javax.swing.GroupLayout.DEFAULT_SIZE, 271, Short.MAX_VALUE)
.addGap(5, 5, 5)
.addComponent(jPanelDistrict, javax.swing.GroupLayout.DEFAULT_SIZE, 271, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanelSocialCard, javax.swing.GroupLayout.DEFAULT_SIZE, 273, Short.MAX_VALUE))
);
jPanelSocialKeywordLayout.setVerticalGroup(
jPanelSocialKeywordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelSocialKeywordLayout.createSequentialGroup()
.addGroup(jPanelSocialKeywordLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanelClinic, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanelDistrict, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanelSocialCard, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel8.add(jPanelSocialKeyword);
jPanelMotherFather.setLayout(new java.awt.GridLayout(1, 0, 5, 0));
jPanelFather.setLayout(new java.awt.GridLayout(0, 1));
labFother.setText("Отец");
jPanelFather.add(labFother);
jPanel24.setLayout(new java.awt.BorderLayout());
editFather.setEditable(false);
editFather.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED));
jPanel24.add(editFather, java.awt.BorderLayout.CENTER);
btFatherSelect.setText("...");
btFatherSelect.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btFatherSelectActionPerformed(evt);
}
});
jPanel24.add(btFatherSelect, java.awt.BorderLayout.EAST);
jPanelFather.add(jPanel24);
jPanelMotherFather.add(jPanelFather);
jPanelMother.setLayout(new java.awt.GridLayout(0, 1));
labMother.setText("Мать");
jPanelMother.add(labMother);
jPanel25.setLayout(new java.awt.BorderLayout());
editMother.setEditable(false);
editMother.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED));
jPanel25.add(editMother, java.awt.BorderLayout.CENTER);
btMotherSelect.setText("...");
btMotherSelect.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btMotherSelectActionPerformed(evt);
}
});
jPanel25.add(btMotherSelect, java.awt.BorderLayout.EAST);
jPanelMother.add(jPanel25);
jPanelMotherFather.add(jPanelMother);
jPanel6.setLayout(new java.awt.GridLayout(2, 1));
labFother1.setText("Представитель");
jPanel6.add(labFother1);
jPanel28.setLayout(new java.awt.BorderLayout());
editRepresentative.setEditable(false);
editRepresentative.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED));
jPanel28.add(editRepresentative, java.awt.BorderLayout.CENTER);
btRepresentativeSelect.setText("...");
btRepresentativeSelect.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btRepresentativeSelectActionPerformed(evt);
}
});
jPanel28.add(btRepresentativeSelect, java.awt.BorderLayout.EAST);
jPanel6.add(jPanel28);
jPanelMotherFather.add(jPanel6);
jPanel27.setLayout(new java.awt.GridLayout(2, 1));
jLabel13.setText("Статус представителя");
jPanel27.add(jLabel13);
jPanel27.add(cbRepresStatus);
jPanelMotherFather.add(jPanel27);
jPanel8.add(jPanelMotherFather);
jPanelRemark.setLayout(new java.awt.GridLayout(2, 1));
labRemark.setText("Примечание");
jPanelRemark.add(labRemark);
editRemark.setColumns(255);
editRemark.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED));
editRemark.setMinimumSize(new java.awt.Dimension(700, 20));
jPanelRemark.add(editRemark);
jPanel8.add(jPanelRemark);
jPanelEmailPhone.setLayout(new java.awt.GridLayout(0, 4, 5, 0));
jPanelSocial.setLayout(new java.awt.GridLayout(0, 1));
jLabel2.setText("Социальное положение");
jPanelSocial.add(jLabel2);
jComboSocial.setEditable(true);
jPanelSocial.add(jComboSocial);
jPanelEmailPhone.add(jPanelSocial);
jPanelEmail.setLayout(new java.awt.GridLayout(0, 1));
labEmail.setText("E-mail");
jPanelEmail.add(labEmail);
editEmail.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED));
editEmail.setMinimumSize(new java.awt.Dimension(70, 20));
jPanelEmail.add(editEmail);
jPanelEmailPhone.add(jPanelEmail);
jPanelTelephones.setLayout(new java.awt.GridLayout(0, 1));
labTelephones.setText("Телефоны");
jPanelTelephones.add(labTelephones);
editTelephones.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED));
editTelephones.setMinimumSize(new java.awt.Dimension(70, 20));
editTelephones.setPreferredSize(new java.awt.Dimension(70, 20));
jPanelTelephones.add(editTelephones);
jPanelEmailPhone.add(jPanelTelephones);
jPanelKeyword.setLayout(new java.awt.GridLayout(0, 1));
labKeyword.setText("Ключевая фраза");
jPanelKeyword.add(labKeyword);
editKeyword.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED));
jPanelKeyword.add(editKeyword);
jPanelEmailPhone.add(jPanelKeyword);
jPanel8.add(jPanelEmailPhone);
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel8, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 826, Short.MAX_VALUE)
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, 462, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(72, Short.MAX_VALUE))
);
btExcemption.setText("Категория льготности");
btExcemption.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btExcemptionActionPerformed(evt);
}
});
jPanel7.add(btExcemption);
btJob.setText("Место работы");
btJob.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btJobActionPerformed(evt);
}
});
jPanel7.add(btJob);
btContract.setText("Договора");
jPanel7.add(btContract);
btService.setText("Услуги");
jPanel7.add(btService);
btDiscount.setText("Дисконтные карты");
btDiscount.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btDiscountActionPerformed(evt);
}
});
jPanel7.add(btDiscount);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel7, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 826, Short.MAX_VALUE))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
}// </editor-fold>//GEN-END:initComponents
private void changeModelDistrict(final DirectoryLpuItem lpu) throws ClipsException {
DirectoryDistrict dirDistrict = DirectoryLocator.getDirectory(DirectoryDistrict.class);
ROList<DirectoryDistrictItem> filteredItems = dirDistrict.getFilteredItems(lpu);
ROList<DirectoryDistrictItem> items = dirDistrict.getFilteredItems(lpu);
if (!items.contains(clientLocal.getDistrict())) {
clientLocal.setDistrict(dirDistrict.getNullItem());
}
DelegateComboboxModel model = new DelegateComboboxModel<ClientLocal>(cbDistrict, clientLocal, true) {
@Override
public Object getElementAtImp(int index) throws ClipsException {
System.out.println("getElementAtImp");
DirectoryDistrict dirDistrict = DirectoryLocator.getDirectory(DirectoryDistrict.class);
return dirDistrict.getFilteredItems(lpu).get(index);
}
@Override
public int getSizeImp() throws ClipsException {
System.out.println("getSizeImp");
DirectoryDistrict dirDistrict = DirectoryLocator.getDirectory(DirectoryDistrict.class);
return dirDistrict.getFilteredItems(lpu).size();
}
@Override
public Object getSelectedItemImp() throws ClipsException {
System.out.println("getSelectedItemImp");
DirectoryDistrict dirDistrict = DirectoryLocator.getDirectory(DirectoryDistrict.class);
ROList<DirectoryDistrictItem> items = dirDistrict.getFilteredItems(lpu);
return getObject().getDistrict();
}
@Override
public void setSelectedItemImp(Object anItem) throws ClipsException {
System.out.println("setSelectedItemImp");
getObject().setDistrict((DirectoryDistrictItem) anItem);
}
};
}
private void setPassportFields() throws ClipsException {
tfDocSeries.setText(clientLocal.getClientDocument().getSeries());
tfDocNumber.setText(clientLocal.getClientDocument().getNumber());
dcDocGivenDate.setDate(clientLocal.getClientDocument().getDate());
cbDocGivenPlace.setSelectedItem(clientLocal.getClientDocument().getGivenPlace());
DirectoryDocumentTypeItem item = clientLocal.getClientDocument().getType();
boolean b = (item != null && item.getID() != 0);
tfDocNumber.setEditable(b);
tfDocSeries.setEditable(b);
dcDocGivenDate.setEnabled(b);
cbDocGivenPlace.setEnabled(b);
}
private void setSocialCardFields() throws ClipsException {
if (clientLocal.getSocialСardCode() == null){
editSocialCardNumber.setText("<нет>");
btSocialCardLink.setText("Связать");
}
else{
editSocialCardNumber.setText("Пациент связан");
btSocialCardLink.setText("Очистить");
}
}
private void checkRepresentative() throws ClipsException {
Date born = clientLocal.getBorn();
Date current = TimeLocal.getCurrentTime().getTime();
int calcAge = DateTimeUtils.calcAge(born, current);
if (calcAge > 14 && clientLocal.getRepresentative() != null) {
MessageBox.showWarning("Пациенту больше 14 лет и указан представитель");
}
}
private void setScreenFields() throws ClipsException {
ClientLocal mother = clientLocal.getMother();
if (mother != null) {
editMother.setText(mother.getSurname() + " " + mother.getName() +
" " + mother.getPathron());
} else {
editMother.setText("");
}
ClientLocal father = clientLocal.getFather();
if (father != null) {
editFather.setText(father.getSurname() + " " + father.getName() +
" " + father.getPathron());
} else {
editFather.setText("");
}
ClientLocal representative = clientLocal.getRepresentative();
if (representative != null) {
editRepresentative.setText(representative.getSurname() + " " + representative.getName() +
" " + representative.getPathron());
} else {
editRepresentative.setText("");
}
cbRepresStatus.setEnabled(clientLocal.getRepresentative() != null);
cbRepresStatus.setSelectedItem(clientLocal.getRepresStatus());
editRemark.setText(clientLocal.getRemarks());
editEmail.setText(clientLocal.getEmail());
editTelephones.setText(clientLocal.getTelephones());
editSnils.setText(clientLocal.getSnils());
editKeyword.setText(clientLocal.getKeyword());
// editInn.setText(clientLocal.getInn());
PolisData polisData = clientLocal.getPolisOMS();
DirectoryInsurerItem insurer = null;
String polis = "";
if (polisData != null) {
insurer = polisData.getInsurer();
if (polisData.getSeries() != null) {
polis += polisData.getSeries() + " ";
}
if (polisData.getNumber() != null) {
polis += polisData.getNumber();
}
}
String insurerT = "";
if (insurer != null && insurer.getID() != 0) {
insurerT = insurer.getTitle();
}
tfOMI.setText((polis + " " + insurerT).trim());
tfOMI.setCaretPosition(0);
cbDistrict.setSelectedItem(clientLocal.getDistrict());
cbBloodGroup.setSelectedItem(clientLocal.getBloodGroup());
// clDocData = clientLocal.getClientDocument();
cbDocType.getModel().setSelectedItem(clientLocal.getClientDocument().getType());
setSocialCardFields();
setPassportFields();
selectedLpu = clientLocal.getDistrict().getLpu();
cbLpu.setSelectedItem(selectedLpu);
}
/**
* Скрывает панель действий с пациентом (на которой кнопки услуги, место
* работы, договора и т.д.)
*/
public void hideToolPanel() {
jPanel7.setVisible(false);
}
private void btAddressActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAddressActionPerformed
try {
Address address = UserInfo.get().getCollaborator().getLpu().getAddress();
DialogAddressM dialog = new DialogAddressM((Frame) getContainer(), clientLocal.getAddress(), address, getAuditManager());
dialog.setVisible(true);
if (dialog.getDlgResult() == ModalDialog.DLG_OK) {
if (!dialog.getAddress().equals(clientLocal.getAddress())){
clientLocal.setAddress(dialog.getAddress());
setDefaultDistrict(clientLocal.getDefaultDistrict(dialog.getAddress()));
}
}
getContainer().contentStateChanged();
// editAddress.setText(clientLocal.getAddress().toString());
} catch (ClipsException ex) {
MessageBox.showException(ex);
}
}//GEN-LAST:event_btAddressActionPerformed
private void setDefaultDistrict(DirectoryDistrictItem item) throws ClipsException {
//if (!item.isNullItem()) {
cbLpu.setSelectedItem(item.getLpu());
//changeModelDistrict(item.getLpu());
//}
cbDistrict.setSelectedItem(item);
}
/**
* Нажатие на кнопку Назначить мать
* Вызыват диалоговое окно с находящейся на ней панелью поиска клиентов
* в режиме выбора. если результат работы диалога ОК то клиенту назначается
* мать
* @param evt
*/
private void btMotherSelectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btMotherSelectActionPerformed
try {
EmptyDialog dialog = new EmptyDialog(MainWindow.mainWindow, "Выбор матери пациента", getAuditManager());
PanelUserSearch panel = new PanelUserSearch(dialog, PanelUserSearch.MODE_SELECT);
dialog.addNewPage((PageGeneric) panel, null);
dialog.setVisible(true);
ClientLocal mother = panel.getSelectedClient();
if (dialog.getDlgResult() == ModalDialog.DLG_OK) {
clientLocal.setMother(mother);
if (mother != null) {
editMother.setText(mother.getSurname() + " " +
mother.getName() +
" " + mother.getPathron());
} else {
editMother.setText("");
}
}
} catch (PageException ex) {
MessageBox.showException(ex);
} catch (ClipsException ex) {
MessageBox.showException(ex);
}
}//GEN-LAST:event_btMotherSelectActionPerformed
/**
* Нажатие на кнопку Назначить отец
* Вызыват диалоговое окно с находящейся на ней панелью поиска клиентов
* в режиме выбора. если результат работы диалога ОК то клиенту назначается
* мать
* @param evt
*/
private void btFatherSelectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btFatherSelectActionPerformed
try {
EmptyDialog dialog = new EmptyDialog(MainWindow.mainWindow, "Выбор отца пациента", getAuditManager());
PanelUserSearch panel = new PanelUserSearch(dialog, PanelUserSearch.MODE_SELECT);
dialog.addNewPage((PageGeneric) panel, null);
dialog.setVisible(true);
ClientLocal father = panel.getSelectedClient();
if (dialog.getDlgResult() == ModalDialog.DLG_OK) {
clientLocal.setFather(father);
if (father != null) {
editFather.setText(father.getSurname() + " " +
father.getName() +
" " + father.getPathron());
} else {
editFather.setText("");
}
}
} catch (PageException ex) {
MessageBox.showException(ex);
} catch (ClipsException ex) {
MessageBox.showException(ex);
}
}//GEN-LAST:event_btFatherSelectActionPerformed
private void btJobActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btJobActionPerformed
try {
PanelJobList panel = new PanelJobList(getContainer(), clientLocal);
PageGeneric page = getContainer().addNewPage(panel, this);
getContainer().activatePage(page);
} catch (PageException ex) {
MessageBox.showException(ex);
} catch (ClipsException ex) {
MessageBox.showException(ex);
}
}//GEN-LAST:event_btJobActionPerformed
private void btExcemptionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btExcemptionActionPerformed
try {
PanelClientExcemption panel = new PanelClientExcemption(getContainer(), clientLocal);
PageGeneric page = getContainer().addNewPage((PageGeneric) panel, this);
getContainer().activatePage(page);
} catch (PageException ex) {
MessageBox.showException(ex);
} catch (ClipsException ex) {
MessageBox.showException(ex);
}
}//GEN-LAST:event_btExcemptionActionPerformed
/**
* Нажали на дисконтную карту
* @param evt
*/
private void btDiscountActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btDiscountActionPerformed
try {
PanelClientDiscountCard pcdc = new PanelClientDiscountCard(getContainer(), clientLocal, null);
PageGeneric page = getContainer().addNewPage(pcdc, this);
getContainer().activatePage(page);
} catch (ClipsException ex) {
MessageBox.showException(ex);
}
}//GEN-LAST:event_btDiscountActionPerformed
private void btOMIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btOMIActionPerformed
try {
PolisData polis = clientLocal.getPolisOMS();
if (polis == null){
polis = new PolisData(new ContractLocal(getAuditManager()), clientLocal);
}
DialogPolisOMI dialog = new DialogPolisOMI(MainWindow.mainWindow, polis, getAuditManager());
dialog.setVisible(true);
if (dialog.getDlgResult() == ModalDialog.DLG_OK) {
PolisData polisData = dialog.getPolisOMI();
clientLocal.setPolisOMS(polisData);
clientLocal.setAddress(polisData.getAddress());
setDefaultDistrict(clientLocal.getDefaultDistrict(polisData.getAddress()));
}
setScreenFields();
checkRepresentative();
} catch (ClipsException ex) {
MessageBox.showException(ex);
}
}//GEN-LAST:event_btOMIActionPerformed
private void btSocialCardLinkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSocialCardLinkActionPerformed
// TODO
// try {
// if (clientLocal.getSocialСardCode() == null) {
// SmartCardServer service = null;
// service = AppMainWindow.getMainWindow().getApplication().getSmartCardService();
// ArrayList<String> idList = NewSocialCardListener.getCardID(service);
// idList.remove(UserInfo.get().getCollaboratorSocialCardID());
// if (idList.size() == 0) {
// MessageBox.showError(MessageBox.E_SOCIAL_CARD_NOT_FOUND);
// } else if (idList.size() > 1) {
// MessageBox.showError(MessageBox.E_SOCIAL_CARD_TOO_MANY);
// } else {
// clientLocal.setSocialСardCode(idList.get(0));
// }
// } else {
// clientLocal.setSocialСardCode(null);
// }
// setSocialCardFields();
// } catch (CardException ex) {
// MessageBox.showExceptionOnly(ex);
// } catch (ClipsException ex) {
// MessageBox.showException(ex);
// }
}//GEN-LAST:event_btSocialCardLinkActionPerformed
private void btRepresentativeSelectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btRepresentativeSelectActionPerformed
try {
EmptyDialog dialog = new EmptyDialog(MainWindow.mainWindow, "Выбор представителя пациента", getAuditManager());
PanelUserSearch panel = new PanelUserSearch(dialog, PanelUserSearch.MODE_SELECT);
dialog.addNewPage((PageGeneric) panel, null);
dialog.setVisible(true);
ClientLocal representative = panel.getSelectedClient();
if (dialog.getDlgResult() == ModalDialog.DLG_OK) {
clientLocal.setRepresentative(representative);
if (representative != null) {
editRepresentative.setText(representative.getSurname() + " " +
representative.getName() +
" " + representative.getPathron());
} else {
DirectoryRepresentativeStatusItem item = dir.getNullItem();
clientLocal.setRepresStatus(item);
cbRepresStatus.setSelectedItem(item);
editRepresentative.setText("");
}
cbRepresStatus.setEnabled(clientLocal.getRepresentative() != null);
}
checkRepresentative();
} catch (PageException ex) {
MessageBox.showException(ex);
} catch (ClipsException ex) {
MessageBox.showException(ex);
}
}//GEN-LAST:event_btRepresentativeSelectActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private org.infotechservice.ICalendar.components.ICDateChooser bornChooser;
private javax.swing.JButton btAddress;
private javax.swing.JButton btContract;
private javax.swing.JButton btDiscount;
private javax.swing.JButton btExcemption;
private javax.swing.JButton btFatherSelect;
private javax.swing.JButton btJob;
private javax.swing.JButton btMotherSelect;
private javax.swing.JButton btOMI;
private javax.swing.JButton btRepresentativeSelect;
private javax.swing.JButton btService;
private javax.swing.JButton btSocialCardLink;
private javax.swing.JComboBox cbBloodGroup;
private javax.swing.JComboBox cbDistrict;
private javax.swing.JComboBox cbDocGivenPlace;
private javax.swing.JComboBox cbDocType;
private javax.swing.JComboBox cbLpu;
private javax.swing.JComboBox cbRepresStatus;
private javax.swing.JComboBox cbSex;
private org.infotechservice.ICalendar.components.ICDateChooser dcDocGivenDate;
private javax.swing.JTextField editAddress;
private javax.swing.JTextField editEmail;
private javax.swing.JTextField editEmcNumber;
private javax.swing.JTextField editFather;
private javax.swing.JTextField editInn;
private javax.swing.JTextField editKeyword;
private javax.swing.JTextField editMother;
private javax.swing.JTextField editRemark;
private javax.swing.JTextField editRepresentative;
private javax.swing.JTextField editSnils;
private javax.swing.JTextField editSocialCardNumber;
private javax.swing.JTextField editTelephones;
private javax.swing.JComboBox jComboGroup;
private javax.swing.JComboBox jComboName;
private javax.swing.JComboBox jComboPathron;
private javax.swing.JComboBox jComboSocial;
private javax.swing.JComboBox jComboSurname;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JLabel jLabelClinic;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel10;
private javax.swing.JPanel jPanel11;
private javax.swing.JPanel jPanel12;
private javax.swing.JPanel jPanel13;
private javax.swing.JPanel jPanel14;
private javax.swing.JPanel jPanel15;
private javax.swing.JPanel jPanel16;
private javax.swing.JPanel jPanel17;
private javax.swing.JPanel jPanel18;
private javax.swing.JPanel jPanel19;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel20;
private javax.swing.JPanel jPanel21;
private javax.swing.JPanel jPanel22;
private javax.swing.JPanel jPanel23;
private javax.swing.JPanel jPanel24;
private javax.swing.JPanel jPanel25;
private javax.swing.JPanel jPanel26;
private javax.swing.JPanel jPanel27;
private javax.swing.JPanel jPanel28;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JPanel jPanel5;
private javax.swing.JPanel jPanel6;
private javax.swing.JPanel jPanel7;
private javax.swing.JPanel jPanel8;
private javax.swing.JPanel jPanel9;
private javax.swing.JPanel jPanelAddress;
private javax.swing.JPanel jPanelAdress;
private javax.swing.JPanel jPanelClinic;
private javax.swing.JPanel jPanelDistrict;
private javax.swing.JPanel jPanelEmail;
private javax.swing.JPanel jPanelEmailPhone;
private javax.swing.JPanel jPanelEmcNumber;
private javax.swing.JPanel jPanelFather;
private javax.swing.JPanel jPanelKeyword;
private javax.swing.JPanel jPanelMother;
private javax.swing.JPanel jPanelMotherFather;
private javax.swing.JPanel jPanelOMI;
private javax.swing.JPanel jPanelRemark;
private javax.swing.JPanel jPanelSnils;
private javax.swing.JPanel jPanelSocial;
private javax.swing.JPanel jPanelSocialCard;
private javax.swing.JPanel jPanelSocialKeyword;
private javax.swing.JPanel jPanelTelephones;
private javax.swing.JLabel labAddress;
private javax.swing.JLabel labDateBorn;
private javax.swing.JLabel labEmail;
private javax.swing.JLabel labFother;
private javax.swing.JLabel labFother1;
private javax.swing.JLabel labKeyword;
private javax.swing.JLabel labMother;
private javax.swing.JLabel labName;
private javax.swing.JLabel labPathron;
private javax.swing.JLabel labRemark;
private javax.swing.JLabel labSex;
private javax.swing.JLabel labSocialCardName;
private javax.swing.JLabel labSurname;
private javax.swing.JLabel labTelephones;
private javax.swing.JLabel labUserGroup;
private javax.swing.JTextField tfDocNumber;
private javax.swing.JTextField tfDocSeries;
private javax.swing.JTextField tfOMI;
// End of variables declaration//GEN-END:variables
@Override
public String getPageTitle() {
if (clientLocal.isNewlyCreated()) {
return "Новый пациент";
} else {
return clientLocal.toString();
}
}
@Override
public boolean isDirty() {
return clientLocal.isDirty();
}
@Override
public void save() throws ClipsException {
if (clientLocal.getSex() == null || clientLocal.getSex().getID() == 0) {
throw new ClipsException("Поле \"Пол пациента\" обязательно для заполнения");
}
else {
clientLocal.save1();
}
//setPassportFields();
checkRepresentative();
}
@Override
public void restore() {
try {
if (clientLocal.isNewlyCreated()) {
clientLocal.restore();
getContainer().removePage(this, true);
} else {
clientLocal.restore();
setScreenFields();
}
} catch (ClipsException ex) {
MessageBox.showException(ex); //поидее должен всяко суметь вывести на экран данные толькочто сохраненного клиента
}
}
@Override
public void lock() {
// throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public ClientLocal getDelegate() {
if (!clientLocal.isNewlyCreated()) {
return clientLocal;
} else {
return null;
}
}
@Override
public boolean readyForPrint() {
return !isDirty();
}
@Override
public void print() {
try {
if (readyForPrint()) {
CombinedReportCreator parCreator = ReporterFactory.createCombinedReporter(getClass(), 1);
CombinedReportOptions ops = new CombinedReportOptions();
ops.topMargin =0;
ops.bottomMargin = 0;
ops.leftMargin =0;
ops.rightMargin = 0;
ops.setPageA5();
ops.setOrentation(PageOrentation.horizontal);
parCreator.setUpReport(null, ops, null);
clientLocal.print(parCreator);
parCreator.finish();
}
} catch (ClipsException ex) {
MessageBox.showException(ex);
}
}
@Override
public void contentStateChanged() {
boolean hasClient = this.getDelegate() != null;
btExcemption.setEnabled(hasClient);
btJob.setEnabled(hasClient);
btService.setEnabled(hasClient);
btDiscount.setEnabled(hasClient);
btContract.setEnabled(hasClient);
getContainer().contentStateChanged();
}
@Override
public void beforeOpen() {
//DO NOTHING
}
@Override
public void beforeClose() {
clientLocal.removeContentStateListener(this);
for (int i = 0; i < autoModels.size(); i++) {
ObjectContainer d = autoModels.get(i);
d.setObject(null);
}
}
}