public ActionForward execute(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws javax.servlet.ServletException, java.io.IOException {

    logger.debug("********************************************");
    logger.debug("*** Entering ProcessFirstCallInformation ***");

    CemAnStatus form = (CemAnStatus) actionForm;
    ActionErrors errors = new ActionErrors();
    formErrors = new ArrayList();
    HttpSession session = request.getSession();
    DbUserSession sessionUser = (DbUserSession) session.getAttribute(SessionValueKeys.DB_USER);

    logger.debug("ExecutorSame request value : " + request.getParameter("executorSame"));

    DatabaseTransaction t = null;
    FdmsDb fdmsdb = null;
    DbVitalsDeceased deceased = null;
    DbVitalsInformant informant = null;
    DbVitalsFirstCall firstCall = null;
    DbCase caseinfo = null;
    DbVitalsNextKin nextkin = null;
    DbPreneed preneed = null;
    DbVitalsSchedule sched = null;
    DbVitalsExecutor executor = null;
    DbCemAtneed cematneed = null;
    boolean addmode = false;
    int vitalsid = 0;
    String directive = form.getDirective();

    // Try to set the vitalsid from the form.
    try {
      vitalsid = FormatNumber.parseInteger(form.getVitalsId());
    } catch (Exception e) {
      vitalsid = 0;
    }

    cematneed = new DbCemAtneed();
    cematneed.setNew();

    if (directive.equals("cancel")) {
      // go back to case status unless no vitalsid then, show introduction.
      vitalsid = SessionHelpers.getVitalsIdFromSession(request, sessionUser);
      if (vitalsid > 0) {
        return mapping.findForward("showCaseStatusGlobal");
      } else {
        return mapping.findForward("ShowIntroductionGlobal");
      }
    }

    if (directive.equals("help")) {
      return mapping.findForward("usingHelp");
    }

    // From this point, we need to access the database
    try {
      t = (DatabaseTransaction) DatabaseTransaction.getTransaction(sessionUser);
      fdmsdb = FdmsDb.getInstance();

      if (directive.equals("redisplay")) {
        redisplayForm(t, sessionUser, form, errors);
        form.setDirective(" ");
        session.setAttribute("cemAnStatus", form);
        return new ActionForward(mapping.getInput());
      }

      validateForm(t, sessionUser, form, errors);
      // if errors found, return to input screen without saving anything
      if (!errors.isEmpty()) {
        // AppLog.info("ProcessFirstCall Invoking forward mapping getInput() after validation.");
        saveErrors(request, errors);
        request.setAttribute("formErrors", formErrors);

        form.setDirective(" ");
        session.setAttribute("cemAnStatus", form);
        return new ActionForward(mapping.getInput());
      } else {
        // AppLog.trace("ProcessFirstCall past validation.");
      }

      // Get the DbVitalDeceased and DbVitalsFirstCall objects
      if (vitalsid == 0) {
        deceased = new DbVitalsDeceased();
        deceased.setNew();
        addmode = true;
      } else {
        deceased = fdmsdb.getVitalsDeceased(t, vitalsid);
      }

      // Set the data in the DbVitalsDeceased and DbVitalsFirstCall records
      setVitalsDeceased(deceased, informant, form, errors);
      // if errors found, return to input screen without saving anything
      if (!errors.isEmpty()) {
        // AppLog.info("ProcessFirstCall Invoking forward mapping getInput() after
        // setVitalsDeceased.");
        saveErrors(request, errors);
        request.setAttribute("formErrors", formErrors);
        session.setAttribute("cemAnStatus", form);
        form.setDirective(" ");
        return new ActionForward(mapping.getInput());
      } else {
        // AppLog.trace("ProcessFirstCall past setVitalsDeceased.");
      }

      if (vitalsid == 0) {
        t.addPersistent(deceased);
        t.save();
        t.closeConnection();
        t = null;

        vitalsid = deceased.getId();
        form.setVitalsId(String.valueOf(vitalsid));
        sessionUser.setCurrentCaseID(vitalsid);
        // Need another transaction to continue with add
        t = (DatabaseTransaction) DatabaseTransaction.getTransaction(sessionUser);
        // increment next contract number if user did not change it
        // and assign to this case
        // if user changed contract# then use the one they entered.
        if (form.getContractNumber().equals(form.getNextContractNumber())) {
          int newnextno =
              SessionHelpers.nextContractNumber(sessionUser.getDbLookup(), sessionUser.getRegion());
          form.setContractNumber(String.valueOf(newnextno));
          form.setNextContractNumber(form.getContractNumber());
          // need new transaction since save in above method ends that transaction
        }
        sched = fdmsdb.getVitalsSchedule(t, vitalsid);
        sched.setDefaultAtNeedCheckList(sessionUser.getRegion(), sessionUser.getDbLookup());
      } else {
        sched = fdmsdb.getVitalsSchedule(t, vitalsid);
      }

      // Now, lets update the other Vitals information
      SessionHelpers.setVitalsIdInRequest(request, vitalsid);
      firstCall = fdmsdb.getVitalsFirstCall(t, vitalsid);
      informant = fdmsdb.getVitalsInformant(t, vitalsid);
      caseinfo = fdmsdb.getCase(t, vitalsid);
      nextkin = fdmsdb.getVitalsNextKin(t, vitalsid);
      executor = fdmsdb.getVitalsExecutor(t, vitalsid);
      // cematneed = fdmsdb.getCemAtneed(t, vitalsid);
      if (executor == null) {
        executor = new DbVitalsExecutor();
        executor.setNew();
      }
      setVitalsRest(
          t,
          sessionUser,
          deceased,
          firstCall,
          informant,
          caseinfo,
          nextkin,
          executor,
          cematneed,
          form,
          errors);
      // if errors found, return to input screen without saving anything
      if (!errors.isEmpty()) {
        // AppLog.info("ProcessFirstCall Invoking forward mapping getInput() after setVitalsRest.");
        saveErrors(request, errors);
        request.setAttribute("formErrors", formErrors);
        session.setAttribute("cemAnStatus", form);
        form.setDirective(" ");
        return new ActionForward(mapping.getInput());
      } else {
        logger.debug("no errors exist in processfirstcall information");
        // AppLog.trace("ProcessFirstCall past setVitalsRest.");
      }

      // determine whether active preneed or deceased
      preneed = fdmsdb.getPreneed(t, vitalsid);
      String relation = "Deceased";
      if (preneed.getStatus().equals(DbPreneed.ACTIVE)) {
        relation = "Preneed";
      }
      t.removePersistent(preneed);

      // update special survivor information for searching deceased, informant, case#, contract#
      DbSurvivor.addUpdateSurvivor(
          t,
          vitalsid,
          DbSurvivor.DECEASED,
          deceased.getSalutation(),
          deceased.getDecFName(),
          deceased.getDecMName(),
          deceased.getDecLName(),
          deceased.getSuffix(),
          deceased.getMaidenName(),
          deceased.getFullName(),
          deceased.getDecResStreet() + " " + deceased.getDecAptNo(),
          "",
          deceased.getDecResMailCity(),
          deceased.getDecResState(),
          deceased.getDecResZip(),
          "",
          "",
          "",
          relation,
          "",
          "",
          "");
      DbSurvivor.addUpdateSurvivor(
          t,
          vitalsid,
          DbSurvivor.INFORMANT,
          informant.getSalutation(),
          informant.getFname(),
          informant.getMname(),
          informant.getLname(),
          "",
          "",
          "",
          informant.getStreet() + " " + informant.getRoad2() + " " + informant.getRoad3(),
          "",
          informant.getCity(),
          informant.getState(),
          informant.getZip(),
          informant.getPhone(),
          "",
          informant.getInformantEmail(),
          "Informant",
          "",
          "",
          "");
      DbSurvivor.addUpdateSurvivor(
          t,
          vitalsid,
          DbSurvivor.CONTRACT,
          "",
          deceased.getDecLName(),
          "",
          caseinfo.getContractCode(),
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          deceased.getDecFName(),
          "",
          "",
          "");
      DbSurvivor.addUpdateSurvivor(
          t,
          vitalsid,
          DbSurvivor.CASECODE,
          "",
          deceased.getDecLName(),
          "",
          caseinfo.getCaseCode(),
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          "",
          deceased.getDecFName(),
          "",
          "",
          "");

      // add informant and next-of-kin as normal survivors but only during add cycle
      if (addmode) {
        // AppLog.trace("Adding informant and NOK as survivors.");
        DbSurvivor infsurv =
            new DbSurvivor(
                vitalsid,
                informant.getSalutation(),
                informant.getFname(),
                informant.getMname(),
                informant.getLname(),
                "",
                "",
                "",
                informant.getStreet() + " " + informant.getRoad2() + " " + informant.getRoad3(),
                "",
                informant.getCity(),
                informant.getState(),
                informant.getZip(),
                informant.getPhone(),
                "",
                informant.getInformantEmail(),
                informant.getRelated(),
                "",
                "",
                "",
                "");
        t.addPersistent(infsurv);
        if (!form.getNextKinSame()) {
          DbSurvivor noksurv =
              new DbSurvivor(
                  vitalsid,
                  nextkin.getSalutation(),
                  nextkin.getFirstname(),
                  "",
                  nextkin.getLastname(),
                  "",
                  "",
                  "",
                  nextkin.getStreet() + nextkin.getRoad2() + " " + nextkin.getRoad3(),
                  "",
                  nextkin.getCity(),
                  nextkin.getState(),
                  nextkin.getZip(),
                  nextkin.getPhone(),
                  "",
                  "",
                  nextkin.getRelation(),
                  "",
                  "",
                  "",
                  "");
          t.addPersistent(noksurv);
        }
      }
      t.addPersistent(cematneed);

      if (executor != null) t.addPersistent(executor);

      // Final commit and cleanup
      t.save();

    } catch (PersistenceException pe) {
      logger.error("PersistenceException in doPerform() : ", pe);
      errors.add(
          ActionErrors.GLOBAL_ERROR, new ActionError("error.PersistenceException", pe.getCause()));
    } catch (Exception pe) {
      logger.error("Error in doPerform() : ", pe);
      errors.add(
          ActionErrors.GLOBAL_ERROR, new ActionError("error.GeneralException", pe.getMessage()));
    } finally {
      if (t != null) {
        try {
          t.closeConnection();
          t = null;
        } catch (Exception e) {
          logger.error("Error in closeConnection() : ", e);
        }
      }
    }

    if (!errors.isEmpty()) {
      // AppLog.info("ProcessFirstCallInformation Invoking forward mapping getInput().");
      saveErrors(request, errors);
      request.setAttribute("formErrors", formErrors);
      form.setDirective(" ");
      session.setAttribute("cemAnStatus", form);
      return (new ActionForward(mapping.getInput()));
    }

    // remove session variables used in FirstCall page
    SessionHelpers.removeArrangerListFromSession(request);
    SessionHelpers.removeChapelListInSession(request);
    session.removeAttribute("cemAnStatus");
    SessionHelpers.setVitalsIdInRequest(request, vitalsid);

    // Since we are forwarding to another ACTION, need to go through this exercise
    /*	ActionMappings mappings = mapping.getMappings();
           String returnPath = actionForward.getPath();
           int periodpos = returnPath.indexOf(".do");
           returnPath = returnPath.substring(0,periodpos);
           ActionMapping finalMapping = mappings.findMapping(returnPath);
           Action finalAction = null;

           try {
               Class clazz = Class.forName(finalMapping.getType());
               finalAction = (Action) clazz.newInstance();
               AppLog.trace("chaining to:"+finalAction.toString());
           } catch (Exception e) {
               AppLog.warning("Could not find chained action: " + e.getMessage());
               return forwardGlobalCancel(mapping) ;
           }

           return finalAction.perform(finalMapping,form,request,response);
    */
    // return forwardShowCaseStatusGlobal(mapping);

    if (errors.isEmpty()) {
      request.setAttribute("redirect", Boolean.TRUE);
      request.setAttribute("vitalsId", new Integer(vitalsid));
    }
    return new ActionForward(mapping.getInput());
  }