Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register

Changeset 5051

Show
Ignore:
Timestamp:
07/25/08 22:37:39 (6 months ago)
Author:
nribeka
Message:

patient matching module: added logic for include vs blocking order, re-ordering blocking sessions is now saved #935

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs-modules/patientmatching/src/org/regenstrief/linkage/gui/RandomSampleLoggingFrame.java

    r4257 r5051  
    44 
    55import java.awt.event.ActionEvent; 
     6import java.util.List; 
    67 
    78import javax.swing.JButton; 
     
    1011import org.regenstrief.linkage.analysis.RandomSampleAnalyzer; 
    1112import org.regenstrief.linkage.util.MatchingConfig; 
     13import org.regenstrief.linkage.util.MatchingConfigRow; 
    1214 
    1315/** 
     
    6365         * random sampling result. 
    6466         */ 
    65         this.config = analyzer.getAnalyzerMatchingConfig(); 
     67        MatchingConfig analyzerConfig = analyzer.getAnalyzerMatchingConfig(); 
     68        for(MatchingConfigRow row: analyzerConfig.getMatchingConfigRows()) { 
     69            String name = row.getName(); 
     70            MatchingConfigRow guiRow = config.getMatchingConfigRowByName(name); 
     71            guiRow.setNonAgreement(row.getNonAgreement()); 
     72        } 
     73         
    6674        JOptionPane.showMessageDialog( 
    6775                this, "Values copied to current session parameter.", 
  • openmrs-modules/patientmatching/src/org/regenstrief/linkage/gui/SessionsPanel.java

    r4657 r5051  
    4040import javax.swing.event.ListSelectionEvent; 
    4141import javax.swing.event.ListSelectionListener; 
     42import javax.swing.event.TableModelEvent; 
     43import javax.swing.event.TableModelListener; 
    4244import javax.swing.table.TableColumn; 
     45import javax.swing.table.TableModel; 
    4346 
    4447import org.regenstrief.linkage.util.DataColumn; 
     
    5255 * 
    5356 */ 
    54 public class SessionsPanel extends JPanel implements ActionListener, KeyListener, ListSelectionListener, ItemListener, FocusListener{ 
     57public class SessionsPanel extends JPanel implements ActionListener, KeyListener, 
     58        ListSelectionListener, ItemListener, FocusListener, TableModelListener{ 
    5559        public final String DEFAULT_NAME = "New match"; 
    5660         
     
    439443         
    440444        private Component getSessionTable(){ 
    441                 session_options = new JTable(new SessionOptionsTableModel());            
     445            SessionOptionsTableModel model = new SessionOptionsTableModel(); 
     446            model.addTableModelListener(this); 
     447                session_options = new JTable(model); 
    442448                 
    443449                jcb = new JComboBox(); 
     
    487493                } 
    488494                current_working_config = mc; 
    489                 session_options.setModel(new SessionOptionsTableModel(mc)); 
     495                SessionOptionsTableModel model = new SessionOptionsTableModel(mc); 
     496                model.addTableModelListener(this); 
     497                session_options.setModel(model); 
    490498                TableColumn tc = session_options.getColumnModel().getColumn(6); 
    491499                tc.setCellEditor(new DefaultCellEditor(jcb)); 
    492         } 
    493          
    494         private MatchingConfig getSelectedConfig(){ 
    495                 // gets the matching config object currely selected in the jlist object 
    496                 DefaultListModel dlm = (DefaultListModel)runs.getModel(); 
    497                 MatchingConfig mc = (MatchingConfig)dlm.getElementAt(runs.getSelectedIndex()); 
    498                  
    499                 return mc; 
    500500        } 
    501501         
     
    537537                        dlm.add(index - 1, to_move); 
    538538                        runs.setSelectedIndex(index - 1); 
     539            // swap matching config 
     540            MatchingConfig configA = rm_conf.getMatchingConfigs().remove(index); 
     541            MatchingConfig configB = rm_conf.getMatchingConfigs().remove(index - 1); 
     542            rm_conf.getMatchingConfigs().add(index - 1, configA); 
     543            rm_conf.getMatchingConfigs().add(index, configB); 
    539544                } 
    540545        } 
     
    549554                        dlm.add(index + 1, to_move); 
    550555                        runs.setSelectedIndex(index + 1); 
     556            // swap matching config 
     557            MatchingConfig configA = rm_conf.getMatchingConfigs().remove(index); 
     558            MatchingConfig configB = rm_conf.getMatchingConfigs().remove(index + 1); 
     559            rm_conf.getMatchingConfigs().add(index, configB); 
     560            rm_conf.getMatchingConfigs().add(index + 1, configA); 
    551561                } 
    552562        } 
     
    787797                } 
    788798        } 
     799 
     800    public void tableChanged(TableModelEvent e) { 
     801        /*--NOTES--*/ 
     802        // changes to the SessionOptionsTableModel must be propagated to this method 
     803        // changes that need to be propagated are: 
     804        // - adding new columns 
     805        // - deleting columns 
     806        int rowIndex = e.getFirstRow(); 
     807        int columnIndex = e.getColumn(); 
     808        TableModel model = (TableModel) e.getSource(); 
     809        if(columnIndex == 3) { 
     810            Boolean included = (Boolean) model.getValueAt(rowIndex, columnIndex); 
     811            if(included){ 
     812                model.setValueAt(0, rowIndex, 1); 
     813            } 
     814        } else if (columnIndex == 1) { 
     815            Integer blockOrder = (Integer) model.getValueAt(rowIndex, columnIndex); 
     816            if(blockOrder > 0) { 
     817                model.setValueAt(new Boolean(false), rowIndex, 3); 
     818            } 
     819        } 
     820    } 
    789821}