All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.imsweb.algorithms.iccc.IcccExecutableSiteGroupDto Maven / Gradle / Ivy

package com.imsweb.algorithms.iccc;

import java.util.List;

import com.imsweb.algorithms.internal.Utils;

/**
 * Internal site group DTO used to calculate the recode, this class should not be used outside of SEER*Utils...
 * User: depryf
 * Date: 8/22/12
 */
public class IcccExecutableSiteGroupDto {

    /**
     * Unique identifier
     */
    private String _id;

    /**
     * Name of the group
     */
    private String _name;

    /**
     * Site inclusions (single integer values or ranges)
     */
    private List _siteInclusions;

    /**
     * Site exclusions (single integer values or ranges)
     */
    private List _siteExclusions;

    /**
     * Histology inclusions (single integer values or ranges)
     */
    private List _histologyInclusions;

    /**
     * Histology exclusions (single integer values or ranges)
     */
    private List _histologyExclusions;

    /**
     * Behavior inclusions (single integer values
     */
    private List _behaviorInclusions;

    /**
     * Recode
     */
    private String _recode;

    private String _recodeExtended;

    public String getId() {
        return _id;
    }

    public String getName() {
        return _name;
    }

    public List getSiteInclusions() {
        return _siteInclusions;
    }

    public List getSiteExclusions() {
        return _siteExclusions;
    }

    public List getHistologyInclusions() {
        return _histologyInclusions;
    }

    public List getHistologyExclusions() {
        return _histologyExclusions;
    }

    public List getBehaviorInclusions() {
        return _behaviorInclusions;
    }

    public String getRecode() {
        return _recode;
    }

    public String getRecodeExtended() {
        return _recodeExtended;
    }

    public void setId(String id) {
        _id = id;
    }

    public void setSiteInclusions(List siteInclusions) {
        _siteInclusions = siteInclusions;
    }

    public void setSiteExclusions(List siteExclusions) {
        _siteExclusions = siteExclusions;
    }

    public void setHistologyInclusions(List histologyInclusions) {
        _histologyInclusions = histologyInclusions;
    }

    public void setHistologyExclusions(List histologyExclusions) {
        _histologyExclusions = histologyExclusions;
    }

    public void setBehaviorInclusions(List behaviorInclusions) {
        _behaviorInclusions = behaviorInclusions;
    }

    public void setName(String name) {
        _name = name;
    }

    public void setRecode(String recode) {
        _recode = recode;
    }

    public void setRecodeExtended(String recodeExtended) {
        _recodeExtended = recodeExtended;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o)
            return true;
        if (o == null || getClass() != o.getClass())
            return false;

        IcccExecutableSiteGroupDto that = (IcccExecutableSiteGroupDto)o;

        return !(_id != null ? !_id.equals(that._id) : that._id != null);

    }

    @Override
    public int hashCode() {
        return _id != null ? _id.hashCode() : 0;
    }

    public boolean matches(Integer site, Integer histology, Integer behavior) {
        boolean siteOk, histOk = false, behavOk = false;

        // check site
        if (_siteInclusions != null)
            siteOk = Utils.isContained(_siteInclusions, site);
        else if (_siteExclusions != null)
            siteOk = !Utils.isContained(_siteExclusions, site);
        else
            siteOk = true;

        // check histology (only if site matched)
        if (siteOk) {
            if (_histologyInclusions != null)
                histOk = Utils.isContained(_histologyInclusions, histology);
            else if (_histologyExclusions != null)
                histOk = !Utils.isContained(_histologyExclusions, histology);
            else
                histOk = true;
        }

        //Check the behavior
        if (siteOk && histOk) {
            if (_behaviorInclusions != null)
                behavOk = Utils.isContained(_behaviorInclusions, behavior);
            else
                behavOk = true;
        }

        return siteOk && histOk && behavOk;
    }
}