Subversion Repository Public Repository

Satyam

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bestray.healthcareinpatient.view;

import com.bestray.healthcarecommonutil.exception.ProcessingException;
import com.bestray.healthcarecommonutil.util.DisabledGlassPane;
import com.bestray.healthcarecommonutil.util.Initcap;
import com.bestray.healthcarecommonutil.util.SimpleGradientPanel;
import com.bestray.healthcarecommonutil.util.TextPrompt;
import com.bestray.healthcarecommonutil.vo.TDiagnosisMaster;
import com.bestray.healthcarecommonutil.vo.TEncounterDiagnosis;
import com.bestray.healthcarecommonutil.vo.TInpatentAdmission;
import com.bestray.healthcarecommonutil.vo.TPatientEncounter;
import com.bestray.healthcareinpatient.controller.InPatientRoundingController;
import com.bestray.healthcareinpatient.util.MessageProperties;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JRootPane;
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;

/**
 *
 * @author User1
 */
public class DiagnosisPanel extends javax.swing.JPanel {

    /**
     * Creates new form DiagnosisPanel
     */
    public DiagnosisPanel(TPatientEncounter enc,TInpatentAdmission inPatAdmission) {
        this.encounter = enc;
        this.inpatadmission=inPatAdmission;
        populate();
        initComponents();
        TextPrompt tp7 = new TextPrompt("Search For Diagnosis", searchdiagtb);
        tp7.setForeground( Color.RED );
        tp7.changeAlpha(0.5f);
        tp7.changeStyle(Font.BOLD);
        getDiagnosis(encounter);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        diagnosispanel = new SimpleGradientPanel(Color.WHITE, Color.LIGHT_GRAY);
        jToolBar1 = new javax.swing.JToolBar();
        jLabel1 = new javax.swing.JLabel();
        jScrollPane20 = new javax.swing.JScrollPane();
        diagnosis_table = new javax.swing.JTable(){
            public boolean isCellEditable(int row, int column){
                return false;
            }
            public Component prepareRenderer(TableCellRenderer renderer, int rowIndex, int vColIndex) {
                Component c = super.prepareRenderer(renderer, rowIndex, vColIndex);
                if (rowIndex % 2 == 0 && !isCellSelected(rowIndex, vColIndex)) {
                    c.setForeground(Color.BLACK);
                    c.setBackground(new Color(200, 225, 250));
                }
                else if(rowIndex % 2 == 0 && isCellSelected(rowIndex, vColIndex)){
                    c.setForeground(Color.WHITE);
                    c.setBackground(Color.BLUE);
                }
                else if(rowIndex % 2 != 0 && isCellSelected(rowIndex, vColIndex)){
                    c.setForeground(Color.WHITE);
                    c.setBackground(Color.BLUE);
                }
                else {
                    c.setForeground(Color.BLACK);
                    c.setBackground(getBackground());
                }
                return c;
            }
        };
        jPanel1 = new SimpleGradientPanel();
        searchdiagtb = new javax.swing.JTextField();
        jToolBar12 = new javax.swing.JToolBar();
        diagsearchbutton = new javax.swing.JButton();
        removediagnosis_button = new javax.swing.JButton();

        setLayout(new java.awt.BorderLayout());

        jToolBar1.setBackground(new java.awt.Color(204, 255, 204));
        jToolBar1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jToolBar1.setFloatable(false);
        jToolBar1.setRollover(true);

        jLabel1.setFont(new java.awt.Font("SansSerif", 1, 14)); // NOI18N
        jLabel1.setText("  Diagnosis :");
        jToolBar1.add(jLabel1);

        diagnosis_table.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "ICD 10 Codes", "Diagnosis Name", "Comments", "Id"
            }
        ));
        diagnosis_table.setRowHeight(21);
        diagnosis_table.getTableHeader().setReorderingAllowed(false);
        diagnosis_table.getColumnModel().getColumn(3).setMinWidth(0);
        diagnosis_table.getColumnModel().getColumn(3).setPreferredWidth(0);
        diagnosis_table.getColumnModel().getColumn(3).setMaxWidth(0);
        diagnosis_table.getTableHeader().setFont(new Font("SansSerif", Font.BOLD, 11));
        diagnosis_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        diagnosis_table.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                diagnosis_tableMouseClicked(evt);
            }
        });
        jScrollPane20.setViewportView(diagnosis_table);

        searchdiagtb.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                searchdiagtbKeyPressed(evt);
            }
        });

        jToolBar12.setBackground(new java.awt.Color(204, 255, 255));
        jToolBar12.setBorder(null);
        jToolBar12.setFloatable(false);
        jToolBar12.setRollover(true);
        jToolBar12.setOpaque(false);

        diagsearchbutton.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        diagsearchbutton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/search-icon16X16.png"))); // NOI18N
        diagsearchbutton.setText("Search");
        diagsearchbutton.setFocusable(false);
        diagsearchbutton.setMargin(new java.awt.Insets(2, 20, 2, 20));
        diagsearchbutton.setOpaque(false);
        diagsearchbutton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                diagsearchbuttonActionPerformed(evt);
            }
        });
        jToolBar12.add(diagsearchbutton);

        removediagnosis_button.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        removediagnosis_button.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/minus-icon.png"))); // NOI18N
        removediagnosis_button.setText("Remove");
        removediagnosis_button.setFocusable(false);
        removediagnosis_button.setMargin(new java.awt.Insets(2, 20, 2, 20));
        removediagnosis_button.setOpaque(false);
        removediagnosis_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                removediagnosis_buttonActionPerformed(evt);
            }
        });
        jToolBar12.add(removediagnosis_button);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(searchdiagtb, javax.swing.GroupLayout.PREFERRED_SIZE, 234, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jToolBar12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jToolBar12, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(searchdiagtb, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        javax.swing.GroupLayout diagnosispanelLayout = new javax.swing.GroupLayout(diagnosispanel);
        diagnosispanel.setLayout(diagnosispanelLayout);
        diagnosispanelLayout.setHorizontalGroup(
            diagnosispanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, diagnosispanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(diagnosispanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jToolBar1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jScrollPane20, javax.swing.GroupLayout.DEFAULT_SIZE, 658, Short.MAX_VALUE))
                .addContainerGap())
        );
        diagnosispanelLayout.setVerticalGroup(
            diagnosispanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, diagnosispanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, 0)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, 0)
                .addComponent(jScrollPane20, javax.swing.GroupLayout.DEFAULT_SIZE, 265, Short.MAX_VALUE)
                .addContainerGap())
        );

        add(diagnosispanel, java.awt.BorderLayout.CENTER);
    }// </editor-fold>//GEN-END:initComponents

    private void diagnosis_tableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_diagnosis_tableMouseClicked
        if (evt.getClickCount()==2) {
            TEncounterDiagnosis diagnosisDetails = new TEncounterDiagnosis();
            try{
                int row = diagnosis_table.getSelectedRow();
                diagnosisDetails = (TEncounterDiagnosis)diagnosis_table.getValueAt(row, 3);
                DisabledGlassPane glassPane = new DisabledGlassPane();
                JRootPane rootPane = SwingUtilities.getRootPane(this);
                rootPane.setGlassPane(glassPane);
                DiagnosisModificationDialog diagnosisModificationDialog = new DiagnosisModificationDialog(MainAPP, true, diagnosisDetails);
                diagnosisModificationDialog.setResizable(false);
                diagnosisModificationDialog.setLocationRelativeTo(null);
                glassPane.activate("");
                diagnosisModificationDialog.setVisible(true);
                diagnosisModificationDialog.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
                glassPane.deactivate();
                String buttonclick = diagnosisModificationDialog.getbuttonclick();
                if(buttonclick.equalsIgnoreCase("done")){
                    TEncounterDiagnosis d = diagnosisModificationDialog.getDiagnosis();
                    if(d!=null){
                        diagnosis_table.setValueAt(d.getComments(), row, 2);
                        inpatenc = getOrCreateIPEncounter(inpatadmission);
                        inPatientRoundingController.saveDiagnosis(d);
                    }
                    
                }
            }catch(Exception e){
                e.printStackTrace();
                JOptionPane.showMessageDialog(null, MessageProperties.getMessage("notselected.edit"));
            }
        }
    }//GEN-LAST:event_diagnosis_tableMouseClicked

    private void searchdiagtbKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_searchdiagtbKeyPressed
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            diagsearchbutton.doClick();
        }
    }//GEN-LAST:event_searchdiagtbKeyPressed

    private void diagsearchbuttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_diagsearchbuttonActionPerformed
        rootPane = SwingUtilities.getRootPane(this);
        glassPane = new DisabledGlassPane();
        if(searchdiagtb.getText().length()>=0){
            try {
                expr = Initcap.toInitCap(searchdiagtb.getText());
                SwingWorker s = new SwingWorker() {

                    @Override
                    protected Object doInBackground() throws Exception {
                        rootPane.setGlassPane(glassPane);
                        glassPane.activateLoadingImage();
                        if(expr.length()>0){
                        diaglist = inPatientRoundingController.getDiagnosis(expr);
                        }else{
                          diaglist = inPatientRoundingController.getAllDiagnosis();  
                        }
                        return diaglist;
                    }

                    @Override
                    protected void done() {
                        if(diaglist.size()!=0){
                            super.done();
                            glassPane.deactivate();
                            glassPane.activate("");
                            DiagnosisSearchDialog diagnosisSearchDialog = new DiagnosisSearchDialog(MainAPP, true,diaglist);
                            diagnosisSearchDialog.setResizable(false);
                            diagnosisSearchDialog.setLocationRelativeTo(null);
                            diagnosisSearchDialog.setVisible(true);
                            diagnosisSearchDialog.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
                            glassPane.deactivate();
                            List<TDiagnosisMaster> diag = diagnosisSearchDialog.getDiagnosisList();
                            if(diag!=null){
                                saveEncDiag(diag);
                                //showSelectedDiagnosis(diag);
                            }
                        }else{
                            JOptionPane.showMessageDialog(null, "No diagnosis present");
                            glassPane.deactivate();
                            searchdiagtb.setText(null);
                        }
                    }

                };
                s.execute();
            } catch (Exception ex) {
                Logger.getLogger(DiagnosisPanel.class.getName()).log(Level.SEVERE, null, ex);
            }
        }else{
            JOptionPane.showMessageDialog(null, "Search filed is empty");
        }
    }//GEN-LAST:event_diagsearchbuttonActionPerformed

    private void removediagnosis_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removediagnosis_buttonActionPerformed
        int row = diagnosis_table.getSelectedRow();
        model = (DefaultTableModel)diagnosis_table.getModel();
        if(row!=-1){
            if(model.getValueAt(row, 3)!=null){
                int reply = JOptionPane.showConfirmDialog(null, "Do you want to delete ?", " Delete", JOptionPane.YES_NO_OPTION);
                if (reply == JOptionPane.YES_OPTION){
                    try {
                        TEncounterDiagnosis ediag = (TEncounterDiagnosis)diagnosis_table.getValueAt(row, 3);
                        inpatenc = getOrCreateIPEncounter(inpatadmission);
                        inPatientRoundingController.deleteEncDiag(ediag);
                        model.removeRow(row);
                    } catch (ProcessingException ex) {
                        Logger.getLogger(DiagnosisPanel.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }/*else{
                model.removeRow(row);
            }*/
        }else{
            JOptionPane.showMessageDialog(null, "No diagnosis record seleted for delete");
        }
    }//GEN-LAST:event_removediagnosis_buttonActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    public static javax.swing.JTable diagnosis_table;
    private javax.swing.JPanel diagnosispanel;
    private javax.swing.JButton diagsearchbutton;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane20;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JToolBar jToolBar12;
    private javax.swing.JButton removediagnosis_button;
    private javax.swing.JTextField searchdiagtb;
    // End of variables declaration//GEN-END:variables
    private JFrame MainAPP;
    private JRootPane rootPane;
    private DisabledGlassPane glassPane;
    private String expr;
    private DefaultTableModel model;
    private Vector<Object> addObject;
    private List<Long> removediagnosislist = new ArrayList<Long>();
    private Vector<TDiagnosisMaster> diaglist = new Vector<TDiagnosisMaster>();
    private Vector<TDiagnosisMaster> diagnosisList = new Vector<TDiagnosisMaster>();
    private InPatientRoundingController inPatientRoundingController;
    private TPatientEncounter encounter;
    private TInpatentAdmission inpatadmission;
    private TPatientEncounter inpatenc;
    private TEncounterDiagnosis encounterDiagnosis;
    private List<TEncounterDiagnosis> encDiagnosis;
    
    private void populate() {
        inPatientRoundingController=(InPatientRoundingController)HealthCareInpatientHome.context.getBean("inPatientRoundingController");
    }
    
    private void showSelectedDiagnosis(TEncounterDiagnosis diag){
        model = (DefaultTableModel)diagnosis_table.getModel();
        addObject = new Vector<Object>();
        addObject.add(diag.getDiagnosis().getIcd10Codes());
        addObject.add(diag.getDiagnosis().getDiagnosisName());
        addObject.add(diag.getComments());
        addObject.add(diag);
        model.addRow(addObject);
    }
    
    private TPatientEncounter getOrCreateIPEncounter(TInpatentAdmission inpatadmission) {
        try{
            inpatenc = inPatientRoundingController.getIPEncounterByPatient(inpatadmission.getPatientId());
            if(inpatenc!=null){
                inpatenc = inPatientRoundingController.saveIPEncounter(true,inpatenc);
            }else{
                inpatenc = new TPatientEncounter();
                inpatenc.setPatient(inpatadmission.getPatientId());
                inpatenc.setDoctor(inpatadmission.getDoctorId());
                inpatenc = inPatientRoundingController.saveIPEncounter(false,inpatenc);
            }
        }catch(Exception ex){
            Logger.getLogger(RoundingPanel.class.getName()).log(Level.SEVERE, null, ex);
        }
        return inpatenc;
    }
    
    private void saveEncDiag(List<TDiagnosisMaster> diag) {
        encounter = getOrCreateIPEncounter(inpatadmission);
        for(TDiagnosisMaster d:diag){
            try {
                encounterDiagnosis = new TEncounterDiagnosis();
                encounterDiagnosis.setEncounterDiagnosis(encounter);
                encounterDiagnosis.setDiagnosis(d);
                encounterDiagnosis.setComments(null);
                TEncounterDiagnosis encdiag = inPatientRoundingController.saveDiagnosis(encounterDiagnosis);
                showSelectedDiagnosis(encdiag);
            } catch (ProcessingException ex) {
                Logger.getLogger(DiagnosisPanel.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
    
    private void getDiagnosis(TPatientEncounter encounter){
        try {
            encDiagnosis = inPatientRoundingController.getEncounterDiagnosis(encounter);
        } catch (ProcessingException ex) {
            Logger.getLogger(EncounterPanel.class.getName()).log(Level.SEVERE, null, ex);
        }
        model = (DefaultTableModel)diagnosis_table.getModel();
        for(TEncounterDiagnosis m:encDiagnosis){
            showSelectedDiagnosis(m);
        }
    }
}

Commits for Satyam/AuroCareHealthCareInPatient/src/main/java/com/bestray/healthcareinpatient/view/DiagnosisPanel.java

Diff revisions: vs.
Revision Author Commited Message
1 girijabapi picture girijabapi Fri 20 Jul, 2018 05:59:17 +0000