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
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
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
/*
 * 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.report.LabReceipt;
import com.bestray.healthcarecommonutil.util.ButtonType;
import com.bestray.healthcarecommonutil.util.CurvedGradientPanel;
import com.bestray.healthcarecommonutil.util.SimpleGradientPanel;
import com.bestray.healthcarecommonutil.util.StandardButton;
import com.bestray.healthcarecommonutil.util.Theme;
import com.bestray.healthcarecommonutil.vo.TAccount;
import com.bestray.healthcarecommonutil.vo.TPatLabReceipt;
import com.bestray.healthcarecommonutil.vo.TPatient;
import com.bestray.healthcarecommonutil.vo.TProcedureMaster;
import com.bestray.healthcareemr.Controller.LabReceiptAmbulatoryController;
import com.bestray.healthcareemr.Controller.ProcedureMasterController;
import com.bestray.healthcarecommonutil.util.Initcap;
import com.bestray.healthcareemr.Util.MessageProperties;
import com.bestray.healthcarecommonutil.util.PreferenceUtil;
import com.bestray.healthcarecommonutil.util.TimeRange;
import com.bestray.healthcarecommonutil.vo.TEncounterProcedure;
import com.bestray.healthcarecommonutil.vo.TPatientEncounter;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.text.SimpleDateFormat;
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.JOptionPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.table.TableCellRenderer;
import org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException;

/**
 *
 * @author User1
 */
public class LabReceiptAmbulatoryDialog extends javax.swing.JDialog {

