Subversion Repository Public Repository

Aurocare_27_07_2018

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
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bestray.healthcareemr.Views;

import com.bestray.healthcarecommonutil.exception.HealthCareException;
import com.bestray.healthcarecommonutil.exception.ProcessingException;
import com.bestray.healthcarecommonutil.util.AutoSuggestorMedication;
import com.bestray.healthcarecommonutil.util.DisabledGlassPane;
import com.bestray.healthcarecommonutil.util.PreferenceUtil;
import com.bestray.healthcarecommonutil.util.SimpleGradientPanel;
import com.bestray.healthcarecommonutil.vo.TAccountDepartment;
import com.bestray.healthcarecommonutil.vo.TAllergiesMaster;
import com.bestray.healthcarecommonutil.vo.TEncounterAllergy;
import com.bestray.healthcarecommonutil.vo.TEncounterDiagnosis;
import com.bestray.healthcarecommonutil.vo.TEncounterHistoryVisit;
import com.bestray.healthcarecommonutil.vo.TEncounterMedication;
import com.bestray.healthcarecommonutil.vo.TEncounterVitalSign;
import com.bestray.healthcarecommonutil.vo.TMedicationMaster;
import com.bestray.healthcarecommonutil.vo.TPatient;
import com.bestray.healthcarecommonutil.vo.TPatientEncounter;
import com.bestray.healthcareemr.Controller.AllergiesMasterController;
import com.bestray.healthcareemr.Controller.BusinessDelegate;
import com.bestray.healthcareemr.Controller.DiagnosisMasterController;
import com.bestray.healthcareemr.Controller.MedicationMasterController;
import com.bestray.healthcareemr.Controller.OutPatientController;
import com.bestray.healthcareemr.Controller.ProcedureMasterController;
import com.bestray.healthcareemr.Util.MessageProperties;
import com.bestray.healthcareemr.Vo.OutPatientDTO;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
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.DefaultListModel;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JRootPane;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;

/**
 *
 * @author Bitu
 */
public class EncounterMedicationPanel extends javax.swing.JPanel {

    /**
     * Creates new form EncounterMedicationPanel
     */
    public EncounterMedicationPanel(TPatient patientinfo) {
        this.patientinfo = patientinfo;
        populate();
        initComponents();
        new AutoSuggestorMedication().suggesting(medication_combobox, medicationList);
        getCurrentMedications(1);
    }

