· 9 years ago · Dec 21, 2016, 12:00 PM
1package gosi.business.socialinsurance.occupationalhazards.injury.session;
2// Import Statements
3import gosi.core.util.ServiceLocator;
4import gosi.core.util.GOSIDebug;
5import javax.ejb.SessionBean;
6import javax.ejb.SessionContext;
7import javax.ejb.EJBException;
8import java.rmi.RemoteException;
9import java.sql.Connection;
10import java.sql.PreparedStatement;
11import java.sql.ResultSet;
12import java.util.HashMap;
13import java.util.ArrayList;
14import java.util.Calendar;
15import javax.naming.Context;
16import javax.rmi.PortableRemoteObject;
17import gosi.core.util.GOSIInstrumentationLog;
18import gosi.core.util.GOSIConstants;
19import gosi.core.util.GOSIErrorMessages;
20import gosi.core.util.GOSIException;
21import gosi.core.util.GOSIUtilities;
22import gosi.core.util.beans.AuditBean;
23import gosi.core.workflow.beans.WorkflowParamBean;
24import gosi.business.socialinsurance.occupationalhazards.injury.beans.TransferOHHelperBean;
25import gosi.business.socialinsurance.occupationalhazards.common.beans.OHConstants;
26import gosi.business.socialinsurance.occupationalhazards.common.beans.OHServices;
27import gosi.business.socialinsurance.common.beans.SITables;
28import java.sql.Timestamp;
29import gosi.core.util.GOSIDateUtilities;
30import gosi.business.socialinsurance.common.beans.SIUtilities;
31import gosi.core.dms.beans.DMSRequestHeaderBean;
32import gosi.core.dms.beans.DMSConstants;
33import gosi.core.dms.util.DMSUtilities;
34import gosi.core.util.CommonTransactions;
35import gosi.core.util.beans.NotificationLetterBean;
36import gosi.business.socialinsurance.occupationalhazards.injury.beans.OHQueryInjury;
37import gosi.business.socialinsurance.registration.engagement.beans.EngagementDetailsBean;
38import gosi.business.socialinsurance.registration.engagement.beans.EngagementBean;
39import gosi.business.socialinsurance.registration.engagement.beans.EngagementOccupationBean;
40import gosi.business.socialinsurance.registration.engagement.beans.WageChangeCoverageBean;
41import gosi.business.socialinsurance.common.beans.PersonBean;
42import gosi.business.socialinsurance.registration.establishment.beans.EstablishmentBean;
43import gosi.business.socialinsurance.registration.establishment.beans.EstablishmentUtility;
44import gosi.business.socialinsurance.registration.establishment.beans.EstablishmentBean;
45import gosi.business.socialinsurance.common.beans.PersonBean;
46import gosi.business.socialinsurance.common.beans.PersonUtilities;
47import gosi.business.socialinsurance.occupationalhazards.injury.beans.AddInjuryHelperBean;
48import gosi.database.socialinsurance.occupationalhazards.injury.entity.InjuryDocReqEntity;
49import gosi.database.socialinsurance.occupationalhazards.injury.entity.InjuryDocReqEntityHome;
50import gosi.database.socialinsurance.occupationalhazards.injury.entity.InjuryEntity;
51import gosi.database.socialinsurance.occupationalhazards.injury.entity.InjuryEntityHome;
52import gosi.database.socialinsurance.occupationalhazards.injury.entity.PMREntity;
53import gosi.database.socialinsurance.occupationalhazards.injury.entity.PMREntityHome;
54import gosi.database.socialinsurance.occupationalhazards.injury.entity.PreexistingDeformitiesEntity;
55import gosi.database.socialinsurance.occupationalhazards.injury.entity.PreexistingDeformitiesEntityHome;
56import gosi.database.socialinsurance.occupationalhazards.injury.entity.BodyPartsEntity;
57import gosi.database.socialinsurance.occupationalhazards.injury.entity.BodyPartsEntityHome;
58import gosi.database.socialinsurance.occupationalhazards.injury.entity.TransferOHEntity;
59import gosi.database.socialinsurance.occupationalhazards.injury.entity.TransferOHEntityHome;
60import gosi.database.socialinsurance.occupationalhazards.injury.entity.TreatmentEntity;
61import gosi.database.socialinsurance.occupationalhazards.injury.entity.TreatmentEntityHome;
62import gosi.business.socialinsurance.occupationalhazards.injury.beans.BodyPartsListBean;
63import gosi.business.socialinsurance.registration.engagement.beans.ContributorBean;
64import gosi.business.socialinsurance.registration.engagement.beans.ContributorUtilities;
65import gosi.database.socialinsurance.occupationalhazards.injury.entity.InjuryDiagnosisEntity;
66import gosi.database.socialinsurance.occupationalhazards.injury.entity.InjuryDiagnosisEntityHome;
67import gosi.database.socialinsurance.occupationalhazards.injury.entity.ResumeTreatmentEntity;
68import gosi.database.socialinsurance.occupationalhazards.injury.entity.ResumeTreatmentEntityHome;
69import gosi.business.socialinsurance.occupationalhazards.injury.beans.ChangeRegNoBean;
70import gosi.database.socialinsurance.occupationalhazards.injury.entity.OHestChangesEntityHome;
71import gosi.database.socialinsurance.occupationalhazards.injury.entity.OHestChangesEntity;
72import gosi.business.socialinsurance.occupationalhazards.injury.beans.InjuryDocReqListBean;
73import gosi.business.socialinsurance.occupationalhazards.injury.beans.InjuryDocReqSearchBean;
74import gosi.business.socialinsurance.occupationalhazards.injury.beans.OHPopSearchListBean;
75import gosi.business.socialinsurance.occupationalhazards.injury.beans.InjuryBean;
76import gosi.business.socialinsurance.occupationalhazards.injury.beans.PMRHelperBean;
77import gosi.business.socialinsurance.occupationalhazards.injury.beans.ResumeBean;
78import gosi.business.socialinsurance.occupationalhazards.injury.beans.TreatmentPeriodBean;
79import gosi.core.util.beans.IndividualContactBean;
80import gosi.business.socialinsurance.occupationalhazards.common.beans.OHUtilities;
81import gosi.business.socialinsurance.common.beans.ContactDetailsUtility;
82import gosi.business.socialinsurance.registration.common.beans.RegistrationConstants;
83import gosi.business.socialinsurance.registration.engagement.beans.EngagementUtilities;
84import gosi.common.letters.beans.LetterHeaderBean;
85import gosi.common.letters.util.LetterUtilities;
86import gosi.common.reports.beans.ReportConstants;
87import java.util.TreeMap;
88import gosi.core.security.common.beans.SecurityAndWorkflowConstants;
89
90/**
91 * @CLASS NAME : MaintainInjurySessionEJB
92 * @TYPE : SessionEJB
93 * @AUTHOR : TCS
94 * @VERSION : 1
95 * @EXTENDS : Nil
96 * @INFORMATION : Session EJB object is used to Maintain Injury Component.
97 * @IMPLEMENTS : SessionBean
98 * @TABLES REFERRED : T_injury,T_accident,T_injurysource,T_injurynature,T_contributor,T_conpreexistingdeformities,T_establishment
99 * @LAST MODIFIED BY :
100 * @LAST MODIFIED DATE :
101 * @stereotype SessionBean
102 * @homeInterface gosi.business.socialinsurance.occupationalhazards.injury.session.MaintainInjurySessionHome
103 * @remoteInterface gosi.business.socialinsurance.occupationalhazards.injury.session.MaintainInjurySession
104 */
105public class MaintainInjurySessionEJB implements SessionBean
106{
107 private Connection conn=null;
108 private SessionContext sesCtx = null;
109 /**
110 * @METHOD NAME : MaintainInjurySessionEJB
111 * @INFORMATION : This method is the constructor
112 * @PARAM : class java.lang.String
113 * @RETURN : class java.lang.Class
114 * @EXCEPTION :
115 * @LAST MODIFIED BY :
116 * @LAST MODIFIED DATE :
117 **/
118 public MaintainInjurySessionEJB()
119 {
120 }
121 /**
122 * @METHOD NAME : ejbCreate
123 * @INFORMATION : This method is to ejb Create
124 * @PARAM :
125 * @RETURN : void
126 * @EXCEPTION :
127 * @LAST MODIFIED BY :
128 * @LAST MODIFIED DATE :
129 **/
130 public void ejbCreate ()
131 {
132 }
133 /**
134 * @METHOD NAME : ejbRemove
135 * @INFORMATION : This method is to ejb Remove
136 * @PARAM :
137 * @RETURN : void
138 * @EXCEPTION :
139 * @LAST MODIFIED BY :
140 * @LAST MODIFIED DATE :
141 **/
142 public void ejbRemove ()
143 {
144 }
145 /**
146 * @METHOD NAME : ejbActivate
147 * @INFORMATION : This method is to ejb Activate
148 * @PARAM :
149 * @RETURN : void
150 * @EXCEPTION :
151 * @LAST MODIFIED BY :
152 * @LAST MODIFIED DATE :
153 **/
154 public void ejbActivate ()
155 {
156 }
157 /**
158 * @METHOD NAME : ejbPassivate
159 * @INFORMATION : This method is to ejb Passivate
160 * @PARAM :
161 * @RETURN : void
162 * @EXCEPTION :
163 * @LAST MODIFIED BY :
164 * @LAST MODIFIED DATE :
165 **/
166 public void ejbPassivate ()
167 {
168 }
169 /**
170 * @METHOD NAME : setSessionContext
171 * @INFORMATION : This method is to set Session Context
172 * @PARAM : interface javax.ejb.SessionContext
173 * @RETURN : void
174 * @EXCEPTION : class javax.ejb.EJBException,
175 class java.rmi.RemoteException
176 * @LAST MODIFIED BY :
177 * @LAST MODIFIED DATE :
178 **/
179 public void setSessionContext(SessionContext sesCtx)
180 throws EJBException,RemoteException
181 {
182 this.sesCtx=sesCtx;
183 }
184 /**
185 * @METHOD NAME : isValidSocInsNumber
186 * @INFORMATION : This method is to Validate the Social Insurance Number entered
187 * @PARAM : class java.lang.Long
188 * @RETURN : boolean
189 * @EXCEPTION : class gosi.core.util.GOSIException
190 * @LAST MODIFIED BY :
191 * @LAST MODIFIED DATE :
192 **/
193 public boolean isValidSocInsNumber(Long socInsNumber) throws GOSIException
194 {
195 boolean isSocInsNumber=false;
196 PreparedStatement ps =null;
197 ResultSet rsCommon =null;
198 String sqlQuery="";
199 long startTime = 0;
200 long endTime = 0;
201 long elapsedTime = 0;
202 startTime = System.currentTimeMillis();
203
204 try
205 {
206 conn =GOSIUtilities.getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
207 StringBuffer queryBuffer =new StringBuffer();
208 //Query to get contributor details from contributor table
209 queryBuffer.append(OHQueryInjury.OhQry_QRY_00056 );
210 queryBuffer.append(" FROM ");
211 queryBuffer.append(SITables.T_CONTRIBUTOR);
212 queryBuffer.append(" WHERE SOCIALINSURANCENUMBER=?");
213
214 sqlQuery = queryBuffer.toString();
215 GOSIDebug.debugMessages(""+sqlQuery);
216 ps=conn.prepareStatement(sqlQuery);
217 ps.setLong(1,socInsNumber.longValue());
218 rsCommon=ps.executeQuery();
219 GOSIDebug.debugMessages(""+sqlQuery);
220 if(rsCommon.next())
221 {
222 if (rsCommon.getInt("con") >0)
223 {
224 isSocInsNumber=true;
225 }
226 }
227 // if contributor details found flag set to true
228 // else set to false
229
230 if(isSocInsNumber == false)
231 {
232 throw new GOSIException( GOSIConstants.SEVERITY_THREE,
233 GOSIConstants.SOCIAL_INSURANCE,
234 this.getClass().toString(),
235 "isValidSocInsNumber()",
236 new GOSIException(),
237 "SOI_ERR_1012"
238 );
239 }
240 endTime = System.currentTimeMillis();
241 elapsedTime = endTime - startTime;
242 GOSIInstrumentationLog.writeInstrumentationToLog(
243 this.getClass().toString(),
244 "isValidSocInsNumber()",
245 elapsedTime);
246
247 }
248 catch (GOSIException ge)
249 {
250 throw ge;
251 }
252 catch(Exception e)
253 {
254
255 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
256 GOSIConstants.SOCIAL_INSURANCE,
257 this.getClass().toString(),
258 "isValidSocInsNumber()",
259 e,
260 "CMN_ERR_1000"
261 );
262 }
263 finally
264 {
265 GOSIUtilities.cleanUp(conn, ps, rsCommon);
266 }
267 return isSocInsNumber;
268 }
269 /**
270 * @METHOD NAME : searchIndividualContactList
271 * @INFORMATION : This method is to get the Individual Contact details of the contributor
272 * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.AddInjuryHelperBean
273 * @RETURN : class java.util.ArrayList
274 * @EXCEPTION : class gosi.core.util.GOSIException
275 * @LAST MODIFIED BY :
276 * @LAST MODIFIED DATE :
277 **/
278 public ArrayList searchIndividualContactList
279 (AddInjuryHelperBean injuryBean)
280 throws GOSIException
281 {
282 Long contactId=null;
283 long startTime = 0;
284 long endTime = 0;
285 long elapsedTime = 0;
286 ArrayList contactArrayList=null;
287 startTime = System.currentTimeMillis();
288 try
289 {
290 // the contact details of the contributor is fetched using
291 // the ContactDetailsUtility and using the contact id
292 // stored in the disease bean
293 contactId=injuryBean.getContactId();
294 if(contactId!=null)
295 {
296 contactArrayList=ContactDetailsUtility.
297 getIndividualContactList
298 (contactId,GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
299 GOSIDebug.debugMessages("After coming out of utilities:"+
300 contactArrayList);
301 }
302 }
303 catch (GOSIException ge)
304 {
305 throw ge;
306 }
307 catch(Exception e)
308 {
309 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
310 GOSIConstants.SOCIAL_INSURANCE,
311 this.getClass().toString(),
312 "searchIndividualContactList()",
313 e,
314 "CMN_ERR_1000"
315 );
316 }
317 endTime = System.currentTimeMillis();
318 elapsedTime = endTime - startTime;
319 GOSIInstrumentationLog.writeInstrumentationToLog(
320 this.getClass().toString(),
321 "searchIndividualContactList()",
322 elapsedTime);
323 return contactArrayList;
324 }
325 /**
326 * @METHOD NAME : getContactIdList
327 * @INFORMATION : This method is to check whether the contact details exist for this contributor or not.
328 * @PARAM : class java.lang.Long
329 * @RETURN : class java.util.ArrayList
330 * @EXCEPTION : class gosi.core.util.GOSIException
331 * @LAST MODIFIED BY :
332 * @LAST MODIFIED DATE :
333 **/
334 public ArrayList getContactIdList(Long socInsNumber)
335 throws GOSIException
336 {
337
338 String sqlQuery="";
339 PreparedStatement ps =null;
340 ResultSet rsCommon =null;
341 long startTime = 0;
342 long endTime = 0;
343 long elapsedTime = 0;
344
345 startTime = System.currentTimeMillis();
346
347 StringBuffer queryBuffer = new StringBuffer();
348 // query to get the contact details of the contributor
349
350 queryBuffer.append(OHQueryInjury.OhQry_QRY_00057 );
351 queryBuffer.append(" FROM ");
352 queryBuffer.append(SITables.T_CONTRIBUTOR);
353 queryBuffer.append(" WHERE SOCIALINSURANCENUMBER=?");
354
355 sqlQuery = queryBuffer.toString();
356
357 ArrayList contactDetExists=new ArrayList();
358
359 contactDetExists.clear();
360 try
361 {
362 conn = GOSIUtilities.
363 getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
364 ps=conn.prepareStatement(sqlQuery);
365 ps.setLong(1,socInsNumber.longValue());
366 rsCommon=ps.executeQuery();
367 GOSIDebug.debugMessages(""+sqlQuery);
368
369 AddInjuryHelperBean injuryBean =null;
370 // if contact details exists the contact id is added to the
371 // disease bean and added to the array list and returned
372
373 while(rsCommon.next())
374 {
375 injuryBean =
376 new AddInjuryHelperBean();
377 injuryBean.
378 setContactId(new Long
379 (rsCommon.getLong("CONTACTID")));
380 if(!rsCommon.wasNull())
381 {
382 GOSIDebug.debugMessages("setContactId:"+
383 injuryBean.getContactId());
384 contactDetExists.add(injuryBean);
385 GOSIDebug.debugMessages("size of list in sesBean:"+
386 contactDetExists.size());
387 }
388 }
389 endTime = System.currentTimeMillis();
390 elapsedTime = endTime - startTime;
391 GOSIInstrumentationLog.writeInstrumentationToLog(
392 this.getClass().toString(),
393 "getContactIdList()",
394 elapsedTime);
395 }
396 catch (GOSIException ge)
397 {
398 throw ge;
399 }
400 catch(Exception e)
401 {
402 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
403 GOSIConstants.SOCIAL_INSURANCE,
404 this.getClass().toString(),
405 "getContactId()",
406 e,
407 "CMN_ERR_1000"
408 );
409 }
410 finally
411 {
412 GOSIUtilities.cleanUp(conn, ps, rsCommon);
413 }
414 return contactDetExists;
415 }
416 /**
417 * @METHOD NAME : addInjury
418 * @INFORMATION : This method is to add an injury
419 (save it into the T_INJURY table and the child
420 tables T_BODYPARTS,T_CONPREEXISTINGDEFORMITIES,
421 T_INJURYDIAGNOSIS)
422 * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.AddInjuryHelperBean,
423 class gosi.core.workflow.beans.WorkflowParamBean,
424 class java.lang.String,
425 class java.util.ArrayList,
426 class gosi.core.util.beans.AuditBean,
427 class java.util.ArrayList,
428 class java.util.ArrayList,
429 int,
430 class gosi.core.dms.beans.DMSRequestHeaderBean
431 * @RETURN : class java.util.HashMap
432 * @EXCEPTION : class gosi.core.util.GOSIException
433 * @LAST MODIFIED BY :
434 * @LAST MODIFIED DATE :
435 **/
436 public HashMap addInjury(AddInjuryHelperBean injuryBean,
437 WorkflowParamBean workflowParamBean,
438 String contact,
439 ArrayList contactList,
440 AuditBean contactAuditBean,
441 ArrayList injuryBodyParts,
442 ArrayList icdList,int noOfYears,
443 DMSRequestHeaderBean headerBean)
444 throws GOSIException
445 {
446 Long injuryNumber;
447 String userName="";
448 GOSIDebug.debugMessages("getPreExistDeformitiesId().............."+
449 injuryBean.getPreExistDeformitiesId());
450 Long contactID;
451 long startTime = 0;
452 long endTime = 0;
453 long elapsedTime = 0;
454
455 startTime = System.currentTimeMillis();
456 HashMap injuryMap = null;
457 try
458 {
459 // this method is used to add the injury details into the
460 // T_INJURY table , along with injury , other tables such
461 // as T_Induvidualcontactdetails ,T_conprexistingdeformities
462 // T_injurredbodyparts and T_icd details are modifed
463 conn = GOSIUtilities.getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
464 injuryBean.setInjuryId(
465 GOSIUtilities.getPrimaryKey("T_INJURY",
466 injuryBean.getCreatedBy()));
467 injuryBean.setInjuryNumber(
468 GOSIUtilities.getPrimaryKey("INJURYNUMBER",
469 injuryBean.getCreatedBy()));
470 injuryNumber=injuryBean.getInjuryNumber();
471
472 if(contact!=null) {
473 contactAuditBean.setModuleId(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
474 contactAuditBean.setCreationTimestamp(new Timestamp(System.currentTimeMillis()));
475 contactAuditBean.setLastModifiedTimestamp(new Timestamp(System.currentTimeMillis()));
476
477 GOSIDebug.debugMessages("ContactList inside sesBean:"+contactList.size());
478 }
479
480 // updating contact details if present.
481 // logic checks if atleast one contact details record is present
482 // for the contributor else it throws error
483
484 if((contact!=null) && contactList.size()>0)
485 {
486 int count=0;
487 for(int i=0; i<contactList.size();i++)
488 {
489 IndividualContactBean contactBean =
490 (IndividualContactBean)contactList.get(i);
491 contactBean.setModuleId
492 (GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
493 String contMode =""+contactAuditBean.DELETE_MODE;
494 String entMode =""+contactBean.getMode();
495 if(!entMode.equals(contMode))
496 {
497 count=count+1;
498 }
499 }
500 if(count==0)
501 {
502 throw new GOSIException( GOSIConstants.SEVERITY_THREE,
503 GOSIConstants.SOCIAL_INSURANCE,
504 this.getClass().toString(),
505 "addInjury()",
506 new GOSIException(),
507 "SOI_ERR_4467");
508 }
509 }
510 if((contact!=null) && contact.equals("Add"))
511 {
512 if(contactList.size()==0)
513 {
514 GOSIDebug.debugMessages("Inside count==null");
515 throw new GOSIException( GOSIConstants.SEVERITY_THREE,
516 GOSIConstants.SOCIAL_INSURANCE,
517 this.getClass().toString(),
518 "addInjury()",
519 new GOSIException(),
520 "SOI_ERR_4467");
521 }
522 }
523 GOSIDebug.debugMessages("contact in session bean:"+contact);
524 if((contact!=null) && (!("").equals(contact)))
525 {
526 if("Add".equals(contact))
527 {
528 contactID=GOSIUtilities.
529 createIndividualContactDetails(contactList,
530 contactAuditBean);
531 GOSIDebug.debugMessages("Inside SessionBean ContactId is:"+
532 contactID);
533 injuryBean.setContactId(contactID);
534
535 }
536 else if("Modify".equals(contact))
537 {
538 GOSIUtilities.
539 modifyIndividualContactDetails(contactList,
540 contactAuditBean);
541 }
542 }
543 // converting String dates entered by user to Timestamp for storage
544 if( injuryBean.getInjuryDate()!= null)
545 {
546 injuryBean.setInjuryDate(SIUtilities.getDateTimestamp
547 (injuryBean.getInjuryDateStr(),
548 injuryBean.getInjuryDateEntFmt()));
549 }
550 if( injuryBean.getWorkDisabilityDate()!= null)
551 {
552 injuryBean.setWorkDisabilityDate(SIUtilities.getDateTimestamp
553 (injuryBean.getWorkDisabilityDateStr(),
554 injuryBean.getWorkDisabilityDateEntFmt()));
555 }
556 if( injuryBean.getEmpNotifyDate()!= null)
557 {
558 injuryBean.setEmpNotifyDate(SIUtilities.getDateTimestamp
559 (injuryBean.getEmpNotifyDateStr(),
560 injuryBean.getEmpNotifyDateEntFmt()));
561 }
562 if( injuryBean.getWorkerIntimateDate()!= null)
563 {
564 injuryBean.setWorkerIntimateDate(SIUtilities.getDateTimestamp
565 (injuryBean.getWorkerIntDateStr(),
566 injuryBean.getWorkerIntDateEntFmt()));
567 }
568 if( injuryBean.getWageStoppingDate()!= null)
569 {
570 injuryBean.setWageStoppingDate(SIUtilities.getDateTimestamp
571 (injuryBean.getWageStoppingDateStr(),
572 injuryBean.getWageStoppingDateEntFmt()));
573 }
574 if( injuryBean.getDateComplication()!= null)
575 {
576 injuryBean.setDateComplication(SIUtilities.getDateTimestamp
577 (injuryBean.getComplicationDateStr(),
578 injuryBean.getDateComplicationEntFmt()));
579 }
580 GOSIDebug.debugMessages("injurydate format in ses bean:"+
581 injuryBean.getInjuryDateStr());
582 // setting audit information
583 injuryBean.
584 setCreationTimestamp(new Timestamp(System.currentTimeMillis()));
585 injuryBean.setLastModifiedTimestamp
586 (new Timestamp(System.currentTimeMillis()));
587 // setting workflow status
588 if(workflowParamBean != null && GOSIConstants.COMPLETED.equals(workflowParamBean.getRoutingCriterion()))
589 {
590 injuryBean.setWorkFlowStatus(OHConstants.WFS_INJ_ENTERED);
591 }
592 else
593 {
594 injuryBean.
595 setWorkFlowStatus(OHConstants.WFS_INJ_PENDING_DATA_ENTRY);
596 }
597 // validating the injury
598 // checks for valid coverage, engagement,etc
599 injuryMap = isValidInjury(injuryBean);
600
601 // validating the injury
602 boolean isValidInjury =
603 ((Boolean)injuryMap.get("isValidInjury")).booleanValue();
604
605 if(!isValidInjury)
606 {
607 Short rejectionCode = (Short)injuryMap.get("rejectionCode");
608 String message = (String)injuryMap.get("message");
609 injuryBean.setInjuryStatus(OHConstants.INJ_STS_REJECTED);
610 injuryBean.setRejectionCode(rejectionCode);
611 injuryBean.setWorkFlowStatus(OHConstants.
612 WFS_INJ_REJECTED);
613 // letter generated if injury is not a valid one
614 generateLetter(injuryBean);
615 }else
616 {
617 //The implementation moved to the isValidInjuryMethod
618 }
619 injuryMap.put("injuryNumber",injuryNumber);
620 // calling injury entity
621 InjuryEntityHome home=getInjuryHome();
622 InjuryEntity oInjuryEntity = (InjuryEntity)home.create(injuryBean);
623 GOSIDebug.debugMessages("header bean"+ headerBean);
624 // the DMS key values are set and the dms interface called
625 if(headerBean != null)
626 {
627 headerBean.setSourceRecordId("" + injuryBean.getInjuryId());
628 GOSIDebug.debugMessages("headerbean-SourceRecordId: "+ injuryBean.getInjuryId());
629 headerBean.setSourceTable(SITables.T_INJURY);
630 GOSIDebug.debugMessages("headerbean-SourceTable: "+ SITables.T_INJURY);
631 headerBean.setCreatedBy(injuryBean.getCreatedBy()); //new Long (injuryBean.getCreatedBy())
632 headerBean.setKeyList(DMSConstants.SI_NUMBER,
633 "" + injuryBean.getSocInsNumber());
634 GOSIDebug.debugMessages("headerbean-KeyList: "+ injuryBean.getSocInsNumber());
635 headerBean.setKeyList(DMSConstants.REGISTRATION_NUMBER,
636 "" + injuryBean.getRegNumber());
637 GOSIDebug.debugMessages("headerbean-KeyList: "+ injuryBean.getRegNumber());
638 headerBean.setKeyList(DMSConstants.INJURY_NUMBER,
639 "" + injuryBean.getInjuryNumber());
640 GOSIDebug.debugMessages("headerbean-KeyList: "+ injuryBean.getInjuryNumber());
641
642 DMSUtilities.startDMS(headerBean);
643 }
644 // calling workflow interface and returning the next user name
645 if(isValidInjury)
646 {
647 if(workflowParamBean != null && GOSIConstants.COMPLETED.equals(workflowParamBean.getRoutingCriterion()))
648 {
649 workflowParamBean.setrecordDescription(
650 workflowParamBean.getrecordDescription()+"-"+
651 injuryBean.getSocInsNumber());
652 workflowParamBean.
653 setPrimaryKeyOfTherecord
654 (injuryBean.getInjuryId().toString());
655
656 WorkflowParamBean initialWorkflow = new WorkflowParamBean ();
657
658 initialWorkflow.setUserId(workflowParamBean.getUserId());
659 initialWorkflow.setUserLocationId(workflowParamBean.getUserLocationId());
660 initialWorkflow.setRoleId(workflowParamBean.getRoleId());
661 initialWorkflow.setStepShortName ("ADD_OH_INJURY_INITIAL_STEP");
662 initialWorkflow.setModuleId(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
663 initialWorkflow.setrecordDescription(GOSIErrorMessages.getErrorDesc("SOI_ERR_5641")+"-"+injuryBean.getSocInsNumber());
664 initialWorkflow.setRoutingCriterion(GOSIConstants.COMPLETED);
665 initialWorkflow.setComments(null);
666 initialWorkflow.setTransactionEntityMap(workflowParamBean.getTransactionEntityMap());
667 initialWorkflow.setPrimaryKeyOfTherecord(workflowParamBean.getPrimaryKeyOfTherecord());
668 initialWorkflow.setTargetUserId(workflowParamBean.getUserId());
669
670 GOSIUtilities.startWorkflow(initialWorkflow);
671
672 userName=GOSIUtilities.
673 startWorkflow(workflowParamBean);
674 injuryMap.put("userName",userName);
675 }
676 }
677 // To insert bodyparts
678 if (injuryBodyParts != null)
679 {
680 insertBodyParts(injuryBean.getInjuryId(),injuryBodyParts,injuryBean);
681 }
682 // To insert ICDList
683 if (icdList != null)
684 {
685 insertICDDiagnosis(injuryBean.getInjuryId(),icdList,injuryBean);
686 }
687 // To insert/update Preexisting deformities
688 if(injuryBean.getPreviousNonOH()!=null)
689 {
690 PreexistingDeformitiesEntityHome preexistDeformitiesHome =
691 getPreExistDeformitiesHome();
692 if(injuryBean.getPreExistDeformitiesId()==null)
693 {
694 // creating record if preexisting deformities for
695 // contributor does not exists
696 injuryBean.setPreExistDeformitiesId(
697 GOSIUtilities.getPrimaryKey("T_CONPREEXISTINGDEFORMITIES",
698 injuryBean.getCreatedBy()));
699 PreexistingDeformitiesEntity oPreexistDeformitiesEntity =
700 (PreexistingDeformitiesEntity)preexistDeformitiesHome.
701 create(injuryBean);
702 }
703 else
704 {
705 // updating the contributor preexisting deformities information
706 PreexistingDeformitiesEntity oPreexistDeformitiesEntity =
707 (PreexistingDeformitiesEntity)preexistDeformitiesHome.
708 findByPrimaryKey(injuryBean.getPreExistDeformitiesId());
709 oPreexistDeformitiesEntity.
710 updatePreexistDeformities(injuryBean);
711 }
712 }
713 GOSIDebug.debugMessages("contributorId:"+injuryBean.getContributorId());
714 GOSIDebug.debugMessages("getContactId:"+injuryBean.getContactId());
715 // To Update Contributor table with contact id
716 if(injuryBean.getContactId()!=null)
717 {
718 ContributorBean oContributorBean=
719 new ContributorBean();
720 oContributorBean=ContributorUtilities.
721 displayContributor(injuryBean.getContributorId());
722 oContributorBean.setContactId(injuryBean.getContactId());
723 oContributorBean.
724 setLastModifiedTimestamp
725 (new Timestamp(System.currentTimeMillis()));
726 oContributorBean.setLastModifiedBy
727 (injuryBean.getLastModifiedBy());
728 ContributorUtilities.updateContributor
729 (oContributorBean,false);
730 }
731 if(injuryBean.getIsEngagementProactive() && injuryBean.getEngagementApprovalDate() == null)
732 {
733 // Activate proactive registartion
734 ContributorUtilities.completingNonSaudiProactiveRegistration(injuryBean.getIqamaNumber(), injuryBean.getBoarderNumber(), injuryBean.getRegNumber(), RegistrationConstants.OH_MODE);
735 }
736 }
737 catch (GOSIException ge)
738 {
739 sesCtx.setRollbackOnly();
740 throw ge;
741 }
742 catch(Exception e)
743 {
744 e.printStackTrace();
745 sesCtx.setRollbackOnly();
746 GOSIDebug.debugMessages("Exception inside the Session save:"+e);
747 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
748 GOSIConstants.SOCIAL_INSURANCE,
749 this.getClass().toString(),
750 "addInjury()",
751 e,
752 "CMN_ERR_1000"
753 );
754 }
755 finally
756 {
757 GOSIUtilities.cleanUp (conn);
758 }
759 endTime = System.currentTimeMillis();
760 elapsedTime = endTime - startTime;
761 GOSIInstrumentationLog.writeInstrumentationToLog(
762 this.getClass().toString(),
763 "addInjury()",elapsedTime);
764 return injuryMap;
765 // returning the hashmap with the next users name
766 }
767 /**
768 * @METHOD NAME : addInjuryCompln
769 * @INFORMATION : This method is to add a complication of an injury
770 * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.AddInjuryHelperBean,
771 class gosi.core.workflow.beans.WorkflowParamBean,
772 class java.lang.String,
773 class java.util.ArrayList,
774 class gosi.core.util.beans.AuditBean,
775 class java.util.ArrayList,
776 class gosi.core.dms.beans.DMSRequestHeaderBean
777 * @RETURN : String
778 * @EXCEPTION : class gosi.core.util.GOSIException
779 * @LAST MODIFIED BY :
780 * @LAST MODIFIED DATE :
781 **/
782 public String addInjuryCompln(AddInjuryHelperBean injuryBean,
783 WorkflowParamBean workflowParamBean,
784 String contact,
785 ArrayList contactList,
786 AuditBean contactAuditBean,
787 ArrayList bodyPartsList,
788 DMSRequestHeaderBean headerBean)
789 throws GOSIException
790 {
791
792 long startTime = 0;
793 long endTime = 0;
794 long elapsedTime = 0;
795
796 startTime = System.currentTimeMillis();
797 String message = "";
798
799 try
800 {
801 // this method is used to insert the complication for an injury
802 // T_injury , and its child tables will be updates
803 // method similar to add injury.
804 // no validation required because complications are allways
805 // for the approved injury
806 injuryBean.setInjuryId(
807 GOSIUtilities.getPrimaryKey("T_INJURY",injuryBean.getCreatedBy()));
808
809 Long contactID;
810
811 if(contact!=null) {
812 contactAuditBean.setModuleId(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
813 contactAuditBean.setCreationTimestamp(new Timestamp(System.currentTimeMillis()));
814 contactAuditBean.setLastModifiedTimestamp(new Timestamp(System.currentTimeMillis()));
815 }
816
817 // adding contact details if present
818 // logic checks if atleast one contact details record is present
819 // for the contributor else it throws error
820 if((contact!=null) && contactList.size()>0)
821 {
822 int count=0;
823 for(int i=0; i<contactList.size();i++)
824 {
825 IndividualContactBean contactBean =
826 (IndividualContactBean)contactList.get(i);
827 contactBean.setModuleId
828 (GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
829 GOSIDebug.debugMessages("ModuleId inside sesBean:"+
830 contactBean.getModuleId());
831 GOSIDebug.debugMessages("2343432"+contactBean.getMode());
832 String contMode =""+contactAuditBean.DELETE_MODE;
833 String entMode =""+contactBean.getMode();
834 if(!entMode.equals(contMode))
835 {
836 count=count+1;
837 }
838 }
839 if(count==0)
840 {
841 throw new GOSIException( GOSIConstants.SEVERITY_THREE,
842 GOSIConstants.SOCIAL_INSURANCE,
843 this.getClass().toString(),
844 "addInjury()",
845 new GOSIException(),
846 "SOI_ERR_4467");
847 }
848 }
849 if((contact!=null) && contact.equals("Add"))
850 {
851 if(contactList.size()==0)
852 {
853 throw new GOSIException( GOSIConstants.SEVERITY_THREE,
854 GOSIConstants.SOCIAL_INSURANCE,
855 this.getClass().toString(),
856 "addInjury()",
857 new GOSIException(),
858 "SOI_ERR_4467");
859 }
860 }
861 if((contact!=null) && (!("").equals(contact)))
862 {
863 if("Add".equals(contact))
864 {
865 contactID=GOSIUtilities.
866 createIndividualContactDetails(contactList,
867 contactAuditBean);
868 injuryBean.setContactId(contactID);
869
870 }
871 else if("Modify".equals(contact))
872 {
873 GOSIUtilities.
874 modifyIndividualContactDetails(contactList,
875 contactAuditBean);
876 }
877 }
878 GOSIDebug.debugMessages("InjuryNumber inside the ses bean:"+
879 injuryBean.getInjuryNumber());
880
881 Short parentInjuryStatus = getParentInjuryStatus(injuryBean.getInjuryNumber());
882
883 // setting audit information
884 injuryBean.setCreationTimestamp
885 (new Timestamp(System.currentTimeMillis()));
886 injuryBean.setLastModifiedTimestamp
887 (new Timestamp(System.currentTimeMillis()));
888 // setting workflow status
889 if(workflowParamBean != null && GOSIConstants.COMPLETED.equals(workflowParamBean.getRoutingCriterion()))
890 {
891 injuryBean.setWorkFlowStatus(OHConstants.WFS_INJ_ENTERED);
892 }
893 else
894 {
895 injuryBean.
896 setWorkFlowStatus(OHConstants.WFS_INJ_PENDING_DATA_ENTRY);
897 }
898 // converting String dates entered by user to Timestamp for storage
899 if( injuryBean.getInjuryDate()!= null)
900 {
901 injuryBean.setInjuryDate(SIUtilities.getDateTimestamp
902 (injuryBean.getInjuryDateStr(),
903 injuryBean.getInjuryDateEntFmt()));
904 }
905 if( injuryBean.getWorkDisabilityDate()!= null)
906 {
907 injuryBean.setWorkDisabilityDate(SIUtilities.getDateTimestamp
908 (injuryBean.getWorkDisabilityDateStr(),
909 injuryBean.getWorkDisabilityDateEntFmt()));
910 }
911 if( injuryBean.getEmpNotifyDate()!= null)
912 {
913 injuryBean.setEmpNotifyDate(SIUtilities.getDateTimestamp
914 (injuryBean.getEmpNotifyDateStr(),
915 injuryBean.getEmpNotifyDateEntFmt()));
916 }
917 if( injuryBean.getWorkerIntimateDate()!= null)
918 {
919 injuryBean.setWorkerIntimateDate(SIUtilities.getDateTimestamp
920 (injuryBean.getWorkerIntDateStr(),
921 injuryBean.getWorkerIntDateEntFmt()));
922 }
923 if( injuryBean.getWageStoppingDate()!= null)
924 {
925 injuryBean.setWageStoppingDate(SIUtilities.getDateTimestamp
926 (injuryBean.getWageStoppingDateStr(),
927 injuryBean.getWageStoppingDateEntFmt()));
928 }
929 if( injuryBean.getDateComplication()!= null)
930 {
931 injuryBean.setDateComplication(SIUtilities.getDateTimestamp
932 (injuryBean.getComplicationDateStr(),
933 injuryBean.getDateComplicationEntFmt()));
934 }
935 if(OHConstants.INJ_STS_REJECTED.equals(parentInjuryStatus))
936 {
937 injuryBean.setInjuryStatus(OHConstants.INJ_STS_REJECTED);
938 injuryBean.setRejectionCode(new Short("1044"));
939 injuryBean.setWorkFlowStatus(OHConstants.WFS_INJ_REJECTED);
940 message = GOSIErrorMessages.getErrorDesc("SOI_ERR_5556");
941 }
942 // calling injury home and inserting injury record
943 InjuryEntityHome home=getInjuryHome();
944 InjuryEntity oInjuryEntity =
945 (InjuryEntity)home.create(injuryBean);
946 // Calling workflow interface
947
948 if(!OHConstants.INJ_STS_REJECTED.equals(parentInjuryStatus))
949 {
950 if(workflowParamBean != null && GOSIConstants.COMPLETED.equals(workflowParamBean.getRoutingCriterion()))
951 {
952 workflowParamBean.setrecordDescription(
953 workflowParamBean.getrecordDescription()+"-"+
954 injuryBean.getSocInsNumber());
955
956 workflowParamBean.setPrimaryKeyOfTherecord
957 (injuryBean.getInjuryId().toString());
958
959 WorkflowParamBean initialWorkflow = new WorkflowParamBean ();
960
961 initialWorkflow.setUserId(workflowParamBean.getUserId());
962 initialWorkflow.setUserLocationId(workflowParamBean.getUserLocationId());
963 initialWorkflow.setRoleId(workflowParamBean.getRoleId());
964 initialWorkflow.setStepShortName ("COMPLICATION_INJURY_INITIAL_STEP");
965 initialWorkflow.setModuleId(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
966 initialWorkflow.setrecordDescription(GOSIErrorMessages.getErrorDesc("SOI_ERR_5642")+"-"+injuryBean.getSocInsNumber());
967 initialWorkflow.setRoutingCriterion(GOSIConstants.COMPLETED);
968 initialWorkflow.setComments(null);
969 initialWorkflow.setTransactionEntityMap(workflowParamBean.getTransactionEntityMap());
970 initialWorkflow.setPrimaryKeyOfTherecord(workflowParamBean.getPrimaryKeyOfTherecord());
971 initialWorkflow.setTargetUserId(workflowParamBean.getUserId());
972
973 GOSIUtilities.startWorkflow(initialWorkflow);
974
975 String userName=GOSIUtilities.startWorkflow(workflowParamBean);
976 message = GOSIErrorMessages.getErrorDesc("SOI_ERR_5402")
977 + " : "+ userName;
978 }else
979 {
980 message = GOSIErrorMessages.getErrorDesc("SOI_ERR_4609");
981 }
982 }
983 GOSIDebug.debugMessages("header bean"+ headerBean);
984 // the DMS key values are set and the dms interface called
985 if(headerBean != null)
986 {
987 headerBean.setSourceRecordId
988 ("" + injuryBean.getInjuryId());
989 headerBean.
990 setSourceTable(SITables.T_INJURY);
991 headerBean.setCreatedBy
992 (new Long (workflowParamBean.getUserId()));
993 headerBean.setKeyList(DMSConstants.SI_NUMBER,
994 "" + injuryBean.getSocInsNumber());
995 headerBean.setKeyList(DMSConstants.REGISTRATION_NUMBER,
996 "" + injuryBean.getRegNumber());
997 headerBean.setKeyList(DMSConstants.INJURY_NUMBER,
998 "" + injuryBean.getInjuryNumber());
999 DMSUtilities.startDMS(headerBean);
1000 }
1001 // inseting body parts in complication reenter
1002 if (bodyPartsList != null)
1003 {
1004 insertBodyPartsComplnEnter(injuryBean.getInjuryId(),bodyPartsList,injuryBean);
1005 }
1006 // To insert/update Preexisting deformities
1007
1008 if(injuryBean.getPreviousNonOH()!=null)
1009 {
1010 PreexistingDeformitiesEntityHome preexistDeformitiesHome =
1011 getPreExistDeformitiesHome();
1012 // if its already present it will be modifed else entered
1013 if(injuryBean.getPreExistDeformitiesId()==null)
1014 {
1015 // creating record if preexisting deformities for
1016 // contributor does not exists
1017 injuryBean.setPreExistDeformitiesId(
1018 GOSIUtilities.getPrimaryKey("T_CONPREEXISTINGDEFORMITIES",
1019 injuryBean.getCreatedBy()));
1020 PreexistingDeformitiesEntity oPreexistDeformitiesEntity =
1021 (PreexistingDeformitiesEntity)preexistDeformitiesHome.
1022 create(injuryBean);
1023 }
1024 else
1025 {
1026 // updating the contributor preexisting deformities information
1027 PreexistingDeformitiesEntity oPreexistDeformitiesEntity =
1028 (PreexistingDeformitiesEntity)preexistDeformitiesHome.
1029 findByPrimaryKey(injuryBean.getPreExistDeformitiesId());
1030 oPreexistDeformitiesEntity.
1031 updatePreexistDeformities(injuryBean);
1032 }
1033 }
1034 // To update contact id in Contributor table
1035 if(injuryBean.getContactId()!=null)
1036 {
1037 ContributorBean oContributorBean=
1038 new ContributorBean();
1039 oContributorBean=ContributorUtilities.
1040 displayContributor(injuryBean.getContributorId());
1041 oContributorBean.setContactId(injuryBean.getContactId());
1042 oContributorBean.
1043 setLastModifiedTimestamp
1044 (new Timestamp(System.currentTimeMillis()));
1045 oContributorBean.setLastModifiedBy
1046 (injuryBean.getLastModifiedBy());
1047 ContributorUtilities.
1048 updateContributor(oContributorBean,false);
1049 }
1050 endTime = System.currentTimeMillis();
1051 elapsedTime = endTime - startTime;
1052 GOSIInstrumentationLog.writeInstrumentationToLog(
1053 this.getClass().toString(),"addInjuryCompln()",
1054 elapsedTime);
1055 }
1056 catch (GOSIException ge)
1057 {
1058 sesCtx.setRollbackOnly();
1059 throw ge;
1060 }
1061 catch(Exception e)
1062 {
1063 sesCtx.setRollbackOnly();
1064 GOSIDebug.debugMessages("Exception inside the Session save:"+e);
1065 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
1066 GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
1067 "addInjuryCompln()", e, "CMN_ERR_1000" );
1068 }
1069 return message;
1070 }
1071
1072 /**
1073 * @METHOD NAME : injModifyReenter
1074 * @INFORMATION : This method is to update Injury details in Reenter/enter mode
1075 * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.AddInjuryHelperBean,
1076 class gosi.core.workflow.beans.WorkflowParamBean,
1077 class java.lang.String,
1078 class java.util.ArrayList,
1079 class gosi.core.util.beans.AuditBean,
1080 class java.util.ArrayList,
1081 class java.util.ArrayList,
1082 class gosi.core.dms.beans.DMSRequestHeaderBean,
1083 class java.util.ArrayList
1084 * @RETURN : class java.lang.String
1085 * @EXCEPTION : class gosi.core.util.GOSIException
1086 * @LAST MODIFIED BY :
1087 * @LAST MODIFIED DATE :
1088 **/
1089 public String injModifyReenter(AddInjuryHelperBean injuryBean,
1090 WorkflowParamBean workflowParamBean,
1091 String contact,
1092 ArrayList contactList,
1093 AuditBean contactAuditBean,
1094 ArrayList bodyPartsList,
1095 ArrayList icdList,
1096 DMSRequestHeaderBean headerBean,
1097 ArrayList injuryDocReqList)
1098 throws GOSIException
1099 {
1100
1101 Long contactID;
1102 String userName="";
1103 long startTime = 0;
1104 long endTime = 0;
1105 long elapsedTime = 0;
1106
1107 startTime = System.currentTimeMillis();
1108
1109 try
1110 {
1111 conn = GOSIUtilities.getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
1112 // this method is used to update the injury in reneter mode
1113 // T_injury , and its child tables will be updated
1114 if(contact!=null) {
1115 contactAuditBean.setModuleId(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
1116 contactAuditBean.setCreationTimestamp(new Timestamp(System.currentTimeMillis()));
1117 contactAuditBean.setLastModifiedTimestamp(new Timestamp(System.currentTimeMillis()));
1118 }
1119 // adding contact details if present
1120 // logic checks if atleast one contact details record is present
1121 // for the contributor else it throws error
1122 if((contact!=null) && contactList.size()>0)
1123 {
1124 int count=0;
1125 for(int i=0; i<contactList.size();i++)
1126 {
1127 IndividualContactBean contactBean =
1128 (IndividualContactBean)contactList.get(i);
1129 contactBean.setModuleId
1130 (GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
1131 GOSIDebug.debugMessages("ModuleId inside sesBean:"+
1132 contactBean.getModuleId());
1133 GOSIDebug.debugMessages("2343432"+contactBean.getMode());
1134 String contMode =""+contactAuditBean.DELETE_MODE;
1135 String entMode =""+contactBean.getMode();
1136 if(!entMode.equals(contMode))
1137 {
1138 count=count+1;
1139 }
1140 }
1141 if(count==0)
1142 {
1143 throw new GOSIException( GOSIConstants.SEVERITY_THREE,
1144 GOSIConstants.SOCIAL_INSURANCE,
1145 this.getClass().toString(),
1146 "injModifyReenter()",
1147 new GOSIException(),"SOI_ERR_4467");
1148 }
1149 }
1150 if((contact!=null) && contact.equals("Add"))
1151 {
1152 if(contactList.size()==0)
1153 {
1154 throw new GOSIException( GOSIConstants.SEVERITY_THREE,
1155 GOSIConstants.SOCIAL_INSURANCE,
1156 this.getClass().toString(),
1157 "injModifyReenter()",
1158 new GOSIException(),"SOI_ERR_4467");
1159 }
1160 }
1161 GOSIDebug.debugMessages("contact in session bean:"+contact);
1162 if((contact!=null) && (!("").equals(contact)))
1163 {
1164 if("Add".equals(contact))
1165 {
1166 contactID=GOSIUtilities.
1167 createIndividualContactDetails(contactList,
1168 contactAuditBean);
1169 GOSIDebug.debugMessages("Inside SessionBean ContactId is:"+
1170 contactID);
1171 injuryBean.setContactId(contactID);
1172
1173 }
1174 else if("Modify".equals(contact))
1175 {
1176 GOSIDebug.debugMessages("Inside update contact ");
1177 GOSIUtilities.
1178 modifyIndividualContactDetails(contactList,
1179 contactAuditBean);
1180 }
1181 }
1182 // converting String dates entered by user to Timestamp for storage
1183 if( injuryBean.getInjuryDate()!= null)
1184 {
1185 injuryBean.setInjuryDate(SIUtilities.getDateTimestamp
1186 (injuryBean.getInjuryDateStr(),
1187 injuryBean.getInjuryDateEntFmt()));
1188 }
1189 if( injuryBean.getWorkDisabilityDate()!= null)
1190 {
1191 injuryBean.setWorkDisabilityDate(SIUtilities.getDateTimestamp
1192 (injuryBean.getWorkDisabilityDateStr(),
1193 injuryBean.getWorkDisabilityDateEntFmt()));
1194 }
1195 if(injuryBean.getEmpNotifyDate()!= null)
1196 {
1197 injuryBean.setEmpNotifyDate(SIUtilities.getDateTimestamp
1198 (injuryBean.getEmpNotifyDateStr(),
1199 injuryBean.getEmpNotifyDateEntFmt()));
1200 }
1201 if(injuryBean.getWorkerIntimateDate()!= null)
1202 {
1203 injuryBean.setWorkerIntimateDate(SIUtilities.getDateTimestamp
1204 (injuryBean.getWorkerIntDateStr(),
1205 injuryBean.getWorkerIntDateEntFmt()));
1206 }
1207 if( injuryBean.getWageStoppingDate()!= null)
1208 {
1209 injuryBean.setWageStoppingDate(SIUtilities.getDateTimestamp
1210 (injuryBean.getWageStoppingDateStr(),
1211 injuryBean.getWageStoppingDateEntFmt()));
1212 }
1213 if( injuryBean.getDateComplication()!= null)
1214 {
1215 injuryBean.setDateComplication(SIUtilities.getDateTimestamp
1216 (injuryBean.getComplicationDateStr(),
1217 injuryBean.getDateComplicationEntFmt()));
1218 }
1219 //setting audit information for injury bean
1220 injuryBean.
1221 setLastModifiedTimestamp
1222 (new Timestamp(System.currentTimeMillis()));
1223 GOSIDebug.debugMessages("Inside LAST MODIFIED:"+
1224 injuryBean.getLastModifiedTimestamp());
1225 // calling injury entity home
1226 InjuryEntityHome home=getInjuryHome();
1227 InjuryEntity oInjuryEntity =(InjuryEntity)home.findByPrimaryKey
1228 (injuryBean.getInjuryId());
1229
1230 // added for validating if wage stop date is modified
1231 InjuryBean storedInjuryBean = oInjuryEntity.getInjury();
1232 if(storedInjuryBean.getInjuryStatus().equals(OHConstants.INJ_STS_APPROVED))
1233 {
1234 // checking if the wage stop date can be changed or not
1235 if(storedInjuryBean.getWageStopDateGreg()== null &&
1236 injuryBean.getWageStoppingDate() == null)
1237 {
1238 //canChangeWageStopDate(injuryBean.getInjuryId());
1239 //if its null dont check
1240 }else
1241 if(storedInjuryBean.getWageStopDateGreg()!=null &&
1242 injuryBean.getWageStoppingDate() == null)
1243 {
1244 canChangeWageStopDate(injuryBean.getInjuryId());
1245 }else
1246 if(storedInjuryBean.getWageStopDateGreg()==null &&
1247 injuryBean.getWageStoppingDate() != null)
1248 {
1249 canChangeWageStopDate(injuryBean.getInjuryId());
1250 }else
1251 if(!storedInjuryBean.getWageStopDateGreg().equals(
1252 injuryBean.getWageStoppingDate()))
1253 {
1254 canChangeWageStopDate(injuryBean.getInjuryId());
1255 }
1256
1257 /* PRD00067443 Abdulrazaq Alabdulrazaq 12/01/2015 */
1258 // if the date of injury has been changed
1259 if(!storedInjuryBean.getInjuryDateGreg().equals(
1260 injuryBean.getInjuryDate()))
1261 {
1262 // check if there is duplicate injury with same date of new date
1263 isInjuryAlreadyEntered(injuryBean.getSocInsNumber(),injuryBean.getInjuryDate());
1264
1265 // Check if Injury has another Injury for the same contributor is taking In Patient Treatment in the same date
1266 checkTreatmentInpatientforAnotherInjury(injuryBean.getSocInsNumber(),injuryBean.getInjuryId(),injuryBean.getInjuryDate());
1267
1268
1269 /* if the date of injury has been changed and the new date after the old date
1270 * that might exist OH benefit still not recovered or Treatment Service not Recovered
1271 */
1272 if(storedInjuryBean.getInjuryDateGreg().before(
1273 injuryBean.getInjuryDate()))
1274 {
1275 Timestamp oldDate=storedInjuryBean.getInjuryDateGreg();
1276 Timestamp NewDate=injuryBean.getInjuryDate();
1277 Timestamp tempDate=oldDate;
1278 while (!tempDate.equals(NewDate))
1279 {
1280 // check if there OH benefit not Covered on period between Old injury date until New injury date
1281 checkInjuryHasOHBenefit(injuryBean.getInjuryId(), tempDate);
1282 // check if there is Treatment service not covered period between Old injury date until New injury date
1283 checkInjuryHasTreatmentService(injuryBean.getInjuryId(), tempDate);
1284 // get next day
1285 tempDate=GOSIUtilities.getNextDate(tempDate);
1286 }
1287
1288 //check if there treatment period that on period between Old injury date until New injury date
1289 checkInjuryHasTreatmentOrTransfer(injuryBean);
1290
1291 // check if the fisrt visit date on the T_PMR need to be update (may be it will before the New date !!)
1292 updateFirstVisitDate(injuryBean);
1293
1294
1295 // check if the start treatment date on the T_INJURY need to be update (may be it will before the New date !!)
1296 if(storedInjuryBean.getTreatmentStDateGreg()!=null
1297 && storedInjuryBean.getTreatmentStDateGreg().before(injuryBean.getInjuryDate()))
1298 {
1299 storedInjuryBean.setTreatmentStDateGreg(injuryBean.getInjuryDate());
1300 oInjuryEntity.modifyInjury(storedInjuryBean);
1301 }
1302 }
1303
1304 // check if have Complication of these injury (that have same injuryNumber ) we will update the Complication Details also
1305 /* to be added on modifying Complication
1306 ArrayList<Long> complicationList= checkInjuryHasComplicationList(injuryBean);
1307
1308 for (Long comloicationInjuryId : complicationList )
1309 {
1310 InjuryEntity oComplicationEntity =(InjuryEntity)home.findByPrimaryKey
1311 (comloicationInjuryId);
1312
1313 oComplicationEntity.updateInjuryDetailsOfComplication(injuryBean);
1314 }
1315 /* if the date of injury has been changed and the New date before the old date
1316 * that means not need to any check
1317 */
1318 }
1319
1320
1321 }
1322
1323 // updating injury & calling workflow interface
1324 oInjuryEntity.updateInjury(injuryBean);
1325
1326 if((OHConstants.VERIFIED).
1327 equals(workflowParamBean.getRoutingCriterion())||
1328 (OHConstants.APPROVED).
1329 equals(workflowParamBean.getRoutingCriterion())||
1330 (GOSIConstants.REJECTED).
1331 equals(workflowParamBean.getRoutingCriterion())||
1332 (GOSIConstants.COMPLETED).
1333 equals(workflowParamBean.getRoutingCriterion())||
1334 (GOSIConstants.CANCELLED).
1335 equals(workflowParamBean.getRoutingCriterion()))
1336 {
1337 workflowParamBean.setrecordDescription(
1338 workflowParamBean.getrecordDescription()+"-"+
1339 injuryBean.getSocInsNumber());
1340
1341 workflowParamBean.
1342 setPrimaryKeyOfTherecord(injuryBean.getInjuryId().toString());
1343 userName=GOSIUtilities.startWorkflow(workflowParamBean);
1344 }
1345 else
1346 {
1347 injuryBean.
1348 setWorkFlowStatus(OHConstants.WFS_INJ_PENDING_DATA_ENTRY);
1349 }
1350
1351 if(injuryDocReqList!=null)
1352 {
1353 InjuryDocReqEntityHome ReqDocHome = getInjuryReqDocHome();
1354
1355 for (int i=0; i<injuryDocReqList.size();i++)
1356 {
1357
1358 InjuryDocReqListBean injuryDocReqListBean=(InjuryDocReqListBean)injuryDocReqList.get(i);
1359 InjuryDocReqEntity injuryDocReqEntity =(InjuryDocReqEntity)ReqDocHome.findByPrimaryKey(injuryDocReqListBean.getInjuryDocReqId());
1360 injuryDocReqEntity.updateInjuryDocReq(injuryBean.getLastModifiedBy(),new Timestamp(System.currentTimeMillis()));
1361 }
1362 }
1363 // the DMS key values are set and the dms interface called
1364 GOSIDebug.debugMessages("header bean"+ headerBean);
1365 if(headerBean != null)
1366 {
1367 GOSIDebug.debugMessages("inside header");
1368 headerBean.setSourceRecordId
1369 ("" + injuryBean.getInjuryId());
1370 headerBean.
1371 setSourceTable(SITables.T_INJURY);
1372 headerBean.setCreatedBy
1373 (new Long (workflowParamBean.getUserId()));
1374 headerBean.setKeyList(DMSConstants.SI_NUMBER,
1375 "" + injuryBean.getSocInsNumber());
1376 headerBean.setKeyList(DMSConstants.REGISTRATION_NUMBER,
1377 "" + injuryBean.getRegNumber());
1378 headerBean.setKeyList(DMSConstants.INJURY_NUMBER,
1379 "" + injuryBean.getInjuryNumber());
1380
1381 DMSUtilities.startDMS(headerBean);
1382 }
1383
1384 // To insert bodyparts
1385 if(bodyPartsList != null) {
1386 insertBodyParts(injuryBean.getInjuryId(),bodyPartsList,injuryBean);
1387 }
1388 // To insert ICDList
1389 if(icdList != null) {
1390 insertICDDiagnosis(injuryBean.getInjuryId(),icdList,injuryBean);
1391 }
1392 if(injuryBean.getPreviousNonOH()!=null)
1393 {
1394 PreexistingDeformitiesEntityHome preexistDeformitiesHome =
1395 getPreExistDeformitiesHome();
1396 // if its already present it will be modifed else entered
1397 if(injuryBean.getPreExistDeformitiesId()==null)
1398 {
1399 // creating record if preexisting deformities for
1400 // contributor does not exists
1401 injuryBean.setPreExistDeformitiesId(GOSIUtilities.getPrimaryKey
1402 ("T_CONPREEXISTINGDEFORMITIES",injuryBean.getCreatedBy()));
1403 PreexistingDeformitiesEntity oPreexistDeformitiesEntity =
1404 (PreexistingDeformitiesEntity)preexistDeformitiesHome.
1405 create(injuryBean);
1406 }
1407 else
1408 {
1409 // updating the contributor preexisting deformities information
1410 PreexistingDeformitiesEntity oPreexistDeformitiesEntity =
1411 (PreexistingDeformitiesEntity)preexistDeformitiesHome.
1412 findByPrimaryKey(injuryBean.getPreExistDeformitiesId());
1413 oPreexistDeformitiesEntity.updatePreexistDeformities(injuryBean);
1414 }
1415 }
1416
1417 // Updating contact details.
1418 GOSIDebug.debugMessages("contributorId:"+injuryBean.getContributorId());
1419 GOSIDebug.debugMessages("getContactId:"+injuryBean.getContactId());
1420 // To update contact id in Contributor table
1421 if(injuryBean.getContactId()!=null)
1422 {
1423 ContributorBean oContributorBean=
1424 new ContributorBean();
1425 oContributorBean=ContributorUtilities.
1426 displayContributor(injuryBean.getContributorId());
1427 oContributorBean.setContactId(injuryBean.getContactId());
1428 oContributorBean.
1429 setLastModifiedTimestamp
1430 (new Timestamp(System.currentTimeMillis()));
1431 oContributorBean.setLastModifiedBy
1432 (injuryBean.getLastModifiedBy());
1433 ContributorUtilities.updateContributor(oContributorBean,false);
1434 }
1435 // letter to be generated if injury is rejected
1436 if(OHConstants.INJ_STS_REJECTED.equals(injuryBean.getInjuryStatus()))
1437 {
1438 generateLetter(injuryBean);
1439 }
1440 }
1441 catch (GOSIException ge)
1442 {
1443 sesCtx.setRollbackOnly();
1444 throw ge;
1445 }
1446 catch(Exception e)
1447 {
1448
1449 sesCtx.setRollbackOnly();
1450 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
1451 GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
1452 "injModifyReenter()", e, "CMN_ERR_1000");
1453 }
1454 finally
1455 {
1456 GOSIUtilities.cleanUp (conn);
1457 }
1458 endTime = System.currentTimeMillis();
1459 elapsedTime = endTime - startTime;
1460 GOSIInstrumentationLog.writeInstrumentationToLog(
1461 this.getClass().toString(), "injModifyReenter()",elapsedTime);
1462 return userName;
1463 }
1464
1465 /**
1466 * @METHOD NAME : modifyInjuryDetails
1467 * @INFORMATION : This method is to update Injury details in the database for the workflow
1468 * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.AddInjuryHelperBean,
1469 class gosi.core.workflow.beans.WorkflowParamBean,
1470 class java.util.ArrayList,
1471 class java.util.ArrayList,
1472 class gosi.core.dms.beans.DMSRequestHeaderBean
1473 * @RETURN : class java.lang.String
1474 * @EXCEPTION : class gosi.core.util.GOSIException
1475 * @LAST MODIFIED BY :
1476 * @LAST MODIFIED DATE :
1477 **/
1478 public String modifyInjuryDetails(AddInjuryHelperBean injuryBean,
1479 WorkflowParamBean workflowParamBean,
1480 ArrayList injuryBodyParts,
1481 ArrayList icdList,
1482 DMSRequestHeaderBean headerBean,InjuryDocReqSearchBean injuryDocReq)
1483 throws GOSIException
1484 {
1485
1486 Long contactID;
1487 String userName="";
1488 long startTime = 0;
1489 long endTime = 0;
1490 long elapsedTime = 0;
1491
1492 startTime = System.currentTimeMillis();
1493
1494 try
1495 {
1496 GOSIDebug.debugMessages("--------------modifyInjuryDetails-------------------");
1497 conn = GOSIUtilities.getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
1498 // converting String dates entered by user to Timestamp for storage
1499 if( injuryBean.getInjuryDate()!= null)
1500 {
1501 if(OHConstants.HIJRAH.
1502 equals(injuryBean.getInjuryDateEntFmt()))
1503 {
1504 injuryBean.setInjuryDate(GOSIUtilities.getTimestamp
1505 (GOSIDateUtilities.convertToGregorian(
1506 injuryBean.getInjuryDateStr())));
1507 }
1508 else
1509 {
1510 injuryBean.setInjuryDate(GOSIUtilities.getTimestamp
1511 (injuryBean.getInjuryDateStr()));
1512 }
1513 }
1514 if( injuryBean.getWorkDisabilityDate()!= null)
1515 {
1516 injuryBean.setWorkDisabilityDate(SIUtilities.getDateTimestamp
1517 (injuryBean.getWorkDisabilityDateStr(),
1518 injuryBean.getWorkDisabilityDateEntFmt()));
1519 }
1520 if( injuryBean.getEmpNotifyDate()!= null)
1521 {
1522 injuryBean.setEmpNotifyDate(SIUtilities.getDateTimestamp
1523 (injuryBean.getEmpNotifyDateStr(),
1524 injuryBean.getEmpNotifyDateEntFmt()));
1525 }
1526 if( injuryBean.getWorkerIntimateDate()!= null)
1527 {
1528 injuryBean.setWorkerIntimateDate(SIUtilities.getDateTimestamp
1529 (injuryBean.getWorkerIntDateStr(),
1530 injuryBean.getWorkerIntDateEntFmt()));
1531 }
1532 if( injuryBean.getWageStoppingDate()!= null)
1533 {
1534 injuryBean.setWageStoppingDate(SIUtilities.getDateTimestamp
1535 (injuryBean.getWageStoppingDateStr(),
1536 injuryBean.getWageStoppingDateEntFmt()));
1537 }
1538 if( injuryBean.getDateComplication()!= null)
1539 {
1540 injuryBean.setDateComplication(SIUtilities.getDateTimestamp
1541 (injuryBean.getComplicationDateStr(),
1542 injuryBean.getDateComplicationEntFmt()));
1543 }
1544 // setting audit information
1545 injuryBean.setLastModifiedTimestamp
1546 (new Timestamp(System.currentTimeMillis()));
1547 injuryBean.setCreationTimestamp
1548 (new Timestamp(System.currentTimeMillis()));
1549 // getting injury entity home
1550 InjuryEntityHome home=getInjuryHome();
1551
1552 GOSIDebug.debugMessages("Injury Id value:"+injuryBean.getInjuryId());
1553 InjuryEntity oInjuryEntity =(InjuryEntity)home.
1554 findByPrimaryKey(injuryBean.getInjuryId());
1555
1556 InjuryBean storedInjuryBean = oInjuryEntity.getInjury();
1557 // checking if wage stop dates can be changed or not
1558 if(storedInjuryBean.getInjuryStatus().equals(OHConstants.INJ_STS_APPROVED))
1559 {
1560 if(storedInjuryBean.getWageStopDateGreg()== null &&
1561 injuryBean.getWageStoppingDate() == null)
1562 {
1563 //canChangeWageStopDate(injuryBean.getInjuryId());
1564 // if the dates are null do not check .
1565 }else
1566 if(storedInjuryBean.getWageStopDateGreg()!=null &&
1567 injuryBean.getWageStoppingDate() == null)
1568 {
1569 canChangeWageStopDate(injuryBean.getInjuryId());
1570 }else
1571 if(storedInjuryBean.getWageStopDateGreg()==null &&
1572 injuryBean.getWageStoppingDate() != null)
1573 {
1574 canChangeWageStopDate(injuryBean.getInjuryId());
1575 }else
1576 if(!storedInjuryBean.getWageStopDateGreg().equals(
1577 injuryBean.getWageStoppingDate()))
1578 {
1579 canChangeWageStopDate(injuryBean.getInjuryId());
1580 }
1581 }
1582 // updating the injury record
1583 oInjuryEntity.updateInjury(injuryBean);
1584 GOSIDebug.debugMessages("getInjuryStatus:"+injuryBean.getInjuryStatus());
1585 // calling the workflow interface
1586 if((OHConstants.VERIFIED).
1587 equals(workflowParamBean.getRoutingCriterion())||
1588 (OHConstants.APPROVED).
1589 equals(workflowParamBean.getRoutingCriterion())||
1590 (GOSIConstants.REJECTED).
1591 equals(workflowParamBean.getRoutingCriterion())||
1592 (GOSIConstants.COMPLETED).
1593 equals(workflowParamBean.getRoutingCriterion())||
1594 (GOSIConstants.CANCELLED).
1595 equals(workflowParamBean.getRoutingCriterion()))
1596 {
1597 workflowParamBean.setrecordDescription(
1598 workflowParamBean.getrecordDescription()+"-"+
1599 injuryBean.getSocInsNumber());
1600 workflowParamBean.
1601 setPrimaryKeyOfTherecord(injuryBean.getInjuryId().toString());
1602 userName=GOSIUtilities.startWorkflow(workflowParamBean);
1603 GOSIDebug.debugMessages("userName inside the ses bean:"+userName);
1604 }else if(OHConstants.INJ_STS_APPROVED.equals(injuryBean.getInjuryStatus()))
1605 {
1606 GOSIDebug.debugMessages("getInjuryStatus:"+injuryBean.getInjuryStatus());
1607 }
1608 else
1609 {
1610 injuryBean.
1611 setWorkFlowStatus(OHConstants.WFS_INJ_PENDING_DATA_ENTRY);
1612 }
1613
1614 // the DMS key values are set and the dms interface called
1615 GOSIDebug.debugMessages("header bean"+ headerBean);
1616 if(headerBean != null)
1617 {
1618 GOSIDebug.debugMessages("inside header");
1619 headerBean.setSourceRecordId
1620 ("" + injuryBean.getInjuryId());
1621 headerBean.
1622 setSourceTable(SITables.T_INJURY);
1623 headerBean.setCreatedBy
1624 (new Long (workflowParamBean.getUserId()));
1625 headerBean.setKeyList(DMSConstants.SI_NUMBER,
1626 "" + injuryBean.getSocInsNumber());
1627 headerBean.setKeyList(DMSConstants.REGISTRATION_NUMBER,
1628 "" + injuryBean.getRegNumber());
1629 headerBean.setKeyList(DMSConstants.INJURY_NUMBER,
1630 "" + injuryBean.getInjuryNumber());
1631
1632 DMSUtilities.startDMS(headerBean);
1633
1634 }
1635 // To insert Request Doucument form Establishment
1636 if(injuryDocReq!=null)
1637 {
1638 InjuryDocReqEntityHome ReqDocHome = getInjuryReqDocHome();
1639 ArrayList list =injuryDocReq.getDocReq();
1640 InjuryDocReqListBean injuryDocReqListBean= null;
1641 for (int i=0; i<list.size();i++){
1642 injuryDocReqListBean= new InjuryDocReqListBean ();
1643 injuryDocReqListBean.setInjuryDocReqId(GOSIUtilities.getPrimaryKey("T_injuryDocReq",injuryDocReq.getCreatedBy()));
1644 injuryDocReqListBean.setInjuryId(injuryDocReq.getInjuryId());
1645 injuryDocReqListBean.setDocReq(new Long((String)list.get(i)));
1646 injuryDocReqListBean.setCreatedBy(injuryDocReq.getCreatedBy());
1647 injuryDocReqListBean.setCreationTimestamp(new Timestamp(System.currentTimeMillis()));
1648 InjuryDocReqEntity injuryDocReqEntity =ReqDocHome.create(injuryDocReqListBean);
1649 }
1650
1651 }
1652 // To insert bodyparts
1653 insertBodyParts(injuryBean.getInjuryId(),injuryBodyParts,injuryBean);
1654 // To insert ICDList
1655 insertICDDiagnosis(injuryBean.getInjuryId(),icdList,injuryBean);
1656 // updating pre existing deformities.
1657 if(injuryBean.getPreviousNonOH()!=null)
1658 {
1659 PreexistingDeformitiesEntityHome preexistDeformitiesHome =
1660 getPreExistDeformitiesHome();
1661 // if its already present it will be modifed else entered
1662 if(injuryBean.getPreExistDeformitiesId()==null)
1663 {
1664 // creating record if preexisting deformities for
1665 // contributor does not exists
1666 injuryBean.setPreExistDeformitiesId(
1667 GOSIUtilities.getPrimaryKey("T_CONPREEXISTINGDEFORMITIES",
1668 injuryBean.getCreatedBy()));
1669 PreexistingDeformitiesEntity oPreexistDeformitiesEntity =
1670 (PreexistingDeformitiesEntity)preexistDeformitiesHome.
1671 create(injuryBean);
1672 }
1673 else
1674 {
1675 // updating the contributor preexisting deformities information
1676 PreexistingDeformitiesEntity oPreexistDeformitiesEntity =
1677 (PreexistingDeformitiesEntity)preexistDeformitiesHome.
1678 findByPrimaryKey(injuryBean.getPreExistDeformitiesId());
1679 oPreexistDeformitiesEntity.
1680 updatePreexistDeformities(injuryBean);
1681 }
1682 }
1683 // Letter to be generated if injury is rejected
1684 if(OHConstants.INJ_STS_REJECTED.equals(injuryBean.getInjuryStatus()))
1685 {
1686 generateLetter(injuryBean);
1687 }
1688 GOSIDebug.debugMessages("--------------modifyInjuryDetails*-------------------");
1689 }
1690 catch (GOSIException ge)
1691 {
1692 sesCtx.setRollbackOnly();
1693 throw ge;
1694 }
1695 catch(Exception e)
1696 {
1697 sesCtx.setRollbackOnly();
1698 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
1699 GOSIConstants.SOCIAL_INSURANCE,
1700 this.getClass().toString(),
1701 "modifyInjuryDetails()",e, "CMN_ERR_1000"
1702 );
1703 }
1704 finally
1705 {
1706 GOSIUtilities.cleanUp (conn);
1707 }
1708 endTime = System.currentTimeMillis();
1709 elapsedTime = endTime - startTime;
1710 GOSIInstrumentationLog.writeInstrumentationToLog(
1711 this.getClass().toString(), "modifyInjuryDetails()",
1712 elapsedTime);
1713
1714 return userName;
1715 }
1716
1717 /**
1718 * @METHOD NAME : reenterCompln
1719 * @INFORMATION : This method is to update Complication Injury details in the Reenter mode
1720 * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.AddInjuryHelperBean,
1721 class gosi.core.workflow.beans.WorkflowParamBean,
1722 class java.lang.String,
1723 class java.util.ArrayList,
1724 class gosi.core.util.beans.AuditBean,
1725 class java.util.ArrayList,
1726 class gosi.core.dms.beans.DMSRequestHeaderBean,
1727 class java.util.ArrayList
1728 * @RETURN : class java.lang.String
1729 * @EXCEPTION : class gosi.core.util.GOSIException
1730 * @LAST MODIFIED BY :
1731 * @LAST MODIFIED DATE :
1732 **/
1733 public String reenterCompln(AddInjuryHelperBean injuryBean,
1734 WorkflowParamBean workflowParamBean,
1735 String contact,
1736 ArrayList contactList,
1737 AuditBean contactAuditBean,
1738 ArrayList injuryBodyParts,
1739 DMSRequestHeaderBean headerBean,
1740 ArrayList injuryDocReqList)
1741 throws GOSIException
1742 {
1743
1744 Long contactID;
1745 String userName="";
1746 long startTime = 0;
1747 long endTime = 0;
1748 long elapsedTime = 0;
1749
1750 startTime = System.currentTimeMillis();
1751 try
1752 {
1753 conn = GOSIUtilities.getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
1754 // this method is called to update the complication details
1755 // in the reenter mode, T_injury and the realted child tables
1756 // are modified in this method
1757 if(contact!=null) {
1758 contactAuditBean.setModuleId(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
1759 contactAuditBean.setCreationTimestamp(new Timestamp(System.currentTimeMillis()));
1760 contactAuditBean.setLastModifiedTimestamp(new Timestamp(System.currentTimeMillis()));
1761
1762 GOSIDebug.debugMessages("ContactList inside sesBean:" + contactList.size());
1763 }
1764 // adding contact details if present
1765 // logic checks if atleast one contact details record is present
1766 // for the contributor else it throws error
1767 if((contact!=null) && contactList.size()>0)
1768 {
1769 int count=0;
1770 for(int i=0; i<contactList.size();i++)
1771 {
1772 IndividualContactBean contactBean =
1773 (IndividualContactBean)contactList.get(i);
1774 contactBean.setModuleId
1775 (GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
1776 GOSIDebug.debugMessages("ModuleId inside sesBean:"+
1777 contactBean.getModuleId());
1778 String contMode =""+contactAuditBean.DELETE_MODE;
1779 String entMode =""+contactBean.getMode();
1780 if(!entMode.equals(contMode))
1781 {
1782 count=count+1;
1783 }
1784 }
1785 if(count==0)
1786 {
1787 throw new GOSIException( GOSIConstants.SEVERITY_THREE,
1788 GOSIConstants.SOCIAL_INSURANCE,
1789 this.getClass().toString(),
1790 "reenterCompln()",
1791 new GOSIException(),"SOI_ERR_4467");
1792 }
1793 }
1794 if((contact!=null) && contact.equals("Add"))
1795 {
1796 if(contactList.size()==0)
1797 {
1798 GOSIDebug.debugMessages("Inside count==null");
1799 throw new GOSIException( GOSIConstants.SEVERITY_THREE,
1800 GOSIConstants.SOCIAL_INSURANCE,
1801 this.getClass().toString(),
1802 "reenterCompln()",new GOSIException(),
1803 "SOI_ERR_4467");
1804 }
1805 }
1806 GOSIDebug.debugMessages("contact in session bean:"+contact);
1807 if(contact!=null && !("").equals(contact))
1808 {
1809 if("Add".equals(contact))
1810 {
1811 contactID=GOSIUtilities.
1812 createIndividualContactDetails(contactList,
1813 contactAuditBean);
1814 injuryBean.setContactId(contactID);
1815
1816 }
1817 else if("Modify".equals(contact))
1818 {
1819 GOSIUtilities.
1820 modifyIndividualContactDetails(contactList,
1821 contactAuditBean);
1822 }
1823 }
1824 GOSIDebug.debugMessages("Inside try of modify in ses bean:"+
1825 injuryBean.getInjuryId());
1826 // converting String dates entered by user to Timestamp for storage
1827 if( injuryBean.getInjuryDate()!= null)
1828 {
1829 injuryBean.setInjuryDate(SIUtilities.getDateTimestamp
1830 (injuryBean.getInjuryDateStr(),
1831 injuryBean.getInjuryDateEntFmt()));
1832 }
1833 if( injuryBean.getWorkDisabilityDate()!= null)
1834 {
1835 injuryBean.setWorkDisabilityDate(SIUtilities.getDateTimestamp
1836 (injuryBean.getWorkDisabilityDateStr(),
1837 injuryBean.getWorkDisabilityDateEntFmt()));
1838 }
1839 if( injuryBean.getEmpNotifyDate()!= null)
1840 {
1841 injuryBean.setEmpNotifyDate(SIUtilities.getDateTimestamp
1842 (injuryBean.getEmpNotifyDateStr(),
1843 injuryBean.getEmpNotifyDateEntFmt()));
1844 }
1845 if( injuryBean.getWorkerIntimateDate()!= null)
1846 {
1847 injuryBean.setWorkerIntimateDate(SIUtilities.getDateTimestamp
1848 (injuryBean.getWorkerIntDateStr(),
1849 injuryBean.getWorkerIntDateEntFmt()));
1850 }
1851 if( injuryBean.getWageStoppingDate()!= null)
1852 {
1853 injuryBean.setWageStoppingDate(SIUtilities.getDateTimestamp
1854 (injuryBean.getWageStoppingDateStr(),
1855 injuryBean.getWageStoppingDateEntFmt()));
1856 }
1857 if( injuryBean.getDateComplication()!= null)
1858 {
1859 injuryBean.setDateComplication(SIUtilities.getDateTimestamp
1860 (injuryBean.getComplicationDateStr(),
1861 injuryBean.getDateComplicationEntFmt()));
1862 }
1863 // setting audit information
1864 injuryBean.setLastModifiedTimestamp(new Timestamp
1865 (System.currentTimeMillis()));
1866 // calling injury entity home
1867 InjuryEntityHome home=getInjuryHome();
1868 InjuryEntity oInjuryEntity =(InjuryEntity)home.findByPrimaryKey
1869 (injuryBean.getInjuryId());
1870 oInjuryEntity.updateInjury(injuryBean);
1871 // updating injury
1872 // calling workflow interface
1873 if(OHConstants.WFS_INJ_PENDING_DATA_ENTRY.equals(injuryBean.getWorkFlowStatus())||
1874 OHConstants.INJ_STS_APPROVED.equals(injuryBean.getInjuryStatus()))
1875 {
1876 //No work flow
1877 }else
1878 {
1879 workflowParamBean.setrecordDescription(
1880 workflowParamBean.getrecordDescription()+"-"+
1881 injuryBean.getSocInsNumber());
1882 workflowParamBean.
1883 setPrimaryKeyOfTherecord(injuryBean.getInjuryId().toString());
1884 userName=GOSIUtilities.startWorkflow(workflowParamBean);
1885 }
1886
1887
1888 if(injuryDocReqList!=null)
1889 {
1890 InjuryDocReqEntityHome ReqDocHome = getInjuryReqDocHome();
1891
1892 for (int i=0; i<injuryDocReqList.size();i++)
1893 {
1894
1895 InjuryDocReqListBean injuryDocReqListBean=(InjuryDocReqListBean)injuryDocReqList.get(i);
1896 InjuryDocReqEntity injuryDocReqEntity =(InjuryDocReqEntity)ReqDocHome.findByPrimaryKey(injuryDocReqListBean.getInjuryDocReqId());
1897 injuryDocReqEntity.updateInjuryDocReq(injuryBean.getLastModifiedBy(),new Timestamp(System.currentTimeMillis()));
1898 }
1899 }
1900
1901 // the DMS key values are set and the dms interface called
1902 GOSIDebug.debugMessages("header bean"+ headerBean);
1903 if(headerBean != null)
1904 {
1905 GOSIDebug.debugMessages("inside header");
1906 headerBean.setSourceRecordId
1907 ("" + injuryBean.getInjuryId());
1908 headerBean.setSourceTable(SITables.T_INJURY);
1909 headerBean.setCreatedBy
1910 (new Long (workflowParamBean.getUserId()));
1911 headerBean.setKeyList(DMSConstants.SI_NUMBER,
1912 "" + injuryBean.getSocInsNumber());
1913 headerBean.setKeyList(DMSConstants.REGISTRATION_NUMBER,
1914 "" + injuryBean.getRegNumber());
1915 headerBean.setKeyList(DMSConstants.INJURY_NUMBER,
1916 "" + injuryBean.getInjuryNumber());
1917
1918 DMSUtilities.startDMS(headerBean);
1919
1920 }
1921
1922 // To insert bodyparts
1923 if(injuryBodyParts != null) {
1924 insertBodyParts(injuryBean.getInjuryId(),injuryBodyParts,injuryBean);
1925 }
1926 // updating preexisting deformities
1927 if(injuryBean.getPreviousNonOH()!=null)
1928 {
1929 PreexistingDeformitiesEntityHome preexistDeformitiesHome =
1930 getPreExistDeformitiesHome();
1931 // if its already present it will be modifed else entered
1932 if(injuryBean.getPreExistDeformitiesId()==null)
1933 {
1934 // creating record if preexisting deformities for
1935 // contributor does not exists
1936 injuryBean.setPreExistDeformitiesId(
1937 GOSIUtilities.getPrimaryKey("T_CONPREEXISTINGDEFORMITIES",
1938 injuryBean.getCreatedBy()));
1939 PreexistingDeformitiesEntity oPreexistDeformitiesEntity =
1940 (PreexistingDeformitiesEntity)preexistDeformitiesHome.
1941 create(injuryBean);
1942 }
1943 else
1944 {
1945 // updating the contributor preexisting deformities information
1946 PreexistingDeformitiesEntity oPreexistDeformitiesEntity =
1947 (PreexistingDeformitiesEntity)preexistDeformitiesHome.
1948 findByPrimaryKey(injuryBean.getPreExistDeformitiesId());
1949 oPreexistDeformitiesEntity.
1950 updatePreexistDeformities(injuryBean);
1951 }
1952 }
1953 // To update contact id in Contributor table
1954 if(injuryBean.getContactId()!=null)
1955 {
1956 ContributorBean oContributorBean=
1957 new ContributorBean();
1958 oContributorBean=ContributorUtilities.
1959 displayContributor(injuryBean.getContributorId());
1960 oContributorBean.setContactId(injuryBean.getContactId());
1961 oContributorBean.
1962 setLastModifiedTimestamp
1963 (new Timestamp(System.currentTimeMillis()));
1964 oContributorBean.setLastModifiedBy
1965 (injuryBean.getLastModifiedBy());
1966 ContributorUtilities.
1967 updateContributor(oContributorBean,false);
1968 }
1969 // generating letter if injury is rejected
1970 if(OHConstants.INJ_STS_REJECTED.equals(injuryBean.getInjuryStatus()))
1971 {
1972 generateLetter(injuryBean);
1973 }
1974 }
1975 catch (GOSIException ge)
1976 {
1977 sesCtx.setRollbackOnly();
1978 throw ge;
1979 }
1980 catch(Exception e)
1981 {
1982 sesCtx.setRollbackOnly();
1983 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
1984 GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
1985 "reenterCompln()", e, "CMN_ERR_1000" );
1986 }
1987 finally
1988 {
1989 GOSIUtilities.cleanUp (conn);
1990 }
1991 endTime = System.currentTimeMillis();
1992 elapsedTime = endTime - startTime;
1993 GOSIInstrumentationLog.writeInstrumentationToLog(
1994 this.getClass().toString(), "reenterCompln()", elapsedTime);
1995 return userName;
1996 }
1997
1998 /**
1999 * @METHOD NAME : searchInjModifyList
2000 * @INFORMATION : This method is to search the Injury/Complication details
2001 from the database for the workflow
2002 * @PARAM : class java.lang.Long,
2003 class java.lang.String
2004 * @RETURN : class java.util.ArrayList
2005 * @EXCEPTION : class gosi.core.util.GOSIException
2006 * @LAST MODIFIED BY :
2007 * @LAST MODIFIED DATE :
2008 **/
2009 public ArrayList searchInjModifyList(Long injuryId,String mode)
2010 throws GOSIException
2011 {
2012
2013 String sqlQuery="";
2014 PreparedStatement ps =null;
2015 ResultSet rsCommon =null;
2016 long startTime = 0;
2017 long endTime = 0;
2018 long elapsedTime = 0;
2019
2020 startTime = System.currentTimeMillis();
2021
2022 ArrayList injuryArrayList = new ArrayList();
2023 injuryArrayList.clear();
2024
2025 ArrayList finalInjuryArrayList = new ArrayList();
2026 finalInjuryArrayList.clear();
2027
2028 try
2029 {
2030 // Query to fetch the injury details in modify list
2031 // injury id is used to fetch the record
2032 // the injury bean is added in an array list and returned
2033 sqlQuery=OHQueryInjury.OhQry_QRY_00058 ;
2034
2035 conn = GOSIUtilities.getConnection
2036 (GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
2037 ps=conn.prepareStatement(sqlQuery);
2038 ps.setLong(1,injuryId.longValue());
2039
2040 GOSIDebug.debugMessages("sqlQuery:"+sqlQuery);
2041 GOSIDebug.debugMessages("MaintainInjurySessionEjb:InjuryId:"+injuryId);
2042 rsCommon=ps.executeQuery();
2043
2044 AddInjuryHelperBean injuryListBean =null;
2045
2046 if(rsCommon.next())
2047 {
2048 GOSIDebug.debugMessages("In the while loop of searchInjuryDetails:");
2049 injuryListBean =
2050 new AddInjuryHelperBean();
2051 injuryListBean.
2052 setInjuryId(new Long(rsCommon.getLong("INJURYID")));
2053 injuryListBean.
2054 setContributorId(new Long(rsCommon.getLong("CONTRIBUTORID")));
2055 injuryListBean.
2056 setEstablishmentId(new Long
2057 (rsCommon.getLong("ESTABLISHMENTID")));
2058 injuryListBean.
2059 setSocInsNumber(new Long(rsCommon.getLong("SOCINSNUMBER")));
2060 injuryListBean.
2061 setContactId(new Long(rsCommon.getLong("CONTACTID")));
2062 injuryListBean.
2063 setRegNumber(new Long(rsCommon.getLong("REGISTRATIONNUMBER")));
2064 injuryListBean.
2065 setInjuryDate(rsCommon.getTimestamp("INJURYDATE"));
2066 GOSIDebug.debugMessages("Injury Date:"+
2067 injuryListBean.getInjuryDate());
2068 injuryListBean.
2069 setInjuryDateEntFmt(rsCommon.getString("INJURYDATEENTFMT"));
2070 GOSIDebug.debugMessages("Injury Date:entfmt"+
2071 injuryListBean.getInjuryDateEntFmt());
2072 if (injuryListBean.getInjuryDateEntFmt()!= null)
2073 {
2074 injuryListBean.
2075 setInjuryDateStr(SIUtilities.getDateString(
2076 injuryListBean.getInjuryDate(),
2077 injuryListBean.getInjuryDateEntFmt()));
2078 GOSIDebug.debugMessages("injuryDateStr:"+
2079 injuryListBean.getInjuryDateStr());
2080 }
2081 injuryListBean.setWorkDisabilityDate(
2082 rsCommon.getTimestamp("WORKDISABILITYDATE"));
2083 GOSIDebug.debugMessages("workDisabilitydate in ses:"+
2084 injuryListBean.getWorkDisabilityDate());
2085 injuryListBean.setWorkDisabilityDateEntFmt(
2086 rsCommon.getString("WORKDISABILITYDATEENTFMT"));
2087 GOSIDebug.debugMessages("entfmt :::"+injuryListBean.
2088 getWorkDisabilityDateEntFmt());
2089 if (injuryListBean.getWorkDisabilityDateEntFmt()!= null)
2090 {
2091 injuryListBean.setWorkDisabilityDateStr
2092 (SIUtilities.getDateString(
2093 injuryListBean.getWorkDisabilityDate(),
2094 injuryListBean.getWorkDisabilityDateEntFmt()));
2095 GOSIDebug.debugMessages("WorkDisabilityDateStr in G"+
2096 injuryListBean.getWorkDisabilityDateStr());
2097 }
2098 injuryListBean.
2099 setReceiveWageFromEmp(new Byte(
2100 rsCommon.getByte("RECEIVINGWAGEFROMEMP")));
2101 injuryListBean.
2102 setInjuryNumber(new Long(rsCommon.getLong("INJURYNUMBER")));
2103 injuryListBean.
2104 setInjuryDescription(rsCommon.getString("DESCRIPTION"));
2105 injuryListBean.
2106 setDateComplication(
2107 rsCommon.getTimestamp("DATECOMPLICATION"));
2108 injuryListBean.
2109 setDateComplicationEntFmt(
2110 rsCommon.getString("DATECOMPLICATIONENTFMT"));
2111 if (injuryListBean.getDateComplicationEntFmt()!= null)
2112 {
2113 injuryListBean.setComplicationDateStr
2114 (SIUtilities.getDateString(
2115 injuryListBean.getDateComplication(),
2116 injuryListBean.getDateComplicationEntFmt()));
2117 }
2118 injuryListBean.setFieldOfficeCode(new Short(
2119 rsCommon.getShort("FIELDOFFICECODE")));
2120 if(rsCommon.getObject("ENTEREDBY")!=null) {
2121 injuryListBean.setEnteredBy(new Short(rsCommon.getShort("ENTEREDBY")));
2122 }
2123 if(rsCommon.getObject("INITIATEDBY")!=null) {
2124 injuryListBean.setInitiatedBy(new Short(rsCommon.getShort("INITIATEDBY")));
2125 }
2126 if(rsCommon.getObject("CREATEDBY")!=null) {
2127 injuryListBean.setCreatedBy(new Long(rsCommon.getLong("CREATEDBY")));
2128 }
2129 injuryListBean.setCreationTimestamp(rsCommon.getTimestamp("CREATIONTIMESTAMP"));
2130 if(rsCommon.getObject("GOVERNMENTSECTOR")!=null) {
2131 injuryListBean.setGovernmentSector(new Short(rsCommon.getShort("GOVERNMENTSECTOR")));
2132 }
2133 if(rsCommon.getObject("DELAYREASON")!=null) {
2134 injuryListBean.setDelayReason(rsCommon.getString("DELAYREASON"));
2135 }
2136 String firstName="";
2137 String secondName="";
2138 String thirdName="";
2139 String surName="";
2140 String finalName="";
2141 if(rsCommon.getString("FIRSTNAME")!=null)
2142 {
2143 firstName=""+rsCommon.getString("FIRSTNAME");
2144 }
2145 if(rsCommon.getString("SECONDNAME")!=null)
2146 {
2147 secondName=""+rsCommon.getString("SECONDNAME");
2148 }
2149 if(rsCommon.getString("THIRDNAME")!=null)
2150 {
2151 thirdName=""+rsCommon.getString("THIRDNAME");
2152 }
2153 if(rsCommon.getString("SURNAME")!=null)
2154 {
2155 surName=""+rsCommon.getString("SURNAME");
2156 }
2157 finalName=firstName+" "+secondName+" "+thirdName+" "+surName;
2158 injuryListBean.setName(finalName);
2159 injuryListBean.
2160 setInjuryTimeHrs(rsCommon.getString("INJURYTIMEHR"));
2161 injuryListBean.
2162 setInjuryTimeMins(rsCommon.getString("INJURYTIMEMIN"));
2163 injuryListBean.
2164 setInjuryTimeAmPm(
2165 new Byte(rsCommon.getByte("INJURYTIMEAMPM")));
2166 injuryListBean.
2167 setEmpNotifyDate(rsCommon.getTimestamp
2168 ("EMPLOYERNOTIFYDATE"));
2169 injuryListBean.
2170 setEmpNotifyDateEntFmt(
2171 rsCommon.getString("EMPLOYERNOTIFYDATEENTFMT"));
2172 if (injuryListBean.getEmpNotifyDateEntFmt()!= null)
2173 {
2174 injuryListBean.setEmpNotifyDateStr
2175 (SIUtilities.getDateString(
2176 injuryListBean.getEmpNotifyDate(),
2177 injuryListBean.getEmpNotifyDateEntFmt()));
2178 }
2179 injuryListBean.
2180 setWorkerIntimateDate(rsCommon.getTimestamp
2181 ("WORKERINTIMATIONDATE"));
2182 injuryListBean.
2183 setWorkerIntDateEntFmt(
2184 rsCommon.getString("WORKERINTIMATIONDATEENTFMT"));
2185 if (injuryListBean.getWorkerIntDateEntFmt()!= null)
2186 {
2187 injuryListBean.setWorkerIntDateStr
2188 (SIUtilities.getDateString(
2189 injuryListBean.getWorkerIntimateDate(),
2190 injuryListBean.getWorkerIntDateEntFmt()));
2191 }
2192 injuryListBean.
2193 setPlaceOfInjury(rsCommon.getString("PLACEINJURY"));
2194 injuryListBean.
2195 setActivityAtTimeInjury(
2196 rsCommon.getString("ACTIVITYATTIMEINJURY"));
2197 injuryListBean.
2198 setWageStoppingDate(rsCommon.getTimestamp("WAGESTOPDATE"));
2199 injuryListBean.
2200 setWageStoppingDateEntFmt(
2201 rsCommon.getString("WAGESTOPDATEENTFMT"));
2202 if (injuryListBean.getWageStoppingDateEntFmt()!= null)
2203 {
2204 injuryListBean.setWageStoppingDateStr
2205 (SIUtilities.getDateString(
2206 injuryListBean.getWageStoppingDate(),
2207 injuryListBean.getWageStoppingDateEntFmt()));
2208 }
2209 injuryListBean.
2210 setNationalityCode(
2211 new Short(rsCommon.getShort("NATIONALITYCODE")));
2212 injuryListBean.
2213 setInjuryStatus(
2214 new Short(rsCommon.getShort("INJURYSTATUS")));
2215 injuryListBean.
2216 setEstablishmentName(
2217 rsCommon.getString("ESTABLISHMENTNAMEENG"));
2218 injuryListBean.
2219 setEstablishmentNameArb(
2220 rsCommon.getString("ESTABLISHMENTNAMEARB"));
2221 GOSIDebug.debugMessages("EstablishmentNameArb:"+
2222 injuryListBean.
2223 getEstablishmentNameArb());
2224 if(rsCommon.getObject("RESPONSIBLEFOROHPAYMENT")!=null)
2225 {
2226 injuryListBean.setResponsibleForOHPayment
2227 (new Byte(rsCommon.getByte("RESPONSIBLEFOROHPAYMENT")));
2228 }
2229
2230
2231 if(rsCommon.getObject("ACCIDENTCODE")!=null)
2232 {
2233 injuryListBean.setAccidentCode(
2234 new Short(rsCommon.getShort("ACCIDENTCODE")));
2235 }
2236 if(rsCommon.getObject("ACCIDENTOTHER")!=null)
2237 {
2238 injuryListBean.setAccidentOther(
2239 rsCommon.getString("ACCIDENTOTHER"));
2240 }
2241 if(rsCommon.getObject("INJURYSOURCECODE") != null)
2242 {
2243 injuryListBean.
2244 setInjurySourceCode(
2245 new Short(rsCommon.getShort("INJURYSOURCECODE")));
2246 }
2247 if(rsCommon.getObject("INJURYSOURCEOTHER") != null)
2248 {
2249 injuryListBean.
2250 setInjurySourceOther(rsCommon.getString("INJURYSOURCEOTHER"));
2251 }
2252 injuryListBean.
2253 setInjuryNatureCode(
2254 new Short(rsCommon.getShort("INJURYNATURECODE")));
2255 if(rsCommon.getObject("INJURYNATUREOTHER") != null)
2256 {
2257 injuryListBean.
2258 setInjuryNatureOther(rsCommon.getString("INJURYNATUREOTHER"));
2259 }
2260 injuryListBean.
2261 setHospitalCode(
2262 new Long(rsCommon.getLong("HOSPITALCODE")));
2263 injuryListBean.
2264 setWorkFlowStatus(
2265 new Short(rsCommon.getShort("WORKFLOWSTATUS")));
2266 injuryListBean.
2267 setOHEligibilityStatus(new Byte(
2268 rsCommon.getByte("OHELIGIBILITYSTATUS")));
2269 if(rsCommon.getObject("REJECTIONCODE")!=null)
2270 {
2271 injuryListBean.setRejectionCode(new Short(
2272 rsCommon.getShort("REJECTIONCODE")));
2273 }
2274 injuryListBean.setLastModifiedTimestamp(
2275 rsCommon.getTimestamp("LASTMODIFIEDTIMESTAMP"));
2276
2277 if(rsCommon.getString("RoutingFlag")!=null)
2278 {
2279 injuryListBean.setRoutingFlag(new Byte(
2280 rsCommon.getByte("ROUTINGFLAG")));
2281 }
2282
2283
2284
2285 GOSIDebug.debugMessages("routing flag:"+
2286 injuryListBean.getRoutingFlag());
2287 injuryArrayList.add(injuryListBean);
2288 }
2289 // getting details for the varios codes stored in injury table
2290 if(injuryArrayList.size()!=0)
2291 {
2292 AddInjuryHelperBean injuryHelpBean = null;
2293 for(int i=0;i<injuryArrayList.size();i++)
2294 {
2295 injuryHelpBean = new AddInjuryHelperBean();
2296 injuryHelpBean=(AddInjuryHelperBean)injuryArrayList.get(i);
2297 // getting accident details
2298 if(injuryHelpBean.getAccidentCode()!=null)
2299 {
2300 String strQuery="";
2301 StringBuffer queryBuffer = new StringBuffer();
2302
2303 queryBuffer.append(" select ACCIDENTCODE, ACCIDENTNAMEARB, " );
2304 queryBuffer.append(" ACCIDENTNAMEENG FROM ");
2305 queryBuffer.append(SITables.T_ACCIDENT);
2306 queryBuffer.append(" WHERE ");
2307 queryBuffer.append(" ACCIDENTCODE=? ");
2308
2309 strQuery = queryBuffer.toString();
2310
2311 ps=conn.prepareStatement(strQuery);
2312 ps.setInt(1,injuryHelpBean.getAccidentCode().shortValue());
2313 rsCommon=ps.executeQuery();
2314 if(rsCommon.next())
2315 {
2316 injuryHelpBean.setAccidentType
2317 (rsCommon.getString("ACCIDENTNAMEENG"));
2318 injuryHelpBean.setAccidentTypeArb
2319 (rsCommon.getString("ACCIDENTNAMEARB"));
2320 }
2321 }// getting injury source details
2322 if(injuryHelpBean.getInjurySourceCode()!=null)
2323 {
2324 String strQuery="";
2325 StringBuffer queryBuffer = new StringBuffer();
2326
2327 queryBuffer.append(OHQueryInjury.OhQry_QRY_00059 );
2328 queryBuffer.append("g.INJURYSOURCEARB FROM ");
2329 queryBuffer.append(SITables.T_INJURYSOURCE);
2330 queryBuffer.append(" g ");
2331 queryBuffer.append("WHERE ");
2332 queryBuffer.append("g.INJURYSOURCECODE=?");
2333
2334 strQuery = queryBuffer.toString();
2335
2336 ps=conn.prepareStatement(strQuery);
2337 ps.setInt(1,injuryHelpBean.getInjurySourceCode().
2338 shortValue());
2339 rsCommon=ps.executeQuery();
2340 if(rsCommon.next())
2341 {
2342 injuryHelpBean.
2343 setInjurySource
2344 (rsCommon.getString("INJURYSOURCEENG"));
2345 injuryHelpBean.setInjurySourceArb(
2346 rsCommon.getString("INJURYSOURCEARB"));
2347 }
2348 }// getting injury nature details
2349 if(injuryHelpBean.getInjuryNatureCode()!=null)
2350 {
2351 String strQuery="";
2352
2353 StringBuffer queryBuffer = new StringBuffer();
2354
2355 queryBuffer.append(OHQueryInjury.OhQry_QRY_00060 );
2356 queryBuffer.append("h.INJURYNATUREARB FROM ");
2357 queryBuffer.append(SITables.T_INJURYNATURE);
2358 queryBuffer.append(" h ");
2359 queryBuffer.append("WHERE h.INJURYNATURECODE=?");
2360
2361 strQuery=queryBuffer.toString();
2362 GOSIDebug.debugMessages(""+strQuery);
2363 ps=conn.prepareStatement(strQuery);
2364 ps.setInt(1,injuryHelpBean.getInjuryNatureCode().
2365 shortValue());
2366 rsCommon=ps.executeQuery();
2367 if(rsCommon.next())
2368 {
2369 injuryHelpBean.setInjuryNature(
2370 rsCommon.getString("INJURYNATUREENG"));
2371 injuryHelpBean.setInjuryNatureArb(
2372 rsCommon.getString("INJURYNATUREARB"));
2373 }
2374 }// getting hospital details
2375 if(injuryHelpBean.getHospitalCode()!=null)
2376 {
2377
2378 String strQuery="";
2379 StringBuffer queryBuffer = new StringBuffer();
2380 queryBuffer.append(OHQueryInjury.OhQry_QRY_00061 );
2381 queryBuffer.append("i.HOSPITALNAMEARB FROM ");
2382 queryBuffer.append(SITables.T_HOSPITAL);
2383 queryBuffer.append(" i ");
2384 queryBuffer.append("WHERE i.HOSPITALCODE=?");
2385
2386 strQuery = queryBuffer.toString();
2387 GOSIDebug.debugMessages("Inside the for loop::3:Query");
2388 GOSIDebug.debugMessages(""+strQuery);
2389 ps=conn.prepareStatement(strQuery);
2390 ps.setLong
2391 (1,injuryHelpBean.getHospitalCode().intValue());
2392 rsCommon=ps.executeQuery();
2393 if(rsCommon.next())
2394 {
2395 injuryHelpBean.setHospitalName(
2396 rsCommon.getString("HOSPITALNAMEENG"));
2397 injuryHelpBean.setHospitalNameArb(
2398 rsCommon.getString("HOSPITALNAMEARB"));
2399
2400 }
2401 }// getting contributor preexisting details
2402 if(injuryHelpBean.getContributorId()!=null)
2403 {
2404 String strQuery="";
2405 StringBuffer queryBuffer = new StringBuffer();
2406 queryBuffer.append
2407 (OHQueryInjury.OhQry_QRY_00062 );
2408 queryBuffer.append(" PRE.PREEXISTINGDEFORMITIES ");
2409 queryBuffer.append
2410 (" FROM "+SITables.T_CONPREEXISTINGDEFORMITIES);
2411 queryBuffer.append(" PRE,");
2412 queryBuffer.append(SITables.T_CONTRIBUTOR);
2413 queryBuffer.append(" CON ");
2414 queryBuffer.append
2415 (" WHERE PRE.CONTRIBUTORID=CON.CONTRIBUTORID ");
2416 queryBuffer.append(" AND CON.CONTRIBUTORID=? ");
2417
2418 strQuery=queryBuffer.toString();
2419
2420 ps=conn.prepareStatement(strQuery);
2421 ps.setLong(1,injuryHelpBean.
2422 getContributorId().longValue());
2423 rsCommon=ps.executeQuery();
2424 if(rsCommon.next())
2425 {
2426 injuryHelpBean.
2427 setPreExistDeformitiesId(new Long(
2428 rsCommon.getLong("PREEXISTINGDEFORMITIESID")));
2429 injuryHelpBean.setPreviousNonOH(
2430 rsCommon.getString("PREEXISTINGDEFORMITIES"));
2431 }
2432 }
2433 GOSIDebug.debugMessages("ContributorId:"+
2434 injuryHelpBean.getContributorId());
2435 GOSIDebug.debugMessages("establishmentId:"+
2436 injuryHelpBean.getEstablishmentId());
2437 // getting occupation and engagement details
2438 if(injuryHelpBean.getContributorId()!=null)
2439 {
2440 String strQuery="";
2441 StringBuffer queryBuffer = new StringBuffer();
2442 queryBuffer.append(
2443 OHQueryInjury.OhQry_QRY_00063 );
2444 queryBuffer.append(" ENG.JOININGMONTHLYMOVEMENTID, ");
2445 queryBuffer.append(" ENG.JOININGDATE,");
2446 queryBuffer.append(" ENG.JOININGDATEENTFMT, ");
2447 queryBuffer.append(" ENG.LEAVINGDATE,");
2448 queryBuffer.append(" ENG.LEAVINGDATEENTFMT, ");
2449 queryBuffer.append(" ENG.ENGAGEMENTSTATUS,");
2450 queryBuffer.append(" OCC.OCCUPATIONNAMEENG, ");
2451 queryBuffer.append(" OCC.OCCUPATIONNAMEARB ");
2452 queryBuffer.append(" FROM ");
2453 queryBuffer.append(SITables.T_ENGAGEMENT);
2454 queryBuffer.append(" ENG,");
2455 queryBuffer.append(SITables.T_OCCUPATION);
2456 queryBuffer.append(" OCC, ");
2457 queryBuffer.append(SITables.T_ENGAGEMENTOCCUPATION);
2458 queryBuffer.append(" ENGOCC ");
2459 queryBuffer.append
2460 (" WHERE ENG.ENGAGEMENTID=ENGOCC.ENGAGEMENTID ");
2461 queryBuffer.append
2462 (" AND OCC.OCCUPATIONCODE=ENGOCC.OCCUPATIONCODE ");
2463 queryBuffer.append(" AND ENG.CONTRIBUTORID=? ");
2464 queryBuffer.append(" AND ENG.ESTABLISHMENTID=? ");
2465 queryBuffer.append(" AND ENG.JOININGDATE <= ? and NVL(ENG.LEAVINGDATE,?)>= ?");
2466
2467 strQuery = queryBuffer.toString();
2468 GOSIDebug.debugMessages(""+strQuery);
2469 ps=conn.prepareStatement(strQuery);
2470 ps.setLong(1,injuryHelpBean.
2471 getContributorId().longValue());
2472 ps.setLong(2,injuryHelpBean.
2473 getEstablishmentId().longValue());
2474 ps.setTimestamp(3,injuryHelpBean.getInjuryDate());
2475 ps.setTimestamp(4,new Timestamp(System.currentTimeMillis()));
2476 ps.setTimestamp(5,injuryHelpBean.getInjuryDate());
2477
2478 rsCommon=ps.executeQuery();
2479 while(rsCommon.next())
2480 {
2481 injuryHelpBean.
2482 setEngagementId(new Long(
2483 rsCommon.getLong("ENGAGEMENTID")));
2484 injuryHelpBean.setMonthlyMovementId
2485 (new Long(rsCommon.
2486 getLong("JOININGMONTHLYMOVEMENTID")));
2487 injuryHelpBean.setOccupation
2488 (rsCommon.getString("OCCUPATIONNAMEENG"));
2489 injuryHelpBean.setOccupationArb
2490 (rsCommon.getString("OCCUPATIONNAMEARB"));
2491 injuryHelpBean.
2492 setEngagementStatus(
2493 rsCommon.getShort("ENGAGEMENTSTATUS"));
2494 injuryHelpBean.
2495 setJoiningDate(
2496 rsCommon.getTimestamp("JOININGDATE"));
2497 injuryHelpBean.
2498 setJoiningDateEntFmt
2499 (rsCommon.getString("JOININGDATEENTFMT"));
2500 if(injuryHelpBean.getJoiningDateEntFmt()!= null)
2501 {
2502 injuryHelpBean.setJoiningDateStr
2503 (SIUtilities.getDateString(
2504 injuryHelpBean.getJoiningDate(),
2505 injuryHelpBean.getJoiningDateEntFmt()));
2506 }
2507 injuryHelpBean.setLeavingDate(rsCommon.
2508 getTimestamp("LEAVINGDATE"));
2509 injuryHelpBean.setLeavingDateEntFmt
2510 (rsCommon.getString("LEAVINGDATEENTFMT"));
2511 if(injuryHelpBean.getLeavingDateEntFmt()!= null)
2512 {
2513 injuryHelpBean.setLeavingDateStr
2514 (SIUtilities.getDateString(
2515 injuryHelpBean.getLeavingDate(),
2516 injuryHelpBean.getLeavingDateEntFmt()));
2517 }
2518 }
2519 }
2520 GOSIDebug.debugMessages("EstablishmentId:"+
2521 injuryHelpBean.getEstablishmentId());
2522 // getting form submission date
2523 if(injuryHelpBean.getEstablishmentId()!=null &&
2524 injuryHelpBean.getMonthlyMovementId()!=null)
2525 {
2526 String strQuery="";
2527 StringBuffer queryBuffer = new StringBuffer();
2528 queryBuffer.append(
2529 OHQueryInjury.OhQry_QRY_00064 );
2530 queryBuffer.append
2531 (" FROM T_MONTHLYMOVEMENTSUMMARY ");
2532 queryBuffer.append
2533 (" WHERE MONTHLYMOVEMENTSUMMARYID=? ");
2534 queryBuffer.append(" AND ESTABLISHMENTID=? ");
2535
2536 strQuery = queryBuffer.toString();
2537 ps=conn.prepareStatement(strQuery);
2538 ps.setLong(1,injuryHelpBean.
2539 getMonthlyMovementId().longValue());
2540 ps.setLong(2,injuryHelpBean.
2541 getEstablishmentId().longValue());
2542 GOSIDebug.debugMessages(""+strQuery);
2543 rsCommon=ps.executeQuery();
2544 while(rsCommon.next())
2545 {
2546 injuryHelpBean.
2547 setFormSubmissionDate(
2548 rsCommon.getTimestamp("FORMSUBMISSIONDATE"));
2549 GOSIDebug.debugMessages("FormSubmissionDate:"+
2550 injuryHelpBean.getFormSubmissionDate());
2551 injuryHelpBean.
2552 setFormSubmissionDateEntFmt(
2553 injuryHelpBean.getInjuryDateEntFmt());
2554 GOSIDebug.debugMessages("FormSubmissionEntFmt:"+
2555 injuryHelpBean.getFormSubmissionDateEntFmt());
2556 if (injuryHelpBean.
2557 getFormSubmissionDateEntFmt()!= null)
2558 {
2559 injuryHelpBean.setFormSubmissionDateStr
2560 (SIUtilities.getDateString(
2561 injuryHelpBean.getFormSubmissionDate(),
2562 injuryHelpBean.getFormSubmissionDateEntFmt()));
2563 }
2564 }
2565 }
2566 // getting coverage details
2567 if(injuryHelpBean.getEngagementId()!=null)
2568 {
2569 String strQuery ="";
2570 strQuery=
2571 OHQueryInjury.OhQry_QRY_00065 ;
2572 GOSIDebug.debugMessages("eng id:"+
2573 injuryHelpBean.getEngagementId());
2574 GOSIDebug.debugMessages(""+strQuery);
2575 ps=conn.prepareStatement(strQuery);
2576 ps.setLong(1,injuryHelpBean.
2577 getEngagementId().longValue());
2578 ps.setShort(2,RegistrationConstants.VALID);
2579 ps.setShort(3,RegistrationConstants.
2580 DATA_FINALLY_APPROVED.shortValue());
2581 //ps.setByte(4,RegistrationConstants.ACTIVE_WORKER.byteValue());
2582 ps.setLong(4,injuryHelpBean.
2583 getEngagementId().longValue());
2584 rsCommon=ps.executeQuery();
2585 if(rsCommon.next())
2586 {
2587 injuryHelpBean.setCoverage(new Short(
2588 rsCommon.getShort("COVERAGE")));
2589 GOSIDebug.debugMessages("setCoverage::"+
2590 injuryHelpBean.getCoverage());
2591 }
2592 }
2593 finalInjuryArrayList.add(injuryHelpBean);
2594 }
2595 }
2596 endTime = System.currentTimeMillis();
2597 elapsedTime = endTime - startTime;
2598 GOSIInstrumentationLog.writeInstrumentationToLog(
2599 this.getClass().toString(), "searchInjModifyList()",
2600 elapsedTime);
2601 }
2602 catch (GOSIException ge)
2603 {
2604 ge.printStackTrace();
2605 throw ge;
2606 }
2607 catch(Exception e)
2608 {
2609 e.printStackTrace();
2610 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
2611 GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
2612 "searchInjModifyList()", e, "CMN_ERR_1000");
2613 }
2614 finally
2615 {
2616 GOSIUtilities.cleanUp(conn, ps, rsCommon);
2617 }
2618 return finalInjuryArrayList;
2619 // returning injury details in an array list
2620 }
2621
2622 /**
2623 * @METHOD NAME : searchInjuryDetailsList
2624 * @INFORMATION : This method will search for the Injury Details
2625 in the popup if the record is already exists
2626 * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.AddInjuryHelperBean
2627 * @RETURN : class java.util.ArrayList
2628 * @EXCEPTION : class gosi.core.util.GOSIException
2629 * @LAST MODIFIED BY :
2630 * @LAST MODIFIED DATE :
2631 **/
2632 public ArrayList searchInjuryDetailsList
2633 (AddInjuryHelperBean injuryBean)
2634 throws GOSIException
2635 {
2636
2637 String sqlQuery="";
2638 PreparedStatement ps =null;
2639 ResultSet rsCommon =null;
2640 long startTime = 0;
2641 long endTime = 0;
2642 long elapsedTime = 0;
2643 startTime = System.currentTimeMillis();
2644
2645 ArrayList injuryArrayList = new ArrayList();
2646 ArrayList finalInjuryArrayList=new ArrayList();
2647 // Query to fetch the injury details in modify mode
2648 // sin and injury date is used to fetch the record
2649 // the injury bean is added in an array list and returned
2650 sqlQuery=OHQueryInjury.OhQry_QRY_00066 ;
2651 try
2652 {
2653 GOSIDebug.debugMessages(""+sqlQuery);
2654 GOSIDebug.debugMessages("injurydate"+injuryBean.getInjuryDate());
2655 GOSIDebug.debugMessages("socinsnumber"+injuryBean.getSocInsNumber());
2656 GOSIDebug.debugMessages("OHConstants.INJ_STS_APPROVED"+
2657 OHConstants.INJ_STS_APPROVED);
2658 GOSIDebug.debugMessages("OHConstants.WFS_INJ_PENDING_DATA_ENTRY"+
2659 OHConstants.WFS_INJ_PENDING_DATA_ENTRY);
2660 GOSIDebug.debugMessages("Injury Type:"+OHConstants.INJ_TYPE_INJURY);
2661 conn = GOSIUtilities.
2662 getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
2663 ps=conn.prepareStatement(sqlQuery);
2664 ps.setByte(1,OHConstants.INJ_TYPE_INJURY.byteValue());
2665 ps.setShort(2,OHConstants.INJ_STS_APPROVED.shortValue());
2666 ps.setShort(3,OHConstants.
2667 WFS_INJ_PENDING_DATA_ENTRY.shortValue());
2668 ps.setLong(4,injuryBean.getSocInsNumber().longValue());
2669 ps.setTimestamp(5,injuryBean.getInjuryDate());
2670
2671 rsCommon=ps.executeQuery();
2672
2673 AddInjuryHelperBean injuryListBean =null;
2674
2675 while(rsCommon.next())
2676 {
2677 injuryListBean = new AddInjuryHelperBean();
2678
2679 injuryListBean.
2680 setInjuryId(
2681 new Long(rsCommon.getLong("INJURYID")));
2682 injuryListBean.
2683 setSocInsNumber(
2684 new Long(rsCommon.getLong("SOCINSNUMBER")));
2685 injuryListBean.
2686 setRegNumber(new Long
2687 (rsCommon.getLong("REGISTRATIONNUMBER")));
2688 injuryListBean.
2689 setEstablishmentId(new Long
2690 (rsCommon.getLong("ESTABLISHMENTID")));
2691 injuryListBean.
2692 setInjuryDate(rsCommon.getTimestamp("INJURYDATE"));
2693 injuryListBean.
2694 setInjuryDateEntFmt(
2695 rsCommon.getString("INJURYDATEENTFMT"));
2696
2697 if (injuryListBean.getInjuryDateEntFmt()!= null)
2698 {
2699 injuryListBean.setInjuryDateStr
2700 (SIUtilities.getDateString(
2701 injuryListBean.getInjuryDate(),
2702 injuryListBean.getInjuryDateEntFmt()));
2703 }
2704 injuryListBean.setWorkDisabilityDate(
2705 rsCommon.getTimestamp("WORKDISABILITYDATE"));
2706 injuryListBean.setWorkDisabilityDateEntFmt(
2707 rsCommon.getString("WORKDISABILITYDATEENTFMT"));
2708 if (injuryListBean.getWorkDisabilityDateEntFmt()!= null)
2709 {
2710 injuryListBean.setWorkDisabilityDateStr
2711 (SIUtilities.getDateString(
2712 injuryListBean.getWorkDisabilityDate(),
2713 injuryListBean.getWorkDisabilityDateEntFmt()));
2714 }
2715 injuryListBean.
2716 setReceiveWageFromEmp(new Byte(
2717 rsCommon.getByte("RECEIVINGWAGEFROMEMP")));
2718 injuryListBean.setContributorId(new Long(
2719 rsCommon.getLong("CONTRIBUTORID")));
2720 injuryListBean.setInjuryNumber(
2721 new Long(rsCommon.getLong("INJURYNUMBER")));
2722 injuryListBean.setInjuryDescription(
2723 rsCommon.getString("DESCRIPTION"));
2724 String firstName="";
2725 String secondName="";
2726 String thirdName="";
2727 String surName="";
2728 String finalName="";
2729 if(rsCommon.getString("FIRSTNAME")!=null)
2730 {
2731 firstName=""+rsCommon.getString("FIRSTNAME");
2732 }
2733 if(rsCommon.getString("SECONDNAME")!=null)
2734 {
2735 secondName=""+rsCommon.getString("SECONDNAME");
2736 }
2737 if(rsCommon.getString("THIRDNAME")!=null)
2738 {
2739 thirdName=""+rsCommon.getString("THIRDNAME");
2740 }
2741 if(rsCommon.getString("SURNAME")!=null)
2742 {
2743 surName=""+rsCommon.getString("SURNAME");
2744 }
2745 finalName=firstName+" "+secondName+" "+thirdName+" "+surName;
2746 injuryListBean.setName(finalName);
2747 injuryListBean.
2748 setInjuryTimeHrs(
2749 rsCommon.getString("INJURYTIMEHR"));
2750 injuryListBean.
2751 setInjuryTimeMins(rsCommon.getString("INJURYTIMEMIN"));
2752 injuryListBean.setInjuryTimeAmPm(
2753 new Byte(rsCommon.getByte("INJURYTIMEAMPM")));
2754 injuryListBean.
2755 setEmpNotifyDate(rsCommon.getTimestamp
2756 ("EMPLOYERNOTIFYDATE"));
2757 injuryListBean.setEmpNotifyDateEntFmt(
2758 rsCommon.getString("EMPLOYERNOTIFYDATEENTFMT"));
2759 if (injuryListBean.getEmpNotifyDateEntFmt()!= null)
2760 {
2761 injuryListBean.setEmpNotifyDateStr
2762 (SIUtilities.getDateString(
2763 injuryListBean.getEmpNotifyDate(),
2764 injuryListBean.getEmpNotifyDateEntFmt()));
2765 }
2766 injuryListBean.
2767 setWorkerIntimateDate(rsCommon.getTimestamp
2768 ("WORKERINTIMATIONDATE"));
2769 injuryListBean.setWorkerIntDateEntFmt(
2770 rsCommon.getString("WORKERINTIMATIONDATEENTFMT"));
2771 if (injuryListBean.getWorkerIntDateEntFmt()!= null)
2772 {
2773 injuryListBean.setWorkerIntDateStr
2774 (SIUtilities.getDateString(
2775 injuryListBean.getWorkerIntimateDate(),
2776 injuryListBean.getWorkerIntDateEntFmt()));
2777 }
2778 injuryListBean.
2779 setPlaceOfInjury(
2780 rsCommon.getString("PLACEINJURY"));
2781 injuryListBean.
2782 setActivityAtTimeInjury(
2783 rsCommon.getString("ACTIVITYATTIMEINJURY"));
2784 injuryListBean.
2785 setLastModifiedTimestamp(
2786 rsCommon.getTimestamp("LASTMODIFIEDTIMESTAMP"));
2787 GOSIDebug.debugMessages("last modified timestamp:"+
2788 injuryListBean.getLastModifiedTimestamp());
2789 injuryListBean.
2790 setWageStoppingDate(
2791 rsCommon.getTimestamp("WAGESTOPDATE"));
2792 injuryListBean.
2793 setWageStoppingDateEntFmt(
2794 rsCommon.getString("WAGESTOPDATEENTFMT"));
2795 if (injuryListBean.getWageStoppingDateEntFmt()!= null)
2796 {
2797 injuryListBean.setWageStoppingDateStr
2798 (SIUtilities.getDateString(
2799 injuryListBean.getWageStoppingDate(),
2800 injuryListBean.getWageStoppingDateEntFmt()));
2801 }
2802 injuryListBean.
2803 setNationalityCode(
2804 new Short(rsCommon.getShort("NATIONALITYCODE")));
2805 injuryListBean.
2806 setEstablishmentName(
2807 rsCommon.getString("ESTABLISHMENTNAMEENG"));
2808 injuryListBean.
2809 setEstablishmentNameArb(
2810 rsCommon.getString("ESTABLISHMENTNAMEARB"));
2811
2812 if(rsCommon.getObject("ACCIDENTCODE")!= null)
2813 {
2814 injuryListBean.setAccidentCode
2815 (new Short(rsCommon.getShort("ACCIDENTCODE")));
2816 }
2817 if(rsCommon.getObject("INJURYSOURCECODE") != null)
2818 {
2819 injuryListBean.
2820 setInjurySourceCode(
2821 new Short(rsCommon.getShort("INJURYSOURCECODE")));
2822 }
2823 if(rsCommon.getObject("INJURYNATURECODE")!= null)
2824 {
2825 injuryListBean.setInjuryNatureCode(
2826 new Short(rsCommon.getShort("INJURYNATURECODE")));
2827 }
2828 if(rsCommon.getObject("ACCIDENTOTHER")!= null)
2829 {
2830 injuryListBean.setAccidentOther(rsCommon.getString("ACCIDENTOTHER"));
2831 }
2832 if(rsCommon.getObject("DELAYREASON")!=null) {
2833 injuryListBean.setDelayReason(rsCommon.getString("DELAYREASON"));
2834 }
2835 if(rsCommon.getObject("INJURYSOURCEOTHER") != null)
2836 {
2837 injuryListBean.
2838 setInjurySourceOther(rsCommon.getString("INJURYSOURCEOTHER"));
2839 }
2840 if(rsCommon.getObject("INJURYNATUREOTHER")!= null)
2841 {
2842 injuryListBean.setInjuryNatureOther(rsCommon.getString("INJURYNATUREOTHER"));
2843 }
2844
2845 injuryListBean.
2846 setHospitalCode(new Long(rsCommon.getLong("HOSPITALCODE")));
2847 injuryListBean.
2848 setInjuryStatus(new Short(rsCommon.getShort("INJURYSTATUS")));
2849 injuryListBean.setWorkFlowStatus(
2850 new Short(rsCommon.getShort("WORKFLOWSTATUS")));
2851 injuryListBean.setFieldOfficeCode(
2852 new Short(rsCommon.getShort("FIELDOFFICECODE")));
2853
2854 injuryListBean.setInjuryType(
2855 new Byte(rsCommon.getByte("INJURYTYPE")));
2856 injuryListBean.
2857 setContactId(new Long(rsCommon.getLong("CONTACTID")));
2858 if(rsCommon.wasNull())
2859 {
2860 injuryListBean.setContactId(null);
2861 }
2862 injuryArrayList.add(injuryListBean);
2863 }
2864 // if the query fetches more than one record
2865 // each bean is itrated through this loop to set the details
2866 if(injuryArrayList.size()!=0)
2867 {
2868 AddInjuryHelperBean injuryHelpBean = null;
2869 // itrating the list
2870 for(int i=0;i<injuryArrayList.size();i++)
2871 {
2872 injuryHelpBean =
2873 new AddInjuryHelperBean();
2874 injuryHelpBean=
2875 (AddInjuryHelperBean)injuryArrayList.get(i);
2876 GOSIDebug.debugMessages(".......socinsnumber........"+
2877 injuryHelpBean.getInjuryId());
2878 //getting accident details
2879 if(injuryHelpBean.getAccidentCode()!=null)
2880 {
2881 String strQuery="";
2882 strQuery=OHQueryInjury.OhQry_QRY_00137 ;
2883 GOSIDebug.debugMessages(""+strQuery);
2884 ps=conn.prepareStatement(strQuery);
2885 ps.setInt(1,injuryHelpBean.
2886 getAccidentCode().intValue());
2887 rsCommon=ps.executeQuery();
2888 if(rsCommon.next())
2889 {
2890
2891 injuryHelpBean.setAccidentType(rsCommon.
2892 getString("ACCIDENTNAMEENG"));
2893 injuryHelpBean.setAccidentTypeArb(rsCommon.
2894 getString("ACCIDENTNAMEARB"));
2895
2896 }
2897 }
2898 //getting injury source details
2899 if(injuryHelpBean.getInjurySourceCode()!=null)
2900 {
2901 String strQuery="";
2902 strQuery=
2903 OHQueryInjury.OhQry_QRY_00067 ;
2904 ps=conn.prepareStatement(strQuery);
2905 ps.setInt(1,injuryHelpBean.
2906 getInjurySourceCode().intValue());
2907 rsCommon=ps.executeQuery();
2908 if(rsCommon.next())
2909 {
2910 injuryHelpBean.setInjurySource(
2911 rsCommon.getString("INJURYSOURCEENG"));
2912 injuryHelpBean.setInjurySourceArb(
2913 rsCommon.getString("INJURYSOURCEARB"));
2914 }
2915 }
2916 //getting injury nature details
2917 if(injuryHelpBean.getInjuryNatureCode()!=null)
2918 {
2919 String strQuery="";
2920 strQuery=
2921 OHQueryInjury.OhQry_QRY_00068 ;
2922 ps=conn.prepareStatement(strQuery);
2923 ps.setInt(1,injuryHelpBean.
2924 getInjuryNatureCode().intValue());
2925 rsCommon=ps.executeQuery();
2926 if(rsCommon.next())
2927 {
2928 injuryHelpBean.setInjuryNature(
2929 rsCommon.getString("INJURYNATUREENG"));
2930 injuryHelpBean.setInjuryNatureArb(
2931 rsCommon.getString("INJURYNATUREARB"));
2932 }
2933 }//getting hospital details
2934 if(injuryHelpBean.getHospitalCode()!=null)
2935 {
2936 String strQuery="";
2937 strQuery=
2938 OHQueryInjury.OhQry_QRY_00069 ;
2939 ps=conn.prepareStatement(strQuery);
2940 ps.setLong(1,injuryHelpBean.
2941 getHospitalCode().longValue());
2942 rsCommon=ps.executeQuery();
2943 if(rsCommon.next())
2944 {
2945 injuryHelpBean.setHospitalName(
2946 rsCommon.getString("HOSPITALNAMEENG"));
2947 injuryHelpBean.setHospitalNameArb(
2948 rsCommon.getString("HOSPITALNAMEARB"));
2949 }
2950 }// getting contributor preexisting deformities details
2951 if(injuryHelpBean.getContributorId()!=null)
2952 {
2953 String strQuery="";
2954 strQuery=
2955 OHQueryInjury.OhQry_QRY_00070 ;
2956
2957 ps=conn.prepareStatement(strQuery);
2958 ps.setLong(1,injuryHelpBean.
2959 getContributorId().longValue());
2960 rsCommon=ps.executeQuery();
2961 if(rsCommon.next())
2962 {
2963
2964 injuryHelpBean.
2965 setPreExistDeformitiesId(new Long(
2966 rsCommon.getLong("PREEXISTINGDEFORMITIESID")));
2967 injuryHelpBean.
2968 setPreviousNonOH(
2969 rsCommon.getString("PREEXISTINGDEFORMITIES"));
2970 }
2971 }
2972 GOSIDebug.debugMessages("monthlymovementid:"+
2973 injuryHelpBean.getMonthlyMovementId());
2974 GOSIDebug.debugMessages("establishmentId:"+
2975 injuryHelpBean.getEstablishmentId());
2976 // getting occupation details of contributor
2977 if(injuryHelpBean.getContributorId()!=null)
2978 {
2979 String strQuery="";
2980 strQuery=
2981 OHQueryInjury.OhQry_QRY_00071 ;
2982 GOSIDebug.debugMessages(""+strQuery);
2983 ps=conn.prepareStatement(strQuery);
2984 ps.setLong(1,injuryHelpBean.
2985 getContributorId().longValue());
2986 rsCommon=ps.executeQuery();
2987 GOSIDebug.debugMessages("Inside engage method b4 while:");
2988 while(rsCommon.next())
2989 {
2990 injuryHelpBean.setEngagementId(new Long(
2991 rsCommon.getLong("ENGAGEMENTID")));
2992 injuryHelpBean.setMonthlyMovementId
2993 (new Long(rsCommon.
2994 getLong("JOININGMONTHLYMOVEMENTID")));
2995 injuryHelpBean.setOccupation
2996 (rsCommon.getString("OCCUPATIONNAMEENG"));
2997 injuryHelpBean.setOccupationArb
2998 (rsCommon.getString("OCCUPATIONNAMEARB"));
2999 }
3000 }// getting from submission date
3001 if(injuryHelpBean.getEstablishmentId()!=null &&
3002 injuryHelpBean.getMonthlyMovementId()!= null)
3003 {
3004 String strQuery="";
3005 strQuery=
3006 OHQueryInjury.OhQry_QRY_00072 ;
3007 ps=conn.prepareStatement(strQuery);
3008 ps.setLong(1,injuryHelpBean.
3009 getMonthlyMovementId().longValue());
3010 ps.setLong(2,injuryHelpBean.
3011 getEstablishmentId().longValue());
3012 GOSIDebug.debugMessages(""+strQuery);
3013 rsCommon=ps.executeQuery();
3014 while(rsCommon.next())
3015 {
3016 injuryHelpBean.
3017 setFormSubmissionDate(
3018 rsCommon.getTimestamp("FORMSUBMISSIONDATE"));
3019 GOSIDebug.debugMessages("FormSubmissionDate:"+
3020 injuryHelpBean.getFormSubmissionDate());
3021 injuryHelpBean.setFormSubmissionDateEntFmt(
3022 injuryHelpBean.getInjuryDateEntFmt());
3023 GOSIDebug.debugMessages("FormSubmissionEntFmt:"+
3024 injuryHelpBean.getFormSubmissionDateEntFmt());
3025 if (injuryHelpBean.
3026 getFormSubmissionDateEntFmt()!= null)
3027 {
3028 injuryHelpBean.setFormSubmissionDateStr
3029 (SIUtilities.getDateString(
3030 injuryHelpBean.getFormSubmissionDate(),
3031 injuryHelpBean.getFormSubmissionDateEntFmt()));
3032 }
3033 }
3034 }
3035 finalInjuryArrayList.add(injuryHelpBean);
3036 }
3037 }
3038 endTime = System.currentTimeMillis();
3039 elapsedTime = endTime - startTime;
3040 GOSIInstrumentationLog.writeInstrumentationToLog(
3041 this.getClass().toString(), "searchInjuryDetailsList()",
3042 elapsedTime);
3043 }
3044 catch (GOSIException ge)
3045 {
3046 throw ge;
3047 }
3048 catch(Exception e)
3049 {
3050 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
3051 GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
3052 "searchInjuryDetailsList()", e, "CMN_ERR_1000" );
3053 }
3054 finally
3055 {
3056 GOSIUtilities.cleanUp(conn, ps, rsCommon);
3057 }
3058 return finalInjuryArrayList;
3059 // returning the result
3060
3061 }
3062 /**
3063 * @METHOD NAME : searchPersonDetailsList
3064 * @INFORMATION : This method is to search Person Details during
3065 add injury if contributor is present and has a
3066 valid engagement it will return the details
3067 * @PARAM : class java.lang.Long,
3068 class java.sql.Timestamp
3069 * @RETURN : class java.util.ArrayList
3070 * @EXCEPTION : class gosi.core.util.GOSIException
3071 * @LAST MODIFIED BY :
3072 * @LAST MODIFIED DATE :
3073 **/
3074 public ArrayList searchPersonDetailsList (Long socInsNumber, Timestamp injuryDate) throws GOSIException
3075 {
3076
3077 PreparedStatement ps =null;
3078 ResultSet rsCommon =null;
3079 long startTime = 0;
3080 long endTime = 0;
3081 long elapsedTime = 0;
3082
3083 startTime = System.currentTimeMillis();
3084 ArrayList personArrayList=new ArrayList();
3085
3086 ArrayList personDetailsList=new ArrayList();
3087 String sqlQuery="";
3088 String query="";
3089 int vicValid=-1;
3090 int engVIC=-1;
3091 Short totalInjury=null;
3092 try
3093 {
3094 //Query to check if the contributor is a VIC or not
3095 query=OHQueryInjury.OhQry_QRY_00073 ;
3096 conn = GOSIUtilities.
3097 getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
3098 GOSIDebug.debugMessages("Inside the for loop1:::Query");
3099 GOSIDebug.debugMessages(""+query);
3100 ps=conn.prepareStatement(query);
3101 ps.setLong(1,socInsNumber.longValue());
3102 rsCommon=ps.executeQuery();
3103 while(rsCommon.next())
3104 {
3105 engVIC=rsCommon.getInt("num");
3106 GOSIDebug.debugMessages("engVIC:"+engVIC);
3107 }
3108 //Query to get engagment details in at the time of injury
3109 sqlQuery=OHQueryInjury.OhQry_QRY_00074 ;
3110 GOSIDebug.debugMessages(""+sqlQuery);
3111 ps=conn.prepareStatement(sqlQuery);
3112 GOSIDebug.debugMessages("socinsnumber:"+socInsNumber);
3113 GOSIDebug.debugMessages("injuryDate:"+injuryDate);
3114 ps.setLong(1,socInsNumber.longValue());
3115 ps.setTimestamp(2,injuryDate);
3116 ps.setTimestamp(3,injuryDate);
3117 rsCommon=ps.executeQuery();
3118 while(rsCommon.next())
3119 {
3120 vicValid=rsCommon.getInt("num");
3121 GOSIDebug.debugMessages("vicValid:"+vicValid);
3122 }
3123
3124 // Total of Injury occured This Year except compliaction.
3125 totalInjury = getTotalOfInjuryThisYear(socInsNumber);
3126 // throw exception if the contributor is vic
3127 if(!((vicValid == 0) && (engVIC > 0)))
3128 {
3129 throw new GOSIException( GOSIConstants.SEVERITY_THREE,
3130 GOSIConstants.SOCIAL_INSURANCE,
3131 this.getClass().toString(),
3132 "searchPersonDetailsList()",
3133 new GOSIException(), "SOI_ERR_5249" );
3134 }
3135 // getting all engagement for contributor
3136 ArrayList engagementFullList = EngagementUtilities.displayAllEngagementForSINIncludingProactive (socInsNumber, injuryDate);
3137
3138 // if no engagements throw exception
3139 if(engagementFullList == null ||engagementFullList.size()==0)
3140 {
3141 throw new GOSIException( GOSIConstants.SEVERITY_THREE,
3142 GOSIConstants.SOCIAL_INSURANCE,
3143 this.getClass().toString(),
3144 "searchPersonDetailsList()",
3145 new GOSIException(), "SOI_ERR_4257" );
3146 }
3147 // if the person has engagements set person details into bean
3148 if(engagementFullList.size()>0)
3149 {
3150 EngagementDetailsBean engagementBean =
3151 (EngagementDetailsBean)engagementFullList.get(0);
3152 WageChangeCoverageBean wageBean =
3153 engagementBean.getWageChangeCoverageBean();
3154 EstablishmentBean establishmentBean =
3155 engagementBean.getEstablishmentBean();
3156 ContributorBean contributorBean = engagementBean.getContributorBean();
3157 PersonBean personBean = engagementBean.getPersonBean();
3158
3159 AddInjuryHelperBean injuryListBean =new AddInjuryHelperBean();
3160 String finalName=personBean.getFirstName();
3161 if(personBean.getSecondName()!= null &&
3162 !"".equals(personBean.getSecondName()))
3163 {
3164 finalName = finalName+ " "+personBean.getSecondName();
3165 }
3166 if(personBean.getThirdName()!= null &&
3167 !"".equals(personBean.getThirdName()))
3168 {
3169 finalName = finalName+ " "+personBean.getThirdName();
3170 }
3171 if(personBean.getSurName()!= null &&
3172 !"".equals(personBean.getSurName()))
3173 {
3174 finalName = finalName+ " "+personBean.getSurName();
3175 }
3176 injuryListBean.setName(finalName);
3177 injuryListBean.setNationalityCode(personBean.getNationalityCode());
3178 injuryListBean.setContactId(contributorBean.getContactId());
3179 injuryListBean.setContributorId(contributorBean.getContributorId());
3180
3181 // Additional parameters related to MOL proactive registartion project
3182 if(injuryListBean.getNationalityCode().equals(OHConstants.NATIONALITY_CODE_SAUDI))
3183 {
3184 injuryListBean.setIsEngagementProactive(Boolean.FALSE);
3185 }
3186 else if(engagementBean.getEngagementBean().getIsProactive().equals(RegistrationConstants.PROACTIVE_YES))
3187 {
3188 injuryListBean.setIsEngagementProactive(Boolean.TRUE);
3189 injuryListBean.setEngagementApprovalDate(engagementBean.getEngagementBean().getApprovalDate());
3190 }
3191 else
3192 {
3193 injuryListBean.setIsEngagementProactive(Boolean.FALSE);
3194 }
3195
3196 personArrayList.add(injuryListBean);
3197 }
3198 // if the person has atleast one engagement
3199 if(personArrayList.size() >0)
3200 {
3201 int personArrayListSize = personArrayList.size();
3202 AddInjuryHelperBean injuryHelpBean =
3203 new AddInjuryHelperBean();
3204 injuryHelpBean=
3205 (AddInjuryHelperBean)personArrayList.get(0);
3206 // query to get contributor preexisting deformities
3207 String strQuery=OHQueryInjury.OhQry_QRY_00077 ;
3208
3209 ps=conn.prepareStatement(strQuery);
3210 ps.setLong(1,injuryHelpBean.
3211 getContributorId().longValue());
3212 rsCommon=ps.executeQuery();
3213 GOSIDebug.debugMessages(""+strQuery);
3214 if(rsCommon.next())
3215 {
3216 injuryHelpBean.setPreExistDeformitiesId(new Long(
3217 rsCommon.getLong("PREEXISTINGDEFORMITIESID")));
3218 injuryHelpBean.setPreviousNonOH(
3219 rsCommon.getString("PREEXISTINGDEFORMITIES"));
3220 }
3221 //setting the number of engagements
3222 injuryHelpBean.setNoOfEngagements
3223 (new Integer(engagementFullList.size()));
3224 // setting engagement /coverage/occupation details for contributor
3225 if(engagementFullList.size()==1)
3226 {
3227 EngagementDetailsBean engagementDetailsBean =
3228 (EngagementDetailsBean)engagementFullList.get(0);
3229 EngagementBean engagementBean =
3230 engagementDetailsBean.getEngagementBean();
3231 WageChangeCoverageBean wageBean =
3232 engagementDetailsBean.getWageChangeCoverageBean();
3233 EstablishmentBean establishmentBean =
3234 engagementDetailsBean.getEstablishmentBean();
3235 EngagementOccupationBean engagementOccupationBean =
3236 engagementDetailsBean.getEngagementOccupationBean();
3237
3238 injuryHelpBean.setEngagementId(engagementBean.getEngagementId());
3239 injuryHelpBean.setEstablishmentId
3240 (establishmentBean.getEstablishmentId());
3241 injuryHelpBean.setEngagementStatus(engagementBean.getEngagementStatus());
3242 injuryHelpBean.setJoiningDate(engagementBean.getJoiningDate());
3243 injuryHelpBean.setJoiningDateEntFmt(engagementBean.getJoiningDateEntFmt());
3244 injuryHelpBean.setJoiningDateStr(engagementBean.getJoiningDateStr());
3245 injuryHelpBean.setLeavingDate(engagementBean.getLeavingDate());
3246 injuryHelpBean.setLeavingDateEntFmt(engagementBean.getLeavingDateEntFmt());
3247 injuryHelpBean.setLeavingDateStr(engagementBean.getLeavingDateStr());
3248 //injuryHelpBean.setMonthlyMovementId
3249 injuryHelpBean.setFormSubmissionDate(engagementDetailsBean.getFormSubmissionDate());
3250 //injuryHelpBean.setFormSubmissionDateEntFmt(engagementDetailsBean.getFormSubmissionEntFmt());
3251 injuryHelpBean.setFormSubmissionDateStr(engagementDetailsBean.getFormSubmissionDateStr());
3252 injuryHelpBean.setRegNumber(establishmentBean.getRegistrationNumber());
3253 injuryHelpBean.setEstablishmentName(establishmentBean.getEstablishmentNameEng());
3254 injuryHelpBean.setEstablishmentNameArb(establishmentBean.getEstablishmentNameArb());
3255 injuryHelpBean.setEstablishmentCalendarType(establishmentBean.getCalendarType());
3256 injuryHelpBean.setOHEligibilityStatus(establishmentBean.getOHEligibilityStatus());
3257 injuryHelpBean.setResponsibleForOHPayment(establishmentBean.getResponsibleForOHPayment());
3258
3259 if(!injuryHelpBean.getIsEngagementProactive()) {
3260 injuryHelpBean.setOccupation(engagementOccupationBean.getOccupationDescEng());
3261 injuryHelpBean.setOccupationArb(engagementOccupationBean.getOccupationDescArb());
3262 injuryHelpBean.setCoverage(wageBean.getCoverage());
3263 GOSIDebug.debugMessages("setCoverage::"+injuryHelpBean.getCoverage());
3264 injuryHelpBean.setInlandAbroad(wageBean.getInlandAbroadIndicator());
3265 GOSIDebug.debugMessages("inlandabroad"+injuryHelpBean.getInlandAbroad());
3266
3267 if (injuryHelpBean.getOccupation() == null || injuryHelpBean.getEstablishmentName()== null)
3268 {
3269 injuryHelpBean.setOccupation (engagementOccupationBean.getOccupationDescArb());
3270 }
3271 }
3272
3273 injuryHelpBean.setNumberOfInjuryThisYear(totalInjury);
3274 GOSIDebug.debugMessages("inlandabroad"+injuryHelpBean.getInlandAbroad());
3275
3276 if (injuryHelpBean.getEstablishmentName() == null || injuryHelpBean.getEstablishmentName() == null)
3277 {
3278 injuryHelpBean.setEstablishmentName (establishmentBean.getEstablishmentNameArb());
3279 }
3280 if (injuryHelpBean.getEstablishmentCalendarType() == null || injuryHelpBean.getEstablishmentCalendarType()== null)
3281 {
3282 injuryHelpBean.setEstablishmentCalendarType (OHConstants.GREGORIAN);
3283 }
3284 }
3285 personDetailsList.add(injuryHelpBean);
3286 }
3287 endTime = System.currentTimeMillis();
3288 elapsedTime = endTime - startTime;
3289 GOSIInstrumentationLog.writeInstrumentationToLog(
3290 this.getClass().toString(), "searchPersonDetailsList()",
3291 elapsedTime);
3292 }
3293 catch (GOSIException ge)
3294 {
3295 GOSIDebug.debugMessages("searchPersonDetailsList:ge:"+ge);
3296 throw ge;
3297 }
3298 catch(Exception e)
3299 {
3300 GOSIDebug.debugMessages("searchPersonDetailsList:e:"+e);
3301 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
3302 GOSIConstants.SOCIAL_INSURANCE,
3303 this.getClass().toString(),
3304 "searchPersonDetailsList()", e,
3305 "CMN_ERR_1000" );
3306 }
3307 finally
3308 {
3309 GOSIUtilities.cleanUp(conn,ps,rsCommon);
3310 }
3311 return personDetailsList;
3312 }
3313 /**
3314 * @METHOD NAME : searchPersonDetailsListTerminatedWorker
3315 * @INFORMATION : This method is to search Person Details for
3316 a terminated worker it will get his details of
3317 his last engagement.
3318 * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.AddInjuryHelperBean
3319 * @RETURN : class java.util.ArrayList
3320 * @EXCEPTION : class gosi.core.util.GOSIException
3321 * @LAST MODIFIED BY :
3322 * @LAST MODIFIED DATE :
3323 **/
3324 public ArrayList searchPersonDetailsListTerminatedWorker
3325 (AddInjuryHelperBean injuryBean) throws GOSIException
3326 {
3327 ArrayList personDetailsList=new ArrayList();
3328 try
3329 {
3330 ContributorBean contributorBean = ContributorUtilities.
3331 displayContributorForSIN(injuryBean.getSocInsNumber());
3332 // getting the last terminated engagement
3333 EngagementBean engagementBean = EngagementUtilities.
3334 getLastTerminatedEngagement(contributorBean.getContributorId());
3335
3336 if(engagementBean != null)
3337 {
3338 Timestamp leavingDate = engagementBean.getLeavingDate();
3339 Timestamp injuryDate = injuryBean.getInjuryDate();
3340
3341 //leaving date is set as injury date bcos it will
3342 //use this date to fetch the engagement on this day
3343 injuryBean.setInjuryDate(leavingDate);
3344 personDetailsList = searchPersonDetailsList(injuryBean.getSocInsNumber(), injuryBean.getInjuryDate());
3345
3346 // if still he doesnt have any enagements
3347 if(personDetailsList != null && personDetailsList.size()>0)
3348 {
3349 for(int i=0;i<personDetailsList.size();i++)
3350 {
3351 ((AddInjuryHelperBean)personDetailsList.get(i)).setInjuryDate(injuryDate);
3352 }
3353 }else
3354 {
3355 throw new GOSIException( GOSIConstants.SEVERITY_THREE,
3356 GOSIConstants.SOCIAL_INSURANCE,
3357 this.getClass().toString(),
3358 "searchPersonDetailsList()",
3359 new GOSIException(), "SOI_ERR_4257" );
3360 }
3361 }
3362 else
3363 {
3364 throw new GOSIException( GOSIConstants.SEVERITY_THREE,
3365 GOSIConstants.SOCIAL_INSURANCE,
3366 this.getClass().toString(),
3367 "searchPersonDetailsList()",
3368 new GOSIException(), "SOI_ERR_4257" );
3369 }
3370
3371 }
3372 catch (GOSIException ge)
3373 {
3374 GOSIDebug.debugMessages("searchPersonDetailsListTerminatedWorker:ge:"+ge);
3375 throw ge;
3376 }
3377 catch(Exception e)
3378 {
3379 GOSIDebug.debugMessages("searchPersonDetailsListTerminatedWorker:e:"+e);
3380 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
3381 GOSIConstants.SOCIAL_INSURANCE,
3382 this.getClass().toString(),
3383 "searchPersonDetailsListTerminatedWorker()", e,
3384 "CMN_ERR_1000" );
3385 }
3386 return personDetailsList;
3387 }
3388
3389 /**
3390 * @METHOD NAME : setSearchRegNumberList
3391 * @INFORMATION : This method is to Search engagement and
3392 establishment details of the worker
3393 * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.AddInjuryHelperBean
3394 * @RETURN : class java.util.ArrayList
3395 * @EXCEPTION : class gosi.core.util.GOSIException
3396 * @LAST MODIFIED BY :
3397 * @LAST MODIFIED DATE :
3398 **/
3399 public ArrayList setSearchRegNumberList
3400 (AddInjuryHelperBean injuryBean) throws GOSIException
3401 {
3402
3403 String sqlQuery="";
3404 PreparedStatement ps =null;
3405 ResultSet rsCommon =null;
3406 long startTime = 0;
3407 long endTime = 0;
3408 long elapsedTime = 0;
3409
3410 Timestamp compDate=null;
3411 startTime = System.currentTimeMillis();
3412 ArrayList multipleEmpList=new ArrayList();
3413
3414 try
3415 {
3416
3417 if(injuryBean.getDateComplication()!=null)
3418 {
3419 compDate=injuryBean.getDateComplication();
3420 }
3421 else
3422 {
3423 compDate=injuryBean.getInjuryDate();
3424 }
3425 GOSIDebug.debugMessages("compDate : :::::::"+compDate);
3426 // getting all engagements for contributor
3427 ArrayList engagementFullList = EngagementUtilities.
3428 displayAllEngagementForSIN
3429 (injuryBean.getSocInsNumber(),compDate);
3430
3431 if(engagementFullList == null ||engagementFullList.size()==0)
3432 {
3433 return multipleEmpList;
3434 }
3435 // setting engagement /coverage/occupation details for contributor
3436 for (int i=0;i<engagementFullList.size() ;i++ )
3437 {
3438 EngagementDetailsBean engagementDetailsBean =
3439 (EngagementDetailsBean)engagementFullList.get(i);
3440 EngagementBean engagementBean =
3441 engagementDetailsBean.getEngagementBean();
3442 WageChangeCoverageBean wageBean =
3443 engagementDetailsBean.getWageChangeCoverageBean();
3444 EstablishmentBean establishmentBean =
3445 engagementDetailsBean.getEstablishmentBean();
3446 EngagementOccupationBean engagementOccupationBean =
3447 engagementDetailsBean.getEngagementOccupationBean();
3448
3449 if (injuryBean.getEstablishmentId()==null || !injuryBean.getEstablishmentId().equals(establishmentBean.getEstablishmentId()))
3450 {
3451 AddInjuryHelperBean injuryHelpBean=new AddInjuryHelperBean();
3452
3453 injuryHelpBean.setSocInsNumber(injuryBean.getSocInsNumber());
3454 injuryHelpBean.setEngagementId(engagementBean.getEngagementId());
3455 injuryHelpBean.setEstablishmentId
3456 (establishmentBean.getEstablishmentId());
3457 injuryHelpBean.setEngagementStatus(engagementBean.getEngagementStatus());
3458 injuryHelpBean.setJoiningDate(engagementBean.getJoiningDate());
3459 injuryHelpBean.setJoiningDateEntFmt(engagementBean.getJoiningDateEntFmt());
3460 injuryHelpBean.setJoiningDateStr(engagementBean.getJoiningDateStr());
3461 injuryHelpBean.setLeavingDate(engagementBean.getLeavingDate());
3462 injuryHelpBean.setLeavingDateEntFmt(engagementBean.getLeavingDateEntFmt());
3463 injuryHelpBean.setLeavingDateStr(engagementBean.getLeavingDateStr());
3464 //injuryHelpBean.setMonthlyMovementId
3465 injuryHelpBean.setFormSubmissionDate(engagementDetailsBean.getFormSubmissionDate());
3466 //injuryHelpBean.setFormSubmissionDateEntFmt(engagementDetailsBean.getFormSubmissionEntFmt());
3467 injuryHelpBean.setFormSubmissionDateStr(engagementDetailsBean .getFormSubmissionDateStr());
3468 injuryHelpBean.setRegNumber(establishmentBean.getRegistrationNumber());
3469 injuryHelpBean.setEstablishmentName(establishmentBean.getEstablishmentNameEng());
3470 injuryHelpBean.setEstablishmentNameArb(establishmentBean.getEstablishmentNameArb());
3471 injuryHelpBean.setOHEligibilityStatus(establishmentBean.getOHEligibilityStatus());
3472 injuryHelpBean.setOccupation(engagementOccupationBean.getOccupationDescArb());
3473 injuryHelpBean.setOccupationArb(engagementOccupationBean.getOccupationDescArb());
3474 injuryHelpBean.setCoverage(wageBean.getCoverage());
3475 GOSIDebug.debugMessages("setCoverage::"+injuryHelpBean.getCoverage());
3476 injuryHelpBean.setInlandAbroad(wageBean.getInlandAbroadIndicator());
3477 GOSIDebug.debugMessages("inlandabroad"+injuryHelpBean.getInlandAbroad());
3478 multipleEmpList.add(injuryHelpBean);
3479 }
3480 }
3481 endTime = System.currentTimeMillis();
3482 elapsedTime = endTime - startTime;
3483 GOSIInstrumentationLog.writeInstrumentationToLog(
3484 this.getClass().toString(), "setSearchRegNumberList()",
3485 elapsedTime);
3486 }
3487 catch (GOSIException ge)
3488 {
3489 throw ge;
3490 }
3491 catch(Exception e)
3492 {
3493
3494 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
3495 GOSIConstants.SOCIAL_INSURANCE,
3496 this.getClass().toString(),
3497 "setSearchRegNumberList()",
3498 e, "CMN_ERR_1000" );
3499 }
3500 finally
3501 {
3502 GOSIUtilities.cleanUp(conn, ps, rsCommon);
3503 }
3504 return multipleEmpList;
3505 }
3506
3507 /**
3508 * @METHOD NAME : getAccidentCodeResultList
3509 * @INFORMATION : This method is to search for the Accident Type from the database
3510 * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.AddInjuryHelperBean
3511 * @RETURN : class java.util.ArrayList
3512 * @EXCEPTION : class gosi.core.util.GOSIException
3513 * @LAST MODIFIED BY :
3514 * @LAST MODIFIED DATE :
3515 **/
3516 public ArrayList getAccidentCodeResultList(AddInjuryHelperBean injuryBean)
3517 throws GOSIException
3518 {
3519
3520 Short accidentCode=null;
3521 String sqlQuery="";
3522 PreparedStatement ps =null;
3523 ResultSet rsCommon =null;
3524 long startTime = 0;
3525 long endTime = 0;
3526 long elapsedTime = 0;
3527
3528 startTime = System.currentTimeMillis();
3529 accidentCode=injuryBean.getAccidentCode();
3530
3531 ArrayList popAccidentArrayList=new ArrayList();
3532
3533 popAccidentArrayList.clear();
3534 // Query to get accident details using accident code from T_accident table
3535 sqlQuery=OHQueryInjury.OhQry_QRY_00087 ;
3536 try
3537 {
3538 conn = GOSIUtilities.
3539 getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
3540 ps=conn.prepareStatement(sqlQuery);
3541 ps.setLong(1,accidentCode.intValue());
3542 rsCommon=ps.executeQuery();
3543 GOSIDebug.debugMessages(""+sqlQuery);
3544 if(rsCommon.next())
3545 {
3546 injuryBean.
3547 setAccidentType(rsCommon.getString("ACCIDENTNAMEENG"));
3548 injuryBean.
3549 setAccidentTypeArb(rsCommon.getString("ACCIDENTNAMEARB"));
3550 popAccidentArrayList.add(injuryBean);
3551 }
3552 if(popAccidentArrayList.size()==0)
3553 {
3554 throw new GOSIException( GOSIConstants.SEVERITY_THREE,
3555 GOSIConstants.SOCIAL_INSURANCE,
3556 this.getClass().toString(),
3557 "getAccidentCodeResultList()",
3558 new GOSIException(), "SOI_ERR_4030" );
3559 }
3560 endTime = System.currentTimeMillis();
3561 elapsedTime = endTime - startTime;
3562 GOSIInstrumentationLog.writeInstrumentationToLog(
3563 this.getClass().toString(), "getAccidentCodeResultList()",
3564 elapsedTime);
3565 }
3566 catch (GOSIException ge)
3567 {
3568 throw ge;
3569 }
3570 catch(Exception e)
3571 {
3572 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
3573 GOSIConstants.SOCIAL_INSURANCE,
3574 this.getClass().toString(), "getAccidentCodeResultList()",
3575 e, "CMN_ERR_1000" );
3576 }
3577 finally
3578 {
3579 GOSIUtilities.cleanUp(conn, ps, rsCommon);
3580 }
3581 return popAccidentArrayList;
3582 }
3583
3584 /**
3585 * @METHOD NAME : getInjurySourceCodeResultList
3586 * @INFORMATION : This method is to search for the Injury Source from the database
3587 * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.AddInjuryHelperBean
3588 * @RETURN : class java.util.ArrayList
3589 * @EXCEPTION : class gosi.core.util.GOSIException
3590 * @LAST MODIFIED BY :
3591 * @LAST MODIFIED DATE :
3592 **/
3593 public ArrayList getInjurySourceCodeResultList
3594 (AddInjuryHelperBean injuryBean) throws GOSIException
3595 {
3596
3597 Short injurySourceCode=null;
3598 String sqlQuery="";
3599 PreparedStatement ps =null;
3600 ResultSet rsCommon =null;
3601 long startTime = 0;
3602 long endTime = 0;
3603 long elapsedTime = 0;
3604
3605 startTime = System.currentTimeMillis();
3606 injurySourceCode=injuryBean.getInjurySourceCode();
3607
3608 ArrayList popInjSourceArrayList=new ArrayList();
3609 popInjSourceArrayList.clear();
3610 // Query to get Injury Source details using InjurySource code from T_INJURYSOURCE table
3611 sqlQuery=OHQueryInjury.OhQry_QRY_00088 ;
3612 try
3613 {
3614 GOSIDebug.debugMessages(""+sqlQuery);
3615 conn = GOSIUtilities.
3616 getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
3617 ps=conn.prepareStatement(sqlQuery);
3618 ps.setLong(1,injurySourceCode.intValue());
3619 GOSIDebug.debugMessages(""+sqlQuery);
3620 rsCommon=ps.executeQuery();
3621 if(rsCommon.next())
3622 {
3623 injuryBean.
3624 setInjurySource(rsCommon.getString("INJURYSOURCEENG"));
3625 injuryBean.
3626 setInjurySourceArb(rsCommon.getString("INJURYSOURCEARB"));
3627 popInjSourceArrayList.add(injuryBean);
3628 }
3629 if(popInjSourceArrayList.size()==0)
3630 {
3631 throw new GOSIException( GOSIConstants.SEVERITY_THREE,
3632 GOSIConstants.SOCIAL_INSURANCE,
3633 this.getClass().toString(),
3634 "getInjurySourceCodeResultList()",
3635 new GOSIException(), "SOI_ERR_4031" );
3636 }
3637 endTime = System.currentTimeMillis();
3638 elapsedTime = endTime - startTime;
3639 GOSIInstrumentationLog.writeInstrumentationToLog(
3640 this.getClass().toString(),
3641 "getInjurySourceCodeResultList()", elapsedTime);
3642 }
3643 catch (GOSIException ge)
3644 {
3645 throw ge;
3646 }
3647 catch(Exception e)
3648 {
3649 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
3650 GOSIConstants.SOCIAL_INSURANCE,
3651 this.getClass().toString(),
3652 "getInjurySourceCodeResultList()", e, "CMN_ERR_1000" );
3653 }
3654 finally
3655 {
3656 GOSIUtilities.cleanUp(conn, ps, rsCommon);
3657 }
3658 return popInjSourceArrayList;
3659 }
3660
3661
3662 /**
3663 * @METHOD NAME : getInjuryNatureCodeResultList
3664 * @INFORMATION : This method is to search for the Injury Nature from the database
3665 * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.AddInjuryHelperBean
3666 * @RETURN : class java.util.ArrayList
3667 * @EXCEPTION : class gosi.core.util.GOSIException
3668 * @LAST MODIFIED BY :
3669 * @LAST MODIFIED DATE :
3670 **/
3671 public ArrayList getInjuryNatureCodeResultList
3672 (AddInjuryHelperBean injuryBean) throws GOSIException
3673 {
3674
3675 Short injuryNatureCode=null;
3676 String sqlQuery="";
3677 PreparedStatement ps =null;
3678 ResultSet rsCommon =null;
3679 long startTime = 0;
3680 long endTime = 0;
3681 long elapsedTime = 0;
3682
3683 startTime = System.currentTimeMillis();
3684
3685 injuryNatureCode=injuryBean.getInjuryNatureCode();
3686
3687 ArrayList popInjNatureArrayList=new ArrayList();
3688 popInjNatureArrayList.clear();
3689 // Query to get Injury nature details using Injurynature code from T_INJURYNATURE table
3690 sqlQuery=OHQueryInjury.OhQry_QRY_00089 ;
3691 try
3692 {
3693 conn = GOSIUtilities.
3694 getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
3695 ps=conn.prepareStatement(sqlQuery);
3696 ps.setLong(1,injuryNatureCode.intValue());
3697 rsCommon=ps.executeQuery();
3698 GOSIDebug.debugMessages(""+sqlQuery);
3699 if(rsCommon.next())
3700 {
3701 injuryBean.setInjuryNature
3702 (rsCommon.getString("INJURYNATUREENG"));
3703 injuryBean.setInjuryNatureArb
3704 (rsCommon.getString("INJURYNATUREARB"));
3705 popInjNatureArrayList.add(injuryBean);
3706 }
3707 if(popInjNatureArrayList.size()==0)
3708 {
3709 throw new GOSIException( GOSIConstants.SEVERITY_THREE,
3710 GOSIConstants.SOCIAL_INSURANCE,
3711 this.getClass().toString(),
3712 "getInjuryNatureCodeResultList()",
3713 new GOSIException(), "SOI_ERR_4032" );
3714 }
3715 endTime = System.currentTimeMillis();
3716 elapsedTime = endTime - startTime;
3717 GOSIInstrumentationLog.writeInstrumentationToLog(
3718 this.getClass().toString(),
3719 "getInjuryNatureCodeResultList()", elapsedTime);
3720 }
3721 catch (GOSIException ge)
3722 {
3723 throw ge;
3724 }
3725 catch(Exception e)
3726 {
3727 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
3728 GOSIConstants.SOCIAL_INSURANCE,
3729 this.getClass().toString(),
3730 "getInjuryNatureCodeResultList()", e, "CMN_ERR_1000");
3731 }
3732 finally
3733 {
3734 GOSIUtilities.cleanUp(conn, ps, rsCommon);
3735 }
3736 return popInjNatureArrayList;
3737 }
3738
3739 /**
3740 * @METHOD NAME : getHospitalCodeResultList
3741 * @INFORMATION : This method is to search the Hospital Name from the database
3742 * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.AddInjuryHelperBean
3743 * @RETURN : class java.util.ArrayList
3744 * @EXCEPTION : class gosi.core.util.GOSIException
3745 * @LAST MODIFIED BY :
3746 * @LAST MODIFIED DATE :
3747 **/
3748 public ArrayList getHospitalCodeResultList
3749 (AddInjuryHelperBean injuryBean)
3750 throws GOSIException
3751 {
3752
3753 Long hospitalCode=null;
3754 PreparedStatement ps =null;
3755 ResultSet rsCommon =null;
3756 long startTime = 0;
3757 long endTime = 0;
3758 long elapsedTime = 0;
3759
3760 startTime = System.currentTimeMillis();
3761
3762 hospitalCode=injuryBean.getHospitalCode();
3763 // getting hospital type and hospital name for injury
3764
3765 ArrayList popHospitalArrayList=new ArrayList();
3766 popHospitalArrayList.clear();
3767
3768 StringBuffer sbQuery = new StringBuffer();
3769 Timestamp minInjuryDate = null;
3770 Timestamp maxInjuryDate = null;
3771 GOSIDebug.debugMessages("Before the injurydate str:::"+
3772 injuryBean.getInjuryDateStr());
3773 if(injuryBean.getInjuryDateStr() != null)
3774 {
3775
3776 minInjuryDate = (OHUtilities.getGregDate
3777 (injuryBean.getInjuryDateStr(),
3778 injuryBean.getInjuryDateEntFmt()));
3779 maxInjuryDate = (OHUtilities.getGregDate
3780 (injuryBean.getInjuryDateStr(),
3781 injuryBean.getInjuryDateEntFmt()));
3782
3783 }
3784 else
3785 {
3786 minInjuryDate = OHUtilities.getGregDate
3787 (OHConstants.MIN_INJURY_DATE,OHConstants.GREGORIAN);
3788 maxInjuryDate = OHUtilities.getGregDate
3789 (OHConstants.MAX_INJURY_DATE,OHConstants.GREGORIAN);
3790 }
3791 GOSIDebug.debugMessages("min inj date " +minInjuryDate);
3792 GOSIDebug.debugMessages("max inj date " + maxInjuryDate);
3793 GOSIDebug.debugMessages("Inside the hospitalcode:");
3794 try
3795 {
3796 // query to get hospital details based on hospital code
3797 // and disease code to check the contract date in case
3798 // of registered hospital
3799 sbQuery.append(OHQueryInjury.OhQry_QRY_00090 );
3800 sbQuery.append(" HOSPITALNAMEARB, ");
3801 sbQuery.append(" HOSPITALNAMEENG FROM ");
3802 sbQuery.append( SITables.T_HOSPITAL );
3803 sbQuery.append(" WHERE HOSPITALTYPE <> ? ");
3804 sbQuery.append(" AND FIELDOFFICECODE = ? " );
3805 sbQuery.append(" AND HOSPITALCODE = ? " );
3806 sbQuery.append(" UNION " );
3807 sbQuery.append(OHQueryInjury.OhQry_QRY_00091 );
3808 sbQuery.append(" HOSP.HOSPITALNAMEARB, ");
3809 sbQuery.append(" HOSP.HOSPITALNAMEENG FROM ");
3810 sbQuery.append( SITables.T_HOSPITAL + " HOSP, " );
3811 sbQuery.append( SITables.T_HOSPITALCONTRACT );
3812 sbQuery.append(" CON WHERE ");
3813 sbQuery.append(" CON.CONTRSTDATE <= ? AND " );
3814 sbQuery.append(" NVL(CON.CONTRENDDATE,SYSDATE) ");
3815 sbQuery.append(" >= ? ");
3816 sbQuery.append(" AND HOSP.HOSPITALCODE = ");
3817 sbQuery.append(" CON.HOSPITALCODE ");
3818 sbQuery.append(" AND HOSP.HOSPITALTYPE = ? ");
3819 sbQuery.append(" AND HOSP.FIELDOFFICECODE = ? " );
3820 sbQuery.append(" AND HOSP.HOSPITALCODE = ? " );
3821 GOSIDebug.debugMessages("Before tthe conn:::::");
3822 conn = GOSIUtilities.
3823 getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
3824 GOSIDebug.debugMessages("conn value:"+conn);
3825 ps=conn.prepareStatement(sbQuery.toString());
3826 GOSIDebug.debugMessages("unreg_hosp"+OHConstants.UNREG_HOSPITAL);
3827 GOSIDebug.debugMessages("injuryBean.getFieldOfficeCode()"+
3828 injuryBean.getFieldOfficeCode());
3829 GOSIDebug.debugMessages("injuryBean.getHospitalCode()"+
3830 injuryBean.getHospitalCode());
3831 GOSIDebug.debugMessages("maxInjuryDate"+maxInjuryDate);
3832 ps.setShort
3833 (1,OHConstants.REG_HOSPITAL.shortValue());
3834 ps.setShort
3835 (2,injuryBean.getFieldOfficeCode().shortValue());
3836 ps.setLong(3,injuryBean.getHospitalCode().longValue());
3837 ps.setTimestamp(4,maxInjuryDate);
3838 ps.setTimestamp(5,minInjuryDate);
3839 ps.setShort
3840 (6,OHConstants.REG_HOSPITAL.shortValue());
3841 ps.setShort
3842 (7,injuryBean.getFieldOfficeCode().shortValue());
3843 ps.setLong(8,injuryBean.getHospitalCode().longValue());
3844 GOSIDebug.debugMessages(""+sbQuery.toString());
3845 rsCommon=ps.executeQuery();
3846 if(rsCommon.next())
3847 {
3848 GOSIDebug.debugMessages("Inside the while:::::");
3849 injuryBean.
3850 setHospitalName(
3851 rsCommon.getString("HOSPITALNAMEENG"));
3852 injuryBean.
3853 setHospitalNameArb(rsCommon.getString("HOSPITALNAMEARB"));
3854 popHospitalArrayList.add(injuryBean);
3855 }
3856 GOSIDebug.debugMessages("Hospital list in the ses bean:"+
3857 popHospitalArrayList);
3858 if(popHospitalArrayList.size()==0)
3859 {
3860 throw new GOSIException( GOSIConstants.SEVERITY_THREE,
3861 GOSIConstants.SOCIAL_INSURANCE,
3862 this.getClass().toString(),
3863 "getHospitalCodeResultList()",
3864 new GOSIException(), "SOI_ERR_4033" );
3865 }
3866 endTime = System.currentTimeMillis();
3867 elapsedTime = endTime - startTime;
3868 GOSIInstrumentationLog.writeInstrumentationToLog(
3869 this.getClass().toString(), "getHospitalCodeResultList()",
3870 elapsedTime);
3871 }
3872 catch (GOSIException ge)
3873 {
3874 throw ge;
3875 }
3876 catch(Exception e)
3877 {
3878 e.printStackTrace();
3879 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
3880 GOSIConstants.SOCIAL_INSURANCE,
3881 this.getClass().toString(),
3882 "getHospitalCodeResultList()", e, "CMN_ERR_1000" );
3883 }
3884 finally
3885 {
3886 GOSIUtilities.cleanUp(conn, ps, rsCommon);
3887 }
3888 return popHospitalArrayList;
3889 }
3890
3891 /**
3892 * @METHOD NAME : checkNumberOfDays
3893 * @INFORMATION : This method is to get the Number of days difference
3894 between Complication date and Worker Intimation Date
3895 * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.AddInjuryHelperBean
3896 * @RETURN : int
3897 * @EXCEPTION : class gosi.core.util.GOSIException
3898 * @LAST MODIFIED BY :
3899 * @LAST MODIFIED DATE :
3900 **/
3901 public int checkNumberOfDays(AddInjuryHelperBean injuryBean)
3902 throws GOSIException
3903 {
3904
3905 GOSIDebug.debugMessages("CheckNumberOfDays:");
3906 long startTime = 0;
3907 long endTime = 0;
3908 long elapsedTime = 0;
3909
3910 startTime = System.currentTimeMillis();
3911
3912 int dateValid=0;
3913 Timestamp complicationDate=injuryBean.getDateComplication();
3914 Timestamp workerIntimationDate=
3915 injuryBean.getWorkerIntimateDate();
3916
3917 try
3918 {
3919 // method to get the number of days between two days
3920 int x=(1000*24*60*60);
3921 GOSIDebug.debugMessages("x value is:"+x);
3922 dateValid=(int)
3923 ((workerIntimationDate.
3924 getTime()-complicationDate.getTime())/x)+1;
3925 dateValid=dateValid-1;
3926 GOSIDebug.debugMessages(" Inside the date validate :::"+dateValid);
3927 }
3928 catch(Exception e)
3929 {
3930 e.printStackTrace();
3931 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
3932 GOSIConstants.SOCIAL_INSURANCE,
3933 this.getClass().toString(),
3934 "checkNumberOfDays()", e, "CMN_ERR_1000" );
3935 }
3936 endTime = System.currentTimeMillis();
3937 elapsedTime = endTime - startTime;
3938 GOSIInstrumentationLog.writeInstrumentationToLog(
3939 this.getClass().toString(),
3940 "checkNumberOfDays()", elapsedTime);
3941 return dateValid;
3942 }
3943
3944 /**
3945 * @METHOD NAME : checkNumberOfDaysWorker
3946 * @INFORMATION : This method is to get the Number of days difference
3947 between Injury date and Worker Intimation date
3948 * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.AddInjuryHelperBean
3949 * @RETURN : int
3950 * @EXCEPTION : class gosi.core.util.GOSIException
3951 * @LAST MODIFIED BY :
3952 * @LAST MODIFIED DATE :
3953 **/
3954 public int checkNumberOfDaysWorker(AddInjuryHelperBean injuryBean)
3955 throws GOSIException
3956 {
3957
3958 int dateValid=0;
3959 long startTime = 0;
3960 long endTime = 0;
3961 long elapsedTime = 0;
3962
3963 startTime = System.currentTimeMillis();
3964 Timestamp injuryDate=injuryBean.getInjuryDate();
3965 Timestamp workerIntimateDate=injuryBean.getWorkerIntimateDate();
3966 try
3967 {
3968 // method to get the number of days between workerIntimateDate and injuryDate
3969 int x=(1000*24*60*60);
3970 dateValid=(int)
3971 ((workerIntimateDate.getTime()-injuryDate.getTime())/x)+1;
3972 GOSIDebug.debugMessages(" before //\\the date validate :::"+dateValid);
3973 dateValid=dateValid-1;
3974 GOSIDebug.debugMessages(" Inside the date validate :::"+dateValid);
3975 }
3976 catch(Exception e)
3977 {
3978 e.printStackTrace();
3979 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
3980 GOSIConstants.SOCIAL_INSURANCE,
3981 this.getClass().toString(),
3982 "checkNumberOfDaysWorker()", e, "CMN_ERR_1000");
3983 }
3984 endTime = System.currentTimeMillis();
3985 elapsedTime = endTime - startTime;
3986 GOSIInstrumentationLog.writeInstrumentationToLog(
3987 this.getClass().toString(),
3988 "checkNumberOfDaysWorker()", elapsedTime);
3989 return dateValid;
3990 }
3991
3992 /**
3993 * @METHOD NAME : checkNumberOfDaysEmployer
3994 * @INFORMATION : This method is to get the Number of days difference
3995 between Worker Intimation date and Employer Notification date
3996 * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.AddInjuryHelperBean
3997 * @RETURN : int
3998 * @EXCEPTION : class gosi.core.util.GOSIException
3999 * @LAST MODIFIED BY :
4000 * @LAST MODIFIED DATE :
4001 **/
4002 public int checkNumberOfDaysEmployer(AddInjuryHelperBean injuryBean)
4003 throws GOSIException
4004 {
4005
4006 int noOfDaysEmployer=0;
4007 long startTime = 0;
4008 long endTime = 0;
4009 long elapsedTime = 0;
4010
4011 startTime = System.currentTimeMillis();
4012
4013 Timestamp workerIntimationDate=injuryBean.getWorkerIntimateDate();
4014 Timestamp empNotifyDate=injuryBean.getEmpNotifyDate();
4015 try
4016 {
4017 // method to get the number of days between workerIntimateDate and empNotifyDate
4018 int x=(1000*24*60*60);
4019 noOfDaysEmployer=(int)
4020 ((empNotifyDate.getTime()-workerIntimationDate.
4021 getTime())/x)+1;
4022 noOfDaysEmployer=noOfDaysEmployer-1;
4023 }
4024 catch(Exception e)
4025 {
4026 e.printStackTrace();
4027 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
4028 GOSIConstants.SOCIAL_INSURANCE,
4029 this.getClass().toString(),
4030 "checkNumberOfDaysEmployer()", e, "CMN_ERR_1000");
4031 }
4032 endTime = System.currentTimeMillis();
4033 elapsedTime = endTime - startTime;
4034 GOSIInstrumentationLog.writeInstrumentationToLog(
4035 this.getClass().toString(), "checkNumberOfDaysEmployer()",
4036 elapsedTime);
4037 return noOfDaysEmployer;
4038 }
4039
4040
4041 /**
4042 * @METHOD NAME : checkNumberOfDaysHospital
4043 * @INFORMATION : This method is to get the Number of days difference
4044 between injury notification date and hospital PMR entry date
4045 * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.AddInjuryHelperBean
4046 * @RETURN : int
4047 * @EXCEPTION : class gosi.core.util.GOSIException
4048 * @LAST MODIFIED BY :
4049 * @LAST MODIFIED DATE :
4050 **/
4051 public int checkNumberOfDaysHospital(AddInjuryHelperBean injuryBean) throws GOSIException
4052 {
4053 PreparedStatement ps = null;
4054 ResultSet rs = null;
4055
4056 int noOfDaysHospital = 0;
4057
4058 Timestamp injuryNotificationDate = injuryBean.getCreationTimestamp();
4059
4060 try
4061 {
4062 /* Get the PMR entry date if this injury has been entered via GOSI On-Line */
4063 conn = GOSIUtilities.getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
4064 ps = conn.prepareStatement("SELECT creationtimestamp FROM t_pmr WHERE injuryid = ? ");
4065 ps.setLong(1, injuryBean.getInjuryId());
4066 rs = ps.executeQuery();
4067
4068 if(rs.next())
4069 {
4070 Timestamp pmrEntryDate = rs.getTimestamp("CREATIONTIMESTAMP");
4071
4072 // method to get the number of days between injury notification date and PMR entry date
4073 int x=(1000*24*60*60);
4074 noOfDaysHospital=(int)
4075 ((pmrEntryDate.getTime()-injuryNotificationDate.
4076 getTime())/x)+1;
4077 noOfDaysHospital=noOfDaysHospital-1;
4078 }
4079 }
4080 catch(Exception e)
4081 {
4082 throw new GOSIException (GOSIConstants.SEVERITY_ONE,
4083 GOSIConstants.SOCIAL_INSURANCE,
4084 this.getClass().toString(),
4085 "checkNumberOfDaysHospital()",
4086 e,
4087 "CMN_ERR_1000");
4088 }
4089 finally
4090 {
4091 GOSIUtilities.cleanUp(conn, ps, rs);
4092 }
4093
4094 return noOfDaysHospital;
4095 }
4096
4097 /**
4098 * @METHOD NAME : checkNoOfDaysComplnDiff
4099 * @INFORMATION : This method is to get the Number of days difference between
4100 treatment end date and complication date
4101 * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.AddInjuryHelperBean,
4102 class java.util.ArrayList
4103 * @RETURN : int
4104 * @EXCEPTION : class gosi.core.util.GOSIException
4105 * @LAST MODIFIED BY :
4106 * @LAST MODIFIED DATE :
4107 **/
4108 public int checkNoOfDaysComplnDiff(AddInjuryHelperBean injuryBean,
4109 ArrayList trmtList)
4110 throws GOSIException
4111 {
4112
4113 GOSIDebug.debugMessages("inside checkNoOfDaysCompln........sesbean");
4114 int noOfDaysComplnDiff=0;
4115 Timestamp trmtEndDate=null;
4116 String trmtEndDateStr="";
4117 long startTime = 0;
4118 long endTime = 0;
4119 long elapsedTime = 0;
4120
4121 startTime = System.currentTimeMillis();
4122
4123 AddInjuryHelperBean injuryListBean=new AddInjuryHelperBean();
4124
4125 Timestamp complicationDate=injuryBean.getDateComplication();
4126 try
4127 {
4128 // method to get the number of days between trmtEndDate and complicationDate
4129 for(int i=0;i<trmtList.size();i++)
4130 {
4131 injuryListBean=(AddInjuryHelperBean)trmtList.get(i);
4132 trmtEndDateStr=injuryListBean.getTrmtEndDateStr();
4133 }
4134 trmtEndDate=GOSIUtilities.getTimestamp(trmtEndDateStr);
4135 int x=(1000*24*60*60);
4136 noOfDaysComplnDiff=(int)
4137 ((complicationDate.getTime()-trmtEndDate.
4138 getTime())/x)+1;
4139 noOfDaysComplnDiff=noOfDaysComplnDiff-1;
4140 }
4141 catch(Exception e)
4142 {
4143 e.printStackTrace();
4144 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
4145 GOSIConstants.SOCIAL_INSURANCE,
4146 this.getClass().toString(),
4147 "checkNoOfDaysComplnDiff()", e,"CMN_ERR_1000" );
4148 }
4149 endTime = System.currentTimeMillis();
4150 elapsedTime = endTime - startTime;
4151 GOSIInstrumentationLog.writeInstrumentationToLog(
4152 this.getClass().toString(),
4153 "checkNoOfDaysComplnDiff()", elapsedTime);
4154 return noOfDaysComplnDiff;
4155 }
4156
4157 /**
4158 * @METHOD NAME : insertBodyParts
4159 * @INFORMATION : This method is to insert Body Parts
4160 * @PARAM : class java.lang.Long,
4161 class java.util.ArrayList,
4162 class gosi.business.socialinsurance.occupationalhazards.injury.beans.AddInjuryHelperBean
4163 * @RETURN : void
4164 * @EXCEPTION : class gosi.core.util.GOSIException
4165 * @LAST MODIFIED BY :
4166 * @LAST MODIFIED DATE :
4167 **/
4168 private void insertBodyParts(Long injuryID,
4169 ArrayList injuredBodyPartsList,
4170 AddInjuryHelperBean injuryBean)
4171 throws GOSIException
4172 {
4173
4174
4175 long startTime = 0;
4176 long endTime = 0;
4177 long elapsedTime = 0;
4178 startTime = System.currentTimeMillis();
4179
4180 try
4181 {
4182 //calling body parts entity
4183 BodyPartsEntityHome home=(BodyPartsEntityHome)
4184 ServiceLocator.getInstance().getRemoteHome(
4185 OHConstants.BODY_PARTS_ENTITY_JNDI,
4186 BodyPartsEntityHome.class);
4187 // if body parts selected
4188 if(injuredBodyPartsList!=null)
4189 {
4190 for(int i=0;i<injuredBodyPartsList.size();i++)
4191 {
4192 // inserting body parts based on mode
4193 // M for modify
4194 // D for delete
4195 BodyPartsListBean bodyPartsBean = (BodyPartsListBean)
4196 injuredBodyPartsList.get(i);
4197 bodyPartsBean.setCreatedBy(injuryBean.getCreatedBy());
4198 bodyPartsBean.setCreationTimestamp(
4199 new Timestamp(System.currentTimeMillis()));
4200
4201 if(!(("D").equals(""+bodyPartsBean.getMode())))
4202 {
4203
4204 if(!("M".equals(""+bodyPartsBean.getMode())))
4205 {
4206 // insert into t_bodyparts table
4207 Long primary=GOSIUtilities.
4208 getPrimaryKey("T_BODYPARTS",
4209 bodyPartsBean.getCreatedBy());
4210 bodyPartsBean.setInjuryBodyPartsId(primary);
4211 bodyPartsBean.setInjuryId(injuryID);
4212
4213 BodyPartsEntity remote=(BodyPartsEntity)home.
4214 create(bodyPartsBean);
4215 }
4216 }// deleting the entered body parts
4217 if(("D").equals(""+bodyPartsBean.getMode()))
4218 {
4219 GOSIDebug.debugMessages("Inside else bodyParts:");
4220 GOSIDebug.debugMessages("findByPrimaryKey:"+
4221 bodyPartsBean.getInjuryBodyPartsId());
4222 if(bodyPartsBean.getInjuryBodyPartsId()!=null)
4223 {
4224 BodyPartsEntity remote=(BodyPartsEntity)home.
4225 findByPrimaryKey(bodyPartsBean.
4226 getInjuryBodyPartsId());
4227 remote.remove();
4228 }
4229 }
4230 }
4231 }
4232 endTime = System.currentTimeMillis();
4233 elapsedTime = endTime - startTime;
4234 GOSIInstrumentationLog.writeInstrumentationToLog(
4235 this.getClass().toString(),
4236 "insertBodyParts()",
4237 elapsedTime);
4238 }
4239 catch (GOSIException ge)
4240 {
4241 throw ge;
4242 }
4243 catch(Exception e)
4244 {
4245 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
4246 GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
4247 "insertBodyParts()", e, "CMN_ERR_1000" );
4248 }
4249 finally
4250 {
4251
4252 }
4253 }
4254
4255
4256 /**
4257 * @METHOD NAME : insertBodyPartsComplnEnter
4258 * @INFORMATION : This method is to insert Body Parts during complication injury Entry
4259 * @PARAM : class java.lang.Long,
4260 class java.util.ArrayList,
4261 class gosi.business.socialinsurance.occupationalhazards.injury.beans.AddInjuryHelperBean
4262 * @RETURN : void
4263 * @EXCEPTION : class gosi.core.util.GOSIException
4264 * @LAST MODIFIED BY :
4265 * @LAST MODIFIED DATE :
4266 **/
4267 private void insertBodyPartsComplnEnter(Long injuryID,
4268 ArrayList injuredBodyPartsList,
4269 AddInjuryHelperBean injuryBean)
4270 throws GOSIException
4271 {
4272
4273 try
4274 {
4275 long startTime = 0;
4276 long endTime = 0;
4277 long elapsedTime = 0;
4278 startTime = System.currentTimeMillis();
4279 // inserting body parts for complication
4280 BodyPartsEntityHome home=(BodyPartsEntityHome)
4281 ServiceLocator.getInstance().getRemoteHome(
4282 OHConstants.BODY_PARTS_ENTITY_JNDI,
4283 BodyPartsEntityHome.class);
4284 GOSIDebug.debugMessages("Inside Insert body parts:");
4285 // if body parts entered
4286 if(injuredBodyPartsList!=null)
4287 {
4288 for(int i=0;i<injuredBodyPartsList.size();i++)
4289 {
4290
4291 // setting audit information
4292 BodyPartsListBean bodyPartsBean = (BodyPartsListBean)
4293 injuredBodyPartsList.get(i);
4294 bodyPartsBean.setCreatedBy(injuryBean.getCreatedBy());
4295 bodyPartsBean.setCreationTimestamp(
4296 new Timestamp(System.currentTimeMillis()));
4297 Long primary=GOSIUtilities.getPrimaryKey("T_BODYPARTS",
4298 bodyPartsBean.getCreatedBy());
4299 bodyPartsBean.setInjuryBodyPartsId(primary);
4300 bodyPartsBean.setInjuryId(injuryID);
4301 // inserting body parts into the db
4302 BodyPartsEntity remote=(BodyPartsEntity)home.
4303 create(bodyPartsBean);
4304 }
4305 }
4306 endTime = System.currentTimeMillis();
4307 elapsedTime = endTime - startTime;
4308 GOSIInstrumentationLog.writeInstrumentationToLog(
4309 this.getClass().toString(),
4310 "insertBodyPartsComplnEnter()",
4311 elapsedTime);
4312
4313 }
4314 catch (GOSIException ge)
4315 {
4316 throw ge;
4317 }
4318 catch(Exception e)
4319 {
4320 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
4321 GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
4322 "insertBodyPartsComplnEnter()", e, "CMN_ERR_1000" );
4323 }
4324 finally
4325 {
4326
4327 }
4328 }
4329
4330 /**
4331 * @METHOD NAME : insertICDDiagnosis
4332 * @INFORMATION : This method is to insert ICD Diagnosis Details
4333 * @PARAM : class java.lang.Long,
4334 class java.util.ArrayList,
4335 class gosi.business.socialinsurance.occupationalhazards.injury.beans.AddInjuryHelperBean
4336 * @RETURN : void
4337 * @EXCEPTION : class gosi.core.util.GOSIException
4338 * @LAST MODIFIED BY :
4339 * @LAST MODIFIED DATE :
4340 **/
4341 private void insertICDDiagnosis(Long injuryID,
4342 ArrayList icdList,
4343 AddInjuryHelperBean injuryBean)
4344 throws GOSIException
4345 {
4346 long startTime = 0;
4347 long endTime = 0;
4348 long elapsedTime = 0;
4349 startTime = System.currentTimeMillis();
4350 GOSIDebug.debugMessages("Inside insert ICDDiagnosis:");
4351 try
4352 {
4353 // method to add the selected icd details to the injury or
4354 // complication , records inserted if icd list is not null
4355
4356 InjuryDiagnosisEntityHome home=(InjuryDiagnosisEntityHome)
4357 ServiceLocator.getInstance().getRemoteHome(
4358 OHConstants.INJURY_DIAGNOSIS_ENTITY_JNDI,
4359 InjuryDiagnosisEntityHome.class);
4360 GOSIDebug.debugMessages("ICD LIST SIZE IN SES"+icdList.size());
4361 if(icdList!=null)
4362 {
4363 for(int i=0;i<icdList.size();i++)
4364 {
4365
4366 OHPopSearchListBean icdListBean = (OHPopSearchListBean)
4367 icdList.get(i);
4368 icdListBean.setCreatedBy(injuryBean.getCreatedBy());
4369 // setting audit information
4370 icdListBean.setCreationTimestamp(
4371 new Timestamp(System.currentTimeMillis()));
4372
4373
4374 if(!(("D").equals(""+icdListBean.getMode())))
4375 {
4376 // if mode is new record is inserted
4377 GOSIDebug.debugMessages("Inside !D..Create");
4378 if(!("M".equals(""+icdListBean.getMode())))
4379 {
4380 GOSIDebug.debugMessages("Inside M..Create");
4381 Long injuryDiagnosisId=GOSIUtilities.getPrimaryKey
4382 ("T_INJURYDIAGNOSIS",
4383 icdListBean.getCreatedBy());
4384 icdListBean.setInjuryDiagnosisId(injuryDiagnosisId);
4385 icdListBean.setInjuryId(injuryID);
4386 InjuryDiagnosisEntity oInjuryDiagnosisEntity=
4387 (InjuryDiagnosisEntity)home.
4388 create(icdListBean);
4389 }
4390 }// id mode is D record is deleted
4391 if(("D").equals(""+icdListBean.getMode()))
4392 {
4393 GOSIDebug.debugMessages("Inside else bodyParts:");
4394 GOSIDebug.debugMessages("findByPrimaryKey:"+
4395 icdListBean.getInjuryDiagnosisId());
4396 if(icdListBean.getInjuryDiagnosisId()!=null)
4397 {
4398 InjuryDiagnosisEntity remote=
4399 (InjuryDiagnosisEntity)home.
4400 findByPrimaryKey(icdListBean.
4401 getInjuryDiagnosisId());
4402 remote.remove();
4403 }
4404 }
4405 }
4406 }
4407 endTime = System.currentTimeMillis();
4408 elapsedTime = endTime - startTime;
4409 GOSIInstrumentationLog.writeInstrumentationToLog(
4410 this.getClass().toString(),
4411 "insertICDDiagnosis()",
4412 elapsedTime);
4413 }
4414 catch (GOSIException ge)
4415 {
4416 throw ge;
4417 }
4418 catch(Exception e)
4419 {
4420 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
4421 GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
4422 "insertICDDiagnosis()", e, "CMN_ERR_1000" );
4423 }
4424 finally
4425 {
4426 }
4427 }
4428
4429 /**
4430 * @METHOD NAME : subPartsList
4431 * @INFORMATION : This method is to search for the SubBodyParts from the database
4432 * @PARAM :
4433 * @RETURN : class java.util.ArrayList
4434 * @EXCEPTION : class gosi.core.util.GOSIException
4435 * @LAST MODIFIED BY :
4436 * @LAST MODIFIED DATE :
4437 **/
4438 public ArrayList subPartsList() throws GOSIException
4439 {
4440 PreparedStatement ps =null;
4441 ResultSet rsCommon =null;
4442 long startTime = 0;
4443 long endTime = 0;
4444 long elapsedTime = 0;
4445
4446 startTime = System.currentTimeMillis();
4447
4448 ArrayList subPartsList = new ArrayList();
4449
4450 try
4451 {
4452 // query to get the sub body parts list
4453 String sysDate=GOSIUtilities.getDateFullString(new Timestamp
4454 (System.currentTimeMillis()));
4455 String query=OHQueryInjury.OhQry_QRY_00092
4456 +SITables.T_BODYPARTS;
4457 GOSIDebug.debugMessages(""+query);
4458 conn=GOSIUtilities.getConnection
4459 (GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
4460 ps=conn.prepareStatement(query,
4461 ResultSet.TYPE_SCROLL_INSENSITIVE,
4462 ResultSet.CONCUR_READ_ONLY);
4463 rsCommon = ps.executeQuery();
4464 String searchValue=null;
4465 BodyPartsListBean subParts =null;
4466
4467 while(rsCommon.next())
4468 {
4469 subParts = new BodyPartsListBean();
4470
4471 searchValue=rsCommon.getString("BODYPARTSCODE");
4472 if(searchValue!=null)
4473 {
4474 subParts.setBodyPartCode(new Long(searchValue));
4475 }
4476
4477 searchValue=rsCommon.getString("BODYPARTNAMEENG");
4478 if(searchValue!=null)
4479 {
4480 subParts.setBodyPartNameEng(searchValue);
4481 }
4482
4483 searchValue=rsCommon.getString("BODYPARTNAMEARB");
4484 if(searchValue!=null)
4485 {
4486 subParts.setBodyPartNameArb(searchValue);
4487 }
4488
4489 searchValue=rsCommon.getString("MAINBODYPARTCODE");
4490 if(searchValue!=null)
4491 {
4492 subParts.setMainBodyPart(new Long(searchValue));
4493 }
4494 subPartsList.add(subParts);
4495 }
4496 endTime = System.currentTimeMillis();
4497 elapsedTime = endTime - startTime;
4498 GOSIInstrumentationLog.writeInstrumentationToLog(
4499 this.getClass().toString(), "subPartsList()",
4500 elapsedTime);
4501 return subPartsList;
4502 }
4503 catch(GOSIException ge)
4504 {
4505 throw ge;
4506 }
4507 catch(Exception e)
4508 {
4509 e.printStackTrace();
4510 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
4511 GOSIConstants.SOCIAL_INSURANCE,
4512 this.getClass().toString(),
4513 "subPartsList()", e, "CMN_ERR_1000" );
4514 }
4515 finally
4516 {
4517 try
4518 {
4519 GOSIUtilities.cleanUp(conn, ps, rsCommon);
4520 }
4521 catch(Exception e)
4522 {
4523 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
4524 GOSIConstants.SOCIAL_INSURANCE,
4525 this.getClass().toString(),
4526 "finally of subPartsList",
4527 e, "CMN_ERR_1000");
4528 }
4529 }
4530
4531 }
4532
4533 /**
4534 * @METHOD NAME : mainPartsList
4535 * @INFORMATION : This method is to search for the main Body Parts
4536 from the database
4537 * @PARAM :
4538 * @RETURN : class java.util.ArrayList
4539 * @EXCEPTION : class gosi.core.util.GOSIException
4540 * @LAST MODIFIED BY :
4541 * @LAST MODIFIED DATE :
4542 **/
4543 public ArrayList mainPartsList() throws GOSIException
4544 {
4545
4546 PreparedStatement ps =null;
4547 ResultSet rsCommon =null;
4548 long startTime = 0;
4549 long endTime = 0;
4550 long elapsedTime = 0;
4551
4552 startTime = System.currentTimeMillis();
4553 ArrayList mainPartsList = new ArrayList();
4554
4555 try
4556 {
4557 // query to get the body parts list
4558 String sysDate=GOSIUtilities.getDateFullString(new Timestamp
4559 (System.currentTimeMillis()));
4560 String query=OHQueryInjury.OhQry_QRY_00093 ;
4561 GOSIDebug.debugMessages(""+query);
4562 conn=GOSIUtilities.getConnection
4563 (GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
4564 ps=conn.prepareStatement(query,
4565 ResultSet.TYPE_SCROLL_INSENSITIVE,
4566 ResultSet.CONCUR_READ_ONLY);
4567 rsCommon = ps.executeQuery();
4568 String searchValue=null;
4569 BodyPartsListBean mainParts =null;
4570
4571 while(rsCommon.next())
4572 {
4573 mainParts = new BodyPartsListBean();
4574 searchValue=rsCommon.getString("BODYPARTSCODE");
4575 if(searchValue!=null)
4576 {
4577 mainParts.setMainBodyPart(new Long(searchValue));
4578 }
4579
4580 searchValue=rsCommon.getString("BODYPARTNAMEENG");
4581 if(searchValue!=null)
4582 {
4583 mainParts.setBodyPartNameEng(searchValue);
4584 }
4585
4586 searchValue=rsCommon.getString("BODYPARTNAMEARB");
4587 if(searchValue!=null)
4588 {
4589 mainParts.setBodyPartNameArb(searchValue);
4590 }
4591 mainPartsList.add(mainParts);
4592 }
4593 return mainPartsList;
4594 }
4595 catch(GOSIException ge)
4596 {
4597 throw ge;
4598 }
4599 catch(Exception e)
4600 {
4601 e.printStackTrace();
4602 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
4603 GOSIConstants.SOCIAL_INSURANCE,
4604 this.getClass().toString(),
4605 "mainPartsList()",
4606 e, "CMN_ERR_1000");
4607 }
4608 finally
4609 {
4610 try{
4611 GOSIUtilities.cleanUp(conn, ps, rsCommon);
4612 }
4613 catch(Exception e)
4614 {
4615 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
4616 GOSIConstants.SOCIAL_INSURANCE,
4617 this.getClass().toString(),
4618 "finally of mainPartsList",
4619 e,"CMN_ERR_1000");
4620 }
4621 }
4622 }
4623
4624 /**
4625 * @METHOD NAME : srchBodyPartsList
4626 * @INFORMATION : This method is to search for the Body parts in the
4627 database for theworkflow
4628 * @PARAM : class java.lang.Long
4629 * @RETURN : class java.util.ArrayList
4630 * @EXCEPTION : class gosi.core.util.GOSIException
4631 * @LAST MODIFIED BY :
4632 * @LAST MODIFIED DATE :
4633 **/
4634 public ArrayList srchBodyPartsList(Long injuryId) throws GOSIException
4635 {
4636
4637 PreparedStatement ps =null;
4638 ResultSet rsCommon =null;
4639 String sqlQuery="";
4640 long startTime = 0;
4641 long endTime = 0;
4642 long elapsedTime = 0;
4643
4644 startTime = System.currentTimeMillis();
4645 try
4646 { // query to get the injured body parts for the injury
4647 // using injuryid
4648 sqlQuery=OHQueryInjury.OhQry_QRY_00094 ;
4649 GOSIDebug.debugMessages("INJURY ID IS :"+injuryId);
4650 GOSIDebug.debugMessages(""+sqlQuery);
4651 conn = GOSIUtilities.
4652 getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
4653 ps=conn.prepareStatement(sqlQuery);
4654 ps.setLong(1,injuryId.longValue());
4655 rsCommon=ps.executeQuery();
4656 ArrayList bodyListArray = new ArrayList();
4657
4658 BodyPartsListBean injuredPartsBean =null;
4659
4660 while(rsCommon.next())
4661 {
4662 injuredPartsBean = new BodyPartsListBean();
4663 String searchValue=rsCommon.getString("INJUREDBODYPARTSID");
4664 if(searchValue!=null)
4665 {
4666 injuredPartsBean.setInjuryBodyPartsId
4667 (new Long(searchValue));
4668 }
4669 searchValue=rsCommon.getString("BODYPARTSCODE");
4670 if(searchValue!=null)
4671 {
4672 injuredPartsBean.setBodyPartCode(new Long(searchValue));
4673 }
4674 searchValue=rsCommon.getString("INJURYID");
4675 if(searchValue!=null)
4676 {
4677 injuredPartsBean.setMainBodyPart(new Long(searchValue));
4678 }
4679 injuredPartsBean.setBodyPartNameArb(rsCommon.getString(
4680 "BODYPARTNAMEARB"));
4681
4682 injuredPartsBean.setBodyPartNameEng(rsCommon.getString(
4683 "BODYPARTNAMEENG"));
4684 bodyListArray.add(injuredPartsBean);
4685 }
4686 endTime = System.currentTimeMillis();
4687 elapsedTime = endTime - startTime;
4688 GOSIInstrumentationLog.writeInstrumentationToLog(
4689 this.getClass().toString(), "srchBodyPartsList()",
4690 elapsedTime);
4691 return bodyListArray;
4692 }
4693 catch(Exception e)
4694 {
4695 e.printStackTrace();
4696 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
4697 GOSIConstants.SOCIAL_INSURANCE,
4698 this.getClass().toString(),
4699 "srchBodyPartsList()", e,
4700 "CMN_ERR_1000");
4701 }
4702 finally
4703 {
4704 GOSIUtilities.cleanUp(conn, ps, rsCommon);
4705 }
4706 }
4707
4708
4709 /**
4710 * @METHOD NAME : searchPreviousInjuryId
4711 * @INFORMATION : This method is to search previous Injury Id for ICD Diagnosis list
4712 * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.AddInjuryHelperBean
4713 * @RETURN : class java.lang.Long
4714 * @EXCEPTION : class gosi.core.util.GOSIException
4715 * @LAST MODIFIED BY :
4716 * @LAST MODIFIED DATE :
4717 **/
4718 public Long searchPreviousInjuryId
4719 (AddInjuryHelperBean injuryBean)
4720 throws GOSIException
4721 {
4722
4723 PreparedStatement ps =null;
4724 ResultSet rsCommon =null;
4725 Long previousInjuryId=null;
4726 String sqlQuery="";
4727 long startTime = 0;
4728 long endTime = 0;
4729 long elapsedTime = 0;
4730
4731 startTime = System.currentTimeMillis();
4732 GOSIDebug.debugMessages("Inside search ICD Diagnosis List");
4733
4734 try
4735 {
4736 //Query to get the injury id for the parent injury
4737 // called during adding the complication for the injury
4738 sqlQuery=OHQueryInjury.OhQry_QRY_00095 ;
4739
4740 GOSIDebug.debugMessages(""+sqlQuery);
4741 conn = GOSIUtilities.
4742 getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
4743 ps=conn.prepareStatement(sqlQuery);
4744 ps.setLong(1,injuryBean.getInjuryNumber().longValue());
4745 ps.setTimestamp(2,injuryBean.getInjuryDate());
4746 rsCommon=ps.executeQuery();
4747 GOSIDebug.debugMessages("b4 while");
4748 while(rsCommon.next())
4749 {
4750 previousInjuryId=new Long(rsCommon.getLong("INJURYID"));
4751 GOSIDebug.debugMessages("PreviousInjuryId:"+previousInjuryId);
4752 }
4753 }
4754 catch(Exception e)
4755 {
4756 e.printStackTrace();
4757 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
4758 GOSIConstants.SOCIAL_INSURANCE,
4759 this.getClass().toString(),
4760 "searchPreviousInjuryId()",
4761 e, "CMN_ERR_1000" );
4762 }
4763 finally
4764 {
4765 GOSIUtilities.cleanUp(conn, ps, rsCommon);
4766 }
4767 endTime = System.currentTimeMillis();
4768 elapsedTime = endTime - startTime;
4769 GOSIInstrumentationLog.writeInstrumentationToLog(
4770 this.getClass().toString(), "searchPreviousInjuryId()",
4771 elapsedTime);
4772 return previousInjuryId;
4773 }
4774
4775 /**
4776 * @METHOD NAME : getTrmtEndDate
4777 * @INFORMATION : This method is to get Trmtment End Date
4778 * @PARAM : class java.lang.Long
4779 * @RETURN : class java.util.ArrayList
4780 * @EXCEPTION : class gosi.core.util.GOSIException
4781 * @LAST MODIFIED BY :
4782 * @LAST MODIFIED DATE :
4783 **/
4784 public ArrayList getTrmtEndDate
4785 (Long injuryNumber)
4786 throws GOSIException
4787 {
4788
4789 PreparedStatement ps =null;
4790 ResultSet rsCommon =null;
4791 java.sql.Timestamp treatmentDate=null;
4792 String sqlQuery="";
4793 long startTime = 0;
4794 long endTime = 0;
4795 long elapsedTime = 0;
4796
4797 startTime = System.currentTimeMillis();
4798 GOSIDebug.debugMessages("Inside search ICD Diagnosis List");
4799 // this method is used to get the treatment enddate in the injury table
4800 // using injury number as parameter
4801
4802 ArrayList trmtDateList=new ArrayList();
4803 trmtDateList.clear();
4804 try
4805 {
4806 sqlQuery=OHQueryInjury.OhQry_QRY_00096 ;
4807 // query to get treatment end date
4808 GOSIDebug.debugMessages(""+sqlQuery);
4809 conn = GOSIUtilities.
4810 getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
4811 ps=conn.prepareStatement(sqlQuery);
4812 ps.setLong(1,injuryNumber.longValue());
4813 ps.setLong(2,injuryNumber.longValue());
4814 rsCommon=ps.executeQuery();
4815 GOSIDebug.debugMessages("b4 while");
4816
4817 AddInjuryHelperBean injuryListBean=null;
4818
4819 while(rsCommon.next())
4820 {
4821
4822 injuryListBean=new AddInjuryHelperBean();
4823 injuryListBean.setTmtEndDate
4824 (rsCommon.getTimestamp("TREATMENTENDDATE"));
4825 injuryListBean.setTmtEndDateEntFmt
4826 (rsCommon.getString("TREATMENTENDDATEENTFMT"));
4827 GOSIDebug.debugMessages("TrmtEndDateEntFmt:::"+
4828 injuryListBean.getTmtEndDateEntFmt());
4829 GOSIDebug.debugMessages("TrmtEndDate:::"+
4830 injuryListBean.getTmtEndDate());
4831 if (injuryListBean.getTmtEndDate()!= null &&
4832 injuryListBean.getTmtEndDateEntFmt()!= null)
4833 {
4834 GOSIDebug.debugMessages("inside if trmtenddate:");
4835 if (OHConstants.HIJRAH.equals
4836 (injuryListBean.getTmtEndDateEntFmt()))
4837 {
4838 injuryListBean.setTrmtEndDateStr(
4839 GOSIDateUtilities.convertToHijra(
4840 GOSIUtilities.getDateFullString
4841 (injuryListBean.getTmtEndDate())));
4842 }
4843 else
4844 {
4845 injuryListBean.setTrmtEndDateStr
4846 (GOSIUtilities.getDateFullString(
4847 injuryListBean.getTmtEndDate()));
4848
4849 }
4850 }
4851 trmtDateList.add(injuryListBean);
4852 }
4853 }
4854 catch(Exception e)
4855 {
4856 e.printStackTrace();
4857 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
4858 GOSIConstants.SOCIAL_INSURANCE,
4859 this.getClass().toString(),
4860 "getTrmtEndDate()",
4861 e, "CMN_ERR_1000");
4862 }
4863 finally
4864 {
4865 GOSIUtilities.cleanUp(conn, ps, rsCommon);
4866 }
4867 endTime = System.currentTimeMillis();
4868 elapsedTime = endTime - startTime;
4869 GOSIInstrumentationLog.writeInstrumentationToLog(
4870 this.getClass().toString(), "getTrmtEndDate()", elapsedTime);
4871 return trmtDateList;
4872 }
4873
4874 /**
4875 * @METHOD NAME : searchICDDiagnosisList
4876 * @INFORMATION : This method is to search for the ICD Codes in the
4877 database for the workflow
4878 * @PARAM : class java.lang.Long
4879 * @RETURN : class java.util.ArrayList
4880 * @EXCEPTION : class gosi.core.util.GOSIException
4881 * @LAST MODIFIED BY :
4882 * @LAST MODIFIED DATE :
4883 **/
4884 public ArrayList searchICDDiagnosisList(Long injuryId)
4885 throws GOSIException
4886 {
4887
4888 GOSIDebug.debugMessages("Inside search ICD Diagnosis List");
4889 PreparedStatement ps =null;
4890 ResultSet rsCommon =null;
4891 String sqlQuery="";
4892 long startTime = 0;
4893 long endTime = 0;
4894 long elapsedTime = 0;
4895
4896 startTime = System.currentTimeMillis();
4897 ArrayList icdList = new ArrayList();
4898 icdList.clear();
4899
4900 try
4901 {
4902 //query to get the ICD diagnosis code entered for the disease
4903 // using injury id
4904 sqlQuery=OHQueryInjury.OhQry_QRY_00097 ;
4905 GOSIDebug.debugMessages("INJURY ID IS :"+injuryId);
4906 GOSIDebug.debugMessages(""+sqlQuery);
4907 conn = GOSIUtilities.
4908 getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
4909 ps=conn.prepareStatement(sqlQuery);
4910 ps.setLong(1,injuryId.longValue());
4911 rsCommon=ps.executeQuery();
4912
4913 OHPopSearchListBean icdListBean=null;
4914 while(rsCommon.next())
4915 {
4916
4917 icdListBean = new OHPopSearchListBean();
4918
4919 GOSIDebug.debugMessages("Inside while:");
4920 icdListBean.setInjuryDiagnosisId(new Long(
4921 rsCommon.getLong("INJURYDIAGNOSISID")));
4922 icdListBean.setICDDiagnosisId(new Long(rsCommon.getLong(
4923 "ICDDIAGNOSISID")));
4924 icdListBean.setICDCode(rsCommon.getString("ICD10CODE"));
4925 icdListBean.setDiagnosisArb(rsCommon.getString(
4926 "ICDDIAGNOSISARB"));
4927 icdListBean.setDiagnosisEng(rsCommon.getString(
4928 "ICDDIAGNOSISENG"));
4929 icdList.add(icdListBean);
4930 }
4931 }
4932 catch(Exception e)
4933 {
4934 e.printStackTrace();
4935 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
4936 GOSIConstants.SOCIAL_INSURANCE,
4937 this.getClass().toString(),
4938 "searchICDDiagnosisList()",
4939 e, "CMN_ERR_1000");
4940 }
4941 finally
4942 {
4943 GOSIUtilities.cleanUp(conn, ps, rsCommon);
4944 }
4945 endTime = System.currentTimeMillis();
4946 elapsedTime = endTime - startTime;
4947 GOSIInstrumentationLog.writeInstrumentationToLog(
4948 this.getClass().toString(),
4949 "searchICDDiagnosisList()", elapsedTime);
4950 return icdList;
4951 }
4952 /**
4953 * @METHOD NAME : getInjuryHome
4954 * @INFORMATION : This method is to call Injury Entity
4955 * @PARAM :
4956 * @RETURN : interface gosi.database.socialinsurance.occupationalhazards.injury.entity.InjuryEntityHome
4957 * @EXCEPTION : class gosi.core.util.GOSIException
4958 * @LAST MODIFIED BY :
4959 * @LAST MODIFIED DATE :
4960 **/
4961 private InjuryEntityHome getInjuryHome() throws GOSIException
4962 {
4963
4964 try
4965 {
4966 return (InjuryEntityHome)
4967 ServiceLocator.getInstance().getRemoteHome(
4968 OHConstants.INJURY_ENTITY_JNDI,
4969 InjuryEntityHome.class);
4970 }
4971 catch (GOSIException ge)
4972 {
4973 throw ge;
4974 }
4975 catch(Exception e)
4976 {
4977 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
4978 GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
4979 "getInjuryHome()", e, "CMN_ERR_1000"
4980 );
4981 }
4982 finally
4983 {
4984
4985 }
4986 }
4987 /**
4988 * @METHOD NAME : getInjuryReqDocHome
4989 * @INFORMATION : This method is to call Injury Entity
4990 * @PARAM :
4991 * @RETURN : interface gosi.database.socialinsurance.occupationalhazards.injury.entity.InjuryReqDocHome
4992 * @EXCEPTION : class gosi.core.util.GOSIException
4993 * @LAST MODIFIED BY :
4994 * @LAST MODIFIED DATE :
4995 **/
4996 private InjuryDocReqEntityHome getInjuryReqDocHome() throws GOSIException
4997 {
4998
4999 try
5000 {
5001 return (InjuryDocReqEntityHome)
5002 ServiceLocator.getInstance().getRemoteHome(
5003 OHConstants.INJURY_DOC_REQ_ENTITY_JNDI,
5004 InjuryDocReqEntityHome.class);
5005 }
5006 catch (GOSIException ge)
5007 {
5008 throw ge;
5009 }
5010 catch(Exception e)
5011 {
5012 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
5013 GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
5014 "getInjuryReqDocHome()", e, "CMN_ERR_1000"
5015 );
5016 }
5017 finally
5018 {
5019
5020 }
5021 }
5022
5023 /**
5024 * @METHOD NAME : getPreExistDeformitiesHome
5025 * @INFORMATION : This method is to call PreexistingDeformitiesEntity
5026 * @PARAM :
5027 * @RETURN : interface gosi.database.socialinsurance.occupationalhazards.injury.entity.PreexistingDeformitiesEntityHome
5028 * @EXCEPTION : class gosi.core.util.GOSIException
5029 * @LAST MODIFIED BY :
5030 * @LAST MODIFIED DATE :
5031 **/
5032 private PreexistingDeformitiesEntityHome getPreExistDeformitiesHome()
5033 throws GOSIException
5034 {
5035
5036 try
5037 {
5038 return (PreexistingDeformitiesEntityHome)
5039 ServiceLocator.getInstance().getRemoteHome(
5040 OHConstants.PREEXIST_DEFORMITIES_ENTITY_JNDI,
5041 PreexistingDeformitiesEntityHome.class);
5042 }
5043 catch (GOSIException ge)
5044 {
5045 throw ge;
5046 }
5047 catch(Exception e)
5048 {
5049 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
5050 GOSIConstants.SOCIAL_INSURANCE,
5051 this.getClass().toString(), "getPreexistingDeformitiesHome()",
5052 e, "CMN_ERR_1000"
5053 );
5054 }
5055 finally
5056 {
5057
5058 }
5059 }
5060
5061
5062 /**
5063 * @METHOD NAME : isValidInjury
5064 * @INFORMATION : This method is to is Validate Injury
5065 * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.AddInjuryHelperBean
5066 * @RETURN : class java.util.HashMap
5067 * @EXCEPTION : class gosi.core.util.GOSIException
5068 * @LAST MODIFIED BY :
5069 * @LAST MODIFIED DATE :
5070 **/
5071 private HashMap isValidInjury(AddInjuryHelperBean injuryBean)throws GOSIException
5072 {
5073 try
5074 {
5075 // the valiadation of the method is implimented in the
5076 // MaintainNotifyInjuryInternetSessionEJB refer that file to
5077 // know validation details
5078 MaintainNotifyInjuryInternetSessionHome home = (MaintainNotifyInjuryInternetSessionHome)
5079 ServiceLocator.getInstance().getRemoteHome(
5080 OHConstants.MAINTAIN_NOTIFY_INJURY_INTERNET_SESSION_JNDI,
5081 MaintainNotifyInjuryInternetSessionHome.class);
5082 MaintainNotifyInjuryInternetSession remote = home.create();
5083 return remote.isValidInjury(injuryBean,null);
5084 }
5085 catch(GOSIException ge)
5086 {
5087 throw ge;
5088 }
5089 catch(Exception e)
5090 {
5091 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
5092 GOSIConstants.SOCIAL_INSURANCE,
5093 this.getClass().toString(),
5094 "isValidInjury()", e, "CMN_ERR_1000");
5095 }
5096 }
5097
5098
5099 /**
5100 * @METHOD NAME : checkFormSubmissionDate
5101 * @INFORMATION : This method is to check Form Submission Date
5102 * @PARAM : class java.lang.Long,
5103 class java.sql.Timestamp
5104 * @RETURN : void
5105 * @EXCEPTION : class gosi.core.util.GOSIException
5106 * @LAST MODIFIED BY :
5107 * @LAST MODIFIED DATE :
5108 **/
5109 public void checkFormSubmissionDate (Long socInsNumber, Timestamp injuryDate) throws GOSIException
5110 {
5111 PreparedStatement ps = null;
5112 ResultSet rs = null;
5113
5114 try
5115 {
5116 String sqlQuery = "SELECT NVL(A.FORMSUBMISSIONDATE,B.JOININGDATE) as FORMSUBMISSIONDATE " +
5117 " FROM " + SITables.T_MONTHLYMOVEMENTSUMMARY + " a, " + SITables.T_ENGAGEMENT + " b " +
5118 " WHERE a.monthlymovementsummaryid(+) = b.joiningmonthlymovementid " +
5119 " AND b.joiningdate <= ? " +
5120 " AND (b.leavingdate >= ? OR b.leavingdate IS NULL) " +
5121 " AND b.contributorid IN ( " +
5122 " SELECT contributorid " +
5123 " FROM t_contributor " +
5124 " WHERE socialinsurancenumber = ?) " +
5125 " AND b.approvalstatus <> ? " +
5126 " AND b.engagementstatus NOT IN (?, ?) ";
5127
5128 conn = GOSIUtilities.getConnection (GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
5129
5130 ps = conn.prepareStatement (sqlQuery);
5131
5132 ps.setTimestamp (1, injuryDate);
5133 ps.setTimestamp (2, injuryDate);
5134 ps.setLong (3, socInsNumber);
5135 ps.setShort (4, RegistrationConstants.DATA_FINALLY_CANCELLED);
5136 ps.setShort (5, RegistrationConstants.ENG_CANCEL_IN_PROGRESS);
5137 ps.setShort (6, RegistrationConstants.ENG_CANCELLED);
5138
5139 rs = ps.executeQuery ();
5140
5141 if (! rs.next())
5142 {
5143 throw new GOSIException (GOSIConstants.SEVERITY_ONE,
5144 GOSIConstants.SOCIAL_INSURANCE,
5145 this.getClass().toString(),
5146 "checkFormSubmissionDate()",
5147 null,
5148 "SOI_ERR_5782");
5149 }
5150 else if (rs.getObject ("FORMSUBMISSIONDATE") == null || ! injuryDate.after(rs.getTimestamp("FORMSUBMISSIONDATE")))
5151 {
5152 throw new GOSIException (GOSIConstants.SEVERITY_ONE,
5153 GOSIConstants.SOCIAL_INSURANCE,
5154 this.getClass().toString(),
5155 "checkFormSubmissionDate()",
5156 null,
5157 GOSIUtilities.getDateDifference(injuryDate, rs.getTimestamp("FORMSUBMISSIONDATE")) == 0 ? "SOI_ERR_5789" : "SOI_ERR_5782");
5158 }
5159 }
5160 catch (GOSIException ge)
5161 {
5162 throw ge;
5163 }
5164 catch (Exception e)
5165 {
5166 throw new GOSIException (GOSIConstants.SEVERITY_ONE,
5167 GOSIConstants.SOCIAL_INSURANCE,
5168 this.getClass().toString(),
5169 "checkFormSubmissionDate()",
5170 e,
5171 "CMN_ERR_1000");
5172 }
5173 finally
5174 {
5175 GOSIUtilities.cleanUp (conn, ps, rs);
5176 }
5177 }
5178
5179 /**
5180 * @METHOD NAME : checkTreatmentInpatient
5181 * @INFORMATION : This method is to check Treatment on Inpatient
5182 it will check whether the injury date is on inpatient period
5183 * @PARAM : class java.lang.Long,
5184 class java.sql.Timestamp
5185 * @RETURN : void
5186 * @EXCEPTION : class gosi.core.util.GOSIException
5187 * @LAST MODIFIED BY :
5188 * @LAST MODIFIED DATE :
5189 **/
5190 public void checkTreatmentInpatient(Long siNumber, Timestamp injuryDate)
5191 throws GOSIException
5192 {
5193 PreparedStatement ps =null;
5194 ResultSet rs =null;
5195 StringBuilder sqlQuery=new StringBuilder();
5196 long startTime = 0;
5197 long endTime = 0;
5198 long elapsedTime = 0;
5199 startTime = System.currentTimeMillis();
5200 try
5201 {
5202 // this method is to check if the injury date is on an inpatient
5203 // period for the contributor
5204 sqlQuery.append(" SELECT COUNT(*) CNT ");
5205 sqlQuery.append(" FROM "+SITables.T_TREATMENT +" a, ");
5206 sqlQuery.append(SITables.T_INJURY+" b ");
5207 sqlQuery.append(" where a.INJURYID=b.INJURYID ");
5208 sqlQuery.append(" and b.SOCINSNUMBER=? ");
5209 sqlQuery.append(" and ( b.INJURYSTATUS != ? and b.INJURYSTATUS != ?) ");
5210 sqlQuery.append(" AND a.STARTDATE <= ? AND a.ENDDATE >= ? ");
5211 sqlQuery.append(" AND a.TREATMENTTYPE=? ");
5212 sqlQuery.append(" AND a.TREATMENTSTATUS <> ? ");
5213 GOSIDebug.debugMessages("checkTreatmentInpatient:sqlQuery:"+sqlQuery.toString());
5214 conn = GOSIUtilities.
5215 getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
5216 ps=conn.prepareStatement(sqlQuery.toString());
5217 ps.setLong(1,siNumber.longValue());
5218 ps.setShort(2,OHConstants.INJ_STS_CANCELLED.shortValue());
5219 ps.setShort(3,OHConstants.INJ_STS_REJECTED.shortValue());
5220 ps.setTimestamp(4,injuryDate);
5221 ps.setTimestamp(5,injuryDate);
5222 ps.setShort(6,OHConstants.TRMT_TYPE_INPATIENT.shortValue());
5223 ps.setShort(7,OHConstants.TRMT_STS_CANCELLED.shortValue());
5224 rs=ps.executeQuery();
5225 if(rs.next())
5226 {
5227 //Injury cannot be booked when another Injury for the same
5228 //contributor is taking In Patient Treatment
5229 if(rs.getInt("CNT")>0)
5230 {
5231 throw new GOSIException( GOSIConstants.SEVERITY_THREE,
5232 GOSIConstants.SOCIAL_INSURANCE,
5233 this.getClass().toString(),
5234 "checkTreatmentInpatient()",
5235 new GOSIException(),
5236 "SOI_ERR_5388");
5237 }
5238 GOSIDebug.debugMessages("rs.getInt(CNT)==="+rs.getInt("CNT"));
5239 }
5240 endTime = System.currentTimeMillis();
5241 elapsedTime = endTime - startTime;
5242 GOSIInstrumentationLog.writeInstrumentationToLog(
5243 this.getClass().toString(),
5244 "checkTreatmentInpatient()",
5245 elapsedTime);
5246 }
5247 catch (GOSIException ge)
5248 {
5249 throw ge;
5250 }
5251 catch(Exception e)
5252 {
5253 throw new GOSIException(GOSIConstants.SEVERITY_ONE,
5254 GOSIConstants.SOCIAL_INSURANCE,
5255 this.getClass().toString(),
5256 "viewUnregHospitalInvoice()",
5257 e,"CMN_ERR_1000");
5258 }
5259 finally
5260 {
5261 GOSIUtilities.cleanUp(conn, ps, rs);
5262 }
5263
5264
5265 }
5266
5267 /**
5268 * @METHOD NAME : isAnyOpenInjury
5269 * @INFORMATION : This method is to check Any Open Injury is present
5270 for the contributor
5271 * @PARAM : class java.lang.Long
5272 * @RETURN : boolean
5273 * @EXCEPTION : class gosi.core.util.GOSIException
5274 * @LAST MODIFIED BY :
5275 * @LAST MODIFIED DATE :
5276 **/
5277 public boolean isAnyOpenInjury(Long siNumber,Timestamp injuryDate)
5278 throws GOSIException
5279 {
5280 long startTime = 0;
5281 long endTime = 0;
5282 long elapsedTime = 0;
5283 startTime = System.currentTimeMillis();
5284
5285 PreparedStatement ps =null;
5286 ResultSet rs =null;
5287 String sqlQuery="";
5288 boolean isAnyOpenInjury = false;
5289 try
5290 {
5291 // Query to check whether the contributor has any open injuries
5292 // or not
5293 sqlQuery=" SELECT COUNT(1) CNT "+
5294 " FROM "+SITables.T_INJURY +
5295 " where SOCINSNUMBER=? "+
5296 " and (INJURYSTATUS =? or INJURYSTATUS = ? or INJURYSTATUS = ?) "+
5297 " and INJURYDATE != ? ";
5298
5299 GOSIDebug.debugMessages("isAnyOpenInjury:sqlQuery:"+sqlQuery);
5300 conn = GOSIUtilities.
5301 getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
5302 ps=conn.prepareStatement(sqlQuery);
5303 ps.setLong(1,siNumber.longValue());
5304 ps.setShort(2,OHConstants.INJ_STS_APPROVED.shortValue());
5305 ps.setShort(3,OHConstants.INJ_STS_NOTIFIED.shortValue());
5306 ps.setShort(4,OHConstants.INJ_STS_FIRST_NOTIFIED.shortValue());
5307 ps.setTimestamp(5,injuryDate);
5308 rs=ps.executeQuery();
5309 int count = 0;
5310 if(rs.next())
5311 {
5312 if(rs.getInt("CNT")>0)
5313 {
5314 // set to true if there is an open injury
5315 isAnyOpenInjury = true;
5316 count = rs.getInt("CNT");
5317 }
5318 GOSIDebug.debugMessages("rs.getInt(CNT)==="+count);
5319 }
5320
5321 endTime = System.currentTimeMillis();
5322 elapsedTime = endTime - startTime;
5323 GOSIInstrumentationLog.writeInstrumentationToLog(
5324 this.getClass().toString(),
5325 "isAnyOpenInjury()",
5326 elapsedTime);
5327 return isAnyOpenInjury;
5328 }
5329 catch (GOSIException ge)
5330 {
5331 throw ge;
5332 }
5333 catch(Exception e)
5334 {
5335 throw new GOSIException(GOSIConstants.SEVERITY_ONE,
5336 GOSIConstants.SOCIAL_INSURANCE,
5337 this.getClass().toString(),
5338 "isAnyOpenInjury()",
5339 e,"CMN_ERR_1000");
5340 }
5341 finally
5342 {
5343 GOSIUtilities.cleanUp(conn, ps, rs);
5344 }
5345 }
5346
5347
5348 /**
5349 * @METHOD NAME : generateLetter
5350 * @INFORMATION : This method is to generate Letter when injury is rejected
5351 * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.AddInjuryHelperBean
5352 * @RETURN : void
5353 * @EXCEPTION : class gosi.core.util.GOSIException
5354 * @LAST MODIFIED BY :
5355 * @LAST MODIFIED DATE :
5356 **/
5357 private void generateLetter(AddInjuryHelperBean injuryBean)
5358 throws GOSIException
5359 {
5360 LetterHeaderBean letterHeader = null;
5361 HashMap letterMap=null;
5362 TreeMap parameterList = null;
5363 long printSerialNumber = 0;
5364 Long contactId = null;
5365 String injuryDateStr = "";
5366 Short partialDisablity = OHConstants.INJ_STS_CURED_WITH_DISABILITY;
5367 Long userId= null;
5368
5369
5370 try
5371 {
5372 // method to generate letter during rejection of injury
5373 GOSIDebug.debugMessages("-----------GENERATE LTTER--------------------");
5374 GOSIDebug.debugMessages("Social Insurance Number:"+injuryBean.getSocInsNumber());
5375 GOSIDebug.debugMessages("EstablishmentId:"+injuryBean.getEstablishmentId());
5376 if(null != injuryBean.getHospitalCode() && isRegisteredHospital(injuryBean.getHospitalCode()))
5377 {
5378 generateLetterHospital(injuryBean);
5379 }
5380 Timestamp injuryDate = null;
5381 if(injuryBean.getDateComplication()!=null)
5382 {
5383 injuryDate = injuryBean.getDateComplication();
5384 }else
5385 {
5386 injuryDate = injuryBean.getInjuryDate();
5387 }
5388 injuryDateStr = OHUtilities.getDateStr(injuryDate,OHConstants.GREGORIAN);
5389
5390 EstablishmentBean estBean = EstablishmentUtility.
5391 getEstablishmentDetails(injuryBean.getEstablishmentId().longValue(),
5392 false,true);
5393 contactId = estBean.getEstablishmentContactId();
5394
5395 ContributorBean conBean = ContributorUtilities.displayContributorForSIN
5396 (injuryBean.getSocInsNumber());
5397 PersonBean personBean = PersonUtilities.displayPerson(conBean.getPersonId());
5398
5399 String name = personBean.getFirstName();
5400 if(personBean.getSecondName()!= null)
5401 {
5402 name = name + " " + personBean.getSecondName();
5403 }
5404 if(personBean.getThirdName()!= null)
5405 {
5406 name = name + " " + personBean.getThirdName();
5407 }
5408 if(personBean.getSurName()!= null)
5409 {
5410 name = name + " " + personBean.getSurName();
5411 }
5412 String reasonCode = "";
5413 if(injuryBean.getRejectionCode()!=null)
5414 {
5415 reasonCode = GOSIUtilities.getDomainDesc("OH Rejection Code",
5416 injuryBean.getRejectionCode().shortValue(),true);
5417 }
5418
5419 if(injuryBean.getLastModifiedBy()!=null)
5420 {
5421 userId = injuryBean.getLastModifiedBy();
5422 }else
5423 {
5424 userId = injuryBean.getCreatedBy();
5425 }
5426
5427 letterHeader = new LetterHeaderBean();
5428 letterHeader.setRequestedBy(userId);
5429 letterHeader.setReportId("16_02_0013");
5430 letterHeader.setLetterStatusFlag(new Short("5"));
5431 letterHeader.setRecordId(""+injuryBean.getInjuryId());
5432
5433 letterHeader.setFieldOfficeCode(
5434 injuryBean.getFieldOfficeCode());
5435
5436 letterMap = new HashMap();
5437
5438 letterHeader.setStakeHolders(new Short(
5439 ReportConstants.STAKE_HOLDER_REG_ESTABLISHMENT),
5440 contactId,
5441 estBean.getRegistrationNumber().toString());
5442
5443 letterMap.put("ESTABLISHMENTNAMEARB", ""+estBean.getEstablishmentNameArb());
5444 letterMap.put("REGNUM",""+estBean.getRegistrationNumber());
5445 letterMap.put("SINUM", ""+ injuryBean.getSocInsNumber());
5446 letterMap.put("CONTRIBUTORNAME",""+name);
5447 letterMap.put("DATEOFINJURY", "" + injuryDateStr);
5448 letterMap.put("REASONCODE", ""+reasonCode);
5449
5450 // These S.O.P is tp Test Dynamic Field Values for Master Data
5451 GOSIDebug.debugMessages("Field ESTABLISHMENTNAMEARB : "+ letterMap.get("ESTABLISHMENTNAMEARB"));
5452 GOSIDebug.debugMessages("Field REGNUM : "+ letterMap.get("REGNUM"));
5453 GOSIDebug.debugMessages("Field SINUM : " + letterMap.get("SINUM"));
5454 GOSIDebug.debugMessages("Field CONTRIBUTORNAME : "+ letterMap.get("CONTRIBUTORNAME"));
5455 GOSIDebug.debugMessages("Field DATEOFINJURY : "+ letterMap.get("DATEOFINJURY"));
5456 GOSIDebug.debugMessages("Field REASONCODE : "+ letterMap.get("REASONCODE"));
5457
5458 parameterList = new TreeMap();
5459 parameterList.put("1", letterMap);
5460 printSerialNumber = LetterUtilities.createSingleLetter(
5461 parameterList, letterHeader);
5462 GOSIDebug.debugMessages(" PRINT SERIAL NUMBER :"
5463 + printSerialNumber);
5464
5465 /*START of Notification Letter*/
5466 //Establishment:
5467 String longName = CommonTransactions.getTransactionLongName(GOSIConstants.OCCUPATIONAL_HAZARDS_ID, "MNT_INJURY");
5468 Long transactionId = CommonTransactions.getTransactionId(GOSIConstants.OCCUPATIONAL_HAZARDS_ID, "MNT_INJURY");
5469
5470 ArrayList identifiers = new ArrayList();
5471 identifiers.add(estBean.getRegistrationNumber());
5472 identifiers.add(SecurityAndWorkflowConstants.ESTABLISHMENT_ADMIN);
5473 identifiers.add(SecurityAndWorkflowConstants.OH_EMPLOYEE);
5474
5475 NotificationLetterBean objNotificationLetterBean = new NotificationLetterBean();
5476 objNotificationLetterBean.setPrintSerialNumber(printSerialNumber);
5477 objNotificationLetterBean.setNotificationTitle(GOSIErrorMessages.getErrorDesc("SOI_ERR_5757")+" "+injuryBean.getSocInsNumber());
5478 objNotificationLetterBean.setTransactionName(longName);
5479 objNotificationLetterBean.setTransactionID(transactionId);
5480 objNotificationLetterBean.setTargetUsers(GOSIConstants.GOL_GIVEN_REG_NUM_AND_ROLES.shortValue());
5481 objNotificationLetterBean.setIdentifiers(identifiers);
5482 objNotificationLetterBean.setCreatedBy(userId);
5483 objNotificationLetterBean.setIssuingFieldOffice(injuryBean.getFieldOfficeCode());
5484 objNotificationLetterBean.setReportID(letterHeader.getReportId());
5485 GOSIUtilities.sendNotificationLetter(GOSIConstants.OCCUPATIONAL_HAZARDS_ID, objNotificationLetterBean);
5486
5487 /*END*/
5488 }
5489 catch (GOSIException ge)
5490 {
5491 throw ge;
5492 }
5493 catch(Exception se)
5494 {
5495 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
5496 GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
5497 "generateLetter()", se, "CMN_ERR_1000");
5498 }
5499
5500 }
5501
5502 /**
5503 * @METHOD NAME : canChangeWageStopDate
5504 * @INFORMATION : This method is to check whether WageStopDate can be
5505 changed , will throw an exception if the benefit is already paid
5506 * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.AddInjuryHelperBean
5507 * @RETURN : void
5508 * @EXCEPTION : class gosi.core.util.GOSIException
5509 * @LAST MODIFIED BY :
5510 * @LAST MODIFIED DATE :
5511 **/
5512
5513 private void canChangeWageStopDate(Long injuryId)throws GOSIException
5514 {
5515 PreparedStatement ps = null;
5516 ResultSet rs = null;
5517 boolean canChangeWageStopDate = false;
5518 try
5519 {
5520 // Query to check if oh benefit has been calculated or not
5521 // if oh benefit is calculated the wage stop date shd
5522 // not be modified
5523 String sqlQuery = " select OHBENID from "+
5524 SITables.T_OHBENEFIT +
5525 " where INJURYID = ? "+
5526 " and BENSTATUS != ? ";
5527 conn = GOSIUtilities.getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
5528 ps = conn.prepareStatement(sqlQuery);
5529 ps.setLong(1,injuryId.longValue());
5530 ps.setShort(2,OHConstants.OH_BNFT_STS_CANCELLED.shortValue());
5531 rs = ps.executeQuery();
5532 if(rs.next())
5533 {
5534 canChangeWageStopDate = true;
5535 }
5536 if(canChangeWageStopDate)
5537 {
5538 //Cannot modify the wage stop date as oh benefit has been calculated
5539 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
5540 GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
5541 "canChangeWageStopDate()",null,"SOI_ERR_5524");
5542 }
5543 }
5544 catch (GOSIException ge)
5545 {
5546 throw ge;
5547 }
5548 catch(Exception se)
5549 {
5550 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
5551 GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
5552 "canChangeWageStopDate()", se, "CMN_ERR_1000");
5553 }
5554 finally
5555 {
5556 GOSIUtilities.cleanUp(conn,ps,rs);
5557 }
5558 }
5559
5560 /**
5561 * @METHOD NAME : searchPersonDetailsListTerminatedWorker
5562 * @INFORMATION : This method is to check wheather an injury has been booked for this person on this day
5563 * @PARAM : class java.lang.Long,
5564 class java.sql.Timestamp
5565 * @RETURN : void
5566 * @EXCEPTION : class gosi.core.util.GOSIException
5567 * @LAST MODIFIED BY :
5568 * @LAST MODIFIED DATE :
5569 **/
5570 public void isInjuryAlreadyEntered(Long socInsNumber, Timestamp injuryDate)
5571 throws GOSIException
5572 {
5573 PreparedStatement ps = null;
5574 ResultSet rs = null;
5575 try
5576 {
5577 // this method checks whether an injury has already been entered
5578 // or not checks for any injury with same sin and injury date
5579 String sqlQuery = " select INJURYID from "+
5580 SITables.T_INJURY + " where INJURYSTATUS != ? "+
5581 " and SOCINSNUMBER = ? and INJURYDATE = ? ";
5582 conn = GOSIUtilities.
5583 getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
5584 ps=conn.prepareStatement(sqlQuery);
5585 ps.setShort(1,OHConstants.INJ_STS_CANCELLED.shortValue());
5586 ps.setLong(2,socInsNumber.longValue());
5587 ps.setTimestamp(3,injuryDate);
5588 rs = ps.executeQuery();
5589 if(rs.next())
5590 {
5591 //SOI_ERR_5018
5592 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
5593 GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
5594 "isInjuryAlreadyEntered()", null,"SOI_ERR_5018");
5595 }
5596 }
5597 catch (GOSIException ge)
5598 {
5599 throw ge;
5600 }
5601 catch(Exception se)
5602 {
5603 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
5604 GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
5605 "isInjuryAlreadyEntered()", se, "CMN_ERR_1000");
5606 }
5607 finally
5608 {
5609 GOSIUtilities.cleanUp(conn,ps,rs);
5610 }
5611 }
5612
5613
5614 /**
5615 * @METHOD NAME : isComplicationAlreadyEntered
5616 * @INFORMATION : This method is to check if the complication is already entered or not
5617 * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.AddInjuryHelperBean
5618 * @RETURN : void
5619 * @EXCEPTION : class gosi.core.util.GOSIException
5620 * @LAST MODIFIED BY :
5621 * @LAST MODIFIED DATE :
5622 **/
5623 public void isComplicationAlreadyEntered(AddInjuryHelperBean injuryBean)
5624 throws GOSIException
5625 {
5626 PreparedStatement ps = null;
5627 ResultSet rs = null;
5628 try
5629 {
5630 // this method checks whether an injury has already been entered
5631 // or not checks for any injury with same sin and complication date
5632 String sqlQuery = " select INJURYID from "+
5633 SITables.T_INJURY + " where INJURYSTATUS != ? "+
5634 " and SOCINSNUMBER = ? and INJURYDATE = ? and DATECOMPLICATION = ? ";
5635 conn = GOSIUtilities.
5636 getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
5637 ps=conn.prepareStatement(sqlQuery);
5638 ps.setShort(1,OHConstants.INJ_STS_CANCELLED.shortValue());
5639 ps.setLong(2,injuryBean.getSocInsNumber().longValue());
5640 ps.setTimestamp(3,injuryBean.getInjuryDate());
5641 ps.setTimestamp(4,injuryBean.getDateComplication());
5642 rs = ps.executeQuery();
5643 if(rs.next())
5644 {
5645 //SOI_ERR_5018
5646 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
5647 GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
5648 "isInjuryAlreadyEntered()", null,"SOI_ERR_5018");
5649 }
5650 }
5651 catch (GOSIException ge)
5652 {
5653 throw ge;
5654 }
5655 catch(Exception se)
5656 {
5657 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
5658 GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
5659 "isInjuryAlreadyEntered()", se, "CMN_ERR_1000");
5660 }
5661 finally
5662 {
5663 GOSIUtilities.cleanUp(conn,ps,rs);
5664 }
5665 }
5666
5667 /**
5668 * @METHOD NAME : getParentInjuryStatus
5669 * @INFORMATION : This method is to get the injurystatus of the parent injury for which the complication is being entered
5670 * @PARAM : class java.lang.Long
5671 * @RETURN : class java.lang.Short
5672 * @EXCEPTION : class gosi.core.util.GOSIException
5673 * @LAST MODIFIED BY :
5674 * @LAST MODIFIED DATE :
5675 **/
5676
5677 private Short getParentInjuryStatus(Long injuryNumber) throws GOSIException
5678 {
5679 PreparedStatement ps = null;
5680 ResultSet rs = null;
5681 Short injuryStatus = null;
5682 try
5683 {
5684 String sqlQuery = "select INJURYSTATUS from "
5685 + SITables.T_INJURY
5686 + " where INJURYNUMBER = ? "
5687 + " and DATECOMPLICATION is null ";
5688
5689 conn = GOSIUtilities.getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
5690 ps = conn.prepareStatement(sqlQuery);
5691 ps.setLong(1,injuryNumber.longValue());
5692
5693 rs = ps.executeQuery();
5694 if(rs.next())
5695 {
5696 injuryStatus = new Short (rs.getShort("INJURYSTATUS"));
5697 }
5698 }
5699 catch (GOSIException ge)
5700 {
5701 throw ge;
5702 }
5703 catch(Exception se)
5704 {
5705 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
5706 GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
5707 "getParentInjuryStatus()", se, "CMN_ERR_1000");
5708 }
5709 finally
5710 {
5711 GOSIUtilities.cleanUp(conn,ps,rs);
5712 }
5713 return injuryStatus;
5714 }
5715
5716 /**
5717 * @METHOD NAME : generateLetterHospital
5718 * @INFORMATION : This method is to generate Letter to hospital when injury is rejected
5719 * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.AddInjuryHelperBean
5720 * @RETURN : void
5721 * @EXCEPTION : class gosi.core.util.GOSIException
5722 * @LAST MODIFIED BY :
5723 * @LAST MODIFIED DATE :
5724 **/
5725 private void generateLetterHospital(AddInjuryHelperBean injuryBean)
5726 throws GOSIException
5727 {
5728 LetterHeaderBean letterHeader = null;
5729 HashMap letterMap=null;
5730 TreeMap parameterList = null;
5731 long printSerialNumber = 0;
5732 Long contactId = null;
5733 String injuryDateStr = "";
5734 Short partialDisablity = OHConstants.INJ_STS_CURED_WITH_DISABILITY;
5735 Long userId= null;
5736 String patientNumber = "";
5737
5738
5739 try
5740 {
5741 // method to generate letter during rejection of injury
5742 GOSIDebug.debugMessages("-----------GENERATE LTTER--------------------");
5743 GOSIDebug.debugMessages("Social Insurance Number:"+injuryBean.getSocInsNumber());
5744 GOSIDebug.debugMessages("EstablishmentId:"+injuryBean.getEstablishmentId());
5745
5746 Timestamp injuryDate = null;
5747 if(injuryBean.getDateComplication()!=null)
5748 {
5749 injuryDate = injuryBean.getDateComplication();
5750 }else
5751 {
5752 injuryDate = injuryBean.getInjuryDate();
5753 }
5754 injuryDateStr = OHUtilities.getDateStr(injuryDate,OHConstants.GREGORIAN);
5755
5756 EstablishmentBean estBean = EstablishmentUtility.
5757 getEstablishmentDetails(injuryBean.getEstablishmentId().longValue(),
5758 false,true);
5759
5760 EstablishmentBean hospitalBean = EstablishmentUtility.
5761 getEstablishmentDetails(injuryBean.getHospitalCode().longValue(),
5762 true,false);
5763 contactId = hospitalBean.getEstablishmentContactId();
5764
5765 ContributorBean conBean = ContributorUtilities.displayContributorForSIN
5766 (injuryBean.getSocInsNumber());
5767 PersonBean personBean = PersonUtilities.displayPerson(conBean.getPersonId());
5768
5769 String name = personBean.getFirstName();
5770 if(personBean.getSecondName()!= null)
5771 {
5772 name = name + " " + personBean.getSecondName();
5773 }
5774 if(personBean.getThirdName()!= null)
5775 {
5776 name = name + " " + personBean.getThirdName();
5777 }
5778 if(personBean.getSurName()!= null)
5779 {
5780 name = name + " " + personBean.getSurName();
5781 }
5782 String reasonCode = "";
5783 if(injuryBean.getRejectionCode()!=null)
5784 {
5785 reasonCode = GOSIUtilities.getDomainDesc("OH Rejection Code",
5786 injuryBean.getRejectionCode().shortValue(),true);
5787 }
5788 patientNumber = getPatientNumber(injuryBean.getInjuryId());
5789 if(injuryBean.getLastModifiedBy()!=null)
5790 {
5791 userId = injuryBean.getLastModifiedBy();
5792 }else
5793 {
5794 userId = injuryBean.getCreatedBy();
5795 }
5796
5797 letterHeader = new LetterHeaderBean();
5798 letterHeader.setRequestedBy(userId);
5799 letterHeader.setReportId("16_02_0021");
5800 letterHeader.setLetterStatusFlag(new Short("5"));
5801 letterHeader.setRecordId(""+injuryBean.getInjuryId());
5802
5803 letterHeader.setFieldOfficeCode(
5804 injuryBean.getFieldOfficeCode());
5805
5806 letterMap = new HashMap();
5807
5808 letterHeader.setStakeHolders(new Short(
5809 ReportConstants.STAKE_HOLDER_REG_HOSPITAL),
5810 contactId,
5811 injuryBean.getSocInsNumber().toString());
5812
5813 letterMap.put("HOSPITALNAME", ""+hospitalBean.getEstablishmentNameArb());
5814 letterMap.put("ESTABLISHMENTNAMEARB", ""+estBean.getEstablishmentNameArb());
5815 letterMap.put("REGNUM",""+estBean.getRegistrationNumber());
5816 letterMap.put("SINUM", ""+ injuryBean.getSocInsNumber());
5817 letterMap.put("CONTRIBUTORNAME",""+name);
5818 letterMap.put("DATEOFINJURY", "" + injuryDateStr);
5819 letterMap.put("REASONCODE", ""+reasonCode);
5820 letterMap.put("PATIENTNUMBER", ""+patientNumber);
5821
5822 // These S.O.P is tp Test Dynamic Field Values for Master Data
5823 GOSIDebug.debugMessages("Field ESTABLISHMENTNAMEARB : "+ letterMap.get("ESTABLISHMENTNAMEARB"));
5824 GOSIDebug.debugMessages("Field REGNUM : "+ letterMap.get("REGNUM"));
5825 GOSIDebug.debugMessages("Field SINUM : " + letterMap.get("SINUM"));
5826 GOSIDebug.debugMessages("Field CONTRIBUTORNAME : "+ letterMap.get("CONTRIBUTORNAME"));
5827 GOSIDebug.debugMessages("Field DATEOFINJURY : "+ letterMap.get("DATEOFINJURY"));
5828 GOSIDebug.debugMessages("Field REASONCODE : "+ letterMap.get("REASONCODE"));
5829 GOSIDebug.debugMessages("Field PATIENTNUMBER : "+ letterMap.get("PATIENTNUMBER"));
5830
5831 parameterList = new TreeMap();
5832 parameterList.put("1", letterMap);
5833 printSerialNumber = LetterUtilities.createSingleLetter(
5834 parameterList, letterHeader);
5835 GOSIDebug.debugMessages(" PRINT SERIAL NUMBER :"
5836 + printSerialNumber);
5837
5838 /*Start Notification Letter*/
5839 String longName = CommonTransactions.getTransactionLongName(GOSIConstants.OCCUPATIONAL_HAZARDS_ID, "MNT_INJURY");
5840 Long transactionId = CommonTransactions.getTransactionId(GOSIConstants.OCCUPATIONAL_HAZARDS_ID, "MNT_INJURY");
5841
5842 ArrayList identifiers = new ArrayList();
5843 identifiers.add( injuryBean.getHospitalCode());
5844 identifiers.add(SecurityAndWorkflowConstants.HOSPITAL_EMPLOYEE);
5845 identifiers.add(SecurityAndWorkflowConstants.HOSPITAL_ADMIN);
5846
5847 //Hospital:
5848 NotificationLetterBean objNotificationLetterBean2 = new NotificationLetterBean();
5849 objNotificationLetterBean2.setPrintSerialNumber(printSerialNumber);
5850 objNotificationLetterBean2.setNotificationTitle(GOSIErrorMessages.getErrorDesc("SOI_ERR_5757")+" "+injuryBean.getSocInsNumber());
5851 objNotificationLetterBean2.setTransactionName(longName);
5852 objNotificationLetterBean2.setTransactionID(transactionId);
5853 objNotificationLetterBean2.setTargetUsers(GOSIConstants.GOL_GIVEN_REG_NUM_AND_ROLES.shortValue());
5854 objNotificationLetterBean2.setIdentifiers(identifiers);
5855 objNotificationLetterBean2.setCreatedBy(userId);
5856 objNotificationLetterBean2.setIssuingFieldOffice(injuryBean.getFieldOfficeCode());
5857 objNotificationLetterBean2.setReportID(letterHeader.getReportId());
5858 GOSIUtilities.sendNotificationLetter(GOSIConstants.OCCUPATIONAL_HAZARDS_ID, objNotificationLetterBean2);
5859 /*End*/
5860 }
5861 catch (GOSIException ge)
5862 {
5863 throw ge;
5864 }
5865 catch(Exception se)
5866 {
5867 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
5868 GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
5869 "generateLetterHospital()", se, "CMN_ERR_1000");
5870 }
5871
5872 }
5873 /**
5874 * @METHOD NAME : getPatientNumber
5875 * @INFORMATION : This method is to get Patient Number
5876 * @PARAM : class java.lang.Long
5877 * @RETURN : class java.lang.String
5878 * @EXCEPTION : class gosi.core.util.GOSIException
5879 * @LAST MODIFIED BY :
5880 * @LAST MODIFIED DATE :
5881 **/
5882 private String getPatientNumber(Long injuryID)throws GOSIException
5883 {
5884 PreparedStatement ps = null;
5885 ResultSet rs = null;
5886 String patientNumber = "";
5887 String sqlQuery="";
5888 try
5889 {
5890 sqlQuery=" SELECT PATIENTNUMBER FROM T_TREATMENT WHERE INJURYID =?";
5891 GOSIDebug.debugMessages("SQLQuery:" + sqlQuery + ":");
5892 GOSIDebug.debugMessages("\t\t Param 1 :" +injuryID+ ":");
5893 ps = conn.prepareStatement(sqlQuery);
5894 ps.setLong(1,injuryID.longValue());
5895 rs = ps.executeQuery();
5896
5897 if(rs.next())
5898 {
5899 patientNumber=rs.getString("PATIENTNUMBER");
5900 }
5901
5902 }
5903 catch(Exception e)
5904 {
5905 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
5906 GOSIConstants.SOCIAL_INSURANCE,
5907 this.getClass().toString(),
5908 "getPatientNumber()",
5909 e,"CMN_ERR_1000");
5910 }
5911 finally
5912 {
5913 GOSIUtilities.cleanUp(ps,rs);
5914 }
5915 return patientNumber;
5916 }
5917 /**
5918 * @METHOD NAME : getContributorDetails
5919 * @INFORMATION : This method is to get Contributor details
5920 * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.AddInjuryHelperBean
5921 * @RETURN : void
5922 * @EXCEPTION : class gosi.core.util.GOSIException
5923 * @LAST MODIFIED BY :
5924 * @LAST MODIFIED DATE :
5925 **/
5926
5927 public ArrayList getContributorDetails (AddInjuryHelperBean injuryListBean)
5928 throws GOSIException
5929 {
5930 ArrayList personArrayList = new ArrayList();
5931 PreparedStatement ps = null;
5932 ResultSet rsCommon = null;
5933 try
5934 {
5935 ContributorBean contributorBean = ContributorUtilities.
5936 displayContributorForSIN(injuryListBean.getSocInsNumber());
5937 PersonBean personBean = PersonUtilities.
5938 displayPerson(contributorBean.getPersonId());
5939 //injuryListBean =new AddInjuryHelperBean();
5940 String finalName=personBean.getFirstName();
5941 if(personBean.getSecondName()!= null &&
5942 !"".equals(personBean.getSecondName()))
5943 {
5944 finalName = finalName+ " "+personBean.getSecondName();
5945 }
5946 if(personBean.getThirdName()!= null &&
5947 !"".equals(personBean.getThirdName()))
5948 {
5949 finalName = finalName+ " "+personBean.getThirdName();
5950 }
5951 if(personBean.getSurName()!= null &&
5952 !"".equals(personBean.getSurName()))
5953 {
5954 finalName = finalName+ " "+personBean.getSurName();
5955 }
5956 injuryListBean.setName(finalName);
5957 injuryListBean.setNationalityCode(personBean.getNationalityCode());
5958 injuryListBean.setContactId(contributorBean.getContactId());
5959 injuryListBean.setContributorId(contributorBean.getContributorId());
5960 //
5961 if(injuryListBean != null)
5962 {
5963 // query to get contributor preexisting deformities
5964 String strQuery=OHQueryInjury.OhQry_QRY_00077 ;
5965 conn = GOSIUtilities.getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
5966 ps=conn.prepareStatement(strQuery);
5967 ps.setLong(1,injuryListBean.getContributorId().longValue());
5968 rsCommon=ps.executeQuery();
5969 GOSIDebug.debugMessages(""+strQuery);
5970 if(rsCommon.next())
5971 {
5972 injuryListBean.setPreExistDeformitiesId(new Long(
5973 rsCommon.getLong("PREEXISTINGDEFORMITIESID")));
5974 injuryListBean.setPreviousNonOH(
5975 rsCommon.getString("PREEXISTINGDEFORMITIES"));
5976 }
5977 }
5978 personArrayList.add(injuryListBean);
5979 }
5980 catch (GOSIException ge)
5981 {
5982 throw ge;
5983 }
5984 catch (Exception e)
5985 {
5986 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
5987 GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
5988 "getContributorDetails()", e, "CMN_ERR_1000");
5989
5990 }
5991 finally
5992 {
5993 GOSIUtilities.cleanUp(conn,ps,rsCommon);
5994 }
5995 return personArrayList;
5996 }
5997
5998 private boolean isRegisteredHospital(Long hospitalCode)
5999 throws GOSIException
6000 {
6001 boolean isRegistered = false;
6002 Connection con = null;
6003 PreparedStatement ps = null;
6004 ResultSet rs = null;
6005 String sqlQuery = null;
6006 sqlQuery = " SELECT HOSPITALTYPE ";
6007 sqlQuery += " FROM " + SITables.T_HOSPITAL;
6008 sqlQuery += " WHERE HOSPITALCODE = ? " ;
6009
6010 try
6011 {
6012 GOSIDebug.debugMessages("SQLQuery:" + sqlQuery + ":");
6013 GOSIDebug.debugMessages("\t\t Param 1 :" + hospitalCode.longValue() + ":");
6014 con = GOSIUtilities.getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
6015 ps = con.prepareStatement(sqlQuery);
6016 ps.setLong(1,hospitalCode.longValue());
6017 rs = ps.executeQuery();
6018 if(rs.next())
6019 {
6020 if(OHConstants.REG_HOSPITAL.equals(new Short(rs.getShort("HOSPITALTYPE"))))
6021 {
6022 isRegistered = true;
6023 }
6024 }
6025 GOSIDebug.debugMessages("isRegisteredHospital:" + isRegistered + ":");
6026 return isRegistered;
6027 }
6028 catch (Exception e)
6029 {
6030 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
6031 GOSIConstants.SOCIAL_INSURANCE,
6032 this.getClass().toString(),
6033 "isRegisteredHospital()",e,"CMN_ERR_1000");
6034 }
6035 finally
6036 {
6037 GOSIUtilities.cleanUp(con,ps,rs);
6038 }
6039
6040 }
6041
6042 /**
6043 * @METHOD NAME : getTotalOfInjuryThisYear
6044 * @INFORMATION : his method is to get Total of Injury occured This Year except compliaction.
6045 * @PARAM : class java.lang.Long
6046 * @RETURN : class java.lang.Short
6047 * @EXCEPTION : class gosi.core.util.GOSIException
6048 * @LAST MODIFIED BY :
6049 * @LAST MODIFIED DATE :
6050 **/
6051
6052 private Short getTotalOfInjuryThisYear(Long socialInsuranceNumber) throws GOSIException
6053 {
6054 PreparedStatement ps =null;
6055 ResultSet rsCommon =null;
6056 Calendar rightNow = Calendar.getInstance();
6057 String countQuery="";
6058 Short totalInjury=null;
6059 //Query to get number of injury occured from begining of the current year
6060 countQuery = " SELECT COUNT(*) TOTALINJURY FROM T_INJURY "
6061 +" WHERE SOCINSNUMBER=? AND INJURYDATE>=? AND DATECOMPLICATION IS NULL";
6062 try
6063 {
6064 conn = GOSIUtilities.getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
6065 GOSIDebug.debugMessages(""+countQuery);
6066 ps=conn.prepareStatement(countQuery);
6067 GOSIDebug.debugMessages("socinsnumber:"+socialInsuranceNumber);
6068 GOSIDebug.debugMessages("Current Year :"+rightNow.get(Calendar.YEAR));
6069 ps.setLong(1,socialInsuranceNumber.longValue());
6070 ps.setTimestamp(2,new Timestamp (rightNow.get(Calendar.YEAR)-1900,0,1,0,0,0,0));
6071 rsCommon=ps.executeQuery();
6072 while(rsCommon.next())
6073 {
6074 totalInjury = new Short (rsCommon.getShort("TOTALINJURY"));
6075 }
6076 return totalInjury;
6077 }
6078 catch (GOSIException ge)
6079 {
6080 throw ge;
6081 }
6082 catch(Exception se)
6083 {
6084 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
6085 GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
6086 "getTotalInjuryThisYear()", se, "CMN_ERR_1000");
6087 }
6088 finally
6089 {
6090 GOSIUtilities.cleanUp(ps,rsCommon);
6091 }
6092 }
6093
6094 /**
6095 * @METHOD NAME : resumeTreatmetRequest
6096 * @INFORMATION : This method is to insert resume treatment request for closed injury
6097 * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.ResumeBean
6098 * @RETURN : void
6099 * @EXCEPTION : class gosi.core.util.GOSIException
6100 * @LAST MODIFIED BY :
6101 * @LAST MODIFIED DATE :
6102 **/
6103
6104 public void resumeTreatmetRequest(ResumeBean resumeBean)
6105 throws GOSIException
6106 {
6107
6108 try
6109 {
6110 long startTime = 0;
6111 long endTime = 0;
6112 long elapsedTime = 0;
6113 startTime = System.currentTimeMillis();
6114 // inserting resume treatment request for closed injury
6115 ResumeTreatmentEntityHome home=(ResumeTreatmentEntityHome)
6116 ServiceLocator.getInstance().getRemoteHome(
6117 OHConstants.RESUMETREATMET_ENTITY_JNDI,
6118 ResumeTreatmentEntityHome.class);
6119 GOSIDebug.debugMessages("Inside Resume treatment request:");
6120
6121 if(resumeBean !=null)
6122 {
6123 resumeBean.setResumeId(
6124 GOSIUtilities.getPrimaryKey("T_RESUMETREATMENT",
6125 resumeBean.getCreatedBy()));
6126 resumeBean.setCreationTimestamp(
6127 new Timestamp(System.currentTimeMillis()));
6128
6129 // inserting resume treatment request for closed injury into the db
6130 ResumeTreatmentEntity remote=(ResumeTreatmentEntity)home.
6131 create(resumeBean);
6132
6133 }
6134 endTime = System.currentTimeMillis();
6135 elapsedTime = endTime - startTime;
6136 GOSIInstrumentationLog.writeInstrumentationToLog(
6137 this.getClass().toString(),
6138 "resumeTreatmetRequest()",
6139 elapsedTime);
6140
6141 }
6142 catch (GOSIException ge)
6143 {
6144 throw ge;
6145 }
6146 catch(Exception e)
6147 {
6148 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
6149 GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
6150 "resumeTreatmetRequest()", e, "CMN_ERR_1000" );
6151 }
6152 }
6153 /**
6154 * @METHOD NAME : changeRegNo
6155 * @INFORMATION : This method is to change the regestiration number for contributor
6156 * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.ChangeRegNoBean
6157 * class gosi.core.workflow.beans.WorkflowParamBean
6158 * @RETURN : class gosi.business.socialinsurance.occupationalhazards.injury.beans.ChangeRegNoBean
6159 * @EXCEPTION : class gosi.core.util.GOSIException
6160 * @LAST MODIFIED BY : PRD00008536
6161 * @LAST MODIFIED DATE :
6162 **/
6163
6164 public ChangeRegNoBean changeRegNo (ChangeRegNoBean selectedRegBean,WorkflowParamBean workflowParamBean)
6165 throws GOSIException
6166 {
6167 Connection con = null;
6168 PreparedStatement ps = null;
6169 ResultSet rs = null;
6170 String sqlQuery="";
6171 String message="";
6172 ChangeRegNoBean regBean= selectedRegBean;
6173 try
6174 {
6175 con = GOSIUtilities.getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
6176
6177 // check the record is participating in workflow. Throw error if there is a workitem for the same injury
6178 sqlQuery = "SELECT * FROM T_OHESTCHANGES WHERE INJURYID = ?";
6179 ps = con.prepareStatement(sqlQuery);
6180
6181 ps.setLong(1,regBean.getInjuryId().longValue());
6182 rs = ps.executeQuery();
6183
6184 if(rs.next()){
6185 //The Establishment change cannot occur because it's already done
6186 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
6187 GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
6188 "changeRegNo()",null,"SOI_ERR_5605");
6189 }
6190
6191 // check the record is participating in workflow. Throw error if there is a workitem for the same injury
6192 sqlQuery = "SELECT * FROM T_OHBENEFIT WHERE INJURYID = ? AND BENSTATUS =? ";
6193 ps = con.prepareStatement(sqlQuery);
6194 ps.setLong(1,regBean.getInjuryId().longValue());
6195 ps.setShort(2,OHConstants.OH_BNFT_STS_ENTERED.shortValue());
6196 rs = ps.executeQuery();
6197
6198 if(rs.next()){
6199 //There are benefits in workflow for this injury
6200 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
6201 GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
6202 "changeRegNo()",null,"SOI_ERR_5607");
6203 }
6204
6205 //clear resultset and preparestatement
6206 GOSIUtilities.cleanUp(ps,rs);
6207
6208
6209 regBean.setEstChangeId(GOSIUtilities.getPrimaryKey("T_ohestchanges",regBean.getCreatedBy()));
6210 GOSIDebug.debugMessages("\t\t Param 1 InjuryId:" + regBean.getInjuryId().longValue() + ":");
6211 GOSIDebug.debugMessages("\t\t Param 2 EstChangeId:" + regBean.getEstChangeId().longValue() + ":");
6212 sqlQuery = "SELECT CONTRIBUTORID,ESTABLISHMENTID,INJURYNUMBER,SOCINSNUMBER " ;
6213 sqlQuery += " FROM "+ SITables.T_INJURY;
6214 sqlQuery += " WHERE injuryid = ? ";
6215
6216
6217
6218 GOSIDebug.debugMessages("SQLQuery:" + sqlQuery + ":");
6219 GOSIDebug.debugMessages("\t\t Param 1 :" + regBean.getInjuryId().longValue() + ":");
6220
6221 ps = con.prepareStatement(sqlQuery);
6222 ps.setLong(1,regBean.getInjuryId().longValue());
6223 rs = ps.executeQuery();
6224 if(rs.next())
6225 {
6226 regBean.setOldEstablishmentId(new Long(rs.getLong("ESTABLISHMENTID")));
6227 regBean.setSocInsNumber(new Long(rs.getLong("SOCINSNUMBER")));
6228 regBean.setInjuryNumber(new Long(rs.getLong("INJURYNUMBER")));
6229 regBean.setContributorId(new Long(rs.getLong("CONTRIBUTORID")));
6230
6231 }
6232 String stepShortName =workflowParamBean.getStepShortName();
6233 String routingCriterion =workflowParamBean.getRoutingCriterion();
6234
6235 if (stepShortName.equals("ADD_CHANGE_REG_NUMBER"))
6236 {
6237 if(OHConstants.COMPLETED.equals(routingCriterion))
6238 {
6239 regBean.setStatus(OHConstants.REG_NUMBER_CHANGE_ENTERED);
6240 regBean.setWorkflowStatus(OHConstants.WFS_REG_NUMBER_CHANGE_ENTERED_BY_SUPERVISOR);
6241 }
6242 }
6243
6244 regBean.setCreationTimestamp(new Timestamp(System.currentTimeMillis()));
6245
6246 EstablishmentBean oldEstBean = EstablishmentUtility.
6247 getEstablishmentDetails(regBean.getOldEstablishmentId().longValue(),
6248 false,true);
6249
6250 EstablishmentBean newEstBean = EstablishmentUtility.
6251 getEstablishmentDetails(regBean.getNewEstablishmentId().longValue(),
6252 false,true);
6253
6254 ContributorBean contributorBean = ContributorUtilities.
6255 displayContributorForSIN(regBean.getSocInsNumber());
6256 PersonBean personBean = PersonUtilities.
6257 displayPerson(contributorBean.getPersonId());
6258 String finalName=personBean.getFullName();
6259 regBean.setName(finalName);
6260
6261
6262
6263 GOSIDebug.debugMessages("Old Establishmentid==============>:" + oldEstBean.getEstablishmentNameArb() + ":");
6264 GOSIDebug.debugMessages("New Establishmentid==============>:" + newEstBean.getEstablishmentNameArb() + ":");
6265
6266 OHestChangesEntityHome home=getOHestChangesHome();
6267 OHestChangesEntity oOHestChangesEntity = (OHestChangesEntity)home.create(regBean);
6268
6269 regBean.setOldEstablishmentName(oldEstBean.getEstablishmentNameArb() );
6270 regBean.setOldEstablishmentNumber(oldEstBean.getRegistrationNumber() );
6271 regBean.setNewEstablishmentName(newEstBean.getEstablishmentNameArb() );
6272 regBean.setNewEstablishmentNumber(newEstBean.getRegistrationNumber() );
6273
6274
6275 GOSIDebug.debugMessages("Old Establishmentid After Sitting in the Bean==============>:" + regBean.getOldEstablishmentName () + ":");
6276 GOSIDebug.debugMessages("New Establishmentid After Sitting in the Bean==============>:" + regBean.getNewEstablishmentName () + ":");
6277 GOSIDebug.debugMessages("InjuryNumber After Sitting in the Bean=====================>:" + regBean.getInjuryNumber() + ":");
6278
6279 workflowParamBean.setPrimaryKeyOfTherecord(regBean.getEstChangeId().toString());
6280 String userName=GOSIUtilities.startWorkflow(workflowParamBean);
6281 message = GOSIErrorMessages.getErrorDesc("SOI_ERR_5615")+""+userName ;
6282
6283 }
6284 catch (GOSIException ge)
6285 {
6286 GOSIDebug.debugMessages("SESSION:changeRegNo:ge:"+ge);
6287 sesCtx.setRollbackOnly();
6288 throw ge;
6289 }
6290 catch (Exception e)
6291 {
6292 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
6293 GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
6294 "changeRegNo()",e, "CMN_ERR_1000");
6295
6296 }
6297 finally
6298
6299 {
6300 GOSIUtilities.cleanUp(con,ps,rs);
6301 }
6302
6303 return regBean;
6304
6305 }
6306 /**
6307 * @METHOD NAME : getModifiedEstablishmentDetails
6308 * @INFORMATION : This method is to get details about modified establishment
6309 * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.ChangeRegNoBean
6310 * @RETURN : class gosi.business.socialinsurance.occupationalhazards.injury.beans.ChangeRegNoBean
6311 * @EXCEPTION : class gosi.core.util.GOSIException
6312 * @LAST MODIFIED BY : PRD00008536
6313 * @LAST MODIFIED DATE :
6314 **/
6315
6316
6317 public ChangeRegNoBean getModifiedEstablishmentDetails (ChangeRegNoBean selectedRegBean)
6318 throws GOSIException
6319 {
6320 ChangeRegNoBean regBean= selectedRegBean;
6321 Connection con = null;
6322 PreparedStatement ps = null;
6323 ResultSet rs = null;
6324 String sqlQuery="";
6325 try
6326 {
6327 GOSIDebug.debugMessages("\t\t Param 2 EstChangeId:" + regBean.getEstChangeId().longValue() + ":");
6328 sqlQuery = " SELECT A.INJURYID,A.OLDESTABLISHMENTID,A.NEWESTABLISHMENTID,A.STATUS,A.WORKFLOWSTATUS,";
6329 sqlQuery += " B.SOCINSNUMBER,B.INJURYNUMBER,B.CONTRIBUTORID" ;
6330 sqlQuery += " FROM "+ SITables.T_OHESTCHANGES+" A,"+SITables.T_INJURY+" B ";
6331 sqlQuery += " WHERE A.INJURYID = B.INJURYID ";
6332 sqlQuery += " AND A.ESTCHANGESID = ? ";
6333
6334
6335
6336 GOSIDebug.debugMessages("SQLQuery:" + sqlQuery + ":");
6337 GOSIDebug.debugMessages("\t\t Param 1 :" + regBean.getEstChangeId().longValue() + ":");
6338 con = GOSIUtilities.getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
6339 ps = con.prepareStatement(sqlQuery);
6340 ps.setLong(1,regBean.getEstChangeId().longValue());
6341 rs = ps.executeQuery();
6342 if(rs.next())
6343 {
6344 regBean.setInjuryId(new Long(rs.getLong("INJURYID")));
6345 regBean.setOldEstablishmentId(new Long(rs.getLong("OLDESTABLISHMENTID")));
6346 regBean.setNewEstablishmentId(new Long(rs.getLong("NEWESTABLISHMENTID")));
6347 regBean.setStatus(new Short(rs.getShort("STATUS")));
6348 regBean.setWorkflowStatus(new Short(rs.getShort("WORKFLOWSTATUS")));
6349 regBean.setSocInsNumber(new Long(rs.getLong("SOCINSNUMBER")));
6350 regBean.setInjuryNumber(new Long(rs.getLong("INJURYNUMBER")));
6351 regBean.setContributorId(new Long(rs.getLong("CONTRIBUTORID")));
6352
6353 }
6354 EstablishmentBean oldEstBean = EstablishmentUtility.
6355 getEstablishmentDetails(regBean.getOldEstablishmentId().longValue(),
6356 false,true);
6357
6358 EstablishmentBean newEstBean = EstablishmentUtility.
6359 getEstablishmentDetails(regBean.getNewEstablishmentId().longValue(),
6360 false,true);
6361
6362 ContributorBean contributorBean = ContributorUtilities.
6363 displayContributorForSIN(regBean.getSocInsNumber());
6364 PersonBean personBean = PersonUtilities.
6365 displayPerson(contributorBean.getPersonId());
6366 String finalName=personBean.getFullName();
6367 regBean.setName(finalName);
6368 regBean.setOldEstablishmentName(oldEstBean.getEstablishmentNameArb() );
6369 regBean.setOldEstablishmentNumber(oldEstBean.getRegistrationNumber() );
6370 regBean.setNewEstablishmentName(newEstBean.getEstablishmentNameArb() );
6371 regBean.setNewEstablishmentNumber(newEstBean.getRegistrationNumber() );
6372
6373 GOSIDebug.debugMessages("Old Establishmentid After Sitting in the Bean==============>:" + regBean.getOldEstablishmentName () + ":");
6374 GOSIDebug.debugMessages("New Establishmentid After Sitting in the Bean==============>:" + regBean.getNewEstablishmentName () + ":");
6375 GOSIDebug.debugMessages("InjuryNumber After Sitting in the Bean=====================>:" + regBean.getInjuryNumber() + ":");
6376 GOSIDebug.debugMessages("Old Establishmentid==============>:" + oldEstBean.getEstablishmentNameArb() + ":");
6377 GOSIDebug.debugMessages("New Establishmentid==============>:" + newEstBean.getEstablishmentNameArb() + ":");
6378
6379
6380
6381 }
6382 catch (GOSIException ge)
6383 {
6384 GOSIDebug.debugMessages("SESSION:getModifiedEstablishmentDetails:ge:"+ge);
6385 sesCtx.setRollbackOnly();
6386 throw ge;
6387 }
6388 catch (Exception e)
6389 {
6390 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
6391 GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
6392 "getModifiedEstablishmentDetails()",e, "CMN_ERR_1000");
6393 }
6394 finally
6395
6396 {
6397 GOSIUtilities.cleanUp(con,ps,rs);
6398 }
6399
6400 return regBean;
6401
6402 }
6403
6404 /**
6405 * @METHOD NAME : saveChangeRegNo
6406 * @INFORMATION : This method is to change the registration number for contributor
6407 * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.ChangeRegNoBean
6408 * class gosi.core.workflow.beans.WorkflowParamBean
6409 * @RETURN : class java.lang.String
6410 * @EXCEPTION : class gosi.core.util.GOSIException
6411 * @LAST MODIFIED BY : PRD00008536
6412 * @LAST MODIFIED DATE :
6413 **/
6414
6415
6416 public String saveChangeRegNo (ChangeRegNoBean selectedRegBean,WorkflowParamBean workflowParamBean)
6417 throws GOSIException
6418 {
6419 Connection con = null;
6420 PreparedStatement ps = null;
6421 ResultSet rs = null;
6422 String sqlQuery="";
6423 DMSRequestHeaderBean headerBean = new DMSRequestHeaderBean();
6424 String message="";
6425 try
6426 {
6427 ChangeRegNoBean regBean= selectedRegBean;
6428 GOSIDebug.debugMessages("\t\t Param 2 EstChangeId:" + regBean.getEstChangeId().longValue() + ":");
6429 sqlQuery = "SELECT o.INJURYID, o.OLDESTABLISHMENTID,o.NEWESTABLISHMENTID,o.STATUS,o.WORKFLOWSTATUS, ";
6430 sqlQuery += "e.REGISTRATIONNUMBER,a.INJURYNUMBER,a.SOCINSNUMBER" ;
6431 sqlQuery += " FROM "+ SITables.T_OHESTCHANGES +" o,"+ SITables.T_ESTABLISHMENT +" e,"+ SITables.T_INJURY +" a";
6432 sqlQuery += " WHERE o.ESTCHANGESID = ? AND e.ESTABLISHMENTID = o.NEWESTABLISHMENTID AND a.INJURYID = o.INJURYID ";
6433
6434 GOSIDebug.debugMessages("SQLQuery:" + sqlQuery + ":");
6435 GOSIDebug.debugMessages("\t\t Param 1 :" + regBean.getEstChangeId().longValue() + ":");
6436 con = GOSIUtilities.getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
6437 ps = con.prepareStatement(sqlQuery);
6438 ps.setLong(1,regBean.getEstChangeId().longValue());
6439 rs = ps.executeQuery();
6440 if(rs.next())
6441 {
6442 regBean.setInjuryId(new Long(rs.getLong("INJURYID")));
6443 regBean.setOldEstablishmentId(new Long(rs.getLong("OLDESTABLISHMENTID")));
6444 regBean.setNewEstablishmentId(new Long(rs.getLong("NEWESTABLISHMENTID")));
6445 regBean.setNewRegistrationNumber(new Long(rs.getLong("REGISTRATIONNUMBER")));
6446 regBean.setStatus(new Short(rs.getShort("STATUS")));
6447 regBean.setWorkflowStatus(new Short(rs.getShort("WORKFLOWSTATUS")));
6448 regBean.setInjuryNumber(new Long(rs.getLong("INJURYNUMBER")));
6449 regBean.setSocInsNumber(new Long(rs.getLong("SOCINSNUMBER")));
6450 }
6451
6452
6453 GOSIDebug.debugMessages("OldEstablishmentId:" + regBean.getOldEstablishmentId() + ":");
6454
6455 AddInjuryHelperBean injuryBean =null;
6456 injuryBean = new AddInjuryHelperBean();
6457 injuryBean.setInjuryId(regBean.getInjuryId());
6458 injuryBean.setEstablishmentId(regBean.getNewEstablishmentId());
6459 injuryBean.setLastModifiedBy((regBean.getLastModifiedBy()));
6460 injuryBean.setLastModifiedTimestamp(new Timestamp(System.currentTimeMillis()));
6461
6462 GOSIDebug.debugMessages("NewEstablishmentId:" + injuryBean.getEstablishmentId() + ":");
6463 GOSIDebug.debugMessages("LastModifiedBy:" + injuryBean.getLastModifiedBy() + ":");
6464 GOSIDebug.debugMessages("LastModifiedTimestamp:" + injuryBean.getLastModifiedTimestamp() + ":");
6465
6466
6467 String stepShortName = workflowParamBean.getStepShortName();
6468 String routingCriterion = workflowParamBean.getRoutingCriterion();
6469 if (stepShortName.equals("VER_CHANGE_REG_NUMBER_OH_HEAD"))
6470 {
6471 if(OHConstants.COMPLETED.equals(routingCriterion))
6472 {
6473 regBean.setStatus(OHConstants.REG_NUMBER_CHANGE_APPROVED);
6474 regBean.setWorkflowStatus(OHConstants.WFS_REG_NUMBER_CHANGE_APPROVED_BY_OH_HEAD);
6475
6476 OHestChangesEntityHome home=getOHestChangesHome();
6477 OHestChangesEntity oOHestChangesEntity =(OHestChangesEntity)home.findByPrimaryKey (regBean.getEstChangeId());
6478 oOHestChangesEntity.updateStatusAndWorkflowStatus(regBean);
6479
6480 InjuryEntityHome injuryhome=getInjuryHome();
6481 InjuryEntity oInjuryEntity =(InjuryEntity)injuryhome.findByPrimaryKey
6482 (injuryBean.getInjuryId());
6483 oInjuryEntity.updateEstablishmentId(injuryBean);
6484
6485 workflowParamBean.setPrimaryKeyOfTherecord(regBean.getEstChangeId().toString());
6486
6487 headerBean.setTransactionStepName("ADD_OH_INJURY_MENU");
6488 headerBean.setSourceRecordId("" + regBean.getInjuryId());
6489 headerBean.setKeyList(DMSConstants.SI_NUMBER,"" + regBean.getSocInsNumber());
6490 headerBean.setKeyList(DMSConstants.REGISTRATION_NUMBER,"" + regBean.getNewRegistrationNumber());
6491 headerBean.setKeyList(DMSConstants.INJURY_NUMBER,"" + regBean.getInjuryNumber());
6492 headerBean.setModuleId(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
6493
6494 GOSIUtilities.updateScanReqDetails(headerBean);
6495
6496 GOSIUtilities.startWorkflow(workflowParamBean);
6497
6498 message = GOSIErrorMessages.getErrorDesc("SOI_ERR_5400");
6499 }
6500
6501 else if(OHConstants.REJECTED.equals(routingCriterion))
6502 {
6503
6504 regBean.setStatus(OHConstants.REG_NUMBER_CHANGE_REJECTED);
6505 regBean.setWorkflowStatus(OHConstants.WFS_REG_NUMBER_CHANGE_REJECTED_BY_OH_HEAD);
6506
6507 OHestChangesEntityHome home=getOHestChangesHome();
6508 OHestChangesEntity oOHestChangesEntity =(OHestChangesEntity)home.findByPrimaryKey (regBean.getEstChangeId());
6509 oOHestChangesEntity.updateStatusAndWorkflowStatus(regBean);
6510
6511 workflowParamBean.setPrimaryKeyOfTherecord(regBean.getEstChangeId().toString());
6512 String userName=GOSIUtilities.startWorkflow(workflowParamBean);
6513
6514 message = GOSIErrorMessages.getErrorDesc("SOI_ERR_5401")+""+userName;
6515
6516 }
6517 }
6518
6519
6520
6521 if (stepShortName.equals("REENTER_CHANGE_REG_NUMBER"))
6522 {
6523 if(OHConstants.COMPLETED.equals(routingCriterion))
6524 {
6525 regBean.setStatus(OHConstants.REG_NUMBER_CHANGE_ENTERED);
6526 regBean.setWorkflowStatus(OHConstants.WFS_REG_NUMBER_CHANGE_RENTERED_BY_SUPERVISOR);
6527
6528 OHestChangesEntityHome home=getOHestChangesHome();
6529 OHestChangesEntity oOHestChangesEntity =(OHestChangesEntity)home.findByPrimaryKey (regBean.getEstChangeId());
6530 oOHestChangesEntity.updateStatusAndWorkflowStatus(regBean);
6531
6532 workflowParamBean.setPrimaryKeyOfTherecord(regBean.getEstChangeId().toString());
6533 String userName=GOSIUtilities.startWorkflow(workflowParamBean);
6534
6535 message = GOSIErrorMessages.getErrorDesc("SOI_ERR_5402")+""+userName;;
6536 }
6537
6538 if(OHConstants.REJECTED.equals(routingCriterion))
6539 {
6540
6541 regBean.setStatus(OHConstants.REG_NUMBER_CHANGE_CANCELLED);
6542 regBean.setWorkflowStatus(OHConstants.WFS_REG_NUMBER_CHANGE_CANCELLED_BY_OH_SUPERVISOR);
6543
6544 OHestChangesEntityHome home=getOHestChangesHome();
6545 OHestChangesEntity oOHestChangesEntity =(OHestChangesEntity)home.findByPrimaryKey (regBean.getEstChangeId());
6546 oOHestChangesEntity.updateStatusAndWorkflowStatus(regBean);
6547
6548 workflowParamBean.setPrimaryKeyOfTherecord(regBean.getEstChangeId().toString());
6549 GOSIUtilities.startWorkflow(workflowParamBean);
6550
6551 message = GOSIErrorMessages.getErrorDesc("SOI_ERR_5608");
6552
6553 }
6554 }
6555
6556 }
6557 catch (GOSIException ge)
6558 {
6559 GOSIDebug.debugMessages("SESSION:saveChangeRegNo:ge:"+ge);
6560 sesCtx.setRollbackOnly();
6561 throw ge;
6562 }
6563 catch (Exception e)
6564 {
6565 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
6566 GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
6567 "saveChangeRegNo()",e, "CMN_ERR_1000");
6568 }
6569 finally
6570
6571 {
6572 GOSIUtilities.cleanUp(con,ps,rs);
6573 }
6574
6575 return message;
6576
6577 }
6578
6579 /**
6580 * @METHOD NAME : getInjuryDetials
6581 * @INFORMATION : This method is to get injury details
6582 * @PARAM : class java.lang.Long
6583 * @RETURN : class gosi.business.socialinsurance.occupationalhazards.injury.beans.AddInjuryHelperBean,
6584 * @EXCEPTION : class java.rmi.RemoteException,
6585 class gosi.core.util.GOSIException
6586 * @LAST MODIFIED BY : PRD00008536
6587 * @LAST MODIFIED DATE :
6588 **/
6589
6590 public AddInjuryHelperBean getInjuryDetails (Long estChangeId)
6591 throws GOSIException
6592{
6593 Connection con = null;
6594 PreparedStatement ps = null;
6595 ResultSet rs = null;
6596 String sqlQuery="";
6597 AddInjuryHelperBean injuryBean =null;
6598 try
6599 {
6600 injuryBean = new AddInjuryHelperBean();
6601
6602 sqlQuery = " SELECT B.INJURYDATE,B.SOCINSNUMBER,B.INJURYNUMBER,B.CONTRIBUTORID,B.ESTABLISHMENTID" ;
6603 sqlQuery += " FROM "+ SITables.T_OHESTCHANGES+" A,"+SITables.T_INJURY+" B ";
6604 sqlQuery += " WHERE A.INJURYID = B.INJURYID ";
6605 sqlQuery += " AND A.ESTCHANGESID = ? ";
6606
6607
6608 GOSIDebug.debugMessages("SQLQuery:" + sqlQuery + ":");
6609 GOSIDebug.debugMessages("\t\t Param 1 :" + estChangeId+ ":");
6610 con = GOSIUtilities.getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
6611 ps = con.prepareStatement(sqlQuery);
6612 ps.setLong(1,estChangeId.longValue());
6613 rs = ps.executeQuery();
6614 if(rs.next())
6615 {
6616 injuryBean.setInjuryDate(rs.getTimestamp("INJURYDATE"));
6617 injuryBean.setSocInsNumber(new Long(rs.getLong("SOCINSNUMBER")));
6618 injuryBean.setInjuryNumber(new Long(rs.getLong("INJURYNUMBER")));
6619 injuryBean.setContributorId(new Long(rs.getLong("CONTRIBUTORID")));
6620 injuryBean.setEstablishmentId(new Long(rs.getLong("ESTABLISHMENTID")));
6621 }
6622
6623 GOSIDebug.debugMessages("SocInsNumber After Sitting in the Bean==============>:" + injuryBean.getSocInsNumber () + ":");
6624 GOSIDebug.debugMessages("SocInsNumber After Sitting in the Bean==============>:" + injuryBean.getInjuryDate() + ":");
6625 GOSIDebug.debugMessages("InjuryNumber After Sitting in the Bean=====================>:" + injuryBean.getInjuryNumber() + ":");
6626 GOSIDebug.debugMessages("ContributorId After Sitting in the Bean=====================>:" + injuryBean.getContributorId() + ":");
6627 }
6628 catch (GOSIException ge)
6629 {
6630 GOSIDebug.debugMessages("SESSION:getInjuryDetials:ge:"+ge);
6631 sesCtx.setRollbackOnly();
6632 throw ge;
6633 }
6634 catch (Exception e)
6635 {
6636 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
6637 GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
6638 "getInjuryDetials()",e, "CMN_ERR_1000");
6639 }
6640 finally
6641
6642 {
6643 GOSIUtilities.cleanUp(con,ps,rs);
6644 }
6645 return injuryBean;
6646
6647}
6648
6649
6650 /**
6651 * @METHOD NAME : getinjuryBean
6652 * @INFORMATION : This method is to get injurydate or complication date
6653 * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.AddInjuryHelperBean
6654 * @RETURN : class java.util.ArrayList
6655 * @EXCEPTION : class java.rmi.RemoteException,
6656 class gosi.core.util.GOSIException
6657 * @LAST MODIFIED BY : PRD00008536
6658 * @LAST MODIFIED DATE :
6659 **/
6660
6661
6662 public ArrayList getinjuryBean (AddInjuryHelperBean injuryBean)
6663 throws GOSIException
6664 {
6665 ArrayList resultRegList = new ArrayList();
6666 Connection con = null;
6667 PreparedStatement ps = null;
6668 ResultSet rs = null;
6669 String sqlQuery="";
6670 Long injuryId =null;
6671 try
6672 {
6673 injuryId = injuryBean.getInjuryId();
6674
6675 if (!(injuryId==null))
6676 {
6677 sqlQuery = "SELECT INJURYDATE,DATECOMPLICATION,ESTABLISHMENTID" ;
6678 sqlQuery += " FROM "+ SITables.T_INJURY;
6679 sqlQuery += " WHERE INJURYID = ? ";
6680
6681 GOSIDebug.debugMessages("SQLQuery:" + sqlQuery + ":");
6682 GOSIDebug.debugMessages("\t\t Param 1 :" +injuryBean.getInjuryId().longValue()+ ":");
6683 con = GOSIUtilities.getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
6684 ps = con.prepareStatement(sqlQuery);
6685 ps.setLong(1,injuryBean.getInjuryId().longValue());
6686 rs = ps.executeQuery();
6687 if(rs.next())
6688 {
6689 injuryBean.setInjuryDate(rs.getTimestamp("INJURYDATE"));
6690 injuryBean.setDateComplication(rs.getTimestamp("DATECOMPLICATION"));
6691 injuryBean.setEstablishmentId(rs.getLong("ESTABLISHMENTID"));
6692 }
6693 }
6694 else
6695 {
6696 sqlQuery = "SELECT INJURYDATE,DATECOMPLICATION,ESTABLISHMENTID" ;
6697 sqlQuery += " FROM "+ SITables.T_INJURY;
6698 sqlQuery += " WHERE SOCINSNUMBER = ? ";
6699
6700 GOSIDebug.debugMessages("SQLQuery:" + sqlQuery + ":");
6701 GOSIDebug.debugMessages("\t\t Param 1 :" +injuryBean.getSocInsNumber().longValue()+ ":");
6702 con = GOSIUtilities.getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
6703 ps = con.prepareStatement(sqlQuery);
6704 ps.setLong(1,injuryBean.getSocInsNumber().longValue());
6705 rs = ps.executeQuery();
6706 if(rs.next())
6707 {
6708 injuryBean.setInjuryDate(rs.getTimestamp("INJURYDATE"));
6709 injuryBean.setDateComplication(rs.getTimestamp("DATECOMPLICATION"));
6710 injuryBean.setEstablishmentId(rs.getLong("ESTABLISHMENTID"));
6711 }
6712 }
6713
6714 resultRegList=setSearchRegNumberList(injuryBean);
6715 }
6716 catch (GOSIException ge)
6717 {
6718 GOSIDebug.debugMessages("SESSION:insertRecordList:ge:"+ge);
6719 sesCtx.setRollbackOnly();
6720 throw ge;
6721 }
6722 catch (Exception e)
6723 {
6724 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
6725 GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
6726 "getinjuryBean()",e, "CMN_ERR_1000");
6727 }
6728 finally
6729
6730 {
6731 GOSIUtilities.cleanUp(con,ps,rs);
6732 }
6733 return resultRegList;
6734 }
6735 /**
6736 * @METHOD NAME : getOHestChangesHome
6737 * @INFORMATION : This method is to call Injury Entity
6738 * @PARAM :
6739 * @RETURN : interface gosi.database.socialinsurance.occupationalhazards.injury.entity.OHestChangesEntity
6740 * @EXCEPTION : class gosi.core.util.GOSIException
6741 * @LAST MODIFIED BY : PRD00008536
6742 * @LAST MODIFIED DATE :
6743 **/
6744 private OHestChangesEntityHome getOHestChangesHome() throws GOSIException
6745 {
6746 try
6747 {
6748 return (OHestChangesEntityHome)
6749 ServiceLocator.getInstance().getRemoteHome(
6750 OHConstants.OHESTCHANGES_ENTITY_JNDI,
6751 OHestChangesEntityHome.class);
6752 }
6753 catch (GOSIException ge)
6754 {
6755 throw ge;
6756 }
6757 catch(Exception e)
6758 {
6759 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
6760 GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
6761 "getOHestChangesHome()", e, "CMN_ERR_1000"
6762 );
6763 }
6764 }
6765 /**
6766 * @METHOD NAME : getInjuryDocReqList
6767 * @INFORMATION : This method is to call Injury Entity
6768 * @PARAM :
6769 * @RETURN : interface gosi.database.socialinsurance.occupationalhazards.injury.entity.InjuryDocReqSearchBean
6770 * @EXCEPTION : class gosi.core.util.GOSIException
6771 * @LAST MODIFIED BY : PRD00008536
6772 * @LAST MODIFIED DATE :
6773 **/
6774 public HashMap getInjuryDocReqList
6775 (Long injuryid) throws GOSIException
6776 {
6777 ArrayList injuryDocReqListBean =new ArrayList();
6778 ArrayList docReq =new ArrayList();
6779 HashMap result=new HashMap();
6780 InjuryDocReqSearchBean injuryDocReqSearch=new InjuryDocReqSearchBean();
6781 injuryDocReqSearch.setInjuryId(injuryid);
6782 InjuryDocReqListBean injuryDocReq =null;
6783 Connection con = null;
6784 PreparedStatement ps = null;
6785 ResultSet rs = null;
6786 String sqlQuery="";
6787 try
6788 {
6789 sqlQuery = "SELECT INJURYDOCREQID,DOCREQ,CREATIONTIMESTAMP" ;
6790 sqlQuery += " FROM "+ SITables.T_INJURYDOCREQ;
6791 sqlQuery += " WHERE INJURYID = ? AND LASTMODIFIEDBY is null order by DOCREQ Asc";
6792
6793 GOSIDebug.debugMessages("SQLQuery:" + sqlQuery + ":");
6794 GOSIDebug.debugMessages("\t\t Param 1 :" +injuryid.longValue()+ ":");
6795
6796 con = GOSIUtilities.getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
6797 ps = con.prepareStatement(sqlQuery);
6798 ps.setLong(1,injuryid.longValue());
6799 rs = ps.executeQuery();
6800 while(rs.next())
6801 {
6802 injuryDocReq =new InjuryDocReqListBean();
6803 injuryDocReq.setInjuryDocReqId(rs.getLong("INJURYDOCREQID"));
6804 injuryDocReq.setInjuryId(injuryid);
6805 injuryDocReq.setDocReq(rs.getLong("DOCREQ"));
6806 injuryDocReq.setCreationTimestamp(rs.getTimestamp("CREATIONTIMESTAMP"));
6807 docReq.add(injuryDocReq.getDocReq().toString());
6808 injuryDocReqListBean.add(injuryDocReq);
6809 }
6810 if(injuryDocReqListBean.size()==0){
6811 sqlQuery = "SELECT INJURYDOCREQID,DOCREQ,CREATIONTIMESTAMP" ;
6812 sqlQuery += " FROM "+ SITables.T_INJURYDOCREQ;
6813 sqlQuery += " WHERE INJURYID = ? AND LASTMODIFIEDTIMESTAMP > to_date ((SELECT to_date(max (CREATIONTIMESTAMP))"
6814 +" FROM T_INJURYDOCREQ WHERE INJURYID = ? ))order by DOCREQ Asc";
6815 ps = con.prepareStatement(sqlQuery);
6816 ps.setLong(1,injuryid.longValue());
6817 ps.setLong(2,injuryid.longValue());
6818 rs = ps.executeQuery();
6819 while(rs.next())
6820 {
6821 injuryDocReq =new InjuryDocReqListBean();
6822 injuryDocReq.setInjuryDocReqId(rs.getLong("INJURYDOCREQID"));
6823 injuryDocReq.setInjuryId(injuryid);
6824 injuryDocReq.setDocReq(rs.getLong("DOCREQ"));
6825 injuryDocReq.setCreationTimestamp(rs.getTimestamp("CREATIONTIMESTAMP"));
6826 docReq.add(injuryDocReq.getDocReq().toString());
6827 injuryDocReqListBean.add(injuryDocReq);
6828 }
6829 }
6830 }
6831 catch (GOSIException ge)
6832 {
6833 throw ge;
6834 }
6835 catch(Exception e)
6836 {
6837 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
6838 GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
6839 "getOHestChangesHome()", e, "CMN_ERR_1000"
6840 );
6841 }
6842 finally{
6843 if(docReq.size()>0){
6844 injuryDocReqSearch.setDocReq(docReq);
6845 result.put("injuryDocReq", injuryDocReqSearch);
6846 result.put("injuryDocReqList", injuryDocReqListBean);
6847 }
6848 GOSIUtilities.cleanUp(con,ps,rs);
6849 return result;
6850 }
6851 }
6852
6853 /**
6854 * @METHOD NAME : checkInjuryHasTreatmentOrTransfer
6855 * @INFORMATION : This method is to check if Injury Have Treatment on injury date
6856 * @PARAM : class java.lang.Long,
6857 class java.sql.Timestamp
6858 * @RETURN : Boolean
6859 * @EXCEPTION : class gosi.core.util.GOSIException
6860 * @LAST MODIFIED BY : Abdulrazaq Alabdulrazaq
6861 * @LAST MODIFIED DATE : 12/01/2015
6862 **/
6863 private void checkInjuryHasTreatmentOrTransfer(AddInjuryHelperBean injuryBean)
6864 throws GOSIException
6865 {
6866 PreparedStatement ps =null;
6867 ResultSet rs =null;
6868 StringBuilder sqlQuery=new StringBuilder();
6869 Boolean isInjuryHasTreatment=false;
6870 TreatmentPeriodBean trmtBean =null;
6871 TransferOHHelperBean transferBean =null;
6872 try
6873 {
6874 // this method is to check if Injury Have Treatment on injury date
6875 sqlQuery.append(" SELECT a.TREATMENTID , a.STARTDATE , a.ENDDATE , a.TREATMENTSTATUS , a.WORKFLOWID ");
6876 sqlQuery.append(" FROM "+SITables.T_TREATMENT +" a ");
6877 sqlQuery.append(" where a.INJURYID=? ");
6878 sqlQuery.append(" AND a.STARTDATE <= ? AND a.ENDDATE >= ? ");
6879 sqlQuery.append(" AND a.TREATMENTSTATUS <> ? ");
6880 sqlQuery.append(" ORDER BY a.STARTDATE ASC ");
6881
6882 GOSIDebug.debugMessages("checkInjuryHasTreatment:sqlQuery:"+sqlQuery.toString());
6883 conn = GOSIUtilities.
6884 getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
6885 ps=conn.prepareStatement(sqlQuery.toString());
6886 ps.setLong(1,injuryBean.getInjuryId().longValue());
6887 ps.setTimestamp(2,injuryBean.getInjuryDate());
6888 ps.setTimestamp(3,injuryBean.getInjuryDate());
6889 ps.setShort(4,OHConstants.TRMT_STS_CANCELLED.shortValue());
6890 rs=ps.executeQuery();
6891 while(rs.next())
6892 {
6893 trmtBean =new TreatmentPeriodBean();
6894 trmtBean.setTreatmentId(rs.getLong("TREATMENTID"));
6895 trmtBean.setStartDateGreg(rs.getTimestamp("STARTDATE"));
6896 trmtBean.setEndDateGreg(rs.getTimestamp("ENDDATE"));
6897 trmtBean.setTreatmentStatus(rs.getShort("TREATMENTSTATUS"));
6898 trmtBean.setWorkflowId(rs.getLong("WORKFLOWID"));
6899 trmtBean.setLastModifiedBy(injuryBean.getLastModifiedBy());
6900 trmtBean.setLastModifiedTimestamp(injuryBean.getLastModifiedTimestamp());
6901 if (OHConstants.TRMT_STS_ENTERED.equals(trmtBean.getTreatmentStatus())
6902 && trmtBean.getWorkflowStatus()!=null )
6903 {
6904 throw new GOSIException( GOSIConstants.SEVERITY_THREE,
6905 GOSIConstants.SOCIAL_INSURANCE,
6906 this.getClass().toString(),
6907 "checkInjuryHasTreatmentOrTransfer()",
6908 new GOSIException(),
6909 "SOI_ERR_5905");
6910 }
6911
6912 TreatmentEntity oTreatment=getTreatmentHome().findByPrimaryKey(trmtBean.getTreatmentId());
6913 // if the treatment period before the injury date
6914 if(trmtBean.getEndDateGreg().before(injuryBean.getInjuryDate()))
6915 {
6916 trmtBean.setTreatmentStatus(OHConstants.TRMT_STS_CANCELLED);
6917 trmtBean.setWorkflowStatus(OHConstants.WFS_TRMT_CANCELLED);
6918 oTreatment.UpdateTreatmentStatus(trmtBean);
6919 }
6920 // if the treatment period overlapped with injury date
6921 else if(trmtBean.getStartDateGreg().before(injuryBean.getInjuryDate()))
6922 {
6923 trmtBean.setStartDateGreg(injuryBean.getInjuryDate());
6924 oTreatment.UpdateTreatmentPeriodDate(trmtBean);
6925 }
6926
6927 }
6928
6929 GOSIUtilities.cleanUp(ps, rs);
6930 sqlQuery=new StringBuilder("");
6931 sqlQuery.append(" SELECT a.TRANSFEROHID, a.TRANSFERDATE, a.STATUS ");
6932 sqlQuery.append(" FROM "+SITables.T_TRANSFEROH +" a ");
6933 sqlQuery.append(" where a.INJURYID = ? ");
6934 sqlQuery.append(" AND a.TRANSFERDATE < ? ");
6935 sqlQuery.append(" AND a.STATUS <> ? ");
6936 sqlQuery.append(" ORDER BY a.TRANSFERDATE ASC ");
6937
6938 GOSIDebug.debugMessages("checkInjuryHasTransfer:sqlQuery:"+sqlQuery.toString());
6939 conn = GOSIUtilities.
6940 getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
6941 ps=conn.prepareStatement(sqlQuery.toString());
6942 ps.setLong(1,injuryBean.getSocInsNumber().longValue());
6943 ps.setTimestamp(2,injuryBean.getInjuryDate());
6944 ps.setShort(3,OHConstants.TRANSFER_STS_CANCELLED.shortValue());
6945 rs=ps.executeQuery();
6946 while(rs.next())
6947 {
6948 transferBean =new TransferOHHelperBean();
6949 transferBean.setTransferOHId(rs.getLong("TRANSFEROHID"));
6950 transferBean.setTransferDate(rs.getTimestamp("TRANSFERDATE"));
6951 transferBean.setTransferStatus(rs.getShort("STATUS"));
6952 transferBean.setLastModifiedBy(injuryBean.getLastModifiedBy());
6953 transferBean.setLastModifiedTimestamp(injuryBean.getLastModifiedTimestamp());
6954 if (OHConstants.TRANSFER_STS_NOTIFIED.equals(trmtBean.getTreatmentStatus()))
6955 {
6956 throw new GOSIException( GOSIConstants.SEVERITY_THREE,
6957 GOSIConstants.SOCIAL_INSURANCE,
6958 this.getClass().toString(),
6959 "checkInjuryHasTreatmentOrTransfer()",
6960 new GOSIException(),
6961 "SOI_ERR_5631");
6962 }
6963
6964 TransferOHEntity oTransfer=getTransferOHHome().findByPrimaryKey(transferBean.getTransferOHId());
6965 // if the trnasfer date before the injury date will be cancelled
6966 if(transferBean.getTransferDate().before(injuryBean.getInjuryDate()))
6967 {
6968 transferBean.setTransferStatus(OHConstants.TRANSFER_STS_CANCELLED);
6969 transferBean.setWorkFlowStatus(OHConstants.WFS_TRANS_OH_CANCELLED);
6970 oTransfer.updateTransferOHStatus(transferBean);
6971 }
6972
6973
6974 }
6975
6976 }
6977 catch (GOSIException ge)
6978 {
6979 throw ge;
6980 }
6981 catch(Exception e)
6982 {
6983 throw new GOSIException(GOSIConstants.SEVERITY_ONE,
6984 GOSIConstants.SOCIAL_INSURANCE,
6985 this.getClass().toString(),
6986 "checkInjuryHasTreatmentOrTransfer()",
6987 e,"CMN_ERR_1000");
6988 }
6989 finally
6990 {
6991 GOSIUtilities.cleanUp(conn, ps, rs);
6992 }
6993 }
6994
6995 /**
6996 * @METHOD NAME : checkInjuryHasOHBenefit
6997 * @INFORMATION : This method is to check if Injury Have OH Benefit not Recovered on injury date
6998 * @PARAM : class java.lang.Long,
6999 class java.sql.Timestamp
7000 * @RETURN : Boolean
7001 * @EXCEPTION : class gosi.core.util.GOSIException
7002 * @LAST MODIFIED BY : Abdulrazaq Alabdulrazaq
7003 * @LAST MODIFIED DATE : 12/01/2015
7004 **/
7005 private void checkInjuryHasOHBenefit(Long injuryId, Timestamp injuryDate)
7006 throws GOSIException
7007 {
7008 PreparedStatement ps =null;
7009 ResultSet rs =null;
7010 StringBuilder sqlQuery=new StringBuilder();
7011 try
7012 {
7013 // this method is to check if Injury Have OH Benefit not Recovered on injury date
7014 sqlQuery.append(" SELECT COUNT(*) CNT ");
7015 sqlQuery.append(" FROM "+SITables.T_OHBENEFIT +" a, ");
7016 sqlQuery.append(SITables.T_INJURY+" b, "+SITables.T_RECFROMCONTRIBUTOR+" c, "+SITables.T_RECFROMEMP+" d ");
7017 sqlQuery.append(" where a.INJURYID=b.INJURYID AND C.OHBENID(+)=A.OHBENID AND D.OHBENID(+) = A.OHBENID ");
7018 sqlQuery.append(" AND b.INJURYID= ? ");
7019 sqlQuery.append(" AND a.BENSTDATE <= ? AND a.BENSTDATE >= ? ");
7020 sqlQuery.append(" AND A.BENSTATUS NOT IN ( ? , ? ) ");
7021 sqlQuery.append(" AND D.DEBNOTEID IS NULL AND C.DEBITNOTEID IS NULL ");
7022
7023 GOSIDebug.debugMessages("checkInjuryHasOHBenefit:sqlQuery:"+sqlQuery.toString());
7024 conn = GOSIUtilities.
7025 getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
7026 ps=conn.prepareStatement(sqlQuery.toString());
7027 ps.setLong(1,injuryId.longValue());
7028 ps.setTimestamp(2,injuryDate);
7029 ps.setTimestamp(3,injuryDate);
7030 ps.setShort(4,OHConstants.OH_BNFT_STS_RECOVERED);
7031 ps.setShort(5,OHConstants.OH_BNFT_STS_CANCELLED);
7032 rs=ps.executeQuery();
7033 if(rs.next())
7034 {
7035 GOSIDebug.debugMessages("rs.getInt(CNT)==="+rs.getInt("CNT"));
7036 if(rs.getInt("CNT")>0)
7037 {
7038 throw new GOSIException( GOSIConstants.SEVERITY_THREE,
7039 GOSIConstants.SOCIAL_INSURANCE,
7040 this.getClass().toString(),
7041 "checkInjuryHasOHBenefit()",
7042 new GOSIException(),
7043 "SOI_ERR_7252");
7044 }
7045 }
7046 }
7047 catch (GOSIException ge)
7048 {
7049 throw ge;
7050 }
7051 catch(Exception e)
7052 {
7053 throw new GOSIException(GOSIConstants.SEVERITY_ONE,
7054 GOSIConstants.SOCIAL_INSURANCE,
7055 this.getClass().toString(),
7056 "checkInjuryHasOHBenefit()",
7057 e,"CMN_ERR_1000");
7058 }
7059 finally
7060 {
7061 GOSIUtilities.cleanUp(conn, ps, rs);
7062 }
7063 }
7064
7065
7066 /**
7067 * @METHOD NAME : checkInjuryHasTreatmentService
7068 * @INFORMATION : This method is to check if Injury Has Treatment Service Not Recovered on injury date
7069 * @PARAM : class java.lang.Long,
7070 class java.sql.Timestamp
7071 * @RETURN : Boolean
7072 * @EXCEPTION : class gosi.core.util.GOSIException
7073 * @LAST MODIFIED BY : Abdulrazaq Alabdulrazaq
7074 * @LAST MODIFIED DATE : 12/01/2015
7075 **/
7076 private void checkInjuryHasTreatmentService(Long injuryId, Timestamp injuryDate)
7077 throws GOSIException
7078 {
7079 PreparedStatement ps =null;
7080 ResultSet rs =null;
7081 StringBuilder sqlQuery=new StringBuilder();
7082 try
7083 {
7084 // this method is to check if Injury Has Treatment Service Not Recovered on injury date
7085 sqlQuery.append(" SELECT COUNT(*) CNT ");
7086 sqlQuery.append(" FROM "+SITables.T_REGHOSPINVOICEDET +" a, ");
7087 sqlQuery.append(SITables.T_INJURY+" b ,"+SITables.T_RECFROMEMP+" d ");
7088 sqlQuery.append(" where a.INJURYID=b.INJURYID AND D.INJURYID(+) = A.INJURYID ");
7089 sqlQuery.append(" AND b.INJURYID=? ");
7090 sqlQuery.append(" AND ( b.INJURYSTATUS != ? and b.INJURYSTATUS != ?) ");
7091 sqlQuery.append(" AND a.TRMTSTARTDATE <= ? AND a.TRMTSTARTDATE >= ? ");
7092 sqlQuery.append(" AND A.STATUS <> ? ");
7093 sqlQuery.append(" AND (D.DEBNOTEID IS NULL OR ( D.DEBNOTEID IS NOT NULL AND D.CREDITNOTEID IS NOT NULL)) ");
7094
7095 GOSIDebug.debugMessages("checkInjuryHasTreatmentService:sqlQuery:"+sqlQuery.toString());
7096 conn = GOSIUtilities.
7097 getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
7098 ps=conn.prepareStatement(sqlQuery.toString());
7099 ps.setLong(1,injuryId.longValue());
7100 ps.setShort(2,OHConstants.INJ_STS_CANCELLED.shortValue());
7101 ps.setShort(3,OHConstants.INJ_STS_REJECTED.shortValue());
7102 ps.setTimestamp(4,injuryDate);
7103 ps.setTimestamp(5,injuryDate);
7104 ps.setShort(6,OHConstants.REG_HOSP_INVC_DETAILS_CANCELLED);
7105 rs=ps.executeQuery();
7106 if(rs.next())
7107 {
7108 GOSIDebug.debugMessages("rs.getInt(CNT)==="+rs.getInt("CNT"));
7109 if(rs.getInt("CNT")>0)
7110 {
7111 throw new GOSIException( GOSIConstants.SEVERITY_THREE,
7112 GOSIConstants.SOCIAL_INSURANCE,
7113 this.getClass().toString(),
7114 "checkInjuryHasTreatmentService()",
7115 new GOSIException(),
7116 "SOI_ERR_7253");
7117 }
7118 }
7119
7120 }
7121 catch (GOSIException ge)
7122 {
7123 throw ge;
7124 }
7125 catch(Exception e)
7126 {
7127 throw new GOSIException(GOSIConstants.SEVERITY_ONE,
7128 GOSIConstants.SOCIAL_INSURANCE,
7129 this.getClass().toString(),
7130 "checkInjuryHasTreatmentService()",
7131 e,"CMN_ERR_1000");
7132 }
7133 finally
7134 {
7135 GOSIUtilities.cleanUp(conn, ps, rs);
7136 }
7137 }
7138
7139 /**
7140 * @METHOD NAME : checkInjuryHasComplicationList
7141 * @INFORMATION : This method is to check if Injury Has Treatment Service Not Recovered on injury date
7142 * @PARAM : class java.lang.Long,
7143 class java.sql.Timestamp
7144 * @RETURN : Long
7145 * @EXCEPTION : class gosi.core.util.GOSIException
7146 * @LAST MODIFIED BY : Abdulrazaq Alabdulrazaq
7147 * @LAST MODIFIED DATE : 12/01/2015
7148 **/
7149 private ArrayList checkInjuryHasComplicationList(AddInjuryHelperBean injuryBean)
7150 throws GOSIException
7151 {
7152 PreparedStatement ps =null;
7153 ResultSet rs =null;
7154 StringBuilder sqlQuery=new StringBuilder();
7155 ArrayList<Long> complicationList= new ArrayList<Long> ();
7156 try
7157 {
7158 // this method is to check if Injury Has Treatment Service Not Recovered on injury date
7159 sqlQuery.append(" SELECT INJURYID ");
7160 sqlQuery.append(" FROM "+SITables.T_INJURY+" a ");
7161 sqlQuery.append(" where a.SOCINSNUMBER=? AND a.INJURYNUMBER= ? AND a.INJURYID <> ? ");
7162 sqlQuery.append(" AND ( a.INJURYSTATUS != ? and a.INJURYSTATUS != ?) ");
7163 sqlQuery.append(" AND a.DATECOMPLICATION IS NOT NULL ");
7164
7165 GOSIDebug.debugMessages("checkInjuryHasComplicationList:sqlQuery:"+sqlQuery.toString());
7166 conn = GOSIUtilities.
7167 getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
7168 ps=conn.prepareStatement(sqlQuery.toString());
7169 ps.setLong(1,injuryBean.getSocInsNumber().longValue());
7170 ps.setLong(2,injuryBean.getInjuryNumber().longValue());
7171 ps.setLong(3,injuryBean.getInjuryId().longValue());
7172 ps.setShort(4,OHConstants.INJ_STS_CANCELLED.shortValue());
7173 ps.setShort(5,OHConstants.INJ_STS_REJECTED.shortValue());
7174 rs=ps.executeQuery();
7175 while(rs.next())
7176 {
7177 GOSIDebug.debugMessages("rs.getLong(INJURYID)==="+rs.getLong("INJURYID"));
7178 if(rs.getObject("INJURYID")!=null)
7179 {
7180 complicationList.add(rs.getLong("INJURYID"));
7181 }
7182
7183 }
7184 return complicationList;
7185 }
7186 catch (GOSIException ge)
7187 {
7188 throw ge;
7189 }
7190 catch(Exception e)
7191 {
7192 throw new GOSIException(GOSIConstants.SEVERITY_ONE,
7193 GOSIConstants.SOCIAL_INSURANCE,
7194 this.getClass().toString(),
7195 "checkInjuryHasComplicationList()",
7196 e,"CMN_ERR_1000");
7197 }
7198 finally
7199 {
7200 GOSIUtilities.cleanUp(conn, ps, rs);
7201 }
7202 }
7203
7204 /**
7205 * @METHOD NAME : updateFirstVisitDate
7206 * @INFORMATION : This method is to update First Visit Date if it before the injury date
7207 * @PARAM : class java.lang.Long,
7208 class java.sql.Timestamp
7209 * @RETURN : void
7210 * @EXCEPTION : class gosi.core.util.GOSIException
7211 * @LAST MODIFIED BY : Abdulrazaq Alabdulrazaq
7212 * @LAST MODIFIED DATE : 12/01/2015
7213 **/
7214 private void updateFirstVisitDate(AddInjuryHelperBean injuryBean)
7215 throws GOSIException
7216 {
7217 PreparedStatement ps =null;
7218 ResultSet rs =null;
7219 StringBuilder sqlQuery=new StringBuilder();
7220 Long pmrId=null;
7221 Timestamp firstVisitDate=null;
7222 try
7223 {
7224 // this method is to check if Injury Have Treatment on injury date
7225 sqlQuery.append(" SELECT PMRID , FIRSTVISITDATE ");
7226 sqlQuery.append(" FROM "+SITables.T_PMR+" a ");
7227 sqlQuery.append(" where a.INJURYID= ? ");
7228 GOSIDebug.debugMessages("updateFirstVisitDate:sqlQuery:"+sqlQuery.toString());
7229 conn = GOSIUtilities.
7230 getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
7231 ps=conn.prepareStatement(sqlQuery.toString());
7232 ps.setLong(1,injuryBean.getInjuryId().longValue());
7233 rs=ps.executeQuery();
7234 if(rs.next())
7235 {
7236 pmrId=rs.getLong("PMRID");
7237 firstVisitDate=rs.getTimestamp("FIRSTVISITDATE");
7238 // check if the fisrt visit date on the T_PMR need to be update (may be it will before the New date !!)
7239 if(firstVisitDate.before(injuryBean.getInjuryDate()))
7240 {
7241 PMREntity injuryPMR=getPMRHome().findByPrimaryKey(pmrId);
7242 PMRHelperBean pmrBean =new PMRHelperBean();
7243 pmrBean.setPmrId(pmrId);
7244 pmrBean.setFirstVisitDate(injuryBean.getInjuryDate());
7245 pmrBean.setLastModifiedBy(injuryBean.getLastModifiedBy());
7246 pmrBean.setLastModifiedTimestamp(injuryBean.getLastModifiedTimestamp());
7247 injuryPMR.updateFirstVisitDate(pmrBean);
7248 }
7249 }
7250
7251 }
7252 catch (GOSIException ge)
7253 {
7254 throw ge;
7255 }
7256 catch(Exception e)
7257 {
7258 throw new GOSIException(GOSIConstants.SEVERITY_ONE,
7259 GOSIConstants.SOCIAL_INSURANCE,
7260 this.getClass().toString(),
7261 "updateFirstVisitDate()",
7262 e,"CMN_ERR_1000");
7263 }
7264 finally
7265 {
7266 GOSIUtilities.cleanUp(conn, ps, rs);
7267 }
7268 }
7269
7270
7271 /**
7272 * @METHOD NAME : getPMRHome
7273 * @INFORMATION : This method is to call PMR Entity
7274 * @PARAM :
7275 * @RETURN : interface gosi.database.socialinsurance.occupationalhazards.injury.entity.PMREntityHome
7276 * @EXCEPTION : class gosi.core.util.GOSIException
7277 * @LAST MODIFIED BY :
7278 * @LAST MODIFIED DATE :
7279 **/
7280 private PMREntityHome getPMRHome() throws GOSIException
7281 {
7282
7283 try
7284 {
7285 return (PMREntityHome)
7286 ServiceLocator.getInstance().getRemoteHome(
7287 OHConstants.PMR_ENTITY_JNDI,
7288 PMREntityHome.class);
7289 }
7290 catch (GOSIException ge)
7291 {
7292 throw ge;
7293 }
7294 catch(Exception e)
7295 {
7296 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
7297 GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
7298 "getPMRHome()", e, "CMN_ERR_1000"
7299 );
7300 }
7301 finally
7302 {
7303
7304 }
7305 }
7306
7307 /**
7308 * @METHOD NAME : getTreatmentHome
7309 * @INFORMATION : This method is to call Treatment Entity
7310 * @PARAM :
7311 * @RETURN : interface gosi.database.socialinsurance.occupationalhazards.injury.entity.PMREntityHome
7312 * @EXCEPTION : class gosi.core.util.GOSIException
7313 * @LAST MODIFIED BY :
7314 * @LAST MODIFIED DATE :
7315 **/
7316 private TreatmentEntityHome getTreatmentHome() throws GOSIException
7317 {
7318
7319 try
7320 {
7321 return (TreatmentEntityHome)
7322 ServiceLocator.getInstance().getRemoteHome(
7323 OHConstants.TRMT_PRD_ENTITY_JNDI,
7324 TreatmentEntityHome.class);
7325 }
7326 catch (GOSIException ge)
7327 {
7328 throw ge;
7329 }
7330 catch(Exception e)
7331 {
7332 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
7333 GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
7334 "getTreatmentHome()", e, "CMN_ERR_1000"
7335 );
7336 }
7337 finally
7338 {
7339
7340 }
7341 }
7342 /**
7343 * @METHOD NAME : getTransferOHHome
7344 * @INFORMATION : This method is to call TransferOH Entity
7345 * @PARAM :
7346 * @RETURN : interface gosi.database.socialinsurance.occupationalhazards.injury.entity.PMREntityHome
7347 * @EXCEPTION : class gosi.core.util.GOSIException
7348 * @LAST MODIFIED BY :
7349 * @LAST MODIFIED DATE :
7350 **/
7351 private TransferOHEntityHome getTransferOHHome() throws GOSIException
7352 {
7353
7354 try
7355 {
7356 return (TransferOHEntityHome)
7357 ServiceLocator.getInstance().getRemoteHome(
7358 OHConstants.TRANSFER_OH_ENTITY_JNDI,
7359 TransferOHEntityHome.class);
7360 }
7361 catch (GOSIException ge)
7362 {
7363 throw ge;
7364 }
7365 catch(Exception e)
7366 {
7367 throw new GOSIException( GOSIConstants.SEVERITY_ONE,
7368 GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
7369 "getTransferOHHome()", e, "CMN_ERR_1000"
7370 );
7371 }
7372 finally
7373 {
7374
7375 }
7376 }
7377
7378 /**
7379 * @METHOD NAME : checkTreatmentInpatientforAnotherInjury
7380 * @INFORMATION : This method is to check Treatment on Inpatient for another Injury
7381 it will check whether the injury date is on inpatient period
7382 * @PARAM : class java.lang.Long,
7383 class java.sql.Timestamp
7384 * @RETURN : void
7385 * @EXCEPTION : class gosi.core.util.GOSIException
7386 * @LAST MODIFIED BY : Abdulrazaq Alabdulrazaq
7387 * @LAST MODIFIED DATE : 12/01/2015
7388 **/
7389 private void checkTreatmentInpatientforAnotherInjury(Long siNumber, Long injuryId, Timestamp injuryDate)
7390 throws GOSIException
7391 {
7392 PreparedStatement ps =null;
7393 ResultSet rs =null;
7394 StringBuilder sqlQuery=new StringBuilder();
7395 long startTime = 0;
7396 long endTime = 0;
7397 long elapsedTime = 0;
7398 startTime = System.currentTimeMillis();
7399 try
7400 {
7401 // this method is to check if the injury date is on an inpatient
7402 // period for the contributor
7403 sqlQuery.append(" SELECT COUNT(*) CNT ");
7404 sqlQuery.append(" FROM "+SITables.T_TREATMENT +" a, ");
7405 sqlQuery.append(SITables.T_INJURY+" b ");
7406 sqlQuery.append(" where a.INJURYID=b.INJURYID ");
7407 sqlQuery.append(" and b.SOCINSNUMBER=? AND b.INJURYID <> ? ");
7408 sqlQuery.append(" and ( b.INJURYSTATUS != ? and b.INJURYSTATUS != ?) ");
7409 sqlQuery.append(" AND a.STARTDATE <= ? AND a.ENDDATE >= ? ");
7410 sqlQuery.append(" AND a.TREATMENTTYPE=? ");
7411 sqlQuery.append(" AND a.TREATMENTSTATUS <> ? ");
7412 GOSIDebug.debugMessages("checkTreatmentInpatientforAnotherInjury:sqlQuery:"+sqlQuery.toString());
7413 conn = GOSIUtilities.
7414 getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
7415 ps=conn.prepareStatement(sqlQuery.toString());
7416 ps.setLong(1,siNumber.longValue());
7417 ps.setLong(2,injuryId.longValue());
7418 ps.setShort(3,OHConstants.INJ_STS_CANCELLED.shortValue());
7419 ps.setShort(4,OHConstants.INJ_STS_REJECTED.shortValue());
7420 ps.setTimestamp(5,injuryDate);
7421 ps.setTimestamp(6,injuryDate);
7422 ps.setShort(7,OHConstants.TRMT_TYPE_INPATIENT.shortValue());
7423 ps.setShort(8,OHConstants.TRMT_STS_CANCELLED.shortValue());
7424 rs=ps.executeQuery();
7425 if(rs.next())
7426 {
7427 //Injury cannot be booked when another Injury for the same
7428 //contributor is taking In Patient Treatment
7429 if(rs.getInt("CNT")>0)
7430 {
7431 throw new GOSIException( GOSIConstants.SEVERITY_THREE,
7432 GOSIConstants.SOCIAL_INSURANCE,
7433 this.getClass().toString(),
7434 "checkTreatmentInpatient()",
7435 new GOSIException(),
7436 "SOI_ERR_5388");
7437 }
7438 GOSIDebug.debugMessages("rs.getInt(CNT)==="+rs.getInt("CNT"));
7439 }
7440 endTime = System.currentTimeMillis();
7441 elapsedTime = endTime - startTime;
7442 GOSIInstrumentationLog.writeInstrumentationToLog(
7443 this.getClass().toString(),
7444 "checkTreatmentInpatientforAnotherInjury()",
7445 elapsedTime);
7446 }
7447 catch (GOSIException ge)
7448 {
7449 throw ge;
7450 }
7451 catch(Exception e)
7452 {
7453 throw new GOSIException(GOSIConstants.SEVERITY_ONE,
7454 GOSIConstants.SOCIAL_INSURANCE,
7455 this.getClass().toString(),
7456 "checkTreatmentInpatientforAnotherInjury()",
7457 e,"CMN_ERR_1000");
7458 }
7459 finally
7460 {
7461 GOSIUtilities.cleanUp(conn, ps, rs);
7462 }
7463
7464
7465 }
7466}