    /**
     * Creates new form LabReceiptAmbulatoryDialog
     */
    public LabReceiptAmbulatoryDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }
    
    public LabReceiptAmbulatoryDialog(java.awt.Frame parent, boolean modal, TPatient patientInfo, JTable procedureTable, TPatientEncounter enc) {
        super(parent, modal);
        populateData();
        initComponents();
        showPatientInfo(patientInfo);
        this.encounter = enc;
        showSelectedProcedures(procedureTable);
    }

    /**
     * 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 SimpleGradientPanel(Color.WHITE,Color.LIGHT_GRAY);
        jPanel2 = new javax.swing.JPanel();
        jLabel38 = new javax.swing.JLabel();
        patientidlabel = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        namelabel = new javax.swing.JLabel();
        sexlabel = new javax.swing.JLabel();
        agelabel = new javax.swing.JLabel();
        doblabel = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        contactnumberlabel = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        addresslabel = new javax.swing.JLabel();
        jButton1 = new StandardButton("Close",Theme.STANDARD_RED_THEME,ButtonType.BUTTON_RECTANGULAR);
        jPanel3 = new CurvedGradientPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        orderPrice_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;
            }

        };
        jLabel39 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        paidPrice_textbox = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        comment_taxtArea = new javax.swing.JTextArea();
        jLabel13 = new javax.swing.JLabel();
        receivedBy_textbox = new javax.swing.JTextField();
        star_label = new javax.swing.JLabel();
        adjustment_textbox = new javax.swing.JTextField();
        totalPrice_textbox = new javax.swing.JTextField();
        receivedNumber_textbox = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        mandatoryStar_label = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        save_button = new StandardButton("Save & Print",Theme.STANDARD_ORANGE_THEME,ButtonType.BUTTON_RECTANGULAR);

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setUndecorated(true);

        jPanel2.setBackground(new java.awt.Color(255, 255, 204));
        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel38.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jLabel38.setText("Patient ID :");

        patientidlabel.setFont(new java.awt.Font("Bookman Old Style", 0, 13)); // NOI18N
        patientidlabel.setText("patientId");

        jLabel3.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jLabel3.setText("Name :");

        jLabel9.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jLabel9.setText("Sex :");

        jLabel7.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jLabel7.setText("Age :");

        jLabel11.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jLabel11.setText("DOB :");

        namelabel.setFont(new java.awt.Font("Bookman Old Style", 0, 13)); // NOI18N
        namelabel.setText("jLabel1");

        sexlabel.setFont(new java.awt.Font("Bookman Old Style", 0, 13)); // NOI18N
        sexlabel.setText("jLabel1");

        agelabel.setFont(new java.awt.Font("Bookman Old Style", 0, 13)); // NOI18N
        agelabel.setText("jLabel1");

        doblabel.setFont(new java.awt.Font("Bookman Old Style", 0, 13)); // NOI18N
        doblabel.setText("jLabel1");

        jLabel1.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jLabel1.setText("Contact Number :");

        contactnumberlabel.setFont(new java.awt.Font("Bookman Old Style", 0, 13)); // NOI18N
        contactnumberlabel.setText("jLabel2");

        jLabel2.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jLabel2.setText("Address :");

        addresslabel.setFont(new java.awt.Font("Bookman Old Style", 0, 13)); // NOI18N
        addresslabel.setText("jLabel5");

        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()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(namelabel, javax.swing.GroupLayout.PREFERRED_SIZE, 212, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel38)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(patientidlabel, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(contactnumberlabel, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(addresslabel, javax.swing.GroupLayout.PREFERRED_SIZE, 183, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(sexlabel, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(95, 95, 95)
                        .addComponent(jLabel11)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(doblabel, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(33, 33, 33)
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(agelabel, javax.swing.GroupLayout.PREFERRED_SIZE, 210, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(105, 105, 105))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel38)
                    .addComponent(patientidlabel)
                    .addComponent(jLabel9)
                    .addComponent(sexlabel)
                    .addComponent(jLabel11)
                    .addComponent(doblabel)
                    .addComponent(jLabel7)
                    .addComponent(agelabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(contactnumberlabel)
                    .addComponent(jLabel2)
                    .addComponent(addresslabel)
                    .addComponent(jLabel3)
                    .addComponent(namelabel))
                .addContainerGap())
        );

        jButton1.setFont(new java.awt.Font("SansSerif", 1, 13)); // NOI18N
        jButton1.setText("Close");
        jButton1.setOpaque(false);
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

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

        orderPrice_table.getTableHeader().setFont(new Font("SansSerif", Font.BOLD, 11));
        orderPrice_table.setModel(new javax.swing.table.DefaultTableModel(prescribeOrderList,header));
        orderPrice_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        jScrollPane1.setViewportView(orderPrice_table);

        jLabel39.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jLabel39.setText("Lab Orders :");

        jLabel6.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
        jLabel6.setText("Total Amount :");

        jLabel8.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
        jLabel8.setText("Paid Amount :");

        paidPrice_textbox.setBackground(new java.awt.Color(255, 243, 251));
        paidPrice_textbox.setFont(new java.awt.Font("SansSerif", 0, 13)); // NOI18N
        paidPrice_textbox.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                paidPrice_textboxKeyReleased(evt);
            }
        });

        jLabel10.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
        jLabel10.setText("Adjustment :");

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

        comment_taxtArea.setColumns(20);
        comment_taxtArea.setRows(5);
        jScrollPane2.setViewportView(comment_taxtArea);

        jLabel13.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
        jLabel13.setText("Received By :");

        receivedBy_textbox.setBackground(new java.awt.Color(255, 243, 251));
        receivedBy_textbox.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N

        star_label.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        star_label.setForeground(new java.awt.Color(255, 0, 0));
        star_label.setText("*");
        star_label.setVisible(false);

        adjustment_textbox.setEditable(false);
        adjustment_textbox.setBackground(new java.awt.Color(255, 243, 251));
        adjustment_textbox.setFont(new java.awt.Font("SansSerif", 0, 13)); // NOI18N
        adjustment_textbox.setBorder(null);
        adjustment_textbox.setOpaque(false);

        totalPrice_textbox.setEditable(false);
        totalPrice_textbox.setBackground(new java.awt.Color(255, 243, 251));
        totalPrice_textbox.setFont(new java.awt.Font("SansSerif", 0, 13)); // NOI18N
        totalPrice_textbox.setBorder(null);
        totalPrice_textbox.setOpaque(false);

        receivedNumber_textbox.setEditable(false);
        receivedNumber_textbox.setBackground(new java.awt.Color(255, 243, 251));
        receivedNumber_textbox.setFont(new java.awt.Font("SansSerif", 0, 13)); // NOI18N
        receivedNumber_textbox.setForeground(new java.awt.Color(255, 0, 0));
        receivedNumber_textbox.setBorder(null);
        receivedNumber_textbox.setOpaque(false);

        jLabel14.setFont(new java.awt.Font("SansSerif", 0, 14)); // NOI18N
        jLabel14.setText("Receipt # :");

        mandatoryStar_label.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        mandatoryStar_label.setForeground(new java.awt.Color(255, 0, 0));
        mandatoryStar_label.setText("*");
        star_label.setVisible(false);

        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()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel39)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 537, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(mandatoryStar_label)
                        .addGap(0, 0, 0)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel8)
                            .addComponent(jLabel12)
                            .addComponent(jLabel13)
                            .addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(receivedNumber_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 190, Short.MAX_VALUE)
                                    .addComponent(receivedBy_textbox))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(star_label))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(paidPrice_textbox, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(totalPrice_textbox, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel10)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(adjustment_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap(39, Short.MAX_VALUE))
        );

        jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {adjustment_textbox, paidPrice_textbox, totalPrice_textbox});

        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel39)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 151, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(receivedNumber_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel14))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(totalPrice_textbox)
                            .addComponent(adjustment_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel8)
                            .addComponent(paidPrice_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(mandatoryStar_label))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel12)
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(star_label))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(receivedBy_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel13))
                        .addGap(22, 22, 22))))
        );

        jPanel3Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {adjustment_textbox, paidPrice_textbox, receivedBy_textbox, receivedNumber_textbox, totalPrice_textbox});

        jLabel4.setFont(new java.awt.Font("SansSerif", 1, 13)); // NOI18N
        jLabel4.setForeground(new java.awt.Color(102, 153, 255));
        jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/edit order detail 24X24.png"))); // NOI18N
        jLabel4.setText("Lab Order Receipt :");

        save_button.setFont(new java.awt.Font("SansSerif", 1, 13)); // NOI18N
        save_button.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Save-icon 16X16.png"))); // NOI18N
        save_button.setText("Save & Print");
        save_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                save_buttonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 971, Short.MAX_VALUE)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton1))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(save_button)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(5, 5, 5)
                        .addComponent(jLabel4))
                    .addComponent(jButton1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 12, Short.MAX_VALUE)
                .addComponent(save_button)
                .addContainerGap())
        );

        getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        dispose();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void save_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_save_buttonActionPerformed
        try{
            if(validateReceiptSave()){
                 if(labReceipt!=null){
                    labReceipt.setTotalTrice(totalPrice_textbox.getText());
                    labReceipt.setPaidPrice(String.valueOf(Double.parseDouble(paidPrice_textbox.getText())));
                    labReceipt.setAdjustmentAmount(adjustment_textbox.getText());
                    labReceipt.setComments(comment_taxtArea.getText());
                    labReceipt.setReceivedBy(receivedBy_textbox.getText());
                    Long ID = labReceiptAmbulatoryController.saveReceiptDetails(labReceipt);
                    JOptionPane.showMessageDialog(null, "Information saved and printing receipt.");
                    //For Lab Receipt Print
                    LabReceipt labreceipt = new LabReceipt();
                    String procedure_master_id = "";
                    String receipt_id = String.valueOf(labReceipt.getId());
                    for(Long procedureID:prescribedTest){
                        procedure_master_id = procedure_master_id.concat(procedureID.toString()).concat(",");
                    }
                    int lastIndex = procedure_master_id.lastIndexOf(",");
                    String orderid = procedure_master_id.substring(0, lastIndex);
                    String patientName = namelabel.getText();
                     labreceipt.getPdfReport(receipt_id, orderid,patientName);
                           int reply = JOptionPane.showConfirmDialog(null, "Do you want to open this file ?", "All Lab Report", JOptionPane.YES_NO_OPTION);
                           if (reply == JOptionPane.YES_OPTION){
                               labreceipt.openPdfReport();
                           }
             
            
                 }else{
                     labReceipt = new TPatLabReceipt();
                    labReceipt.setReceiptNumber(receivedNumber_textbox.getText());
                    labReceipt.setPatientId(patientinfo);
                    labReceipt.setTotalTrice(totalPrice_textbox.getText());
                    labReceipt.setPaidPrice(String.valueOf(Double.parseDouble(paidPrice_textbox.getText())));
                    labReceipt.setAdjustmentAmount(adjustment_textbox.getText());
                    labReceipt.setComments(comment_taxtArea.getText());
                    labReceipt.setReceivedBy(receivedBy_textbox.getText());
                    labReceipt.setEncounterId(encounter);
                    savedReceiptID = labReceiptAmbulatoryController.saveReceiptDetails(labReceipt);
                    JOptionPane.showMessageDialog(null, "Information saved and printing receipt.");

                    //For Lab Receipt Print
                    LabReceipt labreceipt = new LabReceipt();
                    String procedure_master_id = "";
                    String receipt_id = String.valueOf(savedReceiptID);
                    for(Long procedureID:prescribedTest){
                        procedure_master_id = procedure_master_id.concat(procedureID.toString()).concat(",");
                    }
                    int lastIndex = procedure_master_id.lastIndexOf(",");
                    String orderid = procedure_master_id.substring(0, lastIndex);
                    String patientName = namelabel.getText();
                     labreceipt.getPdfReport(receipt_id, orderid,patientName);
                    int reply = JOptionPane.showConfirmDialog(null, "Do you want to open this file ?", "All Lab Report", JOptionPane.YES_NO_OPTION);
                    if (reply == JOptionPane.YES_OPTION){
                        labreceipt.openPdfReport();
                    }
               }
               }else{
//                     JOptionPane.showMessageDialog(null, "Information not saved.");
               }
           }catch(HibernateOptimisticLockingFailureException e){
                 JOptionPane.showMessageDialog(null, MessageProperties.getMessage("error.update",new Object[]{"Receipt"}));
           }catch(ProcessingException e){
                 JOptionPane.showMessageDialog(null, MessageProperties.getMessage("error.save",new Object[]{"Receipt"}));
                 throw new HealthCareException(MessageProperties.getMessage("error.dao"));
           }catch(Exception e){
                 JOptionPane.showMessageDialog(null, MessageProperties.getMessage("error.save",new Object[]{"Receipt"}));
           }
    }//GEN-LAST:event_save_buttonActionPerformed

    private void paidPrice_textboxKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_paidPrice_textboxKeyReleased
        if(validateAmountPaid()){
        Double remaining = Double.parseDouble(totalPrice_textbox.getText())-Double.parseDouble(paidPrice_textbox.getText());
        adjustment_textbox.setText(String.valueOf(remaining));
        if(remaining!=0){
            star_label.setVisible(true);
        }else{
            star_label.setVisible(false);
        }
      }
    }//GEN-LAST:event_paidPrice_textboxKeyReleased

    /**
     * @param args the command line arguments
     
    public static void main(String args[]) {
        /* Set the Nimbus look and feel 
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(LabReceiptAmbulatoryDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(LabReceiptAmbulatoryDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(LabReceiptAmbulatoryDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(LabReceiptAmbulatoryDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the dialog 
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                LabReceiptAmbulatoryDialog dialog = new LabReceiptAmbulatoryDialog(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }*/
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel addresslabel;
    private javax.swing.JTextField adjustment_textbox;
    private javax.swing.JLabel agelabel;
    private javax.swing.JTextArea comment_taxtArea;
    private javax.swing.JLabel contactnumberlabel;
    private javax.swing.JLabel doblabel;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel38;
    private javax.swing.JLabel jLabel39;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel mandatoryStar_label;
    private javax.swing.JLabel namelabel;
    private javax.swing.JTable orderPrice_table;
    private javax.swing.JTextField paidPrice_textbox;
    private javax.swing.JLabel patientidlabel;
    private javax.swing.JTextField receivedBy_textbox;
    private javax.swing.JTextField receivedNumber_textbox;
    private javax.swing.JButton save_button;
    private javax.swing.JLabel sexlabel;
    private javax.swing.JLabel star_label;
    private javax.swing.JTextField totalPrice_textbox;
    // End of variables declaration//GEN-END:variables
    private TPatient patientinfo;
    SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-YYYY");
    private Vector<String> header;
    private Vector<Vector<String>> prescribeOrderList = new Vector<Vector<String>>();
    List<Long> prescribedTest = new ArrayList<Long>();
    private ProcedureMasterController procedureMasterController;
    private LabReceiptAmbulatoryController labReceiptAmbulatoryController;
    private TPatLabReceipt labReceipt;
    private Long savedReceiptID;
    private TPatientEncounter encounter;
    
    private void populateData(){
        //labReceipt = new TPatLabReceipt();
        patientinfo = new TPatient();
        encounter = new TPatientEncounter();
        header = new Vector<String>();
        header.add("Order Name");
        header.add("Order Date");
        header.add("Order Price");
        procedureMasterController=(ProcedureMasterController)HealthcareLogin.context.getBean("procedureMasterController");
        labReceiptAmbulatoryController=(LabReceiptAmbulatoryController)HealthcareLogin.context.getBean("labReceiptAmbulatoryController");
    }
    
    private void showPatientInfo(TPatient patient) {
        this.patientinfo = patient;
        String patientFullName = null;
        if(patientinfo.getPatientMName()!=null){
            patientFullName = Initcap.toInitCap(patientinfo.getPatientFName())+" "+Initcap.toInitCap(patientinfo.getPatientMName())+" "+Initcap.toInitCap(patientinfo.getPatientLName());
        }else if(patientinfo.getPatientMName()==null){
            patientFullName = Initcap.toInitCap(patientinfo.getPatientFName())+" "+Initcap.toInitCap(patientinfo.getPatientLName());
        }
        namelabel.setText(patientFullName);
        doblabel.setText(sdf.format(patientinfo.getBirthDate()));
        sexlabel.setText(patientinfo.getPatientGender());
        patientidlabel.setText(patientinfo.getPatientId());
        List<String> totalAge = TimeRange.calculateAge(patientinfo.getBirthDate());
        agelabel.setText(totalAge.get(0)+" Yrs "+totalAge.get(1)+" months ");
        if(patientinfo.getPatientMNumber()!=null){
            contactnumberlabel.setText(String.valueOf(patientinfo.getPatientMNumber()));
         }else{
                contactnumberlabel.setText("");
         }
         if(patientinfo.getPresentAddress1()!=null){
            addresslabel.setText(String.valueOf(patientinfo.getPresentAddress1()));
         }else{
            addresslabel.setText("");
         }
    }

    private void showSelectedProcedures(JTable procedureTable) {
        Double totalPrice = 0d;
        String receiptID = null;
        labReceipt = findAvailableLabReceipt();
        if(labReceipt!=null){
                try {
                    for(int i=0;i<procedureTable.getRowCount();i++){
                        String procedureName = procedureTable.getValueAt(i, 1).toString(); System.out.println("procedureName"+procedureName);
                        String orderDate = procedureTable.getValueAt(i, 3).toString();
                        TProcedureMaster procedure = procedureMasterController.getProcedureByName(procedureName);
                        prescribedTest.add(procedure.getId());
                        Double testPrice = procedure.getProcedurePrice();
                        totalPrice+=testPrice;
                        Vector<String> priceList = new Vector<String>();
                        priceList.add(procedureName);
                        priceList.add(orderDate);
                        priceList.add(String.valueOf(testPrice));
                        prescribeOrderList.add(priceList);
                     }
                }catch (ProcessingException ex) {
                    Logger.getLogger(LabReceiptAmbulatoryDialog.class.getName()).log(Level.SEVERE, null, ex);
                }
            orderPrice_table.setModel(new javax.swing.table.DefaultTableModel(prescribeOrderList,header));
            totalPrice_textbox.setText(String.valueOf(totalPrice));
            receivedNumber_textbox.setText(labReceipt.getReceiptNumber());
            TAccount useraccount = null;
            Preferences myPrefObj = Preferences.userRoot();
            try{
                useraccount = (TAccount)PreferenceUtil.getObject(myPrefObj, "user");
            }catch(Exception e){
                receivedBy_textbox.setText("");
            }
            receivedBy_textbox.setText(useraccount.getFirstName()+" "+ useraccount.getLastName());
        }else{
            try {
                    for(int i=0;i<procedureTable.getRowCount();i++){
                        TEncounterProcedure encProcedure = (TEncounterProcedure)procedureTable.getValueAt(i, 0);
                        TProcedureMaster procedureMaster = encProcedure.getProcedure();
                        String procedureName = procedureMaster.getProcedureName();
                        String orderDate = procedureTable.getValueAt(i, 3).toString();
                        TProcedureMaster procedure = procedureMasterController.getProcedureByName(procedureName);
                        prescribedTest.add(procedure.getId());
                        Double testPrice = procedure.getProcedurePrice();
                        totalPrice+=testPrice;
                        Vector<String> priceList = new Vector<String>();
                        priceList.add(procedureName);
                        priceList.add(orderDate);
                        priceList.add(String.valueOf(testPrice));
                        prescribeOrderList.add(priceList);
                     }
                }catch (ProcessingException ex) {
                    Logger.getLogger(LabReceiptAmbulatoryDialog.class.getName()).log(Level.SEVERE, null, ex);
                }
            orderPrice_table.setModel(new javax.swing.table.DefaultTableModel(prescribeOrderList,header));
            totalPrice_textbox.setText(String.valueOf(totalPrice));
            try{
                receiptID = labReceiptAmbulatoryController.getReceiptId();
            }catch(Exception e){
                throw new HealthCareException("Failed To Get The Max Lab Receipt Id");
            }
            receivedNumber_textbox.setText(receiptID);
            TAccount useraccount = null;
            Preferences myPrefObj = Preferences.userRoot();
            try{
                useraccount = (TAccount)PreferenceUtil.getObject(myPrefObj, "user");
            }catch(Exception e){
                receivedBy_textbox.setText("");
            }
            receivedBy_textbox.setText(useraccount.getFirstName()+" "+ useraccount.getLastName());
        }

    }

    private boolean validateAmountPaid() {
        boolean valid = true;
        if (this.paidPrice_textbox.getText().trim().length() == 0) {
            JOptionPane.showMessageDialog(null, MessageProperties.getMessage("labPaidAmount.mandatory"));
            paidPrice_textbox.requestFocus();
            valid = false;
        }
        else if(!this.paidPrice_textbox.getText().matches("^\\d*[\\.]?\\d*$")) {
            JOptionPane.showMessageDialog(null, MessageProperties.getMessage("labPaidAmount.type"));
            paidPrice_textbox.requestFocus();
            paidPrice_textbox.selectAll();
            valid = false;
        }
        return valid;
    }
    
    private boolean validateReceiptSave() {
        boolean valid = true;
        if (Double.parseDouble(adjustment_textbox.getText())!=0) {
            if(comment_taxtArea.getText().length()==0){
                JOptionPane.showMessageDialog(null, "Please Enter a proper reason in comment section.");
                valid = false;
            }
        }
        return valid;
    }
    
    private TPatLabReceipt findAvailableLabReceipt(){
        try{
            return labReceiptAmbulatoryController.findAvailableLabReceipt(patientinfo,encounter);
        }catch (ProcessingException ex) {
                Logger.getLogger(LabReceiptAmbulatoryDialog.class.getName()).log(Level.SEVERE, null, ex);
                return null;
        }
        
    }
    
}

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

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