    /**
     * 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() {

        medicationspanel = new javax.swing.JPanel();
        jSplitPane5 = new javax.swing.JSplitPane();
        jScrollPane12 = new javax.swing.JScrollPane();
        jPanel14 = new javax.swing.JPanel();
        jToolBar7 = new javax.swing.JToolBar();
        jLabel21 = new javax.swing.JLabel();
        jToolBar8 = new javax.swing.JToolBar();
        addmedication_button = new javax.swing.JButton();
        remove_medication_button = new javax.swing.JButton();
        taking_button = new javax.swing.JButton();
        reorder_button = new javax.swing.JButton();
        prev_medi_button = new javax.swing.JButton();
        jPanel15 = new SimpleGradientPanel();
        jLabel40 = new javax.swing.JLabel();
        jLabel42 = new javax.swing.JLabel();
        jLabel43 = new javax.swing.JLabel();
        jLabel44 = new javax.swing.JLabel();
        jScrollPane13 = new javax.swing.JScrollPane();
        medication_comments = new javax.swing.JTextArea();
        route_textbox = new javax.swing.JTextField();
        frequency_textbox = new javax.swing.JTextField();
        medication_combobox = new javax.swing.JComboBox();
        jLabel41 = new javax.swing.JLabel();
        dose_textbox = new javax.swing.JTextField();
        jPanel22 = new SimpleGradientPanel();
        medicationscroll = new javax.swing.JScrollPane();
        medication_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);
                try{
                    String id = (String)getModel().getValueAt(rowIndex, 0);
                    c.setBackground(Color.WHITE);
                    c.setForeground(Color.BLACK);
                    if(isCellSelected(rowIndex, vColIndex)){
                        c.setForeground(Color.WHITE);
                        c.setBackground(Color.BLUE);
                    }
                }catch(ClassCastException e){
                    c.setBackground(new Color(204,204,255));
                    c.setForeground(Color.BLACK);
                    if(isCellSelected(rowIndex, vColIndex)){
                        c.setForeground(Color.WHITE);
                        c.setBackground(Color.BLUE);
                    }

                }
                return c;
            }
        };

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

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

        jSplitPane5.setBorder(null);
        jSplitPane5.setDividerLocation(254);
        jSplitPane5.setDividerSize(-1);
        jSplitPane5.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

        jScrollPane12.setBorder(null);

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

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

        jLabel21.setFont(new java.awt.Font("SansSerif", 1, 14)); // NOI18N
        jLabel21.setText("  Medications :");
        jToolBar7.add(jLabel21);

        jPanel14.add(jToolBar7, java.awt.BorderLayout.PAGE_START);

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

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

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

        taking_button.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        taking_button.setText("Taking / Not Taking");
        taking_button.setFocusable(false);
        taking_button.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        taking_button.setMargin(new java.awt.Insets(2, 20, 2, 20));
        taking_button.setOpaque(false);
        taking_button.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        taking_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                taking_buttonActionPerformed(evt);
            }
        });
        jToolBar8.add(taking_button);

        reorder_button.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        reorder_button.setText("Reorder / Not Reorder");
        reorder_button.setFocusable(false);
        reorder_button.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        reorder_button.setMargin(new java.awt.Insets(2, 20, 2, 20));
        reorder_button.setOpaque(false);
        reorder_button.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        reorder_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                reorder_buttonActionPerformed(evt);
            }
        });
        jToolBar8.add(reorder_button);

        prev_medi_button.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        prev_medi_button.setText("Previous Medication");
        prev_medi_button.setFocusable(false);
        prev_medi_button.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        prev_medi_button.setMargin(new java.awt.Insets(2, 20, 2, 20));
        prev_medi_button.setOpaque(false);
        prev_medi_button.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        prev_medi_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                prev_medi_buttonActionPerformed(evt);
            }
        });
        jToolBar8.add(prev_medi_button);

        jPanel14.add(jToolBar8, java.awt.BorderLayout.PAGE_END);

        jLabel40.setFont(new java.awt.Font("SansSerif", 0, 12)); // NOI18N
        jLabel40.setText("Name :");

        jLabel42.setFont(new java.awt.Font("SansSerif", 0, 12)); // NOI18N
        jLabel42.setText("Frequency :");

        jLabel43.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N
        jLabel43.setText("Route :");

        jLabel44.setFont(new java.awt.Font("SansSerif", 0, 12)); // NOI18N
        jLabel44.setText("Comments :");

        medication_comments.setColumns(20);
        medication_comments.setRows(5);
        jScrollPane13.setViewportView(medication_comments);

        medication_combobox.setEditable(true);
        /*
        medication_combobox.setModel(new javax.swing.DefaultComboBoxModel(medicationList));
        medication_combobox.setSelectedIndex(-1);
        AutoCompleteDecorator.decorate(this.medication_combobox);*/
        medication_combobox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                medication_comboboxItemStateChanged(evt);
            }
        });

        jLabel41.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N
        jLabel41.setText("Dose :");

        javax.swing.GroupLayout jPanel15Layout = new javax.swing.GroupLayout(jPanel15);
        jPanel15.setLayout(jPanel15Layout);
        jPanel15Layout.setHorizontalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel15Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel15Layout.createSequentialGroup()
                        .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel44)
                            .addComponent(jLabel42)
                            .addComponent(jLabel43))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(medication_combobox, 0, 288, Short.MAX_VALUE)
                            .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(jScrollPane13, javax.swing.GroupLayout.DEFAULT_SIZE, 288, Short.MAX_VALUE)
                                .addComponent(route_textbox, javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(frequency_textbox))))
                    .addGroup(jPanel15Layout.createSequentialGroup()
                        .addComponent(jLabel41)
                        .addGap(40, 40, 40)
                        .addComponent(dose_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, 288, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel40, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );
        jPanel15Layout.setVerticalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel15Layout.createSequentialGroup()
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel15Layout.createSequentialGroup()
                        .addGap(12, 12, 12)
                        .addComponent(jLabel40, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel15Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(medication_combobox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(8, 8, 8)
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel42)
                    .addComponent(frequency_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(8, 8, 8)
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel41)
                    .addComponent(dose_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(8, 8, 8)
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel43)
                    .addComponent(route_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(8, 8, 8)
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel44)
                    .addComponent(jScrollPane13, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jPanel14.add(jPanel15, java.awt.BorderLayout.CENTER);

        jScrollPane12.setViewportView(jPanel14);

        jSplitPane5.setTopComponent(jScrollPane12);

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

            },
            new String [] {
                "Id", "Name", "Dose", "Frequency", "Route", "Comments", "Status", "Reorder", "EncId"
            }
        ));
        medication_table.setRowHeight(21);
        medication_table.getTableHeader().setReorderingAllowed(false);
        medication_table.getColumnModel().getColumn(0).setMinWidth(0);
        medication_table.getColumnModel().getColumn(0).setPreferredWidth(0);
        medication_table.getColumnModel().getColumn(0).setMaxWidth(0);

        medication_table.getColumnModel().getColumn(8).setMinWidth(0);
        medication_table.getColumnModel().getColumn(8).setPreferredWidth(0);
        medication_table.getColumnModel().getColumn(8).setMaxWidth(0);
        medication_table.getTableHeader().setFont(new Font("SansSerif", Font.BOLD, 11));
        medication_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        medication_table.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                medication_tableMouseClicked(evt);
            }
        });
        medicationscroll.setViewportView(medication_table);

        javax.swing.GroupLayout jPanel22Layout = new javax.swing.GroupLayout(jPanel22);
        jPanel22.setLayout(jPanel22Layout);
        jPanel22Layout.setHorizontalGroup(
            jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel22Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(medicationscroll, javax.swing.GroupLayout.DEFAULT_SIZE, 1046, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel22Layout.setVerticalGroup(
            jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel22Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(medicationscroll, javax.swing.GroupLayout.DEFAULT_SIZE, 156, Short.MAX_VALUE)
                .addContainerGap())
        );

        jSplitPane5.setRightComponent(jPanel22);

        medicationspanel.add(jSplitPane5, java.awt.BorderLayout.CENTER);

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

    private void addmedication_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addmedication_buttonActionPerformed
        if(validateMedication()){
            i=0;
            if(medication_table.getRowCount()>0){
                addmedlist = new ArrayList<String>();
                for(int i=0;i<medication_table.getRowCount();i++){
                    String medname = String.valueOf(medication_table.getValueAt(i, 1));
                    addmedlist.add(medname);
                }
                String name = medication_combobox.getSelectedItem().toString();
                for(String o:addmedlist){
                    if(o.equalsIgnoreCase(name)){
                        i=1;
                        JOptionPane.showMessageDialog(null, "Already added in table.");
                    }
                }
                if(i!=1){
                    addMedicationIntoTable();
                }
            }
            else{
                addMedicationIntoTable();
            }
        }
    }//GEN-LAST:event_addmedication_buttonActionPerformed

    private void remove_medication_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_remove_medication_buttonActionPerformed
        int row = medication_table.getSelectedRow();
        if(row!=-1){
            model = (DefaultTableModel) medication_table.getModel();
            if(String.valueOf(model.getValueAt(row, 6)).equalsIgnoreCase("canceled")){
                JOptionPane.showMessageDialog(null, "Already Canceled");
            }else{
                try{
                    String id = (String)model.getValueAt(row, 0);
                    model.removeRow(row);
                }catch(ClassCastException e){
                    DisabledGlassPane glassPane = new DisabledGlassPane();
                    JRootPane rootPane = SwingUtilities.getRootPane(this);
                    rootPane.setGlassPane(glassPane);
                    CommentsForCancelDialog c = new CommentsForCancelDialog(MainAPP, true);
                    c.setResizable(false);
                    c.setLocationRelativeTo(null);
                    glassPane.activate("");
                    c.setVisible(true);
                    c.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
                    glassPane.deactivate();
                    String comments = String.valueOf(medication_table.getValueAt(row, 5));
                    System.out.println(c.getComments());
                    if(c.getComments()!=null){
                        if(comments.equalsIgnoreCase("-")||comments==null){
                            comments=c.getComments().concat("");
                        }
                        medication_table.setValueAt(comments, row, 5);
                        medication_table.setValueAt("Canceled", row, 6);
                    }
                }
            }
        }else{
            JOptionPane.showMessageDialog(null, "No medication record selected for delete");
        }
    }//GEN-LAST:event_remove_medication_buttonActionPerformed

    private void taking_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_taking_buttonActionPerformed
        int row[] = medication_table.getSelectedRows();
        for(int i=0;i<row.length;i++){
            if(row[i]!=-1){
                String id = medication_table.getValueAt(row[i], 0).toString();
                String status = medication_table.getValueAt(row[i], 6).toString();
                String orderStatus = medication_table.getValueAt(row[i], 7).toString();
                if(!id.equalsIgnoreCase("-")){
                    if(!orderStatus.equalsIgnoreCase("Reordered")){
                        if(status.equalsIgnoreCase("taking")){
                            medication_table.setValueAt("Not Taking", row[i], 6);
                        }else if(status.equalsIgnoreCase("not taking")){
                            medication_table.setValueAt("Taking", row[i], 6);
                        }
                    }else{
                        JOptionPane.showMessageDialog(null, "First Cancel the ReOrder...");
                    }
                }else{
                    JOptionPane.showMessageDialog(null, "You can't change the status of new medication...");
                }
            }else{
                JOptionPane.showMessageDialog(null, "Select a record to change the status");
            }
        }
    }//GEN-LAST:event_taking_buttonActionPerformed

    private void reorder_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_reorder_buttonActionPerformed
        int row[] = medication_table.getSelectedRows();
        for(int i=0;i<row.length;i++){
            if(row[i]!=-1){
                String id = medication_table.getValueAt(row[i], 0).toString();
                String reorderstatus = medication_table.getValueAt(row[i], 7).toString();
                if(id.equalsIgnoreCase("-")){
                    JOptionPane.showMessageDialog(null, "You can't reorder new medication...");
                }else{
                    if(reorderstatus.equalsIgnoreCase("Reordered")){
                        medication_table.setValueAt("-", row[i], 7);
                        medication_table.setValueAt("Taking", row[i], 6);
                    }else{
                        medication_table.setValueAt("Reordered", row[i], 7);
                        medication_table.setValueAt("Not Taking", row[i], 6);
                    }
                }
            }else{
                JOptionPane.showMessageDialog(null, "Select a record to reorder");
            }
        }
    }//GEN-LAST:event_reorder_buttonActionPerformed

    private void prev_medi_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_prev_medi_buttonActionPerformed
        getPreviousMedication(0); // 0 for not taking
        DisabledGlassPane glassPane = new DisabledGlassPane();
        JRootPane rootPane = SwingUtilities.getRootPane(this);
        rootPane.setGlassPane(glassPane);
        PreviousMedicationDialog preferenceListDialog = new PreviousMedicationDialog(MainAPP, true, encPreviousMedication);
        preferenceListDialog.setResizable(false);
        preferenceListDialog.setLocationRelativeTo(null);
        glassPane.activate("");
        preferenceListDialog.setVisible(true);
        preferenceListDialog.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        glassPane.deactivate();
    }//GEN-LAST:event_prev_medi_buttonActionPerformed

    private void medication_comboboxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_medication_comboboxItemStateChanged
        TMedicationMaster id = new TMedicationMaster();
        if(medication_combobox.getSelectedIndex()!=-1){
            id = (TMedicationMaster) medication_combobox.getSelectedItem();
            if(id.getMedicationDose()!=null){
                dose_textbox.setText(String.valueOf(id.getMedicationDose()));
            }else{
                dose_textbox.setText(null);
            }
            if(id.getMedicationFrequency()!=null){
                frequency_textbox.setText(String.valueOf(id.getMedicationFrequency()));
            }else{
                frequency_textbox.setText(null);
            }
            if(id.getMedicationAdministration()!=null){
                route_textbox.setText(String.valueOf(id.getMedicationAdministration()));
            }else{
                route_textbox.setText(null);
            }
        }
    }//GEN-LAST:event_medication_comboboxItemStateChanged

    private void medication_tableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_medication_tableMouseClicked
        if (evt.getClickCount()==2) {
            TEncounterMedication medicationDetails = new TEncounterMedication();
            try{
                int row = medication_table.getSelectedRow();
                String id = String.valueOf(medication_table.getValueAt(row, 0));
                if(!id.equalsIgnoreCase("-")){
                    //we cannot modify taking status..
                    JOptionPane.showMessageDialog(null, "Selected record cann't be modified");
                }else{
                    try{
                        medicationDetails.setMedication((TMedicationMaster)(medication_table.getValueAt(row, 1)));
                    }catch(ClassCastException e){
                        TMedicationMaster medication = new TMedicationMaster();
                        medication.setMedicationName(medication_table.getValueAt(row, 1).toString());
                        medicationDetails.setMedication(medication);
                    }

                    medicationDetails.setDose(String.valueOf(medication_table.getValueAt(row, 2)));
                    medicationDetails.setFrequency(String.valueOf(medication_table.getValueAt(row, 3)));
                    medicationDetails.setRoute(String.valueOf(medication_table.getValueAt(row, 4)));
                    medicationDetails.setComments(String.valueOf(medication_table.getValueAt(row, 5)));
                    DisabledGlassPane glassPane = new DisabledGlassPane();
                    JRootPane rootPane = SwingUtilities.getRootPane(this);
                    rootPane.setGlassPane(glassPane);
                    MedicationModificationDialoge medicationModificationDialog = new MedicationModificationDialoge(MainAPP, true, medicationDetails);
                    medicationModificationDialog.setResizable(false);
                    medicationModificationDialog.setLocationRelativeTo(null);
                    glassPane.activate("");
                    medicationModificationDialog.setVisible(true);
                    medicationModificationDialog.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
                    glassPane.deactivate();
                    TEncounterMedication m = medicationModificationDialog.getMedication();
                    if(m!=null){
                        medication_table.setValueAt(m.getMedication(), row, 1);
                        medication_table.setValueAt(m.getDose(), row, 2);
                        medication_table.setValueAt(m.getFrequency(), row, 3);
                        medication_table.setValueAt(m.getRoute(), row, 4);
                        medication_table.setValueAt(m.getComments(), row, 5);
                    }
                }
            }catch(Exception e){
                e.printStackTrace();
                JOptionPane.showMessageDialog(null, MessageProperties.getMessage("notselected.edit"));
            }

        }
    }//GEN-LAST:event_medication_tableMouseClicked

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton addmedication_button;
    private javax.swing.JTextField dose_textbox;
    private javax.swing.JTextField frequency_textbox;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel40;
    private javax.swing.JLabel jLabel41;
    private javax.swing.JLabel jLabel42;
    private javax.swing.JLabel jLabel43;
    private javax.swing.JLabel jLabel44;
    private javax.swing.JPanel jPanel14;
    private javax.swing.JPanel jPanel15;
    private javax.swing.JPanel jPanel22;
    private javax.swing.JScrollPane jScrollPane12;
    private javax.swing.JScrollPane jScrollPane13;
    private javax.swing.JSplitPane jSplitPane5;
    private javax.swing.JToolBar jToolBar7;
    private javax.swing.JToolBar jToolBar8;
    private javax.swing.JComboBox medication_combobox;
    private javax.swing.JTextArea medication_comments;
    private javax.swing.JTable medication_table;
    private javax.swing.JScrollPane medicationscroll;
    private javax.swing.JPanel medicationspanel;
    private javax.swing.JButton prev_medi_button;
    private javax.swing.JButton remove_medication_button;
    private javax.swing.JButton reorder_button;
    private javax.swing.JTextField route_textbox;
    private javax.swing.JButton taking_button;
    // End of variables declaration//GEN-END:variables
    private int i=0;
    private List<String> addmedlist;
    private Vector<Object> addObject;
    private DefaultTableModel model;
    private JFrame MainAPP;
    private List<TEncounterMedication> encPreviousMedication;
    private DefaultListModel listModel;
    private List<TPatientEncounter> lastvist=null;
    private List<TEncounterMedication> encCurrentMedication;
    private OutPatientController outPatientController;
    private MedicationMasterController medicationController;
    private Vector<TMedicationMaster> medicationList = new Vector<TMedicationMaster>();
    private TPatient patientinfo;
    private OutPatientDTO medicdto;
    
    private void populate(){
        outPatientController=(OutPatientController)HealthcareLogin.context.getBean("outPatientController");
        medicationController=(MedicationMasterController)HealthcareLogin.context.getBean("medicationMasterController");
        try{
            medicationList = medicationController.getAllMedication();
            lastvist = outPatientController.getEncounterDates(patientinfo);
        }catch(Exception e){
             JOptionPane.showMessageDialog(null,MessageProperties.getMessage("error.fetch",new Object[]{"visit type"}));
             throw new HealthCareException(MessageProperties.getMessage("error.dao"));
        }
    }
    
    private boolean validateMedication(){
        boolean valid = true;
        if(medication_combobox.getSelectedIndex()==-1 && ((JTextField)medication_combobox.getEditor().getEditorComponent()).getText().length()==0){
            JOptionPane.showMessageDialog(null, MessageProperties.getMessage("medication.mandatory"));
            valid = false;
        }
        return valid;
    }
    
    private void addMedicationIntoTable() {
        addObject = new Vector<Object>();
        model = (DefaultTableModel) medication_table.getModel();
        addObject.add("-");
        addObject.add(medication_combobox.getSelectedItem());
        if(dose_textbox.getText().trim().length()>0){
            addObject.add(dose_textbox.getText());
        }else{
            addObject.add("-");
        }
        if(frequency_textbox.getText().trim().length()>0){
            addObject.add(frequency_textbox.getText());
        }else{
            addObject.add("-");
        }
        if(route_textbox.getText().trim().length()>0){
            addObject.add(route_textbox.getText());
        }else{
            addObject.add("-");
        }
        if(medication_comments.getText().trim().length()>0){
            addObject.add(medication_comments.getText());
        }else{
            addObject.add("-");
        }
        addObject.add("-");
        addObject.add("-");
        addObject.add("-");
        model.addRow(addObject);
        clearMedication();
    }
    
    private void clearMedication(){
        medication_combobox.setSelectedIndex(-1);
        dose_textbox.setText(null);
        frequency_textbox.setText(null);
        medication_comments.setText(null);
        route_textbox.setText(null);
    }
    
    private void getPreviousMedication(int status){
        try {
            encPreviousMedication = outPatientController.getEncounterMedication(lastvist,status);
        } catch (ProcessingException ex) {
            Logger.getLogger(OutPatientEncounterPanel.class.getName()).log(Level.SEVERE, null, ex);
        }
        listModel = new DefaultListModel();
        for(TEncounterMedication m:encPreviousMedication){
            listModel.addElement(m.getMedication());
        }
    }
    
    private void getCurrentMedications(int status){
        try {
            encCurrentMedication = outPatientController.getEncounterMedication(lastvist,status);
        } catch (ProcessingException ex) {
            Logger.getLogger(OutPatientEncounterPanel.class.getName()).log(Level.SEVERE, null, ex);
        }
        model = (DefaultTableModel)medication_table.getModel();
        for(TEncounterMedication m:encCurrentMedication){
             addObject = new Vector<Object>();
             addObject.add(m.getId());
             addObject.add(m.getMedication());
             if(m.getDose()!=null){
                 addObject.add(m.getDose());
             }else{
                 addObject.add("-");
             }
             if(m.getFrequency()!=null){
                 addObject.add(m.getFrequency());
             }else{
                 addObject.add("-");
             }
             if(m.getRoute()!=null){
                 addObject.add(m.getRoute());
             }else{
                 addObject.add("-");
             }
             if(m.getComments()!=null){
                 addObject.add(m.getComments());
             }else{
                 addObject.add("-");
             }
             if(m.getStatus()==1){
                 addObject.add("Taking");
             }else{
                 addObject.add("Not Taking");
             }
             addObject.add("-");
             addObject.add(m.getEncounterMed());
             model.addRow(addObject);
        }
    }
    
    public OutPatientDTO setmedicdata(){
        medicdto = new OutPatientDTO();
        medicdto.setMedicationtable(medication_table);
        return medicdto;
    }
    
    private void medtablemodel(){
        medication_table.setModel(new javax.swing.table.DefaultTableModel(new Object [][] {},new String [] {
            "Id", "Name", "Dose", "Frequency", "Route", "Comments", "Status", "Reorder", "EncId" }));
        medication_table.getColumnModel().getColumn(0).setMinWidth(0);
        medication_table.getColumnModel().getColumn(0).setPreferredWidth(0);
        medication_table.getColumnModel().getColumn(0).setMaxWidth(0);
        medication_table.getColumnModel().getColumn(8).setMinWidth(0);
        medication_table.getColumnModel().getColumn(8).setPreferredWidth(0);
        medication_table.getColumnModel().getColumn(8).setMaxWidth(0);
        medication_table.getTableHeader().setFont(new Font("SansSerif", Font.BOLD, 11));
        medication_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    }
}

Commits for Aurocare_27_07_2018/AuroCareEMR/src/main/java/com/bestray/healthcareemr/Views/EncounterMedicationPanel.java

Diff revisions: vs.
Revision Author Commited Message
1 girijabapi picture girijabapi Fri 27 Jul, 2018 07:21:55 +0000