Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // -- Java Code Generation Process --
- package gosi.business.socialinsurance.occupationalhazards.injury.session;
- // Import Statements
- import gosi.business.financialaccounting.common.beans.FAConstants;
- import gosi.core.util.ServiceLocator;
- import gosi.core.util.GOSIDebug;
- import javax.ejb.SessionBean;
- import java.util.ArrayList;
- import javax.ejb.SessionContext;
- import javax.ejb.EJBException;
- import java.rmi.RemoteException;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.Timestamp;
- import java.util.ArrayList;
- import java.util.Calendar;
- import java.util.GregorianCalendar;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.Hashtable;
- import java.util.StringTokenizer;
- import javax.naming.Context;
- import javax.naming.InitialContext;
- import java.util.Properties;
- import javax.rmi.PortableRemoteObject;
- import java.lang.Math;
- import gosi.core.util.GOSIException;
- import gosi.core.util.GOSIConstants;
- import gosi.core.util.GOSIErrorMessages;
- import gosi.core.util.GOSIUtilities;
- import gosi.core.util.GOSIInstrumentationLog;
- import gosi.core.util.GOSIDateUtilities;
- import gosi.core.util.GOSIApplicationProperties;
- import gosi.core.util.beans.AuditBean;
- import gosi.core.workflow.beans.WorkflowParamBean;
- import gosi.business.interfaces.beans.OccupationalHazardsInterfaceConstants;
- import gosi.business.socialinsurance.common.beans.SITables;
- import gosi.rules.socialinsurance.occupationalhazards.beans.OHRuleBean;
- import gosi.business.socialinsurance.occupationalhazards.common.beans.OHUtilities;
- import gosi.business.socialinsurance.occupationalhazards.injury.beans.InjuryPopDetails;
- import gosi.business.socialinsurance.occupationalhazards.injury.beans.VisitBean;
- import gosi.business.socialinsurance.occupationalhazards.injury.beans.OHAllowanceBean;
- import gosi.business.socialinsurance.occupationalhazards.injury.beans.TreatmentPeriodBean;
- import gosi.business.socialinsurance.occupationalhazards.injury.beans.RecEmployerBean;
- import gosi.business.socialinsurance.occupationalhazards.injury.beans.RecFromContributorHeaderBean;
- import gosi.business.socialinsurance.occupationalhazards.injury.beans.RecalculateBenefitInputBean;
- import gosi.business.socialinsurance.occupationalhazards.injury.beans.ResumeBean;
- import gosi.business.socialinsurance.occupationalhazards.common.beans.OHServices;
- import gosi.business.socialinsurance.occupationalhazards.common.beans.OHConstants;
- import gosi.business.socialinsurance.annuities.common.beans.PaymentBankAccountBean;
- import gosi.database.socialinsurance.annuities.entity.PaymentBankAccountEntity;
- import gosi.database.socialinsurance.annuities.entity.PaymentBankAccountEntityHome;
- import gosi.database.socialinsurance.occupationalhazards.injury.entity.OHAllowanceEntity;
- import gosi.database.socialinsurance.occupationalhazards.injury.entity.OHAllowanceEntityHome;
- import gosi.business.socialinsurance.registration.common.beans.RegistrationConstants;
- import gosi.business.socialinsurance.registration.establishment.beans.EstablishmentUtility;
- import gosi.business.socialinsurance.registration.establishment.beans.EstablishmentBean;
- import gosi.database.socialinsurance.occupationalhazards.injury.entity.RecEmployerEntity;
- import gosi.database.socialinsurance.occupationalhazards.injury.entity.RecEmployerEntityHome;
- import gosi.database.socialinsurance.occupationalhazards.injury.entity.RecFromContributorEntity;
- import gosi.database.socialinsurance.occupationalhazards.injury.entity.RecFromContributorEntityHome;
- import gosi.business.socialinsurance.occupationalhazards.injury.beans.CompanionBean;
- import gosi.business.socialinsurance.registration.engagement.beans.ContributorUtilities;
- import gosi.business.socialinsurance.registration.engagement.beans.ContributorBean;
- import gosi.business.socialinsurance.common.beans.PersonBean;
- import gosi.business.socialinsurance.common.beans.PersonUtilities;
- import gosi.core.util.beans.IndividualContactBean;
- import gosi.business.interfaces.beans.CNInterfaceBean;
- import gosi.business.interfaces.beans.CNInterfaceDetailBean;
- import gosi.business.interfaces.beans.FAInterfaceConstants;
- import gosi.business.interfaces.FinanceImplProxy;
- import gosi.business.interfaces.FinancialAccountingInterface;
- import gosi.business.interfaces.beans.PartyInterfaceBean;
- import gosi.database.socialinsurance.occupationalhazards.common.entity.MaintainOHServicesEntityHome;
- import gosi.database.socialinsurance.occupationalhazards.common.entity.MaintainOHServicesEntity;
- import gosi.database.socialinsurance.occupationalhazards.injury.entity.InjuryEntityHome;
- import gosi.database.socialinsurance.occupationalhazards.injury.entity.InjuryEntity;
- import gosi.business.socialinsurance.occupationalhazards.injury.beans.InjuryBean;
- import gosi.core.dms.beans.DMSRequestHeaderBean;
- import gosi.core.dms.beans.DMSConstants;
- import gosi.core.dms.util.DMSUtilities;
- import java.util.Iterator;
- /**
- * @CLASS NAME : MaintainOHAllowanceSessionEJB
- * @TYPE : SessionEJB
- * @AUTHOR : TCS
- * @VERSION : 1
- * @EXTENDS : Nil
- * @INFORMATION : Session EJB object is used to Maintain OH Allowance
- * @IMPLEMENTS : SessionBean
- * @TABLES REFERRED : T_ohbenefit, T_injury,T_contributor,T_person,T_establishemnt,
- T_engagement,T_engagementwagecoverage,T_treatment,T_hospital,
- T_stopresumeohallowance
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- * @stereotype SessionBean
- * @homeInterface gosi.business.socialinsurance.occupationalhazards.injury.session.MaintainOHAllowanceSessionHome
- * @remoteInterface gosi.business.socialinsurance.occupationalhazards.injury.session.MaintainOHAllowanceSession
- */
- public class MaintainOHAllowanceSessionEJB implements javax.ejb.SessionBean
- {
- private Connection con=null;
- private SessionContext ctx=null;
- /**
- * @METHOD NAME : searchInjuryList
- * @INFORMATION : This method is to search Injury List with sin and injurydate
- * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.InjuryPopDetails
- * @RETURN : class java.util.ArrayList
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- public ArrayList searchInjuryList(InjuryPopDetails searchBean)
- throws GOSIException
- {
- // get injury with status other than cancelled
- long startTime = 0;
- long endTime = 0;
- long elapsedTime = 0;
- startTime = System.currentTimeMillis();
- PreparedStatement ps = null;
- ResultSet rs = null;
- GOSIDebug.debugMessages("\t\t Start searchInjuryList - MaintainOHAllowanceSessionEJB");
- String message = "";
- Long socInsNum = searchBean.getSocialInsuranceNumber();
- Timestamp startDate = null;
- Timestamp endDate = null;
- String entFmt = searchBean.getBenefitStartDateEntFmt();
- GOSIDebug.debugMessages("EntFmt:" + entFmt);
- GOSIDebug.debugMessages("SIN:" + socInsNum + "\t startDate:" + startDate);
- String sqlQuery = "";
- ArrayList injuryList = new ArrayList();
- //Query to get injurys which has treatment for the benefit period
- sqlQuery= " select "+
- " INJURYID, "+
- " SOCINSNUMBER, "+
- " CONTRIBUTORID, "+
- " ESTABLISHMENTID, "+
- " INJURYDATE, "+
- " DATECOMPLICATION, "+
- " INJURYNUMBER, "+
- " DESCRIPTION, "+
- " FIELDOFFICECODE, "+
- " INJURYSTATUS, "+
- " EMPLOYERNOTIFYDATE, "+
- " WORKERINTIMATIONDATE, "+
- " WAGESTOPDATE, "+
- " (NVL(WORKDISABILITYDATE,INJURYDATE +1)) MINDISABLITYDATE, "+
- " TREATMENTSTDATE, "+
- " TREATMENTENDDATE " +
- " from "+ SITables.T_INJURY +
- " where SOCINSNUMBER = ? "+
- " and TREATMENTSTDATE <= ? "+
- " and TREATMENTENDDATE >= ? "+
- " and INJURYSTATUS != ? "+
- " order by INJURYDATE ";
- try
- {
- Timestamp currentDate = new Timestamp(System.currentTimeMillis());
- startDate = OHUtilities.getGregDate
- (searchBean.getBenefitStartDateStr(),
- searchBean.getBenefitStartDateEntFmt());
- GOSIDebug.debugMessages("startDate:" + startDate);
- endDate = OHUtilities.getGregDate
- (searchBean.getBenefitEndDateStr(),
- searchBean.getBenefitEndDateEntFmt());
- GOSIDebug.debugMessages("StartDate:" + startDate + " : EndDate:" + endDate + ":");
- // comparing end date with current date
- if(endDate.compareTo(currentDate) > 0)
- {
- throw new GOSIException( GOSIConstants.SEVERITY_THREE,
- GOSIConstants.OCCUPATIONAL_HAZARDS,
- this.getClass().toString(),
- "searchInjuryList()",null,
- "SOI_ERR_4189");
- }
- //comparing startdate with current date
- if(startDate.compareTo(endDate) > 0)
- {
- throw new GOSIException( GOSIConstants.SEVERITY_THREE,
- GOSIConstants.OCCUPATIONAL_HAZARDS,
- this.getClass().toString(),
- "searchInjuryList()",null,
- "SOI_ERR_4190");
- }
- con = GOSIUtilities.getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
- ps = con.prepareStatement(sqlQuery);
- ps.setLong(1,socInsNum.longValue());
- ps.setTimestamp(2,endDate);
- ps.setTimestamp(3,startDate);
- ps.setShort(4,OHConstants.INJ_STS_CANCELLED.shortValue());
- GOSIDebug.debugMessages("SqlQuery :" + sqlQuery + ":");
- GOSIDebug.debugMessages("\t\t Param 1 :" + socInsNum.longValue() + ":");
- GOSIDebug.debugMessages("\t\t Param 2 :" + endDate + ":");
- GOSIDebug.debugMessages("\t\t Param 3 :" + startDate + ":");
- GOSIDebug.debugMessages("\t\t Param 4 :" + OHConstants.INJ_STS_CANCELLED.shortValue() + ":");
- rs = ps.executeQuery();
- while(rs.next())
- {
- GOSIDebug.debugMessages("SearchInjuryList has records");
- InjuryPopDetails injuryDetails = new InjuryPopDetails();
- injuryDetails.setInjuryID(new Long(rs.getLong("INJURYID")));
- injuryDetails.setSocialInsuranceNumber
- (new Long(rs.getLong("SOCINSNUMBER")));
- injuryDetails.setEstablishmentId
- (new Long(rs.getLong("ESTABLISHMENTID")));
- injuryDetails.setContributorId
- (new Long(rs.getLong("CONTRIBUTORID")));
- injuryDetails.setInjuryDate(rs.getTimestamp("INJURYDATE"));
- if (OHConstants.HIJRAH.equals(entFmt))
- {
- injuryDetails.setInjuryDateStr
- (GOSIDateUtilities.convertToHijra(
- GOSIUtilities.getDateFullString(
- injuryDetails.getInjuryDate())));
- }
- else
- {
- injuryDetails.setInjuryDateStr
- (GOSIUtilities.getDateFullString(
- injuryDetails.getInjuryDate()));
- }
- if(rs.getObject("DATECOMPLICATION") != null)
- {
- injuryDetails.setComplicationDate
- (rs.getTimestamp("DATECOMPLICATION"));
- }
- injuryDetails.setInjuryNumber
- (new Long(rs.getLong("INJURYNUMBER")));
- GOSIDebug.debugMessages("Injury Number:" + injuryDetails.getInjuryNumber() + ":");
- injuryDetails.setDescription(rs.getString("DESCRIPTION"));
- injuryDetails.setFieldOffice
- (new Short(rs.getShort("FIELDOFFICECODE")));
- injuryDetails.setInjuryStatus
- (new Short(rs.getString("INJURYSTATUS")));
- if(rs.getObject("EMPLOYERNOTIFYDATE")!= null)
- {
- injuryDetails.setEmployerNotifyDate
- (rs.getTimestamp("EMPLOYERNOTIFYDATE"));
- }
- if(rs.getObject("WORKERINTIMATIONDATE") != null)
- {
- injuryDetails.setWorkerIntimationDate
- (rs.getTimestamp("WORKERINTIMATIONDATE"));
- }
- if(rs.getObject("WAGESTOPDATE") != null)
- {
- injuryDetails.setWageStopDate
- (rs.getTimestamp("WAGESTOPDATE"));
- }
- if(rs.getObject("TREATMENTSTDATE") != null)
- {
- injuryDetails.setTreatmentStartDate
- (rs.getTimestamp("TREATMENTSTDATE"));
- }
- if(rs.getObject("TREATMENTENDDATE") != null)
- {
- injuryDetails.setTreatmentEndDate
- (rs.getTimestamp("TREATMENTENDDATE"));
- }
- if(rs.getObject("MINDISABLITYDATE") !=null)
- {
- injuryDetails.setWorkDisabilityDate
- (rs.getTimestamp("MINDISABLITYDATE"));
- }
- // setting contributor details
- injuryDetails = setContributorDetails(injuryDetails);
- // setting establishment details
- injuryDetails = setEstablishmentDetails(injuryDetails);
- injuryDetails.setBenefitStartDateStr
- (searchBean.getBenefitStartDateStr());
- injuryDetails.setBenefitEndDateStr
- (searchBean.getBenefitEndDateStr());
- injuryDetails.setBenefitStartDate(startDate);
- injuryDetails.setBenefitEndDate(endDate);
- injuryDetails.setBenefitStartDateEntFmt(entFmt);
- injuryDetails.setBenefitEndDateEntFmt(entFmt);
- GOSIDebug.debugMessages("Pay to SI: " +
- injuryDetails.getBenefitPayableTo() + ":");
- injuryList.add(injuryDetails);
- // adding injurydetails to list for multiple injuryies
- }
- int injuryListSize = injuryList.size();
- if(injuryListSize == 0)
- {
- throw new GOSIException( GOSIConstants.SEVERITY_FOUR,
- GOSIConstants.OCCUPATIONAL_HAZARDS,
- this.getClass().toString(),
- "searchInjuryList()",null,
- "SOI_ERR_4762");
- }
- for(int i=0;i<injuryListSize;i++)
- {
- InjuryPopDetails injuryDetails =
- (InjuryPopDetails)injuryList.get(i);
- GOSIDebug.debugMessages("InjuryNumber:" + injuryDetails.getInjuryNumber() +
- ": InjuryId:" + injuryDetails.getInjuryID() + ":");
- if(injuryDetails.getInjuryStatus().equals
- (OHConstants.INJ_STS_NOTIFIED))
- {
- // UnApproved Injury Details found for the
- // period entered, Please redefine your calculation period
- // or Approve the Injury record
- throw new GOSIException( GOSIConstants.SEVERITY_FOUR,
- GOSIConstants.OCCUPATIONAL_HAZARDS,
- this.getClass().toString(),
- "searchInjuryList()",null,
- "SOI_ERR_5189");
- }else
- {
- //setting injury date to complication date
- // if complication date is not null and
- // the person is having a valid engagement on complication date
- Timestamp injuryDate = injuryDetails.getInjuryDate();
- if(injuryDetails.getComplicationDate() != null)
- {
- if(injuryDetails.getIsEngagementPresentOnComplicationAndEligibleForOH())
- {
- injuryDate = injuryDetails.getComplicationDate();
- }
- //setting wage for the injured engagement
- injuryDetails = setTotalConWage(injuryDate,injuryDetails);
- }else
- {
- //setting wage for the injured engagement
- injuryDetails = setTotalConWage(injuryDate,injuryDetails);
- }
- }
- }
- // calculating the total contributory wage
- injuryList = getTotalContributorWage(injuryList);
- endTime = System.currentTimeMillis();
- elapsedTime = endTime - startTime;
- GOSIInstrumentationLog.writeInstrumentationToLog(
- this.getClass().toString(),
- "searchInjuryList()",
- elapsedTime);
- }
- catch (GOSIException ge)
- {
- throw ge;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("session:searchInjuryList:e:" + e);
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass().toString(),
- "searchInjuryList()",e,
- "CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp(con, ps, rs);
- }
- GOSIDebug.debugMessages("\t\t End searchInjuryList - MaintainOHAllowanceSessionEJB");
- return injuryList ;
- }
- /**
- * @METHOD NAME : setTotalConWage
- * @INFORMATION : This method is to calculate wage at the time of injury
- * @PARAM : class Timestamp,gosi.business.socialinsurance.occupationalhazards.injury.beans.InjuryPopDetails
- * @RETURN : class gosi.business.socialinsurance.occupationalhazards.injury.beans.InjuryPopDetails
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private InjuryPopDetails setTotalConWage
- (Timestamp injuryDate,InjuryPopDetails injuryDetails)
- throws GOSIException
- {
- GOSIDebug.debugMessages("\t\t Start setTotalConWage - MaintainOHAllowanceSessionEJB");
- try
- {
- // wage of previous month of injured month or if not employed on the
- // previous month wage as on injured month. Month should
- // be based on employer calender type.
- String calenderType = injuryDetails.getCalendarType();
- String injuryDateStr = OHUtilities.getDateStr(injuryDate,calenderType); //OHConstants.HIJRAH
- int month = OHUtilities.getMonth(injuryDateStr);
- int year = OHUtilities.getYear(injuryDateStr);
- int lastMonth =(month-1);
- int lastYear = year;
- if (lastMonth==0)
- {
- lastMonth = 12;
- lastYear = year-1;
- }
- Double wage = new Double("0.00");
- Long engagementId = injuryDetails.getEngagementId();
- Timestamp firstDate = OHUtilities.getGregDate
- (OHUtilities.getMonthStartDate(lastMonth,lastYear),
- calenderType);
- //OHConstants.HIJRAH);
- Timestamp lastDate = OHUtilities.getGregDate
- (GOSIDateUtilities.getMonthEndDate(lastMonth,lastYear),
- calenderType);
- //OHConstants.HIJRAH);
- GOSIDebug.debugMessages("LastDate:" + lastDate + ":");
- wage = getWageforMonth(engagementId,lastDate);
- if(wage == null)
- {
- GOSIDebug.debugMessages("FirstWage is null");
- lastDate = OHUtilities.getGregDate
- (GOSIDateUtilities.getMonthEndDate(month,year), calenderType);
- //OHConstants.HIJRAH);
- GOSIDebug.debugMessages("LastDate:" + lastDate);
- wage = getWageforMonth(engagementId,lastDate);
- }
- injuryDetails.setTotalConWage(wage);
- injuryDetails.setInjuredEstablishmentWage(wage);
- }
- catch (GOSIException ge)
- {
- throw ge;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("session:setTotalConWage:e:"+e);
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass().toString(),
- "setTotalConWage()",e,
- "CMN_ERR_1000");
- }
- GOSIDebug.debugMessages("\t\t End setTotalConWage - MaintainOHAllowanceSessionEJB");
- return injuryDetails;
- }
- /**
- * @METHOD NAME : setContributorDetails
- * @INFORMATION : This method is to set Contributor Details
- * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.InjuryPopDetails
- * @RETURN : class gosi.business.socialinsurance.occupationalhazards.injury.beans.InjuryPopDetails
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private InjuryPopDetails setContributorDetails(InjuryPopDetails injuryBean)
- throws GOSIException
- {
- PreparedStatement ps =null;
- ResultSet rs =null;
- try
- {
- //Query to get the contirbutor details like nationality and name
- //getting merged sin to check for other sin for the same person
- String sqlQuery =" select "+
- " a.NATIONALITYCODE,b.MERGEDSOCIALINSURANCENUMBER, "+
- " a.FIRSTNAME, a.SECONDNAME, a.THIRDNAME, a.SURNAME, "+
- " a.NAMEENGLISH from "+
- SITables.T_PERSON +" a, "+
- SITables.T_CONTRIBUTOR +" b "+
- " where b.CONTRIBUTORID =? and b.PERSONID = a.PERSONID ";
- ps = con.prepareStatement(sqlQuery);
- ps.setLong(1,injuryBean.getContributorId().longValue());
- GOSIDebug.debugMessages("SqlQuery:" + sqlQuery + ":");
- GOSIDebug.debugMessages("\t\t Param 1 :" + injuryBean.getContributorId() + ":");
- rs = ps.executeQuery();
- if(rs.next())
- {
- injuryBean.setNationality
- (new Short(rs.getShort("NATIONALITYCODE")));
- String name ="";
- if(rs.getObject("FIRSTNAME")!=null)
- {
- name =name+rs.getString("FIRSTNAME");
- }if(rs.getObject("SECONDNAME")!=null)
- {
- name =name+" "+rs.getString("SECONDNAME");
- }
- if(rs.getObject("THIRDNAME")!=null)
- {
- name =name+" "+rs.getString("THIRDNAME");
- }if(rs.getObject("SURNAME")!=null)
- {
- name =name+" "+rs.getString("SURNAME");
- }
- if(rs.getObject("MERGEDSOCIALINSURANCENUMBER")!= null)
- {
- injuryBean.setMergedSIN(new Long
- (rs.getLong("MERGEDSOCIALINSURANCENUMBER")));
- }
- injuryBean.setName(name);
- injuryBean.setContributorNameEnglish
- (rs.getString("NAMEENGLISH"));
- }
- return injuryBean;
- //returning the injury bean set with the details of contributor
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("session:setContributorDetails:e:"+e);
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass().toString(),
- "setContributorDetails()",e,
- "CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp(ps, rs);
- }
- }
- /**
- * @METHOD NAME : getWageforMonth
- * @INFORMATION : This method is to get contributor Wage for Month
- * @PARAM : class java.lang.Long,
- class java.sql.Timestamp
- * @RETURN : class java.lang.Double
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private Double getWageforMonth(Long engagementId,Timestamp endDate)
- throws GOSIException
- {
- java.sql.ResultSet rs = null;
- java.sql.PreparedStatement ps = null;
- Double wage = null;
- try
- {
- if(engagementId != null)
- {
- //Query to get the wage of the contributor on the month
- // end date who is covered for oh (monthly contributory wage)
- String sqlQuery=""+
- " select MONTHLYCONTRIBUTORYWAGE from "+
- SITables.T_ENGAGEMENTWAGECOVERAGE +" where "+
- " ENGAGEMENTID = ? and "+
- " EFFECTIVESTARTDATE <= ? and "+
- " (EFFECTIVEENDDATE is null or EFFECTIVEENDDATE >= ? ) "+
- " and STATUS in(?,?,?) "+
- " and APPROVALSTATUS in(?,?) "+
- //" and ACTIVEIND = ? "+
- " and COVERAGE in (?,?,?)";
- int i = 0;
- ps = con.prepareStatement(sqlQuery);
- ps.setLong(++i,engagementId.longValue());
- ps.setTimestamp(++i,endDate);
- ps.setTimestamp(++i,endDate);
- ps.setShort(++i,RegistrationConstants.VALID);
- ps.setShort(++i,RegistrationConstants.TO_BE_MADE_VALID);
- ps.setShort(++i,RegistrationConstants.TO_BE_MADE_VALID_WGECHG);
- ps.setShort(++i,
- RegistrationConstants.DATA_FINALLY_APPROVED.shortValue());
- ps.setShort(++i,
- RegistrationConstants.OLD_UNAPP_STATUS.shortValue());
- //ps.setByte(7,RegistrationConstants.ACTIVE_WORKER.byteValue());
- ps.setShort(++i,RegistrationConstants.OH);
- ps.setShort(++i,RegistrationConstants.OH_ANNUITY);
- ps.setShort(++i,RegistrationConstants.OH_ANNUITY_UNEMPLOYMENT);
- //psReg.setShort(2,OHConstants.ENGAGEMENT_STS_ACTIVE);
- GOSIDebug.debugMessages("Sqlquery :" + sqlQuery + ":");
- GOSIDebug.debugMessages("\t\t Param 1 :" + engagementId.longValue() + ":");
- GOSIDebug.debugMessages("\t\t Param 2 :" + endDate + ":");
- GOSIDebug.debugMessages("\t\t Param 3 :" + endDate + ":");
- GOSIDebug.debugMessages("\t\t Param 4 :" + RegistrationConstants.VALID + ":");
- GOSIDebug.debugMessages("\t\t Param 5 :" + RegistrationConstants.TO_BE_MADE_VALID + ":");
- GOSIDebug.debugMessages("\t\t Param 6 :" + RegistrationConstants.TO_BE_MADE_VALID_WGECHG + ":");
- GOSIDebug.debugMessages("\t\t Param 7 :" + RegistrationConstants.DATA_FINALLY_APPROVED.shortValue() + ":");
- GOSIDebug.debugMessages("\t\t Param 8 :" + RegistrationConstants.OLD_UNAPP_STATUS.shortValue() + ":");
- GOSIDebug.debugMessages("\t\t Param 9 :" + RegistrationConstants.OH + ":");
- GOSIDebug.debugMessages("\t\t Param 10:" + RegistrationConstants.OH_ANNUITY + ":");
- GOSIDebug.debugMessages("\t\t Param 11:" + RegistrationConstants.OH_ANNUITY_UNEMPLOYMENT + ":");
- rs = ps.executeQuery();
- while(rs.next())
- {
- if(rs.getObject("MONTHLYCONTRIBUTORYWAGE")!=null)
- {
- wage = new Double
- (rs.getDouble("MONTHLYCONTRIBUTORYWAGE"));
- }
- }
- GOSIDebug.debugMessages("Montyly Wage :" + wage + ":");
- }
- return wage;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("session:getWageforMonth:e:"+e);
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass().toString(),
- "getWageforMonth()",e,"CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities. cleanUp(ps,rs);
- }
- }
- /**
- * @METHOD NAME : getTotalContributorWage
- * @INFORMATION : This method is to get Total Contributor Wage
- * @PARAM : class java.util.ArrayList
- * @RETURN : class java.util.ArrayList
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private ArrayList getTotalContributorWage(ArrayList injuryList)
- throws gosi.core.util.GOSIException
- {
- java.sql.ResultSet rs = null;
- java.sql.PreparedStatement ps = null;
- try
- {
- /*
- calculating total wage =
- wage of injured establishment +
- wage of other simultanious engagements (if he is saudi only).
- For NON-Saudi there is no need to combine the wages from multiple
- engagements.
- */
- double wage = 0.00;
- String calendarType = OHConstants.HIJRAH;
- String sqlQuery = "";
- ArrayList engagementList = new ArrayList();
- for(int i=0;i<injuryList.size();i++)
- {
- InjuryPopDetails injuryBean =(InjuryPopDetails)injuryList.get(i);
- if(injuryBean.getMergedSIN() != null)
- {
- //Query to get list of engagements if the person has more
- // than one sin
- sqlQuery = " select eng.ENGAGEMENTID,eng.ESTABLISHMENTID from T_CONTRIBUTOR con ,"+
- " T_ENGAGEMENT eng where "+
- " eng.CONTRIBUTORID = con.CONTRIBUTORID "+
- " and con.MERGEDSOCIALINSURANCENUMBER = ? "+
- " and eng.JOININGDATE <=? and "+
- " ( eng.LEAVINGDATE >=? or eng.LEAVINGDATE is null) and "+
- " eng.ENGAGEMENTSTATUS != ? ";
- }else
- {
- //Query to get list of engagements if the person has only one sin
- sqlQuery = "select ENGAGEMENTID,ESTABLISHMENTID from T_ENGAGEMENT "+
- " where CONTRIBUTORID =? and JOININGDATE <=? and "+
- " ( LEAVINGDATE >=? or LEAVINGDATE is null) and "+
- " ENGAGEMENTSTATUS != ? ";
- }
- GOSIDebug.debugMessages("Injury number:" + injuryBean.getInjuryNumber());
- //logic checks if the person has valid engagement on complication date
- Timestamp injuryDate = injuryBean.getInjuryDate();
- if(injuryBean.getComplicationDate()!=null)
- {
- if(injuryBean.getIsEngagementPresentOnComplicationAndEligibleForOH())
- {
- injuryDate = injuryBean.getComplicationDate();
- }
- }
- calendarType = injuryBean.getCalendarType();
- ps = con.prepareStatement(sqlQuery);
- GOSIDebug.debugMessages("SqlQuery:" + sqlQuery + ":");
- if(injuryBean.getMergedSIN() != null)
- {
- ps.setLong(1,(injuryBean.getMergedSIN()).longValue());
- GOSIDebug.debugMessages("\t\t Param 1 :" + (injuryBean.getMergedSIN()).longValue() + ":");
- }else
- {
- ps.setLong(1,(injuryBean.getContributorId()).longValue());
- GOSIDebug.debugMessages("\t\t Param 1 :" + (injuryBean.getContributorId()).longValue() + ":");
- }
- ps.setTimestamp(2,injuryDate);
- ps.setTimestamp(3,injuryDate);
- ps.setShort(4,
- RegistrationConstants.ENG_JOIN_IN_PROGRESS.shortValue());
- //ps.setByte(5,RegistrationConstants.ACTIVE_WORKER.byteValue());
- GOSIDebug.debugMessages("\t\t Param 2 :" + injuryDate + ":");
- GOSIDebug.debugMessages("\t\t Param 3 :" + injuryDate + ":");
- GOSIDebug.debugMessages("\t\t Param 4 :" +
- RegistrationConstants.ENG_JOIN_IN_PROGRESS.shortValue() + ":");
- rs = ps.executeQuery();
- while(rs.next())
- {
- // this logic adds each unique engagement into the list
- Long engagementId = new Long(rs.getLong("ENGAGEMENTID"));
- Long establishmentId = new Long(rs.getLong("ESTABLISHMENTID"));
- int engagementListSize = engagementList.size();
- boolean flag = true;
- for(int j=0;j<engagementListSize;j=j+2)
- {
- Long engagementListId = (Long)engagementList.get(j);
- if(engagementId.equals(engagementListId))
- {
- flag = false;
- break;
- }
- }
- //Dont pay benefits to the Establishmetn that not paying contribution
- boolean isEstPaycontributions = OHUtilities.isEligibleforOHCoverage(establishmentId,injuryDate);
- if(flag /* && isEstPaycontributions*/)
- {
- GOSIDebug.debugMessages("ENGAGEMENTID:" + engagementId);
- engagementList.add(engagementId);
- engagementList.add(injuryDate);
- }
- }
- }
- // if the person has more than one injury pay to contriubtor
- // else follow the rule as below
- int injuryListSize = injuryList.size();
- Short payableTo = OHConstants.OH_BNFT_PAY_TO_CON;
- if(engagementList.size() > 2)
- {
- payableTo = OHConstants.OH_BNFT_PAY_TO_CON;
- }else
- {
- InjuryPopDetails injuryDetailsBean = (InjuryPopDetails)injuryList.get(0);
- if(OHConstants.OH_BNFT_PAY_TO_EMP.equals
- (injuryDetailsBean.getBenefitPayableTo())&&
- null == injuryDetailsBean.getWageStopDate())
- {
- payableTo = OHConstants.OH_BNFT_PAY_TO_EMP;
- }else
- {
- payableTo = OHConstants.OH_BNFT_PAY_TO_CON;
- }
- }
- boolean isContributorSaudi = false;
- for(int j=0;j<injuryList.size();j++)
- {
- InjuryPopDetails injuryDetailsBean =(InjuryPopDetails)injuryList.get(j);
- injuryDetailsBean.setBenefitPayableTo(payableTo);
- GOSIDebug.debugMessages("Injury number:" + injuryDetailsBean.getInjuryNumber());
- GOSIDebug.debugMessages("Nationality code:" + injuryDetailsBean.getNationality());
- if(OHConstants.NATIONALITY_CODE_SAUDI.equals(injuryDetailsBean.getNationality()))
- {
- isContributorSaudi = true;
- }
- }
- GOSIDebug.debugMessages("isContributorSaudi:" + isContributorSaudi);
- // if contributor is non saudi calculate the wage only for the
- // the injured engagement
- for(int i=0;i<engagementList.size();i=i+2)
- {
- Long engagementId =(Long)engagementList.get(i);
- boolean flag = true;
- Double tempWage = null;
- for(int j=0;j<injuryList.size();j++)
- {
- InjuryPopDetails injuryDetailsBean =(InjuryPopDetails)injuryList.get(j);
- if(engagementId.equals(injuryDetailsBean.getEngagementId()))
- {
- flag = false;
- tempWage = injuryDetailsBean.getTotalConWage();
- break;
- }
- }
- // logic for calculating the wage.
- if(flag && isContributorSaudi)
- {
- //Timestamp injuryDate = ((InjuryPopDetails)injuryList.get(injuryListSize-1)).getInjuryDate();\
- Timestamp injuryDate =(Timestamp)engagementList.get(i+1);
- String injuryDateStr = OHUtilities.getDateStr(injuryDate,calendarType);//OHConstants.HIJRAH
- int month =OHUtilities.getMonth(injuryDateStr);
- int year =OHUtilities.getYear(injuryDateStr);
- int lastMonth =(month-1);
- int lastYear = year;
- if (lastMonth==0)
- {
- lastMonth = 12;
- lastYear = year-1;
- }
- Timestamp endDate = OHUtilities.getGregDate
- (GOSIDateUtilities.getMonthEndDate(lastMonth,lastYear),
- calendarType);//OHConstants.HIJRAH
- tempWage = getWageforMonth(engagementId,endDate);
- if(tempWage == null)
- {
- endDate = OHUtilities.getGregDate(GOSIDateUtilities.getMonthEndDate(month,year),calendarType);//OHConstants.HIJRAH
- tempWage = getWageforMonth(engagementId,endDate);
- }
- }
- GOSIDebug.debugMessages("EstablishmentId:" + engagementId.longValue() + ":Wage:" + tempWage+ ":");
- if(tempWage != null)
- {
- wage = wage + tempWage.doubleValue();
- }
- }
- // setting the total contributor wage on all beans on list
- for(int j=0;j<injuryList.size();j++)
- {
- InjuryPopDetails injuryDetailsBean =(InjuryPopDetails)injuryList.get(j);
- injuryDetailsBean.setTotalConWage(new Double(wage));
- GOSIDebug.debugMessages("InjuryNumber:"+injuryDetailsBean.getInjuryNumber());
- }
- return injuryList;
- //returning the list
- }
- catch(GOSIException ge)
- {
- GOSIDebug.debugMessages("Session:getTotalContibutorWage :ge:"+ge);
- throw ge;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("session:getTotalContibutorWage :e:"+e);
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "getTotalContibutorWage()",e,"CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities. cleanUp(ps,rs);
- }
- }
- /**
- * @METHOD NAME : checkBenefitPeriod
- * @INFORMATION : This method is to check whether benefit
- calculated for the Benefit Period
- * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.InjuryPopDetails
- * @RETURN : void
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- public void checkBenefitPeriod(InjuryPopDetails injuryBean)
- throws GOSIException
- {
- long startTime = 0;
- long endTime = 0;
- long elapsedTime = 0;
- startTime = System.currentTimeMillis();
- PreparedStatement ps = null;
- ResultSet rs = null;
- try
- {
- // this query returns the list of benefits payed for
- // the period, if benefits found throw error
- con = GOSIUtilities.getConnection
- (GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
- Timestamp benefitStartDate = injuryBean.getBenefitStartDate();
- Timestamp benefitEndDate = injuryBean.getBenefitEndDate();
- String sqlQuery ="select OHBENID from "+
- SITables.T_OHBENEFIT +
- " where BENSTATUS != ? and BENSTDATE <= ? and "+
- " BENENDDATE >= ? and "+
- " OHBENCODE in(?,?) and "+
- " CONTRIBUTORID = "+
- " (select CONTRIBUTORID from "+SITables.T_CONTRIBUTOR +
- " where SOCIALINSURANCENUMBER = ?) ";
- ps= con.prepareStatement(sqlQuery) ;
- ps.setShort(1,OHConstants.OH_BNFT_STS_CANCELLED.shortValue());
- ps.setTimestamp(2,benefitEndDate);
- ps.setTimestamp(3,benefitStartDate);
- ps.setShort(4,OHConstants.OH_ALWNC_DAIlY_INPATIENT.shortValue());
- ps.setShort(5,OHConstants.OH_ALWNC_DAIlY_OUTPATIENT.shortValue());
- ps.setLong(6,injuryBean.getSocialInsuranceNumber().longValue());
- GOSIDebug.debugMessages("sqlQuery:" + sqlQuery + ":");
- boolean flag = false;
- rs = ps.executeQuery();
- while (rs.next())
- {
- flag = true;
- }
- if(flag)
- {
- //Redefine your Benefit period as the period contains Periods
- //for which OH Allowance has already been calculated
- throw new GOSIException(GOSIConstants.SEVERITY_THREE,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass().toString(),
- "checkBenefitPeriod()",
- null,
- "SOI_ERR_5190");
- }
- endTime = System.currentTimeMillis();
- elapsedTime = endTime - startTime;
- GOSIInstrumentationLog.writeInstrumentationToLog(
- this.getClass().toString(),
- "checkBenefitPeriod()",
- elapsedTime);
- }
- catch (GOSIException ge)
- {
- throw ge;
- }
- catch (Exception e)
- {
- GOSIDebug.debugMessages("session:checkBenefitPeriod :e:"+e);
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "checkBenefitPeriod()",e,"CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp(con,ps,rs);
- }
- }
- /**
- * @METHOD NAME : saveOHAllowance
- * @INFORMATION : This method is to save OH Allowance into the T_ohbenefit table
- * @PARAM : class java.util.ArrayList,
- class gosi.core.workflow.beans.WorkflowParamBean,
- class java.lang.Long
- * @RETURN : class java.lang.String
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- public String saveOHAllowance(ArrayList benefitList,
- WorkflowParamBean workflowParamBean,Long socInsNum,ArrayList contactList)
- throws GOSIException
- {
- long startTime = 0;
- long endTime = 0;
- long elapsedTime = 0;
- startTime = System.currentTimeMillis();
- String message = "";
- try
- {
- GOSIDebug.debugMessages(""+OHConstants.OH_ALLOWANCE_ENTITY_JNDI);
- OHAllowanceEntityHome home=(OHAllowanceEntityHome)
- ServiceLocator.getInstance().getRemoteHome(
- OHConstants.OH_ALLOWANCE_ENTITY_JNDI,
- OHAllowanceEntityHome.class);
- Timestamp currentTime=new Timestamp (System.currentTimeMillis());
- Long injuryId=((OHAllowanceBean)benefitList.get(0)).getInjuryId();
- //checking bank details if payable to bank
- boolean isBankDetailsPresent =
- isBankDetailsPresent(benefitList,socInsNum);
- GOSIDebug.debugMessages("is bank details present:"+isBankDetailsPresent);
- // checking if an autorized person is present
- // if mode is OH_BNFT_PAY_TO_AUTH_PERSON
- for(int i=0;i<benefitList.size();i++)
- {
- OHAllowanceBean benefitBean=(OHAllowanceBean)benefitList.get(i);
- if(OHConstants.OH_BNFT_PAY_TO_AUTH_PERSON.equals(benefitBean.getBenefitPayableTo()))
- {
- isAuthPersonPresent(benefitBean.getContributorId());
- break;
- }
- }
- // validating the contact details of the contributor
- validateContactDetails(contactList,benefitList);
- if(isBankDetailsPresent)
- {
- //inserting benefit details into the T_ohbenefit table
- for(int i=0;i<benefitList.size();i++)
- {
- OHAllowanceBean benefitBean=(OHAllowanceBean)benefitList.get(i);
- benefitBean.setCreationTimestamp(currentTime);
- benefitBean.setOhBenId(GOSIUtilities.getPrimaryKey
- ("T_OHBENEFIT",benefitBean.getCreatedBy()));
- OHAllowanceEntity remoteEntity=(OHAllowanceEntity)home.create(benefitBean);
- GOSIDebug.debugMessages("After calling entity:"+remoteEntity);
- }
- //calling the workflow interface
- if(workflowParamBean!=null)
- {
- GOSIDebug.debugMessages("workflowParamBean :"+workflowParamBean);
- workflowParamBean.setrecordDescription(
- workflowParamBean.getrecordDescription()+" - "+socInsNum);
- String userName = GOSIUtilities.startWorkflow(workflowParamBean);
- GOSIDebug.debugMessages("user :"+userName);
- message = GOSIErrorMessages.getErrorDesc("SOI_ERR_5194")+
- " "+userName;
- }
- }else
- {
- //Please enter contributor bank details before saving
- throw new GOSIException(GOSIConstants.SEVERITY_THREE,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass().toString(),
- "saveOHAllowance()",null,"SOI_ERR_4541");
- }
- endTime = System.currentTimeMillis();
- elapsedTime = endTime - startTime;
- GOSIInstrumentationLog.writeInstrumentationToLog(
- this.getClass().toString(),
- "saveOHAllowance()",
- elapsedTime);
- return message;
- }
- catch(GOSIException gosiException)
- {
- GOSIDebug.debugMessages("session:save:ge:message:"+gosiException.getMessage());
- ctx.setRollbackOnly();
- throw gosiException;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("session:save: :The exception is "+e);
- ctx.setRollbackOnly();
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "saveOHAllowance()",e,"CMN_ERR_1000");
- }
- }
- /**
- * @METHOD NAME : isAuthPersonPresent
- * @INFORMATION : This method is to is check if Authorized Person Present or not
- * @PARAM : class java.lang.Long
- * @RETURN : boolean
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private boolean isAuthPersonPresent(Long contributorId)
- throws GOSIException
- {
- PreparedStatement ps = null;
- ResultSet rs = null;
- String payeeName = null;
- boolean isAuthPersonPresent = false;
- try
- {
- //Query to get the authorized person for a contributor
- String sqlQuery = " select AUTHORIZEDPERSONID from "+
- SITables.T_OHAUTHORIZEDPERSON +
- " where CONTRIBUTORID =? and STATUS = ? ";
- con = GOSIUtilities.getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
- ps = con.prepareStatement(sqlQuery);
- ps.setLong(1,contributorId.longValue());
- ps.setShort(2,OHConstants.AUTHORIZED_PERSON_STATUS_ACTIVE.shortValue());
- rs = ps.executeQuery();
- if(rs.next())
- {
- isAuthPersonPresent = true;
- }
- // if authorized person is present return true else
- // throw error
- if(!isAuthPersonPresent)
- {
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
- "isAuthPersonPresent()",null,"SOI_ERR_5507");
- }
- return isAuthPersonPresent;
- }
- catch (GOSIException ge)
- {
- throw ge;
- }
- catch(Exception se)
- {
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
- "isAuthPersonPresent()",se,"CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp(con,ps,rs);
- }
- }
- /**
- * @METHOD NAME : modifyOHAllowance
- * @INFORMATION : This method is to modify OH Allowance
- * @PARAM : class java.util.ArrayList,
- class java.util.ArrayList,
- class gosi.business.socialinsurance.occupationalhazards.injury.beans.InjuryPopDetails,
- class gosi.core.workflow.beans.WorkflowParamBean,
- class java.lang.String,
- boolean,
- class gosi.core.dms.beans.DMSRequestHeaderBean
- * @RETURN : class java.lang.String
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- public String modifyOHAllowance
- (ArrayList benefitList,ArrayList contactList,InjuryPopDetails injuryBean,
- WorkflowParamBean workflowParamBean,String mode,boolean canSendForWorkflow,DMSRequestHeaderBean headerBean)
- throws GOSIException
- {
- long startTime = 0;
- long endTime = 0;
- long elapsedTime = 0;
- startTime = System.currentTimeMillis();
- String message = GOSIErrorMessages.getErrorDesc("SOI_ERR_4192");
- try
- {
- // This method updates, deletes the records in the oh benefit table
- // updates the status during the workflow and
- // deletes the records if benefit is cancelled
- Short breakUpType = null;
- FinancialAccountingInterface faInterface;
- faInterface = FinanceImplProxy.getFAInterface();
- Long userId = new Long (workflowParamBean.getUserId());
- Long workflowId = ((OHAllowanceBean)benefitList.get(0)).
- getWorkflowId();
- Short fieldOffice = injuryBean.getFieldOffice();
- OHAllowanceEntityHome home=(OHAllowanceEntityHome)
- ServiceLocator.getInstance().getRemoteHome(
- OHConstants.OH_ALLOWANCE_ENTITY_JNDI,
- OHAllowanceEntityHome.class);
- Timestamp currentTime=new Timestamp (System.currentTimeMillis());
- // method to trow error if it reaches the inbox of
- // interior audit manager, double check done for change of workflow
- if(OHConstants.APPROVE_INT_AUD_HEAD.equals(mode)&&
- GOSIConstants.COMPLETED.equals
- (workflowParamBean.getRoutingCriterion()))
- {
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "modifyOHAllowance()",null,"CMN_ERR_1000");
- }
- // This is the final approval where the status is
- // updated as approved and the finance interface called
- if(OHConstants.APPROVE_INT_AUD_CLK.equals(mode)&&
- GOSIConstants.COMPLETED.equals
- (workflowParamBean.getRoutingCriterion()))
- {
- GOSIDebug.debugMessages("calling interface");
- //Interface with finance
- OHAllowanceBean benefitBean = (OHAllowanceBean) benefitList.get(0);
- Long partyCode = null;
- Short paymentMode = null;
- for (int counter = 0; counter < benefitList.size(); counter++)
- {
- OHAllowanceBean allowanceBean = (OHAllowanceBean) benefitList.get(counter);
- if(allowanceBean.getPaymentMode() != null)
- {
- paymentMode = allowanceBean.
- getPaymentMode();
- break;
- }
- }
- int partyType=0;
- GOSIDebug.debugMessages("session : bnft pay 2 :"
- +benefitBean.getBenefitPayableTo());
- // getting the distict list for the particular transaction
- // it will return either contributor , employer or both
- // based on who its paying.
- ArrayList payeeList = getDistinctPayableTo(workflowId);
- GOSIDebug.debugMessages("payeee list" + payeeList.size());
- for(int i=0 ; i<payeeList.size();i++)
- {
- CNInterfaceBean oCNInterfaceBean = new CNInterfaceBean();
- ArrayList detailList=new ArrayList();
- oCNInterfaceBean.setCreditNoteType
- (new Integer(FAInterfaceConstants.OH_ALLOWANCE_CN));
- oCNInterfaceBean.setTransactionDate(currentTime);
- oCNInterfaceBean.setLocationCode(new Long("" + fieldOffice));
- Short payeeType=(Short)payeeList.get(i);
- String partyName = "";
- GOSIDebug.debugMessages("partyType:"+payeeType);
- GOSIDebug.debugMessages("partyCode:"+benefitBean.getPartyCode());
- GOSIDebug.debugMessages("payment mode" +benefitBean.getPaymentMode() );
- // if payable to is hospital -- currently this option is disabled
- if((OHConstants.OH_BNFT_PAY_TO_HOS).equals(payeeType))
- {
- GOSIDebug.debugMessages("payable to hospital");
- partyType=FAInterfaceConstants.HOSPITALS_PARTYTYPE;
- fieldOffice = ((OHAllowanceBean)benefitList.get(0)).
- getFieldofficeCode();
- for(int k=0 ; k<benefitList.size();k++)
- {
- OHAllowanceBean bnftBean =
- (OHAllowanceBean)benefitList.get(k);
- if(OHConstants.OH_BNFT_PAY_TO_HOS .equals
- (bnftBean.getBenefitPayableTo()))
- {
- partyCode = bnftBean.getPartyCode();
- break;
- }
- }
- }//if payable to is employer
- else if((OHConstants.OH_BNFT_PAY_TO_EMP).equals(payeeType))
- {
- GOSIDebug.debugMessages("payable to Employer");
- partyType=FAInterfaceConstants.EMPLOYER_PARTYTYPE;
- for(int k=0 ; k<benefitList.size();k++)
- {
- OHAllowanceBean bnftBean =
- (OHAllowanceBean)benefitList.get(k);
- if (OHConstants.OH_BNFT_PAY_TO_EMP.equals(bnftBean.getBenefitPayableTo()))
- {
- partyCode = bnftBean.getPartyCode();
- break;
- }
- }
- partyName = injuryBean.getEstablishmentName();
- // partyCode=benefitBean.getPartyCode();
- }// if payable to is contributor or authorized person for contributor
- else if(OHConstants.OH_BNFT_PAY_TO_CON.equals(payeeType)
- ||OHConstants.OH_BNFT_PAY_TO_AUTH_PERSON.equals(payeeType))
- {
- GOSIDebug.debugMessages("payable to Contributor");
- partyType = FAInterfaceConstants.CONTRIBUTOR_PARTYTYPE;
- partyCode = injuryBean.getSocialInsuranceNumber();
- partyName = injuryBean.getName();
- OHServices ohServices = new OHServices();
- // method to get the break up type in case of contributors
- breakUpType = ohServices.getPartyAccountBreakUpType
- (injuryBean.getInjuryID(),null,null);
- }
- GOSIDebug.debugMessages("\n\n partyType:"+payeeType);
- GOSIDebug.debugMessages("partyCode:"+partyCode);
- oCNInterfaceBean.setPartyType(new Integer(partyType));
- oCNInterfaceBean.setPartyCode(partyCode);
- oCNInterfaceBean.setCreatedBy(userId);
- oCNInterfaceBean.setPayeeName(partyName);
- if(breakUpType!=null)
- {
- oCNInterfaceBean.setBreakUpType(breakUpType);
- }
- // if paybable to contributor or authorized person
- // check if contributor/authorizedperson is present as party in finance
- // else create the party first
- if(OHConstants.OH_BNFT_PAY_TO_CON.equals(payeeType)
- ||OHConstants.OH_BNFT_PAY_TO_AUTH_PERSON.equals(payeeType))
- {
- ContributorBean contributorBean = ContributorUtilities.
- displayContributorForSIN(injuryBean.getSocialInsuranceNumber());
- GOSIDebug.debugMessages("contactId:"+contributorBean.getContactId());
- if(OHConstants.OH_BNFT_PAY_TO_AUTH_PERSON.equals(payeeType))
- {
- String authPersonName = getPayeeName(contributorBean.getContributorId());
- if(authPersonName!=null &&
- !"".equals(authPersonName))
- {
- oCNInterfaceBean.setPayeeName(authPersonName);
- }
- }
- GOSIDebug.debugMessages("Payee Name :" + oCNInterfaceBean.getPayeeName());
- Long contactId = contributorBean.getContactId();
- GOSIDebug.debugMessages("contactId:"+contactId);
- HashMap inputPartyCodePresent = new HashMap();
- HashMap outputPartyCodePresent = new HashMap();
- Boolean isPartyCodePresent = null;
- inputPartyCodePresent.put("moduleId", new Short( GOSIConstants.OCCUPATIONAL_HAZARDS_ID));
- inputPartyCodePresent.put("partyType", new Integer (FAInterfaceConstants.CONTRIBUTOR_PARTYTYPE));
- inputPartyCodePresent.put("partyCode", partyCode);
- inputPartyCodePresent.put("methodDescription",
- FAInterfaceConstants.VALIDATE_PARTY);
- outputPartyCodePresent = faInterface.invokeService(inputPartyCodePresent);
- if(outputPartyCodePresent != null)
- {
- isPartyCodePresent = (Boolean)
- outputPartyCodePresent.get("partyExists");
- GOSIDebug.debugMessages("isPartyCodePresent" +
- isPartyCodePresent);
- if(isPartyCodePresent != null)
- {
- if(new Boolean(false).equals(isPartyCodePresent))
- {
- GOSIDebug.debugMessages("inside not present party");
- /* Store the contributor details in
- PartyInterfaceBean
- to create party type
- for the contributor*/
- PartyInterfaceBean partyBean = new
- PartyInterfaceBean();
- partyBean.setPartyNameArb
- (injuryBean.getName());
- partyBean.setPartyType(new Integer(
- FAInterfaceConstants.CONTRIBUTOR_PARTYTYPE));
- partyBean.setPartyCode
- (partyCode);
- partyBean.setPaymentTerm(new Long
- ("" + FAInterfaceConstants.
- IMMEDIATE_PAYMENTTERM));
- //Added to get the breakUpType of party
- partyBean.setBreakUpType(breakUpType);
- //Addition ends here
- /* To be removed has been removed :) */
- partyBean.setContactID
- (contactId);
- partyBean.setContactType(new Integer (FAInterfaceConstants.
- INDIVIDUAL_CONTACT_TYPE));
- GOSIDebug.debugMessages("getContactId:"+partyBean.getContactID());
- /* To be removed */
- GOSIDebug.debugMessages
- ("last modified by " +
- userId);
- partyBean.setCreatedBy
- (userId);
- partyBean.setCreationTimestamp
- (new Timestamp
- (System.currentTimeMillis()));
- partyBean.setModuleId(GOSIConstants.
- OCCUPATIONAL_HAZARDS_ID);
- HashMap inputPartyDetails = new HashMap();
- HashMap outputPartyDetails = new HashMap();
- inputPartyDetails.put("methodDescription",
- FAInterfaceConstants.PARTY_INTERFACE);
- inputPartyDetails.put
- ("interfaceBean",partyBean);
- outputPartyDetails =
- faInterface.invokeService(inputPartyDetails);
- GOSIDebug.debugMessages("outputPartyDetails" +
- outputPartyDetails);
- }
- }
- }
- }
- // payment mode to be set as Local cheque
- // if payable to is employer or hospital
- if((OHConstants.OH_BNFT_PAY_TO_HOS.equals(payeeType)
- ||(OHConstants.OH_BNFT_PAY_TO_EMP).equals(payeeType)))
- {
- oCNInterfaceBean.setPaymentMode
- (new Integer
- (FAInterfaceConstants.LC_CHEQUE));
- }
- else if((OHConstants.OH_BNFT_PAY_TO_CON).equals(payeeType))
- {
- // else if payment mode is contributor set the payment mode
- // specified by the user . bank transfer is currently disabled
- if(paymentMode != null)
- {
- if(OHConstants.PAYMENT_MODE_BANK_TRANSFER.
- equals(paymentMode))
- {
- oCNInterfaceBean.setPaymentMode
- (new Integer
- (FAInterfaceConstants.ACCOUNT_TRANSFER));
- }
- else if(OHConstants.PAYMENT_MODE_CHEQUE.
- equals(paymentMode))
- {
- oCNInterfaceBean.setPaymentMode
- (new Integer
- (FAInterfaceConstants.LC_CHEQUE));
- }
- else if(OHConstants.PAYMENT_MODE_CHEQUE_OVERSEAS.
- equals(paymentMode))
- {
- oCNInterfaceBean.setPaymentMode
- (new Integer(FAInterfaceConstants.LC_CHEQUE));
- oCNInterfaceBean.setLocationCode
- (new Long(""+OHConstants.FIELD_OFFICE_GOSI_RIYADH));
- }
- }
- else
- {
- oCNInterfaceBean.setPaymentMode
- (new Integer
- (FAInterfaceConstants.LC_CHEQUE));
- }
- }else
- {
- oCNInterfaceBean.setPaymentMode
- (new Integer
- (FAInterfaceConstants.LC_CHEQUE));
- }
- // setting currency ,exchange rate and other required values
- oCNInterfaceBean.setCurrency
- (new Integer(FAInterfaceConstants.LC_CURRENCY));
- int baseCurrency = GOSIUtilities.getBaseCurrency();
- GOSIDebug.debugMessages("base currency " + baseCurrency );
- if(baseCurrency ==
- FAInterfaceConstants.LC_CURRENCY)
- {
- oCNInterfaceBean.setExchangeRateType(new Integer
- (FAInterfaceConstants.ERT_NONE));
- oCNInterfaceBean.setExchangeRate
- (new Double(FAInterfaceConstants.
- LC_EXCHANGERATE));
- }
- else
- {
- oCNInterfaceBean.setExchangeRateType(new Integer
- (FAInterfaceConstants.ERT_CORPORATE));
- }
- GOSIDebug.debugMessages("exchange rate type " +
- oCNInterfaceBean.getExchangeRateType());
- oCNInterfaceBean.setPaymentTerm(new Integer
- (FAInterfaceConstants.IMMEDIATE_PAYMENTTERM));
- oCNInterfaceBean.setStatus(new Integer
- (FAInterfaceConstants.WORKFLOW_NOT_REQUIRED));
- oCNInterfaceBean.setModuleId
- (GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
- // getting the details for each distict payee type
- HashMap benefitDetails = getDetailsList
- (benefitBean.getWorkflowId(),payeeType,fieldOffice,paymentMode);
- detailList=(ArrayList)benefitDetails.get("detailList");
- Double total = (Double)benefitDetails.get("total");
- oCNInterfaceBean.setAmountFC(total);
- String narration = GOSIErrorMessages.getErrorDesc("SOI_ERR_5115")
- + " "
- + total
- + " for "
- + GOSIErrorMessages.getErrorDesc("SOI_ERR_5582")
- + " "
- + injuryBean.getSocialInsuranceNumber().longValue();
- GOSIDebug.debugMessages("SIN :" + injuryBean.getSocialInsuranceNumber().longValue() + ":");
- GOSIDebug.debugMessages("narration :" + narration + ":");
- oCNInterfaceBean.setNarration(narration);
- /* commented on 4/16/2005 bcos payment mode is set earlier
- oCNInterfaceBean.setPaymentMode
- (new Integer
- (FAInterfaceConstants.LC_CHEQUE));
- */
- GOSIDebug.debugMessages("PAYMENT MODE &&&& " +
- oCNInterfaceBean.getPaymentMode());
- // The below logic explains how to adjust the amount
- // if any negative amount is present as adjustment
- // the negative amount will be adjusted with the next positive detail
- double adjustmentAmount = 0.00;
- boolean isNeedtobeAdjusted = false;
- for(int j=0;j<detailList.size();j++)
- {
- CNInterfaceDetailBean oDetailBean=
- (CNInterfaceDetailBean)detailList.get(j);
- if(isNeedtobeAdjusted)
- {
- oDetailBean.setAmountFC(new Double(
- oDetailBean.getAmountFC().doubleValue()+adjustmentAmount));
- adjustmentAmount =0.00;
- isNeedtobeAdjusted = false;
- }
- if(oDetailBean.getAmountFC().doubleValue()<0)
- {
- adjustmentAmount = oDetailBean.getAmountFC().doubleValue();
- isNeedtobeAdjusted = true;
- detailList.remove(j);
- j--;
- }
- GOSIDebug.debugMessages("\n getAmountFC :"+oDetailBean.getAmountFC());
- GOSIDebug.debugMessages("\n ShortDesc :"+oDetailBean.getShortDesc());
- GOSIDebug.debugMessages("ReasonCode :"+oDetailBean.getReasonCode());
- }
- GOSIDebug.debugMessages("detail List size :"+detailList.size());
- oCNInterfaceBean.setCnInterfaceDetailList(detailList);
- java.util.HashMap interfaceInput=new HashMap();
- interfaceInput.put("interfaceBean",oCNInterfaceBean);
- interfaceInput.put("methodDescription",
- FAInterfaceConstants.CN_INTERFACE);
- GOSIDebug.debugMessages("before invoking FA Interface");
- GOSIDebug.debugMessages("Payee Name :"+oCNInterfaceBean.getPayeeName());
- //calling the finance interface
- //the return value will be stored as the journal header id
- java.util.HashMap returnValue =
- faInterface.invokeService(interfaceInput);
- Long headerId=(Long)returnValue.get("returnValue");
- GOSIDebug.debugMessages("HeaderId============="+headerId);
- // method to update the journal header id in benefit bean
- benefitList=setJournalType(benefitList,payeeType,headerId);
- }
- }
- GOSIDebug.debugMessages("interface closed");
- // the benefit records will be updated based on mode
- for(int i=0;i<benefitList.size();i++)
- {
- OHAllowanceBean benefitBean=(OHAllowanceBean)benefitList.get(i);
- // the benefit record is inserted if mode is new
- if(benefitBean.getMode()==benefitBean.NEW_MODE)
- {
- benefitBean.setCreationTimestamp(currentTime);
- benefitBean.setOhBenId(GOSIUtilities.getPrimaryKey
- ("T_OHBENEFIT",benefitBean.getCreatedBy()));
- benefitBean.setInjuryId(injuryBean.getInjuryID());
- benefitBean.setContributorId(injuryBean.getContributorId());
- OHAllowanceEntity remoteEntity=(OHAllowanceEntity)home.create(benefitBean);
- }// benefit record is deleted if mode is delete
- else if(benefitBean.getMode()==benefitBean.DELETE_MODE)
- {
- benefitList.remove (i--);
- benefitBean.setLastModifiedTimestamp(currentTime);
- OHAllowanceEntity remoteEntity=
- (OHAllowanceEntity)home.findByPrimaryKey
- (benefitBean.getOhBenId());
- remoteEntity.remove();
- }// else the benefit record is modified
- else
- {
- benefitBean.setLastModifiedTimestamp(currentTime);
- OHAllowanceEntity remoteEntity=
- (OHAllowanceEntity)home.findByPrimaryKey
- (benefitBean.getOhBenId());
- remoteEntity.modifyOHBenefits(benefitBean);
- }
- }
- GOSIDebug.debugMessages("OHAllowance Updated sucessfully");
- if(OHConstants.REENTER.equals(mode))
- {
- /* Verify autorized person details */
- for (int i = 0; i < benefitList.size (); i++)
- {
- OHAllowanceBean benefitBean = (OHAllowanceBean) benefitList.get (i);
- if(OHConstants.OH_BNFT_PAY_TO_AUTH_PERSON.equals (benefitBean.getBenefitPayableTo ()))
- {
- isAuthPersonPresent (benefitBean.getContributorId ());
- break;
- }
- }
- /* Validate contact details */
- validateContactDetails (contactList, benefitList);
- /* Create recovery records if benefit amount < 0 */
- HashMap updateRecoveryMap = updateRecovery (benefitList, workflowParamBean, injuryBean);
- double totalAmount = ((Double) updateRecoveryMap.get ("totalAmount")).doubleValue ();
- if (totalAmount < 0)
- {
- message = GOSIErrorMessages.getErrorDesc ("SOI_ERR_5194");
- if(updateRecoveryMap.get ("workFlowEmployer") != null)
- {
- message = message + " : " + (String) updateRecoveryMap.get ("workFlowEmployer");
- }
- if(updateRecoveryMap.get ("workFlowContributor") != null)
- {
- message = message + " : " + (String) updateRecoveryMap.get ("workFlowContributor");
- }
- }
- /* Approval is not needed if recovery is indicated */
- if(workflowParamBean.getRoutingCriterion().equals(GOSIConstants.COMPLETED))
- {
- workflowParamBean.setRangeCheck (
- GOSIConstants.RANGECHECK_IS_TYPE, (totalAmount < 0) ? OHConstants.RANGE_VALUE_STOP.longValue ()
- : OHConstants.RANGE_VALUE_CONTINUE.longValue ());
- }
- workflowParamBean.setPrimaryKeyOfTherecord (workflowId.toString ());
- workflowParamBean.setStepShortName ("REENTER_MISC_OH_ALLWNC");
- /* Set DMS header bean and call DMS interface */
- if(headerBean != null)
- {
- headerBean.setSourceRecordId (injuryBean.getInjuryID ().toString());
- headerBean.setSourceTable (SITables.T_INJURY);
- headerBean.setCreatedBy (new Long (workflowParamBean.getUserId ()));
- headerBean.setKeyList (DMSConstants.SI_NUMBER, injuryBean.getSocialInsuranceNumber ().toString ());
- headerBean.setKeyList (DMSConstants.REGISTRATION_NUMBER, injuryBean.getRegistrationNumber ().toString ());
- headerBean.setKeyList (DMSConstants.INJURY_NUMBER, injuryBean.getInjuryNumber ().toString ());
- DMSUtilities.startDMS (headerBean);
- }
- }
- if (canSendForWorkflow)
- {
- // can send for workflow is set from the servlet
- // it will be true if called from oh benefit screen
- // else if its from the treatemnt period screen its will be false
- workflowParamBean.setrecordDescription(
- workflowParamBean.getrecordDescription () + " - " + injuryBean.getSocialInsuranceNumber ());
- String userName = "";
- try
- {
- userName = GOSIUtilities.startWorkflow (workflowParamBean);
- }
- catch (GOSIException ge)
- {
- if (ge.getErrorId().equals("CMN_ERR_1019"))
- {
- workflowParamBean.setTargetUserId (0);
- userName = GOSIUtilities.startWorkflow (workflowParamBean);
- }
- else throw ge;
- }
- if (userName != null && !"".equals (userName))
- {
- message = GOSIErrorMessages.getErrorDesc ("SOI_ERR_5194") + " " + userName;
- }
- }
- endTime = System.currentTimeMillis();
- elapsedTime = endTime - startTime;
- GOSIInstrumentationLog.writeInstrumentationToLog(
- this.getClass().toString(),
- "modifyOHAllowance()",
- elapsedTime);
- return message;
- // return the message with username if send for workflow
- }
- catch(GOSIException ge)
- {
- GOSIDebug.debugMessages("session :modify :ge: "+ge);
- ctx.setRollbackOnly();
- throw ge;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("session :modify :e: "+e);
- ctx.setRollbackOnly();
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "modifyOHAllowance()",e,"CMN_ERR_1000");
- }
- }
- /**
- * @METHOD NAME : MaintainOHAllowanceSessionEJB
- * @INFORMATION : This method is the constructor$
- * @PARAM : class java.lang.String
- * @RETURN : class java.lang.Class
- * @EXCEPTION :
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- public MaintainOHAllowanceSessionEJB ()
- {
- }
- /**
- * @METHOD NAME : ejbCreate
- * @INFORMATION : This method is to ejb Create
- * @PARAM :
- * @RETURN : void
- * @EXCEPTION :
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- public void ejbCreate ()
- {
- }
- /**
- * @METHOD NAME : ejbRemove
- * @INFORMATION : This method is to ejb Remove
- * @PARAM :
- * @RETURN : void
- * @EXCEPTION :
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- public void ejbRemove ()
- {
- }
- /**
- * @METHOD NAME : ejbActivate
- * @INFORMATION : This method is to ejb Activate
- * @PARAM :
- * @RETURN : void
- * @EXCEPTION :
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- public void ejbActivate ()
- {
- }
- /**
- * @METHOD NAME : ejbPassivate
- * @INFORMATION : This method is to ejb Passivate
- * @PARAM :
- * @RETURN : void
- * @EXCEPTION :
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- public void ejbPassivate ()
- {
- }
- /**
- * @METHOD NAME : setSessionContext
- * @INFORMATION : This method is to set Session Context
- * @PARAM : interface javax.ejb.SessionContext
- * @RETURN : void
- * @EXCEPTION :
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- public void setSessionContext (javax.ejb.SessionContext sc)
- {
- this.ctx=sc;
- }
- /**
- * @METHOD NAME : calculateDailyAllowance
- * @INFORMATION : This method is to calculate Daily Allowance
- * @PARAM : class java.util.ArrayList,
- class java.lang.Double,
- class java.lang.Short,
- class java.lang.String
- * @RETURN : class java.util.ArrayList
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private ArrayList calculateDailyAllowance
- (ArrayList trmtList,Double totalWage,Short payableTo,String calenderType)
- throws GOSIException
- {
- ArrayList benefitList = new ArrayList();
- try
- { // this method calculates the oh benefit
- // the period for which the benefit need to be calculated is set in the trmt list
- // the other parameters are used for calculating the benefit for each trmt period
- Long injuryId = null;
- if(trmtList!=null&&trmtList.size()!=0)
- {
- injuryId =((TreatmentPeriodBean)trmtList.get(0)).getInjuryId();
- }
- for(int i=0;i<trmtList.size();i++)
- {
- TreatmentPeriodBean trmtBean= new TreatmentPeriodBean();
- trmtBean=(TreatmentPeriodBean)trmtList.get(i);
- OHAllowanceBean benefitBean = new OHAllowanceBean();
- GOSIDebug.debugMessages("startDate:" + trmtBean.getStartDateGreg() + ":");
- GOSIDebug.debugMessages("EndDate:" + trmtBean.getEndDateGreg() + ":");
- benefitBean.setInjuryId(trmtBean.getInjuryId());
- benefitBean.setBenStDateGreg(trmtBean.getStartDateGreg());
- benefitBean.setBenEndDateGreg(trmtBean.getEndDateGreg());
- benefitBean.setTotalContWage(totalWage);
- benefitBean.setBenefitPayableTo(payableTo);
- if(trmtBean.getTreatmentType().equals
- (OHConstants.TRMT_TYPE_INPATIENT))
- {
- benefitBean.setOhBenCode
- (OHConstants.OH_ALWNC_DAIlY_INPATIENT);
- }else
- {
- benefitBean.setOhBenCode
- (OHConstants.OH_ALWNC_DAIlY_OUTPATIENT);
- }
- GOSIDebug.debugMessages("HospitalType:" + trmtBean.getHospitalType());
- if(OHConstants.HIJRAH.equals(calenderType))
- {
- benefitBean = setDailyAllowanceHij
- (benefitBean,trmtBean.getHospitalType());
- }else
- {
- benefitBean = setDailyAllowanceGreg
- (benefitBean,trmtBean.getHospitalType());
- }
- benefitList.add(benefitBean);
- }
- return benefitList;
- }
- catch(GOSIException ge)
- {
- GOSIDebug.debugMessages("session:calculateDailyAllowance:ge:"+ge);
- throw ge;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("session:calculateDailyAllowance:e:"+e);
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "calculateDailyAllowance()",e,"CMN_ERR_1000");
- }
- }
- /**
- * @METHOD NAME : setDailyAllowanceGreg
- * @INFORMATION : This method is to set Daily Allowance calculation for Gregorian employers
- * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.OHAllowanceBean,
- class java.lang.Short
- * @RETURN : class gosi.business.socialinsurance.occupationalhazards.injury.beans.OHAllowanceBean
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private OHAllowanceBean setDailyAllowanceGreg
- (OHAllowanceBean benefitBean,Short hospitalType)throws GOSIException
- {
- try
- {
- GOSIDebug.debugMessages("\t\t Start setDailyAllowanceGreg - MaintainOHAllowanceSessionEJB");
- // this method calculates the dailly allowace for the particular benefit bean
- // it get the start and end dates and based on the calender type
- // splits / dont split the record and calculate the benefit
- // this is called if the calender type is gregorian
- int noDays = benefitBean.getNumberDays();
- double wage = benefitBean.getTotalContWage().doubleValue();
- GOSIDebug.debugMessages("Wage:" + wage);
- double percentage = 0;
- Timestamp startDate = benefitBean.getBenStDateGreg();
- String lawIndicator = OHConstants.NEW_LAW;
- if(startDate.compareTo(OHRuleBean.getNewLawApplicableDate())<0)
- {
- lawIndicator = OHConstants.OLD_LAW;
- }
- Timestamp endDate = benefitBean.getBenEndDateGreg();
- Calendar cal= Calendar.getInstance();
- cal.setTime(new java.util.Date(startDate.getTime()));
- int firstMonth = cal.get(Calendar.MONTH);
- int firstYear = cal.get(Calendar.YEAR);
- GOSIDebug.debugMessages("FirstYear:" + firstYear);
- cal.setTime(new java.util.Date(endDate.getTime()));
- int secondMonth = cal.get(Calendar.MONTH);
- int secondYear = cal.get(Calendar.YEAR);
- GOSIDebug.debugMessages("SecondYear:" + secondYear);
- int noMonths = 0;
- boolean flag = false;
- if(secondYear > firstYear)
- {
- secondMonth = secondMonth + ((secondYear-firstYear)*12);
- }
- if(secondMonth > firstMonth)
- {
- flag = true;
- noMonths = secondMonth - firstMonth+1;
- }
- if(benefitBean.getOhBenCode().equals
- (OHConstants.OH_ALWNC_DAIlY_INPATIENT))
- {
- if(hospitalType.equals(OHConstants.REG_HOSPITAL))
- {
- //percentage =0.75;
- percentage = OHRuleBean.
- getInpatientPercentageforRegHospital(lawIndicator);
- }
- else if(hospitalType.equals(OHConstants.UNREG_HOSPITAL))
- {
- //percentage =0.75;
- percentage = OHRuleBean.
- getInpatientPercentageforUnRegHospital(lawIndicator);
- }else if(hospitalType.equals(OHConstants.GOVT_FREE_HOSPITAL))
- {
- //percentage =1.0;
- percentage = OHRuleBean.
- getInpatientPercentageforGovFreeHospital(lawIndicator);
- }else if(hospitalType.equals(OHConstants.GOVT_PAID_HOSPITAL))
- {
- //percentage =0.75;
- percentage = OHRuleBean.
- getInpatientPercentageforGovPaidHospital(lawIndicator);
- }
- }else
- {
- if(hospitalType.equals(OHConstants.REG_HOSPITAL))
- {
- //percentage =1.0;
- percentage = OHRuleBean.
- getOutpatientPercentageforRegHospital(lawIndicator);
- }else if(hospitalType.equals(OHConstants.UNREG_HOSPITAL))
- {
- //percentage =1.0;
- percentage = OHRuleBean.
- getOutpatientPercentageforUnRegHospital(lawIndicator);
- }else if(hospitalType.equals(OHConstants.GOVT_FREE_HOSPITAL))
- {
- //percentage =1.0;
- percentage = OHRuleBean.
- getOutpatientPercentageforGovFreeHospital(lawIndicator);
- }else if(hospitalType.equals(OHConstants.GOVT_PAID_HOSPITAL))
- {
- //percentage =1.0;
- percentage = OHRuleBean.
- getOutpatientPercentageforGovPaidHospital(lawIndicator);
- }
- }
- int maxDays = 0;
- double amount = 0;
- if(flag)
- {
- for(int i=1;i<=noMonths;i++)
- {
- if(i == 1)
- {
- cal.setTime(new java.util.Date(startDate.getTime()));
- noDays = cal.getActualMaximum(Calendar.DAY_OF_MONTH)
- -cal.get(Calendar.DAY_OF_MONTH)+1;
- maxDays = cal.getActualMaximum((Calendar.DAY_OF_MONTH));
- }
- else if(i>1 && i<noMonths)
- {
- cal.setTime(new java.util.Date(startDate.getTime()));
- cal.add(Calendar.MONTH,(i-1));
- noDays= cal.getActualMaximum((Calendar.DAY_OF_MONTH));
- maxDays= cal.getActualMaximum((Calendar.DAY_OF_MONTH));
- }
- else if(i == noMonths)
- {
- cal.setTime(new java.util.Date(endDate.getTime()));
- noDays=cal.get(Calendar.DAY_OF_MONTH);
- maxDays=cal.getActualMaximum((Calendar.DAY_OF_MONTH));
- }
- GOSIDebug.debugMessages("NoDays :"+noDays);
- GOSIDebug.debugMessages("MaxDays :"+maxDays);
- GOSIDebug.debugMessages("Percentage :"+percentage);
- amount = amount +
- ((noDays*percentage*
- benefitBean.getTotalContWage().doubleValue())
- /maxDays);
- GOSIDebug.debugMessages("Amount:"+amount);
- }
- }else
- {
- noDays=benefitBean.getNumberDays();
- cal.setTime(new java.util.Date(startDate.getTime()));
- maxDays= cal.getActualMaximum((Calendar.DAY_OF_MONTH));
- GOSIDebug.debugMessages("NoDays :" + noDays);
- GOSIDebug.debugMessages("MaxDays :" + maxDays);
- GOSIDebug.debugMessages("Percentage :" + percentage);
- amount =
- ((noDays*percentage*benefitBean.getTotalContWage()
- .doubleValue())/maxDays);
- GOSIDebug.debugMessages("Amount:" + amount);
- }
- Double benAmount = new Double(amount);
- benefitBean.setBenAmount(benAmount);
- GOSIDebug.debugMessages("\t\t End setDailyAllowanceGreg - MaintainOHAllowanceSessionEJB");
- return benefitBean;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("session:setDailyAllowance:e:" + e);
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "setDailyAllowance()",e,"CMN_ERR_1000");
- }
- }
- /**
- * @METHOD NAME : setDailyAllowanceHij
- * @INFORMATION : This method is to set Daily Allowance calculation for Hijrah employers
- * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.OHAllowanceBean,
- class java.lang.Short
- * @RETURN : class gosi.business.socialinsurance.occupationalhazards.injury.beans.OHAllowanceBean
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private OHAllowanceBean setDailyAllowanceHij
- (OHAllowanceBean benefitBean,Short hospitalType)throws GOSIException
- {
- try
- {
- GOSIDebug.debugMessages("--------------setDailyAllowanceHIJ---------");
- // this method calculates the dailly allowace for the particulat benefit bean
- // it get the start and end dates and based on the calender type
- // splits / dont split the record and calculate the benefit
- // this is called if the calender type is hijrah
- int noDays=benefitBean.getNumberDays();
- double wage=benefitBean.getTotalContWage().doubleValue();
- double percentage =0;
- Timestamp startDate=benefitBean.getBenStDateGreg();
- String lawIndicator = OHConstants.NEW_LAW;
- if(startDate.compareTo(OHRuleBean.getNewLawApplicableDate())<0)
- {
- lawIndicator =OHConstants.OLD_LAW;
- }
- String startDateHij = OHUtilities.getDateStr(startDate,OHConstants.HIJRAH);
- Timestamp endDate=benefitBean.getBenEndDateGreg();
- String endDateHij = OHUtilities.getDateStr(endDate,OHConstants.HIJRAH);
- GOSIDebug.debugMessages("startDate:"+startDateHij);
- GOSIDebug.debugMessages(" endDate:"+endDateHij);
- int firstMonth=OHUtilities.getMonth(startDateHij);
- int firstYear= OHUtilities.getYear(startDateHij);
- GOSIDebug.debugMessages("firstyear:"+firstYear);
- //cal.setTime(new java.util.Date(endDate.getTime()));
- int secondMonth=OHUtilities.getMonth(endDateHij);
- int secondYear =OHUtilities.getYear(endDateHij);
- int noMonths=0;
- boolean flag=false;
- if(secondYear > firstYear)
- {
- secondMonth=secondMonth+((secondYear-firstYear)*12);
- }
- GOSIDebug.debugMessages("No Months :"+noMonths);
- if(secondMonth > firstMonth)
- {
- flag= true;
- noMonths=secondMonth-firstMonth+1;
- }
- GOSIDebug.debugMessages("flag:"+flag);
- if(benefitBean.getOhBenCode().equals(OHConstants.OH_ALWNC_DAIlY_INPATIENT))
- {
- if(hospitalType.equals(OHConstants.REG_HOSPITAL))
- {
- //percentage =0.75;
- percentage=OHRuleBean.getInpatientPercentageforRegHospital(lawIndicator);
- }
- else if(hospitalType.equals(OHConstants.UNREG_HOSPITAL))
- {
- //percentage =0.75;
- percentage=OHRuleBean.getInpatientPercentageforUnRegHospital(lawIndicator);
- }else if(hospitalType.equals(OHConstants.GOVT_FREE_HOSPITAL))
- {
- //percentage =1.0;
- percentage=OHRuleBean.getInpatientPercentageforGovFreeHospital(lawIndicator);
- }else if(hospitalType.equals(OHConstants.GOVT_PAID_HOSPITAL))
- {
- //percentage =0.75;
- percentage=OHRuleBean.getInpatientPercentageforGovPaidHospital(lawIndicator);
- }
- }else
- {
- if(hospitalType.equals(OHConstants.REG_HOSPITAL))
- {
- //percentage =1.0;
- percentage=OHRuleBean.getOutpatientPercentageforRegHospital(lawIndicator);
- }else if(hospitalType.equals(OHConstants.UNREG_HOSPITAL))
- {
- //percentage =1.0;
- percentage=OHRuleBean.getOutpatientPercentageforUnRegHospital(lawIndicator);
- }else if(hospitalType.equals(OHConstants.GOVT_FREE_HOSPITAL))
- {
- //percentage =1.0;
- percentage=OHRuleBean.getOutpatientPercentageforGovFreeHospital(lawIndicator);
- }else if(hospitalType.equals(OHConstants.GOVT_PAID_HOSPITAL))
- {
- //percentage =1.0;
- percentage=OHRuleBean.getOutpatientPercentageforGovPaidHospital(lawIndicator);
- }
- }
- int maxDays=0;
- double amount=0;
- if(flag)
- {
- for(int i=1;i<=noMonths;i++)
- {
- if(i==1)
- {
- String lastDateHij =OHUtilities.getMonthEndDate(startDateHij);
- noDays = OHUtilities.getDay(lastDateHij)-OHUtilities.getDay(startDateHij)+1;
- maxDays =OHUtilities.getDay(lastDateHij);
- }
- else if(i>1 && i<noMonths)
- {
- String addedMonthDate =GOSIDateUtilities.getDateForMonths
- (startDateHij,GOSIConstants.HIJ_CALENDARTYPE,
- GOSIConstants.DATE_NEXT_INDICATOR,(i-1));
- String lastDateHij =OHUtilities.getMonthEndDate(addedMonthDate);
- noDays = OHUtilities.getDay(lastDateHij);
- maxDays =OHUtilities.getDay(lastDateHij);
- }
- else if(i==noMonths)
- {
- //cal.setTime(new java.util.Date(endDate.getTime()));
- String lastDateHij =OHUtilities.getMonthEndDate(endDateHij);
- noDays = OHUtilities.getDay(endDateHij);
- maxDays= OHUtilities.getDay(lastDateHij);
- }
- GOSIDebug.debugMessages("noDays :"+noDays);
- GOSIDebug.debugMessages("maxDays :"+maxDays);
- GOSIDebug.debugMessages("percentage :"+percentage);
- amount=amount+((noDays*percentage*benefitBean.getTotalContWage().doubleValue())/maxDays);
- GOSIDebug.debugMessages("temp amount:"+amount);
- }
- }else
- {
- noDays=benefitBean.getNumberDays();
- String lastDateHij =OHUtilities.getMonthEndDate(endDateHij);
- maxDays= OHUtilities.getDay(lastDateHij);
- amount =((noDays*percentage*benefitBean.getTotalContWage().doubleValue())/maxDays);
- }
- Double benAmount=new Double(amount);
- benefitBean.setBenAmount(benAmount);
- GOSIDebug.debugMessages("--------------setDailyAllowance*---------");
- return benefitBean;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("session-clcltDlyAllwnc : The exception is "+e);
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "setDailyAllowance()",e,"CMN_ERR_1000");
- }
- }
- /**
- * @METHOD NAME : getPayableHospital
- * @INFORMATION : This method is to get Payable Hospital
- * @PARAM : class java.lang.Long,
- class java.sql.Timestamp
- * @RETURN : class java.lang.Long
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private Long getPayableHospital(Long injuryId,Timestamp compStartDate,boolean isTreatmentApproved)
- throws GOSIException
- {
- PreparedStatement ps = null;
- ResultSet rs =null;
- String sqlQuery;
- boolean flag=true;
- Long hospitalCode = null;
- // this method is to get the hospital details for which the the companion
- // allowance is to be paid , this functionality is currently diabled
- // and now the companion allowance is paid with treatment service
- sqlQuery = " select HOSPITALCODE from " + SITables.T_TREATMENT +
- " where INJURYID= ? and STARTDATE <= ? "+
- " and ENDDATE>=? and TREATMENTSTATUS = ? ";
- try
- {
- ps =con.prepareStatement(sqlQuery);
- ps.setLong(1,injuryId.longValue());
- ps.setTimestamp(2,compStartDate);
- ps.setTimestamp(3,compStartDate);
- if(isTreatmentApproved)
- {
- ps.setShort(4,OHConstants.TRMT_STS_APPROVED.shortValue());
- }else
- {
- ps.setShort(4,OHConstants.TRMT_STS_ENTERED.shortValue());
- }
- rs=ps.executeQuery();
- if(rs!=null)
- {
- while(rs.next())
- {
- hospitalCode=new Long(rs.getLong("HOSPITALCODE"));
- }
- }
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("session:getPayableHospital :e:"+e);
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "getPayableHospital()",e,"CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp(ps,rs);
- }
- return hospitalCode;
- }
- /**
- * @METHOD NAME : getBenefitStartDate
- * @INFORMATION : This method is to get Benefit Start Date
- of the entered benefit in workflow
- * @PARAM : class java.lang.Long
- * @RETURN : class java.sql.Timestamp
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private Timestamp getBenefitStartDate(Long injuryId)
- throws GOSIException
- { Timestamp benifitStartDate=null;
- PreparedStatement ps = null;
- ResultSet rs = null;
- String sqlQuery;
- // This method is to get Benefit Start Date
- // of the entered benefit in workflow
- try
- {
- sqlQuery= " select max (BENENDDATE) from "+
- SITables.T_OHBENEFIT + " where INJURYID=? and "+
- " ( OHBENCODE =? or OHBENCODE = ? or OHBENCODE = ? ) ";
- ps =con.prepareStatement(sqlQuery);
- ps.setLong(1,injuryId.longValue());
- ps.setShort(2,OHConstants.OH_ALWNC_DAIlY_INPATIENT.shortValue());
- ps.setShort(3,OHConstants.OH_ALWNC_DAIlY_OUTPATIENT.shortValue());
- ps.setShort(4,OHConstants.OH_ALWNC_CONVEYENCE.shortValue());
- rs =ps.executeQuery();
- while(rs.next())
- {
- if(rs.getObject(1)!=null)
- {
- benifitStartDate=rs.getTimestamp(1);
- }
- }
- // if no benefit is found the benefit start date is the next day of injury
- sqlQuery =" select INJURYDATE from "+
- SITables.T_INJURY + " where INJURYID=? ";
- if(benifitStartDate==null)
- {
- ps =con.prepareStatement(sqlQuery);
- ps.setLong(1,injuryId.longValue());
- rs =ps.executeQuery();
- while(rs.next())
- {
- benifitStartDate=rs.getTimestamp("INJURYDATE");
- }
- }
- if(benifitStartDate!=null)
- {
- benifitStartDate=GOSIUtilities.getNextDate(benifitStartDate);
- }
- return benifitStartDate;
- }
- catch(GOSIException ge)
- {
- GOSIDebug.debugMessages("session-getBenefitStartDate: exp is:"+ge);
- throw ge;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("session-getBenefitStartDate: exp is:"+e);
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "calculateDailyAllowance()",e,"CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp(ps, rs);
- }
- }
- /**
- * @METHOD NAME : canAvailBenefitdueToDisablity
- * @INFORMATION : This method is to check whether contributor
- can Avail Benefit due To Disablity
- * @PARAM : class java.lang.Long
- * @RETURN : boolean
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private boolean canAvailBenefitdueToDisablity(Long socInsNumber)
- throws GOSIException
- {
- String sqlQuery;
- boolean flag = true;
- PreparedStatement ps = null;
- ResultSet rs = null;
- try
- {
- // this method checks if the contributor has a disability percentage
- // more than 50 percent if his maximum disability is more than 50
- // it returns false else true
- sqlQuery = " select max(DISABILITYPERCENTAGE) MAXDISABILITY from "+
- SITables.T_DISBASSMT +
- " where SOCIALINSURANCENUMBER = ? "+
- " and ((DISBSTATUS = ? and WORKFLOWSTATUS = ? ) or "+
- " DISBSTATUS in(?,?)) ";
- ps =con.prepareStatement(sqlQuery);
- ps.setLong(1,socInsNumber.longValue());
- ps.setShort(2,OHConstants.ASSMT_COMPLETED.shortValue());
- ps.setShort(3,OHConstants.ASSMT_COMPLETED.shortValue());
- ps.setShort(4,OHConstants.ASSMT_APPEALED.shortValue());
- ps.setShort(5,OHConstants.ASSMT_APPEAL_WITHDRAWN.shortValue());
- GOSIDebug.debugMessages("SqlQuery:" + sqlQuery + ":");
- GOSIDebug.debugMessages("\t\t Param 1 :" + socInsNumber.longValue() + ":");
- GOSIDebug.debugMessages("\t\t Param 2 :" + OHConstants.ASSMT_COMPLETED.shortValue() + ":");
- GOSIDebug.debugMessages("\t\t Param 3 :" + OHConstants.ASSMT_COMPLETED.shortValue() + ":");
- GOSIDebug.debugMessages("\t\t Param 4 :" + OHConstants.ASSMT_APPEALED.shortValue() + ":");
- GOSIDebug.debugMessages("\t\t Param 5 :" + OHConstants.ASSMT_APPEAL_WITHDRAWN.shortValue() + ":");
- rs = ps.executeQuery();
- double percentage = 0.00;
- while(rs.next())
- {
- if(rs.getObject("MAXDISABILITY")!=null)
- {
- percentage=rs.getDouble("MAXDISABILITY");
- }
- GOSIDebug.debugMessages("Percentage Disability :" + percentage);
- }
- GOSIDebug.debugMessages("Flag:" + (percentage > 50.00));
- if(percentage > OHRuleBean.getMaxEligibleDisPercentageforDA())
- {
- flag = false;
- }
- return flag;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("session-checkDisabilityStatus: exp is:"+e);
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "canAvailBenefitdueToDisablity()",e,"CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp(ps,rs);
- }
- }
- /**
- * @METHOD NAME : getContributorBank
- * @INFORMATION : This method is to get Contributor Bank details
- * @PARAM : class java.lang.Long
- * @RETURN : class gosi.business.socialinsurance.annuities.common.beans.PaymentBankAccountBean
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- public PaymentBankAccountBean getContributorBank( Long socInsNum)
- throws gosi.core.util.GOSIException
- {
- long startTime = 0;
- long endTime = 0;
- long elapsedTime = 0;
- startTime = System.currentTimeMillis();
- double wage=0;
- PaymentBankAccountBean bankAccBean = null;
- PreparedStatement ps = null;
- ResultSet rs =null;
- try
- {
- // This method returns the bank details of the contributor
- // stored in the T_paymentbank account table
- String sqlQuery=""+
- " select "+
- " PAYMENTACCOUNTRECID,"+
- " BANKCODE, "+
- " BRANCHCODE, "+
- " ACCOUNTNUMBER, "+
- " CONTRIBUTORID, "+
- " PAYEETYPE,"+
- " PAYEEID,"+
- " STARTDATE, "+
- " STARTDATEENTFMT, "+
- " WORKFLOWSTATUS, "+
- " CREATEDBY,"+
- " CREATIONTIMESTAMP ,"+
- " LASTMODIFIEDBY ,"+
- " LASTMODIFIEDTIMESTAMP "+
- " from "+ SITables.T_PAYMENTBANKACCOUNT +
- " where CONTRIBUTORID= "+
- " (select CONTRIBUTORID from "+
- SITables.T_CONTRIBUTOR +
- " where SOCIALINSURANCENUMBER=? )"+
- " and PAYEETYPE= ? and "+
- " ENDDATE is null ";
- GOSIDebug.debugMessages("sqlQuery:"+sqlQuery);
- con=GOSIUtilities.getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
- ps=con.prepareStatement(sqlQuery);
- ps.setLong(1,socInsNum.longValue());
- ps.setShort(2,OHConstants.PAYEE_TYPE_CONTRIBUTOR.shortValue());
- rs=ps.executeQuery();
- while(rs.next())
- {
- bankAccBean = new PaymentBankAccountBean();
- bankAccBean.setPaymentAccountRecId
- (new Long(rs.getLong("PAYMENTACCOUNTRECID")));
- bankAccBean.setBankCode(new Short (rs.getShort("BANKCODE")));
- bankAccBean.setBranchCode(new Short (rs.getShort("BRANCHCODE")));
- bankAccBean.setAccountNumber(rs.getString("ACCOUNTNUMBER"));
- bankAccBean.setContributorId
- (new Long (rs.getLong("CONTRIBUTORID")));
- bankAccBean.setPayeeType(new Short(rs.getShort("PAYEETYPE")));
- bankAccBean.setPayeeId(new Long(rs.getLong("PAYEEID")));
- bankAccBean.setStartDate(rs.getTimestamp("STARTDATE"));
- bankAccBean.setStartDateEntFmt(rs.getString("STARTDATEENTFMT"));
- bankAccBean.setWorkflowStatus
- (new Short(rs.getShort("WORKFLOWSTATUS")));
- bankAccBean.setCreatedBy(new Long(rs.getLong("CREATEDBY")));
- bankAccBean.setCreationTimestamp
- (rs.getTimestamp("CREATIONTIMESTAMP"));
- if(rs.getObject("LASTMODIFIEDBY")!=null)
- {
- bankAccBean.setLastModifiedBy
- (new Long (rs.getLong("LASTMODIFIEDBY")));
- bankAccBean.setLastModifiedTimestamp
- (rs.getTimestamp("LASTMODIFIEDTIMESTAMP"));
- }
- bankAccBean.setMode(AuditBean.OLD_MODE);
- }
- endTime = System.currentTimeMillis();
- elapsedTime = endTime - startTime;
- GOSIInstrumentationLog.writeInstrumentationToLog(
- this.getClass().toString(),
- "getContributorBank()",
- elapsedTime);
- return bankAccBean;
- }
- catch(GOSIException ge)
- {
- throw ge;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("session-getContributorBank : e: "+e);
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "getContributorBank()",e,"CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities. cleanUp(con,ps,rs);
- }
- }
- /**
- * @METHOD NAME : getContributorId
- * @INFORMATION : This method is to get Contributor Id
- * @PARAM : class java.lang.Long
- * @RETURN : class java.lang.Long
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- public Long getContributorId(Long socInsNum)throws GOSIException
- {
- long startTime = 0;
- long endTime = 0;
- long elapsedTime = 0;
- startTime = System.currentTimeMillis();
- Long contributorId = null;
- PreparedStatement ps = null;
- ResultSet rs =null;
- try
- {
- // this is the query to get the contributor id of the contributor
- // using social insurance number
- String sqlQuery = " select CONTRIBUTORID from "+
- SITables.T_CONTRIBUTOR +
- " where SOCIALINSURANCENUMBER=? ";
- con=GOSIUtilities.getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
- ps=con.prepareStatement(sqlQuery);
- ps.setLong(1, socInsNum.longValue());
- rs = ps.executeQuery();
- while(rs.next())
- {
- contributorId = new Long(rs.getLong("CONTRIBUTORID"));
- }
- endTime = System.currentTimeMillis();
- elapsedTime = endTime - startTime;
- GOSIInstrumentationLog.writeInstrumentationToLog(
- this.getClass().toString(),
- "getContributorId()",
- elapsedTime);
- return contributorId;
- }
- catch (GOSIException ge)
- {
- GOSIDebug.debugMessages("session:getContributorId:ge:"+ge);
- throw ge;
- }
- catch (Exception e)
- {
- GOSIDebug.debugMessages("session:getContributorId:e:"+e);
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "getTotalContibutorWage()",e,"CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities. cleanUp(con,ps,rs);
- }
- }
- /**
- * @METHOD NAME : saveBankDetails
- * @INFORMATION : This method is to save Bank Details
- * @PARAM : class gosi.business.socialinsurance.annuities.common.beans.PaymentBankAccountBean
- * @RETURN : void
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- public void saveBankDetails
- (PaymentBankAccountBean bankAccountBean) throws GOSIException
- {
- long startTime = 0;
- long endTime = 0;
- long elapsedTime = 0;
- startTime = System.currentTimeMillis();
- try
- {
- // this method saves the bank details entered by the user
- // into the T_PAYMENTBANKACCOUNT table
- // based on the modes it will insert or update the table
- PaymentBankAccountEntityHome home=(PaymentBankAccountEntityHome)
- ServiceLocator.getInstance().getRemoteHome(
- OHConstants.PAYMENT_BANK_ENTITY_JNDI,
- PaymentBankAccountEntityHome.class);
- Timestamp currentTime=new Timestamp (System.currentTimeMillis());
- if(AuditBean.OLD_MODE == bankAccountBean.getMode())
- {
- GOSIDebug.debugMessages("no need to change Bank account details");
- }
- else if ((AuditBean.NEW_MODE == bankAccountBean.getMode()))
- {
- GOSIDebug.debugMessages("the mode is new mode");
- bankAccountBean.setPaymentAccountRecId(GOSIUtilities.
- getPrimaryKey("T_PAYMENTBANKACCOUNT",
- bankAccountBean.getCreatedBy()));
- bankAccountBean.setCreationTimestamp
- (new Timestamp(System.currentTimeMillis()));
- PaymentBankAccountEntity remote = home.create(bankAccountBean);
- }
- else if ((AuditBean.MODIFY_MODE == bankAccountBean.getMode()))
- {
- GOSIDebug.debugMessages("the mode is modify mode");
- PaymentBankAccountEntity remote=home.findByPrimaryKey
- (bankAccountBean.getPaymentAccountRecId());
- remote.modify(bankAccountBean);
- }
- endTime = System.currentTimeMillis();
- elapsedTime = endTime - startTime;
- GOSIInstrumentationLog.writeInstrumentationToLog(
- this.getClass().toString(),
- "saveBankDetails()",
- elapsedTime);
- }
- catch(GOSIException ge)
- {
- GOSIDebug.debugMessages("session:save:ge:"+ge);
- ctx.setRollbackOnly();
- throw ge;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("servlet-saveBankDetails :The exception is "+e);
- ctx.setRollbackOnly();
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "saveBankDetails()",e,"CMN_ERR_1000");
- }
- }
- /**
- * @METHOD NAME : setEstablishmentDetails
- * @INFORMATION : This method is to set Establishment Details for the injury
- * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.InjuryPopDetails
- * @RETURN : class gosi.business.socialinsurance.occupationalhazards.injury.beans.InjuryPopDetails
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private InjuryPopDetails setEstablishmentDetails
- (InjuryPopDetails injuryDetails)throws GOSIException
- {
- GOSIDebug.debugMessages("Start setEstablishmentDetails - MaintainOHAllowanceSessionEJB");
- String establishmentName = "xyz";
- java.sql.ResultSet rs = null;
- java.sql.PreparedStatement ps = null;
- try
- {
- // establishment and engagement details to be set
- // esatablishment details like name ,registration number ,
- // responsible for oh payment etc are set
- EstablishmentBean estBean = EstablishmentUtility.
- getEstablishmentDetails(injuryDetails.getEstablishmentId().longValue(),
- false,true);
- injuryDetails.setEstablishmentName(estBean.getEstablishmentNameArb());
- injuryDetails.setEstablishmentNameEnglish(estBean.getEstablishmentNameEng());
- injuryDetails.setRegistrationNumber(estBean.getRegistrationNumber());
- if(estBean.getResponsibleForOHPayment() != null)
- {
- injuryDetails.setBenefitPayableTo
- (new Short(estBean.getResponsibleForOHPayment().shortValue()));
- injuryDetails.setInjuredEstablishmentBenefitPayableTo(
- new Short(estBean.getResponsibleForOHPayment().shortValue()));
- }
- //The Complication allowance is paid like injury allowance.
- //no need to pay to contributor when he is getting wage from employer.
- /*
- if(injuryDetails.getComplicationDate() != null)
- {
- injuryDetails.setBenefitPayableTo
- (OHConstants.OH_BNFT_PAY_TO_CON);
- }*/
- GOSIDebug.debugMessages("Benefit PayableTo :" + injuryDetails.getBenefitPayableTo());
- double wage = 0;
- // the logic below checks if the contributor has any valid engagement
- // on complication date and if any set the flag setIsEngagementPresentOnComplication
- // to true and calender date as complication date else its false and injury date
- Timestamp injDate = injuryDetails.getInjuryDate();
- Timestamp calDate = injuryDetails.getInjuryDate();
- if(injuryDetails.getComplicationDate()!=null)
- {
- injDate = injuryDetails.getComplicationDate();
- calDate = injuryDetails.getComplicationDate();
- injuryDetails = getEngagementforEstablishment(injDate,injuryDetails);
- if(injuryDetails.getEngagementId() == null)
- {
- injDate = injuryDetails.getInjuryDate();
- calDate = injuryDetails.getInjuryDate();
- injuryDetails = getEngagementforEstablishment(injDate,injuryDetails);
- injuryDetails.setIsEngagementPresentOnComplicationAndEligibleForOH(false);
- }
- else if(OHUtilities.isEligibleforOHCoverage(injuryDetails.getEstablishmentId(), injDate))
- {
- injuryDetails.setIsEngagementPresentOnComplicationAndEligibleForOH(true);
- }
- }else
- {
- injuryDetails = getEngagementforEstablishment(injDate,injuryDetails);
- injuryDetails.setIsEngagementPresentOnComplicationAndEligibleForOH(false);
- }
- GOSIDebug.debugMessages(" IsEngagementPresentOnComplicationAndEligibleForOH :"+
- injuryDetails.getIsEngagementPresentOnComplicationAndEligibleForOH());
- // this method set the establishment calender at the time of injury
- String calType = EstablishmentUtility.getCalendar
- (estBean.getEstablishmentId(),calDate);
- injuryDetails.setCalendarType(calType);
- GOSIDebug.debugMessages("End setEstablishmentDetails - MaintainOHAllowanceSessionEJB");
- return injuryDetails;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("Exception inside setEstablishmentDetails :" + e);
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "getEstablishmentName()",e,"CMN_ERR_1000");
- }finally
- {
- GOSIUtilities.cleanUp(ps,rs);
- }
- }
- /**
- * @METHOD NAME : getEngagementforEstablishment
- * @INFORMATION : This method is to get engagement Details for the establishment of the injury
- * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.InjuryPopDetails
- * @RETURN : class gosi.business.socialinsurance.occupationalhazards.injury.beans.InjuryPopDetails
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private InjuryPopDetails getEngagementforEstablishment
- (Timestamp injuryDate,InjuryPopDetails injuryDetails)
- throws GOSIException
- {
- GOSIDebug.debugMessages("\t\t Start getEngagementforEstablishment - MaintainOHAllowanceSessionEJB");
- java.sql.ResultSet rs = null;
- java.sql.PreparedStatement ps = null;
- StringBuffer sqlQuery = new StringBuffer();
- Connection con1 = null;
- ArrayList contributorIdList = null;
- try
- {
- // the below logic gets the engagement of the contributor
- // on the time of injury with the registered establishment
- if(injuryDetails.getMergedSIN()!= null)
- {
- // if the contributor has a merged sin
- contributorIdList = getContributorIdList(injuryDetails.getMergedSIN());
- }
- else
- {
- // if the contriubutor doesnt have a merged sin
- contributorIdList = new ArrayList();
- contributorIdList.add(injuryDetails.getContributorId());
- }
- sqlQuery.append(" SELECT");
- sqlQuery.append(" ENGAGEMENTID ");
- sqlQuery.append(" FROM ");
- sqlQuery.append(SITables.T_ENGAGEMENT);
- sqlQuery.append(" WHERE ");
- sqlQuery.append(" CONTRIBUTORID = ? AND ");
- sqlQuery.append(" ESTABLISHMENTID = ? AND ");
- sqlQuery.append(" JOININGDATE <= ? AND ");
- sqlQuery.append(" (LEAVINGDATE is null or LEAVINGDATE >= ?) AND ");
- sqlQuery.append(" ENGAGEMENTSTATUS NOT IN ( ?,?) ");
- con1 = GOSIUtilities.getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
- ps = con1.prepareStatement(sqlQuery.toString());
- ps.setLong(2,injuryDetails.getEstablishmentId().longValue());
- ps.setTimestamp(3,injuryDate);
- ps.setTimestamp(4,injuryDate);
- ps.setShort(5,RegistrationConstants.ENG_JOIN_IN_PROGRESS.shortValue());
- // PRD00078198 to avoid return cancel ENGAGEMENT for the contributor.
- ps.setShort(6, RegistrationConstants.ENG_CANCELLED.shortValue());
- for(int i = 0 ; i < contributorIdList.size(); i++)
- {
- ps.setLong(1,((Long)contributorIdList.get(i)).longValue());
- GOSIDebug.debugMessages("sqlQuery:" + sqlQuery.toString() + ":");
- GOSIDebug.debugMessages("\t\t Param 1 :" + (Long)contributorIdList.get(i) + ":");
- GOSIDebug.debugMessages("\t\t Param 2 :" + injuryDetails.getEstablishmentId().longValue() + ":");
- GOSIDebug.debugMessages("\t\t Param 3 :" + injuryDate + ":");
- GOSIDebug.debugMessages("\t\t Param 4 :" + injuryDate + ":");
- GOSIDebug.debugMessages("\t\t Param 5 :" + RegistrationConstants.ENG_JOIN_IN_PROGRESS.shortValue() + ":");
- GOSIDebug.debugMessages("\t\t Param 6 :" + RegistrationConstants.ENG_CANCELLED.shortValue() + ":");
- GOSIDebug.debugMessages("Time:" + System.currentTimeMillis());
- rs = ps.executeQuery();
- GOSIDebug.debugMessages("Time:" + System.currentTimeMillis());
- if(rs.next())
- {
- if( rs.getObject("ENGAGEMENTID") != null)
- {
- long engagementId = rs.getLong("ENGAGEMENTID");
- GOSIDebug.debugMessages("Engagement Id:" + engagementId + ":");
- injuryDetails.setEngagementId(new Long(engagementId));
- break;
- }
- }
- }
- // the injury's engagement id is set if found into the injury bean
- GOSIDebug.debugMessages("Engagement Id in InjuryDetails Bean:" + injuryDetails.getEngagementId() + ":");
- GOSIDebug.debugMessages("\t\t End getEngagementforEstablishment - MaintainOHAllowanceSessionEJB");
- return injuryDetails;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("Exception inside getEngagementforEstablishment :" + e);
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "getEngagementforEstablishment()",e,"CMN_ERR_1000");
- }finally
- {
- GOSIUtilities.cleanUp(con1,ps,rs);
- }
- }
- /**
- * @METHOD NAME : getReasonCode
- * @INFORMATION : This method is to get Reason Code of finance
- * @PARAM : class java.lang.Short
- * @RETURN : int
- * @EXCEPTION :
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private int getReasonCode(Short benefitType)
- {
- int reasonCode=0;
- if(OHConstants.OH_ALWNC_DAIlY_INPATIENT.equals(benefitType))
- {
- reasonCode = FAInterfaceConstants.IN_PATIENT_DAILY_ALLOWANCE_RC;
- }
- else if(OHConstants.OH_ALWNC_DAIlY_OUTPATIENT.equals(benefitType))
- {
- reasonCode = FAInterfaceConstants.OUT_PATIENT_DAILY_ALLOWANCE_RC;
- }
- else if(OHConstants.OH_ALWNC_CONVEYENCE.equals(benefitType))
- {
- reasonCode = FAInterfaceConstants.CONVEYANCE_ALLOWANCE_RC;
- }
- else if(OHConstants.OH_ALWNC_COMP_CONVEYENCE.equals(benefitType))
- {
- reasonCode = FAInterfaceConstants.COMPANI0N_CONVEYANCE_ALLOWANCE_RC;
- }else if(OHConstants.OH_ALWNC_COMP_DAILY.equals(benefitType))
- {
- reasonCode = FAInterfaceConstants.COMPANION_DAILY_ALLOWANCE_RC;
- }
- else if(OHConstants.OH_ALWNC_DOC_COMP_DAILY.equals(benefitType))
- {
- reasonCode = FAInterfaceConstants.COMPANION_DAILY_ALLW_DOCTOR_RC;
- }
- else if(OHConstants.OH_ALWNC_NUR_COMP_DAILY.equals(benefitType))
- {
- reasonCode = FAInterfaceConstants.COMPANION_DAILY_ALLW_NURSE_RC;
- }
- else
- if(OHConstants.OH_ALWNC_DAILY_INPATIENT_ADJUSTMENT.equals(benefitType))
- {
- reasonCode = FAInterfaceConstants.IN_PATIENT_DAILY_ALLW_ADJST_RC;
- }
- else
- if(OHConstants.OH_ALWNC_DAILY_OUTPATIENT_ADJUSTMENT.equals(benefitType))
- {
- reasonCode = FAInterfaceConstants.OUT_PATIENT_DAILY_ALLW_ADJST_RC;
- }
- else if(OHConstants.OH_ALWNC_CONVEYENCE_ADJUSTMENT.equals(benefitType))
- {
- reasonCode = FAInterfaceConstants.CONVEYANCE_ALLOWANCE_RC;
- }else if (OHConstants.OH_ALWNC_MISCELLANEOUS.equals(benefitType))
- {
- reasonCode = FAInterfaceConstants.OUT_PATIENT_DAILY_ALLOWANCE_RC;
- }
- return reasonCode;
- }
- /**
- * @METHOD NAME : getDistinctPayableTo
- * @INFORMATION : This method is to get Distinct Payable To
- entities(contributor /establishment/authorized person)
- * @PARAM : class java.lang.Long
- * @RETURN : class java.util.ArrayList
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private ArrayList getDistinctPayableTo(Long workflowId)
- throws GOSIException
- {
- String sqlQuery;
- PreparedStatement ps = null;
- ResultSet rs =null;
- ArrayList payableList = new ArrayList();
- sqlQuery = " select distinct (PAYABLETO) from "+
- SITables.T_OHBENEFIT +
- " where WORKFLOWID=? ";
- try
- {
- // This query is used to get the distict entities to which
- // the oh benefit is paid ,
- con=GOSIUtilities.
- getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
- ps =con.prepareStatement(sqlQuery);
- GOSIDebug.debugMessages("sqlquery" + sqlQuery);
- GOSIDebug.debugMessages("workflowId" + workflowId);
- ps.setLong(1,workflowId.longValue());
- rs=ps.executeQuery();
- while(rs.next())
- {
- payableList.add(new Short(rs.getShort("PAYABLETO")));
- }
- GOSIDebug.debugMessages("PAYABLELIST " +payableList.size());
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("session-compAlwnc :The exception is "+e);
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "calculateCompanionAllowance()",e,"CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp(con,ps,rs);
- return payableList;
- }
- }
- /**
- * @METHOD NAME : setJournalType
- * @INFORMATION : This method is to set Journal Type for finance
- * @PARAM : class java.util.ArrayList,
- class java.lang.Short,
- class java.lang.Long
- * @RETURN : class java.util.ArrayList
- * @EXCEPTION :
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private ArrayList setJournalType(ArrayList benefitList,Short payableTo,
- Long journalHeaderId )
- {
- // this method set the journal header id into each of the
- // benefit bean in the benefit list
- for(int i=0;i<benefitList.size();i++)
- {
- OHAllowanceBean benefitBean = (OHAllowanceBean)benefitList.get(i);
- if(payableTo.equals(benefitBean.getBenefitPayableTo()))
- {
- benefitBean.setJournalHeaderId(journalHeaderId);
- }
- }
- return benefitList;
- }
- /**
- * @METHOD NAME : getDetailsList
- * @INFORMATION : This method is to get Details List for populating
- credit note details, namely the benefit types and amount
- * @PARAM : class java.lang.Long,
- class java.lang.Short,
- class java.lang.Short
- * @RETURN : class java.util.HashMap
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private HashMap getDetailsList(Long workflowId,Short payeeType,
- Short fieldOffice,Short paymentMode)throws GOSIException
- {
- String sqlQuery="";
- ArrayList detailList=new ArrayList();
- HashMap details =new HashMap();
- PreparedStatement ps = null;
- ResultSet rs =null;
- try
- {
- // first the distict benefit codes for a particular payable to
- // and workflowid is found
- con=GOSIUtilities.getConnection
- (GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
- sqlQuery = " select distinct OHBENCODE,OHBENTYPE from "+
- SITables.T_OHBENEFIT +" where WORKFLOWID= ? "+
- " and PAYABLETO = ? "+
- " order by OHBENCODE ";
- ps = con.prepareStatement(sqlQuery);
- ps.setLong(1,workflowId.longValue());
- ps.setShort(2,payeeType.shortValue());
- rs=ps.executeQuery();
- ArrayList benCodeList= new ArrayList();
- while (rs.next())
- {
- benCodeList.add(new Short (rs.getShort("OHBENCODE")));
- benCodeList.add(rs.getString("OHBENTYPE"));
- }
- double total = 0.00;
- // for each of the distinct benefit codes the sum of the
- // benefit amount is taken and set into the details list
- for(int i=0; i< benCodeList.size();i++)
- {
- Short benCode = (Short)benCodeList.get(i);
- String benType =(String)benCodeList.get(i+1);
- i++;
- sqlQuery = " select sum (BENAMOUNT) TOTAL from "+
- SITables.T_OHBENEFIT +" where WORKFLOWID=? "+
- " and OHBENCODE= ? and PAYABLETO = ? ";
- ps = con.prepareStatement(sqlQuery);
- ps.setLong(1,workflowId.longValue());
- ps.setShort(2,benCode.shortValue());
- ps.setShort(3,payeeType.shortValue());
- rs=ps.executeQuery();
- ArrayList serviceList= new ArrayList();
- double sum = 0.00;
- while (rs.next())
- {
- sum = rs.getDouble("TOTAL");
- }
- CNInterfaceDetailBean oDetailBean=
- new CNInterfaceDetailBean();
- // if the payment mode is found to be overseas
- // the field office is set to RIYADH FO
- if(OHConstants.PAYMENT_MODE_CHEQUE_OVERSEAS.equals(paymentMode))
- {
- oDetailBean.setLocationCode(
- new Integer(""+OHConstants.FIELD_OFFICE_GOSI_RIYADH));
- }else
- {
- oDetailBean.setLocationCode(new Integer("" + fieldOffice));
- }
- oDetailBean.setShortDesc(benType);
- oDetailBean.setReasonCode(new Integer
- (getReasonCode(benCode)));
- oDetailBean.setAmountFC(new Double (sum));
- detailList.add(oDetailBean);
- total=total+sum;
- }
- // the details are put into a hash map and returned
- details.put("detailList", detailList);
- details.put("total",new Double(total));
- return details;
- }
- catch(GOSIException ge)
- {
- throw ge;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("servlet-searchInjury :The exception is "+e);
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "saveOHAllowance()",e,"CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp(con,ps,rs);
- }
- }
- /**
- * @METHOD NAME : isBankDetailsPresent
- * @INFORMATION : This method is to check if Bank Details are Present or not
- * @PARAM : class java.util.ArrayList,
- class java.lang.Long
- * @RETURN : boolean
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private boolean isBankDetailsPresent(ArrayList benefitList,Long socInsNum)
- throws GOSIException
- {
- boolean flag = true;
- try
- {
- // this method checks if a valid bank details is present for the contributor
- boolean isPayableToCon =false;
- for (int i=0;i<benefitList.size();i++)
- {
- OHAllowanceBean benefitBean =
- (OHAllowanceBean)benefitList.get(i);
- if(OHConstants.OH_BNFT_PAY_TO_CON.equals
- (benefitBean.getBenefitPayableTo()) )
- {
- GOSIDebug.debugMessages("bnft payable to :"+
- benefitBean.getBenefitPayableTo());
- GOSIDebug.debugMessages("payment mode :"+
- benefitBean.getPaymentMode());
- if(OHConstants.PAYMENT_MODE_BANK_TRANSFER.equals
- (benefitBean.getPaymentMode()))
- {
- isPayableToCon = true;
- break;
- }
- }
- }
- GOSIDebug.debugMessages("isPayableToCon"+isPayableToCon);
- if(isPayableToCon)
- {
- PaymentBankAccountBean bankBean=getContributorBank(socInsNum);
- if(bankBean == null)
- {
- flag =false;
- //String message = "";
- //message = GOSIErrorMessages.getErrorDesc("SOI_ERR_4541");
- throw new GOSIException(GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "isBankDetailsPresent()",
- new GOSIException(), "SOI_ERR_4541");
- }
- }
- return flag;
- }
- catch (GOSIException ge)
- {
- throw ge;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("session-compAlwnc :The exception is "+e);
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "isBankDetailsPresent()",e,"CMN_ERR_1000");
- }
- }
- /**
- * @METHOD NAME : getInjuryStoppedPeriodList
- * @INFORMATION : This method is to get Stopped Period for the injury
- * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.InjuryPopDetails
- * @RETURN : class java.util.ArrayList
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private ArrayList getInjuryStoppedPeriodList(InjuryPopDetails injuryBean,boolean isTreatmentApproved)throws
- GOSIException
- {
- GOSIDebug.debugMessages("\t\t Start getInjuryStoppedPeriodList - MaintainOHAllowanceSessionEJB");
- PreparedStatement ps = null;
- ResultSet rs =null;
- try
- {
- ArrayList stoppedPeriodList = new ArrayList();
- // this query returns the stopped periods for the injury from the
- // stop resume oh allowance table
- String sqlQuery= " select FROMDATE, " +
- " TODATE, "+
- " STOPORRESUMEFLAG from " +
- SITables.T_STOPRESUMEOHALLOWANCE +
- " where "+
- " STATUS =? "+
- " and CONTRIBUTORID = ? and "+
- " FROMDATE <= ? and "+
- " TODATE >= ? ";
- con= GOSIUtilities.getConnection
- (GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
- ps =con.prepareStatement(sqlQuery);
- ps.setShort(1,
- OHConstants.STOP_ALLOW_STS_APPROVED.shortValue());
- ps.setLong(2, injuryBean.getContributorId().longValue());
- ps.setTimestamp(3,injuryBean.getBenefitEndDate());
- ps.setTimestamp(4,injuryBean.getBenefitStartDate());
- rs=ps.executeQuery();
- while(rs.next())
- {
- TreatmentPeriodBean trmtBean = new TreatmentPeriodBean();
- trmtBean.setStartDateGreg(rs.getTimestamp("FROMDATE"));
- trmtBean.setEndDateGreg(rs.getTimestamp("TODATE"));
- Byte stopResumeflag =
- new Byte(rs.getByte("STOPORRESUMEFLAG"));
- // this method will add/remove the stopped period to the list
- // based on the stopResumeflag
- stoppedPeriodList = getStopPeriodList
- (stoppedPeriodList,trmtBean,stopResumeflag);
- }
- GOSIDebug.debugMessages("------getInjuryStoppedPeriodList (Out Patient)-------");
- // this query returns the treatment periods with
- // type out patient , this period also shd not be paid
- sqlQuery = " select STARTDATE, ENDDATE from " +
- SITables.T_TREATMENT + " where TREATMENTSTATUS =? "+
- " and TREATMENTTYPE = ? and INJURYID = ? "+
- " and STARTDATE <= ? and ENDDATE >= ?";
- ps = con.prepareStatement(sqlQuery);
- if(isTreatmentApproved)
- {
- ps.setShort(1,OHConstants.TRMT_STS_APPROVED.shortValue());
- }else
- {
- ps.setShort(1,OHConstants.TRMT_STS_ENTERED.shortValue());
- }
- ps.setShort(2,OHConstants.TRMT_TYPE_OUTPATIENT.shortValue());
- ps.setLong(3,injuryBean.getInjuryID().longValue());
- ps.setTimestamp(4,injuryBean.getBenefitEndDate());
- ps.setTimestamp(5,injuryBean.getBenefitStartDate());
- rs = ps.executeQuery();
- while(rs.next())
- {
- TreatmentPeriodBean trmtBean = new TreatmentPeriodBean();
- trmtBean.setStartDateGreg(rs.getTimestamp("STARTDATE"));
- trmtBean.setEndDateGreg(rs.getTimestamp("ENDDATE"));
- Byte stopResumeflag = OHConstants.STOP_ALLOWANCE_FLAG;
- // this method will add the stopped period to the list
- stoppedPeriodList = getStopPeriodList
- (stoppedPeriodList,trmtBean,stopResumeflag);
- }
- GOSIDebug.debugMessages("------getInjuryStoppedPeriodList (Out Patient)-------");
- GOSIDebug.debugMessages("\t\t End getInjuryStoppedPeriodList - MaintainOHAllowanceSessionEJB");
- return stoppedPeriodList;
- }
- catch(GOSIException ge)
- {
- throw ge;
- }
- catch(Exception e)
- {
- throw new GOSIException();
- }
- finally
- {
- GOSIUtilities.cleanUp(ps,rs);
- }
- }
- /**
- * @METHOD NAME : getAllowncePayablePeriodList
- * @INFORMATION : This method is to get Allownce Payable Period
- List for injury
- * @PARAM : class java.util.ArrayList,
- class java.util.ArrayList
- * @RETURN : class java.util.ArrayList
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private ArrayList getAllowncePayablePeriodList(ArrayList trmtList ,
- ArrayList actualStoppedList)throws GOSIException
- {
- try
- {
- // the below logic removes the stopped period from the
- // actual payable period
- ArrayList newTrmtList = new ArrayList();
- int l = -1;
- int trmtListSize = trmtList.size();
- int stoppedListSize = actualStoppedList.size();
- for(int i=0;i<stoppedListSize;i++)
- {
- TreatmentPeriodBean stopBean = (TreatmentPeriodBean)
- actualStoppedList.get(i);
- for(int j=0;j<trmtListSize;j++)
- {
- TreatmentPeriodBean trmtBean =
- (TreatmentPeriodBean)trmtList.get(j);
- if(stopBean.getStartDateGreg().compareTo
- (trmtBean.getStartDateGreg())>=0 &&
- stopBean.getStartDateGreg().compareTo
- (trmtBean.getEndDateGreg())<=0 )
- {
- if(l==j)
- {
- trmtBean.setStartDateGreg(GOSIUtilities.getNextDate
- (((TreatmentPeriodBean)newTrmtList.
- get(newTrmtList.size()-1)).getEndDateGreg()));
- }
- l=j;
- if(stopBean.getStartDateGreg().compareTo
- (trmtBean.getStartDateGreg())==0 &&
- stopBean.getEndDateGreg().compareTo
- (trmtBean.getEndDateGreg())==0 )
- {
- trmtBean =null;
- break;
- }else
- if((stopBean.getStartDateGreg().compareTo
- (trmtBean.getStartDateGreg())==0 &&
- stopBean.getEndDateGreg().compareTo
- (trmtBean.getEndDateGreg())<0 ))
- {
- trmtBean.setStartDateGreg(GOSIUtilities.
- getNextDate(stopBean.getEndDateGreg()));
- newTrmtList.add(trmtBean);
- break;
- }
- else
- if((stopBean.getStartDateGreg().compareTo
- (trmtBean.getStartDateGreg())>0 &&
- stopBean.getEndDateGreg().compareTo
- (trmtBean.getEndDateGreg())==0 ))
- {
- trmtBean.setEndDateGreg
- (OHUtilities.getPrevDate
- (stopBean.getStartDateGreg()));
- newTrmtList.add(trmtBean);
- break;
- }
- else
- if((stopBean.getStartDateGreg().compareTo
- (trmtBean.getStartDateGreg())>0 &&
- stopBean.getEndDateGreg().compareTo
- (trmtBean.getEndDateGreg())<0 ))
- {
- TreatmentPeriodBean newTrmtBean =
- new TreatmentPeriodBean(trmtBean);
- trmtBean.setEndDateGreg
- (OHUtilities.getPrevDate
- (stopBean.getStartDateGreg()));
- newTrmtBean.setStartDateGreg
- (GOSIUtilities.getNextDate
- (stopBean.getEndDateGreg()));
- newTrmtList.add(trmtBean);
- newTrmtList.add(newTrmtBean);
- break;
- }else if(stopBean.getEndDateGreg().compareTo
- (trmtBean.getEndDateGreg())>0)
- {
- if((stopBean.getStartDateGreg().compareTo
- (trmtBean.getStartDateGreg())>0))
- {
- trmtBean.setEndDateGreg(OHUtilities.getPrevDate
- (stopBean.getStartDateGreg()));
- newTrmtList.add(trmtBean);
- }else
- if(stopBean.getStartDateGreg().compareTo
- (trmtBean.getStartDateGreg())==0)
- {
- trmtBean = null;
- }
- for (int k=j;k<trmtListSize ;k++ )
- {
- TreatmentPeriodBean tempTrmtBean =
- (TreatmentPeriodBean)actualStoppedList.get(k);
- if(stopBean.getEndDateGreg().compareTo
- (tempTrmtBean.getStartDateGreg())>=0 &&
- stopBean.getEndDateGreg().compareTo
- (tempTrmtBean.getEndDateGreg())<=0 )
- {
- if(stopBean.getEndDateGreg().compareTo
- (tempTrmtBean.getEndDateGreg())==0)
- {
- tempTrmtBean = null;
- }else if(stopBean.getEndDateGreg().compareTo
- (tempTrmtBean.getEndDateGreg())<=0)
- {
- tempTrmtBean.setStartDateGreg
- (GOSIUtilities.getNextDate
- (stopBean.getEndDateGreg()));
- newTrmtList.add(tempTrmtBean);
- }
- break;
- }
- }
- break;
- }
- }
- }
- }
- return newTrmtList;
- }
- catch(GOSIException ge)
- {
- GOSIDebug.debugMessages("session-getAllowncePayablePeriodList:ge:"+ge);
- throw ge;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("session-getAllowncePayablePeriodList:e:"+e);
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "getAllowncePayablePeriodList()",e,"CMN_ERR_1000");
- }
- }
- /**
- * @METHOD NAME : getUniqueTreatmentIdLists
- * @INFORMATION : This method is to get Unique Treatment Id Lists
- * @PARAM : class java.util.ArrayList
- * @RETURN : class java.util.ArrayList
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private ArrayList getUniqueTreatmentIdLists(ArrayList trmtList)
- throws GOSIException
- {
- try
- {
- // the below logic get the unique treatmentids in the treatment list
- // and return the an array list with the unique ids
- int trmtListSize=trmtList.size();
- ArrayList uniqueTrmtList = new ArrayList();
- for(int i=0;i<trmtListSize;i++)
- {
- TreatmentPeriodBean trmtBean=
- (TreatmentPeriodBean)trmtList.get(i);
- Long trmtId = trmtBean.getTreatmentId();
- boolean trmtIdPresent = true;
- for(int j=0;j<uniqueTrmtList.size();j++)
- {
- TreatmentPeriodBean tempTrmtBean=
- (TreatmentPeriodBean)uniqueTrmtList.get(j);
- Long trmpTrmtId = tempTrmtBean.getTreatmentId();
- if(trmpTrmtId.equals(trmtId))
- {
- trmtIdPresent = false;
- break;
- }
- }
- if(trmtIdPresent)
- {
- uniqueTrmtList.add(trmtBean);
- }
- }
- return uniqueTrmtList;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("session-getUniqueTreatmentIdLists:e:"+e);
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "getUniqueTreatmentIdLists()",e,"CMN_ERR_1000");
- }
- }
- /**
- * @METHOD NAME : isValidVisitDate
- * @INFORMATION : This method is to validate Visit Date
- * @PARAM : class java.util.ArrayList,
- class gosi.business.socialinsurance.occupationalhazards.injury.beans.VisitBean
- * @RETURN : boolean
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private boolean isValidVisitDate(ArrayList stopPeriodList,
- VisitBean visitBean)throws GOSIException
- {
- try
- {
- // the below logic checks wether a vist falls on the
- // stopped or resumed period if falls on stopped period return false
- Timestamp visitDate = visitBean.getDateOfVisitGreg();
- Long visitInjuryId = visitBean.getInjuryId();
- int stopPeriodListSize = stopPeriodList.size();
- boolean isValidVisitflag = true;
- for(int i=0;i<stopPeriodListSize;i++)
- {
- TreatmentPeriodBean trmtBean =
- (TreatmentPeriodBean)stopPeriodList.get(i);
- if(visitDate.compareTo(trmtBean.getStartDateGreg())>=0 &&
- visitDate.compareTo(trmtBean.getEndDateGreg())<=0 &&
- visitInjuryId.equals(trmtBean.getInjuryId()))
- {
- isValidVisitflag = false;
- break;
- }
- }
- return isValidVisitflag;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("session-isValidVisitDate:e:"+e);
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "isValidVisitDate()",e,"CMN_ERR_1000");
- }
- }
- /**
- * @METHOD NAME : isValidcompanionDate
- * @INFORMATION : This method is to Validate companion Dates
- * @PARAM : class java.util.ArrayList,
- class java.sql.Timestamp
- * @RETURN : boolean
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private boolean isValidcompanionDate(ArrayList stopPeriodList,
- Timestamp companionDate)throws GOSIException
- {
- try
- {
- // the below logic checks wether a companion dates falls on the
- // stopped or resumed period if falls on stopped period return false
- int stopPeriodListSize = stopPeriodList.size();
- boolean isValidVisitflag = true;
- for(int i=0;i<stopPeriodListSize;i++)
- {
- TreatmentPeriodBean trmtBean =
- (TreatmentPeriodBean)stopPeriodList.get(i);
- if(companionDate.compareTo(trmtBean.getStartDateGreg())>=0
- && companionDate.compareTo(trmtBean.getEndDateGreg())<=0 )
- {
- isValidVisitflag = false;
- break;
- }
- }
- return isValidVisitflag;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("session-isValidVisitDate:e:"+e);
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "isValidcompanionDate()",e,"CMN_ERR_1000");
- }
- }
- /**
- * @METHOD NAME : changeDates
- * @INFORMATION : This method is to change Dates to the user formats
- * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.InjuryPopDetails
- * @RETURN : class gosi.business.socialinsurance.occupationalhazards.injury.beans.InjuryPopDetails
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- public InjuryPopDetails changeDates(InjuryPopDetails injuryDetails)
- throws GOSIException
- {
- long startTime = 0;
- long endTime = 0;
- long elapsedTime = 0;
- startTime = System.currentTimeMillis();
- try
- {
- // this method converts the date entered as string into the
- // gregorian format injury date , bnefit start and enddates are converted
- Timestamp injuryDate =null;
- Timestamp benefitEndDate =null;
- Timestamp benefitStartDate =null;
- if(injuryDetails.getInjuryDateStr()!=null &&
- !("").equals(injuryDetails.getInjuryDateStr()))
- {
- if(OHConstants.HIJRAH.equals
- (injuryDetails.getInjuryDateEntFmt()))
- {
- injuryDate=GOSIUtilities.getTimestamp
- (GOSIDateUtilities.convertToGregorian
- (injuryDetails.getInjuryDateStr()));
- }else
- {
- injuryDate = GOSIUtilities.getTimestamp(
- injuryDetails.getInjuryDateStr());
- }
- injuryDetails.setInjuryDate(injuryDate);
- }
- if(injuryDetails.getBenefitEndDateStr()!=null &&
- !("").equals(injuryDetails.getBenefitEndDateStr()))
- {
- if(OHConstants.HIJRAH.equals
- (injuryDetails.getBenefitEndDateEntFmt()))
- {
- benefitEndDate=GOSIUtilities.getTimestamp
- (GOSIDateUtilities.convertToGregorian
- (injuryDetails.getBenefitEndDateStr()));
- }else
- {
- benefitEndDate = GOSIUtilities.getTimestamp(
- injuryDetails.getBenefitEndDateStr());
- }
- injuryDetails.setBenefitEndDate( benefitEndDate);
- }
- if(injuryDetails.getBenefitStartDateStr()!=null&&
- !("").equals(injuryDetails.getBenefitStartDateStr()))
- {
- if(OHConstants.HIJRAH.equals
- (injuryDetails.getBenefitStartDateEntFmt()))
- {
- benefitStartDate=GOSIUtilities.getTimestamp
- (GOSIDateUtilities.convertToGregorian
- (injuryDetails.getBenefitStartDateStr()));
- }else
- {
- benefitStartDate = GOSIUtilities.getTimestamp(
- injuryDetails.getBenefitStartDateStr());
- }
- injuryDetails.setBenefitStartDate( benefitStartDate);
- }
- endTime = System.currentTimeMillis();
- elapsedTime = endTime - startTime;
- GOSIInstrumentationLog.writeInstrumentationToLog(
- this.getClass().toString(),
- "changeDates()",
- elapsedTime);
- return injuryDetails;
- }catch(GOSIException ge)
- {
- GOSIDebug.debugMessages("session-changeDates : ge:"+ge);
- throw ge;
- }catch(Exception e)
- {
- GOSIDebug.debugMessages("session-changeDates :The exception is "+e);
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "changeDates()",e,"CMN_ERR_1000");
- }
- }
- /**
- * @METHOD NAME : changeBenefitDates
- * @INFORMATION : This method is to change Benefit Dates to the user formats
- * @PARAM : class java.util.ArrayList,
- class java.lang.String
- * @RETURN : class java.util.ArrayList
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- public ArrayList changeBenefitDates(ArrayList benefitList ,
- String entryFormat) throws GOSIException
- {
- GOSIDebug.debugMessages("-------changeBenefitDates-------");
- GOSIDebug.debugMessages("EntFmt:"+entryFormat);
- long startTime = 0;
- long endTime = 0;
- long elapsedTime = 0;
- startTime = System.currentTimeMillis();
- // this method converts the time stamp dates generated to string of the specifed format
- // bnefit start and enddates in the generated benefit list are converted
- try
- {int listSize = benefitList.size();
- for(int i=0;i<listSize;i++)
- {
- OHAllowanceBean benefitBean=(OHAllowanceBean)benefitList.get(i);
- if(OHConstants.HIJRAH.equals(entryFormat))
- {
- benefitBean.setBenStDateStr
- (GOSIDateUtilities.convertToHijra(
- GOSIUtilities.getDateFullString
- (benefitBean.getBenStDateGreg())));
- }
- else
- {
- benefitBean.setBenStDateStr
- (GOSIUtilities.getDateFullString(
- benefitBean.getBenStDateGreg()));
- }
- benefitBean.setBenStDateEntFmt(entryFormat);
- if(OHConstants.HIJRAH.equals(entryFormat))
- {
- benefitBean.setBenEndDateStr
- (GOSIDateUtilities.convertToHijra(
- GOSIUtilities.getDateFullString(
- benefitBean.getBenEndDateGreg())));
- }
- else
- {
- benefitBean.setBenEndDateStr
- (GOSIUtilities.getDateFullString(
- benefitBean.getBenEndDateGreg()));
- }
- benefitBean.setBenEndDateEntFmt(entryFormat) ;
- }
- endTime = System.currentTimeMillis();
- elapsedTime = endTime - startTime;
- GOSIInstrumentationLog.writeInstrumentationToLog(
- this.getClass().toString(),
- "changeBenefitDates()",
- elapsedTime);
- return benefitList;
- }catch(GOSIException ge)
- {
- throw ge;
- }catch(Exception e)
- {
- GOSIDebug.debugMessages("session-changeDates :The exception is "+e);
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "changeBenefitDates()",e,"CMN_ERR_1000");
- }
- }
- /**
- * @return
- *
- */
- /**
- * @METHOD NAME : calculateOHAllowance
- * @INFORMATION : This method is to calculate OH Allowance
- * @PARAM : class java.util.ArrayList
- boolean
- * @RETURN : class java.util.ArrayList
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- public ArrayList calculateOHAllowance(ArrayList injuryList,boolean isTreatmentApproved)
- throws GOSIException
- {
- GOSIDebug.debugMessages("\t\t Start calculateOHAllowance - MaintainOHAllowanceSessionEJB");
- long startTime = 0;
- long endTime = 0;
- long elapsedTime = 0;
- startTime = System.currentTimeMillis();
- String calenderType = "";
- ArrayList benefitList = new ArrayList();
- try
- {
- // this method is called from the OHAllowanceServlet to calculate oh benefit
- // for the contributor, the injury list contains details of injury
- // and the benefit period and the boolean flag determining to
- // calculate benefit for approved or unapporved trmeatment periods
- con = GOSIUtilities.getConnection (GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
- if (!isTreatmentApproved)
- {
- // injury details from servlet
- InjuryPopDetails injuryDetails = (InjuryPopDetails) injuryList.remove (0);
- // get current injury details
- InjuryPopDetails injuryBean = getInjuryBean (injuryDetails.getInjuryID());
- injuryBean.setBenefitStartDate (injuryDetails.getBenefitStartDate());
- injuryBean.setBenefitStartDateStr (injuryDetails.getBenefitStartDateStr());
- injuryBean.setBenefitStartDateEntFmt (injuryDetails.getBenefitStartDateEntFmt());
- injuryBean.setBenefitEndDate (injuryDetails.getBenefitEndDate());
- injuryBean.setBenefitEndDateStr (injuryDetails.getBenefitEndDateStr());
- injuryBean.setBenefitEndDateEntFmt (injuryDetails.getBenefitEndDateEntFmt());
- if (injuryBean.getInjuryStatus().equals(OHConstants.INJ_STS_NOTIFIED))
- {
- // UnApproved Injury Details found for the
- // period entered, Please redefine your calculation period
- // or Approve the Injury record
- throw new GOSIException (GOSIConstants.SEVERITY_FOUR,
- GOSIConstants.OCCUPATIONAL_HAZARDS,
- this.getClass().toString(),
- "calculateOHAllowance()",
- null,
- "SOI_ERR_5189");
- }
- // comparing end date with current date
- if (injuryBean.getBenefitEndDate().compareTo(new Timestamp(System.currentTimeMillis())) > 0)
- {
- throw new GOSIException (GOSIConstants.SEVERITY_THREE,
- GOSIConstants.OCCUPATIONAL_HAZARDS,
- this.getClass().toString(),
- "calculateOHAllowance()",
- null,
- "SOI_ERR_4189");
- }
- //comparing startdate with end date
- if (injuryBean.getBenefitStartDate().compareTo(injuryBean.getBenefitEndDate()) > 0)
- {
- throw new GOSIException (GOSIConstants.SEVERITY_THREE,
- GOSIConstants.OCCUPATIONAL_HAZARDS,
- this.getClass().toString(),
- "calculateOHAllowance()",
- null,
- "SOI_ERR_4190");
- }
- // getting contributor and establishment details
- injuryBean = setContributorDetails (injuryBean);
- injuryBean = setEstablishmentDetails (injuryBean);
- //setting injury date to complication date
- // if complication date is not null and
- // the person is having a valid engagement on complication date
- Timestamp injuryDate = injuryBean.getInjuryDate();
- if (injuryBean.getComplicationDate() != null)
- {
- if (injuryBean.getIsEngagementPresentOnComplicationAndEligibleForOH())
- {
- injuryDate = injuryBean.getComplicationDate();
- }
- //setting wage for the injured engagement
- injuryBean = setTotalConWage(injuryDate, injuryBean);
- }
- else
- {
- //setting wage for the injured engagement
- injuryBean = setTotalConWage(injuryDate, injuryBean);
- }
- // store injury bean back into list
- injuryList.add (0, injuryBean);
- // calculating the total contributory wage
- injuryList = getTotalContributorWage (injuryList);
- if (injuryBean.getTotalConWage() == null || injuryBean.getTotalConWage().doubleValue() == 0)
- {
- throw new GOSIException (GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass().toString(),
- "calculateOHAllowance()",
- null,
- "SOI_ERR_5559");
- }
- }
- calenderType = getCalendarType(injuryList);
- int injuryListSize = injuryList.size();
- InjuryPopDetails injuryDetails = (InjuryPopDetails)injuryList.get(0);
- String entFmt = injuryDetails.getBenefitStartDateEntFmt();
- Long socInsNumber = injuryDetails.getSocialInsuranceNumber();
- Timestamp startDate = null;
- Timestamp endDate = null;
- ArrayList totalPayablePeriodList = new ArrayList();
- // Logic for getting the treatment period list for which
- // benfit is to be calculated
- GOSIDebug.debugMessages("injuryListSize:" + injuryListSize +":" );
- for(int i=0;i<injuryListSize;i++)
- {
- InjuryPopDetails injuryBean = (InjuryPopDetails)injuryList.get(i);
- Long injuryId = injuryBean.getInjuryID();
- startDate = injuryBean.getBenefitStartDate();
- endDate = injuryBean.getBenefitEndDate();
- ArrayList periodList = null;
- ArrayList stoppedList = null;
- ArrayList payablePeriodList = null;
- periodList = getTreatmentPeriodList(injuryBean,isTreatmentApproved);
- GOSIDebug.debugMessages("PeriodListSize:" + periodList.size());
- if(periodList != null)
- {
- stoppedList = getInjuryStoppedPeriodList(injuryBean,isTreatmentApproved);
- GOSIDebug.debugMessages("StoppedListSize:" + stoppedList.size());
- payablePeriodList = getPayablePeriodList
- (periodList,stoppedList);
- GOSIDebug.debugMessages("PayablePeriodListSize:" + payablePeriodList.size());
- }
- int payablePeriodListSize = payablePeriodList.size();
- for (int j=0;j<payablePeriodListSize;j++)
- {
- totalPayablePeriodList.add(payablePeriodList.get(j));
- }
- }
- // for each of the valid days the trmt type is set
- // so at the end this logic we get a list of days for which the
- // benefit is to be calculated
- ArrayList daysList = new ArrayList();
- startDate = injuryDetails.getBenefitStartDate();
- endDate = injuryDetails.getBenefitEndDate();
- GOSIDebug.debugMessages("StartDate :" + startDate + " EndDate:" + endDate);
- int noDays = OHUtilities.getDays(startDate,endDate);
- Timestamp trmtDate = startDate;
- GOSIDebug.debugMessages("TotalPayableListSize:" + totalPayablePeriodList.size() + ":TotalDays:" + noDays +":");
- for (int i=0; i<noDays ; i++)
- {
- TreatmentPeriodBean trmtBean = getTrmtDetailsforDate
- (trmtDate,totalPayablePeriodList);
- if(trmtBean != null)
- {
- daysList.add(trmtBean);
- }
- trmtDate = GOSIUtilities.getNextDate(trmtDate);
- }
- GOSIDebug.debugMessages("DaysListSize:" + daysList.size());
- for (int i=0; i<daysList.size() ; i++)
- {
- GOSIDebug.debugMessages("Date:" + ((TreatmentPeriodBean)daysList.get(i)).getStartDateGreg());
- }
- //ArrayList payablePeriodList = getBenefitPayableTrmtList(totalPayablePeriodList);
- // this method converts back the days list into period lists
- ArrayList payablePeriodList = getBenefitPayableTrmtList(daysList);
- // this method calculates the daily allowace for the period
- ArrayList dailyAllowanceList =
- calculateDailyAllowance(injuryList,payablePeriodList,isTreatmentApproved);
- //GOSIDebug.debugMessages("DailyAllowance LIST:" + dailyAllowanceList.size());
- // this method calculate the vists for the period
- ArrayList visitList =
- calculateConveyenceAllowance(injuryList,false,isTreatmentApproved);
- //GOSIDebug.debugMessages("ConveyenceAllowance LIST:" + visitList.size());
- // this method calculates the companion allowance for the period
- ArrayList companionList =
- calculateCompanionAllowance(injuryList,false,isTreatmentApproved);
- //GOSIDebug.debugMessages("CompanionAllowance LIST:" + companionList.size());
- GOSIDebug.debugMessages("DailyAllowance LIST:" + dailyAllowanceList.size());
- GOSIDebug.debugMessages("ConveyenceAllowance LIST:" + visitList.size());
- GOSIDebug.debugMessages("CompanionAllowance LIST:" + companionList.size());
- // if the person can get the oh benefit his daily allowance is
- // added to the benefit list else only the other allowances are paid
- if(this.canAvailBenefitdueToDisablity(socInsNumber))
- {
- benefitList = addToBenefitList(benefitList,dailyAllowanceList);
- }
- // adding vists to benefit list
- benefitList = addToBenefitList(benefitList,visitList);
- // adding companinon allowance to benefit list
- benefitList = addToBenefitList(benefitList,companionList);
- GOSIDebug.debugMessages("---------calculateOHAllowance*----------");
- // changing the date of benefit list to users entry format
- benefitList = changeBenefitDates(benefitList,entFmt);
- for(int i=0;i<benefitList.size();i++)
- {
- OHAllowanceBean benefitBean =
- (OHAllowanceBean)benefitList.get(i);
- // setting injury number for each benefit
- benefitBean.setInjuryNumber
- (getInjuryNumber(injuryList,benefitBean.getInjuryId()));
- }
- GOSIDebug.debugMessages("---------calculateWorkerEmployerBenefitList----------");
- if(injuryList.size()== 1)
- {
- // corercting the period for which to pay to employer and to contributor
- GOSIDebug.debugMessages("BenefitList size before calling calculateWorkerEmployerBenefitList:" + benefitList.size() + ":");
- benefitList = calculateWorkerEmployerBenefitList
- (benefitList,injuryList);
- //if contributor is working in more than one establishemnt then
- //distribute total amount based on each establishment's wage.
- benefitList = distributeWageToEstablishments(
- benefitList,injuryList);
- }
- // checking if the single visit is already paid or not
- // if paid it will throw an error
- isDuplicateSingleVisit(benefitList);
- endTime = System.currentTimeMillis();
- elapsedTime = endTime - startTime;
- GOSIInstrumentationLog.writeInstrumentationToLog(
- this.getClass().toString(),
- "calculateOHAllowance()",
- elapsedTime);
- GOSIDebug.debugMessages("\t\t End calculateOHAllowance - MaintainOHAllowanceSessionEJB");
- return benefitList;
- }
- catch(GOSIException ge)
- {
- GOSIDebug.debugMessages("session-calculateOHAllowance :ge:"+ge);
- throw ge;
- }catch(Exception e)
- {
- GOSIDebug.debugMessages("session-calculateOHAllowance :e:"+e);
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "calculateOHAllowance()",e,"CMN_ERR_1000");
- }
- finally
- {
- GOSIDebug.debugMessages("connection Closed");
- GOSIUtilities.cleanUp(con);
- }
- }
- /**
- * @METHOD NAME : recalculateBenefitDetails
- * @INFORMATION : This method is to recalculate benefit details
- * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.RecalculateBenefitInputBean,
- class gosi.core.workflow.beans.WorkflowParamBean
- * @RETURN : void
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- public void recalculateBenefitDetails (RecalculateBenefitInputBean recalculateBean, WorkflowParamBean workflowParamBean)
- throws GOSIException
- {
- /**
- * Service method for recalculating benefit amounts for a given contributor following a change
- * in his or her wage.
- *
- * This process creates a new OH benefit for the given contributor accounting for the difference
- * in recalculated benefit amounts. If the difference is negative, an employer/contributor
- * recovery transaction is added to the workflow registry.
- *
- * This functionality is already present in OH Batch 12. It was reimplemented here to fulfill a service
- * requirement from the Registration department; See CQ PRD00007841.
- */
- try
- {
- con = GOSIUtilities.getConnection (GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
- /**
- * Step 1: Compile list of OH benefits subject to recalculation
- */
- ArrayList benefitList = getBenefitListAffectedByWageChange (recalculateBean.getContributorId (),
- recalculateBean.getFromDate (),
- recalculateBean.getToDate ());
- if (benefitList == null || benefitList.size () == 0)
- {
- GOSIDebug.debugMessages ("recalculateBenefitDetails (): Could not find any benefits affected by wage change for given contributor (contributor id: " + recalculateBean.getContributorId () + ")");
- GOSIDebug.debugMessages ("recalculateBenefitDetails (): No further processing at this point");
- return;
- }
- else
- {
- GOSIDebug.debugMessages ("recalculateBenefitDetails (): Compiled benefit list has " + benefitList.size () + " element(s)");
- }
- /**
- * Step 2: Compile list of injury records pertaining to OH benefit list compiled above
- */
- ArrayList injuryList = getInjuryListPertainingToBenefitRecalculation (benefitList,
- recalculateBean.getEngagementId (),
- recalculateBean.getWage (),
- recalculateBean.getFromDate ());
- if (injuryList == null || injuryList.size () == 0)
- {
- GOSIDebug.debugMessages ("recalculateBenefitDetails (): Could not retrieve injury details for the given contributor for injury records saved on " + recalculateBean.getFromDate () + " or later (contributor id: " + recalculateBean.getContributorId () + ", engagement id: " + recalculateBean.getEngagementId () + ")");
- GOSIDebug.debugMessages ("recalculateBenefitDetails (): No further processing at this point");
- return;
- }
- else
- {
- GOSIDebug.debugMessages ("recalculateBenefitDetails (): Compiled injury record list has " + injuryList.size () + " element(s)");
- }
- /**
- * Step 3: Recalculate and update OH benefits
- *
- * Loop through the list of benefits affected by wage change and, in each loop iteration, recalculate the
- * benefit amounts using provided wage data and update records accordingly.
- */
- Long userId = new Long (workflowParamBean.getUserId ());
- String calenderType = getCalendarType (injuryList);
- Long approvalWorkflowId = GOSIUtilities.getPrimaryKey ("OHBNFTWORKFLOWID", userId);
- Long recoveryWorkflowId = GOSIUtilities.getPrimaryKey ("OHBNFTWORKFLOWID", userId);
- String contributorName = "";
- Long socialInsuranceNumber = null;
- Long registrationNumber = null;
- Short destinationFieldOffice = null;
- for (int i = 0; i < benefitList.size (); i++)
- {
- InjuryPopDetails injuryBean = new InjuryPopDetails ();
- OHAllowanceBean benefitBean = (OHAllowanceBean) benefitList.get (i);
- Timestamp startDate = benefitBean.getBenStDateGreg ();
- Timestamp endDate = benefitBean.getBenEndDateGreg ();
- injuryBean.setBenefitStartDate (benefitBean.getBenStDateGreg ());
- injuryBean.setBenefitEndDate (benefitBean.getBenEndDateGreg ());
- injuryBean = getInjuryBean (injuryList, benefitBean.getInjuryId());
- destinationFieldOffice = benefitBean.getFieldofficeCode();
- Double totalConWage = injuryBean.getTotalConWage();
- contributorName = injuryBean.getName ();
- socialInsuranceNumber = injuryBean.getSocialInsuranceNumber ();
- registrationNumber = injuryBean.getRegistrationNumber ();
- double changeAmount = totalConWage.doubleValue () - benefitBean.getTotalContWage ().doubleValue ();
- GOSIDebug.debugMessages ("recalculateBenefitDetails (): Current contributor wage is " + totalConWage.doubleValue ());
- GOSIDebug.debugMessages ("recalculateBenefitDetails (): Adjusted contributor wage is " + benefitBean.getTotalContWage ().doubleValue ());
- benefitBean.setTotalContWage (new Double (changeAmount));
- Long injuryId = benefitBean.getInjuryId ();
- Short hospitalType = getHospitalType (injuryId, startDate, endDate);
- if (benefitBean.getBenStDateGreg ().compareTo (OHRuleBean.getNewLawApplicableDate ()) < 0 &&
- benefitBean.getBenEndDateGreg ().compareTo (OHRuleBean.getNewLawApplicableDate ()) >= 0)
- {
- GOSIDebug.debugMessages ("recalculateBenefitDetails (): Recalculation is subject to former GOSI business that were applicable before " + OHRuleBean.getNewLawApplicableDate ());
- OHAllowanceBean oldLawBean = new OHAllowanceBean (benefitBean);
- OHAllowanceBean newLawBean = new OHAllowanceBean (benefitBean);
- oldLawBean.setBenEndDateGreg (OHUtilities.getPrevDate (OHRuleBean.getNewLawApplicableDate ()));
- newLawBean.setBenStDateGreg (OHRuleBean.getNewLawApplicableDate ());
- if (OHConstants.HIJRAH.equals (calenderType))
- {
- oldLawBean = setDailyAllowanceHij (oldLawBean, hospitalType);
- newLawBean = setDailyAllowanceHij (newLawBean, hospitalType);
- }
- else
- {
- oldLawBean = setDailyAllowanceGreg (oldLawBean, hospitalType);
- newLawBean = setDailyAllowanceGreg (newLawBean, hospitalType);
- }
- double totalAmount = oldLawBean.getBenAmount ().doubleValue ()
- + newLawBean.getBenAmount ().doubleValue ();
- benefitBean.setBenAmount (new Double (totalAmount));
- }
- else
- {
- GOSIDebug.debugMessages ("recalculateBenefitDetails (): Recalculation is subject to current GOSI business rules applicable since " + OHRuleBean.getNewLawApplicableDate ());
- if (OHConstants.HIJRAH.equals(calenderType))
- {
- benefitBean = setDailyAllowanceHij (benefitBean, hospitalType);
- }
- else
- {
- benefitBean = setDailyAllowanceGreg (benefitBean, hospitalType);
- }
- }
- benefitBean.setTotalContWage (totalConWage);
- if (benefitBean.getBenAmount ().doubleValue () > 0)
- {
- benefitBean.setWorkflowId (approvalWorkflowId);
- }
- else if (benefitBean.getBenAmount ().doubleValue () < 0)
- {
- benefitBean.setWorkflowId (recoveryWorkflowId);
- }
- benefitBean.setBenStatus (OHConstants.OH_BNFT_STS_ENTERED);
- benefitBean.setWorkflowStatus (OHConstants.WFS_OH_BNFT_ENTERED);
- benefitBean.setCreatedBy (userId);
- benefitBean.setCreationTimestamp (new Timestamp (System.currentTimeMillis ()));
- benefitBean.setOhBenId (GOSIUtilities.getPrimaryKey ("T_OHBENEFIT", userId));
- if(benefitBean.getOhBenCode ().equals (OHConstants.OH_ALWNC_DAIlY_INPATIENT))
- {
- benefitBean.setOhBenCode (OHConstants.OH_ALWNC_DAILY_INPATIENT_ADJUSTMENT);
- benefitBean.setOhBenType (GOSIUtilities.getDomainDesc("OH Benefit Type", OHConstants.OH_ALWNC_DAILY_INPATIENT_ADJUSTMENT.shortValue (), true));
- }
- else if(benefitBean.getOhBenCode ().equals (OHConstants.OH_ALWNC_DAIlY_OUTPATIENT))
- {
- benefitBean.setOhBenCode (OHConstants.OH_ALWNC_DAILY_OUTPATIENT_ADJUSTMENT);
- benefitBean.setOhBenType (GOSIUtilities.getDomainDesc("OH Benefit Type", OHConstants.OH_ALWNC_DAILY_OUTPATIENT_ADJUSTMENT.shortValue (), true));
- }
- }
- /**
- * Step 4: Create OH Benefit for beneficiary
- *
- * Insert a new benefit record for the beneficiary accounting for the difference amount
- * due to recalculation. This benefit amount could be either positive or negative.
- */
- OHAllowanceEntityHome home = (OHAllowanceEntityHome)
- ServiceLocator.getInstance ().getRemoteHome(
- OHConstants.OH_ALLOWANCE_ENTITY_JNDI,
- OHAllowanceEntityHome.class);
- boolean approvalNeeded = false;
- boolean recoveryNeeded = false;
- for (int i = 0; i < benefitList.size (); i++)
- {
- OHAllowanceBean benefitBean = (OHAllowanceBean) benefitList.get (i);
- if (benefitBean.getBenAmount ().doubleValue () > 0)
- {
- approvalNeeded = true;
- }
- else if (benefitBean.getBenAmount ().doubleValue () < 0)
- {
- recoveryNeeded = true;
- benefitBean.setBenStatus (OHConstants.OH_BNFT_STS_APPROVED);
- benefitBean.setWorkflowStatus (OHConstants.WFS_OH_BNFT_APPROVED_OH_HEAD);
- }
- home.create (benefitBean);
- }
- /**
- * Step 5: Complete recalculation process
- *
- * Since recalculation may change benefit amount, it is necessary for this change to go through
- * procedures to finalize such a change
- *
- */
- /**
- * Step 5 (a): Start the approval transaction if an OH benefit having a postive amount was created
- */
- if (approvalNeeded)
- {
- WorkflowParamBean approvalWorkflowBean = new WorkflowParamBean ();
- approvalWorkflowBean.setModuleId (GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
- approvalWorkflowBean.setUserId (userId.longValue ());
- approvalWorkflowBean.setUserLocationId (workflowParamBean.getUserLocationId ());
- approvalWorkflowBean.setStepShortName ("CALCULATE_OH_ALLWNC");
- approvalWorkflowBean.setDestinationLocationId (destinationFieldOffice.shortValue ());
- approvalWorkflowBean.setrecordDescription (GOSIErrorMessages.getErrorDesc ("SOI_ERR_5620") + " - " + contributorName + " - " + socialInsuranceNumber);
- approvalWorkflowBean.setRoutingCriterion (GOSIConstants.COMPLETED);
- approvalWorkflowBean.setPrimaryKeyOfTherecord (approvalWorkflowId.toString ());
- GOSIUtilities.startWorkflow (approvalWorkflowBean);
- }
- /**
- * Step 5 (b): Recover amounts from parties if an OH benefit having a negative amount was created
- */
- if (recoveryNeeded)
- {
- ArrayList recEmpList = new ArrayList ();
- ArrayList recConList = new ArrayList ();
- double recEmpAmount = 0.00;
- double recConAmount = 0.00;
- for (int i = 0; i < benefitList.size (); i++)
- {
- OHAllowanceBean benefitBean = (OHAllowanceBean) benefitList.get (i);
- if (benefitBean.getBenAmount ().doubleValue () > 0)
- {
- continue; /* Omit recovering positive amounts */
- }
- if (OHConstants.OH_BNFT_PAY_TO_CON.equals (benefitBean.getBenefitPayableTo ()) ||
- OHConstants.OH_BNFT_PAY_TO_AUTH_PERSON.equals (benefitBean.getBenefitPayableTo ()))
- {
- recConList.add (benefitBean);
- recConAmount = recConAmount + Math.abs(benefitBean.getBenAmount ().doubleValue ());
- }
- else if (OHConstants.OH_BNFT_PAY_TO_EMP.equals (benefitBean.getBenefitPayableTo ()))
- {
- recEmpList.add (benefitBean);
- recEmpAmount = recEmpAmount + Math.abs(benefitBean.getBenAmount ().doubleValue ());
- }
- }
- GOSIDebug.debugMessages ("recalculateBenefitDetails (): Amount to be recovered from employer is " + recEmpAmount);
- GOSIDebug.debugMessages ("recalculateBenefitDetails (): Amount to be recovered from contributor is " + recConAmount);
- if (recEmpList.size () > 0)
- {
- Long recEmpWorkflowId = GOSIUtilities.getPrimaryKey ("RECFROMEMPWORKFLOWID", userId);
- Long recInjuryId = null;
- ArrayList recoverFromEmployerList = new ArrayList ();
- for (int i = 0; i < recEmpList.size (); i++)
- {
- OHAllowanceBean benefitBean = (OHAllowanceBean) recEmpList.get (i);
- recInjuryId = benefitBean.getInjuryId ();
- RecEmployerBean recEmpBean = new RecEmployerBean ();
- recEmpBean.setRecID (GOSIUtilities.getPrimaryKey ("T_RECFROMEMP", userId));
- recEmpBean.setOhBenID (benefitBean.getOhBenId ());
- recEmpBean.setWorkFlowID (recEmpWorkflowId);
- recEmpBean.setEstablishmentID (getEstablishmentId (benefitBean.getPartyCode (), injuryList));
- if (benefitBean.getBenAmount () != null)
- {
- recEmpBean.setAmountDue (new Double (Math.abs(benefitBean.getBenAmount ().doubleValue ())));
- }
- else
- {
- recEmpBean.setAmountDue (new Double("0"));
- }
- recEmpBean.setAmountReceived (new Double ("0"));
- recEmpBean.setStatus (OHConstants.REC_FROM_EMP_ENTERED);
- recEmpBean.setRequestDate (new Timestamp (System.currentTimeMillis ()));
- recEmpBean.setRequestDateEntFmt (OHConstants.GREGORIAN);
- recEmpBean.setWorkflowStatus (OHConstants.REC_FROM_EMP_CLERK_ENT);
- recEmpBean.setCreatedBy (userId);
- recEmpBean.setRecoveryType (OHConstants.RECOVERY_TYPE_OH_BENEFIT);
- recEmpBean.setInjuryId (benefitBean.getInjuryId ());
- recEmpBean.setCreationTimestamp (new Timestamp (System.currentTimeMillis ()));
- recEmpBean.setLocationCode (destinationFieldOffice);
- recoverFromEmployerList.add (recEmpBean);
- }
- createRecFromEmp (recoverFromEmployerList);
- WorkflowParamBean recoveryWorkflowBean = new WorkflowParamBean ();
- recoveryWorkflowBean.setModuleId (GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
- recoveryWorkflowBean.setUserId (userId.longValue ());
- recoveryWorkflowBean.setUserLocationId (workflowParamBean.getUserLocationId ());
- recoveryWorkflowBean.setStepShortName ("REC_FROM_EMPLOYER");
- recoveryWorkflowBean.setrecordDescription (GOSIErrorMessages.getErrorDesc ("SOI_ERR_5621") + " - " + registrationNumber);
- recoveryWorkflowBean.setDestinationLocationId (destinationFieldOffice.shortValue ());
- recoveryWorkflowBean.setRoutingCriterion (GOSIConstants.COMPLETED);
- recoveryWorkflowBean.setPrimaryKeyOfTherecord (recEmpWorkflowId.toString () + "~" + recInjuryId.toString ());
- GOSIUtilities.startWorkflow (recoveryWorkflowBean);
- }
- if (recConList.size () > 0)
- {
- ArrayList recoverContributorList = new ArrayList();
- Long recConWorkflowId = GOSIUtilities.getPrimaryKey ("RECFROMCONWORKFLOWID", userId);
- for (int i = 0; i < recConList.size (); i++)
- {
- OHAllowanceBean benefitBean = (OHAllowanceBean) recConList.get (i);
- RecFromContributorHeaderBean recConBean = new RecFromContributorHeaderBean ();
- recConBean.setOHBenID (benefitBean.getOhBenId ());
- recConBean.setWorkFlowID (recConWorkflowId);
- recConBean.setRecID (GOSIUtilities.getPrimaryKey ("T_RECFROMCONTRIBUTOR", userId));
- if (benefitBean.getBenAmount () != null)
- {
- recConBean.setAmountReceived (new Double (Math.abs(benefitBean.getBenAmount ().doubleValue ())));
- }
- else
- {
- recConBean.setAmountReceived (new Double ("0"));
- }
- recConBean.setFromDateGreg (recalculateBean.getFromDate ());
- recConBean.setFromDateEntFmt (OHConstants.GREGORIAN);
- recConBean.setToDateGreg (recalculateBean.getToDate ());
- recConBean.setToDateEntFmt (OHConstants.GREGORIAN);
- recConBean.setRequestDate (new Timestamp (System.currentTimeMillis ()));
- recConBean.setRequestDateEntFmt (OHConstants.GREGORIAN);
- recConBean.setWorkflowStatus (OHConstants.REC_FROM_CON_CLERK_ENT);
- recConBean.setCreatedBy (userId);
- recConBean.setCreationTimestamp (new Timestamp (System.currentTimeMillis ()));
- recoverContributorList.add(recConBean);
- }
- createRecFromCon (recoverContributorList);
- WorkflowParamBean recoveryWorkflowBean = new WorkflowParamBean ();
- recoveryWorkflowBean.setModuleId (GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
- recoveryWorkflowBean.setUserId (userId.longValue ());
- recoveryWorkflowBean.setUserLocationId (workflowParamBean.getUserLocationId ());
- recoveryWorkflowBean.setStepShortName ("REC_FROM_CONTRIBUTOR");
- recoveryWorkflowBean.setrecordDescription (GOSIErrorMessages.getErrorDesc ("SOI_ERR_5622") + " - " + socialInsuranceNumber);
- recoveryWorkflowBean.setRoutingCriterion (GOSIConstants.COMPLETED);
- recoveryWorkflowBean.setDestinationLocationId (destinationFieldOffice.shortValue ());
- recoveryWorkflowBean.setPrimaryKeyOfTherecord (recConWorkflowId.toString ());
- GOSIUtilities.startWorkflow (recoveryWorkflowBean);
- }
- }
- }
- catch (GOSIException ge)
- {
- throw ge;
- }
- catch (Exception e)
- {
- throw new GOSIException (GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass ().toString (),
- "recalculateBenefitDetails ()",
- e,
- "CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp (con);
- }
- }
- /**
- * @METHOD NAME : getBenefitListAffectedByWageChange
- * @INFORMATION : Compiles a list of all approved benefits for a specific contributor
- for the purpose of recalculation
- * @PARAM : long, java.sql.Timestamp, java.sql.Timestamp
- * @RETURN : java.util.ArrayList
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private ArrayList getBenefitListAffectedByWageChange (Long contributorId, Timestamp fromDate, Timestamp toDate)
- throws GOSIException
- {
- ArrayList benefitList = new ArrayList ();
- PreparedStatement ps = null;
- ResultSet rs = null;
- try
- {
- String sqlQuery = "SELECT a.ohbenid, a.injuryid, a.fieldofficecode, a.ohbencode, a.ohbentype, a.benstdate, "
- + " a.benstdateentfmt, a.benenddate, a.benenddateentfmt, a.benamount, a.benstatus, "
- + " a.paymentmode, a.bankcode, a.bankaccnumber, a.totalcontwage, a.payableto, "
- + " a.partycode, a.contributorid "
- + " FROM " + SITables.T_OHBENEFIT + " a, " + SITables.T_INJURY + " b "
- + " WHERE b.injurydate <= ? "
- + " AND b.injurydate >= ? "
- + " AND a.contributorid = ? "
- + " AND a.ohbencode IN (?, ?, ?, ?) "
- + " AND a.benstatus NOT IN (?, ?) "
- + " AND a.injuryid = b.injuryid "
- + "ORDER BY a.benstdate, a.ohbenid";
- GOSIDebug.debugMessages ("-- sqlQuery -- " + sqlQuery);
- ps = con.prepareStatement (sqlQuery);
- int i = 0;
- ps.setTimestamp (++i, getEffectiveToDate (toDate));
- ps.setTimestamp (++i, fromDate);
- ps.setLong (++i, contributorId.longValue ());
- ps.setShort (++i, OHConstants.OH_ALWNC_DAIlY_INPATIENT.shortValue ());
- ps.setShort (++i, OHConstants.OH_ALWNC_DAIlY_OUTPATIENT.shortValue ());
- ps.setShort (++i, OHConstants.OH_ALWNC_DAILY_INPATIENT_ADJUSTMENT.shortValue ());
- ps.setShort (++i, OHConstants.OH_ALWNC_DAILY_OUTPATIENT_ADJUSTMENT.shortValue ());
- ps.setShort (++i, OHConstants.OH_BNFT_STS_REJECTED.shortValue ());
- ps.setShort (++i, OHConstants.OH_BNFT_STS_CANCELLED.shortValue ());
- rs = ps.executeQuery ();
- while (rs.next ())
- {
- OHAllowanceBean benefitBean = new OHAllowanceBean ();
- benefitBean.setInjuryId (new Long (rs.getLong ("INJURYID")));
- benefitBean.setFieldofficeCode (new Short (rs.getShort ("FIELDOFFICECODE")));
- benefitBean.setOhBenCode (new Short (rs.getShort ("OHBENCODE")));
- benefitBean.setOhBenType (rs.getString ("OHBENTYPE"));
- benefitBean.setBenStDateGreg (rs.getTimestamp ("BENSTDATE"));
- benefitBean.setBenEndDateGreg (rs.getTimestamp ("BENENDDATE"));
- benefitBean.setBenStDateEntFmt (rs.getString ("BENSTDATEENTFMT"));
- benefitBean.setBenEndDateEntFmt (rs.getString ("BENENDDATEENTFMT"));
- benefitBean.setBenAmount (new Double (rs.getDouble ("BENAMOUNT")));
- if (rs.getObject ("PAYMENTMODE") != null)
- {
- benefitBean.setPaymentMode (new Short (rs.getShort ("PAYMENTMODE")));
- }
- else
- {
- benefitBean.setPaymentMode (OHConstants.PAYMENT_MODE_CHEQUE);
- }
- if (rs.getObject ("BANKCODE") != null)
- {
- benefitBean.setBankCode (new Integer (rs.getInt ("BANKCODE")));
- }
- if (rs.getObject ("BANKACCNUMBER") != null)
- {
- benefitBean.setBankAccNumber (new Long (rs.getLong ("BANKACCNUMBER")));
- }
- benefitBean.setTotalContWage (new Double (rs.getDouble ("TOTALCONTWAGE")));
- benefitBean.setBenefitPayableTo (new Short (rs.getShort ("PAYABLETO")));
- benefitBean.setPartyCode (new Long (rs.getLong ("PARTYCODE")));
- benefitBean.setContributorId (new Long (rs.getLong ("CONTRIBUTORID")));
- if (OHConstants.OH_ALWNC_DAILY_INPATIENT_ADJUSTMENT.equals (benefitBean.getOhBenCode ()) ||
- OHConstants.OH_ALWNC_DAILY_OUTPATIENT_ADJUSTMENT.equals (benefitBean.getOhBenCode ()))
- {
- benefitList.remove (benefitList.size () - 1);
- if(OHConstants.OH_ALWNC_DAILY_INPATIENT_ADJUSTMENT.equals (benefitBean.getOhBenCode ()))
- {
- benefitBean.setOhBenCode (OHConstants.OH_ALWNC_DAIlY_INPATIENT);
- }
- else if(OHConstants.OH_ALWNC_DAILY_OUTPATIENT_ADJUSTMENT.equals (benefitBean.getOhBenCode ()))
- {
- benefitBean.setOhBenCode (OHConstants.OH_ALWNC_DAIlY_OUTPATIENT);
- }
- benefitList.add (benefitBean);
- }
- else if (OHConstants.OH_ALWNC_DAIlY_INPATIENT.equals (benefitBean.getOhBenCode ()) &&
- benefitBean.getBenAmount () != null &&
- benefitBean.getBenAmount ().doubleValue () < 0.00)
- {
- /* Skipping record; does not need to be considered for adjustment */
- }
- else
- {
- benefitList.add (benefitBean);
- }
- }
- }
- catch (Exception e)
- {
- throw new GOSIException (GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass ().toString (),
- "getBenefitListAffectedByWageChange ()",
- e,
- "CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp (ps, rs);
- }
- return benefitList;
- }
- /**
- * @METHOD NAME : getEffectiveToDate
- * @INFORMATION : Determines the effective end date on which a benefit recalculation is applicable
- for the purpose of recalculation
- * @PARAM : java.sql.Timestamp
- * @RETURN : java.sql.Timestamp
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private Timestamp getEffectiveToDate (Timestamp toDate)
- throws GOSIException
- {
- Timestamp effectiveToDate = null;
- try
- {
- Calendar calendar = GregorianCalendar.getInstance ();
- calendar.setTime (toDate);
- if (calendar.get (Calendar.DAY_OF_MONTH) == calendar.getActualMaximum (Calendar.DAY_OF_MONTH))
- {
- calendar.add (Calendar.MONTH, 1);
- calendar.set (Calendar.DAY_OF_MONTH, calendar.getActualMaximum (Calendar.DAY_OF_MONTH));
- effectiveToDate = new Timestamp (calendar.getTimeInMillis ());
- }
- else
- {
- effectiveToDate = toDate;
- }
- }
- catch (Exception e)
- {
- throw new GOSIException (GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass ().toString (),
- "getEffectiveToDate ()",
- e,
- "CMN_ERR_1000");
- }
- return effectiveToDate;
- }
- /**
- * @METHOD NAME : getInjuryListPertainingToBenefitRecalculation
- * @INFORMATION : Compiles a list of all injuries pertaining to benefits found in the given list
- for the purpose of recalculation
- * @PARAM : java.util.ArrayList,
- java.lang.Long,
- java.lang.Double,
- java.sql.Timestamp
- * @RETURN : java.util.ArrayList
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private ArrayList getInjuryListPertainingToBenefitRecalculation (ArrayList benefitList, Long engagementIdWC, Double newWage, Timestamp wageChangeDate)
- throws GOSIException
- {
- ArrayList injuryList = null;
- try
- {
- Hashtable injuryTable = new Hashtable ();
- for (int i = 0; i < benefitList.size (); i++)
- {
- OHAllowanceBean benefitBean = (OHAllowanceBean) benefitList.get (i);
- if (! injuryTable.containsKey (benefitBean.getInjuryId ()))
- {
- InjuryPopDetails injuryBean = getInjuryBean (benefitBean.getInjuryId ());
- injuryBean = setContributorDetails (injuryBean);
- injuryBean = setEstablishmentDetails (injuryBean);
- injuryTable.put (benefitBean.getInjuryId (), injuryBean);
- }
- }
- injuryList = new ArrayList (injuryTable.values ()); /* Set view of all injury records */
- String calendarType = getCalendarType (injuryList);
- for (int i = 0; i < injuryList.size (); i++)
- {
- InjuryPopDetails injuryBean = (InjuryPopDetails) injuryList.get (i);
- Timestamp injuryDate = injuryBean.getInjuryDate ();
- if (injuryBean.getComplicationDate () != null)
- {
- injuryDate = injuryBean.getComplicationDate ();
- }
- String injuryDateStr = OHUtilities.getDateStr (injuryDate, calendarType);
- int month = OHUtilities.getMonth (injuryDateStr);
- int year = OHUtilities.getYear (injuryDateStr);
- int lastMonth = month - 1;
- int lastYear = year;
- if (lastMonth == 0)
- {
- lastMonth = 12; /* Overlap month */
- lastYear = year - 1; /* Decrement year due to overlapping */
- }
- Double wage = new Double ("0.00");
- Long engagementId = injuryBean.getEngagementId ();
- Timestamp firstDate = OHUtilities.getGregDate (OHUtilities.getMonthStartDate (lastMonth, lastYear), calendarType);
- Timestamp lastDate = OHUtilities.getGregDate (GOSIDateUtilities.getMonthEndDate (lastMonth, lastYear), calendarType);
- wage = getWageforMonth (engagementId, lastDate);
- if (wage == null)
- {
- lastDate = OHUtilities.getGregDate (GOSIDateUtilities.getMonthEndDate (month, year), calendarType);
- wage = getWageforMonth (engagementId, lastDate);
- }
- if (engagementId.equals (engagementIdWC))
- {
- if (! lastDate.before (wageChangeDate))
- {
- wage = newWage;
- }
- else
- {
- return null; /* Invalidate data and abort the process */
- }
- }
- injuryBean.setTotalConWage (wage);
- }
- injuryList = updateTotalContributorWage (injuryList, engagementIdWC, newWage, wageChangeDate);
- }
- catch(GOSIException ge)
- {
- throw ge;
- }
- catch(Exception e)
- {
- throw new GOSIException (GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass ().toString (),
- "getInjuryListPertainingToBenefitRecalculation ()",
- e,
- "CMN_ERR_1000");
- }
- return injuryList;
- }
- /**
- * @METHOD NAME : updateTotalContributorWage
- * @INFORMATION : update total contributor wage due to wage change
- * @PARAM : class java.util.ArrayList
- class java.lang.Long,
- class java.lang.Double,
- class java.sql.Timestamp
- * @RETURN : class java.util.ArrayList
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private ArrayList updateTotalContributorWage (ArrayList injuryList,
- Long engagementIdWC,
- Double newWage,
- Timestamp wageChangeDate) throws GOSIException
- {
- /**
- * The total contributor wage is composed of several wages added up from
- * having multiple engagements (i.e. multiple employers) at a time.
- *
- * In the event of a backdated wage change to one or more of these engagements,
- * injury records pertaining to the other engagment records have to be updated to
- * reflect the total wage correctly; hence, this method is invoked.
- *
- * This method was implemented just to ensure consistency of injury records
- * in the event of a backdated change. In other words, if the contributor for
- * whom the wage change is being processed for had only one engagement (i.e. single employer)
- * for duration of the wage change proposed time frame, then calling this method will
- * have no effect on the process.
- */
- PreparedStatement ps = null;
- ResultSet rs = null;
- try
- {
- for (int i = 0; i < injuryList.size (); i++)
- {
- InjuryPopDetails injuryBean = (InjuryPopDetails) injuryList.get (i);
- Timestamp injuryDate = injuryBean.getInjuryDate ();
- if (injuryBean.getComplicationDate () != null)
- {
- injuryDate = injuryBean.getComplicationDate ();
- }
- String sqlQuery = "SELECT DISTINCT engagementid"
- + " FROM " + SITables.T_ENGAGEMENT
- + " WHERE contributorid = ?"
- + " AND joiningdate <= ?"
- + " AND (leavingdate >= ? OR leavingdate IS NULL)"
- + " AND engagementstatus != ?";
- ps = con.prepareStatement (sqlQuery);
- ps.setLong (1, (injuryBean.getContributorId ()).longValue ());
- ps.setTimestamp (2, injuryDate);
- ps.setTimestamp (3, injuryDate);
- ps.setShort (4, RegistrationConstants.ENG_JOIN_IN_PROGRESS.shortValue ());
- rs = ps.executeQuery ();
- ArrayList engagementList = new ArrayList ();
- while (rs.next ())
- {
- Long engagementId = new Long (rs.getLong ("ENGAGEMENTID"));
- engagementList.add (engagementId);
- }
- Short payableTo = OHConstants.OH_BNFT_PAY_TO_CON; /* Default payee */
- if (engagementList.size () > 2)
- {
- payableTo = OHConstants.OH_BNFT_PAY_TO_CON; /* Due to multiple engagements */
- }
- else
- {
- if (OHConstants.OH_BNFT_PAY_TO_EMP.equals (injuryBean.getBenefitPayableTo ()) &&
- injuryBean.getWageStopDate () == null)
- {
- payableTo = OHConstants.OH_BNFT_PAY_TO_EMP; /* As indicated in the injury record */
- }
- }
- /* Set benefit payable to */
- injuryBean.setBenefitPayableTo (payableTo);
- double totalContributorWage = 0.00;
- /* Add up wage amounts for each engagement record */
- for (int j = 0; j < engagementList.size (); j++)
- {
- Long engagementId = (Long) engagementList.get (j);
- Double engagementWage = null; /* Wage amount pertaining to an engagment record */
- if (engagementId.equals (injuryBean.getEngagementId ()))
- {
- engagementWage = injuryBean.getTotalConWage ();
- }
- else
- {
- String injuryDateStr = OHUtilities.getDateStr (injuryDate, OHConstants.HIJRAH);
- int month = OHUtilities.getMonth (injuryDateStr);
- int year = OHUtilities.getYear (injuryDateStr);
- int lastMonth = month - 1;
- int lastYear = year;
- if (lastMonth == 0)
- {
- lastMonth = 12; /* Overlap month */
- lastYear = year - 1; /* Decrement year due to overlapping */
- }
- Timestamp date = OHUtilities.getGregDate (GOSIDateUtilities.getMonthEndDate (lastMonth, lastYear), OHConstants.HIJRAH);
- engagementWage = getWageforMonth (engagementId, date);
- if (engagementWage == null)
- {
- date = OHUtilities.getGregDate (GOSIDateUtilities.getMonthEndDate (month, year), OHConstants.HIJRAH);
- engagementWage = getWageforMonth (engagementId, date);
- }
- if (engagementId.equals (engagementIdWC))
- {
- if (! date.before (wageChangeDate))
- {
- /**
- * Substitute wage amount found in records with newly adjusted wage for
- * this engagement only and for the indicated time frame.
- */
- engagementWage = newWage;
- }
- else
- {
- return null; /* Invalidate data and abort the process */
- }
- }
- }
- if (engagementWage != null)
- {
- totalContributorWage = totalContributorWage + engagementWage.doubleValue ();
- }
- }
- /* Update injury record with new total contribtor wage */
- injuryBean.setTotalConWage (new Double (totalContributorWage));
- }
- }
- catch (GOSIException ge)
- {
- throw ge;
- }
- catch (Exception e)
- {
- throw new GOSIException (GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass ().toString (),
- "updateTotalContributorWage ()",
- e,
- "CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp (ps, rs);
- }
- return injuryList;
- }
- /**
- * @METHOD NAME : getInjuryBean
- * @INFORMATION : This method is to get Injury Bean
- * @PARAM : cass java.lang.Long
- * @RETURN : class gosi.business.socialinsurance.occupationalhazards.injury.beans.InjuryPopDetails
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private InjuryPopDetails getInjuryBean (Long injuryId)
- throws GOSIException
- {
- InjuryPopDetails injuryBean = new InjuryPopDetails ();
- PreparedStatement ps = null;
- ResultSet rs = null;
- try
- {
- String sqlQuery = "SELECT injuryid, socinsnumber, contributorid, establishmentid, injurydate,"
- + " datecomplication, injurynumber, description, fieldofficecode,"
- + " injurystatus, employernotifydate, workerintimationdate, wagestopdate,"
- + " (NVL (workdisabilitydate, injurydate + 1)) mindisablitydate,"
- + " treatmentstdate, treatmentenddate"
- + " FROM t_injury"
- + " WHERE injuryid = ?";
- ps = con.prepareStatement (sqlQuery);
- ps.setLong (1, injuryId.longValue ());
- rs = ps.executeQuery ();
- if (rs.next ())
- {
- injuryBean.setInjuryID (new Long (rs.getLong ("INJURYID")));
- injuryBean.setSocialInsuranceNumber (new Long (rs.getLong ("SOCINSNUMBER")));
- injuryBean.setEstablishmentId (new Long (rs.getLong ("ESTABLISHMENTID")));
- injuryBean.setContributorId (new Long (rs.getLong ("CONTRIBUTORID")));
- injuryBean.setInjuryDate (rs.getTimestamp ("INJURYDATE"));
- if (rs.getObject ("DATECOMPLICATION") != null)
- {
- injuryBean.setComplicationDate (rs.getTimestamp ("DATECOMPLICATION"));
- }
- injuryBean.setInjuryNumber (new Long (rs.getLong ("INJURYNUMBER")));
- if (rs.getObject ("DESCRIPTION") != null)
- {
- injuryBean.setDescription (rs.getString ("DESCRIPTION"));
- }
- injuryBean.setFieldOffice (new Short (rs.getShort ("FIELDOFFICECODE")));
- injuryBean.setInjuryStatus (new Short (rs.getShort ("INJURYSTATUS")));
- if (rs.getObject ("EMPLOYERNOTIFYDATE") != null)
- {
- injuryBean.setEmployerNotifyDate (rs.getTimestamp("EMPLOYERNOTIFYDATE"));
- }
- if (rs.getObject ("WORKERINTIMATIONDATE") != null)
- {
- injuryBean.setWorkerIntimationDate (rs.getTimestamp("WORKERINTIMATIONDATE"));
- }
- if (rs.getObject ("WAGESTOPDATE") != null)
- {
- injuryBean.setWageStopDate (rs.getTimestamp("WAGESTOPDATE"));
- }
- if (rs.getObject ("TREATMENTSTDATE") != null)
- {
- injuryBean.setTreatmentStartDate (rs.getTimestamp("TREATMENTSTDATE"));
- }
- if (rs.getObject ("TREATMENTENDDATE") != null)
- {
- injuryBean.setTreatmentEndDate (rs.getTimestamp("TREATMENTENDDATE"));
- }
- if (rs.getObject ("MINDISABLITYDATE") != null)
- {
- injuryBean.setWorkDisabilityDate (rs.getTimestamp("MINDISABLITYDATE"));
- }
- }
- }
- catch (Exception e)
- {
- throw new GOSIException (GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass ().toString (),
- "getInjuryBean ()",
- e,
- "CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp (ps, rs);
- }
- return injuryBean;
- }
- /**
- * @METHOD NAME : getInjuryBean
- * @INFORMATION : This method is to get Injury Bean
- * @PARAM : class java.util.ArrayList,
- class java.lang.Long
- * @RETURN : class gosi.business.socialinsurance.occupationalhazards.injury.beans.InjuryPopDetails
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private InjuryPopDetails getInjuryBean (ArrayList injuryList, Long injuryId)
- throws GOSIException
- {
- InjuryPopDetails injuryBean = null;
- try
- {
- for (int i = 0; i < injuryList.size(); i++)
- {
- injuryBean = (InjuryPopDetails) injuryList.get (i);
- if (injuryBean.getInjuryID ().equals (injuryId))
- {
- break;
- }
- }
- }
- catch (Exception e)
- {
- throw new GOSIException (GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass ().toString (),
- "getInjuryBean ()",
- e,
- "CMN_ERR_1000");
- }
- return injuryBean;
- }
- /**
- * @METHOD NAME : getEstablishmentId
- * @INFORMATION : This method is to get Establishment Id
- * @PARAM : class java.lang.Long,
- class java.util.ArrayList
- * @RETURN : class java.lang.Long
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private Long getEstablishmentId (Long registrationNumber, ArrayList injuryList)
- throws GOSIException
- {
- Long establishmentId = null;
- try
- {
- for (int i = 0; i < injuryList.size (); i++)
- {
- InjuryPopDetails injuryBean = (InjuryPopDetails) injuryList.get(i);
- if (registrationNumber.equals (injuryBean.getRegistrationNumber ()))
- {
- establishmentId = injuryBean.getEstablishmentId ();
- break;
- }
- }
- }
- catch (Exception e)
- {
- throw new GOSIException (GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass ().toString (),
- "getEstablishmentId ()",
- e,
- "CMN_ERR_1000");
- }
- finally
- {
- return establishmentId;
- }
- }
- /**
- * @METHOD NAME : getCalendarType
- * @INFORMATION : This method is to get the Calender Type of the
- establishment under which the injury is registered
- * @PARAM : class java.util.ArrayList
- * @RETURN : class java.lang.String
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- public String getCalendarType (ArrayList injuryList) throws GOSIException
- {
- String calendarType = OHConstants.GREGORIAN;
- try
- {
- for (int i = 0; i < injuryList.size (); i++)
- {
- InjuryPopDetails injuryBean = (InjuryPopDetails) injuryList.get (i);
- if (OHConstants.HIJRAH.equals (injuryBean.getCalendarType ()))
- {
- calendarType = OHConstants.HIJRAH;
- break;
- }
- }
- }
- catch (Exception e)
- {
- throw new GOSIException (GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass ().toString (),
- "getCalendarType ()",
- e,
- "CMN_ERR_1000");
- }
- return calendarType;
- }
- /**
- * @METHOD NAME : getHospitalType
- * @INFORMATION : This method is to get Hospital Type
- * @PARAM : class java.lang.Long,
- class java.sql.Timestamp,
- class java.sql.Timestamp
- * @RETURN : class java.lang.Short
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private Short getHospitalType (Long injuryId, Timestamp startDate, Timestamp endDate)
- throws GOSIException
- {
- Short hospitalType = null;
- PreparedStatement ps = null;
- ResultSet rs = null;
- try
- {
- GOSIDebug.debugMessages ("getHospitalType (" + injuryId + ", " + startDate + ", " + endDate + ")");
- String sqlQuery = "SELECT HOSPITALTYPE "
- + " FROM " + SITables.T_HOSPITAL
- + " WHERE HOSPITALCODE = "
- + " (SELECT DISTINCT HOSPITALCODE "
- + " FROM "+ SITables.T_TREATMENT
- + " WHERE INJURYID = ? AND "
- + " STARTDATE <= ? AND ENDDATE >= ? AND"
- + " TREATMENTSTATUS in (?, ?)"
- + " )";
- ps = con.prepareStatement (sqlQuery);
- GOSIDebug.debugMessages ("sqlQuery - " + sqlQuery);
- ps.setLong (1, injuryId.longValue ());
- ps.setTimestamp (2, endDate);
- ps.setTimestamp (3, startDate);
- ps.setShort (4, OHConstants.TRMT_STS_APPROVED.shortValue ());
- ps.setShort (5, OHConstants.TRMT_STS_ENTERED.shortValue ());
- GOSIDebug.debugMessages ("sqlQuery arg 1 - " + injuryId.longValue ());
- GOSIDebug.debugMessages ("sqlQuery arg 2 - " + endDate);
- GOSIDebug.debugMessages ("sqlQuery arg 3 - " + startDate);
- GOSIDebug.debugMessages ("sqlQuery arg 4 - " + OHConstants.TRMT_STS_APPROVED.shortValue ());
- GOSIDebug.debugMessages ("sqlQuery arg 5 - " + OHConstants.TRMT_STS_ENTERED.shortValue ());
- rs = ps.executeQuery ();
- while (rs.next ())
- {
- if (rs.getObject ("HOSPITALTYPE") != null)
- {
- hospitalType = new Short (rs.getShort ("HOSPITALTYPE"));
- }
- }
- }
- catch (Exception e)
- {
- throw new GOSIException (GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass ().toString (),
- "getHospitalType ()",
- e,
- "CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp (ps,rs);
- }
- GOSIDebug.debugMessages ("hospitalType - " + hospitalType);
- return hospitalType;
- }
- /**
- * @METHOD NAME : addToBenefitList
- * @INFORMATION : This method is to add the new list to the benefit list
- * @PARAM : class java.util.ArrayList,
- class java.util.ArrayList
- * @RETURN : class java.util.ArrayList
- * @EXCEPTION :
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private ArrayList addToBenefitList(ArrayList currentList,ArrayList newList)
- {
- int newListSize = newList.size();
- for(int i= 0;i<newListSize;i++)
- {
- currentList.add(newList.get(i));
- }
- return currentList;
- }
- /**
- * @METHOD NAME : getTreatmentPeriodList
- * @INFORMATION : This method is to get Treatment Period List for calculating oh allowance
- * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.InjuryPopDetails
- * @RETURN : class java.util.ArrayList
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private ArrayList getTreatmentPeriodList(InjuryPopDetails injuryBean,boolean isTreatmentApproved)
- throws GOSIException
- {
- GOSIDebug.debugMessages("\t\t Start getTreatmentPeriodList - MaintainOHAllowanceSessionEJB");
- ArrayList benefitList = new ArrayList();
- PreparedStatement ps = null;
- ResultSet rs = null;
- try
- {
- // isTreatmentApproved notify from which screen allowance is calculated
- // true if from oh benefit screen
- // false if from treatment period screen
- ArrayList trmtList = new ArrayList();
- Long injuryId = injuryBean.getInjuryID();
- Timestamp startDate = injuryBean.getBenefitStartDate();
- Timestamp endDate = injuryBean.getBenefitEndDate();
- String sqlQuery = "" +
- " select a.TREATMENTID,a.INJURYID, " +
- " a.HOSPITALCODE,b.HOSPITALTYPE,a.STARTDATE, " +
- " a.ENDDATE,a.TREATMENTSTATUS,a.TREATMENTTYPE from " +
- SITables.T_TREATMENT + " a, " +
- SITables.T_HOSPITAL + " b " +
- " where a.INJURYID =? and " +
- " a.TREATMENTSTATUS = ? " +
- " and a.ENDDATE >= ? and a.STARTDATE <= ? " +
- " and a.HOSPITALCODE = b.HOSPITALCODE " +
- " order by STARTDATE ";
- con = GOSIUtilities.getConnection
- (GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
- ps = con.prepareStatement(sqlQuery);
- GOSIDebug.debugMessages("SqlQuery:" + sqlQuery + ":");
- GOSIDebug.debugMessages("\t\t Param 1 :" + injuryId.longValue() + ":");
- ps.setLong(1,injuryId.longValue());
- if(isTreatmentApproved)
- {
- ps.setShort(2,OHConstants.TRMT_STS_APPROVED.shortValue());
- GOSIDebug.debugMessages("\t\t Param 2 :" + OHConstants.TRMT_STS_APPROVED.shortValue() + ":");
- }else
- {
- ps.setShort(2,OHConstants.TRMT_STS_ENTERED.shortValue());
- GOSIDebug.debugMessages("\t\t Param 2 :" + OHConstants.TRMT_STS_ENTERED.shortValue() + ":");
- }
- ps.setTimestamp(3,startDate);
- ps.setTimestamp(4,endDate);
- GOSIDebug.debugMessages("\t\t Param 3 :" + startDate + ":");
- GOSIDebug.debugMessages("\t\t Param 4 :" + endDate + ":");
- rs = ps.executeQuery();
- while(rs.next())
- {
- TreatmentPeriodBean trmtBean=new TreatmentPeriodBean();
- trmtBean.setTreatmentId(new Long(rs.getLong("TREATMENTID")));
- trmtBean.setInjuryId(new Long(rs.getLong("INJURYID")));
- trmtBean.setHospitalCode(new Long(rs.getLong("HOSPITALCODE")));
- trmtBean.setHospitalType(new Short(rs.getShort("HOSPITALTYPE")));
- trmtBean.setTreatmentType(new Short(rs.getShort("TREATMENTTYPE")));
- trmtBean.setStartDateGreg(rs.getTimestamp("STARTDATE"));
- trmtBean.setEndDateGreg(rs.getTimestamp("ENDDATE"));
- trmtBean.setTreatmentStatus(new Short(rs.getShort("TREATMENTSTATUS")));
- trmtList.add(trmtBean);
- }
- int trmtListSize = trmtList.size();
- // this logic sets start date and end dates of the first and
- // last bean to benefit start date and benefit end date
- if(trmtListSize > 0)
- {
- TreatmentPeriodBean firstBean =
- (TreatmentPeriodBean)trmtList.get(0);
- if(startDate.compareTo(firstBean.getStartDateGreg())>0)
- {
- firstBean.setStartDateGreg(startDate);
- }
- TreatmentPeriodBean lastBean =
- (TreatmentPeriodBean)trmtList.get(trmtListSize-1);
- if(endDate.compareTo(lastBean.getEndDateGreg())<0)
- {
- lastBean.setEndDateGreg(endDate);
- }
- }
- GOSIDebug.debugMessages("\t\t End getTreatmentPeriodList - MaintainOHAllowanceSessionEJB");
- return trmtList;
- }
- catch(GOSIException ge)
- {
- GOSIDebug.debugMessages("session-getTreatmentPeriodList :ge:" + ge);
- throw ge;
- }catch(Exception e)
- {
- GOSIDebug.debugMessages("session-getTreatmentPeriodList :e:" + e);
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "getTreatmentPeriodList()",e,"CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp(con);
- }
- }
- /**
- * @METHOD NAME : getStopPeriodList
- * @INFORMATION : This method is to get Stop Period List for the injury
- * @PARAM : class java.util.ArrayList,
- class gosi.business.socialinsurance.occupationalhazards.injury.beans.TreatmentPeriodBean,
- class java.lang.Byte
- * @RETURN : class java.util.ArrayList
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- public ArrayList getStopPeriodList(ArrayList stoppedPeriodList,
- TreatmentPeriodBean trmtBean, Byte stopResumeflag)throws GOSIException
- {
- //will itrate the list to come up with the actual stopped list
- // based on flag the trmt bean is added or removed from
- // the stop list
- long startTime = 0;
- long endTime = 0;
- long elapsedTime = 0;
- startTime = System.currentTimeMillis();
- int stopListSize = 0;
- Timestamp startDate = trmtBean.getStartDateGreg();
- Timestamp endDate = trmtBean.getEndDateGreg();
- if(stoppedPeriodList.size()== 0)
- {
- stoppedPeriodList.add(trmtBean);
- }else
- {
- // if resume flag is to resume oh allowance for the period
- // the for that particular period is removed from the stop periods
- if(OHConstants.RESUME_ALLOWANCE_FLAG.equals(stopResumeflag))
- {
- stopListSize = stoppedPeriodList.size();
- // the logic below checks each of the stoped period list with
- // the resume period and if the resume period falls on the
- // stopped period removes the stopped period from the list
- // the code takes care of removing stopped records inside
- // resume period as well as overlapping resume period in
- // multiple stopped records, and resume period inside a particualr
- // stopped record
- for(int i=0;i<stopListSize;i++)
- {
- TreatmentPeriodBean stopBean =
- (TreatmentPeriodBean)stoppedPeriodList.get(i);
- Timestamp stopStartDate =stopBean.getStartDateGreg();
- Timestamp stopEndDate =stopBean.getEndDateGreg();
- if(startDate.compareTo(stopStartDate)>=0 &&
- startDate.compareTo(stopEndDate)<=0 )
- {
- if(startDate.compareTo(stopStartDate)==0 &&
- endDate.compareTo(stopEndDate)==0 )
- {
- stoppedPeriodList.remove(i);
- break;
- }else
- if(startDate.compareTo(stopStartDate)==0 &&
- endDate.compareTo(stopEndDate)<0 )
- {
- stopBean.setStartDateGreg
- (GOSIUtilities.getNextDate(endDate));
- break;
- }
- else
- if(startDate.compareTo(stopStartDate)>0 &&
- endDate.compareTo(stopEndDate)==0 )
- {
- stopBean.setEndDateGreg
- (OHUtilities.getPrevDate(startDate));
- break;
- }
- else
- if(startDate.compareTo(stopStartDate)>0 &&
- endDate.compareTo(stopEndDate)<0 )
- {
- TreatmentPeriodBean newTrmtBean =
- new TreatmentPeriodBean(stopBean);
- stopBean.setEndDateGreg
- (OHUtilities.getPrevDate(startDate));
- newTrmtBean.setStartDateGreg
- (GOSIUtilities.getNextDate(endDate));
- stoppedPeriodList.add((i+1),newTrmtBean);
- break;
- }else if(endDate.compareTo(stopEndDate)>0)
- {
- if(startDate.compareTo(stopStartDate)>0)
- {
- stopBean.setEndDateGreg
- (OHUtilities.getPrevDate(startDate));
- }else
- if(startDate.compareTo(stopStartDate)==0)
- {
- stoppedPeriodList.remove(i);
- }
- for (int k=0;k<stoppedPeriodList.size() ;k++ )
- {
- TreatmentPeriodBean tempTrmtBean =
- (TreatmentPeriodBean)stoppedPeriodList.get(k);
- if(endDate.compareTo
- (tempTrmtBean.getStartDateGreg())>=0 &&
- endDate.compareTo
- (tempTrmtBean.getEndDateGreg())<=0 )
- {
- if(stopBean.getEndDateGreg().compareTo
- (tempTrmtBean.getEndDateGreg())==0)
- {
- tempTrmtBean = null;
- stoppedPeriodList.remove(k);
- break;
- }else
- if(stopBean.getEndDateGreg().compareTo
- (tempTrmtBean.getEndDateGreg())<=0)
- {
- tempTrmtBean.setStartDateGreg
- (GOSIUtilities.getNextDate(endDate));
- break;
- }
- }
- }
- break;
- }
- }
- }
- }
- else
- {
- // the logic below checks the stop period list if its found
- // empty new list is created and the stop list is inserted
- // the logic also checks for overlapping stopped periods
- // incase its resumed and then stopped again
- if(stopListSize == 0)
- {
- stoppedPeriodList.add(trmtBean);
- }else
- {
- for(int i=0;i<stopListSize;i++)
- {
- TreatmentPeriodBean stopBean =
- (TreatmentPeriodBean)stoppedPeriodList.get(i);
- Timestamp stopStartDate =stopBean.getStartDateGreg();
- Timestamp nextStopStartDate = null;
- if(i+1==stopListSize)
- {
- stoppedPeriodList.add(trmtBean);
- break;
- }
- else
- {
- nextStopStartDate =
- ((TreatmentPeriodBean)stoppedPeriodList.get(i+1)).
- getStartDateGreg();
- }
- if(nextStopStartDate !=null &&
- startDate.compareTo(stopStartDate)>0 &&
- startDate.compareTo(nextStopStartDate)<0)
- {
- stoppedPeriodList.add(i+1,trmtBean);
- break;
- }
- }
- }
- }
- }
- endTime = System.currentTimeMillis();
- elapsedTime = endTime - startTime;
- GOSIInstrumentationLog.writeInstrumentationToLog(
- this.getClass().toString(),
- "getStopPeriodList()",
- elapsedTime);
- return stoppedPeriodList;
- }
- /**
- * @METHOD NAME : getPayablePeriodList
- * @INFORMATION : This method is to get Payable Period List
- * @PARAM : class java.util.ArrayList,
- class java.util.ArrayList
- * @RETURN : class java.util.ArrayList
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private ArrayList getPayablePeriodList(ArrayList trmtList ,
- ArrayList actualStoppedList)throws GOSIException
- {
- // will itrate the list to come up with the actual payable period list
- // based on the stopped list the the periods stopped are
- // removed from the trmt list
- GOSIDebug.debugMessages("\t\t Start getPayablePeriodList - MaintainOHAllowanceSessionEJB");
- ArrayList newTrmtList = new ArrayList();
- int l = -1;
- int trmtListSize = trmtList.size();
- int stoppedListSize = actualStoppedList.size();
- if(stoppedListSize==0)
- {
- newTrmtList = trmtList;
- }
- for(int i=0;i<stoppedListSize;i++)
- {
- TreatmentPeriodBean stopBean = (TreatmentPeriodBean)actualStoppedList.get(i);
- for(int j=0;j<trmtListSize;j++)
- {
- TreatmentPeriodBean trmtBean = (TreatmentPeriodBean)trmtList.get(j);
- if(stopBean.getStartDateGreg().compareTo(trmtBean.getStartDateGreg())>=0 &&
- stopBean.getStartDateGreg().compareTo(trmtBean.getEndDateGreg())<=0 )
- {
- if(l==j)
- {
- GOSIDebug.debugMessages("0.1 inside multiple stops");
- trmtBean.setStartDateGreg(GOSIUtilities.getNextDate
- (((TreatmentPeriodBean)newTrmtList.get
- (newTrmtList.size()-1)).getEndDateGreg()));
- }
- l=j;
- if(stopBean.getStartDateGreg().compareTo(trmtBean.getStartDateGreg())==0 &&
- stopBean.getEndDateGreg().compareTo(trmtBean.getEndDateGreg())==0 )
- {
- GOSIDebug.debugMessages("1.Treatment period Removed at"+j);
- trmtBean =null;
- break;
- }else
- if(stopBean.getStartDateGreg().compareTo(trmtBean.getStartDateGreg())==0 &&
- stopBean.getEndDateGreg().compareTo(trmtBean.getEndDateGreg())<0 )
- {
- GOSIDebug.debugMessages("2.Treatment period start Date set at"+j);
- trmtBean.setStartDateGreg(GOSIUtilities.getNextDate(stopBean.getEndDateGreg()));
- newTrmtList.add(trmtBean);
- break;
- }
- else
- if(stopBean.getStartDateGreg().compareTo(trmtBean.getStartDateGreg())>0 &&
- stopBean.getEndDateGreg().compareTo(trmtBean.getEndDateGreg())==0 )
- {
- GOSIDebug.debugMessages("3.Treatment period End Date set at"+j);
- trmtBean.setEndDateGreg(OHUtilities.getPrevDate(stopBean.getStartDateGreg()));
- newTrmtList.add(trmtBean);
- break;
- }
- else
- if(stopBean.getStartDateGreg().compareTo(trmtBean.getStartDateGreg())>0 &&
- stopBean.getEndDateGreg().compareTo(trmtBean.getEndDateGreg())<0 )
- {
- GOSIDebug.debugMessages("4. two Treatment period set at"+j);
- TreatmentPeriodBean newTrmtBean = new TreatmentPeriodBean(trmtBean);
- trmtBean.setEndDateGreg(OHUtilities.getPrevDate(stopBean.getStartDateGreg()));
- newTrmtBean.setStartDateGreg(GOSIUtilities.getNextDate(stopBean.getEndDateGreg()));
- newTrmtList.add(trmtBean);
- newTrmtList.add(newTrmtBean);
- break;
- }else if(stopBean.getEndDateGreg().compareTo(trmtBean.getEndDateGreg())>0)
- {
- GOSIDebug.debugMessages(" 5 gone into to big if");
- if(stopBean.getStartDateGreg().compareTo(trmtBean.getStartDateGreg())>0)
- {
- GOSIDebug.debugMessages("5.1 end date set");
- trmtBean.setEndDateGreg(OHUtilities.getPrevDate(stopBean.getStartDateGreg()));
- newTrmtList.add(trmtBean);
- }else
- if(stopBean.getStartDateGreg().compareTo(trmtBean.getStartDateGreg())==0)
- {
- GOSIDebug.debugMessages("5.2 bean removed");
- trmtBean = null;
- }
- for (int k=(j+1);k<trmtListSize ;k++ )
- {
- GOSIDebug.debugMessages("5.3.0 k value :" + k);
- TreatmentPeriodBean tempTrmtBean = (TreatmentPeriodBean)trmtList.get(k);
- if(stopBean.getEndDateGreg().compareTo(tempTrmtBean.getStartDateGreg())>=0 &&
- stopBean.getEndDateGreg().compareTo(tempTrmtBean.getEndDateGreg())<=0 )
- {
- GOSIDebug.debugMessages("5.3 k value :" + k);
- if(stopBean.getEndDateGreg().compareTo(tempTrmtBean.getEndDateGreg())==0)
- {
- GOSIDebug.debugMessages("5.4 bean set to null at :" + k);
- tempTrmtBean = null;
- }else if(stopBean.getEndDateGreg().compareTo(tempTrmtBean.getEndDateGreg())<=0)
- {
- GOSIDebug.debugMessages("5.5 startDate set for " + k);
- tempTrmtBean.setStartDateGreg(GOSIUtilities.getNextDate(stopBean.getEndDateGreg()));
- newTrmtList.add(tempTrmtBean);
- }
- j = k;
- break;
- }
- }
- //break;
- }
- }
- }
- }
- for(int j=0;j<trmtListSize;j++)
- {
- TreatmentPeriodBean trmtBean = (TreatmentPeriodBean)trmtList.get(j);
- Timestamp trmtStartDate =trmtBean.getStartDateGreg();
- Timestamp trmtEndDate = trmtBean.getEndDateGreg();
- boolean flag = true;
- for(int i=0;i<stoppedListSize;i++)
- {
- TreatmentPeriodBean stopBean = (TreatmentPeriodBean)actualStoppedList.get(i);
- Timestamp stopStartDate =stopBean.getStartDateGreg();
- Timestamp stopEndDate =stopBean.getEndDateGreg();
- if((stopStartDate.compareTo(trmtStartDate)<=0 &&
- stopEndDate.compareTo(trmtStartDate)>=0)||
- (stopStartDate.compareTo(trmtEndDate)<=0 &&
- stopEndDate.compareTo(trmtEndDate)>=0) )
- {
- flag = false;
- break;
- }
- }
- if(flag)
- {
- newTrmtList.add(trmtBean);
- }
- }
- GOSIDebug.debugMessages("\t\t End getPayablePeriodList - MaintainOHAllowanceSessionEJB");
- return newTrmtList;
- }
- /**
- * @METHOD NAME : getTrmtDetailsforDate
- * @INFORMATION : This method is to get Trmt Details for a Date
- * @PARAM : class java.sql.Timestamp,
- class java.util.ArrayList
- * @RETURN : class gosi.business.socialinsurance.occupationalhazards.injury.beans.TreatmentPeriodBean
- * @EXCEPTION :
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private TreatmentPeriodBean getTrmtDetailsforDate
- (Timestamp trmtDate,ArrayList trmtList)
- {
- GOSIDebug.debugMessages("\t\t Start getTrmtDetailsforDate - MaintainOHAllowanceSessionEJB");
- // This method is called to find set the payment type for
- // the trmt date (inpatient/outpatient)?
- TreatmentPeriodBean tempTrmtBean = null;
- int trmtListSize = trmtList.size();
- for (int i=0; i<trmtListSize ; i++)
- {
- TreatmentPeriodBean trmtBean = (TreatmentPeriodBean)trmtList.get(i);
- if(trmtBean.getStartDateGreg().compareTo(trmtDate)<=0 &&
- trmtBean.getEndDateGreg().compareTo(trmtDate)>=0 )
- {
- if(tempTrmtBean == null)
- {
- tempTrmtBean = new TreatmentPeriodBean(trmtBean);
- tempTrmtBean.setStartDateGreg(trmtDate);
- tempTrmtBean.setEndDateGreg(trmtDate);
- }else
- {
- if(OHConstants.TRMT_TYPE_INPATIENT.equals(trmtBean.getTreatmentType()))
- {
- tempTrmtBean = new TreatmentPeriodBean(trmtBean);
- tempTrmtBean.setStartDateGreg(trmtDate);
- tempTrmtBean.setEndDateGreg(trmtDate);
- }
- }
- }
- }
- GOSIDebug.debugMessages("\t\t End getTrmtDetailsforDate - MaintainOHAllowanceSessionEJB");
- return tempTrmtBean;
- }
- /**
- * @METHOD NAME : getBenefitPayableTrmtList
- * @INFORMATION : This method is to get Benefit Payable Trmt List
- * @PARAM : class java.util.ArrayList
- * @RETURN : class java.util.ArrayList
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private ArrayList getBenefitPayableTrmtList(ArrayList trmtList)
- throws GOSIException
- {
- GOSIDebug.debugMessages("\t\t Start getBenefitPayableTrmtList - MaintainOHAllowanceSessionEJB");
- // will list of the dates for which benefit can be payed
- ArrayList newTrmtList = new ArrayList();
- for(int i=0; i<trmtList.size() ; i++)
- {
- TreatmentPeriodBean trmtBean =
- (TreatmentPeriodBean)trmtList.get(i);
- // this gives the position of bean where the trmt type change in the trmt list
- int j = getChangeStatus(trmtList,trmtBean,i);
- TreatmentPeriodBean tempTrmtBean =
- (TreatmentPeriodBean)trmtList.get(j);
- trmtBean.setEndDateGreg(tempTrmtBean.getEndDateGreg());
- newTrmtList.add(trmtBean);
- i=j;
- }
- GOSIDebug.debugMessages("\t\t End getBenefitPayableTrmtList - MaintainOHAllowanceSessionEJB");
- return newTrmtList;
- }
- /**
- * @METHOD NAME : getChangeStatus
- * @INFORMATION : This method is to get Change Status
- returns record id where trmt type changes
- * @PARAM : class java.util.ArrayList,
- class gosi.business.socialinsurance.occupationalhazards.injury.beans.TreatmentPeriodBean,
- int
- * @RETURN : int
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private int getChangeStatus(ArrayList trmtList,
- TreatmentPeriodBean trmtBean,int recNum)throws GOSIException
- {
- GOSIDebug.debugMessages("\t\t Start getChangeStatus - MaintainOHAllowanceSessionEJB");
- int j = recNum;
- Timestamp tempDate = trmtBean.getStartDateGreg();
- GOSIDebug.debugMessages("tempDate :" + tempDate);
- GOSIDebug.debugMessages("j:" + j);
- GOSIDebug.debugMessages("Temp InjuryId:" + trmtBean.getInjuryId());
- GOSIDebug.debugMessages("Temp TreatmentId:" + trmtBean.getTreatmentId());
- GOSIDebug.debugMessages("_____________________________________");
- // logic to check where the treatment type changes from
- // element at recNum
- for (int i=recNum; i<trmtList.size() ; i++)
- {
- TreatmentPeriodBean tempTrmtBean =
- (TreatmentPeriodBean)trmtList.get(i);
- GOSIDebug.debugMessages("TempTDate:" + tempTrmtBean.getStartDateGreg());
- GOSIDebug.debugMessages("j:" + j);
- GOSIDebug.debugMessages("Temp InjuryId" + tempTrmtBean.getInjuryId());
- GOSIDebug.debugMessages("Temp TId" + tempTrmtBean.getTreatmentId());
- if(tempTrmtBean.getInjuryId().equals(trmtBean.getInjuryId()) &&
- tempTrmtBean.getTreatmentId().equals(trmtBean.getTreatmentId())&&
- tempDate.equals(tempTrmtBean.getStartDateGreg()))
- {
- j = i;
- tempDate = GOSIUtilities.getNextDate
- (tempTrmtBean.getStartDateGreg());
- }else
- {
- j = i - 1;
- break;
- }
- }
- GOSIDebug.debugMessages("\t\t End getChangeStatus - MaintainOHAllowanceSessionEJB");
- return j;
- }
- /**
- * @METHOD NAME : calculateDailyAllowance
- * @INFORMATION : This method is to calculate Daily Allowance
- * @PARAM : class java.util.ArrayList,
- class java.util.ArrayList
- * @RETURN : class java.util.ArrayList
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private ArrayList calculateDailyAllowance(ArrayList injuryList,
- ArrayList periodList,boolean isTreatmentApproved)
- throws GOSIException
- {
- GOSIDebug.debugMessages("\t\t Start calculateDailyAllowance - MaintainOHAllowanceSessionEJB");
- PreparedStatement ps = null;
- ResultSet rs = null;
- String sqlQuery = "";
- try
- {
- // this method calculates the dailly allowance
- // input is the injury list with all details of contriubtor
- // and period list with the actual payable period
- String calenderType = getCalendarType(injuryList);
- GOSIDebug.debugMessages("PeriodListsize:" + periodList.size() + ":");
- ArrayList trmtList = new ArrayList();
- int c= periodList.size();
- Timestamp workStopDate = null;
- Timestamp workStartDate = null;
- Timestamp firstInjuryDate = null;
- Timestamp benefitStartDate =
- ((InjuryPopDetails)injuryList.get(0)).getBenefitStartDate();
- Timestamp benefitEndDate =
- ((InjuryPopDetails)injuryList.get(0)).getBenefitEndDate();
- Long contributorId =
- ((InjuryPopDetails)injuryList.get(0)).getContributorId();
- int periodListSize =periodList.size();
- for(int i=0; i<periodListSize; i++)
- {
- trmtList.add(periodList.get(i));
- }
- String subQuery = "";
- int injuryListSize =injuryList.size();
- if(injuryListSize==1)
- {
- subQuery = "";
- }else
- {
- for(int i=0;i<(injuryListSize-1);i++)
- {
- subQuery = subQuery + " ?, ";
- }
- }
- // Query to find from which date the benefit can be paid
- // benefit will be paid from work disability date
- // till date of return to work normally
- Timestamp currentDate = new Timestamp(System.currentTimeMillis());
- sqlQuery = " select " +
- " min(NVL(DATECOMPLICATION,INJURYDATE)) MININJURYDATE , " +
- " min(NVL(NVL(DATECOMPLICATION+1,WORKDISABILITYDATE),NVL(DATECOMPLICATION+1,INJURYDATE +1))) MINDISABLITYDATE," +
- " max(NVL(DATERETURNTOWORK,?)) MAXRETURNTOWORKDATE from " +
- SITables.T_INJURY +
- " where INJURYID in ( " +
- subQuery +
- " ?) ";
- GOSIDebug.debugMessages("sqlQuery:" + sqlQuery + ":");
- GOSIDebug.debugMessages("\t\t Param 1 :" + currentDate + ":");
- ps = con.prepareStatement(sqlQuery);
- ps.setTimestamp(1,currentDate);
- for(int i=0;i<injuryListSize;i++)
- {
- Long injuryId =
- ((InjuryPopDetails)injuryList.get(i)).getInjuryID();
- ps.setLong(i+2,injuryId.longValue());
- GOSIDebug.debugMessages("\t\t Param " + (i+2) + ":" + injuryId.longValue() + ":");
- }
- rs = ps.executeQuery();
- while(rs.next())
- {
- Timestamp minInjuryDate = null;
- if(rs.getObject("MININJURYDATE")!= null)
- {
- minInjuryDate = rs.getTimestamp("MININJURYDATE");
- }
- if(rs.getObject("MINDISABLITYDATE")!= null)
- {
- workStopDate = rs.getTimestamp("MINDISABLITYDATE");
- GOSIDebug.debugMessages("TestIFB workstopdate: "+workStopDate) ;
- if(minInjuryDate.equals(workStopDate))
- {
- workStopDate = GOSIUtilities.getNextDate(minInjuryDate);
- GOSIDebug.debugMessages("TestIF workstopdate: "+workStopDate) ;
- }
- else if(minInjuryDate.after(workStopDate))
- {
- workStopDate = GOSIUtilities.getNextDate(minInjuryDate);
- GOSIDebug.debugMessages("TestELSE workstopdate: "+workStopDate) ;
- }
- }
- if(rs.getObject("MAXRETURNTOWORKDATE")!= null)
- {
- workStartDate = rs.getTimestamp("MAXRETURNTOWORKDATE");
- if(workStartDate.compareTo(currentDate)==0)
- {
- workStartDate = null;
- }
- }
- }
- // logic to set the start and end dates
- Timestamp actualStartDate = null;
- Timestamp actualEndDate = null;
- if(workStopDate!=null && workStopDate.compareTo(benefitStartDate)>0)
- {
- actualStartDate = workStopDate;
- }
- else
- {
- actualStartDate =benefitStartDate;
- }
- //GOSIDebug.debugMessages("startDate :"+startDate);
- GOSIDebug.debugMessages("ActualStartDate :" + actualStartDate + ":");
- /*if(canWaive)
- {
- if(startDate.compareTo(actualStartDate)>0)
- {
- actualStartDate =startDate;
- }
- }*/
- GOSIDebug.debugMessages("ActualStartDate :" + actualStartDate + ":");
- if(workStartDate!=null && workStartDate.compareTo(benefitEndDate)<0)
- {
- actualEndDate = OHUtilities.getPrevDate(workStartDate);
- }else
- {
- actualEndDate =benefitEndDate;
- }
- /*if(canWaive)
- {
- startDate = getActualWaivableFromDate(injuryList);
- }*/
- GOSIDebug.debugMessages("Actual startDate :" + actualStartDate);
- GOSIDebug.debugMessages("Actual endDate :" + actualEndDate);
- int trmtListSize = trmtList.size();
- //Timestamp trmtStartDate =((TreatmentPeriodBean)trmtList.get(0)).getStartDateGreg();
- //Timestamp trmtEndDate =((TreatmentPeriodBean)trmtList.get(trmtListSize-1)).getEndDateGreg();
- for(int i=0;i<trmtList.size();i++)
- {
- TreatmentPeriodBean trmtBean =(TreatmentPeriodBean)trmtList.get(i);
- Timestamp trmtStartDate = trmtBean.getStartDateGreg();
- Timestamp trmtEndDate = trmtBean.getEndDateGreg();
- GOSIDebug.debugMessages("-----------------------------------");
- GOSIDebug.debugMessages("Actual startDate :" + actualStartDate);
- GOSIDebug.debugMessages("Actual endDate :" + actualEndDate);
- GOSIDebug.debugMessages("TrmtStartDate :" + trmtStartDate);
- GOSIDebug.debugMessages("TrmtEndDate :" + trmtEndDate);
- // if actual dates before Treatment period
- if(actualStartDate.compareTo(trmtStartDate)<0 &&
- actualEndDate.compareTo(trmtStartDate)<0)
- {
- GOSIDebug.debugMessages("----1");
- GOSIDebug.debugMessages("1 element at"+ i+" removed");
- trmtList.remove(i);
- i=-1;
- }
- // if actual dates comes inside a Treatment period
- // ActualstartDate after trmt st Date
- else if(actualStartDate.compareTo(trmtStartDate)>0 &&
- actualStartDate.compareTo(trmtEndDate)<=0)
- {
- GOSIDebug.debugMessages("----2 ");
- trmtBean.setStartDateGreg(actualStartDate);
- GOSIDebug.debugMessages("2 element at"+ i +" startDate set");
- }
- //Trmt period before actual startDate
- if(trmtBean.getStartDateGreg().compareTo(actualStartDate)<0 &&
- trmtBean.getEndDateGreg().compareTo(actualStartDate)<0)
- {
- GOSIDebug.debugMessages("----3");
- GOSIDebug.debugMessages("3 at "+i+" removed before period");
- trmtList.remove(i);
- i=-1;
- }
- //trmt period after actual end Dates
- if(trmtBean.getStartDateGreg().compareTo(actualEndDate)>0 &&
- trmtBean.getEndDateGreg().compareTo(actualEndDate)>0)
- {
- GOSIDebug.debugMessages("----4");
- GOSIDebug.debugMessages("4 at"+i+" removed after period");
- trmtList.remove(i);
- i=-1;
- }
- // actual enddate after trmtStartDate and
- // actual enddate before trmtEndDate
- else
- if(actualEndDate.compareTo(trmtBean.getStartDateGreg()) >= 0 &&
- actualEndDate.compareTo(trmtBean.getEndDateGreg())< 0)
- {
- GOSIDebug.debugMessages("----5");
- GOSIDebug.debugMessages(" 5 element at"+ i +" endDateSet");
- trmtBean.setEndDateGreg(actualEndDate);
- }
- GOSIDebug.debugMessages("-----------------------------------");
- }
- GOSIDebug.debugMessages("TrmtListSize:" + trmtList.size());
- /* code for making the day b4 the work startdate as outpatient if
- it happens to be out patient: modified code below
- if(workStartDate!=null)
- {
- TreatmentPeriodBean trmtBean =
- (TreatmentPeriodBean)trmtList.get(trmtList.size()-1);
- Timestamp trmtStartDate = trmtBean.getStartDateGreg();
- Timestamp trmtEndDate =trmtBean.getEndDateGreg();
- if(workStartDate.compareTo
- (GOSIUtilities.getNextDate(trmtEndDate))==0)
- {
- if(OHConstants.TRMT_TYPE_INPATIENT.equals
- (trmtBean.getTreatmentType()))
- {
- if(trmtStartDate.compareTo(trmtEndDate)==0)
- {
- trmtBean.setTreatmentType
- (OHConstants.TRMT_TYPE_OUTPATIENT);
- }else
- {
- TreatmentPeriodBean tempTrmtBean =
- new TreatmentPeriodBean(trmtBean);
- tempTrmtBean.setStartDateGreg(trmtEndDate);
- trmtBean.setEndDateGreg
- (OHUtilities.getPrevDate(trmtEndDate));
- trmtList.add(tempTrmtBean);
- }
- }
- }
- }
- */
- /* commented iteration to make a single day outpatient if the single day
- happened to be an inpatient between two sickleave or out patient periods
- for(int i=1; i < (trmtList.size()-1);i++)
- {
- TreatmentPeriodBean trmtBean=
- (TreatmentPeriodBean)trmtList.get(i);
- if(trmtBean.getStartDateGreg().compareTo
- (trmtBean.getEndDateGreg())==0)
- {
- if(trmtBean.getTreatmentType().equals
- (OHConstants.TRMT_TYPE_INPATIENT))
- {
- if((!((TreatmentPeriodBean)trmtList.get(i+1)).
- getTreatmentType().equals
- (OHConstants.TRMT_TYPE_INPATIENT))&&
- (!((TreatmentPeriodBean)trmtList.get(i-1)).
- getTreatmentType().equals
- (OHConstants.TRMT_TYPE_INPATIENT)))
- {
- ((TreatmentPeriodBean)trmtList.get(i)).
- setTreatmentType
- (OHConstants.TRMT_TYPE_OUTPATIENT);
- }
- }
- }
- }
- */
- // code for making the last day of an inpatient period as out patient
- for(int i=0; i < (trmtList.size());i++)
- {
- TreatmentPeriodBean trmtBean=
- (TreatmentPeriodBean)trmtList.get(i);
- if(trmtBean.getTreatmentType().equals
- (OHConstants.TRMT_TYPE_INPATIENT))
- {
- if(canLastDayMadeOutpatient(trmtBean,isTreatmentApproved))
- {
- if(1 == trmtBean.getTreatmentPeriod().intValue())
- {
- trmtBean.setTreatmentType(OHConstants.TRMT_TYPE_OUTPATIENT);
- }else
- {
- Timestamp lastDate = trmtBean.getEndDateGreg();
- trmtBean.setEndDateGreg(OHUtilities.getPrevDate(lastDate));
- TreatmentPeriodBean tempTrmtBean =
- new TreatmentPeriodBean(trmtBean);
- tempTrmtBean.setStartDateGreg(lastDate);
- tempTrmtBean.setEndDateGreg(lastDate);
- tempTrmtBean.setTreatmentType(OHConstants.TRMT_TYPE_OUTPATIENT);
- trmtList.add(++i,tempTrmtBean);
- GOSIDebug.debugMessages("i:"+i);
- }
- }
- }
- }
- // printing each trmt start and end dates and type
- for (int i=0;i< trmtList.size();i++)
- {
- TreatmentPeriodBean trmtBean =
- (TreatmentPeriodBean)trmtList.get(i);
- GOSIDebug.debugMessages("StartDate :" + trmtBean.getStartDateGreg());
- GOSIDebug.debugMessages("EndDate :" + trmtBean.getEndDateGreg());
- GOSIDebug.debugMessages("TrmtType :" + trmtBean.getTreatmentType());
- GOSIDebug.debugMessages("HospitalType:" + trmtBean.getHospitalType());
- }
- Double totalWage =
- ((InjuryPopDetails)injuryList.get(0)).getTotalConWage();
- Short payableTo =
- ((InjuryPopDetails)injuryList.get(0)).getBenefitPayableTo();
- GOSIDebug.debugMessages("TotalConWage:" + totalWage);
- // method called to calculate the benefit amount
- ArrayList benefitList =
- calculateDailyAllowance(trmtList,totalWage,payableTo,calenderType);
- GOSIDebug.debugMessages("---------calculateDailyAllowance*-----------");
- for (int i=0;i<benefitList.size();i++)
- {
- ((OHAllowanceBean)benefitList.get(i)).
- setContributorId(contributorId);
- }
- // adjustment if last paid period is paid as out patient
- // and current start date is inpatient
- adjustLastInpatientDate(injuryList,benefitList,isTreatmentApproved);
- GOSIDebug.debugMessages("\t\t End calculateDailyAllowance - MaintainOHAllowanceSessionEJB");
- return benefitList;
- }
- catch(GOSIException ge)
- {
- GOSIDebug.debugMessages("session-getTreatmentPeriodList :ge:"+ge);
- throw ge;
- }catch(Exception e)
- {
- GOSIDebug.debugMessages("session-getTreatmentPeriodList :e:"+e);
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "getTreatmentPeriodList()",e,"CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp(ps,rs);
- }
- }
- /*
- */
- /**
- * @METHOD NAME : calculateCompanionAllowance
- * @INFORMATION : This method is to calculate companion Allowance
- * @PARAM : class java.util.ArrayList,
- boolean
- * @RETURN : class java.util.ArrayList
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private ArrayList calculateCompanionAllowance(ArrayList injuryList ,
- boolean resumeFlag,boolean isTreatmentApproved )throws GOSIException
- {
- GOSIDebug.debugMessages("\n\n--------calculateCompanionAllowance--------");
- String sqlQuery;
- ArrayList compAllowanceList=new ArrayList();
- PreparedStatement ps = null;
- ResultSet rs =null;
- boolean flag=true;
- String subQuery = "";
- int injuryListSize = injuryList.size();
- try
- {
- // companion allowance is calculated for every injury
- for (int i=0;i<injuryListSize;i++)
- {
- InjuryPopDetails injuryBean =
- (InjuryPopDetails)injuryList.get(i);
- Long injuryId= injuryBean.getInjuryID();
- Long contributorId = injuryBean.getContributorId();
- ArrayList stoppedList =getInjuryStoppedPeriodList
- (injuryBean,isTreatmentApproved);
- // if its calculated from stop resume oh allowance
- // the stopped period needs to be considered
- // else all companion details to be paid
- if(resumeFlag)
- {
- TreatmentPeriodBean trmtBean = new TreatmentPeriodBean();
- trmtBean.setInjuryId(injuryBean.getInjuryID());
- trmtBean.setStartDateGreg(injuryBean.getBenefitStartDate());
- trmtBean.setEndDateGreg(injuryBean.getBenefitEndDate());
- stoppedList =getStopPeriodList
- (stoppedList,trmtBean,OHConstants.RESUME_ALLOWANCE_FLAG);
- }
- /*
- sqlQuery = " select OHBENID from "+SITables.T_OHBENEFIT +
- " where INJURYID =? and "+
- " ( OHBENCODE = ? or OHBENCODE = ? or OHBENCODE = ? )";
- ps =con.prepareStatement(sqlQuery);
- ps.setLong (1,injuryId.longValue());
- ps.setShort(2,OHConstants.OH_ALWNC_DOC_COMP_DAILY.shortValue());
- ps.setShort(3,OHConstants.OH_ALWNC_NUR_COMP_DAILY.shortValue());
- ps.setShort(4,OHConstants.OH_ALWNC_COMP_DAILY.shortValue());
- rs=ps.executeQuery();
- if(rs!=null)
- {
- while(rs.next())
- {
- flag=false;
- }
- }
- */
- //Query to get companion details for the benefit period
- sqlQuery=" select INJURYID,TYPEOFCOMP,CONVALLOWANCECOMP, "+
- " DAILYALLOWANCECOMP,STATUS, "+
- " COMPSTDATE,COMPENDDATE from "+
- SITables.T_COMPANION +
- " where INJURYID =? and STATUS = ? "+
- " and COMPSTDATE >= ? and COMPENDDATE <=? "+
- " and TYPEOFCOMP = ? ";
- GOSIDebug.debugMessages("sqlQuery :"+sqlQuery);
- GOSIDebug.debugMessages("flag:"+flag);
- if(flag)
- {
- ps = con.prepareStatement(sqlQuery);
- ps.setLong (1, injuryId.longValue());
- ps.setShort(2,OHConstants.COMP_STS_APPROVED.shortValue());
- ps.setTimestamp(3,injuryBean.getBenefitStartDate());
- ps.setTimestamp(4,injuryBean.getBenefitEndDate());
- ps.setShort(5,OHConstants.COMPANION_TYPE_OTHERS.shortValue());
- rs =ps.executeQuery();
- double compDailyAllowanceAmt=0;
- double compConvAllowanceAmt=0;
- Short compType = null;
- OHAllowanceBean benefitBean=null;
- while(rs.next())
- {
- GOSIDebug.debugMessages("inside rs.next");
- benefitBean=new OHAllowanceBean();
- benefitBean.setInjuryId
- (new Long( rs.getLong("INJURYID")));
- compType = new Short(rs.getShort("TYPEOFCOMP"));
- compDailyAllowanceAmt=
- rs.getDouble("DAILYALLOWANCECOMP");
- if(rs.getObject("CONVALLOWANCECOMP")!=null)
- {
- compConvAllowanceAmt=
- rs.getDouble("CONVALLOWANCECOMP");
- }
- benefitBean.setBenStDateGreg
- (rs.getTimestamp("COMPSTDATE"));
- benefitBean.setBenEndDateGreg
- (rs.getTimestamp("COMPENDDATE"));
- }
- GOSIDebug.debugMessages("benefitbean :"+benefitBean);
- if(benefitBean == null)
- {
- compAllowanceList=new ArrayList();
- }
- else
- {
- // calculating companion allowance paid
- Timestamp compStartDate =benefitBean.getBenStDateGreg();
- Timestamp compEndDate=benefitBean.getBenEndDateGreg() ;
- OHAllowanceBean compDailyAllowance=new OHAllowanceBean();
- if(compDailyAllowanceAmt!=0)
- {
- compDailyAllowance.setInjuryId(injuryId);
- compDailyAllowance.setContributorId(contributorId);
- compDailyAllowance.setBenStDateGreg
- (benefitBean.getBenStDateGreg());
- compDailyAllowance.setBenEndDateGreg
- (benefitBean.getBenEndDateGreg());
- compDailyAllowance.setBenAmount
- (new Double(compDailyAllowanceAmt));
- if(OHConstants.COMPANION_TYPE_DOCTOR.
- equals(compType))
- {
- compDailyAllowance.setBenefitPayableTo
- (OHConstants.OH_BNFT_PAY_TO_HOS);
- compDailyAllowance.setOhBenCode
- (OHConstants.OH_ALWNC_DOC_COMP_DAILY);
- compDailyAllowance.setPartyCode
- (getPayableHospital(injuryId,
- benefitBean.getBenStDateGreg(),isTreatmentApproved));
- }else
- if(OHConstants.COMPANION_TYPE_NURSE.
- equals(compType))
- {
- compDailyAllowance.setBenefitPayableTo
- (OHConstants.OH_BNFT_PAY_TO_HOS);
- compDailyAllowance.setOhBenCode
- (OHConstants.OH_ALWNC_NUR_COMP_DAILY);
- compDailyAllowance.setPartyCode
- (getPayableHospital(injuryId,
- benefitBean.getBenStDateGreg(),isTreatmentApproved));
- }else
- {
- compDailyAllowance.setBenefitPayableTo
- (OHConstants.OH_BNFT_PAY_TO_CON);
- compDailyAllowance.setOhBenCode
- (OHConstants.OH_ALWNC_COMP_DAILY);
- }
- compAllowanceList.add(compDailyAllowance);
- }
- }
- }
- }
- //GOSIDebug.debugMessages("comPList size:"+compAllowanceList.size());
- GOSIDebug.debugMessages("-------calculateCompanionAllowance*----------");
- return compAllowanceList;
- }
- /* catch(GOSIException ge)
- {
- GOSIDebug.debugMessages("session-compAlwnc :The exception is "+ge);
- throw ge;
- }*/
- catch(Exception e)
- {
- GOSIDebug.debugMessages("session-compAlwnc :The exception is "+e);
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "calculateCompanionAllowance()",e,"CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp(ps, rs);
- }
- }
- /**
- * @METHOD NAME : calculateConveyenceAllowance
- * @INFORMATION : This method is to calculate Conveyence Allowance
- * @PARAM : class java.util.ArrayList,
- boolean
- * @RETURN : class java.util.ArrayList
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private ArrayList calculateConveyenceAllowance
- (ArrayList injuryList, boolean resumeFlag ,boolean isTreatmentApproved )
- throws GOSIException
- {
- GOSIDebug.debugMessages("\n\n-------calculateConveyenceAllowance---------");
- ArrayList conveyanceBenefitList = new ArrayList();
- PreparedStatement ps = null;
- ResultSet rs =null;
- int injuryListSize = injuryList.size();
- try
- {
- // visit allowance will be calculated for each injury
- for(int j=0;j<injuryListSize;j++)
- {
- ps = null;
- rs =null;
- ArrayList visitsList=new ArrayList();
- InjuryPopDetails injuryBean=(InjuryPopDetails)injuryList.get(j);
- Timestamp startDate=injuryBean.getBenefitStartDate();
- Timestamp injuryDate = injuryBean.getInjuryDate();
- Timestamp visitLastDate = null;
- if(startDate.compareTo(injuryDate)<0)
- {
- startDate = injuryDate;
- }
- Timestamp endDate=injuryBean.getBenefitEndDate();
- GOSIDebug.debugMessages("startDate::::::::"+startDate);
- GOSIDebug.debugMessages("endDate::::::::::"+endDate);
- Short payableTo = injuryBean.getBenefitPayableTo();
- Long contributorId = injuryBean.getContributorId();
- Long injuryId = injuryBean.getInjuryID();
- boolean firstVisitflag =canFirstVisitBeCalculated(injuryBean);
- // Query to get the visit records for the period
- String sqlQuery;
- sqlQuery=" select a.VISITID,a.INJURYID,a.TREATMENTID,"+
- " NVL(a.DATEOFVISIT ,(select ENDDATE from "+
- SITables.T_TREATMENT +
- " b where b.TREATMENTID =a.TREATMENTID) ) VISITDATE ,"+
- " a.NUMBERVISITS from "+SITables.T_VISITS +" a where "+
- " injuryId = ? "+
- " and VISITSTATUS = ? order by VISITDATE asc ";
- OHAllowanceBean benefitBean=new OHAllowanceBean();
- // getting the stopped period list for the injury
- ArrayList stoppedList =getInjuryStoppedPeriodList(injuryBean,isTreatmentApproved);
- if(resumeFlag)
- {
- TreatmentPeriodBean trmtBean = new TreatmentPeriodBean();
- trmtBean.setInjuryId(injuryBean.getInjuryID());
- trmtBean.setStartDateGreg(injuryBean.getBenefitStartDate());
- trmtBean.setEndDateGreg(injuryBean.getBenefitEndDate());
- stoppedList =getStopPeriodList
- (stoppedList,trmtBean,OHConstants.RESUME_ALLOWANCE_FLAG);
- }
- ps=con.prepareStatement(sqlQuery);
- ps.setLong(1,injuryId.longValue());
- ps.setShort(2, OHConstants.VISITS_STS_APPROVED.shortValue());
- GOSIDebug.debugMessages("sqlQuery:"+sqlQuery);
- rs=ps.executeQuery();
- while(rs.next())
- {
- GOSIDebug.debugMessages("Has visits");
- VisitBean visitBean =new VisitBean();
- visitBean.setVisitId(new Long(rs.getLong("VISITID")));
- visitBean.setInjuryId(new Long(rs.getLong("INJURYID")));
- Timestamp visitDate =rs.getTimestamp("VISITDATE");
- visitBean.setDateOfVisitGreg(visitDate);
- visitBean.setNumberVisits
- (new Integer(rs.getInt("NUMBERVISITS")));
- visitBean.setTreatmentId
- (new Long(rs.getLong("TREATMENTID")));
- if(startDate.compareTo(visitDate)<=0&&
- endDate.compareTo(visitDate)>=0)
- {
- if(isValidVisitDate(stoppedList,visitBean))
- {
- visitsList.add(visitBean);
- }
- visitLastDate = visitDate ;
- }
- }
- if(visitLastDate != null)
- {
- if(visitLastDate.compareTo(endDate) < 0)
- {
- endDate =visitLastDate;
- }
- }
- GOSIDebug.debugMessages("visitList size:"+visitsList.size());
- double conveyenceAmount=0;
- // calling rule bean to get the visit amount per day
- // if first visit flag is true 15 riyals is subtracted from the vist amount
- for(int i=0;i<visitsList.size();i++)
- {
- VisitBean visitBean=(VisitBean)visitsList.get(i);
- double amount=0;
- amount = visitBean.getNumberVisits().intValue()*
- OHRuleBean.getVisitAmountperVisit();
- if(i==0 && firstVisitflag)
- {
- amount = amount - OHRuleBean.getFirstVisitAmount();
- }
- if(amount > OHRuleBean.getMaxVisitAmountperDay())
- {
- amount=OHRuleBean.getMaxVisitAmountperDay();
- }
- conveyenceAmount=conveyenceAmount+amount;
- }
- // setting the visit amount into the benefit bean
- if(conveyenceAmount!=0)
- {
- benefitBean.setInjuryId(injuryBean.getInjuryID());
- benefitBean.setBenStDateGreg(startDate);
- benefitBean.setBenEndDateGreg(endDate);
- benefitBean.setBenAmount(new Double(conveyenceAmount));
- benefitBean.setOhBenCode(OHConstants.OH_ALWNC_CONVEYENCE);
- benefitBean.setBenefitPayableTo(payableTo);
- benefitBean.setContributorId(contributorId);
- benefitBean.setTotalContWage(injuryBean.getTotalConWage());
- conveyanceBenefitList.add(benefitBean);
- }else
- {
- benefitBean=null;
- }
- }
- GOSIDebug.debugMessages("-------calculateConveyenceAllowance*--------");
- return conveyanceBenefitList;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("session-calConv :The exception is "+e);
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "calculateConveyenceAllowance()",e,"CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp(ps, rs);
- }
- }
- /**
- * @METHOD NAME : canLastDayMadeOutpatient
- * @INFORMATION : This method is to check wether last day can
- be Made Outpatient
- * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.TreatmentPeriodBean
- * @RETURN : boolean
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private boolean canLastDayMadeOutpatient(TreatmentPeriodBean trmtBean,
- boolean isTreatmentApproved)
- throws GOSIException
- {
- PreparedStatement ps = null;
- ResultSet rs = null;
- boolean canLastDayMadeOutpatient = false;
- try
- {
- // for every treatment if the next day of the end date is of
- // any type other than inpatient the last day can be made out patient
- // but the current treatment type shd be inpatient
- Timestamp nextDate = GOSIUtilities.getNextDate(trmtBean.getEndDateGreg());
- Short trmtType = null;
- String sqlQuery = " select TREATMENTTYPE from "+
- SITables.T_TREATMENT + " where "+
- "INJURYID = ? and STARTDATE <= ? and ENDDATE >= ? "+
- " and TREATMENTSTATUS =? ";
- ps = con.prepareStatement(sqlQuery);
- ps.setLong(1, trmtBean.getInjuryId().longValue());
- ps.setTimestamp(2,nextDate);
- ps.setTimestamp(3,nextDate);
- if(isTreatmentApproved)
- {
- ps.setShort(4,OHConstants.TRMT_STS_APPROVED.shortValue());
- }else
- {
- ps.setShort(4,OHConstants.TRMT_STS_ENTERED.shortValue());
- }
- rs = ps.executeQuery();
- while(rs.next())
- {
- if(rs.getObject("TREATMENTTYPE")!=null)
- {
- trmtType = new Short(rs.getShort("TREATMENTTYPE"));
- }
- }
- GOSIDebug.debugMessages("TrmtType :" + trmtType + ":");
- if( trmtType!= null )
- {
- if(OHConstants.TRMT_TYPE_INPATIENT.equals(trmtType))
- {
- canLastDayMadeOutpatient = false;
- }else
- {
- canLastDayMadeOutpatient = true;
- }
- }else
- {
- canLastDayMadeOutpatient = true;
- }
- return canLastDayMadeOutpatient;
- }
- catch(GOSIException ge)
- {
- throw ge;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("session-canLastDayMadeOutpatient:e:"+e);
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "canLastDayMadeOutpatient()",e,"CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp(ps, rs);
- }
- }
- /**
- * @METHOD NAME : canFirstVisitBeCalculated
- * @INFORMATION : This method is to check whether First Visit Be Calculated
- * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.InjuryPopDetails
- * @RETURN : boolean
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private boolean canFirstVisitBeCalculated(InjuryPopDetails injuryBean)
- throws GOSIException
- {
- GOSIDebug.debugMessages("\n\n--------canFirstVisitBeCalculated----------");
- PreparedStatement ps=null;
- ResultSet rs= null;
- try
- {
- // if no visits has been paid for an injury the flag
- // canFirstVisitBeCalculated is true else false
- Long injuryId = injuryBean.getInjuryID();
- boolean canFirstVisitBeCalculated =true;
- String sqlQuery = "select OHBENID from "+
- SITables.T_OHBENEFIT +
- " where INJURYID = ? "+
- " and OHBENCODE = ? "+
- " and BENSTATUS not in(?,?) " ;
- ps =con.prepareStatement(sqlQuery);
- ps.setLong(1,injuryId.longValue());
- ps.setShort(2,OHConstants.OH_ALWNC_CONVEYENCE.shortValue());
- ps.setShort(3,OHConstants.OH_BNFT_STS_REJECTED.shortValue());
- ps.setShort(4,OHConstants.OH_BNFT_STS_CANCELLED.shortValue());
- rs = ps.executeQuery();
- if(rs.next())
- {
- canFirstVisitBeCalculated = false;
- }
- GOSIDebug.debugMessages("---------canFirstVisitBeCalculated*--------"+canFirstVisitBeCalculated);
- return canFirstVisitBeCalculated;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("session:canFirstVisitBeCalculated:e:"+e);
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "getTotalContibutorWage()",e,"CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities. cleanUp(ps,rs);
- }
- }
- /**
- * @METHOD NAME : getIntimationDates
- * @INFORMATION : This method is to get Intimation Dates from injury
- * @PARAM : class java.util.ArrayList
- * @RETURN : class java.util.HashMap
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private HashMap getIntimationDates
- (ArrayList injuryList) throws GOSIException
- {
- GOSIDebug.debugMessages("----------getIntimationDates-----------");
- try
- {
- // this method sets the varios intimation dates for the injury
- // like the worker notification date , employer notification date
- // and based on the dates the benefit start date is calculated
- // if there is a delay in notification the the delay notification
- // flag is set
- int injuryListSize = injuryList.size();
- for (int i=0; i< injuryListSize; i++ )
- {
- InjuryPopDetails injuryBean =
- (InjuryPopDetails)injuryList.get(i);
- Timestamp injuryDate = injuryBean.getInjuryDate();
- Timestamp workDisabilityDate=injuryBean.getWorkDisabilityDate();
- Timestamp employerNotifyDate=injuryBean.getEmployerNotifyDate();
- Timestamp workerIntimationDate =
- injuryBean.getWorkerIntimationDate();
- Timestamp startDate = workDisabilityDate;
- int workerIntimationDay =
- OHUtilities.getDays(injuryDate,workerIntimationDate);
- int employerNotifyDay =
- OHUtilities.getDays(workerIntimationDate,employerNotifyDate);
- boolean payFromInjuryDate = true;
- boolean payFromWorkerIntimationDate =false;
- boolean payFromEmpNotifyDate =false;
- boolean canWaiveDelay =false;
- Short reportingStatus = null;
- GOSIDebug.debugMessages("workerIntimationDay:"+workerIntimationDay);
- GOSIDebug.debugMessages("employerNotifyDay:"+employerNotifyDay);
- if(workerIntimationDay > OHRuleBean.getMaxLimitWorkerIntimation())
- {
- payFromInjuryDate = false ;
- payFromWorkerIntimationDate =true;
- GOSIDebug.debugMessages("payFromWorkerIntimationDate:"+payFromWorkerIntimationDate);
- GOSIDebug.debugMessages("payFromEmpNotifyDate:"+payFromEmpNotifyDate);
- }
- if(employerNotifyDay > OHRuleBean.getMaxLimitEmployerNotification())
- {
- payFromInjuryDate = false ;
- payFromEmpNotifyDate = true;
- GOSIDebug.debugMessages("payFromWorkerIntimationDate:"+payFromWorkerIntimationDate);
- GOSIDebug.debugMessages("payFromEmpNotifyDate:"+payFromEmpNotifyDate);
- }
- if( payFromEmpNotifyDate && payFromWorkerIntimationDate)
- {
- GOSIDebug.debugMessages(""+payFromWorkerIntimationDate+","+payFromEmpNotifyDate);
- startDate = employerNotifyDate;
- reportingStatus = injuryBean.LATE_REPORTED;
- }else
- if( !payFromEmpNotifyDate && payFromWorkerIntimationDate)
- {
- GOSIDebug.debugMessages(""+payFromWorkerIntimationDate+","+payFromEmpNotifyDate);
- startDate = workerIntimationDate;
- reportingStatus = injuryBean.WORKER_LATE_REPORTING;
- }else
- if( !payFromEmpNotifyDate && !payFromWorkerIntimationDate)
- {
- GOSIDebug.debugMessages(""+payFromWorkerIntimationDate+","+payFromEmpNotifyDate);
- startDate = workDisabilityDate;
- reportingStatus = injuryBean.NORMAL_REPORTING;
- }else
- if( payFromEmpNotifyDate && !payFromWorkerIntimationDate)
- {
- GOSIDebug.debugMessages(""+payFromWorkerIntimationDate+","+payFromEmpNotifyDate);
- startDate = employerNotifyDate;
- reportingStatus = injuryBean.EMPLOYER_LATE_REPORTING;
- }
- GOSIDebug.debugMessages("startDate :"+startDate);
- injuryBean.setStartDate(startDate);
- injuryBean.setReportingStatus(reportingStatus);
- }
- Timestamp startDate =null;
- for (int i=0; i< injuryListSize; i++ )
- {
- InjuryPopDetails injuryBean =
- (InjuryPopDetails)injuryList.get(i);
- if(startDate ==null)
- {
- startDate = injuryBean.getStartDate();
- }else
- {
- if( startDate.compareTo(injuryBean.getStartDate())>0)
- {
- startDate =injuryBean.getStartDate();
- }
- }
- }
- GOSIDebug.debugMessages("startDate :"+startDate);
- HashMap details = new HashMap();
- /*for (int i=0; i< injuryListSize; i++ )
- {
- InjuryPopDetails injuryBean = (injuryPopDetails)injurylist.get(i);
- injuryBean.setStartDate(startDate);
- }*/
- details.put("injuryList",injuryList);
- details.put("startDate",startDate);
- GOSIDebug.debugMessages("----------getIntimationDates**-----------");
- return details;
- }
- catch (Exception e)
- {
- throw new GOSIException();
- }
- }
- /**
- * @METHOD NAME : searchOHAllowance
- * @INFORMATION : This method is to search OH Allowance
- * @PARAM : class java.lang.Long
- * @RETURN : class java.util.HashMap
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- public HashMap searchOHAllowance(Long workflowId)
- throws GOSIException
- {
- long startTime = 0;
- long endTime = 0;
- long elapsedTime = 0;
- startTime = System.currentTimeMillis();
- // here the oh benefit records for the workflowid is fetched
- // from the oh benefit table , this method is called in
- // workflow
- PreparedStatement ps = null;
- ResultSet rs =null;
- //Query to get benefit details
- String sqlQuery = "" + "select " + " OHBENID, " + " INJURYID, "
- + " CONTRIBUTORID, " + " FIELDOFFICECODE, " + " OHBENCODE, "
- + " OHBENTYPE, " + " BENSTDATE, " + " BENSTDATEENTFMT,"
- + " BENENDDATE, " + " BENENDDATEENTFMT, " + " BENAMOUNT, "
- + " BENSTATUS, " + " PAYMENTMODE, " + " BANKCODE, "
- + " BANKACCNUMBER, " + " DATEPAYMENT, "
- + " DATEPAYMENTENTFMT, " + " WORKFLOWSTATUS, JOURNALHEADERID , "
- + " TOTALCONTWAGE, " + " CREATEDBY, " + " CREATIONTIMESTAMP, "
- + " LASTMODIFIEDBY, " + " LASTMODIFIEDTIMESTAMP, "
- + " REJECTIONCODE, " + " PAYABLETO, " + " PARTYCODE, "
- + " DESCRIPTION, " + " WORKFLOWID from " + SITables.T_OHBENEFIT
- + " where WORKFLOWID = ? " + " order by OHBENID ";
- HashMap details = new HashMap();
- try
- {
- Long conId = null;
- GOSIDebug.debugMessages("SqlQuery :" + sqlQuery + ":");
- GOSIDebug.debugMessages("\t\t Param 1 :" + workflowId.longValue() + ":");
- String entFmt = OHConstants.DEFAULT_ENT_FMT;
- ArrayList benefitList=new ArrayList();
- con=GOSIUtilities.getConnection
- (GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
- ps=con.prepareStatement(sqlQuery);
- ps.setLong(1,workflowId.longValue());
- rs=ps.executeQuery();
- while(rs.next())
- {
- OHAllowanceBean benefitBean=new OHAllowanceBean();
- benefitBean.setOhBenId(new Long(rs.getLong("OHBENID")));
- benefitBean.setInjuryId (new Long(rs.getLong("INJURYID")));
- benefitBean.setContributorId
- (new Long(rs.getLong("CONTRIBUTORID")));
- GOSIDebug.debugMessages("----conId:"+conId);
- if(conId !=null)
- {
- GOSIDebug.debugMessages("conId:"+conId);
- GOSIDebug.debugMessages("conId:"+benefitBean.getContributorId());
- if(!conId.equals( benefitBean.getContributorId()))
- {
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "searchOHAllowance()",
- "Data Corrupted,Contact System Administrator",
- null,"CMN_ERR_1000");
- }
- }else
- {
- conId = benefitBean.getContributorId();
- }
- GOSIDebug.debugMessages("---conId:"+conId);
- benefitBean.setFieldofficeCode
- (new Short(rs.getShort("FIELDOFFICECODE")));
- benefitBean.setOhBenCode(new Short(rs.getShort("OHBENCODE")));
- benefitBean.setOhBenType(rs.getString("OHBENTYPE"));
- benefitBean.setBenStDateGreg(rs.getTimestamp("BENSTDATE"));
- benefitBean.setBenStDateEntFmt(rs.getString("BENSTDATEENTFMT"));
- benefitBean.setBenEndDateGreg
- (rs.getTimestamp("BENENDDATE"));
- benefitBean.setBenEndDateEntFmt
- (rs.getString("BENENDDATEENTFMT"));
- entFmt=benefitBean.getBenEndDateEntFmt();
- benefitBean.setBenAmount(new Double(rs.getDouble("BENAMOUNT")));
- benefitBean.setBenStatus(new Short(rs.getShort("BENSTATUS")));
- if(rs.getObject("JOURNALHEADERID")!=null)
- {
- benefitBean.setJournalHeaderId
- (new Long(rs.getLong("JOURNALHEADERID")));
- }
- if(rs.getObject("PAYMENTMODE")!=null)
- {
- benefitBean.setPaymentMode
- (new Short(rs.getShort("PAYMENTMODE")));
- }
- if(rs.getObject("BANKCODE")!=null)
- {
- benefitBean.setBankCode
- (new Integer(rs.getInt("BANKCODE")));
- }
- if(rs.getObject("BANKACCNUMBER")!=null)
- {
- benefitBean.setBankAccNumber
- (new Long(rs.getLong("BANKACCNUMBER")));
- }
- if(rs.getObject("DATEPAYMENT")!=null)
- {
- benefitBean.setDatePaymentGreg
- (rs.getTimestamp("DATEPAYMENT"));
- benefitBean.setDatePaymentEntFmt
- (rs.getString("DATEPAYMENTENTFMT"));
- }
- benefitBean.setWorkflowStatus
- (new Short(rs.getShort("WORKFLOWSTATUS")));
- benefitBean.setTotalContWage
- (new Double(rs.getDouble("TOTALCONTWAGE")));
- benefitBean.setCreatedBy(new Long(rs.getLong("CREATEDBY")));
- benefitBean.setCreationTimestamp
- (rs.getTimestamp("CREATIONTIMESTAMP"));
- if(rs.getObject("LASTMODIFIEDBY")!=null)
- {
- benefitBean.setLastModifiedBy
- (new Long(rs.getLong("LASTMODIFIEDBY")));
- benefitBean.setLastModifiedTimestamp
- (rs.getTimestamp("LASTMODIFIEDTIMESTAMP"));
- }
- if(rs.getObject("REJECTIONCODE")!=null)
- {
- benefitBean.setRejectionCode
- (new Short(rs.getShort("REJECTIONCODE")));
- }
- if(rs.getObject("PARTYCODE")!=null)
- {
- benefitBean.setPartyCode
- (new Long (rs.getLong("PARTYCODE")));
- }
- if(rs.getObject("PAYABLETO")!=null)
- {
- benefitBean.setBenefitPayableTo
- (new Short (rs.getShort("PAYABLETO")));
- }
- if(rs.getObject("DESCRIPTION")!=null)
- {
- benefitBean.setDescription(rs.getString("DESCRIPTION"));
- }
- GOSIDebug.debugMessages("DESCRIPTION:"+benefitBean.getDescription());
- benefitBean.setWorkflowId(new Long(rs.getLong("WORKFLOWID")));
- benefitList.add(benefitBean);
- }
- if(benefitList!= null && benefitList.size()>0)
- {
- Double totalConWage=
- ((OHAllowanceBean) benefitList.get(0)).getTotalContWage();
- Long contributorId =
- ((OHAllowanceBean) benefitList.get(0)).getContributorId();
- entFmt =((OHAllowanceBean) benefitList.get(0)).getBenStDateEntFmt();
- //query to get injury details
- sqlQuery = "SELECT a.injuryid, a.socinsnumber, a.contributorid, a.establishmentid, "
- + " a.injurydate, a.injurynumber, a.description, a.treatmentstdate, "
- + " a.treatmentenddate, a.fieldofficecode, a.injurystatus, "
- + " a.employernotifydate, a.workerintimationdate, a.wagestopdate, "
- + " NVL (a.workdisabilitydate, a.injurydate + 1) workdisabilitydate, "
- + " MIN (b.benstdate) benstartdate, MAX (b.benenddate) benenddate "
- + " FROM " + SITables.T_INJURY + " a, " + SITables.T_OHBENEFIT + " b "
- + " WHERE a.injuryid = b.injuryid "
- + " AND a.contributorid = ? "
- + " AND b.workflowid = ? "
- + " AND a.injurystatus != ? "
- + "GROUP BY a.injuryid, a.socinsnumber, a.contributorid, a.establishmentid, "
- + " a.injurydate, a.injurynumber, a.description, a.treatmentstdate, "
- + " a.treatmentenddate, a.fieldofficecode, a.injurystatus, a.employernotifydate, "
- + " a.workerintimationdate, a.wagestopdate, a.workdisabilitydate, a.injurydate "
- + "ORDER BY a.injurydate ";
- GOSIDebug.debugMessages("SqlQuery :" +sqlQuery + ":");
- GOSIDebug.debugMessages("\t\t Param 1 :" + contributorId.longValue() + ":");
- GOSIDebug.debugMessages("\t\t Param 2 :" + workflowId.longValue() + ":");
- GOSIDebug.debugMessages("\t\t Param 3 :" + OHConstants.INJ_STS_CANCELLED.shortValue() + ":");
- ArrayList injuryList = new ArrayList();
- ps=con.prepareStatement(sqlQuery);
- ps.setLong(1,contributorId.longValue());
- ps.setLong(2,workflowId.longValue());
- ps.setShort(3,OHConstants.INJ_STS_CANCELLED.shortValue());
- rs=ps.executeQuery();
- while(rs.next())
- {
- GOSIDebug.debugMessages("searchInjuryList has records");
- InjuryPopDetails injuryDetails =new InjuryPopDetails();
- injuryDetails.setInjuryID(new Long(rs.getLong("INJURYID")));
- injuryDetails.setSocialInsuranceNumber
- (new Long(rs.getLong("SOCINSNUMBER")));
- injuryDetails.setEstablishmentId
- (new Long(rs.getLong("ESTABLISHMENTID")));
- injuryDetails.setContributorId
- (new Long(rs.getLong("CONTRIBUTORID")));
- injuryDetails.setInjuryDate(rs.getTimestamp("INJURYDATE"));
- if (OHConstants.HIJRAH.equals(entFmt))
- {
- injuryDetails.setInjuryDateStr
- (GOSIDateUtilities.convertToHijra(
- GOSIUtilities.getDateFullString(
- injuryDetails.getInjuryDate())));
- }
- else
- {
- injuryDetails.setInjuryDateStr
- (GOSIUtilities.getDateFullString(
- injuryDetails.getInjuryDate()));
- }
- injuryDetails.setInjuryNumber
- (new Long(rs.getLong("INJURYNUMBER")));
- injuryDetails.setDescription(rs.getString("DESCRIPTION"));
- injuryDetails.setTreatmentStartDate(rs.getTimestamp("TREATMENTSTDATE"));
- injuryDetails.setTreatmentEndDate(rs.getTimestamp("TREATMENTENDDATE"));
- injuryDetails.setFieldOffice
- (new Short(rs.getShort("FIELDOFFICECODE")));
- injuryDetails.setInjuryStatus
- (new Short(rs.getString("INJURYSTATUS")));
- if(rs.getObject("EMPLOYERNOTIFYDATE")!= null)
- {
- injuryDetails.setEmployerNotifyDate
- (rs.getTimestamp("EMPLOYERNOTIFYDATE"));
- }
- if(rs.getObject("WORKERINTIMATIONDATE")!= null)
- {
- injuryDetails.setWorkerIntimationDate
- (rs.getTimestamp("WORKERINTIMATIONDATE"));
- }
- if(rs.getObject("WAGESTOPDATE")!= null)
- {
- injuryDetails.setWageStopDate
- (rs.getTimestamp("WAGESTOPDATE"));
- }
- if(rs.getObject("WORKDISABILITYDATE")!= null)
- {
- injuryDetails.setWorkDisabilityDate
- (rs.getTimestamp("WORKDISABILITYDATE"));
- }
- // setting contributor details
- injuryDetails = setContributorDetails(injuryDetails);
- // setting establishment details
- injuryDetails=setEstablishmentDetails(injuryDetails);
- injuryDetails.setBenefitStartDateStr
- (OHUtilities.getDateStr(rs.getTimestamp("BENSTARTDATE"),entFmt));
- injuryDetails.setBenefitEndDateStr
- (OHUtilities.getDateStr(rs.getTimestamp("BENENDDATE"),entFmt));
- injuryDetails.setBenefitStartDate(rs.getTimestamp("BENSTARTDATE"));
- injuryDetails.setBenefitEndDate(rs.getTimestamp("BENENDDATE"));
- injuryDetails.setTotalConWage(totalConWage);
- GOSIDebug.debugMessages("pay to SI: " + injuryDetails.getBenefitPayableTo());
- injuryList.add(injuryDetails);
- }
- //getting total contributory wage
- injuryList = getTotalContributorWage(injuryList);
- int injuryListSize = injuryList.size();
- // checking for wage change
- for(int i=0;i<injuryListSize;i++)
- {
- InjuryPopDetails injuryBean=(InjuryPopDetails)injuryList.get(i);
- if(injuryBean.getTotalConWage().doubleValue()!=
- totalConWage.doubleValue())
- {
- GOSIDebug.debugMessages("wage Changed");
- injuryBean.setTotalConWage(totalConWage);
- }
- }
- // changeing the time stamp dates to string dates
- benefitList = changeBenefitDates(benefitList,entFmt);
- boolean benefitPayableToAuthperson = false;
- for(int i=0;i<benefitList.size();i++)
- {
- // setting injurynumber for benefit
- OHAllowanceBean benefitBean = (OHAllowanceBean)benefitList.get(i);
- benefitBean.setInjuryNumber
- (getInjuryNumber(injuryList,benefitBean.getInjuryId()));
- /* benefitPayableToAuthperson flag will be true only when the payment is
- * choosen to pay for Authorized Person*/
- if(benefitBean.getBenefitPayableTo().equals(OHConstants.OH_BNFT_PAY_TO_AUTH_PERSON))
- {
- benefitPayableToAuthperson = true;
- }
- }
- /* if the benefit payableTo is authorized person then set the
- * injurydetails payableTo as authorized person.
- */
- if(benefitPayableToAuthperson)
- {
- for(int i=0;i<injuryListSize;i++)
- {
- InjuryPopDetails injuryBean = (InjuryPopDetails)injuryList.get(i);
- injuryBean.setBenefitPayableTo(OHConstants.OH_BNFT_PAY_TO_AUTH_PERSON);
- }
- }
- // getting waving details
- details = getIntimationDates(injuryList);
- boolean canWaiveDelay = canWaiveDelayNotification(workflowId,injuryList);
- boolean canReenterBenefit = canReenterBenefit(workflowId, injuryList);
- details.put("canWaiveDelay", new Boolean(canWaiveDelay));
- details.put("canReenterBenefit", new Boolean(canReenterBenefit));
- //details.put("injuryList",injuryList);
- details.put("benefitList",benefitList);
- }
- GOSIDebug.debugMessages("-----searchOHAllowance*--------");
- endTime = System.currentTimeMillis();
- elapsedTime = endTime - startTime;
- GOSIInstrumentationLog.writeInstrumentationToLog(
- this.getClass().toString(),
- "searchOHAllowance()",
- elapsedTime);
- return details;
- }
- catch(GOSIException ge)
- {
- GOSIDebug.debugMessages("session-searchOHAllowance : The exp is "+ge);
- throw ge;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("session-searchOHAllowance : The exp is "+e);
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "searchOHAllowance()",e,"CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp(con,ps,rs);
- }
- }
- /**
- * @METHOD NAME : canWaiveDelayNotification
- * @INFORMATION : This method is to check can Waive Delay Notification
- * @PARAM : class java.lang.Long,
- class java.util.ArrayList
- * @RETURN : boolean
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private boolean canWaiveDelayNotification
- (Long workflowId,ArrayList injuryList)throws GOSIException
- {
- PreparedStatement ps = null;
- ResultSet rs = null;
- boolean canWaive = false;
- try
- {
- // it get the canwaive flag from the get intimation method
- // and checks if the delay can be waived
- // this method is called during workflow
- String sqlQuery = "select MIN(BENSTDATE) MINBENSTARTDATE, "+
- " MAX(BENENDDATE) MAXBENENDDATE from " +
- SITables.T_OHBENEFIT +" where WORKFLOWID =? ";
- String sqlQuery2= " and OHBENCODE in(?,?) ";
- ps = con.prepareStatement(sqlQuery);
- ps.setLong(1,workflowId.longValue());
- rs = ps.executeQuery();
- Timestamp startDate = null;
- Timestamp endDate = null;
- while(rs.next())
- {
- if(rs.getObject("MINBENSTARTDATE")!=null)
- {
- startDate = rs.getTimestamp("MINBENSTARTDATE");
- }
- if(rs.getObject("MAXBENENDDATE")!=null)
- {
- endDate = rs.getTimestamp("MAXBENENDDATE");
- }
- }
- /* To get Daily allowance startDate and end date */
- sqlQuery =sqlQuery +sqlQuery2;
- GOSIDebug.debugMessages("sqlQuery:\n"+sqlQuery);
- ps = con.prepareStatement(sqlQuery);
- ps.setLong(1,workflowId.longValue());
- ps.setShort(2,OHConstants.OH_ALWNC_DAIlY_INPATIENT.shortValue());
- ps.setShort(3,OHConstants.OH_ALWNC_DAIlY_OUTPATIENT.shortValue());
- rs = ps.executeQuery();
- Timestamp dailyAllowanceStartDate = null;
- Timestamp dailyAllowanceEndDate = null;
- while(rs.next())
- {
- if(rs.getObject("MINBENSTARTDATE")!=null)
- {
- dailyAllowanceStartDate= rs.getTimestamp("MINBENSTARTDATE");
- }
- else
- {
- dailyAllowanceStartDate = startDate;
- }
- if(rs.getObject("MAXBENENDDATE")!=null)
- {
- dailyAllowanceEndDate= rs.getTimestamp("MAXBENENDDATE");
- }
- }
- HashMap details = getIntimationDates(injuryList);
- injuryList =(ArrayList)details.get(injuryList);
- startDate = (Timestamp)details.get("startDate");
- GOSIDebug.debugMessages("dailyAllowanceStartDate:"+dailyAllowanceStartDate);
- GOSIDebug.debugMessages("startDate:"+startDate);
- // if benefit start date after the daily allowance start date
- // the can waive is ture else false bcos nothing to waive
- if(startDate.compareTo(dailyAllowanceStartDate)>0 )
- {
- canWaive =true;
- }
- else
- {
- canWaive =false;
- GOSIDebug.debugMessages("No need To check for waive delay intimation");
- GOSIDebug.debugMessages("status :"+startDate.compareTo(dailyAllowanceStartDate));
- }
- return canWaive;
- }
- catch (Exception e)
- {
- GOSIDebug.debugMessages("session - canWaiveDelayNotification :e:"+e);
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "getActualWaivableFromDate()",e,"CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp(ps,rs);
- }
- }
- /**
- * @METHOD NAME : canReenterBenefit
- * @INFORMATION : This method is to check can Reenter Benefit
- * @PARAM : class java.lang.Long,
- class java.util.ArrayList
- * @RETURN : boolean
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private boolean canReenterBenefit (Long workflowId, ArrayList injuryList) throws GOSIException
- {
- boolean canReenterBenefit = true;
- PreparedStatement ps = null;
- ResultSet rs = null;
- try
- {
- String sqlQuery = "SELECT COUNT(*) "
- + " FROM " + SITables.T_OHBENEFIT
- + " WHERE WORKFLOWID = ? AND OHBENCODE <> ? ";
- ps = con.prepareStatement (sqlQuery);
- ps.setLong (1, workflowId.longValue ());
- ps.setShort (2, OHConstants.OH_ALWNC_MISCELLANEOUS.shortValue ());
- rs = ps.executeQuery ();
- if (rs.next () && rs.getLong (1) > 0)
- {
- canReenterBenefit = false; /* Benefits other than miscellaneous benefits cannot be reentered */
- }
- }
- catch (Exception e)
- {
- throw new GOSIException (GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass ().toString (),
- "canReenterBenefit ()",
- e,
- "CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp (ps, rs);
- }
- return canReenterBenefit;
- }
- /**
- * @METHOD NAME : getActualWaivableFromDate
- * @INFORMATION : This method is to get Actual Waivable From Date
- * @PARAM : class java.util.ArrayList
- * @RETURN : class java.sql.Timestamp
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private Timestamp getActualWaivableFromDate(ArrayList injuryList)
- throws GOSIException
- {
- try
- {
- // if the delay in notification is to be waived this
- // calculates the day from which the benefit can be calculated
- int injuryListSize =injuryList.size();
- for ( int i=0;i<injuryListSize ; i++)
- {
- InjuryPopDetails injuryBean =(InjuryPopDetails)injuryList.get(i);
- if(!injuryBean.getReportingStatus().equals
- (injuryBean.NORMAL_REPORTING))
- {
- if(injuryBean.getReportingStatus().equals
- (injuryBean.WORKER_LATE_REPORTING))
- {
- injuryBean.setStartDate
- (injuryBean.getWorkDisabilityDate());
- }else if(injuryBean.getReportingStatus().equals
- (injuryBean.EMPLOYER_LATE_REPORTING))
- {
- injuryBean.setStartDate
- (injuryBean.getWorkDisabilityDate());
- }
- else if(injuryBean.getReportingStatus().equals
- (injuryBean.LATE_REPORTED))
- {
- injuryBean.setStartDate
- (injuryBean.getWorkDisabilityDate());
- }
- }else
- {
- injuryBean.setStartDate
- (injuryBean.getWorkDisabilityDate());
- }
- }
- Timestamp startDate =null;
- for (int i=0; i< injuryListSize; i++ )
- {
- InjuryPopDetails injuryBean=(InjuryPopDetails)injuryList.get(i);
- if(startDate ==null)
- {
- startDate = injuryBean.getStartDate();
- }else
- {
- if( startDate.compareTo(injuryBean.getStartDate())>0)
- {
- startDate =injuryBean.getStartDate();
- }
- }
- }
- return startDate;
- }
- /*catch(GOSIException ge)
- {
- GOSIDebug.debugMessages("session - getActualWaivableFromDate :ge:"+ge);
- throw ge;
- }*/catch(Exception e)
- {
- GOSIDebug.debugMessages("session - getActualWaivableFromDate :e:"+e);
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "getActualWaivableFromDate()",e,"CMN_ERR_1000");
- }
- }
- /**
- * @METHOD NAME : isDuplicateSingleVisit
- * @INFORMATION : This method is to check if the benefit contains only visits
- * @PARAM : class java.util.ArrayList
- * @RETURN : class java.sql.Timestamp
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private void isDuplicateSingleVisit (ArrayList benefitList)
- throws GOSIException
- {
- PreparedStatement ps = null;
- ResultSet rs = null;
- try
- {
- if(benefitList !=null && benefitList.size()==1)
- {
- OHAllowanceBean benefitBean = (OHAllowanceBean)benefitList.get(0);
- // if the beneift list contains only visits this logic check
- // if it has been calculated earlier to prevent duplicates
- if(OHConstants.OH_ALWNC_CONVEYENCE.equals
- (benefitBean.getOhBenCode()))
- {
- boolean isCalculated = false;
- String sqlQuery = " select OHBENID from "+
- SITables.T_OHBENEFIT +
- " where INJURYID = ? and OHBENCODE = ? and BENSTATUS not in(?,?) "+
- " and BENSTDATE = ? and BENENDDATE = ? ";
- ps = con.prepareStatement(sqlQuery);
- ps.setLong(1,benefitBean.getInjuryId().longValue());
- ps.setShort(2,OHConstants.OH_ALWNC_CONVEYENCE.shortValue());
- ps.setShort(3,OHConstants.OH_BNFT_STS_REJECTED.shortValue());
- ps.setShort(4,OHConstants.OH_BNFT_STS_CANCELLED.shortValue());
- ps.setTimestamp(5,benefitBean.getBenStDateGreg());
- ps.setTimestamp(6,benefitBean.getBenEndDateGreg());
- rs = ps.executeQuery();
- if(rs.next())
- {
- isCalculated = true;
- }
- if(isCalculated)
- {
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "isDuplicateSingleVisit()",null,"SOI_ERR_5190");
- }
- }
- }
- }
- catch (GOSIException ge)
- {
- throw ge;
- }
- catch(Exception e)
- {
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
- "isDuplicateSingleVisit()",e,"CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp(ps,rs);
- }
- }
- /**
- * @METHOD NAME : calculateResumeOHAllowance
- * @INFORMATION : This method is to calculate Resume OH Allowance
- * @PARAM : class java.util.ArrayList,
- boolean,
- boolean
- * @RETURN : class java.util.ArrayList
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- public ArrayList calculateResumeOHAllowance(ArrayList injuryList,
- boolean resumeFlag,boolean canWaive)throws GOSIException
- {
- long startTime = 0;
- long endTime = 0;
- long elapsedTime = 0;
- startTime = System.currentTimeMillis();
- boolean isTreatmentApproved = true;
- ArrayList benefitList = new ArrayList();
- try
- {
- GOSIDebug.debugMessages("\n\n------calculateResumeOHAllowance---------");
- // this method is called from the stop resume oh allowance servlet
- // to display the benefit amount for the stopped periods
- // the logic here is similar to the actual calculate method
- con=GOSIUtilities.getConnection
- (GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
- int injuryListSize = injuryList.size();
- InjuryPopDetails injuryDetails =(InjuryPopDetails)injuryList.get(0);
- Long socInsNumber = injuryDetails.getSocialInsuranceNumber();
- Timestamp startDate = null;
- Timestamp endDate =null;
- ArrayList totalPayablePeriodList = new ArrayList();
- for(int i=0;i<injuryListSize;i++)
- {
- InjuryPopDetails injuryBean =
- (InjuryPopDetails)injuryList.get(i);
- Long injuryId = injuryBean.getInjuryID();
- startDate =injuryBean.getBenefitStartDate();
- endDate = injuryBean.getBenefitEndDate();
- ArrayList periodList =null;
- ArrayList stoppedList =null;
- ArrayList payablePeriodList =null;
- periodList = getTreatmentPeriodList(injuryBean,isTreatmentApproved);
- GOSIDebug.debugMessages("periodListSize:"+periodList.size());
- if(periodList != null)
- {
- stoppedList = getInjuryStoppedPeriodList(injuryBean,isTreatmentApproved);
- GOSIDebug.debugMessages("stoppedListSize:"+stoppedList.size());
- for(int a=0;a<stoppedList.size();a++)
- {
- TreatmentPeriodBean trmtBean =
- (TreatmentPeriodBean)stoppedList.get(a);
- GOSIDebug.debugMessages("stopStartDate :"+trmtBean.getStartDateGreg());
- GOSIDebug.debugMessages("stopEndDate :"+trmtBean.getEndDateGreg());
- }
- if(resumeFlag)
- {
- TreatmentPeriodBean trmtBean = new TreatmentPeriodBean();
- trmtBean.setInjuryId(injuryBean.getInjuryID());
- trmtBean.setStartDateGreg(startDate);
- trmtBean.setEndDateGreg(endDate);
- stoppedList =getStopPeriodList(stoppedList,trmtBean,
- OHConstants.RESUME_ALLOWANCE_FLAG);
- for(int a=0;a<stoppedList.size();a++)
- {
- TreatmentPeriodBean atrmtBean =
- (TreatmentPeriodBean)stoppedList.get(a);
- GOSIDebug.debugMessages("AstopStartDate :"+atrmtBean.getStartDateGreg());
- GOSIDebug.debugMessages("AstopEndDate :"+atrmtBean.getEndDateGreg());
- }
- }
- GOSIDebug.debugMessages("stoppedListSize:"+stoppedList.size());
- payablePeriodList = getPayablePeriodList
- (periodList,stoppedList);
- GOSIDebug.debugMessages("payablePeriodListSize:"+payablePeriodList.size());
- }
- int payablePeriodListSize =payablePeriodList.size();
- for (int j=0;j<payablePeriodListSize;j++)
- {
- totalPayablePeriodList.add(payablePeriodList.get(j));
- }
- }
- ArrayList daysList = new ArrayList();
- startDate =injuryDetails.getBenefitStartDate();
- endDate = injuryDetails.getBenefitEndDate();
- GOSIDebug.debugMessages("startDate :"+startDate+"\nendDate:"+endDate);
- int noDays =OHUtilities.getDays(startDate,endDate);
- Timestamp trmtDate =startDate;
- GOSIDebug.debugMessages("totalPayableListSize:"+totalPayablePeriodList.size());
- for (int i=0; i<noDays ; i++)
- {
- TreatmentPeriodBean trmtBean = getTrmtDetailsforDate
- (trmtDate,totalPayablePeriodList);
- if(trmtBean!= null)
- {
- daysList.add(trmtBean);
- }
- trmtDate = GOSIUtilities.getNextDate(trmtDate);
- }
- GOSIDebug.debugMessages("daysListSize:"+daysList.size());
- for (int i=0; i<daysList.size() ; i++)
- {
- GOSIDebug.debugMessages("Date:"+((TreatmentPeriodBean)daysList.get(i)).getStartDateGreg());
- }
- //ArrayList payablePeriodList =getBenefitPayableTrmtList(totalPayablePeriodList);
- ArrayList payablePeriodList =getBenefitPayableTrmtList(daysList);
- ArrayList dailyAllowanceList = new ArrayList();
- if(canWaive==false)
- {
- HashMap details = getIntimationDates(injuryList);
- Timestamp newStartDate =(Timestamp)details.get("startDate");
- ArrayList newInjuryList = new ArrayList();
- for(int i=0;i<injuryList.size();i++)
- {
- InjuryPopDetails injuryBean =
- ((InjuryPopDetails)injuryList.get(i));
- //injuryBean.setBenefitStartDate(newStartDate);
- GOSIDebug.debugMessages("injuryBean:"+injuryBean);
- newInjuryList.add(new InjuryPopDetails(injuryBean));
- }
- for(int i=0;i<newInjuryList.size();i++)
- {
- InjuryPopDetails injuryBean =
- ((InjuryPopDetails)newInjuryList.get(i));
- GOSIDebug.debugMessages("injuryBean:"+injuryBean);
- injuryBean.setBenefitStartDate(newStartDate);
- }
- dailyAllowanceList = calculateDailyAllowance
- (newInjuryList,payablePeriodList,isTreatmentApproved);
- }else
- {
- dailyAllowanceList = calculateDailyAllowance
- (injuryList,payablePeriodList,isTreatmentApproved);
- }
- GOSIDebug.debugMessages("DA LIST:"+dailyAllowanceList.size());
- ArrayList visitList = new ArrayList();
- ArrayList companionList =new ArrayList();
- if(canWaive)
- {
- visitList =
- calculateConveyenceAllowance(injuryList,resumeFlag,isTreatmentApproved);
- companionList =
- calculateCompanionAllowance(injuryList,resumeFlag,isTreatmentApproved);
- }
- GOSIDebug.debugMessages("CA LIST:"+visitList.size());
- GOSIDebug.debugMessages("COMPA LIST:"+companionList.size());
- GOSIDebug.debugMessages("\nDA LIST:"+dailyAllowanceList.size());
- GOSIDebug.debugMessages("CA LIST:"+visitList.size());
- GOSIDebug.debugMessages("COMPA LIST:"+companionList.size());
- if(this.canAvailBenefitdueToDisablity(socInsNumber))
- {
- benefitList = addToBenefitList(benefitList,dailyAllowanceList);
- }
- benefitList = addToBenefitList(benefitList,visitList);
- benefitList = addToBenefitList(benefitList,companionList);
- GOSIDebug.debugMessages("--------calculateResumeOHAllowance*------");
- benefitList=changeBenefitDates(benefitList,"G");
- endTime = System.currentTimeMillis();
- elapsedTime = endTime - startTime;
- GOSIInstrumentationLog.writeInstrumentationToLog(
- this.getClass().toString(),
- "calculateResumeOHAllowance()",
- elapsedTime);
- return benefitList;
- }
- catch(GOSIException ge)
- {
- GOSIDebug.debugMessages("session-calculateOHAllowance :ge:"+ge);
- throw ge;
- }catch(Exception e)
- {
- GOSIDebug.debugMessages("session-calculateOHAllowance :e:"+e);
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "calculateOHAllowance()",e,"CMN_ERR_1000");
- }
- finally
- {
- GOSIDebug.debugMessages("connection Closed");
- GOSIUtilities.cleanUp(con);
- }
- }
- /**
- * @METHOD NAME : getNextPayableDates
- * @INFORMATION : This method is to get Next Payable Dates
- * @PARAM : class java.util.ArrayList
- * @RETURN : class java.lang.String
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- public String getNextPayableDates (ArrayList injuryList)
- throws GOSIException
- {
- long startTime = 0;
- long endTime = 0;
- long elapsedTime = 0;
- startTime = System.currentTimeMillis();
- Long injuryId=null;
- Timestamp compDate = null;
- Timestamp startDate = null;
- PreparedStatement ps = null;
- ResultSet rs = null;
- Timestamp resumedate= null;
- try
- {
- // the next payable date is the next day of the end date of the
- // last paid benefit , if till now no benefits are paid
- // its the next day of complication or the injury date
- con = GOSIUtilities.getConnection
- (GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
- Long contributorId = ((InjuryPopDetails)
- injuryList.get(0)).getContributorId();
- String subQuery = "";
- Timestamp benefitStartDate =
- ((InjuryPopDetails)injuryList.get(0)).getBenefitStartDate();
- int injuryListSize =injuryList.size();
- if(injuryListSize==1)
- {
- subQuery = "";
- }else
- {
- for(int i=0;i<(injuryListSize-1);i++)
- {
- subQuery=subQuery+" ?, ";
- }
- }
- String sqlQuery =
- " select max(BENENDDATE) MAXBENENDDATE from "+
- SITables.T_OHBENEFIT + " where CONTRIBUTORID = ? and "+
- " BENSTATUS != ? and INJURYID in ( " + subQuery + " ?)";
- ps = con.prepareStatement(sqlQuery);
- ps.setLong(1,contributorId.longValue());
- ps.setShort(2,OHConstants.OH_BNFT_STS_CANCELLED.shortValue());
- for(int i=0;i<injuryListSize;i++)
- {
- injuryId =
- ((InjuryPopDetails)injuryList.get(i)).getInjuryID();
- GOSIDebug.debugMessages("injuryId=" + injuryId);
- ps.setLong(i+3,injuryId.longValue());
- }
- GOSIDebug.debugMessages("SqlQuery :" + sqlQuery);
- GOSIDebug.debugMessages("ContributorId :" + contributorId.longValue());
- GOSIDebug.debugMessages("OHConstants.OH_BNFT_STS_CANCELLED :" +
- OHConstants.OH_BNFT_STS_CANCELLED.shortValue());
- rs= ps.executeQuery();
- while(rs.next())
- {
- if(rs.getObject("MAXBENENDDATE")!= null)
- {
- startDate = rs.getTimestamp("MAXBENENDDATE");
- }
- }
- if(startDate == null)
- {
- for(int i=0;i<injuryListSize;i++)
- {
- Timestamp injuryDate =
- ((InjuryPopDetails)injuryList.get(i)).getInjuryDate();
- if(startDate == null)
- {
- startDate =injuryDate;
- }
- else
- {
- if(startDate.compareTo(injuryDate) > 0)
- {
- startDate = injuryDate;
- }
- }
- }
- }else
- {
- startDate = GOSIUtilities.getNextDate(startDate);
- }
- GOSIUtilities.cleanUp(ps,rs);
- sqlQuery="SELECT DATECOMPLICATION FROM "+
- SITables.T_INJURY +" WHERE "+
- "DATECOMPLICATION IS NOT NULL and "+
- " INJURYSTATUS in(?,?,?,?)"+
- " AND INJURYID=?";
- ps = con.prepareStatement(sqlQuery);
- ps.setShort(1, OHConstants.INJ_STS_APPROVED.shortValue());
- ps.setShort(2, OHConstants.INJ_STS_CURED_WITHOUT_DISABILITY.shortValue());
- ps.setShort(3, OHConstants.INJ_STS_CURED_WITH_DISABILITY.shortValue());
- ps.setShort(4, OHConstants.INJ_STS_RESULTED_IN_DEATH.shortValue());
- ps.setLong(5, injuryId.longValue());
- GOSIDebug.debugMessages("sqlQuery="+sqlQuery);
- rs= ps.executeQuery();
- if(rs.next())
- {
- compDate=rs.getTimestamp("DATECOMPLICATION");
- }
- GOSIUtilities.cleanUp(ps,rs);
- //check if there is any resume request for injuryid
- sqlQuery="SELECT RESUMEDATE FROM "+
- SITables.T_RESUMETREATMENT +" WHERE "+
- "INJURYID=?";
- ps = con.prepareStatement(sqlQuery);
- ps.setLong(1, injuryId.longValue());
- GOSIDebug.debugMessages("sqlQuery="+sqlQuery);
- rs= ps.executeQuery();
- if(rs.next())
- {
- //
- if(rs.getTimestamp("RESUMEDATE") != null)
- {
- resumedate = rs.getTimestamp("RESUMEDATE");
- }
- }
- String msg = "";
- GOSIDebug.debugMessages("startDate"+startDate);
- GOSIDebug.debugMessages("benefitStartDate"+benefitStartDate);
- GOSIDebug.debugMessages("compDate"+compDate);
- if (resumedate !=null && startDate.compareTo(resumedate)==0)
- {
- String startDateStr = OHUtilities.getDateStr(resumedate,"G");
- msg = GOSIErrorMessages.getErrorDesc("SOI_ERR_5385")+startDateStr;
- }
- else
- if(startDate.compareTo(benefitStartDate)!=0 && resumedate ==null)
- {
- String startDateStr = OHUtilities.getDateStr(startDate,"G");
- msg = GOSIErrorMessages.getErrorDesc("SOI_ERR_5385")+startDateStr;
- }
- else
- if(startDate.compareTo(benefitStartDate)==0&& resumedate ==null)
- {
- }
- else
- if(compDate!=null && resumedate ==null)
- {
- if(compDate.compareTo(benefitStartDate)!=0)
- {
- String compDateStr = OHUtilities.getDateStr(compDate,"G");
- msg = GOSIErrorMessages.getErrorDesc("SOI_ERR_5385")+compDateStr;
- }
- }
- GOSIDebug.debugMessages("message:"+msg);
- endTime = System.currentTimeMillis();
- elapsedTime = endTime - startTime;
- GOSIInstrumentationLog.writeInstrumentationToLog(
- this.getClass().toString(),
- "getNextPayableDates()",
- elapsedTime);
- return msg;
- }
- catch (GOSIException ge)
- {
- throw ge;
- }
- catch (Exception e)
- {
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "getNextPayableDates()",e,"CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp(con,ps,rs);
- }
- }
- /**
- * @METHOD NAME : getInjuryNumber
- * @INFORMATION : This method returns the Injury Number of the injury
- * @PARAM : class java.util.ArrayList,
- class java.lang.Long
- * @RETURN : class java.lang.Long
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private Long getInjuryNumber(ArrayList injuryList,Long injuryId)
- throws GOSIException
- {
- try
- {
- Long injuryNumber = null;
- for(int i=0;i<injuryList.size();i++)
- {
- InjuryPopDetails injuryBean =
- (InjuryPopDetails)injuryList.get(i);
- if(injuryId.equals(injuryBean.getInjuryID()))
- {
- injuryNumber = injuryBean.getInjuryNumber();
- break;
- }
- }
- return injuryNumber;
- }
- catch (Exception e)
- {
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "getInjuryNumber()",e,"CMN_ERR_1000");
- }
- }
- /**
- * @METHOD NAME : createRecFromEmp
- * @INFORMATION : This method is to create Rec From Emp
- * @PARAM : class java.util.ArrayList
- * @RETURN : void
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private void createRecFromEmp(ArrayList recEmpList)throws GOSIException
- {
- try
- {
- RecEmployerEntityHome home=(RecEmployerEntityHome)
- ServiceLocator.getInstance().getRemoteHome(
- OHConstants.REC_FROM_EMP_ENTITY_JNDI,
- RecEmployerEntityHome.class);
- for(int i=0;i<recEmpList.size();i++)
- {
- home.create((RecEmployerBean)recEmpList.get(i));
- }
- }
- catch (GOSIException ge)
- {
- throw ge;
- }
- catch (Exception e)
- {
- throw new GOSIException(GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass().toString(),
- "createRecFromEmp()",e,"CMN_ERR_1000");
- }
- }
- /**
- * @METHOD NAME : createRecFromCon
- * @INFORMATION : This method is to create Rec From Con
- * @PARAM : class java.util.ArrayList
- * @RETURN : void
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private void createRecFromCon(ArrayList recConList)throws GOSIException
- {
- try
- {
- RecFromContributorEntityHome home=(RecFromContributorEntityHome)
- ServiceLocator.getInstance().getRemoteHome(
- OHConstants.REC_FROM_CON_ENTITY_JNDI,
- RecFromContributorEntityHome.class);
- home.create(recConList);
- }
- catch (GOSIException ge)
- {
- throw ge;
- }
- catch (Exception e)
- {
- throw new GOSIException(GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass().toString(),
- "createRecFromConp()",e,"CMN_ERR_1000");
- }
- }
- /**
- * @METHOD NAME : calculateWorkerEmployerBenefitList
- * @INFORMATION : This method is to workers Employer BenefitList
- * @PARAM : class java.util.ArrayList,
- class java.util.ArrayList
- * @RETURN : class java.util.ArrayList
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private ArrayList calculateWorkerEmployerBenefitList(ArrayList
- curBenefitList,ArrayList injuryList) throws GOSIException
- {
- // this method will split the benefit to woker / employer based on wage stop date
- ArrayList newBenefitList = new ArrayList();
- Timestamp wageStopDate = null;
- Timestamp nextDate = null;
- GOSIDebug.debugMessages("\t\t Start calculateWorkerEmployerBenefitList - MaintainOHAllowanceSessionEJB");
- try
- {
- InjuryPopDetails injuryBean = (InjuryPopDetails)injuryList.get(0);
- wageStopDate = getWageStopDate(injuryBean.getInjuryID());
- if(wageStopDate != null)
- {
- GOSIDebug.debugMessages("Before for------------");
- injuryBean.setWageStopDate(wageStopDate);
- // till the wage stop date the allowance will be paid to the
- // establishment after that it will be paid to contributor
- for(int i=0;i<curBenefitList.size();i++)
- {
- GOSIDebug.debugMessages("i:" + i);
- OHAllowanceBean benefitBean = (OHAllowanceBean)curBenefitList.get(i);
- GOSIDebug.debugMessages("BenefitPayableTo:" + benefitBean.getBenefitPayableTo());
- if(benefitBean.getBenefitPayableTo().equals
- (OHConstants.OH_BNFT_PAY_TO_CON) )
- {
- if(OHConstants.OH_ALWNC_DAIlY_INPATIENT.equals(benefitBean.getOhBenCode())
- ||OHConstants.OH_ALWNC_DAIlY_OUTPATIENT.equals(benefitBean.getOhBenCode()))
- {
- if((benefitBean.getBenStDateGreg().equals(wageStopDate))&&
- (benefitBean.getBenEndDateGreg().equals(wageStopDate)))
- {
- GOSIDebug.debugMessages(" both on the same day");
- benefitBean.setBenefitPayableTo(OHConstants.OH_BNFT_PAY_TO_EMP);
- benefitBean.setPartyCode(injuryBean.getRegistrationNumber());
- benefitBean.setPaymentMode(null);
- newBenefitList.add(benefitBean);
- }else
- if((!benefitBean.getBenStDateGreg().after(wageStopDate))&&
- (!benefitBean.getBenEndDateGreg().after(wageStopDate)))
- {
- GOSIDebug.debugMessages(" both before");
- benefitBean.setBenefitPayableTo(OHConstants.OH_BNFT_PAY_TO_EMP);
- benefitBean.setPartyCode(injuryBean.getRegistrationNumber());
- benefitBean.setPaymentMode(null);
- newBenefitList.add(benefitBean);
- }else if((!benefitBean.getBenStDateGreg().after(wageStopDate))&&
- (benefitBean.getBenEndDateGreg().after(wageStopDate)))
- {
- GOSIDebug.debugMessages(" before and after");
- OHAllowanceBean nextBenefitBean = new OHAllowanceBean();
- nextBenefitBean.setInjuryId(benefitBean.getInjuryId());
- nextBenefitBean.setContributorId(benefitBean.getContributorId());
- nextBenefitBean.setTotalContWage(benefitBean.getTotalContWage());
- nextBenefitBean.setBenefitPayableTo(OHConstants.OH_BNFT_PAY_TO_EMP);
- nextBenefitBean.setOhBenCode(benefitBean.getOhBenCode());
- nextBenefitBean.setInjuryNumber(benefitBean.getInjuryNumber());
- nextBenefitBean.setWorkflowId(benefitBean.getWorkflowId());
- nextBenefitBean.setOhBenId(benefitBean.getOhBenId());
- nextBenefitBean.setFieldofficeCode(benefitBean.getFieldofficeCode());
- nextBenefitBean.setOhBenType(benefitBean.getOhBenType());
- nextBenefitBean.setBenStDateGreg(benefitBean.getBenStDateGreg());
- nextBenefitBean.setBenStDateStr(benefitBean.getBenStDateStr());
- nextBenefitBean.setBenStDateEntFmt(benefitBean.getBenStDateEntFmt());
- nextBenefitBean.setBenEndDateGreg(wageStopDate);
- nextBenefitBean.setBenEndDateStr(GOSIUtilities.getDateFullString(wageStopDate));
- nextBenefitBean.setBenEndDateEntFmt(benefitBean.getBenEndDateEntFmt());
- nextBenefitBean.setBenStatus(benefitBean.getBenStatus());
- nextBenefitBean.setPaymentMode(benefitBean.getPaymentMode());
- nextBenefitBean.setBankCode(benefitBean.getBankCode());
- nextBenefitBean.setBankAccNumber(benefitBean.getBankAccNumber());
- nextBenefitBean.setDatePaymentGreg(benefitBean.getDatePaymentGreg());
- nextBenefitBean.setDatePaymentEntFmt(benefitBean.getDatePaymentEntFmt());
- nextBenefitBean.setWorkflowStatus(benefitBean.getWorkflowStatus());
- nextBenefitBean.setJournalHeaderId(benefitBean.getJournalHeaderId());
- nextBenefitBean.setPartyCode(benefitBean.getPartyCode());
- int noDays =OHUtilities.getDays(nextBenefitBean.getBenStDateGreg(),wageStopDate);
- int maxDays=OHUtilities.getDays(benefitBean.getBenStDateGreg(),benefitBean.getBenEndDateGreg());
- double amount1=(benefitBean.getBenAmount().doubleValue()*noDays)/maxDays;
- double amount2=(benefitBean.getBenAmount().doubleValue()*(maxDays-noDays))/maxDays;
- nextBenefitBean.setBenAmount(new Double(amount1));
- newBenefitList.add(nextBenefitBean);
- nextDate=GOSIUtilities.getRequiredDate(wageStopDate,1);
- benefitBean.setBenStDateGreg(nextDate);
- benefitBean.setBenStDateStr(GOSIUtilities.getDateFullString(nextDate));
- benefitBean.setBenAmount(new Double(amount2));
- newBenefitList.add(benefitBean);
- }else
- {
- GOSIDebug.debugMessages(" after");
- newBenefitList.add(benefitBean);
- }
- }else
- {
- GOSIDebug.debugMessages(" not inpatient of out patient ");
- newBenefitList.add(benefitBean);
- }
- }else
- {
- newBenefitList.add(benefitBean);
- }
- }
- GOSIDebug.debugMessages("After for------------");
- }else
- {
- GOSIDebug.debugMessages("Not payable to contributor ");
- newBenefitList = curBenefitList;
- }
- GOSIDebug.debugMessages("\t\t End calculateWorkerEmployerBenefitList - MaintainOHAllowanceSessionEJB");
- return newBenefitList;
- }
- catch(GOSIException ge)
- {
- GOSIDebug.debugMessages("session:calculateWorkerEmployerBenefitList :ge:"+ge);
- throw ge;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("session:getTotalContibutorWage :e:"+e);
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "calculateWorkerEmployerBenefitList()",e,"CMN_ERR_1000");
- }
- finally
- {
- //GOSIUtilities.cleanUp(ps,rs);
- }
- }
- /**
- * @METHOD NAME : checkSaveOHBenefit
- * @INFORMATION : This method is to check if oh benefit is Saved
- * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.CompanionBean,
- class gosi.core.workflow.beans.WorkflowParamBean,
- class java.lang.Long
- * @RETURN : void
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- public void checkSaveOHBenefit(CompanionBean companionBean,
- WorkflowParamBean workflowParamBean,Long siNum) throws GOSIException
- {
- // checks if oh benefit is saved for the period ,
- //if saved starts a new oh workflow for companion allowance
- PreparedStatement ps=null;
- ResultSet rs=null;
- String sqlQuery=null;
- Long contributorId=null;
- boolean canSendforWorkflow = false;
- try
- {
- sqlQuery="SELECT CONTRIBUTORID FROM "+SITables.T_INJURY+
- " WHERE INJURYID=?";
- GOSIDebug.debugMessages("sqlQuery="+sqlQuery+"companionBean.getInjuryId()="+companionBean.getInjuryId());
- con=GOSIUtilities.getConnection(
- GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
- ps=con.prepareStatement(sqlQuery);
- ps.setLong(1,companionBean.getInjuryId().longValue());
- rs=ps.executeQuery();
- if(rs.next())
- {
- contributorId=new Long (rs.getLong("CONTRIBUTORID"));
- }
- GOSIUtilities.cleanUp(ps,rs);
- Long workflowId=null;
- Short benefitPayableTo = null;
- Short paymentMode = OHConstants.PAYMENT_MODE_CHEQUE;
- // Query to check if there is benefit paid for the period
- // if its not paid no records will be iserted into t_ohbenefit
- // canSendforWorkflow will be true if oh benefit already calculated for
- // the period
- if(contributorId!=null)
- {
- int i=0;
- sqlQuery="SELECT OHBENID,WORKFLOWID,PAYMENTMODE, PAYABLETO FROM "
- +SITables.T_OHBENEFIT+
- " WHERE CONTRIBUTORID = ? AND BENSTATUS NOT IN (?,?)"+
- " AND BENSTDATE <= ? AND BENENDDATE >=?";
- GOSIDebug.debugMessages("sqlQuery="+sqlQuery+
- "companionBean.getCompStDateGreg()="
- +companionBean.getCompStDateGreg()+
- "contributorId.longValue()="
- +contributorId.longValue());
- ps=con.prepareStatement(sqlQuery);
- ps.setLong(++i,contributorId.longValue());
- ps.setShort(++i,OHConstants.OH_BNFT_STS_CANCELLED.shortValue());
- ps.setShort(++i,OHConstants.OH_BNFT_STS_REJECTED.shortValue());
- ps.setTimestamp(++i,companionBean.getCompStDateGreg());
- ps.setTimestamp(++i,companionBean.getCompStDateGreg());
- rs=ps.executeQuery();
- WHILE:while(rs.next())
- {
- canSendforWorkflow = true;
- benefitPayableTo = new Short(rs.getShort("PAYABLETO"));
- if(rs.getObject("PAYMENTMODE") != null)
- {
- paymentMode = new Short(rs.getShort("PAYMENTMODE"));
- }
- workflowId=new Long(rs.getInt("WORKFLOWID"));
- if(OHConstants.OH_BNFT_PAY_TO_CON.equals(benefitPayableTo))
- {
- break WHILE;
- }
- }
- GOSIUtilities.cleanUp(ps,rs);
- }
- GOSIDebug.debugMessages("workflowId="+workflowId);
- // if companion allowance can be send for workflow
- // it will be inserted into the oh benefit bean and a
- // workflow record created
- if(canSendforWorkflow)
- {
- HashMap details=null;
- ArrayList existingBenefitList=null;
- ArrayList benefitList=new ArrayList();
- OHAllowanceBean allowanceBean= null;
- details = searchOHAllowance(workflowId);
- existingBenefitList=(ArrayList)details.get("benefitList");
- allowanceBean=(OHAllowanceBean)existingBenefitList.get(0);
- allowanceBean.setOhBenCode(OHConstants.OH_ALWNC_COMP_DAILY);
- allowanceBean.setOhBenType(GOSIUtilities.getDomainDesc
- ("OH Benefit Type",OHConstants.OH_ALWNC_COMP_DAILY.shortValue()));
- allowanceBean.setBenStDateGreg(companionBean.getCompStDateGreg());
- allowanceBean.setBenStDateEntFmt(companionBean.getCompStDateEntFmt());
- allowanceBean.setBenEndDateGreg(companionBean.getCompEndDateGreg());
- allowanceBean.setBenEndDateEntFmt(companionBean.getCompEndDateEntFmt());
- allowanceBean.setBenStDateStr(companionBean.getCompStartDateStr());
- allowanceBean.setBenEndDateStr(companionBean.getCompEndDateStr());
- allowanceBean.setBenAmount(companionBean.getDailyAllowanceComp());
- allowanceBean.setBenefitPayableTo(OHConstants.OH_BNFT_PAY_TO_CON);
- allowanceBean.setPaymentMode(paymentMode);
- allowanceBean.setPartyCode(siNum);
- allowanceBean.setBenStatus(OHConstants.OH_BNFT_STS_ENTERED);
- allowanceBean.setWorkflowStatus(OHConstants.WFS_OH_BNFT_ENTERED);
- allowanceBean.setWorkflowId(
- GOSIUtilities.getPrimaryKey("OHBNFTWORKFLOWID",
- new Long(workflowParamBean.getUserId())));
- allowanceBean.setInjuryId(companionBean.getInjuryId());
- allowanceBean.setCreatedBy(new Long (workflowParamBean.getUserId()));
- allowanceBean.setCreationTimestamp(new Timestamp(System.currentTimeMillis()));
- allowanceBean.setLastModifiedBy(null);
- allowanceBean.setLastModifiedTimestamp(null);
- benefitList.add(allowanceBean);
- workflowParamBean.
- setPrimaryKeyOfTherecord(allowanceBean.getWorkflowId().toString());
- GOSIDebug.debugMessages("workflowParamBean="+workflowParamBean);
- String message=saveOHAllowance(benefitList,workflowParamBean,siNum,null);
- }
- }
- catch(GOSIException ge)
- {
- throw ge;
- }
- catch(Exception e)
- {
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass().toString(),
- "checkSaveOHBenefit()",e,"CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp(con,ps,rs);
- }
- }
- /**
- * @METHOD NAME : adjustLastInpatientDate
- * @INFORMATION : This method is to adjust the last inpatient
- trmt date to the benefit list
- * @PARAM : class java.util.ArrayList,
- class java.util.ArrayList
- * @RETURN : class java.util.ArrayList
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private ArrayList adjustLastInpatientDate(ArrayList injuryList,
- ArrayList benefitList,boolean isTreatmentApproved) throws GOSIException
- {
- try
- {
- GOSIDebug.debugMessages("Start adjustLastInpatientDate - MaintainOHAllowanceSessionEJB");
- // these methods added for the adjustment of the last
- // inpatient period payed as sickleave.
- if(benefitList.size()==0)
- {
- return benefitList;
- }
- OHAllowanceBean benefitBean = (OHAllowanceBean)benefitList.get(0);
- Timestamp benefitStartDate = benefitBean.getBenStDateGreg();
- Long injuryId = benefitBean.getInjuryId();
- Timestamp prevBenefitDate = OHUtilities.getPrevDate(benefitStartDate);
- Double totalContWage = benefitBean.getTotalContWage();
- HashMap details = null;
- Short hospitalType = null;
- Short prevTreatmentType = null;
- Short currentTreatmentType = null;
- Short prevBenefitType = null;
- // for getting previos trmt type isTreatmentApproved is true
- details = getTreatmentType(injuryId,prevBenefitDate,true);
- if (details.get("treatmentType")!= null)
- {
- prevTreatmentType = (Short)details.get("treatmentType");
- hospitalType = (Short)details.get("hospitalType");
- }
- if(prevTreatmentType == null)
- {
- return benefitList;
- }
- OHAllowanceBean PrevBenefitBean = getPrevBenefitBean(injuryId,prevBenefitDate);
- if(PrevBenefitBean == null)
- {
- return benefitList;
- }
- prevBenefitType = PrevBenefitBean.getOhBenCode();
- details = getTreatmentType(injuryId,benefitStartDate,isTreatmentApproved);
- if (details.get("treatmentType")!= null)
- {
- currentTreatmentType = (Short)details.get("treatmentType");
- }
- OHAllowanceBean adjBenBean = new OHAllowanceBean(PrevBenefitBean);
- adjBenBean.setTotalContWage(totalContWage);
- // if the previos trmt type is inpatient
- // and the previos paid trmt type is out patient
- // and the cureent trmt type is inpatient
- // the extra amount paid last time as outpatient is adjusted this time
- if(OHConstants.TRMT_TYPE_INPATIENT.equals(prevTreatmentType)&&
- OHConstants.TRMT_TYPE_INPATIENT.equals(currentTreatmentType)&&
- OHConstants.OH_ALWNC_DAIlY_OUTPATIENT.equals(prevBenefitType))
- {
- String calenderType = getCalendarType(injuryList);
- adjBenBean.setOhBenCode
- (OHConstants.OH_ALWNC_DAIlY_INPATIENT);
- if(OHConstants.HIJRAH.equals(calenderType))
- {
- adjBenBean=setDailyAllowanceHij
- (adjBenBean,hospitalType);
- }else
- {
- adjBenBean=setDailyAllowanceGreg
- (adjBenBean,hospitalType);
- }
- Double prevOUTBenAmount = PrevBenefitBean.getBenAmount();
- Double adjINBenAmount = adjBenBean.getBenAmount();
- double adjBenAmount = adjINBenAmount.doubleValue()-prevOUTBenAmount.doubleValue();
- GOSIDebug.debugMessages("BENEFIT AMOUNT PREVOUT :"+prevOUTBenAmount);
- GOSIDebug.debugMessages("BENEFIT AMOUNT ADJIN :"+adjINBenAmount);
- GOSIDebug.debugMessages("BENEFIT AMOUNT ADJ :"+adjBenAmount);
- if(adjBenAmount!= 0)
- {
- adjBenBean.setBenAmount(new Double(adjBenAmount));
- if(OHConstants.OH_BNFT_PAY_TO_AUTH_PERSON.equals(
- adjBenBean.getBenefitPayableTo()))
- {
- adjBenBean.setBenefitPayableTo(OHConstants.OH_BNFT_PAY_TO_CON);
- }
- benefitList.add(0,adjBenBean);
- }
- }
- GOSIDebug.debugMessages("BenefitListSize:" + benefitList + ":");
- GOSIDebug.debugMessages("End adjustLastInpatientDate - MaintainOHAllowanceSessionEJB");
- return benefitList;
- }
- catch(GOSIException ge)
- {
- throw ge;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("session-getPrevBenefitBean : The exp is "+e);
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "getTreatmentType()",e,"CMN_ERR_1000");
- }
- }
- /**
- * @METHOD NAME : getTreatmentType
- * @INFORMATION : This method is to get Treatment Type
- * @PARAM : class java.lang.Long,
- class java.sql.Timestamp
- * @RETURN : class java.util.HashMap
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private HashMap getTreatmentType(Long injuryId,Timestamp treatmentDate,boolean isTreatmentApproved)
- throws GOSIException
- {
- PreparedStatement ps = null;
- ResultSet rs = null;
- String sqlQuery = "";
- Short treatmentType = null;
- Short hospitalType = null;
- HashMap details = new HashMap();
- try
- {
- // this query returns the treatment and hosptial type for an injury
- // at a particular date
- sqlQuery = " select a.HOSPITALTYPE,b.TREATMENTTYPE from "+
- SITables.T_HOSPITAL +" a ,"+
- SITables.T_TREATMENT +" b where b.INJURYID =? and "+
- " a.hospitalcode = b.hospitalcode and "+
- " b.STARTDATE <= ? and b.ENDDATE >= ? and "+
- " TREATMENTSTATUS = ? ";
- ps = con.prepareStatement(sqlQuery);
- ps.setLong(1,injuryId.longValue());
- ps.setTimestamp(2,treatmentDate);
- ps.setTimestamp(3,treatmentDate);
- if(isTreatmentApproved)
- {
- ps.setShort(4,OHConstants.TRMT_STS_APPROVED.shortValue());
- }else
- {
- ps.setShort(4,OHConstants.TRMT_STS_ENTERED.shortValue());
- }
- rs = ps.executeQuery();
- while (rs.next())
- {
- if(rs.getObject("TREATMENTTYPE")!= null)
- {
- treatmentType = new Short(rs.getShort("TREATMENTTYPE"));
- details.put("treatmentType",treatmentType);
- }
- if(rs.getObject("HOSPITALTYPE")!= null)
- {
- hospitalType = new Short(rs.getShort("HOSPITALTYPE"));
- details.put("hospitalType",hospitalType);
- }
- }
- return details;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("session-getPrevBenefitBean : The exp is "+e);
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "getTreatmentType()",e,"CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp(ps,rs);
- }
- }
- /**
- * @METHOD NAME : getPrevBenefitBean
- * @INFORMATION : This method is to get Previous Benefit Bean
- * @PARAM : class java.lang.Long,
- class java.sql.Timestamp
- * @RETURN : class gosi.business.socialinsurance.occupationalhazards.injury.beans.OHAllowanceBean
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private OHAllowanceBean getPrevBenefitBean (Long injuryId,Timestamp benefitDate)
- throws GOSIException
- {
- GOSIDebug.debugMessages("Starting getPrevBenefitBean - MaintainOHAllowanceSessionEJB");
- PreparedStatement ps = null;
- ResultSet rs =null;
- OHAllowanceBean prevBenefitBean=null;
- try
- {
- // this method returns the last paid benefit bean
- // is used to find the adjustment amount
- String sqlQuery = "" + " select " + " OHBENID, INJURYID, "
- + " CONTRIBUTORID, FIELDOFFICECODE, "
- + " OHBENCODE, OHBENTYPE, BENSTDATE, "
- + " BENSTDATEENTFMT, BENENDDATE, "
- + " BENENDDATEENTFMT, BENAMOUNT, BENSTATUS, "
- + " PAYMENTMODE, BANKCODE, BANKACCNUMBER, "
- + " DATEPAYMENT, DATEPAYMENTENTFMT, "
- + " WORKFLOWSTATUS, TOTALCONTWAGE, CREATEDBY, "
- + " CREATIONTIMESTAMP, LASTMODIFIEDBY, "
- + " LASTMODIFIEDTIMESTAMP, REJECTIONCODE, "
- + " PAYABLETO, PARTYCODE, WORKFLOWID from "
- + SITables.T_OHBENEFIT
- + " where INJURYID = ? "
- + " and BENSTDATE = ? "
- + " and BENENDDATE = ? "
- + " and BENSTATUS not in (?,?) "
- + " and OHBENCODE in (?,?) ";
- String entFmt = OHConstants.DEFAULT_ENT_FMT;
- ps=con.prepareStatement(sqlQuery);
- ps.setLong(1,injuryId.longValue());
- ps.setTimestamp(2,benefitDate);
- ps.setTimestamp(3,benefitDate);
- ps.setShort(4,OHConstants.OH_BNFT_STS_REJECTED.shortValue());
- ps.setShort(5,OHConstants.OH_BNFT_STS_CANCELLED.shortValue());
- ps.setShort(6,OHConstants.OH_ALWNC_DAIlY_OUTPATIENT.shortValue());
- ps.setShort(7,OHConstants.OH_ALWNC_DAILY_OUTPATIENT_ADJUSTMENT.shortValue());
- GOSIDebug.debugMessages("SqlQuery:"+sqlQuery);
- GOSIDebug.debugMessages("\t\t Param 1 :" + injuryId.longValue() + ":");
- GOSIDebug.debugMessages("\t\t Param 2 :" + benefitDate + ":");
- GOSIDebug.debugMessages("\t\t Param 3 :" + benefitDate + ":");
- GOSIDebug.debugMessages("\t\t Param 4 :" + OHConstants.OH_BNFT_STS_REJECTED.shortValue() + ":");
- GOSIDebug.debugMessages("\t\t Param 5 :" + OHConstants.OH_BNFT_STS_CANCELLED.shortValue()+ ":");
- GOSIDebug.debugMessages("\t\t Param 6 :" + OHConstants.OH_ALWNC_DAIlY_OUTPATIENT.shortValue() + ":");
- GOSIDebug.debugMessages("\t\t Param 7 :" + OHConstants.OH_ALWNC_DAILY_OUTPATIENT_ADJUSTMENT.shortValue() + ":");
- rs = ps.executeQuery();
- ArrayList prevBenefitList = new ArrayList();
- double benefitAmount = 0.00;
- while(rs.next())
- {
- OHAllowanceBean benefitBean=new OHAllowanceBean();
- benefitBean.setOhBenId(new Long(rs.getLong("OHBENID")));
- benefitBean.setInjuryId (new Long(rs.getLong("INJURYID")));
- benefitBean.setContributorId
- (new Long(rs.getLong("CONTRIBUTORID")));
- benefitBean.setFieldofficeCode
- (new Short(rs.getShort("FIELDOFFICECODE")));
- benefitBean.setOhBenCode(new Short(rs.getShort("OHBENCODE")));
- benefitBean.setOhBenType(rs.getString("OHBENTYPE"));
- benefitBean.setBenStDateGreg(rs.getTimestamp("BENSTDATE"));
- benefitBean.setBenStDateEntFmt(rs.getString("BENSTDATEENTFMT"));
- benefitBean.setBenEndDateGreg
- (rs.getTimestamp("BENENDDATE"));
- benefitBean.setBenEndDateEntFmt
- (rs.getString("BENENDDATEENTFMT"));
- entFmt=benefitBean.getBenEndDateEntFmt();
- benefitBean.setBenAmount(new Double(rs.getDouble("BENAMOUNT")));
- benefitAmount = benefitAmount+benefitBean.getBenAmount().doubleValue();
- benefitBean.setBenStatus(new Short(rs.getShort("BENSTATUS")));
- if(rs.getObject("PAYMENTMODE")!=null)
- {
- benefitBean.setPaymentMode
- (new Short(rs.getShort("PAYMENTMODE")));
- }
- if(rs.getObject("BANKCODE")!=null)
- {
- benefitBean.setBankCode
- (new Integer(rs.getInt("BANKCODE")));
- }
- if(rs.getObject("BANKACCNUMBER")!=null)
- {
- benefitBean.setBankAccNumber
- (new Long(rs.getLong("BANKACCNUMBER")));
- }
- if(rs.getObject("DATEPAYMENT")!=null)
- {
- benefitBean.setDatePaymentGreg
- (rs.getTimestamp("DATEPAYMENT"));
- benefitBean.setDatePaymentEntFmt
- (rs.getString("DATEPAYMENTENTFMT"));
- }
- benefitBean.setWorkflowStatus
- (new Short(rs.getShort("WORKFLOWSTATUS")));
- benefitBean.setTotalContWage
- (new Double(rs.getDouble("TOTALCONTWAGE")));
- benefitBean.setCreatedBy(new Long(rs.getLong("CREATEDBY")));
- benefitBean.setCreationTimestamp
- (rs.getTimestamp("CREATIONTIMESTAMP"));
- if(rs.getObject("LASTMODIFIEDBY")!=null)
- {
- benefitBean.setLastModifiedBy
- (new Long(rs.getLong("LASTMODIFIEDBY")));
- benefitBean.setLastModifiedTimestamp
- (rs.getTimestamp("LASTMODIFIEDTIMESTAMP"));
- }
- if(rs.getObject("REJECTIONCODE")!=null)
- {
- benefitBean.setRejectionCode
- (new Short(rs.getShort("REJECTIONCODE")));
- }
- if(rs.getObject("PARTYCODE")!=null)
- {
- benefitBean.setPartyCode
- (new Long (rs.getLong("PARTYCODE")));
- }
- if(rs.getObject("PAYABLETO")!=null)
- {
- benefitBean.setBenefitPayableTo
- (new Short (rs.getShort("PAYABLETO")));
- }
- benefitBean.setWorkflowId(new Long(rs.getLong("WORKFLOWID")));
- prevBenefitList.add(benefitBean);
- }
- if(prevBenefitList.size()==0)
- {
- prevBenefitBean = null;
- }else
- if(prevBenefitList.size()==1)
- {
- prevBenefitBean = (OHAllowanceBean)prevBenefitList.get(0);
- }
- else
- {
- for (int i=0;i<prevBenefitList.size() ;i++ )
- {
- OHAllowanceBean benefitBean = (OHAllowanceBean)prevBenefitList.get(i);
- if(OHConstants.OH_ALWNC_DAIlY_OUTPATIENT.equals(benefitBean.getOhBenCode()))
- {
- prevBenefitBean = benefitBean;
- prevBenefitBean.setBenAmount(new Double(benefitAmount));
- }
- }
- }
- GOSIDebug.debugMessages("Ending getPrevBenefitBean - MaintainOHAllowanceSessionEJB");
- return prevBenefitBean;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("session-getPrevBenefitBean : The exp is "+e);
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "getPrevBenefitBean()",e,"CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp(ps,rs);
- }
- }
- /**
- * @METHOD NAME : getPayeeName
- * @INFORMATION : This method is to get Payee Name
- * @PARAM : class java.lang.Long
- * @RETURN : class java.lang.String
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private String getPayeeName(Long contributorId)
- throws GOSIException
- {
- // payee name = authorized person name if he is there else contributor name
- PreparedStatement ps = null;
- ResultSet rs = null;
- String payeeName = null;
- Long personId = null;
- Long contactId = null;
- try
- {
- String sqlQuery = " select AUTHORIZEDPERSONID FROM "
- + SITables.T_OHAUTHORIZEDPERSON
- + " where CONTRIBUTORID =? and STATUS = ? ";
- con = GOSIUtilities.getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
- ps = con.prepareStatement(sqlQuery);
- GOSIDebug.debugMessages("SqlQuery :" + sqlQuery + ":");
- GOSIDebug.debugMessages("\t\t Param 1 :" + contributorId.longValue() + ":");
- GOSIDebug.debugMessages("\t\t Param 2 :" + OHConstants.AUTHORIZED_PERSON_STATUS_ACTIVE.shortValue() + ":");
- ps.setLong(1, contributorId.longValue());
- ps.setShort(2, OHConstants.AUTHORIZED_PERSON_STATUS_ACTIVE.shortValue());
- rs = ps.executeQuery();
- if(rs.next())
- {
- personId = new Long(rs.getLong("AUTHORIZEDPERSONID"));
- }
- if(personId != null)
- {
- PersonBean personBean = PersonUtilities.displayPerson(personId);
- payeeName = personBean.getFirstName();
- if(personBean.getSecondName()!= null)
- {
- payeeName = payeeName + " " + personBean.getSecondName();
- }
- if(personBean.getThirdName()!= null)
- {
- payeeName = payeeName + " " + personBean.getThirdName();
- }
- if(personBean.getSurName()!= null)
- {
- payeeName = payeeName + " " + personBean.getSurName();
- }
- }
- return payeeName;
- }
- catch (GOSIException ge)
- {
- throw ge;
- }
- catch(Exception se)
- {
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
- "getPayeeName()",se,"CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp(con,ps,rs);
- }
- }
- /**
- * @METHOD NAME : sentOHAllowanceforWorkflow
- * @INFORMATION : This method is to sent OH Allowancefor
- Workflow from view benefit screen
- * @PARAM : class java.lang.Long,
- class gosi.core.workflow.beans.WorkflowParamBean
- * @RETURN : class java.lang.String
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- public String sentOHAllowanceforWorkflow(Long injuryId ,
- WorkflowParamBean workflowParamBean)throws GOSIException
- {
- PreparedStatement ps = null;
- ResultSet rs = null;
- try
- {
- // this query picks up all records with workflow staus
- // pending data entry and send them into workflow inbox
- // only for cases migrated into the new system
- ArrayList benefitList = new ArrayList();
- String name = "";
- con = GOSIUtilities.getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
- String sqlQuery = " select OHBENID "+
- " from " +SITables.T_OHBENEFIT +
- " where INJURYID = ? and BENSTATUS = ? and WORKFLOWSTATUS = ? ";
- ps = con.prepareStatement(sqlQuery);
- ps.setLong(1,injuryId.longValue());
- ps.setLong(2,OHConstants.OH_BNFT_STS_ENTERED.shortValue());
- ps.setLong(3,OHConstants.WFS_OH_BNFT_PENDING_DATA_ENTRY.shortValue());
- rs = ps.executeQuery();
- while(rs.next())
- {
- Long benefitId = new Long(rs.getLong("OHBENID"));
- benefitList.add(benefitId);
- }
- Long userId=new Long(workflowParamBean.getUserId());
- Timestamp currentTime =new Timestamp(System.currentTimeMillis());
- if(benefitList.size()>0)
- {
- Long workflowId=GOSIUtilities.getPrimaryKey("OHBNFTWORKFLOWID",userId);
- OHAllowanceEntityHome home=(OHAllowanceEntityHome)
- ServiceLocator.getInstance().getRemoteHome(
- OHConstants.OH_ALLOWANCE_ENTITY_JNDI,
- OHAllowanceEntityHome.class);
- // updating oh benefit
- for (int i=0;i<benefitList.size();i++)
- {
- Long benefitId = (Long)benefitList.get(i);
- OHAllowanceEntity remote=(OHAllowanceEntity)
- home.findByPrimaryKey(benefitId);
- OHAllowanceBean benefitBean = remote.getOHBenefits();
- benefitBean.setWorkflowId(workflowId);
- benefitBean.setWorkflowStatus(OHConstants.WFS_OH_BNFT_ENTERED);
- benefitBean.setLastModifiedBy(userId);
- benefitBean.setLastModifiedTimestamp(currentTime);
- remote.modifyOHBenefits(benefitBean);
- }
- workflowParamBean.setPrimaryKeyOfTherecord(workflowId.toString());
- name = GOSIUtilities.startWorkflow(workflowParamBean);
- }else
- {
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
- "sentOHAllowanceforWorkflow()",null,"CMN_ERR_1000");
- }
- return name;
- }
- catch (GOSIException ge)
- {
- ctx.setRollbackOnly();
- throw ge;
- }
- catch(Exception e)
- {
- ctx.setRollbackOnly();
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
- "sentOHAllowanceforWorkflow()",e,"CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp(con,ps,rs);
- }
- }
- /**
- * @METHOD NAME : validateContactDetails
- * @INFORMATION : This method is to validate the payment details if payment mode is overseas cheque
- * @PARAM : class java.util.ArrayList,
- * @PARAM : class java.util.ArrayList,
- class java.lang.Long
- * @RETURN : void
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private void validateContactDetails(ArrayList contactList,
- ArrayList benefitList) throws GOSIException
- {
- try
- {
- boolean isPayableToCon = false;
- boolean hasValidContact = false;
- boolean isContactDetailsPresent = false;
- Long createdBy = null;
- // this method validates the contact details of the contributor
- // checks if his adress is non saudi if the payment mode is FC check
- Short paymentMode = null;
- Long contributorId = null;
- for (int i =0;i<benefitList.size() ;i++ )
- {
- OHAllowanceBean benefitBean = (OHAllowanceBean)benefitList.get(i);
- createdBy = benefitBean.getCreatedBy();
- if(OHConstants.OH_BNFT_PAY_TO_CON.equals(benefitBean.getBenefitPayableTo())
- ||OHConstants.OH_BNFT_PAY_TO_AUTH_PERSON.equals(benefitBean.getBenefitPayableTo()))
- {
- isPayableToCon = true;
- paymentMode = benefitBean.getPaymentMode();
- contributorId = benefitBean.getContributorId();
- break;
- }
- }
- if(contactList == null)
- {
- isContactDetailsPresent = false;
- }else
- {
- isContactDetailsPresent = true;
- }
- if(isPayableToCon &&
- OHConstants.PAYMENT_MODE_CHEQUE_OVERSEAS.equals(paymentMode))
- {
- if(contactList == null)
- {
- ContributorBean contributorBean = ContributorUtilities.
- displayContributor(contributorId);
- Long contactId = contributorBean.getContactId();
- GOSIDebug.debugMessages("contactId:"+contactId);
- contactList = GOSIUtilities.
- getIndividualContactDetails
- (contactId,GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
- }
- if(contactList != null && contactList.size()>0)
- {
- for (int i =0;i<contactList.size() ;i++ )
- {
- IndividualContactBean contactBean = (IndividualContactBean)contactList.get(i);
- if(contactBean.getCurrentMailingAddrInd()==RegistrationConstants.CURRENT_MAILING_ADDRESS.byteValue())
- {
- if(contactBean.getCountry()!= OHConstants.NATIONALITY_CODE_SAUDI.shortValue())
- {
- hasValidContact = true;
- }
- break;
- }
- }
- }
- if(!hasValidContact)
- {
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
- "validatePaymentDetails()",null,"SOI_ERR_5548");
- }
- }
- else if(isPayableToCon &&
- OHConstants.PAYMENT_MODE_CHEQUE.equals(paymentMode))
- {
- if(contactList == null)
- {
- ContributorBean contributorBean = ContributorUtilities.
- displayContributor(contributorId);
- Long contactId = contributorBean.getContactId();
- GOSIDebug.debugMessages("contactId:"+contactId);
- contactList = GOSIUtilities.
- getIndividualContactDetails
- (contactId,GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
- }
- if(contactList != null && contactList.size()>0)
- {
- for (int i =0;i<contactList.size() ;i++ )
- {
- IndividualContactBean contactBean = (IndividualContactBean)contactList.get(i);
- if(contactBean.getCurrentMailingAddrInd()==RegistrationConstants.CURRENT_MAILING_ADDRESS.byteValue())
- {
- if(contactBean.getCountry()== OHConstants.NATIONALITY_CODE_SAUDI.shortValue())
- {
- hasValidContact = true;
- }
- break;
- }
- }
- }
- if(!hasValidContact)
- {
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
- "validatePaymentDetails()",null,"SOI_ERR_7213");
- }
- }
- // inserting contact Details
- if(isContactDetailsPresent)
- {
- AuditBean contactAuditBean =new AuditBean();
- Timestamp currentTime =new Timestamp(System.currentTimeMillis());
- contactAuditBean.setCreatedBy(createdBy);
- contactAuditBean.setLastModifiedBy(createdBy);
- contactAuditBean.setCreationTimestamp(currentTime);
- contactAuditBean.setLastModifiedTimestamp(currentTime);
- contactAuditBean.setModuleId(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
- boolean contactflag =false;
- if((contactList!=null)&&(contactList.size()!=0))
- { int count = 0;
- for(int i=0; i<contactList.size();i++)
- {
- IndividualContactBean contactBean=
- (IndividualContactBean)contactList.get(i);
- GOSIDebug.debugMessages("mode:"+contactBean.getMode());
- if(AuditBean.DELETE_MODE != contactBean.getMode())
- {
- count=count+1;
- }
- }
- if(count==0)
- {
- contactflag = false;
- }else
- {
- contactflag=true;
- }
- }else
- {
- contactflag=false;
- }
- if(!contactflag)
- {
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
- "validatePaymentDetails()",null,"SOI_ERR_4406");
- }
- GOSIUtilities.modifyIndividualContactDetails(contactList,contactAuditBean);
- }
- }
- catch (GOSIException ge)
- {
- throw ge;
- }
- catch(Exception e)
- {
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
- "validatePaymentDetails()",e,"CMN_ERR_1000");
- }
- }
- /**
- * @METHOD NAME : cancelChequeIssued
- * @INFORMATION : This method is to update the status of paid
- ohbenfit to cheque returned when the cheque is
- cancelled by finance
- * @PARAM : class java.util.HashMap
- * @RETURN : class java.util.HashMap
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- public HashMap cancelChequeIssued(HashMap hashMapInterfaceInput)
- throws GOSIException
- {
- PreparedStatement ps = null;
- ResultSet rs = null;
- try
- {
- ArrayList benefitList = new ArrayList();
- // this interface method updates the oh benefit status
- // to check returned when the check is cancelled in finance
- Long journalHeaderId = (Long)hashMapInterfaceInput.
- get(OccupationalHazardsInterfaceConstants.CREDIT_NOTE_ID);
- Short moduleId =(Short)hashMapInterfaceInput.
- get(OccupationalHazardsInterfaceConstants.MODULE_ID);
- con = GOSIUtilities.getConnection(moduleId.shortValue());
- String sqlQuery = " select OHBENID "+
- " from " +SITables.T_OHBENEFIT +
- " where JOURNALHEADERID = ? and BENSTATUS in(?,?) ";
- ps = con.prepareStatement(sqlQuery);
- ps.setLong(1,journalHeaderId.longValue());
- ps.setLong(2,OHConstants.OH_BNFT_STS_PAID.shortValue());
- ps.setLong(3,OHConstants.OH_BNFT_STS_APPROVED.shortValue());
- rs = ps.executeQuery();
- while(rs.next())
- {
- Long benefitId = new Long(rs.getLong("OHBENID"));
- benefitList.add(benefitId);
- }
- Long userId=(Long)hashMapInterfaceInput.
- get(OccupationalHazardsInterfaceConstants.USER_ID);
- Timestamp currentTime = new Timestamp(System.currentTimeMillis());
- MaintainOHServicesEntityHome home = (MaintainOHServicesEntityHome) ServiceLocator
- .getInstance().getRemoteHome(
- OHConstants.MAINTAIN_OH_SERVICES_ENTITY_JNDI,
- MaintainOHServicesEntityHome.class);
- MaintainOHServicesEntity remote = home.findByPrimaryKey(new Long("0"));
- remote.updateOHBenefitStatus(hashMapInterfaceInput);
- return hashMapInterfaceInput;
- }
- catch (GOSIException ge)
- {
- ctx.setRollbackOnly();
- throw ge;
- }
- catch(Exception e)
- {
- ctx.setRollbackOnly();
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
- "cancelChequeIssued()",e,"CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp(con,ps,rs);
- }
- }
- /**
- * @METHOD NAME : reIssueCancelledCheque
- * @INFORMATION : This method is to re isssue the
- cancelled cheque details with the new details
- * @PARAM : class java.lang.Long
- * @RETURN : class java.util.ArrayList
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- public void reIssueCancelledCheque(ArrayList contactList,
- WorkflowParamBean workflowParamBean, Long contributorId,Short paymentMode, Integer chequeCancelCode,
- PersonBean personBean,boolean isArabNation)
- throws GOSIException
- {
- PreparedStatement ps = null;
- ResultSet rs = null;
- String payeeFirstName = "";
- String payeeSecondName = "";
- String payeeThirdName = "";
- String payeeSurName = "";
- String payeeName = "";
- String payeeNameEnglish = "";
- Short paymentModeFA=null;
- try
- {
- ArrayList benefitList = new ArrayList();
- OHAllowanceBean ohBenefitBean= new OHAllowanceBean();
- con = GOSIUtilities.getConnection(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
- // query to get all benefit with status returned
- String sqlQuery = " select OHBENID,JOURNALHEADERID "+
- " from " +SITables.T_OHBENEFIT +
- " where CONTRIBUTORID = ? and BENSTATUS IN (?, ?) ";
- GOSIDebug.debugMessages("SqlQuery :" + sqlQuery + ":");
- GOSIDebug.debugMessages("\t\t Param 1 :" + contributorId.longValue() + ":");
- GOSIDebug.debugMessages("\t\t Param 2 :" + OHConstants.OH_BNFT_STS_RETURNED.shortValue() + ":");
- GOSIDebug.debugMessages("\t\t Param 3 :" + OHConstants.OH_BNFT_STS_RETURNED2.shortValue() + ":");
- ps = con.prepareStatement(sqlQuery);
- ps.setLong(1, contributorId.longValue());
- ps.setLong(2, OHConstants.OH_BNFT_STS_RETURNED.shortValue());
- ps.setLong(3, OHConstants.OH_BNFT_STS_RETURNED2.shortValue());
- rs = ps.executeQuery();
- while(rs.next())
- {
- ohBenefitBean.setOhBenId(new Long(rs.getLong("OHBENID")));
- ohBenefitBean.setJournalHeaderId(new Long(rs.getLong("JOURNALHEADERID")));
- benefitList.add(ohBenefitBean);
- }
- Long userId = new Long(workflowParamBean.getUserId());
- Timestamp currentTime =new Timestamp(System.currentTimeMillis());
- ArrayList newBenefitList = new ArrayList();
- // updating all returned benefits to status approved
- OHAllowanceEntityHome home=(OHAllowanceEntityHome)
- ServiceLocator.getInstance().getRemoteHome(
- OHConstants.OH_ALLOWANCE_ENTITY_JNDI,
- OHAllowanceEntityHome.class);
- if(benefitList.size()>0)
- {
- for (int i=0;i<benefitList.size();i++)
- {
- OHAllowanceBean OHAllowanceBean = (OHAllowanceBean)benefitList.get(i);
- OHAllowanceEntity remote=(OHAllowanceEntity)
- home.findByPrimaryKey(OHAllowanceBean.getOhBenId());
- OHAllowanceBean benefitBean = remote.getOHBenefits();
- benefitBean.setBenStatus(OHConstants.OH_BNFT_STS_APPROVED);
- benefitBean.setWorkflowStatus(OHConstants.WFS_OH_BNFT_APPROVED_INT_AUD_CLK);
- benefitBean.setPaymentMode(paymentMode);
- benefitBean.setLastModifiedBy(userId);
- benefitBean.setLastModifiedTimestamp(currentTime);
- remote.modifyOHBenefits(benefitBean);
- newBenefitList.add(benefitBean);
- }
- }
- else
- {
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
- "cancelChequeIssued()",null,"CMN_ERR_1000");
- }
- // validating the contact detals for the contributor
- validateContactDetails(contactList,newBenefitList);
- // calling finance interface to remove hold and
- // update the payment mode
- ContributorBean contributorBean = ContributorUtilities.
- displayContributor(contributorId);
- /* Convert payment mode to its equivalent value in finance */
- if (paymentMode != null)
- {
- if (paymentMode.equals(OHConstants.PAYMENT_MODE_BANK_TRANSFER))
- {
- paymentModeFA = new Short ((short) FAConstants.ACCOUNT_TRANSFER);
- }
- else if (paymentMode.equals(OHConstants.PAYMENT_MODE_CHEQUE))
- {
- paymentModeFA = new Short ((short) FAConstants.LC_CHEQUE);
- }
- else if (paymentMode.equals(OHConstants.PAYMENT_MODE_CHEQUE_OVERSEAS))
- {
- paymentModeFA = new Short ((short) FAConstants.LC_CHEQUE);
- }
- else if (paymentMode.equals(OHConstants.PAYMENT_MODE_CHEQUE_AUTHORIZED_PERSON))
- {
- paymentModeFA = new Short ((short) FAConstants.LC_CHEQUE);
- }
- else
- {
- paymentModeFA = new Short ((short) FAConstants.LC_CHEQUE);
- }
- }
- IndividualContactBean contactBean = null;
- for (int i = 0; i < contactList.size(); i++)
- {
- IndividualContactBean aContactBean = (IndividualContactBean)contactList.get(i);
- if(aContactBean.getCurrentMailingAddrInd()==RegistrationConstants.CURRENT_MAILING_ADDRESS.byteValue())
- {
- contactBean = aContactBean;
- break;
- }
- }
- payeeNameEnglish = personBean.getNameEnglish();
- if(!isArabNation)
- {
- if ((payeeNameEnglish == null) || "".equals(payeeNameEnglish))
- {
- throw new GOSIException (GOSIConstants.SEVERITY_THREE,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass ().toString (),
- "reIssueCancelledCheque ()",
- new GOSIException (),
- "SOI_ERR_5619");
- }
- payeeName=payeeNameEnglish;
- StringTokenizer names=new StringTokenizer(payeeNameEnglish," ");
- if(names.hasMoreTokens())
- {
- payeeFirstName=String.valueOf(names.nextToken());
- }
- if(names.hasMoreTokens())
- {
- payeeSecondName=String.valueOf(names.nextToken());
- }
- if(names.hasMoreTokens())
- {
- payeeThirdName=String.valueOf(names.nextToken());
- }
- if(names.hasMoreTokens())
- {
- payeeSurName=String.valueOf(names.nextToken());
- }
- if(payeeFirstName.length()>11 || payeeSecondName.length()>11 || payeeThirdName.length()>11 || payeeSurName.length()>11) {
- throw new GOSIException (GOSIConstants.SEVERITY_THREE,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass ().toString (),
- "reIssueCancelledCheque ()",
- new GOSIException (),
- "SOI_ERR_5820");
- }
- contactBean.setLanguageType("E");
- }
- else
- {
- payeeName=personBean.getFullName();
- payeeFirstName = personBean.getFirstName();
- payeeSecondName = personBean.getSecondName();
- payeeThirdName = personBean.getThirdName();
- payeeSurName = personBean.getSurName();
- contactBean.setLanguageType("A");
- }
- HashMap interfaceInputMap = new HashMap();
- interfaceInputMap.put("methodDescription", FAInterfaceConstants.PAY_ONLINE_REL_HOLD_INTERFACE);
- interfaceInputMap.put(FAInterfaceConstants.BENEFICIARY_ID, contributorBean.getSocialInsuranceNumber());
- interfaceInputMap.put(FAInterfaceConstants.MODULE_ID, new Short(GOSIConstants.OCCUPATIONAL_HAZARDS_ID));
- interfaceInputMap.put(FAInterfaceConstants.RELEASE_UNTIL_DATE, currentTime);
- interfaceInputMap.put(FAInterfaceConstants.LAST_MODIFIED_BY, userId);
- interfaceInputMap.put(FAInterfaceConstants.PAYMENT_MODE, paymentModeFA);
- if(chequeCancelCode.equals(FAInterfaceConstants.BENEFICIARY_NOT_ALIVE))
- interfaceInputMap.put(FAInterfaceConstants.BENEFICIARY_NOT_ALIVE, chequeCancelCode);
- else if(chequeCancelCode.equals(FAInterfaceConstants.BENEFICIARY_LEFT_SA))
- interfaceInputMap.put(FAInterfaceConstants.BENEFICIARY_LEFT_SA, chequeCancelCode);
- interfaceInputMap.put(FAInterfaceConstants.PAYEE_FIRST_NAME, payeeFirstName);
- interfaceInputMap.put(FAInterfaceConstants.PAYEE_SECOND_NAME, payeeSecondName);
- interfaceInputMap.put(FAInterfaceConstants.PAYEE_THIRD_NAME, payeeThirdName);
- interfaceInputMap.put(FAInterfaceConstants.PAYEE_SUR_NAME, payeeSurName);
- interfaceInputMap.put(FAInterfaceConstants.PAYEE_NAME, payeeName);
- interfaceInputMap.put(FAInterfaceConstants.CONTACT_ID, contactBean.getContactId());
- interfaceInputMap.put(FAInterfaceConstants.BENADDRESS, contactBean.getFreeTextDescription());
- interfaceInputMap.put(FAInterfaceConstants.COUNTRY, contactBean.getCountry());
- interfaceInputMap.put(FAInterfaceConstants.LANGUAGE_CODE, contactBean.getLanguageType());
- //Service parameters
- GOSIDebug.debugMessages("***********************************************************");
- GOSIDebug.debugMessages("Invoking finance service: ");
- GOSIDebug.debugMessages(" param methodDescription = FAInterfaceConstants.PAY_ONLINE_REL_HOLD_INTERFACE");
- GOSIDebug.debugMessages(" param FAInterfaceConstants.BENEFICIARY_ID = " + contributorBean.getSocialInsuranceNumber());
- GOSIDebug.debugMessages(" param FAInterfaceConstants.MODULE_ID = GOSIConstants.OCCUPATIONAL_HAZARDS_ID");
- GOSIDebug.debugMessages(" param FAInterfaceConstants.RELEASE_UNTIL_DATE = " + currentTime);
- GOSIDebug.debugMessages(" param FAInterfaceConstants.LAST_MODIFIED_BY = " + userId);
- GOSIDebug.debugMessages(" param FAInterfaceConstants.PAYMENT_MODE = " + paymentModeFA);
- if(chequeCancelCode.equals(FAInterfaceConstants.BENEFICIARY_NOT_ALIVE))
- GOSIDebug.debugMessages(" param FAInterfaceConstants.BENEFICIARY_NOT_ALIVE = " + chequeCancelCode);
- else if(chequeCancelCode.equals(FAInterfaceConstants.BENEFICIARY_LEFT_SA))
- GOSIDebug.debugMessages(" param FAInterfaceConstants.BENEFICIARY_LEFT_SA = " + chequeCancelCode);
- GOSIDebug.debugMessages(" param FAInterfaceConstants.PAYEE_FIRST_NAME = " + payeeFirstName);
- GOSIDebug.debugMessages(" param FAInterfaceConstants.PAYEE_SECOND_NAME = " + payeeSecondName);
- GOSIDebug.debugMessages(" param FAInterfaceConstants.PAYEE_THIRD_NAME = " + payeeThirdName);
- GOSIDebug.debugMessages(" param FAInterfaceConstants.PAYEE_SUR_NAME = " + payeeSurName);
- GOSIDebug.debugMessages(" param FAInterfaceConstants.PAYEE_NAME = " + payeeName);
- GOSIDebug.debugMessages(" param FAInterfaceConstants.CONTACT_ID = " + contactBean.getContactId());
- GOSIDebug.debugMessages(" param FAInterfaceConstants.BENADDRESS = " + contactBean.getFreeTextDescription());
- GOSIDebug.debugMessages(" param FAInterfaceConstants.COUNTRY = " + contactBean.getCountry());
- GOSIDebug.debugMessages(" param FAInterfaceConstants.LANGUAGE_CODE = " + contactBean.getLanguageType());
- GOSIDebug.debugMessages("***********************************************************");
- FinancialAccountingInterface faInterface;
- faInterface = FinanceImplProxy.getFAInterface();
- interfaceInputMap = faInterface.invokeService(interfaceInputMap);
- if(!interfaceInputMap.isEmpty())
- {
- Iterator iterator = interfaceInputMap.keySet().iterator();
- ArrayList journalHeaderIdlist = new ArrayList();
- while(iterator.hasNext())
- {
- Long oldJournalHeaderId = null;
- oldJournalHeaderId=(Long)iterator.next();
- journalHeaderIdlist.add(oldJournalHeaderId);
- }
- ArrayList OHBenefitIdList = getOHBenefitIdList(journalHeaderIdlist);
- if(OHBenefitIdList.size()>0)
- {
- for (int i=0;i<OHBenefitIdList.size();i++)
- {
- OHAllowanceBean OHAllowanceBean1 = (OHAllowanceBean)OHBenefitIdList.get(i);
- OHAllowanceEntity remote=(OHAllowanceEntity)
- home.findByPrimaryKey(OHAllowanceBean1.getOhBenId());
- OHAllowanceBean newOHAllowanceBean = remote.getOHBenefits();
- if( interfaceInputMap.containsKey(newOHAllowanceBean.getJournalHeaderId()))
- {
- newOHAllowanceBean.setJournalHeaderId((Long)interfaceInputMap.get(newOHAllowanceBean.getJournalHeaderId()));
- newOHAllowanceBean.setBenStatus(OHConstants.OH_BNFT_STS_APPROVED);
- newOHAllowanceBean.setWorkflowStatus(OHConstants.WFS_OH_BNFT_APPROVED_INT_AUD_CLK);
- newOHAllowanceBean.setPaymentMode(paymentMode);
- newOHAllowanceBean.setLastModifiedBy(userId);
- newOHAllowanceBean.setLastModifiedTimestamp(currentTime);
- remote.modifyOHBenefits(newOHAllowanceBean);
- }
- }
- }
- }
- else
- {
- throw new GOSIException (GOSIConstants.SEVERITY_THREE,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass ().toString (),
- "reIssueCancelledCheque ()",
- new GOSIException (),
- "SOI_ERR_5610");
- }
- }
- catch (GOSIException ge)
- {
- ctx.setRollbackOnly();
- throw ge;
- }
- catch(Exception e)
- {
- ctx.setRollbackOnly();
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
- "reIssueCancelledCheque()",e,"CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp(con,ps,rs);
- }
- }
- /**
- * @METHOD NAME : saveContactDetailsContributor
- * @INFORMATION : This method is to save the contact details
- of the contributor
- * @PARAM : class java.lang.Long
- * @RETURN : class java.util.ArrayList
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- public void saveContactDetailsContributor(ArrayList contactList,
- WorkflowParamBean workflowParamBean)
- throws GOSIException
- {
- try
- {
- Long createdBy = new Long(workflowParamBean.getUserId());
- Timestamp currentTime =new Timestamp(System.currentTimeMillis());
- // this will update the contact details of the contributor
- if(contactList != null)
- {
- AuditBean contactAuditBean = new AuditBean();
- contactAuditBean.setCreatedBy(createdBy);
- contactAuditBean.setLastModifiedBy(createdBy);
- contactAuditBean.setCreationTimestamp(currentTime);
- contactAuditBean.setLastModifiedTimestamp(currentTime);
- contactAuditBean.setModuleId(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
- boolean contactflag =false;
- if((contactList!=null)&&(contactList.size()!=0))
- { int count = 0;
- for(int i=0; i<contactList.size();i++)
- {
- IndividualContactBean contactBean=
- (IndividualContactBean)contactList.get(i);
- GOSIDebug.debugMessages("mode:"+contactBean.getMode());
- if(AuditBean.DELETE_MODE != contactBean.getMode())
- {
- count=count+1;
- }
- }
- if(count==0)
- {
- contactflag = false;
- }else
- {
- contactflag=true;
- }
- }else
- {
- contactflag=false;
- }
- if(!contactflag)
- {
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
- "saveContactDetailsContributor()",null,"SOI_ERR_4406");
- }
- GOSIUtilities.modifyIndividualContactDetails(contactList,contactAuditBean);
- }
- }
- catch (GOSIException ge)
- {
- ctx.setRollbackOnly();
- throw ge;
- }
- catch(Exception e)
- {
- ctx.setRollbackOnly();
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE, this.getClass().toString(),
- "saveContactDetailsContributor()",e,"CMN_ERR_1000");
- }
- }
- /**
- * @METHOD NAME : searchInjuryMiscAllowance
- * @INFORMATION : This method is to search Injury List with sin and injurydate
- * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.InjuryPopDetails
- * @RETURN : class java.util.ArrayList
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- public ArrayList searchInjuryMiscAllowance(InjuryPopDetails searchBean)
- throws GOSIException
- {
- // get injury with status other than cancelled
- long startTime = 0;
- long endTime = 0;
- long elapsedTime = 0;
- startTime = System.currentTimeMillis();
- PreparedStatement ps = null;
- ResultSet rs =null;
- GOSIDebug.debugMessages("-----session:searchInjuryMiscAllowance-----");
- String message ="";
- Long socInsNum = searchBean.getSocialInsuranceNumber();
- Timestamp injuryDate = searchBean.getInjuryDate();
- String entFmt = searchBean.getInjuryDateEntFmt();
- GOSIDebug.debugMessages("EntFmt:"+entFmt);
- GOSIDebug.debugMessages("SIN:"+socInsNum+"\n startDate:"+injuryDate);
- String sqlQuery="";
- ArrayList injuryList=new ArrayList();
- //Query to get injurys which has trmt for the benefit period
- sqlQuery= " select "+
- " INJURYID, "+
- " SOCINSNUMBER, "+
- " CONTRIBUTORID, "+
- " ESTABLISHMENTID, "+
- " INJURYDATE, "+
- " DATECOMPLICATION, "+
- " INJURYNUMBER, "+
- " DESCRIPTION, "+
- " FIELDOFFICECODE, "+
- " INJURYSTATUS, "+
- " EMPLOYERNOTIFYDATE, "+
- " WORKERINTIMATIONDATE, "+
- " WAGESTOPDATE, "+
- " DATEOFDEATH, "+
- " (NVL(WORKDISABILITYDATE,INJURYDATE +1)) MINDISABLITYDATE, "+
- " TREATMENTSTDATE, "+
- " TREATMENTENDDATE " +
- " from "+ SITables.T_INJURY +
- " where SOCINSNUMBER=? "+
- " and INJURYDATE = ? "+
- " and INJURYSTATUS not in (?,?,?) "+
- " order by INJURYDATE ";
- GOSIDebug.debugMessages("sqlQuery :\n" +sqlQuery);
- try
- {
- Timestamp currentDate = new Timestamp(System.currentTimeMillis());
- // comparing end date with current date
- if(injuryDate.compareTo(currentDate)>0)
- {
- throw new GOSIException( GOSIConstants.SEVERITY_THREE,
- GOSIConstants.OCCUPATIONAL_HAZARDS,
- this.getClass().toString(),
- "searchInjuryList()",null,
- "SOI_ERR_4038");
- }
- con = GOSIUtilities.getConnection
- (GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
- ps=con.prepareStatement(sqlQuery);
- ps.setLong(1,socInsNum.longValue());
- ps.setTimestamp(2,injuryDate);
- ps.setShort(3,OHConstants.INJ_STS_NOTIFIED.shortValue());
- ps.setShort(4,OHConstants.INJ_STS_FIRST_NOTIFIED.shortValue());
- ps.setShort(5,OHConstants.INJ_STS_CANCELLED.shortValue());
- rs=ps.executeQuery();
- while(rs.next())
- {
- GOSIDebug.debugMessages("searchInjuryList has records");
- InjuryPopDetails injuryDetails =new InjuryPopDetails();
- injuryDetails.setInjuryID(new Long(rs.getLong("INJURYID")));
- injuryDetails.setSocialInsuranceNumber
- (new Long(rs.getLong("SOCINSNUMBER")));
- injuryDetails.setEstablishmentId
- (new Long(rs.getLong("ESTABLISHMENTID")));
- injuryDetails.setContributorId
- (new Long(rs.getLong("CONTRIBUTORID")));
- injuryDetails.setInjuryDate(rs.getTimestamp("INJURYDATE"));
- injuryDetails.setInjuryDateEntFmt(entFmt);
- if (OHConstants.HIJRAH.equals(entFmt))
- {
- injuryDetails.setInjuryDateStr
- (GOSIDateUtilities.convertToHijra(
- GOSIUtilities.getDateFullString(
- injuryDetails.getInjuryDate())));
- }
- else
- {
- injuryDetails.setInjuryDateStr
- (GOSIUtilities.getDateFullString(
- injuryDetails.getInjuryDate()));
- }
- if(rs.getObject("DATECOMPLICATION")!= null)
- {
- /* Populate data with the complication date */
- injuryDetails.setComplicationDate
- (rs.getTimestamp("DATECOMPLICATION"));
- if (OHConstants.HIJRAH.equalsIgnoreCase (injuryDetails.getInjuryDateEntFmt ()))
- {
- injuryDetails.setComplicationDateStr
- (GOSIDateUtilities.convertToHijra(
- GOSIUtilities.getDateFullString(
- injuryDetails.getComplicationDate())));
- }
- else
- {
- injuryDetails.setComplicationDateStr
- (GOSIUtilities.getDateFullString(injuryDetails.getComplicationDate()));
- }
- }
- injuryDetails.setInjuryNumber
- (new Long(rs.getLong("INJURYNUMBER")));
- GOSIDebug.debugMessages("injury number:"+injuryDetails.getInjuryNumber());
- injuryDetails.setDescription(rs.getString("DESCRIPTION"));
- injuryDetails.setFieldOffice
- (new Short(rs.getShort("FIELDOFFICECODE")));
- injuryDetails.setInjuryStatus
- (new Short(rs.getString("INJURYSTATUS")));
- if(rs.getObject("EMPLOYERNOTIFYDATE")!= null)
- {
- injuryDetails.setEmployerNotifyDate
- (rs.getTimestamp("EMPLOYERNOTIFYDATE"));
- }
- if(rs.getObject("WORKERINTIMATIONDATE")!= null)
- {
- injuryDetails.setWorkerIntimationDate
- (rs.getTimestamp("WORKERINTIMATIONDATE"));
- }
- if(rs.getObject("WAGESTOPDATE")!= null)
- {
- injuryDetails.setWageStopDate
- (rs.getTimestamp("WAGESTOPDATE"));
- }
- if(rs.getObject("TREATMENTSTDATE")!= null)
- {
- injuryDetails.setTreatmentStartDate
- (rs.getTimestamp("TREATMENTSTDATE"));
- }
- if(rs.getObject("TREATMENTENDDATE")!= null)
- {
- injuryDetails.setTreatmentEndDate
- (rs.getTimestamp("TREATMENTENDDATE"));
- }
- if(rs.getObject("MINDISABLITYDATE")!=null)
- {
- injuryDetails.setWorkDisabilityDate
- (rs.getTimestamp("MINDISABLITYDATE"));
- }
- if(rs.getObject("DATEOFDEATH")!= null)
- {
- injuryDetails.setDeathDate(rs.getTimestamp("DATEOFDEATH"));
- }
- // setting contributor details
- injuryDetails = setContributorDetails(injuryDetails);
- // setting establishment details
- injuryDetails=setEstablishmentDetails(injuryDetails);
- GOSIDebug.debugMessages("pay to SI: "
- +injuryDetails.getBenefitPayableTo());
- injuryList.add(injuryDetails);
- // adding injurydetails to list for multiple injuryies
- }
- int injuryListSize =injuryList.size();
- if(injuryListSize==0)
- {
- throw new GOSIException( GOSIConstants.SEVERITY_FOUR,
- GOSIConstants.OCCUPATIONAL_HAZARDS,
- this.getClass().toString(),
- "searchInjuryList()",null,
- "SOI_ERR_4762");
- }
- for(int i=0;i<injuryListSize;i++)
- {
- InjuryPopDetails injuryDetails =
- (InjuryPopDetails)injuryList.get(i);
- GOSIDebug.debugMessages("injury number:"+injuryDetails.getInjuryNumber());
- if(injuryDetails.getInjuryStatus().equals
- (OHConstants.INJ_STS_NOTIFIED))
- {
- // UnApproved Injury Details found for the
- // period entered, Please redefine your calculation period
- // or Approve the Injury record
- throw new GOSIException( GOSIConstants.SEVERITY_FOUR,
- GOSIConstants.OCCUPATIONAL_HAZARDS,
- this.getClass().toString(),
- "searchInjuryList()",null,
- "SOI_ERR_5189");
- }else
- {
- //setting injury date to complication date
- // if complication date is not null and
- // the person is having a valid engagement on complication date
- Timestamp tempInjuryDate = injuryDetails.getInjuryDate();
- if(injuryDetails.getComplicationDate()!=null)
- {
- if(injuryDetails.getIsEngagementPresentOnComplicationAndEligibleForOH())
- {
- tempInjuryDate = injuryDetails.getComplicationDate();
- }
- //setting wage for the injured engagement
- injuryDetails = setTotalConWage(tempInjuryDate,injuryDetails);
- }else
- {
- //setting wage for the injured engagement
- injuryDetails = setTotalConWage(tempInjuryDate,injuryDetails);
- }
- }
- }
- // calculating the total contributory wage
- injuryList=getTotalContributorWage(injuryList);
- endTime = System.currentTimeMillis();
- elapsedTime = endTime - startTime;
- GOSIInstrumentationLog.writeInstrumentationToLog(
- this.getClass().toString(),
- "searchInjuryMiscAllowance()",
- elapsedTime);
- }
- catch (GOSIException ge)
- {
- throw ge;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("session:searchInjuryMiscAllowance:e:"+e);
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass().toString(),
- "searchInjuryMiscAllowance()",e,
- "CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp(con, ps, rs);
- }
- return injuryList ;
- }
- /**
- * @METHOD NAME : isValidMiscBenefit
- * @INFORMATION : This method is to validate the misc benefit entered
- * @PARAM : class gosi.business.socialinsurance.occupationalhazards.injury.beans.InjuryPopDetails
- * @RETURN : class java.util.ArrayList
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- public OHAllowanceBean isValidMiscBenefit(OHAllowanceBean benefitBean,
- InjuryPopDetails injuryBean)
- throws GOSIException
- {
- try
- {
- long startTime = 0;
- long endTime = 0;
- long elapsedTime = 0;
- startTime = System.currentTimeMillis();
- Timestamp tempDate = null;
- Timestamp currentDate = new Timestamp(startTime);
- // if benefit end date after current date
- if(benefitBean.getBenEndDateGreg().after(currentDate))
- {
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass().toString(),
- "isValidMiscBenefit()",null,
- "SOI_ERR_4189");
- }
- // if benefit end date before start date
- if(benefitBean.getBenEndDateGreg().before(benefitBean.getBenStDateGreg()))
- {
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass().toString(),
- "isValidMiscBenefit()",null,
- "SOI_ERR_4190");
- }
- // if complication date is not null temp date is complication date
- // else injury date
- if(injuryBean.getComplicationDate()!= null)
- {
- tempDate = injuryBean.getComplicationDate();
- }else
- {
- tempDate = injuryBean.getInjuryDate();
- }
- // if benefit start date after temp date (injury/ complication date)
- if(tempDate.after(benefitBean.getBenStDateGreg()))
- {
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass().toString(),
- "isValidMiscBenefit()",null,
- "SOI_ERR_5551");
- }
- // if injury status is approved and benefit enddate after treatment end date
- // not a valid benefit enter treatment first
- if(OHConstants.INJ_STS_APPROVED.equals(injuryBean.getInjuryStatus())
- ||OHConstants.INJ_STS_CURED_WITHOUT_DISABILITY.equals(injuryBean.getInjuryStatus()))
- {
- if(benefitBean.getBenEndDateGreg().after(injuryBean.getTreatmentEndDate()))
- {
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass().toString(),
- "isValidMiscBenefit()",null,
- "SOI_ERR_5552");
- }
- }
- // if injury status equals resulted in death no payment shd be after the
- // death date
- if(OHConstants.INJ_STS_RESULTED_IN_DEATH.equals(injuryBean.getInjuryStatus()))
- {
- if(benefitBean.getBenEndDateGreg().after(
- injuryBean.getDeathDate()))
- {
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass().toString(),
- "isValidMiscBenefit()",null,
- "SOI_ERR_5554");
- }
- }
- // if benefit started before the treatment ,enter allowance as a missed period
- if(benefitBean.getBenStDateGreg().before(injuryBean.getTreatmentStartDate()))
- {
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass().toString(),
- "isValidMiscBenefit()",null,
- "SOI_ERR_5553");
- }
- endTime = System.currentTimeMillis();
- elapsedTime = endTime - startTime;
- GOSIInstrumentationLog.writeInstrumentationToLog(
- this.getClass().toString(),
- "isValidMiscBenefit()",
- elapsedTime);
- }
- catch(GOSIException ge)
- {
- GOSIDebug.debugMessages("session:isValidMiscBenefit:ge:"+ge);
- throw ge;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("session:isValidMiscBenefit:e:"+e);
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass().toString(),
- "isValidMiscBenefit()",e,
- "CMN_ERR_1000");
- }
- return benefitBean ;
- }
- /**
- * @METHOD NAME : saveMiscOHAllowance
- * @INFORMATION : This method is to save Miscellaneous OH Allowance into the T_ohbenefit table
- * @PARAM : class java.util.ArrayList,
- class gosi.core.workflow.beans.WorkflowParamBean,
- class java.lang.Long
- * @RETURN : class java.lang.String
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- public String saveMiscOHAllowance(InjuryPopDetails injuryBean,
- ArrayList benefitList,ArrayList contactList,
- WorkflowParamBean workflowParamBean,
- DMSRequestHeaderBean headerBean)
- throws GOSIException
- {
- long startTime = 0;
- long endTime = 0;
- long elapsedTime = 0;
- startTime = System.currentTimeMillis();
- double totalAmount = 0.00;
- String message = "";
- try
- {
- GOSIDebug.debugMessages(""+OHConstants.OH_ALLOWANCE_ENTITY_JNDI);
- OHAllowanceEntityHome home=(OHAllowanceEntityHome)
- ServiceLocator.getInstance().getRemoteHome(
- OHConstants.OH_ALLOWANCE_ENTITY_JNDI,
- OHAllowanceEntityHome.class);
- Timestamp currentTime=new Timestamp (System.currentTimeMillis());
- Long workflowId = GOSIUtilities.getPrimaryKey
- ("OHBNFTWORKFLOWID",new Long(workflowParamBean.getUserId()));
- for(int i=0;i<benefitList.size();i++)
- {
- OHAllowanceBean benefitBean=(OHAllowanceBean)benefitList.get(i);
- benefitBean.setOhBenId(GOSIUtilities.getPrimaryKey
- ("T_OHBENEFIT",new Long(workflowParamBean.getUserId())));
- benefitBean.setContributorId(injuryBean.getContributorId());
- benefitBean.setInjuryId(injuryBean.getInjuryID());
- benefitBean.setFieldofficeCode(workflowParamBean.getUserLocationId());
- benefitBean.setBenStatus(OHConstants.OH_BNFT_STS_ENTERED);
- if(benefitBean.getBenAmount().doubleValue() > 0.00)
- {
- benefitBean.setWorkflowStatus(OHConstants.WFS_OH_BNFT_ENTERED);
- }
- else if(benefitBean.getBenAmount().doubleValue() < 0.00)
- {
- benefitBean.setWorkflowStatus(OHConstants.WFS_OH_BNFT_RECOVER);
- }
- benefitBean.setTotalContWage(injuryBean.getTotalConWage());
- benefitBean.setWorkflowId(workflowId);
- benefitBean.setCreatedBy(new Long(workflowParamBean.getUserId()));
- benefitBean.setCreationTimestamp(currentTime);
- if(OHConstants.OH_BNFT_PAY_TO_EMP.equals(benefitBean.getBenefitPayableTo()))
- {
- benefitBean.setPartyCode(injuryBean.getRegistrationNumber());
- }else
- {
- benefitBean.setPartyCode(injuryBean.getSocialInsuranceNumber());
- }
- }
- // checking if an autorized person is present
- // if mode is OH_BNFT_PAY_TO_AUTH_PERSON
- for(int i=0;i<benefitList.size();i++)
- {
- OHAllowanceBean benefitBean=(OHAllowanceBean)benefitList.get(i);
- if(OHConstants.OH_BNFT_PAY_TO_AUTH_PERSON.equals(benefitBean.getBenefitPayableTo()))
- {
- isAuthPersonPresent(benefitBean.getContributorId());
- break;
- }
- }
- // validating the contact details of the contributor
- validateContactDetails(contactList,benefitList);
- // check for overlapping misc benefits
- if(hasOverlappingMiscBenefits(benefitList))
- {
- throw new GOSIException (GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass().toString(),
- "saveMiscOHAllowance()",
- new Exception ("Given benefit periods are overlapping"),
- "SOI_ERR_5653");
- }
- else
- {
- ArrayList allMiscBenefits = new ArrayList ();
- allMiscBenefits.addAll (benefitList);
- allMiscBenefits.addAll (getMiscBenefitList (injuryBean.getInjuryID()));
- if(hasOverlappingMiscBenefits(allMiscBenefits))
- {
- throw new GOSIException (GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass().toString(),
- "saveMiscOHAllowance()",
- new Exception ("Misc benefits for given period were already entered"),
- "SOI_ERR_5652");
- }
- }
- //inserting benefit details into the T_ohbenefit table
- for(int i=0;i<benefitList.size();i++)
- {
- OHAllowanceBean benefitBean=(OHAllowanceBean)benefitList.get(i);
- OHAllowanceEntity remoteEntity=(OHAllowanceEntity)home.create(benefitBean);
- GOSIDebug.debugMessages("After calling entity:" + remoteEntity);
- }
- HashMap updateRecoveryMap = updateRecovery(benefitList,workflowParamBean,injuryBean);
- totalAmount = ((Double)updateRecoveryMap.get("totalAmount")).doubleValue();
- message = GOSIErrorMessages.getErrorDesc("SOI_ERR_5194");
- //calling the workflow interface
- if(totalAmount > 0 && workflowParamBean!=null)
- {
- workflowParamBean.setPrimaryKeyOfTherecord(workflowId.toString());
- String userName = GOSIUtilities.startWorkflow(workflowParamBean);
- GOSIDebug.debugMessages("user :" + userName);
- message = message + " " + userName;
- }
- if(null != updateRecoveryMap.get("workFlowEmployer"))
- {
- message = message + " : " + (String)updateRecoveryMap.get("workFlowEmployer");
- }
- if(null != updateRecoveryMap.get("workFlowContributor"))
- {
- message = message + " : " + (String)updateRecoveryMap.get("workFlowContributor");
- }
- // the DMS key values are set and the dms interface called
- if(headerBean != null)
- {
- headerBean.setSourceRecordId
- ("" + injuryBean.getInjuryID());
- headerBean.
- setSourceTable(SITables.T_INJURY);
- headerBean.setCreatedBy
- (new Long (workflowParamBean.getUserId()));
- headerBean.setKeyList(DMSConstants.SI_NUMBER,
- "" + injuryBean.getSocialInsuranceNumber());
- headerBean.setKeyList(DMSConstants.REGISTRATION_NUMBER,
- "" + injuryBean.getRegistrationNumber());
- headerBean.setKeyList(DMSConstants.INJURY_NUMBER,
- "" + injuryBean.getInjuryNumber());
- DMSUtilities.startDMS(headerBean);
- }
- endTime = System.currentTimeMillis();
- elapsedTime = endTime - startTime;
- GOSIInstrumentationLog.writeInstrumentationToLog(
- this.getClass().toString(),
- "saveMiscOHAllowance()",
- elapsedTime);
- return message;
- }
- catch(GOSIException gosiException)
- {
- GOSIDebug.debugMessages("session:saveMiscOHAllowance:ge:message:" +
- gosiException.getMessage());
- ctx.setRollbackOnly();
- throw gosiException;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("session:saveMiscOHAllowance: :The exception is "+e);
- ctx.setRollbackOnly();
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "saveMiscOHAllowance()",e,"CMN_ERR_1000");
- }
- }
- /**
- * @METHOD NAME : hasOverlappingMiscBenefits
- * @INFORMATION : This method is to check for overlapping misc benefits
- * @PARAM : class java.util.ArrayList
- * @RETURN : void
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private boolean hasOverlappingMiscBenefits (ArrayList benefitList) throws GOSIException
- {
- boolean hasOverlappingMiscBenefits = false;
- try
- {
- main_loop:
- for (int i = 0; i < benefitList.size () - 1; i++)
- {
- OHAllowanceBean miscBenefitBean = (OHAllowanceBean) benefitList.get (i);
- if (OHConstants.OH_BNFT_STS_CANCELLED.equals(miscBenefitBean.getBenStatus()) || miscBenefitBean.getMode() == miscBenefitBean.DELETE_MODE)
- {
- continue;
- }
- for (int j = i + 1; j < benefitList.size (); j++)
- {
- OHAllowanceBean benefitBean = (OHAllowanceBean) benefitList.get (j);
- if (OHConstants.OH_BNFT_STS_CANCELLED.equals(benefitBean.getBenStatus()) || benefitBean.getMode() == benefitBean.DELETE_MODE)
- {
- continue;
- }
- if (benefitBean.getInjuryId().equals(miscBenefitBean.getInjuryId()))
- {
- if (miscBenefitBean.getBenStDateGreg().after(benefitBean.getBenEndDateGreg()) ||
- miscBenefitBean.getBenEndDateGreg().before(benefitBean.getBenStDateGreg()))
- {
- continue;
- }
- hasOverlappingMiscBenefits = true;
- break main_loop;
- }
- }
- }
- }
- catch (Exception e)
- {
- throw new GOSIException (GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass().toString(),
- "hasOverlappingMiscBenefits ()",
- e,
- "CMN_ERR_1000");
- }
- return hasOverlappingMiscBenefits;
- }
- /**
- * @METHOD NAME : getMiscBenefitList
- * @INFORMATION : This method is to get Misc Benefit List
- * @PARAM : class java.lang.Long
- * @RETURN : class java.util.ArrayList
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- public ArrayList getMiscBenefitList (Long injuryId) throws GOSIException
- {
- ArrayList miscBenefitList = new ArrayList ();
- PreparedStatement ps = null;
- ResultSet rs = null;
- try
- {
- con = GOSIUtilities.getConnection (GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
- String sqlQuery = "SELECT ohbenid, injuryid, contributorid, fieldofficecode, ohbencode, "
- + " ohbentype, benstdate, benstdateentfmt, benenddate, benenddateentfmt, "
- + " benamount, benstatus, paymentmode, bankcode, bankaccnumber, "
- + " datepayment, datepaymententfmt, workflowstatus, totalcontwage, "
- + " workflowid, rejectioncode, payableto, partycode, description, "
- + " createdby, creationtimestamp, lastmodifiedby, lastmodifiedtimestamp "
- + " FROM " + SITables.T_OHBENEFIT
- + " WHERE ohbencode = ? AND benstatus <> ? AND injuryid = ?";
- ps = con.prepareStatement (sqlQuery);
- ps.setShort (1, OHConstants.OH_ALWNC_MISCELLANEOUS.shortValue ());
- ps.setShort (2, OHConstants.OH_BNFT_STS_CANCELLED.shortValue ());
- ps.setLong (3, injuryId.longValue ());
- rs = ps.executeQuery ();
- while (rs.next())
- {
- OHAllowanceBean benefitBean = new OHAllowanceBean ();
- benefitBean.setOhBenId (new Long(rs.getLong("OHBENID")));
- benefitBean.setInjuryId (new Long(rs.getLong("INJURYID")));
- benefitBean.setContributorId (new Long(rs.getLong("CONTRIBUTORID")));
- benefitBean.setFieldofficeCode (new Short(rs.getShort("FIELDOFFICECODE")));
- benefitBean.setOhBenCode (new Short(rs.getShort("OHBENCODE")));
- benefitBean.setOhBenType (rs.getString("OHBENTYPE"));
- benefitBean.setBenStDateGreg (rs.getTimestamp("BENSTDATE"));
- benefitBean.setBenStDateEntFmt (rs.getString("BENSTDATEENTFMT"));
- benefitBean.setBenEndDateGreg (rs.getTimestamp("BENENDDATE"));
- benefitBean.setBenEndDateEntFmt (rs.getString("BENENDDATEENTFMT"));
- benefitBean.setBenAmount (new Double(rs.getDouble("BENAMOUNT")));
- benefitBean.setBenStatus (new Short(rs.getShort("BENSTATUS")));
- if (rs.getObject("PAYMENTMODE") != null)
- {
- benefitBean.setPaymentMode (new Short(rs.getShort("PAYMENTMODE")));
- }
- if (rs.getObject("BANKCODE") != null)
- {
- benefitBean.setBankCode (new Integer(rs.getInt("BANKCODE")));
- }
- if (rs.getObject("BANKACCNUMBER") != null)
- {
- benefitBean.setBankAccNumber (new Long(rs.getLong("BANKACCNUMBER")));
- }
- if (rs.getObject("DATEPAYMENT") != null)
- {
- benefitBean.setDatePaymentGreg (rs.getTimestamp("DATEPAYMENT"));
- benefitBean.setDatePaymentEntFmt (rs.getString("DATEPAYMENTENTFMT"));
- }
- benefitBean.setWorkflowStatus (new Short(rs.getShort("WORKFLOWSTATUS")));
- benefitBean.setTotalContWage (new Double(rs.getDouble("TOTALCONTWAGE")));
- if (rs.getObject("WORKFLOWID") != null)
- {
- benefitBean.setWorkflowId (new Long(rs.getLong("WORKFLOWID")));
- }
- if (rs.getObject("REJECTIONCODE") != null)
- {
- benefitBean.setRejectionCode (new Short(rs.getShort("REJECTIONCODE")));
- }
- if (rs.getObject("PARTYCODE") != null)
- {
- benefitBean.setPartyCode (new Long (rs.getLong("PARTYCODE")));
- }
- if (rs.getObject("PAYABLETO") != null)
- {
- benefitBean.setBenefitPayableTo (new Short (rs.getShort("PAYABLETO")));
- }
- if (rs.getObject("DESCRIPTION") != null)
- {
- benefitBean.setDescription (rs.getString("DESCRIPTION"));
- }
- benefitBean.setCreatedBy (new Long(rs.getLong("CREATEDBY")));
- benefitBean.setCreationTimestamp (rs.getTimestamp("CREATIONTIMESTAMP"));
- if (rs.getObject("LASTMODIFIEDBY") != null)
- {
- benefitBean.setLastModifiedBy (new Long(rs.getLong("LASTMODIFIEDBY")));
- benefitBean.setLastModifiedTimestamp (rs.getTimestamp("LASTMODIFIEDTIMESTAMP"));
- }
- /**
- * Add misc. benefit to the list
- */
- miscBenefitList.add (benefitBean);
- }
- }
- catch (GOSIException ge)
- {
- throw ge;
- }
- catch (Exception e)
- {
- throw new GOSIException (GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass().toString(),
- "getMiscBenefitList ()",
- e,
- "CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp (con, ps, rs);
- }
- return miscBenefitList;
- }
- /**
- * @METHOD NAME : updateRecovery
- * @INFORMATION : This method is to update Recovery
- * @PARAM : class java.util.ArrayList,
- class gosi.core.workflow.beans.WorkflowParamBean,
- class gosi.business.socialinsurance.occupationalhazards.injury.beans.InjuryBean
- * @RETURN : class java.util.HashMap
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private HashMap updateRecovery(ArrayList benefitList,
- WorkflowParamBean workflowParamBean,
- InjuryPopDetails injuryBean) throws GOSIException
- {
- double totalAmount = 0.00;
- String workFlowEmployer = null;
- String workFlowContributor = null;
- HashMap updateRecoveryMap = new HashMap();
- try
- {
- for(int i=0; i < benefitList.size(); i++)
- {
- OHAllowanceBean benefitBean = (OHAllowanceBean) benefitList.get(i);
- totalAmount += benefitBean.getBenAmount().doubleValue();
- }
- if(totalAmount < 0)
- {
- ArrayList recEmpList = new ArrayList();
- ArrayList recConList = new ArrayList();
- double recEmpAmount = 0.00;
- double recConAmount = 0.00;
- for(int i=0;i<benefitList.size();i++)
- {
- OHAllowanceBean benefitBean = (OHAllowanceBean)benefitList.get(i);
- if(OHConstants.OH_BNFT_PAY_TO_CON.equals(benefitBean.getBenefitPayableTo()) ||
- OHConstants.OH_BNFT_PAY_TO_AUTH_PERSON.equals(benefitBean.getBenefitPayableTo()))
- {
- recConList.add(benefitBean);
- recConAmount += benefitBean.getBenAmount().doubleValue();
- }
- else if(OHConstants.OH_BNFT_PAY_TO_EMP.equals(benefitBean.getBenefitPayableTo()))
- {
- recEmpList.add(benefitBean);
- recEmpAmount += benefitBean.getBenAmount().doubleValue();
- }
- }
- if(recEmpList.size() > 0 && recEmpAmount < 0 )
- {
- Long recEmpWorkflowId = GOSIUtilities.getPrimaryKey("RECFROMEMPWORKFLOWID",new Long (workflowParamBean.getUserId()));
- Long recInjuryId = null;
- ArrayList recoverFromEmployerList = new ArrayList();
- for (int i=0;i<recEmpList.size();i++)
- {
- OHAllowanceBean benefitBean = (OHAllowanceBean)recEmpList.get(i);
- RecEmployerBean recEmpBean = new RecEmployerBean();
- recEmpBean.setRecID(GOSIUtilities.getPrimaryKey("T_RECFROMEMP",new Long (workflowParamBean.getUserId())));
- recEmpBean.setOhBenID(benefitBean.getOhBenId());
- recEmpBean.setWorkFlowID(recEmpWorkflowId);
- recEmpBean.setEstablishmentID(injuryBean.getEstablishmentId());
- if(benefitBean.getBenAmount()!=null)
- {
- recEmpBean.setAmountDue(new Double(Math.abs(benefitBean.getBenAmount().doubleValue())));
- }else
- {
- recEmpBean.setAmountDue(new Double("0"));
- }
- recEmpBean.setAmountReceived(new Double("0"));
- recEmpBean.setStatus(OHConstants.REC_FROM_EMP_ENTERED);
- recEmpBean.setRequestDate(new Timestamp(System.currentTimeMillis()));
- recEmpBean.setRequestDateEntFmt(OHConstants.GREGORIAN);
- recEmpBean.setWorkflowStatus(OHConstants.REC_FROM_EMP_CLERK_ENT);
- recEmpBean.setCreatedBy(new Long(workflowParamBean.getUserId()));
- recEmpBean.setRecoveryType(OHConstants.RECOVERY_TYPE_OH_BENEFIT);
- recEmpBean.setInjuryId(benefitBean.getInjuryId());
- recInjuryId = benefitBean.getInjuryId();
- recEmpBean.setCreationTimestamp(new Timestamp(System.currentTimeMillis()));
- recEmpBean.setLocationCode(workflowParamBean.getUserLocationId());
- recoverFromEmployerList.add(recEmpBean);
- }
- createRecFromEmp(recoverFromEmployerList);
- workflowParamBean.setPrimaryKeyOfTherecord(recEmpWorkflowId.toString() + "~" + recInjuryId.toString());
- workflowParamBean.setModuleId(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
- workflowParamBean.setStepShortName("REC_FROM_EMPLOYER");
- workflowParamBean.setrecordDescription(GOSIErrorMessages.getErrorDesc("SOI_ERR_4360") + " - " + injuryBean.getRegistrationNumber());
- workflowParamBean.setRoutingCriterion(GOSIConstants.COMPLETED);
- workFlowEmployer = GOSIUtilities.startWorkflow(workflowParamBean);
- }
- if (recConList.size() > 0 && recConAmount < 0)
- {
- Long recInjuryId = null;
- Long recConWorkflowId = GOSIUtilities.getPrimaryKey("RECFROMCONWORKFLOWID",new Long (workflowParamBean.getUserId()));
- ArrayList recoverContributorList = new ArrayList();
- for(int i=0; i<recConList.size(); i++)
- {
- OHAllowanceBean benefitBean = (OHAllowanceBean)recConList.get(i);
- RecFromContributorHeaderBean recConBean = new RecFromContributorHeaderBean();
- recConBean.setOHBenID(benefitBean.getOhBenId());
- recConBean.setWorkFlowID(recConWorkflowId);
- recConBean.setRecID(GOSIUtilities.getPrimaryKey("T_RECFROMCONTRIBUTOR",new Long (workflowParamBean.getUserId())));
- if(benefitBean.getBenAmount()!=null)
- {
- recConBean.setAmountReceived(new Double(Math.abs(benefitBean.getBenAmount().doubleValue())));
- }else
- {
- recConBean.setAmountReceived(new Double("0"));
- }
- recConBean.setFromDateGreg(benefitBean.getBenStDateGreg());
- recConBean.setFromDateEntFmt(OHConstants.GREGORIAN);
- recConBean.setToDateGreg(benefitBean.getBenEndDateGreg());
- recConBean.setToDateEntFmt(OHConstants.GREGORIAN);
- recConBean.setRequestDate(new Timestamp(System.currentTimeMillis()));
- recConBean.setRequestDateEntFmt(OHConstants.GREGORIAN);
- recConBean.setWorkflowStatus(OHConstants.REC_FROM_CON_CLERK_ENT);
- recConBean.setCreatedBy(new Long(workflowParamBean.getUserId()));
- recInjuryId = benefitBean.getInjuryId();
- recConBean.setCreationTimestamp(new Timestamp(System.currentTimeMillis()));
- recoverContributorList.add(recConBean);
- }
- createRecFromCon(recoverContributorList);
- workflowParamBean.setPrimaryKeyOfTherecord(recConWorkflowId.toString());
- workflowParamBean.setModuleId(GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
- workflowParamBean.setStepShortName("REC_FROM_CONTRIBUTOR");
- workflowParamBean.setrecordDescription(GOSIErrorMessages.getErrorDesc("SOI_ERR_4701") + " - " + injuryBean.getSocialInsuranceNumber());
- workflowParamBean.setRoutingCriterion(GOSIConstants.COMPLETED);
- workFlowContributor = GOSIUtilities.startWorkflow(workflowParamBean);
- }
- }
- updateRecoveryMap.put("totalAmount",new Double(totalAmount));
- updateRecoveryMap.put("workFlowEmployer",workFlowEmployer);
- updateRecoveryMap.put("workFlowContributor",workFlowContributor);
- }
- catch (GOSIException ge)
- {
- GOSIDebug.debugMessages("session:updateRecovery:ge:"+ge);
- throw ge;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("session:updateRecovery:e:"+e);
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass().toString(),
- "updateRecovery()",e,
- "CMN_ERR_1000");
- }
- return updateRecoveryMap;
- }
- /**
- * @METHOD NAME : getContributorIdList
- * @INFORMATION : This method is to get the contributor list using
- mergedSocialInsuranceNumber
- * @PARAM : class java.lang.Long
- * @RETURN : class java.util.ArrayList
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private ArrayList getContributorIdList(Long mergedSocialInsuranceNumber)
- throws GOSIException
- {
- ArrayList contributorIdList = new ArrayList();
- ResultSet rsContributorList = null;
- PreparedStatement psContributorList = null;
- StringBuffer sqlQuery = new StringBuffer();
- Connection conContributorList = null;
- GOSIDebug.debugMessages("Start getContributorIdList - MaintainOHAllowanceSessionEJB");
- try
- {
- /*
- * Get the list of contributorid from T_CONTRIBUTOR with
- * mergedsocialinsurancenumber and store it in the list.
- */
- sqlQuery.append("SELECT");
- sqlQuery.append(" CONTRIBUTORID");
- sqlQuery.append(" FROM ");
- sqlQuery.append(SITables.T_CONTRIBUTOR);
- sqlQuery.append(" WHERE ");
- sqlQuery.append("MERGEDSOCIALINSURANCENUMBER = ? ");
- GOSIDebug.debugMessages("SqlQuery :" + sqlQuery.toString() + ":");
- GOSIDebug.debugMessages("\t\t Param 1 :" +
- mergedSocialInsuranceNumber.longValue() + ":");
- conContributorList = GOSIUtilities.getConnection(
- GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
- psContributorList = con.prepareStatement(sqlQuery.toString());
- psContributorList.setLong(1,mergedSocialInsuranceNumber.longValue());
- GOSIDebug.debugMessages("Start Time:" + System.currentTimeMillis());
- rsContributorList = psContributorList.executeQuery();
- GOSIDebug.debugMessages("End Time:" + System.currentTimeMillis());
- while(rsContributorList.next())
- {
- contributorIdList.add(new Long(
- rsContributorList.getLong("CONTRIBUTORID")));
- GOSIDebug.debugMessages("Contributorid :" +
- rsContributorList.getString("CONTRIBUTORID") + ":");
- }
- }
- catch(GOSIException ge)
- {
- GOSIDebug.debugMessages("Error Getting ContributorList :" +
- ge.getMessage() + ":");
- throw ge;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("Error Getting ContributorList :" +
- e.getMessage() + ":");
- throw new GOSIException( GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "getContributorIdList()",e,"CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp(conContributorList,psContributorList,
- rsContributorList);
- }
- GOSIDebug.debugMessages("End getContributorIdList - MaintainOHAllowanceSessionEJB");
- return contributorIdList;
- }
- /**
- * @METHOD NAME : distributeWageToEstablishments
- * @INFORMATION : This method is to distribute the wage to establishment
- and to the contributor based on the wagestop date.
- * @PARAM : class java.lang.Long
- * @RETURN : class java.util.ArrayList
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private ArrayList distributeWageToEstablishments(ArrayList benefitList,
- ArrayList injuryList) throws GOSIException
- {
- GOSIDebug.debugMessages("\t\t Start distributeWageToEstablisments - MaintainOHAllowanceSessionEJB");
- ArrayList benList = new ArrayList();
- Timestamp wageStopDate = null;
- Double totalConWage = null;
- InjuryPopDetails injuryDetails = (InjuryPopDetails)injuryList.get(0);
- wageStopDate = injuryDetails.getWageStopDate();
- totalConWage = injuryDetails.getTotalConWage();
- GOSIDebug.debugMessages("WageStopDate:" + wageStopDate + ":");
- GOSIDebug.debugMessages("TotalContWage:" + totalConWage + ":");
- GOSIDebug.debugMessages("Initial BenefitListSize:" + benefitList.size() + ":");
- if(wageStopDate != null && !totalConWage.equals(injuryDetails.getInjuredEstablishmentWage()))
- {
- Double benefitAmount = null;
- GOSIDebug.debugMessages("Wage Stop date is Not Null");
- for(int i =0;i<benefitList.size();i++)
- {
- OHAllowanceBean benefitBean = (OHAllowanceBean)benefitList.get(i);
- if(OHConstants.OH_BNFT_PAY_TO_EMP.equals(benefitBean.getBenefitPayableTo()))
- {
- OHAllowanceBean newBenefitBean = new OHAllowanceBean(benefitBean);
- newBenefitBean.setBenefitPayableTo(OHConstants.OH_BNFT_PAY_TO_CON);
- double localBenefitAmount = (injuryDetails.getInjuredEstablishmentWage().doubleValue() / totalConWage.doubleValue()) * benefitBean.getBenAmount().doubleValue();
- benefitAmount = new Double(localBenefitAmount);
- GOSIDebug.debugMessages("SplitedBenefitAmount :" + benefitAmount + ":");
- newBenefitBean.setBenAmount(new Double(benefitBean.getBenAmount().doubleValue() - benefitAmount.doubleValue()));
- benefitBean.setBenAmount(benefitAmount);
- benList.add(newBenefitBean);
- }
- benList.add(benefitBean);
- }
- }
- else
- {
- GOSIDebug.debugMessages("InjuredEstablishmentWage :"+ injuryDetails.getInjuredEstablishmentWage() +":");
- GOSIDebug.debugMessages("InjuredEstablishmentPayableTo :"+ injuryDetails.getInjuredEstablishmentBenefitPayableTo() +":");
- if(!totalConWage.equals(injuryDetails.getInjuredEstablishmentWage())
- && OHConstants.OH_BNFT_PAY_TO_EMP.equals(
- injuryDetails.getInjuredEstablishmentBenefitPayableTo()))
- {
- Double benefitAmount = null;
- //Split the benefit amount into two.
- /*Change the benefitbean's and new benefitBean's amount based on the total
- amount calculation
- */
- //Payment Calculation to the InjuredEstablishment.
- for(int i =0;i<benefitList.size();i++)
- {
- OHAllowanceBean benefitBean = (OHAllowanceBean)benefitList.get(i);
- OHAllowanceBean newBenefitBean = new OHAllowanceBean(benefitBean);
- if(OHConstants.OH_ALWNC_DAIlY_INPATIENT.equals(benefitBean.getOhBenCode())
- || OHConstants.OH_ALWNC_DAIlY_OUTPATIENT.equals(benefitBean.getOhBenCode()))
- {
- newBenefitBean.setBenefitPayableTo(OHConstants.OH_BNFT_PAY_TO_EMP);
- double localBenefitAmount = (injuryDetails.getInjuredEstablishmentWage().doubleValue() / totalConWage.doubleValue()) * benefitBean.getBenAmount().doubleValue();
- benefitAmount = new Double(localBenefitAmount);
- GOSIDebug.debugMessages("SplitedBenefitAmount :" + benefitAmount + ":");
- newBenefitBean.setBenAmount(benefitAmount);
- benefitBean.setBenAmount(new Double(benefitBean.getBenAmount().doubleValue() - benefitAmount.doubleValue()));
- benList.add(newBenefitBean);
- }
- benList.add(benefitBean);
- }
- }
- else
- {
- benList = benefitList;
- }
- }
- GOSIDebug.debugMessages("=========Final BenefitList Size:" + benList.size() + ":");
- GOSIDebug.debugMessages("\t\t End distributeWageToEstablisments - MaintainOHAllowanceSessionEJB");
- return benList;
- }
- private Timestamp getWageStopDate(Long injuryid) throws GOSIException
- {
- PreparedStatement ps = null;
- ResultSet rs = null;
- StringBuffer sqlQuery = new StringBuffer();
- Timestamp wageStopDate = null;
- GOSIDebug.debugMessages("\t\t Start getWageStopDate - MaintainOHAllowanceSessionEJB");
- try
- {
- sqlQuery.append("SELECT WAGESTOPDATE FROM T_INJURY WHERE INJURYID = ?");
- GOSIDebug.debugMessages("SqlQuery:" + sqlQuery.toString() + ":");
- GOSIDebug.debugMessages("\t\t Param 1 :" + injuryid.longValue() + ":");
- ps = con.prepareStatement(sqlQuery.toString());
- ps.setLong(1,injuryid.longValue());
- rs = ps.executeQuery();
- if(rs.next())
- {
- wageStopDate = rs.getTimestamp("WAGESTOPDATE");
- wageStopDate = GOSIUtilities.getRequiredDate(wageStopDate,-1);
- GOSIDebug.debugMessages("Wage StopDate:" + wageStopDate + ":");
- // this is to make sure that the establishment will be
- // paid till the last wage paid date.
- }
- }
- catch(GOSIException ge)
- {
- GOSIDebug.debugMessages("Session:getWageStopDate :" + ge);
- throw ge;
- }
- catch(Exception e)
- {
- GOSIDebug.debugMessages("Session:getWageStopDate :" + e);
- throw new GOSIException( GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,this.getClass().toString(),
- "getWageStopDate()",e,"CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp(ps,rs);
- }
- GOSIDebug.debugMessages("\t\t End getWageStopDate - MaintainOHAllowanceSessionEJB");
- return wageStopDate;
- }
- /**
- * @METHOD NAME : getCancellationReasonForReturnedBenefitCheque
- * @INFORMATION : This method will invoke service from finance to get the cancellation details.
- * @PARAM : long
- * @RETURN : java.lang.Integer
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- public Integer getCancellationReasonForReturnedBenefitCheque (long journalHeaderId)
- throws GOSIException
- {
- /* Invoke service from finance to get additional information about the status of the
- * returned check recipient */
- try
- {
- HashMap interfaceInputMap = new HashMap ();
- interfaceInputMap.put (FAInterfaceConstants.METHOD_DESCRIPTION, FAInterfaceConstants.CHEQUE_RETURN_INTERFACE);
- interfaceInputMap.put (FAInterfaceConstants.MODULE_ID, new Short (GOSIConstants.OCCUPATIONAL_HAZARDS_ID));
- interfaceInputMap.put ("CN_DN_RecordId", new Long (journalHeaderId));
- FinancialAccountingInterface faInterface;
- faInterface = FinanceImplProxy.getFAInterface ();
- interfaceInputMap = faInterface.invokeService (interfaceInputMap);
- GOSIDebug.debugMessages("chequeCancellationCode " + interfaceInputMap.get ("CancellationCode"));
- GOSIDebug.debugMessages("chequeCancelCodeDesc " + interfaceInputMap.get ("CancelCodeDesc"));
- /**
- * Service method will return the cancellation reason as an Integer value, below is the description matrix
- *
- * Cancellation Reason Code | Cancellation Reason Description
- * ----------------------------------------------------------- | ---------------------------------------------------------------
- * FAInterfaceConstants.CHEQUE_NOT_CANCELLED | Cheque is returned but not yet canceled in finance
- * FAInterfaceConstants.OVER_SIX_MONTHS | Cheque has not been cashed for over six months
- * FAInterfaceConstants.DAMAGED_CHEQUE_BENEFICIARY_REQUEST | Cheque is in the incorrect amt/name or it was lost or damaged
- * FAInterfaceConstants.BENEFICIARY_LEFT_SA | Cheque canceled. Beneficiary residing overseas
- * FAInterfaceConstants.BENEFICIARY_NOT_ALIVE | The beneficiary is no longer alive
- * FAInterfaceConstants.CANCEL_REASON_OTHERS | Cancellation reason not indicated
- */
- String cancellationCodeStr = (String) interfaceInputMap.get ("CancellationCode");
- if (cancellationCodeStr == null ||
- Integer.valueOf(cancellationCodeStr).intValue () == 0)
- {
- return FAInterfaceConstants.CHEQUE_NOT_CANCELLED; // For compatibility
- }
- return Integer.valueOf(cancellationCodeStr);
- }
- catch (GOSIException ge)
- {
- GOSIDebug.debugMessages ("Invoking finance service failed ! Could not determine cheque status.");
- throw ge;
- }
- catch (Exception e)
- {
- GOSIDebug.debugMessages ("Session:getCancellationReasonForReturnedBenefitCheque :" + e);
- throw new GOSIException (GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass ().toString (),
- "getCancellationReasonForReturnedBenefitCheque ()",
- e,
- "CMN_ERR_1000");
- }
- }
- /**
- * @METHOD NAME : getEstablishmentID
- * @INFORMATION : This method is to take injuryid and returns establishmentID
- * @PARAM : class java.lang.Double,
- class java.sql.Timestamp,
- class java.lang.Long,
- class java.lang.Long,
- boolean,
- class gosi.core.workflow.beans.WorkflowParamBean
- * @RETURN : void
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- Long getEstablishmentID(Long injuryId)
- throws GOSIException
- {
- Long establishmentId = null;
- PreparedStatement ps = null;
- ResultSet rs = null;
- try
- {
- /* Get connection handler */
- con = GOSIUtilities.getConnection (GOSIConstants.OCCUPATIONAL_HAZARDS_ID);
- /* Compile SQL statement object */
- ps = con.prepareStatement ("SELECT ESTABLISHMENTID FROM " + SITables.T_INJURY + "WHERE INJURYID=?");
- ps.setLong (1, injuryId.longValue ());
- /* Execute query, and download the result set */
- rs = ps.executeQuery ();
- if (rs.next ())
- {
- establishmentId = (new Long (rs.getLong ("ESTABLISHMENTID")));
- }
- }
- catch (GOSIException ge)
- {
- GOSIDebug.debugMessages ("Session:getEstablishmentID :" + ge);
- throw ge;
- }
- catch (Exception e)
- {
- GOSIDebug.debugMessages ("Session:getEstablishmentID :" + e);
- throw new GOSIException (GOSIConstants.SEVERITY_TWO,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass().toString(),
- "getEstablishmentID()",
- e,
- "CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp (ps, rs);
- }
- return establishmentId;
- }
- /**
- * @METHOD NAME : getOHBenefitIdList
- * @INFORMATION : This method is to get OH Benefit Id List
- * @PARAM : class java.util.ArrayList
- * @RETURN : class java.util.ArrayList
- * @EXCEPTION : class gosi.core.util.GOSIException
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private ArrayList getOHBenefitIdList (ArrayList journalHeaderIdList) throws GOSIException
- {
- ArrayList OHBenefitIdList = new ArrayList ();
- PreparedStatement ps = null;
- ResultSet rs = null;
- try
- {
- String subQuery = "";
- int journalHeaderIdListSize =journalHeaderIdList.size();
- for(int i=0;i<journalHeaderIdListSize;i++)
- {
- if(i==0)
- {
- subQuery = " ? ";
- }
- else
- {
- subQuery = subQuery + " ,? ";
- }
- }
- String sqlQuery = " SELECT OHBENID, JOURNALHEADERID "
- + " FROM " + SITables.T_OHBENEFIT
- + " WHERE JOURNALHEADERID in ( " + subQuery + " ) ";
- ps = con.prepareStatement (sqlQuery);
- for(int i=0;i<journalHeaderIdListSize;i++)
- {
- Long journalHeaderId = (Long) journalHeaderIdList.get(i);
- ps.setLong(i+1,journalHeaderId.longValue());
- GOSIDebug.debugMessages("\t\t Param " + (i+1) + ":" + journalHeaderId.longValue() + ":");
- }
- rs = ps.executeQuery ();
- while (rs.next())
- {
- OHAllowanceBean benefitBean = new OHAllowanceBean ();
- if (rs.getObject("OHBENID") != null)
- {
- benefitBean.setOhBenId(new Long(rs.getLong("OHBENID")));
- }
- if (rs.getObject("JOURNALHEADERID") != null)
- {
- benefitBean.setJournalHeaderId(new Long(rs.getLong("JOURNALHEADERID")));
- }
- OHBenefitIdList.add (benefitBean);
- }
- }
- catch (Exception e)
- {
- throw new GOSIException (GOSIConstants.SEVERITY_ONE,
- GOSIConstants.SOCIAL_INSURANCE,
- this.getClass().toString(),
- "getOHBenefitIdList ()",
- e,
- "CMN_ERR_1000");
- }
- finally
- {
- GOSIUtilities.cleanUp (ps, rs);
- }
- return OHBenefitIdList;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement