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
package com.bestray.healthcareemr.Util;

import com.bestray.healthcarecommonutil.dao.PatientDao;
import com.bestray.healthcareemr.Dao.LabReceiptAmbulatoryDao;

    // TODO: Auto-generated Javadoc
/**
     * The Class UniqueID.
     */
    public class UniqueID {
        
        /** The current. */
        static long current= System.currentTimeMillis();
        
        /** The patient dao. */
        
        private PatientDao patientDao;
        
        /** The Lab Receipt dao. */
        
        private LabReceiptAmbulatoryDao labReceiptDao;
        
        /** The single instance. */
        private static UniqueID singleInstance;
        
    
        /**
         * Instantiates a new unique id.
         */
        private UniqueID() {}
        
        /**
         * Instantiates a new unique id.
         *
         * @param patientDao the patient dao
         */
        /*public UniqueID(PatientDao patientDao,LabReceiptAmbulatoryDao labReceiptDao){
            this.patientDao = patientDao;
            this.labReceiptDao = labReceiptDao;
        }*/

        /**
         * Gets the.
         *
         * @return the long
         */
        public static synchronized long get(){

            return current++;
        }
        
        /**
         * Gets the patient id.
         *
         * @return the patient id
         */
        /*
        public synchronized String getPatientId(){
            try{
                String patientId=patientDao.getIdToInsert();
                long idpartnum=Integer.parseInt(patientId);
                idpartnum+=1;
                return String.valueOf(idpartnum);
            }catch(DataAccessException | NumberFormatException e){
                throw new HealthCareException("Failed To Get The Max Patient Id");
            }
        }
        
        public synchronized String getReceiptId(){
            try{
                String receiptId=labReceiptDao.getIdToInsert();
                long idpartnum=Integer.parseInt(receiptId);
                idpartnum+=1;
                return String.valueOf(idpartnum);
            }catch(DataAccessException | NumberFormatException e){
                throw new HealthCareException("Failed To Get The Max Patient Id");
            }
        }
        public synchronized String getPatientId(){
            String patientId=null;
            try{
                patientId=patientDao.getIdToInsert();
                
                String idpart1=patientId.substring(0,1);
                String idpart2=patientId.substring(1);
                //System.out.println("idpart1 :"+idpart1);
                //System.out.println("idpart2 :"+idpart2);
                //String fullid=idpart1.concat(idpart2);
                //System.out.println("Original ID :"+fullid);
                long idpart2num=Integer.parseInt(idpart2);
        
                if(!idpart1.equalsIgnoreCase("z") && !idpart2.matches("[9]+")){
                    idpart2num+=1;
                }
        
                if(idpart1.equalsIgnoreCase("z") && !idpart2.matches("[9]+")){
                    idpart2num+=1;
                }
        
                if(!idpart1.equalsIgnoreCase("z") && idpart2.matches("[9]+")){
                    char c=idpart1.charAt(0);
                    char newc=(char)((int)c+1);
                    idpart1=String.valueOf(newc);
                    idpart2num+=1;
                }
        
                if(idpart1.equalsIgnoreCase("z") && idpart2.matches("[9]+")){
                    //System.out.println("1st part contains Z and 2nd Part contains only 9");
                    idpart1="A";
                    idpart2num+=1;
                }
                String newId=idpart1+idpart2num;
                //System.out.println("New Id :"+newId);
                return newId;
            }catch(Exception e){
                e.printStackTrace();
                throw new HealthCareException("Failed To Get The Max Patient Id");
            }
    }*/
    /**
         * Gets the single instance.
         *
         * @return the single instance
         */
        public static UniqueID getSingleInstance() {
    if (singleInstance == null) {
      synchronized (UniqueID.class) {
        if (singleInstance == null) {
          singleInstance = new UniqueID();
        }
      }
    }
    return singleInstance;
  }

}

Commits for Aurocare_27_07_2018/AuroCareEMR/src/main/java/com/bestray/healthcareemr/Util/UniqueID.java

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