Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package gosi.business.batch.socialinsurance.occupationalhazards.injury.controller;
- //gosi.business.batch.socialinsurance.occupationalhazards.injury.controller.ServiceController
- import gosi.common.batch.util.BatchProcessController;
- import gosi.common.batch.util.GOSIBatchConstants;
- import gosi.common.batch.util.GOSIBatchException;
- import gosi.common.batch.util.beans.BatchRestart;
- import gosi.common.batch.util.GOSIBatchUtilities;
- import gosi.common.batch.util.GOSIBatchSQL;
- import gosi.common.batch.util.BatchComponentDAOFactory;
- import gosi.common.batch.util.GOSIBatchErrorMessages;
- import java.sql.PreparedStatement;
- import java.sql.SQLException;
- import java.util.ArrayList;
- import java.util.GregorianCalendar;
- import java.util.HashMap;
- import java.sql.Timestamp;
- import gosi.business.batch.socialinsurance.occupationalhazards.injury.beans.RegHospInvoiceHeaderBean;
- import gosi.business.batch.socialinsurance.occupationalhazards.injury.beans.TreatmentHeaderBean;
- import gosi.business.batch.socialinsurance.occupationalhazards.injury.beans.TreatmentServiceBean;
- import gosi.business.batch.socialinsurance.occupationalhazards.common.beans.OHBatchConstants;
- import gosi.business.batch.socialinsurance.occupationalhazards.common.beans.OHBatchUtilities;
- import gosi.database.batch.socialinsurance.occupationalhazards.injury.dao.SendWFRegHosInvDAO;
- import gosi.common.batch.workflow.beans.BatchWorkflowParamBean;
- import gosi.common.reports.beans.BatchReportConstants;
- import gosi.common.reports.util.ReportInterfaceUtility;
- public class SendWFRegHosInvController extends BatchProcessController
- {
- String selectInvoiceHeaderDetails = null;
- String selectInjuryListDetails = null;
- String selectTreatmentServiceList = null;
- String selectExistDuplicateRecordByInjuryId = null;
- String selectExistDuplicateRecordByDisAssmtId = null;
- String updateTreatmentService = null;
- PreparedStatement psSelectInvoiceHeaderDetailsDAO = null;
- PreparedStatement psSelectInjuryListDetailsDAO = null;
- PreparedStatement psSelectTreatmentServiceListDAO = null;
- PreparedStatement psSelectExistDuplicateRecordByInjuryIdDAO = null;
- PreparedStatement psSelectExistDuplicateRecordByDisAssmtIdDAO = null;
- PreparedStatement psUpdateTreatmentServiceDAO = null;
- ReportInterfaceUtility reportInterfaceUtility = null;
- long requestId = 0;
- SendWFRegHosInvDAO sendWFRegHosInvDAO = null;
- Timestamp currentDate=new Timestamp(System.currentTimeMillis());
- private BatchRestart restart = getBatchRestartInLastRun();
- //Batch parameters
- String fileName = "";
- String fileType= "";
- short fileNameParamValue=(short)1001;
- Long systemId = new Long(getUserCode());
- int noOfRequests =0;
- /**
- * @roseuid
- * @J2EE_METHOD -- GenerateRegHospitalInvoiceController
- *
- */
- public SendWFRegHosInvController(String batchId,byte batchFlag)
- throws GOSIBatchException
- {
- super(batchId,batchFlag);
- System.out.println("Inside constructor:batchId:"+batchId);
- }
- public boolean invokeBatchService()
- throws GOSIBatchException
- {
- try
- {
- System.out.println("|-----------invokeBatchService-------------|");
- long startTime=System.currentTimeMillis();
- selectInvoiceHeaderDetails = GOSIBatchSQL.getSqlString("OHZ_026_SQL_1001");
- System.out.println("OHZ_026_SQL_1001:"+selectInvoiceHeaderDetails);
- psSelectInvoiceHeaderDetailsDAO = getConnection().prepareStatement( selectInvoiceHeaderDetails );
- selectInjuryListDetails = GOSIBatchSQL.getSqlString("OHZ_026_SQL_1002");
- System.out.println("OHZ_026_SQL_1002:"+selectInjuryListDetails);
- psSelectInjuryListDetailsDAO = getConnection().prepareStatement( selectInjuryListDetails );
- selectTreatmentServiceList = GOSIBatchSQL.getSqlString("OHZ_026_SQL_1003");
- System.out.println("OHZ_026_SQL_1003:"+selectTreatmentServiceList);
- psSelectTreatmentServiceListDAO = getConnection().prepareStatement( selectTreatmentServiceList );
- selectExistDuplicateRecordByInjuryId = GOSIBatchSQL.getSqlString("OHZ_026_SQL_1004");
- System.out.println("OHZ_026_SQL_1004:"+selectExistDuplicateRecordByInjuryId);
- psSelectExistDuplicateRecordByInjuryIdDAO = getConnection().prepareStatement( selectExistDuplicateRecordByInjuryId );
- selectExistDuplicateRecordByDisAssmtId = GOSIBatchSQL.getSqlString("OHZ_026_SQL_1005");
- System.out.println("OHZ_026_SQL_1005:"+selectExistDuplicateRecordByDisAssmtId);
- psSelectExistDuplicateRecordByDisAssmtIdDAO = getConnection().prepareStatement( selectExistDuplicateRecordByDisAssmtId );
- updateTreatmentService = GOSIBatchSQL.getSqlString("OHZ_026_SQL_1006");
- System.out.println("OHZ_026_SQL_1006:"+updateTreatmentService);
- psUpdateTreatmentServiceDAO = getConnection().prepareStatement( updateTreatmentService );
- sendWFRegHosInvDAO = (SendWFRegHosInvDAO)BatchComponentDAOFactory.
- getBatchDAOInstance(getBatchMaster(),
- getBatchErrorList(),
- getBatchError(),
- getConnection(),
- OHBatchConstants.SEND_WORKFLOW_REG_HOSP_INVOICE_DAO);
- reportInterfaceUtility =
- new ReportInterfaceUtility(
- BatchReportConstants.CMN_LETTER_GEN_SERVICEID,
- getBatchMaster(),
- getBatchErrorList(),
- getBatchError(),
- getConnection(),
- getBatchParamList());
- //Checking the batchFlah to process only error or all records
- //Note :- Workflow Batch does not require the restsrt keys
- //in the last run.
- //In normal cases if the restart keys are not
- //null Process Component need process the records from that
- //Point
- if(getBatchFlag()==GOSIBatchConstants.PROCESS_ONLY_ERROR_RECORDS)
- {
- //processOnlyErrorRecords();
- }
- else
- {
- //processOnlyErrorRecords();
- processAllRecords();
- }
- long endTime=System.currentTimeMillis();
- long totalTime=(endTime-startTime)/1000;
- System.out.println("|-----------StratBatchTime*------------|");
- System.out.println(currentDate);
- System.out.println("|-----------EndBatchTime*------------|");
- System.out.println(new Timestamp(System.currentTimeMillis()));
- System.out.println("|-----------BatchTakeTime*------------|");
- System.out.println("Time required for batch run in minute :"+totalTime/60);
- System.out.println("Time required for batch run :"+totalTime);
- System.out.println("|-----------invokeBatchService*------------|");
- }
- catch(GOSIBatchException ge)
- {
- updateBatchRunStatus(false);
- rollBack();
- throw ge;
- }
- catch(Exception e)
- {
- updateBatchRunStatus(false);
- rollBack();
- new GOSIBatchException(e,
- this.getClass().toString(),
- "invokeBatchService",
- getBatchMaster(),
- getBatchError(),
- getBatchErrorList(),
- GOSIBatchConstants.
- WORKFLOW_HISTORY_LOOP_ONE,
- GOSIBatchConstants.SEVERITY_ONE,
- "CMN_001_ERR_1001");
- }
- finally
- {
- GOSIBatchUtilities.cleanUp( psSelectInvoiceHeaderDetailsDAO);
- GOSIBatchUtilities.cleanUp( psSelectInjuryListDetailsDAO);
- GOSIBatchUtilities.cleanUp( psSelectTreatmentServiceListDAO);
- GOSIBatchUtilities.cleanUp( psUpdateTreatmentServiceDAO);
- GOSIBatchUtilities.cleanUp(getConnection());
- }
- return getBatchRunStatus();
- }
- /**
- * @
- * @J2EE_METHOD -- processOnlyErrorRecords
- *
- */
- private void processOnlyErrorRecords()
- throws GOSIBatchException
- {
- int loopCount=1;
- try
- {
- System.out.println("|-----------processOnlyErrorRecords-------------|");
- System.out.println("|-----------processOnlyErrorRecords*------------|");
- }
- catch(Exception e)
- {
- updateBatchRunStatus(false);
- rollBack();
- new GOSIBatchException(e,
- this.getClass().toString(),
- "processOnlyErrorRecords",
- getBatchMaster(),
- getBatchError(),
- getBatchErrorList(),
- loopCount,
- GOSIBatchConstants.SEVERITY_ONE,
- "CMN_001_ERR_1000");
- }
- }
- /**
- * @
- * @J2EE_METHOD -- processOnlyErrorRecords
- *
- */
- private void processAllRecords()
- throws GOSIBatchException
- {
- System.out.println("|-----------processAllRecords------------|");
- System.out.println("Inside process all records" );
- Long hospitalCode=null;
- noOfRequests = getNoOfRequests();
- int loopCount=1;
- int numOfRecordsInserted=0 ;
- ArrayList invoiceHeaderList = null;
- // location has to be retrieved from ?
- try
- {
- /*int restartRun=0;
- if(restart!=null)
- {
- if(restart.getRestartKeys()!=null)
- {
- restartRun=1;
- }
- } */
- // Start Business Validation
- // get list of files
- invoiceHeaderList=getInvoiceHeaderDetails(psSelectInvoiceHeaderDetailsDAO);
- for (int j=0;j<invoiceHeaderList.size();j++)
- {
- RegHospInvoiceHeaderBean invoiceHeaderBean =(RegHospInvoiceHeaderBean)invoiceHeaderList.get(j);
- hospitalCode=invoiceHeaderBean.getHospitalCode();
- int month=OHBatchUtilities.getMonth(invoiceHeaderBean.getInvoiceDateStr());
- int year=OHBatchUtilities.getYear(invoiceHeaderBean.getInvoiceDateStr());
- Timestamp stDate=invoiceHeaderBean.getStartDate();
- String endDateStr=OHBatchUtilities.getMonthEndDate(OHBatchUtilities.getDateStr(stDate, "G"));
- Timestamp endDate=OHBatchUtilities.getGregDate(endDateStr, "G");
- Timestamp maxUploadMonthDate=invoiceHeaderBean.getMaxUploadedMonthDate();
- System.out.println("=============================================================== \t \t \t \t Invoice Month/Year : "+month+"/"+year+" for hospitalCode:"+hospitalCode +" \t \t \t \t ====================================================================");
- System.out.println();
- ArrayList injuryList=getInjuryDetailsThatDoNotHaveWF(psSelectInjuryListDetailsDAO,hospitalCode,month,year);
- System.out.println("\t\t *************************************************************************************** \t the list of injuryList size is : "+injuryList.size() + "\t **************************************************************************");
- System.out.println();
- //GOSIBatchUtilities.cleanUp( psUpdateTreatmentServiceDAO);
- for(int x=0;x<injuryList.size();x++)
- {
- TreatmentHeaderBean trmtBean=(TreatmentHeaderBean)injuryList.get(x);
- int differentDate=GOSIBatchUtilities.getDateDifference(maxUploadMonthDate, trmtBean.getMaxTrmtDate());
- String maxDateStr=OHBatchUtilities.getDateStr(trmtBean.getMaxTrmtDate(), "G");
- String lastServiceDateStr=OHBatchUtilities.getDateStr(trmtBean.getMaxTrmtDate(), "G");
- psSelectTreatmentServiceListDAO.setLong(1, trmtBean.getTrmtServiceHdrId());
- psSelectTreatmentServiceListDAO.setShort(2, OHBatchConstants.TRMT_SRVC_STS_PENDING_WORKFLOW_ENTRY);
- psSelectTreatmentServiceListDAO.setShort(3, OHBatchConstants.TRMT_SRVC_STS_PENDING_WORKFLOW_ENTRY_RECORRECTED);
- ArrayList trmtServiceDetForInjuryList=sendWFRegHosInvDAO.getTrmrServiceList(psSelectTreatmentServiceListDAO);
- Boolean isAllServiceReCorrected=true;
- for (int a=0;a<trmtServiceDetForInjuryList.size();a++){
- if(((TreatmentServiceBean)trmtServiceDetForInjuryList.get(a)).getTrmtSrvcStatus().equals(OHBatchConstants.TRMT_SRVC_STS_PENDING_WORKFLOW_ENTRY))
- {
- isAllServiceReCorrected=false;
- break;
- }
- }
- Boolean createWorkflow=false;
- if (!trmtBean.getInvoiceStatus().equals(OHBatchConstants.REG_HOSP_INVC_PENDING_DATA_ENTRY))
- {
- createWorkflow=true;
- }
- else if (differentDate>OHBatchConstants.MAX_DIFFERENT_DATE_TO_CREATE_WORKFLOW_TREATMETN_SERVICE)
- {
- if(!isAllServiceReCorrected || !trmtBean.getIsHaveErrorInEClaim())
- createWorkflow=true;
- }
- else if (endDate.equals(trmtBean.getMaxTrmtDate()))
- {
- if(!isAllServiceReCorrected || !trmtBean.getIsHaveErrorInEClaim())
- createWorkflow=true;
- }
- else if (trmtBean.getInjuryId()!=null && trmtBean.getLastServiceDate()!=null && trmtBean.getMaxTrmtDate().equals(trmtBean.getLastServiceDate()))
- {
- //case injury Or Complication
- if(!isAllServiceReCorrected || !trmtBean.getIsHaveErrorInEClaim())
- createWorkflow=true;
- }
- System.out.println("\t\t\t "+(trmtBean.getDisAssmtId()!=null?("disability id :"+trmtBean.getDisAssmtId()):("injuryid :"+trmtBean.getInjuryId()))+", max Trmt date : "+OHBatchUtilities.getDateStr(trmtBean.getMaxTrmtDate(),"G")+" , Max Upload Month Date :"+maxUploadMonthDate+" , differentDate :"+differentDate +" endDateStr : "+endDateStr);
- System.out.println("\t\t\t getInvoiceStatus : " +trmtBean.getInvoiceStatus() +" ,getIsHaveErrorInEClaim : " +trmtBean.getIsHaveErrorInEClaim()+" ,getLastServiceDate : " +OHBatchUtilities.getDateStr(trmtBean.getLastServiceDate(),"G")+" , trmtServiceDetForInjuryList size is : "+trmtServiceDetForInjuryList.size() +", createWorkflow : "+createWorkflow+" \t\t");
- if(createWorkflow)
- {
- // create for loop to insure each workflow have just only less or equals 900 treatment Service
- int index =0;
- int maxSize =0;
- do
- {
- System.out.println("trmtServiceDetForInjuryList size :"+trmtServiceDetForInjuryList.size());
- System.out.println("MAX_TRMT_SERVICE_IN_WORKFLOW :"+OHBatchConstants.MAX_TRMT_SERVICE_IN_WORKFLOW);
- System.out.println("before index :"+index);
- System.out.println("before maxSize :"+maxSize);
- index=maxSize;
- if(trmtServiceDetForInjuryList.size()<=(maxSize+OHBatchConstants.MAX_TRMT_SERVICE_IN_WORKFLOW))
- {
- maxSize=trmtServiceDetForInjuryList.size();
- }
- else
- {
- maxSize+=OHBatchConstants.MAX_TRMT_SERVICE_IN_WORKFLOW;
- }
- System.out.println("after index will be :"+index);
- System.out.println("after maxSize will be :"+maxSize);
- Long workflowId =GOSIBatchUtilities.getPrimaryKey("TRMTSRVCWRKFLOID",getUserCode());
- System.out.println("new workflowId:"+workflowId);
- for (int z=index;z<maxSize;z++)
- {
- TreatmentServiceBean trtmService = (TreatmentServiceBean)trmtServiceDetForInjuryList.get(z);
- String trmtCode=trtmService.getSFDACode()!=null?trtmService.getSFDACode():trtmService.getTrmtCode();
- int hour=Integer.parseInt(trtmService.getTrmtTimeHr());
- int min=Integer.parseInt(trtmService.getTrmtTimeMin());
- int pmAp=trtmService.getTrmtTimeAmPm().intValue();
- Boolean isExistDuplicateRecord=false;
- String caseId="";
- if (trmtBean.getInjuryId()!=null)
- {
- caseId="injury id :"+trmtBean.getInjuryId();
- isExistDuplicateRecord=isExistDuplicateRecord(psSelectExistDuplicateRecordByInjuryIdDAO,
- trmtBean.getInjuryId(),trmtCode,trtmService.getTrmtDateGreg(),hour,min,pmAp,trtmService.getTrmtServiceDetId());
- }
- else
- {
- caseId="DisAssmtId id :"+trmtBean.getDisAssmtId();
- isExistDuplicateRecord=isExistDuplicateRecord(psSelectExistDuplicateRecordByDisAssmtIdDAO,
- trmtBean.getDisAssmtId(),trmtCode,trtmService.getTrmtDateGreg(),hour,min,pmAp,trtmService.getTrmtServiceDetId());
- }
- // Check if Exist Duplicate
- if(isExistDuplicateRecord)
- {
- System.err.println("err duplicate treatment Service for "+caseId+" On Treatment Or Medicine Code :"+trmtCode+
- " which getTrmtServiceHdrId :"+trtmService.getTrmtServiceHdrId()+" And TrmtServiceDetId :"+trtmService.getTrmtServiceDetId());
- throw new Exception();
- }
- trtmService.setTrmtSrvcStatus(OHBatchConstants.TRMT_SRVC_STS_ENTERED);
- trtmService.setTrmtSrvcWrkfloId(workflowId);
- sendWFRegHosInvDAO.updateTreatmentService(trtmService, psUpdateTreatmentServiceDAO);
- } // end for loop of each service
- BatchWorkflowParamBean workflowParamBean = new BatchWorkflowParamBean();
- workflowParamBean.setCompletedStepShortName ("ADD_TRMT_SRVC");
- workflowParamBean.setKeyVal1(trmtBean.getSocInsNumber().toString());
- workflowParamBean.setKeyVal2(GOSIBatchUtilities.getDateFullString(trmtBean.getInjuryDate()));
- workflowParamBean.setRecordDescription (String.format(GOSIBatchErrorMessages.getErrorDesc("OHZ_022_ERR_001"),
- (getMonthName(month,true) +" - "+ year))+" " + trmtBean.getSocInsNumber().toString());
- workflowParamBean.setDestinationLoactionId(trmtBean.getFieldOffice().shortValue());
- workflowParamBean.setRoutingCriterion(GOSIBatchConstants.COMPLETED);
- // PrimaryKey is the WORKFLOWID
- // WORKFLOWID FROM T_TRMTSERVICESDET TABLE
- workflowParamBean.setPrimaryKey (workflowId.toString());
- System.out.println("\t\t\t PrimaryKey----"+workflowParamBean.getPrimaryKey());
- GOSIBatchUtilities.startBatchWorkflow(workflowParamBean,getConnection());
- sendWFRegHosInvDAO.executeBatchStatment(psUpdateTreatmentServiceDAO);
- }while(maxSize<trmtServiceDetForInjuryList.size());
- } // end if createWorkflow
- System.out.println();
- System.out.println("\t\t *********************************************************************************************************************************************************************************************************");
- System.out.println();
- } // end for injury List
- System.out.println();
- System.out.println("=================================================================================================================================================================================================================================================================== \n \n \n ");
- System.out.println();
- System.out.println();
- System.out.println();
- }
- updateBatchRunStatus (true);
- endOfProcess();
- System.out.println("|-----------processAllRecords*------------|");
- }
- catch(GOSIBatchException ge)
- {
- System.out.println("controller:processAllRecords:"+ge);
- ge.printStackTrace();
- rollBack();
- updateBatchRunStatus(false);
- throw ge;
- }
- catch(Exception e)
- {
- System.out.println("controller:processAllRecords:"+e);
- updateBatchRunStatus(false);
- e.printStackTrace();
- rollBack();
- new GOSIBatchException(e,
- this.getClass().toString(),
- "processAllRecords",
- getBatchMaster(),
- getBatchError(),
- getBatchErrorList(),
- loopCount,
- GOSIBatchConstants.SEVERITY_ONE,
- "CMN_001_ERR_1001");
- }
- }
- /**
- * getRegHosInvHdrList ()
- *
- * @param psSelectRegHosInvoiceHdrDAO, Long , GregorianCalendar
- * @return get list of invoice header that related with the month of file
- */
- private HashMap getRegHosInvHdrList(PreparedStatement psSelectRegHosInvoiceHdrDAO, Long hospitalCode ,
- GregorianCalendar calendar) throws GOSIBatchException
- {
- int i =0;
- HashMap regHosInvHdrList=null;
- // System.out.println ("Start getRegHosInvHdrList");
- try
- {
- psSelectRegHosInvoiceHdrDAO.setLong(++i, hospitalCode);
- psSelectRegHosInvoiceHdrDAO.setTimestamp(++i, new Timestamp(calendar.getTime().getTime()));
- psSelectRegHosInvoiceHdrDAO.setShort(++i, OHBatchConstants.REG_HOSP_INVC_PENDING_DATA_ENTRY);
- regHosInvHdrList=sendWFRegHosInvDAO.getRegHosInvHdrList(psSelectRegHosInvoiceHdrDAO);
- }
- catch (GOSIBatchException ge)
- {
- updateBatchRunStatus (false);
- rollBack();
- throw ge;
- }
- catch (Exception e)
- {
- updateBatchRunStatus (false);
- rollBack();
- new GOSIBatchException (e,
- this.getClass().toString(),
- "getRegHosInvHdrList",
- getBatchMaster(),
- getBatchError(),
- getBatchErrorList(),
- OHBatchConstants.LOOP_ONE,
- GOSIBatchConstants.SEVERITY_ONE,
- "CMN_001_ERR_1001");
- }
- // System.out.println ("End getRegHosInvHdrList");
- return regHosInvHdrList;
- }
- /**
- * getRegHosInvDetList ()
- *
- * @param psSelectTrmtServiceHdrDAO, Long , GregorianCalendar
- * @return get list of All invoice details and Treatment Header that related with the month of file
- */
- private HashMap getRegHosInvDetList(PreparedStatement psSelectTrmtServiceHdrDAO, Long hospitalCode ,
- GregorianCalendar calendar) throws GOSIBatchException
- {
- int i =0;
- HashMap regHosInvDetList=null;
- //System.out.println ("Start getRegHosInvHdrList");
- try
- {
- psSelectTrmtServiceHdrDAO.setShort(++i, OHBatchConstants.WFS_SRVC_ENTERED_BY_BATCH);
- psSelectTrmtServiceHdrDAO.setShort(++i, OHBatchConstants.TRMT_SRVC_STS_ENTERED);
- psSelectTrmtServiceHdrDAO.setLong(++i, hospitalCode);
- psSelectTrmtServiceHdrDAO.setTimestamp(++i, new Timestamp(calendar.getTime().getTime()));
- psSelectTrmtServiceHdrDAO.setShort(++i, OHBatchConstants.REG_HOSP_INVC_PENDING_DATA_ENTRY);
- regHosInvDetList=sendWFRegHosInvDAO.getRegHosInvDetList(psSelectTrmtServiceHdrDAO);
- }
- catch (GOSIBatchException ge)
- {
- updateBatchRunStatus (false);
- rollBack();
- throw ge;
- }
- catch (Exception e)
- {
- updateBatchRunStatus (false);
- rollBack();
- new GOSIBatchException (e,
- this.getClass().toString(),
- "getRegHosInvDetList",
- getBatchMaster(),
- getBatchError(),
- getBatchErrorList(),
- OHBatchConstants.LOOP_ONE,
- GOSIBatchConstants.SEVERITY_ONE,
- "CMN_001_ERR_1001");
- }
- //System.out.println ("End getRegHosInvDetList");
- return regHosInvDetList;
- }
- /**
- * getInjuryDetails ()
- *
- * @param psSelectInjuryListDetailsDAO, String
- * @return get list of All Injury details that entered in the file
- */
- private ArrayList getInjuryDetails(PreparedStatement psSelectInjuryListDetailsDAO,
- String fileUploadInfoId, Long hospitalcode,int month , int year ) throws GOSIBatchException
- {
- int i =0;
- ArrayList injuryList=null;
- //System.out.println ("Start getInjuryDetails");
- try
- {
- psSelectInjuryListDetailsDAO.setString(++i, fileUploadInfoId);
- psSelectInjuryListDetailsDAO.setLong(++i, hospitalcode);
- psSelectInjuryListDetailsDAO.setInt(++i, month);
- psSelectInjuryListDetailsDAO.setInt(++i, year);
- injuryList=sendWFRegHosInvDAO.getInjuryDetails(psSelectInjuryListDetailsDAO);
- }
- catch (GOSIBatchException ge)
- {
- updateBatchRunStatus (false);
- rollBack();
- throw ge;
- }
- catch (Exception e)
- {
- updateBatchRunStatus (false);
- rollBack();
- new GOSIBatchException (e,
- this.getClass().toString(),
- "getInjuryDetails",
- getBatchMaster(),
- getBatchError(),
- getBatchErrorList(),
- OHBatchConstants.LOOP_ONE,
- GOSIBatchConstants.SEVERITY_ONE,
- "CMN_001_ERR_1001");
- }
- //System.out.println ("End getInjuryDetails");
- return injuryList;
- }
- /**
- * getFileUploadInfoList ()
- *
- * @param psSelectFileUploadInfoDAO
- * @return List of Invoice that status is pending entery
- */
- private ArrayList getInvoiceHeaderDetails(PreparedStatement psSelectInvoiceHeaderDetailsDAO) throws GOSIBatchException
- {
- int i =0;
- ArrayList invoiceList=null;
- //System.out.println ("Start getInvoiceHeaderDetails");
- try
- {
- invoiceList=sendWFRegHosInvDAO.getInvoiceHeaderDetails(psSelectInvoiceHeaderDetailsDAO);
- }
- catch (GOSIBatchException ge)
- {
- updateBatchRunStatus (false);
- rollBack();
- throw ge;
- }
- catch (Exception e)
- {
- updateBatchRunStatus (false);
- rollBack();
- new GOSIBatchException (e,
- this.getClass().toString(),
- "getFileUploadInfoList",
- getBatchMaster(),
- getBatchError(),
- getBatchErrorList(),
- OHBatchConstants.LOOP_ONE,
- GOSIBatchConstants.SEVERITY_ONE,
- "CMN_001_ERR_1001");
- }
- //System.out.println ("End getInvoiceHeaderDetails");
- return invoiceList;
- }
- /**
- * getInjuryDetailsThatDoNotHaveWF ()
- *
- * @param psSelectInjuryListDetailsDAO, String
- * @return get list of All Injury details that entered in the file
- */
- private ArrayList getInjuryDetailsThatDoNotHaveWF(PreparedStatement psSelectInjuryListDetailsDAO,Long hospitalcode,int month , int year ) throws GOSIBatchException
- {
- int i =0;
- ArrayList injuryList=null;
- try
- {
- psSelectInjuryListDetailsDAO.setLong(++i, hospitalcode);
- psSelectInjuryListDetailsDAO.setInt(++i, month);
- psSelectInjuryListDetailsDAO.setInt(++i, year);
- psSelectInjuryListDetailsDAO.setLong(++i, hospitalcode);
- psSelectInjuryListDetailsDAO.setInt(++i, month);
- psSelectInjuryListDetailsDAO.setInt(++i, year);
- psSelectInjuryListDetailsDAO.setShort(++i, OHBatchConstants.EXTN_SICKLEAVE_STS_APPROVED);
- psSelectInjuryListDetailsDAO.setLong(++i, hospitalcode);
- psSelectInjuryListDetailsDAO.setInt(++i, month);
- psSelectInjuryListDetailsDAO.setInt(++i, year);
- injuryList=sendWFRegHosInvDAO.getInjuryDetails(psSelectInjuryListDetailsDAO);
- }
- catch (GOSIBatchException ge)
- {
- updateBatchRunStatus (false);
- rollBack();
- throw ge;
- }
- catch (Exception e)
- {
- updateBatchRunStatus (false);
- rollBack();
- e.printStackTrace();
- new GOSIBatchException (e,
- this.getClass().toString(),
- "getInjuryDetailsThatDoNotHaveWF",
- getBatchMaster(),
- getBatchError(),
- getBatchErrorList(),
- OHBatchConstants.LOOP_ONE,
- GOSIBatchConstants.SEVERITY_ONE,
- "CMN_001_ERR_1001");
- }
- //System.out.println ("End getInjuryDetailsThatDoNotHaveWF");
- return injuryList;
- }
- /**
- * isExistDuplicateRecord()
- *
- * @param psSelectExistDuplicateRecord,Long , String , Timestamp , int , int
- * @return true if Exist Duplicate Record else return false;
- */
- private Boolean isExistDuplicateRecord (PreparedStatement psSelectExistDuplicateRecord
- , Long Id , String treatmentOrMedicineCode , Timestamp trmtDateGreg , int hour , int minute , int AmOrPm,Long trmtServiceDetId ) throws GOSIBatchException
- {
- int i =0;
- Boolean isExistDuplicateRecord=false;
- //System.out.println ("Start isExistDuplicateRecord");
- try
- {
- psSelectExistDuplicateRecord.setLong(++i, Id);
- psSelectExistDuplicateRecord.setShort(++i, OHBatchConstants.TRMT_SRVC_STS_CANCELLED);
- psSelectExistDuplicateRecord.setString(++i,treatmentOrMedicineCode);
- psSelectExistDuplicateRecord.setString(++i,treatmentOrMedicineCode);
- psSelectExistDuplicateRecord.setTimestamp(++i, trmtDateGreg);
- psSelectExistDuplicateRecord.setInt(++i, hour);
- psSelectExistDuplicateRecord.setInt(++i, minute);
- psSelectExistDuplicateRecord.setInt(++i, AmOrPm);
- psSelectExistDuplicateRecord.setLong(++i, trmtServiceDetId);
- isExistDuplicateRecord=sendWFRegHosInvDAO.isExistDuplicateRecordDAO(psSelectExistDuplicateRecord);
- }
- catch (GOSIBatchException ge)
- {
- updateBatchRunStatus (false);
- rollBack();
- throw ge;
- }
- catch (Exception e)
- {
- updateBatchRunStatus (false);
- rollBack();
- e.printStackTrace();
- new GOSIBatchException (e,
- this.getClass().toString(),
- "isExistDuplicateRecord",
- getBatchMaster(),
- getBatchError(),
- getBatchErrorList(),
- OHBatchConstants.LOOP_ONE,
- GOSIBatchConstants.SEVERITY_ONE,
- "CMN_001_ERR_1001");
- }
- // System.out.println ("End isExistDuplicateRecord");
- return isExistDuplicateRecord;
- }
- public String getMonthName (int month ,Boolean isArabic)throws GOSIBatchException{
- String monthName="";
- switch (month)
- {
- case 1:
- {
- monthName=GOSIBatchErrorMessages.getErrorDesc("OHZ_022_ERR_051", isArabic);
- break;
- }
- case 2:
- {
- monthName=GOSIBatchErrorMessages.getErrorDesc("OHZ_022_ERR_052", isArabic);
- break;
- }
- case 3:
- {
- monthName=GOSIBatchErrorMessages.getErrorDesc("OHZ_022_ERR_053", isArabic);
- break;
- }
- case 4:
- {
- monthName=GOSIBatchErrorMessages.getErrorDesc("OHZ_022_ERR_054", isArabic);
- break;
- }
- case 5:
- {
- monthName=GOSIBatchErrorMessages.getErrorDesc("OHZ_022_ERR_055", isArabic);
- break;
- }
- case 6:
- {
- monthName=GOSIBatchErrorMessages.getErrorDesc("OHZ_022_ERR_056", isArabic);
- break;
- }
- case 7:
- {
- monthName=GOSIBatchErrorMessages.getErrorDesc("OHZ_022_ERR_057", isArabic);
- break;
- }
- case 8:
- {
- monthName=GOSIBatchErrorMessages.getErrorDesc("OHZ_022_ERR_058", isArabic);
- break;
- }
- case 9:
- {
- monthName=GOSIBatchErrorMessages.getErrorDesc("OHZ_022_ERR_059", isArabic);
- break;
- }
- case 10:
- {
- monthName=GOSIBatchErrorMessages.getErrorDesc("OHZ_022_ERR_060", isArabic);
- break;
- }
- case 11:
- {
- monthName=GOSIBatchErrorMessages.getErrorDesc("OHZ_022_ERR_061", isArabic);
- break;
- }
- case 12:
- {
- monthName=GOSIBatchErrorMessages.getErrorDesc("OHZ_022_ERR_062", isArabic);
- break;
- }
- }
- return monthName;
- }
- /**
- * @METHOD NAME : rollBack
- * @INFORMATION : rollBack excuted records from DB.
- * @PARAM :
- * @RETURN : void
- * @EXCEPTION :
- * @LAST MODIFIED BY :
- * @LAST MODIFIED DATE :
- **/
- private void rollBack()
- {
- try
- {
- getConnection().rollback();
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- }
- }
- # SQL STATEMENT FOR THIS BATCH:
- 1#
- /* Formatted on 21/12/16 02:50:25 م (QP5 v5.185.11230.41888) */
- SELECT H.HOSPITALCODE, H.STARTDATE, maxDate.maxDate
- FROM ( SELECT H.HOSPITALCODE, H.STARTDATE
- FROM T_REGHOSPINVOICEHDR H
- LEFT JOIN T_REGHOSPINVOICEDET D
- ON D.INVOICEHEADERID = H.INVOICEHEADERID
- LEFT JOIN T_TRMTSERVICESHDR TH
- ON TH.INVOICEDETAILSID = D.INVOICEDETAILSID
- LEFT JOIN T_TRMTSERVICESDET TD
- ON TD.TRMTSERVICEHDRID = TH.TRMTSERVICEHDRID
- WHERE H.BATCHPROCESSED IS NOT NULL
- AND H.INVOICESTATUS <> 1004
- AND TD.TRMTSRVCWRKFLOID IS NULL
- GROUP BY H.HOSPITALCODE, H.STARTDATE) H
- LEFT JOIN
- ( SELECT U.MAPPINGKEY,
- U.MONTH,
- U.YEAR,
- MAX (R.TRMTDATE) maxdate
- FROM T_REGHOSPINVOICEFILE r
- LEFT JOIN
- T_FILEUPLOADINFO u
- ON u.FILEUPLOADINFOID = r.FILEID
- GROUP BY U.MAPPINGKEY, U.MONTH, U.YEAR) maxDate
- ON maxDate.MAPPINGKEY = H.HOSPITALCODE
- AND maxDate.month = TO_CHAR (H.STARTDATE, 'MM')
- AND maxDate.year = TO_CHAR (H.STARTDATE, 'YYYY')
- ORDER BY H.STARTDATE ASC
- 2#
- /* Formatted on 21/12/16 02:50:28 م (QP5 v5.185.11230.41888) */
- SELECT A.*,
- O.LASTSERVICEDATE,
- J.INJURYDATE,
- M.SESSIONDATE,
- NVL (M.SOCINSNUMBER, J.SOCINSNUMBER) AS SOCINSNUMBER,
- HAVEERROR.CASEID
- FROM ( SELECT H.FIELDOFFICE,
- H.INVOICESTATUS,
- TH.TRMTSERVICEHDRID,
- TH.INJURYID,
- TH.DISASSMTID,
- TH.INVOICEDETAILSID,
- MAX (TD.TRMTDATE) MAXDATE
- FROM T_REGHOSPINVOICEHDR H
- LEFT JOIN T_REGHOSPINVOICEDET D
- ON D.INVOICEHEADERID = H.INVOICEHEADERID
- LEFT JOIN T_TRMTSERVICESHDR TH
- ON TH.INVOICEDETAILSID = D.INVOICEDETAILSID
- LEFT JOIN T_TRMTSERVICESDET TD
- ON TD.TRMTSERVICEHDRID = TH.TRMTSERVICEHDRID
- WHERE H.BATCHPROCESSED IS NOT NULL
- AND TD.TRMTSRVCWRKFLOID IS NULL
- AND TH.TRMTSERVICEHDRID IS NOT NULL
- AND H.HOSPITALCODE = ?
- AND H.INVOICESTATUS <> 1004
- AND TO_CHAR (H.STARTDATE, 'MM') = ?
- AND TO_CHAR (H.STARTDATE, 'YYYY') = ?
- GROUP BY H.FIELDOFFICE,
- H.INVOICESTATUS,
- TH.TRMTSERVICEHDRID,
- TH.INJURYID,
- TH.DISASSMTID,
- TH.INVOICEDETAILSID) A
- LEFT JOIN (SELECT DISTINCT INJURYID, O.LASTSERVICEDATE
- FROM T_OHSICKLEAVE O
- WHERE O.HOSPITALCODE = ?
- AND O.MONTH = ?
- AND O.YEAR = ?
- AND O.STATUS = ?) O
- ON A.INJURYID = O.INJURYID
- LEFT JOIN T_INJURY J
- ON A.INJURYID = J.INJURYID
- LEFT JOIN T_MBAPPOINTMENT M
- ON A.DISASSMTID = M.SCHEDULEID
- LEFT JOIN (SELECT DISTINCT
- SOCINSNUMBER, SUBSTR (OHCASEID, 2) AS CASEID
- FROM T_REGHOSPINVOICEFILE
- WHERE FILEID IN
- (SELECT FILEUPLOADINFOID
- FROM T_FILEUPLOADINFO F
- WHERE F.FILETYPE = 1121
- AND F.MAPPINGKEY = ?
- AND F.MONTH = ?
- AND F.YEAR = ?
- AND F.FILESTATUS NOT IN
- (1001, 1002, 1005))
- AND TRMTSERVICEDETID IS NULL
- AND TRIM (ERRORCODE) NOT IN
- ('OHZ_022_ERR_002',
- 'OHZ_022_ERR_003',
- 'OHZ_022_ERR_005',
- 'OHZ_022_ERR_006',
- 'OHZ_022_ERR_015',
- 'OHZ_022_ERR_070',
- 'OHZ_022_ERR_072',
- 'OHZ_022_ERR_073')) HAVEERROR
- ON HAVEERROR.CASEID = NVL (M.SCHEDULEID, J.INJURYID)
- 3#
- /* Formatted on 21/12/16 02:50:32 م (QP5 v5.185.11230.41888) */
- SELECT *
- FROM T_TRMTSERVICESHDR TH
- LEFT JOIN
- T_TRMTSERVICESDET TD
- ON TD.TRMTSERVICEHDRID = TH.TRMTSERVICEHDRID
- WHERE TH.TRMTSERVICEHDRID = ?
- AND TD.TRMTSRVCWRKFLOID IS NULL
- AND TD.TRMTSRVCSTATUS IN (?, ?)
- ORDER BY NVL (TD.SFDACODE, TD.ICD10TRMTDIAGNOSISCODE), TD.TRMTDATE ASC
- 4#
- /* Formatted on 21/12/16 02:50:36 م (QP5 v5.185.11230.41888) */
- SELECT TD.TRMTSERVICEDETID
- FROM T_TRMTSERVICESHDR TH
- JOIN
- T_TRMTSERVICESDET TD
- ON TH.TRMTSERVICEHDRID = TD.TRMTSERVICEHDRID
- AND (TH.INJURYID = ?)
- AND TD.TRMTSRVCSTATUS <> ?
- AND (TD.ICD10TRMTDIAGNOSISCODE = ? OR TD.SFDACODE = ?)
- AND TD.TRMTDATE = ?
- AND TD.TRMTTIMEHR = ?
- AND TD.TRMTTIMEMIN = ?
- AND TD.TRMTTIMEAMPM = ?
- AND TRMTSERVICEDETID <> ?
- 5#
- /* Formatted on 21/12/16 02:50:38 م (QP5 v5.185.11230.41888) */
- SELECT TD.TRMTSERVICEDETID
- FROM T_TRMTSERVICESHDR TH
- JOIN
- T_TRMTSERVICESDET TD
- ON TH.TRMTSERVICEHDRID = TD.TRMTSERVICEHDRID
- AND (TH.DISASSMTID = ?)
- AND TD.TRMTSRVCSTATUS <> ?
- AND (TD.ICD10TRMTDIAGNOSISCODE = ? OR TD.SFDACODE = ?)
- AND TD.TRMTDATE = ?
- AND TD.TRMTTIMEHR = ?
- AND TD.TRMTTIMEMIN = ?
- AND TD.TRMTTIMEAMPM = ?
- AND TRMTSERVICEDETID <> ?
- 6#
- /* Formatted on 21/12/16 02:50:41 م (QP5 v5.185.11230.41888) */
- UPDATE T_TRMTSERVICESDET
- SET TRMTSRVCSTATUS = ?,
- TRMTSRVCWRKFLOID = ?,
- LASTMODIFIEDBY = ?,
- LASTMODIFIEDTIMESTAMP = ?
- WHERE TRMTSERVICEDETID = ?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement