}
}
});
diagnosisLocals = new ArrayList<DiagnosisLocal>();
DiagnosisLocal specificDiagnosis;
if (!followUpLocal.isNewlyCreated()){
specificDiagnosis = followUpLocal.getDiagnosis();
}else{
specificDiagnosis = followUpLocal.getSerrenUp().getDiseaseLocal().getSpecificDiagnosis();
}
if (specificDiagnosis != null){
diagnosisLocals.add(specificDiagnosis);
diagnosisLocals.addAll(specificDiagnosis.getAccompDiagnosis());
}
if (diagnosisLocals.isEmpty()) {
throw new ClipsException("В заболевании не выставлен диагноз");
} else {
new DelegateComboboxModel<FollowupLocal>(cbDiagnosis, followUpLocal, false) {
@Override
public Object getElementAtImp(int index) throws ClipsException {
return diagnosisLocals.get(index);
}
@Override
public int getSizeImp() throws ClipsException {
return diagnosisLocals.size();
}
@Override
public Object getSelectedItemImp() throws ClipsException {
return getObject().getDiagnosis();
}
@Override
public void setSelectedItemImp(Object anItem) throws ClipsException {
getObject().setDiagnosis((DiagnosisLocal) anItem);
}
};
cbDiagnosis.setRenderer(new DefaultListCellRenderer(){
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel component = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof DiagnosisLocal){
try {
DiagnosisLocal dl = (DiagnosisLocal) value;
component.setText(dl.getMkbAndStage()+ " (" + (dl.hasReferencedDiagnosis() ? "Cопутствующий" : dl.getType()) + ")");
} catch (ClipsException ex) {
ex.printStackTrace();
return ErrorValue.VALUE;
}
}