Пример #1
0
  public Hashtable<String, Object> runReport(ArrayList<ArrayList<String>> list, Date asofDate) {

    int inList = 0;
    double done = 0, doneWithGrace = 0;
    ArrayList<PreventionReportDisplay> returnReport = new ArrayList<PreventionReportDisplay>();

    for (int i = 0; i < list.size(); i++) { // for each  element in arraylist
      ArrayList<String> fieldList = list.get(i);
      Integer demo = Integer.valueOf(fieldList.get(0));

      // search   prevention_date prevention_type  deleted   refused
      ArrayList<Map<String, Object>> prevs = PreventionData.getPreventionData("FOBT", demo);
      PreventionData.addRemotePreventions(prevs, demo, "FOBT", null);
      ArrayList<Map<String, Object>> colonoscopys =
          PreventionData.getPreventionData("COLONOSCOPY", demo);
      PreventionData.addRemotePreventions(colonoscopys, demo, "COLONOSCOPY", null);
      PreventionReportDisplay prd = new PreventionReportDisplay();
      prd.demographicNo = demo;
      prd.bonusStatus = "N";
      prd.billStatus = "N";
      Date prevDate = null;
      if (ineligible(prevs) || colonoscopywith5(colonoscopys, asofDate)) {
        prd.rank = 5;
        prd.lastDate = "------";
        prd.state = "Ineligible";
        prd.numMonths = "------";
        prd.color = "grey";
        inList++;
      } else if (prevs.size() == 0) { // no info
        prd.rank = 1;
        prd.lastDate = "------";
        prd.state = "No Info";
        prd.numMonths = "------";
        prd.color = "Magenta";
      } else {
        Map<String, Object> h = prevs.get(prevs.size() - 1);
        DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String prevDateStr = (String) h.get("prevention_date");

        try {
          prevDate = formatter.parse(prevDateStr);
        } catch (Exception e) {
          // empty
        }
        boolean refused = false;
        if (h.get("refused") != null && ((String) h.get("refused")).equals("1")) {
          refused = true;
        }

        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.YEAR, -2);
        Date dueDate = cal.getTime();
        cal.add(Calendar.MONTH, -6);
        Date cutoffDate = cal.getTime();

        Calendar cal2 = GregorianCalendar.getInstance();
        cal2.add(Calendar.YEAR, -2);
        // Date dueDate2 = cal.getTime();
        // cal2.roll(Calendar.YEAR, -1);
        cal2.add(Calendar.MONTH, -6);
        Date cutoffDate2 = cal2.getTime();

        log.info("cut 1 " + cutoffDate.toString() + " cut 2 " + cutoffDate2.toString());

        // if prevDate is less than as of date and greater than 2 years prior
        Calendar bonusEl = Calendar.getInstance();
        bonusEl.setTime(asofDate);
        bonusEl.add(Calendar.MONTH, -30);
        Date bonusStartDate = bonusEl.getTime();

        log.debug("\n\n\n prevDate " + prevDate);
        log.debug("bonusEl date " + bonusStartDate + " " + bonusStartDate.before(prevDate));
        log.debug("asofDate date" + asofDate + " " + asofDate.after(prevDate));
        String result = PreventionData.getExtValue((String) h.get("id"), "result");

        if (!refused
            && bonusStartDate.before(prevDate)
            && asofDate.after(prevDate)
            && !result.equalsIgnoreCase("pending")) {
          prd.bonusStatus = "Y";
          prd.billStatus = "Y";
          done++;
        }

        // Calendar today = Calendar.getInstance();
        // change as of date to run the report for a different year
        String numMonths = "------";
        if (prevDate != null) {
          int num = UtilDateUtilities.getNumMonths(prevDate, asofDate);
          numMonths = "" + num + " months";
        }

        // outcomes
        log.debug(
            "due Date "
                + dueDate.toString()
                + " cutoffDate "
                + cutoffDate.toString()
                + " prevDate "
                + prevDate.toString());
        log.debug(
            "due Date  ("
                + dueDate.toString()
                + " ) After Prev ("
                + prevDate.toString()
                + " ) "
                + dueDate.after(prevDate));
        log.debug(
            "cutoff Date  ("
                + cutoffDate.toString()
                + " ) before Prev ("
                + prevDate.toString()
                + " ) "
                + cutoffDate.before(prevDate));
        if (!refused && dueDate.after(prevDate) && cutoffDate.before(prevDate)) { // overdue
          prd.rank = 2;
          prd.lastDate = prevDateStr;
          prd.state = "due";
          prd.numMonths = numMonths;
          prd.color = "yellow"; // FF00FF
          doneWithGrace++;

        } else if (!refused && cutoffDate.after(prevDate)) { // overdue
          prd.rank = 2;
          prd.lastDate = prevDateStr;
          prd.state = "Overdue";
          prd.numMonths = numMonths;
          prd.color = "red"; // FF00FF

        } else if (refused) { // recorded and refused
          prd.rank = 3;
          prd.lastDate = "-----";
          prd.state = "Refused";
          prd.numMonths = numMonths;
          prd.color = "orange"; // FF9933
        } else if (dueDate.before(prevDate) && result.equalsIgnoreCase("pending")) {
          prd.rank = 4;
          prd.lastDate = prevDateStr;
          prd.state = "Pending";
          prd.numMonths = numMonths;
          prd.color = "pink";

        } else if (dueDate.before(prevDate)) { // recorded done
          prd.rank = 4;
          prd.lastDate = prevDateStr;
          prd.state = "Up to date";
          prd.numMonths = numMonths;
          prd.color = "green";
          // done++;
        }
      }
      letterProcessing(prd, "FOBF", asofDate, prevDate);
      returnReport.add(prd);
    }
    String percentStr = "0";
    String percentWithGraceStr = "0";
    double eligible = list.size() - inList;
    log.debug("eligible " + eligible + " done " + done);
    if (eligible != 0) {
      double percentage = (done / eligible) * 100;
      double percentageWithGrace = (done + doneWithGrace) / eligible * 100;
      log.debug("in percentage  " + percentage + " " + (done / eligible));
      percentStr = "" + Math.round(percentage);
      percentWithGraceStr = "" + Math.round(percentageWithGrace);
    }

    Collections.sort(returnReport);

    Hashtable<String, Object> h = new Hashtable<String, Object>();

    h.put("up2date", "" + Math.round(done));
    h.put("percent", percentStr);
    h.put("percentWithGrace", percentWithGraceStr);
    h.put("returnReport", returnReport);
    h.put("inEligible", "" + inList);
    h.put("eformSearch", "FOBT");
    h.put("followUpType", "FOBF");
    h.put("BillCode", "Q005A");
    log.debug("set returnReport " + returnReport);
    return h;
  }
