Subversion Repository Public Repository

Pharmacy_09_03_18

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
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bestray.healthcareemr.Views;

import com.bestray.healthcarecommonutil.controller.MyFavController;
import com.bestray.healthcarecommonutil.exception.HealthCareException;
import com.bestray.healthcarecommonutil.exception.ProcessingException;
import com.bestray.healthcarecommonutil.util.DisabledGlassPane;
import com.bestray.healthcarecommonutil.util.HeadingPanel;
import com.bestray.healthcarecommonutil.util.Initcap;
import com.bestray.healthcarecommonutil.util.PanelType;
import com.bestray.healthcarecommonutil.util.PreferenceUtil;
import com.bestray.healthcarecommonutil.util.SimpleGradientPanel;
import com.bestray.healthcarecommonutil.util.TextPrompt;
import com.bestray.healthcarecommonutil.util.Theme;
import com.bestray.healthcarecommonutil.vo.TAccount;
import com.bestray.healthcarecommonutil.vo.TAllergiesMaster;
import com.bestray.healthcarecommonutil.vo.TEncounterAllergy;
import com.bestray.healthcarecommonutil.vo.TPatientEncounter;
import com.bestray.healthcareemr.Controller.AllergiesMasterController;
import com.bestray.healthcareemr.Util.MessageProperties;
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 java.util.prefs.Preferences;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JRootPane;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
import com.bestray.healthcarecommonutil.views.MyFavAllergySearchDialog;
import com.bestray.healthcareemr.Controller.AmbulatoryAllergyController;

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

    /**
     * Creates new form AmbulatoryAllergyPanel
     */
    public AmbulatoryAllergyPanel() {
        populateData();
        initComponents();
        TextPrompt tp7 = new TextPrompt("Search For Allergy", allergySerachTextfield);
        tp7.setForeground( Color.RED );
        tp7.changeAlpha(0.5f);
        tp7.changeStyle(Font.BOLD);
    }
    
    public AmbulatoryAllergyPanel(TPatientEncounter encounter) {
        this.encounter = encounter;
        populateData();
        initComponents();
        TextPrompt tp7 = new TextPrompt("Search For Allergy", allergySerachTextfield);
        tp7.setForeground( Color.RED );
        tp7.changeAlpha(0.5f);
        tp7.changeStyle(Font.BOLD);
        this.encounter = encounter;
        allergyTableModel();
        fetchAvailableAllergy();
    }

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

        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        ambulatoryAllergyTable = 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;
            }

        };
        jToolBar2 = new javax.swing.JToolBar();
        allergyRemoveButton = new javax.swing.JButton();
        allergyEditButton = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jPanel2 = new HeadingPanel("", Theme.GLOSSY_SKYBLUE_THEME, PanelType.PANEL_ROUNDED_RECTANGLUR);
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jPanel3 = new SimpleGradientPanel();
        allergySerachTextfield = new javax.swing.JTextField();
        jToolBar1 = new javax.swing.JToolBar();
        allergySerachButton = new javax.swing.JButton();

        setBackground(new java.awt.Color(255, 255, 255));
        setLayout(new java.awt.BorderLayout());

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));

        ambulatoryAllergyTable.setAutoCreateRowSorter(true);
        ambulatoryAllergyTable.setFont(new java.awt.Font("SansSerif", 0, 12)); // NOI18N
        ambulatoryAllergyTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        ambulatoryAllergyTable.setRowHeight(25);
        ambulatoryAllergyTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        ambulatoryAllergyTable.setShowHorizontalLines(false);
        ambulatoryAllergyTable.setShowVerticalLines(false);
        ambulatoryAllergyTable.getTableHeader().setReorderingAllowed(false);
        ambulatoryAllergyTable.getTableHeader().setFont(new Font("SansSerif", Font.BOLD, 10));
        jScrollPane1.setViewportView(ambulatoryAllergyTable);

        jToolBar2.setBackground(new java.awt.Color(204, 204, 255));
        jToolBar2.setFloatable(false);
        jToolBar2.setRollover(true);

        allergyRemoveButton.setFont(new java.awt.Font("SansSerif", 1, 11)); // NOI18N
        allergyRemoveButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/delete 16x16.png"))); // NOI18N
        allergyRemoveButton.setText("Remove");
        allergyRemoveButton.setFocusable(false);
        allergyRemoveButton.setMargin(new java.awt.Insets(2, 20, 2, 20));
        allergyRemoveButton.setOpaque(false);
        allergyRemoveButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                allergyRemoveButtonActionPerformed(evt);
            }
        });
        jToolBar2.add(allergyRemoveButton);

        allergyEditButton.setFont(new java.awt.Font("SansSerif", 1, 11)); // NOI18N
        allergyEditButton.setText("Edit Details");
        allergyEditButton.setFocusable(false);
        allergyEditButton.setMargin(new java.awt.Insets(2, 20, 2, 20));
        allergyEditButton.setOpaque(false);
        //allergyEditButton.setVisible(false);
        allergyEditButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                allergyEditButtonActionPerformed(evt);
            }
        });
        jToolBar2.add(allergyEditButton);

        jButton4.setFont(new java.awt.Font("SansSerif", 1, 11)); // NOI18N
        jButton4.setText("Previeous Allergies");
        jButton4.setFocusable(false);
        jButton4.setMargin(new java.awt.Insets(2, 20, 2, 20));
        jButton4.setOpaque(false);
        jButton4.setVisible(false);
        jToolBar2.add(jButton4);

        jPanel2.setBackground(new java.awt.Color(127, 180, 234));

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Text-Edit-icon24X24.png"))); // NOI18N

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setText("Allergy Details");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel2)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addGap(5, 5, 5)
                .addComponent(jLabel1)
                .addGap(5, 5, 5))
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addContainerGap())
        );

        jPanel3.setBackground(new java.awt.Color(255, 255, 255));

        allergySerachTextfield.setFont(new java.awt.Font("SansSerif", 0, 12)); // NOI18N

        jToolBar1.setBackground(new java.awt.Color(255, 255, 255));
        jToolBar1.setFloatable(false);
        jToolBar1.setRollover(true);
        jToolBar1.setOpaque(false);

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

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(allergySerachTextfield, javax.swing.GroupLayout.PREFERRED_SIZE, 270, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, 0)
                .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addGap(8, 8, 8)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(allergySerachTextfield)
                    .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(8, 8, 8))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jToolBar2, javax.swing.GroupLayout.DEFAULT_SIZE, 1026, Short.MAX_VALUE)
            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING)
            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, 0)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, 0)
                .addComponent(jToolBar2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, 0)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 339, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, 0))
        );

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

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

                    @Override
                    protected Object doInBackground() throws Exception {
                        rootPane.setGlassPane(glassPane);
                        glassPane.activateLoadingImage();
                        if(expr.length()>0){
                            allergieslist = myFavController.getAllergyByName(expr);
                        }else{
                            allergieslist = allergiesController.getAllAllergies();
                        }
                        return allergieslist;
                    }

                    @Override
                    protected void done() {
                        if(allergieslist.size()!=0){
                            super.done();
                            myfavallergieslist = new Vector<TAllergiesMaster>();
                            try {
                                myfavallergieslist = myFavController.getFavAllergyByAccount(useraccount,"ALLERGY");
                            } catch (ProcessingException ex) {
                                Logger.getLogger(EncounterFollowupPanel.class.getName()).log(Level.SEVERE, null, ex);
                            }
                            glassPane.deactivate();
                            glassPane.activate("");
                            MyFavAllergySearchDialog allergySearchDialog = new MyFavAllergySearchDialog(MainAPP, true,allergieslist,myfavallergieslist,expr);
                            allergySearchDialog.setResizable(false);
                            allergySearchDialog.setLocationRelativeTo(null);
                            allergySearchDialog.setVisible(true);
                            allergySearchDialog.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
                            glassPane.deactivate();
                            List<TAllergiesMaster> allergies = allergySearchDialog.getAllergyList();
                            if(allergies.size()>0){
                                showSelectedAllergy(allergies);
                            }
                        }else{
                            JOptionPane.showMessageDialog(null, "No allergy present");
                            glassPane.deactivate();
                            allergySerachTextfield.setText(null);
                        }
                    }

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

    private void allergyRemoveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allergyRemoveButtonActionPerformed
        int row = ambulatoryAllergyTable.getSelectedRow();
        model = (DefaultTableModel) ambulatoryAllergyTable.getModel();
            if(row!=-1){
                    TEncounterAllergy allergy = (TEncounterAllergy)ambulatoryAllergyTable.getValueAt(row, 0);
                    model.removeRow(row);
                    removeAllergy(allergy.getId());               
            }else{
                JOptionPane.showMessageDialog(null, "No allergy selected for delete");
            }
    }//GEN-LAST:event_allergyRemoveButtonActionPerformed

    private void allergyEditButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allergyEditButtonActionPerformed
        
            try{
                int row = ambulatoryAllergyTable.getSelectedRow();
                if(row != -1){
                    TEncounterAllergy encAllergy = (TEncounterAllergy)ambulatoryAllergyTable.getValueAt(row, 0);
//                    TEncounterAllergy encAllergy = new TEncounterAllergy();
//                    TAllergiesMaster tAllergiesMaster = (TAllergiesMaster)ambulatoryAllergyTable.getValueAt(row, 0); 
//                    encAllergy.setAllergy(tAllergiesMaster);
                    encAllergy.setAllergy((encAllergy.getAllergy()));
                    encAllergy.setEncounter(encounter);
                if(ambulatoryAllergyTable.getValueAt(row, 1)!=null){
                    encAllergy.setReaction(String.valueOf(ambulatoryAllergyTable.getValueAt(row, 2)));
                }else{
                    encAllergy.setReaction(null);
                }
                if(ambulatoryAllergyTable.getValueAt(row, 2)!=null){
                    encAllergy.setSeverity(String.valueOf(ambulatoryAllergyTable.getValueAt(row, 3)));
                }else{
                    encAllergy.setSeverity(null);
                }
                if(ambulatoryAllergyTable.getValueAt(row, 3)!=null){
                    encAllergy.setComments(String.valueOf(ambulatoryAllergyTable.getValueAt(row, 4)));
                }else{
                    encAllergy.setComments(null);
                }
                DisabledGlassPane glassPane = new DisabledGlassPane();
                JRootPane rootPane = SwingUtilities.getRootPane(this);
                rootPane.setGlassPane(glassPane);
                AllergyModificationDialog allergyModificationDialog = new AllergyModificationDialog(MainAPP, true, encAllergy);
                allergyModificationDialog.setResizable(false);
                allergyModificationDialog.setLocationRelativeTo(null);
                glassPane.activate("");
                allergyModificationDialog.setVisible(true);
                allergyModificationDialog.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
                glassPane.deactivate();
                TEncounterAllergy encounterAllergy = allergyModificationDialog.getAllergy();
                if(encounterAllergy != null){
                    ambulatoryAllergyController.saveAllergyEncounter(allergyModificationDialog.getAllergy());
                    ambulatoryAllergyTable.setValueAt(encounterAllergy, row, 0);
                    ambulatoryAllergyTable.setValueAt(encounterAllergy.getAllergy().getAllergiesName(), row, 1);
                    ambulatoryAllergyTable.setValueAt(encounterAllergy.getReaction(), row, 2);
                    ambulatoryAllergyTable.setValueAt(encounterAllergy.getSeverity(), row, 3);
                    ambulatoryAllergyTable.setValueAt(encounterAllergy.getComments(), row, 4);
                }
                }else{
                    JOptionPane.showMessageDialog(null, MessageProperties.getMessage("notselected.edit"));
                }
            }catch(Exception e){
                e.printStackTrace();
//                JOptionPane.showMessageDialog(null, MessageProperties.getMessage("notselected.edit"));
            }
    }//GEN-LAST:event_allergyEditButtonActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton allergyEditButton;
    private javax.swing.JButton allergyRemoveButton;
    private javax.swing.JButton allergySerachButton;
    private javax.swing.JTextField allergySerachTextfield;
    private javax.swing.JTable ambulatoryAllergyTable;
    private javax.swing.JButton jButton4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JToolBar jToolBar2;
    // End of variables declaration//GEN-END:variables
    private TPatientEncounter encounter = new TPatientEncounter();
    private TEncounterAllergy allergyEnc = new TEncounterAllergy();
    private TEncounterAllergy allergyDetails;
    private AmbulatoryAllergyController ambulatoryAllergyController;
    private MyFavController myFavController;
    private AllergiesMasterController allergiesController;
    private TAccount useraccount;
    private Preferences myPrefObj = Preferences.userRoot();
    private List<TEncounterAllergy> availableAllergyOnCurrentEnc = new ArrayList<TEncounterAllergy>();
    private Vector<TAllergiesMaster> allergieslist = new Vector<TAllergiesMaster>();
    private Vector<TAllergiesMaster> myfavallergieslist = new Vector<TAllergiesMaster>();
    private Vector<Object> addObject;
    private DefaultTableModel model;
    private JRootPane rootPane;
    private DisabledGlassPane glassPane;
    private JFrame MainAPP;
    private String expr;    
    
    private void populateData(){
        ambulatoryAllergyController = (AmbulatoryAllergyController)HealthcareLogin.context.getBean("ambulatoryAllergyController");
        allergiesController =(AllergiesMasterController)HealthcareLogin.context.getBean("allergiesMasterController");
        myFavController = (MyFavController)HealthcareLogin.context.getBean("myFavController");
        try{
            useraccount = (TAccount)PreferenceUtil.getObject(myPrefObj, "user");
        }catch(Exception e){
             JOptionPane.showMessageDialog(null,MessageProperties.getMessage("error.fetch",new Object[]{"Current ueser details"}));
             throw new HealthCareException(MessageProperties.getMessage("error.dao"));
        }
    }

    private void allergyTableModel() {
        ambulatoryAllergyTable.setModel(new javax.swing.table.DefaultTableModel(new Object [][] {},new String [] {
                "Obj","Agents", "Reaction", "Severity", "Comments"}));
        ambulatoryAllergyTable.getColumnModel().getColumn(0).setMinWidth(0);
        ambulatoryAllergyTable.getColumnModel().getColumn(0).setPreferredWidth(0);
        ambulatoryAllergyTable.getColumnModel().getColumn(0).setMaxWidth(0);
    }

    private void fetchAvailableAllergy() {                
        try{
            availableAllergyOnCurrentEnc = ambulatoryAllergyController.getEncounterAllergy(encounter);
        } catch (ProcessingException ex) {
            Logger.getLogger(AmbulatoryAllergyPanel.class.getName()).log(Level.SEVERE, null, ex);
        }
        showAvaialbleAllergy(availableAllergyOnCurrentEnc);
    }

    private void showAvaialbleAllergy(List<TEncounterAllergy> allergies) {
        model = (DefaultTableModel)ambulatoryAllergyTable.getModel();
          for(TEncounterAllergy encAllergy:allergies){
            addObject = new Vector<Object>();  
            addObject.add(encAllergy);
            addObject.add(encAllergy.getAllergy().getAllergiesName());
            addObject.add(encAllergy.getReaction());
            addObject.add(encAllergy.getSeverity());
            addObject.add(encAllergy.getComments());
            model.addRow(addObject);
          }             
    }
    /*Show All Selected Allergy By Encounter*/
    private void showSelectedAllergy(List<TAllergiesMaster> selectedAllergies) {
        model = (DefaultTableModel)ambulatoryAllergyTable.getModel();
       for(TAllergiesMaster allergy : selectedAllergies){
           addObject = new Vector<Object>();  
           TEncounterAllergy encounterAllergy = new TEncounterAllergy();
           encounterAllergy.setEncounter(encounter);
           encounterAllergy.setAllergy(allergy);
           encounterAllergy.setComments("");
           encounterAllergy.setReaction("");
           encounterAllergy.setSeverity("");
            try {
                allergyEnc = ambulatoryAllergyController.saveAllergyEncounter(encounterAllergy);
                allergyDetails = allergyEnc;
                addObject.add(allergyEnc);
                addObject.add(allergyEnc.getAllergy().getAllergiesName());
                addObject.add(allergyEnc.getReaction());
                addObject.add(allergyEnc.getSeverity());
                addObject.add(allergyEnc.getComments());
                model.addRow(addObject);
            } catch (ProcessingException ex) {
                Logger.getLogger(AmbulatoryAllergyPanel.class.getName()).log(Level.SEVERE, null, ex);
            }
       }
    }
   /* Remove Allergy from Encounter*/
    private void removeAllergy(Long removeallergy){
            try {
                ambulatoryAllergyController.deleteEncounterAllergies(removeallergy);
            } catch (ProcessingException ex) {
                Logger.getLogger(AmbulatoryAllergyPanel.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IllegalArgumentException ex) {
                Logger.getLogger(AmbulatoryAllergyPanel.class.getName()).log(Level.SEVERE, null, ex);
            }
    }
}

Commits for Pharmacy_09_03_18/Dr Gyana ProjectSpace/DrGyanaEMR/src/main/java/com/bestray/healthcareemr/Views/AmbulatoryAllergyPanel.java

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