Subversion Repository Public Repository

Satyam

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bestray.healthcarecommonutil.serviceimpl;

import com.bestray.healthcarecommonutil.dao.CodeTypeDao;
import com.bestray.healthcarecommonutil.dao.CodeValuesDao;
import com.bestray.healthcarecommonutil.exception.DataAccessException;
import com.bestray.healthcarecommonutil.exception.HealthCareException;
import com.bestray.healthcarecommonutil.exception.ProcessingException;
import com.bestray.healthcarecommonutil.service.CodeValuesService;
import com.bestray.healthcarecommonutil.vo.TCCodeType;
import com.bestray.healthcarecommonutil.vo.TCCodeValues;
import java.sql.Timestamp;
import java.util.List;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


// TODO: Auto-generated Javadoc
/**
 * The Class CodeValuesServiceImpl.
 *
 * @author user3
 */
@Transactional
@Service
public class CodeValuesServiceImpl implements CodeValuesService{
    
    /** The code type dao. */
    @Autowired
    private CodeTypeDao codeTypeDao;
    
    /** The codetype. */
    private TCCodeType codetype;
    
    /** The codevalues. */
    private TCCodeValues codevalues;
    
    /** The codeid. */
    private int codeid;
    
    /** The codetypeid. */
    private int codetypeid;
    
    /** The id. */
    private int id;
    
    /** The flag. */
    private boolean flag;
    
    /** The code values dao. */
    @Autowired
    private CodeValuesDao codeValuesDao;
    
    /** The date. */
    final java.util.Date date= new java.util.Date();

    public CodeValuesServiceImpl() {
        codetype = new TCCodeType();
        codevalues = new TCCodeValues();
        codeid=0;
        codetypeid=0;
    }
    
    /**
     * Instantiates a new code values service impl.
     *
     * @param codeTypeDao the code type dao
     * @param codeValuesDao the code values dao
     
    public CodeValuesServiceImpl(CodeTypeDao codeTypeDao,CodeValuesDao codeValuesDao){
        this.codeTypeDao = codeTypeDao;
        codetype = new TCCodeType();
        codevalues = new TCCodeValues();
        codeid=0;
        codetypeid=0;
        this.codeValuesDao = codeValuesDao;
    }
    
    /* (non-Javadoc)
     * @see com.bestray.healthcareemr.Service.CodeValuesService#createNewCodeValue(com.bestray.healthcareemr.Vo.TCCodeValues, java.lang.String)
     */
    @Override
    public boolean createNewCodeValue(TCCodeValues codevalues, String s)throws ProcessingException,HibernateOptimisticLockingFailureException {
          try{
              List<TCCodeType> codetypes = codeTypeDao.searchForCodeTypeName(s);
              flag = false;
              codetype = new TCCodeType();
              if(codetypes.isEmpty()){
                codetype.setCodeTypeName(s);
                codeTypeDao.addToCodeType(codetype);
                if(codevalues.getCodeValueName()!=null && codevalues.getCodeValueName().trim().length()>0){
                  List<TCCodeType> codetypess = codeTypeDao.searchForCodeTypeName(s);
                  TCCodeType ctype=null;
                  for(TCCodeType codetyp : codetypess){
                      ctype=codetyp;
                      codeid = codetyp.getCodeTypeId();
                 }
                  codevalues.setTccodetype(ctype);
                  codevalues.setCreatedDate(new Timestamp(date.getTime()));
                  codeValuesDao.addToCodeValues(codevalues);
                  flag=true;
              } 
              return flag;
          }
          else{
              for(TCCodeType codetype1 : codetypes){
            	  codetype=codetype1;
                  codetypeid=codetype1.getCodeTypeId();
              }
              

              if(codevalues.getCodeValueId()!=null && codevalues.getCodeValueId()>0){
                    codevalues.setUpdatedDate(new Timestamp(date.getTime()));
                    codeValuesDao.updateCodeValues(codevalues);
                    flag=true;
                }else{
                	List<TCCodeValues> codeval = codeValuesDao.searchForCodeValueName(codevalues.getCodeValueName(),codetype);
                    if(!codeval.isEmpty()){
                        JOptionPane.showMessageDialog(null, "Value Name Already Exist...");
                        flag=false;
                    }else{
                        
                        codevalues.setTccodetype(codetype);
                        codevalues.setCreatedDate(new Timestamp(date.getTime()));
                        codeValuesDao.addToCodeValues(codevalues);
                        flag=true;
                    }
                }
              return flag;
          }
          }catch(HibernateOptimisticLockingFailureException e){
            Logger.getLogger(CodeValuesServiceImpl.class.getName()).log(Level.SEVERE, null, e);
            throw e;
         }catch(DataAccessException e){
              Logger.getLogger(CodeValuesServiceImpl.class.getName()).log(Level.SEVERE, null, e);
              throw new ProcessingException();
         }catch(Exception e){
             Logger.getLogger(CodeValuesServiceImpl.class.getName()).log(Level.SEVERE, null, e);
             throw new HealthCareException("Error in Saving...");
        }
    }
    