Пример #2
0
  private String letterProcessing(
      PreventionReportDisplay prd, String measurementType, Date asofDate, Date prevDate) {
    if (prd != null) {
      boolean inclUpToDate = false;
      if (prd.state.equals("Up to date")) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(asofDate);
        cal.add(Calendar.YEAR, -2);
        Date dueDate = cal.getTime();
        cal.add(Calendar.MONTH, -6);
        Date cutoffDate = cal.getTime();

        if ((dueDate.after(prevDate) && cutoffDate.before(prevDate))
            || cutoffDate.after(prevDate)) {
          inclUpToDate = true;
        }
      }

      if (prd.state.equals("No Info")
          || prd.state.equals("due")
          || prd.state.equals("Overdue")
          || inclUpToDate) {

        // Get LAST contact method
        EctMeasurementsDataBeanHandler measurementDataHandler =
            new EctMeasurementsDataBeanHandler(prd.demographicNo, measurementType);
        log.debug("getting followup data for " + prd.demographicNo);

        Collection<EctMeasurementsDataBean> followupData =
            measurementDataHandler.getMeasurementsDataVector();
        // NO Contact

        if (followupData.size() == 0) {
          prd.nextSuggestedProcedure = this.LETTER1;
          return this.LETTER1;
        } else { // There has been contact

          Calendar oneyear = Calendar.getInstance();
          oneyear.setTime(asofDate);
          oneyear.add(Calendar.YEAR, -1);

          Calendar onemonth = Calendar.getInstance();
          onemonth.setTime(asofDate);
          onemonth.add(Calendar.MONTH, -1);

          Date observationDate = null;
          int count = 0;
          int index = 0;
          EctMeasurementsDataBean measurementData = null;

          @SuppressWarnings("unchecked")
          Iterator<EctMeasurementsDataBean> iterator = followupData.iterator();

          while (iterator.hasNext()) {
            measurementData = iterator.next();
            observationDate = measurementData.getDateObservedAsDate();

            if (index == 0) {
              log.debug("fluData " + measurementData.getDataField());
              log.debug(
                  "lastFollowup "
                      + measurementData.getDateObservedAsDate()
                      + " last procedure "
                      + measurementData.getDateObservedAsDate());
              log.debug("toString: " + measurementData.toString());
              prd.lastFollowup = observationDate;
              prd.lastFollupProcedure = measurementData.getDataField();

              if (measurementData.getDateObservedAsDate().before(oneyear.getTime())) {
                prd.nextSuggestedProcedure = this.LETTER1;
                return this.LETTER1;
              }

              if (prd.lastFollupProcedure.equals(this.PHONE1)) {
                prd.nextSuggestedProcedure = "----";
                return "----";
              }
            }

            log.debug(
                prd.demographicNo
                    + " obs"
                    + observationDate
                    + String.valueOf(observationDate.before(onemonth.getTime()))
                    + " OneYear "
                    + oneyear.getTime()
                    + " "
                    + String.valueOf(observationDate.after(oneyear.getTime())));
            if (observationDate.before(onemonth.getTime())
                && observationDate.after(oneyear.getTime())) {
              ++count;
            } else if (count > 1 && observationDate.after(oneyear.getTime())) {
              ++count;
            }

            ++index;
          }

          switch (count) {
            case 0:
              prd.nextSuggestedProcedure = this.LETTER1;
              break;
            case 1:
              prd.nextSuggestedProcedure = this.LETTER2;
              break;
            case 2:
              prd.nextSuggestedProcedure = this.PHONE1;
              break;
            default:
              prd.nextSuggestedProcedure = "----";
          }

          return prd.nextSuggestedProcedure;

          /*                      if ( measurementData.getDateObservedAsDate().before(onemonth.getTime())){
                                        if (prd.lastFollupProcedure.equals(this.LETTER1)){
                                              prd.nextSuggestedProcedure = this.LETTER2;
                                              return this.LETTER2;
                                        }else if(prd.lastFollupProcedure.equals(this.LETTER2)){
                                              prd.nextSuggestedProcedure = this.PHONE1;
                                              return this.PHONE1;
                                        }else{
                                            prd.nextSuggestedProcedure = "----";
                                            return "----";
                                        }

                                    }else if(prd.lastFollupProcedure.equals(this.LETTER2)){
                                        prd.nextSuggestedProcedure = this.PHONE1;
                                        return this.PHONE1;
                                    }else{
                                        prd.nextSuggestedProcedure = "----";
                                        return "----";
                                    }

          */

        }

      } else if (prd.state.equals("Refused")) { // Not sure what to do about refused
        // prd.lastDate = "-----";
        prd.nextSuggestedProcedure = "----";
        // prd.numMonths ;
      } else if (prd.state.equals("Ineligible")) {
        // Do nothing
        prd.nextSuggestedProcedure = "----";
      } else if (prd.state.equals("Pending")) {
        prd.nextSuggestedProcedure = this.CALLFU;
      } else if (prd.state.equals("Up to date")) {
        // Do nothing
        prd.nextSuggestedProcedure = "----";
      } else {
        log.debug("NOT SURE WHAT HAPPEND IN THE LETTER PROCESSING");
      }
    }
    return null;
  }