private void redisplayForm( DatabaseTransaction t, DbUserSession sessionUser, fdms.ui.struts.form.CemAnStatus form, ActionErrors errors) { // Don't retrieve data if Facility information has already been supplied. if (form.getFacilityName() != null && form.getFacilityName().trim().length() > 0) { return; } DbLocation dbLocation = FdmsDb.getInstance().getLocation(t, Integer.parseInt(form.getChapel())); form.setFacilityName(dbLocation.getName()); form.setFacilityStreet(dbLocation.getAddr1()); form.setFacilityCity(dbLocation.getCity()); form.setFacilityState(dbLocation.getState()); form.setFacilityZip(dbLocation.getZip()); form.setFacilityLicense(dbLocation.getLicenseNumber()); form.setFacilityPhone(FormatString.formatPhone(dbLocation.getPhone())); return; }
/** * Set the DbVitals and DbCase values from the FirstCallInformation form. Creation date: * (10/25/2002 11:00:39 AM) * * @param t com.aldorsolutions.webfdms.database.DatabaseTransaction * @param firstCall com.aldorsolutions.webfdms.beans.DbVitalsFirstCall * @param informant com.aldorsolutions.webfdms.beans.DbVitalsInformant * @param caseinfo com.aldorsolutions.webfdms.beans.DbCase * @param nextkin com.aldorsolutions.webfdms.beans.DbVitalsNextKin * @param nextkin com.aldorsolutions.webfdms.beans.DbVitalsExecutor * @param form fdms.ui.struts.form.FirstCallInformationForm * @param errors org.apache.struts.action.ActionErrors */ public void setVitalsRest( DatabaseTransaction t, DbUserSession sessionUser, DbVitalsDeceased deceased, DbVitalsFirstCall firstCall, DbVitalsInformant informant, DbCase caseinfo, DbVitalsNextKin nextkin, DbVitalsExecutor executor, DbCemAtneed cematneed, CemAnStatus form, ActionErrors errors) { boolean continueDuplicate = true; try { if (form.isExecutorSame()) { logger.debug("Executor is the same"); executor.setIsExecutorSame("Y"); executor.setExecutorPersonId(form.getExecutorPersonId()); executor.setExecutorFirstname(form.getInformantFirst()); executor.setExecutorLastname(form.getInformantLast()); executor.setExecutorStreet(form.getInformantStreet()); executor.setExecutorStreet2(form.getInformantStreet2()); executor.setExecutorStreet3(form.getInformantStreet3()); executor.setExecutorCity(form.getInformantCity()); executor.setExecutorState(form.getInformantState()); executor.setExecutorZip(form.getInformantZip()); executor.setExecutorPhone(FormatString.formatPhone(form.getInformantPhone())); executor.setExecutorRelation(form.getInformantRelation()); executor.setExecutorEmail(form.getInformantEmail()); // sets the vitals id for DbExecutor so I can insert values into database Persistent p = (Persistent) executor; p.setId(new Integer(form.getVitalsId()).intValue()); } else { logger.debug("Executor is not the same"); executor.setIsExecutorSame("N"); executor.setExecutorPersonId(form.getExecutorPersonId()); executor.setExecutorFirstname(form.getExecutorFirstName()); executor.setExecutorLastname(form.getExecutorLastName()); executor.setExecutorStreet(form.getExecutorStreet()); executor.setExecutorStreet2(form.getExecutorStreet2()); executor.setExecutorStreet3(form.getExecutorStreet3()); executor.setExecutorCity(form.getExecutorCity()); executor.setExecutorState(form.getExecutorState()); executor.setExecutorZip(form.getExecutorZip()); executor.setExecutorPhone(FormatString.formatPhone(form.getExecutorPhone())); executor.setExecutorRelation(form.getExecutorRelation()); executor.setExecutorEmail(form.getExecutorEmail()); // sets the vitals id for DbExecutor so I can insert values into database Persistent p = (Persistent) executor; p.setId(new Integer(form.getVitalsId()).intValue()); } firstCall.setArrangeDate(FormatDate.convertToDateMMDDYYYY(form.getArrangeDate())); firstCall.setDispositionDate(FormatDate.convertToDateMMDDYYYY(form.getDispDate())); firstCall.setOriginalPnDate(FormatDate.convertToDateMMDDYYYY(form.getPreneedDate())); firstCall.setArrangeTime(form.getTime()); firstCall.setPlaceDeathAddr(form.getLocationDeceased()); firstCall.setSource(form.getSource()); firstCall.setEmbalmingReason(form.getEmbalming()); firstCall.setPlaceDeath(form.getPlaceDeath()); firstCall.setPlaceDeathCity(form.getPlaceDeathCity()); firstCall.setPlaceDeathState(form.getPlaceDeathState()); firstCall.setPlaceDeathZip(form.getPlaceDeathZip()); firstCall.setAgeYears(FormatNumber.parseInteger(form.getAge())); int chapelId = 0; if (form.getChapel() != null) { try { chapelId = Integer.parseInt(form.getChapel()); } catch (NumberFormatException e) { // unable to parse int from String } } logger.debug("ChapelId : " + chapelId); DbLocation dbLocation = FdmsDb.getInstance().getLocation(t, chapelId); if (dbLocation != null) { firstCall.setFacilityName(dbLocation.getName()); firstCall.setFacilityStreet(dbLocation.getAddr1()); firstCall.setFacilityCityStZip( dbLocation.getCity() + ", " + dbLocation.getState() + ", " + dbLocation.getZip()); firstCall.setFacilityLicenseNo(dbLocation.getLicenseNumber()); firstCall.setFacilityPhone(FormatString.formatPhone(dbLocation.getPhone())); } else { firstCall.setFacilityName(form.getFacilityName()); firstCall.setFacilityStreet(form.getFacilityStreet()); firstCall.setFacilityCityStZip( form.getFacilityCity() + ", " + form.getFacilityState() + ", " + form.getFacilityZip()); firstCall.setFacilityPhone(FormatString.formatPhone(form.getFacilityPhone())); firstCall.setFacilityLicenseNo(form.getFacilityLicense()); } firstCall.setShippingInfo(form.getShippingInfo()); DbArrangers dbArranger = FdmsDb.getInstance().getArranger(t, Integer.parseInt(form.getDirector())); firstCall.setArrangerName(dbArranger.getName()); firstCall.setArrangerID(dbArranger.getId()); informant.setSalutation(form.getInformantSalutation()); informant.setFname(form.getInformantFirst()); informant.setMname(form.getInformantMiddle()); informant.setLname(form.getInformantLast()); informant.setStreet(form.getInformantStreet()); informant.setRoad2(form.getInformantStreet2()); informant.setRoad3(form.getInformantStreet3()); informant.setCity(form.getInformantCity()); informant.setState(form.getInformantState()); informant.setZip(form.getInformantZip()); informant.setPhone(FormatString.formatPhone(form.getInformantPhone())); informant.setRelated(form.getInformantRelation()); informant.setInformantEmail(form.getInformantEmail()); if (form.getNextKinSame()) { nextkin.setSameAsInformant("Y"); nextkin.setSalutation(form.getInformantSalutation()); nextkin.setFirstname(form.getInformantFirst()); nextkin.setLastname(form.getInformantLast()); nextkin.setStreet(form.getInformantStreet()); nextkin.setRoad2(form.getInformantStreet2()); nextkin.setRoad3(form.getInformantStreet3()); nextkin.setCity(form.getInformantCity()); nextkin.setState(form.getInformantState()); nextkin.setZip(form.getInformantZip()); nextkin.setPhone(FormatString.formatPhone(form.getInformantPhone())); nextkin.setRelation(form.getInformantRelation()); } else { nextkin.setSameAsInformant("N"); nextkin.setSalutation(form.getNextKinSalutation()); nextkin.setFirstname(form.getNextKinFirst()); nextkin.setLastname(form.getNextKinLast()); nextkin.setStreet(form.getNextKinStreet()); nextkin.setRoad2(form.getNextKinStreet2()); nextkin.setRoad3(form.getNextKinStreet3()); nextkin.setCity(form.getNextKinCity()); nextkin.setState(form.getNextKinState()); nextkin.setZip(form.getNextKinZip()); nextkin.setPhone(FormatString.formatPhone(form.getNextKinPhone())); nextkin.setRelation(form.getNextKinRelation()); } cematneed.setCem_plottype(form.getCem_plottype()); cematneed.setCem_section(form.getCem_section()); cematneed.setCem_block(form.getCem_block()); cematneed.setCem_lot_tier(form.getCem_lot_tier()); cematneed.setCem_grave_row(form.getCem_grave_row()); cematneed.setCem_Amount(form.getCem_Amount()); cematneed.setCem_ANBuyerAptNo(form.getCem_ANBuyerAptNo()); cematneed.setCem_ANBuyerCity(form.getCem_ANBuyerCity()); cematneed.setCem_ANBuyerMidName(form.getCem_ANBuyerMidName()); cematneed.setCem_ANBuyerTitle(form.getCem_ANBuyerTitle()); cematneed.setCem_ANBuyerPhone(form.getCem_ANBuyerPhone()); cematneed.setCem_ANBuyerState(form.getCem_ANBuyerState()); cematneed.setCem_ANBuyerStreet(form.getCem_ANBuyerStreet()); cematneed.setCem_ANBuyerFirstName(form.getCem_ANBuyerFirstName()); cematneed.setCem_ANBuyerLastName(form.getCem_ANBuyerLastName()); cematneed.setCem_ANBuyerZip(form.getCem_ANBuyerZip()); cematneed.setCem_MapID(form.getCem_MapID()); cematneed.setCem_Record(form.getCem_Record()); cematneed.setCem_ContractDate(form.getCem_ContractDate()); cematneed.setCem_MiscDesc(form.getCem_MiscDesc()); cematneed.setCem_MiscAmount(form.getCem_MiscAmount()); deceased.setDecFName(form.getBeneficiaryFirst()); deceased.setDecMName(form.getBeneficiaryMiddle()); deceased.setDecLName(form.getBeneficiaryLast()); deceased.setDecResStreet(form.getBeneficiaryStreet()); deceased.setDecResMailCity(form.getBeneficiaryCity()); deceased.setDecResState(form.getBeneficiaryState()); deceased.setDecResZip(form.getBeneficiaryZipCode()); deceased.setDecResPhone(form.getBeneficiaryPhone()); deceased.setSSNo(FormatString.removeDashes(form.getBeneficiarySocialSecurityNumber())); deceased.setDecFullName(form.getBeneficiaryFirst() + " " + form.getBeneficiaryLast()); deceased.setDecmrmrs(form.getBeneficiaryTitle()); deceased.setDecAptNo(form.getBeneficiaryAptno()); caseinfo.setChapelLocation(dbLocation.getName()); caseinfo.setChapelNumber(dbLocation.getId()); caseinfo.setLocale(dbLocation.getLocaleNumber()); caseinfo.setDeathDate(FormatDate.convertToDateYYYYMMDD(form.getDeathDate())); caseinfo.setServiceDate(FormatDate.convertToDateYYYYMMDD(form.getServiceDate())); caseinfo.setSaleDate(FormatDate.convertToDateYYYYMMDD(form.getServiceDate())); DatabaseTransaction x = null; // Regardless of whether the user changed the contract number or not, we need to make sure // that the // contract number is unique before we proceed. if (form.getContractNumber() != null && form.getContractNumber().trim().length() > 0) { try { x = (DatabaseTransaction) DatabaseTransaction.getTransaction(sessionUser); while (continueDuplicate) { // Check for duplicate Contract Numbers. DbCase checkCase = new DbCase(); checkCase.setNew(); checkCase.setLocale(sessionUser.getRegion()); checkCase.setId(deceased.getId()); checkCase.setContractCode(form.getContractNumber()); if (FdmsDb.getInstance().checkCaseExists(x, checkCase, DbCasePeer.CONTRACTCODE)) { // AppLog.trace("Contract " +form.getContractNumber() + " is a duplicate."); // If the user changed the contract number, give them an error if (!form.getNextContractNumber().equals(form.getContractNumber())) { errors.add( ActionErrors.GLOBAL_ERROR, new ActionError("error.duplicate.contractNumber")); formErrors.add("contractNumber"); continueDuplicate = false; } else { // contract number is same so need to increment and retest for duplicate form.setContractNumber( String.valueOf( SessionHelpers.nextContractNumber( sessionUser.getDbLookup(), sessionUser.getRegion()))); form.setNextContractNumber(form.getContractNumber()); // AppLog.trace("Incremented contract# because duplicated. New next // number="+form.getContractNumber()); } } else { continueDuplicate = false; } } } catch (Exception e) { logger.error("Error : ", e); } finally { if (x != null) { x.closeConnection(); x = null; } } } caseinfo.setContractCode(form.getContractNumber()); caseinfo.setCaseCode(form.getCaseNumber()); // Add Informant as BillTo if no BillTos already exist. DbBillto[] dbBillTo = FdmsDb.getInstance().getBilltoForID(t, deceased.getId()); if (dbBillTo == null || dbBillTo.length == 0) { if ((form.getInformantFirst() != null && form.getInformantFirst().trim().length() > 0) || (form.getInformantLast() != null && form.getInformantLast().trim().length() > 0)) { DbBillto newBillTo = new DbBillto(); newBillTo.setNew(); // newBillTo.setCashSale(); newBillTo.setCity(form.getInformantCity()); // newBillTo.setContractSigner(); // newBillTo.setCounty(); newBillTo.setEmailAddress(form.getInformantEmail()); // newBillTo.setFileVersion(); newBillTo.setFirstName(form.getInformantFirst()); newBillTo.setHomePhone(FormatString.formatPhone(form.getInformantPhone())); newBillTo.setHonorific(form.getInformantSalutation()); // newBillTo.setLanguage(form.getInformant); newBillTo.setLastName(form.getInformantLast()); // newBillTo.setRefused(form.getInformant); newBillTo.setRelation(form.getInformantRelation()); newBillTo.setSendInvoice("Y"); newBillTo.setSeqNo(Short.parseShort("0")); // newBillTo.setSocialSecurityNo(form.getInformant); newBillTo.setState(form.getInformantState()); newBillTo.setStreet1(form.getInformantStreet()); newBillTo.setStreet2(form.getInformantStreet2()); newBillTo.setStreet3(form.getInformantStreet3()); // newBillTo.setStreet4(form.getInformant); newBillTo.setVitalsID(deceased.getId()); // newBillTo.setWorkPhone(form.getInformant); newBillTo.setZip(form.getInformantZip()); if (form.getInformantContractSigner()) { newBillTo.setContractSigner("Y"); } t.addPersistent(newBillTo); } } } catch (Exception e) { logger.error("Exception in setVitalsRest() ", e); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.ui.setData")); } return; }