public Integer getBreastCyclesCount(Long serviceId) {
    Integer returnInteger = 0;

    String hsql =
        "select  new health.state.mn.us.action.bill.RsdiServiceCount(count(distinct c.clientCycleId)) from BreastCycle c "
            + "left join c.rsdiFormVisitSummaries rsdiFormVisitSummaries "
            + "left join rsdiFormVisitSummaries.rsdiFormVisitSummary rsdiFormVisitSummary "
            + "left join c.rsdiFormImagingSummaries rsdiFormImagingSummaries "
            + "left join rsdiFormImagingSummaries.rsdiFormImagingSummary rsdiFormImagingSummary "
            + "left join c.rsdiFormAbnormalBreasts rsdiFormAbnormalBreasts "
            + "left join rsdiFormAbnormalBreasts.rsdiFormAbnormalBreast rsdiFormAbnormalBreast "
            + "left join c.rsdiFormBreastCases rsdiFormBreastCases "
            + "left join rsdiFormBreastCases.rsdiFormBreastCase rsdiFormBreastCase "
            + "left join c.rsdiFormBreastDiagnostics rsdiFormBreastDiagnostics "
            + "left join rsdiFormBreastDiagnostics.rsdiFormBreastDiagnostic rsdiFormBreastDiagnostic "
            + "where 1 = 1 ";

    try {

      if (serviceId != null) {
        hsql =
            hsql
                + "and ( "
                + "rsdiFormVisitSummary.serviceId = :serviceId "
                + "or rsdiFormImagingSummary.serviceId = :serviceId "
                + "or rsdiFormAbnormalBreast.serviceId = :serviceId "
                + "or rsdiFormBreastCase.serviceId = :serviceId "
                + "or rsdiFormBreastDiagnostic.serviceId = :serviceId "
                + ") ";
      }

      // hsql = hsql + "order by c.chargeCode asc ";

      Query q = getEntityManager().createQuery(hsql);

      if (serviceId != null) {
        q.setParameter("serviceId", serviceId);
      }

      RsdiServiceCount rsdiServiceCount = (RsdiServiceCount) q.getSingleResult();

      if (rsdiServiceCount != null) {
        returnInteger = rsdiServiceCount.getCount().intValue();
        if (rsdiServiceCount.getCount().intValue() > 0) {
          String s = "";
        }
      }

    } catch (Exception e) {
      System.out.println(">>>Error in query - getCervicalCycles");
      System.out.println(e.getMessage());
    }

    return returnInteger;
  }
  public Integer getBreastBxCyclesCount(Long serviceId) {
    Integer returnInteger = 0;

    String hsql =
        "select  new health.state.mn.us.action.bill.RsdiServiceCount(count(distinct c.clientCycleId)) from BreastCycle c "
            + "left join c.rsdiFormAbnormalBreasts rsdiFormAbnormalBreasts "
            + "left join rsdiFormAbnormalBreasts.rsdiFormAbnormalBreast rsdiFormAbnormalBreast "
            + "where 1 = 1 ";

    try {

      if (serviceId != null) {
        hsql = hsql + "and ( " + "rsdiFormAbnormalBreast.serviceId = :serviceId " + ") ";
      }

      hsql =
          hsql
              + "and ( "
              + "rsdiFormAbnormalBreast.repeatBreastExamDoneDate is not null "
              + "or rsdiFormAbnormalBreast.cystDoneDate is not null "
              + "or rsdiFormAbnormalBreast.fineNeedleDoneDate is not null "
              + "or rsdiFormAbnormalBreast.postBiopsyVisit is not null "
              + "or rsdiFormAbnormalBreast.postBiopsyDate is not null "
              + ") ";

      // hsql = hsql + "order by c.chargeCode asc ";

      Query q = getEntityManager().createQuery(hsql);

      if (serviceId != null) {
        q.setParameter("serviceId", serviceId);
      }
      RsdiServiceCount rsdiServiceCount = (RsdiServiceCount) q.getSingleResult();

      if (rsdiServiceCount != null) {
        returnInteger = rsdiServiceCount.getCount().intValue();
        if (rsdiServiceCount.getCount().intValue() > 0) {
          String s = "";
        }
      }

    } catch (Exception e) {
      System.out.println(">>>Error in query - getCervicalCycles");
      System.out.println(e.getMessage());
    }

    return returnInteger;
  }