Package beans.report.selectors.disease.sicklist

Source Code of beans.report.selectors.disease.sicklist.SickTimeReportSelector

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package beans.report.selectors.disease.sicklist;

import beans.report.selectors.disease.*;
import beans.directory.mkb10.entity.Mkb10;
import beans.directory.simple.entities.DisabilityType;
import framework.utils.DateTimeUtils;
import java.util.ArrayList;
import java.util.Date;
import javax.persistence.EntityManager;

/**
*
* @author finder
*/
public class SickTimeReportSelector extends SickListDataSelector {
  protected static final int      SPECIAL_LINE_TYPE_IGNORE_SANATORIUM_HEALING = 1;
  protected static final int      SPECIAL_LINE_TYPE_DISEATED_SUPPORT = 2;
  protected static final int      SPECIAL_LINE_TYPE_QUARANTINE = 3;
  protected static final int      SPECIAL_LINE_TYPE_ABORTION = 4;
  protected static final int      SPECIAL_LINE_TYPE_MATERNITY_LEAVE = 5;
  protected static final int      SPECIAL_LINE_TYPE_SANATORIUM_HEALING = 6;
  protected static final int      SPECIAL_LINE_TYPE_TOTAL = 7;
     
  public SickTimeReportSelector(EntityManager manager, ArrayList<DiseaseLine> lines) {
    super(manager, lines);
  }

  @Override
  protected boolean isValidForLine(SickListElement ds, DiseaseLine line) {
    int          disType = ds.getDisType().getId();
    switch (getSpecialLineTypeID()){
      case SPECIAL_LINE_TYPE_NORMAL:
        if (disType != DisabilityType.DISABILITY_TYPE_DISEATED_SUPPORT
            //&& disType != DisabilityType.DISABILITY_TYPE_MATERNITY_LEAVE
            && disType != DisabilityType.DISABILITY_TYPE_SANATORIUM_HEALING){
          return super.isValidForLine(ds, line);
        }
        else{
          return false;
        }
      case SPECIAL_LINE_TYPE_IGNORE_SANATORIUM_HEALING:
        Mkb10      dsMkb = getMkbForItem(ds);
        if (disType == DisabilityType.DISABILITY_TYPE_SANATORIUM_HEALING){
          return isExcludedFromLine(dsMkb, line);
        }
        else if (disType != DisabilityType.DISABILITY_TYPE_DISEATED_SUPPORT
            && disType != DisabilityType.DISABILITY_TYPE_MATERNITY_LEAVE){
          return isIncludedToLine(dsMkb, line) || isExcludedFromLine(dsMkb, line);
        }
        else{
          return false;
        }
      case SPECIAL_LINE_TYPE_DISEATED_SUPPORT:
        return disType == DisabilityType.DISABILITY_TYPE_DISEATED_SUPPORT;
      case SPECIAL_LINE_TYPE_QUARANTINE:
        if (disType == DisabilityType.DISABILITY_TYPE_QUARANTINE) {
          return !isExcludedFromLine(getMkbForItem(ds), line);
        }
        else {
          return isIncludedToLine(getMkbForItem(ds), line);
        }
      case SPECIAL_LINE_TYPE_ABORTION:
        if (disType == DisabilityType.DISABILITY_TYPE_ABORTION) {
          return !isExcludedFromLine(getMkbForItem(ds), line);
        }
        else {
          return isIncludedToLine(getMkbForItem(ds), line);
        }
      case SPECIAL_LINE_TYPE_MATERNITY_LEAVE:
        if (disType == DisabilityType.DISABILITY_TYPE_MATERNITY_LEAVE) {
          return !isExcludedFromLine(getMkbForItem(ds), line);
        }
        else {
          return super.isValidForLine(ds, line);
        }
      case SPECIAL_LINE_TYPE_SANATORIUM_HEALING:
        if (disType == DisabilityType.DISABILITY_TYPE_SANATORIUM_HEALING) {
          return !isExcludedFromLine(getMkbForItem(ds), line);
        }
        else {
          return isIncludedToLine(getMkbForItem(ds), line);
        }
      case SPECIAL_LINE_TYPE_TOTAL:
        return true;
      default:
        throw new IllegalArgumentException("Неизвестный тип специальной линии");
    }
  }

  @Override
  protected void addDataItem(SickListElement ds, SicklistTableLineData data) {
    SickListElement      cur = ds;
    int            lenInDay = 0;
    while (cur != null){
      ds = cur;
      lenInDay +=DateTimeUtils.daysBetween(cur.getDateOpen(), cur.getDateClose());
      cur = cur.getRefItem();
    }
    boolean          isMale = isMale(ds);
    Date          born = ds.getClientBorn();
    Date          mark = ds.getDateOpen();
    data.incData(lenInDay, isMale, born, mark);
  }
}
TOP

Related Classes of beans.report.selectors.disease.sicklist.SickTimeReportSelector

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.