    /* (non-Javadoc)
     * @see com.bestray.healthcareemr.Service.CodeValuesService#getValuesList(java.lang.String, java.lang.String, int, int)
     */
    @Transactional(readOnly = true)       
    @Override
    public Vector<Vector<String>> getValuesList(String codeType,String expr,int min,int max)throws ProcessingException {
        TCCodeType codetype=null;
        try {
            List<TCCodeType> codetypes = codeTypeDao.searchForCodeTypeName(codeType);
            for(TCCodeType code : codetypes){
                codetype = code;
                id = code.getCodeTypeId();
            }
            Vector<Vector<String>> value = new Vector<Vector<String>>();
            List<TCCodeValues> valuesList;
            
                valuesList = codeValuesDao.findAllValuesList(codetype,expr,min,max);
            
            for (TCCodeValues val : valuesList) {
                Vector<String> valss = new Vector<String>();
                valss.add(String.valueOf(val.getCodeValueId()));
                valss.add(String.valueOf(min+1));
                valss.add(String.valueOf(val.getCodeValueName()));
                if(val.getRecordStatus()==true){
                    valss.add("ACTIVE");
                }
                else{
                    valss.add("INACTIVE");
                }
                value.add(valss);
                min++;
            }
            return value;
        }catch (DataAccessException ex) {
            Logger.getLogger(CodeValuesServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
            throw new ProcessingException();
        }catch(Exception ex) {
            Logger.getLogger(CodeValuesServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
            throw new HealthCareException("Error in populating data");
         }
    }

    /* (non-Javadoc)
     * @see com.bestray.healthcareemr.Service.CodeValuesService#getValues(java.lang.Long)
     */
    @Transactional(readOnly = true)
    @Override
    public TCCodeValues getValues(Long valuesId)throws ProcessingException {
        TCCodeValues values;
        try{
            values = codeValuesDao.getDetails(valuesId);
            return values;
        }catch(DataAccessException e){
            Logger.getLogger(CodeValuesServiceImpl.class.getName()).log(Level.SEVERE, null, e);
            throw new ProcessingException();
        }
    }

    /* (non-Javadoc)
     * @see com.bestray.healthcareemr.Service.CodeValuesService#deleteValues(java.lang.Long)
     */
    @Override
    public void deleteValues(Long valuesId)throws ProcessingException,IllegalArgumentException {
        try{
            codeValuesDao.deleteValuesMaster(valuesId);
        }catch(IllegalArgumentException e){
            //Logger.getLogger(CodeValuesServiceImpl.class.getName()).log(Level.SEVERE, null, e);
            throw e;
        }catch(DataAccessException e){
            Logger.getLogger(CodeValuesServiceImpl.class.getName()).log(Level.SEVERE, null, e);
            throw new ProcessingException();
        }
    }

    /* (non-Javadoc)
     * @see com.bestray.healthcareemr.Service.CodeValuesService#getMaxId()
     */
    @Override
    public Long getMaxId() throws ProcessingException {
        try{
             return codeValuesDao.getMaxId();
        }catch(DataAccessException e){
            Logger.getLogger(CodeValuesServiceImpl.class.getName()).log(Level.SEVERE, null, e);
            throw new ProcessingException();
        }
    }

    /* (non-Javadoc)
     * @see com.bestray.healthcareemr.Service.CodeValuesService#numberOfCodeValueRecords(java.lang.String, java.lang.String)
     */
    @Override
    public int numberOfCodeValueRecords(String expr,String codeType) throws ProcessingException {
        TCCodeType codetype=null;
        try{
            List<TCCodeType> codetypes = codeTypeDao.searchForCodeTypeName(codeType);
            for(TCCodeType code : codetypes){
                codetype = code;
                //id = code.getCodeTypeId();
            }
            return codeValuesDao.numberOfCodeValueRecords(expr,codetype);
            
        }catch(DataAccessException e){
            Logger.getLogger(CodeValuesServiceImpl.class.getName()).log(Level.SEVERE, null, e);
            throw new ProcessingException();
        }
    }

    /* (non-Javadoc)
     * @see com.bestray.healthcareemr.Service.CodeValuesService#getCodeAllType()
     */
    @Override
    public List<TCCodeType> getCodeAllType() throws ProcessingException {
        try{
            return codeTypeDao.getCodeAllType();
        }catch(DataAccessException e){
            Logger.getLogger(CodeValuesServiceImpl.class.getName()).log(Level.SEVERE, null, e);
            throw new ProcessingException();
        }
    }

    /* (non-Javadoc)
     * @see com.bestray.healthcareemr.Service.CodeValuesService#getCodeValues(java.lang.String)
     */
    @Override
    public List<TCCodeValues> getCodeValues(String codeTypeName)throws ProcessingException{
        TCCodeType codetype = null;
        try{
            List<TCCodeType> codeTypes = codeTypeDao.getCodeAllType();
            for(TCCodeType codeType:codeTypes){
                if(codeType.getCodeTypeName().equalsIgnoreCase(codeTypeName)){
                    codetype = codeType;
                }
            }
            return codeValuesDao.getCodeValues(codetype);
        }catch(DataAccessException e){
            Logger.getLogger(CodeValuesServiceImpl.class.getName()).log(Level.SEVERE, null, e);
            throw new ProcessingException();
        }
    }
}

Commits for Satyam/AuroCareCommonUtil/src/main/java/com/bestray/healthcarecommonutil/serviceimpl/CodeValuesServiceImpl.java

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