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

com.imsweb.validation.edits.seer.SeerCompiledRules.groovy Maven / Gradle / Ivy

There is a newer version: 024-13
Show newest version
package com.imsweb.validation.edits.seer

import com.imsweb.validation.functions.StagingContextFunctions
import com.imsweb.validation.runtime.CompiledRules
import groovy.transform.CompileStatic

@CompileStatic
class SeerCompiledRules implements CompiledRules {

    @Override
    public String getValidatorId() {
        return 'seer'
    }

    @Override
    public String getValidatorVersion() {
        return 'SE24-024-11'
    }

    @Override
    public Map>> getMethodParameters() {
        return [
            'lines' : [Binding.class, Map.class, StagingContextFunctions.class, List.class],
            'lines.line' : [Binding.class, Map.class, StagingContextFunctions.class, List.class, Map.class]
        ]
    }

    // ID: Address_at_DX_State; NAME: Addr at DX--State (NAACCR)
    public boolean address_at_dx_state(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return ((Map)context.Diagnosis_State).containsKey(line.addrAtDxState)
    }

    // ID: Age_at_Diagnosis; NAME: Age at Diagnosis (SEER AGEDX)
    public boolean age_at_diagnosis(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return functions.matches(line.ageAtDiagnosis, /^(999|0\d\d|1[0-1]\d|120)$/)
    }

    // ID: AJCC_TNM_Post_Therapy_Clin_Stage_Group; NAME: AJCC TNM Post Therapy Clin (yc) Stage Group (COC)
    public boolean ajcc_tnm_post_therapy_clin_stage_group(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.ajccTnmPostTherapyClinStageGrp == null
    }

    // ID: Behavior_Code_ICD-O-3; NAME: Behavior ICDO3 (COC)
    public boolean behavior_code_icdO3(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.behaviorCodeIcdO3 == null || functions.matches(line.behaviorCodeIcdO3, /^[0123]$/)
    }

    // ID: Behavior_Code_ICD-O-3_Submission; NAME: SEER Submission Edit 01 (SEER)
    public boolean behavior_code_icdO3_submission(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return  line.behaviorCodeIcdO3 != null
    }

    // ID: Behavior_ICDO3_Submission; NAME: SEER Submission Edit 02 (SEER)
    public boolean behavior_icdo3_submission(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (    line.dateOfDiagnosisYear >= '2001'
             && line.dateOfDiagnosisYear <= '2003'
             && line.behaviorCodeIcdO3 != '2'
             && line.behaviorCodeIcdO3 != '3'
           )
            return false
        return true
    }

    // ID: Birthplace_Country; NAME: Birthplace--Country (NAACCR)
    public boolean birthplace_country(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return ((Map)context.Country_State).containsKey(line.birthplaceCountry)
    }

    // ID: Birthplace_State; NAME: Birthplace--State (NAACCR)
    public boolean birthplace_state(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return ((Map)context.State).containsKey(line.birthplaceState)
    }

    // ID: Cancer_Status; NAME: Cancer Status (NAACCR)
    public boolean cancer_status(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.cancerStatus == null || functions.matches(line.cancerStatus, /^[129]$/)
    }

    // ID: Cause_of_Death; NAME: Cause of Death (SEER COD)
    public boolean cause_of_death(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return functions.matches(line.causeOfDeath, /^[A-Z0-9][0-9][0-9][0-9]?$/)
    }

    // ID: Census_Cod_Sys_1970-80-90; NAME: Census Cod Sys 1970/80/90 (SEER RESSYST)
    public boolean census_cod_sys_19708090(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if ( line.censusCodSys19708090 != null
             && !(functions.matches(line.censusCodSys19708090, /^[0-3\s]$/))
           )
            return false
        return true
    }

    // ID: Census_Tr_Cert_1970-80-90; NAME: Census Tr Cert 1970/80/90 (SEER CENSCERT)
    public boolean census_tr_cert_19708090(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if ( line.censusTrCert19708090 != null && !(functions.matches(line.censusTrCert19708090, /^[1234569\s]$/)))
            return false
        return true
    }

    // ID: Census_Tr_Certainty_2000; NAME: Census Tr Certainty 2000 (SEER)
    public boolean census_tr_certainty_2000(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return  line.censusTrCertainty2000 == null || functions.matches(line.censusTrCertainty2000, /^[1234569\s]$/)
    }

    // ID: Census_Tr_Certainty_2010; NAME: Census Tr Certainty 2010 (SEER)
    public boolean census_tr_certainty_2010(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return  line.censusTrCertainty2010 == null || functions.matches(line.censusTrCertainty2010, /^[1234569\s]$/)
    }

    // ID: Census_Tr_Certainty_2020; NAME: Census Tr Certainty 2020 (NAACCR)
    public boolean census_tr_certainty_2020(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return  line.censusTractCertainty2020 == null || functions.matches(line.censusTractCertainty2020, /^[1234569\s]$/)
    }

    // ID: Census_Tract_1970-80-90; NAME: Census Tract 1970/80/90 (SEER TRACT)
    public boolean census_tract_19708090(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.censusTract19708090 != null && line.censusTract19708090 != '000000' && line.censusTract19708090 != '999999'
                && (!(functions.matches(line.censusTract19708090, /^[0-9]{6}$/)) || !functions.between(line.censusTract19708090, '000100', '9999998')))
              return false
        return true
    }

    // ID: Census_Tract_2000; NAME: Census Tract 2000 (SEER)
    public boolean census_tract_2000(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.censusTract2000 == null || line.censusTract2000 == '000000' || (functions.matches(line.censusTract2000, /^[0-9]{6}$/) && functions.between(line.censusTract2000, '000100', '999999'))
    }

    // ID: Census_Tract_2010; NAME: Census Tract 2010 (SEER)
    public boolean census_tract_2010(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.censusTract2010 == null || line.censusTract2010 == '000000' || (functions.matches(line.censusTract2010, /^[0-9]{6}$/) && functions.between(line.censusTract2010, '000100', '999999'))
    }

    // ID: Census_Tract_2020; NAME: Census Tract 2020 (NAACCR)
    public boolean census_tract_2020(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.censusTract2020 == null || line.censusTract2020 == '000000' || (functions.matches(line.censusTract2020, /^[0-9]{6}$/) && functions.between(line.censusTract2020, '000100', '999999'))
    }

    // ID: Census_Tract_Block_Group_2000; NAME: Census Block Group 2000 (NAACCR)
    public boolean census_tract_block_group_2000(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.censusBlockGroup2000 == null || functions.matches(line.censusBlockGroup2000, /^[0-9]$/)
    }

    // ID: Census_Tract_Block_Group_708090; NAME: Census Block Grp 1970-90 (NAACCR)
    public boolean census_tract_block_group_708090(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.censusBlockGrp197090 == null || functions.matches(line.censusBlockGrp197090, /^[0-9]$/)
    }

    // ID: CoC_Accredited_Flag; NAME: CoC Accredited Flag (NPCR)
    public boolean coc_accredited_flag(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.cocAccreditedFlag == null || functions.matches(line.cocAccreditedFlag, /^[012]$/)
    }

    // ID: Coding_System_for_EOD; NAME: Coding System for EOD (SEER EODSYST)
    public boolean coding_system_for_eod(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.codingSystemForEod == null || functions.matches(line.codingSystemForEod, /^[0-4\s]$/)
    }

    // ID: County_at_DX_Analysis; NAME: County at DX Analysis (NAACCR)
    public boolean county_at_dx_analysis(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.countyAtDxAnalysis == null || functions.matches(line.countyAtDxAnalysis, /^\d\d[1-9]|\d[1-9]0|[1-9]\d0$/)
    }

    // ID: County_at_DX_Geocode1990; NAME: County at DX Geocode 1970/80/90 (NAACCR)
    public boolean county_at_dx_geocode1990(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.countyAtDxGeocode1990 == null || (functions.matches(line.countyAtDxGeocode1990, /^\d\d\d$/) && line.countyAtDxGeocode1990 != '000')
    }

    // ID: County_at_DX_Geocode2000; NAME: County at DX Geocode2000 (NAACCR)
    public boolean county_at_dx_geocode2000(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.countyAtDxGeocode2000 == null || (functions.matches(line.countyAtDxGeocode2000, /^\d\d\d$/) && line.countyAtDxGeocode2000 != '000')
    }

    // ID: County_at_DX_Geocode2010; NAME: County at DX Geocode2010 (NAACCR)
    public boolean county_at_dx_geocode2010(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.countyAtDxGeocode2010 == null || (functions.matches(line.countyAtDxGeocode2010, /^\d\d\d$/) && line.countyAtDxGeocode2010 != '000')
    }

    // ID: County_at_DX_Geocode2020; NAME: County at DX Geocode2020 (NAACCR)
    public boolean county_at_dx_geocode2020(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.countyAtDxGeocode2020 == null || (functions.matches(line.countyAtDxGeocode2020, /^\d\d\d$/) && line.countyAtDxGeocode2020 != '000')
    }

    // ID: County_Submission; NAME: SEER Submission Edit 01 (SEER)
    public boolean county_submission(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.countyAtDxAnalysis != null
    }

    // ID: Covid_19_Antibody_Test; NAME: Covid-19 Antibody Test and Date
    public boolean covid_19_antibody_test(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.covid19AntibodyTest != '1' || line.covid19AntibodyTestDateYear != null
    }

    // ID: Covid_19_Antibody_Test_Date; NAME: Covid-19 Antibody Test Date
    public boolean covid_19_antibody_test_date(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.covid19AntibodyTestDateYear == null)
           return (line.covid19AntibodyTestDateMonth == null && line.covid19AntibodyTestDateDay == null)
        
        if (line.covid19AntibodyTestDateYear < '2019')
            return false
        
        Integer year = functions.asInt(line.covid19AntibodyTestDateYear)
        Integer month = functions.asInt(line.covid19AntibodyTestDateMonth)
        Integer day = functions.asInt(line.covid19AntibodyTestDateDay)
        
        Integer yearCur  = functions.getCurrentYear()
        Integer monthCur = functions.getCurrentMonth()
        Integer dayCur = functions.getCurrentDay()
        
        if ((line.covid19AntibodyTestDateMonth == null && line.covid19AntibodyTestDateDay != null) || (month > 12 || (line.covid19AntibodyTestDateMonth != null && month < 1)))
           return false
        
        if (!functions.between(year, 1930, yearCur))
            return false
        
        if (line.covid19AntibodyTestDateMonth == null) //by now year fits and day is null if month is null
            return true
        
        if (year == yearCur && month > monthCur)
            return false
        
        if (line.covid19AntibodyTestDateDay == null) //by now year and month fit
            return true
        
        if (year == yearCur && month == monthCur && day > dayCur)
            return false
        
        Calendar cal = new GregorianCalendar(year, month - 1, 1)
        return cal != null && day <= cal.getActualMaximum(Calendar.DAY_OF_MONTH)
    }

    // ID: Covid_19_Decision_To_Delay_Date; NAME: Covid-19 Decision to Delay Date
    public boolean covid_19_decision_to_delay_date(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.covid19DecisionToDelayDateYear == null)
           return (line.covid19DecisionToDelayDateMonth == null && line.covid19DecisionToDelayDateDay == null)
        
        if (line.covid19DecisionToDelayDateYear < '2019')
            return false
        
        Integer year = functions.asInt(line.covid19DecisionToDelayDateYear)
        Integer month = functions.asInt(line.covid19DecisionToDelayDateMonth)
        Integer day = functions.asInt(line.covid19DecisionToDelayDateDay)
        
        Integer yearCur  = functions.getCurrentYear()
        Integer monthCur = functions.getCurrentMonth()
        Integer dayCur = functions.getCurrentDay()
        
        if ((line.covid19DecisionToDelayDateMonth == null && line.covid19DecisionToDelayDateDay != null) || (month > 12 || (line.covid19DecisionToDelayDateMonth != null && month < 1)))
           return false
        
        if (!functions.between(year, 1930, yearCur))
            return false
        
        if (line.covid19DecisionToDelayDateMonth == null) //by now year fits and day is null if month is null
            return true
        
        if (year == yearCur && month > monthCur)
            return false
        
        if (line.covid19DecisionToDelayDateDay == null) //by now year and month fit
            return true
        
        if (year == yearCur && month == monthCur && day > dayCur)
            return false
        
        Calendar cal = new GregorianCalendar(year, month - 1, 1)
        return cal != null && day <= cal.getActualMaximum(Calendar.DAY_OF_MONTH)
    }

    // ID: Covid_19_Delayed_CA_Events; NAME: Covid-19 Delayed CA Events and Decision to Delay Date
    public boolean covid_19_delayed_ca_events(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.covid19DelayedCAEvents != '1' || line.covid19DecisionToDelayDateYear != null
    }

    // ID: Covid_19_Diagnosed; NAME: Covid-19 Diagnosis and Date
    public boolean covid_19_diagnosed(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.covid19Diagnosed != '1' || line.covid19DxDateYear != null
    }

    // ID: Covid_19_Diagnosis_Date; NAME: Covid-19 Diagnosis Date
    public boolean covid_19_diagnosis_date(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.covid19DxDateYear == null)
           return (line.covid19DxDateMonth == null && line.covid19DxDateDay == null)
        
        if (line.covid19DxDateYear < '2019')
            return false
        
        Integer year = functions.asInt(line.covid19DxDateYear)
        Integer month = functions.asInt(line.covid19DxDateMonth)
        Integer day = functions.asInt(line.covid19DxDateDay)
        
        Integer yearCur  = functions.getCurrentYear()
        Integer monthCur = functions.getCurrentMonth()
        Integer dayCur = functions.getCurrentDay()
        
        if ((line.covid19DxDateMonth == null && line.covid19DxDateDay != null) || (month > 12 || (line.covid19DxDateMonth != null && month < 1)))
           return false
        
        if (!functions.between(year, 1930, yearCur))
            return false
        
        if (line.covid19DxDateMonth == null) //by now year fits and day is null if month is null
            return true
        
        if (year == yearCur && month > monthCur)
            return false
        
        if (line.covid19DxDateDay == null) //by now year and month fit
            return true
        
        if (year == yearCur && month == monthCur && day > dayCur)
            return false
        
        Calendar cal = new GregorianCalendar(year, month - 1, 1)
        return cal != null && day <= cal.getActualMaximum(Calendar.DAY_OF_MONTH)
    }

    // ID: Covid_19_Viral_Test; NAME: Covid-19 Viral Test and Date
    public boolean covid_19_viral_test(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.covid19ViralTest != '1' || line.covid19ViralTestDateYear != null
    }

    // ID: Covid_19_Viral_Test_Date; NAME: Covid-19 Viral Test Date
    public boolean covid_19_viral_test_date(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.covid19ViralTestDateYear == null)
           return (line.covid19ViralTestDateMonth == null && line.covid19ViralTestDateDay == null)
        
        if (line.covid19ViralTestDateYear < '2019')
            return false
        
        Integer year = functions.asInt(line.covid19ViralTestDateYear)
        Integer month = functions.asInt(line.covid19ViralTestDateMonth)
        Integer day = functions.asInt(line.covid19ViralTestDateDay)
        
        Integer yearCur  = functions.getCurrentYear()
        Integer monthCur = functions.getCurrentMonth()
        Integer dayCur = functions.getCurrentDay()
        
        if ((line.covid19ViralTestDateMonth == null && line.covid19ViralTestDateDay != null) || (month > 12 || (line.covid19ViralTestDateMonth != null && month < 1)))
           return false
        
        if (!functions.between(year, 1930, yearCur))
            return false
        
        if (line.covid19ViralTestDateMonth == null) //by now year fits and day is null if month is null
            return true
        
        if (year == yearCur && month > monthCur)
            return false
        
        if (line.covid19ViralTestDateDay == null) //by now year and month fit
            return true
        
        if (year == yearCur && month == monthCur && day > dayCur)
            return false
        
        Calendar cal = new GregorianCalendar(year, month - 1, 1)
        return cal != null && day <= cal.getActualMaximum(Calendar.DAY_OF_MONTH)
    }

    // ID: CS_Extension; NAME: CS Extension (CS)
    public boolean cs_extension(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csExtension == null || functions.matches(line.csExtension, /(^[0-9][0-9][0-9]$)|(^\s\s\s$)/)
    }

    // ID: CS_Lymph_Nodes; NAME: CS Lymph Nodes (CS)
    public boolean cs_lymph_nodes(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return  line.csLymphNodes == null || functions.matches(line.csLymphNodes, /(^[0-9][0-9][0-9]$)|(^\s\s\s$)/)
    }

    // ID: CS_Mets_at_DX; NAME: CS Mets at DX (CS)
    public boolean cs_mets_at_dx(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csMetsAtDx == null || functions.matches(line.csMetsAtDx, /(^[0-9][0-9]$)|(^\s\s$)/)
    }

    // ID: CS_Mets_at_DX_Bone; NAME: CS Mets at DX-Bone (CS)
    public boolean cs_mets_at_dx_bone(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csMetsAtDxBone == null || functions.matches(line.csMetsAtDxBone, /^[0189]$/)
    }

    // ID: CS_Mets_at_DX_Brain; NAME: CS Mets at DX-Brain (CS)
    public boolean cs_mets_at_dx_brain(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csMetsAtDxBrain == null || functions.matches(line.csMetsAtDxBrain, /^[0189]$/)
    }

    // ID: CS_Mets_at_DX_Liver; NAME: CS Mets at DX-Liver (CS)
    public boolean cs_mets_at_dx_liver(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csMetsAtDxLiver == null || functions.matches(line.csMetsAtDxLiver, /^[0189]$/)
    }

    // ID: CS_Mets_at_DX_Lung; NAME: CS Mets at DX-Lung (CS)
    public boolean cs_mets_at_dx_lung(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csMetsAtDxLung == null || functions.matches(line.csMetsAtDxLung, /^[0189]$/)
    }

    // ID: CS_Mets_Eval; NAME: CS Mets Eval (CS)
    public boolean cs_mets_eval(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csMetsEval == null || functions.matches(line.csMetsEval, /^[01235689\s]$/)
    }

    // ID: CS_Reg_Node_Eval; NAME: CS Lymph Nodes Eval (CS)
    public boolean cs_reg_node_eval(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return  line.csLymphNodesEval == null || functions.matches(line.csLymphNodesEval, /^[01235689\s]$/)
    }

    // ID: CS_Site-Specific_Factor_1; NAME: CS Site-Specific Factor 1 (CS)
    public boolean cs_siteSpecific_factor_1(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csSiteSpecificFactor1 == null || functions.matches(line.csSiteSpecificFactor1, /(^[0-9][0-9][0-9]$)|(^\s\s\s$)/)
    }

    // ID: CS_Site-Specific_Factor_2; NAME: CS Site-Specific Factor 2 (CS)
    public boolean cs_siteSpecific_factor_2(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csSiteSpecificFactor2 == null || functions.matches(line.csSiteSpecificFactor2, /(^[0-9][0-9][0-9]$)|(^\s\s\s$)/)
    }

    // ID: CS_Site-Specific_Factor_3; NAME: CS Site-Specific Factor 3 (CS)
    public boolean cs_siteSpecific_factor_3(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csSiteSpecificFactor3 == null || functions.matches(line.csSiteSpecificFactor3, /(^[0-9][0-9][0-9]$)|(^\s\s\s$)/)
    }

    // ID: CS_Site-Specific_Factor_4; NAME: CS Site-Specific Factor 4 (CS)
    public boolean cs_siteSpecific_factor_4(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csSiteSpecificFactor4 == null || functions.matches(line.csSiteSpecificFactor4, /(^[0-9][0-9][0-9]$)|(^\s\s\s$)/)
    }

    // ID: CS_Site-Specific_Factor_5; NAME: CS Site-Specific Factor 5 (CS)
    public boolean cs_siteSpecific_factor_5(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csSiteSpecificFactor5 == null || functions.matches(line.csSiteSpecificFactor5, /(^[0-9][0-9][0-9]$)|(^\s\s\s$)/)
    }

    // ID: CS_Site-Specific_Factor_6; NAME: CS Site-Specific Factor 6 (CS)
    public boolean cs_siteSpecific_factor_6(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csSiteSpecificFactor6 == null || functions.matches(line.csSiteSpecificFactor6, /(^[0-9][0-9][0-9]$)|(^\s\s\s$)/)
    }

    // ID: CS_Site-Specific_Factor_7; NAME: CS Site-Specific Factor 7 (CS)
    public boolean cs_siteSpecific_factor_7(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csSiteSpecificFactor7 == null || functions.matches(line.csSiteSpecificFactor7, /(^[0-9][0-9][0-9]$)|(^\s\s\s$)/)
    }

    // ID: CS_Site-Specific_Factor_8; NAME: CS Site-Specific Factor 8 (CS)
    public boolean cs_siteSpecific_factor_8(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csSiteSpecificFactor8 == null || functions.matches(line.csSiteSpecificFactor8, /(^[0-9][0-9][0-9]$)|(^\s\s\s$)/)
    }

    // ID: CS_Site-Specific_Factor_9; NAME: CS Site-Specific Factor 9 (CS)
    public boolean cs_siteSpecific_factor_9(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csSiteSpecificFactor9 == null || functions.matches(line.csSiteSpecificFactor9, /(^[0-9][0-9][0-9]$)|(^\s\s\s$)/)
    }

    // ID: CS_Site-Specific_Factor_10; NAME: CS Site-Specific Factor10 (CS)
    public boolean cs_siteSpecific_factor_10(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csSiteSpecificFactor10 == null || functions.matches(line.csSiteSpecificFactor10, /(^[0-9][0-9][0-9]$)|(^\s\s\s$)/)
    }

    // ID: CS_Site-Specific_Factor_11; NAME: CS Site-Specific Factor11 (CS)
    public boolean cs_siteSpecific_factor_11(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csSiteSpecificFactor11 == null || functions.matches(line.csSiteSpecificFactor11, /(^[0-9][0-9][0-9]$)|(^\s\s\s$)/)
    }

    // ID: CS_Site-Specific_Factor_12; NAME: CS Site-Specific Factor12 (CS)
    public boolean cs_siteSpecific_factor_12(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csSiteSpecificFactor12 == null || functions.matches(line.csSiteSpecificFactor12, /(^[0-9][0-9][0-9]$)|(^\s\s\s$)/)
    }

    // ID: CS_Site-Specific_Factor_13; NAME: CS Site-Specific Factor13 (CS)
    public boolean cs_siteSpecific_factor_13(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csSiteSpecificFactor13 == null || functions.matches(line.csSiteSpecificFactor13, /(^[0-9][0-9][0-9]$)|(^\s\s\s$)/)
    }

    // ID: CS_Site-Specific_Factor_14; NAME: CS Site-Specific Factor14 (CS)
    public boolean cs_siteSpecific_factor_14(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csSiteSpecificFactor14 == null || functions.matches(line.csSiteSpecificFactor14, /(^[0-9][0-9][0-9]$)|(^\s\s\s$)/)
    }

    // ID: CS_Site-Specific_Factor_15; NAME: CS Site-Specific Factor15 (CS)
    public boolean cs_siteSpecific_factor_15(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csSiteSpecificFactor15 == null || functions.matches(line.csSiteSpecificFactor15, /(^[0-9][0-9][0-9]$)|(^\s\s\s$)/)
    }

    // ID: CS_Site-Specific_Factor_16; NAME: CS Site-Specific Factor16 (CS)
    public boolean cs_siteSpecific_factor_16(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csSiteSpecificFactor16 == null || functions.matches(line.csSiteSpecificFactor16, /(^[0-9][0-9][0-9]$)|(^\s\s\s$)/)
    }

    // ID: CS_Site-Specific_Factor_17; NAME: CS Site-Specific Factor17 (CS)
    public boolean cs_siteSpecific_factor_17(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csSiteSpecificFactor17 == null || functions.matches(line.csSiteSpecificFactor17, /(^[0-9][0-9][0-9]$)|(^\s\s\s$)/)
    }

    // ID: CS_Site-Specific_Factor_18; NAME: CS Site-Specific Factor18 (CS)
    public boolean cs_siteSpecific_factor_18(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csSiteSpecificFactor18 == null || functions.matches(line.csSiteSpecificFactor18, /(^[0-9][0-9][0-9]$)|(^\s\s\s$)/)
    }

    // ID: CS_Site-Specific_Factor_19; NAME: CS Site-Specific Factor19 (CS)
    public boolean cs_siteSpecific_factor_19(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csSiteSpecificFactor19 == null || functions.matches(line.csSiteSpecificFactor19, /(^[0-9][0-9][0-9]$)|(^\s\s\s$)/)
    }

    // ID: CS_Site-Specific_Factor_20; NAME: CS Site-Specific Factor20 (CS)
    public boolean cs_siteSpecific_factor_20(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csSiteSpecificFactor20 == null || functions.matches(line.csSiteSpecificFactor20, /(^[0-9][0-9][0-9]$)|(^\s\s\s$)/)
    }

    // ID: CS_Site-Specific_Factor_21; NAME: CS Site-Specific Factor21 (CS)
    public boolean cs_siteSpecific_factor_21(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csSiteSpecificFactor21 == null || functions.matches(line.csSiteSpecificFactor21, /(^[0-9][0-9][0-9]$)|(^\s\s\s$)/)
    }

    // ID: CS_Site-Specific_Factor_22; NAME: CS Site-Specific Factor22 (CS)
    public boolean cs_siteSpecific_factor_22(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csSiteSpecificFactor22 == null || functions.matches(line.csSiteSpecificFactor22, /(^[0-9][0-9][0-9]$)|(^\s\s\s$)/)
    }

    // ID: CS_Site-Specific_Factor_23; NAME: CS Site-Specific Factor23 (CS)
    public boolean cs_siteSpecific_factor_23(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csSiteSpecificFactor23 == null || functions.matches(line.csSiteSpecificFactor23, /(^[0-9][0-9][0-9]$)|(^\s\s\s$)/)
    }

    // ID: CS_Site-Specific_Factor_24; NAME: CS Site-Specific Factor24 (CS)
    public boolean cs_siteSpecific_factor_24(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csSiteSpecificFactor24 == null || functions.matches(line.csSiteSpecificFactor24, /(^[0-9][0-9][0-9]$)|(^\s\s\s$)/)
    }

    // ID: CS_Site-Specific_Factor_25; NAME: CS Site-Specific Factor25 (CS)
    public boolean cs_siteSpecific_factor_25(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csSiteSpecificFactor25 == null || functions.matches(line.csSiteSpecificFactor25, /(^[0-9][0-9][0-9]$)|(^\s\s\s$)/)
    }

    // ID: CS_Tumor_Size; NAME: CS Tumor Size (CS)
    public boolean cs_tumor_size(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return  line.csTumorSize == null || functions.matches(line.csTumorSize, /(^[0-9][0-9][0-9]$)|(^\s\s\s$)/)
    }

    // ID: CS_Tumor_Size_Ext_Eval; NAME: CS Tumor Size/Ext Eval (CS)
    public boolean cs_tumor_size_ext_eval(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csTumorSizeExtEval == null || functions.matches(line.csTumorSizeExtEval, /^[0-5689\s]$/)
    }

    // ID: CS_Version_Derived; NAME: CS Version Derived (CS)
    public boolean cs_version_derived(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csVersionDerived == null || (functions.matches(line.csVersionDerived, /^0205\d\d$/) && line.csVersionDerived <= functions.getCsVersion())
    }

    // ID: CS_Version_Input_Current; NAME: CS Version Input Current (CS)
    public boolean cs_version_input_current(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csVersionInputCurrent == null)
            return true
        
        if (line.csVersionInputCurrent <= functions.getCsVersion()) {
            Integer version = functions.asInt(line.csVersionInputCurrent)
            return ['020550','020540','020530','020520','020510'].contains(line.csVersionInputCurrent) ||
                version > 20550
        }
        
        return false
    }

    // ID: CS_Version_Input_Original; NAME: CS Version Input Original (CS)
    public boolean cs_version_input_original(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csVersionInputOriginal == null)
            return true
        
        if (['020440','020302','020200','020100','020001','010401','010400','010300','010200','010100','010005','010004','010003','010002','010000','000937'].contains(line.csVersionInputOriginal))
            return true
        
        Integer version = functions.asInt(line.csVersionInputOriginal)
        if (version > functions.asInt(functions.getCsVersion()))
            return false
        
        if (line.csVersionInputOriginal.startsWith('0205'))
           return version >= 20550
        
        return false
    }

    // ID: DateBirthEdit; NAME: Date of Birth (NAACCR)
    public boolean datebirthedit(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer year = functions.asInt(line.dateOfBirthYear)
        Integer month = functions.asInt(line.dateOfBirthMonth)
        Integer day = functions.asInt(line.dateOfBirthDay)
        
        Integer yearCur = functions.getCurrentYear()
        Integer monthCur = functions.getCurrentMonth()
        Integer dayCur = functions.getCurrentDay()
        
        if (line.dateOfBirthYear == null)
            return line.dateOfBirthMonth == null && line.dateOfBirthDay == null
        
        if ((line.dateOfBirthMonth == null && line.dateOfBirthDay != null) || (month > 12 || (month != null && month < 1)))
            return false
        
        if (!functions.between(year, 1810, yearCur))
            return false
        
        if (line.dateOfBirthMonth == null) //by now year fits and day is null if month is null
            return true
        
        if (year == yearCur && month > monthCur)
            return false
        
        if (line.dateOfBirthDay == null) //by now year and month fit
            return true
        
        if (year == yearCur && month == monthCur && day > dayCur)
            return false
        
        // check for day of the month too big (need to check leap years too)
        Calendar cal = new GregorianCalendar(year, month - 1, 1)
        return cal != null && day <= cal.getActualMaximum(Calendar.DAY_OF_MONTH)
    }

    // ID: DateDiagnosisEdit; NAME: Date of Diagnosis (NAACCR DATEEDIT)
    public boolean datediagnosisedit(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer year = functions.asInt(line.dateOfDiagnosisYear)
        Integer month = functions.asInt(line.dateOfDiagnosisMonth)
        Integer day = functions.asInt(line.dateOfDiagnosisDay)
        
        Integer yearCur  = functions.getCurrentYear()
        Integer monthCur = functions.getCurrentMonth()
        Integer dayCur = functions.getCurrentDay()
        
        if (line.dateOfDiagnosisYear == null)
           return line.dateOfDiagnosisMonth == null && line.dateOfDiagnosisDay == null
        
        if ((line.dateOfDiagnosisMonth == null && line.dateOfDiagnosisDay != null) || (month > 12 || (line.dateOfDiagnosisMonth != null && month < 1)))
           return false
        
        if (!functions.between(year, 1930, yearCur))
            return false
        
        if (line.dateOfDiagnosisMonth == null) //by now year fits and day is null if month is null
            return true
        
        if (year == yearCur && month > monthCur)
            return false
        
        if (line.dateOfDiagnosisDay == null) //by now year and month fit
            return true
        
        if (year == yearCur && month == monthCur && day > dayCur)
            return false
        
        Calendar cal = new GregorianCalendar(year, month - 1, 1)
        return cal != null && day <= cal.getActualMaximum(Calendar.DAY_OF_MONTH)
    }

    // ID: DateFollowUpEdit; NAME: Date of Last Contact (NAACCR DATEEDIT)
    public boolean datefollowupedit(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer year = functions.asInt(line.dateOfLastContactYear)
        Integer month = functions.asInt(line.dateOfLastContactMonth)
        Integer day = functions.asInt(line.dateOfLastContactDay)
        
        Integer yearCur  = functions.getCurrentYear()
        Integer monthCur = functions.getCurrentMonth()
        Integer dayCur = functions.getCurrentDay()
        
        if (line.dateOfLastContactYear == null)
            return (line.dateOfLastContactMonth == null && line.dateOfLastContactDay == null)
        
        if ((line.dateOfLastContactMonth == null && line.dateOfLastContactDay != null) || (month > 12 || (line.dateOfLastContactMonth != null && month < 1)))
            return false
        
        if (!functions.between(year, 1930, yearCur))
            return false
        
        if (line.dateOfLastContactMonth == null) //by now year fits and day is null if month is null
            return true
        
        if (year == yearCur && month > monthCur)
            return false
        
        if (line.dateOfLastContactDay == null) //by now year and month fit
            return true
        
        if (year == yearCur && month == monthCur && day > dayCur)
            return false
        
         Calendar cal = new GregorianCalendar(year, month - 1, 1)
         return cal != null && day <= cal.getActualMaximum(Calendar.DAY_OF_MONTH)
    }

    // ID: DateRegionalLymphNodeDissectionEdit; NAME: Date Regional Lymph Node Dissection (COC)
    public boolean dateregionallymphnodedissectionedit(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer year = functions.asInt(line.dateRegionalLNDissectionYear)
        Integer month = functions.asInt(line.dateRegionalLNDissectionMonth)
        Integer day = functions.asInt(line.dateRegionalLNDissectionDay)
        
        Integer yearCur  = functions.getCurrentYear()
        Integer monthCur = functions.getCurrentMonth()
        Integer dayCur = functions.getCurrentDay()
        
        if (line.dateRegionalLNDissectionYear == null)
            return (line.dateRegionalLNDissectionMonth == null && line.dateRegionalLNDissectionDay == null)
        
        if ((line.dateRegionalLNDissectionMonth == null && line.dateRegionalLNDissectionDay != null) || (month > 12 || (line.dateRegionalLNDissectionMonth != null && month < 1)))
            return false
        
        if (!functions.between(year, 1930, yearCur))
            return false
        
        if (line.dateRegionalLNDissectionMonth == null) //by now year fits and day is null if month is null
            return true
        
        if (year == yearCur && month > monthCur)
            return false
        
        if (line.dateRegionalLNDissectionDay == null) //by now year and month fit
            return true
        
        if (year == yearCur && month == monthCur && day > dayCur)
            return false
        
        Calendar cal = new GregorianCalendar(year, month - 1, 1)
        return cal != null && day <= cal.getActualMaximum(Calendar.DAY_OF_MONTH)
    }

    // ID: DateSentinelLymphNodeBiopsyEdit; NAME: Date of Sentinel Lymph Node Biopsy (COC)
    public boolean datesentinellymphnodebiopsyedit(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer year = functions.asInt(line.dateSentinelLymphNodeBiopsyYear)
        Integer month = functions.asInt(line.dateSentinelLymphNodeBiopsyMonth)
        Integer day = functions.asInt(line.dateSentinelLymphNodeBiopsyDay)
        
        Integer yearCur  = functions.getCurrentYear()
        Integer monthCur = functions.getCurrentMonth()
        Integer dayCur = functions.getCurrentDay()
        
        if (line.dateSentinelLymphNodeBiopsyYear == null)
            return (line.dateSentinelLymphNodeBiopsyMonth == null && line.dateSentinelLymphNodeBiopsyDay == null)
        
        if ((line.dateSentinelLymphNodeBiopsyMonth == null && line.dateSentinelLymphNodeBiopsyDay != null) || (month > 12 || (line.dateSentinelLymphNodeBiopsyMonth != null && month < 1)))
            return false
        
        if (!functions.between(year, 1930, yearCur))
            return false
        
        if (line.dateSentinelLymphNodeBiopsyMonth == null) //by now year fits and day is null if month is null
            return true
        
        if (year == yearCur && month > monthCur)
            return false
        
        if (line.dateSentinelLymphNodeBiopsyDay == null) //by now year and month fit
            return true
        
        if (year == yearCur && month == monthCur && day > dayCur)
            return false
        
        Calendar cal = new GregorianCalendar(year, month - 1, 1)
        return cal != null && day <= cal.getActualMaximum(Calendar.DAY_OF_MONTH)
    }

    // ID: DateTherapyEdit; NAME: Date Initial RX SEER (NAACCR)
    public boolean datetherapyedit(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer year = functions.asInt(line.dateInitialRxSeerYear)
        Integer month = functions.asInt(line.dateInitialRxSeerMonth)
        Integer day = functions.asInt(line.dateInitialRxSeerDay)
        
        Integer yearCur  = functions.getCurrentYear()
        Integer monthCur = functions.getCurrentMonth()
        Integer dayCur = functions.getCurrentDay()
        
        if (line.registryId == '0000001544' && line.dateOfDiagnosisYear < '2000')
            return true
        
        if (line.dateInitialRxSeerYear == null)
           return (line.dateInitialRxSeerMonth == null && line.dateInitialRxSeerDay == null)
        
        if ((line.dateInitialRxSeerMonth == null && line.dateInitialRxSeerDay != null) || (month > 12 || (line.dateInitialRxSeerMonth != null && month < 1)))
           return false
        
        if (!functions.between(year, 1930, yearCur))
            return false
        
        if (line.dateInitialRxSeerMonth == null) //by now year fits and day is null if month is null
            return true
        
        if (year == yearCur && month > monthCur)
            return false
        
        if (line.dateInitialRxSeerDay == null) //by now year and month fit
            return true
        
        if (year == yearCur && month == monthCur && day > dayCur)
            return false
        
        Calendar cal = new GregorianCalendar(year, month - 1, 1)
        return cal != null && day <= cal.getActualMaximum(Calendar.DAY_OF_MONTH)
    }

    // ID: Day_BRM; NAME: RX Date BRM (COC)
    public boolean day_brm(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxDateBrmDay == null || functions.matches(line.rxDateBrmDay, /^(0[1-9]|[12][0-9]|3[0-1])$/)
    }

    // ID: Day_Chemo; NAME: RX Date Chemo (COC)
    public boolean day_chemo(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxDateChemoDay == null || functions.matches(line.rxDateChemoDay, /^0[1-9]|[12][0-9]|3[0-1]$/)
    }

    // ID: Day_Hormone; NAME: RX Date Hormone (COC)
    public boolean day_hormone(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxDateHormoneDay == null || functions.matches(line.rxDateHormoneDay, /^(0[1-9]|[12][0-9]|3[0-1])$/)
    }

    // ID: Day_Most_Defin_Surg; NAME: RX Date Mst Defn Srg (COC)
    public boolean day_most_defin_surg(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxDateMostDefinSurgDay == null || functions.matches(line.rxDateMostDefinSurgDay, /^(0[1-9]|[12][0-9]|3[01])$/)
    }

    // ID: Day_of_Birth; NAME: Date of Birth (NAACCR)
    public boolean day_of_birth(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return  line.dateOfBirthDay == null || line.dateOfBirthDay  ==~ /^(0[1-9]|[12][0-9]|3[01])$/
    }

    // ID: Day_of_Diagnosis; NAME: Date of Diagnosis (NAACCR DATEEDIT)
    public boolean day_of_diagnosis(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.dateOfDiagnosisDay == null || functions.matches(line.dateOfDiagnosisDay, /^(0[1-9]|[12][0-9]|3[01])$/)
    }

    // ID: Day_of_Initial_RX--SEER; NAME: Date Initial RX SEER (NAACCR)
    public boolean day_of_initial_rxSeer(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.dateInitialRxSeerDay == null || functions.matches(line.dateInitialRxSeerDay, /^(0[1-9]|[12][0-9]|3[0-1])$/)
    }

    // ID: Day_of_Last_Contact; NAME: Date of Last Contact (NAACCR DATEEDIT)
    public boolean day_of_last_contact(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.dateOfLastContactDay == null || functions.matches(line.dateOfLastContactDay, /^(0[1-9]|[12][0-9]|3[01])$/)
    }

    // ID: Day_Other; NAME: RX Date Other (COC)
    public boolean day_other(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxDateOtherDay == null || functions.matches(line.rxDateOtherDay, /^(0[1-9]|[12][0-9]|3[0-1])$/)
    }

    // ID: Day_Radiation; NAME: RX Date Radiation (COC)
    public boolean day_radiation(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxDateRadiationDay == null || functions.matches(line.rxDateRadiationDay, /^(0[1-9]|[12][0-9]|3[01])$/)
    }

    // ID: Day_Recurrence_Date_1st; NAME: Recurrence Date--1st (COC)
    public boolean day_recurrence_date_1st(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.recurrenceDate1stDay == null || line.recurrenceDate1stDay  ==~ /^(0[1-9]|[12][0-9]|3[01])$/
    }

    // ID: Day_Regional_Lymph_Node_Dissection; NAME: Date Regional Lymph Node Dissection (COC)
    public boolean day_regional_lymph_node_dissection(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.dateRegionalLNDissectionDay == null || functions.matches(line.dateRegionalLNDissectionDay, /^(0[1-9]|[12][0-9]|3[01])$/)
    }

    // ID: Day_Sentinel_Lymph_Node_Biopsy; NAME: Date of Sentinel Lymph Node Biopsy (COC)
    public boolean day_sentinel_lymph_node_biopsy(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.dateSentinelLymphNodeBiopsyDay == null || functions.matches(line.dateSentinelLymphNodeBiopsyDay, /^(0[1-9]|[12][0-9]|3[01])$/)
    }

    // ID: Day_Surgery; NAME: RX Date Surgery (COC)
    public boolean day_surgery(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxDateSurgeryDay == null || functions.matches(line.rxDateSurgeryDay, /^(0[1-9]|[12][0-9]|3[01])$/)
    }

    // ID: Day_SurvDateActiveFollowup; NAME: Surv-Date Active Followup (SEER)
    public boolean day_survdateactivefollowup(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.survDateActiveFollowupDay == null || functions.matches(line.survDateActiveFollowupDay, /^(0[1-9]|[12][0-9]|3[01])$/)
    }

    // ID: Day_SurvDateDXRecode; NAME: Surv-Date DX Recode (SEER)
    public boolean day_survdatedxrecode(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.survDateDxRecodeDay == null || functions.matches(line.survDateDxRecodeDay, /^(0[1-9]|[12][0-9]|3[01])$/)
    }

    // ID: Day_SurvDatePresumedAlive; NAME: Surv-Date Presumed Alive (SEER)
    public boolean day_survdatepresumedalive(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.survDatePresumedAliveDay == null || functions.matches(line.survDatePresumedAliveDay, /^(0[1-9]|[12][0-9]|3[01])$/)
    }

    // ID: Day_Systemic; NAME: RX Date Systemic (COC)
    public boolean day_systemic(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxDateSystemicDay == null || functions.matches(line.rxDateSystemicDay, /^(0[1-9]|[12][0-9]|3[01])$/)
    }

    // ID: Derived_AJCC_6_M; NAME: Derived AJCC-6 M (CS)
    public boolean derived_ajcc_6_m(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.derivedAjcc6M == null || functions.matches(line.derivedAjcc6M, /(^00$)|(^1[01239]$)|(^88$)|(^99$)|(^\s\s$)/)
    }

    // ID: Derived_AJCC_6_M_Descriptor; NAME: Derived AJCC-6 M Descriptor (CS)
    public boolean derived_ajcc_6_m_descriptor(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.derivedAjcc6MDescript == null || functions.matches(line.derivedAjcc6MDescript, /^[cpayN\s]$/)
    }

    // ID: Derived_AJCC_6_N; NAME: Derived AJCC-6 N (CS)
    public boolean derived_ajcc_6_n(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.derivedAjcc6N == null || line.derivedAjcc6N==~ /(^0[01234]$)|(^1[012389]$)|(^[23][01239]$)|(^88$)|(^99$)|(^\s\s$)/
    }

    // ID: Derived_AJCC_6_N_Descriptor; NAME: Derived AJCC-6 N Descriptor (CS)
    public boolean derived_ajcc_6_n_descriptor(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.derivedAjcc6NDescript == null || functions.matches(line.derivedAjcc6NDescript, /^[cpayN\s]$/)
    }

    // ID: Derived_AJCC_6_Stage_Group; NAME: Derived AJCC-6 Stage Group (CS)
    public boolean derived_ajcc_6_stage_group(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.derivedAjcc6StageGrp == null || functions.matches(line.derivedAjcc6StageGrp, /(^0[012]$)|(^[135][0-9]$)|(^[27][0-4]$)|(^[46][0-3]$)|(^88$)|(^9[09]$)|(^\s\s$)/)
    }

    // ID: Derived_AJCC_6_T; NAME: Derived AJCC-6 T (CS)
    public boolean derived_ajcc_6_t(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.derivedAjcc6T == null || functions.matches(line.derivedAjcc6T, /(^0[01567]$)|(^1[0-9]$)|(^[23][01239]$)|(^4[012349]$)|(^8[018]$)|(^9[09]$)|(^\s\s$)/)
    }

    // ID: Derived_AJCC_6_T_Descriptor; NAME: Derived AJCC-6 T Descriptor (CS)
    public boolean derived_ajcc_6_t_descriptor(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.derivedAjcc6TDescript == null || functions.matches(line.derivedAjcc6TDescript, /^[cpayN\s]$/)
    }

    // ID: Derived_AJCC_7_M; NAME: Derived AJCC-7 M (CS)
    public boolean derived_ajcc_7_m(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.derivedAjcc7M == null || functions.matches(line.derivedAjcc7M, /(^999$)|(^0[01]0$)|(^1[012345]0$)|(^199$)|(^888$)/)
    }

    // ID: Derived_AJCC_7_M_Descriptor; NAME: Derived AJCC-7 M Descriptor (CS)
    public boolean derived_ajcc_7_m_descriptor(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.derivedAjcc7MDescript == null || functions.matches(line.derivedAjcc7MDescript, /^[cpayN\s]$/)
    }

    // ID: Derived_AJCC_7_N; NAME: Derived AJCC-7 N (CS)
    public boolean derived_ajcc_7_n(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.derivedAjcc7N == null || functions.matches(line.derivedAjcc7N, /(^999$)|(^0[01234]0$)|(^1[01238]0$)|(^199$)|(^2[0123]0$)|(^299$)|(^399$)|(^3[0123]0$)|(^400$)|(^499$)|(^888$)/)
    }

    // ID: Derived_AJCC_7_N_Descriptor; NAME: Derived AJCC-7 N Descript (CS)
    public boolean derived_ajcc_7_n_descriptor(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.derivedAjcc7NDescript == null || functions.matches(line.derivedAjcc7NDescript, /^[cpayN\s]$/)
    }

    // ID: Derived_AJCC_7_Stage_Group; NAME: Derived AJCC-7 Stage Group (CS)
    public boolean derived_ajcc_7_stage_group(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.derivedAjcc7StageGrp == null || functions.matches(line.derivedAjcc7StageGrp, /(^0[012]0$)|(^1[0-9]0$)|(^1[25]1$)|(^2[01234]0$)|(^3[0-9]0$)|(^32[123]$)|(^4[0123]0$)|(^5[0-9]0$)|(^54[12]$)|(^6[0123]0$)|(^7[01234]0$)|(^72[12]$)|(^888$)|(^900$)|(^999$)/)
    }

    // ID: Derived_AJCC_7_T; NAME: Derived AJCC-7 T (CS)
    public boolean derived_ajcc_7_t(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.derivedAjcc7T == null || functions.matches(line.derivedAjcc7T, /(^999$)|(^0[01567]0$)|(^1[0-9]0$)|(^1[259][12])|(^181$)|(^199$)|(^2[01234]0$)|(^20[12])|(^299$)|(^21[123]$)|(^399$)|(^3[01234]0$)|(^30[12])|(^4[012345]0$)|(^4[129][12])|(^499$)|(^8[01]0$)|(^888$)/)
    }

    // ID: Derived_AJCC_7_T_Descriptor; NAME: Derived AJCC-7 T Descript (CS)
    public boolean derived_ajcc_7_t_descriptor(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return  line.derivedAjcc7TDescript == null || functions.matches(line.derivedAjcc7TDescript, /^[cpayN\s]$/)
    }

    // ID: Derived_AJCC_Flag; NAME: Derived AJCC--Flag (CS)
    public boolean derived_ajcc_flag(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.derivedAjccFlag == null || functions.matches(line.derivedAjccFlag, /^[12\s]$/)
    }

    // ID: Derived_EOD_2018_M; NAME: Derived EOD 2018 M (SEER)
    public boolean derived_eod_2018_m(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.derivedEod2018M == null || ((List)context.Derived_EOD_2018_M_Table).contains(line.derivedEod2018M)
    }

    // ID: Derived_EOD_2018_N; NAME: Derived EOD 2018 N (SEER)
    public boolean derived_eod_2018_n(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.derivedEod2018N == null || ((List)context.Derived_EOD_2018_N_Table).contains(line.derivedEod2018N)
    }

    // ID: Derived_EOD_2018_Stage_Group; NAME: Derived EOD 2018 Stage Group (SEER)
    public boolean derived_eod_2018_stage_group(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.derivedEod2018StageGroup == null)
                    return true
        
        if (line.derivedEod2018StageGroup == '90' &&
            (line.derivedEod2018T == '88' || (['00410','00440'].contains(line.schemaId) && (line.gradeClinical == 'H' || line.gradePathological == 'H'))))
            return true
        
        return ((List)context.Derived_EOD_2018_Stage_Group_Table).contains(line.derivedEod2018StageGroup)
    }

    // ID: Derived_EOD_2018_T; NAME: Derived EOD 2018 T (SEER)
    public boolean derived_eod_2018_t(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.derivedEod2018T == null || ((List)context.Derived_EOD_2018_T_Table).contains(line.derivedEod2018T)
    }

    // ID: Derived_SEER_Clin_Stg_Grp; NAME: Derived SEER Clin Stg Grp (SEER)
    public boolean derived_seer_clin_stg_grp(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.derivedSeerClinStgGrp == null || ((List)context.Derived_Stage_Group_Table).contains(line.derivedSeerClinStgGrp)
    }

    // ID: Derived_SEER_Cmb_M; NAME: Derived SEER Combined M (SEER)
    public boolean derived_seer_cmb_m(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.derivedSeerCombinedM == null)
             return true
        
        return functions.matches(line.derivedSeerCombinedM, /^[cp].+|88$/) && (((List)context.TNM_Clin_M_Table).contains(line.derivedSeerCombinedM) || ((List)context.TNM_Path_M_Table).contains(line.derivedSeerCombinedM))
    }

    // ID: Derived_SEER_Cmb_M_Src; NAME: Derived SEER Cmb M Src (SEER)
    public boolean derived_seer_cmb_m_src(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.derivedSeerCmbMSrc == null || functions.matches(line.derivedSeerCmbMSrc, /^[1239]$/)
    }

    // ID: Derived_SEER_Cmb_N; NAME: Derived SEER Combined N (SEER)
    public boolean derived_seer_cmb_n(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.derivedSeerCombinedN == null)
             return true
        
        return functions.matches(line.derivedSeerCombinedN, /^[cp].+|88$/) && (((List)context.TNM_Clin_N_Table).contains(line.derivedSeerCombinedN) || ((List)context.TNM_Path_N_Table).contains(line.derivedSeerCombinedN))
    }

    // ID: Derived_SEER_Cmb_N_Src; NAME: Derived SEER Cmb N Src (SEER)
    public boolean derived_seer_cmb_n_src(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.derivedSeerCmbNSrc == null || functions.matches(line.derivedSeerCmbNSrc, /^[1239]$/)
    }

    // ID: Derived_SEER_Cmb_Stg_Grp; NAME: Derived SEER Cmb Stg Grp (SEER)
    public boolean derived_seer_cmb_stg_grp(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.derivedSeerCmbStgGrp == null || ((List)context.Derived_Stage_Group_Table).contains(line.derivedSeerCmbStgGrp)
    }

    // ID: Derived_SEER_Cmb_T; NAME: Derived SEER Combined T (SEER)
    public boolean derived_seer_cmb_t(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.derivedSeerCombinedT == null)
             return true
        
        return functions.matches(line.derivedSeerCombinedT, /^[cp].+|88$/) && (((List)context.TNM_Clin_T_Table).contains(line.derivedSeerCombinedT) || ((List)context.TNM_Path_T_Table).contains(line.derivedSeerCombinedT))
    }

    // ID: Derived_SEER_Cmb_T_Src; NAME: Derived SEER Cmb T Src (SEER)
    public boolean derived_seer_cmb_t_src(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.derivedSeerCmbTSrc == null || functions.matches(line.derivedSeerCmbTSrc, /^[1239]$/)
    }

    // ID: Derived_SEER_Path_Stg_Grp; NAME: Derived SEER Path Stg Grp (SEER)
    public boolean derived_seer_path_stg_grp(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.derivedSeerPathStgGrp == null || ((List)context.Derived_Stage_Group_Table).contains(line.derivedSeerPathStgGrp)
    }

    // ID: Derived_SS1977; NAME: Derived SS1977 (CS)
    public boolean derived_ss1977(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.derivedSs1977 == null || functions.matches(line.derivedSs1977, /^[012345789\s]$/)
    }

    // ID: Derived_SS1977_Flag; NAME: Derived SS1977--Flag (CS)
    public boolean derived_ss1977_flag(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.derivedSs1977Flag == null || functions.matches(line.derivedSs1977Flag, /^[12\s]$/)
    }

    // ID: Derived_SS2000; NAME: Derived SS2000 (CS)
    public boolean derived_ss2000(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.derivedSs2000 == null || functions.matches(line.derivedSs2000, /^[012345789\s]$/)
    }

    // ID: Derived_SS2000_Flag; NAME: Derived SS2000--Flag (CS)
    public boolean derived_ss2000_flag(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.derivedSs2000Flag == null || functions.matches(line.derivedSs2000Flag, /^[12\s]$/)
    }

    // ID: Derived_Summary_Grade_2018; NAME: Derived Summary Grade (NAACCR)
    public boolean derived_summary_grade_2018(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        
        return line.derivedSummaryGrade2018 == null || functions.matches(line.derivedSummaryGrade2018, /^[1234589ABCDEHLMS]$/)
    }

    // ID: Derived_Summary_Stage_2018; NAME: Derived Summary Stage 2018 (SEER)
    public boolean derived_summary_stage_2018(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.derivedSummaryStage2018 == null || functions.matches(line.derivedSummaryStage2018, /^[0-47-9]$/)
    }

    // ID: Diagnostic_confirmation; NAME: Diagnostic Confirmation (SEER DXCONF)
    public boolean diagnostic_confirmation(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return  line.diagnosticConfirmation != null && functions.matches(line.diagnosticConfirmation, /^[123456789]$/)
    }

    // ID: EOD--Extension; NAME: EOD--Extension (SEER)
    public boolean eodExtension(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.eodExtension == null || functions.matches(line.eodExtension, /(^\d{2}$)|(^\s\s$)/)
    }

    // ID: EOD--Extension_Prost_Path; NAME: EOD--Extension Prost Path (SEER)
    public boolean eodExtension_prost_path(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.eodExtensionProstPath == null || functions.matches(line.eodExtensionProstPath, /(^[0-9][0-9]$)|(^\s\s$)/)
    }

    // ID: EOD--Lymph_Node_Involv; NAME: EOD--Lymph Node Involv (SEER)
    public boolean eodLymph_node_involv(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.eodLymphNodeInvolv == null || functions.matches(line.eodLymphNodeInvolv, /^[0-9]$/)
    }

    // ID: EOD--Old_2_Digit; NAME: EOD--Old 2 digit (SEER)
    public boolean eodOld_2_digit(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.eodOld2Digit == null || functions.matches(line.eodOld2Digit, /^(\d|-|&|\s){2}$/)
    }

    // ID: EOD--Old_4_Digit_Extent; NAME: EOD-4 Extension (SEER)
    public boolean eodOld_4_digit_extent(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        String eodOld4DigitExtent = null
        if (line.eodOld4Digit != null && line.eodOld4Digit.length() > 2)
            eodOld4DigitExtent = line.eodOld4Digit.substring(2, 3)
        return eodOld4DigitExtent == null || functions.matches(eodOld4DigitExtent, /^[0-9\s]$/)
    }

    // ID: EOD--Old_4_Digit_Nodes; NAME: EOD-4 Lymph Nodes (SEER)
    public boolean eodOld_4_digit_nodes(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        String eodOld4DigitNodes = null
        if (line.eodOld4Digit != null && line.eodOld4Digit.length() > 3)
            eodOld4DigitNodes = line.eodOld4Digit.substring(3, 4)
        return eodOld4DigitNodes == null || functions.matches(eodOld4DigitNodes, /^[0-9\s]$/)
    }

    // ID: EOD--Old_4_Digit_Size; NAME: EOD-4 Tumor Size (SEER)
    public boolean eodOld_4_digit_size(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        String eodOld4DigitSize = null
        if (line.eodOld4Digit != null && line.eodOld4Digit.length() > 1)
            eodOld4DigitSize = line.eodOld4Digit.substring(0, 2)
        if (line.eodOld4Digit?.length() == 1)
            eodOld4DigitSize = line.eodOld4Digit
        return eodOld4DigitSize == null || functions.matches(eodOld4DigitSize, /(^[0-9][0-9]$)|(^\s\s$)/)
    }

    // ID: EOD--Old_13_Digit; NAME: EOD--Old 13 digit (SEER)
    public boolean eodOld_13_digit(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.eodOld13Digit == null || functions.matches(line.eodOld13Digit, /^(\d|-|&|\s){13}$/)
    }

    // ID: EOD--Tumor_Size; NAME: EOD--Tumor Size (COC)
    public boolean eodTumor_size(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.eodTumorSize == null || functions.matches(line.eodTumorSize, /(^[0-9]{3}$)|(^\s\s\s$)/)
    }

    // ID: EOD_Mets; NAME: EOD Mets (SEER)
    public boolean eod_mets(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.eodMets == null || functions.matches(line.eodMets, /^0[05]|[1-4]5|[1-7]0|88|99$/)
    }

    // ID: EOD_Primary_Tumor; NAME: EOD Primary Tumor (SEER)
    public boolean eod_primary_tumor(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.eodPrimaryTumor == null || ((List)context.EOD_Primary_Tumor_Table).contains(line.eodPrimaryTumor)
    }

    // ID: EOD_Regional_Nodes; NAME: EOD Regional Nodes (SEER)
    public boolean eod_regional_nodes(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.eodRegionalNodes == null || functions.matches(line.eodRegionalNodes, /^0[0357]0|[1-7][05]0|800|888|987|999$/)
    }

    // ID: Grade; NAME: Grade (COC)
    public boolean grade(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.grade == null || functions.matches(line.grade, /^[1-9]$/)
    }

    // ID: Grade_Clinical; NAME: Grade Clinical (NAACCR)
    public boolean grade_clinical(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return  line.gradeClinical == null || functions.matches(line.gradeClinical, /^[1-589A-EHLMS]$/)
    }

    // ID: Grade_Pathological; NAME: Grade Pathological (NAACCR)
    public boolean grade_pathological(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return  line.gradePathological == null || functions.matches(line.gradePathological, /^[1-589A-EHLMS]$/)
    }

    // ID: Grade_Post_Therapy; NAME: Grade Post Therapy Path (yp) (NAACCR)
    public boolean grade_post_therapy(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return  line.gradePostTherapy == null || functions.matches(line.gradePostTherapy, /^[1-589A-EHLMS]$/)
    }

    // ID: Grade_Post_Therapy_Clin; NAME: Grade Post Therapy Clin (yc) (NAACCR)
    public boolean grade_post_therapy_clin(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.gradePostTherapyClin == null || functions.matches(line.gradePostTherapyClin, /^[1-589A-EHLMS]$/)
    }

    // ID: Histologic_Type_ICD-O-3; NAME: Histologic Type ICDO3 (SEER)
    public boolean histologic_type_icdO3(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.histologicTypeIcdO3 == null || ((List)context.Histologic_Type_ICD_O_3_Table).contains(functions.asInt(line.histologicTypeIcdO3))
    }

    // ID: Histologic_Type_ICD-O-3_Submission; NAME: SEER Submission Edit 01 (SEER)
    public boolean histologic_type_icdO3_submission(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return  line.histologicTypeIcdO3 != null
    }

    // ID: ICD_Revision_Number; NAME: ICD Revision Number (SEER ICDCODE)
    public boolean icd_revision_number(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.icdRevisionNumber == null || functions.matches(line.icdRevisionNumber, /^[01789]$/)
    }

    // ID: ICD_revision_number_Submission; NAME: SEER Submission Edit 01 (SEER)
    public boolean icd_revision_number_submission(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return  line.icdRevisionNumber != null
    }

    // ID: IF01; NAME: EOD--Old 13 digit, Primary Site, Hist (SEER IF01)
    public boolean if01(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '1975' || line.dateOfDiagnosisYear > '1982'
               || line.registryId == '0000001544' || line.typeOfReportingSource == '7')
            return true
        
        if (((line.dateOfDiagnosisYear == '1975' && ((line.registryId == '0000001501' && (functions.asInt(line.countyAtDxAnalysis) >= 75) && functions.asInt(line.countyAtDxAnalysis) <= 81)
               || line.registryId != '0000001501')) || line.dateOfDiagnosisYear > '1975') && functions.matches(line.primarySite, /^C(18[02-7]|199|209|50\d)$/))
            return line.codingSystemForEod == '2'
        
        if ((line.dateOfDiagnosisYear > '1977' || (line.dateOfDiagnosisYear == '1977' && (line.dateOfDiagnosisMonth != null && functions.asInt(line.dateOfDiagnosisMonth) >= 5))) && ((functions.matches(line.primarySite, /^C(024|099|111|142|379|422|77\d)$/) && functions.between(line.histologicTypeIcdO3, '9590', '9698'))
               || (functions.matches(line.primarySite, /^C(44[0-7]|51\d|60[0189])$/) && functions.between(line.histologicTypeIcdO3, '8720', '8790'))))
            return line.codingSystemForEod == '2'
        
        if ((line.dateOfDiagnosisYear > '1977' || (line.dateOfDiagnosisYear == '1977' && (line.dateOfDiagnosisMonth != null && functions.asInt(line.dateOfDiagnosisMonth) >= 11))) && functions.matches(line.primarySite, /^C(16[1-9]|34[1-9]|53\d|54[0-8]|619|67[0-689])$/))
           return line.codingSystemForEod == '2'
        
        return true
    }

    // ID: IF02; NAME: Type of Report Srce (AO), Date of Dx (SEER IF02)
    public boolean if02(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfLastContactYear == null)
            return true
        
        if (line.typeOfReportingSource == '6')
            return (line.dateOfDiagnosisYear == line.dateOfLastContactYear && line.dateOfDiagnosisMonth == line.dateOfLastContactMonth &&
                line.dateOfDiagnosisDay == line.dateOfLastContactDay)
        
        return true
    }

    // ID: IF04_3; NAME: Type of Rep Srce(DC),Seq Num--Cent,ICDO3 (SEER IF04)
    public boolean if04_3(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.overRideReportSource != '1' && line.histologicTypeIcdO3 != null) {
            if (line.typeOfReportingSource == '7'  && functions.between(line.histologicTypeIcdO3, '8000', '9589')
                    && !(line.sequenceNumberCentral == '00' || line.sequenceNumberCentral == '60'))
                return false
        }
        
        return true
    }

    // ID: IF05; NAME: Type of Report Srce(DC/AO), Diag Conf (SEER IF05)
    public boolean if05(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.typeOfReportingSource == '6')
            return line.diagnosticConfirmation ==~/^[16]$/
        
        if (line.typeOfReportingSource == '7')
            return line.diagnosticConfirmation == '9'
        
        return true
    }

    // ID: IF08; NAME: Type of Report Srce(DC/AO), Vital Stat (SEER IF08)
    public boolean if08(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.typeOfReportingSource ==~/^[67]$/)
           return line.vitalStatus == '0' || line.vitalStatus == '4'
        return true
    }

    // ID: IF09; NAME: Type of Report Srce(DC/AO), COD (SEER IF09)
    public boolean if09(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if ((line.typeOfReportingSource ==~/^[67]$/ && line.causeOfDeath == '0000') ||
            (line.typeOfReportingSource == '7' && line.causeOfDeath == '7777'))
            return false
        return true
    }

    // ID: IF11; NAME: Type of Report Srce(DC), EOD Coding Sys (SEER IF11)
    public boolean if11(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear != null && line.dateOfDiagnosisYear < '1983' &&
            line.registryId != '0000001544' && line.typeOfReportingSource == '7')
            return line.codingSystemForEod == '0'
        return true
    }

    // ID: IF12; NAME: Date of Last Contact, Cause of Death (SEER IF12)
    public boolean if12(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.icdRevisionNumber == '9' && (line.vitalStatus == '0' || line.vitalStatus == '4') && line.causeOfDeath >= '0420' && line.causeOfDeath <= '0449')
            return (line.dateOfLastContactYear == null || line.dateOfLastContactYear > '1986')
        
            if (line.icdRevisionNumber == '1' && line.vitalStatus == '0' && ['U070', 'U071', 'U072'].contains(line.causeOfDeath))
                return (line.dateOfLastContactYear == null || line.dateOfLastContactYear > '2018')
        return true
    }

    // ID: IF13; NAME: Age, Birth Date, Date of Diagnosis (NAACCR IF13)
    public boolean if13(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer age = functions.asInt(line.ageAtDiagnosis)
        Integer monthBirth = functions.asInt(line.dateOfBirthMonth)
        Integer yearBirth = functions.asInt(line.dateOfBirthYear)
        Integer monthDx = functions.asInt(line.dateOfDiagnosisMonth)
        Integer yearDx = functions.asInt(line.dateOfDiagnosisYear)
        
        if (age == 999)
            return (line.dateOfDiagnosisYear == null || line.dateOfBirthYear == null)
        if (age == 0 && (line.overRideAgeSiteMorph == '2' || line.overRideAgeSiteMorph == '3'))
           return true
        if (line.dateOfDiagnosisYear == null || line.dateOfBirthYear == null)
            return age == 999
        if (line.dateOfDiagnosisMonth == null || line.dateOfBirthMonth == null)
           return ((yearDx - yearBirth) == age || ((yearDx - yearBirth) - 1) == age)
        if ((((((yearDx * 12) + monthDx) - ((yearBirth * 12) + monthBirth))) / 12).intValue() < 0)
           return false
        if (monthDx == monthBirth &&
             (line.dateOfDiagnosisDay == null || line.dateOfBirthDay == null))
           return ((((((((yearDx * 12) + monthDx) - ((yearBirth * 12) + monthBirth))) / 12).intValue() - 1) == age) ||
              ((((((yearDx * 12) + monthDx) - ((yearBirth * 12) + monthBirth))) / 12).intValue() == age))
        if (monthDx == monthBirth && line.dateOfDiagnosisDay < line.dateOfBirthDay)
           return ((((((yearDx * 12) + monthDx) - ((yearBirth * 12) + monthBirth))) / 12).intValue() - 1) == age
        
        return (((((yearDx * 12) + monthDx) - ((yearBirth * 12) + monthBirth))) / 12).intValue() == age
    }

    // ID: IF14; NAME: Marital Status at DX, Age at Diagnosis (SEER IF14)
    public boolean if14(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.registryId == '0000001542' &&
            (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2000') &&
            line.maritalStatusAtDx == null)
            return true
        
        if (line.registryId == '0000001565' && (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023') && line.maritalStatusAtDx == null)
            return true
        if (line.registryId == '0000001566' && (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2022') && line.maritalStatusAtDx == null)
            return true
        
        if (functions.asInt(line.ageAtDiagnosis) < 15)
           return (line.maritalStatusAtDx == '1')
        
        return true
    }

    // ID: IF15_3; NAME: Age, Primary Site, Morphology ICDO3 (SEER IF15)
    public boolean if15_3(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer age = functions.asInt(line.ageAtDiagnosis)
        
        if (line.overRideAgeSiteMorph == '1' || line.overRideAgeSiteMorph == '3' || line.histologicTypeIcdO3 == null || line.dateOfDiagnosisYear >= '2001'
        || line.dateOfDiagnosisYear == null)
            return true
        if (age < 20 && (functions.matches(line.primarySite, /^C(15\d|17\d|199|209|21[0-8]|239|24\d|25\d|384|50\d|54\d|559)$/)
                || (functions.matches(line.primarySite, /^C18\d$/) && !functions.between(line.histologicTypeIcdO3,'8240','8245'))
                || (functions.matches(line.primarySite, /^C(339|34\d)$/) && !functions.between(line.histologicTypeIcdO3,'8240','8245'))
                || (functions.matches(line.primarySite, /^C53\d$/) && line.behaviorCodeIcdO3 == '3')))
            return false
        if (age < 15 && line.behaviorCodeIcdO3 == '2' && functions.matches(line.primarySite, /^C53\d$/))
            return false
        if ((age < 15 || age > 45) && line.primarySite == 'C589' && line.histologicTypeIcdO3 == '9100')
            return false
        if (age < 30 && (line.primarySite == 'C609' || ['9732','9823','9863','9875','9876','9945'].contains(line.histologicTypeIcdO3)))
            return false
        if (age < 40 && line.primarySite == 'C619' && line.histologicTypeIcdO3 == '8140')
            return false
        if (age > 5 && functions.matches(line.primarySite, /^C69\d$/) && functions.between(line.histologicTypeIcdO3, '9510', '9514'))
            return false
        if (age > 14 && (line.histologicTypeIcdO3 == '8960' || line.histologicTypeIcdO3 == '9946'))
            return false
        return true
    }

    // ID: IF17; NAME: Sex, Primary Site (SEER IF17)
    public boolean if17(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (((line.sex == '2' || line.sex == '9') && functions.matches(line.primarySite, /^C6[0-3]\d$/)) ||
            ((line.sex == '1' || line.sex == '9') && functions.matches(line.primarySite, /^C5[1-8]\d$/)))
            return false
        return true
    }

    // ID: IF18; NAME: Date Initial RX SEER, Date of DX (NAACCR IF18)
    public boolean if18(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer iRxDay   = functions.asInt(line.dateInitialRxSeerDay)
        Integer iRxMonth = functions.asInt(line.dateInitialRxSeerMonth)
        Integer iRxYear  = functions.asInt(line.dateInitialRxSeerYear)
        Integer iDxDay   = functions.asInt(line.dateOfDiagnosisDay)
        Integer iDxMonth = functions.asInt(line.dateOfDiagnosisMonth)
        Integer iDxYear  = functions.asInt(line.dateOfDiagnosisYear)
        
        if (iDxYear == null || iRxYear == null || (line.registryId == '0000001544' && iDxYear < 2000))
            return true
        if  (iRxDay == null && iRxMonth == null && iRxYear == null)
           return true
        if  (iRxDay == 0 && iRxMonth == 0 && iRxYear == 0)
           return true
        if (iRxYear < iDxYear)
            return false
        if (iRxYear > iDxYear || iRxMonth == null || iDxMonth == null)
           return true
        if (iRxMonth < iDxMonth)
            return false
        if (iRxMonth > iDxMonth || iRxDay == null || iDxDay == null)
           return true
        return (iRxDay >= iDxDay)
    }

    // ID: IF19; NAME: Date of Last Contact, Date of Diag (NAACCR IF19)
    public boolean if19(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfLastContactYear == null || line.dateOfDiagnosisYear == null)
             return true
        if (line.dateOfLastContactYear < line.dateOfDiagnosisYear)
            return false
        if ((line.dateOfLastContactYear > line.dateOfDiagnosisYear) ||
             line.dateOfLastContactMonth == null || line.dateOfDiagnosisMonth == null)
            return true
        if (line.dateOfLastContactMonth < line.dateOfDiagnosisMonth)
            return false
        if ((line.dateOfLastContactMonth > line.dateOfDiagnosisMonth) ||
             line.dateOfLastContactDay == null || line.dateOfDiagnosisDay == null)
            return true
        return (line.dateOfLastContactDay >= line.dateOfDiagnosisDay)
    }

    // ID: IF22_3; NAME: Seq Num--Central, Prim Site, Morph ICDO3 (SEER IF22)
    public boolean if22_3(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.matches(line.sequenceNumberCentral, /^([67]\d|8[0-8]|98)$/) || line.overRideIllDefineSite == '1' ||
           line.histologicTypeIcdO3 == null)
           return true
        
        if ((functions.matches(line.primarySite, /^C(76[0-8]|809)$/) && functions.between(line.histologicTypeIcdO3,'8000','9589')) ||
            (functions.matches(line.primarySite, /^C77\d$/) && !(functions.between(line.histologicTypeIcdO3,'9590','9729') ||
                                                functions.between(line.histologicTypeIcdO3,'9735','9738')  ||
                                                functions.between(line.histologicTypeIcdO3,'9811','9819')  ||
                                                ['9823','9826','9827','9837'].contains(line.histologicTypeIcdO3))) ||
            (functions.matches(line.primarySite, /^C42[0-4]$/) && ! functions.between(line.histologicTypeIcdO3,'9590','9993')) ||
             functions.between(line.histologicTypeIcdO3,'9740','9759'))
           return line.sequenceNumberCentral == '00'
        
        return true
    }

    // ID: IF23; NAME: Diagnostic Confirm, Seq Num--Central (SEER IF23)
    public boolean if23(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.overRideSeqnoDxconf == '1' || functions.matches(line.sequenceNumberCentral, /^[6-9]\d$/) || functions.matches(line.primarySite, /^C(76[0-8]|809)$/))
            return true
        if (line.diagnosticConfirmation ==~/^[6789]$/)
            return line.sequenceNumberCentral == '00'
        return true
    }

    // ID: IF24; NAME: Laterality, Primary Site, Date of Diag (SEER IF24)
    public boolean if24(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear >= '2021' && line.primarySite == 'C444')
            return line.laterality != '0'
        
        if (line.dateOfDiagnosisYear >= '2018' && functions.matches(line.primarySite, /^C09[01]$/))
            return true
        
        if (line.laterality == '5')
            return line.dateOfDiagnosisYear >= '2010' && functions.matches(line.primarySite, /^C(700|71[0-4]|72[2-5]|443|445)$/)
        
        if (functions.matches(line.primarySite, /^C(079|080|09[189]|301|31[02]|34[1-9]|384|50\d|569|570|62\d|63[01]|6[456]9|69\d|74\d|754)$/))
            return line.laterality != '0'
        else if (line.dateOfDiagnosisYear > '1978' && functions.matches(line.primarySite, /^C(081|090|40[0-3]|44[123567]|47[12]|49[12])$/))
            return line.laterality != '0'
        else if (line.dateOfDiagnosisYear > '2003' && functions.matches(line.primarySite, /^C(700|71[0-4]|72[2-5])$/))
            return line.laterality != '0'
        
        return true
    }

    // ID: IF25_3; NAME: Primary Site, Morphology-Type, Beh ICDO3 (SEER IF25)
    public boolean if25_3(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear > '2023' || line.overRideSiteType == '1' || line.histologicTypeIcdO3 == null || line.behaviorCodeIcdO3 == null)
           return true
        
        Integer siteNum = functions.asInt(line.primarySite.substring(1))
        Integer histNum = functions.asInt(line.histologicTypeIcdO3)
        Integer behNum = functions.asInt(line.behaviorCodeIcdO3)
        
        return ((List)((Map)((Map)context.If25_3_SiteReferenceTable).getOrDefault(siteNum, [:])).getOrDefault(behNum, [])).contains(histNum)
    }

    // ID: IF26E98_3_P1; NAME: Extent of Disease 12-Digit ICDO3 (SEER IF26E98)
    public boolean if26e98_3_p1(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.codingSystemForEod != '4' || line.dateOfDiagnosisYear < '1998' || line.dateOfDiagnosisYear == null ||
            (line.histologicTypeIcdO3 == null && line.behaviorCodeIcdO3 == null))
          return true
        
        Integer siteNum = functions.asInt(line.primarySite.substring(1))
        
        return (functions.matches(line.primarySite, /^C[0-9][0-9][0-9]$/) &&
            functions.matches(line.histologicTypeIcdO3, /^[0-9][0-9][0-9][0-9]$/) && functions.matches(line.behaviorCodeIcdO3, /^[123]$/) &&
            siteNum <= 810)
    }

    // ID: IF26E98_3_P10; NAME: EOD--Lymph Node Involv, Reg Nodes Pos,ICDO3 (NAACCR)
    public boolean if26e98_3_p10(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.codingSystemForEod != '4' || line.dateOfDiagnosisYear < '1998' || line.dateOfDiagnosisYear == null
                || (line.histologicTypeIcdO3 == null && line.behaviorCodeIcdO3 == null) || line.typeOfReportingSource == '7'
                || line.regionalNodesPositive == null || line.regionalNodesExamined == null)
            return true
        
        Integer histNum = functions.asInt(line.histologicTypeIcdO3)
        
        if (!(line.histologicTypeIcdO3 == '9140' || ((List)context.Hematopoietic).contains(histNum) || ((List)context.Lymphomas).contains(histNum) || line.histologicTypeIcdO3 == '9700' || line.histologicTypeIcdO3 == '9701'
                || functions.matches(line.primarySite, /^C(700|71\d)$/) || functions.matches(line.primarySite, /^C(70[19]|72[0-589])$/) || functions.matches(line.primarySite, /^C(42\d|76[0-578]|77\d|809)$/))) {
            if (line.regionalNodesPositive >= '01' && line.regionalNodesPositive <= '97' && (line.eodLymphNodeInvolv < '1' || line.eodLymphNodeInvolv > '8'))
               return false
        }
        
        return true
    }

    // ID: IF26E98_3_P11; NAME: Extent of Disease 12-Digit ICDO3 (SEER IF26E98)
    public boolean if26e98_3_p11(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.codingSystemForEod != '4' ||
            line.dateOfDiagnosisYear < '1998' || line.dateOfDiagnosisYear == null ||
            (line.histologicTypeIcdO3 == null && line.behaviorCodeIcdO3 == null) ||
            line.typeOfReportingSource != '7')
            return true
        
        if (line.primarySite == 'C619')
            return (line.eodTumorSize == '999' && line.eodExtension == '90' && line.eodLymphNodeInvolv == '9' &&
                line.regionalNodesPositive == '99' && line.regionalNodesExamined == '99' &&
                line.eodExtensionProstPath == '90')
        
        return (line.eodTumorSize == '999' && line.eodExtension == '99' && line.eodLymphNodeInvolv == '9' &&
               line.regionalNodesPositive == '99' && line.regionalNodesExamined == '99' && line.eodExtensionProstPath == null)
    }

    // ID: IF26E98_3_P12; NAME: EOD--Extension Prost Path, Prim Site, ICDO3 (NAACCR)
    public boolean if26e98_3_p12(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.codingSystemForEod != '4' || line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '1998' || (line.histologicTypeIcdO3 == null && line.behaviorCodeIcdO3 == null))
            return true
        if (line.primarySite != 'C619')
            return line.eodExtensionProstPath == null
        else if (line.histologicTypeIcdO3 < '9590' && line.histologicTypeIcdO3 != '9140') {
            if (line.eodExtensionProstPath == null)
                return false
            if (line.typeOfReportingSource == '7' && line.eodExtensionProstPath != '90')
                return false
            if (line.behaviorCodeIcdO3 == '2' && !(line.eodExtensionProstPath == '00' || line.eodExtensionProstPath == '99'))
                return false
            if (line.behaviorCodeIcdO3 == '3' && !functions.matches(line.eodExtensionProstPath, /^(2[03]|3[0-4]|4[0-358]|[567]0|85|9[089])$/))
                return false
        }
        return true
    }

    // ID: IF26E98_3_P2; NAME: EOD--Extension, Primary Site, ICDO3 (NAACCR)
    public boolean if26e98_3_p2(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.codingSystemForEod != '4' || line.dateOfDiagnosisYear < '1998' || line.dateOfDiagnosisYear == null ||
            (line.histologicTypeIcdO3 == null && line.behaviorCodeIcdO3 == null) ||
            line.typeOfReportingSource == '7' || line.behaviorCodeIcdO3 == '2')
            return true
        
        if (!(functions.matches(line.eodExtension, /^[0-9][0-9]$/)))
            return false
        
        if (line.primarySite == 'C778' && functions.matches(line.eodExtension, /^1[01]$/))
            return false
        
        if (['9731','9734','9750','9751','9752'].contains(line.histologicTypeIcdO3) && line.eodExtension == '10')
            return true
        
        Integer siteNum = functions.asInt(line.primarySite.substring(1))
        Integer histNum = functions.asInt(line.histologicTypeIcdO3)
        Integer eodExtNum = functions.asInt(line.eodExtension)
        
        List histList = (List)((Map)context.If26E98_3_HIST_MALIG_EXT).get(histNum)
        if (histList != null)
            return histList.contains(eodExtNum)
        
        List histSiteList = (List)((Map)((Map)context.If26E98_3_HIST_SITE_MALIG_EXT).getOrDefault(histNum, [:])).get(siteNum)
        if (histSiteList != null)
           return histSiteList.contains(eodExtNum)
        
        List siteList = (List)((Map)context.If26E98_3_SITE_MALIG_EXT).get(siteNum)
        if (siteList != null)
           return siteList.contains(eodExtNum)
        
        return false
    }

    // ID: IF26E98_3_P3; NAME: EOD--Extension, Primary Site, ICDO3 (NAACCR)
    public boolean if26e98_3_p3(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.codingSystemForEod != '4' || line.dateOfDiagnosisYear < '1998' || line.dateOfDiagnosisYear == null ||
            (line.histologicTypeIcdO3 == null && line.behaviorCodeIcdO3 == null) ||
             line.typeOfReportingSource == '7' || line.behaviorCodeIcdO3 != '2')
            return true
        
        if (! (functions.matches(line.eodExtension, /^[0-9][0-9]$/)))
            return false
        
        if (line.primarySite == 'C778' && functions.matches(line.eodExtension, /^1[01]$/))
            return false
        
        Integer siteNum = functions.asInt(line.primarySite.substring(1))
        Integer histNum = functions.asInt(line.histologicTypeIcdO3)
        Integer eodExtNum = functions.asInt(line.eodExtension)
        
        List histList = (List)((Map)context.If26E98_3_HIST_INSITU_EXT).get(histNum)
        if (histList != null)
            return histList.contains(eodExtNum)
        
        List histSiteList = (List)((Map)((Map)context.If26E98_3_HIST_SITE_INSITU_EXT).getOrDefault(histNum, [:])).get(siteNum)
        if (histSiteList != null)
           return histSiteList.contains(eodExtNum)
        
        List siteList = (List)((Map)context.If26E98_3_SITE_INSITU_EXT).get(siteNum)
        if (siteList != null)
           return siteList.contains(eodExtNum)
        
        return false
    }

    // ID: IF26E98_3_P4; NAME: EOD--Tumor Size, Primary Site, ICDO3 (NAACCR)
    public boolean if26e98_3_p4(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.codingSystemForEod != '4' || line.dateOfDiagnosisYear < '1998' || line.dateOfDiagnosisYear == null
                || (line.histologicTypeIcdO3 == null && line.behaviorCodeIcdO3 == null) || line.typeOfReportingSource == '7')
            return true
        
        if (!(functions.matches(line.eodTumorSize, /^[0-9][0-9][0-9]$/)))
            return false
        
        Integer siteNum = functions.asInt(line.primarySite.substring(1))
        Integer histNum = functions.asInt(line.histologicTypeIcdO3)
        Integer eodExtNum = functions.asInt(line.eodTumorSize)
        
        if (((List)context.ColoRectal).contains(siteNum) && line.eodTumorSize == '998' && !(line.histologicTypeIcdO3 == '8220' || line.histologicTypeIcdO3 == '8221'))
            return false
        
        List histList = (List)((Map)context.If26E98_3_HIST_SIZE).get(histNum)
        if (histList != null)
            return histList.contains(eodExtNum)
        
        List histSiteList = (List)((Map)((Map)context.If26E98_3_HIST_SITE_SIZE).getOrDefault(histNum, [:])).get(siteNum)
        if (histSiteList != null)
           return histSiteList.contains(eodExtNum)
        
        List siteList = (List)((Map)context.If26E98_3_SITE_SIZE).get(siteNum)
        if (siteList != null)
           return siteList.contains(eodExtNum)
        
        return false
    }

    // ID: IF26E98_3_P5; NAME: EOD--Lymph Node Involv, Prim Site, ICDO3 (NAACCR)
    public boolean if26e98_3_p5(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.codingSystemForEod != '4' || line.dateOfDiagnosisYear < '1998' || line.dateOfDiagnosisYear == null ||
           (line.histologicTypeIcdO3 == null && line.behaviorCodeIcdO3 == null) ||
           line.typeOfReportingSource == '7' || line.behaviorCodeIcdO3 == '2')
           return true
        
        if (! (functions.matches(line.eodLymphNodeInvolv, /^[0-9]$/)))
           return false
        
        Integer siteNum = functions.asInt(line.primarySite.substring(1))
        Integer histNum = functions.asInt(line.histologicTypeIcdO3)
        Integer eodLymphNodesNum = functions.asInt(line.eodLymphNodeInvolv)
        
        List histList = (List)((Map)context.If26E98_3_HIST_MALIG_LN).get(histNum)
        if (histList != null)
            return histList.contains(eodLymphNodesNum)
        
        List histSiteList = (List)((Map)((Map)context.If26E98_3_HIST_SITE_MALIG_LN).getOrDefault(histNum, [:])).get(siteNum)
        if (histSiteList != null)
           return histSiteList.contains(eodLymphNodesNum)
        
        List siteList = (List)((Map)context.If26E98_3_SITE_MALIG_LN).get(siteNum)
        if (siteList != null)
           return siteList.contains(eodLymphNodesNum)
        
        return false
    }

    // ID: IF26E98_3_P6; NAME: EOD--Lymph Node Involv, Prim Site, ICDO3 (NAACCR)
    public boolean if26e98_3_p6(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.codingSystemForEod != '4' || line.dateOfDiagnosisYear < '1998' || line.dateOfDiagnosisYear == null ||
             (line.histologicTypeIcdO3 == null && line.behaviorCodeIcdO3 == null) ||
              line.typeOfReportingSource == '7' || line.behaviorCodeIcdO3 != '2')
           return true
        
        if (!(functions.matches(line.eodLymphNodeInvolv, /^[0-9]$/)))
           return false
        
        Integer siteNum = functions.asInt(line.primarySite.substring(1))
        Integer histNum = functions.asInt(line.histologicTypeIcdO3)
        Integer eodLymphNodesNum = functions.asInt(line.eodLymphNodeInvolv)
        
        List histList = (List)((Map)context.If26E98_3_HIST_INSITU_LN).get(histNum)
        if (histList != null)
            return histList.contains(eodLymphNodesNum)
        
        List histSiteList = (List)((Map)((Map)context.If26E98_3_HIST_SITE_INSITU_LN).getOrDefault(histNum, [:])).get(siteNum)
        if (histSiteList != null)
           return histSiteList.contains(eodLymphNodesNum)
        
        List siteList = (List)((Map)context.If26E98_3_SITE_INSITU_LN).get(siteNum)
        if (siteList != null)
           return siteList.contains(eodLymphNodesNum)
        
        return false
    }

    // ID: IF26E98_3_P7; NAME: Extent of Disease 12-Digit ICDO3 (SEER IF26E98)
    public boolean if26e98_3_p7(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.codingSystemForEod != '4' || line.dateOfDiagnosisYear < '1998' ||
              line.dateOfDiagnosisYear == null ||
             (line.histologicTypeIcdO3 == null && line.behaviorCodeIcdO3 == null) ||
              line.typeOfReportingSource == '7')
            return true
        
        if (!(functions.matches(line.regionalNodesPositive, /^[0-9][0-9]$/)))
            return false
        
        Integer siteNum = functions.asInt(line.primarySite.substring(1))
        Integer histNum = functions.asInt(line.histologicTypeIcdO3)
        Integer regNodesPosNum = functions.asInt(line.regionalNodesPositive)
        
        if (line.behaviorCodeIcdO3 == '2') {
            List histList = (List)((Map)context.If26E98_3_HIST_INSITU_POS_NODES).get(histNum)
            if (histList != null)
                return histList.contains(regNodesPosNum)
        
            List histSiteList = (List)((Map)((Map)context.If26E98_3_HIST_SITE_INSITU_POS_NODES).getOrDefault(histNum, [:])).get(siteNum)
            if (histSiteList != null)
               return histSiteList.contains(regNodesPosNum)
        
            List siteList = (List)((Map)context.If26E98_3_SITE_INSITU_POS_NODES).get(siteNum)
            if (siteList != null)
               return siteList.contains(regNodesPosNum)
        
            return false
        }
        else if (line.behaviorCodeIcdO3 == '3' || line.behaviorCodeIcdO3 == '1') {
            List histList = (List)((Map)context.If26E98_3_HIST_MALIG_POS_NODES).get(histNum)
            if (histList != null)
                return histList.contains(regNodesPosNum)
        
            List histSiteList = (List)((Map)((Map)context.If26E98_3_HIST_SITE_MALIG_POS_NODES).getOrDefault(histNum, [:])).get(siteNum)
            if (histSiteList != null)
               return histSiteList.contains(regNodesPosNum)
        
            List siteList = (List)((Map)context.If26E98_3_SITE_MALIG_POS_NODES).get(siteNum)
            if (siteList != null)
               return siteList.contains(regNodesPosNum)
        
            return false
        }
        
        return true
    }

    // ID: IF26E98_3_P8; NAME: Extent of Disease 12-Digit ICDO3 (SEER IF26E98)
    public boolean if26e98_3_p8(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.codingSystemForEod != '4' || line.dateOfDiagnosisYear < '1998' || line.dateOfDiagnosisYear == null
                || (line.histologicTypeIcdO3 == null && line.behaviorCodeIcdO3 == null) || line.typeOfReportingSource == '7')
            return true
        
        if (! (functions.matches(line.regionalNodesExamined, /^[0-9][0-9]$/)))
            return false
        
        Integer siteNum = functions.asInt(line.primarySite.substring(1))
        Integer histNum = functions.asInt(line.histologicTypeIcdO3)
        Integer regNodesExNum = functions.asInt(line.regionalNodesExamined)
        
        if (line.behaviorCodeIcdO3 == '2') {
            List histList = (List)((Map)context.If26E98_3_HIST_INSITU_REG_EXAM).get(histNum)
            if (histList != null)
                return histList.contains(regNodesExNum)
        
            List histSiteList = (List)((Map)((Map)context.If26E98_3_HIST_SITE_INSITU_REG_EXAM).getOrDefault(histNum, [:])).get(siteNum)
            if (histSiteList != null)
               return histSiteList.contains(regNodesExNum)
        
            List siteList = (List)((Map)context.If26E98_3_SITE_INSITU_REG_EXAM).get(siteNum)
            if (siteList != null)
               return siteList.contains(regNodesExNum)
        
            return false
        }
        else if (line.behaviorCodeIcdO3 == '3' || line.behaviorCodeIcdO3 == '1') {
            List histList = (List)((Map)context.If26E98_3_HIST_MALIG_REG_EXAM).get(histNum)
            if (histList != null)
                return histList.contains(regNodesExNum)
        
            List histSiteList = (List)((Map)((Map)context.If26E98_3_HIST_SITE_MALIG_REG_EXAM).getOrDefault(histNum, [:])).get(siteNum)
            if (histSiteList != null)
               return histSiteList.contains(regNodesExNum)
        
            List siteList = (List)((Map)context.If26E98_3_SITE_MALIG_REG_EXAM).get(siteNum)
            if (siteList != null)
               return siteList.contains(regNodesExNum)
        
            return false
        }
        
        return true
    }

    // ID: IF26E98_3_P9; NAME: EOD--Reg Nodes Ex,ReNodes Pos, Site, ICDO3 (NAACCR)
    public boolean if26e98_3_p9(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '1998' || line.dateOfDiagnosisYear > '2003' || line.histologicTypeIcdO3 == null ||
                    line.behaviorCodeIcdO3 == null || line.typeOfReportingSource == '7' || (line.registryId == '0000001544' && line.dateOfDiagnosisYear < '2000'))
            return true
        
        if (functions.matches(line.histologicTypeIcdO3, /^9(59\d|6\d\d|7(0[2-9]|[12]\d|3[1-4]|4\d|5[0-8]|[6789]\d)|8\d\d|9[0-8]\d)$/) &&
            !(line.regionalNodesPositive == '99' && line.regionalNodesExamined == '99'))
            return false
        
        if (functions.matches(line.primarySite, /^C(42\d|7(0[019]|1\d|2[0-589]|6[0-578]|7\d)|809)$/) && line.histologicTypeIcdO3 != '9140' &&
            !(line.regionalNodesPositive == '99' && line.regionalNodesExamined == '99'))
            return false
        
        if (line.behaviorCodeIcdO3 == '2' && !(line.regionalNodesPositive == '00' || line.regionalNodesPositive == '98'))
            return false
        
        if (line.regionalNodesExamined == '00' && line.regionalNodesPositive != '98')
            return false
        if (functions.matches(line.regionalNodesExamined, /^0[1-9]|[1-8]\d$/) &&
            !(line.regionalNodesPositive == '97' || line.regionalNodesPositive == '99' || line.regionalNodesPositive <= line.regionalNodesExamined))
            return false
        if (functions.matches(line.regionalNodesExamined, /^9[0678]$/) && !(functions.matches(line.regionalNodesPositive, /^[0-8]\d|9[079]$/)))
            return false
        if (line.regionalNodesExamined == '99' && line.regionalNodesPositive != '99')
            return false
        
        if (line.regionalNodesPositive == '97' && !functions.matches(line.regionalNodesExamined, /^0[2-9]|[1-8]\d|9[0-8]$/))
            return false
        if (functions.matches(line.regionalNodesPositive, /^[0-8]\d|9[0-6]$/) && line.regionalNodesPositive > line.regionalNodesExamined)
            return false
        return true
    }

    // ID: IF26NSPC_P1; NAME: EOD--Old 2 digit, Morphology (SEER IF26NSPC)
    public boolean if26nspc_p1(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.codingSystemForEod != '0')
            return true
        
        return (functions.matches(line.eodOld2Digit, /^[-&0456789][-]$/))
    }

    // ID: IF26NSPC_P2; NAME: EOD--Old 2 digit, Morphology (SEER IF26NSPC)
    public boolean if26nspc_p2(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.codingSystemForEod != '0')
           return true
        
        if (line.behaviorCodeIcdO3 == '2')
           return line.eodOld2Digit == '0-'
        
        if (line.behaviorCodeIcdO3 == '3')
           return line.eodOld2Digit != '0-'
        return true
    }

    // ID: IF29; NAME: RX Summ--Surgery Type, Site, RptSrc (SEER IF29)
    public boolean if29(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null
                || (line.registryId == '0000001544' && line.dateOfDiagnosisYear < '2000') || (line.registryId == '0000001541' && line.dateOfDiagnosisYear < '1998'))
            return true
        
        if (line.registryId == '0000001562' || line.registryId == '0000001563')
            return true
        
        if (line.dateOfDiagnosisYear < '1998' && line.typeOfReportingSource == '6')
            return line.rxSummSurgeryType == '00'
        
        if (line.dateOfDiagnosisYear < '1998' && line.typeOfReportingSource == '7')
            return line.rxSummSurgeryType == '09'
        
        if (line.dateOfDiagnosisYear > '1997')
            return line.rxSummSurgeryType == null
        
        Integer siteNum = functions.asInt(line.primarySite.substring(1))
        
        if (siteNum < 0 || line.rxSummSurgeryType == null || line.rxSummSurgeryType < '00' || line.rxSummSurgeryType > '99')
            return false
        
        if (functions.between(siteNum,540,549) && line.dateOfDiagnosisYear > '1989' && line.rxSummSurgeryType == '35')
            return true
        
        if (functions.between(siteNum,530,539) && ((line.dateOfDiagnosisYear > '1989' && line.rxSummSurgeryType == '35')
                || (line.dateOfDiagnosisYear > '1990' && line.rxSummSurgeryType == '17')))
            return true
        
        if (functions.between(siteNum,440,449) && (line.histologicTypeIcdO3 < '8720' || line.histologicTypeIcdO3 > '8790')
                && line.dateOfDiagnosisYear < '1988' && line.registryId != '0000001529' && line.rxSummSurgeryType != '09' && line.rxSummSurgeryType != '90')
            return false
        
        if (functions.between(siteNum,530,539) && line.dateOfDiagnosisYear > '1987' && line.rxSummSurgeryType == '15' && line.behaviorCodeIcdO3 != '2')
            return false
        
        Integer surgType = functions.asInt(line.rxSummSurgeryType)
        
        if (functions.between(siteNum,500,509) && line.behaviorCodeIcdO3 == '2')
            return ((List)((Map)context.IF29_Post1987).getOrDefault(siteNum, [])).contains(surgType)
        
        if (functions.between(siteNum,700,729) && line.dateOfDiagnosisYear >= '1992' && line.dateOfDiagnosisYear <= '1997' &&
               (line.rxSummSurgeryType == '35' || line.rxSummSurgeryType == '55'))
            return false
        
        if (line.dateOfDiagnosisYear < '1983')
            return line.rxSummSurgeryType == '09' || line.rxSummSurgeryType == '90'
        
        if (line.dateOfDiagnosisYear < '1988' && line.registryId != '0000001529')
            return ((List)((Map)context.IF29_Pre1988).getOrDefault(siteNum, [])).contains(surgType)
        
        return ((List)((Map)context.IF29_Post1987).getOrDefault(siteNum, [])).contains(surgType)
    }

    // ID: IF31_3; NAME: Diagnostic Confirmation, Behavior ICDO3 (SEER IF31)
    public boolean if31_3(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.overRideHistology == '2' || line.overRideHistology == '3' ||
            line.behaviorCodeIcdO3 != '2' || line.dateOfDiagnosisYear == null)
           return true
        
        if (line.histologicTypeIcdO3 == '8453' && line.dateOfDiagnosisYear >= '2024')
            return true
        
        return line.diagnosticConfirmation ==~/^[124]$/
    }

    // ID: IF33; NAME: Date of Diagnosis, EOD Coding Sys, EOD (SEER IF33)
    public boolean if33(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || (line.dateOfDiagnosisYear < '1992' && line.registryId == '0000001535')
                 || (line.registryId == '0000001544' && (line.dateOfDiagnosisYear == '1998' || line.dateOfDiagnosisYear == '1999') && line.codingSystemForEod == null))
            return true
        
        if (line.registryId == '0000001541' && line.dateOfDiagnosisYear < '1994')
            return true
        
        if (['0000001563', '0000001565', '0000001566'].contains(line.registryId))
            return true
        
        if ((line.registryId == '0000001544' && line.dateOfDiagnosisYear < '1998') ||
            line.registryId == '0000001561' || line.registryId == '0000001562')
            return line.codingSystemForEod == null
        
        if (line.dateOfDiagnosisYear < '1983') {
            if (line.codingSystemForEod == '0') {
                return (functions.matches(line.eodOld2Digit, /^[-&04-9][-]$/) &&
                 line.eodOld4Digit == null && line.eodOld13Digit == null &&
                 line.eodTumorSize == null && line.eodExtension == null &&
                 line.eodLymphNodeInvolv == null && line.regionalNodesPositive == null &&
                 line.regionalNodesExamined == null && line.eodExtensionProstPath == null)
            }
            if (line.codingSystemForEod == '1') {
                return (line.eodOld4Digit == null && line.eodOld13Digit == null
                     && line.eodTumorSize == null && line.eodExtension == null
                     && line.eodLymphNodeInvolv == null && line.regionalNodesPositive == null
                     && line.regionalNodesExamined == null && line.eodExtensionProstPath == null
                     && functions.matches(line.eodOld2Digit, /^[-&0-9][-&0-9]$/))
            }
            if (line.codingSystemForEod == '2' &&
               line.eodOld4Digit == null && line.eodOld2Digit == null &&
               line.eodTumorSize == null && line.eodExtension == null &&
               line.eodLymphNodeInvolv == null && line.regionalNodesPositive == null &&
               line.regionalNodesExamined == null && line.eodExtensionProstPath == null) {
                return functions.matches(line.eodOld13Digit, /^[-&0-9]{13}$/)
           }
           return false
        }
        
        String eodOld4DigitNodes = null, eodOld4DigitSize = null, eodOld4DigitExtent = null
        if (line.eodOld4Digit != null && line.eodOld4Digit.length() > 3)
            eodOld4DigitNodes = line.eodOld4Digit.substring(3, 4)
        if (line.eodOld4Digit != null && line.eodOld4Digit.length() > 1)
            eodOld4DigitSize = line.eodOld4Digit.substring(0, 2)
        if (line.eodOld4Digit != null && line.eodOld4Digit.length() > 2)
            eodOld4DigitExtent = line.eodOld4Digit.substring(2, 3)
        
        if (line.dateOfDiagnosisYear > '1982' && line.dateOfDiagnosisYear < '1988' &&
            line.registryId != '0000001529') {
            if (line.codingSystemForEod == '3') {
               return (eodOld4DigitSize != null && eodOld4DigitExtent != null && eodOld4DigitNodes != null &&
                  eodOld4DigitSize >= '00' && eodOld4DigitSize <= '99' &&
                  eodOld4DigitExtent >= '0' && eodOld4DigitExtent <= '9' &&
                  eodOld4DigitNodes >= '0' && eodOld4DigitNodes <= '9' &&
                  line.eodOld2Digit == null && line.eodOld13Digit == null &&
                  line.eodTumorSize == null && line.eodExtension == null &&
                  line.eodLymphNodeInvolv == null && line.regionalNodesPositive == null &&
                  line.regionalNodesExamined == null && line.eodExtensionProstPath == null)
            }
            return false
        }
        if ((line.dateOfDiagnosisYear >= '1988' && line.dateOfDiagnosisYear <= '2003') ||
             (line.registryId == '0000001529' && line.dateOfDiagnosisYear <= '2003')) {
            if (line.codingSystemForEod == '4')
                return (line.eodOld4Digit == null &&
                  line.eodOld2Digit == null && line.eodOld13Digit == null &&
                  line.eodTumorSize != null && line.eodExtension != null && line.eodLymphNodeInvolv != null &&
                  line.regionalNodesPositive != null && line.regionalNodesExamined != null &&
                  line.eodTumorSize >= '000' && line.eodTumorSize <= '999' &&
                  line.eodExtension >= '00' && line.eodExtension <= '99' &&
                  line.eodLymphNodeInvolv >= '0' && line.eodLymphNodeInvolv <= '9' &&
                  line.regionalNodesPositive >= '00' && line.regionalNodesPositive <= '99' &&
                  line.regionalNodesExamined >= '00' && line.regionalNodesExamined <= '99')
             return false
        }
        if (line.dateOfDiagnosisYear > '2003') {
           return (line.codingSystemForEod == null &&
              line.eodTumorSize == null && line.eodExtension == null && line.eodLymphNodeInvolv == null &&
              line.eodExtensionProstPath == null && line.eodOld4Digit == null &&
              line.eodOld2Digit == null && line.eodOld13Digit == null)
        }
        return true
    }

    // ID: IF34; NAME: Date Initial RX SEER, Ca Dir RX Pre-98 (SEER IF34)
    public boolean if34(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer iDxYear = functions.asInt(line.dateOfDiagnosisYear)
        
        if (line.registryId == '0000001544' || line.registryId == '0000001541' || iDxYear == null ||  iDxYear >= 1998)
           return true
        
        Boolean radToCnsNoUnk = line.rxSummRadToCns ==~/^[0789]$/
        Boolean radToCnsYes = line.rxSummRadToCns == '1'
        Boolean dateHasValue = (line.dateInitialRxSeerYear != null || line.dateInitialRxSeerMonth != null || line.dateInitialRxSeerDay != null)
        Boolean rxSummBrmNoUnk = functions.matches(line.rxSummBrm, /^(00|8[25-8]||99)$/)
        Boolean rxSummBrmYes = line.rxSummBrm == '01'
        Boolean rxSummRadNoUnk = functions.matches(line.rxSummRadiation, /^[0789]$/)
        Boolean rxSummRadYes = functions.matches(line.rxSummRadiation, /^[1-6]$/)
        Boolean rxSummSurgRadSeqNoUnk = line.rxSummSurgRadSeq == '0'
        Boolean rxSummSurgRadSeqYes = functions.matches(line.rxSummSurgRadSeq, /^[2-9]$/)
        Boolean rxSummChemoNoUnk = functions.matches(line.rxSummChemo, /^(00|8[25-8]|99)$/)
        Boolean rxSummChemoYes = functions.matches(line.rxSummChemo, /^0[123]$/)
        Boolean rxSummHormoneNoUnk = functions.matches(line.rxSummHormone, /^(00|8[25-8]|99)$/)
        Boolean rxSummHormoneYes = line.rxSummHormone == '01'
        Boolean rxSummOtherNoUnk = functions.matches(line.rxSummOther, /^[0789]$/)
        Boolean rxSummOtherYes = functions.matches(line.rxSummOther, /^[1236]$/)
        Boolean rxSummTransplntEndocrNoUnk = functions.matches(line.rxSummTransplntEndocr, /^(00|8[25-8]|99)$/)
        Boolean rxSummTransplntEndocrYes = functions.matches(line.rxSummTransplntEndocr, /^1[012]|[234]0$/)
        Boolean primSiteHistCheck = (functions.matches(line.primarySite, /^C34\d$/) || functions.between(line.histologicTypeIcdO3, '9800', '9941'))
        
        if (iDxYear < 1988 && line.registryId != '0000001529') {
            if(dateHasValue &&
                (line.rxSummSurgeryType == '00' || (line.rxSummSurgeryType == '09' && line.reasonForNoSurgery ==~/^[68]$/) || (line.rxSummSurgeryType == '09' && line.reasonForNoSurgery == '9'))
                && rxSummRadNoUnk && rxSummSurgRadSeqNoUnk
                && rxSummChemoNoUnk && rxSummHormoneNoUnk
                && rxSummBrmNoUnk && rxSummOtherNoUnk
                && rxSummTransplntEndocrNoUnk) {
                return false
            }
            else if (dateHasValue &&
                (line.rxSummSurgeryType != null && functions.matches(line.rxSummSurgeryType, /^([1-8]\d|9[0-8])$/))
                || line.reasonForNoSurgery == '0' || rxSummRadYes
                || rxSummSurgRadSeqYes || rxSummChemoYes
                || rxSummHormoneYes || rxSummBrmYes || rxSummOtherYes
                || rxSummTransplntEndocrYes) {
               return true
            }
        }
        else {
            if(dateHasValue &&
                ((line.rxSummSurgeryType != null && functions.between(line.rxSummSurgeryType, '00', '09'))
                && functions.matches(line.reasonForNoSurgery, /^[1-8]$/) || (line.rxSummSurgeryType == '09' && line.reasonForNoSurgery == '9'))
                && rxSummRadNoUnk && rxSummSurgRadSeqNoUnk
                && rxSummChemoNoUnk && rxSummHormoneNoUnk
                && rxSummBrmNoUnk && rxSummOtherNoUnk
                && rxSummTransplntEndocrNoUnk
                && ((!(primSiteHistCheck)) || radToCnsNoUnk)) {
                return false
            }
            else if (dateHasValue &&
                (line.rxSummSurgeryType != null && functions.matches(line.rxSummSurgeryType, /^([1-8]\d|9[0-8])$/))
                || line.reasonForNoSurgery == '0' || rxSummRadYes
                || rxSummSurgRadSeqYes || rxSummChemoYes
                || rxSummHormoneYes || rxSummBrmYes || rxSummOtherYes
                || rxSummTransplntEndocrYes || (primSiteHistCheck && radToCnsYes)) {
                return true
            }
        }
        
        return true
    }

    // ID: IF35; NAME: Date Initial RX SEER, Date Last Cont (NAACCR IF35)
    public boolean if35(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer iLastContactYear = functions.asInt(line.dateOfLastContactYear)
        Integer iLastContactMonth = functions.asInt(line.dateOfLastContactMonth)
        Integer iLastContactDay = functions.asInt(line.dateOfLastContactDay)
        Integer iRxYear = functions.asInt(line.dateInitialRxSeerYear)
        Integer iRxMonth  = functions.asInt(line.dateInitialRxSeerMonth)
        Integer iRxDay = functions.asInt(line.dateInitialRxSeerDay)
        
        if ((line.registryId == '0000001544' && line.dateOfDiagnosisYear < '1995') || iRxYear == null
                || iLastContactYear == null)
            return true
        
        if (iRxYear == null && iRxMonth == null && iRxDay == null)
            return true
        
        if (iRxYear == 0 && iRxMonth == 0 && iRxDay == 0)
            return true
        
        if (iRxYear > iLastContactYear)
           return false
        
        if (iRxYear < iLastContactYear || iRxMonth == null || line.dateOfLastContactMonth == null)
           return true
        
        if (iRxMonth > iLastContactMonth)
           return false
        
        if (iRxMonth < iLastContactMonth || iRxDay == null ||
             line.dateOfLastContactDay == null)
           return true
        
        return iRxDay <= iLastContactDay
    }

    // ID: IF36; NAME: Vital Status, Cause of Death (SEER IF36)
    public boolean if36(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.vitalStatus == '1')
           return line.causeOfDeath == '0000'
        
        if (line.vitalStatus == '0')
           return line.causeOfDeath != '0000'
        
        return true
    }

    // ID: IF37; NAME: ICD Revision Number, Cause of Death (SEER IF37)
    public boolean if37(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        String cod = line.causeOfDeath
        if (cod == '0000')
           return line.icdRevisionNumber == '0'
        
        if (line.icdRevisionNumber == '0')
           return false
        
        if (cod == '7777' || cod == '7797' || line.icdRevisionNumber == null)
           return true
        
        if (line.icdRevisionNumber == '1') {
           if (cod != null && cod.length() == 4)
               return ((List)((Map)context.ICD10_Table_3).getOrDefault(cod.substring(0,1), [])).contains(functions.asInt(cod.substring(1)))
           else if (cod != null && cod.length() == 3)
               return ((List)((Map)context.ICD10_Table_2).getOrDefault(cod.substring(0,1), [])).contains(functions.asInt(cod.substring(1)))
           else
               return false
        }
        
        // if ICD Revision Number is not ICD-10, the length must be 4
        if (cod != null && cod.length() != 4)
            return false
        
        if (line.icdRevisionNumber == '7')
           return cod != null && ((List)context.ICD7_Table).contains(functions.asInt(cod))
        
        if (line.icdRevisionNumber == '8')
           return cod != null && ((List)context.ICD8_Table).contains(functions.asInt(cod))
        
        if (line.icdRevisionNumber == '9')
           return cod != null && ((List)context.ICD9_Table).contains(functions.asInt(cod))
        
        return true
    }

    // ID: IF38_3; NAME: Primary Site, Morphology-Imposs ICDO3 (SEER IF38)
    public boolean if38_3(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer site = functions.asInt(line.primarySite.substring(1))
        Integer hist = functions.asInt(line.histologicTypeIcdO3)
        
        if (hist == null || line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear > '2023')
           return true
        
        // check Glioblastomas
        if (((site >= 0 && site <= 709) || (site >= 728 && site <= 750) || site == 752 || (site >= 754 && site <= 809)) && hist >= 9440 && hist <= 9442)
            return false
        
        // check the rest
        return !((List)((Map)context.IF38_3Table).getOrDefault(site, [])).contains(hist)
    }

    // ID: IF39_3; NAME: Primary Site, Behavior Code ICDO3 (SEER IF39)
    public boolean if39_3(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.behaviorCodeIcdO3 != '2' || line.overRideSiteBehavior == '1')
           return true
        
        return !((List)context.InvalidInsituSites).contains(functions.asInt(line.primarySite.substring(1)))
    }

    // ID: IF40_3; NAME: Primary Site, EOD, ICDO3 (SEER IF40)
    public boolean if40_3(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.overRideSiteEodDxDt == '1' || line.histologicTypeIcdO3 == null ||
            (line.histologicTypeIcdO3 == '9140' && line.codingSystemForEod == '4') ||
            line.histologicTypeIcdO3 >= '9590' || line.behaviorCodeIcdO3 == '2' ||
            line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear == '9999' ||
            line.dateOfDiagnosisYear > '2003')
            return true
        
        String eodOld4DigitExtent = null
        if (line.eodOld4Digit != null && line.eodOld4Digit.length() > 2)
            eodOld4DigitExtent = line.eodOld4Digit.substring(2, 3)
        
        if (line.primarySite == 'C189' &&  ! ['8210','8220','8261','8263'].contains(line.histologicTypeIcdO3)) {
           if (functions.matches(line.codingSystemForEod, /^[01]$/) && line.eodOld2Digit == '4-')
              return false
           if (line.codingSystemForEod == '3' && functions.matches(eodOld4DigitExtent, /^[123]$/))
              return false
           if (line.codingSystemForEod == '4' && functions.matches(line.eodExtension, /^([12]\d|30)$/))
              return false
        }
        else if (functions.matches(line.codingSystemForEod, /^[01]$/))
           return (!((functions.matches(line.primarySite, /^C(069|26\d|39\d|4[0179]9|5[57]9|639|76[0-8]|809)$/) && line.eodOld2Digit == '4-') ||
                 (functions.matches(line.primarySite, /^C(76[0-8]|809)$/) && line.eodOld2Digit == '5-')))
        else if (line.codingSystemForEod == '3' && functions.matches(line.primarySite, /^C(069|26\d|39\d|4[0179]9|5[57]9|639|76[0-8]|809)$/) &&
                 functions.matches(eodOld4DigitExtent, /^[123]$/))
           return false
        else if (line.codingSystemForEod == '4' && functions.matches(line.primarySite, /^C(069|26\d|39\d|4[0179]9|5[57]9|639|76[0-8]|809)$/) &&
                 functions.matches(line.eodExtension, /^([12]\d|30)$/))
           return false
        
        return true
    }

    // ID: IF41_3; NAME: Primary Site, Laterality, EOD, ICDO3 (SEER IF41)
    public boolean if41_3(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer site = functions.asInt(line.primarySite.substring(1))
        
        if (line.overRideSiteLatEod == '1' || line.histologicTypeIcdO3 == null || line.dateOfDiagnosisYear > '2003' || line.dateOfDiagnosisYear == null)
            return true
        
        String eodOld4DigitExtent = null
        if (line.eodOld4Digit != null && line.eodOld4Digit.length() > 2)
            eodOld4DigitExtent = line.eodOld4Digit.substring(2, 3)
        
        if (functions.matches(line.primarySite, /^C(079|080|09[189]|301|31[02]|34[1-9]|384|50\d|569|570|62\d|63[01]|6[456]9|69\d|74\d|754)$/)
               || (line.dateOfDiagnosisYear > '1978' &&
               [81,90,400,401,402,403,441,442,446,447,471,472,491,492].contains(site))) {
            if ((line.histologicTypeIcdO3 == '9140' && line.dateOfDiagnosisYear > '1987') ||
                functions.between(line.histologicTypeIcdO3, '9590','9989'))
                return true
            if (line.codingSystemForEod == '0') {
                if (line.laterality == '9' && ['0-','4-','5-'].contains(line.eodOld2Digit))
                    return false
        
                if (line.laterality == '4' && ['0-','4-','5-'].contains(line.eodOld2Digit) &&
                     ! (site == 569 || (site == 649 && line.histologicTypeIcdO3 == '8960')
                        || (site == 692 && ['9510','9511','9512','9513','9514'].contains(line.histologicTypeIcdO3))))
                   return false
            }
            else if (line.codingSystemForEod == '1') {
                if (line.laterality == '9' && functions.matches(line.eodOld2Digit, /^[01234][-&0-9\s]$/))
                    return false
        
                    if (line.laterality == '4' && functions.matches(line.eodOld2Digit, /^[01234][-&0-9\s]$/) &&
                       ! (site == 569 || (site == 649 && line.histologicTypeIcdO3 == '8960') ||
                         (site == 692 && ['9510','9511','9512','9513','9514'].contains(line.histologicTypeIcdO3))))
                        return false
                }
                else if (line.codingSystemForEod == '3') {
                    if (line.laterality == '9' && functions.matches(eodOld4DigitExtent, /^[0123\s]$/))
                        return false
        
                    if (line.laterality == '4' && functions.matches(eodOld4DigitExtent, /^[0123\s]$/) &&
                        ! (site == 569 || (site == 649 && line.histologicTypeIcdO3 == '8960')
                          || (site == 692 && ['9510','9511','9512','9513','9514'].contains(line.histologicTypeIcdO3))))
                        return false
                }
                else if (line.codingSystemForEod == '4') {
                    if (line.laterality == '9' &&
                      (functions.between(site,500,509) && (functions.matches(line.eodExtension, /^[01]\d$/)) ||
                      (functions.matches(line.primarySite, /^C(079|08[01]|09[0189]|301|31[02]|34[1-9]|384|40[0-3]|4[79][12]|569|570|62\d|63[01]|6[456]9|69\d|74\d|754)$/) &&
                      functions.matches(line.eodExtension, /^([012]\d|30)$/)) ||
                      ([441,442,446,447].contains(site) && functions.matches(line.eodExtension, /^([0-3]\d|40)$/))))
                        return false
                    if ([90,91,98,99,569].contains(site) ||
                      (site == 649 && line.histologicTypeIcdO3 == '8960') ||
                      (site == 692 && ['9510','9511','9512','9513','9514'].contains(line.histologicTypeIcdO3)))
                        return true
                    if (line.laterality == '4' &&
                      ((functions.between(site,500,509) && functions.matches(line.eodExtension, /^[01]\d$/)) ||
                      (functions.matches(line.primarySite, /^C(079|08[01]|09[0189]|301|31[02]|34[1-9]|384|40[0-3]|4[79][12]|569|570|62\d|63[01]|6[456]9|69\d|74\d|754)$/)
                      && functions.matches(line.eodExtension, /^([012]\d|30)$/)) ||
                      ([441,442,446,447].contains(site) && functions.matches(line.eodExtension, /^([0-3]\d|40)$/))))
                        return false
                }
        }
        return true
    }

    // ID: IF42_3; NAME: Laterality, Primary Site, Morph ICDO3 (SEER IF42)
    public boolean if42_3(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.overRideSiteLatMorph == '1' || line.histologicTypeIcdO3 == null || line.histologicTypeIcdO3 >= '9590' ||
            ((line.dateOfDiagnosisYear >= '1988' || line.dateOfDiagnosisYear == null) && line.histologicTypeIcdO3 == '9140'))
            return true
        else if (line.dateOfDiagnosisYear >= '2018' && (line.primarySite == 'C090' || line.primarySite == 'C091') && line.laterality == '0')
            return true
        else if (line.dateOfDiagnosisYear >= '2021' && functions.matches(line.primarySite, /^C44[345]$/) && line.histologicTypeIcdO3 >= '8720' && line.histologicTypeIcdO3 <= '8790')
            return line.laterality != '0'
        
        if (functions.matches(line.primarySite, /^C(079|080|09[189]|301|31[02]|34[1-9]|384|50\d|569|570|62\d|63[01]|6[456]9|69\d|74\d|754)$/)
                || ((line.dateOfDiagnosisYear > '1978' || line.dateOfDiagnosisYear == null) && functions.matches(line.primarySite, /^C(081|090|40[0-3]|44[1267]|4[79][12])$/)))
            return !(line.behaviorCodeIcdO3 == '2' && !(line.laterality ==~/^[1235]$/))
        
        return true
    }

    // ID: IF43_3; NAME: Age, Histologic Type, COD, ICDO3 (SEER IF43)
    public boolean if43_3(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer iAgeAtDiagnosis = functions.asInt(line.ageAtDiagnosis)
        
        return (line.histologicTypeIcdO3 == null || !(iAgeAtDiagnosis < 30
                && line.histologicTypeIcdO3 == '9800' && (line.causeOfDeath == '2040' || line.causeOfDeath == 'C910')))
    }

    // ID: IF44; NAME: RX Summ--Surgery Type, Radiation (SEER IF44)
    public boolean if44(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.rxSummSurgeryType == null)
            return true
        
        if (functions.matches(line.rxSummSurgeryType, /^[1-9]\d$/) && (functions.matches(line.rxSummRadiation, /^[1-6]$/) || line.rxSummRadToCns == '1'))
            return functions.matches(line.rxSummSurgRadSeq, /^[2-69]$/)
        
        if (line.rxSummSurgeryType < '10' || line.rxSummRadiation == '0')
            return line.rxSummSurgRadSeq == '0'
        
        return true
    }

    // ID: IF45; NAME: Census Tract 1970/80/90, Census Cod Sys (SEER IF45)
    public boolean if45(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if ((line.censusCodSys19708090 == '0' && line.censusTract19708090 != '000000') || line.censusCodSys19708090 != '0' && line.censusTract19708090 == '000000')
            return false
        
        if ((line.censusCodSys19708090 == null && line.censusTract19708090 != null) || (line.censusCodSys19708090 != null && line.censusTract19708090 == null))
            return false
        
        return true
    }

    // ID: IF46; NAME: RX Summ--Surgery Type, Diag Conf (SEER IF46)
    public boolean if46(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.registryId == '0000001544' && (line.dateOfDiagnosisYear < '2000' || line.dateOfDiagnosisYear == null))
            return true
        if (line.overRideSurgDxconf == '1')
            return true
        
        return !functions.matches(line.rxSummSurgeryType, /^(0[12567]|[1-8]\d|9[0-8])$/) || functions.matches(line.diagnosticConfirmation, /^[1234]$/)
    }

    // ID: IF47; NAME: Date of Birth, Date of Diagnosis (NAACCR IF47)
    public boolean if47(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer dxYear = functions.asInt(line.dateOfDiagnosisYear)
        Integer dxMonth = functions.asInt(line.dateOfDiagnosisMonth)
        Integer dxDay = functions.asInt(line.dateOfDiagnosisDay)
        Integer birthYear = functions.asInt(line.dateOfBirthYear)
        Integer birthMonth = functions.asInt(line.dateOfBirthMonth)
        Integer birthDay = functions.asInt(line.dateOfBirthDay)
        
        if (line.dateOfDiagnosisYear == null || line.dateOfBirthYear == null)
           return true
        
        if (birthYear < dxYear)
           return true
        
        if (line.dateOfDiagnosisMonth == null || line.dateOfBirthMonth == null) {
           if (birthYear == dxYear)
              return true
           if (birthYear - dxYear == 1) {
              if (line.dateOfDiagnosisMonth == null && line.dateOfBirthMonth != null) {
                 if (birthMonth >= 8)
                    return false
                 return line.overRideAgeSiteMorph == '2' || line.overRideAgeSiteMorph == '3'
              }
              if (line.dateOfBirthMonth == null && line.dateOfDiagnosisMonth != null) {
                 if (dxMonth <= 5)
                    return false
                 return line.overRideAgeSiteMorph == '2' || line.overRideAgeSiteMorph == '3'
              }
              return true
           }
           return false
        }
        
        Integer iDateDiff = (birthYear * 12 + birthMonth) - (dxYear * 12 + dxMonth)
        
        if (iDateDiff < 0)
           return true
        if (iDateDiff == 0) {
           if (line.dateOfDiagnosisDay == null || line.dateOfBirthDay == null || dxDay >= birthDay)
              return true
           return line.overRideAgeSiteMorph == '2' || line.overRideAgeSiteMorph == '3'
        }
        if (iDateDiff < 7)
           return line.overRideAgeSiteMorph == '2' || line.overRideAgeSiteMorph == '3'
        if (iDateDiff == 7) {
           if (line.dateOfDiagnosisDay == null || line.dateOfBirthDay == null || dxDay >= birthDay)
              return line.overRideAgeSiteMorph == '2' || line.overRideAgeSiteMorph == '3'
           return false
        }
        
        return false
    }

    // ID: IF48_3; NAME: Diagnostic Confirmation, Histology ICDO3 (SEER IF48)
    public boolean if48_3(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.overRideLeukLymphoma == '1')
           return true
        if (line.histologicTypeIcdO3 == null)
           return true
        if (functions.between(line.histologicTypeIcdO3, '9590', '9993') && line.diagnosticConfirmation == '6')
           return false
        if (line.diagnosticConfirmation == '3')
           return functions.between(line.histologicTypeIcdO3, '9590', '9993')
        
        return true
    }

    // ID: IF49; NAME: Census Cod Sys 1970/80/90, Date of Diag (SEER IF49)
    public boolean if49(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer countyDxNumber = functions.asInt(line.countyAtDxAnalysis)
        
            if ( line.censusCodSys19708090 != null && line.registryId >= '0000001500' && line.registryId <= '0000001599' && !(['0000001529','0000001533','0000001537','0000001542','0000001543','0000001544','0000001551','0000001561'].contains(line.registryId)) && line.dateOfDiagnosisYear != null) {
                if (line.registryId == '0000001522' && [17,49,181].contains(countyDxNumber)) {
                    if (line.dateOfDiagnosisYear > '1972' && line.dateOfDiagnosisYear < '1978')
                        return line.censusCodSys19708090 == '0'
                    if (line.dateOfDiagnosisYear > '1977' && line.dateOfDiagnosisYear < '1988')
                        return line.censusCodSys19708090 == '0' || line.censusCodSys19708090 == '2'
                    if (line.dateOfDiagnosisYear > '1987')
                        return line.censusCodSys19708090 == '3'
                }
                else if (line.registryId == '0000001523') {
                    if (line.dateOfDiagnosisYear > '1972' && line.dateOfDiagnosisYear < '1978') {
                       if ([1,43].contains(countyDxNumber))
                           return line.censusCodSys19708090 == '1'
                       return line.censusCodSys19708090 == '0'
                    }
                    if (line.dateOfDiagnosisYear > '1977' && line.dateOfDiagnosisYear < '1988')
                       return line.censusCodSys19708090 == '2'
                    if (line.dateOfDiagnosisYear > '1987')
                       return line.censusCodSys19708090 == '3'
                }
                else if (['0000001501','0000001502','0000001520','0000001521','0000001527','0000001531','0000001535'].contains(line.registryId)
                        || (line.registryId == '0000001522' && [13,61,103,113,153,155,163,193].contains(countyDxNumber))
                        || (line.registryId == '0000001525' && [33,35,53,61,67,73].contains(countyDxNumber))
                        || (line.registryId == '0000001526' && [11,35,49,57].contains(countyDxNumber))
                        || (line.registryId == '0000001526' && countyDxNumber == 45 && line.dateOfDiagnosisYear > '1977')) {
                    if (line.censusCodSys19708090 == '0')
                       return false
                    if (line.dateOfDiagnosisYear > '1972' && line.dateOfDiagnosisYear < '1978') {
                       if (line.registryId == '0000001525' && [35,67,73].contains(countyDxNumber))
                          return line.censusCodSys19708090 == '2'
                       return line.censusCodSys19708090 == '1'
                    }
                    if (line.dateOfDiagnosisYear > '1977' && line.dateOfDiagnosisYear < '1988')
                       return line.censusCodSys19708090 == '2'
                    if (line.dateOfDiagnosisYear > '1987')
                       return line.censusCodSys19708090 == '3'
                }
                else if (line.dateOfDiagnosisYear > '1987')
                    return line.censusCodSys19708090 == '3'
                else if (line.dateOfDiagnosisYear != null)
                    return line.censusCodSys19708090 == '0'
            }
        
        return true
    }

    // ID: IF51; NAME: RX Summ--Surgery, Reason for No Surgery (SEER IF51)
    public boolean if51(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear > '1997')
            return true
        if (line.rxSummSurgeryType == '09' || line.rxSummSurgeryType == null)
            return true
        if (functions.matches(line.rxSummSurgeryType, /^0[1-7]$/))
            return functions.matches(line.reasonForNoSurgery, /^[12678]$/)
        if (functions.matches(line.rxSummSurgeryType, /^[1-9]\d$/))
            return line.reasonForNoSurgery == '0'
        
        return true
    }

    // ID: IF55; NAME: Diagnostic Confirmation, Date of Diag (SEER IF55)
    public boolean if55(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.registryId == '0000001562')
          return true
        
        if (line.dateOfDiagnosisYear < '1988' && functions.matches(line.diagnosticConfirmation, /^[1246-9]$/))
            return true
        
        if (line.dateOfDiagnosisYear > '1987' && line.dateOfDiagnosisYear < '2010' && functions.matches(line.diagnosticConfirmation, /^[124-9]$/))
            return true
        
        return line.dateOfDiagnosisYear > '2009' && functions.matches(line.diagnosticConfirmation, /^[1-9]$/)
    }

    // ID: IF57; NAME: Reason for No Surgery, DateDX, RPTSRC (SEER IF57)
    public boolean if57(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        if (line.registryId == '0000001544' && line.dateOfDiagnosisYear < '2000')
            return true
        if (line.registryId == '0000001562' && line.dateOfDiagnosisYear < '2003')
            return true
        if (line.registryId == '0000001565' && (line.dateOfDiagnosisYear == '2000' || line.dateOfDiagnosisYear == '2003'))
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2002' && line.dateOfDiagnosisYear < '2006')
            return true
        
        if (line.dateOfDiagnosisYear < '1988') {
            if (line.typeOfReportingSource == '6')
                return line.reasonForNoSurgery == '2'
            if (line.typeOfReportingSource == '7')
                return line.reasonForNoSurgery == '9'
            if (line.registryId == '0000001529')
                return functions.matches(line.reasonForNoSurgery, /^[0126-9]$/)
        
            return functions.matches(line.reasonForNoSurgery, /^[0689]$/)
        }
        if (functions.between(line.dateOfDiagnosisYear, '1988', '2002')) {
            if (line.typeOfReportingSource == '6')
                return line.reasonForNoSurgery == '2'
            if (line.typeOfReportingSource == '7')
                return line.reasonForNoSurgery == '9'
        
            return functions.matches(line.reasonForNoSurgery, /^[0126-9]$/)
        }
        /* year must be 2003-2017 */
        if (line.dateOfDiagnosisYear >= '2003' && line.dateOfDiagnosisYear <= '2017') {
            if (line.typeOfReportingSource == '6' || line.typeOfReportingSource == '7')
                return line.reasonForNoSurgery == '9'
            return functions.matches(line.reasonForNoSurgery, /^[0125-9]$/)
        }
        
        /* year must be 2018+*/
        if (line.dateOfDiagnosisYear >= '2018') {
            if (line.typeOfReportingSource == '6' || line.typeOfReportingSource == '7')
                return line.reasonForNoSurgery == '1' || line.reasonForNoSurgery == '9'
            return functions.matches(line.reasonForNoSurgery, /^[0125-9]$/)
        }
    }

    // ID: IF58; NAME: RX Summ--Radiation, DateDX, RptSrc (SEER IF58)
    public boolean if58(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear > '2017')
            return true
        if (line.registryId == '0000001544' && line.dateOfDiagnosisYear < '2000')
            return true
        if (line.registryId == '0000001562' && line.dateOfDiagnosisYear < '2003')
            return true
        if (line.registryId == '0000001565' && functions.matches(line.dateOfDiagnosisYear, /^20(0[36-9]|1\d)$/))
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear < '2012')
            return true
        
        if (line.typeOfReportingSource == '6')
            return line.rxSummRadiation == '0'
        if (line.typeOfReportingSource == '7')
            return line.rxSummRadiation == '9'
        if (line.dateOfDiagnosisYear != null && line.dateOfDiagnosisYear < '1988')
            return functions.matches(line.rxSummRadiation, /^[0145689]$/)
        if (line.dateOfDiagnosisYear > '1987' && line.dateOfDiagnosisYear != null)
            return functions.matches(line.rxSummRadiation, /^[0-5789]$/)
        
        return true
    }

    // ID: IF59; NAME: RX Summ--Rad to CNS, Prim Site, RptSrc (SEER IF59)
    public boolean if59(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || (line.registryId == '0000001544' && line.dateOfDiagnosisYear < '2000'))
            return true
        
        if (line.dateOfDiagnosisYear < '1988' && line.rxSummRadToCns == null)
            return true
        else if (line.dateOfDiagnosisYear < '1988' && line.registryId != '0000001529')
            return line.rxSummRadToCns == '9'
        
        if (functions.between(line.dateOfDiagnosisYear,'1988','1997') || (functions.between(line.dateOfDiagnosisYear, '1984', '1997') && line.registryId == '0000001529')) {
            if (functions.matches(line.primarySite, /^C34\d$/) || ['9733','9742'].contains(line.histologicTypeIcdO3) || functions.between(line.histologicTypeIcdO3, '9800', '9945')) {
                if (line.typeOfReportingSource == '6')
                    return line.rxSummRadToCns == '0'
                if (line.typeOfReportingSource == '7')
                    return line.rxSummRadToCns == '9'
        
                return functions.matches(line.rxSummRadToCns, /^[01789]$/)
            }
        
            return line.rxSummRadToCns == '9'
        }
        if (line.dateOfDiagnosisYear >= '1998')
            return line.rxSummRadToCns == null || line.rxSummRadToCns == '9'
        
        return true
    }

    // ID: IF60; NAME: RX Summ--Surg/Rad Seq, DateDX, RptSrc (SEER IF60)
    public boolean if60(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.registryId == '0000001562' && line.dateOfDiagnosisYear < '2003')
            return true
        if (line.registryId == '0000001544' && line.dateOfDiagnosisYear < '2000')
            return true
        if (line.registryId == '0000001565' && (line.dateOfDiagnosisYear == '2000' || line.dateOfDiagnosisYear == '2003'))
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '1999' && line.dateOfDiagnosisYear < '2012')
            return true
        
        if (line.typeOfReportingSource == '6' || line.typeOfReportingSource == '7')
            return line.rxSummSurgRadSeq == '0'
        if (line.dateOfDiagnosisYear != null && line.dateOfDiagnosisYear < '1988')
            return functions.matches(line.rxSummSurgRadSeq, /^[02349]$/)
        if ((line.dateOfDiagnosisYear > '1987' && line.dateOfDiagnosisYear < '2012'))
            return functions.matches(line.rxSummSurgRadSeq, /^[0234569]$/)
        if (line.dateOfDiagnosisYear > '2011' && line.dateOfDiagnosisYear != null)
            return functions.matches(line.rxSummSurgRadSeq, /^[02345679]$/)
        return true
    }

    // ID: IF61; NAME: RX Summ--Chemo, DateDX, RptSrc (SEER IF61)
    public boolean if61(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.registryId == '0000001544' && (line.dateOfDiagnosisYear < '2000' || line.dateOfDiagnosisYear == null))
            return true
        if ((line.registryId == '0000001562' && line.dateOfDiagnosisYear < '2003') || (line.registryId == '0000001565' && line.dateOfDiagnosisYear == '2003'))
            return true
        if (line.typeOfReportingSource == '6')
            return line.rxSummChemo == '00'
        if (line.typeOfReportingSource == '7')
            return line.rxSummChemo == '99'
        if (line.dateOfDiagnosisYear == null)
            return true
        if (line.dateOfDiagnosisYear < '1988') {
            if (line.registryId == '0000001529')
                return functions.matches(line.rxSummChemo, /^(0[0-3]|8[78]|99)$/)
        
            return functions.matches(line.rxSummChemo, /^(0[01]|88|99)$/)
        }
        if (functions.between(line.dateOfDiagnosisYear, '1988', '2002'))
            return functions.matches(line.rxSummChemo, /^(0[0-3]|8[78]|99)$/)
        /* dx year must be 2003+ */
        return functions.matches(line.rxSummChemo, /^(0[0-3]|8[25678]|99)$/)
    }

    // ID: IF62; NAME: RX Summ--Hormone, DateDX, RptSrc (SEER IF62)
    public boolean if62(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.registryId == '0000001544' && (line.dateOfDiagnosisYear < '2000' || line.dateOfDiagnosisYear == null))
            return true
        if ((line.registryId == '0000001562' && line.dateOfDiagnosisYear < '2003') || (line.registryId == '0000001565' && line.dateOfDiagnosisYear == '2003'))
            return true
        
        if (line.typeOfReportingSource == '6')
            return line.rxSummHormone == '00'
        
        if (line.typeOfReportingSource == '7')
            return line.rxSummHormone == '99'
        
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '1988')
            return functions.matches(line.rxSummHormone, /^(0[01]|88|99)$/)
        
        if (functions.between(line.dateOfDiagnosisYear, '1988', '2002'))
            return functions.matches(line.rxSummHormone, /^(0[01]|8[78]|99)$/)
        
        /* Dx year must be 2003+ */
        return functions.matches(line.rxSummHormone, /^(0[01]|8[25678]|99)$/)
    }

    // ID: IF63; NAME: RX Summ--BRM, DateDX, RptSrc (SEER IF63)
    public boolean if63(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.registryId == '0000001544' && (line.dateOfDiagnosisYear < '2000' || line.dateOfDiagnosisYear == null))
            return true
        if ((line.registryId == '0000001562' && line.dateOfDiagnosisYear < '2003') || (line.registryId == '0000001565' && line.dateOfDiagnosisYear == '2003'))
            return true
        if (line.typeOfReportingSource == '6')
            return line.rxSummBrm == '00'
        if (line.typeOfReportingSource == '7')
            return line.rxSummBrm == '99'
        if (line.dateOfDiagnosisYear == null)
            return true
        if (line.dateOfDiagnosisYear < '1988')
            return functions.matches(line.rxSummBrm, /^(0[01]|88|99)$/)
        if (functions.between(line.dateOfDiagnosisYear, '1988', '2002'))
            return functions.matches(line.rxSummBrm, /^(0[01]|8[78]|99)$/)
        
        /* year dx must be 2003+ */
        return functions.matches(line.rxSummBrm, /^(0[01]|8[25678]|99)$/)
    }

    // ID: IF64; NAME: RX Summ--Other, DateDX, RptSrc (SEER IF64)
    public boolean if64(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.registryId == '0000001544' && (line.dateOfDiagnosisYear < '2000' || line.dateOfDiagnosisYear == null))
            return true
        if ((line.registryId == '0000001562' && line.dateOfDiagnosisYear < '2003') || (line.registryId == '0000001565' && line.dateOfDiagnosisYear == '2003'))
            return true
        if (line.typeOfReportingSource == '6')
            return line.rxSummOther == '0'
        if (line.typeOfReportingSource == '7')
            return line.rxSummOther == '9'
        if (line.dateOfDiagnosisYear == null)
            return true
        if (line.dateOfDiagnosisYear < '1988')
            return functions.matches(line.rxSummOther, /^[0123689]$/)
        /* yr dx >= 1988 */
        return functions.matches(line.rxSummOther, /^[01236789]$/)
    }

    // ID: IF65; NAME: Tumor Marker 1, Date of Diagnosis (SEER IF65)
    public boolean if65(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || (line.registryId == '0000001544' && line.dateOfDiagnosisYear < '2000'))
            return true
        if (line.registryId == '0000001561' && line.dateOfDiagnosisYear >= '1996' && line.dateOfDiagnosisYear <= '2003')
            return true
        if (functions.matches(line.registryId, /^000000156[2356]$/) && line.dateOfDiagnosisYear < '2004')
            return true
        
        if (line.dateOfDiagnosisYear < '1990')
            return line.tumorMarker1 == '9' || line.tumorMarker1 == null
        if (line.dateOfDiagnosisYear <= '1997')
            return (!functions.matches(line.primarySite, /^C50\d$/) || functions.matches(line.tumorMarker1, /^[012389]$/))
        if (line.dateOfDiagnosisYear <= '2003')
            return ((!functions.matches(line.primarySite, /^C(50\d|619)$/) || functions.matches(line.tumorMarker1, /^[012389]$/))
                    && (!functions.matches(line.primarySite, /^C62\d$/) || functions.matches(line.tumorMarker1, /^[0245689]$/)))
        /* year dx 2004+ */
        return line.tumorMarker1 == null
    }

    // ID: IF66; NAME: Tumor Marker 2, Date of Diagnosis (SEER IF66)
    public boolean if66(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || (line.registryId == '0000001544'  && line.dateOfDiagnosisYear < '2000'))
            return true
        if (functions.matches(line.registryId, /^000000156[12356]$/) && line.dateOfDiagnosisYear < '2004')
            return true
        
        if (line.dateOfDiagnosisYear < '1990')
            return line.tumorMarker2 == '9' || line.tumorMarker2 == null
        if (line.dateOfDiagnosisYear <= '1997')
            return (!functions.matches(line.primarySite, /^C50\d$/) || functions.matches(line.tumorMarker2, /^[012389]$/))
        if (line.dateOfDiagnosisYear <= '2003')
            return ((!functions.matches(line.primarySite, /^C(50\d|619)$/) || functions.matches(line.tumorMarker2, /^[012389]$/))
                    && (!functions.matches(line.primarySite, /^C62\d$/) || functions.matches(line.tumorMarker2, /^[0245689]$/)))
        /* Year Dx 2004+ */
        return line.tumorMarker2 == null
    }

    // ID: IF67; NAME: Tumor Marker 1, Type of Report Srce (SEER IF67)
    public boolean if67(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        String regId = line.registryId
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear >= '2004' || (regId == '0000001544' && line.dateOfDiagnosisYear < '2000'))
            return true
        if (functions.matches(regId, /^000000156[12356]$/))
            return true
        
        if ((line.dateOfDiagnosisYear > '1989' && functions.matches(line.primarySite, /^C50\d$/))
                || (line.dateOfDiagnosisYear > '1997' && functions.matches(line.primarySite, /^C(619|62\d)$/))) {
            if (line.typeOfReportingSource == '6')
                return line.tumorMarker1 == '0'
            if (line.typeOfReportingSource == '7')
                return line.tumorMarker1 == '9'
        }
        
        return true
    }

    // ID: IF68; NAME: Tumor Marker 2, Type of Report Srce (SEER IF68)
    public boolean if68(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        String regId = line.registryId
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear >= '2004' || (regId == '0000001544'  && line.dateOfDiagnosisYear < '2000'))
            return true
        if (functions.matches(regId, /^000000156[12356]$/))
            return true
        
        if ((line.dateOfDiagnosisYear > '1989' && functions.matches(line.primarySite, /^C50\d$/))
                || (line.dateOfDiagnosisYear > '1997' && functions.matches(line.primarySite, /^C(619|62\d)$/))) {
            if (line.typeOfReportingSource == '6')
                return line.tumorMarker2 == '0'
            if (line.typeOfReportingSource == '7')
                return line.tumorMarker2 == '9'
        }
        
        return true
    }

    // ID: IF73; NAME: Tumor Marker 3, Date of Diagnosis (SEER IF73)
    public boolean if73(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || (line.registryId == '0000001544' && line.dateOfDiagnosisYear < '2000'))
            return true
        if (functions.matches(line.registryId, /^000000156[12356]$/) && line.dateOfDiagnosisYear < '2004')
            return true
        
        if (line.dateOfDiagnosisYear <= '1997')
            return line.tumorMarker3 == '9' || line.tumorMarker3 == null
        if (line.dateOfDiagnosisYear <= '2003')
            return !functions.matches(line.primarySite, /^C62\d$/) || functions.matches(line.tumorMarker3, /^[0245689]$/)
        /* Year Dx 2004+ */
        return line.tumorMarker3 == null
    }

    // ID: IF74; NAME: Tumor Marker 3, Type of Report Srce (SEER IF74)
    public boolean if74(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear >= '2004' || (line.registryId == '0000001544' && line.dateOfDiagnosisYear < '2000'))
            return true
        if (functions.matches(line.registryId, /^000000156[12356]$/))
            return true
        
        if (line.dateOfDiagnosisYear > '1997' && functions.matches(line.primarySite, /^C62\d$/)) {
            if (line.typeOfReportingSource == '6')
                return line.tumorMarker3 == '0'
            if (line.typeOfReportingSource == '7')
                return line.tumorMarker3 == '9'
        }
        
        return true
    }

    // ID: IF75; NAME: Surgery 03-2022, Rad, Surg/Rad Seq (SEER IF75)
    public boolean if75(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.rxSummSurgPrimSite == null || line.rxSummScopeRegLnSur == null || line.rxSummSurgOthRegDis == null || line.dateOfDiagnosisYear > '2017')
            return true
        if (line.rxSummRadiation == null)
            return true
        if (line.registryId == '0000001565' && (line.dateOfDiagnosisYear == '2000' || line.dateOfDiagnosisYear == '2003'))
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear < '2012')
            return true
        
        if ((functions.matches(line.rxSummSurgPrimSite, /^([1-8]\d|90)$/) ||
           (line.dateOfDiagnosisYear < '2012' && functions.matches(line.rxSummScopeRegLnSur, /^[1-7]$/)) ||
           (line.dateOfDiagnosisYear >= '2012' &&
               ((line.regionalNodesExamined >= '01' && line.regionalNodesExamined <= '98' && line.rxSummScopeRegLnSur == '2') ||
                functions.matches(line.rxSummScopeRegLnSur, /^1|[3-7]$/))) ||
                functions.matches(line.rxSummSurgOthRegDis, /^[1-5]$/)) && functions.matches(line.rxSummRadiation, /^[1-6]$/))
            return functions.matches(line.rxSummSurgRadSeq, /^[2345679]$/)
        
        if (((line.rxSummSurgPrimSite == '00' || line.rxSummSurgPrimSite == '99') &&
             ((line.dateOfDiagnosisYear < '2012' && line.rxSummScopeRegLnSur == '0') ||
             (line.dateOfDiagnosisYear >= '2012' && ((functions.matches(line.regionalNodesPositive, /^(00|99)$/) && line.rxSummScopeRegLnSur == '2') ||
                 line.rxSummScopeRegLnSur == '0'))) &&
             line.rxSummSurgOthRegDis == '0') || (line.rxSummRadiation == '0' || line.rxSummRadiation == '9'))
            return line.rxSummSurgRadSeq == '0'
        
        return true
    }

    // ID: IF76; NAME: RX Summ--Surg Prim Site 03-2022, Diag Conf (SEER IF76)
    public boolean if76(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.overRideSurgDxconf != '1' && line.rxSummSurgPrimSite != null) {
            if (functions.matches(line.rxSummSurgPrimSite, /^([2-8]\d|90)$/) && !(line.diagnosticConfirmation ==~/^[1234]$/))
                return false
        }
        
        return true
    }

    // ID: IF77; NAME: Surgery 03-2022, Reason for No Surg (SEER IF77)
    public boolean if77(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        
                    if (line.dateOfDiagnosisYear < '2003' || line.dateOfDiagnosisYear > '2022' || ['6','7'].contains(line.typeOfReportingSource) || line.dateOfDiagnosisYear == null || line.rxSummSurgPrimSite == null)
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear == '2003')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2002' && line.dateOfDiagnosisYear < '2006')
            return true
        
        if (line.rxSummSurgPrimSite == '99')
            return line.reasonForNoSurgery != '0'
        if (line.rxSummSurgPrimSite == '00' || line.rxSummSurgPrimSite == '98')
            return functions.matches(line.reasonForNoSurgery, /^[125-8]$/)
        if (functions.matches(line.rxSummSurgPrimSite, /^([1-8]\d|90)$/))
            return line.reasonForNoSurgery == '0'
        
        return true
    }

    // ID: IF79_3; NAME: RX Summ--Scope Reg 98-02,Site,Rpt,ICDO3 (SEER IF79)
    public boolean if79_3(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.rxSummScopeReg9802 == null || line.histologicTypeIcdO3 == null)
            return true
        if ((line.dateOfDiagnosisYear < '2000' || line.dateOfDiagnosisYear ==  null) && ['0000001544', '0000001563'].contains(line.registryId))
            return true
        
        if (line.typeOfReportingSource == '6') {
            if (functions.matches(line.primarySite, /^C(700|71\d|809)$/) || functions.between(line.histologicTypeIcdO3, '9590', '9989'))
                return (line.rxSummScopeReg9802 == '0' || line.rxSummScopeReg9802 == '9')
            return line.rxSummScopeReg9802 == '0'
        }
        if (line.typeOfReportingSource == '7')
            return line.rxSummScopeReg9802 == '9'
        
        Integer site = functions.asInt(line.primarySite.substring(1))
        return ((List)((Map)context.IF79SiteReferenceTable).getOrDefault(site, [])).contains(functions.asInt(line.rxSummScopeReg9802))
    }

    // ID: IF80_3; NAME: RX Summ--Surg Oth 98-02,Site,Rpt,ICDO3 (SEER IF80)
    public boolean if80_3(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.rxSummSurgOth9802 == null || line.histologicTypeIcdO3 == null)
            return true
        if ((line.dateOfDiagnosisYear < '2000' || line.dateOfDiagnosisYear ==  null) && ['0000001544', '0000001563'].contains(line.registryId))
            return true
        
        if (line.typeOfReportingSource == '6') {
            if (functions.matches(line.primarySite, /^C(700|71\d|809)$/) || functions.between(line.histologicTypeIcdO3, '9590', '9989'))
                return line.rxSummSurgOth9802 == '0' || line.rxSummSurgOth9802 == '9'
            return line.rxSummSurgOth9802 == '0'
        }
        if (line.typeOfReportingSource == '7')
            return line.rxSummSurgOth9802 == '9'
        
        Integer site = functions.asInt(line.primarySite.substring(1))
        return ((List)((Map)context.IF80SiteReferenceTable).getOrDefault(site, [])).contains(functions.asInt(line.rxSummSurgOth9802))
    }

    // ID: IF82; NAME: Primary Site, Laterality (SEER IF82)
    public boolean if82(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.primarySite == 'C342' && (line.laterality == '2' ||
           (line.dateOfDiagnosisYear > '2006' && line.dateOfDiagnosisYear != null && line.laterality == '4')))
           return false
        
        return true
    }

    // ID: IF83; NAME: Registry and Census Tract (SEER IF83)
    public boolean if83(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.censusCodSys19708090 != '3' || line.registryId == '0000001551' || line.registryId == '0000001561')
            return true
        
        String county = line.countyAtDxGeocode1990 ?: line.countyAtDxAnalysis
        Map countyCensusTract = (Map)((Map)context.registry_county_censusTract).get(line.addrAtDxState)
        if (countyCensusTract == null)
            return true
        
        List validCensusTracts = (List)countyCensusTract.getOrDefault(county, [])
        
        if (line.censusTract19708090 != '999999'
             && line.registryId >= '0000001500'
             && line.registryId <= '0000001599'
             && !validCensusTracts.contains(functions.asInt(line.censusTract19708090))
           )
           return false
        
        return true
    }

    // ID: IF89; NAME: Race 2, Date of DX (SEER IF89)
    public boolean if89(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear > '1999')
            return line.race2 != null
        
        return true
    }

    // ID: IF90; NAME: Race 3, Date of DX (SEER IF90)
    public boolean if90(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear > '1999')
            return line.race3 != null
        
        return true
    }

    // ID: IF91; NAME: Race 4, Date of DX (SEER IF91)
    public boolean if91(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
           return true
        
        if (line.dateOfDiagnosisYear > '1999')
           return line.race4 != null
        
        return true
    }

    // ID: IF92; NAME: Race 5, Date of DX (SEER IF92)
    public boolean if92(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
           return true
        
        if (line.dateOfDiagnosisYear > '1999')
           return line.race5 != null
        
        return true
    }

    // ID: IF93; NAME: Race 1, Race 2, Race 3, Race 4, Race 5 (SEER IF93)
    public boolean if93(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.race2 == null && line.race3 == null && line.race4 == null && line.race5 == null)
            return true
        /* if any race code (2 to 5) is blank, then the remaining must be blank */
        if (line.race2 == null && (line.race3 != null || line.race4 != null || line.race5 != null))
            return false
        if (line.race3 == null && (line.race4 != null || line.race5 != null))
            return false
        if (line.race4 == null && line.race5 != null)
            return false
        
        /* if a race variable equals 99, then all must equal 99 */
        if (line.race1 == '99' || line.race2 == '99' || line.race3 == '99' || line.race4 == '99' || line.race5 == '99')
            return (line.race1 == '99' && line.race2 == '99' && line.race3 == '99' && line.race4 == '99' && line.race5 == '99')
        
        /* for patient.race codes 2 thru 5, if one equals 88 then all remaining must equal 88 */
        if (line.race2 == '88' && (line.race3 != '88' || line.race4 != '88' || line.race5 != '88'))
            return false
        if (line.race3 == '88' && (line.race4 != '88' || line.race5 != '88'))
           return false
        if (line.race4 == '88' && line.race5 != '88')
           return false
        
        /* for patient.race codes 1 thru 5, patient.race codes other than space, 88 or 99 must not be duplicated
           No '99's can get here, so we do NOT need to handle that in the code */
        if (line.race1 != null && line.race1 != '88' && (line.race1 == line.race2 || line.race1 == line.race3 || line.race1 == line.race4 || line.race1 == line.race5))
           return false
        
        if (line.race2 != null && line.race2 != '88' && (line.race2 == line.race1 || line.race2 == line.race3 || line.race2 == line.race4 || line.race2 == line.race5))
           return false
        
        if (line.race3 != null && line.race3 != '88' && (line.race3 == line.race1 || line.race3 == line.race2 || line.race3 == line.race4 || line.race3 == line.race5))
           return false
        
        if (line.race4 != null && line.race4 != '88' && (line.race4 == line.race1 || line.race4 == line.race2 || line.race4 == line.race3 || line.race4 == line.race5))
           return false
        
        if (line.race5 != null && line.race5 != '88' && (line.race5 == line.race1 || line.race5 == line.race2 || line.race5 == line.race3 || line.race5 == line.race4))
           return false
        
        /* if any patient.race code is 01, then the next one must be 88 or blank */
        /* Since duplicate patient.races codes can NOT be used, you do not have to check for the occurrence of 01, 01, 99, etc. */
        if (line.race1 == '01' && line.race2 != null && line.race2 != '88')
           return false
        
        if (line.race2 == '01' && line.race3 != null && line.race3 != '88')
           return false
        
        if (line.race3 == '01' && line.race4 != null && line.race4 != '88')
           return false
        
        if (line.race4 == '01' && line.race5 != null && line.race5 != '88')
           return false
        
        return true
    }

    // ID: IF97_3; NAME: RX Summ--Reg LN Ex,DateDX,RptSrc,ICDO3 (SEER IF97)
    public boolean if97_3(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.histologicTypeIcdO3 == null || (line.dateOfDiagnosisYear == '2003' && line.rxSummRegLnExamined == null))
            return true
        if (line.registryId == '0000001562' || line.registryId == '0000001563')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear < '2003')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear == '2000')
            return true
        if (line.dateOfDiagnosisYear < '1998' || line.dateOfDiagnosisYear >= '2004')
            return line.rxSummRegLnExamined == null
        if (line.typeOfReportingSource == '6') {
            if (functions.matches(line.primarySite, /^C(700|71\d|809)$/) || functions.between(line.histologicTypeIcdO3, '9590', '9989'))
                return line.rxSummRegLnExamined == '00' || line.rxSummRegLnExamined == '99'
            return line.rxSummRegLnExamined == '00'
        }
        if (line.typeOfReportingSource == '7')
            return line.rxSummRegLnExamined == '99'
        return line.rxSummRegLnExamined != null
    }

    // ID: IF98; NAME: RX Summ--Scope Reg 98-02, Date of DX (SEER IF98)
    public boolean if98(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.registryId == '0000001566')
            return true
        if ((line.registryId == '0000001562' || line.registryId == '0000001563') && line.dateOfDiagnosisYear < '2003')
            return true
        if (line.registryId == '0000001544' && line.dateOfDiagnosisYear < '2000')
            return true
        
        if (line.dateOfDiagnosisYear <= '1997')
            return line.rxSummScopeReg9802 == null
        if (functions.between(line.dateOfDiagnosisYear, '1998', '2002'))
            return line.rxSummScopeReg9802 != null
        /* dateOfDiagnosisYyyy >= 2003 */
        return line.rxSummScopeReg9802 == null
    }

    // ID: IF99; NAME: RX Summ--Surg Oth 98-02, Date of DX (SEER IF99)
    public boolean if99(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.registryId == '0000001566')
            return true
        if ((line.registryId == '0000001562' || line.registryId == '0000001563') && line.dateOfDiagnosisYear < '2003')
            return true
        if (line.registryId == '0000001544' && line.dateOfDiagnosisYear < '2000')
            return true
        
        if (line.dateOfDiagnosisYear <= '1997')
            return line.rxSummSurgOth9802 == null
        if (functions.between(line.dateOfDiagnosisYear, '1998', '2002'))
            return line.rxSummSurgOth9802 != null
        /* dateOfDiagnosisYyyy >= 2003 */
        return line.rxSummSurgOth9802 == null
    }

    // ID: IF100; NAME: RX Summ--Scope Reg LN Sur, DateDX, RPTSRC (SEER IF100)
    public boolean if100(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear >= '2001' && line.dateOfDiagnosisYear <= '2002' && line.rxSummScopeRegLnSur != null) {
            if (line.typeOfReportingSource == '6')
                return line.rxSummScopeRegLnSur == '0' || line.rxSummScopeRegLnSur == '9'
            if (line.typeOfReportingSource == '7')
                return line.rxSummScopeRegLnSur == '9'
        } 
        
        if (line.dateOfDiagnosisYear > '2002') {
            if (line.typeOfReportingSource == '6')
                return line.rxSummScopeRegLnSur == '0' || line.rxSummScopeRegLnSur == '9'
            if (line.typeOfReportingSource == '7')
                return line.rxSummScopeRegLnSur == '9'
            return line.rxSummScopeRegLnSur != null
        }
        
        return true
    }

    // ID: IF101; NAME: RX Summ--Surg Oth Reg/Dis, DateDX, RPTSRC (SEER IF101)
    public boolean if101(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
           return true
        
        if (line.dateOfDiagnosisYear > '2002') {
            if (line.typeOfReportingSource == '6') {
               if (functions.matches(line.primarySite, /^C(700|71\d|809)$/) || functions.between(line.histologicTypeIcdO3, '9590', '9993'))
                  return functions.matches(line.rxSummSurgOthRegDis, /^[09]$/)
               return line.rxSummSurgOthRegDis == '0'
            }
        
            if (line.typeOfReportingSource == '7')
               return line.rxSummSurgOthRegDis == '9'
        
            return line.rxSummSurgOthRegDis != null
        }
        
        return true
    }

    // ID: IF102; NAME: RX Summ--Surg Prim Site 03-2022, DateDX, RPTSRC (SEER IF102)
    public boolean if102(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || ((line.registryId == '0000001562' || line.registryId == '0000001563') && line.dateOfDiagnosisYear < '2003'))
            return true
        
        if (line.dateOfDiagnosisYear > '1997' && line.dateOfDiagnosisYear < '2023') {
            if (line.typeOfReportingSource == '6')
                return line.rxSummSurgPrimSite == '98' || line.rxSummSurgPrimSite == '00'
            if (line.typeOfReportingSource == '7')
                return line.rxSummSurgPrimSite == '98' || line.rxSummSurgPrimSite == '99'
            return line.rxSummSurgPrimSite != null
        }
        if (line.dateOfDiagnosisYear > '2022')
            return line.rxSummSurgPrimSite == null
        
        return true
    }

    // ID: IF104; NAME: RX Summ--Transplnt/Endocr, DateDX, RPTSRC (SEER IF104)
    public boolean if104(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.registryId == '0000001562' && line.dateOfDiagnosisYear < '2003')
            return true
        if (line.registryId == '0000001544' && line.dateOfDiagnosisYear < '2000')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '1999' && line.dateOfDiagnosisYear < '2004')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '1999' && line.dateOfDiagnosisYear < '2003')
            return true
        
        if (line.typeOfReportingSource == '6')
            return line.rxSummTransplntEndocr == '00'
        
        if (line.typeOfReportingSource == '7')
            return line.rxSummTransplntEndocr == '99'
        
        if (line.dateOfDiagnosisYear < '2003' && line.dateOfDiagnosisYear != null)
            return functions.matches(line.rxSummTransplntEndocr, /(^00$)|(^1[0-2]$)|(^[234]0$)|(^8[78]$)|(^99$)/)
        
        if (line.dateOfDiagnosisYear >= '2003' && line.dateOfDiagnosisYear != null)
            return functions.matches(line.rxSummTransplntEndocr, /(^00$)|(^1[0-2]$)|(^[234]0$)|(^8[25678]$)|(^99$)/)
        
        return true
    }

    // ID: IF105; NAME: Surgery 98-02, Rad, Rad Surg (SEER IF105)
    public boolean if105(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '1998' || line.dateOfDiagnosisYear > '2002')
           return true
        if (functions.matches(line.registryId, /^000000156[236]$/))
            return true
        
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear == '2000')
            return true
        
        if (((line.rxSummSurgPrimSite >= '10' && line.rxSummSurgPrimSite <= '90') ||
           functions.matches(line.rxSummScopeReg9802, /^[1-8]$/) || functions.matches(line.rxSummSurgOth9802, /^[1-8]$/)) &&
           functions.matches(line.rxSummRadiation, /^[1-6]$/))
           return functions.matches(line.rxSummSurgRadSeq, /^[234569]$/)
        
        if (((line.rxSummSurgPrimSite == '00' || line.rxSummSurgPrimSite == '99')
                 && line.rxSummScopeReg9802 == '0' && line.rxSummSurgOth9802 == '0')
                 || line.rxSummRadiation == '0' || line.rxSummRadiation == '7' || line.rxSummRadiation == '8')
           return line.rxSummSurgRadSeq == '0'
        
        return true
    }

    // ID: IF107; NAME: Surgery 98-02, Reason for No Surg (SEER IF107)
    public boolean if107(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '1998' || line.dateOfDiagnosisYear > '2002')
            return true
        if (line.registryId == '0000001562' || line.registryId == '0000001566' || (line.registryId == '0000001544' && (line.dateOfDiagnosisYear == '1998' || line.dateOfDiagnosisYear == '1999')))
            return true
        
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear == '2000')
            return true
        
        if ((line.rxSummSurgPrimSite == '00' || line.rxSummSurgPrimSite == '99')
                && (line.rxSummScopeReg9802 == '0' || line.rxSummScopeReg9802 == '9')
                && (line.rxSummSurgOth9802 == '0' || line.rxSummSurgOth9802 == '9')
                && line.reasonForNoSurgery == '0')
            return false
        if (line.rxSummSurgPrimSite == '00' && line.rxSummScopeReg9802 == '0'
                && line.rxSummSurgOth9802 == '0')
            return functions.matches(line.reasonForNoSurgery, /^[12678]$/)
        if (functions.matches(line.rxSummSurgPrimSite, /^([1-8]\d|90)$/) || functions.matches(line.rxSummScopeReg9802, /^[1-8]$/)
                || functions.matches(line.rxSummSurgOth9802, /^[1-8]$/))
            return line.reasonForNoSurgery == '0'
        
        return true
    }

    // ID: IF108; NAME: RX Summ--Surg Prim Site 03-2022, Site, ICDO3 (SEER IF108)
    public boolean if108(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.rxSummSurgPrimSite == null || line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear > '2017' || line.histologicTypeIcdO3 == null )
            return true
        
        Integer site = functions.asInt(line.primarySite.substring(1))
        Integer hist = functions.asInt(line.histologicTypeIcdO3)
        
        if (line.dateOfDiagnosisYear < '2010' && ((List)context.IF108_Hist_List_Pre2010).contains(hist))
            return line.rxSummSurgPrimSite == '98' || line.rxSummSurgPrimSite == '99'
        
        if (line.dateOfDiagnosisYear >= '2010' && line.dateOfDiagnosisYear < '2018' && ((List)context.IF108_Hist_List_2010).contains(hist))
            return line.rxSummSurgPrimSite == '98' || line.rxSummSurgPrimSite == '99'
        
        if (((List)context.If108_AllOtherSites).contains(site) && line.rxSummSurgPrimSite == '41')
              return site >= 690 && site <= 699
        
        return ((List)((Map)context.IF108SiteReferenceTable).getOrDefault(site, [])).contains(functions.asInt(line.rxSummSurgPrimSite))
    }

    // ID: IF109; NAME: RX Summ--Scope Reg LN Sur, Site, ICDO3 (SEER IF109)
    public boolean if109(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.rxSummScopeRegLnSur == null || line.histologicTypeIcdO3 == null || line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear > '2017')
            return true
        
        Integer site = functions.asInt(line.primarySite.substring(1))
        Integer hist = functions.asInt(line.histologicTypeIcdO3)
        
        Boolean conditionPrimarySites = ((List)context.ExceptionSites).contains(site)
        Boolean condition2A = line.dateOfDiagnosisYear < '2010' && functions.between(site,770,779) && functions.between(line.histologicTypeIcdO3,'9590','9729')
        Boolean condition2B = line.dateOfDiagnosisYear >= '2010' && line.dateOfDiagnosisYear <= '2017' && functions.between(site,770,779) && ((List)context.LymphExcepHist2010To2017).contains(hist)
        Boolean condition3A = line.dateOfDiagnosisYear < '2010' && ((List)context.ExceptionHistologies).contains(hist)
        Boolean condition3B = line.dateOfDiagnosisYear >= '2010' && line.dateOfDiagnosisYear <= '2017' && ((List)context.ExceptionHistologies2010).contains(hist)
        
        if (conditionPrimarySites || condition2A || condition2B || condition3A || condition3B)
            return line.rxSummScopeRegLnSur == '9'
        
        return true
    }

    // ID: IF110; NAME: PIN III ICDO3, Date of Diagnosis (SEER IF110)
    public boolean if110(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        if (line.dateOfDiagnosisYear > '2000' &&
            line.behaviorCodeIcdO3 == '2' && line.primarySite == 'C619')
           return line.histologicTypeIcdO3 != '8148'
        
        return true
    }

    // ID: IF111; NAME: Census Tract 2000, Date of DX (SEER IF111)
    public boolean if111(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.registryId == '0000001565')
            return true
        
        // condition 2
        if (line.registryId < '0000001541' || line.registryId > '0000001544')
           return !(line.dateOfDiagnosisYear > '1995' && line.dateOfDiagnosisYear < '2012'&& line.censusTract2000 == null)
        
        // condition 1
        if (line.dateOfDiagnosisYear > '2000' && line.dateOfDiagnosisYear < '2012')
           return line.censusTract2000 != null
        
        return true
    }

    // ID: IF112; NAME: Census Tr Certainty 2000, Date of DX (SEER IF112)
    public boolean if112(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || ['0000001533', '0000001565'].contains(line.registryId))
            return true
        
        // condition 3
        if (line.registryId < '0000001541' || line.registryId > '0000001544')
           return !(line.dateOfDiagnosisYear > '1995' && line.dateOfDiagnosisYear < '2012'&& line.censusTrCertainty2000 == null)
        
        // condition 2
        if (line.dateOfDiagnosisYear > '2000' && line.dateOfDiagnosisYear < '2012')
           return line.censusTrCertainty2000 != null
        
        return true
    }

    // ID: IF113; NAME: ICD Revisn, Vital Stat, Date Last Cont (SEER IF113)
    public boolean if113(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer yearLastContact = functions.asInt(line.dateOfLastContactYear)
        
        if (line.dateOfLastContactYear == null)
            return true
        
        if (yearLastContact > 1998 && (line.vitalStatus == '0' || line.vitalStatus == '4'))
           return line.icdRevisionNumber == '1'
        
        if (functions.between(yearLastContact, 1979, 1998) && (line.vitalStatus == '0' || line.vitalStatus == '4'))
           return line.icdRevisionNumber == '9'
        
        return true
    }

    // ID: IF114; NAME: Behavior Code ICDO3, Seq Num--Central (SEER IF114)
    public boolean if114(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.behaviorCodeIcdO3 == null)
            return true
        
        if (line.dateOfDiagnosisYear != null && line.dateOfDiagnosisYear < '2001' && ['8442','8451','8462','8472','8473'].contains(line.histologicTypeIcdO3)
                && functions.matches(line.sequenceNumberCentral, /^([0-5]\d|99)$/)  && line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line.dateOfDiagnosisYear > '2000' && line.dateOfDiagnosisYear != null && (line.behaviorCodeIcdO3 == '2' || line.behaviorCodeIcdO3 == '3'))
            return line.sequenceNumberCentral < '60' || line.sequenceNumberCentral > '88'
        
        if (line.dateOfDiagnosisYear > '2000' && line.dateOfDiagnosisYear != null && (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1'))
            return line.sequenceNumberCentral >= '60' && line.sequenceNumberCentral <= '88'
        
        if (functions.matches(line.sequenceNumberCentral, /^([0-5]\d|99)$/))
            return line.behaviorCodeIcdO3 == '2' || line.behaviorCodeIcdO3 == '3'
        
        return true
    }

    // ID: IF117; NAME: Non-Reportable Skin ICDO3 (SEER IF117)
    public boolean if117(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return (line.histologicTypeIcdO3 == null ||
           !(functions.matches(line.primarySite, /^C44\d$/) &&
              functions.between(line.histologicTypeIcdO3, '8000', '8110')))
    }

    // ID: IF118; NAME: Age, Primary Site, Morph ICDO3--Adult (SEER)
    public boolean if118(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer ageDx = functions.asInt(line.ageAtDiagnosis)
        
        if (line.dateOfDiagnosisYear == null ||
             line.histologicTypeIcdO3 == null || line.behaviorCodeIcdO3 == null ||
             line.dateOfDiagnosisYear < '2001' || line.overRideAgeSiteMorph == '1' ||
             ageDx < 15)
           return true
        if (ageDx < 30 &&
           (['9732','9823','9863','9875','9876','9945'].contains(line.histologicTypeIcdO3) ||
           line.primarySite == 'C609'))
           return false
        if (ageDx < 20 &&
                 (functions.matches(line.primarySite, /^C(15\d|17\d|199|209|21[0-8]|239|24\d|25\d|384|50\d|54\d|559)$/) ||
                 (functions.matches(line.primarySite, /^C(18\d|339|34\d)$/) && ! functions.between(line.histologicTypeIcdO3,'8240','8245')) ||
                 (functions.matches(line.primarySite, /^C53\d$/) && line.behaviorCodeIcdO3 == '3')))
           return false
        if ((ageDx < 40 && line.primarySite == 'C619' && line.histologicTypeIcdO3 == '8140') ||
                 (ageDx > 45 && line.primarySite == 'C589' && line.histologicTypeIcdO3 == '9100'))
           return false
        if (functions.matches(line.primarySite, /^C69\d$/) && functions.between(line.histologicTypeIcdO3,'9510','9514'))
           return false
        if (line.histologicTypeIcdO3 == '8960' || line.histologicTypeIcdO3 == '9946')
           return false
        
        return true
    }

    // ID: IF119; NAME: Age, Primary Site, Morph ICDO3--Pediatric (NPCR)
    public boolean if119(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer ageDx = functions.asInt(line.ageAtDiagnosis)
        Integer site = functions.asInt(line.primarySite.substring(1))
        Integer hist = functions.asInt(line.histologicTypeIcdO3)
        
         if (line.dateOfDiagnosisYear == null ||
              line.histologicTypeIcdO3 == null || line.behaviorCodeIcdO3 == null ||
              line.dateOfDiagnosisYear < '2001' || line.overRideAgeSiteMorph == '1' || line.overRideAgeSiteMorph == '3' ||
              ageDx > 14)
            return true
        
         /* Hodgkin Lymphoma */
         if (ageDx < 3 &&
                  functions.between(line.histologicTypeIcdO3,'9650','9667'))
            return false
        
         /* Neuroblastoma and ganglioneuroblastoma */
         if (ageDx > 9 &&
                 ((line.histologicTypeIcdO3 == '9490') || (line.histologicTypeIcdO3 == '9500')))
            return false
        
         /* Retinoblastoma */
         if (ageDx > 5 &&
                  functions.between(line.histologicTypeIcdO3,'9510','9514'))
            return false
        
         /* Wilms tumro, rhabdoid, and clear cell */
         if (ageDx > 8 &&
                 ((line.histologicTypeIcdO3 == '8960') || (line.histologicTypeIcdO3 == '8964') ||
                 ((line.histologicTypeIcdO3 == '8963') && ((site == 649) || (site == 809)))))
            return false
        
         /* Renal carcinoma */
         if (ageDx < 9 &&
                  ((((List)context.Group_VIb).contains(hist) && (site == 649)) ||
                  (line.histologicTypeIcdO3 == '8312')))
            return false
        
         /* Hepatoblastoma */
         if (ageDx > 5 && (line.histologicTypeIcdO3 == '8970'))
            return false
        
         /* Hepatic carcinoma */
         if (ageDx < 9 &&
                 ((((List)context.Group_VIIb).contains(hist) &&
                 ((site == 220) || (site == 221))) ||
                 functions.between(line.histologicTypeIcdO3,'8160','8180')))
            return false
        
         /* Osteosarcoma */
         if (ageDx < 6 &&
                  functions.between(line.histologicTypeIcdO3,'9180','9200'))
            return false
        
         /* Chondrosarcoma */
         if (ageDx < 6 &&
                  (functions.between(line.histologicTypeIcdO3,'9220','9230') ||
                  (((line.histologicTypeIcdO3 == '9231') || (line.histologicTypeIcdO3 == '9240')) &&
                  functions.between(site,400,419))))
            return false
        
         /* Ewing sarcoma */
         if (ageDx < 4 &&
                  (((line.histologicTypeIcdO3 == '9260') &&
                  (functions.between(site,400,419) ||
                  (site == 809))) || (((line.histologicTypeIcdO3 == '9363') ||
                  (line.histologicTypeIcdO3 == '9364')) && functions.between(site,400,419))))
            return false
        
         /* Non-gonadal germ cell */
         if (ageDx > 7 &&
                  functions.between(line.histologicTypeIcdO3,'9060','9102') &&
                  ((List)context.Group_Xb_Site).contains(site))
            return false
        
        /* Gonadal carcinoma */
         if (ageDx < 15 &&
                  ((((List)context.Group_Xd_1).contains(hist) &&
                  ((List)context.Group_Xd_Site_1).contains(site)) ||
                  ((List)context.Group_Xd_2).contains(hist)))
           return false
        
         /* Thyroid carcinoma */
         if (ageDx < 6 &&
               ((((List)context.Group_XIb).contains(hist) && (site == 739)) ||
                 functions.between(line.histologicTypeIcdO3,'8330','8350')))
            return false
        
         /* Nasopharyngeal carcinoma */
         if (ageDx < 6 && ((List)context.Group_XIc).contains(hist) &&
                   functions.between(site,110,119))
            return false
        
         /* Skin carcinoma */
         if (ageDx < 5 && ((List)context.Group_XIe).contains(hist) &&
                   functions.between(site,440,449))
            return false
        
         /* NOS carcinoma */
         if (ageDx < 5 && ((List)context.Group_XIf).contains(hist) &&
                    ((List)context.Group_XIf_Site).contains(site))
            return false
        
         /* Mesothelial neoplasma (M905) */
         if (functions.between(line.histologicTypeIcdO3,'9050','9053'))
            return false
        
         /* Additional SEER Groups */
         if ((line.behaviorCodeIcdO3 == '2' && functions.between(site,530,539))
                   || (line.histologicTypeIcdO3 == '9100' && site == 589)
                   || functions.matches(line.primarySite, /^C(15\d|17\d|199|209|21[0-8]|239|24\d|25\d|384|50\d|54\d|559|609)$/)
                   || (functions.matches(line.primarySite, /^C(18\d|339|34\d)$/)
                   && !functions.between(line.histologicTypeIcdO3,'8240','8245'))
                   || (functions.between(site,530,539) && line.behaviorCodeIcdO3 == '3')
                   || (site == 619 && line.histologicTypeIcdO3 == '8140')
                   || ['9732','9863','9875','9876','9945','9823'].contains(line.histologicTypeIcdO3))
             return false
        
         return true
    }

    // ID: IF121; NAME: CS Extension, CS Lymph Nodes, CS Mets at DX (CS)
    public boolean if121(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.primarySite == null || line._csSchemaId == null || line.histologicTypeIcdO3 == null || line.behaviorCodeIcdO3 == null || line.csExtension == null || line.csLymphNodes == null || line.csMetsAtDx == null)
            return true
        
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') &&
            line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
           return true
        
        if (line._csSchemaId != 'prostate' && line._csSchemaId != 'retinoblastoma' && line.csExtension == '950')
            return  ! (line.csLymphNodes == '000' && line.csMetsAtDx == '00')
        
        if (line._csSchemaId == 'breast') {
            if (line.csExtension == '000')
                return  ( line.csLymphNodes == '000' || line.csLymphNodes == '050') && line.csMetsAtDx == '00'
            return true
        }
        
        if (line._csSchemaId == 'bladder') {
            if (line.csExtension == '010' || line.csExtension == '030' || line.csExtension == '060')
                return line.csLymphNodes == '000' && line.csMetsAtDx == '00'
            return true
        }
        
        if (line._csSchemaId == 'kidney_renal_pelvis') {
            if (line.csExtension == '050' || line.csExtension == '060')
                return line.csLymphNodes == '000' && line.csMetsAtDx == '00'
            return true
        }
        
        if (line._csSchemaId == 'urethra') {
            if (line.csExtension == '050' || line.csExtension == '060' || line.csExtension == '070' || line.csExtension == '080')
                return line.csLymphNodes == '000' && line.csMetsAtDx == '00'
            return true
        }
        
        if (line._csSchemaId == 'urinary_other') {
            if (line.csExtension == '050' || line.csExtension == '060')
                return line.csLymphNodes == '000' && line.csMetsAtDx == '00'
            return true
        }
        
        if (line._csSchemaId == 'intracranial_gland') {
            if (line.csExtension == '000')
                return (line.csLymphNodes == '000' || line.csLymphNodes == '988') && line.csMetsAtDx == '00'
            return true
        }
        
        if (line._csSchemaId != 'breast' && line._csSchemaId != 'bladder' && line._csSchemaId != 'kidney_renal_pelvis' &&
            line._csSchemaId != 'urethra' && line._csSchemaId != 'urinary_other' && line.csExtension == '000')
            return line.csLymphNodes == '000' && line.csMetsAtDx == '00'
        
        return true
    }

    // ID: IF122; NAME: CS Extension, CS Tumor Size, Site, Hist ICDO3 (CS)
    public boolean if122(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line._csSchemaId == null || line.csExtension == null || line.csTumorSize == null)
            return true
        
        if (line._csSchemaId == 'prostate' && line.csExtension == '950' && line.csSiteSpecificFactor3 == '950')
            return line.csTumorSize == '000'
        
        if (line.csExtension == '950' && !['prostate','kaposi_sarcoma','melanoma_skin','conjunctiva','melanoma_conjunctiva','melanoma_choroid','melanoma_iris','melanoma_ciliary_body','lymphoma_ocular_adnexa'].contains(line._csSchemaId))
            return line.csTumorSize == '000'
        
        if (line.csTumorSize == '000' && line._csSchemaId != 'mycosis_fungoides' && line._csSchemaId != 'ill_defined_other' && !((List)context.Mucosal_Melanoma_Head_Neck_Schemas).contains(line._csSchemaId))
            return line.csExtension == '950'
        
        if (((List)((Map)context.IF122_Stated_As_Codes).getOrDefault(line._csSchemaId, [])).contains(functions.asInt(line.csExtension)))
            return line.csTumorSize != '999'
        
        return true
    }

    // ID: IF123; NAME: CS Extension, Primary Site, Behavior ICDO3 (CS)
    public boolean if123(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && (line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland'))
           return true
        if (line.primarySite == null || line.histologicTypeIcdO3 == null || line.csExtension == null || line.typeOfReportingSource == '7')
            return true
        if (line._csSchemaId == null)
            return true
        
        if (line._csSchemaId != 'prostate' && line.csExtension == '000' && line.behaviorCodeIcdO3 != '2')
            return false
        if (['stomach','small_intestine','gist_stomach','gist_small_intestine','net_stomach','net_small_intestine','esophagus_gejunction'].contains(line._csSchemaId) && line.csExtension == '050')
           return line.behaviorCodeIcdO3 == '2'
        if (['colon','rectum','gist_colon','gist_rectum','net_colon','net_rectum'].contains(line._csSchemaId) && line.csExtension == '050')
            return line.behaviorCodeIcdO3 == '2'
        if (['colon','rectum','gist_colon','gist_rectum','net_colon','net_rectum'].contains(line._csSchemaId) &&
            (['8210','8261','8263'].contains(line.histologicTypeIcdO3)) && line.behaviorCodeIcdO3 == '2')
            return line.csExtension == '050'
        if (line._csSchemaId == 'breast' && line.behaviorCodeIcdO3 == '2')
            return line.csExtension == '000' || line.csExtension == '050' || line.csExtension == '070'
        if (line._csSchemaId == 'cervix' && line.csExtension == '010')
            return line.behaviorCodeIcdO3 == '2'
        if (line._csSchemaId == 'penis' && line.csExtension == '050' && ! (functions.between(line.histologicTypeIcdO3,'8720','8790') || functions.between(line.histologicTypeIcdO3,'9700','9701')))
            return line.behaviorCodeIcdO3 == '2'
        if (['brain','cns_other','intracranial_gland'].contains(line._csSchemaId) && line.csExtension == '050')
            return line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1'
        if (['brain','cns_other','intracranial_gland'].contains(line._csSchemaId) && (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1'))
            return line.csExtension == '050'
        if (line._csSchemaId == 'endocrine_other' && (line.primarySite == 'C754' || line.primarySite == 'C755') && line.csExtension == '000')
            return false
        if ((line._csSchemaId == 'kidney_renal_pelvis' || line._csSchemaId == 'urinary_other') && line.behaviorCodeIcdO3 == '2')
            return line.csExtension == '050' || line.csExtension == '060'
        if ((line._csSchemaId == 'kidney_renal_pelvis' || line._csSchemaId == 'urinary_other') && (line.csExtension == '050' || line.csExtension == '060'))
            return line.behaviorCodeIcdO3 == '2'
        if (line._csSchemaId == 'urethra' && line.behaviorCodeIcdO3 == '2')
            return functions.matches(line.csExtension, /^0[5678]0$/)
        if (line._csSchemaId == 'urethra' && functions.matches(line.csExtension, /^0[5678]0$/))
            return line.behaviorCodeIcdO3 == '2'
        if (line._csSchemaId == 'bladder' && line.behaviorCodeIcdO3 == '2')
            return ['010','030','060','100'].contains(line.csExtension)
        if (line._csSchemaId == 'bladder' && functions.matches(line.csExtension, /^0[136]0$/))
            return line.behaviorCodeIcdO3 == '2'
        if (line._csSchemaId == 'melanoma_conjunctiva' && line.csExtension == '005')
            return line.behaviorCodeIcdO3 == '3'
        if (line._csSchemaId == 'melanoma_conjunctiva' && (line.csExtension == '100' || line.csExtension == '120'))
            return line.behaviorCodeIcdO3 == '2' || line.behaviorCodeIcdO3 == '3'
        if (line.csExtension >= '100')
            return line.behaviorCodeIcdO3 == '3'
        
        return true
    }

    // ID: IF124; NAME: CS Extension, KidneyRenalPelvis Schema (CS)
    public boolean if124(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csExtension == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line._csSchemaId != 'kidney_renal_pelvis')
            return true
        
        if (line.primarySite == 'C659')
            return !(line.csExtension == '685' || line.csExtension == '690' || line.csExtension == '695')
        
        if (line.primarySite == 'C669')
            return !(line.csExtension == '600' || line.csExtension == '665' || line.csExtension == '670')
        
        return true
    }

    // ID: IF125; NAME: CS Extension, SSF 1, Thyroid Schema (CS)
    public boolean if125(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csExtension == null || line.csSiteSpecificFactor1 == null || line.csSiteSpecificFactor1 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
           return true
        if (line._csSchemaId == 'thyroid') {
           if (line.csExtension == '100')
              return line.csSiteSpecificFactor1 == '010'
           if (line.csExtension == '200')
              return line.csSiteSpecificFactor1 == '020'
        }
        
        return true
    }

    // ID: IF128; NAME: CS Lymph Nodes, SSF 1, Head/Neck Schemas (CS)
    public boolean if128(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csLymphNodes == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
           return true
        
        if (((List)context.Head_Neck_Schemas).contains(line._csSchemaId))
           return  ! (line.csLymphNodes != '000' && line.csLymphNodes != '999' && line.csSiteSpecificFactor1 == '000')
        
        return true
    }

    // ID: IF129; NAME: CS Lymph Nodes, SSF 4, 5, Breast Schema (CS)
    public boolean if129(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csLymphNodes == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
           return true
        
        if (line._csSchemaId != 'breast')
            return true
        
        if (line.csLymphNodes == '000' && (line.csSiteSpecificFactor4 == '987' || line.csSiteSpecificFactor5 == '987'))
           return false
        
        if (line.csLymphNodes != '000')
            return ((line.csSiteSpecificFactor4 == null || line.csSiteSpecificFactor4 == '987' || line.csSiteSpecificFactor4 == '988') &&
                    (line.csSiteSpecificFactor5 == null || line.csSiteSpecificFactor5 == '987' || line.csSiteSpecificFactor5 == '988'))
        
        return true
    }

    // ID: IF130_P1; NAME: Reg Nodes Ex,Pos,Site,Hist ICDO3,Rpt (SEER IF130)
    public boolean if130_p1(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if ((line.behaviorCodeIcdO3 != '2' && line.behaviorCodeIcdO3 != '3') ||
             line.dateOfDiagnosisYear < '1998' || line.dateOfDiagnosisYear > '2003' ||
             line.regionalNodesExamined == null || line.regionalNodesPositive == null ||
             line.registryId == '0000001562' || line.registryId == '0000001563')
           return true
        
        if (line.regionalNodesExamined == '00' && line.regionalNodesPositive != '98')
           return false
        
        if (line.regionalNodesExamined >= '01' && line.regionalNodesExamined <= '89' &&
            line.regionalNodesPositive != '97' && line.regionalNodesPositive != '99' &&
            line.regionalNodesPositive > line.regionalNodesExamined)
           return false
        
        if ((line.regionalNodesExamined == '90' ||
               (line.regionalNodesExamined >= '96' && line.regionalNodesExamined <= '98')) &&
           ! ((line.regionalNodesPositive >= '00' && line.regionalNodesPositive <= '97') ||
              line.regionalNodesPositive == '99'))
           return false
        
        if (line.regionalNodesExamined == '99' && line.regionalNodesPositive != '99')
           return false
        
        if (line.regionalNodesExamined == '95' && line.regionalNodesPositive != '00' &&
            line.regionalNodesPositive != '97' && line.regionalNodesPositive != '99')
           return false
        
        return true
    }

    // ID: IF130_P2; NAME: Reg Nodes Ex,Pos,Site,Hist ICDO3,Rpt (SEER IF130)
    public boolean if130_p2(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if ((line.behaviorCodeIcdO3 != '2' && line.behaviorCodeIcdO3 != '3') || line.dateOfDiagnosisYear < '1998' || line.dateOfDiagnosisYear > '2003'
               || line.regionalNodesExamined == null || line.regionalNodesPositive == null)
            return true
        
        if (line.typeOfReportingSource == '7' && (line.regionalNodesExamined != '99' || line.regionalNodesPositive != '99'))
            return false
        
        return true
    }

    // ID: IF130_P3; NAME: Reg Nodes Ex,Pos,Site,Hist ICDO3,Rpt (SEER IF130)
    public boolean if130_p3(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if ((line.behaviorCodeIcdO3 != '2' && line.behaviorCodeIcdO3 != '3') ||
             line.dateOfDiagnosisYear < '1998' || line.dateOfDiagnosisYear > '2003' ||
             line.regionalNodesExamined == null || line.regionalNodesPositive == null)
           return true
        
        if ((((List)context.Odd_Histologies).contains(functions.asInt(line.histologicTypeIcdO3)) ||
            (line.histologicTypeIcdO3 != '9140' &&
              ((List)context.Certain_Sites).contains(functions.asInt(line.primarySite.substring(1))))) &&
            (line.regionalNodesExamined != '99' || line.regionalNodesPositive != '99'))
           return false
        
        return true
    }

    // ID: IF132; NAME: CS SSF 1, RX Summ--Surg, Retinoblastoma (SEER)
    public boolean if132(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        boolean skipCondition3 = (line.dateOfDiagnosisYear == '2016' || line.dateOfDiagnosisYear == '2017') && line.csExtension == null
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line.csSiteSpecificFactor1 == null || skipCondition3)
            return true
        if (line.csSiteSpecificFactor1 != null && line._csSchemaId == 'retinoblastoma')
            return !((line.rxSummSurgPrimSite == '40' || line.rxSummSurgPrimSite == '41') && line.csSiteSpecificFactor1 == '970')
        
        return true
    }

    // ID: IF133; NAME: CS SSF 3, RX Summ--Surg, Prostate (SEER)
    public boolean if133(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        boolean skipCondition4 = (line.dateOfDiagnosisYear == '2016' || line.dateOfDiagnosisYear == '2017') && line.csExtension == null
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line.typeOfReportingSource == '6' || line.csSiteSpecificFactor3 == null || skipCondition4)
            return true
        if (line._csSchemaId == 'prostate' && functions.matches(line.rxSummSurgPrimSite, /^[57]0$/))
            return !(functions.matches(line.csSiteSpecificFactor3, /^9[678]0|985$/))
        
        return true
    }

    // ID: IF134; NAME: CS SSF 4, RX Summ--Surg, Testis Schema (CS)
    public boolean if134(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor4 == null || line.csSiteSpecificFactor4 == '988' || line.rxSummSurgPrimSite == null || line.typeOfReportingSource == '7' || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'testis') {
            if (line.rxSummSurgPrimSite == '80' || line.rxSummSurgPrimSite == '90' || line.rxSummSurgPrimSite == '99')
                return line.csSiteSpecificFactor4 == '000' || line.csSiteSpecificFactor4 == '999'
            if (line.rxSummSurgPrimSite != '40')
                return line.csSiteSpecificFactor4 == '000'
            if (line.csSiteSpecificFactor4 == '000')
                return line.rxSummSurgPrimSite != '40'
        }
        
        return true
    }

    // ID: IF136; NAME: CS Tumor Size, Site, Histol ICDO3 (CS)
    public boolean if136(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line.csTumorSize == null)
            return true
        if (line._csSchemaId == 'colon' ||  line._csSchemaId == 'rectum') {
            if (line.csTumorSize == '998')
                return functions.matches(line.histologicTypeIcdO3, /^822[01]$/)
            if (functions.matches(line.histologicTypeIcdO3, /^822[01]$/))
                return line.csTumorSize == '998'
        }
        if (line._csSchemaId == 'ill_defined_other') {
            if (line.primarySite == 'C809')
                return line.csTumorSize == '999'
        }
        
        return true
    }

    // ID: IF137; NAME: CS Tumor Size, SSF 1, MelanomaConjunctiva (CS)
    public boolean if137(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csTumorSize == null || line.csSiteSpecificFactor1 == null ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        if (line._csSchemaId == 'melanoma_conjunctiva'){
            return ((line.csTumorSize == '000' && line.csSiteSpecificFactor1 == '000') ||
              (line.csTumorSize != '000' && line.csSiteSpecificFactor1 != '000'))
        }
        return true
    }

    // ID: IF138; NAME: Unknown Site, Laterality (SEER IF138)
    public boolean if138(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return  ! (line.primarySite == 'C809' && line.laterality != '0')
    }

    // ID: IF141; NAME: EOD--Ext Prost Path, RX Summ--Surg Prim Site 03-2022 (SEER)
    public boolean if141(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.eodExtensionProstPath == null || line.rxSummSurgPrimSite == null ||
           line.primarySite != 'C619' || line.typeOfReportingSource == '6' ||
           line.typeOfReportingSource == '7')
            return true
        if ( ! (functions.matches(line.rxSummSurgPrimSite, /^[35789]0$/)))
            return functions.matches(line.eodExtensionProstPath, /^9[089]$/)
        
        return true
    }

    // ID: IF143; NAME: CS Extension, Hematopoietic (CS)
    public boolean if143(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csExtension == null ||  line.typeOfReportingSource == '7')
           return true
        if (line._csSchemaId != 'heme_retic')
           return true
        if ((line.csExtension == '100' || line.csExtension == '999') && ! ['9740','9750','9751','9755','9756','9757','9758','9930'].contains(line.histologicTypeIcdO3))
            return false
        return true
    }

    // ID: IF145; NAME: CS Version Input Original, CS Version Derived (CS)
    public boolean if145(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csVersionInputOriginal == null || line.csVersionDerived == null || line.csVersionInputOriginal <= line.csVersionDerived
    }

    // ID: IF152; NAME: Type of Reporting Source, Date of DX (SEER IF152)
    public boolean if152(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.typeOfReportingSource == null || line.dateOfDiagnosisYear == null || line.registryId == '0000001562')
            return true
        
        if (line.dateOfDiagnosisYear < '2006')
            return functions.matches(line.typeOfReportingSource, /^[13-7]$/)
        
        return functions.matches(line.typeOfReportingSource, /^[1-8]$/)
    }

    // ID: IF154; NAME: RX Summ--Systemic/Sur Seq, DateDX, RPTSRC (SEER IF154)
    public boolean if154(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear == '2006')
           return true
        
        if (line.dateOfDiagnosisYear > '2006' && line.dateOfDiagnosisYear < '2012') {
            if (line.typeOfReportingSource == '6' || line.typeOfReportingSource == '7')
                return line.rxSummSystemicSurSeq == '0'
            return functions.matches(line.rxSummSystemicSurSeq, /^[0234569]$/)
        }
        
        
        if (line.dateOfDiagnosisYear > '2011') {
            if (line.typeOfReportingSource == '6' || line.typeOfReportingSource == '7')
                return line.rxSummSystemicSurSeq == '0'
            return functions.matches(line.rxSummSystemicSurSeq, /^[02345679]$/)
        }
        
        if (line.dateOfDiagnosisYear < '2006')
           return line.rxSummSystemicSurSeq == null
        
        return true
    }

    // ID: IF158; NAME: CS Lymph Nodes, Regional Nodes Positive (CS)
    public boolean if158(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csLymphNodes == null || line.regionalNodesPositive == null || line._csSchemaId == null ||
          ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') &&
           !['brain','cns_other','intracranial_gland'].contains(line._csSchemaId)))
           return true
        
        if (functions.between(line.regionalNodesPositive,'01','97'))
            return line.csLymphNodes != '000'
        
        return true
    }

    // ID: IF160; NAME: Systemic RX, Surgery 03-2022, Systemic/Sur Seq (COC)
    public boolean if160(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.rxSummSurgPrimSite == null || line.rxSummScopeRegLnSur == null ||
           line.rxSummSurgOthRegDis == null || line.rxSummBrm == null ||
           line.rxSummChemo == null || line.rxSummHormone == null ||
           line.rxSummTransplntEndocr == null || line.rxSummSystemicSurSeq == null ||
           line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear > '2022')
            return true
        
        boolean primSite = line.rxSummSurgPrimSite >= '10' && line.rxSummSurgPrimSite <= '90'
        boolean scopePre2012Surg = line.dateOfDiagnosisYear < '2012' && functions.matches(line.rxSummScopeRegLnSur, /^[1-7]$/)
        boolean scope12To17Surg = line.dateOfDiagnosisYear >= '2012' && line.dateOfDiagnosisYear < '2018' && ((line.regionalNodesExamined >= '01' && line.regionalNodesExamined <= '98' && line.rxSummScopeRegLnSur == '2') || functions.matches(line.rxSummScopeRegLnSur, /^1|[3-7]$/))
        boolean scope18To20Surg = line.dateOfDiagnosisYear >= '2018' && line.dateOfDiagnosisYear < '2021' && ((line.regionalNodesExamined >= '01' && line.regionalNodesExamined <= '98' && line.rxSummScopeRegLnSur == '2') || functions.matches(line.rxSummScopeRegLnSur, /^[3-7]$/))
        boolean scopePost20Surg = line.dateOfDiagnosisYear >= '2021' && functions.matches(line.rxSummScopeRegLnSur, /^[2-7]$/)
        boolean otherSurg = functions.matches(line.rxSummSurgOthRegDis, /^[1-5]$/)
        boolean therapyPerformed = line.rxSummBrm == '01' || functions.matches(line.rxSummChemo, /^0[1-3]$/) || line.rxSummHormone == '01' || functions.matches(line.rxSummTransplntEndocr, /(^[1-3]\d|40$)/)
        
        if ((primSite || scopePre2012Surg || scope12To17Surg || scope18To20Surg || scopePost20Surg || otherSurg) && therapyPerformed)
            return functions.matches(line.rxSummSystemicSurSeq, /^[2-7]|9$/)
        
        boolean noPrimSite = line.rxSummSurgPrimSite == '00' || line.rxSummSurgPrimSite == '99'
        boolean noOtherSurg = line.rxSummSurgOthRegDis == '0'
        boolean regionalNodes1220 = (line.regionalNodesExamined == '00' || line.regionalNodesExamined == '99') && (line.dateOfDiagnosisYear >= '2012' && line.dateOfDiagnosisYear < '2021')
        boolean scopePre2012NoSurg = line.dateOfDiagnosisYear < '2012' && line.rxSummScopeRegLnSur == '0'
        boolean scope12To17NoSurg = line.dateOfDiagnosisYear >= '2012' && line.dateOfDiagnosisYear < '2018' && (line.rxSummScopeRegLnSur == '0' || ((regionalNodes1220) && line.rxSummScopeRegLnSur == '2'))
        boolean scope18To20NoSurg = line.dateOfDiagnosisYear >= '2018' && line.dateOfDiagnosisYear < '2021' && (line.rxSummScopeRegLnSur == '0' || ((regionalNodes1220) && line.rxSummScopeRegLnSur == '2'))
        boolean scopePost20NoSurg = line.dateOfDiagnosisYear >= '2021' && functions.matches(line.rxSummScopeRegLnSur, /^[0-1]$/)
        boolean surgeryAlsoNotPerformed = line.rxSummSurgPrimSite == '98' && line.rxSummScopeRegLnSur == '9'
        boolean noTherapy = functions.matches(line.rxSummBrm, /(^00|8[2-8]|99$)/) &&
           functions.matches(line.rxSummChemo, /(^00|8[2-8]|99$)/) &&
           functions.matches(line.rxSummHormone, /(^00|8[2-8]|99$)/) &&
           functions.matches(line.rxSummTransplntEndocr, /(^00|8[2-8]|99$)/)
        
        if ((noPrimSite && noOtherSurg && (scopePre2012NoSurg || scope12To17NoSurg || scope18To20NoSurg || scopePost20NoSurg)) || (surgeryAlsoNotPerformed && noOtherSurg) || noTherapy)
            return line.rxSummSystemicSurSeq == '0'
        
        return true
    }

    // ID: IF167; NAME: Registry, County and Census Tract (SEER IF167)
    public boolean if167(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        String county = line.countyAtDxGeocode2000 ?: line.countyAtDxAnalysis
        if (line.censusTract2000 == null || county == null || line.censusTract2000 == '000000' || line.censusTract2000 == '999999' || line.registryId < '0000001500' || line.registryId > '0000001599' || line.registryId == '0000001551')
            return true
        if (line.addrAtDxState == 'AK' && county == '900')
            return true
        
        Map countyCensusTract = (Map)((Map)context.registry_county_census2000).get(line.addrAtDxState)
        if (countyCensusTract == null)
            return true
        
        return ((List)countyCensusTract.getOrDefault(county, [])).contains(functions.asInt(line.censusTract2000))
    }

    // ID: IF168_P1; NAME: CS Reg Nodes Ex, Pos, Site, Hist ICDO3, Report (CS)
    public boolean if168_p1(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line._csSchemaId == null || line.regionalNodesExamined == null || line.regionalNodesPositive == null)
            return true
        if (line.dateOfDiagnosisYear == null ||line.dateOfDiagnosisYear < '2004' || line.dateOfDiagnosisYear > '2017')
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !['brain','cns_other','intracranial_gland'].contains(line._csSchemaId))
                return true
        
        if (line.dateOfDiagnosisYear < '2010' && (line.csVersionInputCurrent == '020510' || line.csVersionInputCurrent == null)) {
            if (line.regionalNodesExamined == '00' && line.regionalNodesPositive != '98')
               return false
        
            if (line.regionalNodesExamined >= '01' && line.regionalNodesExamined <= '90' &&
                line.regionalNodesPositive > line.regionalNodesExamined &&
                line.regionalNodesPositive != '97' && line.regionalNodesPositive != '99')
               return false
        
            if (line.regionalNodesExamined >= '95' && line.regionalNodesExamined <= '98' &&
               ! ((line.regionalNodesPositive >= '00' && line.regionalNodesPositive <= '90') ||
                line.regionalNodesPositive == '95' || line.regionalNodesPositive == '97'||
                line.regionalNodesPositive == '99'))
               return false
        
            if (line.regionalNodesExamined == '99' && line.regionalNodesPositive != '99')
               return false
        }
        else {
            if (line.regionalNodesExamined == '00' && line.regionalNodesPositive != '98')
               return false
        
            if (line.regionalNodesExamined >= '01' && line.regionalNodesExamined <= '90' &&
                line.regionalNodesPositive > line.regionalNodesExamined &&
                line.regionalNodesPositive != '95' && line.regionalNodesPositive != '97' &&
                line.regionalNodesPositive != '99')
               return false
        
            if (line.regionalNodesExamined == '95' && line.regionalNodesPositive != '00' &&
                line.regionalNodesPositive != '95' && line.regionalNodesPositive != '99')
               return false
        
            if (line.regionalNodesExamined >= '96' && line.regionalNodesExamined <= '98' &&
               ! ((line.regionalNodesPositive >= '00' && line.regionalNodesPositive <= '90') ||
                line.regionalNodesPositive == '95' || line.regionalNodesPositive == '97' ||
                line.regionalNodesPositive == '99'))
               return false
        
            if (line.regionalNodesExamined == '99' && line.regionalNodesPositive != '99')
               return false
        }
        
        return true
    }

    // ID: IF168_P2; NAME: CS Reg Nodes Ex, Pos, Site, Hist ICDO3, Report (CS)
    public boolean if168_p2(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear < '2004' || line.dateOfDiagnosisYear > '2017' || line.dateOfDiagnosisYear == null
                || line.regionalNodesExamined == null || line._csSchemaId == null
                || line.regionalNodesPositive == null || line.typeOfReportingSource != '7'
                || ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')  &&
                !['brain','cns_other','intracranial_gland'].contains(line._csSchemaId)))
            return true
        
        return line.regionalNodesExamined == '99' && line.regionalNodesPositive == '99'
    }

    // ID: IF168_P3; NAME: CS Reg Nodes Ex, Pos, Site, Hist ICDO3, Report (CS)
    public boolean if168_p3(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear < '2004' || line.dateOfDiagnosisYear > '2017' || line.dateOfDiagnosisYear == null
                || line.regionalNodesExamined == null || line.regionalNodesPositive == null || line._csSchemaId == null
                || ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !['brain','cns_other','intracranial_gland'].contains(line._csSchemaId)))
            return true
        
        if (['heme_retic','lymphoma','brain','cns_other','ill_defined_other','placenta','intracranial_gland'].contains(line._csSchemaId))
            return line.regionalNodesExamined == '99' && line.regionalNodesPositive == '99'
        else if (line._csSchemaId == 'myeloma_plasma_cell_disorder' && line.histologicTypeIcdO3 != '9734')
            return line.regionalNodesExamined == '99' && line.regionalNodesPositive == '99'
        
        return true
    }

    // ID: IF169; NAME: Derived AJCC--Flag, Derived AJCC (SEER)
    public boolean if169(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || ((line.dateOfDiagnosisYear == '2016' || line.dateOfDiagnosisYear == '2017') && line.csExtension == null))
                return true
        
        if (functions.matches(line.registryId, /^000000156[2356]$/))
            return true
        
        if (line.derivedAjccFlag == null)
           return (line.derivedAjcc6T == null && line.derivedAjcc6N == null
             && line.derivedAjcc6M == null && line.derivedAjcc6StageGrp == null
             && line.derivedAjcc7T == null && line.derivedAjcc7N == null
             && line.derivedAjcc7M == null && line.derivedAjcc7StageGrp == null
             && line.derivedAjcc6TDescript == null && line.derivedAjcc6NDescript == null
             && line.derivedAjcc6MDescript == null && line.derivedAjcc7TDescript == null
             && line.derivedAjcc7NDescript == null && line.derivedAjcc7MDescript == null)
        
        if (line.derivedAjccFlag != null && line.dateOfDiagnosisYear > '2009' &&
             (line.derivedAjcc7T == null || line.derivedAjcc7N == null
             || line.derivedAjcc7M == null || line.derivedAjcc7StageGrp == null
             || line.derivedAjcc7TDescript == null || line.derivedAjcc7NDescript == null
             || line.derivedAjcc7MDescript == null))
           return false
        
        if (line.derivedAjccFlag != null && line.dateOfDiagnosisYear > '2007' &&
            (line.derivedAjcc6TDescript == null || line.derivedAjcc6NDescript == null
             || line.derivedAjcc6MDescript == null))
           return false
        
        return (line.derivedAjccFlag != null && line.derivedAjcc6T != null && line.derivedAjcc6N != null
             && line.derivedAjcc6M != null && line.derivedAjcc6StageGrp != null)
    }

    // ID: IF170; NAME: Derived CS Items, Date of DX (SEER)
    public boolean if170(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !['brain','cns_other','intracranial_gland'].contains(line._csSchemaId)))
           return true
        
        if (line._csSchemaId == null || ['0000001562', '0000001563', '0000001566', '0000001565'].contains(line.registryId))
            return true
        
        if (line.dateOfDiagnosisYear >= '2010' && (line.dateOfDiagnosisYear < '2016' || ((line.dateOfDiagnosisYear == '2016' || line.dateOfDiagnosisYear == '2017') && line.csExtension != null)) &&
           (line.derivedAjcc7M == null || line.derivedAjcc7MDescript == null || line.derivedAjcc7N == null ||
            line.derivedAjcc7NDescript == null || line.derivedAjcc7StageGrp == null || line.derivedAjcc7T == null ||
            line.derivedAjcc7TDescript == null || line.derivedAjcc6TDescript == null || line.derivedAjcc6NDescript == null ||
            line.derivedAjcc6MDescript == null || line.derivedAjcc6T == null || line.derivedAjcc6N == null ||
            line.derivedAjcc6M == null || line.derivedAjcc6StageGrp == null || line.derivedSs1977 == null ||
            line.derivedSs2000 == null || line.csVersionDerived == null))
           return false
        
        if (line.dateOfDiagnosisYear >= '2008' && (line.dateOfDiagnosisYear < '2016' || ((line.dateOfDiagnosisYear == '2016' || line.dateOfDiagnosisYear == '2017') && line.csExtension != null)) &&
           (line.derivedAjcc6TDescript == null || line.derivedAjcc6NDescript == null ||
            line.derivedAjcc6MDescript == null || line.derivedAjcc6T == null || line.derivedAjcc6N == null ||
             line.derivedAjcc6M == null || line.derivedAjcc6StageGrp == null || line.derivedSs1977 == null ||
             line.derivedSs2000 == null || line.csVersionDerived == null))
           return false
        
        if (line.dateOfDiagnosisYear >= '2004' && (line.dateOfDiagnosisYear < '2016' || ((line.dateOfDiagnosisYear == '2016' || line.dateOfDiagnosisYear == '2017') && line.csExtension != null)) &&
             (line.derivedAjcc6T == null || line.derivedAjcc6N == null ||
             line.derivedAjcc6M == null || line.derivedAjcc6StageGrp == null ||
             line.derivedSs1977 == null || line.derivedSs2000 == null ||
             line.csVersionDerived == null))
           return false
        
        if (line.dateOfDiagnosisYear <= '2003' &&
              (line.derivedAjcc6T != null || line.derivedAjcc6N != null ||
              line.derivedAjcc6M != null || line.derivedAjcc6StageGrp != null ||
              line.derivedSs1977 != null || line.derivedSs2000 != null ||
              line.csVersionDerived != null))
           return false
        
        return true
    }

    // ID: IF171; NAME: Derived SS1977--Flag, Derived SS1977 (CS)
    public boolean if171(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.derivedSs1977Flag == null)
           return line.derivedSs1977 == null
        
        return line.derivedSs1977 != null
    }

    // ID: IF172; NAME: Derived SS2000--Flag, Derived SS2000 (CS)
    public boolean if172(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.derivedSs2000Flag == null)
           return line.derivedSs2000 == null
        
        return line.derivedSs2000 != null
    }

    // ID: IF174; NAME: CS Items, DX Pre-2004 (SEER)
    public boolean if174(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear >= '2004' || line.dateOfDiagnosisYear == null)
           return true
        
        if (line.csTumorSize != null || line.csExtension != null || line.csTumorSizeExtEval != null ||
           line.csLymphNodes != null || line.csLymphNodesEval != null || line.csMetsAtDx != null || line.csMetsEval != null ||
           line.csSiteSpecificFactor1 != null || line.csSiteSpecificFactor2 != null || line.csSiteSpecificFactor3 != null ||
           line.csSiteSpecificFactor4 != null || line.csSiteSpecificFactor5 != null || line.csSiteSpecificFactor6 != null ||
           line.csSiteSpecificFactor7 != null || line.csSiteSpecificFactor8 != null || line.csSiteSpecificFactor10 != null ||
           line.csSiteSpecificFactor12 != null || line.csSiteSpecificFactor13 != null || line.csSiteSpecificFactor16 != null ||
           line.csSiteSpecificFactor17 != null || line.csSiteSpecificFactor18 != null || line.csSiteSpecificFactor19 != null ||
           line.csSiteSpecificFactor20 != null || line.csSiteSpecificFactor21 != null || line.csSiteSpecificFactor22 != null ||
           line.csSiteSpecificFactor23 != null || line.csSiteSpecificFactor24 != null || line.csSiteSpecificFactor25 != null ||
           line.csVersionInputOriginal != null || line.csVersionInputCurrent != null)
            return false
        
         if (functions.matches(line.primarySite, /^C50\d$/)) {
            if((line.csSiteSpecificFactor9 != null && !['010','020','030','997','998','999'].contains(line.csSiteSpecificFactor9)) ||
              (line.csSiteSpecificFactor11 != null && !['010','020','030','997','998','999'].contains(line.csSiteSpecificFactor11)) ||
              (line.csSiteSpecificFactor14 != null && !['010','020','030','997','998','999'].contains(line.csSiteSpecificFactor14)) ||
              (line.csSiteSpecificFactor15 != null && !['010','020','030','997','998','999'].contains(line.csSiteSpecificFactor15)))
               return false
         }
         else {
            if(line.csSiteSpecificFactor9 != null || line.csSiteSpecificFactor11 != null||
              line.csSiteSpecificFactor14 != null || line.csSiteSpecificFactor15 != null)
               return false
         }
        
         return true
    }

    // ID: IF176; NAME: Primary Site, CS Extension (SEER IF176)
    public boolean if176(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.overRideSiteEodDxDt == '1' ||
            line.dateOfDiagnosisYear < '2004' || line.dateOfDiagnosisYear > '2017' || line.dateOfDiagnosisYear == null ||
            line.histologicTypeIcdO3 == null || line.histologicTypeIcdO3 == '9140' ||
            functions.between(line.histologicTypeIcdO3,'9590','9999') || line.behaviorCodeIcdO3 == '2')
           return true
        
        if ((line.primarySite == 'C479' || line.primarySite == 'C499') &&
           line.csExtension != null && line.csExtension >= '100' && line.csExtension <= '320' &&
           (line.csMetsAtDx == '00' || line.csMetsAtDx == '99'))
           return false
        
        if (functions.matches(line.primarySite, /^C(069|26\d|39\d|4[01]9|579|639)$/)  &&
           line.csExtension != null && line.csExtension >= '100' && line.csExtension <= '300' &&
           (line.csMetsAtDx == '00' || line.csMetsAtDx == '99'))
           return false
        
        if (line.csExtension != null && line.csExtension >= '100' && line.csExtension <= '400' &&
              (line.csMetsAtDx == '00' || line.csMetsAtDx == '99') &&
              ((line.primarySite == 'C189' && !['8210','8220','8261','8263'].contains(line.histologicTypeIcdO3)) ||
              line.primarySite == 'C559'))
           return false
        
        return true
    }

    // ID: IF177; NAME: Primary Site, Laterality, CS Extension (SEER IF177)
    public boolean if177(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer site = functions.asInt(line.primarySite.substring(1))
        
        if (line.overRideSiteLatEod == '1' || line.histologicTypeIcdO3 == null ||
           line.dateOfDiagnosisYear < '2004' || line.csExtension == null ||
           (line.histologicTypeIcdO3 == '9140' || functions.between(line.histologicTypeIcdO3,'9590','9992')) ||
           ((line.dateOfDiagnosisYear == '2016' || line.dateOfDiagnosisYear == '2017') && line.csExtension == null) ||
           !((List)context.Base_Sites_IF177).contains(site))
           return true
        
        if (line.laterality == '9' ||
            (line.laterality == '4' && !((List)context.Bypass_Sites_IF177).contains(site))) {
           if ([471,472,491,492].contains(site))
              return ! (line.csExtension >= '000' && line.csExtension <= '320')
           if (functions.between(site, 500, 509))
              return ! (line.csExtension >= '000' && line.csExtension <= '100')
           if (functions.between(site, 620, 629))
              return ! (line.csExtension >= '000' && line.csExtension <= '310')
           if (functions.between(site, 690, 699))
              return ! (line.csExtension >= '000' && line.csExtension <= '400')
           if (line.laterality == '4' && line.dateOfDiagnosisYear > '2009' &&
               functions.between(site, 340, 349) && line.csExtension >= '000' &&
               line.csExtension <= '300')
              return [23, 25, 26, 36, 38, 40, 41, 42, 43, 50, 51, 52, 53, 70, 75].contains(functions.asInt(line.csMetsAtDx))
        
           return ! (line.csExtension >= '000' && line.csExtension <= '300')
        }
        
        return true
    }

    // ID: IF179; NAME: Date Initial RX SEER, Ca Dir RX 98-02 (SEER IF179)
    public boolean if179(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if ((line.registryId == '0000001544' && line.dateOfDiagnosisYear < '2000') || line.dateOfDiagnosisYear < '1998' || line.dateOfDiagnosisYear > '2002')
            return true
        
        if (['0000001562','0000001563','0000001565'].contains(line.registryId))
            return true
        
        boolean isDateOfTherapyKnown = line.dateInitialRxSeerDay != null || line.dateInitialRxSeerMonth != null || line.dateInitialRxSeerYear != null
        
        if (isDateOfTherapyKnown) {
            if (line.rxSummSurgRadSeq == '0' && functions.matches(line.rxSummRadiation, /^[078]$/) && functions.matches(line.rxSummChemo, /^(00|8[25678])$/)
                 && functions.matches(line.rxSummHormone, /^(00|8[25678])$/) && functions.matches(line.rxSummBrm, /^(00|8[25678])$/) && functions.matches(line.rxSummOther, /^[078]$/)
                 && functions.matches(line.rxSummTransplntEndocr, /^(00|8[25678])$/) && line.rxSummSurgPrimSite == '00' && (line.rxSummScopeReg9802 == '0'
                 || (line.rxSummScopeReg9802 == '9' && functions.matches(line.primarySite, /^C77\d$/))) && line.rxSummSurgOth9802 == '0')
                return false
        
            if ((functions.matches(line.rxSummSurgRadSeq, /^[2-69]$/) || functions.matches(line.rxSummRadiation, /^[1-6]$/) || functions.matches(line.rxSummChemo, /^0[1-3]$/)
                 || line.rxSummHormone == '01' || line.rxSummBrm == '01' || functions.matches(line.rxSummTransplntEndocr, /^(1[012]|[234]0)$/) || functions.matches(line.rxSummOther, /^[1236]$/)
                 || functions.matches(line.rxSummSurgPrimSite, /^([1-8]\d|90)$/) || functions.matches(line.rxSummScopeReg9802, /^[1-8]$/) || functions.matches(line.rxSummSurgOth9802, /^[1-8]$/)))
                return true
            else
                return false
        }
        
        return true
    }

    // ID: IF180; NAME: Date Initial RX SEER, Ca Dir RX 2003-2017 (SEER IF180)
    public boolean if180(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer site = functions.asInt(line.primarySite.substring(1))
        Integer hist = functions.asInt(line.histologicTypeIcdO3)
        
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2003' || line.dateOfDiagnosisYear > '2017' || line.registryId == '0000001565' || line.registryId == '0000001566')
            return true
        
        boolean isDateOfTherapyKnown = line.dateInitialRxSeerDay != null || line.dateInitialRxSeerMonth != null || line.dateInitialRxSeerYear != null
        
        if (isDateOfTherapyKnown) {
            if (line.rxSummSurgRadSeq == '0' && functions.matches(line.rxSummRadiation, /^[078]$/)
                 && functions.matches(line.rxSummChemo, /^(00|8[25678])$/) && functions.matches(line.rxSummHormone, /^(00|8[25678])$/)
                 && functions.matches(line.rxSummBrm, /^(00|8[25678])$/) && functions.matches(line.rxSummOther, /^[078]$/)
                 && functions.matches(line.rxSummTransplntEndocr, /^(00|8[25678])$/)
                 && (line.rxSummSurgPrimSite == '00' || line.rxSummSurgPrimSite == '98')
                 && ((line.rxSummScopeRegLnSur == '0' &&
                     !(((List)context.IF180Hist1Bypass).contains(hist) || ((List)context.IF180CertainSites).contains(site) || (functions.between(site, 770, 779) && ((List)context.IF180Hist2).contains(hist))))
                 || (line.rxSummScopeRegLnSur == '9'
                 && (((List)context.IF180Hist1Bypass).contains(hist) || ((List)context.IF180CertainSites).contains(site) || (functions.between(site, 770, 779) && ((List)context.IF180Hist2).contains(hist))))
                 || (line.rxSummScopeRegLnSur == '2' && line.dateOfDiagnosisYear >= '2012' && functions.matches(line.regionalNodesExamined, /(^00|99$)/)))
                 && line.rxSummSurgOthRegDis == '0')
                return false
        
            if ((functions.matches(line.rxSummSurgRadSeq, /^[2-69]$/) || functions.matches(line.rxSummRadiation, /^[1-6]$/) || functions.matches(line.rxSummChemo, /^0[1-3]$/)
                 || line.rxSummHormone == '01' || line.rxSummBrm == '01' || functions.matches(line.rxSummTransplntEndocr, /^(1[012]|[234]0)$/)
                 || functions.matches(line.rxSummOther, /^[1236]$/) || functions.matches(line.rxSummSurgPrimSite, /^([1-8]\d|90)$/)
                 || (line.dateOfDiagnosisYear < '2012' && functions.matches(line.rxSummScopeRegLnSur, /^[1-7]$/))
                 || (line.dateOfDiagnosisYear >= '2012' && functions.matches(line.regionalNodesExamined, /(^0[1-9]|[1-8]\d|9[0-8]$)/) && line.rxSummScopeRegLnSur == '2')
                 || (line.dateOfDiagnosisYear >= '2012' && functions.matches(line.rxSummScopeRegLnSur, /(^[13-7]$)/))
                 || functions.matches(line.rxSummSurgOthRegDis, /^[1-5]$/)))
                return true
            else
                return false
        
        }
        
        return true
    }

    // ID: IF181; NAME: Primary Payer at DX, Date of DX (SEER IF181)
    public boolean if181(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
           return true
        
        if (line.dateOfDiagnosisYear >= '2007')
           return line.primaryPayerAtDx != null
        
        return true
    }

    // ID: IF188; NAME: CS Lymph Nodes, Nodes Pos, SSF 3, Breast Schema (CS)
    public boolean if188(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csLymphNodes == null || line.csSiteSpecificFactor3 == null ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line._csSchemaId != 'breast' ||
            line.regionalNodesPositive == null)
            return true
        
        if (line.csLymphNodes == '050')
            return line.regionalNodesPositive == '00' && line.csSiteSpecificFactor3 == '000'
        
        Integer ssf3Int = functions.asInt(line.csSiteSpecificFactor3)
        if (ssf3Int >= 1 && ssf3Int <= 97 && functions.matches(line.csLymphNodes, /^000|7[1347]0|735|745|764$/))
            return false
        
        if (functions.matches(line.csSiteSpecificFactor3, /^0[0-8][0-9]$/) && functions.matches(line.regionalNodesPositive, /^[0-8][0-9]$/))
            return functions.asInt(line.csSiteSpecificFactor3) <= functions.asInt(line.regionalNodesPositive)
        
        return true
    }

    // ID: IF189; NAME: CS SSF 3, Breast Schema (CS)
    public boolean if189(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor3 == null || line.csSiteSpecificFactor3 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line._csSchemaId != 'breast')
            return true
        
        if (line.regionalNodesExamined == '00')
            return line.csSiteSpecificFactor3 == '098'
        
        return true
    }

    // ID: IF190; NAME: CS SSF 6, Breast Schema (CS)
    public boolean if190(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor6 == null || line.csSiteSpecificFactor6 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line._csSchemaId != 'breast')
            return true
        
        if (line.behaviorCodeIcdO3 == '2')
            return line.csSiteSpecificFactor6 == '010' || line.csSiteSpecificFactor6 == '987'
        
        if (line.csSiteSpecificFactor6 == '010' && line.histologicTypeIcdO3 != '8543')
            return line.behaviorCodeIcdO3 == '2'
        
        return true
    }

    // ID: IF193; NAME: CS Eval Items, Type of Reporting Source (CS)
    public boolean if193(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.typeOfReportingSource == null || line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear > '2017')
                    return true
        
        if (line._csSchemaId == null || ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !['brain','cns_other','intracranial_gland'].contains(line._csSchemaId)))
            return true
        
        if (line.csTumorSizeExtEval == '8' || line.csLymphNodesEval == '8' || line.csMetsEval == '8')
            return line.typeOfReportingSource == '6'
        
        return true
    }

    // ID: IF194; NAME: CS Eval Items, Vital Status (CS)
    public boolean if194(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.vitalStatus == null || line._csSchemaId == null ||
            ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !['brain','cns_other','intracranial_gland'].contains(line._csSchemaId)))
            return true
        
        if (line.csTumorSizeExtEval == '8' || line.csLymphNodesEval == '8' || line.csMetsEval == '8')
            return (line.vitalStatus == '0' || line.vitalStatus == '4')
        
        if (line._csSchemaId == 'prostate') {
           if (line.csTumorSizeExtEval == '3')
              return (line.vitalStatus == '0' || line.vitalStatus == '4')
        }
        else if (line.csTumorSizeExtEval == '2')
           return (line.vitalStatus == '0' || line.vitalStatus == '4')
        
        return true
    }

    // ID: IF195; NAME: CS Extension, Lymphoma Schema (CS)
    public boolean if195(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csExtension == null || line.typeOfReportingSource == '7')
            return true
        
        if (line._csSchemaId == 'lymphoma') {
           if (line.csExtension == '100' && ! (functions.matches(line.primarySite, /^C(024|09\d|111|1[47]2|181|379|77[0-5]|779)$/)))
              return false
        
           if (line.csExtension == '110' && functions.matches(line.primarySite, /^C(379|422|77[0-5]|779)$/))
              return false
        
           if (line.csExtension == '120' && line.primarySite != 'C422')
              return false
        
           if (line.primarySite == 'C778')
              return functions.matches(line.csExtension, /^[2-9]\d\d$/)
        
           if (line.primarySite == 'C422')
              return [120,220,230,320,330,800,999].contains(functions.asInt(line.csExtension))
        }
        
        return true
    }

    // ID: IF196; NAME: CS TS/Ext Eval, Surgery, Prostate Schema (CS)
    public boolean if196(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csTumorSizeExtEval == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line.rxSummSurgPrimSite == null)
            return true
        
        if (line._csSchemaId == 'prostate') {
            if (line.rxSummSurgPrimSite == '22')
                return line.csTumorSizeExtEval == '1' || line.csTumorSizeExtEval == '2'
        
            if (functions.between(line.rxSummSurgPrimSite,'19', '26'))
                return line.csTumorSizeExtEval == '0' || line.csTumorSizeExtEval == '1' || line.csTumorSizeExtEval == '2'
        
            if (functions.between(line.csTumorSizeExtEval,'4', '6'))
                return functions.between(line.rxSummSurgPrimSite,'30', '80')
        }
        
        return true
    }

    // ID: IF197; NAME: CS Ext, Histol ICDO3, Breast Schema (CS)
    public boolean if197(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csExtension == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'breast' && line.histologicTypeIcdO3 == '8530')
           return functions.matches(line.csExtension, /^7[135]0$/) || functions.matches(line.csExtension, /^7[12]5$/)
        
        return true
    }

    // ID: IF199; NAME: CS Extension, Surgery, Prostate Schema (CS)
    public boolean if199(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csExtension == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line.rxSummSurgPrimSite == null
             || line.dateOfDiagnosisYear == null)
           return true
        
        if (line._csSchemaId != 'prostate')
             return true
        
        if (line.csExtension == '130' || line.csExtension == '140')
             return line.rxSummSurgPrimSite != '00' && line.rxSummSurgPrimSite != '99'
        
        if ((line.dateOfDiagnosisYear >= '2010' || line.csVersionInputOriginal >= '020100') && line.csExtension == '100')
             return line.rxSummSurgPrimSite != '00' && line.rxSummSurgPrimSite != '99'
        
        return true
    }

    // ID: IF200; NAME: CS Extension, TS/Ext Eval, Prostate Schema (CS)
    public boolean if200(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csExtension == null || line.csTumorSizeExtEval == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
           return true
        
        if (line._csSchemaId != 'prostate')
             return true
        
        if ((line.csExtension == '130' || line.csExtension == '140') && line.csTumorSizeExtEval == '0')
             return false
        
        if (line.csTumorSizeExtEval == '2' && !functions.between(line.csExtension,'410','700'))
             return false
        
        if (line.csTumorSizeExtEval == '8' && line.csExtension != '999')
             return false
        
        return true
    }

    // ID: IF201; NAME: CS Lymph Nodes Eval, Nodes Ex (CS)
    public boolean if201(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csLymphNodesEval == null || line.regionalNodesExamined == null || line._csSchemaId == null ||
            ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !['brain','cns_other','intracranial_gland'].contains(line._csSchemaId)))
            return true
        
        if(['appendix','carcinoid_appendix','colon','gist_appendix','gist_colon', 'gist_rectum','lymphoma_ocular_adnexa','melanoma_skin','merkel_cell_skin',
             'merkel_cell_penis','merkel_cell_vulva','merkel_cell_scrotum','net_colon','net_rectum','rectum','retinoblastoma'].contains(line._csSchemaId))
             return true
        
        if ((line.csLymphNodesEval == '3' || line.csLymphNodesEval == '5' || line.csLymphNodesEval == '6') && line.regionalNodesExamined == '00')
             return false
        
        return true
    }

    // ID: IF202; NAME: CS SSF 1, SSF 2, Prostate Schema (CS)
    public boolean if202(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor1 == null || line.csSiteSpecificFactor2 == null ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
           return true
        
        if (line._csSchemaId == 'prostate' &&
            (line.csSiteSpecificFactor1 == '998' || line.csSiteSpecificFactor2 == '998'))
           return (line.csSiteSpecificFactor1 == '998' && line.csSiteSpecificFactor2 == '998')
        
        return true
    }

    // ID: IF203; NAME: CS SSF 1-9, Head and Neck Schemas (CS)
    public boolean if203(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csLymphNodes == null ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
           return true
        
        if (((List)context.Head_Neck_Schemas).contains(line._csSchemaId)){
           if (line.csLymphNodes == '000')
              return line.csSiteSpecificFactor2 == null || line.csSiteSpecificFactor2 == '987' || line.csSiteSpecificFactor2 == '988'
        
           if (line.csLymphNodes != '000' && line.csLymphNodes != '999' && line.csSiteSpecificFactor2 == '987')
              return false
        
           if (line.csSiteSpecificFactor1 == null ||
               line.csSiteSpecificFactor3 == null || line.csSiteSpecificFactor4 == null ||
               line.csSiteSpecificFactor5 == null || line.csSiteSpecificFactor6 == null ||
               line.csSiteSpecificFactor1 == '988' ||
               line.csSiteSpecificFactor3 == '988' || line.csSiteSpecificFactor4 == '988' ||
               line.csSiteSpecificFactor5 == '988' || line.csSiteSpecificFactor6 == '988')
              return true
        
           if (line.csLymphNodes == '999' && (
               line.csSiteSpecificFactor1 != '999' ||
               line.csSiteSpecificFactor3 != '999' || line.csSiteSpecificFactor4 != '999' ||
               line.csSiteSpecificFactor5 != '999' || line.csSiteSpecificFactor6 != '999' ||
               (line.csSiteSpecificFactor2 != '987' && line.csSiteSpecificFactor2 != '999' && line.csSiteSpecificFactor2 != '988' && line.csSiteSpecificFactor2 != null) ||
               (line.csSiteSpecificFactor7 != '999' && line.csSiteSpecificFactor7 != '988' && line.csSiteSpecificFactor7 != null) ||
               (line.csSiteSpecificFactor8 != '999' && line.csSiteSpecificFactor8 != '988' && line.csSiteSpecificFactor8 != null) ||
               (line.csSiteSpecificFactor9 != '999' && line.csSiteSpecificFactor9 != '998' && line.csSiteSpecificFactor9 != '988' && line.csSiteSpecificFactor9 != null) ))
              return false
        }
        
        return true
    }

    // ID: IF208; NAME: CS SSF 3, TS/Ext Eval, Prostate Schema (CS)
    public boolean if208(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor3 == null || line.csTumorSizeExtEval == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line.dateOfDiagnosisYear == null)
           return true
        
        if (line._csSchemaId == 'prostate') {
           if ((line.csExtension == '950' || line.csExtension == '999') && line.csSiteSpecificFactor3 >= '000' && line.csSiteSpecificFactor3 <= '750')
              return !(functions.matches(line.csTumorSizeExtEval, /^[01259]$/))
           if (line.dateOfDiagnosisYear >= '2010' || functions.asInt(line.csVersionInputOriginal) >= 20100) {
               if (functions.matches(line.csExtension, /^(2[0123]\d|240)$/)) {
                  if (line.csSiteSpecificFactor3 == '960')
                      return line.csTumorSizeExtEval == '0' || line.csTumorSizeExtEval == '9'
                  if (line.csSiteSpecificFactor3 == '970' || line.csSiteSpecificFactor3 == '980')
                      return line.csTumorSizeExtEval == '0'
               }
           }
           if (line.csTumorSizeExtEval == '3')
              return !(functions.matches(line.csSiteSpecificFactor3, /^(9[5-9]0)$/))
           if (line.csTumorSizeExtEval == '6')
              return !(functions.matches(line.csSiteSpecificFactor3, /^(9[5-9]0|985)$/))
           if (line.csTumorSizeExtEval == '8')
              return !(functions.matches(line.csSiteSpecificFactor3, /^(9[6-9]0)$/))
           if (line.csTumorSizeExtEval == '5' && !(functions.matches(line.csExtension, /^(950)|(990)$/)) && !(functions.matches(line.csSiteSpecificFactor3, /^(9[5678]\d)|(990)$/))) {
               if (line.csExtension >= line.csSiteSpecificFactor3)
                   return true
        
               //CS Extension = 200-300 (T2) and CS Site-Specific Factor 3 code = 300, 320, or 400 (T2NOS)
               if (line.csExtension >= '200' && line.csExtension <= '300'&& functions.matches(line.csSiteSpecificFactor3, /^(300)|(320)|(400)$/))
                   return true
        
               //CS Extension = 200, 240, 300 (T2NOS) and CS Site-Specific Factor 3 code = 210-230, 330-350, 402-406 (T2a, T2b, T2c)
               if (functions.matches(line.csExtension, /^(200)|(240)|(300)$/) && functions.matches(line.csSiteSpecificFactor3, /^(2[12]\d)|(230)|(3[34]\d)|(350)|(40[23456])$/))
                   return true
        
               //CS Extension = 210 (T2a) and CS Site-Specific Factor 3 = 330 or 402 (T2a)
               if (functions.matches(line.csExtension, /^(210)$/) && functions.matches(line.csSiteSpecificFactor3, /^(330)|(402)$/))
                    return true
        
               //CS Extension = 220 (T2b) and CS Site-Specific Factor 3 = 330, 402 (T2a), 340 or 404 (T2b)
               if (functions.matches(line.csExtension, /^(220)$/) && functions.matches(line.csSiteSpecificFactor3, /^(330)|(402)|(340)|(404)$/))
                   return true
        
               //CS Extension = 230 (T2c) and CS Site-Specific Factor 3 = 330, 402 (T2a), 340, 404 (T2b) 350 or 406 (T2c)
               if (functions.matches(line.csExtension, /^(230)$/) && functions.matches(line.csSiteSpecificFactor3, /^(330)|(402)|(340)|(404)|(350)|(406)$/))
                   return true
        
               //CS Extension = 410-490 (T3) and CS Site-Specific Factor 3 = 495 (T3NOS)
               if (functions.matches(line.csExtension, /^(4[12345678]\d)|(490)$/) && functions.matches(line.csSiteSpecificFactor3, /^(495)$/))
                   return true
        
               //CS Extension = 410 or 490 (T3NOS) and CS Site-Specific Factor 3 = 415-490 (T3a, T3b)
               if (functions.matches(line.csExtension, /^(410)|(490)$/) && functions.matches(line.csSiteSpecificFactor3, /^(41[56789])|(4[2345678]\d)|(490)$/))
                   return true
        
               //CS Extension = 420-445 (T3a) and CS Site-Specific Factor 3 = 430-483 (T3a)
               if (functions.matches(line.csExtension, /^(4[23]\d)|(44[012345])$/) && functions.matches(line.csSiteSpecificFactor3, /^(4[34567]\d)|(48[0123])$/))
                   return true
        
               //CS Extension = 450-470 (T3b) and CS Site-Specific Factor 3 = 480-483(T3a) or 485-490 (T3b)
               if (functions.matches(line.csExtension, /^(4[56]\d)|(470)$/) && functions.matches(line.csSiteSpecificFactor3, /^(48[0123])|(48[56789])|(490)$/))
                   return true
        
               //CS Extension = 500 - 700 (T4) and CS Site-Specific Factor 3 code = 510-750 (T4)
               if (functions.matches(line.csExtension, /^([56]\d\d)|(700)$/) && functions.matches(line.csSiteSpecificFactor3, /^(5[123456789]\d)|(6\d\d)|(7[1234]\d)|(750)$/))
                   return true
        
               return false
           }
           if (functions.matches(line.csTumorSizeExtEval, /^[45]$/))
              return !(functions.matches(line.csSiteSpecificFactor3, /^(9[6-8]0|985)$/))
        
           if (line.csSiteSpecificFactor3 >= '200' && line.csSiteSpecificFactor3 <= '750')
               return line.csTumorSizeExtEval != '0' && line.csTumorSizeExtEval != '1' && line.csTumorSizeExtEval != '9'
        }
        
        return true
    }

    // ID: IF209; NAME: CS Mets Eval, Mets at DX, CS Version Inp Orig (CS)
    public boolean if209(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csMetsAtDx == null || line.csMetsEval == null || line.csVersionInputOriginal < '010400')
           return true
        
        if (functions.matches(line.csMetsEval, /^[236]$/))
           return line.csMetsAtDx != '00'
        
        return true
    }

    // ID: IF210; NAME: CS Extension, Morphology, Bladder ICDO3 (CS)
    public boolean if210(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csExtension == null)
           return true
        
        if (line._csSchemaId == 'bladder') {
           if (line.histologicTypeIcdO3 == '8130' && line.behaviorCodeIcdO3 == '2')
              return line.csExtension != '100'
           if (line.csExtension == '100')
              return line.histologicTypeIcdO3 != '8130' || line.behaviorCodeIcdO3 != '2'
        }
        
        return true
    }

    // ID: IF211; NAME: CS TS/Ext Eval, Surgery, Bladder Schema (CS)
    public boolean if211(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csTumorSizeExtEval == null || line.behaviorCodeIcdO3 == '0' ||  line.behaviorCodeIcdO3 == '1' || line._csSchemaId != 'bladder' || !(functions.matches(line.rxSummSurgPrimSite, /^(1\d|2[0-7])$/)))
            return true
        
        if (functions.matches(line.csExtension, /^(7\d\d|80[012345])$/))
            return !(functions.matches(line.csTumorSizeExtEval, /^[568]$/))
        
        return !(functions.matches(line.csTumorSizeExtEval, /^[3568]$/))
    }

    // ID: IF212; NAME: CS Extension, Brain Schema (CS)
    public boolean if212(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csExtension == null)
           return true
        
         if (line._csSchemaId == 'brain') {
             if (functions.matches(line.primarySite, /^C71[1-5]$/))
                   return ! (functions.matches(line.csExtension, /^1[12]0|200|510$/))
             if (functions.matches(line.primarySite, /^C71[67]$/))
                   return ! (functions.matches(line.csExtension, /^[15]00$/))
         }
        
        return true
    }

    // ID: IF213; NAME: CS Lymph Nodes Eval, Lymph Nodes, Breast Schema (CS)
    public boolean if213(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csLymphNodesEval == null || line.csLymphNodes == null || line.behaviorCodeIcdO3 == '0' ||
            line.behaviorCodeIcdO3 == '1')
           return true
        
        if (line._csSchemaId == 'breast') {
           if (functions.matches(line.csLymphNodes, /^25[57]|510|610|735|810$/))
              return functions.matches(line.csLymphNodesEval, /^[0159]$/)
           if (functions.matches(line.csLymphNodes, /^050|130|15[05]|25[08]|520|620|7[123]0|815$/))
              return functions.matches(line.csLymphNodesEval, /^[2368]$/)
        }
        
        return true
    }

    // ID: IF214; NAME: CS SSF 3, SSF 4, Prostate Schema (CS)
    public boolean if214(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor3 == null || line.csSiteSpecificFactor4 == null || line.behaviorCodeIcdO3 == '0' ||
            line.behaviorCodeIcdO3 == '1' || line.csVersionInputOriginal < '010200' || line.dateOfDiagnosisYear == null ||
            (functions.asInt(line.dateOfDiagnosisYear) >= 2010 && (line.csSiteSpecificFactor4 == null || line.csSiteSpecificFactor4 == '988')))
           return true
        
        if (line.registryId == '0000001566' && line.csSiteSpecificFactor4 == '988')
            return true
        
        if (line._csSchemaId == 'prostate' && functions.matches(line.csSiteSpecificFactor3, /^9[678]0$/))
              return functions.matches(line.csSiteSpecificFactor4, /^\d[5]\d$/)
        
        return true
    }

    // ID: IF215; NAME: CS Extension, Mycosis Fungoides Schema (CS)
    public boolean if215(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csExtension == null ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
           return true
        
        if (line._csSchemaId == 'mycosis_fungoides') {
             if (functions.matches(line.primarySite, /^C44[0-8]$/))
                   return line.csExtension != '300'
        }
        
        return true
    }

    // ID: IF216; NAME: CS Lymph Nodes, SSF 3, Nodes Eval, MelanomaSkin (CS)
    public boolean if216(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csLymphNodes == null || line.csSiteSpecificFactor3 == null ||
            line.csSiteSpecificFactor3 == '988' || line.behaviorCodeIcdO3 == '0' ||
            line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'melanoma_skin') {
            if (functions.matches(line.csSiteSpecificFactor3, /^000|005$/))
                return !(functions.matches(line.csLymphNodes, /^121|128$/))
        
            if (functions.matches(line.csLymphNodes, /^121|128$/))
                return functions.matches(line.csLymphNodesEval, /^0|1|5|9$/)
        
            if (functions.matches(line.csLymphNodes, /^12[234]|15[238]$/))
                return functions.matches(line.csLymphNodesEval, /^2|3|6|8|9$/)
        
            if (functions.matches(line.csSiteSpecificFactor3, /^0[25]0|04[358]|1[05]0$/))
                return line.csLymphNodesEval != '8'
        }
        
        return true
    }

    // ID: IF217; NAME: CS Mets at DX, Lung, Laterality (CS)
    public boolean if217(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csMetsAtDx == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
           return true
        
        if (line._csSchemaId == 'lung' && line.laterality == '4')
           return functions.matches(line.csMetsAtDx, /^23|25|26|36|38|40|41|42|43|50|51|52|53|70|75$/)
        
        return true
    }

    // ID: IF218; NAME: CS SSF 6, Tumor Size, Breast Schema (CS)
    public boolean if218(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor6 == null || line.csSiteSpecificFactor6 == '988' ||
            line.csTumorSize == null || line.behaviorCodeIcdO3 == '0' ||
            line.behaviorCodeIcdO3 == '1' || line.histologicTypeIcdO3 == '9140')
           return true
        if (line._csSchemaId == 'breast') {
           if (functions.matches(line.csSiteSpecificFactor6, /^0[2345]0$/) && line.csTumorSize == '999')
              return false
           if (line.csSiteSpecificFactor6 == '060')
              return line.csTumorSize == '999'
        }
        
        return true
    }

    // ID: IF219; NAME: Derived SS2000, Behavior ICDO3 (CS)
    public boolean if219(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.derivedSs2000 == null || line.typeOfReportingSource == '7' || line._csSchemaId == null ||
            ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !['brain','cns_other','intracranial_gland'].contains(line._csSchemaId)))
           return true
        
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1'))
           return line.derivedSs2000 == '8'
        
        if (line.behaviorCodeIcdO3 == '2') {
           if (line._csSchemaId == 'bladder' && line.csExtension == '100')
              return (line.derivedSs2000 != '0' && line.derivedSs2000 != '8')
        
           return line.derivedSs2000 == '0'
        }
        
        if (line.behaviorCodeIcdO3 == '3') {
           if (line._csSchemaId == 'prostate' && line.csExtension == '999' && line.csSiteSpecificFactor3 == '000')
              return line.derivedSs2000 != '8'
        
           return line.derivedSs2000 != '0' && line.derivedSs2000 != '8'
        }
        
        return true
    }

    // ID: IF222; NAME: Date Initial RX SEER, RPTSRC (SEER)
    public boolean if222(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        if (line.registryId == '0000001544' && line.dateOfDiagnosisYear < '2000')
            return true
        if (line.registryId == '0000001562' && line.dateOfDiagnosisYear < '2019')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear < '2023')
            return true
        
        if (line.typeOfReportingSource == '6' || line.typeOfReportingSource == '7')
            return line.dateInitialRxSeerYear == null && line.dateInitialRxSeerMonth == null && line.dateInitialRxSeerDay == null
        
        return true
    }

    // ID: IF226; NAME: CS Tumor Size, Schema (CS)
    public boolean if226(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null || line.primarySite == null || line.csTumorSize == null)
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
            return true
        
        if (line._csSchemaId == null)
            return true
        
        return functions.isAcceptableCsCode(line,'csTumorSize',line.csTumorSize)
    }

    // ID: IF227; NAME: CS Extension, Schema (CS)
    public boolean if227(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null || line.primarySite == null || line.csExtension == null)
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
            return true
        
        if (line._csSchemaId == null)
            return true
        
        return functions.isAcceptableCsCode(line, 'csExtension',line.csExtension)
    }

    // ID: IF228; NAME: CS Tumor Size/Ext Eval, Schema (CS)
    public boolean if228(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null || line.primarySite == null || line.csTumorSizeExtEval == null)
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
            return true
        
        if (line._csSchemaId == null)
            return true
        
        return functions.isAcceptableCsCode(line, 'csTumorSizeExtEval',line.csTumorSizeExtEval)
    }

    // ID: IF229; NAME: CS Lymph Nodes, Schema (CS)
    public boolean if229(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null || line.primarySite == null || line.csLymphNodes == null)
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
            return true
        
        if (line._csSchemaId == null)
            return true
        
        return functions.isAcceptableCsCode(line, 'csLymphNodes',line.csLymphNodes)
    }

    // ID: IF230; NAME: CS Lymph Nodes Eval, Schema (CS)
    public boolean if230(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null || line.primarySite == null || line.csLymphNodesEval == null)
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
            return true
        
        if (line._csSchemaId == null)
            return true
        
        return functions.isAcceptableCsCode(line, 'csLymphNodesEval',line.csLymphNodesEval)
    }

    // ID: IF231; NAME: CS Mets at DX, Schema (CS)
    public boolean if231(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null || line.primarySite == null || line.csMetsAtDx == null)
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
            return true
        
        if (line._csSchemaId == null)
            return true
        
        return functions.isAcceptableCsCode(line, 'csMetsAtDx',line.csMetsAtDx)
    }

    // ID: IF232; NAME: CS Mets Eval, Schema (CS)
    public boolean if232(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null || line.primarySite == null || line.csMetsEval == null)
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
            return true
        
        if (line._csSchemaId == null)
            return true
        
        return functions.isAcceptableCsCode(line, 'csMetsEval',line.csMetsEval)
    }

    // ID: IF233; NAME: CS Site-Specific Factor 1, Schema (SEER)
    public boolean if233(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null || line.primarySite == null || line.csSiteSpecificFactor1 == null)
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
            return true
        
        if (line._csSchemaId == null)
            return true
        
        if ((line.dateOfDiagnosisYear == '2016' || line.dateOfDiagnosisYear == '2017') && line.csExtension == null && ['retinoblastoma','esophagus','esophagus_gejunction','net_stomach','stomach'].contains(line._csSchemaId))
            return true
        
        return functions.isAcceptableCsCode(line, 'csSiteSpecificFactor1',line.csSiteSpecificFactor1)
    }

    // ID: IF234; NAME: CS Site-Specific Factor 2, Schema (SEER)
    public boolean if234(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null || line.primarySite == null || line.csSiteSpecificFactor2 == null)
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
            return true
        
        if (line._csSchemaId == null)
            return true
        
        if ((line.dateOfDiagnosisYear == '2016' || line.dateOfDiagnosisYear == '2017') && line.csExtension == null && ['appendix','carcinoid_appendix','colon','net_colon','net_rectum','rectum','small_intestine'].contains(line._csSchemaId))
            return true
        
        return functions.isAcceptableCsCode(line, 'csSiteSpecificFactor2',line.csSiteSpecificFactor2)
    }

    // ID: IF235; NAME: CS Site-Specific Factor 3, Schema (SEER)
    public boolean if235(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null || line.primarySite == null || line.csSiteSpecificFactor3 == null)
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
            return true
        
        if (line._csSchemaId == null)
            return true
        
        if ((line.dateOfDiagnosisYear == '2016' || line.dateOfDiagnosisYear == '2017') && line.csExtension == null && ['lacrimal_gland','melanoma_skin','merkel_cell_penis','merkel_cell_scrotum','merkel_cell_skin','merkel_cell_vulva','prostate','skin_eyelid'].contains(line._csSchemaId))
            return true
        
        return functions.isAcceptableCsCode(line, 'csSiteSpecificFactor3',line.csSiteSpecificFactor3)
    }

    // ID: IF236; NAME: CS Site-Specific Factor 4, Schema (CS)
    public boolean if236(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null || line.primarySite == null || line.csSiteSpecificFactor4 == null)
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
            return true
        
        if (line._csSchemaId == null)
            return true
        
        return functions.isAcceptableCsCode(line, 'csSiteSpecificFactor4',line.csSiteSpecificFactor4)
    }

    // ID: IF237; NAME: CS Site-Specific Factor 5, Schema (CS)
    public boolean if237(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null || line.primarySite == null || line.csSiteSpecificFactor5 == null)
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
            return true
        
        if (line._csSchemaId == null)
            return true
        
        return functions.isAcceptableCsCode(line, 'csSiteSpecificFactor5',line.csSiteSpecificFactor5)
    }

    // ID: IF238; NAME: CS Site-Specific Factor 6, Schema (CS)
    public boolean if238(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null || line.primarySite == null || line.csSiteSpecificFactor6 == null)
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
            return true
        
        if (line._csSchemaId == null)
            return true
        
        return functions.isAcceptableCsCode(line, 'csSiteSpecificFactor6',line.csSiteSpecificFactor6)
    }

    // ID: IF239; NAME: CS Site-Specific Factor 7, Schema (CS)
    public boolean if239(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null || line.primarySite == null || line.csSiteSpecificFactor7 == null)
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
            return true
        
        if (line._csSchemaId == null)
            return true
        
        return functions.isAcceptableCsCode(line, 'csSiteSpecificFactor7',line.csSiteSpecificFactor7)
    }

    // ID: IF240; NAME: CS Site-Specific Factor 8, Schema (CS)
    public boolean if240(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null || line.primarySite == null || line.csSiteSpecificFactor8 == null)
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
            return true
        
        if (line._csSchemaId == null)
            return true
        
        return functions.isAcceptableCsCode(line, 'csSiteSpecificFactor8',line.csSiteSpecificFactor8)
    }

    // ID: IF241; NAME: CS Site-Specific Factor 9, Schema (CS)
    public boolean if241(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null || line.primarySite == null || line.csSiteSpecificFactor9 == null)
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
            return true
        
        if (line._csSchemaId == null)
            return true
        
        return functions.isAcceptableCsCode(line, 'csSiteSpecificFactor9',line.csSiteSpecificFactor9)
    }

    // ID: IF242; NAME: CS Site-Specific Factor10, Schema (SEER)
    public boolean if242(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null || line.primarySite == null || line.csSiteSpecificFactor10 == null)
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
            return true
        
        if (line._csSchemaId == null)
            return true
        
        if ((line.dateOfDiagnosisYear == '2016' || line.dateOfDiagnosisYear == '2017') && line.csExtension == null && line._csSchemaId == 'bile_ducts_intrahepat')
            return true
        
        return functions.isAcceptableCsCode(line, 'csSiteSpecificFactor10',line.csSiteSpecificFactor10)
    }

    // ID: IF243; NAME: CS Site-Specific Factor11, Schema (CS)
    public boolean if243(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null || line.primarySite == null || line.csSiteSpecificFactor11 == null)
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
            return true
        
        if (line._csSchemaId == null)
            return true
        
        return functions.isAcceptableCsCode(line, 'csSiteSpecificFactor11',line.csSiteSpecificFactor11)
    }

    // ID: IF244; NAME: CS Site-Specific Factor12, Schema (CS)
    public boolean if244(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null || line.primarySite == null || line.csSiteSpecificFactor12 == null)
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
            return true
        
        if (line._csSchemaId == null)
            return true
        
        return functions.isAcceptableCsCode(line, 'csSiteSpecificFactor12',line.csSiteSpecificFactor12)
    }

    // ID: IF245; NAME: CS Site-Specific Factor13, Schema (CS)
    public boolean if245(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null || line.primarySite == null || line.csSiteSpecificFactor13 == null)
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
            return true
        
        if (line._csSchemaId == null)
            return true
        
        return functions.isAcceptableCsCode(line, 'csSiteSpecificFactor13',line.csSiteSpecificFactor13)
    }

    // ID: IF246; NAME: CS Site-Specific Factor14, Schema (CS)
    public boolean if246(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null || line.primarySite == null || line.csSiteSpecificFactor14 == null)
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
            return true
        
        if (line._csSchemaId == null)
            return true
        
        return functions.isAcceptableCsCode(line, 'csSiteSpecificFactor14',line.csSiteSpecificFactor14)
    }

    // ID: IF247; NAME: CS Site-Specific Factor15, Schema (CS)
    public boolean if247(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null || line.primarySite == null || line.csSiteSpecificFactor15 == null)
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
            return true
        
        if (line._csSchemaId == null)
            return true
        
        return functions.isAcceptableCsCode(line, 'csSiteSpecificFactor15',line.csSiteSpecificFactor15)
    }

    // ID: IF248; NAME: CS Site-Specific Factor16, Schema (CS)
    public boolean if248(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null || line.primarySite == null || line.csSiteSpecificFactor16 == null)
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
            return true
        
        if (line._csSchemaId == null)
            return true
        
        return functions.isAcceptableCsCode(line, 'csSiteSpecificFactor16',line.csSiteSpecificFactor16)
    }

    // ID: IF249; NAME: CS Site-Specific Factor17, Schema (CS)
    public boolean if249(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null || line.primarySite == null || line.csSiteSpecificFactor17 == null)
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
            return true
        
        if (line._csSchemaId == null)
            return true
        
        return functions.isAcceptableCsCode(line, 'csSiteSpecificFactor17',line.csSiteSpecificFactor17)
    }

    // ID: IF250; NAME: CS Site-Specific Factor18, Schema (CS)
    public boolean if250(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null || line.primarySite == null || line.csSiteSpecificFactor18 == null)
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
            return true
        
        if (line._csSchemaId == null)
            return true
        
        return functions.isAcceptableCsCode(line, 'csSiteSpecificFactor18',line.csSiteSpecificFactor18)
    }

    // ID: IF251; NAME: CS Site-Specific Factor19, Schema (CS)
    public boolean if251(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null || line.primarySite == null || line.csSiteSpecificFactor19 == null)
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
            return true
        
        if (line._csSchemaId == null)
            return true
        
        return functions.isAcceptableCsCode(line, 'csSiteSpecificFactor19',line.csSiteSpecificFactor19)
    }

    // ID: IF252; NAME: CS Site-Specific Factor20, Schema (CS)
    public boolean if252(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null || line.primarySite == null || line.csSiteSpecificFactor20 == null)
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
            return true
        
        if (line._csSchemaId == null)
            return true
        
        return functions.isAcceptableCsCode(line, 'csSiteSpecificFactor20',line.csSiteSpecificFactor20)
    }

    // ID: IF253; NAME: CS Site-Specific Factor21, Schema (CS)
    public boolean if253(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null || line.primarySite == null || line.csSiteSpecificFactor21 == null)
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
            return true
        
        if (line._csSchemaId == null)
            return true
        
        return functions.isAcceptableCsCode(line, 'csSiteSpecificFactor21',line.csSiteSpecificFactor21)
    }

    // ID: IF254; NAME: CS Site-Specific Factor22, Schema (CS)
    public boolean if254(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null || line.primarySite == null || line.csSiteSpecificFactor22 == null)
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
            return true
        
        if (line._csSchemaId == null)
            return true
        
        return functions.isAcceptableCsCode(line, 'csSiteSpecificFactor22',line.csSiteSpecificFactor22)
    }

    // ID: IF255; NAME: CS Site-Specific Factor23, Schema (CS)
    public boolean if255(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null || line.primarySite == null || line.csSiteSpecificFactor23 == null)
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
            return true
        
        if (line._csSchemaId == null)
            return true
        
        return functions.isAcceptableCsCode(line, 'csSiteSpecificFactor23',line.csSiteSpecificFactor23)
    }

    // ID: IF256; NAME: CS Site-Specific Factor24, Schema (CS)
    public boolean if256(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null || line.primarySite == null || line.csSiteSpecificFactor24 == null)
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
            return true
        
        if (line._csSchemaId == null)
            return true
        
        return functions.isAcceptableCsCode(line, 'csSiteSpecificFactor24',line.csSiteSpecificFactor24)
    }

    // ID: IF257; NAME: CS Site-Specific Factor25, Schema (CS)
    public boolean if257(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null || line.primarySite == null || line.csSiteSpecificFactor25 == null || line._csSchemaId == null)
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
            return true
        
        if (line._csSchemaId == null)
            return true
        
        if ((line._csSchemaId == 'nasopharynx' || line._csSchemaId == 'pharyngeal_tonsil') && functions.matches(line.primarySite, /^C11[02389]$/))
            return line.csSiteSpecificFactor25 == '981'
        if ((line._csSchemaId == 'esophagus_gejunction' || line._csSchemaId == 'stomach') && functions.matches(line.primarySite, /^C16[3-9]$/))
            return line.csSiteSpecificFactor25 == '981'
        if ((line._csSchemaId == 'esophagus_gejunction' || line._csSchemaId == 'stomach') && line.primarySite == 'C160')
            return line.csSiteSpecificFactor25 == '982'
        if ((line._csSchemaId == 'peritoneum' || line._csSchemaId == 'peritoneum_female_gen') && functions.matches(line.primarySite, /^C48[128]$/)
            && functions.matches(line.histologicTypeIcdO3, /^858[0-9]|86[89]\d|8[78]\d\d|89[01]\d|892[01]|912\d|913[0-6]|914[1-9]|91[5-9]\d|9[2-4]\d\d|95[0-7]\d|958[012]|970[01]$/))
            return line.csSiteSpecificFactor25 == '981'
        
        return functions.isAcceptableCsCode(line, 'csSiteSpecificFactor25',line.csSiteSpecificFactor25)
    }

    // ID: IF258; NAME: CS Extension, CS Tumor Size, Breast Schema (CS)
    public boolean if258(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csExtension == null || line.csTumorSize == null || line.histologicTypeIcdO3 == null || line.primarySite == null)
            return true
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'breast') {
            if (line.csTumorSize == '997' && (line.csExtension != '050' && line.csExtension != '070'))
                return false
            if (line.csTumorSize == '996' && (line.csExtension > '400' && line.csExtension != '999'))
                return false
            if (line.csExtension == '170' && (line.csTumorSize != '990' && line.csTumorSize != '991' && line.csTumorSize != '992'))
                return false
            if (line.csExtension == '180' && line.csTumorSize != '995')
                return false
        }
        
        return true
    }

    // ID: IF259; NAME: CS Extension, SSF 24, Breast Schema (CS)
    public boolean if259(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csExtension == null || line.csSiteSpecificFactor24 == null || line.csSiteSpecificFactor24 == '988' || line.histologicTypeIcdO3 == null || line.primarySite == null)
            return true
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'breast') {
            if (['8540','8541','8543'].contains(line.histologicTypeIcdO3) && line.csSiteSpecificFactor24 != '010' && line.csSiteSpecificFactor24 != '020')
                return false
            if ((line.csExtension == '050' || line.csExtension == '070') && line.csSiteSpecificFactor24 != '010' && line.csSiteSpecificFactor24 != '020')
                return false
        }
        
        return true
    }

    // ID: IF260; NAME: CS Lymph Nodes, Nodes Pos, ColoAppRectal (CS)
    public boolean if260(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csLymphNodes == null || line.regionalNodesPositive == null || line.histologicTypeIcdO3 == null || line.primarySite == null)
            return true
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'colon' || line._csSchemaId == 'appendix' || line._csSchemaId == 'rectum') {
            if (line.regionalNodesPositive >= '01' && line.regionalNodesPositive <= '90' && ['400','410','420','430','450','460','470','480'].contains(line.csLymphNodes))
                return false
            if (['400','410','420','430','450','460','470','480'].contains(line.csLymphNodes) && (line.regionalNodesPositive != '95' && line.regionalNodesPositive != '97'))
                return false
        }
        
        return true
    }

    // ID: IF261; NAME: CS Mets at DX, SSF 20, Breast Schema (CS)
    public boolean if261(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csMetsAtDx == null || line.csSiteSpecificFactor20 == null || line.csSiteSpecificFactor20 == '988' || line.histologicTypeIcdO3 == null || line.primarySite == null)
            return true
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'breast') {
            if ((line.csMetsAtDx == '00' || line.csMetsAtDx == '05' || line.csMetsAtDx == '07') && line.csSiteSpecificFactor20 != '000' && line.csSiteSpecificFactor20 != '005')
                return false
            if (['10','40','42','44','50','60'].contains(line.csMetsAtDx) && (line.csSiteSpecificFactor20 == '000' || line.csSiteSpecificFactor20 == '005'))
                return false
            if (line.csMetsAtDx == '99' && line.csSiteSpecificFactor20 != '999')
                return false
        }
        
        return true
    }

    // ID: IF262; NAME: CS SSF 1, Histol, Urothelial Schemas (CS)
    public boolean if262(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor1 == null || line.histologicTypeIcdO3 == null || line.primarySite == null)
            return true
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'kidney_renal_pelvis' || line._csSchemaId == 'bladder' || line._csSchemaId == 'urethra') {
            if (line.csSiteSpecificFactor1 == '987' && ['8020', '8031', '8082', '8120','8121','8122','8123','8124','8130','8131','8050'].contains(line.histologicTypeIcdO3))
                return false
        }
        
        return true
    }

    // ID: IF262DIG_P1; NAME: EOD--Old 2 digit, Primary Site (SEER IF262DIG)
    public boolean if262dig_p1(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer site = functions.asInt(line.primarySite.substring(1))
        
        return (line.codingSystemForEod != '1' ||
               (((List)context.Skin_IF262DIG).contains(site) &&
               functions.between(line.histologicTypeIcdO3, '8720', '8790')) ||
                ((Map)context.If26_2Digit).containsKey(site))
    }

    // ID: IF262DIG_P2; NAME: EOD--Old 2 digit, Primary Site (SEER IF262DIG)
    public boolean if262dig_p2(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer site = functions.asInt(line.primarySite.substring(1))
        
        return ('1' != line.codingSystemForEod || ([24,99,111,142,379,422,770,771,772,773,774,775,776,777,778,779].contains(site)
             && functions.between(line.histologicTypeIcdO3,'9590','9698')) || (((List)context.Skin_IF262DIG).contains(site) && functions.between(line.histologicTypeIcdO3,'8720','8790')
             && ((List)context.Eod_2Digit_Table_39).contains(line.eodOld2Digit)) || ((List)((Map)context.If26_2Digit).getOrDefault(site, [])).contains(line.eodOld2Digit))
    }

    // ID: IF262DIG_P3; NAME: EOD--Old 2 digit, Primary Site (SEER IF262DIG)
    public boolean if262dig_p3(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer site = functions.asInt(line.primarySite.substring(1))
        
        if (line.codingSystemForEod != '1' || ([24,99,111,142,379,422,770,771,772,773,774,775,776,777,778,779].contains(site)
                && functions.between(line.histologicTypeIcdO3,'9590','9698')))
            return true
        if (line.behaviorCodeIcdO3 == '2') {
            if (((List)context.SmallInstToRectum_IF262DIG).contains(site))
                return (line.eodOld2Digit == '01' || line.eodOld2Digit == '02' || line.eodOld2Digit == '0-')
            return line.eodOld2Digit == '0-'
        }
        if (line.behaviorCodeIcdO3 == '3') {
           if (((List)context.SmallInstToRectum_IF262DIG).contains(site))
               return ( ! (line.eodOld2Digit == '01' || line.eodOld2Digit == '02' || line.eodOld2Digit == '0-'))
           return line.eodOld2Digit != '0-'
        }
        return true
    }

    // ID: IF263; NAME: CS SSF 2, Dx Conf, KidneyRenalPelvis (CS)
    public boolean if263(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor2 == null || line.histologicTypeIcdO3 == null || line.primarySite == null)
            return true
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'kidney_renal_pelvis') {
            if (((line.csSiteSpecificFactor2 >= '000' && line.csSiteSpecificFactor2 <= '980') || line.csSiteSpecificFactor2 == '991') && line.diagnosticConfirmation != '1')
                return false
        }
        
        return true
    }

    // ID: IF264; NAME: CS SSF 4, LymphNodes, NodesPos, ColoRectal (CS)
    public boolean if264(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor4 == null || line.csLymphNodes == null || line.regionalNodesPositive == null || line.histologicTypeIcdO3 == null || line.primarySite == null)
            return true
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'colon' || line._csSchemaId == 'rectum') {
            if (((line.csSiteSpecificFactor4 >= '001' && line.csSiteSpecificFactor4 <= '081') || line.csSiteSpecificFactor4 == '990') && line.regionalNodesPositive >= '01' && line.regionalNodesPositive <= '97' && line.csLymphNodes == '050')
                return false
            if (line.csLymphNodes == '050' && line.csSiteSpecificFactor4 == '000')
                return false
        }
        
        return true
    }

    // ID: IF264DIG_P1; NAME: EOD--Old 4 digit (SEER IF264DIG_P1)
    public boolean if264dig_p1(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer site = functions.asInt(line.primarySite.substring(1))
        Integer histIcdO3 = functions.asInt(line.histologicTypeIcdO3)
        
        if (line.codingSystemForEod == '3' && line.typeOfReportingSource != '7') {
           if (line.histologicTypeIcdO3 == null || histIcdO3 < 8000 || histIcdO3 > 9999)
              return false
           if (line.behaviorCodeIcdO3 != '2' && line.behaviorCodeIcdO3 != '3')
              return false
           if (line.primarySite == null || site > 809 || site < 0)
              return false
           if ((!((Map)context.If26_4DIG_SITE_SIZE).containsKey(site)) &&
                !((Map)context.If26_4DIG_SITE_HIST_SIZE).containsKey(site))
              return false
           if (((Map)context.If26_4DIG_LEUK_LYMPH_SIZE).containsKey(histIcdO3) && line.behaviorCodeIcdO3 == '2')
              return false
        }
        return true
    }

    // ID: IF264DIG_P2; NAME: EOD--Old 4 digit_2, Size (SEER IF264DIG_P2)
    public boolean if264dig_p2(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer site = functions.asInt(line.primarySite.substring(1))
        Integer histIcdO3 = functions.asInt(line.histologicTypeIcdO3)
        String eodOld4DigitSize = null
        if (line.eodOld4Digit != null && line.eodOld4Digit.length() > 1)
            eodOld4DigitSize = line.eodOld4Digit.substring(0, 2)
        Integer eod4DigitSizeInt = functions.asInt(eodOld4DigitSize)
        
        if (line.codingSystemForEod != '3')
           return true
        if (line.typeOfReportingSource == '7')
           return (eod4DigitSizeInt == 99)
        if (! (functions.matches(eodOld4DigitSize, /^[0-9][0-9]$/)))
           return false
        
        if (((List)((Map)context.If26_4DIG_LEUK_LYMPH_SIZE).getOrDefault(histIcdO3, [])).contains(eod4DigitSizeInt))
            return true
        
        if (((List)((Map)((Map)context.If26_4DIG_SITE_HIST_SIZE).getOrDefault(site, [:])).getOrDefault(histIcdO3, [])).contains(eod4DigitSizeInt))
            return true
        
        if (((List)((Map)context.If26_4DIG_SITE_SIZE).getOrDefault(site, [])).contains(eod4DigitSizeInt))
            return true
        
        return false
    }

    // ID: IF264DIG_P3; NAME: EOD--Old 4 digit_3, Extension-In Situ (SEER IF264DIG_P3)
    public boolean if264dig_p3(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer histIcdO3 = functions.asInt(line.histologicTypeIcdO3)
        Integer site = functions.asInt(line.primarySite.substring(1))
        String eodOld4DigitExtent = null
        if (line.eodOld4Digit != null && line.eodOld4Digit.length() > 2)
            eodOld4DigitExtent = line.eodOld4Digit.substring(2, 3)
        Integer eod4DigitExtInt = functions.asInt(eodOld4DigitExtent)
        
        if ((line.codingSystemForEod != '3') || (line.behaviorCodeIcdO3 != '2'))
           return true
        if (line.typeOfReportingSource == '7')
           return (eodOld4DigitExtent == '9')
        if (! (functions.matches(eodOld4DigitExtent, /^[0-9]$/)))
           return false
        
        if (((List)((Map)((Map)context.If26_4DIG_SITE_HIST_INSITU_EXT).getOrDefault(site, [:])).getOrDefault(histIcdO3, [])).contains(eod4DigitExtInt))
            return true
        
        if (((List)((Map)context.If26_4DIG_SITE_INSITU_EXT).getOrDefault(site, [])).contains(eod4DigitExtInt))
            return true
        
        return false
    }

    // ID: IF264DIG_P4; NAME: EOD--Old 4 digit_4, Extension-Malig (SEER IF264DIG_P4)
    public boolean if264dig_p4(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer site = functions.asInt(line.primarySite.substring(1))
        Integer histIcdO3 = functions.asInt(line.histologicTypeIcdO3)
        String eodOld4DigitExtent = null
        if (line.eodOld4Digit != null && line.eodOld4Digit.length() > 2)
            eodOld4DigitExtent = line.eodOld4Digit.substring(2, 3)
        Integer eod4DigitExtInt = functions.asInt(eodOld4DigitExtent)
        
        if (line.codingSystemForEod != '3' || line.behaviorCodeIcdO3 != '3')
           return true
        if (line.typeOfReportingSource == '7')
           return (eodOld4DigitExtent  == '9')
        if (!functions.matches(eodOld4DigitExtent, /^[0-9]$/))
           return false
        
        if (((List)((Map)context.If26_4DIG_LEUK_LYMPH_EXT).getOrDefault(histIcdO3, [])).contains(eod4DigitExtInt))
            return true
        
        if (((List)((Map)((Map)context.If26_4DIG_SITE_HIST_MALIG_EXT).getOrDefault(site, [:])).getOrDefault(histIcdO3, [])).contains(eod4DigitExtInt))
            return true
        
        if (((List)((Map)context.If26_4DIG_SITE_MALIG_EXT).getOrDefault(site, [])).contains(eod4DigitExtInt))
            return true
        
        return false
    }

    // ID: IF264DIG_P5; NAME: EOD--Old 4 digit_5, LymphNodes-In Situ (SEER IF264DIG_P5)
    public boolean if264dig_p5(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer site = functions.asInt(line.primarySite.substring(1))
        Integer histIcdO3 = functions.asInt(line.histologicTypeIcdO3)
        String eodOld4DigitNodes = null
        if (line.eodOld4Digit != null && line.eodOld4Digit.length() > 3)
            eodOld4DigitNodes = line.eodOld4Digit.substring(3, 4)
        Integer eod4DigitNodesInt = functions.asInt(eodOld4DigitNodes)
        
        if (line.codingSystemForEod != '3' || line.behaviorCodeIcdO3 != '2')
           return true
        if (line.typeOfReportingSource == '7')
           return eodOld4DigitNodes == '9'
        if (! (functions.matches(eodOld4DigitNodes, /^[0-9]$/)))
           return false
        
        if (((List)((Map)((Map)context.If26_4DIG_SITE_HIST_INSITU_NODES).getOrDefault(site, [:])).getOrDefault(histIcdO3, [])).contains(eod4DigitNodesInt))
            return true
        
        if (((List)((Map)context.If26_4DIG_SITE_INSITU_NODES).getOrDefault(site, [])).contains(eod4DigitNodesInt))
            return true
        
        return false
    }

    // ID: IF264DIG_P6; NAME: EOD--Old 4 digit_6, LymphNodes-Malig (SEER IF264DIG_P6)
    public boolean if264dig_p6(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer site = functions.asInt(line.primarySite.substring(1))
        Integer histIcdO3 = functions.asInt(line.histologicTypeIcdO3)
        String eodOld4DigitNodes = null
        if (line.eodOld4Digit != null && line.eodOld4Digit.length() > 3)
            eodOld4DigitNodes = line.eodOld4Digit.substring(3, 4)
        Integer eod4DigitNodesInt = functions.asInt(eodOld4DigitNodes)
        
        if (line.codingSystemForEod != '3' || line.behaviorCodeIcdO3 != '3')
           return true
        if (line.typeOfReportingSource == '7')
           return (eodOld4DigitNodes == '9')
        if (! (functions.matches(eodOld4DigitNodes, /^[0-9]$/)))
           return false
        
        if (((List)((Map)context.If26_4DIG_LEUK_LYMPH_NODES).getOrDefault(histIcdO3, [])).contains(eod4DigitNodesInt))
            return true
        
        if (((List)((Map)((Map)context.If26_4DIG_SITE_HIST_MALIG_NODES).getOrDefault(site, [:])).getOrDefault(histIcdO3, [])).contains(eod4DigitNodesInt))
            return true
        
        if (((List)((Map)context.If26_4DIG_SITE_MALIG_NODES).getOrDefault(site, [])).contains(eod4DigitNodesInt))
            return true
        
        return false
    }

    // ID: IF265; NAME: CS SSF 5, RX Summ--Surg, ColoRectal (CS)
    public boolean if265(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor5 == null || line.csSiteSpecificFactor5 == '988' || line.rxSummSurgPrimSite == null || line.histologicTypeIcdO3 == null || line.primarySite == null)
            return true
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'colon' || line._csSchemaId == 'rectum') {
            if (['000','010','020','030'].contains(line.csSiteSpecificFactor5) && (line.rxSummSurgPrimSite == '00' || line.rxSummSurgPrimSite == '99'))
                return false
        }
        
        return true
    }

    // ID: IF266; NAME: CS Version Input Current, CS Version Derived (CS)
    public boolean if266(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csVersionDerived == null || line.csVersionInputCurrent == null || line.csVersionDerived >= line.csVersionInputCurrent
    }

    // ID: IF268; NAME: CS Version Input Original, Version Input Curr (CS)
    public boolean if268(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.csVersionInputCurrent == null || line.csVersionInputOriginal == null || line.csVersionInputCurrent >= line.csVersionInputOriginal
    }

    // ID: IF269; NAME: Obsolete Codes - CS Tumor Size (CS)
    public boolean if269(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csTumorSize == null || line.dateOfDiagnosisYear == null || line.csVersionInputOriginal == null)
             return true
        
        if (line._csSchemaId == null)
            return false
        
        String code = functions.getCsObsoleteReason(line, 'csTumorSize', line.csTumorSize)
        
        if (code != null) {
             if (code == '1' || code == '5' || code == '6' || code == '7' || code == '16' || code == '18') {
                 if (line.dateOfDiagnosisYear >= '2010')
                    return false
                 if (line.csVersionInputOriginal >= '020100')
                    return false
             }
             else if (code == '13' || code == '14' || code == '15') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020300')
                    return false
             }
             else if (code == '17') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020200')
                    return false
             }
             else if (code == '21' || code == '22') {
                 if (line.dateOfDiagnosisYear >= '2012')
                    return false
                 if (line.csVersionInputOriginal >= '020440')
                    return false
             }
             else
                return false
        }
        
        return true
    }

    // ID: IF270; NAME: Obsolete Codes - CS Extension (CS)
    public boolean if270(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csExtension == null || line.dateOfDiagnosisYear == null || line.csVersionInputOriginal == null)
             return true
        
        if (line._csSchemaId == null)
            return false
        
        String code = functions.getCsObsoleteReason(line, 'csExtension', line.csExtension)
        
        if (code != null) {
             if (code == '1' || code == '5' || code == '6' || code == '7' || code == '16' || code == '18') {
                 if (line.dateOfDiagnosisYear >= '2010')
                    return false
                 if (line.csVersionInputOriginal >= '020100')
                    return false
             }
             else if (code == '13' || code == '14' || code == '15') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020300')
                    return false
             }
             else if (code == '17') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020200')
                    return false
             }
             else if (code == '21' || code == '22') {
                 if (line.dateOfDiagnosisYear >= '2012')
                    return false
                 if (line.csVersionInputOriginal >= '020440')
                    return false
             }
             else
                return false
        }
        
        return true
    }

    // ID: IF271; NAME: Obsolete Codes - CS Tumor Size/Ext Eval (CS)
    public boolean if271(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csTumorSizeExtEval == null || line.dateOfDiagnosisYear == null || line.csVersionInputOriginal == null)
             return true
        
        if (line._csSchemaId == null)
            return false
        
        String code = functions.getCsObsoleteReason(line, 'csTumorSizeExtEval', line.csTumorSizeExtEval)
        
        if (code != null) {
             if (code == '1' || code == '5' || code == '6' || code == '7' || code == '16' || code == '18') {
                 if (line.dateOfDiagnosisYear >= '2010')
                    return false
                 if (line.csVersionInputOriginal >= '020100')
                    return false
             }
             else if (code == '13' || code == '14' || code == '15') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020300')
                    return false
             }
             else if (code == '17') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020200')
                    return false
             }
             else if (code == '21' || code == '22') {
                 if (line.dateOfDiagnosisYear >= '2012')
                    return false
                 if (line.csVersionInputOriginal >= '020440')
                    return false
             }
             else
                return false
        }
        
        return true
    }

    // ID: IF272; NAME: Obsolete Codes - CS Lymph Nodes (CS)
    public boolean if272(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csLymphNodes == null || line.dateOfDiagnosisYear == null || line.csVersionInputOriginal == null)
             return true
        
        if (line._csSchemaId == null)
            return false
        
        String code = functions.getCsObsoleteReason(line, 'csLymphNodes', line.csLymphNodes)
        
        if (code != null) {
             if (code == '1' || code == '5' || code == '6' || code == '7' || code == '16' || code == '18') {
                 if (line.dateOfDiagnosisYear >= '2010')
                    return false
                 if (line.csVersionInputOriginal >= '020100')
                    return false
             }
             else if (code == '13' || code == '14' || code == '15') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020300')
                    return false
             }
             else if (code == '17') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020200')
                    return false
             }
             else if (code == '21' || code == '22') {
                 if (line.dateOfDiagnosisYear >= '2012')
                    return false
                 if (line.csVersionInputOriginal >= '020440')
                    return false
             }
             else
                return false
        }
        
        return true
    }

    // ID: IF273; NAME: Obsolete Codes - CS Lymph Nodes Eval (CS)
    public boolean if273(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csLymphNodesEval == null || line.dateOfDiagnosisYear == null || line.csVersionInputOriginal == null)
             return true
        
        if (line._csSchemaId == null)
            return false
        
        String code = functions.getCsObsoleteReason(line, 'csLymphNodesEval', line.csLymphNodesEval)
        
        if (code != null) {
             if (code == '1' || code == '5' || code == '6' || code == '7' || code == '16' || code == '18') {
                 if (line.dateOfDiagnosisYear >= '2010')
                    return false
                 if (line.csVersionInputOriginal >= '020100')
                    return false
             }
             else if (code == '13' || code == '14' || code == '15') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020300')
                    return false
             }
             else if (code == '17') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020200')
                    return false
             }
             else if (code == '21' || code == '22') {
                 if (line.dateOfDiagnosisYear >= '2012')
                    return false
                 if (line.csVersionInputOriginal >= '020440')
                    return false
             }
             else
                return false
        }
        
        return true
    }

    // ID: IF274; NAME: Obsolete Codes - CS Mets at DX (CS)
    public boolean if274(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csMetsAtDx == null || line.dateOfDiagnosisYear == null || line.csVersionInputOriginal == null)
             return true
        
        if (line._csSchemaId == null)
            return false
        
        String code = functions.getCsObsoleteReason(line, 'csMetsAtDx', line.csMetsAtDx)
        
        if (code != null) {
             if (code == '1' || code == '5' || code == '6' || code == '7' || code == '16' || code == '18') {
                 if (line.dateOfDiagnosisYear >= '2010')
                    return false
                 if (line.csVersionInputOriginal >= '020100')
                    return false
             }
             else if (code == '13' || code == '14' || code == '15') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020300')
                    return false
             }
             else if (code == '17') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020200')
                    return false
             }
             else if (code == '21' || code == '22') {
                 if (line.dateOfDiagnosisYear >= '2012')
                    return false
                 if (line.csVersionInputOriginal >= '020440')
                    return false
             }
             else
                return false
        }
        
        return true
    }

    // ID: IF275; NAME: Obsolete Codes - CS Mets Eval (CS)
    public boolean if275(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csMetsEval == null || line.dateOfDiagnosisYear == null || line.csVersionInputOriginal == null)
             return true
        
        if (line._csSchemaId == null)
            return false
        
        String code = functions.getCsObsoleteReason(line, 'csMetsEval', line.csMetsEval)
        
        if (code != null) {
             if (code == '1' || code == '5' || code == '6' || code == '7' || code == '16' || code == '18') {
                 if (line.dateOfDiagnosisYear >= '2010')
                    return false
                 if (line.csVersionInputOriginal >= '020100')
                    return false
             }
             else if (code == '13' || code == '14' || code == '15') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020300')
                    return false
             }
             else if (code == '17') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020200')
                    return false
             }
             else if (code == '21' || code == '22') {
                 if (line.dateOfDiagnosisYear >= '2012')
                    return false
                 if (line.csVersionInputOriginal >= '020440')
                    return false
             }
             else
                return false
        }
        
        return true
    }

    // ID: IF276; NAME: Obsolete Codes - CS Site-Specific Factor 1 (CS)
    public boolean if276(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor1 == null || line.dateOfDiagnosisYear == null || line.csVersionInputOriginal == null)
             return true
        
        if (line._csSchemaId == null)
            return false
        
        String code = functions.getCsObsoleteReason(line, 'csSiteSpecificFactor1', line.csSiteSpecificFactor1)
        
        if (code != null) {
             if (code == '1' || code == '5' || code == '6' || code == '7' || code == '16' || code == '18') {
                 if (line.dateOfDiagnosisYear >= '2010')
                    return false
                 if (line.csVersionInputOriginal >= '020100')
                    return false
             }
             else if (code == '13' || code == '14' || code == '15') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020300')
                    return false
             }
             else if (code == '17') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020200')
                    return false
             }
             else if (code == '21' || code == '22') {
                 if (line.dateOfDiagnosisYear >= '2012')
                    return false
                 if (line.csVersionInputOriginal >= '020440')
                    return false
             }
             else
                return false
        }
        
        return true
    }

    // ID: IF277; NAME: Obsolete Codes - CS Site-Specific Factor 2 (CS)
    public boolean if277(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor2 == null || line.dateOfDiagnosisYear == null ||
            line.csVersionInputOriginal == null || line._csSchemaId == 'melanoma_iris')
             return true
        
        if (line._csSchemaId == null)
            return false
        
        String code = functions.getCsObsoleteReason(line, 'csSiteSpecificFactor2', line.csSiteSpecificFactor2)
        
        if (code != null) {
             if (code == '1' || code == '5' || code == '6' || code == '7' || code == '16' || code == '18') {
                 if (line.dateOfDiagnosisYear >= '2010')
                    return false
                 if (line.csVersionInputOriginal >= '020100')
                    return false
             }
             else if (code == '13' || code == '14' || code == '15') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020300')
                    return false
             }
             else if (code == '17') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020200')
                    return false
             }
             else if (code == '21' || code == '22') {
                 if (line.dateOfDiagnosisYear >= '2012')
                    return false
                 if (line.csVersionInputOriginal >= '020440')
                    return false
             }
             else
                return false
        }
        
        return true
    }

    // ID: IF278; NAME: Obsolete Codes - CS Site-Specific Factor 3 (CS)
    public boolean if278(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor3 == null || line.dateOfDiagnosisYear == null || line.csVersionInputOriginal == null)
             return true
        
        if (line._csSchemaId == null)
            return false
        
        String code = functions.getCsObsoleteReason(line, 'csSiteSpecificFactor3', line.csSiteSpecificFactor3)
        
        if (code != null) {
             if (code == '1' || code == '5' || code == '6' || code == '7' || code == '16' || code == '18') {
                 if (line.dateOfDiagnosisYear >= '2010')
                    return false
                 if (line.csVersionInputOriginal >= '020100')
                    return false
             }
             else if (code == '13' || code == '14' || code == '15') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020300')
                    return false
             }
             else if (code == '17') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020200')
                    return false
             }
             else if (code == '21' || code == '22') {
                 if (line.dateOfDiagnosisYear >= '2012')
                    return false
                 if (line.csVersionInputOriginal >= '020440')
                    return false
             }
             else
                return false
        }
        
        return true
    }

    // ID: IF279; NAME: Obsolete Codes - CS Site-Specific Factor 4 (CS)
    public boolean if279(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor4 == null || line.dateOfDiagnosisYear == null || line.csVersionInputOriginal == null)
             return true
        
        if (line._csSchemaId == null)
            return false
        
        String code = functions.getCsObsoleteReason(line, 'csSiteSpecificFactor4', line.csSiteSpecificFactor4)
        
        if (code != null) {
             if (code == '1' || code == '5' || code == '6' || code == '7' || code == '16' || code == '18') {
                 if (line.dateOfDiagnosisYear >= '2010')
                    return false
                 if (line.csVersionInputOriginal >= '020100')
                    return false
             }
             else if (code == '13' || code == '14' || code == '15') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020300')
                    return false
             }
             else if (code == '17') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020200')
                    return false
             }
             else if (code == '21' || code == '22') {
                 if (line.dateOfDiagnosisYear >= '2012')
                    return false
                 if (line.csVersionInputOriginal >= '020440')
                    return false
             }
             else
                return false
        }
        
        return true
    }

    // ID: IF280; NAME: Obsolete Codes - CS Site-Specific Factor 5 (CS)
    public boolean if280(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor5 == null || line.dateOfDiagnosisYear == null || line.csVersionInputOriginal == null)
             return true
        
        if (line._csSchemaId == null)
            return false
        
        String code = functions.getCsObsoleteReason(line, 'csSiteSpecificFactor5', line.csSiteSpecificFactor5)
        
        if (code != null) {
             if (code == '1' || code == '5' || code == '6' || code == '7' || code == '16' || code == '18') {
                 if (line.dateOfDiagnosisYear >= '2010')
                    return false
                 if (line.csVersionInputOriginal >= '020100')
                    return false
             }
             else if (code == '13' || code == '14' || code == '15') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020300')
                    return false
             }
             else if (code == '17') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020200')
                    return false
             }
             else if (code == '21' || code == '22') {
                 if (line.dateOfDiagnosisYear >= '2012')
                    return false
                 if (line.csVersionInputOriginal >= '020440')
                    return false
             }
             else
                return false
        }
        
        return true
    }

    // ID: IF281; NAME: Obsolete Codes - CS Site-Specific Factor 6 (CS)
    public boolean if281(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor6 == null || line.dateOfDiagnosisYear == null || line.csVersionInputOriginal == null)
             return true
        
        if (line._csSchemaId == null)
            return false
        
        String code = functions.getCsObsoleteReason(line, 'csSiteSpecificFactor6', line.csSiteSpecificFactor6)
        
        if (code != null) {
             if (code == '1' || code == '5' || code == '6' || code == '7' || code == '16' || code == '18') {
                 if (line.dateOfDiagnosisYear >= '2010')
                    return false
                 if (line.csVersionInputOriginal >= '020100')
                    return false
             }
             else if (code == '13' || code == '14' || code == '15') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020300')
                    return false
             }
             else if (code == '17') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020200')
                    return false
             }
             else if (code == '21' || code == '22') {
                 if (line.dateOfDiagnosisYear >= '2012')
                    return false
                 if (line.csVersionInputOriginal >= '020440')
                    return false
             }
             else
                return false
        }
        
        return true
    }

    // ID: IF282; NAME: Obsolete Codes - CS Site-Specific Factor25 (CS)
    public boolean if282(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor25 == null || line.dateOfDiagnosisYear == null || line.csVersionInputOriginal == null)
             return true
        
        if (line._csSchemaId == null)
            return false
        
        String code = functions.getCsObsoleteReason(line, 'csSiteSpecificFactor25', line.csSiteSpecificFactor25)
        
        if (code != null) {
             if (code == '1' || code == '5' || code == '6' || code == '7' || code == '16' || code == '18') {
                 if (line.dateOfDiagnosisYear >= '2010')
                    return false
                 if (line.csVersionInputOriginal >= '020100')
                    return false
             }
             else if (code == '13' || code == '14' || code == '15') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020300')
                    return false
             }
             else if (code == '17') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020200')
                    return false
             }
             else if (code == '21' || code == '22') {
                 if (line.dateOfDiagnosisYear >= '2012')
                    return false
                 if (line.csVersionInputOriginal >= '020440')
                    return false
             }
             else
                return false
        }
        
        return true
    }

    // ID: IF283; NAME: CS Mets at DX-Bone, CS Mets at DX (CS)
    public boolean if283(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csMetsAtDx == null || line.csMetsAtDxBone == null || line._csSchemaId == null)
            return true
        
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
           return true
        
        if (line.csMetsAtDxBone == '1' && (line.csMetsAtDx == '00' || line.csMetsAtDx == '99'))
            return false
        
        if (line.csMetsAtDx == '00' && line.csMetsAtDxBone != '0')
            return false
        
        if (line.csMetsAtDx == '98' && line._csSchemaId != 'ill_defined_other' && line.csMetsAtDxBone != '8')
            return false
        
        return true
    }

    // ID: IF284; NAME: CS Mets at DX-Brain, CS Mets at DX (CS)
    public boolean if284(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csMetsAtDx == null || line.csMetsAtDxBrain == null || line._csSchemaId == null)
            return true
        
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
           return true
        
        if (line.csMetsAtDxBrain == '1' && (line.csMetsAtDx == '00' || line.csMetsAtDx == '99'))
            return false
        
        if (line.csMetsAtDx == '00' && line.csMetsAtDxBrain != '0')
            return false
        
        if (line.csMetsAtDx == '98' && line._csSchemaId != 'ill_defined_other' && line.csMetsAtDxBrain != '8')
            return false
        
        return true
    }

    // ID: IF285; NAME: CS Mets at DX-Liver, CS Mets at DX (CS)
    public boolean if285(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csMetsAtDx == null || line.csMetsAtDxLiver == null || line._csSchemaId == null)
            return true
        
        // this condition is missing from the description, but the metafile contains it...
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
           return true
        
        if (line.csMetsAtDxLiver == '1' && (line.csMetsAtDx == '00' || line.csMetsAtDx == '99'))
            return false
        
        if (line.csMetsAtDx == '00' && line.csMetsAtDxLiver != '0')
            return false
        
        if (line.csMetsAtDx == '98' && line._csSchemaId != 'ill_defined_other' && line.csMetsAtDxLiver != '8')
            return false
        
        return true
    }

    // ID: IF286; NAME: CS Mets at DX-Lung, CS Mets at DX (CS)
    public boolean if286(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csMetsAtDx == null || line.csMetsAtDxLung == null || line._csSchemaId == null)
            return true
        
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland')
           return true
        
        if (line.csMetsAtDxLung == '1' && (line.csMetsAtDx == '00' || line.csMetsAtDx == '99'))
            return false
        
        if (line.csMetsAtDx == '00' && line.csMetsAtDxLung != '0')
            return false
        
        if (line.csMetsAtDx == '98' && line._csSchemaId != 'ill_defined_other' && line.csMetsAtDxLung != '8')
            return false
        
        return true
    }

    // ID: IF287; NAME: CS SSF 6, RX Summ--Surg, ColoRectal (CS)
    public boolean if287(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor6 == null || line.csSiteSpecificFactor6 == '988' || line.rxSummSurgPrimSite == null
               || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'colon' || line._csSchemaId == 'rectum') {
            Integer ssf6 = functions.asInt(line.csSiteSpecificFactor6)
            Integer csVersion = functions.asInt(line.csVersionInputOriginal)
            Integer rxSummSurgPrimSite = functions.asInt(line.rxSummSurgPrimSite)
            if (line.csVersionInputOriginal != null && csVersion < 20500) {
                if (rxSummSurgPrimSite == 0 && ssf6 != 998)
                    return false
            }
            else if (csVersion >= 20500 || line.dateOfDiagnosisYear > '2015') {
                if (rxSummSurgPrimSite >= 0 && rxSummSurgPrimSite <= 29 && ssf6 != 998 && ssf6 != 999)
                    return false
            }
            if (rxSummSurgPrimSite == 99 && ssf6 != 999)
                return false
            if ((ssf6 >= 0 && ssf6 <= 981) || (ssf6 >= 990 && ssf6 <= 996))
                return rxSummSurgPrimSite != 0 && rxSummSurgPrimSite != 99
        }
        
        return true
    }

    // ID: IF288; NAME: CS Items - SEER Required - SSF 1 (CS)
    public boolean if288(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || (line.csVersionInputCurrent == null && line.dateOfDiagnosisYear < '2016') ||
             (line.csVersionInputOriginal == null && line.dateOfDiagnosisYear < '2016') || line._csSchemaId == null)
            return true
        if (functions.matches(line.registryId, /^000000156[2356]$/))
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !['brain','intracranial_gland','cns_other'].contains(line._csSchemaId))
            return true
        
        // condition 1
        if (line.dateOfDiagnosisYear >= '2004' && line.dateOfDiagnosisYear <= '2017' && line.csSiteSpecificFactor1 == null)
            return false
        
        Integer csInputOrig = functions.asInt(line.csVersionInputOriginal)
        Integer csInputCurr = functions.asInt(line.csVersionInputCurrent)
        Integer yearDx = functions.asInt(line.dateOfDiagnosisYear)
        String schemaMatch = ((List)((Map)context.CS_SSF).get(line._csSchemaId))?.get(0)//ssf1
        
        // R = Required, N = Not required after CSv0204
        if (!['N','R'].contains(schemaMatch))
            return true
        
        // condition 2
        if (yearDx > 2015 && line.csExtension == null) {
            if (schemaMatch == 'R')
                if (!['retinoblastoma', 'esophagus', 'esophagus_gejunction', 'net_stomach', 'stomach'].contains(line._csSchemaId))
                    return line.csSiteSpecificFactor1 != '988'
        
            return true
        }
        
        // condition 3
        if ((yearDx >= 2014 && yearDx <= 2015) || ((yearDx == 2016 || yearDx == 2017) && line.csExtension != null) || (yearDx >= 2004 && yearDx <= 2015 && csInputOrig >= 20550)) {
            if (schemaMatch == 'R' && line.csSiteSpecificFactor1 == '988')
                return false
        
            return true
        }
        
        // condition 4
        if ((yearDx >= 2010 && yearDx <= 2013) || csInputOrig >= 20001) {
            if (line.csSiteSpecificFactor1 == '988')
                return false
        
             return true
        }
        
        //  condition 5
        if (yearDx > 2003 && yearDx < 2010 && csInputOrig < 20000) {
            if (csInputCurr == 20510) {
                if (((List)context.IF288_Schemas_1).contains(line._csSchemaId)) {
                    if (line.csSiteSpecificFactor1 != '988')
                        return false
                    return true
                }
                else {
                    if (['stomach','esophagus_gejunction','net_stomach'].contains(line._csSchemaId))
                        return true
                }
                if (line.csSiteSpecificFactor1 == '988')
                    return false
            }
            else if (csInputCurr > 20510) {
                if (((List)context.IF288_Schemas_1).contains(line._csSchemaId) || ['stomach','esophagus_gejunction','net_stomach'].contains(line._csSchemaId))
                    return true
                if (line.csSiteSpecificFactor1 == '988')
                    return false
            }
        }
        
        return true
    }

    // ID: IF289; NAME: CS Items - SEER Required - SSF 2 (CS)
    public boolean if289(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || (line.csVersionInputCurrent == null && line.dateOfDiagnosisYear < '2016') ||
             (line.csVersionInputOriginal == null && line.dateOfDiagnosisYear < '2016') || line._csSchemaId == null)
            return true
        if (functions.matches(line.registryId, /^000000156[2356]$/))
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !['brain','intracranial_gland','cns_other'].contains(line._csSchemaId))
            return true
        
        // condition 1
        if (line.dateOfDiagnosisYear >= '2004' && line.dateOfDiagnosisYear <= '2017' && line.csSiteSpecificFactor2 == null)
            return false
        
        Integer csInputOrig = functions.asInt(line.csVersionInputOriginal)
        Integer csInputCurr = functions.asInt(line.csVersionInputCurrent)
        Integer yearDx = functions.asInt(line.dateOfDiagnosisYear)
        String schemaMatch = ((List)((Map)context.CS_SSF).get(line._csSchemaId))?.get(1)//ssf2
        
        // R = Required, N = Not required after CSv0204
        if (!['N','R'].contains(schemaMatch))
            return true
        
        // condition 2
        if (yearDx > 2015 && line.csExtension == null) {
            if (schemaMatch == 'R') {
                if (!['appendix','carcinoid_appendix','colon','net_colon','net_rectum','rectum','small_intestine'].contains(line._csSchemaId))
                    return line.csSiteSpecificFactor2 != '988'
            }
        
            return true
        }
        
        // condition 3
        if ((yearDx >= 2014 && yearDx <= 2015) || ((yearDx == 2016 || yearDx == 2017) && line.csExtension != null) || (yearDx >= 2004 && yearDx <= 2015 && csInputOrig >= 20550)) {
            if (schemaMatch == 'R' && line.csSiteSpecificFactor2 == '988')
                return false
        
            return true
        }
        
        // condition 4
        if ((yearDx >= 2011 && yearDx <= 2013) ||
             csInputOrig >= 20302) {
        
            if (line.csSiteSpecificFactor2 == '988')
                return false
        
             return true
        }
        
        // skip if schema is MyelomaPlasmaCellDisorder
        if (line._csSchemaId == 'myeloma_plasma_cell_disorder')
            return true
        
        // condition 5
        if (yearDx == 2010 || functions.matches(line.csVersionInputOriginal, /(^0201\d\d$)/) || functions.matches(line.csVersionInputOriginal, /(^0202\d\d$)/)) {
            if (line.csSiteSpecificFactor2 == '988')
                return false
        }
        
        // condition 6
        if (yearDx > 2003 && yearDx < 2010 && csInputOrig < 20000) {
            if (csInputCurr == 20510) {
                if (((List)context.IF289_Schemas_1).contains(line._csSchemaId)) {
                    if (line.csSiteSpecificFactor2 != '988')
                        return false
                    return true
                }
                else {
                    if (['appendix','carcinoid_appendix','net_colon','colon','net_rectum','rectum'].contains(line._csSchemaId))
                        return true
                }
                if (line.csSiteSpecificFactor2 == '988')
                    return false
            }
            else if (csInputCurr > 20510) {
                if (((List)context.IF289_Schemas_1).contains(line._csSchemaId) || ['appendix','carcinoid_appendix','net_colon','colon','net_rectum','rectum'].contains(line._csSchemaId))
                    return true
                if (line.csSiteSpecificFactor2 == '988')
                    return false
            }
        }
        
        return true
    }

    // ID: IF290; NAME: CS Items - SEER Required - SSF 3 (CS)
    public boolean if290(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || (line.csVersionInputCurrent == null && line.dateOfDiagnosisYear < '2016') ||
             (line.csVersionInputOriginal == null && line.dateOfDiagnosisYear < '2016') || line._csSchemaId == null)
            return true
        if (functions.matches(line.registryId, /^000000156[2356]$/))
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !['brain','intracranial_gland','cns_other'].contains(line._csSchemaId))
            return true
        
        // condition 1
        if (line.dateOfDiagnosisYear >= '2004' && line.dateOfDiagnosisYear <= '2017' && line.csSiteSpecificFactor3 == null)
            return false
        
        Integer csInputOrig = functions.asInt(line.csVersionInputOriginal)
        Integer csInputCurr = functions.asInt(line.csVersionInputCurrent)
        Integer yearDx = functions.asInt(line.dateOfDiagnosisYear)
        String schemaMatch = ((List)((Map)context.CS_SSF).get(line._csSchemaId))?.get(2)//ssf3
        
        // R = Required, N = Not required after CSv0204
        if (!['N','R'].contains(schemaMatch))
            return true
        
        // condition 2
        if (yearDx > 2015 && line.csExtension == null) {
            if (schemaMatch == 'R') {
                if (!['lacrimal_gland','melanoma_skin','merkel_cell_penis','merkel_cell_scrotum','merkel_cell_skin','merkel_cell_vulva','prostate','skin_eyelid'].contains(line._csSchemaId))
                    return line.csSiteSpecificFactor3 != '988'
            }
        
            return true
        }
        
        // condition 3
        if ((yearDx >= 2014 && yearDx <= 2015) || ((yearDx == 2016 || yearDx == 2017) && line.csExtension != null) || (yearDx >= 2004 && yearDx <= 2015 && csInputOrig >= 20550)) {
            if (schemaMatch == 'R' && line.csSiteSpecificFactor3 == '988')
                return false
        
            return true
        }
        
        // condition 4
        if ((yearDx >= 2011 && yearDx <= 2013) ||csInputOrig >= 20302) {
            if (line.csSiteSpecificFactor3 == '988')
                return false
        
             return true
        }
        
        
        // skip if schema is MyelomaPlasmaCellDisorder
        if (line._csSchemaId == 'myeloma_plasma_cell_disorder')
            return true
        
        // condition 5
        if (yearDx == 2010 || functions.matches(line.csVersionInputOriginal, /(^0201\d\d$)/) || functions.matches(line.csVersionInputOriginal, /(^0202\d\d$)/)) {
            if (line.csSiteSpecificFactor3 == '988')
                return false
        }
        
        // condition 6
        if (yearDx > 2003 && yearDx < 2010 && csInputOrig < 20000) {
            if (csInputCurr == 20510) {
                if (((List)context.IF290_Schemas_1).contains(line._csSchemaId)) {
                    if (line.csSiteSpecificFactor3 != '988')
                        return false
                    return true
                }
                if (line.csSiteSpecificFactor3 == '988')
                    return false
            }
            else if (csInputCurr > 20510) {
                if (((List)context.IF290_Schemas_1).contains(line._csSchemaId))
                    return true
                if (line.csSiteSpecificFactor3 == '988')
                    return false
            }
        }
        
        return true
    }

    // ID: IF291; NAME: CS Items - SEER Required - SSF 4 (CS)
    public boolean if291(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || (line.csVersionInputCurrent == null && line.dateOfDiagnosisYear < '2016') ||
             (line.csVersionInputOriginal == null && line.dateOfDiagnosisYear < '2016') || line._csSchemaId == null)
            return true
        if (functions.matches(line.registryId, /^000000156[2356]$/))
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !['brain','intracranial_gland','cns_other'].contains(line._csSchemaId))
            return true
        
        // condition 1
        if (line.dateOfDiagnosisYear >= '2004' && line.dateOfDiagnosisYear <= '2017' && line.csSiteSpecificFactor4 == null)
            return false
        
        Integer csInputOrig = functions.asInt(line.csVersionInputOriginal)
        Integer csInputCurr = functions.asInt(line.csVersionInputCurrent)
        Integer yearDx = functions.asInt(line.dateOfDiagnosisYear)
        String schemaMatch = ((List)((Map)context.CS_SSF).get(line._csSchemaId))?.get(3)//ssf4
        
        // condition 2
        if (yearDx >= 2004 && yearDx <= 2009 && line._csSchemaId == 'prostate') {
            if (line.csSiteSpecificFactor4 == '988')
                return false
            return true
        }
        
        // R = Required, N = Not required after CSv0204
        if (!['N','R'].contains(schemaMatch))
            return true
        
        // condition 3
        if (yearDx >= 2014 || csInputOrig >= 20550) {
            if (schemaMatch == 'R' && line.csSiteSpecificFactor4 == '988')
                return false
        
            return true
        }
        
        // condition 4
        if ((yearDx >= 2010 && yearDx <= 2013) || (csInputOrig >= 20001 && csInputOrig < 20550)) {
            if (line.csSiteSpecificFactor4 == '988')
                return false
        
             return true
        }
        
        // condition 5
        if (yearDx > 2003 && yearDx < 2010 && csInputOrig < 20000) {
            if (csInputCurr == 20510) {
                if (((List)context.IF291_Schemas_1).contains(line._csSchemaId)) {
                    if (line.csSiteSpecificFactor4 != '988')
                        return false
                    return true
                }
                if (line.csSiteSpecificFactor4 == '988')
                    return false
            }
            else if (csInputCurr > 20510) {
                if (((List)context.IF291_Schemas_1).contains(line._csSchemaId))
                    return true
                if (line.csSiteSpecificFactor4 == '988')
                    return false
            }
        }
        
        return true
    }

    // ID: IF292; NAME: CS Items - SEER Required - SSF 5 (CS)
    public boolean if292(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || (line.csVersionInputCurrent == null && line.dateOfDiagnosisYear < '2016') ||
             (line.csVersionInputOriginal == null && line.dateOfDiagnosisYear < '2016') || line._csSchemaId == null)
            return true
        if (functions.matches(line.registryId, /^000000156[2356]$/))
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !['brain','intracranial_gland','cns_other'].contains(line._csSchemaId))
            return true
        
        // condition 1
        if (line.dateOfDiagnosisYear >= '2004' && line.dateOfDiagnosisYear <= '2017' && line.csSiteSpecificFactor5 == null)
            return false
        
        Integer csInputOrig = functions.asInt(line.csVersionInputOriginal)
        Integer csInputCurr = functions.asInt(line.csVersionInputCurrent)
        Integer yearDx = functions.asInt(line.dateOfDiagnosisYear)
        String schemaMatch =((List)((Map) context.CS_SSF).get(line._csSchemaId))?.get(4)//ssf5
        
        // R = Required, N = Not required after CSv0204
        if (!['N','R'].contains(schemaMatch))
            return true
        
        // condition 2
        if (yearDx >= 2014 || csInputOrig >= 20550) {
            if (schemaMatch == 'R' && line.csSiteSpecificFactor5 == '988')
                return false
        
            return true
        }
        
        // condition 3
        if ((yearDx >= 2010 && yearDx <= 2013) || (csInputOrig >= 20001 && csInputOrig < 20550)) {
            if (line.csSiteSpecificFactor5 == '988')
                return false
        
             return true
        }
        
        // condition 4
        if (yearDx > 2003 && yearDx < 2010 && csInputOrig < 20000) {
            if (csInputCurr == 20510) {
                if (((List)context.IF292_Schemas_1).contains(line._csSchemaId)) {
                    if (line.csSiteSpecificFactor5 != '988')
                        return false
                    return true
                }
                if (line.csSiteSpecificFactor5 == '988')
                    return false
            }
            else if (csInputCurr > 20510) {
                if (((List)context.IF292_Schemas_1).contains(line._csSchemaId))
                    return true
                if (line.csSiteSpecificFactor5 == '988')
                    return false
            }
        }
        
        return true
    }

    // ID: IF293; NAME: CS Items - SEER Required - SSF 6 (CS)
    public boolean if293(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || (line.csVersionInputCurrent == null && line.dateOfDiagnosisYear < '2016') ||
             (line.csVersionInputOriginal == null && line.dateOfDiagnosisYear < '2016') || line._csSchemaId == null)
            return true
        if (functions.matches(line.registryId, /^000000156[2356]$/))
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !['brain','intracranial_gland','cns_other'].contains(line._csSchemaId))
            return true
        
        // condition 1
        if (line.dateOfDiagnosisYear >= '2004' && line.dateOfDiagnosisYear <= '2017' && line.csSiteSpecificFactor6 == null)
            return false
        
        Integer csInputOrig = functions.asInt(line.csVersionInputOriginal)
        Integer csInputCurr = functions.asInt(line.csVersionInputCurrent)
        Integer yearDx = functions.asInt(line.dateOfDiagnosisYear)
        String schemaMatch = ((List)((Map)context.CS_SSF).get(line._csSchemaId))?.get(5)//ssf6
        
        // R = Required, N = Not required after CSv0204
        if (!['N','R'].contains(schemaMatch))
            return true
        
        // condition 2
        if (yearDx >= 2014 || csInputOrig >= 20550) {
            if (schemaMatch == 'R' && line.csSiteSpecificFactor6 == '988')
                return false
        
            return true
        }
        
        // condition 3
        if ((yearDx >= 2010 && yearDx <= 2013) || (csInputOrig >= 20001 && csInputOrig < 20550)) {
            if (line.csSiteSpecificFactor6 == '988')
                return false
        
             return true
        }
        
        // condition 4
        if (yearDx > 2003 && yearDx < 2010 && csInputOrig < 20000) {
            if (csInputCurr == 20510) {
                if (((List)context.IF293_Schemas_1).contains(line._csSchemaId)) {
                    if (line.csSiteSpecificFactor6 != '988')
                        return false
                    return true
                }
                if (line.csSiteSpecificFactor6 == '988')
                    return false
            }
            else if (csInputCurr > 20510) {
                if (((List)context.IF293_Schemas_1).contains(line._csSchemaId))
                    return true
                if (line.csSiteSpecificFactor6 == '988')
                    return false
            }
        }
        
        return true
    }

    // ID: IF294; NAME: CS Items - SEER Required - SSF 7 (CS)
    public boolean if294(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || (line.csVersionInputCurrent == null && line.dateOfDiagnosisYear < '2016') ||
             (line.csVersionInputOriginal == null && line.dateOfDiagnosisYear < '2016') || line._csSchemaId == null)
            return true
        if (functions.matches(line.registryId, /^000000156[2356]$/))
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !['brain','intracranial_gland','cns_other'].contains(line._csSchemaId))
            return true
        
        // condition 1
        if (line.dateOfDiagnosisYear >= '2004' && line.dateOfDiagnosisYear <= '2017' && line.csSiteSpecificFactor7 == null)
            return false
        
        Integer csInputOrig = functions.asInt(line.csVersionInputOriginal)
        Integer csInputCurr = functions.asInt(line.csVersionInputCurrent)
        Integer yearDx = functions.asInt(line.dateOfDiagnosisYear)
        String schemaMatch = ((List)((Map)context.CS_SSF).get(line._csSchemaId))?.get(6)//ssf7
        
        // R = Required, N = Not required after CSv0204
        if (!['N','R'].contains(schemaMatch))
            return true
        
        // condition 2
        if (yearDx >= 2014 || csInputOrig >= 20550) {
            if (schemaMatch == 'R' && line.csSiteSpecificFactor7 == '988')
                return false
        
            return true
        }
        
        // condition 3
        if ((yearDx >= 2010 && yearDx <= 2013) || (csInputOrig >= 20001 && csInputOrig < 20550)) {
            if (line.csSiteSpecificFactor7 == '988')
                return false
        
             return true
        }
        
        // condition 4
        if (yearDx > 2003 && yearDx < 2010 && csInputOrig < 20000) {
            if (csInputCurr == 20510) {
               if (line.csSiteSpecificFactor7 != '988')
                   return false
            }
        }
        
        return true
    }

    // ID: IF295; NAME: CS Items - SEER Required - SSF 8 (CS)
    public boolean if295(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || (line.csVersionInputCurrent == null && line.dateOfDiagnosisYear < '2016') ||
             (line.csVersionInputOriginal == null && line.dateOfDiagnosisYear < '2016') || line._csSchemaId == null)
            return true
        if (functions.matches(line.registryId, /^000000156[2356]$/))
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !['brain','intracranial_gland','cns_other'].contains(line._csSchemaId))
            return true
        
        // condition 1
        if (line.dateOfDiagnosisYear >= '2004' && line.dateOfDiagnosisYear <= '2017' && line.csSiteSpecificFactor8 == null)
            return false
        
        Integer csInputOrig = functions.asInt(line.csVersionInputOriginal)
        Integer csInputCurr = functions.asInt(line.csVersionInputCurrent)
        Integer yearDx = functions.asInt(line.dateOfDiagnosisYear)
        String schemaMatch = ((List)((Map)context.CS_SSF).get(line._csSchemaId))?.get(7)//ssf8
        
        // R = Required, N = Not required after CSv0204
        if (!['N','R'].contains(schemaMatch))
            return true
        
        // condition 2
        if (yearDx >= 2014 || csInputOrig >= 20550) {
            if (schemaMatch == 'R' && line.csSiteSpecificFactor8 == '988')
                return false
        
            return true
        }
        
        // condition 3
        if ((yearDx >= 2010 && yearDx <= 2013) || (csInputOrig >= 20001 && csInputOrig < 20550)) {
            if (line.csSiteSpecificFactor8 == '988')
                return false
        
             return true
        }
        
        // condition 4
        if (yearDx > 2003 && yearDx < 2010 && csInputOrig < 20000) {
            if (csInputCurr == 20510) {
               if (line.csSiteSpecificFactor8 != '988')
                   return false
            }
        }
        
        return true
    }

    // ID: IF296; NAME: CS Items - SEER Required - SSF 9 (CS)
    public boolean if296(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || (line.csVersionInputCurrent == null && line.dateOfDiagnosisYear < '2016') ||
             (line.csVersionInputOriginal == null && line.dateOfDiagnosisYear < '2016') || line._csSchemaId == null)
            return true
        if (functions.matches(line.registryId, /^000000156[2356]$/))
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !['brain','intracranial_gland','cns_other'].contains(line._csSchemaId))
            return true
        
        // condition 1
        if (line.dateOfDiagnosisYear >= '2004' && line.dateOfDiagnosisYear <= '2017' && line.csSiteSpecificFactor9 == null)
            return false
        
        Integer csInputOrig = functions.asInt(line.csVersionInputOriginal)
        Integer csInputCurr = functions.asInt(line.csVersionInputCurrent)
        Integer yearDx = functions.asInt(line.dateOfDiagnosisYear)
        String schemaMatch = ((List)((Map)context.CS_SSF).get(line._csSchemaId))?.get(8)//ssf9
        
        // R = Required, N = Not required after CSv0204
        if (!['N','R'].contains(schemaMatch))
            return true
        
        // condition 2
        if (yearDx >= 2014 || csInputOrig >= 20550) {
            if (schemaMatch == 'R' && line.csSiteSpecificFactor9 == '988')
                return false
        
            return true
        }
        
        // condition 3
        if ((yearDx >= 2010 && yearDx <= 2013) || (csInputOrig >= 20001 && csInputOrig < 20550)) {
            if (line.csSiteSpecificFactor9 == '988')
                return false
        
             return true
        }
        
        // condition 4
        if (yearDx > 2003 && yearDx < 2010 && csInputOrig < 20000) {
            if (csInputCurr == 20510 && line._csSchemaId != 'breast') {
               if (line.csSiteSpecificFactor9 != '988')
                   return false
            }
        }
        
        return true
    }

    // ID: IF297; NAME: CS Items - SEER Required - SSF 10 (CS)
    public boolean if297(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || (line.csVersionInputCurrent == null && line.dateOfDiagnosisYear < '2016') ||
             (line.csVersionInputOriginal == null && line.dateOfDiagnosisYear < '2016') || line._csSchemaId == null)
            return true
        if (functions.matches(line.registryId, /^000000156[2356]$/))
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !['brain','intracranial_gland','cns_other'].contains(line._csSchemaId))
            return true
        
        // condition 1
        if (line.dateOfDiagnosisYear >= '2004' && line.dateOfDiagnosisYear <= '2017' && line.csSiteSpecificFactor10 == null)
            return false
        
        Integer csInputOrig = functions.asInt(line.csVersionInputOriginal)
        Integer csInputCurr = functions.asInt(line.csVersionInputCurrent)
        Integer yearDx = functions.asInt(line.dateOfDiagnosisYear)
        String schemaMatch = ((List)((Map)context.CS_SSF).get(line._csSchemaId))?.get(9)//ssf10
        
        // R = Required, N = Not required after CSv0204
        if (!['N','R'].contains(schemaMatch))
            return true
        
        // condition 2
        if (yearDx > 2015 && line.csExtension == null) {
            if (schemaMatch == 'R') {
                if (line._csSchemaId != 'bile_ducts_intrahepat')
                    return line.csSiteSpecificFactor10 != '988'
            }
        
            return true
        }
        
        // condition 3
        if ((yearDx >= 2014 && yearDx <= 2015) || ((yearDx == 2016 || yearDx == 2017) && line.csExtension != null) || (yearDx >= 2004 && yearDx <= 2015 && csInputOrig >= 20550)) {
            if (schemaMatch == 'R' && line.csSiteSpecificFactor10 == '988')
                return false
        
            return true
        }
        
        // condition 4
        if ((yearDx >= 2011 && yearDx <= 2013) || (csInputOrig >= 20001 && csInputOrig < 20550)) {
            if (line.csSiteSpecificFactor10 == '988')
                return false
        
             return true
        }
        
        // condition 5
        if (yearDx == 2010 || functions.matches(line.csVersionInputOriginal, /(^0201\d\d$)/) || functions.matches(line.csVersionInputOriginal, /(^0202\d\d$)/)) {
             if (line._csSchemaId == 'bile_ducts_intrahepat')
                return true
        
             if (line.csSiteSpecificFactor10 == '988')
                return false
        }
        
        // condition 6
        if (yearDx > 2003 && yearDx < 2010 && csInputOrig < 20000) {
            if (csInputCurr == 20510) {
               if (line.csSiteSpecificFactor10 != '988')
                   return false
            }
        }
        
        return true
    }

    // ID: IF298; NAME: CS Items - SEER Required - SSF 11 (CS)
    public boolean if298(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || (line.csVersionInputCurrent == null && line.dateOfDiagnosisYear < '2016') ||
             (line.csVersionInputOriginal == null && line.dateOfDiagnosisYear < '2016') || line._csSchemaId == null)
            return true
        if (functions.matches(line.registryId, /^000000156[2356]$/))
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !['brain','intracranial_gland','cns_other'].contains(line._csSchemaId))
            return true
        
        // condition 1
        if (line.dateOfDiagnosisYear >= '2004' && line.dateOfDiagnosisYear <= '2017' && line.csSiteSpecificFactor11 == null)
            return false
        
        Integer csInputOrig = functions.asInt(line.csVersionInputOriginal)
        Integer csInputCurr = functions.asInt(line.csVersionInputCurrent)
        Integer yearDx = functions.asInt(line.dateOfDiagnosisYear)
        String schemaMatch = ((List)((Map)context.CS_SSF).get(line._csSchemaId))?.get(10)//ssf11
        
        // R = Required, N = Not required after CSv0204
        if (!['N','R'].contains(schemaMatch))
            return true
        
        // condition 2
        if (yearDx >= 2014 || csInputOrig >= 20550) {
            if (schemaMatch == 'R' && line.csSiteSpecificFactor11 == '988')
                return false
        
            return true
        }
        
        // condition 3
        if ((yearDx >= 2010 && yearDx <= 2013) || (csInputOrig >= 20001 && csInputOrig < 20550)) {
            if (line.csSiteSpecificFactor11 == '988')
                return false
        
             return true
        }
        
        // condition 4
        if (yearDx > 2003 && yearDx < 2010 && csInputOrig < 20000) {
            if (csInputCurr == 20510 && line._csSchemaId != 'breast') {
               if (line.csSiteSpecificFactor11 != '988')
                   return false
            }
        }
        
        return true
    }

    // ID: IF299; NAME: CS Items - SEER Required - SSF 12 (CS)
    public boolean if299(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || (line.csVersionInputCurrent == null && line.dateOfDiagnosisYear < '2016') ||
             (line.csVersionInputOriginal == null && line.dateOfDiagnosisYear < '2016') || line._csSchemaId == null)
            return true
        if (functions.matches(line.registryId, /^000000156[2356]$/))
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !['brain','intracranial_gland','cns_other'].contains(line._csSchemaId))
            return true
        
        // condition 1
        if (line.dateOfDiagnosisYear >= '2004' && line.dateOfDiagnosisYear <= '2017' && line.csSiteSpecificFactor12 == null)
            return false
        
        Integer csInputOrig = functions.asInt(line.csVersionInputOriginal)
        Integer csInputCurr = functions.asInt(line.csVersionInputCurrent)
        Integer yearDx = functions.asInt(line.dateOfDiagnosisYear)
        String schemaMatch = ((List)((Map)context.CS_SSF).get(line._csSchemaId))?.get(11)//ssf12
        
        // R = Required, N = Not required after CSv0204
        if (!['N','R'].contains(schemaMatch))
            return true
        
        // condition 2
        if (yearDx >= 2014 || csInputOrig >= 20550) {
            if (schemaMatch == 'R' && line.csSiteSpecificFactor12 == '988')
                return false
        
            return true
        }
        
        // condition 3
        if ((yearDx >= 2010 && yearDx <= 2013) || (csInputOrig >= 20001 && csInputOrig < 20550)) {
            if (line.csSiteSpecificFactor12 == '988')
                return false
        
             return true
        }
        
        // condition 4
        if (yearDx > 2003 && yearDx < 2010 && csInputOrig < 20000) {
            if (csInputCurr == 20510) {
               if (line.csSiteSpecificFactor12 != '988')
                   return false
            }
        }
        
        return true
    }

    // ID: IF300; NAME: CS Items - SEER Required - SSF 13 (CS)
    public boolean if300(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || (line.csVersionInputCurrent == null && line.dateOfDiagnosisYear < '2016') ||
             (line.csVersionInputOriginal == null && line.dateOfDiagnosisYear < '2016') || line._csSchemaId == null)
            return true
        if (functions.matches(line.registryId, /^000000156[2356]$/))
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !['brain','intracranial_gland','cns_other'].contains(line._csSchemaId))
            return true
        
        // condition 1
        if (line.dateOfDiagnosisYear >= '2004' && line.dateOfDiagnosisYear <= '2017' && line.csSiteSpecificFactor13 == null)
            return false
        
        Integer csInputOrig = functions.asInt(line.csVersionInputOriginal)
        Integer csInputCurr = functions.asInt(line.csVersionInputCurrent)
        Integer yearDx = functions.asInt(line.dateOfDiagnosisYear)
        String schemaMatch = ((List)((Map)context.CS_SSF).get(line._csSchemaId))?.get(12)//ssf13
        
        // R = Required, N = Not required after CSv0204
        if (!['N','R'].contains(schemaMatch))
            return true
        
        // condition 2
        if (yearDx >= 2014 || csInputOrig >= 20550) {
            if (schemaMatch == 'R' && line.csSiteSpecificFactor13 == '988')
                return false
        
            return true
        }
        
        // condition 3
        if ((yearDx >= 2010 && yearDx <= 2013) || (csInputOrig >= 20001 && csInputOrig < 20550)) {
        
            if (line.csSiteSpecificFactor13 == '988')
                return false
        
             return true
        }
        
        // condition 4
        if (yearDx > 2003 && yearDx < 2010 && csInputOrig < 20000) {
            if (csInputCurr == 20510) {
               if (line.csSiteSpecificFactor13 != '988')
                   return false
            }
        }
        
        return true
    }

    // ID: IF301; NAME: CS Items - SEER Required - SSF 14 (CS)
    public boolean if301(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || (line.csVersionInputCurrent == null && line.dateOfDiagnosisYear < '2016') ||
             (line.csVersionInputOriginal == null && line.dateOfDiagnosisYear < '2016') || line._csSchemaId == null)
            return true
        if (functions.matches(line.registryId, /^000000156[2356]$/))
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !['brain','intracranial_gland','cns_other'].contains(line._csSchemaId))
            return true
        
        // condition 1
        if (line.dateOfDiagnosisYear >= '2004' && line.dateOfDiagnosisYear <= '2017' && line.csSiteSpecificFactor14 == null)
            return false
        
        Integer csInputOrig = functions.asInt(line.csVersionInputOriginal)
        Integer csInputCurr = functions.asInt(line.csVersionInputCurrent)
        Integer yearDx = functions.asInt(line.dateOfDiagnosisYear)
        String schemaMatch = ((List)((Map)context.CS_SSF).get(line._csSchemaId))?.get(13)//ssf14
        
        // R = Required, N = Not required after CSv0204
        if (schemaMatch != 'R')
            return true
        
        // condition 2
        if (yearDx >= 2010 || csInputOrig >= 20001) {
            if (line.csSiteSpecificFactor14 == '988')
                return false
        
             return true
        }
        
        // condition 3
        if (yearDx > 2003 && yearDx < 2010 && csInputOrig < 20000) {
            if (csInputCurr == 20510 && line._csSchemaId != 'breast') {
               if (line.csSiteSpecificFactor14 != '988')
                   return false
            }
        }
        
        return true
    }

    // ID: IF302; NAME: CS Items - SEER Required - SSF 15 (CS)
    public boolean if302(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || (line.csVersionInputCurrent == null && line.dateOfDiagnosisYear < '2016') ||
             (line.csVersionInputOriginal == null && line.dateOfDiagnosisYear < '2016') || line._csSchemaId == null)
            return true
        if (functions.matches(line.registryId, /^000000156[2356]$/))
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !['brain','intracranial_gland','cns_other'].contains(line._csSchemaId))
            return true
        
        // condition 1
        if (line.dateOfDiagnosisYear >= '2004' && line.dateOfDiagnosisYear <= '2017' && line.csSiteSpecificFactor15 == null)
            return false
        
        Integer csInputOrig = functions.asInt(line.csVersionInputOriginal)
        Integer csInputCurr = functions.asInt(line.csVersionInputCurrent)
        Integer yearDx = functions.asInt(line.dateOfDiagnosisYear)
        String schemaMatch = ((List)((Map)context.CS_SSF).get(line._csSchemaId))?.get(14)//ssf15
        
        // R = Required, N = Not required after CSv0204
        if (schemaMatch != 'R')
            return true
        
        // condition 2
        if (yearDx >= 2011 || csInputOrig >= 20302) {
            if (line.csSiteSpecificFactor15 == '988')
                return false
        
            return true
        }
        
        // condition 3
        if (yearDx == 2010 ||
             line.csVersionInputOriginal.startsWith('0201') ||
             line.csVersionInputOriginal.startsWith('0202') ) {
        
            if (line._csSchemaId == 'breast')
                return true
        
            if (line.csSiteSpecificFactor15 == '988')
                return false
        
             return true
        }
        
        // condition 4
        if (yearDx > 2003 && yearDx < 2010 && csInputOrig < 20000) {
            if (csInputCurr == 20510 && line._csSchemaId != 'breast') {
               if (line.csSiteSpecificFactor15 != '988')
                   return false
            }
        }
        
        return true
    }

    // ID: IF303; NAME: CS Items - SEER Required - SSF 16 (CS)
    public boolean if303(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || (line.csVersionInputCurrent == null && line.dateOfDiagnosisYear < '2016') ||
             (line.csVersionInputOriginal == null && line.dateOfDiagnosisYear < '2016') || line._csSchemaId == null)
            return true
        if (functions.matches(line.registryId, /^000000156[2356]$/))
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !['brain','intracranial_gland','cns_other'].contains(line._csSchemaId))
            return true
        
        // condition 1
        if (line.dateOfDiagnosisYear >= '2004' && line.dateOfDiagnosisYear <= '2017' && line.csSiteSpecificFactor16 == null)
            return false
        
        Integer csInputOrig = functions.asInt(line.csVersionInputOriginal)
        Integer csInputCurr = functions.asInt(line.csVersionInputCurrent)
        Integer yearDx = functions.asInt(line.dateOfDiagnosisYear)
        String schemaMatch = ((List)((Map)context.CS_SSF).get(line._csSchemaId))?.get(15)//ssf16
        
        // R = Required, N = Not required after CSv0204
        if (schemaMatch != 'R')
            return true
        
        // condition 2
        if (yearDx >= 2010 || csInputOrig >= 20001) {
        
            if (line.csSiteSpecificFactor16 == '988')
                return false
        
             return true
        }
        
        // condition 3
        if (yearDx > 2003 && yearDx < 2010 && csInputOrig < 20000) {
            if (csInputCurr == 20510) {
               if (line.csSiteSpecificFactor16 != '988')
                   return false
            }
        }
        
        return true
    }

    // ID: IF304; NAME: CS Items - SEER Required - SSF 17 (CS)
    public boolean if304(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || (line.csVersionInputCurrent == null && line.dateOfDiagnosisYear < '2016') ||
             (line.csVersionInputOriginal == null && line.dateOfDiagnosisYear < '2016') || line._csSchemaId == null)
            return true
        if (functions.matches(line.registryId, /^000000156[2356]$/))
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !['brain','intracranial_gland','cns_other'].contains(line._csSchemaId))
            return true
        
        // condition 1
        if (line.dateOfDiagnosisYear >= '2004' && line.dateOfDiagnosisYear <= '2017' && line.csSiteSpecificFactor17 == null)
            return false
        
        Integer csInputOrig = functions.asInt(line.csVersionInputOriginal)
        Integer csInputCurr = functions.asInt(line.csVersionInputCurrent)
        Integer yearDx = functions.asInt(line.dateOfDiagnosisYear)
        String schemaMatch = ((List)((Map)context.CS_SSF).get(line._csSchemaId))?.get(16)//ssf17
        
        // R = Required, N = Not required after CSv0204
        if (schemaMatch != 'R')
            return true
        
        // condition 2
        if (yearDx >= 2010 || csInputOrig >= 20001) {
            if (line.csSiteSpecificFactor17 == '988')
                return false
        
             return true
        }
        
        // condition 3
        if (yearDx > 2003 && yearDx < 2010 && csInputOrig < 20000) {
            if (csInputCurr == 20510) {
               if (line.csSiteSpecificFactor17 != '988')
                   return false
            }
        }
        
        return true
    }

    // ID: IF305; NAME: CS Items - SEER Required - SSF 18 (CS)
    public boolean if305(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || (line.csVersionInputCurrent == null && line.dateOfDiagnosisYear < '2016') ||
             (line.csVersionInputOriginal == null && line.dateOfDiagnosisYear < '2016') || line._csSchemaId == null)
            return true
        if (functions.matches(line.registryId, /^000000156[2356]$/))
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !['brain','intracranial_gland','cns_other'].contains(line._csSchemaId))
            return true
        
        // condition 1
        if (line.dateOfDiagnosisYear >= '2004' && line.dateOfDiagnosisYear <= '2017' && line.csSiteSpecificFactor18 == null)
            return false
        
        Integer csInputOrig = functions.asInt(line.csVersionInputOriginal)
        Integer csInputCurr = functions.asInt(line.csVersionInputCurrent)
        Integer yearDx = functions.asInt(line.dateOfDiagnosisYear)
        String schemaMatch = ((List)((Map)context.CS_SSF).get(line._csSchemaId))?.get(17)//ssf18
        
        // R = Required, N = Not required after CSv0204
        if (schemaMatch != 'R')
            return true
        
        // condition 2
        if (yearDx >= 2010 || csInputOrig >= 20001) {
            if (line.csSiteSpecificFactor18 == '988')
                return false
        
             return true
        }
        
        // condition 3
        if (yearDx > 2003 && yearDx < 2010 && csInputOrig < 20000) {
            if (csInputCurr == 20510) {
               if (line.csSiteSpecificFactor18 != '988')
                   return false
            }
        }
        
        return true
    }

    // ID: IF306; NAME: CS Items - SEER Required - SSF 19 (CS)
    public boolean if306(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2004' || line.dateOfDiagnosisYear > '2017')
            return true
        if (functions.matches(line.registryId, /^000000156[2356]$/))
            return true
        // Pass if schema isn't found for this edit
        if (line._csSchemaId == null)
            return true
        
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !['brain','intracranial_gland','cns_other'].contains(line._csSchemaId))
            return true
        
        if (line.csSiteSpecificFactor19 == null)
            return false
        
        return true
    }

    // ID: IF307; NAME: CS Items - SEER Required - SSF 20 (CS)
    public boolean if307(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2004' || line.dateOfDiagnosisYear > '2017')
            return true
        if (functions.matches(line.registryId, /^000000156[2356]$/))
            return true
        // Pass if schema isn't found for this edit
        if (line._csSchemaId == null)
            return true
        
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !['brain','intracranial_gland','cns_other'].contains(line._csSchemaId))
            return true
        
        if (line.csSiteSpecificFactor20 == null)
            return false
        
        return true
    }

    // ID: IF308; NAME: CS Items - SEER Required - SSF 21 (CS)
    public boolean if308(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || (line.csVersionInputCurrent == null && line.dateOfDiagnosisYear < '2016') ||
             (line.csVersionInputOriginal == null && line.dateOfDiagnosisYear < '2016') || line._csSchemaId == null)
            return true
        if (functions.matches(line.registryId, /^000000156[2356]$/))
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !['brain','intracranial_gland','cns_other'].contains(line._csSchemaId))
            return true
        
        // condition 1
        if (line.dateOfDiagnosisYear >= '2004' && line.dateOfDiagnosisYear <= '2017' && line.csSiteSpecificFactor21 == null)
            return false
        
        Integer csInputOrig = functions.asInt(line.csVersionInputOriginal)
        Integer csInputCurr = functions.asInt(line.csVersionInputCurrent)
        Integer yearDx = functions.asInt(line.dateOfDiagnosisYear)
        String schemaMatch = ((List)((Map)context.CS_SSF).get(line._csSchemaId))?.get(20)//ssf21
        
        // R = Required, N = Not required after CSv0204
        if (!['N','R'].contains(schemaMatch))
            return true
        
        // condition 2
        if (yearDx >= 2014 || csInputOrig >= 20550) {
            if (schemaMatch == 'R' && line.csSiteSpecificFactor21 == '988')
                return false
        
            return true
        }
        
        // condition 3
        if ((yearDx >= 2010 && yearDx <= 2013) || (csInputOrig >= 20001 && csInputOrig < 20550)) {
            if (line.csSiteSpecificFactor21 == '988')
                return false
        
             return true
        }
        
        // condition 4
        if (yearDx > 2003 && yearDx < 2010 && csInputOrig < 20000) {
            if (csInputCurr == 20510) {
               if (line.csSiteSpecificFactor21 != '988')
                   return false
            }
        }
        
        return true
    }

    // ID: IF309; NAME: CS Items - SEER Required - SSF 22 (CS)
    public boolean if309(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || (line.csVersionInputCurrent == null && line.dateOfDiagnosisYear < '2016') ||
             (line.csVersionInputOriginal == null && line.dateOfDiagnosisYear < '2016') || line._csSchemaId == null)
            return true
        if (functions.matches(line.registryId, /^000000156[2356]$/))
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !['brain','intracranial_gland','cns_other'].contains(line._csSchemaId))
            return true
        
        // condition 1
        if (line.dateOfDiagnosisYear >= '2004' && line.dateOfDiagnosisYear <= '2017' && line.csSiteSpecificFactor22 == null)
            return false
        
        Integer csInputOrig = functions.asInt(line.csVersionInputOriginal)
        Integer csInputCurr = functions.asInt(line.csVersionInputCurrent)
        Integer yearDx = functions.asInt(line.dateOfDiagnosisYear)
        String schemaMatch = ((List)((Map)context.CS_SSF).get(line._csSchemaId))?.get(21)//ssf22
        
        // R = Required, N = Not required after CSv0204
        if (schemaMatch != 'R')
            return true
        
        // condition 2
        if (yearDx >= 2010 || csInputOrig >= 20001) {
        
            if (line.csSiteSpecificFactor22 == '988')
                return false
        
             return true
        }
        
        // condition 3
        if (yearDx > 2003 && yearDx < 2010 && csInputOrig < 20000) {
            if (csInputCurr == 20510) {
               if (line.csSiteSpecificFactor22 != '988')
                   return false
            }
        }
        
        return true
    }

    // ID: IF310; NAME: CS Items - SEER Required - SSF 23 (CS)
    public boolean if310(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || (line.csVersionInputCurrent == null && line.dateOfDiagnosisYear < '2016') ||
             (line.csVersionInputOriginal == null && line.dateOfDiagnosisYear < '2016') || line._csSchemaId == null)
            return true
        if (functions.matches(line.registryId, /^000000156[2356]$/))
            return true
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !['brain','intracranial_gland','cns_other'].contains(line._csSchemaId))
            return true
        
        // condition 1
        if (line.dateOfDiagnosisYear >= '2004' && line.dateOfDiagnosisYear <= '2017' && line.csSiteSpecificFactor23 == null)
            return false
        
        Integer csInputOrig = functions.asInt(line.csVersionInputOriginal)
        Integer csInputCurr = functions.asInt(line.csVersionInputCurrent)
        Integer yearDx = functions.asInt(line.dateOfDiagnosisYear)
        String schemaMatch = ((List)((Map)context.CS_SSF).get(line._csSchemaId))?.get(22)//ssf23
        
        // R = Required, N = Not required after CSv0204
        if (schemaMatch != 'R')
            return true
        
        // condition 2
        if (yearDx >= 2010 || csInputOrig >= 20001) {
            if (line.csSiteSpecificFactor23 == '988')
                return false
        
             return true
        }
        
        // condition 3
        if (yearDx > 2003 && yearDx < 2010 && csInputOrig < 20000) {
            if (csInputCurr == 20510) {
               if (line.csSiteSpecificFactor23 != '988')
                   return false
            }
        }
        
        return true
    }

    // ID: IF311; NAME: CS Items - SEER Required - SSF 24 (CS)
    public boolean if311(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2004' || line.dateOfDiagnosisYear > '2017' ||
             ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !(['brain','cns_other','intracranial_gland'].contains(line._csSchemaId))))
            return true
        if (functions.matches(line.registryId, /^000000156[2356]$/))
            return true
        // Pass this edit if schema is invalid
        if (line._csSchemaId == null)
            return true
        
        return line.csSiteSpecificFactor24 != null
    }

    // ID: IF312; NAME: CS Items - SEER Required - Non-SSF (CS)
    public boolean if312(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line._csSchemaId == null || ['0000001562','0000001566'].contains(line.registryId) ||
            ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && line._csSchemaId != 'brain' && line._csSchemaId != 'cns_other' && line._csSchemaId != 'intracranial_gland'))
            return true
        
        Integer yeardx = functions.asInt(line.dateOfDiagnosisYear)
        Integer csInputOrig = functions.asInt(line.csVersionInputOriginal)
        
        if (yeardx > 2015 && (line.csMetsAtDxBone != null || line.csMetsAtDxBrain != null ||
              line.csMetsAtDxLiver != null || line.csMetsAtDxLung != null))
              return false
        if (yeardx > 2015 && line.csExtension == null && (line.csTumorSize != null || line.csTumorSizeExtEval != null ||
              line.csLymphNodes != null || line.csLymphNodesEval != null || line.csMetsAtDx != null || line.csMetsEval != null))
              return false
        if (yeardx > 2015 && line.csExtension != null && (line.csTumorSize == null || line.csTumorSizeExtEval == null ||
              line.csLymphNodes == null || line.csLymphNodesEval == null || line.csMetsAtDx == null || line.csMetsEval == null))
              return false
        if (yeardx > 2009 && yeardx < 2016 && line.registryId != '0000001563' && (line.csMetsAtDxBone == null || line.csMetsAtDxBrain == null ||
              line.csMetsAtDxLiver == null || line.csMetsAtDxLung == null))
              return false
        if (((yeardx > 2007 && yeardx < 2016) || (yeardx > 2003 && yeardx < 2016 && csInputOrig >= 20100)) && ( line.csTumorSizeExtEval == null || line.csLymphNodesEval == null ||
              line.csMetsEval == null))
              return false
        if (yeardx > 2003 && yeardx < 2016 && (line.csTumorSize == null || line.csExtension == null || line.csLymphNodes == null ||
            line.csMetsAtDx == null || line.csVersionInputOriginal == null || line.csVersionInputCurrent == null))
              return false
        
        return true
    }

    // ID: IF313; NAME: CS Mets at DX, Colon Schema (CS)
    public boolean if313(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csMetsAtDx == null)
            return true
        
        int i = 0
        if (line.csMetsAtDxBone == '1')
           i++
        if (line.csMetsAtDxBrain == '1')
           i++
        if (line.csMetsAtDxLiver == '1')
           i++
        if (line.csMetsAtDxLung == '1')
           i++
        
        if (line._csSchemaId == 'colon') {
            if (i >= 1 && functions.matches(line.csMetsAtDx, /^00|08|16|18|31|33$/))
                return false
            if (i > 1)
                return line.csMetsAtDx != '26' && line.csMetsAtDx != '27'
        }
        
        return true
    }

    // ID: IF314; NAME: CS Mets at DX, Rectum Schema (CS)
    public boolean if314(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csMetsAtDx == null)
            return true
        
        if (line._csSchemaId == 'rectum'){
            if (line.csMetsAtDxBone == '1' || line.csMetsAtDxBrain == '1' || line.csMetsAtDxLiver == '1' || line.csMetsAtDxLung == '1')
                return !(functions.matches(line.csMetsAtDx, /^00|08|16|18|29|31|33$/))
        }
        
        return true
    }

    // ID: IF317; NAME: CS Lymph Nodes, IntracranialGland Schema (CS)
    public boolean if317(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csLymphNodes == null || line._csSchemaId != 'intracranial_gland')
            return true
        
        return line.csLymphNodes == '988' || line.csLymphNodes == '999'
    }

    // ID: IF318; NAME: Lymphovascular Invasion, Histology, Behav (CS)
    public boolean if318(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.lymphVascularInvasion == null || line.histologicTypeIcdO3 == null || line.dateOfDiagnosisYear > '2017')
            return true
        
        if (line.histologicTypeIcdO3 >= '9590' && line.histologicTypeIcdO3 <= '9992' && line.lymphVascularInvasion != '8')
            return false
        
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line.behaviorCodeIcdO3 == '2') && line.lymphVascularInvasion == '1')
            return false
        
        return true
    }

    // ID: IF319; NAME: CS Lymph Nodes, SSF 3, Nodes Eval, MerkelCell (CS)
    public boolean if319(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor3 == null || line.csSiteSpecificFactor3 == '988' || line.csLymphNodes == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'merkel_cell_penis') {
            if (line.csSiteSpecificFactor3 == '000' || line.csSiteSpecificFactor3 == '005')
                return line.csLymphNodes == '000' || line.csLymphNodes == '410' || line.csLymphNodes == '420'
            if (line.csLymphNodes == '110')
                return functions.matches(line.csLymphNodesEval, /^0|1|5|9$/)
            if (functions.matches(line.csLymphNodes, /^1[245]0$/))
                return functions.matches(line.csLymphNodesEval, /^2|3|6|8$/)
            if (line.csSiteSpecificFactor3 == '020')
                return line.csLymphNodesEval != '8'
        }
        if (line._csSchemaId == 'merkel_cell_scrotum' || line._csSchemaId == 'merkel_cell_skin') {
            if (line.csSiteSpecificFactor3 == '000' || line.csSiteSpecificFactor3 == '005')
                return line.csLymphNodes == '000' || line.csLymphNodes == '390' || line.csLymphNodes == '400'
            if (line.csLymphNodes == '310')
                return functions.matches(line.csLymphNodesEval, /^0|1|5|9$/)
            if (functions.matches(line.csLymphNodes, /^3[245]0$/))
                return functions.matches(line.csLymphNodesEval, /^2|3|6|8$/)
            if (line.csSiteSpecificFactor3 == '020')
                return line.csLymphNodesEval != '8'
        }
        if (line._csSchemaId == 'merkel_cell_vulva') {
            if (line.csSiteSpecificFactor3 == '000' || line.csSiteSpecificFactor3 == '005')
                return line.csLymphNodes == '000' || line.csLymphNodes == '510' || line.csLymphNodes == '520'
            if (line.csLymphNodes == '114')
                return functions.matches(line.csLymphNodesEval, /^0|1|5|9$/)
            if (functions.matches(line.csLymphNodes, /^1[12]5|120$/))
                return functions.matches(line.csLymphNodesEval, /^2|3|6|8$/)
            if (line.csSiteSpecificFactor3 == '020')
                return line.csLymphNodesEval != '8'
        }
        
        return true
    }

    // ID: IF320; NAME: CS SSF 16, MerkelCell Schemas (CS)
    public boolean if320(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor16 == null || line.csSiteSpecificFactor16 == '988' || line.csLymphNodes == null ||
            line.rxSummScopeRegLnSur == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line.regionalNodesPositive == null)
            return true
        
        if (line._csSchemaId == 'merkel_cell_penis' || line._csSchemaId == 'merkel_cell_scrotum' ||
            line._csSchemaId == 'merkel_cell_skin'  || line._csSchemaId == 'merkel_cell_vulva') {
            if (line.csSiteSpecificFactor16 == '000') {
                if (line._csSchemaId == 'merkel_cell_skin' && !(functions.matches(line.csLymphNodes, /(^000|390|4[08]0|999$)/)))
                    return false
                if (line._csSchemaId == 'merkel_cell_penis' && !(functions.matches(line.csLymphNodes, /(^000|4[12]0|550|999$)/)))
                    return false
                if (line._csSchemaId == 'merkel_cell_scrotum' && !(functions.matches(line.csLymphNodes, /(^000|4[05]0|999$)/)))
                    return false
                if (line._csSchemaId == 'merkel_cell_vulva' && !(functions.matches(line.csLymphNodes, /(^000|5[12]0|700|999$)/)))
                    return false
                if (line.regionalNodesPositive != '00' && line.regionalNodesPositive != '98')
                    return false
            }
            if (line.csTumorSizeExtEval != '2' && line.csTumorSizeExtEval != '8' && line.rxSummScopeRegLnSur == '0')
                return  (line.csSiteSpecificFactor16 == '998' || line.csSiteSpecificFactor16 == '999') && line.regionalNodesPositive == '98'
        }
        
        return true
    }

    // ID: IF321; NAME: CS SSF 16, Skin and Scrotum Schemas (CS)
    public boolean if321(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor16 == null || line.csLymphNodes == null || line.regionalNodesPositive == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId == null)
            return true
        
        if (line._csSchemaId == 'skin' || line._csSchemaId == 'scrotum') {
            if (line.csSiteSpecificFactor16 == '000' && line.regionalNodesPositive != '00' && line.regionalNodesPositive != '98' && line.regionalNodesPositive != '99')
                return false
            if (line.csLymphNodes == '000')
                return line.csSiteSpecificFactor16 == '000' || line.csSiteSpecificFactor16 == '988'
            if (line.csLymphNodes == '999')
                return line.csSiteSpecificFactor16 == '988' || line.csSiteSpecificFactor16 == '999'
        }
        
        return true
    }

    // ID: IF322; NAME: CS SSF 17, MerkelCell Schemas (CS)
    public boolean if322(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor17 == null || line.csSiteSpecificFactor17 == '988' || line.csLymphNodes == null || line.regionalNodesPositive == null || line.rxSummScopeRegLnSur == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'merkel_cell_penis' || line._csSchemaId == 'merkel_cell_scrotum' ||
            line._csSchemaId == 'merkel_cell_skin'  || line._csSchemaId == 'merkel_cell_vulva') {
            if (line.csSiteSpecificFactor17 == '000') {
                if (line.regionalNodesPositive != '00' && line.regionalNodesPositive != '98')
                    return false
                if (line._csSchemaId == 'merkel_cell_penis' && !['000', '420', '999'].contains(line.csLymphNodes))
                    return false
                if (line._csSchemaId == 'merkel_cell_scrotum' && !['000', '400', '999'].contains(line.csLymphNodes))
                    return false
                if (line._csSchemaId == 'merkel_cell_vulva' && !['000', '520', '999'].contains(line.csLymphNodes))
                    return false
                if (line._csSchemaId == 'merkel_cell_skin' && !['000', '400', '480', '999'].contains(line.csLymphNodes))
                    return false
            }
            if (line.csSiteSpecificFactor17 == '010' || line.csSiteSpecificFactor17 == '040' || line.csSiteSpecificFactor17 == '070')
                return line.rxSummScopeRegLnSur != '0' && line.rxSummScopeRegLnSur != '9'
            if (line.csTumorSizeExtEval != '2' && line.csTumorSizeExtEval != '8' && line.rxSummScopeRegLnSur == '0')
                return functions.matches(line.csSiteSpecificFactor17, /(^0[0235689]0|999$)/)
        }
        
        return true
    }

    // ID: IF323; NAME: CS SSF 18, MerkelCell Schemas (CS)
    public boolean if323(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor18 == null || line.csSiteSpecificFactor18 == '988' || line.csLymphNodes == null || line.rxSummScopeRegLnSur == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'merkel_cell_penis' || line._csSchemaId == 'merkel_cell_scrotum' ||
            line._csSchemaId == 'merkel_cell_skin'  || line._csSchemaId == 'merkel_cell_vulva') {
            if (line.csTumorSizeExtEval != '2' && line.csTumorSizeExtEval != '8' && line.rxSummScopeRegLnSur == '0') {
                if (line.csSiteSpecificFactor18 != '000' && line.csSiteSpecificFactor18 != '988' && line.csSiteSpecificFactor18 != '999')
                    return false
            }
            if (line.csSiteSpecificFactor18 == '000' || line.csSiteSpecificFactor18 == '010') {
                if (line.regionalNodesPositive != '00' && line.regionalNodesPositive != '98')
                    return false
                if (line._csSchemaId == 'merkel_cell_penis' && !['000', '420', '999'].contains(line.csLymphNodes))
                    return false
                if (line._csSchemaId == 'merkel_cell_scrotum' && !['000', '400', '999'].contains(line.csLymphNodes))
                    return false
                if (line._csSchemaId == 'merkel_cell_vulva' && !['000', '520', '999'].contains(line.csLymphNodes))
                    return false
                if (line._csSchemaId == 'merkel_cell_skin' && !['000', '400', '480', '999'].contains(line.csLymphNodes))
                    return false
            }
            if (line.csSiteSpecificFactor18 == '020' || line.csSiteSpecificFactor18 == '090' ||
                line.csSiteSpecificFactor18 == '100' || line.csSiteSpecificFactor18 == '200' ||
                line.csSiteSpecificFactor18 == '300')
                return line.csLymphNodes != '000' && line.csLymphNodes != '999'
        }
        
        return true
    }

    // ID: IF324; NAME: Obsolete Codes - CS Site-Specific Factor 7 (CS)
    public boolean if324(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor7 == null || line.dateOfDiagnosisYear == null || line.csVersionInputOriginal == null)
             return true
        
        if (line._csSchemaId == null)
            return false
        
        String code = functions.getCsObsoleteReason(line, 'csSiteSpecificFactor7', line.csSiteSpecificFactor7)
        
        if (code != null) {
             if (code == '1' || code == '5' || code == '6' || code == '7' || code == '16' || code == '18') {
                 if (line.dateOfDiagnosisYear >= '2010')
                    return false
                 if (line.csVersionInputOriginal >= '020100')
                    return false
             }
             else if (code == '13' || code == '14' || code == '15') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020300')
                    return false
             }
             else if (code == '17') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020200')
                    return false
             }
             else if (code == '21' || code == '22') {
                 if (line.dateOfDiagnosisYear >= '2012')
                    return false
                 if (line.csVersionInputOriginal >= '020440')
                    return false
             }
             else
                return false
        }
        
        return true
    }

    // ID: IF325; NAME: Obsolete Codes - CS Site-Specific Factor 8 (CS)
    public boolean if325(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor8 == null || line.dateOfDiagnosisYear == null || line.csVersionInputOriginal == null)
             return true
        
        if (line._csSchemaId == null)
            return false
        
        String code = functions.getCsObsoleteReason(line, 'csSiteSpecificFactor8', line.csSiteSpecificFactor8)
        
        if (code != null) {
             if (code == '1' || code == '5' || code == '6' || code == '7' || code == '16' || code == '18') {
                 if (line.dateOfDiagnosisYear >= '2010')
                    return false
                 if (line.csVersionInputOriginal >= '020100')
                    return false
             }
             else if (code == '13' || code == '14' || code == '15') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020300')
                    return false
             }
             else if (code == '17') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020200')
                    return false
             }
             else if (code == '21' || code == '22') {
                 if (line.dateOfDiagnosisYear >= '2012')
                    return false
                 if (line.csVersionInputOriginal >= '020440')
                    return false
             }
             else
                return false
        }
        
        return true
    }

    // ID: IF326; NAME: Obsolete Codes - CS Site-Specific Factor 9 (CS)
    public boolean if326(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor9 == null || line.dateOfDiagnosisYear == null || line.csVersionInputOriginal == null)
             return true
        
        if (line._csSchemaId == null)
            return false
        
        String code = functions.getCsObsoleteReason(line, 'csSiteSpecificFactor9', line.csSiteSpecificFactor9)
        
        if (code != null) {
             if (code == '1' || code == '5' || code == '6' || code == '7' || code == '16' || code == '18') {
                 if (line.dateOfDiagnosisYear >= '2010')
                    return false
                 if (line.csVersionInputOriginal >= '020100')
                    return false
             }
             else if (code == '13' || code == '14' || code == '15') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020300')
                    return false
             }
             else if (code == '17') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020200')
                    return false
             }
             else if (code == '21' || code == '22') {
                 if (line.dateOfDiagnosisYear >= '2012')
                    return false
                 if (line.csVersionInputOriginal >= '020440')
                    return false
             }
             else
                return false
        }
        
        return true
    }

    // ID: IF327; NAME: Obsolete Codes - CS Site-Specific Factor10 (CS)
    public boolean if327(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor10 == null || line.dateOfDiagnosisYear == null || line.csVersionInputOriginal == null)
             return true
        
        if (line._csSchemaId == null)
            return false
        
        String code = functions.getCsObsoleteReason(line, 'csSiteSpecificFactor10', line.csSiteSpecificFactor10)
        
        if (code != null) {
             if (code == '1' || code == '5' || code == '6' || code == '7' || code == '16' || code == '18') {
                 if (line.dateOfDiagnosisYear >= '2010')
                    return false
                 if (line.csVersionInputOriginal >= '020100')
                    return false
             }
             else if (code == '13' || code == '14' || code == '15') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020300')
                    return false
             }
             else if (code == '17') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020200')
                    return false
             }
             else if (code == '21' || code == '22') {
                 if (line.dateOfDiagnosisYear >= '2012')
                    return false
                 if (line.csVersionInputOriginal >= '020440')
                    return false
             }
             else
                return false
        }
        
        return true
    }

    // ID: IF328; NAME: Obsolete Codes - CS Site-Specific Factor11 (CS)
    public boolean if328(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor11 == null || line.dateOfDiagnosisYear == null || line.csVersionInputOriginal == null)
             return true
        
        if (line._csSchemaId == null)
            return false
        
        String code = functions.getCsObsoleteReason(line, 'csSiteSpecificFactor11', line.csSiteSpecificFactor11)
        
        if (code != null) {
             if (code == '1' || code == '5' || code == '6' || code == '7' || code == '16' || code == '18') {
                 if (line.dateOfDiagnosisYear >= '2010')
                    return false
                 if (line.csVersionInputOriginal >= '020100')
                    return false
             }
             else if (code == '13' || code == '14' || code == '15') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020300')
                    return false
             }
             else if (code == '17') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020200')
                    return false
             }
             else if (code == '21' || code == '22') {
                 if (line.dateOfDiagnosisYear >= '2012')
                    return false
                 if (line.csVersionInputOriginal >= '020440')
                    return false
             }
             else
                return false
        }
        
        return true
    }

    // ID: IF329; NAME: Obsolete Codes - CS Site-Specific Factor12 (CS)
    public boolean if329(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor12 == null || line.dateOfDiagnosisYear == null || line.csVersionInputOriginal == null)
             return true
        
        if (line._csSchemaId == null)
            return false
        
        String code = functions.getCsObsoleteReason(line, 'csSiteSpecificFactor12', line.csSiteSpecificFactor12)
        
        if (code != null) {
             if (code == '1' || code == '5' || code == '6' || code == '7' || code == '16' || code == '18') {
                 if (line.dateOfDiagnosisYear >= '2010')
                    return false
                 if (line.csVersionInputOriginal >= '020100')
                    return false
             }
             else if (code == '13' || code == '14' || code == '15') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020300')
                    return false
             }
             else if (code == '17') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020200')
                    return false
             }
             else if (code == '21' || code == '22') {
                 if (line.dateOfDiagnosisYear >= '2012')
                    return false
                 if (line.csVersionInputOriginal >= '020440')
                    return false
             }
             else
                return false
        }
        
        return true
    }

    // ID: IF330; NAME: Obsolete Codes - CS Site-Specific Factor13 (CS)
    public boolean if330(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor13 == null || line.dateOfDiagnosisYear == null || line.csVersionInputOriginal == null)
             return true
        
        if (line._csSchemaId == null)
            return false
        
        String code = functions.getCsObsoleteReason(line, 'csSiteSpecificFactor13', line.csSiteSpecificFactor13)
        
        if (code != null) {
             if (code == '1' || code == '5' || code == '6' || code == '7' || code == '16' || code == '18') {
                 if (line.dateOfDiagnosisYear >= '2010')
                    return false
                 if (line.csVersionInputOriginal >= '020100')
                    return false
             }
             else if (code == '13' || code == '14' || code == '15') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020300')
                    return false
             }
             else if (code == '17') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020200')
                    return false
             }
             else if (code == '21' || code == '22') {
                 if (line.dateOfDiagnosisYear >= '2012')
                    return false
                 if (line.csVersionInputOriginal >= '020440')
                    return false
             }
             else
                return false
        }
        
        return true
    }

    // ID: IF332; NAME: Obsolete Codes - CS Site-Specific Factor15 (CS)
    public boolean if332(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor15 == null || line.dateOfDiagnosisYear == null || line.csVersionInputOriginal == null)
             return true
        
        if (line._csSchemaId == null)
            return false
        
        String code = functions.getCsObsoleteReason(line, 'csSiteSpecificFactor15', line.csSiteSpecificFactor15)
        
        if (code != null) {
             if (code == '1' || code == '5' || code == '6' || code == '7' || code == '16' || code == '18') {
                 if (line.dateOfDiagnosisYear >= '2010')
                    return false
                 if (line.csVersionInputOriginal >= '020100')
                    return false
             }
             else if (code == '13' || code == '14' || code == '15') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020300')
                    return false
             }
             else if (code == '17') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020200')
                    return false
             }
             else if (code == '21' || code == '22') {
                 if (line.dateOfDiagnosisYear >= '2012')
                    return false
                 if (line.csVersionInputOriginal >= '020440')
                    return false
             }
             else
                return false
        }
        
        return true
    }

    // ID: IF336; NAME: Obsolete Codes - CS Site-Specific Factor19 (CS)
    public boolean if336(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor19 == null || line.dateOfDiagnosisYear == null || line.csVersionInputOriginal == null)
             return true
        
        if (line._csSchemaId == null)
            return false
        
        String code = functions.getCsObsoleteReason(line, 'csSiteSpecificFactor19', line.csSiteSpecificFactor19)
        
        if (code != null) {
             if (code == '1' || code == '5' || code == '6' || code == '7' || code == '16' || code == '18') {
                 if (line.dateOfDiagnosisYear >= '2010')
                    return false
                 if (line.csVersionInputOriginal >= '020100')
                    return false
             }
             else if (code == '13' || code == '14' || code == '15') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020300')
                    return false
             }
             else if (code == '17') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020200')
                    return false
             }
             else if (code == '21' || code == '22') {
                 if (line.dateOfDiagnosisYear >= '2012')
                    return false
                 if (line.csVersionInputOriginal >= '020440')
                    return false
             }
             else
                return false
        }
        
        return true
    }

    // ID: IF338; NAME: Obsolete Codes - CS Site-Specific Factor21 (CS)
    public boolean if338(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor21 == null || line.dateOfDiagnosisYear == null || line.csVersionInputOriginal == null)
             return true
        
        if (line._csSchemaId == null)
            return false
        
        String code = functions.getCsObsoleteReason(line, 'csSiteSpecificFactor21', line.csSiteSpecificFactor21)
        
        if (code != null) {
             if (code == '1' || code == '5' || code == '6' || code == '7' || code == '16' || code == '18') {
                 if (line.dateOfDiagnosisYear >= '2010')
                    return false
                 if (line.csVersionInputOriginal >= '020100')
                    return false
             }
             else if (code == '13' || code == '14' || code == '15') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020300')
                    return false
             }
             else if (code == '17') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020200')
                    return false
             }
             else if (code == '21' || code == '22') {
                 if (line.dateOfDiagnosisYear >= '2012')
                    return false
                 if (line.csVersionInputOriginal >= '020440')
                    return false
             }
             else
                return false
        }
        
        return true
    }

    // ID: IF339; NAME: Obsolete Codes - CS Site-Specific Factor22 (CS)
    public boolean if339(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor22 == null || line.dateOfDiagnosisYear == null || line.csVersionInputOriginal == null)
             return true
        
        if (line._csSchemaId == null)
            return false
        
        String code = functions.getCsObsoleteReason(line, 'csSiteSpecificFactor22', line.csSiteSpecificFactor22)
        
        if (code != null) {
             if (code == '1' || code == '5' || code == '6' || code == '7' || code == '16' || code == '18') {
                 if (line.dateOfDiagnosisYear >= '2010')
                    return false
                 if (line.csVersionInputOriginal >= '020100')
                    return false
             }
             else if (code == '13' || code == '14' || code == '15') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020300')
                    return false
             }
             else if (code == '17') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020200')
                    return false
             }
             else if (code == '21' || code == '22') {
                 if (line.dateOfDiagnosisYear >= '2012')
                    return false
                 if (line.csVersionInputOriginal >= '020440')
                    return false
             }
             else
                return false
        }
        
        return true
    }

    // ID: IF340; NAME: Obsolete Codes - CS Site-Specific Factor23 (CS)
    public boolean if340(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor23 == null || line.dateOfDiagnosisYear == null || line.csVersionInputOriginal == null)
             return true
        
        if (line._csSchemaId == null)
            return false
        
        String code = functions.getCsObsoleteReason(line, 'csSiteSpecificFactor23', line.csSiteSpecificFactor23)
        
        if (code != null) {
             if (code == '1' || code == '5' || code == '6' || code == '7' || code == '16' || code == '18') {
                 if (line.dateOfDiagnosisYear >= '2010')
                    return false
                 if (line.csVersionInputOriginal >= '020100')
                    return false
             }
             else if (code == '13' || code == '14' || code == '15') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020300')
                    return false
             }
             else if (code == '17') {
                 if (line.dateOfDiagnosisYear >= '2011')
                    return false
                 if (line.csVersionInputOriginal >= '020200')
                    return false
             }
             else if (code == '21' || code == '22') {
                 if (line.dateOfDiagnosisYear >= '2012')
                    return false
                 if (line.csVersionInputOriginal >= '020440')
                    return false
             }
             else
                return false
        }
        
        return true
    }

    // ID: IF342; NAME: CS Extension, MyelomaPlasmaCellDisorder (CS)
    public boolean if342(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csExtension == null)
             return true
        
        if (line._csSchemaId == 'myeloma_plasma_cell_disorder') {
            if (line.csExtension == '100' || line.csExtension == '400')
                return line.histologicTypeIcdO3 == '9731' || line.histologicTypeIcdO3 == '9734'
            if (line.csExtension == '110' || line.csExtension == '200' || line.csExtension == '500')
                return line.histologicTypeIcdO3 == '9731'
            if (line.csExtension == '300')
                return line.histologicTypeIcdO3 == '9734'
            if (line.csExtension == '810' || line.csExtension == '820')
                return line.histologicTypeIcdO3 == '9732'
        }
        
        return true
    }

    // ID: IF343; NAME: CS SSF 2, MyelomaPlasmaCellDisorder (CS)
    public boolean if343(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor2 == null)
             return true
        
        if (line._csSchemaId == 'myeloma_plasma_cell_disorder') {
            if (line.csSiteSpecificFactor2  ==~ /^0[123456789]0|999$/)
                return line.histologicTypeIcdO3 == '9732'
            if (line.csSiteSpecificFactor2 == '987')
                return line.histologicTypeIcdO3 == '9731' || line.histologicTypeIcdO3 == '9734'
        }
        
        return true
    }

    // ID: IF344; NAME: CS SSF 3, MyelomaPlasmaCellDisorder (CS)
    public boolean if344(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor3 == null)
             return true
        
        if (line._csSchemaId == 'myeloma_plasma_cell_disorder') {
            if (line.csSiteSpecificFactor3  ==~ /^0[01238]0|100|999$/ && line.histologicTypeIcdO3 != '9732')
                return false
        
            if (line.csSiteSpecificFactor3 == '987' && line.histologicTypeIcdO3 != '9731' && line.histologicTypeIcdO3 != '9734')
                return false
        }
        
        return true
    }

    // ID: IF345; NAME: CS SSF 11, Surg, Appendix Schema (CS)
    public boolean if345(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor11 == null || line.csSiteSpecificFactor11 == '988' || line.behaviorCodeIcdO3 == '0' ||
            line.behaviorCodeIcdO3 == '1' || line.rxSummSurgPrimSite == null)
            return true
        
        if (line._csSchemaId == 'appendix' && line.csSiteSpecificFactor11 == '998')
            return functions.asInt(line.rxSummSurgPrimSite) < 20
        
        return true
    }

    // ID: IF346; NAME: CS Extension, SSF 3, Behavior, Prostate (CS)
    public boolean if346(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csExtension == null || line.behaviorCodeIcdO3 == '0' ||
            line.behaviorCodeIcdO3 == '1' || line.typeOfReportingSource == '7')
            return true
        
        if (line._csSchemaId == 'prostate') {
            Integer ext = functions.asInt(line.csExtension)
            Integer ssf3 = functions.asInt(line.csSiteSpecificFactor3)
            if ((ext == 0 && ssf3 != 985 && (ssf3 < 200 || ssf3 > 750)) ||
                (ssf3 == 0 && (ext < 100 || ext > 750)))
                return line.behaviorCodeIcdO3 == '2'
        }
        return true
    }

    // ID: IF347; NAME: CS Lymph Nodes, MyelomaPlasmaCellDisorder (CS)
    public boolean if347(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csLymphNodes == null)
            return true
        
        if (line._csSchemaId == 'myeloma_plasma_cell_disorder') {
            if (line.csLymphNodes == '000' || line.csLymphNodes == '100' || line.csLymphNodes == '999')
                return line.histologicTypeIcdO3 == '9734'
            if (line.csLymphNodes == '987')
                return line.histologicTypeIcdO3 == '9731' || line.histologicTypeIcdO3 == '9732'
        }
        
        return true
    }

    // ID: IF348; NAME: Primary Site, Heme Morph, DateDX, NoOverride (SEER)
    public boolean if348(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.behaviorCodeIcdO3 == null || line.behaviorCodeIcdO3 != '3' ||
            line.histologicTypeIcdO3 == null || line.histologicTypeIcdO3 < '9590' || line.histologicTypeIcdO3 > '9993' || line.primarySite == null)
            return true
        
        Integer hist = functions.asInt(line.histologicTypeIcdO3)
        String site = line.primarySite
        
        if (line.dateOfDiagnosisYear < '2010' && hist == 9823)
            if (!(site ==~ /^C42[014]$/))
                return false
        
        if (line.dateOfDiagnosisYear > '2017') {
            if (site == 'C420')
                return false
            else if (hist == 9761)
                return site == 'C421'
        }
        
        if (line.dateOfDiagnosisYear >= '2010') {
            if (hist == 9761) {
                if (site != 'C420')
                    return false
            }
            else if (((List)context.IF348_Hist_List_1).contains(hist)) {
                if (site != 'C421')
                    return false
            }
            else if (((List)context.IF348_Hist_List_2).contains(hist)) {
                if (site ==~ /^C42[034]$/)
                    return false
            }
            else if (((List)context.IF348_Hist_List_3).contains(hist)) {
                if (site ==~ /^C42[034]$/)
                    return false
            }
            else if (hist == 9679) {
                if (!(site ==~ /^C38[123]|C379$/))
                    return false
            }
            else if (hist == 9689 || hist == 9716) {
                if (site != 'C422')
                    return false
            }
            else if (hist == 9699) {
                if (site ==~ /^C42[0234]$/)
                    return false
            }
            else if (hist == 9731) {
                if (!(site ==~ /^C4[01][0-9]$/))
                    return false
            }
            else if (hist == 9734) {
                if (site ==~ /^C42[034]$/ || site ==~ /^C4[01][0-9]$/)
                    return false
            }
            else if (hist == 9930) {
                if (site ==~ /^C42[0134]$/)
                    return false
            }
        
            if (site == 'C420' && hist != 9761)
                return false
        }
        
        return true
    }

    // ID: IF349; NAME: CS Ext, LN, Mets at DX, SSF 1, Retinoblastoma (CS)
    public boolean if349(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csExtension == null || line.csLymphNodes == null ||
            line.csMetsAtDx == null || line.csSiteSpecificFactor1 == null ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'retinoblastoma') {
            if (line.csExtension == '950') {
                if ((line.csSiteSpecificFactor1 >= '300' && line.csSiteSpecificFactor1 <= '810') || line.csSiteSpecificFactor1 == '999')
                    return true
                if (line.csLymphNodes >= '100' && line.csLymphNodes <= '800')
                    return true
                if (line.csMetsAtDx >= '10' && line.csMetsAtDx <= '80')
                    return true
                return false
            }
            if (line.csSiteSpecificFactor1 == '950') {
                if (line.csExtension >= '110' && line.csExtension <= '800')
                    return true
                if (line.csLymphNodes >= '100' && line.csLymphNodes <= '800')
                    return true
                if (line.csMetsAtDx >= '10' && line.csMetsAtDx <= '80')
                    return true
                return false
            }
        }
        
        return true
    }

    // ID: IF350; NAME: CS Ext, LN, Mets at DX, SSF 3, Prostate (CS)
    public boolean if350(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csExtension == null || line.csLymphNodes == null ||
            line.csMetsAtDx == null || line.csSiteSpecificFactor3 == null ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'prostate') {
            if (line.csExtension == '950') {
                if ((line.csSiteSpecificFactor3 >= '200' && line.csSiteSpecificFactor3 <= '750') || line.csSiteSpecificFactor3 == '990' || line.csSiteSpecificFactor3 == '000')
                    return true
                if (line.csLymphNodes >= '100' && line.csLymphNodes <= '800')
                    return true
                if (line.csMetsAtDx >= '11' && line.csMetsAtDx <= '60')
                    return true
                return false
            }
            if (line.csSiteSpecificFactor3 == '950') {
                if (line.csExtension >= '000' && line.csExtension <= '750')
                    return true
                if (line.csLymphNodes >= '100' && line.csLymphNodes <= '800')
                    return true
                if (line.csMetsAtDx >= '11' && line.csMetsAtDx <= '60')
                    return true
                return false
            }
        }
        
        return true
    }

    // ID: IF351; NAME: CS Extension, Hist, Grade, Esophagus Schema (CS)
    public boolean if351(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csExtension == null || line.grade == null ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId == null)
            return true
        
        if (line._csSchemaId == 'esophagus' && line.csExtension == '000' &&
            functions.matches(line.histologicTypeIcdO3, /^(8[01234]\d\d)|(85[0123456]\d)|(857[0123456])|(894\d)|(8950)|(898[01])$/))
                return line.grade == '1' || line.grade == '9'
        
        return true
    }

    // ID: IF352; NAME: CS Extension, Hist, Grade, EsophagusGEJunction (CS)
    public boolean if352(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csExtension == null || line.grade == null ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId == null)
            return true
        
        if (line._csSchemaId == 'esophagus_gejunction' && line.csExtension == '000' &&
            ((List)context.IF352_Histologies).contains(functions.asInt(line.histologicTypeIcdO3)))
                return line.grade == '1' || line.grade == '9'
        
        return true
    }

    // ID: IF353; NAME: CS Extension, SSF 1, Lung Schema (CS)
    public boolean if353(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csExtension == null || line.csSiteSpecificFactor1 == null ||
        
            line.csSiteSpecificFactor1 == '988' || line.behaviorCodeIcdO3 == '0' ||
            line.behaviorCodeIcdO3 == '1' || line._csSchemaId == null)
            return true
        
        if (line._csSchemaId == 'lung' && functions.matches(line.csExtension, /^(000)|(9[58]0)$/))
            return !(functions.matches(line.csSiteSpecificFactor1, /^(0[1234]0)$/))
        
        return true
    }

    // ID: IF354; NAME: CS Items, Type Reporting Source-DCO (SEER)
    public boolean if354(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        String dxYear = line.dateOfDiagnosisYear
        String behav = line.behaviorCodeIcdO3
        String schema = line._csSchemaId
        
        if (schema == null || dxYear == null || dxYear < '2004' || dxYear > '2017' || behav == '2' || line.typeOfReportingSource != '7' ||
            ((behav == '0' || behav == '1') && schema != 'brain' && schema != 'cns_other' && schema != 'intracranial_gland') ||
            ((dxYear == '2016' || dxYear == '2017') && line.csExtension == null))
                return true
        
        String tumSize = line.csTumorSize
        String tumSizeExtEval = line.csTumorSizeExtEval
        String ext = line.csExtension
        String nodes =  line.csLymphNodes
        String nodesEval = line.csLymphNodesEval
        String metsAtDx = line.csMetsAtDx
        String metsEval = line.csMetsEval
        String ssf1 = line.csSiteSpecificFactor1
        String ssf2 = line.csSiteSpecificFactor2
        String ssf3 = line.csSiteSpecificFactor3
        String ssf4 = line.csSiteSpecificFactor4
        String ssf5 = line.csSiteSpecificFactor5
        String ssf6 = line.csSiteSpecificFactor6
        String ssf7 = line.csSiteSpecificFactor7
        String ssf8 = line.csSiteSpecificFactor8
        String ssf9 = line.csSiteSpecificFactor9
        String ssf10 = line.csSiteSpecificFactor10
        String ssf11 = line.csSiteSpecificFactor11
        String ssf12 = line.csSiteSpecificFactor12
        String ssf13 = line.csSiteSpecificFactor13
        String ssf14 = line.csSiteSpecificFactor14
        String ssf15 = line.csSiteSpecificFactor15
        String ssf16 = line.csSiteSpecificFactor16
        String ssf17 = line.csSiteSpecificFactor17
        String ssf18 = line.csSiteSpecificFactor18
        String ssf19 = line.csSiteSpecificFactor19
        String ssf20 = line.csSiteSpecificFactor20
        String ssf21 = line.csSiteSpecificFactor21
        String ssf22 = line.csSiteSpecificFactor22
        String ssf23 = line.csSiteSpecificFactor23
        String ssf24 = line.csSiteSpecificFactor24
        String metsBone = line.csMetsAtDxBone
        String metsBrain = line.csMetsAtDxBrain
        String metsLiver = line.csMetsAtDxLiver
        String metsLung = line.csMetsAtDxLung
        String metsVasc = line.lymphVascularInvasion
        
        String failingProp = null
        if (tumSize != '988' && tumSize != '999' && tumSize != null)
            failingProp = 'line.csTumorSize'
        else if (((behav == '0' || behav == '1') && (schema == 'brain' ||  schema == 'cns_other' || schema == 'intracranial_gland')) && ext != '050' && ext != '999' && ext != null)
            failingProp = 'line.csExtension'
        else if (schema == 'heme_retic' && ext != '800' && ext != '999' && ext != null)
            failingProp = 'line.csExtension'
        else if (schema == 'myeloma_plasma_cell_disorder' && ext != '800' && ext != '810' && ext != '820' && ext != '999' && ext != null)
            failingProp = 'line.csExtension'
        else if (schema == 'lymphoma_ocular_adnexa' && ext != '989' && ext != '999' && ext != null)
            failingProp = 'line.csExtension'
        else if (schema != 'heme_retic' && schema != 'myeloma_plasma_cell_disorder' && (schema != 'brain' || (behav != '0' && behav != '1')) && schema != 'cns_other' && schema != 'intracranial_gland' && ext != '988' && ext != '999' && ext != null)
            failingProp = 'line.csExtension'
        else if (tumSizeExtEval != '9' && tumSizeExtEval != null)
            failingProp = 'line.csTumorSizeExtEval'
        else if (schema == 'myeloma_plasma_cell_disorder' && nodes != '987' && nodes != '988' && nodes != '999' && nodes != null)
            failingProp = 'line.csLymphNodes'
        else if (schema != 'myeloma_plasma_cell_disorder' && nodes != '988' && nodes != '999' && nodes != null)
            failingProp = 'line.csLymphNodes'
        else if (nodesEval != '9' && nodesEval != null)
            failingProp = 'line.csLymphNodesEval'
        else if (metsAtDx != '98' && metsAtDx != '99' && metsAtDx != null)
            failingProp = 'line.csMetsAtDx'
        else if (metsEval != '9' && metsEval != null)
            failingProp = 'line.csMetsEval'
        else if (schema == 'retinoblastoma' && ssf1 != '960' && ssf1 != null)
            failingProp = 'line.csSiteSpecificFactor1'
        else if ((schema == 'bladder' || schema == 'kidney_renal_pelvis' || schema == 'urethra') &&  ssf1 != '987' && ssf1 != '988' && ssf1 != '999' && ssf1 != null)
            failingProp = 'line.csSiteSpecificFactor1'
        else if (schema != 'retinoblastoma' && schema != 'bladder' && schema != 'kidney_renal_pelvis' && schema != 'urethra' && ssf1 != '988' && ssf1 != '999' && ssf1 != null)
            failingProp = 'line.csSiteSpecificFactor1'
        else if ((schema == 'myeloma_plasma_cell_disorder' || schema == 'skin_eyelid') && ssf2 != '987' && ssf2 != '988' && ssf2 != '999' && ssf2 != null)
            failingProp = 'line.csSiteSpecificFactor2'
        else if (schema != 'myeloma_plasma_cell_disorder' && schema != 'skin_eyelid' && ssf2 != '988' && ssf2 != '999' && ssf2 != null)
            failingProp = 'line.csSiteSpecificFactor2'
        else if (schema == 'breast' && ssf3 != '988' && ssf3 != '099' && ssf3 != null)
            failingProp = 'line.csSiteSpecificFactor3'
        else if (schema == 'prostate' && ssf3 != '960' && ssf3 != null)
            failingProp = 'line.csSiteSpecificFactor3'
        else if (schema == 'myeloma_plasma_cell_disorder' && ssf3 != '987' && ssf3 != '988' && ssf3 != '999' && ssf3 != null)
            failingProp = 'line.csSiteSpecificFactor3'
        else if (schema != 'breast' && schema != 'prostate' && schema != 'myeloma_plasma_cell_disorder' && ssf3 != '988' && ssf3 != '999' && ssf3 != null)
            failingProp = 'line.csSiteSpecificFactor3'
        else if (schema == 'prostate' && ssf4 != '550' && ssf4 != '988' && ssf4 != '999' && ssf4 != null)
            failingProp = 'line.csSiteSpecificFactor4'
        else if (schema != 'prostate' && ssf4 != '987' && ssf4 != '988' && ssf4 != '999' && ssf4 != null)
            failingProp = 'line.csSiteSpecificFactor4'
        else if (ssf5 != '987' && ssf5 != '988' && ssf5 != '999' && ssf5 != null)
            failingProp = 'line.csSiteSpecificFactor5'
        else if (ssf6 != '987' && ssf6 != '988' && ssf6 != '999' && ssf6 != null)
            failingProp = 'line.csSiteSpecificFactor6'
        else if (ssf7 != '987' && ssf7 != '988' && ssf7 != '999' && ssf7 != null)
            failingProp = 'line.csSiteSpecificFactor7'
        else if (ssf8 != '988' && ssf8 != '999' && ssf8 != null)
            failingProp = 'line.csSiteSpecificFactor8'
        else if (ssf9 != '988' && ssf9 != '999' && ssf9 != null)
            failingProp = 'line.csSiteSpecificFactor9'
        else if (ssf10 != '988' && ssf10 != '999' && ssf10 != null)
            failingProp = 'line.csSiteSpecificFactor10'
        else if (ssf11 != '988' && ssf11 != '999' && ssf11 != null)
            failingProp = 'line.csSiteSpecificFactor11'
        else if (ssf12 != '988' && ssf12 != '999' && ssf12 != null)
            failingProp = 'line.csSiteSpecificFactor12'
        else if (ssf13 != '988' && ssf13 != '999' && ssf13 != null)
            failingProp = 'line.csSiteSpecificFactor13'
        else if (ssf14 != '988' && ssf14 != '999' && ssf14 != null)
            failingProp = 'line.csSiteSpecificFactor14'
        else if (ssf15 != '988' && ssf15 != '999' && ssf15 != null)
            failingProp = 'line.csSiteSpecificFactor15'
        else if (ssf16 != '988' && ssf16 != '999' && ssf16 != null)
            failingProp = 'line.csSiteSpecificFactor16'
        else if (ssf17 != '988' && ssf17 != '999' && ssf17 != null)
            failingProp = 'line.csSiteSpecificFactor17'
        else if (ssf18 != '988' && ssf18 != '999' && ssf18 != null)
            failingProp = 'line.csSiteSpecificFactor18'
        else if (ssf19 != '988' && ssf19 != '999' && ssf19 != null)
            failingProp = 'line.csSiteSpecificFactor19'
        else if (ssf20 != '988' && ssf20 != '999' && ssf20 != null)
            failingProp = 'line.csSiteSpecificFactor20'
        else if (ssf21 != '988' && ssf21 != '999' && ssf21 != null)
            failingProp = 'line.csSiteSpecificFactor21'
        else if (ssf22 != '988' && ssf22 != '999' && ssf22 != null)
            failingProp = 'line.csSiteSpecificFactor22'
        else if (ssf23 != '988' && ssf23 != '999' && ssf23 != null)
            failingProp = 'line.csSiteSpecificFactor23'
        else if (ssf24 != '988' && ssf24 != '999' && ssf24 != null)
            failingProp = 'line.csSiteSpecificFactor24'
        else if (metsBone != '8' && metsBone != '9' && metsBone != null)
            failingProp = 'line.csMetsAtDxBone'
        else if (metsBrain != '8' && metsBrain != '9' && metsBrain != null)
            failingProp = 'line.csMetsAtDxBrain'
        else if (metsLiver != '8' && metsLiver != '9' && metsLiver != null)
            failingProp = 'line.csMetsAtDxLiver'
        else if (metsLung != '8' && metsLung != '9' && metsLung != null)
            failingProp = 'line.csMetsAtDxLung'
        else if (metsVasc != '8' && metsVasc != '9' && metsVasc != null)
            failingProp = 'line.lymphVascularInvasion'
        
        if (failingProp != null) {
            // only fail the properties we care about.  properties must start with 'line.'
            (List)context.IF354_properties.each() { prop -> 
                functions.ignoreFailureOnProperty(binding, 'line.' + prop)
            }
            functions.forceFailureOnProperty(binding, failingProp)
            return false
        }
        
        return true
    }

    // ID: IF355; NAME: CS Lymph Nodes, Nodes Pos, MelanomaSkin (CS)
    public boolean if355(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csLymphNodes == null || line.behaviorCodeIcdO3 == '0' ||
            line.behaviorCodeIcdO3 == '1' || line._csSchemaId == null ||
            line.regionalNodesPositive == null)
            return true
        
        if (line._csSchemaId == 'melanoma_skin') {
            if (functions.matches(line.csLymphNodes, /^(12[234])|(15[238])$/))
                return !(functions.matches(line.regionalNodesPositive, /^(00)|(98)$/))
        }
        
        return true
    }

    // ID: IF356; NAME: CS SSF 1, CS SSF 3, Lower GI Schemas (CS)
    public boolean if356(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor1 == null || line.csSiteSpecificFactor1 == '988'||
            line.csSiteSpecificFactor3 == null || line.csSiteSpecificFactor3 == '988'||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId == null)
            return true
        
        if (line._csSchemaId == 'small_intestine' || line._csSchemaId == 'appendix' ||
            line._csSchemaId == 'colon' || line._csSchemaId == 'rectum') {
            if (line.csSiteSpecificFactor1 == '998' && line.csSiteSpecificFactor3 != '998')
                return false
            if (line.csSiteSpecificFactor3 == '998' && line.csSiteSpecificFactor1 != '998')
                return false
        }
        
        return true
    }

    // ID: IF357; NAME: CS SSF 1, Extension, Gyn Schemas (CS)
    public boolean if357(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor1 == null || line.csSiteSpecificFactor1 == '988'||
            line.csExtension == null || line._csSchemaId == null ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'cervix' || line._csSchemaId == 'corpus_adenosarcoma' ||
            line._csSchemaId == 'corpus_carcinoma' || line._csSchemaId == 'corpus_sarcoma' ||
            line._csSchemaId == 'fallopian_tube' || line._csSchemaId == 'vagina' ||
            line._csSchemaId == 'vulva') {
            if (line.csExtension == '000')
                return line.csSiteSpecificFactor1 == '987'
        }
        
        return true
    }

    // ID: IF358; NAME: CS SSF 1, Skin/Scrotum/Merkel Cell Schemas (CS)
    public boolean if358(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor1 == null || line.csSiteSpecificFactor1 == '988'||
            line.csTumorSize == null || line.csExtension == null ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId == null)
            return true
        
        if (line._csSchemaId == 'skin' || line._csSchemaId == 'scrotum' ||
            line._csSchemaId == 'merkel_cell_penis' || line._csSchemaId == 'merkel_cell_scrotum' ||
            line._csSchemaId == 'merkel_cell_skin' || line._csSchemaId == 'merkel_cell_vulva') {
            if (line.csSiteSpecificFactor1 == '000')
                return line.csTumorSize == '000' && line.csExtension == '950'
        }
        
        return true
    }

    // ID: IF359; NAME: CS SSF 1, Surg, Sarcomas (CS)
    public boolean if359(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor1 == null || line.csSiteSpecificFactor1 == '988'||
            line.rxSummSurgPrimSite == null ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId == null)
            return true
        
        if (line._csSchemaId == 'heart_mediastinum' || line._csSchemaId == 'soft_tissue' ||
            line._csSchemaId == 'retroperitoneum' || line._csSchemaId == 'peritoneum') {
            if (line.csSiteSpecificFactor1 == '998')
                return !(functions.matches(line.rxSummSurgPrimSite, /^([2-8]\d)$/))
        }
        
        return true
    }

    // ID: IF360; NAME: CS SSF 1, Surg, Skin/Scrotum/Merkel (CS)
    public boolean if360(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor1 == '988' || line.csSiteSpecificFactor1 == null ||
            line.rxSummSurgPrimSite == null ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId == null)
            return true
        
        if (line._csSchemaId == 'skin' || line._csSchemaId == 'scrotum' ||
            line._csSchemaId == 'merkel_cell_penis' || line._csSchemaId == 'merkel_cell_scrotum' ||
            line._csSchemaId == 'merkel_cell_skin' || line._csSchemaId == 'merkel_cell_vulva') {
            if (line.csSiteSpecificFactor1 == '998')
                return !(functions.matches(line.rxSummSurgPrimSite, /^([2-8]\d)$/))
        }
        
        return true
    }

    // ID: IF361; NAME: CS SSF 1, Upper GI Schemas (CS)
    public boolean if361(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor1 == null || line.csSiteSpecificFactor1 == '988'||
            line.csLymphNodes == null || line.regionalNodesPositive == null ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId == null)
            return true
        
        if (['esophagus','esophagus_gejunction','stomach','net_stomach'].contains(line._csSchemaId)) {
            if (line.csSiteSpecificFactor1 == '000' && line.regionalNodesPositive == '00')
                return line.csLymphNodes == '000'
            if (functions.matches(line.csSiteSpecificFactor1, /^([123]\d\d)|(400)$/) && line.regionalNodesPositive == '98')
                return line.csLymphNodes != '000'
        }
        
        return true
    }

    // ID: IF362; NAME: CS SSF 10, SSF 11, Breast (CS)
    public boolean if362(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor10 == null || line.csSiteSpecificFactor10 == '988' ||
            line.csSiteSpecificFactor11 == null || line.csSiteSpecificFactor11 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId == null)
            return true
        
        if (line._csSchemaId == 'breast') {
            if (line.csSiteSpecificFactor10 == '998')
                return line.csSiteSpecificFactor11 == '998'
        
            if (line.csSiteSpecificFactor11 == '998')
                return line.csSiteSpecificFactor10 == '998'
        
            if (line.csSiteSpecificFactor10 == '991')
                return line.csSiteSpecificFactor11 != '010'
        
            if (line.csSiteSpecificFactor11 == '010')
                return line.csSiteSpecificFactor10 != '991'
        
            if (line.csSiteSpecificFactor10 > '500' && line.csSiteSpecificFactor10 < '981')
                return line.csSiteSpecificFactor11 != '020'
        
            if (line.csSiteSpecificFactor11 == '020')
                return line.csSiteSpecificFactor10 <= '500' || line.csSiteSpecificFactor10 == '991' || line.csSiteSpecificFactor10 == '997'
        }
        return true
    }

    // ID: IF363; NAME: CS SSF 11, Lip/OralCavity/Nasal Schemas (CS)
    public boolean if363(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor11 == null || line.csSiteSpecificFactor11 == '988'||
            line.csTumorSize == null || line.csExtension == null ||
            line.rxSummSurgPrimSite == null ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId == null)
            return true
        
        if (((List)context.IF363_Schemas).contains(line._csSchemaId)) {
            if (line.csSiteSpecificFactor11 == '000')
                return line.csTumorSize == '000' && line.csExtension == '950'
        
            if (line.csSiteSpecificFactor11 == '998')
                return functions.asInt(line.rxSummSurgPrimSite) < 20
        }
        
        return true
    }

    // ID: IF364; NAME: CS SSF 11, Surg, Skin Schema (CS)
    public boolean if364(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor11 == null || line.csSiteSpecificFactor11 == '988'||
            line.rxSummSurgPrimSite == null ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId == null)
            return true
        
        if (line._csSchemaId == 'skin' && line.csSiteSpecificFactor11 == '998')
            return functions.asInt(line.rxSummSurgPrimSite) < 20
        
        return true
    }

    // ID: IF365; NAME: CS SSF 12, SSF 13, Breast (CS)
    public boolean if365(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor12 == null || line.csSiteSpecificFactor12 == '988' ||
            line.csSiteSpecificFactor13 == null || line.csSiteSpecificFactor13 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId == null)
            return true
        
        if (line._csSchemaId == 'breast') {
            if (line.csSiteSpecificFactor12 == '998' && line.csSiteSpecificFactor13 != '998')
                return false
        
            if (line.csSiteSpecificFactor13 == '998' && line.csSiteSpecificFactor12 != '998')
                return false
        }
        
        return true
    }

    // ID: IF366; NAME: CS SSF 15, SSF 9, 11, 13, 14, Breast (CS)
    public boolean if366(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if ((line.csSiteSpecificFactor9  == null && line.csSiteSpecificFactor11 == null &&
             line.csSiteSpecificFactor13 == null && line.csSiteSpecificFactor14 == null) ||
            (line.csSiteSpecificFactor9  == '988' && line.csSiteSpecificFactor11 == '988' &&
             line.csSiteSpecificFactor13 == '988' && line.csSiteSpecificFactor14 == '988') ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId == null)
            return true
        
        if (line._csSchemaId == 'breast') {
            if (line.csSiteSpecificFactor9   != '998' && line.csSiteSpecificFactor9  != '999' &&
                line.csSiteSpecificFactor9   != '988' && line.csSiteSpecificFactor9  != null &&
                (line.csSiteSpecificFactor15 == '998' || line.csSiteSpecificFactor15 == '999'))
                return false
            if (line.csSiteSpecificFactor11  != '998' && line.csSiteSpecificFactor11 != '999' &&
                line.csSiteSpecificFactor11  != '988' && line.csSiteSpecificFactor11  != null &&
                (line.csSiteSpecificFactor15 == '998' || line.csSiteSpecificFactor15 == '999'))
                return false
            if (line.csSiteSpecificFactor13  != '998' && line.csSiteSpecificFactor13 != '999' &&
                line.csSiteSpecificFactor13  != '988' && line.csSiteSpecificFactor13  != null &&
                (line.csSiteSpecificFactor15 == '998' || line.csSiteSpecificFactor15 == '999'))
                return false
            if (line.csSiteSpecificFactor14  != '998' && line.csSiteSpecificFactor14 != '999' &&
                line.csSiteSpecificFactor14  != '988' && line.csSiteSpecificFactor14  != null &&
                (line.csSiteSpecificFactor15 == '998' || line.csSiteSpecificFactor15 == '999'))
                return false
        }
        
        return true
    }

    // ID: IF367; NAME: CS SSF 2, Extension, Ovary Schema (CS)
    public boolean if367(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor2 == null || line.csSiteSpecificFactor2 == '988'||
            line.csExtension == null ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId == null)
            return true
        
        if (line._csSchemaId == 'ovary' && line.csExtension == '000')
            return line.csSiteSpecificFactor2 == '987'
        
        return true
    }

    // ID: IF368; NAME: CS SSF 2, LN, LN Eval, RNP, SmallIntestine (CS)
    public boolean if368(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor2 == null || line.csSiteSpecificFactor2 == '988' ||
            line.csLymphNodes == null || line.csLymphNodesEval == null ||
            line.regionalNodesPositive == null ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId == null)
            return true
        
        if (line._csSchemaId == 'small_intestine') {
            if (functions.matches(line.csLymphNodes, /^([12]\d\d)|(300)$/) &&
                functions.matches(line.csLymphNodesEval, /^([015])$/) &&
                functions.matches(line.regionalNodesPositive, /^(00)|(9[89])$/))
                return functions.matches(line.csSiteSpecificFactor2, /^([124]00)$/)
        }
        
        return true
    }

    // ID: IF369; NAME: CS SSF 2, Lower GI Schemas (CS)
    public boolean if369(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor2 == null || line.csSiteSpecificFactor2 == '988' ||
            line.csLymphNodes == null || line.regionalNodesPositive == null ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId == null)
            return true
        
        if (['small_intestine','appendix','carcinoid_appendix','colon','rectum','net_colon','net_rectum'].contains(line._csSchemaId)) {
            if (line.csSiteSpecificFactor2 == '000' && line.regionalNodesPositive == '00')
                return line.csLymphNodes == '000' || line.csLymphNodes == '050'
        
            if (functions.matches(line.csSiteSpecificFactor2, /^(0[1-9]\d)|([1-3]\d\d)|(400)$/) && line.regionalNodesPositive == '98')
                return line.csLymphNodes != '000'
        }
        
        return true
    }

    // ID: IF371; NAME: CS SSF 2, RX Summ--Surg, Pleura (CS)
    public boolean if371(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor2 == null || line.csSiteSpecificFactor2 == '988'||
            line.rxSummSurgPrimSite == null ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId == null)
            return true
        
        if (line._csSchemaId == 'pleura' && line.csSiteSpecificFactor2 == '998')
            return !(functions.matches(line.rxSummSurgPrimSite, /^([2-8]\d)$/))
        
        return true
    }

    // ID: IF373; NAME: CS SSF 21, TS/Ext Eval, LN Eval, Breast (CS)
    public boolean if373(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor21 == null || line.csSiteSpecificFactor21 == '988' || line.csTumorSizeExtEval == null || line.csLymphNodesEval == null ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line._csSchemaId == null)
            return true
        
        if (line._csSchemaId == 'breast') {
            if (functions.matches(line.csSiteSpecificFactor21, /^(0[123]0)$/))
                return line.csTumorSizeExtEval == '5' || line.csTumorSizeExtEval == '6' || line.csLymphNodesEval == '5' || line.csLymphNodesEval == '6'
            if (line.csSiteSpecificFactor21 == '987')
                return line.csTumorSizeExtEval != '5' && line.csTumorSizeExtEval != '6' && line.csLymphNodesEval != '5' && line.csLymphNodesEval != '6'
        }
        
        return true
    }

    // ID: IF374; NAME: CS SSF 22, SSF 23, Breast (CS)
    public boolean if374(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor22 == null || line.csSiteSpecificFactor22 == '988' ||
            line.csSiteSpecificFactor23 == null || line.csSiteSpecificFactor23 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId == null)
            return true
        
        if (line._csSchemaId == 'breast') {
            if (line.csSiteSpecificFactor22 == '998' && line.csSiteSpecificFactor23 != '998')
                return false
        
            if (line.csSiteSpecificFactor23 == '998' && line.csSiteSpecificFactor22 != '998')
                return false
        }
        
        return true
    }

    // ID: IF375; NAME: CS SSF 4, CS SSF 5, Liver Schema (CS)
    public boolean if375(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor4 == null || line.csSiteSpecificFactor4 == '988' ||
            line.csSiteSpecificFactor5 == null || line.csSiteSpecificFactor5 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId == null)
            return true
        
        if (line._csSchemaId == 'liver') {
            if (line.csSiteSpecificFactor4 == '998' && line.csSiteSpecificFactor5 != '998')
                return false
        
            if (line.csSiteSpecificFactor5 == '998' && line.csSiteSpecificFactor4 != '998')
                return false
        }
        
        return true
    }

    // ID: IF376; NAME: CS SSF 6, CS SSF 7, Liver Schema (CS)
    public boolean if376(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor6 == null || line.csSiteSpecificFactor6 == '988' ||
            line.csSiteSpecificFactor7 == null || line.csSiteSpecificFactor7 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId == null)
            return true
        
        if (line._csSchemaId == 'liver') {
            if (line.csSiteSpecificFactor6 == '998' && line.csSiteSpecificFactor7 != '998')
                return false
        
            if (line.csSiteSpecificFactor7 == '998' && line.csSiteSpecificFactor6 != '998')
                return false
        }
        
        return true
    }

    // ID: IF377; NAME: CS SSF 8, CS SSF 9, Breast (CS)
    public boolean if377(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor8 == null || line.csSiteSpecificFactor8 == '988' ||
            line.csSiteSpecificFactor9 == null || line.csSiteSpecificFactor9 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId == null)
            return true
        
        if (line._csSchemaId == 'breast') {
            if (line.csSiteSpecificFactor8 == '998' && line.csSiteSpecificFactor9 != '998')
                return false
        
            if (line.csSiteSpecificFactor9 == '998' && line.csSiteSpecificFactor8 != '998')
                return false
        }
        
        return true
    }

    // ID: IF378; NAME: CS SSF 8, RX Summ--Surg, ColoRectal (CS)
    public boolean if378(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor8 == '988' || line.csSiteSpecificFactor8 == null ||
            line.rxSummSurgPrimSite == null ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId == null)
            return true
        
        if (line._csSchemaId == 'colon' || line._csSchemaId == 'rectum') {
            if (line.csSiteSpecificFactor8 == '998')
                return !(functions.matches(line.rxSummSurgPrimSite, /^([2-8]\d)$/))
        }
        
        return true
    }

    // ID: IF379; NAME: CS SSF 9, Head and Neck Schemas (CS)
    public boolean if379(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        String ssf9 = line.csSiteSpecificFactor9
        String regNodesPos = line.regionalNodesPositive
        String scopeRegLnSur = line.rxSummScopeRegLnSur
        String behav = line.behaviorCodeIcdO3
        String schema = line._csSchemaId
        
        if (ssf9 == null || ssf9 == '988' || regNodesPos == null || scopeRegLnSur == null || behav == '0' || behav == '1' || schema == null || !((List)context.HEAD_AND_NECK_Schemas).contains(schema))
            return true
        
        // condition #1
        if (ssf9 == '000' && regNodesPos != '00')
            return false
        
        // condition #2
        if (ssf9 == '998' && regNodesPos != '00' && regNodesPos != '95' && regNodesPos != '98')
            return false
        
        // condition #3
        if (ssf9 == '999' && regNodesPos!= '98' && regNodesPos != '99')
            return false
        
        return true
    }

    // ID: IF380; NAME: Histology ICDO3, Grade, Date of DX (SEER)
    public boolean if380(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2010' || line.dateOfDiagnosisYear > '2017' ||
            line.grade == null || line.histologicTypeIcdO3 == null)
            return true
        
        if (((List)context.IF380_Hist_List_1).contains(line.histologicTypeIcdO3))
            return line.grade == '5'
        
        if (((List)context.IF380_Hist_List_2).contains(line.histologicTypeIcdO3))
            return line.grade == '6'
        
        if (line.histologicTypeIcdO3 == '9714')
            return line.grade == '5' || line.grade == '6'
        
        if (((List)context.IF380_Hist_List_3).contains(line.histologicTypeIcdO3))
            return line.grade == '8'
        
        if (((List)context.IF380_Hist_List_4).contains(line.histologicTypeIcdO3))
            return line.grade == '9'
        
        if (line.histologicTypeIcdO3 == '9831')
            return line.grade == '5' || line.grade == '8' || line.grade == '9'
        
        if (((List)context.IF380_Hist_List_5).contains(line.histologicTypeIcdO3))
            return !(functions.matches(line.grade, /^[1234]$/))
        
        return true
    }

    // ID: IF381; NAME: CS Lymph Nodes, Nodes Pos, MerkelCell Schemas (CS)
    public boolean if381(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csLymphNodes == null || line.regionalNodesPositive == null ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line._csSchemaId == null)
            return true
        
        if (line._csSchemaId == 'merkel_cell_scrotum' || line._csSchemaId == 'merkel_cell_skin') {
            if (functions.matches(line.csLymphNodes, /(^3[245]0$)/))
                return line.regionalNodesPositive != '00' && line.regionalNodesPositive != '98'
        }
        else if (line._csSchemaId == 'merkel_cell_penis') {
            if (functions.matches(line.csLymphNodes, /(^1[245]0$)/))
                return line.regionalNodesPositive != '00' && line.regionalNodesPositive != '98'
        }
        else if (line._csSchemaId == 'merkel_cell_vulva') {
            if (functions.matches(line.csLymphNodes, /(^1[12]5|120$)/))
                return line.regionalNodesPositive != '00' && line.regionalNodesPositive != '98'
        }
        
        return true
    }

    // ID: IF382; NAME: CS SSF 10, SSF 16, Testis (CS)
    public boolean if382(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor10 == '988' || line.csSiteSpecificFactor10 == null ||
            line._csSchemaId == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'testis' && functions.matches(line.csSiteSpecificFactor10, /(^99[56]$)/))
            return !(functions.matches(line.csSiteSpecificFactor16, /(^99[89]$)/))
        
        return true
    }

    // ID: IF383; NAME: CS SSF 12, SSF 13, Testis (CS)
    public boolean if383(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor12 == '988' || line.csSiteSpecificFactor12 == null ||
            line.csSiteSpecificFactor13 == '988' || line.csSiteSpecificFactor13 == null ||
            line._csSchemaId == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'testis') {
            if (line.csSiteSpecificFactor12 == '998')
                return line.csSiteSpecificFactor13 == '998'
            if (line.csSiteSpecificFactor13 == '998')
                return line.csSiteSpecificFactor12 == '998'
        }
        
        return true
    }

    // ID: IF384; NAME: CS SSF 14, SSF 15, Testis (CS)
    public boolean if384(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor14 == '988' || line.csSiteSpecificFactor14 == null ||
            line.csSiteSpecificFactor15 == '988' || line.csSiteSpecificFactor15 == null ||
            line._csSchemaId == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'testis') {
            if (line.csSiteSpecificFactor14 == '998')
                return line.csSiteSpecificFactor15 == '998'
            if (line.csSiteSpecificFactor15 == '998')
                return line.csSiteSpecificFactor14 == '998'
        }
        
        return true
    }

    // ID: IF385; NAME: CS SSF 5, Lymph Nodes, Testis (CS)
    public boolean if385(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor5 == '988' || line.csSiteSpecificFactor5 == null ||
            line.csLymphNodes == null ||
            line._csSchemaId == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'testis') {
            if (line.csSiteSpecificFactor5 == '000')
                return line.csLymphNodes == '000'
            if (functions.matches(line.csSiteSpecificFactor5, /(^0[12]\d|030$)/))
                return functions.matches(line.csLymphNodes, /(^[1-7]\d\d|800$)/)
            if (line.csLymphNodes == '510')
                return functions.matches(line.csSiteSpecificFactor5, /(^010|999$)/)
            if (line.csLymphNodes == '520')
                return functions.matches(line.csSiteSpecificFactor5, /(^020|999$)/)
            if (line.csLymphNodes == '530')
                return functions.matches(line.csSiteSpecificFactor5, /(^030|999$)/)
        }
        
        return true
    }

    // ID: IF386; NAME: CS SSF 6, SSF 12, Testis (CS)
    public boolean if386(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor6 == '988' || line.csSiteSpecificFactor6 == null ||
            line._csSchemaId == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'testis' && functions.matches(line.csSiteSpecificFactor6, /(^99[56]$)/))
            return !(functions.matches(line.csSiteSpecificFactor12, /(^99[89]$)/))
        
        return true
    }

    // ID: IF387; NAME: CS SSF 6, SSF 7, Testis (CS)
    public boolean if387(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor6 == '988' || line.csSiteSpecificFactor6 == null ||
            line.csSiteSpecificFactor7 == '988' || line.csSiteSpecificFactor7 == null ||
            line._csSchemaId == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'testis') {
            if (line.csSiteSpecificFactor6 == '998')
                return line.csSiteSpecificFactor7 == '998'
            if (line.csSiteSpecificFactor7 == '998')
                return line.csSiteSpecificFactor6 == '998'
        }
        
        return true
    }

    // ID: IF388; NAME: CS SSF 7, SSF 13, Testis (CS)
    public boolean if388(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor7 == '988' || line.csSiteSpecificFactor7 == null ||
            line._csSchemaId == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'testis' && functions.matches(line.csSiteSpecificFactor7, /(^99[56]$)/))
            return !(functions.matches(line.csSiteSpecificFactor13, /(^99[89]$)/))
        
        return true
    }

    // ID: IF389; NAME: CS SSF 8, SSF 14, Testis (CS)
    public boolean if389(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor8 == '988' || line.csSiteSpecificFactor8 == null ||
            line._csSchemaId == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'testis' && functions.matches(line.csSiteSpecificFactor8, /(^99[56]$)/))
            return !(functions.matches(line.csSiteSpecificFactor14, /(^99[89]$)/))
        
        return true
    }

    // ID: IF390; NAME: CS SSF 8, SSF 9, Testis (CS)
    public boolean if390(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor8 == '988' || line.csSiteSpecificFactor8 == null ||
            line.csSiteSpecificFactor9 == '988' || line.csSiteSpecificFactor9 == null ||
            line._csSchemaId == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'testis') {
            if (line.csSiteSpecificFactor8 == '998')
                return line.csSiteSpecificFactor9 == '998'
            if (line.csSiteSpecificFactor9 == '998')
                return line.csSiteSpecificFactor8 == '998'
        }
        
        return true
    }

    // ID: IF391; NAME: CS SSF 9, SSF 15, Testis (CS)
    public boolean if391(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor9 == '988' || line.csSiteSpecificFactor9 == null ||
            line._csSchemaId == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'testis' && functions.matches(line.csSiteSpecificFactor9, /(^99[56]$)/))
            return !(functions.matches(line.csSiteSpecificFactor15, /(^99[89]$)/))
        
        return true
    }

    // ID: IF392; NAME: CS TS/Ext Eval, Surg/Rad Seq, Prostate (CS)
    public boolean if392(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csTumorSizeExtEval == null || line.rxSummSurgRadSeq == null ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId == null)
            return true
        
        if (line._csSchemaId == 'prostate' && line.csTumorSizeExtEval == '4')
            return !(functions.matches(line.rxSummSurgRadSeq, /(^2|4$)/))
        
        return true
    }

    // ID: IF393; NAME: CS TS/Ext Eval, Sys/Surg Seq, Prostate (CS)
    public boolean if393(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csTumorSizeExtEval == null || line.rxSummSystemicSurSeq == null ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId == null)
            return true
        
        if (line._csSchemaId == 'prostate' && line.csTumorSizeExtEval == '4')
            return !(functions.matches(line.rxSummSystemicSurSeq, /(^2|4$)/))
        
        return true
    }

    // ID: IF394; NAME: CS Verify CStage Version 0205xx (CS)
    public boolean if394(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear > '2017' || functions.getCsVersion() ==~ /(^0205\d\d$)/
    }

    // ID: IF395; NAME: Sequence number and year of diagnosis conflict (IF395)
    public boolean if395(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.dateOfDiagnosisYear == null || (!(functions.matches(line.sequenceNumberCentral, /(^6\d|7\d|8[0-8]$)/) && line.dateOfDiagnosisYear < '2003'))
    }

    // ID: IF396; NAME: CS SSF 25, PeritoneumFemaleGen (SEER)
    public boolean if396(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        String dxYear = line.dateOfDiagnosisYear
        if (line.primarySite == null || line.histologicTypeIcdO3 == null ||
            dxYear == null || dxYear < '2004' || dxYear > '2017' || ((dxYear == '2016' || dxYear == '2017') && line.csExtension == null))
            return true
        
        Integer hist = functions.asInt(line.histologicTypeIcdO3)
        if (functions.matches(line.primarySite, /(^C48[128]$)/) &&
            (functions.between(hist, 8000, 8576) || functions.between(hist, 8590, 8671) ||
             functions.between(hist, 8930, 8934) || functions.between(hist, 8940, 9110)) &&
             (line.sex == '2' || line.sex == '6'))
             return functions.matches(line.csSiteSpecificFactor25, /(^002|100$)/)
        
        return true
    }

    // ID: IF400; NAME: Birthplace--Country, Birthplace--State (NAACCR)
    public boolean if400(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.birthplaceCountry == null || line.birthplaceState == null)
            return true
        
        if (line.birthplaceState == 'XX' && line.birthplaceCountry == 'ZZX')
            return false
        
        if (((Map)((Map)context.Country_State).getOrDefault(line.birthplaceCountry, [:])).containsKey(line.birthplaceState))
            return true
        
        return false
    }

    // ID: IF401; NAME: Birthplace--State, Date of Diagnosis (NAACCR)
    public boolean if401(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (functions.asInt(line.dateOfDiagnosisYear) > 2012) {
            if (['NN','MM','PP','XN'].contains(line.birthplaceState))
                return false
        }
        
        return true
    }

    // ID: IF403; NAME: CS Ext, Surg, TS/Ext Eval, Prostate (CS)
    public boolean if403(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || functions.asInt(line.dateOfDiagnosisYear) < 2012)
            return true
        
        if (line.csExtension == null || line.rxSummSurgPrimSite == null || line.csTumorSizeExtEval == null)
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'prostate')
            return true
        
        Integer csExtensionInt = functions.asInt(line.csExtension)
        Integer rxSummSurgPrimSiteInt = functions.asInt(line.rxSummSurgPrimSite)
        if (csExtensionInt >= 100 && csExtensionInt <= 150) {
            if (rxSummSurgPrimSiteInt >= 0 && rxSummSurgPrimSiteInt <= 29) {
                if (line.csTumorSizeExtEval != '1' && line.csTumorSizeExtEval != '3')
                    return false
            }
        }
        
        return true
    }

    // ID: IF404; NAME: CS Ext,TS/Ext Eval, SSF 1, MelanomaConjunc (CS)
    public boolean if404(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || functions.asInt(line.dateOfDiagnosisYear) < 2010)
            return true
        
        if (line.csExtension == null)
            return true
        
        if (line.csSiteSpecificFactor1 == null || line.csSiteSpecificFactor1 == '988')
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'melanoma_conjunctiva')
            return true
        
        if (['300','310','315','320','330','335','445','450','470','475','480','485','490','500'].contains(line.csExtension)
            && (['2','3','6','8'].contains(line.csTumorSizeExtEval))) {
                if (line.csSiteSpecificFactor1 == '000' || line.csSiteSpecificFactor1 == '998')
                    return false
        }
        
        if (['325','495'].contains(line.csExtension) && ['2','3','6','8'].contains(line.csTumorSizeExtEval))
            return false
        
        return true
    }

    // ID: IF405; NAME: CS Extension, Histology, Grade, Thyroid (CS)
    public boolean if405(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || functions.asInt(line.dateOfDiagnosisYear) < 2010)
            return true
        
        if (line.csExtension == null || line.grade == null)
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'thyroid')
            return true
        
        if (((List)context.IF405_Hist_List).contains(functions.asInt(line.histologicTypeIcdO3)) && line.grade == '4') {
            if (['405','410','415','420','490'].contains(line.csExtension))
                return false
        }
        if (['8020','8021','8030','8031','8032'].contains(line.histologicTypeIcdO3)) {
            if (['405','410','415','420','490'].contains(line.csExtension))
                return false
        }
        
        return true
    }

    // ID: IF406; NAME: CS Extension, SSF 1, Conjunctiva Schema (CS)
    public boolean if406(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || functions.asInt(line.dateOfDiagnosisYear) < 2010)
            return true
        
        if (line.csExtension == null)
            return true
        
        if (line.csSiteSpecificFactor1 == null || line.csSiteSpecificFactor1 == '988')
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'conjunctiva')
            return true
        
        if (functions.matches(line.csExtension, /(^(1[1245]0|350)$)/)) {
            if (line.csSiteSpecificFactor1 == '000')
                return false
        }
        
        return true
    }

    // ID: IF407; NAME: CS Extension, SSF 2, KidneyRenalPelvis (CS)
    public boolean if407(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csExtension == null || line.csSiteSpecificFactor2 == null)
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'kidney_renal_pelvis')
            return true
        
        if (line.csExtension == '600' && ['3','6'].contains(line.csTumorSizeExtEval)) {
            if (['000','999'].contains(line.csSiteSpecificFactor2))
               return false
        }
        
        if (line.primarySite == 'C659') {
            Integer ssf2Int = functions.asInt(line.csSiteSpecificFactor2)
            Integer extInt = functions.asInt(line.csExtension)
            if ((ssf2Int >= 1 && ssf2Int <= 980) || ssf2Int == 991) {
                if ((extInt >= 50 && extInt <= 400) || extInt == 610 || extInt == 950 || extInt == 999)
                    return false
            }
        }
        
        return true
    }

    // ID: IF408; NAME: CS Extension, SSF 2, Lung Schema (CS)
    public boolean if408(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csExtension == null || line.csSiteSpecificFactor2 == null ||
            line.csSiteSpecificFactor2 == '988')
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'lung')
            return true
        
        Integer extInt = functions.asInt(line.csExtension)
        if (extInt >= 0 && extInt <= 410) {
            if (!(['000','998','999'].contains(line.csSiteSpecificFactor2)))
                return false
        }
        
        if (functions.matches(line.csSiteSpecificFactor2, /(^0[124]0$)/)) {
            if (!(extInt >= 420 && extInt <= 810) && extInt != 999)
                return false
        }
        
        if (line.csSiteSpecificFactor2 == '030') {
            if (!(extInt >= 600 && extInt <= 810) && extInt != 999)
                return false
        }
        
        return true
    }

    // ID: IF409; NAME: CS Extension, SSF 2, MelanomaChoroid (CS)
    public boolean if409(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || functions.asInt(line.dateOfDiagnosisYear) < 2010)
            return true
        
        if (line.csExtension == null || line.csSiteSpecificFactor2 == null ||
            line.csSiteSpecificFactor2 == '988')
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'melanoma_choroid')
            return true
        
        if (functions.matches(line.csExtension, /(^1[5678]0$)/)) {
            if (line.csSiteSpecificFactor2 == '000')
                return false
        }
        
        return true
    }

    // ID: IF410; NAME: CS Extension, SSF 2, MelanomaCiliaryBody (CS)
    public boolean if410(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || functions.asInt(line.dateOfDiagnosisYear) < 2010)
            return true
        
        if (line.csExtension == null || line.csSiteSpecificFactor2 == null ||
            line.csSiteSpecificFactor2 == '988')
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'melanoma_ciliary_body')
            return true
        
        if (functions.matches(line.csExtension, /(^1[68]0$)/)) {
            if (line.csSiteSpecificFactor2 == '000')
                return false
        }
        
        return true
    }

    // ID: IF411; NAME: CS Extension, SSF 3, MelanomaChoroid (CS)
    public boolean if411(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || functions.asInt(line.dateOfDiagnosisYear) < 2010)
            return true
        
        if (line.csExtension == null || line.csSiteSpecificFactor3 == null ||
            line.csSiteSpecificFactor3 == '988')
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'melanoma_choroid')
            return true
        
        if (functions.matches(line.csExtension, /(^1[5678]0$)/)) {
            if (line.csSiteSpecificFactor3 == '000')
                return false
        }
        
        return true
    }

    // ID: IF412; NAME: CS Extension, SSF 3, MelanomaCiliaryBody (CS)
    public boolean if412(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || functions.asInt(line.dateOfDiagnosisYear) < 2010)
            return true
        
        if (line.csExtension == null || line.csSiteSpecificFactor3 == null ||
            line.csSiteSpecificFactor3 == '988')
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'melanoma_ciliary_body')
            return true
        
        if (functions.matches(line.csExtension, /(^1[68]0$)/)) {
            if (line.csSiteSpecificFactor3 == '000')
                return false
        }
        
        return true
    }

    // ID: IF413; NAME: CS Extension, Tumor Size, Lung Schema (CS)
    public boolean if413(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || functions.asInt(line.dateOfDiagnosisYear) < 2010)
            return true
        
        if (line.csExtension == null || line.csTumorSize == null)
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'lung')
            return true
        
        if (line.csExtension == '000') {
            if (line.csTumorSize == '997' || line.csTumorSize == '998')
                return false
        }
        
        return true
    }

    // ID: IF414; NAME: CS LN, Nodes Eval, SSF 3, MelanomaSkin (CS)
    public boolean if414(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || functions.asInt(line.dateOfDiagnosisYear) < 2010)
            return true
        
        if (line.csLymphNodes == null || line.csLymphNodesEval == null ||
            line.csSiteSpecificFactor3 == null || line.csSiteSpecificFactor3 == '988')
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'melanoma_skin')
            return true
        
        if (line.csLymphNodes == '010') {
            if (['0','1','5','9'].contains(line.csLymphNodesEval))
               return false
        }
        if (((List)context.IF414_Lymph_Nodes).contains(functions.asInt(line.csLymphNodes))) {
            if (['0','1','5','9'].contains(line.csLymphNodesEval)) {
                if (['010','100'].contains(line.csSiteSpecificFactor3))
                    return false
            }
        }
        if (['124','158'].contains(line.csLymphNodes)) {
            if (['0','1','5','9'].contains(line.csLymphNodesEval)) {
                if (line.csSiteSpecificFactor3 != '150')
                    return false
             }
        }
        if (line.csLymphNodes == '155') {
            if (['0','1','5','9'].contains(line.csLymphNodesEval)) {
                if (line.csSiteSpecificFactor3 == '010')
                    return false
             }
        }
        
        return true
    }

    // ID: IF415; NAME: CS LN, Nodes Eval, SSF 3, MerkelCellPenis (CS)
    public boolean if415(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || functions.asInt(line.dateOfDiagnosisYear) < 2010)
            return true
        
        if (line.csLymphNodes == null ||
            line.csSiteSpecificFactor3 == null || line.csSiteSpecificFactor3 == '988')
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'merkel_cell_penis')
            return true
        
        Integer lymphNodesInt = functions.asInt(line.csLymphNodes)
        if (lymphNodesInt == 10 || (lymphNodesInt >= 100 && lymphNodesInt <= 400) || lymphNodesInt == 500) {
            if (['000','005','100'].contains(line.csSiteSpecificFactor3))
                return false
        }
        if (line.csLymphNodes == '010') {
            if (['2','3','6','8'].contains(line.csLymphNodesEval)) {
                if (line.csSiteSpecificFactor3 == '150')
                    return false
            }
        }
        if ((lymphNodesInt >= 100 && lymphNodesInt <= 400) || lymphNodesInt == 500) {
            if (['0','1','5','9'].contains(line.csLymphNodesEval)) {
                if (line.csSiteSpecificFactor3 == '010')
                    return false
             }
        }
        
        return true
    }

    // ID: IF416; NAME: CS LN, Nodes Eval, SSF 3, MerkelCellScrotum (CS)
    public boolean if416(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || functions.asInt(line.dateOfDiagnosisYear) < 2010)
            return true
        
        if (line.csLymphNodes == null ||
            line.csSiteSpecificFactor3 == null || line.csSiteSpecificFactor3 == '988')
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'merkel_cell_scrotum')
            return true
        
        Integer lymphNodesInt = functions.asInt(line.csLymphNodes)
        if (lymphNodesInt == 10 || (lymphNodesInt >= 100 && lymphNodesInt <= 360)) {
            if (['000','005','100'].contains(line.csSiteSpecificFactor3))
                return false
        }
        if (line.csLymphNodes == '010') {
            if (['2','3','6','8'].contains(line.csLymphNodesEval)) {
                if (line.csSiteSpecificFactor3 == '150')
                    return false
            }
        }
        if (lymphNodesInt >= 100 && lymphNodesInt <= 360) {
            if (['0','1','5','9'].contains(line.csLymphNodesEval)) {
                if (line.csSiteSpecificFactor3 == '010')
                    return false
            }
        }
        
        return true
    }

    // ID: IF417; NAME: CS LN, Nodes Eval, SSF 3, MerkelCellSkin (CS)
    public boolean if417(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || functions.asInt(line.dateOfDiagnosisYear) < 2010)
            return true
        
        if (line.csLymphNodes == null ||
            line.csSiteSpecificFactor3 == null || line.csSiteSpecificFactor3 == '988')
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'merkel_cell_skin')
            return true
        
        Integer lymphNodesInt = functions.asInt(line.csLymphNodes)
        if (lymphNodesInt == 10 || (lymphNodesInt >= 100 && lymphNodesInt <= 360)) {
            if (['000','005','100'].contains(line.csSiteSpecificFactor3))
                return false
        }
        if (line.csLymphNodes == '010') {
            if (['2','3','6','8'].contains(line.csLymphNodesEval)) {
                if (line.csSiteSpecificFactor3 == '150')
                    return false
            }
        }
        if (lymphNodesInt >= 100 && lymphNodesInt <= 360) {
            if (['0','1','5','9'].contains(line.csLymphNodesEval)) {
                if (line.csSiteSpecificFactor3 == '010')
                    return false
            }
        }
        
        return true
    }

    // ID: IF418; NAME: CS LN, Nodes Eval, SSF 3, MerkelCellVulva (CS)
    public boolean if418(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || functions.asInt(line.dateOfDiagnosisYear) < 2010)
            return true
        
        if (line.csLymphNodes == null ||
            line.csSiteSpecificFactor3 == null || line.csSiteSpecificFactor3 == '988')
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'merkel_cell_vulva')
            return true
        
        Integer lymphNodesInt = functions.asInt(line.csLymphNodes)
        if (lymphNodesInt == 10 || (lymphNodesInt >= 105 && lymphNodesInt <= 109) || (lymphNodesInt >= 114 && lymphNodesInt <= 130) || lymphNodesInt == 600) {
            if (['000','005','100'].contains(line.csSiteSpecificFactor3))
                return false
        }
        if (line.csLymphNodes == '010') {
            if (['2','3','6','8'].contains(line.csLymphNodesEval)) {
                if (line.csSiteSpecificFactor3 == '150')
                    return false
            }
        }
        if ((lymphNodesInt >= 105 && lymphNodesInt <= 109) || (lymphNodesInt >= 114 && lymphNodesInt <= 130) || lymphNodesInt == 600) {
            if (['0','1','5','9'].contains(line.csLymphNodesEval)) {
                if (line.csSiteSpecificFactor3 == '010')
                    return false
            }
        }
        
        return true
    }

    // ID: IF419; NAME: CS Lymph Nodes, LN Nodes Eval, RNP, Testis (CS)
    public boolean if419(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || functions.asInt(line.dateOfDiagnosisYear) < 2010)
            return true
        
        if (line.csLymphNodes == null || line.csLymphNodesEval == null ||
            line.regionalNodesPositive == null)
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'testis')
            return true
        
        Integer csLymphNodesInt = functions.asInt(line.csLymphNodes)
        if (csLymphNodesInt >= 100 && csLymphNodesInt <= 500) {
            if (['2','3','6','8'].contains(line.csLymphNodesEval)) {
                if (['00','98','99'].contains(line.regionalNodesPositive))
                   return false
            }
        }
        
        return true
    }

    // ID: IF420; NAME: CS Lymph Nodes, SSF 17, Penis (CS)
    public boolean if420(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || functions.asInt(line.dateOfDiagnosisYear) < 2010)
            return true
        
        if (line.csLymphNodes == null || line.csSiteSpecificFactor17 == null ||
            line.csSiteSpecificFactor17 == '988')
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'penis')
            return true
        
        if (line.csSiteSpecificFactor17 == '000')
            return line.csLymphNodes == '000'
        
        if (line.csLymphNodes == '000')
            return line.csSiteSpecificFactor17 == '000'
        
        return true
    }

    // ID: IF421; NAME: CS Mets at DX, SSF 4, MelanomaChor/Cil/Iris (CS)
    public boolean if421(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || functions.asInt(line.dateOfDiagnosisYear) < 2010)
            return true
        
        if (line.csMetsAtDx == null || line.csSiteSpecificFactor4 == null ||
            line.csSiteSpecificFactor4 == '988')
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (!['melanoma_choroid','melanoma_ciliary_body','melanoma_iris'].contains(line._csSchemaId))
            return true
        
        if (['10','40','50','52','54','56','60'].contains(line.csMetsAtDx))
            return line.csSiteSpecificFactor4 != '000'
        
        return true
    }

    // ID: IF422; NAME: CS SSF 1, Surg, Urothelial Schemas (CS)
    public boolean if422(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.rxSummSurgPrimSite == null || line.csSiteSpecificFactor1 == null ||
            line.csSiteSpecificFactor1 == '988')
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (!['kidney_renal_pelvis','bladder','urethra'].contains(line._csSchemaId))
            return true
        
        if (line.csSiteSpecificFactor1 == '998')
            return functions.matches(line.rxSummSurgPrimSite, /(^[01]\d|99$)/)
        
        return true
    }

    // ID: IF423; NAME: CS SSF 12, SSF 13, Prostate Schema (CS)
    public boolean if423(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor12 == null ||
            line.csSiteSpecificFactor13 == null ||
            line.csSiteSpecificFactor12 == '988' ||
            line.csSiteSpecificFactor13 == '988')
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'prostate')
            return true
        
        Integer ssf12Int = functions.asInt(line.csSiteSpecificFactor12)
        Integer ssf13Int = functions.asInt(line.csSiteSpecificFactor13)
        if (ssf13Int >= 1 && ssf13Int <= 101) {
            if (ssf12Int != 991 && ssf12Int > ssf13Int && ssf12Int != 999)
                return false
        }
        if (ssf13Int == 991) {
            if (!(ssf12Int >= 0 && ssf12Int <= 101) && ssf12Int != 991 && ssf12Int != 999)
                return false
        }
        if (ssf13Int == 998 && ssf12Int != 998)
            return false
        if (ssf12Int == 998 && ssf13Int != 998)
            return false
        
        return true
    }

    // ID: IF424; NAME: CS SSF 2, Ext, KidneyRenalPelvis (CS)
    public boolean if424(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor2 == null ||
            line.csExtension == null ||
            line.csSiteSpecificFactor2 == '988')
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'kidney_renal_pelvis')
            return true
        
        Integer ssf2Int = functions.asInt(line.csSiteSpecificFactor2)
        Integer extInt = functions.asInt(line.csExtension)
        if ((ssf2Int >= 1 && ssf2Int <= 980) || ssf2Int == 991) {
            if (!(extInt >= 600 && extInt <= 810) && extInt != 999)
                return false
        }
        
        return true
    }

    // ID: IF425; NAME: CS SSF 2, Lymph Nodes, Bladder (CS)
    public boolean if425(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor2 == null ||
            line.csLymphNodes == null ||
            line.csSiteSpecificFactor2 == '988')
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'bladder')
            return true
        
        Integer ssf2Int = functions.asInt(line.csSiteSpecificFactor2)
        Integer lnInt = functions.asInt(line.csLymphNodes)
        
        if (ssf2Int == 0 && lnInt != 0 && lnInt != 999)
            return false
        if (lnInt == 0 && ssf2Int != 0 && ssf2Int != 999)
            return false
        
        if ((ssf2Int >= 1 && ssf2Int <= 980) || (ssf2Int >= 990 && ssf2Int <= 997)) {
            if (lnInt != 150 && lnInt != 250 && !(lnInt >= 350 && lnInt <= 450) &&
                lnInt != 505 && lnInt != 800)
                return false
        }
        if (lnInt == 999) {
            if (ssf2Int != 0 && ssf2Int != 999)
                return false
        }
        
        return true
    }

    // ID: IF426; NAME: CS SSF 2, Lymph Nodes, Vagina (CS)
    public boolean if426(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor2 == null ||
            line.csLymphNodes == null ||
            line.csSiteSpecificFactor2 == '988')
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'vagina')
            return true
        
        Integer lnInt = functions.asInt(line.csLymphNodes)
        
        if ([150,400,425,475].contains(lnInt)) {
            if (line.csSiteSpecificFactor2 != '010')
                return false
        }
        
        return true
    }

    // ID: IF427; NAME: CS SSF 2, Mets at DX, Vagina (CS)
    public boolean if427(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor2 == null ||
            line.csMetsAtDx == null ||
            line.csSiteSpecificFactor2 == '988')
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'vagina')
            return true
        
        Integer metsInt = functions.asInt(line.csMetsAtDx)
        
        if ([20,22].contains(metsInt)) {
            if (line.csSiteSpecificFactor2 != '010')
                return false
        }
        
        return true
    }

    // ID: IF428; NAME: CS SSF 2, SSF 3, Vagina (CS)
    public boolean if428(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor2 == null ||
            line.csSiteSpecificFactor3 == null ||
            line.csSiteSpecificFactor2 == '988' ||
            line.csSiteSpecificFactor3 == '988')
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'vagina')
            return true
        
        if (line.csSiteSpecificFactor2 == '998' && line.csSiteSpecificFactor3 != '998')
            return false
        if (line.csSiteSpecificFactor3 == '998' && line.csSiteSpecificFactor2 != '998')
            return false
        
        return true
    }

    // ID: IF429; NAME: CS SSF 2, Surg, KidneyRenalPelvis (CS)
    public boolean if429(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor2 == null ||
            line.rxSummSurgPrimSite == null ||
            line.csSiteSpecificFactor2 == '988')
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'kidney_renal_pelvis')
            return true
        
        Integer rxSummSurgPrimSiteInt = functions.asInt(line.rxSummSurgPrimSite)
        if (line.csSiteSpecificFactor2 == '998') {
            if (!(rxSummSurgPrimSiteInt >= 0 && rxSummSurgPrimSiteInt <= 19) && rxSummSurgPrimSiteInt != 99)
                return false
        }
        
        return true
    }

    // ID: IF430; NAME: CS SSF 3, Lymph Nodes, Bladder (CS)
    public boolean if430(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor3 == null ||
            line.csLymphNodes == null ||
            line.csSiteSpecificFactor3 == '988')
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'bladder')
            return true
        
        if (line.csSiteSpecificFactor3 == '000' &&  line.csLymphNodes != '000' && line.csLymphNodes != '999')
            return false
        
        if (line.csLymphNodes == '000' &&  line.csSiteSpecificFactor3 != '000' && line.csSiteSpecificFactor3 != '999')
            return false
        
        if (line.csLymphNodes == '999' && line.csSiteSpecificFactor3 != '999' && line.csSiteSpecificFactor3 != '000')
            return false
        
        return true
    }

    // ID: IF431; NAME: CS SSF 3, RX Summ--Scope Reg LN Sur, Vagina (CS)
    public boolean if431(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor3 == null ||
            line.rxSummScopeRegLnSur == null ||
            line.csSiteSpecificFactor3 == '988')
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'vagina')
            return true
        
        if ((line.csSiteSpecificFactor3 == '030' || line.csSiteSpecificFactor3 == '040') && line.rxSummScopeRegLnSur == '0')
            return false
        
        return true
    }

    // ID: IF432; NAME: CS SSF 4, Mets at DX, Vagina (CS)
    public boolean if432(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor4 == null ||
            line.csMetsAtDx == null ||
            line.csSiteSpecificFactor4 == '988')
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'vagina')
            return true
        
        if (line.csSiteSpecificFactor4 == '010' && line.csMetsAtDx != '30' && line.csMetsAtDx != '35' &&
                line.csMetsAtDx != '55' && line.csMetsAtDx != '58')
            return false
        
        return true
    }

    // ID: IF433; NAME: CS SSF 4, SSF 5, Vagina (CS)
    public boolean if433(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor4 == null ||
            line.csSiteSpecificFactor5 == null ||
            line.csSiteSpecificFactor4 == '988' ||
            line.csSiteSpecificFactor5 == '988')
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'vagina')
            return true
        
        if (line.csSiteSpecificFactor4 == '998' && line.csSiteSpecificFactor5 != '998')
            return false
        if (line.csSiteSpecificFactor5 == '998' && line.csSiteSpecificFactor4 != '998')
            return false
        
        return true
    }

    // ID: IF434; NAME: CS SSF 5, SSF 7, RX Summ--Surg Other, Vagina (CS)
    public boolean if434(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor5 == null ||
            line.csSiteSpecificFactor7 == null ||
            line.rxSummSurgOthRegDis == null ||
            line.csSiteSpecificFactor5 == '988' ||
            line.csSiteSpecificFactor7 == '988')
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'vagina')
            return true
        
        if ((line.csSiteSpecificFactor5 == '040' || line.csSiteSpecificFactor7 == '040') && line.rxSummSurgOthRegDis == '0')
            return false
        
        return true
    }

    // ID: IF435; NAME: CS SSF 6, Mets at DX, Vagina (CS)
    public boolean if435(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor6 == null ||
            line.csMetsAtDx == null ||
            line.csSiteSpecificFactor6 == '988')
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'vagina')
            return true
        
        if (line.csSiteSpecificFactor6 == '010' && line.csMetsAtDx != '35' && line.csMetsAtDx != '55' && line.csMetsAtDx != '58')
            return false
        
        return true
    }

    // ID: IF436; NAME: CS SSF 6, SSF 7, Vagina (CS)
    public boolean if436(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor6 == null ||
            line.csSiteSpecificFactor7 == null ||
            line.csSiteSpecificFactor6 == '988' ||
            line.csSiteSpecificFactor7 == '988')
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'vagina')
            return true
        
        if (line.csSiteSpecificFactor6 == '998' && line.csSiteSpecificFactor7 != '998')
            return false
        if (line.csSiteSpecificFactor7 == '998' && line.csSiteSpecificFactor6 != '998')
            return false
        
        return true
    }

    // ID: IF437; NAME: CS SSF 7, 8, 12, 13, Prostate Schema (CS)
    public boolean if437(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor7 == null || line.csSiteSpecificFactor8 == null || line.csSiteSpecificFactor12 == null || line.csSiteSpecificFactor13 == null)
            return true
        
        if (line.csSiteSpecificFactor7 == '988' || line.csSiteSpecificFactor8 == '988' || line.csSiteSpecificFactor12 == '988' || line.csSiteSpecificFactor13 == '988')
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'prostate')
            return true
        
        if (line.csSiteSpecificFactor7 == '998' && line.csSiteSpecificFactor8 == '998') {
            if (line.csSiteSpecificFactor12 == '998' && line.csSiteSpecificFactor13 == '998')
                return true
            return false
        }
        Integer rxSummSurgPrimSiteInt = functions.asInt(line.rxSummSurgPrimSite)
        if (line.csSiteSpecificFactor12 == '998' && line.csSiteSpecificFactor13 == '998' &&
            rxSummSurgPrimSiteInt >= 0 && rxSummSurgPrimSiteInt <= 17) {
            if (line.csSiteSpecificFactor7 == '998' && line.csSiteSpecificFactor8 == '998')
                return true
            return false
        }
        
        return true
    }

    // ID: IF438; NAME: CS SSF 7, SSF 8, Prostate Schema (CS)
    public boolean if438(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor7 == null || line.csSiteSpecificFactor8 == null || line.csSiteSpecificFactor8 == '988' || line.csSiteSpecificFactor7 == '988')
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'prostate')
            return true
        
        
        if (line.csSiteSpecificFactor7 == '998' && line.csSiteSpecificFactor8 != '998')
            return false
        if (line.csSiteSpecificFactor8 == '998' && line.csSiteSpecificFactor7 != '998')
            return false
        
        if (line.csSiteSpecificFactor7 == '011' && line.csSiteSpecificFactor8 != '002')
            return false
        if (line.csSiteSpecificFactor7 == '012' && line.csSiteSpecificFactor8 != '003')
            return false
        if (line.csSiteSpecificFactor7 == '013' && line.csSiteSpecificFactor8 != '004')
            return false
        if (line.csSiteSpecificFactor7 == '014' && line.csSiteSpecificFactor8 != '005')
            return false
        if (line.csSiteSpecificFactor7 == '015' && line.csSiteSpecificFactor8 != '006')
            return false
        if (line.csSiteSpecificFactor7 == '019' && !(['002','003','004','005','006','999'].contains(line.csSiteSpecificFactor8)))
            return false
        if (line.csSiteSpecificFactor7 == '021' && line.csSiteSpecificFactor8 != '003')
            return false
        if (line.csSiteSpecificFactor7 == '022' && line.csSiteSpecificFactor8 != '004')
            return false
        if (line.csSiteSpecificFactor7 == '023' && line.csSiteSpecificFactor8 != '005')
            return false
        if (line.csSiteSpecificFactor7 == '024' && line.csSiteSpecificFactor8 != '006')
            return false
        if (line.csSiteSpecificFactor7 == '025' && line.csSiteSpecificFactor8 != '007')
            return false
        if (line.csSiteSpecificFactor7 == '029' && !(['003','004','005','006','007','999'].contains(line.csSiteSpecificFactor8)))
            return false
        if (line.csSiteSpecificFactor7 == '031' && line.csSiteSpecificFactor8 != '004')
            return false
        if (line.csSiteSpecificFactor7 == '032' && line.csSiteSpecificFactor8 != '005')
            return false
        if (line.csSiteSpecificFactor7 == '033' && line.csSiteSpecificFactor8 != '006')
            return false
        if (line.csSiteSpecificFactor7 == '034' && line.csSiteSpecificFactor8 != '007')
            return false
        if (line.csSiteSpecificFactor7 == '035' && line.csSiteSpecificFactor8 != '008')
            return false
        if (line.csSiteSpecificFactor7 == '039' && !(['004','005','006','007','008','999'].contains(line.csSiteSpecificFactor8)))
            return false
        if (line.csSiteSpecificFactor7 == '041' && line.csSiteSpecificFactor8 != '005')
            return false
        if (line.csSiteSpecificFactor7 == '042' && line.csSiteSpecificFactor8 != '006')
            return false
        if (line.csSiteSpecificFactor7 == '043' && line.csSiteSpecificFactor8 != '007')
            return false
        if (line.csSiteSpecificFactor7 == '044' && line.csSiteSpecificFactor8 != '008')
            return false
        if (line.csSiteSpecificFactor7 == '045' && line.csSiteSpecificFactor8 != '009')
            return false
        if (line.csSiteSpecificFactor7 == '049' && !(['005','006','007','008','009','999'].contains(line.csSiteSpecificFactor8)))
            return false
        if (line.csSiteSpecificFactor7 == '051' && line.csSiteSpecificFactor8 != '006')
            return false
        if (line.csSiteSpecificFactor7 == '052' && line.csSiteSpecificFactor8 != '007')
            return false
        if (line.csSiteSpecificFactor7 == '053' && line.csSiteSpecificFactor8 != '008')
            return false
        if (line.csSiteSpecificFactor7 == '054' && line.csSiteSpecificFactor8 != '009')
            return false
        if (line.csSiteSpecificFactor7 == '055' && line.csSiteSpecificFactor8 != '010')
            return false
        if (line.csSiteSpecificFactor7 == '059' && !(['006','007','008','009','010','999'].contains(line.csSiteSpecificFactor8)))
            return false
        
        return true
    }

    // ID: IF439; NAME: CS SSF 9, SSF 10, Prostate Schema (CS)
    public boolean if439(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.typeOfReportingSource == '7' || (line.registryId == '0000001562' && line.dateOfDiagnosisYear < '2003'))
            return true
        
        if (line.csSiteSpecificFactor9 == null || line.csSiteSpecificFactor10 == null || line.csSiteSpecificFactor9 == '988' || line.csSiteSpecificFactor10 == '988')
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId != 'prostate')
            return true
        
        if (functions.matches(line.rxSummSurgPrimSite, /(^[3578]0$)/) ||
            line.typeOfReportingSource == '6' ||
            line.csTumorSizeExtEval == '3' || line.csTumorSizeExtEval == '8') {
            if (line.csSiteSpecificFactor9 == '998' || line.csSiteSpecificFactor10 == '998')
                return false
        }
        if (!(functions.matches(line.rxSummSurgPrimSite, /(^[3578]0|99$)/)) &&
            line.typeOfReportingSource != '6' && line.typeOfReportingSource != null &&
            line.csTumorSizeExtEval != '3' && line.csTumorSizeExtEval != '8' && line.csTumorSizeExtEval != '9' && line.csTumorSizeExtEval != null) {
            if (line.csSiteSpecificFactor9 != '998' || line.csSiteSpecificFactor10 != '998')
                return false
            return true
        }
        
        if (line.csSiteSpecificFactor9 == '011' && line.csSiteSpecificFactor10 != '002')
            return false
        if (line.csSiteSpecificFactor9 == '012' && line.csSiteSpecificFactor10 != '003')
            return false
        if (line.csSiteSpecificFactor9 == '013' && line.csSiteSpecificFactor10 != '004')
            return false
        if (line.csSiteSpecificFactor9 == '014' && line.csSiteSpecificFactor10 != '005')
            return false
        if (line.csSiteSpecificFactor9 == '015' && line.csSiteSpecificFactor10 != '006')
            return false
        if (line.csSiteSpecificFactor9 == '019' && !(['002','003','004','005','006','999'].contains(line.csSiteSpecificFactor10)))
            return false
        if (line.csSiteSpecificFactor9 == '021' && line.csSiteSpecificFactor10 != '003')
            return false
        if (line.csSiteSpecificFactor9 == '022' && line.csSiteSpecificFactor10 != '004')
            return false
        if (line.csSiteSpecificFactor9 == '023' && line.csSiteSpecificFactor10 != '005')
            return false
        if (line.csSiteSpecificFactor9 == '024' && line.csSiteSpecificFactor10 != '006')
            return false
        if (line.csSiteSpecificFactor9 == '025' && line.csSiteSpecificFactor10 != '007')
            return false
        if (line.csSiteSpecificFactor9 == '029' && !(['003','004','005','006','007','999'].contains(line.csSiteSpecificFactor10)))
            return false
        if (line.csSiteSpecificFactor9 == '031' && line.csSiteSpecificFactor10 != '004')
            return false
        if (line.csSiteSpecificFactor9 == '032' && line.csSiteSpecificFactor10 != '005')
            return false
        if (line.csSiteSpecificFactor9 == '033' && line.csSiteSpecificFactor10 != '006')
            return false
        if (line.csSiteSpecificFactor9 == '034' && line.csSiteSpecificFactor10 != '007')
            return false
        if (line.csSiteSpecificFactor9 == '035' && line.csSiteSpecificFactor10 != '008')
            return false
        if (line.csSiteSpecificFactor9 == '039' && !(['004','005','006','007','008','999'].contains(line.csSiteSpecificFactor10)))
            return false
        if (line.csSiteSpecificFactor9 == '041' && line.csSiteSpecificFactor10 != '005')
            return false
        if (line.csSiteSpecificFactor9 == '042' && line.csSiteSpecificFactor10 != '006')
            return false
        if (line.csSiteSpecificFactor9 == '043' && line.csSiteSpecificFactor10 != '007')
            return false
        if (line.csSiteSpecificFactor9 == '044' && line.csSiteSpecificFactor10 != '008')
            return false
        if (line.csSiteSpecificFactor9 == '045' && line.csSiteSpecificFactor10 != '009')
            return false
        if (line.csSiteSpecificFactor9 == '049' && !(['005','006','007','008','009','999'].contains(line.csSiteSpecificFactor10)))
            return false
        if (line.csSiteSpecificFactor9 == '051' && line.csSiteSpecificFactor10 != '006')
            return false
        if (line.csSiteSpecificFactor9 == '052' && line.csSiteSpecificFactor10 != '007')
            return false
        if (line.csSiteSpecificFactor9 == '053' && line.csSiteSpecificFactor10 != '008')
            return false
        if (line.csSiteSpecificFactor9 == '054' && line.csSiteSpecificFactor10 != '009')
            return false
        if (line.csSiteSpecificFactor9 == '055' && line.csSiteSpecificFactor10 != '010')
            return false
        if (line.csSiteSpecificFactor9 == '059' && !(['006','007','008','009','010','999'].contains(line.csSiteSpecificFactor10)))
            return false
        
        return true
    }

    // ID: IF440; NAME: Obsolete Histology ICDO3, Date of DX (SEER)
    public boolean if440(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        Integer histInt = functions.asInt(line.histologicTypeIcdO3)
        if (histInt == 8157)
            return false
        
        if (line.dateOfDiagnosisYear >= '1992' && histInt == 9810)
                return false
        
        if (line.dateOfDiagnosisYear >= '2010')
            if ([9654,9661,9662,9664,9665,9667,9670,9675,9684,9728,9729,9733,9750,9752,9753,9754,9760,9764,9805,9835,9836,9960,9984,9987].contains(histInt))
                return false
        
        if (line.dateOfDiagnosisYear >= '2021')
            if ([8471,9150,9826,9991,9992,8444,8462,8463,8473,8965].contains(histInt))
                return false
        
        return true
    }

    // ID: IF441; NAME: Registry, County and Census Tract 2010 (SEER IF441)
    public boolean if441(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        String county = line.countyAtDxGeocode2010 ?: line.countyAtDxAnalysis
        if (line.censusTract2010 == null || county == null || line.censusTract2010 == '000000' || line.censusTract2010 == '999999' || line.registryId < '0000001500' || line.registryId > '0000001599' || line.registryId == '0000001551')
            return true
        if (line.addrAtDxState == 'AK' && county == '900')
            return true
        
        Map countyCensusTract = (Map)((Map)context.registry_county_census2010).get(line.addrAtDxState)
        if (countyCensusTract == null)
            return true
        
        return ((List)countyCensusTract.getOrDefault(county, [])).contains(functions.asInt(line.censusTract2010))
    }

    // ID: IF442; NAME: CS LN, RNP, Nodes Eval, SSF 3, MelanomaSkin (CS)
    public boolean if442(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2010' ||
            line.csLymphNodes == null || line.regionalNodesPositive == null ||
            line.csSiteSpecificFactor3 == null || line.csSiteSpecificFactor3 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
        return true
        
        if (line._csSchemaId == 'melanoma_skin') {
            if ((line.csLymphNodesEval == '0' || line.csLymphNodesEval == '1' ||
                line.csLymphNodesEval == '5' || line.csLymphNodesEval == '9') &&
                functions.matches(line.csLymphNodes, /(^10\d|11[0-8]|125|155$)/))
                return line.csSiteSpecificFactor3 != '005'
            if (line.csLymphNodes == '010' && (line.csLymphNodesEval == '0' || line.csLymphNodesEval == '1' ||
                line.csLymphNodesEval == '5' || line.csLymphNodesEval == '9'))
                return false
            if (line.csLymphNodesEval == '2' || line.csLymphNodesEval == '3' ||
                line.csLymphNodesEval == '6' || line.csLymphNodesEval == '8') {
                if (line.csLymphNodes == '010' && (line.regionalNodesPositive == '00' ||
                    line.regionalNodesPositive == '97' || line.regionalNodesPositive == '98'))
                    return !(functions.matches(line.csSiteSpecificFactor3, /(^005|0[1-9]\d|100$)/))
            }
            if (line.csLymphNodesEval == '2' || line.csLymphNodesEval == '3' ||
                line.csLymphNodesEval == '6' || line.csLymphNodesEval == '8') {
                if (line.csLymphNodes == '010' && (line.regionalNodesPositive == '00' ||
                    line.regionalNodesPositive == '97' || line.regionalNodesPositive == '98'))
                    return !(functions.matches(line.csSiteSpecificFactor3, /(^005|0[1-9]\d|100$)/))
                if (line.csLymphNodes == '010' && functions.matches(line.regionalNodesPositive, /(^0[1-9]|[1-8]\d|9[0-5,9]$)/))
                    return line.csSiteSpecificFactor3 != '005' && line.csSiteSpecificFactor3 != '100'
                if (functions.matches(line.csLymphNodes, /(^10\d|11[0-8]$)/) && line.regionalNodesPositive == '00')
                    return line.csSiteSpecificFactor3 != '005' && line.csSiteSpecificFactor3 != '010' &&
                        line.csSiteSpecificFactor3 != '050' && line.csSiteSpecificFactor3 != '100'
                if (functions.matches(line.csLymphNodes, /(^10\d|11[0-8]|125|158$)/) && line.regionalNodesPositive == '98')
                    return line.csSiteSpecificFactor3 != '005' && line.csSiteSpecificFactor3 != '010' &&
                        line.csSiteSpecificFactor3 != '100'
                if ((line.csLymphNodes == '125' || line.csLymphNodes == '155') && line.regionalNodesPositive == '00')
                    return line.csSiteSpecificFactor3 != '005' && line.csSiteSpecificFactor3 != '010' &&
                        line.csSiteSpecificFactor3 != '100'
                if (functions.matches(line.csLymphNodes, /(^10\d|11[0-8]|12[23]|125|15[2-8]$)/) &&
                    functions.matches(line.regionalNodesPositive, /(^0[1-9]|[1-8]\d|9[0-7,9]$)/))
                    return line.csSiteSpecificFactor3 != '005' && line.csSiteSpecificFactor3 != '100'
                if (line.csLymphNodes == '124' &&
                    functions.matches(line.regionalNodesPositive, /(^01|9[579]$)/))
                    return line.csSiteSpecificFactor3 != '005' && line.csSiteSpecificFactor3 != '100'
                if (line.csLymphNodes == '124' &&
                    functions.matches(line.regionalNodesPositive, /(^0[2-9]|[1-8]\d|90$)/))
                    return line.csSiteSpecificFactor3 != '005' && line.csSiteSpecificFactor3 != '050' &&
                        line.csSiteSpecificFactor3 != '100'
            }
            if (line.csLymphNodesEval == null) {
                if (line.csLymphNodes == '010' && (line.regionalNodesPositive == '00' ||
                    line.regionalNodesPositive == '98'))
                    return !(functions.matches(line.csSiteSpecificFactor3, /(^005|100$)/))
                if (functions.matches(line.csLymphNodes, /(^10\d|11[0-8]|12[1-8]|15[23]$)/) && (line.regionalNodesPositive == '00' ||
                    line.regionalNodesPositive == '98'))
                    return line.csSiteSpecificFactor3 != '005' && line.csSiteSpecificFactor3 != '010' &&
                        line.csSiteSpecificFactor3 != '100'
                if (functions.matches(line.csLymphNodes, /(^15[5-8]$)/) && (line.regionalNodesPositive == '00' ||
                    line.regionalNodesPositive == '98'))
                    return line.csSiteSpecificFactor3 != '005' && line.csSiteSpecificFactor3 != '010'
                if (functions.matches(line.csLymphNodes, /(^010|10\d|11[0-8]|12[1-8]|15[2-3]|15[5-8]$)/) &&
                    functions.matches(line.regionalNodesPositive, /(^0[1-9]|[1-8]\d|9[0-7]$)/))
                    return line.csSiteSpecificFactor3 != '005' && line.csSiteSpecificFactor3 != '100'
                if (functions.matches(line.csLymphNodes, /(^010|10\d|11[0-8]|12[1-8]|15[2-3]$)/) &&
                    line.regionalNodesPositive == '99')
                    return line.csSiteSpecificFactor3 != '005' && line.csSiteSpecificFactor3 != '100'
                if (functions.matches(line.csLymphNodes, /(^15[5-8]$)/) && line.regionalNodesPositive == '99')
                    return line.csSiteSpecificFactor3 != '005'
            }
        }
        
        return true
    }

    // ID: IF443; NAME: CS SSF 1, Extension, KidneyParenchyma Schema (CS)
    public boolean if443(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor1 == null || line.csSiteSpecificFactor1 == '988' ||
            line.csExtension == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId != 'kidney_parenchyma')
            return true
        
        if (line.csSiteSpecificFactor1 == '010' || line.csSiteSpecificFactor1 == '020' || line.csSiteSpecificFactor1 == '030' ||
            line.csSiteSpecificFactor1 == '991')
            return line.csExtension != '000' && line.csExtension != '100'
        
        return true
    }

    // ID: IF444; NAME: CS SSF 1, SSF 2, SSF 15, SSF 16, Breast (CS)
    public boolean if444(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor1 == null || line.csSiteSpecificFactor1 == '988' ||
            line.csSiteSpecificFactor2 == null || line.csSiteSpecificFactor2 == '988' ||
            line.csSiteSpecificFactor15 == null || line.csSiteSpecificFactor15 == '988' ||
            line.csSiteSpecificFactor16 == null || line.csSiteSpecificFactor16 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId != 'breast' || line.dateOfDiagnosisYear < '2010')
            return true
        
        if (line.csSiteSpecificFactor1 == '010' && line.csSiteSpecificFactor2 == '010' &&
            line.csSiteSpecificFactor15 == '010')
            return line.csSiteSpecificFactor16 == '111'
        if (line.csSiteSpecificFactor1 == '010' && line.csSiteSpecificFactor2 == '010' &&
            line.csSiteSpecificFactor15 == '020')
            return line.csSiteSpecificFactor16 == '110'
        if (line.csSiteSpecificFactor1 == '010' && line.csSiteSpecificFactor2 == '020' &&
            line.csSiteSpecificFactor15 == '010')
            return line.csSiteSpecificFactor16 == '101'
        if (line.csSiteSpecificFactor1 == '010' && line.csSiteSpecificFactor2 == '020' &&
            line.csSiteSpecificFactor15 == '020')
            return line.csSiteSpecificFactor16 == '100'
        if (line.csSiteSpecificFactor1 == '020' && line.csSiteSpecificFactor2 == '010' &&
            line.csSiteSpecificFactor15 == '010')
            return line.csSiteSpecificFactor16 == '011'
        if (line.csSiteSpecificFactor1 == '020' && line.csSiteSpecificFactor2 == '010' &&
            line.csSiteSpecificFactor15 == '020')
            return line.csSiteSpecificFactor16 == '010'
        if (line.csSiteSpecificFactor1 == '020' && line.csSiteSpecificFactor2 == '020' &&
            line.csSiteSpecificFactor15 == '010')
            return line.csSiteSpecificFactor16 == '001'
        if (line.csSiteSpecificFactor1 == '020' && line.csSiteSpecificFactor2 == '020' &&
            line.csSiteSpecificFactor15 == '020')
            return line.csSiteSpecificFactor16 == '000'
        if (functions.matches(line.csSiteSpecificFactor1, /(^030|99[6789]$)/) ||
            functions.matches(line.csSiteSpecificFactor2, /(^030|99[6789]$)/) ||
            functions.matches(line.csSiteSpecificFactor15, /(^030|99[789]$)/))
            return line.csSiteSpecificFactor16 == '999'
        
        return true
    }

    // ID: IF445; NAME: CS SSF 1, Surgery, KidneyParenchyma Schema (CS)
    public boolean if445(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor1 == null || line.csSiteSpecificFactor1 == '988' ||
            line.rxSummSurgPrimSite == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId != 'kidney_parenchyma')
            return true
        
        Integer rxSummSurgPrimSiteInt = functions.asInt(line.rxSummSurgPrimSite)
        if (line.csSiteSpecificFactor1 == '998')
            return rxSummSurgPrimSiteInt >= 0 && rxSummSurgPrimSiteInt <= 27
        
        return true
    }

    // ID: IF446; NAME: CS SSF 11, Lymph Nodes, Vulva (CS)
    public boolean if446(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor11 == null || line.csSiteSpecificFactor11 == '988' ||
            line.csLymphNodes == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line.behaviorCodeIcdO3 == '2' || line._csSchemaId != 'vulva')
            return true
        
        Integer csLymphNodesInt = functions.asInt(line.csLymphNodes)
        Integer ssf11Int = functions.asInt(line.csSiteSpecificFactor11)
        if (ssf11Int == 0)
            return csLymphNodesInt == 0 || csLymphNodesInt == 999
        if (csLymphNodesInt == 0 && ssf11Int != 0 && ssf11Int != 998 && ssf11Int != 999)
            return false
        if (ssf11Int == 998)
            return !(csLymphNodesInt >= 110 && csLymphNodesInt <= 800)
        if (ssf11Int == 10 || ssf11Int == 20 || ssf11Int == 30)
            return csLymphNodesInt != 0 && csLymphNodesInt != 999
        if (ssf11Int == 999)
            return csLymphNodesInt == 999
        
        return true
    }

    // ID: IF447; NAME: CS SSF 13, Extension, Prostate Schema (CS)
    public boolean if447(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor13 == null || line.csSiteSpecificFactor13 == '988' ||
            line.csExtension == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId != 'prostate')
            return true
        
        if (line.csSiteSpecificFactor13 == '998')
            return line.csExtension != '150'
        
        return true
    }

    // ID: IF448; NAME: CS SSF 2, Extension, KidneyParenchyma Schema (CS)
    public boolean if448(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor2 == null || line.csSiteSpecificFactor2 == '988' ||
            line.csExtension == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId != 'kidney_parenchyma')
            return true
        
        Integer extensionInt = functions.asInt(line.csExtension)
        if (line.csSiteSpecificFactor2 == '010')
            return extensionInt >= 600
        if (line.csSiteSpecificFactor2 == '020' || line.csSiteSpecificFactor2 == '040' ||
            line.csSiteSpecificFactor2 == '050' || line.csSiteSpecificFactor2 == '070')
            return extensionInt == 600 || extensionInt >= 610
        if (line.csSiteSpecificFactor2 == '030' || line.csSiteSpecificFactor2 == '060' ||
            line.csSiteSpecificFactor2 == '080' || line.csSiteSpecificFactor2 == '090')
            return extensionInt >= 620
        
        return true
    }

    // ID: IF449; NAME: CS SSF 2, Surgery, KidneyParenchyma Schema (CS)
    public boolean if449(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor2 == null || line.csSiteSpecificFactor2 == '988' ||
            line.rxSummSurgPrimSite == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId != 'kidney_parenchyma')
            return true
        
        Integer rxSummSurgPrimSiteInt = functions.asInt(line.rxSummSurgPrimSite)
        if (line.csSiteSpecificFactor2 == '998')
            return rxSummSurgPrimSiteInt >= 0 && rxSummSurgPrimSiteInt <= 27
        
        return true
    }

    // ID: IF450; NAME: CS SSF 3, Extension, KidneyParenchyma Schema (CS)
    public boolean if450(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor3 == null || line.csSiteSpecificFactor3 == '988' ||
            line.csExtension == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId != 'kidney_parenchyma')
            return true
        
        Integer extensionInt = functions.asInt(line.csExtension)
        if (line.csSiteSpecificFactor3 == '010' || line.csSiteSpecificFactor3 == '030')
            return extensionInt >= 630
        if (extensionInt == 630 || extensionInt == 640 || extensionInt == 645)
            return line.csSiteSpecificFactor3 != '000' && line.csSiteSpecificFactor3 != '020'
        
        return true
    }

    // ID: IF451; NAME: CS SSF 3, Mets at Dx, KidneyParenchyma Schema (CS)
    public boolean if451(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor3 == null || line.csSiteSpecificFactor3 == '988' ||
            line.csMetsAtDx == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId != 'kidney_parenchyma')
            return true
        
        if (line.csSiteSpecificFactor3 == '020' || line.csSiteSpecificFactor3 == '030')
            return line.csMetsAtDx == '40' || line.csMetsAtDx == '55'
        
        return true
    }

    // ID: IF452; NAME: CS SSF 4, Surgery, KidneyParenchyma Schema (CS)
    public boolean if452(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor4 == null || line.csSiteSpecificFactor4 == '988' ||
            line.rxSummSurgPrimSite == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId != 'kidney_parenchyma')
            return true
        
        Integer rxSummSurgPrimSiteInt = functions.asInt(line.rxSummSurgPrimSite)
        if (line.csSiteSpecificFactor4 == '998')
            return rxSummSurgPrimSiteInt >= 0 && rxSummSurgPrimSiteInt <= 19
        
        return true
    }

    // ID: IF453; NAME: CS SSF 6, Histology, KidneyParenchyma Schema (CS)
    public boolean if453(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor6 == null || line.csSiteSpecificFactor6 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId != 'kidney_parenchyma')
            return true
        
        Integer histInt = functions.asInt(line.histologicTypeIcdO3)
        if (line.csSiteSpecificFactor6 == '987')
            return (histInt != 8260 && histInt != 8310 && histInt != 8312 &&
                histInt != 8510 && histInt != 8959 &&
                !(histInt >= 8316 && histInt <= 8320))
        
        return true
    }

    // ID: IF454; NAME: CS SSF 8, Lymph Nodes, KidneyParenchyma (CS)
    public boolean if454(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor8 == null || line.csSiteSpecificFactor8 == '988' ||
            line.csLymphNodes == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line._csSchemaId != 'kidney_parenchyma')
            return true
        
        Integer lymphNodesInt = functions.asInt(line.csLymphNodes)
        Integer ssf8Int = functions.asInt(line.csSiteSpecificFactor8)
        if (ssf8Int == 0)
            return !(lymphNodesInt >= 100 && lymphNodesInt <= 800)
        if (lymphNodesInt == 0)
            return !(ssf8Int >= 10 && ssf8Int <= 30)
        
        return true
    }

    // ID: IF455; NAME: CS SSF 9, Surgery, MelanomaChor/Cil/Iris (CS)
    public boolean if455(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csSiteSpecificFactor9 == null || line.csSiteSpecificFactor9 == '988' ||
            line.rxSummSurgPrimSite == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            (line._csSchemaId != 'melanoma_choroid' && line._csSchemaId != 'melanoma_ciliary_body' &&
            line._csSchemaId != 'melanoma_iris'))
            return true
        
        Integer rxSummSurgPrimSiteInt = functions.asInt(line.rxSummSurgPrimSite)
        if (line.csSiteSpecificFactor9 == '998')
            return rxSummSurgPrimSiteInt >= 0 && rxSummSurgPrimSiteInt <= 19
        
        return true
    }

    // ID: IF456; NAME: CS Lymph Nodes, Lymph Nodes Eval, RNP (CS)
    public boolean if456(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.csLymphNodes == null || line.csLymphNodesEval == null || line.regionalNodesPositive == null ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || functions.asInt(line.dateOfDiagnosisYear) < 2010)
            return true
        
        if (line._csSchemaId == 'lymphoma_ocular_adnexa' || line._csSchemaId == 'retinoblastoma' ||
            line._csSchemaId == 'melanoma_skin' || line._csSchemaId == 'merkel_cell_penis' ||
            line._csSchemaId == 'merkel_cell_scrotum' || line._csSchemaId == 'merkel_cell_skin' ||
            line._csSchemaId == 'merkel_cell_vulva')
            return true
        
        if (line._csSchemaId == 'breast' && line.csLymphNodes == '050')
            return true
        
        if (line._csSchemaId == 'esophagus_gejunction' && line.csLymphNodes == '100')
            return true
        
        if (line._csSchemaId == 'stomach' && (line.csLymphNodes == '100' || line.csLymphNodes == '110'))
            return true
        
        if (line._csSchemaId == 'colon' && line.csLymphNodes == '050')
            return true
        
        if (line._csSchemaId == 'rectum' && line.csLymphNodes == '050')
            return true
        
        if ((line._csSchemaId == 'net_stomach' || line._csSchemaId == 'net_colon' || line._csSchemaId == 'net_rectum') && (line.csLymphNodes == '050' || line.csLymphNodes == '100'))
            return true
        
        if ((line._csSchemaId == 'gist_appendix' || line._csSchemaId == 'gist_stomach') && (line.csLymphNodes == '050' || line.csLymphNodes == '100'))
            return true
        
        if ((line._csSchemaId == 'gist_colon' || line._csSchemaId == 'gist_rectum') && (line.csLymphNodes == '050' || line.csLymphNodes == '100'))
            return true
        
        if (line.csLymphNodes != '000' && line.csLymphNodes != '999' &&
            (line.csLymphNodesEval == '3' || line.csLymphNodesEval == '6'))
            return line.regionalNodesPositive != '00' && line.regionalNodesPositive != '98'
        
        return true
    }

    // ID: IF460; NAME: CS Extension, SSF 1, MelanomaConjunctiva (CS)
    public boolean if460(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2010' ||
            line.csExtension == null ||
            line.csSiteSpecificFactor1 == null || line.csSiteSpecificFactor1 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'melanoma_conjunctiva') {
            Integer csExtInt = functions.asInt(line.csExtension)
            if (csExtInt >= 300 && csExtInt <= 500 && line.csSiteSpecificFactor1 == '000')
                return false
        }
        
        return true
    }

    // ID: IF461; NAME: Census Tract 2010 and Year of Diagnosis
    public boolean if461(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.registryId == '0000001565')
            return true
        
        if (line.dateOfDiagnosisYear > '2005' && line.dateOfDiagnosisYear < '2022')
            return line.censusTract2010 != null
        
        return true
    }

    // ID: IF462; NAME: Census Tr Certainty 2010 and Year of Diagnosis(SEER IF462)
    public boolean if462(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.registryId != '0000001533' && line.dateOfDiagnosisYear > '2005')
            return line.censusTrCertainty2010 != null
        
        return true
    }

    // ID: IF463; NAME: CS Extension, CS Tumor Size, MycosisFungoides (CS)
    public boolean if463(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 || line._csSchemaId != 'mycosis_fungoides' ||
            line.csExtension == null || line.csTumorSize == null ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (functions.matches(line.csExtension, /(^1[1235]0|2[123]0|300$)/))
            return line.csTumorSize == '000' || line.csTumorSize == '999'
        if (line.csExtension == '600')
            return line.csTumorSize != '990' && line.csTumorSize != '991'
        
        return true
    }

    // ID: IF464; NAME: CS Extension, SSF 1, Head and Neck Schemas (CS)
    public boolean if464(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 || line.csExtension == null ||
            line.csSiteSpecificFactor1 == null || line.csSiteSpecificFactor1 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (((List)context.HEAD_AND_NECK_Schemas).contains(line._csSchemaId) && line.csExtension == '000')
            return line.csSiteSpecificFactor1 == '000' || line.csSiteSpecificFactor1 == '999'
        
        return true
    }

    // ID: IF465; NAME: CS Extension, SSF 11, MerkelCellVulva Schema (CS)
    public boolean if465(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 || line._csSchemaId != 'merkel_cell_vulva' ||
            line.csExtension == null ||
            line.csSiteSpecificFactor11 == null || line.csSiteSpecificFactor11 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line.csExtension == '000')
            return line.csSiteSpecificFactor11 == '000' || line.csSiteSpecificFactor11 == '998' || line.csSiteSpecificFactor11 == '999'
        
        return true
    }

    // ID: IF466; NAME: CS Extension, SSF 11, Vulva Schema (CS)
    public boolean if466(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 || line._csSchemaId != 'vulva' ||
            line.csExtension == null ||
            line.csSiteSpecificFactor11 == null || line.csSiteSpecificFactor11 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line.csExtension == '000')
            return line.csSiteSpecificFactor11 == '000' || line.csSiteSpecificFactor11 == '998' || line.csSiteSpecificFactor11 == '999'
        
        return true
    }

    // ID: IF467; NAME: CS Extension, SSF 16, MerkelCell Schemas (CS)
    public boolean if467(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 ||
            line.csExtension == null ||
            line.csSiteSpecificFactor16 == null || line.csSiteSpecificFactor16 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if ((line._csSchemaId == 'merkel_cell_scrotum' || line._csSchemaId == 'merkel_cell_vulva' ||
             line._csSchemaId == 'merkel_cell_skin' || line._csSchemaId == 'merkel_cell_penis') &&
            line.csExtension == '000')
            return line.csSiteSpecificFactor16 == '000' || line.csSiteSpecificFactor16 == '998' || line.csSiteSpecificFactor16 == '999'
        
        return true
    }

    // ID: IF468; NAME: CS Extension, SSF 16, Scrotum Schema (CS)
    public boolean if468(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 ||
            line.csExtension == null ||
            line.csSiteSpecificFactor16 == null || line.csSiteSpecificFactor16 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'scrotum' && line.csExtension == '000')
            return line.csSiteSpecificFactor16 == '000' || line.csSiteSpecificFactor16 == '999'
        
        return true
    }

    // ID: IF469; NAME: CS Extension, SSF 16, Skin Schema (CS)
    public boolean if469(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 ||
            line.csExtension == null ||
            line.csSiteSpecificFactor16 == null || line.csSiteSpecificFactor16 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'skin' && line.csExtension == '000')
            return line.csSiteSpecificFactor16 == '000' || line.csSiteSpecificFactor16 == '999'
        
        return true
    }

    // ID: IF470; NAME: CS Extension, SSF 17, MerkelCell Schemas (CS)
    public boolean if470(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 ||
            line.csExtension == null ||
            line.csSiteSpecificFactor17 == null || line.csSiteSpecificFactor17 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if ((line._csSchemaId == 'merkel_cell_scrotum' || line._csSchemaId == 'merkel_cell_vulva' ||
             line._csSchemaId == 'merkel_cell_skin' || line._csSchemaId == 'merkel_cell_penis') &&
            line.csExtension == '000')
            return !(line.csSiteSpecificFactor17 == '010' || line.csSiteSpecificFactor17 == '040' || line.csSiteSpecificFactor17 == '070')
        
        return true
    }

    // ID: IF471; NAME: CS Extension, SSF 17, Penis Schema (CS)
    public boolean if471(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 ||
            line.csExtension == null ||
            line.csSiteSpecificFactor17 == null || line.csSiteSpecificFactor17 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'penis' && line.csExtension == '000')
            return line.csSiteSpecificFactor17 == '000' || line.csSiteSpecificFactor17 == '999'
        
        return true
    }

    // ID: IF472; NAME: CS Extension, SSF 18, MerkelCell Schemas (CS)
    public boolean if472(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 ||
            line.csExtension == null ||
            line.csSiteSpecificFactor18 == null || line.csSiteSpecificFactor18 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if ((line._csSchemaId == 'merkel_cell_scrotum' || line._csSchemaId == 'merkel_cell_vulva' ||
             line._csSchemaId == 'merkel_cell_skin' || line._csSchemaId == 'merkel_cell_penis') &&
             line.csExtension == '000')
            return line.csSiteSpecificFactor18 == '000' || line.csSiteSpecificFactor18 == '010' || line.csSiteSpecificFactor18 == '999'
        
        return true
    }

    // ID: IF473; NAME: CS Extension, SSF 2, Bladder Schema (CS)
    public boolean if473(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 ||
            line.csExtension == null ||
            line.csSiteSpecificFactor2 == null || line.csSiteSpecificFactor2 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'bladder' && functions.matches(line.csExtension, /(^0[136]0$)/))
            return line.csSiteSpecificFactor2 == '000' || line.csSiteSpecificFactor2 == '999'
        
        return true
    }

    // ID: IF474; NAME: CS Extension, SSF 2, Vagina Schema (CS)
    public boolean if474(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 ||
            line.csExtension == null ||
            line.csSiteSpecificFactor2 == null || line.csSiteSpecificFactor2 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'vagina' && line.csExtension == '000')
            return line.csSiteSpecificFactor2 == '000' || line.csSiteSpecificFactor2 == '998' || line.csSiteSpecificFactor2 == '999'
        
        return true
    }

    // ID: IF475; NAME: CS Extension, SSF 3, Bladder Schema (CS)
    public boolean if475(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 ||
            line.csExtension == null ||
            line.csSiteSpecificFactor3 == null || line.csSiteSpecificFactor3 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'bladder' && functions.matches(line.csExtension, /(^0[136]0$)/))
            return line.csSiteSpecificFactor3 == '000' || line.csSiteSpecificFactor3 == '999'
        
        return true
    }

    // ID: IF476; NAME: CS Extension, SSF 3, Breast Schema (CS)
    public boolean if476(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 ||
            line.csExtension == null ||
            line.csSiteSpecificFactor3 == null || line.csSiteSpecificFactor3 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'breast' && line.csExtension == '000')
            return line.csSiteSpecificFactor3 == '000' || line.csSiteSpecificFactor3 == '098' || line.csSiteSpecificFactor3 == '099'
        
        return true
    }

    // ID: IF477; NAME: CS Extension, SSF 3, CorpusCarcinoma Schema (CS)
    public boolean if477(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 ||
            line.csExtension == null ||
            line.csSiteSpecificFactor3 == null || line.csSiteSpecificFactor3 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'corpus_carcinoma' && line.csExtension == '000')
            return line.csSiteSpecificFactor3 == '000' || line.csSiteSpecificFactor3 == '098' || line.csSiteSpecificFactor3 == '999'
        
        return true
    }

    // ID: IF478; NAME: CS Extension, SSF 3, Head and Neck Schemas (CS)
    public boolean if478(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 || line.csExtension == null ||
            line.csSiteSpecificFactor3 == null || line.csSiteSpecificFactor3 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (((List)context.HEAD_AND_NECK_Schemas).contains(line._csSchemaId) && line.csExtension == '000')
            return line.csSiteSpecificFactor3 == '000' || line.csSiteSpecificFactor3 == '999'
        
        return true
    }

    // ID: IF479; NAME: CS Extension, SSF 4, FallopianTube Schema (CS)
    public boolean if479(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 ||
            line.csExtension == null ||
            line.csSiteSpecificFactor4 == null || line.csSiteSpecificFactor4 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'fallopian_tube' && line.csExtension == '000')
            return line.csSiteSpecificFactor4 == '000' || line.csSiteSpecificFactor4 == '098' || line.csSiteSpecificFactor4 == '999'
        
        return true
    }

    // ID: IF480; NAME: CS Extension, SSF 4, Head and Neck Schemas (CS)
    public boolean if480(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 || line.csExtension == null ||
            line.csSiteSpecificFactor4 == null || line.csSiteSpecificFactor4 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (((List)context.HEAD_AND_NECK_Schemas).contains(line._csSchemaId) && line.csExtension == '000')
              return line.csSiteSpecificFactor4 == '000' || line.csSiteSpecificFactor4 == '999'
        
        return true
    }

    // ID: IF481; NAME: CS Extension, SSF 4, Vagina Schema (CS)
    public boolean if481(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 ||
            line.csExtension == null ||
            line.csSiteSpecificFactor4 == null || line.csSiteSpecificFactor4 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'vagina' && line.csExtension == '000')
            return line.csSiteSpecificFactor4 == '000' || line.csSiteSpecificFactor4 == '998' || line.csSiteSpecificFactor4 == '999'
        
        return true
    }

    // ID: IF482; NAME: CS Extension, SSF 5, CorpusCarcinoma Schema (CS)
    public boolean if482(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 ||
            line.csExtension == null ||
            line.csSiteSpecificFactor5 == null || line.csSiteSpecificFactor5 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'corpus_carcinoma' && line.csExtension == '000')
            return line.csSiteSpecificFactor5 == '000' || line.csSiteSpecificFactor5 == '098' || line.csSiteSpecificFactor5 == '999'
        
        return true
    }

    // ID: IF483; NAME: CS Extension, SSF 5, Head and Neck Schemas (CS)
    public boolean if483(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 || line.csExtension == null ||
            line.csSiteSpecificFactor5 == null || line.csSiteSpecificFactor5 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (((List)context.HEAD_AND_NECK_Schemas).contains(line._csSchemaId) && line.csExtension == '000')
            return line.csSiteSpecificFactor5 == '000' || line.csSiteSpecificFactor5 == '999'
        
        return true
    }

    // ID: IF484; NAME: CS Extension, SSF 5, Testis Schema (CS)
    public boolean if484(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 ||
            line.csExtension == null ||
            line.csSiteSpecificFactor5 == null || line.csSiteSpecificFactor5 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'testis' && line.csExtension == '000')
            return line.csSiteSpecificFactor5 == '000' || line.csSiteSpecificFactor5 == '999'
        
        return true
    }

    // ID: IF485; NAME: CS Extension, SSF 6, FallopianTube Schema (CS)
    public boolean if485(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 ||
            line.csExtension == null ||
            line.csSiteSpecificFactor6 == null || line.csSiteSpecificFactor6 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'fallopian_tube' && line.csExtension == '000')
            return line.csSiteSpecificFactor6 == '000' || line.csSiteSpecificFactor6 == '098' || line.csSiteSpecificFactor6 == '999'
        
        return true
    }

    // ID: IF486; NAME: CS Extension, SSF 6, Head and Neck Schemas (CS)
    public boolean if486(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 || line.csExtension == null ||
            line.csSiteSpecificFactor6 == null || line.csSiteSpecificFactor6 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (((List)context.HEAD_AND_NECK_Schemas).contains(line._csSchemaId) && line.csExtension == '000')
            return line.csSiteSpecificFactor6 == '000' || line.csSiteSpecificFactor6 == '999'
        
        return true
    }

    // ID: IF487; NAME: CS Extension, SSF 6, Vagina Schema (CS)
    public boolean if487(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 ||
            line.csExtension == null ||
            line.csSiteSpecificFactor6 == null || line.csSiteSpecificFactor6 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'vagina' && line.csExtension == '000')
            return line.csSiteSpecificFactor6 == '000' || line.csSiteSpecificFactor6 == '998' || line.csSiteSpecificFactor6 == '999'
        
        return true
    }

    // ID: IF488; NAME: CS Extension, SSF 8, KidneyParenchyma (CS)
    public boolean if488(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 ||
            line.csExtension == null ||
            line.csSiteSpecificFactor8 == null || line.csSiteSpecificFactor8 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'kidney_parenchyma' && line.csExtension == '000')
            return line.csSiteSpecificFactor8 == '000' || line.csSiteSpecificFactor8 == '999'
        
        return true
    }

    // ID: IF489; NAME: CS Extension, SSF 9, Head and Neck Schemas (CS)
    public boolean if489(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 || line.csExtension == null ||
            line.csSiteSpecificFactor9 == null || line.csSiteSpecificFactor9 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (((List)context.HEAD_AND_NECK_Schemas).contains(line._csSchemaId) && line.csExtension == '000')
            return line.csSiteSpecificFactor9 == '000' || line.csSiteSpecificFactor9 == '998' || line.csSiteSpecificFactor9 == '999'
        
        return true
    }

    // ID: IF490; NAME: CS Mets at DX-BBLL, LymphomaOcularAdnexa (CS)
    public boolean if490(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 || line._csSchemaId != 'lymphoma_ocular_adnexa' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line.dateOfDiagnosisYear > '2015')
            return true
            
        if (line.registryId == '0000001563')
            return true
        
        if (line.csMetsAtDxBrain == '8' || line.csMetsAtDxBone == '8' || line.csMetsAtDxLung == '8' || line.csMetsAtDxLiver == '8')
            return false
        
        return true
    }

    // ID: IF491; NAME: CS Mets at DX-BBLL, MycosisFungoides (CS)
    public boolean if491(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 || line._csSchemaId != 'mycosis_fungoides' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line.dateOfDiagnosisYear > '2015')
            return true
        
        if (line.registryId == '0000001563')
            return true
        
        if (line.csMetsAtDxBrain == '8' || line.csMetsAtDxBone == '8' || line.csMetsAtDxLung == '8' || line.csMetsAtDxLiver == '8')
            return false
        
        return true
    }

    // ID: IF492; NAME: CS SSF 1, Behavior, Lung Schema (CS)
    public boolean if492(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if ((line.csVersionInputOriginal != null && functions.asInt(line.csVersionInputOriginal) < 20500) ||
            line.csSiteSpecificFactor1 == null || line.csSiteSpecificFactor1 == '988')
            return true
        
        if (line._csSchemaId == 'lung' && line.behaviorCodeIcdO3 == '2')
            return line.csSiteSpecificFactor1 == '000'
        
        return true
    }

    // ID: IF493; NAME: CS SSF 1, Lymph Nodes, CorpusAdenosarcoma (CS)
    public boolean if493(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 ||
            line.csLymphNodes == null ||
            line.csSiteSpecificFactor1 == null || line.csSiteSpecificFactor1 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'corpus_adenosarcoma' && line.csLymphNodes != '000' && line.csLymphNodes != '999')
            return !(['100','120','130','140','200','210','220','310','320'].contains(line.csSiteSpecificFactor1))
        
        return true
    }

    // ID: IF494; NAME: CS SSF 1, Lymph Nodes, CorpusCarcinoma (CS)
    public boolean if494(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 ||
            line.csLymphNodes == null ||
            line.csSiteSpecificFactor1 == null || line.csSiteSpecificFactor1 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'corpus_carcinoma' && line.csLymphNodes != '000' && line.csLymphNodes != '999')
            return !(['100','110','120','200','310','320'].contains(line.csSiteSpecificFactor1))
        
        return true
    }

    // ID: IF495; NAME: CS SSF 1, Lymph Nodes, CorpusSarcoma (CS)
    public boolean if495(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 ||
            line.csLymphNodes == null ||
            line.csSiteSpecificFactor1 == null || line.csSiteSpecificFactor1 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'corpus_carcinoma' && line.csLymphNodes != '000' && line.csLymphNodes != '999')
            return !(['100','110','120','200','210','220','310','320'].contains(line.csSiteSpecificFactor1))
        
        return true
    }

    // ID: IF496; NAME: CS SSF 10, Lymph Nodes, Vulva Schema (CS)
    public boolean if496(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 ||
            line.csLymphNodes == null ||
            line.csSiteSpecificFactor10 == null || line.csSiteSpecificFactor10 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'vulva' && line.csLymphNodes != '000' && line.csLymphNodes != '999')
            return !(line.csSiteSpecificFactor10 == '100' || line.csSiteSpecificFactor10 == '110' || line.csSiteSpecificFactor10 == '120' || line.csSiteSpecificFactor10 == '200')
        
        return true
    }

    // ID: IF497; NAME: CS SSF 2, Lymph Nodes, Ovary (CS)
    public boolean if497(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 ||
            line.csLymphNodes == null ||
            line.csSiteSpecificFactor2 == null || line.csSiteSpecificFactor2 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'ovary' && line.csLymphNodes != '000' && line.csLymphNodes != '999')
            return !(['100','110','120','130','200','210','220','230'].contains(line.csSiteSpecificFactor2))
        
        return true
    }

    // ID: IF498; NAME: CS SSF 2, Lymph Nodes, PeritoneumFemaleGen (CS)
    public boolean if498(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.asInt(line.csVersionInputOriginal) < 20500 ||
            line.csLymphNodes == null ||
            line.csSiteSpecificFactor2 == null || line.csSiteSpecificFactor2 == '988' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line._csSchemaId == 'peritoneum_female_gen' && line.csLymphNodes != '000' && line.csLymphNodes != '999')
            return !(['100','110','120','130','200','210','220','230','310','320'].contains(line.csSiteSpecificFactor2))
        
        return true
    }

    // ID: IF499; NAME: CS SSF 1, Brain, CNSOther, IntracranialGland (CS)
    public boolean if499(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line._csSchemaId == null || (line.csVersionInputOriginal != null && functions.asInt(line.csVersionInputOriginal) < 20500) ||
            line.rxSummSurgPrimSite == null || line.behaviorCodeIcdO3 == '0' ||
            line.behaviorCodeIcdO3 == '1' || line.csSiteSpecificFactor1 == null ||
            line.csSiteSpecificFactor1 == '988')
            return true
        
        if (['brain','cns_other','intracranial_gland'].contains(line._csSchemaId) && line.csSiteSpecificFactor1 == '998')
            return functions.between(functions.asInt(line.rxSummSurgPrimSite), 0, 19)
        
        return true
    }

    // ID: IF500; NAME: CS SSF 1, TS/Ext Eval, Retinoblastoma Schema (CS)
    public boolean if500(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line._csSchemaId == null || functions.asInt(line.csVersionInputOriginal) < 20500 ||
            line.csTumorSizeExtEval == null || line.csSiteSpecificFactor1 == null ||
            line.csSiteSpecificFactor1 == '988')
            return true
        
        if (line._csSchemaId == 'retinoblastoma') {
            if (['3','5','6'].contains(line.csTumorSizeExtEval) && line.csSiteSpecificFactor1 == '970')
                return false
            if (line.csTumorSizeExtEval == '6' && line.csSiteSpecificFactor1 == '950')
                return false
        }
        
        return true
    }

    // ID: IF501; NAME: CS SSF 11, GISTAppendix, Colon, Rectum (CS)
    public boolean if501(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line._csSchemaId == null || (line.csVersionInputOriginal != null && functions.asInt(line.csVersionInputOriginal) < 20500) ||
            line.rxSummSurgPrimSite == null || line.behaviorCodeIcdO3 == '0' ||
            line.behaviorCodeIcdO3 == '1' || line.csSiteSpecificFactor11 == null ||
            line.csSiteSpecificFactor11 == '988')
            return true
        
        if (['gist_appendix','gist_colon','gist_rectum'].contains(line._csSchemaId) && line.csSiteSpecificFactor11 == '998')
            return functions.between(functions.asInt(line.rxSummSurgPrimSite), 0, 19)
        
        return true
    }

    // ID: IF502; NAME: CS SSF 4, 5, 6, MelanomaSkin (CS)
    public boolean if502(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line._csSchemaId == null || (line.csVersionInputOriginal != null && functions.asInt(line.csVersionInputOriginal) < 20500) ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            line.csSiteSpecificFactor4 == null || line.csSiteSpecificFactor4 == '988' ||
            line.csSiteSpecificFactor5 == null || line.csSiteSpecificFactor5 == '988' ||
            line.csSiteSpecificFactor6 == null || line.csSiteSpecificFactor6 == '988')
            return true
        
        if (line._csSchemaId == 'melanoma_skin') {
            if (line.csSiteSpecificFactor4 == '998' && (line.csSiteSpecificFactor5 != '998' || line.csSiteSpecificFactor6 != '998'))
                return false
            if (line.csSiteSpecificFactor5 == '998' && (line.csSiteSpecificFactor4 != '998' || line.csSiteSpecificFactor6 != '998'))
                return false
            if (line.csSiteSpecificFactor6 == '998' && (line.csSiteSpecificFactor4 != '998' || line.csSiteSpecificFactor5 != '998'))
                return false
        }
        
        return true
    }

    // ID: IF503; NAME: CS SSF 5, GISTPeritoneum (CS)
    public boolean if503(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line._csSchemaId == null || (line.csVersionInputOriginal != null && functions.asInt(line.csVersionInputOriginal) < 20500) ||
            line.rxSummSurgPrimSite == null || line.behaviorCodeIcdO3 == '0' ||
            line.behaviorCodeIcdO3 == '1' || line.csSiteSpecificFactor5 == null ||
            line.csSiteSpecificFactor5 == '988')
            return true
        
        if (line._csSchemaId == 'gist_peritoneum' && line.csSiteSpecificFactor5 == '998')
            return functions.between(functions.asInt(line.rxSummSurgPrimSite), 0, 19)
        
        return true
    }

    // ID: IF504; NAME: CS SSF 6, GISTEsoph, SmallIntest, Stomach (CS)
    public boolean if504(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line._csSchemaId == null || (line.csVersionInputOriginal != null && functions.asInt(line.csVersionInputOriginal) < 20500) ||
            line.rxSummSurgPrimSite == null || line.behaviorCodeIcdO3 == '0' ||
            line.behaviorCodeIcdO3 == '1' || line.csSiteSpecificFactor6 == null ||
            line.csSiteSpecificFactor6 == '988')
            return true
        
        if (['gist_esophagus','gist_small_intestine','gist_stomach'].contains(line._csSchemaId) && line.csSiteSpecificFactor6 == '998')
            return functions.between(functions.asInt(line.rxSummSurgPrimSite), 0, 19)
        
        return true
    }

    // ID: IF505; NAME: CS SSF 7, MelanomaSkin (CS)
    public boolean if505(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line._csSchemaId == null || (line.csVersionInputOriginal != null && functions.asInt(line.csVersionInputOriginal) < 20500) ||
            line.rxSummSurgPrimSite == null || line.behaviorCodeIcdO3 == '0' ||
            line.behaviorCodeIcdO3 == '1' || line.csSiteSpecificFactor7 == null ||
            line.csSiteSpecificFactor7 == '988')
            return true
        
        if (line._csSchemaId == 'melanoma_skin' && line.csSiteSpecificFactor7 == '998')
            return functions.between(functions.asInt(line.rxSummSurgPrimSite), 0, 19)
        
        return true
    }

    // ID: IF506; NAME: Primary Site, AJCC M - Ed 7, ICDO3 (SEER)
    public boolean if506(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear != '2015' || (line.tnmEditionNumber != '07' && line.tnmEditionNumber != '88') ||
            (line.tnmClinM == null && line.tnmPathM == null) || line.histologicTypeIcdO3 == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line.typeOfReportingSource == '7')
            return true
        
        Integer site = functions.asInt(line.primarySite.substring(1))
        Integer hist = functions.asInt(line.histologicTypeIcdO3)
        String clin = functions.matches(line.tnmClinM, /^[pc].+$/) ? line.tnmClinM.substring(1) : line.tnmClinM
        String path = functions.matches(line.tnmPathM, /^[pc].+$/) ? line.tnmPathM.substring(1) : line.tnmPathM
        
        if (line.tnmEditionNumber == '88' && (clin == null || clin == '88') && (path == null || path == '88') && line.overRideSiteTnmStggrp == '1')
            return true
        
        String code = ((Map)((Map)context.AJCC7SiteHistTable).getOrDefault(site, [:])).getOrDefault(hist, '999')
        
        if (functions.expandList((List)[0..419, 422, 423, 425..440, 442..689, 691..694, 698..809]).contains(site) &&
            functions.expandList((List)[9590..9699, 9702..9729, 9735, 9737, 9738, 9811..9818, 9823, 9827, 9837]).contains(hist))
            code = '57A'
        else if (code == '04C') {
            if (line.csSiteSpecificFactor25 == '020')
                code = '04D'
            else if (line.csSiteSpecificFactor25 != '010')
                code = '999'
        }
        else if (code == '008') {
            if (functions.matches(line.grade, /^[1239]$/)) {
                if (line.ageAtDiagnosis <= '044')
                    code = '08A'
                else if (line.ageAtDiagnosis <= '998')
                    code = '08B'
                else
                    code = '08C'
            }
            else if (line.grade == '4')
                code = '08F'
            else
                code = '999'
        }
        else if (code == '08D') {
            if (line.grade == '4')
                code = '08F'
            else if (!(functions.matches(line.grade, /^[1239]$/)))
                code = '999'
        }
        else if (code == '011') {
            if ((site == 161 || site == 162) && functions.matches(line.csSiteSpecificFactor25, /^0[246]0$/))
                code = '10B'
        }
        else if (code == '16B') {
            if ((480 <= site && site <= 488) && line.csSiteSpecificFactor10 == '020')
                code = '16A'
        }
        else if (code == '021') {
            if (site == 240) {
                if (line.csSiteSpecificFactor25 == '030')
                    code = '020'
                else if (line.csSiteSpecificFactor25 == '040' || line.csSiteSpecificFactor25 == '070')
                    code = '022'
            }
        }
        else if (code == '37B') {
            if ((481 <= site && site <= 488) && line.csSiteSpecificFactor25 != '002')
                code = '999'
        }
        else if (code == '051') {
            if (site == 693)
                code = '51A'
            else if (site == 694) {
                if (line.csSiteSpecificFactor25 == '010' || line.csSiteSpecificFactor25 == '999')
                    code = '51A'
                else if (line.csSiteSpecificFactor25 == '020')
                    code = '51B'
                else
                    code = '999'
            }
        }
        else if (code == '053') {
            if (line.csSiteSpecificFactor25 != '015')
                code = '999'
        }
        
        if (code == '999') {
            if (site == 739 && functions.expandList((List)[8000..8576, 8940..8950, 8980..8981]).contains(hist) && line.grade == '4')
                code = '08F'
            else if ((481 <= site && site <= 488) && functions.expandList((List)[8800..8820, 8823..8934, 8940..9136, 9142..9582]).contains(hist) && line.csSiteSpecificFactor25 != '002')
                code = '028'
            else if ((481 <= site && site <= 488) && functions.expandList((List)[8800..8820, 8823..8921, 9120..9136, 9142..9582]).contains(hist) && line.csSiteSpecificFactor25 == '002')
                code = '028'
            else if ((490 <= site && site <= 499) && functions.expandList((List)[8800..8934, 8940..9044, 9060..9136, 9141..9582]).contains(hist))
                code = '028'
        }
        
        boolean validClin = false
        boolean validPath = false
        if ((code == '028' || code == '37B') && functions.expandList((List)[9050..9055]).contains(hist)) {
            if (clin != null && clin == '88')
                validClin = true
            if (path != null && path == '88')
                validPath = true
        }
        
        if (!validClin && clin != null && !((List)((Map)context.IF506_TNM_CODES_Table).getOrDefault(code, [])).contains(clin))
            return false
        
        if (!validPath && path != null && !((List)((Map)context.IF506_TNM_CODES_Table).getOrDefault(code, [])).contains(path))
            return false
        
        return true
    }

    // ID: IF507; NAME: Primary Site, AJCC N - Ed 7, ICDO3 (SEER)
    public boolean if507(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear != '2015' || (line.tnmEditionNumber != '07' && line.tnmEditionNumber != '88') ||
            (line.tnmClinN == null && line.tnmPathN == null) || line.histologicTypeIcdO3 == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line.typeOfReportingSource == '7')
            return true
        
        Integer site = functions.asInt(line.primarySite.substring(1))
        Integer hist = functions.asInt(line.histologicTypeIcdO3)
        String clin = functions.matches(line.tnmClinN, /^[pc].+$/) ? line.tnmClinN.substring(1) : line.tnmClinN
        String path = functions.matches(line.tnmPathN, /^[pc].+$/) ? line.tnmPathN.substring(1) : line.tnmPathN
        
        if (line.tnmEditionNumber == '88' && (clin == null || clin == '88') && (path == null || path == '88') && line.overRideSiteTnmStggrp == '1')
            return true
        
        String code = ((Map)((Map)context.AJCC7SiteHistTable).getOrDefault(site, [:])).getOrDefault(hist, '999')
        
        if (functions.expandList((List)[0..419, 422, 423, 425..440, 442..689, 691..694, 698..809]).contains(site) &&
            functions.expandList((List)[9590..9699, 9702..9729, 9735, 9737, 9738, 9811..9818, 9823, 9827, 9837]).contains(hist))
            code = '57A'
        else if (code == '04C') {
            if (line.csSiteSpecificFactor25 == '020')
                code = '04D'
            else if (line.csSiteSpecificFactor25 != '010')
                code = '999'
        }
        else if (code == '008') {
            if (functions.matches(line.grade, /^[1239]$/)) {
                if (line.ageAtDiagnosis <= '044')
                    code = '08A'
                else if (line.ageAtDiagnosis <= '998')
                    code = '08B'
                else
                    code = '08C'
            }
            else if (line.grade == '4')
                code = '08F'
            else
                code = '999'
        }
        else if (code == '08D') {
            if (line.grade == '4')
                code = '08F'
            else if (!(functions.matches(line.grade, /^[1239]$/)))
                code = '999'
        }
        else if (code == '011') {
            if ((site == 161 || site == 162) && functions.matches(line.csSiteSpecificFactor25, /^0[246]0$/))
                code = '10B'
        }
        else if (code == '16B') {
            if ((480 <= site && site <= 488) && line.csSiteSpecificFactor10 == '020')
                code = '16A'
        }
        else if (code == '021') {
            if (site == 240) {
                if (line.csSiteSpecificFactor25 == '030')
                    code = '020'
                else if (line.csSiteSpecificFactor25 == '040' || line.csSiteSpecificFactor25 == '070')
                    code = '022'
            }
        }
        else if (code == '37B') {
            if ((481 <= site && site <= 488) && line.csSiteSpecificFactor25 != '002')
                code = '999'
        }
        else if (code == '051') {
            if (site == 693)
                code = '51A'
            else if (site == 694) {
                if (line.csSiteSpecificFactor25 == '010' || line.csSiteSpecificFactor25 == '999')
                    code = '51A'
                else if (line.csSiteSpecificFactor25 == '020')
                    code = '51B'
                else
                    code = '999'
            }
        }
        else if (code == '053') {
            if (line.csSiteSpecificFactor25 != '015')
                code = '999'
        }
        
        if (code == '999') {
            if (site == 739 && functions.expandList((List)[8000..8576, 8940..8950, 8980..8981]).contains(hist) && line.grade == '4')
                code = '08F'
            else if ((481 <= site && site <= 488) && functions.expandList((List)[8800..8820, 8823..8934, 8940..9136, 9142..9582]).contains(hist) && line.csSiteSpecificFactor25 != '002')
                code = '028'
            else if ((481 <= site && site <= 488) && functions.expandList((List)[8800..8820, 8823..8921, 9120..9136, 9142..9582]).contains(hist) && line.csSiteSpecificFactor25 == '002')
                code = '028'
        }
        
        boolean validClin = false
        boolean validPath = false
        if ((code == '028' || code == '37B') && functions.expandList((List)[9050..9055]).contains(hist)) {
            if (clin != null && clin == '88')
                validClin = true
            if (path != null && path == '88')
                validPath = true
        }
        
        if (!validClin && clin != null && !((List)((Map)((Map)context.IF507_TNM_CODES_Table).getOrDefault(code, [:])).getOrDefault('C', [])).contains(clin))
            return false
        
        if (!validPath && path != null && !((List)((Map)((Map)context.IF507_TNM_CODES_Table).getOrDefault(code, [:])).getOrDefault('P', [])).contains(path))
            return false
        
        return true
    }

    // ID: IF508; NAME: Primary Site, AJCC Stage Group - Ed 7, ICDO3 (SEER)
    public boolean if508(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear != '2015' || (line.tnmEditionNumber != '07' && line.tnmEditionNumber != '88') ||
            (line.tnmClinStageGroup == null && line.tnmPathStageGroup == null) || line.histologicTypeIcdO3 == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line.typeOfReportingSource == '7')
            return true
        
        if (line.overRideSiteTnmStggrp == '1') {
            if (line.ageAtDiagnosis > '024')
                return false
            else if (line.tnmEditionNumber == '88' && (line.tnmClinStageGroup == null || line.tnmClinStageGroup == '88') && (line.tnmPathStageGroup == null || line.tnmPathStageGroup == '88'))
                return true
            else
                return false
        }
        
        Integer site = functions.asInt(line.primarySite.substring(1))
        Integer hist = functions.asInt(line.histologicTypeIcdO3)
        String clin = line.tnmClinStageGroup
        String path = line.tnmPathStageGroup
        
        String code = ((Map)((Map)context.AJCC7SiteHistTable).getOrDefault(site, [:])).getOrDefault(hist, '999')
        
        if (functions.expandList((List)[0..419, 422, 423, 425..440, 442..689, 691..694, 698..809]).contains(site) &&
            functions.expandList((List)[9590..9699, 9702..9729, 9735, 9737, 9738, 9811..9818, 9823, 9827, 9837]).contains(hist))
            code = '57A'
        else if (code == '04C') {
            if (line.csSiteSpecificFactor25 == '020')
                code = '04D'
            else if (line.csSiteSpecificFactor25 != '010')
                code = '999'
        }
        else if (code == '008') {
            if (functions.matches(line.grade, /^[1239]$/)) {
                if (line.ageAtDiagnosis <= '044')
                    code = '08A'
                else if (line.ageAtDiagnosis <= '998')
                    code = '08B'
                else
                    code = '08C'
            }
            else if (line.grade == '4')
                code = '08F'
            else
                code = '999'
        }
        else if (code == '08D') {
            if (line.grade == '4')
                code = '08F'
            else if (!(functions.matches(line.grade, /^[1239]$/)))
                code = '999'
        }
        else if (code == '011') {
            if ((site == 161 || site == 162) && functions.matches(line.csSiteSpecificFactor25, /^0[246]0$/))
                code = '10B'
        }
        else if (code == '16B') {
            if ((480 <= site && site <= 488) && line.csSiteSpecificFactor10 == '020')
                code = '16A'
        }
        else if (code == '021') {
            if (site == 240) {
                if (line.csSiteSpecificFactor25 == '030')
                    code = '020'
                else if (line.csSiteSpecificFactor25 == '040' || line.csSiteSpecificFactor25 == '070')
                    code = '022'
            }
        }
        else if (code == '37B') {
            if ((481 <= site && site <= 488) && line.csSiteSpecificFactor25 != '002')
                code = '999'
        }
        else if (code == '051') {
            if (site == 693)
                code = '51A'
            else if (site == 694) {
                if (line.csSiteSpecificFactor25 == '010' || line.csSiteSpecificFactor25 == '999')
                    code = '51A'
                else if (line.csSiteSpecificFactor25 == '020')
                    code = '51B'
                else
                    code = '999'
            }
        }
        else if (code == '053') {
            if (line.csSiteSpecificFactor25 != '015')
                code = '999'
        }
        
        if (code == '999') {
            if (site == 739 && functions.expandList((List)[8000..8576, 8940..8950, 8980..8981]).contains(hist) && line.grade == '4')
                code = '08F'
            else if ((481 <= site && site <= 488) && functions.expandList((List)[8800..8820, 8823..8934, 8940..9136, 9142..9582]).contains(hist) && line.csSiteSpecificFactor25 != '002')
                code = '028'
            else if ((481 <= site && site <= 488) && functions.expandList((List)[8800..8820, 8823..8921, 9120..9136, 9142..9582]).contains(hist) && line.csSiteSpecificFactor25 == '002')
                code = '028'
            else if ([420, 421, 424].contains(site) && functions.expandList((List)[9590..9699, 9702..9729, 9735, 9737, 9738, 9811..9818, 9837]).contains(hist))
                code = '57A'
        }
        
        if  (code == '57A') {
            if (functions.expandList((List)[9811..9818, 9837]).contains(hist))
                code = '57C'
        }
        
        boolean validClin = false
        boolean validPath = false
        if ((code == '028' || code == '37B') && functions.expandList((List)[9050..9055]).contains(hist)) {
            if (clin != null && clin == '88')
                validClin = true
            if (path != null && path == '88')
                validPath = true
        }
        
        if (!validClin && clin != null && !((List)((Map)((Map)context.IF508_TNM_CODES_Table).getOrDefault(code, [:])).getOrDefault('C', [])).contains(clin))
            return false
        
        if (!validPath && path != null && !((List)((Map)((Map)context.IF508_TNM_CODES_Table).getOrDefault(code, [:])).getOrDefault('P', [])).contains(path))
            return false
        
        return true
    }

    // ID: IF509; NAME: Primary Site, AJCC T - Ed 7, ICDO3 (SEER)
    public boolean if509(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear != '2015' || (line.tnmEditionNumber != '07' && line.tnmEditionNumber != '88') ||
            (line.tnmClinT == null && line.tnmPathT == null) || line.histologicTypeIcdO3 == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line.typeOfReportingSource == '7')
            return true
        
        Integer site = functions.asInt(line.primarySite.substring(1))
        Integer hist = functions.asInt(line.histologicTypeIcdO3)
        String clin = line.tnmClinT
        if (clin == 'pISU')
            clin = 'ISPU'
        else if (clin == 'pISD')
            clin = 'ISPD'
        else if (clin ==~ /^[pc].+$/)
             clin = clin.substring(1)
        String path = line.tnmPathT
        if (path == 'pISU')
            path = 'ISPU'
        else if (path == 'pISD')
            path = 'ISPD'
        else if (path ==~ /^[pc].+$/)
             path = path.substring(1)
        
        if (line.tnmEditionNumber == '88' && (clin == null || clin == '88') && (path == null || path == '88') && line.overRideSiteTnmStggrp == '1')
            return true
        
        String code = ((Map)((Map)context.AJCC7SiteHistTable).getOrDefault(site, [:])).getOrDefault(hist, '999')
        
        if (functions.expandList((List)[0..419, 422, 423, 425..440, 442..689, 691..694, 698..809]).contains(site) &&
            functions.expandList((List)[9590..9699, 9702..9729, 9735, 9737, 9738, 9811..9818, 9823, 9827, 9837]).contains(hist))
            code = '57A'
        else if (code == '04C') {
            if (line.csSiteSpecificFactor25 == '020')
                code = '04D'
            else if (line.csSiteSpecificFactor25 != '010')
                code = '999'
        }
        else if (code == '008') {
            if (functions.matches(line.grade, /^[1239]$/)) {
                if (line.ageAtDiagnosis <= '044')
                    code = '08A'
                else if (line.ageAtDiagnosis <= '998')
                    code = '08B'
                else
                    code = '08C'
            }
            else if (line.grade == '4')
                code = '08F'
            else
                code = '999'
        }
        else if (code == '08D') {
            if (line.grade == '4')
                code = '08F'
            else if (!(functions.matches(line.grade, /^[1239]$/)))
                code = '999'
        }
        else if (code == '011') {
            if ((site == 161 || site == 162) && functions.matches(line.csSiteSpecificFactor25, /^0[246]0$/))
                code = '10B'
        }
        else if (code == '16B') {
            if ((480 <= site && site <= 488) && line.csSiteSpecificFactor10 == '020')
                code = '16A'
        }
        else if (code == '021') {
            if (site == 240) {
                if (line.csSiteSpecificFactor25 == '030')
                    code = '020'
                else if (line.csSiteSpecificFactor25 == '040' || line.csSiteSpecificFactor25 == '070')
                    code = '022'
            }
        }
        else if (code == '37B') {
            if ((481 <= site && site <= 488) && line.csSiteSpecificFactor25 != '002')
                code = '999'
        }
        else if (code == '046') {
            if (line.sex == '2')
                code = '46A'
            else
                code = '46B'
        }
        else if (code == '051') {
            if (site == 693)
                code = '51A'
            else if (site == 694) {
                if (line.csSiteSpecificFactor25 == '010' || line.csSiteSpecificFactor25 == '999')
                    code = '51A'
                else if (line.csSiteSpecificFactor25 == '020')
                    code = '51B'
                else
                    code = '999'
            }
        }
        else if (code == '053') {
            if (line.csSiteSpecificFactor25 != '015')
                code = '999'
        }
        
        if (code == '999') {
            if (site == 739 && functions.expandList((List)[8000..8576, 8940..8950, 8980..8981]).contains(hist) && line.grade == '4')
                code = '08F'
            else if ((481 <= site && site <= 488) && functions.expandList((List)[8800..8820, 8823..8934, 8940..9136, 9142..9582]).contains(hist) && line.csSiteSpecificFactor25 != '002')
                code = '028'
            else if ((481 <= site && site <= 488) && functions.expandList((List)[8800..8820, 8823..8921, 9120..9136, 9142..9582]).contains(hist) && line.csSiteSpecificFactor25 == '002')
                code = '028'
        }
        
        boolean validClin = false
        boolean validPath = false
        if ((code == '028' || code == '37B') && functions.expandList((List)[9050..9055]).contains(hist)) {
            if (clin != null && clin == '88')
                validClin = true
            if (path != null && path == '88')
                validPath = true
        }
        
        if (!validClin && clin != null && !((List)((Map)((Map)context.IF509_TNM_CODES_Table).getOrDefault(code, [:])).getOrDefault('C', [])).contains(clin))
            return false
        
        if (!validPath && path != null && !((List)((Map)((Map)context.IF509_TNM_CODES_Table).getOrDefault(code, [:])).getOrDefault('P', [])).contains(path))
            return false
        
        return true
    }

    // ID: IF510; NAME: Primary Site, Heme Morph, DateDX, Override (SEER)
    public boolean if510(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.behaviorCodeIcdO3 == null || line.behaviorCodeIcdO3 != '3' ||
            line.histologicTypeIcdO3 == null || line.histologicTypeIcdO3 < '9590' || line.histologicTypeIcdO3 > '9993' || line.primarySite == null || line.overRideSiteType == '1')
            return true
        
        if (line.dateOfDiagnosisYear >= '2010') {
            Integer hist = functions.asInt(line.histologicTypeIcdO3)
            if ([9650,9651,9652,9653,9655,9659,9663,9688].contains(hist)) {
                if (!(functions.matches(line.primarySite, /^C77[0-9]$/)))
                    return false
            }
            else if ([9597,9700,9701,9709,9718,9725].contains(hist)) {
                if (!(functions.matches(line.primarySite, /^C44[0-9]$/)) && !(functions.matches(line.primarySite, /^C51[01289]$/)) && !(functions.matches(line.primarySite, /^C60[01289]$/)) && line.primarySite != 'C632')
                    return false
            }
            else if (hist == 9708 || hist == 9726) {
                if (!(functions.matches(line.primarySite, /^C4[49][0-9]$/)) && !(functions.matches(line.primarySite, /^C(51|60)[01289]$/)) && line.primarySite != 'C632')
                    return false
            }
            else if (hist == 9719) {
                if (!(functions.matches(line.primarySite, /^C(05|11|31)[0-9]$/)) && !(functions.matches(line.primarySite, /^C30[01]$/)))
                    return false
            }
            else if (hist == 9751) {
                if (!(functions.matches(line.primarySite, /^C(34|4[0149]|77)[0-9]$/)) && line.primarySite != 'C421')
                    return false
            }
        }
        
        return true
    }

    // ID: IF512; NAME: RX Date BRM, Date Last Contact (COC)
    public boolean if512(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.rxDateBrmYear == null || line.dateOfLastContactYear == null)
            return true
        
        if (line.rxDateBrmYear > line.dateOfLastContactYear)
            return false
        
        if (line.rxDateBrmYear < line.dateOfLastContactYear || line.rxDateBrmMonth == null || line.dateOfLastContactMonth == null)
            return true
        
        if (line.rxDateBrmMonth > line.dateOfLastContactMonth)
            return false
        
        if (line.rxDateBrmMonth < line.dateOfLastContactMonth || line.rxDateBrmDay == null || line.dateOfLastContactDay == null)
            return true
        
        return line.rxDateBrmDay <= line.dateOfLastContactDay
    }

    // ID: IF513; NAME: RX Date BRM, Date of Diagnosis (COC)
    public boolean if513(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.rxDateBrmYear == null || line.dateOfDiagnosisYear == null)
            return true
        
        if (line.rxDateBrmYear < line.dateOfDiagnosisYear)
            return false
        
        if (line.rxDateBrmYear > line.dateOfDiagnosisYear || line.rxDateBrmMonth == null || line.dateOfDiagnosisMonth == null)
            return true
        
        if (line.rxDateBrmMonth < line.dateOfDiagnosisMonth)
            return false
        
        if (line.rxDateBrmMonth > line.dateOfDiagnosisMonth || line.rxDateBrmDay == null || line.dateOfDiagnosisDay == null)
            return true
        
        return line.rxDateBrmDay >= line.dateOfDiagnosisDay
    }

    // ID: IF515; NAME: RX Date Chemo, Date Last Contact (COC)
    public boolean if515(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.rxDateChemoYear == null || line.dateOfLastContactYear == null)
            return true
        
        if (line.rxDateChemoYear > line.dateOfLastContactYear)
            return false
        
        if (line.rxDateChemoYear < line.dateOfLastContactYear || line.rxDateChemoMonth == null || line.dateOfLastContactMonth == null)
            return true
        
        if (line.rxDateChemoMonth > line.dateOfLastContactMonth)
            return false
        
        if (line.rxDateChemoMonth < line.dateOfLastContactMonth || line.rxDateChemoDay == null || line.dateOfLastContactDay == null)
            return true
        
        return line.rxDateChemoDay <= line.dateOfLastContactDay
    }

    // ID: IF516; NAME: RX Date Chemo, Date of Diagnosis (COC)
    public boolean if516(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.rxDateChemoYear == null || line.dateOfDiagnosisYear == null)
            return true
        
        if (line.rxDateChemoYear < line.dateOfDiagnosisYear)
            return false
        
        if (line.rxDateChemoYear > line.dateOfDiagnosisYear || line.rxDateChemoMonth == null || line.dateOfDiagnosisMonth == null)
            return true
        
        if (line.rxDateChemoMonth < line.dateOfDiagnosisMonth)
            return false
        
        if (line.rxDateChemoMonth > line.dateOfDiagnosisMonth || line.rxDateChemoDay == null || line.dateOfDiagnosisDay == null)
            return true
        
        return line.rxDateChemoDay >= line.dateOfDiagnosisDay
    }

    // ID: IF518; NAME: RX Date Hormone, Date Last Contact (COC)
    public boolean if518(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.rxDateHormoneYear == null || line.dateOfLastContactYear == null)
            return true
        
        if (line.rxDateHormoneYear > line.dateOfLastContactYear)
            return false
        
        if (line.rxDateHormoneYear < line.dateOfLastContactYear || line.rxDateHormoneMonth == null || line.dateOfLastContactMonth == null)
            return true
        
        if (line.rxDateHormoneMonth > line.dateOfLastContactMonth)
            return false
        
        if (line.rxDateHormoneMonth < line.dateOfLastContactMonth || line.rxDateHormoneDay == null || line.dateOfLastContactDay == null)
            return true
        
        return line.rxDateHormoneDay <= line.dateOfLastContactDay
    }

    // ID: IF519; NAME: RX Date Hormone, Date of Diagnosis (COC)
    public boolean if519(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.rxDateHormoneYear == null || line.dateOfDiagnosisYear == null)
            return true
        
        if (line.rxDateHormoneYear < line.dateOfDiagnosisYear)
            return false
        
        if (line.rxDateHormoneYear > line.dateOfDiagnosisYear || line.rxDateHormoneMonth == null || line.dateOfDiagnosisMonth == null)
            return true
        
        if (line.rxDateHormoneMonth < line.dateOfDiagnosisMonth)
            return false
        
        if (line.rxDateHormoneMonth > line.dateOfDiagnosisMonth || line.rxDateHormoneDay == null || line.dateOfDiagnosisDay == null)
            return true
        
        return line.rxDateHormoneDay >= line.dateOfDiagnosisDay
    }

    // ID: IF521; NAME: RX Date Other, Date Last Contact (COC)
    public boolean if521(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.rxDateOtherYear == null || line.dateOfLastContactYear == null)
            return true
        
        if (line.rxDateOtherYear > line.dateOfLastContactYear)
            return false
        
        if (line.rxDateOtherYear < line.dateOfLastContactYear || line.rxDateOtherMonth == null || line.dateOfLastContactMonth == null)
            return true
        
        if (line.rxDateOtherMonth > line.dateOfLastContactMonth)
            return false
        
        if (line.rxDateOtherMonth < line.dateOfLastContactMonth || line.rxDateOtherDay == null || line.dateOfLastContactDay == null)
            return true
        
        return line.rxDateOtherDay <= line.dateOfLastContactDay
    }

    // ID: IF522; NAME: RX Date Other, Date of Diagnosis (COC)
    public boolean if522(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.rxDateOtherYear == null || line.dateOfDiagnosisYear == null)
            return true
        
        if (line.rxDateOtherYear < line.dateOfDiagnosisYear)
            return false
        
        if (line.rxDateOtherYear > line.dateOfDiagnosisYear || line.rxDateOtherMonth == null || line.dateOfDiagnosisMonth == null)
            return true
        
        if (line.rxDateOtherMonth < line.dateOfDiagnosisMonth)
            return false
        
        if (line.rxDateOtherMonth > line.dateOfDiagnosisMonth || line.rxDateOtherDay == null || line.dateOfDiagnosisDay == null)
            return true
        
        return line.rxDateOtherDay >= line.dateOfDiagnosisDay
    }

    // ID: IF524; NAME: RX Date Radiation, Date Last Contact (COC)
    public boolean if524(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.rxDateRadiationYear == null || line.dateOfLastContactYear == null)
            return true
        
        if (line.rxDateRadiationYear > line.dateOfLastContactYear)
            return false
        
        if (line.rxDateRadiationYear < line.dateOfLastContactYear || line.rxDateRadiationMonth == null || line.dateOfLastContactMonth == null)
            return true
        
        if (line.rxDateRadiationMonth > line.dateOfLastContactMonth)
            return false
        
        if (line.rxDateRadiationMonth < line.dateOfLastContactMonth || line.rxDateRadiationDay == null || line.dateOfLastContactDay == null)
            return true
        
        return line.rxDateRadiationDay <= line.dateOfLastContactDay
    }

    // ID: IF525; NAME: RX Date Radiation, Date of Diagnosis (COC)
    public boolean if525(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.rxDateRadiationYear == null || line.dateOfDiagnosisYear == null)
            return true
        
        if (line.rxDateRadiationYear < line.dateOfDiagnosisYear)
            return false
        
        if (line.rxDateRadiationYear > line.dateOfDiagnosisYear || line.rxDateRadiationMonth == null || line.dateOfDiagnosisMonth == null)
            return true
        
        if (line.rxDateRadiationMonth < line.dateOfDiagnosisMonth)
            return false
        
        if (line.rxDateRadiationMonth > line.dateOfDiagnosisMonth || line.rxDateRadiationDay == null || line.dateOfDiagnosisDay == null)
            return true
        
        return line.rxDateRadiationDay >= line.dateOfDiagnosisDay
    }

    // ID: IF527; NAME: RX Date Surgery, Date Last Contact (COC)
    public boolean if527(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.rxDateSurgeryYear == null || line.dateOfLastContactYear == null)
            return true
        
        if (line.rxDateSurgeryYear > line.dateOfLastContactYear)
            return false
        
        if (line.rxDateSurgeryYear < line.dateOfLastContactYear || line.rxDateSurgeryMonth == null || line.dateOfLastContactMonth == null)
            return true
        
        if (line.rxDateSurgeryMonth > line.dateOfLastContactMonth)
            return false
        
        if (line.rxDateSurgeryMonth < line.dateOfLastContactMonth || line.rxDateSurgeryDay == null || line.dateOfLastContactDay == null)
            return true
        
        return line.rxDateSurgeryDay <= line.dateOfLastContactDay
    }

    // ID: IF528; NAME: RX Date Surgery, Date of Diagnosis (COC)
    public boolean if528(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.rxDateSurgeryYear == null || line.dateOfDiagnosisYear == null)
            return true
        
        if (line.rxDateSurgeryYear < line.dateOfDiagnosisYear)
            return false
        
        if (line.rxDateSurgeryYear > line.dateOfDiagnosisYear || line.rxDateSurgeryMonth == null || line.dateOfDiagnosisMonth == null)
            return true
        
        if (line.rxDateSurgeryMonth < line.dateOfDiagnosisMonth)
            return false
        
        if (line.rxDateSurgeryMonth > line.dateOfDiagnosisMonth || line.rxDateSurgeryDay == null || line.dateOfDiagnosisDay == null)
            return true
        
        return line.rxDateSurgeryDay >= line.dateOfDiagnosisDay
    }

    // ID: IF529; NAME: TNM Clin Descriptor, Date of Diagnosis (SEER)
    public boolean if529(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.dateOfDiagnosisYear > '2017' || line.tnmClinDescriptor != null
    }

    // ID: IF530; NAME: TNM Clin Staged By, Date of Diagnosis (SEER)
    public boolean if530(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        boolean skipCondition1 = line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2015' || line.dateOfDiagnosisYear > '2017'
        boolean skipCondition2 = line.tnmClinStagedBy == null && line.dateOfDiagnosisYear == '2015'
        boolean skipCondition3 = ['0000001563', '0000001566'].contains(line.registryId)
        if (skipCondition1 || skipCondition2 || skipCondition3)
            return true
        
        return functions.matches(line.tnmClinStagedBy, /^[0-6]0|1[1-5]|88|99$/)
    }

    // ID: IF531; NAME: TNM Edition Number, Date of Diagnosis (SEER)
    public boolean if531(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2015')
            return true
        
        if (line.dateOfDiagnosisYear == '2015')
            return ['07', '88'].contains(line.tnmEditionNumber) || line.tnmEditionNumber == null
        else if (line.dateOfDiagnosisYear == '2016' || line.dateOfDiagnosisYear == '2017')
            return ['07', 'U7', '88'].contains(line.tnmEditionNumber)
        else if (line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2021')
            return ['08', '88'].contains(line.tnmEditionNumber) || line.tnmEditionNumber == null
        else if (line.dateOfDiagnosisYear > '2020')
            return ['00', '08', '09', '88'].contains(line.tnmEditionNumber) || line.tnmEditionNumber == null
        return true
    }

    // ID: IF532; NAME: TNM Edition Number, TNM Fields (NPCR)
    public boolean if532(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear != '2015')
            return true
        
        if (line.tnmPathT != null || line.tnmPathN != null || line.tnmPathM != null || line.tnmPathStageGroup != null || line.tnmPathDescriptor != null ||
            line.tnmClinT != null || line.tnmClinN != null || line.tnmClinM != null || line.tnmClinStageGroup != null || line.tnmClinDescriptor != null)
            return line.tnmEditionNumber != null
        
        return true
    }

    // ID: IF533; NAME: TNM Path Descriptor, Date of Diagnosis (SEER)
    public boolean if533(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.dateOfDiagnosisYear > '2017' || line.tnmPathDescriptor != null
    }

    // ID: IF534; NAME: TNM Path Staged By, Date of Diagnosis (SEER)
    public boolean if534(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        boolean skipCondition1 = line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2015' || line.dateOfDiagnosisYear > '2017'
        boolean skipCondition2 = line.tnmPathStagedBy == null && line.dateOfDiagnosisYear == '2015'
        boolean skipCondition3 = ['0000001563', '0000001566'].contains(line.registryId)
        if (skipCondition1 || skipCondition2 || skipCondition3)
            return true
        
        return functions.matches(line.tnmPathStagedBy, /^[0-6]0|1[1-5]|88|99$/)
    }

    // ID: IF535; NAME: CS SSF 8, SSF 10, Grade, Prostate (SEER)
    public boolean if535(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2014' || line.dateOfDiagnosisYear > '2017' || line.typeOfReportingSource == '7')
            return true
        
        if (line.csSiteSpecificFactor8 == null || line.csSiteSpecificFactor8 == '988' || line.csSiteSpecificFactor10 == null || line.csSiteSpecificFactor10 == '988')
            return true
        
        if(line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        Integer hist = functions.asInt(line.histologicTypeIcdO3)
        if (line.primarySite != 'C619' || !((8000 <= hist && hist <= 9136) || (9141 <= hist && hist <= 9582) || hist == 9700 || hist == 9701))
            return true
        
        String ssf10 = line.csSiteSpecificFactor10
        if (functions.matches(line.csSiteSpecificFactor8, /^00[2-6]$/)) {
            if ((ssf10 ==~ /^00[2-6]$/ || ssf10 == '998' || ssf10 == '999') && line.grade != '1')
                return false
            else if (ssf10 == '007' && line.grade != '2')
                return false
            else if (['008','009','010'].contains(ssf10) && line.grade != '3')
                return false
        }
        else if (line.csSiteSpecificFactor8 == '007') {
            if ((ssf10 ==~ /^00[2-7]$/ || ssf10 == '998' || ssf10 == '999') && line.grade != '2')
                return false
            else if (['008','009','010'].contains(ssf10) && line.grade != '3')
                return false
        }
        else if (['008','009','010'].contains(line.csSiteSpecificFactor8)) {
            if ((ssf10 ==~ /^00[2-9]$/ || ssf10 == '010' || ssf10 == '998' || ssf10 == '999') && line.grade != '3')
                return false
        }
        else if (line.csSiteSpecificFactor8 == '998' || line.csSiteSpecificFactor8 == '999') {
            if (ssf10 ==~ /^00[2-6]$/ && line.grade != '1')
                return false
            else if (ssf10 == '007' && line.grade != '2')
                return false
            else if (['008','009','010'].contains(ssf10) && line.grade != '3')
                return false
        }
        
        return true
    }

    // ID: IF536; NAME: CS Items - SEER Required - SSF 25 (CS)
    public boolean if536(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.primarySite == null || line.histologicTypeIcdO3 == null || ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !['brain','cns_other','intracranial_gland'].contains(line._csSchemaId)) || line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear >= '2004' && line.dateOfDiagnosisYear <= '2017' && line.csSiteSpecificFactor25 == null)
            return false
        
        Integer yearDx = functions.asInt(line.dateOfDiagnosisYear)
        String schemaMatch = ((List)((Map)context.CS_SSF).get(line._csSchemaId))?.get(24)//sf25
        // R = Required
        if (line._csSchemaId != null && schemaMatch != 'R')
            return true
        
        if ((yearDx > 2015 && line.csExtension != null) || (yearDx > 2003 && yearDx < 2016))
            return line.csSiteSpecificFactor25 != '988'
        else if (yearDx > 2015 && line.csExtension == null) {
            boolean peritoneumSite = functions.matches(line.primarySite, /^C48[128]$/)
            String hist = line.histologicTypeIcdO3
            boolean peritoneumHist = ('8000' <= hist && hist <= '8934') || ('8940' <= hist && hist <= '9136') || ('9141' <= hist && hist <= '9582') || ('9700' <= hist && hist <= '9701')
            if (line._csSchemaId != 'peritoneum' && line._csSchemaId != 'peritoneum_female_gen' && !(peritoneumSite && peritoneumHist))
                return line.csSiteSpecificFactor25 != '988'
        }
        
        return true
    }

    // ID: IF537; NAME: Regional Nodes Positive, Date of Dx (SEER)
    public boolean if537(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2004' || line.regionalNodesPositive != null
    }

    // ID: IF538; NAME: Regional Nodes Examined, Date of Dx (SEER)
    public boolean if538(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2004' || line.regionalNodesExamined != null
    }

    // ID: IF539; NAME: Mets at DX-Bone, Date of Diagnosis (SEER)
    public boolean if539(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null ||
            (line.registryId == '0000001563' && (line.dateOfDiagnosisYear >= '2016' && line.dateOfDiagnosisYear <= '2019')) ||
            (line.registryId == '0000001565' && (line.dateOfDiagnosisYear >= '2018' && line.dateOfDiagnosisYear <= '2022')) ||
            (line.registryId == '0000001566' && (line.dateOfDiagnosisYear >= '2016' && line.dateOfDiagnosisYear <= '2021')) )
            return true
        
        if (line.dateOfDiagnosisYear > '2015')
            return line.metsAtDxBone != null
        else
            return line.metsAtDxBone == null
    }

    // ID: IF540; NAME: Mets at DX-Brain, Date of Diagnosis (SEER)
    public boolean if540(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null ||
            (line.registryId == '0000001563' && (line.dateOfDiagnosisYear >= '2016' && line.dateOfDiagnosisYear <= '2019')) ||
            (line.registryId == '0000001565' && (line.dateOfDiagnosisYear >= '2018' && line.dateOfDiagnosisYear <= '2022')) ||
            (line.registryId == '0000001566' && (line.dateOfDiagnosisYear >= '2016' && line.dateOfDiagnosisYear <= '2021')) )
            return true
        
        if (line.dateOfDiagnosisYear > '2015')
            return line.metsAtDxBrain != null
        else
            return line.metsAtDxBrain == null
    }

    // ID: IF541; NAME: Mets at DX-Distant LN, Date of Diagnosis (SEER)
    public boolean if541(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null ||
            (line.registryId == '0000001563' && (line.dateOfDiagnosisYear >= '2016' && line.dateOfDiagnosisYear <= '2019')) ||
            (line.registryId == '0000001565' && (line.dateOfDiagnosisYear >= '2018' && line.dateOfDiagnosisYear <= '2022')) ||
            (line.registryId == '0000001566' && (line.dateOfDiagnosisYear >= '2016' && line.dateOfDiagnosisYear <= '2021')) )
            return true
        
        if (line.dateOfDiagnosisYear > '2015')
            return line.metsAtDxDistantLn != null
        else
            return line.metsAtDxDistantLn == null
    }

    // ID: IF542; NAME: Mets at DX-Liver, Date of Diagnosis (SEER)
    public boolean if542(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null ||
            (line.registryId == '0000001563' && (line.dateOfDiagnosisYear >= '2016' && line.dateOfDiagnosisYear <= '2019')) ||
            (line.registryId == '0000001565' && (line.dateOfDiagnosisYear >= '2018' && line.dateOfDiagnosisYear <= '2022')) ||
            (line.registryId == '0000001566' && (line.dateOfDiagnosisYear >= '2016' && line.dateOfDiagnosisYear <= '2021')) )
            return true
        
        if (line.dateOfDiagnosisYear > '2015')
            return line.metsAtDxLiver != null
        else
            return line.metsAtDxLiver == null
    }

    // ID: IF543; NAME: Mets at DX-Lung, Date of Diagnosis (SEER)
    public boolean if543(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null ||
            (line.registryId == '0000001563' && (line.dateOfDiagnosisYear >= '2016' && line.dateOfDiagnosisYear <= '2019')) ||
            (line.registryId == '0000001565' && (line.dateOfDiagnosisYear >= '2018' && line.dateOfDiagnosisYear <= '2022')) ||
            (line.registryId == '0000001566' && (line.dateOfDiagnosisYear >= '2016' && line.dateOfDiagnosisYear <= '2021')) )
            return true
        
        if (line.dateOfDiagnosisYear > '2015')
            return line.metsAtDxLung != null
        else
            return line.metsAtDxLung == null
    }

    // ID: IF544; NAME: Mets at DX-Other, Date of Diagnosis (SEER)
    public boolean if544(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null ||
            (line.registryId == '0000001563' && (line.dateOfDiagnosisYear >= '2016' && line.dateOfDiagnosisYear <= '2019')) ||
            (line.registryId == '0000001565' && (line.dateOfDiagnosisYear >= '2018' && line.dateOfDiagnosisYear <= '2022')) ||
            (line.registryId == '0000001566' && (line.dateOfDiagnosisYear >= '2016' && line.dateOfDiagnosisYear <= '2021')) )
            return true
        
        if (line.dateOfDiagnosisYear > '2015')
            return line.metsAtDxOther != null
        else
            return line.metsAtDxOther == null
    }

    // ID: IF545; NAME: TNM Clin M, Date of Diagnosis (COC)
    public boolean if545(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.dateOfDiagnosisYear > '2017' || line.tnmClinM == null)
            return true
        
        if (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7')
            return true
        
        return line.tnmClinM == '88' || (functions.matches(line.tnmClinM, /^[cp].+$/) && ((List)context.TNM_Clin_M_Table).contains(line.tnmClinM))
    }

    // ID: IF546; NAME: TNM Clin N, Date of Diagnosis (COC)
    public boolean if546(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.dateOfDiagnosisYear > '2017' || line.tnmClinN == null)
            return true
        
        if (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7')
            return true
        
        return ((List)context.IF546_Table).contains(line.tnmClinN)
    }

    // ID: IF547; NAME: TNM Clin T, Date of Diagnosis (SEER)
    public boolean if547(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.dateOfDiagnosisYear > '2017' || line.tnmClinT == null)
            return true
        
        if (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7')
           return true
        
        return line.tnmClinT == '88' || (functions.matches(line.tnmClinT, /^[cp].+$/) && ((List)context.TNM_Clin_T_Table).contains(line.tnmClinT))
    }

    // ID: IF548; NAME: TNM Path M, Date of Diagnosis (COC)
    public boolean if548(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.dateOfDiagnosisYear > '2017' || line.tnmPathM == null)
            return true
        
        if (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7')
            return true
        
        return line.tnmPathM == '88' || (functions.matches(line.tnmPathM, /^[cp].+$/) && ((List)context.TNM_Path_M_Table).contains(line.tnmPathM))
    }

    // ID: IF549; NAME: TNM Path N, Date of Diagnosis (COC)
    public boolean if549(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.dateOfDiagnosisYear > '2017' || line.tnmPathN == null)
            return true
        
        if (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7')
            return true
        
        return ((List)context.IF549_Table).contains(line.tnmPathN)
    }

    // ID: IF550; NAME: TNM Path T, Date of Diagnosis (COC)
    public boolean if550(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.dateOfDiagnosisYear > '2017' || line.tnmPathT == null)
            return true
        
        if (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7')
            return true
        
        return ((List)context.IF550_Table).contains(line.tnmPathT)
    }

    // ID: IF551; NAME: Tumor Size Clinical, Date of Diagnosis (SEER)
    public boolean if551(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
            
        if (line.dateOfDiagnosisYear <= '2017' && line.dateOfDiagnosisYear >= '2016' && line.registryId == '0000001561')
            return true
        if (line.dateOfDiagnosisYear <= '2018' && line.dateOfDiagnosisYear >= '2016' && ['0000001562', '0000001563'].contains(line.registryId))
            return true
        if (line.dateOfDiagnosisYear <= '2021' && line.dateOfDiagnosisYear >= '2016' && line.registryId == '0000001566')
            return true
        if (line.dateOfDiagnosisYear <= '2022' && line.dateOfDiagnosisYear >= '2016' && line.registryId == '0000001565')
            return true
        
        if (line.dateOfDiagnosisYear < '2016')
            return line.tumorSizeClinical == null
        if (line.dateOfDiagnosisYear > '2015' && line.dateOfDiagnosisYear < '2024')
            return line.tumorSizeClinical != null
        return true
    }

    // ID: IF552; NAME: Tumor Size Clinical, Primary Site (SEER)
    public boolean if552(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear > '2023')
                    return true
        
                    return line.tumorSizeClinical != '998' || functions.matches(line.primarySite, /^C(1(5[0-589]|6[0-689]|8[02-9]|99)|209|34[0-389]|50[0-689])$/)
    }

    // ID: IF553; NAME: Tumor Size Clinical, TNM Clin T (SEER)
    public boolean if553(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        boolean dxYearCondition = line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.dateOfDiagnosisYear > '2017'
        if (dxYearCondition || line.typeOfReportingSource == '7' || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || 
            line.tnmClinT == null || line.tnmClinT == '88' || line.tumorSizeClinical == null)
            return true
        
        return (line.tumorSizeClinical == '000' && line.tnmClinT == 'c0') || (line.tumorSizeClinical != '000' && line.tnmClinT != 'c0')
    }

    // ID: IF554; NAME: Tumor Size Pathologic, Date of Diagnosis (SEER)
    public boolean if554(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear <= '2017' && line.dateOfDiagnosisYear >= '2016' && line.registryId == '0000001561')
            return true
        if (line.dateOfDiagnosisYear <= '2018' && line.dateOfDiagnosisYear >= '2016' && ['0000001562', '0000001563'].contains(line.registryId))
            return true
        if (line.dateOfDiagnosisYear <= '2021' && line.dateOfDiagnosisYear >= '2016' && line.registryId == '0000001566')
            return true
        if (line.dateOfDiagnosisYear <= '2022' && line.dateOfDiagnosisYear >= '2016' && line.registryId == '0000001565')
            return true
        
        if (line.dateOfDiagnosisYear < '2016')
            return line.tumorSizePathologic == null
        if (line.dateOfDiagnosisYear > '2015' && line.dateOfDiagnosisYear < '2024')
            return line.tumorSizePathologic != null
        return true
    }

    // ID: IF555; NAME: Tumor Size Pathologic, Primary Site (SEER)
    public boolean if555(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.tumorSizePathologic != '998' || functions.matches(line.primarySite, /^C(1(5[0-589]|6[0-689]|8[02-9]|99)|209|34[0-389]|50[0-689])$/)
    }

    // ID: IF556; NAME: Tumor Size Pathologic, TNM Path T (SEER)
    public boolean if556(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        boolean dxYearCondition = line.dateOfDiagnosisYear < '2016' || line.dateOfDiagnosisYear > '2017' || line.dateOfDiagnosisYear == null
        if (dxYearCondition || line.typeOfReportingSource == '7' || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || 
            line.tnmPathT == null || line.tnmPathT == '88' || line.tumorSizePathologic == null)
            return true
        
        return (line.tumorSizePathologic == '000' && line.tnmPathT == 'p0') || (line.tumorSizePathologic != '000' && line.tnmPathT != 'p0')
    }

    // ID: IF557; NAME: Lymphovascular Invasion, Date of Dx (SEER)
    public boolean if557(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2010')
        return true
        if (line.registryId == '0000001566') {
            if (line.dateOfDiagnosisYear == '2010')
                return true
            if ((line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022') && !['00570','00590'].contains(line.schemaId))
                return true
        }
        
        if (line.dateOfDiagnosisYear < '2018') {
            if ((line._csSchemaId == 'testis' || line._csSchemaId == 'penis') && !functions.matches(line.lymphVascularInvasion, /^[019]$/))
                return false
            else
                return line.lymphVascularInvasion == null || functions.matches(line.lymphVascularInvasion, /^[0189]$/)
        }
        else {
            if ((line.schemaId == '00570' || line.schemaId == '00590') && !functions.matches(line.lymphVascularInvasion, /^[0-49]$/))
                return false
            else
                return functions.matches(line.lymphVascularInvasion, /^[0-489]$/)
        }
    }

    // ID: IF558; NAME: CS SSF 9, Surgery, HeadNeck Schemas (CS)
    public boolean if558(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        String ssf9 = line.csSiteSpecificFactor9
        String scopeRegLnSur = line.rxSummScopeRegLnSur
        String tumSize = line.csTumorSizeExtEval
        String behav = line.behaviorCodeIcdO3
        String schema = line._csSchemaId
        
        if (ssf9 == null || ssf9 == '988' || scopeRegLnSur == null || behav == '0' || behav == '1' || schema == null || !((List)context.HEAD_AND_NECK_Schemas).contains(schema))
            return true
        
        // skipping condition
        if (tumSize == null || tumSize == '2' || tumSize == '8' || tumSize == '9')
            return true
        
        // part 1
        if (scopeRegLnSur == '0' && ssf9 != '998' && ssf9 != '999')
            return false
        
        // part 2
        if (functions.asInt(line.csVersionInputOriginal) >= 20500 && scopeRegLnSur == '1' && ssf9 != '998' && ssf9 != '999')
            return false
        
        return true
    }

    // ID: IF559; NAME: TNM Clin Stage Group, 2016 (COC)
    public boolean if559(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.dateOfDiagnosisYear > '2017' || line.tnmClinStageGroup == null)
            return true
        
        if (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7')
            return true
        
        return ((List)context.TNM_Stage_Group_Table).contains(line.tnmClinStageGroup)
    }

    // ID: IF560; NAME: TNM Path Stage Group, 2016 (COC)
    public boolean if560(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.dateOfDiagnosisYear > '2017' || line.tnmPathStageGroup == null)
            return true
        
        if (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7')
            return true
        
        return ((List)context.TNM_Stage_Group_Table).contains(line.tnmPathStageGroup)
    }

    // ID: IF561; NAME: TNM Fields, Type of Reporting Source (SEER)
    public boolean if561(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.dateOfDiagnosisYear > '2017' || line.typeOfReportingSource != '7')
            return true
        
        return line.tnmClinT == '88' && line.tnmClinN == '88' && line.tnmClinM == '88' && line.tnmClinStageGroup == '88' &&
               line.tnmPathT == '88' && line.tnmPathN == '88' && line.tnmPathM == '88' && line.tnmPathStageGroup == '88'
    }

    // ID: IF562; NAME: Mets at DX-Bone, TNM Clin M, Path M (SEER)
    public boolean if562(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        boolean dxYearSkipCondition = line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.dateOfDiagnosisYear > '2017'
        if (dxYearSkipCondition || line.typeOfReportingSource == '7' || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            (line.tnmPathM == null && line.tnmClinM == null) || (line.tnmPathM == '88' && line.tnmClinM == '88') || line.metsAtDxBone == null)
            return true
        
        if (line.metsAtDxBone != '1')
            return true
        
        if (line.tnmClinM == null)
           return line.tnmPathM != 'c0' && line.tnmPathM != 'c0I+'
        
        if (line.tnmPathM == null)
           return line.tnmClinM != 'c0' && line.tnmClinM != 'c0I+'
        
        return (line.tnmClinM != 'c0' && line.tnmClinM != 'c0I+') || (line.tnmPathM != 'c0' && line.tnmPathM != 'c0I+')
    }

    // ID: IF563; NAME: Mets at DX-Brain, TNM Clin M, Path M (SEER)
    public boolean if563(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        boolean dxYearSkipCondition = line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.dateOfDiagnosisYear > '2017'
        if (dxYearSkipCondition || line.typeOfReportingSource == '7' || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            (line.tnmPathM == null && line.tnmClinM == null) || (line.tnmPathM == '88' && line.tnmClinM == '88') || line.metsAtDxBrain == null)
            return true
        
        if (line.metsAtDxBrain != '1')
            return true
        
        if (line.tnmClinM == null)
           return line.tnmPathM != 'c0' && line.tnmPathM != 'c0I+'
        
        if (line.tnmPathM == null)
           return line.tnmClinM != 'c0' && line.tnmClinM != 'c0I+'
        
        return (line.tnmClinM != 'c0' && line.tnmClinM != 'c0I+') || (line.tnmPathM != 'c0' && line.tnmPathM != 'c0I+')
    }

    // ID: IF564; NAME: Mets at DX-Distant LN, TNM Clin M, Path M (SEER)
    public boolean if564(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        boolean dxYearSkipCondition = line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.dateOfDiagnosisYear > '2017'
        if (dxYearSkipCondition || line.typeOfReportingSource == '7' || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            (line.tnmPathM == null && line.tnmClinM == null) || (line.tnmPathM == '88' && line.tnmClinM == '88') || line.metsAtDxDistantLn == null)
            return true
        
        if (line.metsAtDxDistantLn != '1')
            return true
        
        if (line.tnmClinM == null)
           return line.tnmPathM != 'c0' && line.tnmPathM != 'c0I+'
        
        if (line.tnmPathM == null)
           return line.tnmClinM != 'c0' && line.tnmClinM != 'c0I+'
        
        return (line.tnmClinM != 'c0' && line.tnmClinM != 'c0I+') || (line.tnmPathM != 'c0' && line.tnmPathM != 'c0I+')
    }

    // ID: IF565; NAME: Mets at DX-Liver, TNM Clin M, Path M (SEER)
    public boolean if565(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        boolean dxYearSkipCondition = line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.dateOfDiagnosisYear > '2017'
        if (dxYearSkipCondition || line.typeOfReportingSource == '7' || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            (line.tnmPathM == null && line.tnmClinM == null) || (line.tnmPathM == '88' && line.tnmClinM == '88') || line.metsAtDxLiver == null)
            return true
        
        if (line.metsAtDxLiver != '1')
            return true
        
        if (line.tnmClinM == null)
           return line.tnmPathM != 'c0' && line.tnmPathM != 'c0I+'
        
        if (line.tnmPathM == null)
           return line.tnmClinM != 'c0' && line.tnmClinM != 'c0I+'
        
        return (line.tnmClinM != 'c0' && line.tnmClinM != 'c0I+') || (line.tnmPathM != 'c0' && line.tnmPathM != 'c0I+')
    }

    // ID: IF566; NAME: Mets at DX-Lung, TNM Clin M, Path M (SEER)
    public boolean if566(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        boolean dxYearSkipCondition = line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.dateOfDiagnosisYear > '2017'
        if (dxYearSkipCondition || line.typeOfReportingSource == '7' || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            (line.tnmPathM == null && line.tnmClinM == null) || (line.tnmPathM == '88' && line.tnmClinM == '88') || line.metsAtDxLung == null)
            return true
        
        if (line.metsAtDxLung != '1')
            return true
        
        if (line.tnmClinM == null)
           return line.tnmPathM != 'c0' && line.tnmPathM != 'c0I+'
        
        if (line.tnmPathM == null)
           return line.tnmClinM != 'c0' && line.tnmClinM != 'c0I+'
        
        return (line.tnmClinM != 'c0' && line.tnmClinM != 'c0I+') || (line.tnmPathM != 'c0' && line.tnmPathM != 'c0I+')
    }

    // ID: IF567; NAME: Mets at DX-Other, TNM Clin M, Path M (SEER)
    public boolean if567(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        boolean dxYearSkipCondition = line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.dateOfDiagnosisYear > '2017'
        if (dxYearSkipCondition || line.typeOfReportingSource == '7' || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' ||
            (line.tnmPathM == null && line.tnmClinM == null) || (line.tnmPathM == '88' && line.tnmClinM == '88') || line.metsAtDxOther == null)
            return true
        
        if (line.metsAtDxOther != '1' && line.metsAtDxOther != '2')
            return true
        
        if (line.tnmClinM == null)
           return line.tnmPathM != 'c0' && line.tnmPathM != 'c0I+'
        
        if (line.tnmPathM == null)
           return line.tnmClinM != 'c0' && line.tnmClinM != 'c0I+'
        
        return (line.tnmClinM != 'c0' && line.tnmClinM != 'c0I+') || (line.tnmPathM != 'c0' && line.tnmPathM != 'c0I+')
    }

    // ID: IF568; NAME: SEER Derived Items, Date of DX (SEER)
    public boolean if568(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line._csSchemaId == null)
            return true
        if (line.registryId == '0000001563' || (functions.matches(line.registryId , /^000000156[56]$/) && line.dateOfDiagnosisYear > '2015'))
            return true
        
        if ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !['brain','cns_other','intracranial_gland'].contains(line._csSchemaId))
            return true
        
        if (line.dateOfDiagnosisYear == '2016' || line.dateOfDiagnosisYear == '2017') {
            if (line.derivedSeerPathStgGrp == null || line.derivedSeerClinStgGrp == null || line.derivedSeerCmbStgGrp == null)
                return false
            else if (line.tnmClinT != null || line.tnmClinN != null || line.tnmClinM != null || line.tnmPathT != null || line.tnmPathN != null || line.tnmPathM != null)
                return (line.derivedSeerCombinedT != null && line.derivedSeerCombinedN != null && line.derivedSeerCombinedM != null)
        }
        else if (line.dateOfDiagnosisYear < '2016')
            return (line.derivedSeerPathStgGrp == null && line.derivedSeerClinStgGrp == null && line.derivedSeerCmbStgGrp == null &&
                    line.derivedSeerCombinedT == null && line.derivedSeerCombinedN == null && line.derivedSeerCombinedM == null &&
                    line.derivedSeerCmbTSrc == null && line.derivedSeerCmbNSrc == null && line.derivedSeerCmbMSrc == null)
        
        return true
    }

    // ID: IF569; NAME: TNM Clin T, Histology, Grade, Thyroid (COC)
    public boolean if569(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line.primarySite != 'C739' || line.grade == null || line.tnmClinT == null || line.tnmClinT == '88')
            return true
        
        if (line.tnmPathT != null)
            return true
        
        Integer histNum = functions.asInt(line.histologicTypeIcdO3)
        if ((functions.expandList((List)[8000..8019,8022..8029,8033..8576,8940..8950,8980..8981]).contains(histNum) && line.grade == '4') || [8020,8021,8030,8031,8032].contains(histNum))
            return functions.matches(line.tnmClinT, /^c4[AB]?$/)
        
        return true
    }

    // ID: IF570; NAME: TNM Clin T, Surgery, Prostate (COC)
    public boolean if570(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line.tnmClinT == null || line.tnmClinT == '88' || line.rxSummSurgPrimSite == null)
            return true
        
        Integer histInt = functions.asInt(line.histologicTypeIcdO3)
        if (line.primarySite != 'C619' || !functions.expandList((List)[8000..8110,8140..8576,8940..8950,8980..8981]).contains(histInt))
            return true
        
        if (functions.matches(line.tnmClinT, /^c1[AB]$/))
            return line.rxSummSurgPrimSite != '00' && line.rxSummSurgPrimSite != '99'
        
        return true
    }

    // ID: IF571; NAME: TNM M, Mets at DX, Melanoma of Skin (COC)
    public boolean if571(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line.metsAtDxLung == null)
            return true
        
        //Skip condition 5
        if ((line.tnmClinM == null && line.tnmPathM == null) || (line.tnmClinM == '88' && line.tnmPathM == '88'))
            return true
        
        //Skip condition 7
        if (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7')
            return true
        
        if (line._tnmSchemaId != 'melanoma_skin')
           return true
        
        if (line.metsAtDxLung == '1' && !(functions.matches(line.tnmClinM, /^[cp]1[BC]$/)) && !(functions.matches(line.tnmPathM, /^[cp]1[BC]$/)))
            return false
        else if ((line.metsAtDxLung == '0' || line.metsAtDxLung == '9') && (functions.matches(line.tnmClinM, /^[cp]1B$/) || functions.matches(line.tnmPathM, /^[cp]1B$/)))
            return false
        
        if (functions.matches(line.tnmClinM, /^[cp]1B$/) || functions.matches(line.tnmPathM, /^[cp]1B$/))
            return line.metsAtDxLung == '1'
        
        return true
    }

    // ID: IF572; NAME: TNM M, SSF 4 Melanoma of Skin (COC)
    public boolean if572(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        //Skip condition 5, 6
        if ((line.tnmClinM == null && line.tnmPathM == null) || (line.tnmClinM == '88' && line.tnmPathM == '88') || line.csSiteSpecificFactor4 == null || line.csSiteSpecificFactor4 == '988')
            return true
        
        //Skip condition 7
        if (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7')
            return true
        
        if (line._tnmSchemaId != 'melanoma_skin')
           return true
        
        if (functions.matches(line.csSiteSpecificFactor4, /^0[123]0$/))
            return !(functions.matches(line.tnmClinM, /^[cp]1[AB]$/) || functions.matches(line.tnmPathM, /^[cp]1[AB]$/))
        
        return true
    }

    // ID: IF573; NAME: TNM M, SSF 4 Uveal Melanoma (COC)
    public boolean if573(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        //Skip condition 5, 6
        if ((line.tnmClinM == null && line.tnmPathM == null) || (line.tnmClinM == '88' && line.tnmPathM == '88') ||
            line.csSiteSpecificFactor4 == null || line.csSiteSpecificFactor4 == '988')
            return true
        
        //Skip condition 7
        if (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7')
            return true
        
        if (!(functions.matches(line.primarySite, /^C69[34]$/)) || line.histologicTypeIcdO3 < '8720' || line.histologicTypeIcdO3 > '8790')
           return true
        
        String ssf4 = line.csSiteSpecificFactor4
        if (ssf4 == '000')
            return !(functions.matches(line.tnmClinM, /^[cp]1[ABC]?$/) || functions.matches(line.tnmPathM, /^[cp]1[ABC]?$/))
        else if ((ssf4 >= '001' && ssf4 <= '030') || ssf4 == '991')
            return (functions.matches(line.tnmClinM, /^[cp]1A$/) || functions.matches(line.tnmPathM, /^[cp]1A$/))
        else if ((ssf4 >= '031' && ssf4 <= '080') || ssf4 == '992')
            return (functions.matches(line.tnmClinM, /^[cp]1B$/) || functions.matches(line.tnmPathM, /^[cp]1B$/))
        else if ((ssf4 >= '081' && ssf4 <= '980') || ssf4 == '993')
            return (functions.matches(line.tnmClinM, /^[cp]1C$/) || functions.matches(line.tnmPathM, /^[cp]1C$/))
        
        return true
    }

    // ID: IF574; NAME: TNM N, SSF 3 Melanoma of Skin (COC)
    public boolean if574(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        //Skip conditions 5, 6, 7
        if (line.tnmClinN == null || (line.tnmClinN == '88' && line.tnmPathN == '88') || line.csSiteSpecificFactor3 == null || line.csSiteSpecificFactor3 == '988')
            return true
        
        //Skip conditions 8, 9
        if ((line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7') || line.tnmPathDescriptor == '4' || line.tnmPathDescriptor == '6')
            return true
        
        if (line._tnmSchemaId != 'melanoma_skin')
           return true
        
        String ssf3 = line.csSiteSpecificFactor3
        if (ssf3 == '005')
            return line.tnmClinN == 'c0' && (line.tnmPathN == null || functions.matches(line.tnmPathN, /^[cp]0|pX|p2C$/))
        else if (ssf3 == '010')
            return line.tnmClinN == 'c0' && (line.tnmPathN == null || functions.matches(line.tnmPathN, /^pX|p[12]A|p3$/))
        else if (ssf3 == '043')
            return line.tnmClinN == 'c1'
        else if (ssf3 == '045')
            return line.tnmClinN == 'c2'
        else if (ssf3 == '048')
            return line.tnmClinN == 'c3'
        else if (ssf3 == '100')
            return line.tnmClinN == 'c2C'
        else if (ssf3 == '999')
            return line.tnmClinN == 'cX'
        
        return true
    }

    // ID: IF575; NAME: TNM N, SSF 3 Merkel Cell (COC)
    public boolean if575(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        //Skip conditions 5, 6, 7
        if (line.tnmClinN == null || (line.tnmClinN == '88' && line.tnmPathN == '88') || line.csSiteSpecificFactor3 == null || line.csSiteSpecificFactor3 == '988')
            return true
        
        //Skip conditions 8, 9
        if ((line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7') || line.tnmPathDescriptor == '4' || line.tnmPathDescriptor == '6')
            return true
        
        if (!['merkel_cell_penis','merkel_cell_scrotum','merkel_cell_skin','merkel_cell_vulva'].contains(line._tnmSchemaId))
           return true
        
        String ssf3 = line.csSiteSpecificFactor3
        if (ssf3 == '005')
            return line.tnmClinN == 'c0' && (line.tnmPathN == null || functions.matches(line.tnmPathN, /^[cp]0|pX$/))
        else if (ssf3 == '010')
            return line.tnmClinN == 'c0' && (line.tnmPathN == null || line.tnmPathN == 'p1A')
        else if (ssf3 == '020')
            return line.tnmClinN == 'c1'
        else if (ssf3 == '100' || ssf3 == '150')
            return line.tnmClinN == 'c2'
        else if (ssf3 == '999')
            return line.tnmClinN == 'cX'
        
        return true
    }

    // ID: IF576; NAME: TNM N, SSF 3, 5 Corpus Uteri (COC)
    public boolean if576(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        //Skip condition 5
        if ((line.tnmClinN == null && line.tnmPathN == null) || (line.tnmClinN == '88' && line.tnmPathN == '88'))
            return true
        
        //Skip condition 6
        if ((line.csSiteSpecificFactor3 == null && line.csSiteSpecificFactor5 == null) || (line.csSiteSpecificFactor3 == '988' && line.csSiteSpecificFactor5 == '988'))
            return true
        
        //Skip condition 7
        if (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7')
            return true
        
        if (!(functions.matches(line.primarySite, /^C54[0-389]|C559$/)))
             return true
        if (!functions.between(line.histologicTypeIcdO3, '8000','8790') && line.histologicTypeIcdO3 != '8950' && line.histologicTypeIcdO3 != '8951' && line.histologicTypeIcdO3 != '8980' && line.histologicTypeIcdO3 != '8981')
           return true
        
        String ssf3 = line.csSiteSpecificFactor3
        String ssf5 = line.csSiteSpecificFactor5
        if (ssf3 == '000' && ssf5 == '000')
            return line.tnmPathN == null || line.tnmPathN == 'p0'
        else if (ssf3 ==~ /^00[1-9]|0[1-8]\d|09[057]$/ || ssf5 ==~ /^00[1-9]|0[1-8]\d|09[057]$/)
            return line.tnmClinN != 'c0' || (line.tnmPathN != 'c0' && line.tnmPathN != 'p0')
        else if ((ssf3 == '098' || ssf3 == '999') && (ssf5 == '098' || ssf5 == '999'))
            return line.tnmPathN == null || line.tnmPathN == 'pX' || line.tnmPathN == 'c0'
        
        return true
    }

    // ID: IF577; NAME: TNM N, SSF 4, 6 Fallopian Tube (COC)
    public boolean if577(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        //Skip condition 5
        if ((line.tnmClinN == null && line.tnmPathN == null) || (line.tnmClinN == '88' && line.tnmPathN == '88'))
            return true
        
        //Skip condition 6
        if ((line.csSiteSpecificFactor4 == null && line.csSiteSpecificFactor6 == null) || (line.csSiteSpecificFactor4 == '988' && line.csSiteSpecificFactor6 == '988'))
            return true
        
        //Skip condition 7
        if (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7')
            return true
        
        if (line.primarySite != 'C570')
             return true
        if (!functions.between(line.histologicTypeIcdO3, '8000','8576') && !functions.between(line.histologicTypeIcdO3, '8940','8950') && line.histologicTypeIcdO3 != '8980' && line.histologicTypeIcdO3 != '8981')
           return true
        
        String ssf4 = line.csSiteSpecificFactor4
        String ssf6 = line.csSiteSpecificFactor6
        if(line.tnmPathN == 'p0')
            return (ssf4 == '000' || ssf4 == '098') && (ssf6 == '000' || ssf6 == '098')
        else if(line.tnmPathN == 'c0')
            return (ssf4 == '999' || ssf4 == '098') && (ssf6 == '999' || ssf6 == '098')
        else if (ssf4 ==~ /^00[1-9]|0[1-8]\d|09[057]$/ || ssf6 ==~ /^00[1-9]|0[1-8]\d|09[057]$/)
            return line.tnmClinN != 'c0' || (line.tnmPathN != 'c0' && line.tnmPathN != 'p0')
        
        return true
    }

    // ID: IF578; NAME: TNM N, SSF 5 Testis (COC)
    public boolean if578(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line.csSiteSpecificFactor5 == null || line.csSiteSpecificFactor5 == '988')
            return true
        
        //Skip condition 6
        if ((line.tnmClinN == null && line.tnmPathN == null) || (line.tnmClinN == '88' && line.tnmPathN == '88'))
            return true
        
        //Skip conditions 7, 8
        if ((line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7') || line.tnmPathDescriptor == '4' || line.tnmPathDescriptor == '6')
            return true
        
        //Skip condition 4
        if (!(functions.matches(line.primarySite, /^C62[019]$/)))
            return true
        String hist = line.histologicTypeIcdO3
        if (!(hist >= '8000' && hist <= '8576') && !(hist >= '8590' && hist <= '8670') && !(hist >= '8940' && hist <= '8950') && hist != '8980' && hist != '8981' &&
            !(hist >= '9060' && hist <= '9090') && !(hist >= '9100' && hist <= '9105'))
            return true
        
        String ssf5 = line.csSiteSpecificFactor5
        if (ssf5 == '000')
            return !(functions.matches(line.tnmClinN, /^c[123]$/)) && !(functions.matches(line.tnmPathN, /^p[123]$/))
        else if (ssf5 == '010')
            return line.tnmClinN == 'c1' || line.tnmPathN == 'p1'
        else if (ssf5 == '020')
            return line.tnmClinN == 'c2' || line.tnmPathN == 'p2'
        else if (ssf5 == '030')
            return line.tnmClinN == 'c3' || line.tnmPathN == 'p3'
        else if (ssf5 == '999')
            return !(line.tnmClinN == 'c0' && line.tnmPathN == 'p0')
        
        return true
    }

    // ID: IF579; NAME: TNM Path N, Reg Nodes Ex - Ed 7 (COC)
    public boolean if579(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        boolean skipCondition1 = line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016'
        boolean skipCondition2 = line.typeOfReportingSource == '6' || line.typeOfReportingSource == '7'
        boolean skipCondition3 = line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1'
        boolean skipCondition4 = line.tnmPathN == null || line.tnmPathN == '88'
        if (skipCondition1 || skipCondition2 || skipCondition3 || skipCondition4 || line.regionalNodesExamined == null)
            return true
        
        if (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7')
            return true
        
        // these cases will not generate errors
        String chapter = ((Closure)context.AJCC7CodeLookup16).call(line)
        String tnmPathN = line.tnmPathN
        if (chapter == '014' && tnmPathN == 'p1C')
            return true
        else if ((chapter == '030' || chapter == '052') && tnmPathN == 'p2')
            return true
        else if (chapter == '031' && tnmPathN == 'p2C')
            return true
        else if (chapter == '032' && tnmPathN == 'p2B')
            return true
        else if (chapter == '36A' && (tnmPathN == 'c1' || tnmPathN == 'c2'))
            return true
        else if (chapter == '055' && (tnmPathN == 'p3' || tnmPathN == 'p4'))
            return true
        
        if (line.regionalNodesExamined == '00' || line.regionalNodesExamined == '99')
            return line.tnmPathN == 'pX' || line.tnmPathN == 'c0'
        
        return true
    }

    // ID: IF580; NAME: TNM Path N, Reg Nodes Pos - Ed 7 (COC)
    public boolean if580(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        //Skip conditions 1, 2
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.dateOfDiagnosisYear > '2017'
            || line.typeOfReportingSource == '6' || line.typeOfReportingSource == '7')
            return true
        
        //Skip conditions 3, 4
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line.tnmPathN == null || line.tnmPathN == '88')
            return true
        
        //Skip conditions 5, 6
        if (line.regionalNodesPositive == null || (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7'))
            return true
        
        String hist = line.histologicTypeIcdO3
        String chapter = ((Closure)context.AJCC7CodeLookup16).call(line)
        
        // Exceptions for some chapters
        String tnmPathN = line.tnmPathN
        if (chapter == '014' && tnmPathN == 'p1C')
            return true
        else if ((chapter == '030' || chapter == '052') && tnmPathN == 'p2')
            return true
        else if (chapter == '031' && tnmPathN == 'p2C')
            return true
        else if (chapter == '032' && tnmPathN == 'p2B')
            return true
        else if (chapter == '36A' && (tnmPathN == 'c1' || tnmPathN == 'c2'))
            return true
        else if (chapter == '055' && (tnmPathN == 'p3' || tnmPathN == 'p4'))
            return true
        
        if (functions.matches(tnmPathN, /^.[123].*$/))
            return line.regionalNodesPositive != '00' && line.regionalNodesPositive != '98' && line.regionalNodesPositive != '99'
        
        return true
    }

    // ID: IF581; NAME: TNM Path N, Reg Nodes Pos,Ex, Breast - Ed 7 (COC)
    public boolean if581(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        //Skip conditions 1, 2
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7')
            return true
        
        //Skip conditions 4, 5, 6
        if (line.tnmPathN == null || line.tnmPathN == '88' || line.regionalNodesExamined == null || line.regionalNodesPositive == null)
            return true
        
        //Skip conditions 7, 8
        if ((line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7') || line.tnmPathDescriptor == '4' || line.tnmPathDescriptor == '6')
            return true
        
        //Skip condition 3
        String hist = line.histologicTypeIcdO3
        if (!(functions.matches(line.primarySite, /^C50[0-689]$/)) || !((hist >= '8000' && hist <= '8576') || (hist >= '8940' && hist <= '8950') || hist == '8980' || hist == '8981' || hist == '9020'))
            return true
        
        if (functions.matches(line.tnmPathN, /^p0[IM][+\-]$/))
            return line.regionalNodesExamined != '00' && line.regionalNodesExamined != '99' && line.regionalNodesPositive == '00'
        
        return true
    }

    // ID: IF582; NAME: TNM Path N, SSF 3, 4, 5 Breast (COC)
    public boolean if582(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        //Skip conditions 1, 2
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7')
            return true
        
        //Skip conditions 3, 5
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line.tnmPathN == null || line.tnmPathN == '88')
            return true
        
        //Skip conditions 6, 7
        if (line.tnmPathDescriptor == '4' || line.tnmPathDescriptor == '6' || (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7'))
            return true
        
        //Edit passes if case if not Breast (skip condition 4)
        String hist = line.histologicTypeIcdO3
        if (!(functions.matches(line.primarySite, /^C50\d$/)) || !((hist >= '8000' && hist <= '8576') || (hist >= '8940' && hist <= '8950') || hist == '8980' || hist == '8981' || hist == '9020'))
            return true
        
        if (line.csSiteSpecificFactor3 != null && line.csSiteSpecificFactor3 != '988') {
            if (functions.matches(line.tnmPathN, /^p0([IM][\-+])?$/) && line.csSiteSpecificFactor3 != '000')
                return false
            else if ((line.tnmPathN == 'c0' || line.tnmPathN == 'pX') && !(functions.matches(line.csSiteSpecificFactor3, /^09[789]$/)))
                return false
        }
        
        if (line.csSiteSpecificFactor4 != null || line.csSiteSpecificFactor5 != null) {
            if (line.csSiteSpecificFactor4 == '987' && line.csSiteSpecificFactor5 == '987' && line.tnmPathN == 'pX')
                return true
            else if (line.csSiteSpecificFactor4 == '987' && line.csSiteSpecificFactor5 == '987' && line.tnmPathN == 'p0I+')
                return true
            else if (line.csSiteSpecificFactor4 == '000' && line.csSiteSpecificFactor5 == '000' && line.tnmPathN == 'pX' && line.tnmClinN == 'c0')
                return true
            else if (line.csSiteSpecificFactor4 == '000' && line.csSiteSpecificFactor5 == '000' && line.tnmPathN == 'c0')
                return true
            else if (line.csSiteSpecificFactor4 != '988' || line.csSiteSpecificFactor5 != '988') {
                List codes = (List)((Map)((Map)context.IF582_Table).getOrDefault(line.csSiteSpecificFactor4 ?: '', [:])).getOrDefault(line.csSiteSpecificFactor5 ?: '', null)
                if (codes == null)
                    return true
                else if (codes.contains('ER'))
                    return false
                else if (codes.contains('p1'))
                    return functions.matches(line.tnmPathN, /^p1[ABC]?|p1MI|p2[AB]?|p3[ABC]?$/)
                else if (!codes.contains(line.tnmPathN))
                    return false
            }
        }
        
        return true
    }

    // ID: IF583; NAME: TNM Path N, SSF 4 Colon (COC)
    public boolean if583(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        //Skip conditions 1, 2, 3
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        //Skip conditions 5, 6
        if (line.tnmPathN == null || line.tnmPathN == '88' || line.csSiteSpecificFactor4 == null || line.csSiteSpecificFactor4 == '988')
            return true
        
        //Skip conditions 7, 8
        if (line.tnmPathDescriptor == '4' || line.tnmPathDescriptor == '6' || (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7'))
            return true
        
        //Skip condition 4
        String hist = line.histologicTypeIcdO3
        if (!(functions.matches(line.primarySite, /^C18[02-9]|C199|C209$/)) || !((hist >= '8000' && hist <= '8152') || (hist >= '8154' && hist <= '8231') || hist ==~ /^824[34578]|894\d|8950|898[01]$/ ||
            (hist >= '8250' && hist <= '8576')))
           return true
        
        String ssf4 = line.csSiteSpecificFactor4
        if (ssf4 == '000' && line.tnmPathN == 'p1C')
            return false
        
        if (line.tnmPathN == 'p1C')
            return ssf4 != '000' && ssf4 != '998' && ssf4 != '999'
        else if (line.tnmPathN == 'p0')
            return ssf4 == '000' || ssf4 == '998' || ssf4 == '999'
        
        return true
    }

    // ID: IF584; NAME: TNM Path Stage Group, Prim Site, Surg - Ed 7 (COC)
    public boolean if584(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' || line.typeOfReportingSource == '6' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line.tnmPathStageGroup == null || line.tnmPathStageGroup == '88' || line.rxSummSurgPrimSite == null)
            return true
        
        String hist = line.histologicTypeIcdO3
        if (functions.matches(line.primarySite, /^C67\d$/) && ((hist >= '8000' && hist <= '8576') || (hist >= '8490' && hist <= '8950') || hist == '8980' || hist == '8981')) {
            if (line.tnmPathStageGroup == '0IS' || line.tnmPathStageGroup == '0A')
                return line.rxSummSurgPrimSite >= '30' && line.rxSummSurgPrimSite != '99'
        }
        else {
            if (line.tnmPathStageGroup == '0' || line.tnmPathStageGroup == '0IS' || line.tnmPathStageGroup == '0A')
                return line.rxSummSurgPrimSite >= '20' && line.rxSummSurgPrimSite != '99'
        }
        
        return true
    }

    // ID: IF585; NAME: TNM Path T, SSF 1 Retinoblastoma (COC)
    public boolean if585(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line.tnmPathT == null || line.tnmPathT == '88' || line.csSiteSpecificFactor1 == null)
            return true
        
        //Skip condition 7
        if (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7')
            return true
        
        //Skip condition 4
        if (line.primarySite != 'C692' || line.histologicTypeIcdO3 < '9510' || line.histologicTypeIcdO3 > '9514')
            return true
        
        String ssf1 = line.csSiteSpecificFactor1
        if (ssf1 == '300' || ssf1 == '410' || ssf1 == '430' || ssf1 == '435')
            return line.tnmPathT == 'p1'
        else if (ssf1 == '440' || ssf1 == '460' || ssf1 == '465')
            return line.tnmPathT == 'p2A'
        else if (ssf1 == '470')
            return line.tnmPathT == 'p2B'
        else if (ssf1 == '490')
            return line.tnmPathT == 'p2'
        else if (ssf1 == '540' || ssf1 == '550' || ssf1 == '560')
            return line.tnmPathT == 'p3A'
        else if (ssf1 == '570')
            return line.tnmPathT == 'p3B'
        else if (ssf1 == '590')
            return line.tnmPathT == 'p3'
        else if (ssf1 == '725')
            return line.tnmPathT == 'p4A'
        else if (ssf1 == '745' || ssf1 == '755' || ssf1 == '810')
            return line.tnmPathT == 'p4'
        else if (ssf1 == '765' || ssf1 == '775' || ssf1 == '790')
            return line.tnmPathT == 'p4B'
        else if (ssf1 == '950')
            return line.tnmPathT == 'p0'
        else if (ssf1 == '999')
            return line.tnmPathT == 'pX'
        else if (ssf1 == '960' || ssf1 == '970')
            return line.tnmPathT == 'pX'
        
        return true
    }

    // ID: IF586; NAME: TNM Path T, SSF 1, 2, 3 Kidney (COC)
    public boolean if586(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line.tnmPathT == null || line.tnmPathT == '88')
            return true
        
        //Skip conditions 6, 7
        if ((line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7') || line.tnmPathDescriptor == '4' || line.tnmPathDescriptor == '6')
            return true
        
        //Check for Kidney cases (skip condition 4)
        String hist = line.histologicTypeIcdO3
        if (line.primarySite != 'C649' || !((hist >= '8000' && hist <= '8576') || (hist >= '8940' && hist <= '8950') || hist == '8980' || hist == '8981'))
            return true
        
        // Check SSF 1
        String ssf1 = line.csSiteSpecificFactor1
        String ssf2 = line.csSiteSpecificFactor2
        if (ssf1 != '988' && ssf1 != null) {
            if (ssf1 == '000' && ssf2 == '000' && !(functions.matches(line.tnmPathT, /^p[12][AB]?|pX$/)))
                return false
            else if ((ssf1 == '010' || ssf1 == '020' || ssf1 == '030' || ssf1 == '991') && !(functions.matches(line.tnmPathT, /^p3[ABC]?|p4$/)))
                return false
            else if (ssf1 == '998' && line.tnmPathT != null && line.tnmPathT != 'pX')
                return false
        }
        
        // Check SSF 2
        if (ssf2 != '988' && ssf2 != null) {
            if (ssf2 == '010' && !(functions.matches(line.tnmPathT, /^p3[ABC]?|p4|pX$/)))
                return false
            else if (ssf2 ==~ /^0[2457]0$/ && !(functions.matches(line.tnmPathT, /^p3[BC]|p[4X]$/)))
                return false
            else if (ssf2 ==~ /^0[3689]0$/ && !(functions.matches(line.tnmPathT, /^p3C|p[4X]$/)))
                return false
            else if (ssf2 == '998' && line.tnmPathT != null && line.tnmPathT != 'pX')
                return false
        }
        
        // Check SSF 3
        String ssf3 = line.csSiteSpecificFactor3
        if ((ssf3 == '010' || ssf3 == '030' || ssf3 == '040') && line.tnmPathT != 'p4')
            return false
        
        return true
    }

    // ID: IF587; NAME: TNM Path T, SSF 2, 7 Melanoma Skin (COC)
    public boolean if587(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line.tnmPathT == null || line.tnmPathT == '88')
            return true
        
        //Skip condition 6
        if ((line.csSiteSpecificFactor2 == null && line.csSiteSpecificFactor7 == null) || (line.csSiteSpecificFactor2 == '988' && line.csSiteSpecificFactor7 == '988'))
            return true
        
        //Skip condition 7, 8
        if ((line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7') || line.tnmPathDescriptor == '4' || line.tnmPathDescriptor == '6')
            return true
        
        //Skip condition 4
        if (line._tnmSchemaId != 'melanoma_skin')
            return true
        
        if (functions.matches(line.tnmPathT, /^p[1234]A$/))
            return line.csSiteSpecificFactor2 == '000'
        else if (functions.matches(line.tnmPathT, /^p[234]B$/))
            return line.csSiteSpecificFactor2 == '010'
        else if (line.tnmPathT == 'p1B')
            return line.csSiteSpecificFactor2 != '000' || (line.csSiteSpecificFactor7 != '000' && line.csSiteSpecificFactor7 != '990' && line.csSiteSpecificFactor7 != '998')
        
        return true
    }

    // ID: IF588; NAME: TNM Path T, SSF 3 Prostate (COC)
    public boolean if588(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line.tnmPathT == null || line.tnmPathT == '88' || line.csSiteSpecificFactor3 == null)
            return true
        
        //Skip condition 7
        if (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7')
            return true
        
        //Edit is skipped if case is not prostate (skip condition 4)
        String hist = line.histologicTypeIcdO3
        if (line.primarySite != 'C619' || !((hist >= '8000' && hist <= '8110') || (hist >= '8140' && hist <= '8576') || (hist >= '8940' && hist <= '8950') || hist == '8980' || hist == '8981'))
            return true
        
        String ssf3 = line.csSiteSpecificFactor3
        if (ssf3 == '000')
            return line.tnmPathT == '88'
        else if (ssf3 == '200' || ssf3 == '300' || ssf3 == '320' || ssf3 == '400')
            return line.tnmPathT == 'p2'
        else if (ssf3 == '210' || ssf3 == '330' || ssf3 == '402')
            return line.tnmPathT == 'p2A'
        else if (ssf3 == '220' || ssf3 == '340' || ssf3 == '404')
            return line.tnmPathT == 'p2B'
        else if (ssf3 == '230' || ssf3 == '350' || ssf3 == '406')
            return line.tnmPathT == 'p2C'
        else if (ssf3 == '495')
            return line.tnmPathT == 'p3'
        else if (ssf3 == '415' || ssf3 == '420' || ssf3 == '430' || ssf3 == '480' || ssf3 == '482' || ssf3 == '483')
            return line.tnmPathT == 'p3A'
        else if (ssf3 == '485' || ssf3 == '490')
            return line.tnmPathT == 'p3B'
        else if (ssf3 == '500' || ssf3 == '510' || ssf3 == '520' || ssf3 == '600' || ssf3 == '750')
            return line.tnmPathT == 'p4'
        else if (ssf3 == '950')
            return line.tnmPathT == 'p0'
        else if (ssf3 == '990' || ssf3 == '985')
            return line.tnmPathT == 'pX'
        else if (ssf3 == '960' || ssf3 == '970' || ssf3 == '980')
            return functions.matches(line.tnmPathT, /^pX|p3[AB]?|p4$/)
        
        return true
    }

    // ID: IF589; NAME: TNM T, Breast, Inflam Carcinoma (COC)
    public boolean if589(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || (line.tnmPathT == null && line.tnmClinT == null) || (line.tnmPathT == '88' && line.tnmClinT == '88'))
            return true
        
        //Edit is skipped if case is not Breast
        if (!(functions.matches(line.primarySite, /^C50[0-689]$/)))
            return true
        
        if (line.histologicTypeIcdO3 == '8530')
            return line.tnmClinT == 'c4D' || line.tnmPathT == 'p4D'
        
        return true
    }

    // ID: IF590; NAME: TNM T, Clin and Path Stage, Behavior 3 (COC)
    public boolean if590(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        //Skip condition 4
        if (line.tnmClinT == '88' && line.tnmClinN == '88' && line.tnmClinM == '88' && line.tnmClinStageGroup == '88' &&
            line.tnmPathT == '88' && line.tnmPathN == '88' && line.tnmPathM == '88' && line.tnmPathStageGroup == '88')
            return true
        
        //Skip condition 5
        if (line.tnmClinT == 'cX' && line.tnmClinN == 'cX' && line.tnmClinM == 'cX' && line.tnmClinStageGroup == '99' &&
            line.tnmPathT == 'pX' && line.tnmPathN == 'pX' && (line.tnmPathM == 'pX' || line.tnmPathM == 'cX') && line.tnmPathStageGroup == '99')
            return true
        
        //Skip condition 6
        if (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7')
            return true
        
        if (line.tnmPathT == null && line.tnmPathStageGroup == null && line.tnmClinT != null)
            if (!(functions.matches(line.tnmClinT, /^pA|pIS[UD]?$/)) && !(functions.matches(line.tnmClinStageGroup, /^0(A|IS)?$/)))
                return line.behaviorCodeIcdO3 == '3'
        
        if (line.tnmPathT != null && line.tnmPathStageGroup != null)
            if (!(functions.matches(line.tnmPathT, /^pA|pIS[UD]?$/)) && !(functions.matches(line.tnmClinStageGroup, /^0(A|IS)?$/)) && !(functions.matches(line.tnmPathStageGroup, /^0(A|IS)?$/)))
                return line.behaviorCodeIcdO3 == '3'
        
        return true
    }

    // ID: IF591; NAME: TNM T, Descriptor, SSF 1 Thyroid (COC)
    public boolean if591(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        //Skip condition 5
        if ((line.tnmPathT == null && line.tnmClinT == null) || (line.tnmPathT == '88' && line.tnmClinT == '88'))
            return true
        
        //Skip conditions 6, 7
        if (line.csSiteSpecificFactor1 == null || line.csSiteSpecificFactor1 == '988' || (line.tnmClinDescriptor == null && line.tnmPathDescriptor == null))
            return true
        
        //Skip condition 8
        if (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7')
            return true
        
        //Edit is skipped if case is not Thyroid (skip condition 4)
        String hist = line.histologicTypeIcdO3
        if (line.primarySite != 'C739' || !((hist >= '8000' && hist <= '8576') || (hist >= '8940' && hist <= '8950') || hist == '8980' || hist == '8981'))
            return true
        
        if (line.csSiteSpecificFactor1 == '010' && line.tnmClinDescriptor != '0' && line.tnmPathDescriptor != '0')
            return false
        else if (line.csSiteSpecificFactor1 == '020' && line.tnmClinDescriptor != '3' && line.tnmPathDescriptor != '3' && line.tnmPathDescriptor != '6')
            return false
        else if (line.tnmClinDescriptor == '0' && line.tnmPathDescriptor == '0' && line.csSiteSpecificFactor1 != '010')
            return false
        else if (line.tnmClinDescriptor == '3' && (line.tnmPathDescriptor == '3' || line.tnmPathDescriptor == '6') && line.csSiteSpecificFactor1 != '020')
            return false
        
        return true
    }

    // ID: IF592; NAME: TNM T, N, M - No Primary Found (COC)
    public boolean if592(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line.tnmClinT == 'c0') {
            if ((line.tnmClinN == null || functions.matches(line.tnmClinN, /^cX|c0[AB]?$/)) &&
                (line.tnmClinM == null || line.tnmClinM == 'c0' || line.tnmClinM == 'c0I+') &&
                (line.tnmPathT == null || line.tnmPathT == 'pX' || line.tnmPathT == 'p0') &&
                (line.tnmPathN == null || functions.matches(line.tnmPathN, /^pX|c0|p0([IM][+\-])?$/)) &&
                (line.tnmPathM == null || line.tnmPathM == 'c0' || line.tnmPathM == 'c0I+'))
                return false
        }
        
        if (line.tnmPathT == 'p0') {
            if ((line.tnmClinT == null || line.tnmClinT == 'pX' || line.tnmClinT == 'p0') &&
                (line.tnmClinN == null || functions.matches(line.tnmClinN, /^cX|c0[AB]?$/)) &&
                (line.tnmClinM == null || line.tnmClinM == 'c0' || line.tnmClinM == 'c0I+') &&
                (line.tnmPathN == null || functions.matches(line.tnmPathN, /^pX|c0|p0([IM][+\-])?$/)) &&
                (line.tnmPathM == null || line.tnmPathM == 'c0' || line.tnmPathM == 'c0I+'))
                return false
        }
        
        return true
    }

    // ID: IF593; NAME: TNM T, SSF 1 Conjunctiva (COC)
    public boolean if593(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        //Skip condition 5
        if ((line.tnmClinT == null && line.tnmPathT == null) || (line.tnmClinT == '88' && line.tnmPathT == '88'))
            return true
        
        //Skip conditions 6, 7
        if (line.csSiteSpecificFactor1 == null || line.csSiteSpecificFactor1 == '988' || (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7'))
            return true
        
        //Skip condition 4
        String hist = line.histologicTypeIcdO3
        if (line.primarySite != 'C690' || !((hist >= '8000' && hist <= '8576') || (hist >= '8940' && hist <= '8950') || hist == '8980' || hist == '8981'))
            return true
        
        Integer ssf1 = functions.asInt(line.csSiteSpecificFactor1)
        if ((ssf1 > 0 && ssf1 <= 50) || ssf1 == 990 || ssf1 == 991)
            return !((line.tnmPathT == null && line.tnmClinT == 'c2') || (line.tnmClinT == null && line.tnmPathT == 'p2') || (line.tnmClinT == 'c2' && line.tnmPathT == 'p2'))
        else if ((ssf1 > 50 && ssf1 <= 980) || ssf1 == 992)
            return !((line.tnmPathT == null && line.tnmClinT == 'c1') || (line.tnmClinT == null && line.tnmPathT == 'p1') || (line.tnmClinT == 'c1' && line.tnmPathT == 'p1'))
        
        return true
    }

    // ID: IF594; NAME: TNM T, SSF 1, 2 Lung (COC)
    public boolean if594(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        //Skip conditon 5
        if ((line.tnmClinT == null && line.tnmPathT == null) || (line.tnmClinT == '88' && line.tnmPathT == '88'))
            return true
        
        //Skip condition 6
        if (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7')
            return true
        
        //Edit is skipped if case if not Lung (skip condition 4)
        String hist = line.histologicTypeIcdO3
        if (!(functions.matches(line.primarySite, /^C34[0-389]$/)) || !((hist >= '8000' && hist <= '8576') || (hist >= '8940' && hist <= '8950') || hist == '8980' || hist == '8981'))
            return true
        
        if (line.csSiteSpecificFactor1 == '010' || line.csSiteSpecificFactor1 == '040') {
            if (line.tnmClinT != 'c3' && line.tnmClinT != 'c4' && line.tnmPathT != 'p3' && line.tnmPathT != 'p4')
                return false
        }
        else if (line.csSiteSpecificFactor1 == '020' || line.csSiteSpecificFactor1 == '030') {
            if (line.tnmClinT != 'c4' && line.tnmPathT != 'p4')
                return false
        }
        
        if (line.csSiteSpecificFactor2 == '010' || line.csSiteSpecificFactor2 == '020' || line.csSiteSpecificFactor2 == '040') {
            if (!(functions.matches(line.tnmClinT, /^c[34]|c2[AB]?$/)) && !(functions.matches(line.tnmPathT, /^p[34]|p2[AB]?$/)))
                return false
        }
        else if (line.csSiteSpecificFactor2 == '030') {
            if (line.tnmClinT != 'c3' && line.tnmClinT != 'c4' && line.tnmPathT != 'p3' && line.tnmPathT != 'p4')
                return false
        }
        
        return true
    }

    // ID: IF595; NAME: TNM T, SSF 10 Bile Ducts Intrahepatic (COC)
    public boolean if595(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        //Skip condition 5
        if ((line.tnmClinT == null && line.tnmPathT == null) || (line.tnmClinT == '88' && line.tnmPathT == '88'))
            return true
        
        //Skip conditions 6, 7
        if (line.csSiteSpecificFactor10 == null || line.csSiteSpecificFactor10 == '988' || (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7'))
            return true
        
        //Edit is skipped if Site/Histology group is not Bile Ducts Intrahepatic (skip condition 4)
        if (line.primarySite != 'C221' || (line.histologicTypeIcdO3 != '8160' && line.histologicTypeIcdO3 != '8161' && line.histologicTypeIcdO3 != '8180'))
            return true
        
        if ((line.tnmClinT == 'c4' || line.tnmPathT == 'p4') && line.csSiteSpecificFactor10 != '010')
            return false
        if (line.csSiteSpecificFactor10 == '010' && line.tnmClinT != 'c4' && line.tnmPathT != 'p4')
            return false
        
        return true
    }

    // ID: IF596; NAME: TNM T, SSF 6 Skin of Eyelid (COC)
    public boolean if596(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        //Skip condition 5
        if ((line.tnmClinT == null && line.tnmPathT == null) || (line.tnmClinT == '88' && line.tnmPathT == '88'))
            return true
        
        //Skip conditions 6, 7
        if (line.csSiteSpecificFactor6 == null || line.csSiteSpecificFactor6 == '988' || (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7'))
            return true
        
        //Edit is skipped if Site/Histology group is not Skin of Eyelid (skip condition 4)
        String hist = line.histologicTypeIcdO3
        if (line.primarySite != 'C441' || !((hist >= '8000' && hist <= '8576') || (hist >= '8940' && hist <= '8950') || hist == '8980' || hist == '8981'))
            return true
        
        if (line.csSiteSpecificFactor6 == '010' && !(functions.matches(line.tnmClinT, /^c3[AB]|c4$/)) && !(functions.matches(line.tnmPathT, /^p3[AB]|p4$/)))
            return false
        
        return true
    }

    // ID: IF597; NAME: TNM T, SSF 6 Breast (COC)
    public boolean if597(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        //Skip conditions 5, 6
        if (line.tnmPathT == null || line.tnmPathT == '88' || line.csSiteSpecificFactor6 == null || line.csSiteSpecificFactor6 == '988')
            return true
        
        //Skip conditions 7, 8
        if ((line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7') || line.tnmPathDescriptor == '4' || line.tnmPathDescriptor == '6')
            return true
        
        //Edit is skipped if Site/Histology group is not Breast (skip condition 4)
        String hist = line.histologicTypeIcdO3
        if (!(functions.matches(line.primarySite, /^C50\d$/)) || !((hist >= '8000' && hist <= '8576') || (hist >= '8940' && hist <= '8950') || hist == '8980' || hist == '8981' || hist == '9020'))
            return true
        
        if (line.csSiteSpecificFactor6 == '010')
            return line.tnmPathT == 'pIS'
        if (line.tnmPathT == 'pIS')
            return line.csSiteSpecificFactor6 == '010'
        
        return true
    }

    // ID: IF598; NAME: Tumor Size Pathologic, SSF 6 Breast (SEER)
    public boolean if598(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        //Skip conditions 5, 6
        if (line.tumorSizePathologic == null || line.csSiteSpecificFactor6 == null || line.csSiteSpecificFactor6 == '988')
            return true
        
        //Skip condition 7
        if (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7')
            return true
        
        //Edit is skipped if Site/Histology group is not Breast (32) (skip condition 4)
        if (((Closure)context.AJCC7CodeLookup16).call(line) != '032')
            return true
        
        if (line.csSiteSpecificFactor6 == '060')
            return line.tumorSizePathologic == '999'
        
        return true
    }

    // ID: IF599; NAME: TNM Clin Descriptor, Histologies - Ed 7 (COC)
    public boolean if599(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line.tnmClinDescriptor == null || !(functions.matches(line.tnmClinDescriptor, /^[125]$/)))
            return true
        
        //Ocular Adnexal Lymphoma
        String hist = line.histologicTypeIcdO3
        String site = line.primarySite
        if (site ==~ /^C441|C69[056]$/ && ((hist >= '9590' && hist <= '9699') || (hist >= '9702' && hist <= '9738') || (hist >= '9811' && hist <= '9818') || (hist >= '9820' && hist <= '9837')))
            return true
        
        //Primary Cutaneous Lymphoma
        if (site ==~ /^C44\d|C51[01289]|C60[01289]|C632$/ && (hist == '9700' || hist == '9701'))
            return true
        
        //Neoplasms
        Integer siteInt = functions.asInt(site?.substring(1))
        if (((siteInt >= 0 && siteInt <= 419) || siteInt == 422 || siteInt == 423 || siteInt == 440 || (siteInt >= 442 && siteInt <= 689) || (siteInt >= 691 && siteInt <= 694) ||
            (siteInt >= 698 && siteInt <= 809)) && (hist == '9823' || hist == '9827' || (hist >= '9811' && hist <= '9818') || hist == '9837'))
            return true
        if ((siteInt == 420 || siteInt == 421 || siteInt == 424) && ((hist >= '9811' && hist <= '9818') || hist == '9837'))
            return true
        
        //Other
        if (!(site ==~ /^C441|C69[056]$/) && ((hist >= '9590' && hist <= '9699') || (hist >= '9702' && hist <= '9727') || hist == '9735' || hist == '9737' || hist == '9738'))
            return true
        
        return false
    }

    // ID: IF600; NAME: TNM Clin N, Digestive, Assess Nodes SSF (COC)
    public boolean if600(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line.tnmClinN == null || line.tnmClinN == '88')
            return true
        
        if (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7')
            return true
        
        String siteGroup = (String)((Closure)context.AJCC7CodeLookup16).call(line)
        if (!(siteGroup ==~ /^1[03][AB]|01[124]|17[AC]$/))
            return true
        
        //Check for blank or 988 SSF based on site group
        if (siteGroup ==~ /^10[AB]|011|17A$/ && (line.csSiteSpecificFactor1 == null || line.csSiteSpecificFactor1 == '988'))
            return true
        if (siteGroup ==~ /^01[24]|13[AB]|17C$/ && (line.csSiteSpecificFactor2 == null || line.csSiteSpecificFactor2 == '988'))
            return true
        
        if (siteGroup == '10A' || siteGroup == '10B' || siteGroup == '011') {
            if (line.csSiteSpecificFactor1 == '000' && line.tnmClinN != 'c0')
                return false
            else if (line.csSiteSpecificFactor1 == '100' && line.tnmClinN != 'c1')
                return false
            else if (line.csSiteSpecificFactor1 == '200' && line.tnmClinN != 'c2')
                return false
            else if (line.csSiteSpecificFactor1 == '300' && line.tnmClinN != 'c3')
                return false
            else if (line.csSiteSpecificFactor1 == '400' && line.tnmClinN == 'c0')
                return false
            else if (line.csSiteSpecificFactor1 == '999' && line.tnmClinN != 'cX')
                return false
        }
        
        if (siteGroup == '011') {
            if (line.csSiteSpecificFactor1 == '310' && line.tnmClinN != 'c3A')
                return false
            else if (line.csSiteSpecificFactor1 == '320' && line.tnmClinN != 'c3B')
                return false
        }
        
        if (siteGroup == '012' || siteGroup == '13A' || siteGroup == '014') {
            if (line.csSiteSpecificFactor2 == '000' && line.tnmClinN != 'c0')
                return false
            else if (line.csSiteSpecificFactor2 == '100' && line.tnmClinN != 'c1')
                return false
            else if (line.csSiteSpecificFactor2 == '200' && line.tnmClinN != 'c2')
                return false
            else if (line.csSiteSpecificFactor2 == '400' && line.tnmClinN == 'c0')
                return false
            else if (line.csSiteSpecificFactor2 == '999' && line.tnmClinN != 'cX')
                return false
        }
        
        if (siteGroup == '014') {
            if (line.csSiteSpecificFactor2 == '010' && line.tnmClinN != 'c1A')
                return false
            else if (line.csSiteSpecificFactor2 == '020' && line.tnmClinN != 'c1B')
                return false
            else if (line.csSiteSpecificFactor2 == '110' && line.tnmClinN != 'c2A')
                return false
            else if (line.csSiteSpecificFactor2 == '120' && line.tnmClinN != 'c2B')
                return false
        }
        
        if (siteGroup == '17A') {
            if (line.csSiteSpecificFactor1 == '000' && line.tnmClinN != 'c0')
                return false
            else if (functions.matches(line.csSiteSpecificFactor1, /^[1-4]00$/) && line.tnmClinN != 'c1')
                return false
            else if (line.csSiteSpecificFactor1 == '999' && line.tnmClinN != 'cX')
                return false
        }
        
        if (siteGroup == '13B' || siteGroup == '17C') {
            if (line.csSiteSpecificFactor2 == '000' && line.tnmClinN != 'c0')
                return false
            else if (functions.matches(line.csSiteSpecificFactor2, /^[124]00$/) && line.tnmClinN != 'c1')
                return false
            else if (line.csSiteSpecificFactor2 == '999' && line.tnmClinN != 'cX')
                return false
        }
        
        return true
    }

    // ID: IF601; NAME: TNM Groups Not Stageable - Insitu (COC)
    public boolean if601(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.dateOfDiagnosisYear > '2017' || line.typeOfReportingSource == '7' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line.behaviorCodeIcdO3 == '3')
            return true
        
        String siteGroup = (String)((Closure)context.AJCC7CodeLookup16).call(line)
        if (line.behaviorCodeIcdO3 == '2' && siteGroup ==~ /^00[79]|08[ABCDEF]|13B|16[AB]|17[BC]|018|36[BC]|37A|039|04[13]|47[AB]|51[AB]|05[34]|57B$/)
            return line.tnmClinT == '88' && line.tnmClinN == '88' && line.tnmClinM == '88' && line.tnmClinStageGroup == '88' &&
                   line.tnmPathT == '88' && line.tnmPathN == '88' && line.tnmPathM == '88' && line.tnmPathStageGroup == '88'
        
        return true
    }

    // ID: IF602; NAME: TNM Path T, Primary Site, Surgery - Ed 7 (COC)
    public boolean if602(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        //Skip conditions 1, 2
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' || line.typeOfReportingSource == '6')
            return true
        
        //Skip conditions 3, 4
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line.tnmPathT == null || line.tnmPathT == '88')
            return true
        
        //Skip conditions 5, 6
        if (line.rxSummSurgPrimSite == null || (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7'))
            return true
        
        String siteGroup = (String)((Closure)context.AJCC7CodeLookup16).call(line)
        if (siteGroup == '046') {
            if (line.sex == '2' || line.sex == '6')
                siteGroup = '46A'
            else
                siteGroup = '46B'
        }
        
        //A.
        if (((List)context.IF602_List1).contains(siteGroup) && functions.matches(line.tnmPathT, /^p1[ABCD]?|p1MI|p[23][ABCD]?|p4A?$/) && (line.rxSummSurgPrimSite < '20' || line.rxSummSurgPrimSite == '99'))
            return false
        else if (((List)context.IF602_List2).contains(siteGroup) && functions.matches(line.tnmPathT, /^p1[ABCD]?|p1MI|p2[ABCD]?|p3[AB]?$/) && (line.rxSummSurgPrimSite < '20' || line.rxSummSurgPrimSite == '99'))
            return false
        else if (((List)context.IF602_List3).contains(siteGroup) && functions.matches(line.tnmPathT, /^p1[ABCD]?|p1MI|p[23][ABCD]?|p4[ABC]?$/) && (line.rxSummSurgPrimSite < '20' || line.rxSummSurgPrimSite == '99'))
            return false
        else if (siteGroup == '039' && line.tnmPathT == 'p1' && (line.rxSummSurgPrimSite < '20' || line.rxSummSurgPrimSite == '99'))
            return false
        else if ((siteGroup == '027' || siteGroup == '033') && functions.matches(line.tnmPathT, /^p1[ABCD]?|p2$/) && (line.rxSummSurgPrimSite < '20' || line.rxSummSurgPrimSite == '99'))
            return false
        else if (siteGroup == '028' && functions.matches(line.tnmPathT, /^p1[ABCD]?|p1MI|p2A?$/) && (line.rxSummSurgPrimSite < '20' || line.rxSummSurgPrimSite == '99'))
            return false
        else if (siteGroup == '043' && functions.matches(line.tnmPathT, /^p1[ABCD]?|p1MI|p2[ABCD]?|p3[ABC]?$/) && (line.rxSummSurgPrimSite < '20' || line.rxSummSurgPrimSite == '99'))
            return false
        else if (siteGroup == '052' && functions.matches(line.tnmPathT, /^p1[ABCD]?|p1MI|p[23][ABCD]?|p4A?$/) && (line.rxSummSurgPrimSite < '20' || line.rxSummSurgPrimSite == '99'))
            return false
        else if (siteGroup == '053' && functions.matches(line.tnmPathT, /^p1[ABCD]?|p1MI|p[23][ABCD]?|p4[AB]?$/) && (line.rxSummSurgPrimSite < '20' || line.rxSummSurgPrimSite == '99'))
            return false
        else if (siteGroup == '51A' && functions.matches(line.tnmPathT, /^p[1234][ABCD]?$/) && (line.rxSummSurgPrimSite < '20' || line.rxSummSurgPrimSite == '99'))
            return false
        
        //B.
        if (siteGroup == '041' && functions.matches(line.tnmPathT, /^p2[ABC]?$/) && (line.rxSummSurgPrimSite < '30' || line.rxSummSurgPrimSite == '99'))
            return false
        else if (siteGroup == '045' && functions.matches(line.tnmPathT, /^p1[ABCD]?|p1MI|p2[ABCD]?|p3[AB]?|p4A?$/) && (line.rxSummSurgPrimSite < '30' || line.rxSummSurgPrimSite == '99'))
            return false
        
        //C.
        if (siteGroup == '042' && functions.matches(line.tnmPathT, /^p[0123]$/) && (line.rxSummSurgPrimSite < '40' || line.rxSummSurgPrimSite == '99'))
            return false
        
        return true
    }

    // ID: IF603; NAME: TNM T, Clin and Path Stage, Behavior 2 (COC)
    public boolean if603(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        //Skip conditions 1, 2
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7')
            return true
        
        //Skip conditions 3, 4
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7'))
            return true
        
        String siteGroup = (String)((Closure)context.AJCC7CodeLookup16).call(line)
        if (line.tnmPathT == null) {
            if (siteGroup == '032' && line.tnmClinT == 'pIS' && functions.matches(line.histologicTypeIcdO3, /^854[013]$/))
                return true
            else if (siteGroup == '040' && line.tnmClinT == 'pA')
                return true
            else if (siteGroup == '045' && line.tnmClinT == 'pIS')
                return true
        
            if (!['014','13A','17A','050'].contains(siteGroup))
                if (functions.matches(line.tnmClinT, /^pA|pIS[UD]?$/) && line.behaviorCodeIcdO3 != '2')
                    return false
        }
        else {
            if (siteGroup == '032' && line.tnmPathT == 'pIS' && functions.matches(line.histologicTypeIcdO3, /^854[013]$/))
                return true
            else if (siteGroup == '040' && line.tnmPathT == 'pA')
                return true
            else if (siteGroup == '045' && line.tnmPathT == 'pIS')
                return true
        
            if (!['014','13A','17A','050'].contains(siteGroup))
                if (functions.matches(line.tnmPathT, /^pA|pIS[UD]?$/) && line.tnmPathDescriptor != '4' && line.tnmPathDescriptor != '6' && line.behaviorCodeIcdO3 != '2')
                    return false
        }
        
        return true
    }

    // ID: IF604; NAME: TNM T, Deep Sites Soft Tissue (COC)
    public boolean if604(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        //Skip conditions 1, 2
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7')
            return true
        
        //Skip conditions 3, 4, 5
        boolean behaviorSkipCondition = line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1'
        boolean tnmSkipCondition = (line.tnmClinT == null && line.tnmPathT == null) || (line.tnmClinT == '88' && line.tnmPathT == '88')
        if (behaviorSkipCondition || tnmSkipCondition || (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7'))
            return true
        
        String hist = line.histologicTypeIcdO3
        boolean isFemale = functions.matches(line.sex, /^[26]$/)
        boolean firstSiteGroup = functions.matches(line.primarySite, /^C38[0-38]$/) && ((hist >= '8800' && hist <= '8820') || (hist >= '8823' && hist <= '8935') || (hist >= '8940' && hist <= '9136') || (hist >= '9142' && hist <= '9582'))
        boolean secondSiteGroup = functions.matches(line.primarySite, /^C48[128]$/) && ((hist >= '8800' && hist <= '8820') || (hist >= '8823' && hist <= '8934') || (hist >= '8940' && hist <= '9136') || (hist >= '9142' && hist <= '9582')) && !isFemale
        boolean thirdSiteGroup = functions.matches(line.primarySite, /^C48[128]$/) && ((hist >= '8800' && hist <= '8820') || (hist >= '8823' && hist <= '8921') || (hist >= '9120' && hist <= '9136') || (hist >= '9142' && hist <= '9582')) && isFemale
        boolean fourthSiteGroup = line.primarySite == 'C480' && ((hist >= '8800' && hist <= '8820') || (hist >= '8823' && hist <= '8934') || (hist >= '8940' && hist <= '9136') || (hist >= '9142' && hist <= '9582'))
        if (!firstSiteGroup && !secondSiteGroup && !thirdSiteGroup && !fourthSiteGroup)
            return true
        
        boolean skipPathRequirement = line.tnmPathDescriptor == '4' || line.tnmPathDescriptor == '6'
        
        return (line.tnmClinT == null || functions.matches(line.tnmClinT, /^cX|c[12]B$/)) && (skipPathRequirement || line.tnmPathT == null || functions.matches(line.tnmPathT, /^pX|p[12]B$/))
    }

    // ID: IF605; NAME: TNM Path T, N, M, In Situ (COC)
    public boolean if605(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || !(functions.matches(line.tnmPathT, /^pA|pIS[UD]?$/)))
            return true
        
        //Skip conditions 5, 6
        if ((line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7') || line.tnmPathDescriptor == '4' || line.tnmPathDescriptor == '6')
            return true
        
        String siteGroup = (String)((Closure)context.AJCC7CodeLookup16).call(line)
        if (siteGroup ==~ /^00[79]|08[ABCDEF]|13B|16[AB]|17[BC]|018|36[BC]|37A|039|04[13]|47[AB]|51[AB]|05[34]|57B$/)
            return true
        
        //Group 45 is Bladder
        if (siteGroup == '045') {
            if (line.tnmPathN != 'c0' && line.tnmPathN != 'p0' && line.tnmPathN != null)
                return false
            if (line.tnmPathM != 'c0' && line.tnmPathM != null)
                return false
            if (line.tnmPathStageGroup != '0IS' && line.tnmPathStageGroup != '0A' && line.tnmPathStageGroup != '99')
                return false
        }
        else {
            if (!(functions.matches(line.tnmPathN, /^p0([IM][\-+])?|c0$/)))
                return false
            if (line.tnmPathM != 'c0' && line.tnmPathM != 'c0I+')
                return false
            if (siteGroup != '049' && siteGroup != '050') {
                if (line.tnmPathStageGroup != '0' && line.tnmPathStageGroup != '0IS' && line.tnmPathStageGroup != '0A' && line.tnmPathStageGroup != '99')
                    return false
            }
        }
        
        return true
    }

    // ID: IF606; NAME: TNM Clin T, SSF 2 Melanoma Conjunctiva (COC)
    public boolean if606(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line._tnmSchemaId != 'melanoma_conjunctiva' || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        //Skip condition 5, 6
        if (line.tnmClinT == null || line.tnmClinT == '88' || line.csSiteSpecificFactor2 == null || line.csSiteSpecificFactor2 == '988')
            return true
        
        //Skip condition 7
        if (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7')
            return true
        
        if (line.csSiteSpecificFactor2 == '010' || line.csSiteSpecificFactor2 == '015')
            return line.tnmClinT == 'c1A' || line.tnmClinT == 'c2A' || line.tnmClinT == 'c2C'
        else if (line.csSiteSpecificFactor2 == '020' || line.csSiteSpecificFactor2 == '025')
            return line.tnmClinT == 'c1B' || line.tnmClinT == 'c2B' || line.tnmClinT == 'c2D'
        else if (line.csSiteSpecificFactor2 == '030')
            return line.tnmClinT == 'c1C' || line.tnmClinT == 'c2B' || line.tnmClinT == 'c2D'
        else if (line.csSiteSpecificFactor2 == '035')
            return line.tnmClinT == 'c1C'
        else if (line.csSiteSpecificFactor2 == '040')
            return line.tnmClinT == 'c1D' || line.tnmClinT == 'c2B' || line.tnmClinT == 'c2D'
        else if (line.csSiteSpecificFactor2 == '045')
            return line.tnmClinT == 'c1D'
        
        return true
    }

    // ID: IF607; NAME: TNM Clin T, SSF 3 Soft Tissue (COC)
    public boolean if607(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        //Skip condition 4, 5
        if (line.tnmClinT == null || line.tnmClinT == '88' || line.csSiteSpecificFactor3 == null || line.csSiteSpecificFactor3 == '988')
            return true
        
        //Skip condition 6
        if (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7')
            return true
        
        String siteGroup = (String)((Closure)context.AJCC7CodeLookup16).call(line)
        if (siteGroup != '028')
            return true
        
        if (line.csSiteSpecificFactor3 == '010')
            return line.tnmClinT != 'c1A' && line.tnmClinT != 'c2A'
        
        return true
    }

    // ID: IF608; NAME: TNM M, SSF 3 Kidney (COC)
    public boolean if608(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        //Skip condition 5
        if ((line.tnmClinM == null && line.tnmPathM == null) || (line.tnmClinM == '88' && line.tnmPathM == '88'))
            return true
        
        //Skip conditions 6, 7
        if (line.csSiteSpecificFactor3 == null || line.csSiteSpecificFactor3 == '988' || (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7'))
            return true
        
        //Skip condition 4
        String siteGroup = (String)((Closure)context.AJCC7CodeLookup16).call(line)
        if (siteGroup != '043')
            return true
        
        if (line.csSiteSpecificFactor3 == '020' || line.csSiteSpecificFactor3 == '030')
            return line.tnmClinM == 'p1' || line.tnmPathM == 'p1'
        
        return true
    }

    // ID: IF610; NAME: Primary Site, M 2016 - Ed 7 (SEER)
    public boolean if610(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        boolean skipCondition4 = line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1'
        boolean skipCondition5 = !(line.tnmEditionNumber == '07' || line.tnmEditionNumber == 'U7' || line.tnmEditionNumber == '88')
        boolean skipCondition6 = line.tnmClinM == null && line.tnmPathM == null
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.histologicTypeIcdO3 == null || skipCondition4 || skipCondition5 || skipCondition6)
            return true
        
        if (line.tnmEditionNumber == '88' &&
                (line.tnmClinM == null || line.tnmClinM == '88') &&
                (line.tnmPathM == null || line.tnmPathM == '88') &&
                line.overRideSiteTnmStggrp == '1')
            return true
        
        String siteGroup = (String)((Closure)context.AJCC7CodeLookup16).call(line)
        
        List validCodes = (List)((Map)context.IF610_Table).getOrDefault(siteGroup, ['88'])
        
        // Special Case for group 28 and 37B
        if ((siteGroup == '028' || siteGroup == '37B') && functions.matches(line.histologicTypeIcdO3, /^905[0-5]$/)) {
            if (line.tnmClinM != null && !validCodes.contains(line.tnmClinM) && line.tnmClinM != '88')
                return false
        
            if (line.tnmPathM != null && !validCodes.contains(line.tnmPathM) && line.tnmPathM != '88')
                return false
        
            return true
        }
        
        if (line.tnmClinM != null)
            if (!validCodes.contains(line.tnmClinM))
                return false
        
        if (line.tnmPathM != null)
            if (!validCodes.contains(line.tnmPathM))
                return false
        
        return true
    }

    // ID: IF611; NAME: Primary Site, N 2016 - Ed 7 (SEER)
    public boolean if611(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' || line.histologicTypeIcdO3 == null ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || (line.tnmClinN == null && line.tnmPathN == null))
            return true
        
        //Skip condition 5
        if (!(line.tnmEditionNumber == '07' || line.tnmEditionNumber == 'U7' || line.tnmEditionNumber == '88'))
            return true
        
        if (line.tnmEditionNumber == '88' &&
                (line.tnmClinN == null || line.tnmClinN == '88') &&
                (line.tnmPathN == null || line.tnmPathN == '88') &&
                line.overRideSiteTnmStggrp == '1')
            return true
        
        String siteGroup = (String)((Closure)context.AJCC7CodeLookup16).call(line)
        Map validCodes = (Map)((Map)context.IF611_Table).get(siteGroup)
        
        // Special Case for group 28 and 37B
        if ((siteGroup == '028' || siteGroup == '37B') && functions.matches(line.histologicTypeIcdO3, /^905[0-5]$/)) {
            if (line.tnmClinN != null && !((List)validCodes.getOrDefault('C', [])).contains(line.tnmClinN) && line.tnmClinN != '88')
                return false
        
            if (line.tnmPathN != null && !((List)validCodes.getOrDefault('P', [])).contains(line.tnmPathN) && line.tnmPathN != '88')
                return false
        
            return true
        }
        
        if (line.tnmClinN != null) {
            if (!((List)validCodes.getOrDefault('C', [])).contains(line.tnmClinN))
                return false
        }
        
        if (line.tnmPathN != null) {
            if (!((List)validCodes.getOrDefault('P', [])).contains(line.tnmPathN))
                return false
        }
        
        return true
    }

    // ID: IF612; NAME: Primary Site, Stage Group 2016 - Ed 7 (SEER)
    public boolean if612(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' || line.histologicTypeIcdO3 == null ||
            (line.tnmClinStageGroup == null && line.tnmPathStageGroup == null) || !(line.tnmEditionNumber == '07' || line.tnmEditionNumber == 'U7' || line.tnmEditionNumber == '88'))
            return true
        
        String siteGroup = (String)((Closure)context.AJCC7CodeLookup16).call(line)
        Map validCodes = (Map)((Map)context.IF612_Table).get(siteGroup)
        
        // Special Case for group 28 and 37B
        if ((siteGroup == '028' || siteGroup == '37B') && functions.matches(line.histologicTypeIcdO3, /^905[0-5]$/)) {
            if (line.tnmClinStageGroup != null && !((List)validCodes.getOrDefault('C', [])).contains(line.tnmClinStageGroup) && line.tnmClinStageGroup != '88')
                return false
        
            if (line.tnmPathStageGroup != null && !((List)validCodes.getOrDefault('P', [])).contains(line.tnmPathStageGroup) && line.tnmPathStageGroup != '88')
                return false
        
            return true
        }
        
        if (line.tnmClinStageGroup != null)
            if (!((List)validCodes.getOrDefault('C', [])).contains(line.tnmClinStageGroup))
                return false
        
        if (line.tnmPathStageGroup != null)
            if (!((List)validCodes.getOrDefault('P', [])).contains(line.tnmPathStageGroup))
                return false
        
        return true
    }

    // ID: IF613; NAME: Primary Site, T 2016 - Ed 7 (SEER)
    public boolean if613(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' || line.histologicTypeIcdO3 == null ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || (line.tnmClinT == null && line.tnmPathT == null))
            return true
        
        //Skip condition 5
        if (!(line.tnmEditionNumber == '07' || line.tnmEditionNumber == 'U7' || line.tnmEditionNumber == '88'))
            return true
        
        if (line.tnmEditionNumber == '88' &&
                (line.tnmClinT == null || line.tnmClinT == '88') &&
                (line.tnmPathT == null || line.tnmPathT == '88') &&
                line.overRideSiteTnmStggrp == '1')
            return true
        
        String siteGroup = (String)((Closure)context.AJCC7CodeLookup16).call(line)
        if (siteGroup == '046') {
            if (line.sex == '2' || line.sex == '6')
                siteGroup = '46A'
            else
                siteGroup = '46B'
        }
        
        // Special Case for group 28 and 37B
        Map validCodes = (Map)((Map)context.IF613_Table).get(siteGroup)
        if ((siteGroup == '028' || siteGroup == '37B') && functions.matches(line.histologicTypeIcdO3, /^905[0-5]$/)) {
            if (line.tnmClinT != null && !((List)validCodes.getOrDefault('C', [])).contains(line.tnmClinT) && line.tnmClinT != '88')
                return false
        
            if (line.tnmPathT != null && !((List)validCodes.getOrDefault('P', [])).contains(line.tnmPathT) && line.tnmPathT != '88')
                return false
        
            return true
        }
        
        if (line.tnmClinT != null)
            if (!((List)validCodes.getOrDefault('C', [])).contains(line.tnmClinT))
                return false
        
        if (line.tnmPathT != null)
            if (!((List)validCodes.getOrDefault('P', [])).contains(line.tnmPathT))
                return false
        
        return true
    }

    // ID: IF616; NAME: TNM Clin T, Clin Size, Site Spec - Ed 7 (SEER)
    public boolean if616(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.histologicTypeIcdO3 == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        //Skip condition 6, 7
        if (line.tnmClinT == null || line.tnmClinT == '88' || line.tumorSizeClinical == null || line.tumorSizeClinical == '999')
            return true
        
        //Skip condition 8
        if (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7')
            return true
        
        //Get site group code- special conditions for tumor size edit
        String siteGroup = (String)((Closure)context.AJCC7CodeLookup16).call(line)
        if (siteGroup == '04A') {
            if (functions.matches(line.primarySite, /^C129|C13\d$/))
                siteGroup = '04E'
        }
        else if (siteGroup == '17B') {
            if (line.primarySite == 'C241')
                siteGroup = '17D'
        }
        
        //If this site group is not in the table, pass edit (skip condition 5)
        if (!(siteGroup ==~ /^00[37]|04[ADE]|08[ABCD]|13B|015|16[AB]|17[ABD]|02[45789]|03[02]|04[39]|47[AB]|05[34]$/))
            return true
        
        String clinT = line.tnmClinT
        if ((clinT == 'c1' || clinT == 'c1A' || clinT == 'c1MI') && line.tumorSizeClinical == '990')
            return true
        
        Map groupMap = (Map)((Map)context.TNM_Clin_T_Tumor_Size_Table).getOrDefault(siteGroup, [:])
        if (groupMap.containsKey(clinT))
            return ((List)groupMap.getOrDefault(clinT, [])).contains(functions.asInt(line.tumorSizeClinical))
        
        return true
    }

    // ID: IF617; NAME: TNM N, Size Nodes, Site Spec - Ed 7 (COC)
    public boolean if617(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        //Skip conditions 1, 2, 3
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' || line.histologicTypeIcdO3 == null)
            return true
        
        //Skip condition 6
        if ((line.tnmClinN == null && line.tnmPathN == null) || (line.tnmClinN == '88' && line.tnmPathN == '88'))
            return true
        
        //Skip conditions 4, 7
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7'))
            return true
        
        //If this site group is not in the table, pass edit (skip condition 5)
        String siteGroup = (String)((Closure)context.AJCC7CodeLookup16).call(line)
        if (!(siteGroup ==~ /^00[367]|04[ABCD]|05[AB]|029$/))
            return true
        
        String ssf = line.csSiteSpecificFactor1
        if (siteGroup == '029')
            ssf = line.csSiteSpecificFactor16
        
        if (ssf == '988' || ssf == '999')
            return true
        
        if (ssf ==~ /^99[0123]$/)
            ssf = '030'
        else if (ssf ==~ /^99[456]$/)
            ssf = '050'
        else if (ssf == '997')
            ssf = '061'
        
        boolean pathFail = false
        Map groupMap = (Map)((Map)context.IF617_Table).getOrDefault(siteGroup, [:])
        if (line.tnmPathN != null ) {
            //If Path N value is not in the table for this site group, check Clin N
            if (groupMap.containsKey(line.tnmPathN)) {
                List validNodes = (List)groupMap.getOrDefault(line.tnmPathN, [])
                if (validNodes.contains(functions.asInt(ssf)))
                    return true
                else
                    pathFail = true
            }
        }
        if (line.tnmClinN == null && pathFail)
            return false
        
        if (line.tnmClinN != null && groupMap.containsKey(line.tnmClinN))
            return ((List)groupMap.getOrDefault(line.tnmClinN, [])).contains(functions.asInt(ssf))
        
        return true
    }

    // ID: IF618; NAME: TNM Path T, Path Size, Site Spec - Ed 7 (SEER)
    public boolean if618(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        //Skip conditions 1, 2, 3
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' || line.histologicTypeIcdO3 == null)
            return true
        
        //Skip conditions 4, 6
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line.tnmPathT == null || line.tnmPathT == '88')
            return true
        
        //Skip conditions 7, 8
        if (line.tumorSizePathologic == null || line.tumorSizePathologic == '999' || (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7'))
            return true
        
        //Get site group code- special conditions for tumor size edit
        String siteGroup = (String)((Closure)context.AJCC7CodeLookup16).call(line)
        if (siteGroup == '04A') {
            if (functions.matches(line.primarySite, /^C129|C13\d$/))
                siteGroup = '04E'
        }
        else if (siteGroup == '17B') {
            if (line.primarySite == 'C241')
                siteGroup = '17D'
        }
        
        //If this site group is not in the table, pass edit (skip condition 5)
        if (!(siteGroup ==~ /^00[37]|04[ADE]|08[ABCD]|13B|015|16[AB]|17[ABD]|02[45789]|03[02]|04[39]|47[AB]|05[34]$/))
            return true
        
        String pathT = line.tnmPathT
        if ((pathT == 'p1' || pathT == 'p1A' || pathT == 'p1MI') && line.tumorSizePathologic == '990')
            return true
        
        Map groupMap = (Map)((Map)context.TNM_Path_T_Tumor_Size_Table).getOrDefault(siteGroup, [:])
        if (groupMap.containsKey(pathT))
            return ((List)groupMap.getOrDefault(pathT, [])).contains(functions.asInt(line.tumorSizePathologic))
        
        return true
    }

    // ID: IF619; NAME: Mets at DX-BBDLLO, HemeRetic (SEER)
    public boolean if619(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        boolean allMetsEmpty = (line.metsAtDxBone == null && line.metsAtDxBrain == null && line.metsAtDxDistantLn == null &&
            line.metsAtDxLiver == null && line.metsAtDxLung == null && line.metsAtDxOther == null)
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.dateOfDiagnosisYear > '2017')
            return true
            
        if (line.typeOfReportingSource == '7' || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || allMetsEmpty)
            return true
        
        // Heme4 accepts any valid Mets at DX code
        String hist = line.histologicTypeIcdO3
        if (functions.matches(line.primarySite, /^C42[014]$/) && ((hist >= '9811' && hist <= '9818') || hist == '9837'))
            return true
        
        Integer siteInt = functions.asInt(line.primarySite?.substring(1))
        boolean included = false
        if ((hist >= '9740' && hist <= '9809') || (hist >= '9840' && hist <= '9992'))
            included = true
        else if (((siteInt >= 0 && siteInt <= 440) || (siteInt >= 442 && siteInt <= 689) || (siteInt >= 691 && siteInt <= 694) || (siteInt >= 698 && siteInt <= 809)) &&
            (hist == '9820' || hist == '9826' || (hist >= '9831' && hist <= '9834')))
            included = true
        else if (functions.matches(line.primarySite, /^C42[014]$/) && (hist == '9823' || hist == '9827'))
            included = true
        else if (((siteInt >= 0 && siteInt <= 440) || (siteInt >= 442 && siteInt <= 689) || (siteInt >= 691 && siteInt <= 694) || (siteInt >= 698 && siteInt <= 809)) && (hist == '9731' || hist == '9732' || hist == '9734'))
            included = true
        
        if (included)
            return line.metsAtDxBone == '8' && line.metsAtDxBrain == '8' && line.metsAtDxDistantLn == '8' && line.metsAtDxLiver == '8' && line.metsAtDxLung == '8' && line.metsAtDxOther == '8'
        else
            return line.metsAtDxBone != '8' && line.metsAtDxBrain != '8' && line.metsAtDxDistantLn != '8' && line.metsAtDxLiver != '8' && line.metsAtDxLung != '8' && line.metsAtDxOther != '8'
    }

    // ID: IF620; NAME: TNM T, SSF 12, Tumor Size, Carcinoma of Skin (COC)
    public boolean if620(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line.csSiteSpecificFactor12 == null || line.csSiteSpecificFactor12 == '988')
            return true
        
        //Skip condition 5
        if ((line.tnmClinT == null && line.tnmPathT == null) || (line.tnmClinT == '88' && line.tnmPathT == '88'))
            return true
        
        //Skip condition 7, 8
        if ((line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7') || line.tnmPathDescriptor == '4' || line.tnmPathDescriptor == '6')
            return true
        
        //If case is not Cutaneous CA of skin, edit is skipped (skip condition 4)
        String hist = line.histologicTypeIcdO3
        if (!(functions.matches(line.primarySite, /^C44[02-9]|C632$/)) || !((hist >= '8000' && hist <= '8246') || (hist >= '8248' && hist <= '8576') || (hist >= '8940' && hist <= '8950') || hist == '8980' || hist == '8981'))
            return true
        
        if (line.tnmPathT == null) {
            if (line.tnmClinT == 'c1')
                return functions.matches(line.csSiteSpecificFactor12, /^00[01]|99[139]$/)
            else if (line.tnmClinT == 'c2' && ((line.tumorSizeClinical >= '001' && line.tumorSizeClinical <= '020') || (line.tumorSizeSummary >= '001' && line.tumorSizeSummary <= '020')))
                return functions.matches(line.csSiteSpecificFactor12, /^00[2345]|992$/)
        }
        else {
            if (line.tnmPathT == 'p1')
                return functions.matches(line.csSiteSpecificFactor12, /^00[01]|99[139]$/)
            else if (line.tnmPathT == 'p2' && ((line.tumorSizePathologic >= '001' && line.tumorSizePathologic <= '020') || (line.tumorSizeSummary >= '001' && line.tumorSizeSummary <= '020')))
                return functions.matches(line.csSiteSpecificFactor12, /^00[2345]|992$/)
        }
        
        return true
    }

    // ID: IF621; NAME: TNM Clin Stage Group, SSF 2 Lymphoma (COC)
    public boolean if621(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' ||
            line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line.tnmClinStageGroup == null || line.csSiteSpecificFactor2 == null || line.csSiteSpecificFactor2 == '988')
            return true
        
        if (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7')
            return true
        
        String siteGroup = (String)((Closure)context.AJCC7CodeLookup16).call(line)
        if (siteGroup != '57A' && siteGroup != '57C')
            return true
        
        if (functions.matches(line.tnmClinStageGroup, /^[1-4]A$/))
            return line.csSiteSpecificFactor2 == '000' || line.csSiteSpecificFactor2 == '020'
        else if (functions.matches(line.tnmClinStageGroup, /^[1-4]B$/))
            return line.csSiteSpecificFactor2 == '010' || line.csSiteSpecificFactor2 == '030'
        else if (functions.matches(line.tnmClinStageGroup, /^[1-4]$/))
            return line.csSiteSpecificFactor2 == '999'
        
        return true
    }

    // ID: IF622; NAME: TNM Path T, Depth, Melanoma - Ed 7 (COC)
    public boolean if622(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.typeOfReportingSource == '7' || line.behaviorCodeIcdO3 == '0' ||
            line.behaviorCodeIcdO3 == '1' || line.tnmPathT == null || line.tnmPathT == '88')
            return true
        
        //Skip condition 6
        if (line.csSiteSpecificFactor1 == null || line.csSiteSpecificFactor1 == '999' || line.csSiteSpecificFactor1 == '988')
            return true
        
        //Skip conditions 7, 8
        if ((line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7') || line.tnmPathDescriptor == '4' || line.tnmPathDescriptor == '6')
            return true
        
        //Skip condition 4
        String siteGroup = (String)((Closure)context.AJCC7CodeLookup16).call(line)
        if (siteGroup != '031' && siteGroup != '050')
            return true
        
        Integer ssfInt = functions.asInt(line.csSiteSpecificFactor1)
        if (siteGroup == '050') {
            if (ssfInt == 991)
                ssfInt = 5
            else if (ssfInt >= 992 && ssfInt <= 995)
                ssfInt = 150
            else if (ssfInt == 996)
                ssfInt = 980
            else if (ssfInt == 998 && functions.matches(line.tnmPathT, /^p[12][ABC]$/))
                return false
        }
        
        List validSsf = (List)((Map)((Map)context.IF622_Table).getOrDefault(siteGroup, [:])).getOrDefault(line.tnmPathT, null)
        if (validSsf == null)
            return true
        else if (!validSsf.contains(ssfInt))
            return false
        
        return true
    }

    // ID: IF623; NAME: TNM Clin T, N, M, In Situ (COC)
    public boolean if623(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016' || line.dateOfDiagnosisYear > '2017')
             return true
        if (line.typeOfReportingSource == '7' || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || !(functions.matches(line.tnmClinT, /^pA|pIS[UD]?$/)))
            return true
        if (line.tnmEditionNumber != '07' && line.tnmEditionNumber != 'U7')
            return true
        
        if (line.overRideTnmTis == '1')
            return true
        
        String siteGroup = (String)((Closure)context.AJCC7CodeLookup16).call(line)
        if (siteGroup ==~ /^00[79]|08[ABCDEF]|13B|16[AB]|17[BC]|018|36[BC]|37A|039|04[13]|47[AB]|51[AB]|05[34]|57B$/)
            return true
        
        if (line.tnmClinN != 'c0' && line.tnmClinN != 'c0A' && line.tnmClinN != 'c0B')
            return false
        if (line.tnmClinM != 'c0' && line.tnmClinM != 'c0I+')
            return false
        if (siteGroup != '049' && siteGroup != '050')
            if (line.tnmClinStageGroup != '0' && line.tnmClinStageGroup != '0IS' && line.tnmClinStageGroup != '0A')
                return false
        
        return true
    }

    // ID: IF625; NAME: RX Date Mst Defn Srg, Date Last Contact (COC)
    public boolean if625(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.rxDateMostDefinSurgYear == null || line.dateOfLastContactYear == null)
            return true
        
        if (line.rxDateMostDefinSurgYear > line.dateOfLastContactYear)
            return false
        
        if (line.rxDateMostDefinSurgYear < line.dateOfLastContactYear || line.rxDateMostDefinSurgMonth == null || line.dateOfLastContactMonth == null)
            return true
        
        if (line.rxDateMostDefinSurgMonth > line.dateOfLastContactMonth)
            return false
        
        if (line.rxDateMostDefinSurgMonth < line.dateOfLastContactMonth || line.rxDateMostDefinSurgDay == null || line.dateOfLastContactDay == null)
            return true
        
        return line.rxDateMostDefinSurgDay <= line.dateOfLastContactDay
    }

    // ID: IF626; NAME: RX Date Mst Defn Srg, Date of DX (COC)
    public boolean if626(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.rxDateMostDefinSurgYear == null || line.dateOfDiagnosisYear == null)
            return true
        
        if (line.rxDateMostDefinSurgYear < line.dateOfDiagnosisYear)
            return false
        
        if (line.rxDateMostDefinSurgYear > line.dateOfDiagnosisYear || line.rxDateMostDefinSurgMonth == null || line.dateOfDiagnosisMonth == null)
            return true
        
        if (line.rxDateMostDefinSurgMonth < line.dateOfDiagnosisMonth)
            return false
        
        if (line.rxDateMostDefinSurgMonth > line.dateOfDiagnosisMonth || line.rxDateMostDefinSurgDay == null || line.dateOfDiagnosisDay == null)
            return true
        
        return line.rxDateMostDefinSurgDay >= line.dateOfDiagnosisDay
    }

    // ID: IF627; NAME: Addr at DX-State, Registry ID (SEER IF627)
    public boolean if627(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        String state = line.addrAtDxState
        String registryId = line.registryId
        
        if (registryId == null || state == null)
            return true
        
        if ((registryId == '0000001501' || registryId == '0000001531' || registryId == '0000001535' || registryId == '0000001541') && state == 'CA')
            return true
        else if (registryId == '0000001502' && state == 'CT')
            return true
        else if (registryId == '0000001520' && state == 'MI')
            return true
        else if (registryId == '0000001521' && state == 'HI')
            return true
        else if (registryId == '0000001522' && state == 'IA')
            return true
        else if (registryId == '0000001523' && state == 'NM')
            return true
        else if (registryId == '0000001525' && state == 'WA')
            return true
        else if (registryId == '0000001526' && state == 'UT')
            return true
        else if ((registryId == '0000001527' || registryId == '0000001537' || registryId == '0000001547') && state == 'GA')
            return true
        else if (registryId == '0000001529' && state == 'AK')
            return true
        else if (registryId == '0000001533' && state == 'AZ')
            return true
        else if (registryId == '0000001542' && state == 'KY')
            return true
        else if (registryId == '0000001543' && state == 'LA')
            return true
        else if (registryId == '0000001544' && state == 'NJ')
            return true
        else if (registryId == '0000001551')
            return true
        else if (registryId == '0000001561' && state == 'ID')
            return true
        else if (registryId == '0000001562' && state == 'NY')
            return true
        else if (registryId == '0000001563' && state == 'MA')
            return true
        else if (registryId == '0000001565' && state == 'IL')
            return true
        else if (registryId == '0000001566' && state == 'TX')
            return true
        
        return false
    }

    // ID: IF628; NAME: In Utero Over-ride Flag, Age at Diagnosis conflict
    public boolean if628(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return !functions.matches(line.overRideAgeSiteMorph, /^[23]$/) || line.ageAtDiagnosis == '000'
    }

    // ID: IF629; NAME: Census Tract 2020 and Year of Diagnosis
    public boolean if629(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.registryId == '0000001565')
            return true
        
        if (functions.asInt(line.dateOfDiagnosisYear) > 2015 && line.dateOfDiagnosisYear != '9999')
            return line.censusTract2020 != null
        
        return true
    }

    // ID: IF630; NAME: Census Tr Certainty 2020 and Year of Diagnosis(SEER IF630)
    public boolean if630(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.registryId != '0000001533' && line.dateOfDiagnosisYear > '2015' && line.dateOfDiagnosisYear != '9999')
            return line.censusTractCertainty2020 != null
        
        return true
    }

    // ID: IF631; NAME: Recurrence Date--1st, Date of Diagnosis (SEER)
    public boolean if631(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if ((line.dateOfDiagnosisYear == null && line.dateOfDiagnosisMonth == null && line.dateOfDiagnosisDay == null)
                    || (line.recurrenceDate1stYear == null && line.recurrenceDate1stMonth == null && line.recurrenceDate1stDay == null))
            return true
        
        Integer recurrenceYear = functions.asInt(line.recurrenceDate1stYear)
        Integer recurrenceMonth = functions.asInt(line.recurrenceDate1stMonth)
        Integer recurrenceDay = functions.asInt(line.recurrenceDate1stDay)
        Integer dxYear = functions.asInt(line.dateOfDiagnosisYear)
        Integer dxMonth = functions.asInt(line.dateOfDiagnosisMonth)
        Integer dxDay = functions.asInt(line.dateOfDiagnosisDay)
        
        return ((Integer)((Closure)context.compareDate).call(recurrenceYear, recurrenceMonth, recurrenceDay, dxYear, dxMonth, dxDay)) >= 0
    }

    // ID: IF632; NAME: Registry, County and Census Tract 2020 (SEER IF632)
    public boolean if632(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        String county = line.countyAtDxGeocode2020 ?: line.countyAtDxAnalysis
        if (line.censusTract2020 == null || county == null || line.censusTract2020 == '000000' || line.censusTract2020 == '999999' || line.registryId < '0000001500' || line.registryId > '0000001599' || line.registryId == '0000001551')
            return true
        if (line.addrAtDxState == 'AK' && county == '900')
            return true
        
        Map countyCensusTract = (Map)((Map)context.registry_county_census2020).get(line.addrAtDxState)
        if (countyCensusTract == null)
            return true
        
        return ((List)countyCensusTract.getOrDefault(county, [])).contains(functions.asInt(line.censusTract2020))
    }

    // ID: IF2610DG_P11; NAME: Extent of Disease 10-Digit(SEER IF2610DG)
    public boolean if2610dg_p11(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.codingSystemForEod != '4' || line.dateOfDiagnosisYear < '1930' || line.dateOfDiagnosisYear > '1997'
                || (line.registryId == '0000001541' && line.dateOfDiagnosisYear < '1994')
                || (line.registryId == '0000001535' && line.dateOfDiagnosisYear < '1992')
                || line.typeOfReportingSource != '7')
            return true
        if (line.dateOfDiagnosisYear > '1994' && line.primarySite == 'C619')
            return (line.eodTumorSize == '999' && line.eodExtension == '90' && line.eodLymphNodeInvolv == '9'
                    && line.regionalNodesPositive == '99' && line.regionalNodesExamined == '99' && line.eodExtensionProstPath == '90')
        return (line.eodTumorSize == '999' && line.eodExtension == '99' && line.eodLymphNodeInvolv == '9'
                    && line.regionalNodesPositive == '99' && line.regionalNodesExamined == '99' && line.eodExtensionProstPath == null)
    }

    // ID: IF2610DG_P2; NAME: Extent of Disease 10-Digit(SEER IF2610DG)
    public boolean if2610dg_p2(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer site = functions.asInt(line.primarySite.substring(1))
        Integer histIcdO3 = functions.asInt(line.histologicTypeIcdO3)
        
        if (line.codingSystemForEod != '4' || line.dateOfDiagnosisYear < '1930' || line.dateOfDiagnosisYear > '1997' || (line.registryId == '0000001541' && line.dateOfDiagnosisYear < '1994')
                 || (line.registryId == '0000001535' && line.dateOfDiagnosisYear < '1992') || line.typeOfReportingSource == '7' || line.behaviorCodeIcdO3 != '3')
            return true
        if (!(functions.matches(line.eodExtension, /^[0-9][0-9]$/)))
            return false
        if (site == 589 && functions.matches(line.eodExtension, /^([467][1-4])$/))
            return true
        if (histIcdO3 == 9731 && line.eodExtension == '10')
            return true
        if (site == 778 && functions.matches(line.eodExtension, /^1[01]$/))
            return false
        if (((Map)context.If2610DG_HIST_MALIG_EXT).containsKey(histIcdO3))
            return ((List)((Map)context.If2610DG_HIST_MALIG_EXT).getOrDefault(histIcdO3, [])).contains(functions.asInt(line.eodExtension))
        if (((Map)context.If2610DG_HIST_SITE_MALIG_EXT).containsKey(histIcdO3) && ((Map)((Map)context.If2610DG_HIST_SITE_MALIG_EXT).getOrDefault(histIcdO3, [:])).containsKey(site))
            return ((List)((Map)((Map)context.If2610DG_HIST_SITE_MALIG_EXT).getOrDefault(histIcdO3, [:])).getOrDefault(site, [])).contains(functions.asInt(line.eodExtension))
        if (line.dateOfDiagnosisYear > '1990' && site > 249 && site < 255)
            return functions.matches(line.eodExtension, /^([13]0|4[048]|5[0246]|6[24]|7[2468]|8[05]|99)$/)
        if (line.dateOfDiagnosisYear > '1990' && site > 256 && site < 260)
            return functions.matches(line.eodExtension, /^([135]0|4[05]|8[05]|99)$/)
        if (line.dateOfDiagnosisYear == '1994' && site == 619)
            return functions.matches(line.eodExtension, /^(1[0-5]|2[0-9]|3[01]|4[0189]|5[0-356]|6[0-25]|70|8[05]|99)$/)
        if (line.dateOfDiagnosisYear > '1994' && site == 619)
            return (functions.matches(line.eodExtension, /^(1[0-5]|[23][0-4]|4[1-59]|5[0-3]|6[015]|70|85|90)$/))
        return ((List)((Map)context.If2610DG_SITE_MALIG_EXT).getOrDefault(site, [])).contains(functions.asInt(line.eodExtension))
    }

    // ID: IF2610DG_P3; NAME: Extent of Disease 10-Digit(SEER IF2610DG)
    public boolean if2610dg_p3(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer site = functions.asInt(line.primarySite.substring(1))
        Integer histIcdO3 = functions.asInt(line.histologicTypeIcdO3)
        
        if (line.codingSystemForEod != '4' ||
            line.dateOfDiagnosisYear < '1930' || line.dateOfDiagnosisYear > '1997' ||
            (line.registryId == '0000001541' && line.dateOfDiagnosisYear < '1994') ||
            (line.registryId == '0000001535' && line.dateOfDiagnosisYear < '1992') ||
            line.typeOfReportingSource == '7' || line.behaviorCodeIcdO3 != '2')
            return true
        if (!functions.matches(line.eodExtension, /^[0-9][0-9]$/))
           return false
        if (histIcdO3 == 9731 && line.eodExtension == '10')
           return true
        if (site == 778 && functions.matches(line.eodExtension, /^1[01]$/))
           return false
        if (((Map)context.If2610DG_HIST_INSITU_EXT).containsKey(histIcdO3))
            return ((List)((Map)context.If2610DG_HIST_INSITU_EXT).getOrDefault(histIcdO3, [])).contains(functions.asInt(line.eodExtension))
        if (((Map)context.If2610DG_HIST_SITE_INSITU_EXT).containsKey(histIcdO3) && ((Map)((Map)context.If2610DG_HIST_SITE_INSITU_EXT).getOrDefault(histIcdO3, [:])).containsKey(site))
            return ((List)((Map)((Map)context.If2610DG_HIST_SITE_INSITU_EXT).getOrDefault(histIcdO3, [:])).getOrDefault(site, [])).contains(functions.asInt(line.eodExtension))
        if (line.dateOfDiagnosisYear >= '1994' && site == 619)
           return line.eodExtension == '00'
        return ((List)((Map)context.If2610DG_SITE_INSITU_EXT).getOrDefault(site, [])).contains(functions.asInt(line.eodExtension))
    }

    // ID: IF2610DG_P4; NAME: Extent of Disease 10-Digit(SEER IF2610DG)
    public boolean if2610dg_p4(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer site = functions.asInt(line.primarySite.substring(1))
        Integer histIcdO3 = functions.asInt(line.histologicTypeIcdO3)
        
        if (line.codingSystemForEod != '4' ||
             line.dateOfDiagnosisYear < '1930' || line.dateOfDiagnosisYear > '1997' ||
             (line.registryId == '0000001541' && line.dateOfDiagnosisYear < '1994') ||
             (line.registryId == '0000001535' && line.dateOfDiagnosisYear < '1992') ||
             line.typeOfReportingSource == '7')
           return true
        if ( ! (functions.matches(line.eodTumorSize, /^[0-9][0-9][0-9]$/)))
           return false
        if ([180,181,182,183,184,185,186,187,188,189,199,209].contains(site) &&
            line.eodTumorSize == '998' &&
            !(histIcdO3 == 8220 || histIcdO3 == 8221))
           return false
        if (((Map)context.If2610DG_HIST_SIZE).containsKey(histIcdO3))
            return ((List)((Map)context.If2610DG_HIST_SIZE).getOrDefault(histIcdO3, [])).contains(functions.asInt(line.eodTumorSize))
        if (((Map)context.If2610DG_HIST_SITE_SIZE).containsKey(histIcdO3) && ((Map)((Map)context.If2610DG_HIST_SITE_SIZE).getOrDefault(histIcdO3, [:])).containsKey(site))
            return ((List)((Map)((Map)context.If2610DG_HIST_SITE_SIZE).getOrDefault(histIcdO3, [:])).getOrDefault(site, [])).contains(functions.asInt(line.eodTumorSize))
        return ((List)((Map)context.If2610DG_SITE_SIZE).getOrDefault(site, [])).contains(functions.asInt(line.eodTumorSize))
    }

    // ID: IF2610DG_P7; NAME: Extent of Disease 10-Digit(SEER IF2610DG)
    public boolean if2610dg_p7(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer site = functions.asInt(line.primarySite.substring(1))
        Integer histIcdO3 = functions.asInt(line.histologicTypeIcdO3)
        
        if (line.codingSystemForEod != '4' ||
             line.dateOfDiagnosisYear < '1930' || line.dateOfDiagnosisYear > '1997' ||
             (line.registryId == '0000001541' && line.dateOfDiagnosisYear < '1994') ||
             (line.registryId == '0000001535' && line.dateOfDiagnosisYear < '1992') ||
              line.typeOfReportingSource == '7')
           return true
        if ( ! (line.regionalNodesPositive ==~/^[0-9][0-9]$/))
           return false
        if (line.behaviorCodeIcdO3 == '2') {
            if (((Map)context.If2610DG_HIST_INSITU_POS_NODES).containsKey(histIcdO3))
                return ((List)((Map)context.If2610DG_HIST_INSITU_POS_NODES).getOrDefault(histIcdO3, [])).contains(functions.asInt(line.regionalNodesPositive))
            if (((Map)context.If2610DG_HIST_SITE_INSITU_POS_NODES).containsKey(histIcdO3) && ((Map)((Map)context.If2610DG_HIST_SITE_INSITU_POS_NODES).getOrDefault(histIcdO3, [:])).containsKey(site))
                return ((List)((Map)((Map)context.If2610DG_HIST_SITE_INSITU_POS_NODES).getOrDefault(histIcdO3, [:])).getOrDefault(site, [])).contains(functions.asInt(line.regionalNodesPositive))
            return ((List)((Map)context.If2610DG_SITE_INSITU_POS_NODES).getOrDefault(site, [])).contains(functions.asInt(line.regionalNodesPositive))
        }
        else if (line.behaviorCodeIcdO3 == '3') {
            if (((Map)context.If2610DG_HIST_MALIG_POS_NODES).containsKey(histIcdO3))
                return ((List)((Map)context.If2610DG_HIST_MALIG_POS_NODES).getOrDefault(histIcdO3, [])).contains(functions.asInt(line.regionalNodesPositive))
            if (((Map)context.If2610DG_HIST_SITE_MALIG_POS_NODES).containsKey(histIcdO3) && ((Map)((Map)context.If2610DG_HIST_SITE_MALIG_POS_NODES).getOrDefault(histIcdO3, [:])).containsKey(site))
                return ((List)((Map)((Map)context.If2610DG_HIST_SITE_MALIG_POS_NODES).getOrDefault(histIcdO3, [:])).getOrDefault(site, [])).contains(functions.asInt(line.regionalNodesPositive))
            return ((List)((Map)context.If2610DG_SITE_MALIG_POS_NODES).getOrDefault(site, [])).contains(functions.asInt(line.regionalNodesPositive))
        }
        
        return true
    }

    // ID: IF2610DG_P8; NAME: Extent of Disease 10-Digit(SEER IF2610DG)
    public boolean if2610dg_p8(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer site = functions.asInt(line.primarySite.substring(1))
        Integer histIcdO3 = functions.asInt(line.histologicTypeIcdO3)
        
        if (line.codingSystemForEod != '4' ||
             line.dateOfDiagnosisYear < '1930' || line.dateOfDiagnosisYear > '1997' ||
             (line.registryId == '0000001541' && line.dateOfDiagnosisYear < '1994') ||
             (line.registryId == '0000001535' && line.dateOfDiagnosisYear < '1992') ||
              line.typeOfReportingSource == '7')
           return true
        if ( ! (functions.matches(line.regionalNodesExamined, /^[0-9][0-9]$/)))
           return false
        if (line.behaviorCodeIcdO3 == '2') {
            if (((Map)context.If2610DG_HIST_INSITU_REG_EXAM).containsKey(histIcdO3))
                return ((List)((Map)context.If2610DG_HIST_INSITU_REG_EXAM).getOrDefault(histIcdO3, [])).contains(functions.asInt(line.regionalNodesExamined))
            if (((Map)context.If2610DG_HIST_SITE_INSITU_REG_EXAM).containsKey(histIcdO3) && ((Map)((Map)context.If2610DG_HIST_SITE_INSITU_REG_EXAM).getOrDefault(histIcdO3, [:])).containsKey(site))
                return ((List)((Map)((Map)context.If2610DG_HIST_SITE_INSITU_REG_EXAM).getOrDefault(histIcdO3, [:])).getOrDefault(site, [])).contains(functions.asInt(line.regionalNodesExamined))
            return ((List)((Map)context.If2610DG_SITE_INSITU_REG_EXAM).getOrDefault(site, [])).contains(functions.asInt(line.regionalNodesExamined))
        }
        else if (line.behaviorCodeIcdO3 == '3') {
            if (((Map)context.If2610DG_HIST_MALIG_REG_EXAM).containsKey(histIcdO3))
                return ((List)((Map)context.If2610DG_HIST_MALIG_REG_EXAM).getOrDefault(histIcdO3, [])).contains(functions.asInt(line.regionalNodesExamined))
            if (((Map)context.If2610DG_HIST_SITE_MALIG_REG_EXAM).containsKey(histIcdO3) && ((Map)((Map)context.If2610DG_HIST_SITE_MALIG_REG_EXAM).getOrDefault(histIcdO3, [:])).containsKey(site))
                return ((List)((Map)((Map)context.If2610DG_HIST_SITE_MALIG_REG_EXAM).getOrDefault(histIcdO3, [:])).getOrDefault(site, [])).contains(functions.asInt(line.regionalNodesExamined))
            return ((List)((Map)context.If2610DG_SITE_MALIG_REG_EXAM).getOrDefault(site, [])).contains(functions.asInt(line.regionalNodesExamined))
        }
        
        return true
    }

    // ID: IF2613DG_P1; NAME: EOD--Old 13 digit, Primary Site (SEER IF2613DG)
    public boolean if2613dg_p1(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer site = functions.asInt(line.primarySite.substring(1))
        Integer histIcdO3 = functions.asInt(line.histologicTypeIcdO3)
        
        return ('2' != line.codingSystemForEod
                || (((List)context.IF26_13_Digit_Site_List).contains(site) && !((((List)context.LymphNodesLymphoidTIS_IF2613DG).contains(site) && !((List)context.Lymphoma_IF2613DG).contains(histIcdO3))
                    || (((List)context.Skin_IF2613DG).contains(site) && !((List)context.MaligMelanoma_IF2613DG).contains(histIcdO3)))))
    }

    // ID: IF2613DG_P2; NAME: EOD--Old 13 digit, Primary Site (SEER IF2613DG)
    public boolean if2613dg_p2(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if ('2' != line.codingSystemForEod)
           return true
        if (functions.matches(line.primarySite, /^C16\d$/))  /* STOMACH  */
           return functions.matches(line.eodOld13Digit, /^(0&|\d\d|--)--[-0-9][-0-9][-&0-689]--[-01]-[01][&0-9]$/)
        if (line.primarySite == 'C180')     /* CECUM  */
           return functions.matches(line.eodOld13Digit, /^(0&|[0-8][0-9]|9[0-8]|--)--[-0-9]-[-0-9][-0-7]-[-01]-[01][&0-9]$/)
        if (line.primarySite == 'C182')  /* ASCENDING_COLON  */
           return functions.matches(line.eodOld13Digit, /^(0&|[0-8][0-9]|9[0-8]|--)--[-0-9]-[-0-9][-0-7]-[-01]-[01][&0-9]$/)
        if (functions.matches(line.primarySite, /^C18[345]$/))  /* TRANSVERS_COLON  */
           return functions.matches(line.eodOld13Digit, /^(0&|[0-8][0-9]|9[0-8]|--)--[-&0-9]-[-&0-9][-0-7]-[-01]-[01][&0-9]$/)
        if (line.primarySite == 'C186')  /* DESCENDING_COLON  */
           return functions.matches(line.eodOld13Digit, /^(0&|[0-8][0-9]|9[0-8]|--)--[-0-9]-[-&0-9][-0-7]-[-01]-[01][&0-9]$/)
        if (line.primarySite == 'C187')  /*  SIGMOID_COLON */
           return functions.matches(line.eodOld13Digit, /^(0&|[0-8][0-9]|9[0-8]|--)--[-0-9]-[-&0-9][-0-7]-[-01]-[01][&0-9]$/)
        if (line.primarySite == 'C199')  /* RECTOSIGMOID  */
           return functions.matches(line.eodOld13Digit, /^(0&|[0-8][0-9]|9[0-8]|--)--[-0-9]-[-&0-79][-0-7]-[-01]-[01][&0-9]$/)
        if (line.primarySite == 'C209')   /* RECTUM  */
           return functions.matches(line.eodOld13Digit, /^(0&|[0-8][0-9]|9[0-8]|--)--[-0-689]-[-&0-9][-0-7]-[-01]-[01][&0-9]$/)
        if (functions.matches(line.primarySite, /^C34[01236789]$/))   /* BRONCHUS_LUNG  */
           return functions.matches(line.eodOld13Digit, /^(0[-&]|[0-9][0-9]|--)-[-&0-9][-&0-9][&0-9][0-9][&0-9][-0-9][-01][01][01][&0-589]$/)
        if (functions.matches(line.primarySite, /^C(44[0-7]|51[01289]|60[0189])$/))   /* MALIGNANT_MEL  */
           return functions.matches(line.eodOld13Digit, /^[-0-9][-0-5]-[&1-9][-1-9][0-4][01][0-5][-0-4][-0-2][01][01][&0-9]$/)
        if (functions.matches(line.primarySite, /^C50\d$/))   /* BREAST  */
           return functions.matches(line.eodOld13Digit, /^[-&0-9][-&0-9]-[-&0-9][-&0-24-9]-[-0-4][-0-9]([0-9][0-9]|--)-[01][&0-9]$/)
        if (functions.matches(line.primarySite, /^C53\d$/))   /* CERVIX_UTERI  */
           return functions.matches(line.eodOld13Digit, /^([0-9][0-9]|--)-[&02-9][-&0-9][&0-9][&0-9]-[-0-3][-01][01][01][&0-9]$/)
        if (functions.matches(line.primarySite, /^C54\d$/))   /* CORPUS_UTERI  */
           return functions.matches(line.eodOld13Digit, /^([0-8][0-9]|9[0-8]|--)-[-0-6][-0-9][0-8][0-8]-[-0-3][-01][01][01][&0-9]$/)
        if (line.primarySite == 'C619')   /* PROSTATE  */
           return functions.matches(line.eodOld13Digit, /^[0-8][-&0-8]-[&0-9][-&0-9]--[0-8][0-3][-01][01][01][&0-9]$/)
        if (functions.matches(line.primarySite, /^C67[0-689]$/))   /* BLADDER  */
           return functions.matches(line.eodOld13Digit, /^[-0-8][-&0-8]--[-&0-9][&0-9][&0-9]-[0-3][-01][01][01][&0-9]$/)
        if (functions.matches(line.primarySite, /^C(024|09[89]|111|142|379|422|77\d)$/))   /* LYMPH */
           return functions.matches(line.eodOld13Digit, /^[-&0-57-9][-0-3][-0-3][-0-3][-0-3][0-7][0-7][0-7][0-7][0-3][0-7][0-7]-$/)
        return true
    }

    // ID: IF2613DG_P3; NAME: EOD--Old 13 digit, Primary Site (SEER IF2613DG)
    public boolean if2613dg_p3(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer site = functions.asInt(line.primarySite.substring(1))
        Integer histIcdO3 = functions.asInt(line.histologicTypeIcdO3)
        
        if (line.codingSystemForEod != '2')
           return true
        if (((List)context.BRONCHUS_LUNG_IF2613DG).contains(site)) {
           if (line.behaviorCodeIcdO3 == '2') {
              if (line.eodOld13Digit == null)
                  return false
              return (line.eodOld13Digit.charAt(3) == '0' as char && line.eodOld13Digit.charAt(4) == '1' as char) ||
                (line.eodOld13Digit.charAt(3) == '1' as char && line.eodOld13Digit.charAt(4) == '0' as char)
           }
           if (line.behaviorCodeIcdO3 == '3') {
              if (line.eodOld13Digit == null)
                  return true
              if (line.eodOld13Digit.charAt(3) == '0' as char && line.eodOld13Digit.charAt(4) == '0' as char)
                  return false
           }
        }
        else if (((List)context.Skin_IF2613DG).contains(site) && ((List)context.MaligMelanoma_IF2613DG).contains(histIcdO3)) {
           if (line.behaviorCodeIcdO3 == '2') {
              if (line.eodOld13Digit == null)
                  return false
              return line.eodOld13Digit.charAt(4) == '1' as char
           }
           if (line.behaviorCodeIcdO3 == '3') {
              if (line.eodOld13Digit == null)
                  return true
              return line.eodOld13Digit.charAt(4) != '1' as char
           }
        }
        else if (!((List)context.LymphNodesLymphoidTIS_IF2613DG).contains(site)) {
            if (line.behaviorCodeIcdO3 == '2') {
              if (line.eodOld13Digit == null)
                  return false
              return line.eodOld13Digit.charAt(4) == '0' as char
           }
           if (line.behaviorCodeIcdO3 == '3') {
              if (line.eodOld13Digit == null)
                  return true
              return line.eodOld13Digit.charAt(4) != '0' as char
           }
        }
        return true
    }

    // ID: IFN0246; NAME: Recurrence Date--1st, Date Last Contact (COC)
    public boolean ifn0246(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if ((line.dateOfLastContactYear == null && line.dateOfLastContactMonth == null && line.dateOfLastContactDay == null)
                    || (line.recurrenceDate1stYear == null && line.recurrenceDate1stMonth == null && line.recurrenceDate1stDay == null))
            return true
        
        Integer recurrenceYear = functions.asInt(line.recurrenceDate1stYear)
        Integer recurrenceMonth = functions.asInt(line.recurrenceDate1stMonth)
        Integer recurrenceDay = functions.asInt(line.recurrenceDate1stDay)
        Integer dolcYear = functions.asInt(line.dateOfLastContactYear)
        Integer dolcMonth = functions.asInt(line.dateOfLastContactMonth)
        Integer dolcDay = functions.asInt(line.dateOfLastContactDay)
        
        return ((Integer)((Closure)context.compareDate).call(recurrenceYear, recurrenceMonth, recurrenceDay, dolcYear, dolcMonth, dolcDay)) <= 0
    }

    // ID: IFN0248; NAME: Recurrence Type--1st, Recurrence Date--1st (COC)
    public boolean ifn0248(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.recurrenceType1st == null || (line.recurrenceDate1stYear == null && line.recurrenceDate1stMonth == null && line.recurrenceDate1stDay == null))
            return true
        
        if (line.recurrenceType1st == '00' || line.recurrenceType1st == '70')
            return false
        
        return true
    }

    // ID: IFN0528; NAME: RX Date Systemic, Date Last Contact (COC)
    public boolean ifn0528(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.rxDateSystemicYear == null || line.dateOfLastContactYear == null)
            return true
        
        if (line.rxDateSystemicYear > line.dateOfLastContactYear)
            return false
        
        if (line.rxDateSystemicYear < line.dateOfLastContactYear || line.rxDateSystemicMonth == null || line.dateOfLastContactMonth == null)
            return true
        
        if (line.rxDateSystemicMonth > line.dateOfLastContactMonth)
            return false
        
        if (line.rxDateSystemicMonth < line.dateOfLastContactMonth || line.rxDateSystemicDay == null || line.dateOfLastContactDay == null)
            return true
        
        return line.rxDateSystemicDay <= line.dateOfLastContactDay
    }

    // ID: IFN2514; NAME: Date of Sentinel Lymph Node Biopsy, RPTSRC (SEER)
    public boolean ifn2514(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        boolean dateSentinelLymphNodeBiopsyIsBlank = line.dateSentinelLymphNodeBiopsyYear == null && line.dateSentinelLymphNodeBiopsyMonth == null && line.dateSentinelLymphNodeBiopsyDay == null
            if (line.typeOfReportingSource == '6' || line.typeOfReportingSource == '7')
                return dateSentinelLymphNodeBiopsyIsBlank
        
        return true
    }

    // ID: IFN2516; NAME: Date of Sentinel Lymph Node Biopsy, Date Last Contact (COC)
    public boolean ifn2516(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateSentinelLymphNodeBiopsyYear == null || line.dateOfLastContactYear == null)
            return true
        
        if (line.dateSentinelLymphNodeBiopsyYear > line.dateOfLastContactYear)
            return false
        
        if (line.dateSentinelLymphNodeBiopsyYear < line.dateOfLastContactYear || line.dateSentinelLymphNodeBiopsyMonth == null || line.dateOfLastContactMonth == null)
            return true
        
        if (line.dateSentinelLymphNodeBiopsyMonth > line.dateOfLastContactMonth)
            return false
        
        if (line.dateSentinelLymphNodeBiopsyMonth < line.dateOfLastContactMonth || line.dateSentinelLymphNodeBiopsyDay == null || line.dateOfLastContactDay == null)
            return true
        
        return line.dateSentinelLymphNodeBiopsyDay <= line.dateOfLastContactDay
    }

    // ID: IFN2517; NAME: Date of Sentinel Lymph Node Biopsy, Date of Diagnosis (COC)
    public boolean ifn2517(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateSentinelLymphNodeBiopsyYear == null || line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateSentinelLymphNodeBiopsyYear < line.dateOfDiagnosisYear)
            return false
        
        if (line.dateSentinelLymphNodeBiopsyYear > line.dateOfDiagnosisYear || line.dateSentinelLymphNodeBiopsyMonth == null || line.dateOfDiagnosisMonth == null)
            return true
        
        if (line.dateSentinelLymphNodeBiopsyMonth < line.dateOfDiagnosisMonth)
            return false
        
        if (line.dateSentinelLymphNodeBiopsyMonth > line.dateOfDiagnosisMonth || line.dateSentinelLymphNodeBiopsyDay == null || line.dateOfDiagnosisDay == null)
            return true
        
        return line.dateSentinelLymphNodeBiopsyDay >= line.dateOfDiagnosisDay
    }

    // ID: IFN2522; NAME: Date Regional Lymph Node Dissection, Date Last Contact (COC)
    public boolean ifn2522(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateRegionalLNDissectionYear == null || line.dateOfLastContactYear == null)
            return true
        
        if (line.dateRegionalLNDissectionYear > line.dateOfLastContactYear)
            return false
        
        if (line.dateRegionalLNDissectionYear < line.dateOfLastContactYear || line.dateRegionalLNDissectionMonth == null || line.dateOfLastContactMonth == null)
            return true
        
        if (line.dateRegionalLNDissectionMonth > line.dateOfLastContactMonth)
            return false
        
        if (line.dateRegionalLNDissectionMonth < line.dateOfLastContactMonth || line.dateRegionalLNDissectionDay == null || line.dateOfLastContactDay == null)
            return true
        
        return line.dateRegionalLNDissectionDay <= line.dateOfLastContactDay
    }

    // ID: IFN2523; NAME: Date Regional Lymph Node Dissection, Date of Diagnosis (COC)
    public boolean ifn2523(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateRegionalLNDissectionYear == null || line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateRegionalLNDissectionYear < line.dateOfDiagnosisYear)
            return false
        
        if (line.dateRegionalLNDissectionYear > line.dateOfDiagnosisYear || line.dateRegionalLNDissectionMonth == null || line.dateOfDiagnosisMonth == null)
            return true
        
        if (line.dateRegionalLNDissectionMonth < line.dateOfDiagnosisMonth)
            return false
        
        if (line.dateRegionalLNDissectionMonth > line.dateOfDiagnosisMonth || line.dateRegionalLNDissectionDay == null || line.dateOfDiagnosisDay == null)
            return true
        
        return line.dateRegionalLNDissectionDay >= line.dateOfDiagnosisDay
    }

    // ID: IFN2524; NAME: Date of Last Cancer (tumor) Status (COC)
    public boolean ifn2524(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer year = functions.asInt(line.dateOfLastCancerStatusYear)
        Integer month = functions.asInt(line.dateOfLastCancerStatusMonth)
        Integer day = functions.asInt(line.dateOfLastCancerStatusDay)
        
        Integer yearCur  = functions.getCurrentYear()
        Integer monthCur = functions.getCurrentMonth()
        Integer dayCur = functions.getCurrentDay()
        
        if (line.dateOfLastCancerStatusYear == null)
            return (line.dateOfLastCancerStatusMonth == null && line.dateOfLastCancerStatusDay == null)
        
        if ((line.dateOfLastCancerStatusMonth == null && line.dateOfLastCancerStatusDay != null) || (month > 12 || (line.dateOfLastCancerStatusMonth != null && month < 1)))
            return false
        
        if (!functions.between(year, 1930, yearCur))
            return false
        
        if (line.dateOfLastCancerStatusMonth == null) //by now year fits and day is null if month is null
            return true
        
        if (year == yearCur && month > monthCur)
            return false
        
        if (line.dateOfLastCancerStatusDay == null) //by now year and month fit
            return true
        
        if (year == yearCur && month == monthCur && day > dayCur)
            return false
        
        Calendar cal = new GregorianCalendar(year, month - 1, 1)
        return cal != null && day <= cal.getActualMaximum(Calendar.DAY_OF_MONTH)
    }

    // ID: IFN2528; NAME: Date of Last Cancer (tumor) Status, Date Last Contact (COC)
    public boolean ifn2528(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfLastCancerStatusYear == null || line.dateOfLastContactYear == null)
            return true
        
        if (line.dateOfLastCancerStatusYear > line.dateOfLastContactYear)
            return false
        
        if (line.dateOfLastCancerStatusYear < line.dateOfLastContactYear || line.dateOfLastCancerStatusMonth == null || line.dateOfLastContactMonth == null)
            return true
        
        if (line.dateOfLastCancerStatusMonth > line.dateOfLastContactMonth)
            return false
        
        if (line.dateOfLastCancerStatusMonth < line.dateOfLastContactMonth || line.dateOfLastCancerStatusDay == null || line.dateOfLastContactDay == null)
            return true
        
        return line.dateOfLastCancerStatusDay <= line.dateOfLastContactDay
    }

    // ID: IFN2529; NAME: Date of Last Cancer (tumor) Status, Date of Diagnosis (COC)
    public boolean ifn2529(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfLastCancerStatusYear == null || line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfLastCancerStatusYear < line.dateOfDiagnosisYear)
            return false
        
        if (line.dateOfLastCancerStatusYear > line.dateOfDiagnosisYear || line.dateOfLastCancerStatusMonth == null || line.dateOfDiagnosisMonth == null)
            return true
        
        if (line.dateOfLastCancerStatusMonth < line.dateOfDiagnosisMonth)
            return false
        
        if (line.dateOfLastCancerStatusMonth > line.dateOfDiagnosisMonth || line.dateOfLastCancerStatusDay == null || line.dateOfDiagnosisDay == null)
            return true
        
        return line.dateOfLastCancerStatusDay >= line.dateOfDiagnosisDay
    }

    // ID: IFN2535; NAME: Sentinel Lymph Nodes Examined, Sentinel Lymph Nodes Positive (COC)
    public boolean ifn2535(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.sentinelLymphNodesExamined == null || line.sentinelLymphNodesPositive == null)
            return true
            
        if (line.sentinelLymphNodesExamined == '00' && line.sentinelLymphNodesPositive != '98')
            return false
        else if (line.sentinelLymphNodesExamined >= '01' && line.sentinelLymphNodesExamined <= '90')
            return line.sentinelLymphNodesPositive == '97' || line.sentinelLymphNodesPositive == '99' || line.sentinelLymphNodesPositive <= line.sentinelLymphNodesExamined    
        else if (line.sentinelLymphNodesExamined == '95') 
            return line.sentinelLymphNodesPositive == '00' || line.sentinelLymphNodesPositive == '95' || line.sentinelLymphNodesPositive == '99'
        else if (line.sentinelLymphNodesExamined == '98') 
            return (line.sentinelLymphNodesPositive >= '00' && line.sentinelLymphNodesPositive <= '90') || line.sentinelLymphNodesPositive == '97' || line.sentinelLymphNodesPositive == '99'
        else if (line.sentinelLymphNodesExamined == '99') 
            return line.sentinelLymphNodesPositive == '99'
        return true
    }

    // ID: IFN2536; NAME: Sentinel Lymph Nodes Examined, Date of Sentinel Lymph Node Biopsy (NAACCR)
    public boolean ifn2536(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || !['00480','00470'].contains(line.schemaId) || line.typeOfReportingSource == '7')
            return true
        
        if (line.dateSentinelLymphNodeBiopsyYear != null)
            return functions.matches(line.sentinelLymphNodesExamined, /(^[0-8][0-9]|9[08]$)/)
        if (line.sentinelLymphNodesExamined == '99' || line.sentinelLymphNodesExamined == null)
            return line.dateSentinelLymphNodeBiopsyYear == null
        
        return true
    }

    // ID: IFN2606; NAME: Date of Last Cancer (tumor) Status, Recurrence Date--1st (COC)
    public boolean ifn2606(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        
        if (line.dateOfLastCancerStatusYear == null || line.recurrenceDate1stYear == null)
            return true
        Integer dolctsYear = functions.asInt(line.dateOfLastCancerStatusYear)
        Integer dolctsMonth = functions.asInt(line.dateOfLastCancerStatusMonth)
        Integer dolctsDay = functions.asInt(line.dateOfLastCancerStatusDay)
        Integer recurYear = functions.asInt(line.recurrenceDate1stYear)
        Integer recurMonth = functions.asInt(line.recurrenceDate1stMonth)
        Integer recurDay = functions.asInt(line.recurrenceDate1stDay)
        
        return ((Integer)((Closure)context.compareDate).call(dolctsYear, dolctsMonth, dolctsDay, recurYear, recurMonth, recurDay)) >= 0
                    
    }

    // ID: IFN2621; NAME: Methylation of O6-Methylguanine-Methyltransferase, Date DX (NAACCR)
    public boolean ifn2621(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.methylationOfO6MGMT != null)
            return false
        
        return  line.methylationOfO6MGMT == null || functions.matches(line.methylationOfO6MGMT, /^[01236789]$/)
    }

    // ID: IFN2622; NAME: Chromosome 1p: Loss of Heterozygosity (LOH), Date DX (NAACCR)
    public boolean ifn2622(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.chromosome1pLossHeterozygosity != null)
            return false
        
        return  line.chromosome1pLossHeterozygosity == null || functions.matches(line.chromosome1pLossHeterozygosity, /^[016789]$/)
    }

    // ID: IFN2623; NAME: Chromosome 19q: Loss of Heterozygosity (LOH), Date DX (NAACCR)
    public boolean ifn2623(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.chromosome19qLossHeterozygosity != null)
            return false
        
        return  line.chromosome19qLossHeterozygosity == null || functions.matches(line.chromosome19qLossHeterozygosity, /^[016789]$/)
    }

    // ID: IFN2624; NAME: FIGO Stage, Schema ID, Required (NAACCR)
    public boolean ifn2624(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        String[] schemaIds = ['00500','09500','00510','00520','09520','00528','00530','00541','00542','00551','00552','00553','00560']
        if (schemaIds.contains(line.schemaId))
            return line.figoStage != null && line.figoStage != '98'
        
        return true
    }

    // ID: IFN2632; NAME: LN Laterality, Date DX (NAACCR)
    public boolean ifn2632(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return line.lnLaterality == null
        
        return line.lnLaterality == null || functions.matches(line.lnLaterality, /^[0-389]$/)
    }

    // ID: IFN2634; NAME: LN Assessment Method Para-Aortic, Date DX (NAACCR)
    public boolean ifn2634(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
            
        if (line.dateOfDiagnosisYear < '2018')
            return line.lnAssessMethodParaaortic == null 
            
        return line.lnAssessMethodParaaortic == null || functions.matches(line.lnAssessMethodParaaortic, /^[0-27-9]$/)
    }

    // ID: IFN2635; NAME: LN Assessment Method Pelvic, Date DX (NAACCR)
    public boolean ifn2635(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
            
        if (line.dateOfDiagnosisYear < '2018')
            return line.lnAssessMethodPelvic == null 
            
        return line.lnAssessMethodPelvic == null || functions.matches(line.lnAssessMethodPelvic, /^[0-27-9]$/)
    }

    // ID: IFN2636; NAME: LN Assessment Method Femoral-Inguinal, Date DX (NAACCR)
    public boolean ifn2636(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
            
        if (line.dateOfDiagnosisYear < '2018')
            return line.lnAssessMethodFemoralInguinal == null 
            
        return line.lnAssessMethodFemoralInguinal == null || functions.matches(line.lnAssessMethodFemoralInguinal, /^[012789]$/)
    }

    // ID: IFN2637; NAME: LN Distant: Mediastinal, Scalene, Date DX (NAACCR)
    public boolean ifn2637(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
            
        if (line.dateOfDiagnosisYear < '2018')
            return line.lnDistantMediastinalScalene == null 
            
        return line.lnDistantMediastinalScalene == null || functions.matches(line.lnDistantMediastinalScalene, /^[012389]$/)
    }

    // ID: IFN2638; NAME: LN Distant Assessment Method, Date DX (NAACCR)
    public boolean ifn2638(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
            
        if (line.dateOfDiagnosisYear < '2018')
            return line.lnDistantAssessMethod == null 
            
        return line.lnDistantAssessMethod == null || functions.matches(line.lnDistantAssessMethod, /^[012789]$/)
    }

    // ID: IFN2639; NAME: Peritoneal Cytology, Date DX (NAACCR)
    public boolean ifn2639(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.peritonealCytology != null)
            return false
        
        return  line.peritonealCytology == null || functions.matches(line.peritonealCytology, /^[0123789]$/)
    }

    // ID: IFN2640; NAME: Number of Positive Pelvic Nodes, Date DX (NAACCR)
    public boolean ifn2640(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
            
        if (line.dateOfDiagnosisYear < '2018')
            return line.numberOfPositivePelvicNodes == null 
            
        return line.numberOfPositivePelvicNodes == null || functions.matches(line.numberOfPositivePelvicNodes, /^\d\d|X[12689]$/)
    }

    // ID: IFN2641; NAME: Number of Positive Para-Aortic Nodes, Date DX (NAACCR)
    public boolean ifn2641(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
            
        if (line.dateOfDiagnosisYear < '2018')
            return line.numberOfPositiveParaAorticNodes == null 
            
        return line.numberOfPositiveParaAorticNodes == null || functions.matches(line.numberOfPositiveParaAorticNodes, /^\d\d|X[12689]$/)
    }

    // ID: IFN2642; NAME: Number of Examined Pelvic Nodes, Date DX (NAACCR)
    public boolean ifn2642(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
            
        if (line.dateOfDiagnosisYear < '2018')
            return line.numberOfExaminedPelvicNodes == null 
            
        return line.numberOfExaminedPelvicNodes == null || functions.matches(line.numberOfExaminedPelvicNodes, /^\d\d|X[12689]$/)
    }

    // ID: IFN2643; NAME: Number of Examined Para-Aortic Nodes, Date DX (NAACCR)
    public boolean ifn2643(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.numberOfExaminedParaAorticNodes != null)
            return false
        
        return  line.numberOfExaminedParaAorticNodes == null || functions.matches(line.numberOfExaminedParaAorticNodes, /^\d\d|X[12689]$/)
    }

    // ID: IFN2644; NAME: CA-125 Pretreatment Interpretation, Date DX (NAACCR)
    public boolean ifn2644(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.ca125PretreatmentInterpretation != null)
            return false
        
        return  line.ca125PretreatmentInterpretation == null || functions.matches(line.ca125PretreatmentInterpretation, /^[0-27-9]$/)
    }

    // ID: IFN2645; NAME: HIV Status, Date DX (NAACCR)
    public boolean ifn2645(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
            
        if (line.dateOfDiagnosisYear < '2018')
            return line.hivStatus == null 
            
        return line.hivStatus == null || functions.matches(line.hivStatus, /^[01789]$/)
    }

    // ID: IFN2646; NAME: JAK2, Date DX (NAACCR)
    public boolean ifn2646(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.jak2 != null)
            return false
        
        return  line.jak2 == null || functions.matches(line.jak2, /^[0-57-9]$/)
    }

    // ID: IFN2647; NAME: NCCN International Prognostic Index (IPI), Date DX (NAACCR)
    public boolean ifn2647(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
            
        if (line.dateOfDiagnosisYear < '2018')
            return line.nccnInternationalPrognosticIndex == null 
            
        return line.nccnInternationalPrognosticIndex == null || functions.matches(line.nccnInternationalPrognosticIndex, /^0[0-8]|X[123489]$/)
    }

    // ID: IFN2648; NAME: LN Size, Date DX (NAACCR)
    public boolean ifn2648(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
            
        if (line.dateOfDiagnosisYear < '2018')
            return line.lnSize == null 
            
        return line.lnSize == null || functions.matches(line.lnSize, /^[1-9]{0,1}\d\.\d|XX\.\d$/)
    }

    // ID: IFN2649; NAME: CEA Pretreatment Lab Value, Date DX (NAACCR)
    public boolean ifn2649(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
            
        if (line.dateOfDiagnosisYear < '2018')
            return line.ceaPretreatmentLabValue == null 
            
        return line.ceaPretreatmentLabValue == null || functions.matches(line.ceaPretreatmentLabValue, /^XXXX\.[17-9]|0\.\d|[1-9]\d{0,3}\.\d$/)
    }

    // ID: IFN2650; NAME: AFP Pretreatment Lab Value, Date DX (NAACCR)
    public boolean ifn2650(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
            
        if (line.dateOfDiagnosisYear < '2018')
            return line.afpPretreatmentLabValue == null 
            
        return line.afpPretreatmentLabValue == null || functions.matches(line.afpPretreatmentLabValue, /^XXXX\.[17-9]|0\.\d|[1-9]\d{0,3}\.\d$/)
    }

    // ID: IFN2651; NAME: Creatinine Pretreatment Lab Value, Date DX (NAACCR)
    public boolean ifn2651(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
            
        if (line.dateOfDiagnosisYear < '2018')
            return line.creatininePretreatmentLabValue == null 
            
        return line.creatininePretreatmentLabValue == null || functions.matches(line.creatininePretreatmentLabValue, /^XX\.[17-9]|[1-9]{0,1}\d\.\d$/)
    }

    // ID: IFN2652; NAME: Bilirubin Pretreatment Total Lab Value, Date DX (NAACCR)
    public boolean ifn2652(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
            
        if (line.dateOfDiagnosisYear < '2018')
            return line.bilirubinPretxTotalLabValue == null 
            
        return line.bilirubinPretxTotalLabValue == null || functions.matches(line.bilirubinPretxTotalLabValue, /^XXX\.[17-9]|0\.\d|[1-9]\d{0,2}\.\d$/)
    }

    // ID: IFN2653; NAME: International Normalized Ratio Prothrombin Time, Date DX (NAACCR)
    public boolean ifn2653(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
            
        if (line.dateOfDiagnosisYear < '2018')
            return line.iNRProthrombinTime == null 
            
        return line.iNRProthrombinTime == null || functions.matches(line.iNRProthrombinTime, /^(\d\.\d)|(X\.[1789])$/)
    }

    // ID: IFN2654; NAME: Percent Necrosis Post Neoadjuvant, Date DX (NAACCR)
    public boolean ifn2654(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
            
        if (line.dateOfDiagnosisYear < '2018')
            return line.percentNecrosisPostNeoadjuvant == null 
            
        return line.percentNecrosisPostNeoadjuvant == null || functions.matches(line.percentNecrosisPostNeoadjuvant, /^XXX\.[289]|100\.0|[1-9]{0,1}\d\.\d$/)
    }

    // ID: IFN2655; NAME: Breslow Tumor Thickness, Date DX (NAACCR)
    public boolean ifn2655(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
            
        if (line.dateOfDiagnosisYear < '2018')
            return line.breslowTumorThickness == null 
            
        return line.breslowTumorThickness == null || functions.matches(line.breslowTumorThickness, /^XX\.[189]|A(X\.0|0\.[1-9]|[1-9]\.\d)|[1-9]{0,1}\d\.\d$/)
    }

    // ID: IFN2656; NAME: LDH Lab Value, Date DX (NAACCR)
    public boolean ifn2656(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
            
        if (line.dateOfDiagnosisYear < '2018')
            return line.ldhPretreatmentLabValue == null 
            
        return line.ldhPretreatmentLabValue == null || functions.matches(line.ldhPretreatmentLabValue, /^XXXXX\.[1789]|(0|[1-9]\d{0,4})\.\d$/)
    }

    // ID: IFN2657; NAME: Mitotic Rate Melanoma, Date DX (NAACCR)
    public boolean ifn2657(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.mitoticRateMelanoma != null)
            return false
        
        return line.mitoticRateMelanoma == null || functions.matches(line.mitoticRateMelanoma, /^\d\d|X[1234789]$/)
    }

    // ID: IFN2658; NAME: AFP Pre-Orchiectomy Lab Value, Date DX (NAACCR)
    public boolean ifn2658(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.afpPreOrchiectomyLabValue != null)
            return false
        
        return line.afpPreOrchiectomyLabValue == null || functions.matches(line.afpPreOrchiectomyLabValue, /^0\.\d|([1-9]\d{0,4}\.\d)|XXXXX\.[17-9]$/)
    }

    // ID: IFN2659; NAME: hCG Pre-Orchiectomy Lab Value, Date DX (NAACCR)
    public boolean ifn2659(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.hcgPreOrchiectomyLabValue != null)
            return false
        
        return line.hcgPreOrchiectomyLabValue == null || functions.matches(line.hcgPreOrchiectomyLabValue, /^0\.\d|([1-9]\d{0,4}\.\d)|XXXXX\.[17-9]$/)
    }

    // ID: IFN2660; NAME: AFP Post-Orchiectomy Lab Value, Date DX (NAACCR)
    public boolean ifn2660(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.afpPostOrchiectomyLabValue != null)
            return false
        
        return line.afpPostOrchiectomyLabValue == null || functions.matches(line.afpPostOrchiectomyLabValue, /^(0|[1-9]\d{0,4})\.\d|XXXXX\.[1789]$/)
    }

    // ID: IFN2661; NAME: hCG Post-Orchiectomy Lab Value, Date DX (NAACCR)
    public boolean ifn2661(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.hcgPostOrchiectomyLabValue != null)
            return false
        
        return line.hcgPostOrchiectomyLabValue == null || functions.matches(line.hcgPostOrchiectomyLabValue, /^(0|[1-9]\d{0,4})\.\d|XXXXX\.[1789]$/)
    }

    // ID: IFN2662; NAME: Measured Basal Diameter, Date DX (NAACCR)
    public boolean ifn2662(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.measuredBasalDiameter != null)
            return false
        
        return line.measuredBasalDiameter == null || functions.matches(line.measuredBasalDiameter, /^([1-9]{0,1}\d|XX)\.\d$/)
    }

    // ID: IFN2663; NAME: Measured Thickness, Date DX (NAACCR)
    public boolean ifn2663(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.measuredThickness != null)
            return false
        
        return line.measuredThickness == null || functions.matches(line.measuredThickness, /^[1-9]{0,1}\d\.\d|XX\.[0-689]$/)
    }

    // ID: IFN2664; NAME: Mitotic Count Uveal Melanoma, Date DX (NAACCR)
    public boolean ifn2664(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        if (line.dateOfDiagnosisYear < '2018')
            return line.mitoticCountUvealMelanoma == null
        return line.mitoticCountUvealMelanoma == null || functions.matches(line.mitoticCountUvealMelanoma, /^[1-9]{0,1}\d\.\d|XX\.[1-4789]$/)
    }

    // ID: IFN2665; NAME: Chromosome 3 Status, Date DX (NAACCR)
    public boolean ifn2665(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        if (line.dateOfDiagnosisYear < '2018')
            return line.chromosome3Status == null
        return line.chromosome3Status == null || functions.matches(line.chromosome3Status, /^[0123789]$/)
    }

    // ID: IFN2666; NAME: Chromosome 8q Status, Date DX (NAACCR)
    public boolean ifn2666(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        if (line.dateOfDiagnosisYear < '2018')
            return line.chromosome8qStatus == null
        return line.chromosome8qStatus == null || functions.matches(line.chromosome8qStatus, /^[01789]$/)
    }

    // ID: IFN2667; NAME: Extravascular Matrix Patterns, Date DX (NAACCR)
    public boolean ifn2667(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        if (line.dateOfDiagnosisYear < '2018')
            return line.extravascularMatrixPatterns == null
        return line.extravascularMatrixPatterns == null || functions.matches(line.extravascularMatrixPatterns, /^[0189]$/)
    }

    // ID: IFN2668; NAME: Microvascular Density, Date DX (NAACCR)
    public boolean ifn2668(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        if (line.dateOfDiagnosisYear < '2018')
            return line.microvascularDensity == null
        return line.microvascularDensity == null || functions.matches(line.microvascularDensity, /^X[1-5789]|\d\d$/)
    }

    // ID: IFN2669; NAME: Adenoid Cystic Basaloid Pattern, Date DX (NAACCR)
    public boolean ifn2669(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.adenoidCysticBasaloidPattern != null)
            return false
        
        return line.adenoidCysticBasaloidPattern == null || functions.matches(line.adenoidCysticBasaloidPattern, /^XXX\.[589]|[1-9]{0,1}\d\.\d|100\.0$/)
    }

    // ID: IFN2670; NAME: Separate Tumor Nodules, Date DX (NAACCR)
    public boolean ifn2670(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.separateTumorNodules != null)
            return false
        
        return line.separateTumorNodules == null || functions.matches(line.separateTumorNodules, /^[0-4789]$/)
    }

    // ID: IFN2671; NAME: Visceral and Parietal Pleural Invasion, Date DX (NAACCR)
    public boolean ifn2671(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.visceralParietalPleuralInvasion != null)
            return false
        
        return line.visceralParietalPleuralInvasion == null || functions.matches(line.visceralParietalPleuralInvasion, /^[045689]$/)
    }

    // ID: IFN2672; NAME: Pleural Effusion, Date DX (NAACCR)
    public boolean ifn2672(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        if (line.dateOfDiagnosisYear < '2018')
            return line.pleuralEffusion == null
        return line.pleuralEffusion == null || functions.matches(line.pleuralEffusion, /^[0123489]$/)
    }

    // ID: IFN2673; NAME: LN Positive Axillary Level I-II, Date DX (NAACCR)
    public boolean ifn2673(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        if (line.dateOfDiagnosisYear < '2018')
            return line.lnPositiveAxillaryLevel1To2 == null
            
        return line.lnPositiveAxillaryLevel1To2 == null || functions.matches(line.lnPositiveAxillaryLevel1To2, /^\d\d|X[15689]$/)
    }

    // ID: IFN2674; NAME: Response to Neoadjuvant Therapy, Date DX (NAACCR)
    public boolean ifn2674(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.responseToNeoadjuvantTherapy != null)
            return false
        
        return line.responseToNeoadjuvantTherapy == null || functions.matches(line.responseToNeoadjuvantTherapy, /^[0-489]$/)
    }

    // ID: IFN2675; NAME: Multigene Signature Method, Date DX (NAACCR)
    public boolean ifn2675(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.multigeneSignatureMethod != null)
            return false
        
        return line.multigeneSignatureMethod == null || functions.matches(line.multigeneSignatureMethod, /^[1-9]$/)
    }

    // ID: IFN2676; NAME: Multigene Signature Results, Date DX (NAACCR)
    public boolean ifn2676(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        if (line.dateOfDiagnosisYear < '2018')
            return line.multigeneSignatureResults == null
        return line.multigeneSignatureResults == null || functions.matches(line.multigeneSignatureResults, /^X[1-47-9]|\d\d$/)
    }

    // ID: IFN2677; NAME: Estrogen Receptor Percent Positive or Range, Date DX (NAACCR)
    public boolean ifn2677(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        if (line.dateOfDiagnosisYear < '2018')
            return line.estrogenReceptorPercntPosOrRange == null
            
        return line.estrogenReceptorPercntPosOrRange == null || functions.matches(line.estrogenReceptorPercntPosOrRange, /^100|0\d\d|R([1-9]0|99)|XX[789]$/)
    }

    // ID: IFN2679; NAME: Progesterone Receptor Percent Positive or Range, Date DX (NAACCR)
    public boolean ifn2679(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.progesteroneRecepPrcntPosOrRange != null)
            return false
        
        if (line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2021' && line.progesteroneRecepPrcntPosOrRange == 'XX6')
            return true
        
        return line.progesteroneRecepPrcntPosOrRange == null || functions.matches(line.progesteroneRecepPrcntPosOrRange, /^100|0\d\d|XX[789]|R([1-9]0|99)$/)
    }

    // ID: IFN2686; NAME: Ki-67, Date DX (NAACCR)
    public boolean ifn2686(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.ki67 != null)
            return false
        
        boolean netSchemas = ['00290', '00301', '00302', '00310', '00320', '00330', '00340'].contains(line.schemaId)
        boolean expandedNetSchemas = ['00290', '00301', '00302', '00310', '00320', '00330', '00340', '09290', '09301', '09302', '09310', '09320', '09330', '09340'].contains(line.schemaId)
        
        if (line.dateOfDiagnosisYear < '2021' && netSchemas && line.ki67 != null)
            return false
        
        if (functions.matches(line.ki67, /^XXX\.[456]$/) && !expandedNetSchemas)
            return false
        
        return line.ki67 == null || functions.matches(line.ki67, /^XXX\.[4-9]|[1-9]{0,1}\d\.\d|100\.0$/)
    }

    // ID: IFN2687; NAME: Oncotype Dx Recurrence Score-Invasive, Date DX (NAACCR)
    public boolean ifn2687(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.oncotypeDxRecurrenceScoreInvasiv != null)
            return false
        
        return line.oncotypeDxRecurrenceScoreInvasiv == null || functions.matches(line.oncotypeDxRecurrenceScoreInvasiv, /^0\d\d|100|XX[4-79]$/)
    }

    // ID: IFN2688; NAME: Oncotype Dx Recurrence Score-DCIS, Date DX (NAACCR)
    public boolean ifn2688(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.oncotypeDxRecurrenceScoreDcis != null)
            return false
        
        return line.oncotypeDxRecurrenceScoreDcis == null || functions.matches(line.oncotypeDxRecurrenceScoreDcis, /^0\d\d|100|XX[6-9]$/)
    }

    // ID: IFN2689; NAME: Oncotype Dx Risk Level-Invasive, Date DX (NAACCR)
    public boolean ifn2689(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        String hist = line.histologicTypeIcdO3
        if ((hist == '8520' || hist == '8519' || hist == '8522') && line.behaviorCodeIcdO3 == '2')
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.oncotypeDxRiskLevelInvasive != null)
            return false
        
        return line.oncotypeDxRiskLevelInvasive == null || functions.matches(line.oncotypeDxRiskLevelInvasive, /^[0-26-9]$/)
    }

    // ID: IFN2690; NAME: Oncotype Dx Risk Level-DCIS, Date DX (NAACCR)
    public boolean ifn2690(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.oncotypeDxRiskLevelDcis != null)
            return false
        
        return line.oncotypeDxRiskLevelDcis == null || functions.matches(line.oncotypeDxRiskLevelDcis, /^[0-26-9]$/)
    }

    // ID: IFN2691; NAME: CEA Pretreatment Interpretation, Date DX (NAACCR)
    public boolean ifn2691(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.ceaPretreatmentInterpretation != null)
            return false
        
        return line.ceaPretreatmentInterpretation == null || functions.matches(line.ceaPretreatmentInterpretation, /^[0-37-9]$/)
    }

    // ID: IFN2692; NAME: Tumor Deposits, Date DX (NAACCR)
    public boolean ifn2692(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        if (line.dateOfDiagnosisYear < '2018')
            return line.tumorDeposits == null
        return line.tumorDeposits == null || functions.matches(line.tumorDeposits, /^X[1289]|\d\d$/)
    }

    // ID: IFN2693; NAME: Circumferential Resection Margin (CRM), Date DX (NAACCR)
    public boolean ifn2693(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.circumferentialResectionMargin != null)
            return false
        
        return line.circumferentialResectionMargin == null || functions.matches(line.circumferentialResectionMargin, /^[1-9]{0,1}\d\.\d|XX\.\d$/)
    }

    // ID: IFN2694; NAME: Microsatellite Instability (MSI), Date DX (NAACCR)
    public boolean ifn2694(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return line.microsatelliteInstability == null
        
        return line.microsatelliteInstability == null || functions.matches(line.microsatelliteInstability, /^[01289]$/)
    }

    // ID: IFN2695; NAME: Perineural Invasion, Date DX (NAACCR)
    public boolean ifn2695(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return line.perineuralInvasion == null
        
        return line.perineuralInvasion == null || functions.matches(line.perineuralInvasion, /^[0189]$/)
    }

    // ID: IFN2696; NAME: KRAS, Date DX (NAACCR)
    public boolean ifn2696(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.kras != null)
            return false
        
        return line.kras == null || functions.matches(line.kras, /^[01234789]$/)
    }

    // ID: IFN2697; NAME: Bone Invasion, Date DX (NAACCR)
    public boolean ifn2697(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.boneInvasion != null)
            return false
        
        return line.boneInvasion == null || functions.matches(line.boneInvasion, /^[0189]$/)
    }

    // ID: IFN2698; NAME: KIT Gene Immunohistochemistry, Date DX (NAACCR)
    public boolean ifn2698(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.kitGeneImmunohistochemistry != null)
            return false
        
        return line.kitGeneImmunohistochemistry == null || functions.matches(line.kitGeneImmunohistochemistry, /^[017-9]$/)
    }

    // ID: IFN2699; NAME: LN Isolated Tumor Cells (ITC), Date DX (NAACCR)
    public boolean ifn2699(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return line.lnIsolatedTumorCells == null
        
        return line.lnIsolatedTumorCells == null || functions.matches(line.lnIsolatedTumorCells, /^[0189]$/)
    }

    // ID: IFN2700; NAME: Profound Immune Suppression, Date DX (NAACCR)
    public boolean ifn2700(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.profoundImmuneSuppression != null)
            return false
        
        return line.profoundImmuneSuppression == null || functions.matches(line.profoundImmuneSuppression, /^[0-689]$/)
    }

    // ID: IFN2701; NAME: Ulceration, Date DX (NAACCR)
    public boolean ifn2701(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return line.ulceration == null
        
        return line.ulceration == null || functions.matches(line.ulceration, /^[0189]$/)
    }

    // ID: IFN2702; NAME: LDH Upper Limits of Normal, Date DX (NAACCR)
    public boolean ifn2702(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        if (line.dateOfDiagnosisYear < '2018')
            return line.ldhUpperLimitsOfNormal == null
        return line.ldhUpperLimitsOfNormal == null || functions.matches(line.ldhUpperLimitsOfNormal, /^\d\d[1-9]|[1-9]\d\d|\d[1-9]\d|XX[89]$/)
    }

    // ID: IFN2705; NAME: EOD Prostate Pathologic Extension, Date DX (SEER)
    public boolean ifn2705(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.prostatePathologicalExtension != null)
            return false
        
        return line.prostatePathologicalExtension == null || functions.matches(line.prostatePathologicalExtension, /^999|([39]5|[03-9]0)0$/)
    }

    // ID: IFN2706; NAME: Gleason Patterns Clinical, Date DX (NAACCR)
    public boolean ifn2706(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.gleasonPatternsClinical != null)
            return false
        
        return line.gleasonPatternsClinical == null || functions.matches(line.gleasonPatternsClinical, /^X[6-9]|[1-5][1-59]$/)
    }

    // ID: IFN2707; NAME: Gleason Score Clinical, Date DX (NAACCR)
    public boolean ifn2707(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.gleasonScoreClinical != null)
            return false
        
        return line.gleasonScoreClinical == null || functions.matches(line.gleasonScoreClinical, /^X[7-9]|0[2-9]|10$/)
    }

    // ID: IFN2708; NAME: Gleason Patterns Pathological, Date DX (NAACCR)
    public boolean ifn2708(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.gleasonPatternsPathological != null)
            return false
        
        return line.gleasonPatternsPathological == null || functions.matches(line.gleasonPatternsPathological, /^X[6-9]|[1-5][1-59]$/)
    }

    // ID: IFN2709; NAME: Gleason Score Pathological, Date DX (NAACCR)
    public boolean ifn2709(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.gleasonScorePathological != null)
            return false
        
        return line.gleasonScorePathological == null || functions.matches(line.gleasonScorePathological, /^X[7-9]|0[2-9]|10$/)
    }

    // ID: IFN2710; NAME: Gleason Tertiary Pattern, Date DX (NAACCR)
    public boolean ifn2710(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.gleasonTertiaryPattern != null)
            return false
        
        return line.gleasonTertiaryPattern == null || functions.matches(line.gleasonTertiaryPattern, /^X[7-9]|[1-5]0$/)
    }

    // ID: IFN2711; NAME: Number of Cores Positive, Date DX (NAACCR)
    public boolean ifn2711(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.numberOfCoresPositive != null)
            return false
        
        return line.numberOfCoresPositive == null || functions.matches(line.numberOfCoresPositive, /^X[16-9]|\d\d$/)
    }

    // ID: IFN2712; NAME: Number of Cores Examined, Date DX (NAACCR)
    public boolean ifn2712(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.numberOfCoresExamined != null)
            return false
        
        return line.numberOfCoresExamined == null || functions.matches(line.numberOfCoresExamined, /^X[16-9]|0[1-9]|[1-9]\d$/)
    }

    // ID: IFN2713; NAME: AFP Pre-Orchiectomy Range, Date DX (NAACCR)
    public boolean ifn2713(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.afpPreOrchiectomyRange != null)
            return false
        
        return line.afpPreOrchiectomyRange == null || functions.matches(line.afpPreOrchiectomyRange, /^[0-47-9]$/)
    }

    // ID: IFN2714; NAME: hCG Pre-Orchiectomy Range, Date DX (NAACCR)
    public boolean ifn2714(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.hcgPreOrchiectomyRange != null)
            return false
        
        return line.hcgPreOrchiectomyRange == null || functions.matches(line.hcgPreOrchiectomyRange, /^[0-47-9]$/)
    }

    // ID: IFN2715; NAME: LDH Pre-Orchiectomy Range, Date DX (NAACCR)
    public boolean ifn2715(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.ldhPreOrchiectomyRange != null)
            return false
        
        return line.ldhPreOrchiectomyRange == null || functions.matches(line.ldhPreOrchiectomyRange, /^[0-47-9]$/)
    }

    // ID: IFN2716; NAME: AFP Post-Orchiectomy Range, Date DX (NAACCR)
    public boolean ifn2716(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.afpPostOrchiectomyRange != null)
            return false
        
        return line.afpPostOrchiectomyRange == null || functions.matches(line.afpPostOrchiectomyRange, /^[0-57-9]$/)
    }

    // ID: IFN2717; NAME: hCG Post-Orchiectomy Range, Date DX (NAACCR)
    public boolean ifn2717(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.hcgPostOrchiectomyRange != null)
            return false
        
        return line.hcgPostOrchiectomyRange == null || functions.matches(line.hcgPostOrchiectomyRange, /^[0-457-9]$/)
    }

    // ID: IFN2718; NAME: LDH Post-Orchiectomy Range, Date DX (NAACCR)
    public boolean ifn2718(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.ldhPostOrchiectomyRange != null)
            return false
        
        return line.ldhPostOrchiectomyRange == null || functions.matches(line.ldhPostOrchiectomyRange, /^[0-457-9]$/)
    }

    // ID: IFN2719; NAME: AFP Pretreatment Interpretation, Date DX (NAACCR)
    public boolean ifn2719(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.afpPretreatmentInterpretation != null)
            return false
        
        return line.afpPretreatmentInterpretation == null || functions.matches(line.afpPretreatmentInterpretation, /^[0-27-9]$/)
    }

    // ID: IFN2720; NAME: Fibrosis Score, Date DX (NAACCR)
    public boolean ifn2720(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return line.fibrosisScore == null
        
        return line.fibrosisScore == null || functions.matches(line.fibrosisScore, /^[01789]$/)
    }

    // ID: IFN2721; NAME: Creatinine Pretreatment Unit of Measure, Date DX (NAACCR)
    public boolean ifn2721(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return line.creatininePretxUnitOfMeasure == null
        
        return line.creatininePretxUnitOfMeasure == null || functions.matches(line.creatininePretxUnitOfMeasure, /^[127-9]$/)
    }

    // ID: IFN2722; NAME: Bilirubin Pretreatment Unit of Measure, Date DX (NAACCR)
    public boolean ifn2722(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return  line.bilirubinPretxUnitOfMeasure == null
        
        return  line.bilirubinPretxUnitOfMeasure == null || functions.matches(line.bilirubinPretxUnitOfMeasure, /^[127-9]$/)
    }

    // ID: IFN2725; NAME: LN Head and Neck Levels I-III, Date DX (NAACCR)
    public boolean ifn2725(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return  line.lnHeadAndNeckLevels1To3 == null
        
        return  line.lnHeadAndNeckLevels1To3 == null || functions.matches(line.lnHeadAndNeckLevels1To3, /^\d$/)
    }

    // ID: IFN2726; NAME: LN Head and Neck Levels IV-V, Date DX (NAACCR)
    public boolean ifn2726(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return  line.lnHeadAndNeckLevels4To5 == null
        
        return  line.lnHeadAndNeckLevels4To5 == null || functions.matches(line.lnHeadAndNeckLevels4To5, /^[0-389]$/)
    }

    // ID: IFN2727; NAME: LN Head and Neck Levels VI-VII, Date DX (NAACCR)
    public boolean ifn2727(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return  line.lnHeadAndNeckLevels6To7 == null
        
        return  line.lnHeadAndNeckLevels6To7 == null || functions.matches(line.lnHeadAndNeckLevels6To7, /^[0-389]$/)
    }

    // ID: IFN2728; NAME: LN Head and Neck Other, Date DX (NAACCR)
    public boolean ifn2728(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return  line.lnHeadAndNeckOther == null
        
        return  line.lnHeadAndNeckOther == null || functions.matches(line.lnHeadAndNeckOther, /^\d$/)
    }

    // ID: IFN2729; NAME: Extranodal Extension Head and Neck Clinical, Date DX (NAACCR)
    public boolean ifn2729(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return  line.extranodalExtensionHeadNeckClin == null
        
        return  line.extranodalExtensionHeadNeckClin == null || functions.matches(line.extranodalExtensionHeadNeckClin, /^[0-247-9]$/)
    }

    // ID: IFN2730; NAME: Extranodal Extension Head and Neck Pathological, Date DX (NAACCR)
    public boolean ifn2730(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return  line.extranodalExtensionHeadNeckPath == null
        
        return  line.extranodalExtensionHeadNeckPath == null || functions.matches(line.extranodalExtensionHeadNeckPath, /^(\d\.\d)|(X\.[1-47-9])$/)
    }

    // ID: IFN2731; NAME: High Risk Histologic Features, Date DX (NAACCR)
    public boolean ifn2731(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return  line.highRiskHistologicFeatures == null
        
        return  line.highRiskHistologicFeatures == null || functions.matches(line.highRiskHistologicFeatures, /^[0-689]$/)
    }

    // ID: IFN2732; NAME: Esophagus and EGJ Tumor Epicenter, Date DX (NAACCR)
    public boolean ifn2732(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return  line.esophagusAndEgjTumorEpicenter == null
        
        return  line.esophagusAndEgjTumorEpicenter == null || functions.matches(line.esophagusAndEgjTumorEpicenter, /^[0-29]$/)
    }

    // ID: IFN2733; NAME: Estrogen Receptor Summary, Date DX (NAACCR)
    public boolean ifn2733(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return  line.estrogenReceptorSummary == null
        
        return  line.estrogenReceptorSummary == null || functions.matches(line.estrogenReceptorSummary, /^[0179]$/)
    }

    // ID: IFN2734; NAME: Progesterone Receptor Summary, Date DX (NAACCR)
    public boolean ifn2734(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        if (line.dateOfDiagnosisYear < '2018')
            return line.progesteroneRecepSummary == null
        return line.progesteroneRecepSummary == null || functions.matches(line.progesteroneRecepSummary, /^[0179]$/)
    }

    // ID: IFN2735; NAME: HER2 Overall Summary, Date DX (NAACCR)
    public boolean ifn2735(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' || (line.dateOfDiagnosisYear < '2021' && ['00161', '00169', '00170'].contains(line.schemaId)))
            return line.her2OverallSummary == null
        
        if (line.her2OverallSummary == null || functions.matches(line.her2OverallSummary, /^[0179]$/))
            return true
        
        return ['00161', '00169', '00170'].contains(line.schemaId) && line.her2OverallSummary == '8'
    }

    // ID: IFN2736; NAME: Gestational Trophoblastic Prognostic Scoring Index, Date DX (NAACCR)
    public boolean ifn2736(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return line.gestationalTrophoblasticPxIndex == null
        
        return line.gestationalTrophoblasticPxIndex == null || functions.matches(line.gestationalTrophoblasticPxIndex, /^[01]\d|2[0-5]|X9$/)
    }

    // ID: IFN2737; NAME: PSA (Prostatic Specific Antigen) Lab Value, Date DX (NAACCR)
    public boolean ifn2737(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.psaLabValue != null)
            return false
        
        return  line.psaLabValue == null || functions.matches(line.psaLabValue, /^XXX\.[12379]|[1-9]\d\d\.\d|[1-9]\d\.\d|[1-9]\.\d|0\.[1-9]$/)
    }

    // ID: IFN2738; NAME: S Category Clinical, Date DX (NAACCR)
    public boolean ifn2738(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.sCategoryClinical != null)
            return false
        
        return  line.sCategoryClinical == null || functions.matches(line.sCategoryClinical, /^[0-39]$/)
    }

    // ID: IFN2739; NAME: S Category Pathological, Date DX (NAACCR)
    public boolean ifn2739(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.sCategoryPathological != null)
            return false
        
        return  line.sCategoryPathological == null || functions.matches(line.sCategoryPathological, /^[0-359]$/)
    }

    // ID: IFN2740; NAME: Heritable Trait, Date DX (NAACCR)
    public boolean ifn2740(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.heritableTrait != null)
            return false
        
        return  line.heritableTrait == null || functions.matches(line.heritableTrait, /^[0179]$/)
    }

    // ID: IFN2741; NAME: Adenopathy, Date DX (NAACCR)
    public boolean ifn2741(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return line.adenopathy == null
        
        if (line.primarySite == 'C421')
            return line.adenopathy == null || functions.matches(line.adenopathy, /^[019]$/)
        else
            return line.adenopathy == null || line.adenopathy == '5'
            
    }

    // ID: IFN2742; NAME: Anemia, Date DX (NAACCR)
    public boolean ifn2742(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return line.anemia == null
        
        if (line.primarySite != 'C421')
            return line.anemia == null || line.anemia == '5'
        
        else
            return line.anemia == null || functions.matches(line.anemia, /^[01679]$/)
    }

    // ID: IFN2743; NAME: Lymphocytosis, Date DX (NAACCR)
    public boolean ifn2743(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.lymphocytosis != null)
            return false
        
        if (line.primarySite == 'C421')
            return  line.lymphocytosis == null || functions.matches(line.lymphocytosis, /^[01679]$/)
        
        else
            return  line.lymphocytosis == null || line.lymphocytosis == '5'
    }

    // ID: IFN2744; NAME: Organomegaly, Date DX (NAACCR)
    public boolean ifn2744(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return line.organomegaly == null
        if (line.primarySite == 'C421')
            return line.organomegaly == null || functions.matches(line.organomegaly, /^[019]$/)
        else
            return line.organomegaly == null || line.organomegaly == '5'
    }

    // ID: IFN2745; NAME: Thrombocytopenia, Date DX (NAACCR)
    public boolean ifn2745(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return line.thrombocytopenia == null
        else if (line.primarySite == 'C421')
            return line.thrombocytopenia == null || functions.matches(line.thrombocytopenia, /^[01679]$/)
        else
            return line.thrombocytopenia == null || line.thrombocytopenia == '5'
    }

    // ID: IFN2746; NAME: Peripheral Blood Involvement, Date DX (NAACCR)
    public boolean ifn2746(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return line.peripheralBloodInvolvement == null
        
        return line.peripheralBloodInvolvement == null || functions.matches(line.peripheralBloodInvolvement, /^[0-79]$/)
    }

    // ID: IFN2747; NAME: Serum Albumin Pretreatment Level, Date DX (NAACCR)
    public boolean ifn2747(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return line.serumAlbuminPretreatmentLevel == null
        
        return line.serumAlbuminPretreatmentLevel == null || functions.matches(line.serumAlbuminPretreatmentLevel, /^[01579]$/)
    }

    // ID: IFN2748; NAME: Serum Beta-2 Microglobulin Pretreatment Level, Date DX (NAACCR)
    public boolean ifn2748(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return line.serumBeta2MicroglobulinPretxLvl == null
        
        return line.serumBeta2MicroglobulinPretxLvl == null || functions.matches(line.serumBeta2MicroglobulinPretxLvl, /^[0-2579]$/)
    }

    // ID: IFN2749; NAME: High Risk Cytogenetics, Date DX (NAACCR)
    public boolean ifn2749(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        if (line.dateOfDiagnosisYear < '2018')
            return line.highRiskCytogenetics == null
        return line.highRiskCytogenetics == null || functions.matches(line.highRiskCytogenetics, /^[01579]$/)
    }

    // ID: IFN2750; NAME: LDH Level, Date DX (NAACCR)
    public boolean ifn2750(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return line.ldhPretreatmentLevel == null
        if (line.ldhPretreatmentLevel == '5')
            return line.schemaId == '00821'
        else
            return line.ldhPretreatmentLevel == null || functions.matches(line.ldhPretreatmentLevel, /^[0179]$/)
    }

    // ID: IFN2760; NAME: Schema Discriminator 1, Date DX (NAACCR)
    public boolean ifn2760(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.schemaDiscriminator1 != null)
            return false
        
        return  line.schemaDiscriminator1 == null || functions.matches(line.schemaDiscriminator1, /^[0-79]$/)
    }

    // ID: IFN2802; NAME: Grade Clin,Path,PostTX, Date of Diagnosis (NAACCR)
    public boolean ifn2802(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return line.gradeClinical == null && line.gradePathological == null && line.gradePostTherapy == null
        
        return line.gradeClinical != null && line.gradePathological != null
    }

    // ID: IFN2803; NAME: Grade, Schema ID (NAACCR)
    public boolean ifn2803(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null)
            return true
        
        if (line.gradeClinical == null && line.gradePathological == null)
            return true
        
        List validCodes = (List)((Map)context.IFN2803_Table).get(line.schemaId)
        if (validCodes == null)
            return true
        
        boolean isClinValid = line.gradeClinical == null || validCodes.contains(line.gradeClinical)
        boolean isPathValid = line.gradePathological == null || validCodes.contains(line.gradePathological)
        boolean isPostTxValid = line.gradePostTherapy == null || validCodes.contains(line.gradePostTherapy)
        boolean isPostTxClinValid = line.gradePostTherapyClin == null || validCodes.contains(line.gradePostTherapyClin)
        
        return isClinValid && isPathValid && isPostTxValid && isPostTxClinValid
    }

    // ID: IFN2811; NAME: CoC Accredited Flag, Date DX, Type Report Source (NAACCR)
    public boolean ifn2811(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018')
            return true
        
        if (line.typeOfReportingSource != '7')
            return line.cocAccreditedFlag != null
        
        return line.cocAccreditedFlag == null
    }

    // ID: IFN2814; NAME: _SYS Schema ID, AJCC ID (NAACCR)
    public boolean ifn2814(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.ajccId == null || line.schemaId == null || line.dateOfDiagnosisYear == null)
            return true
        return ((List)(((Map)context.SchemaIdAjccIdTable).getOrDefault(line.schemaId, []))).contains(line.ajccId)
    }

    // ID: IFN2816; NAME: _SYS Schema ID (NAACCR)
    public boolean ifn2816(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.schemaId == null)
            return true
        
        return ((Map)context.SchemaIdAjccIdTable).containsKey(line.schemaId)
    }

    // ID: IFN2822; NAME: _SYS AJCC ID, Date of Diagnosis (NAACCR)
    public boolean ifn2822(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
         if (line.dateOfDiagnosisYear == null)
                    return true
        if (line.dateOfDiagnosisYear < '2018' && line.ajccId != null)
            return false
        else if (line.dateOfDiagnosisYear >= '2018' && line.ajccId == null)
            return false
        else if (line.dateOfDiagnosisYear < '2021' && line.ajccId == '9001')
            return false
        else if (line.dateOfDiagnosisYear < '2023' && functions.matches(line.ajccId, /^(900[2-5])$/))
            return false
        else if (line.dateOfDiagnosisYear < '2024' && functions.matches(line.ajccId, /^(900[6-9]|901[0-2])$/))
            return false
        else if (line.dateOfDiagnosisYear >= '2021' && line.ajccId == '52')
            return false
        else if (line.dateOfDiagnosisYear >= '2023' && functions.matches(line.ajccId, /^(19|21|72)$/))
            return false
        else if (line.dateOfDiagnosisYear >= '2024' && functions.matches(line.ajccId, /^(29|3[0-4]|50)$/))
            return false
        return true
    }

    // ID: IFN2823; NAME: _SYS Schema ID, Date of Diagnosis (NAACCR)
    public boolean ifn2823(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return line.schemaId == null
        else if (line.schemaId == null)
            return false
        
        if (line.schemaId == '00520')
            return line.dateOfDiagnosisYear >= '2018' && line.dateOfDiagnosisYear <= '2020'
        
        if ((line.schemaId == '09520' || line.schemaId == '00528') && line.dateOfDiagnosisYear < '2021')
            return false
        
        if (line.dateOfDiagnosisYear < '2023') {
            if (functions.matches(line.schemaId, /^0972[1234]|09190|09210$/))
                return false
        }
        else if (functions.matches(line.schemaId, /^0072[123]|00190|00210$/))
            return false
        
        return true
    }

    // ID: IFN2827; NAME: Derived Summary Stage 2018, Date of DX (SEER)
    public boolean ifn2827(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.registryId == '0000001563' && line.dateOfDiagnosisYear == '2018')
            return true
        if ('0000001565' == line.registryId && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if ('0000001566' == line.registryId && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return line.derivedSummaryStage2018 == null
        
        return line.derivedSummaryStage2018 != null
    }

    // ID: IFN2833; NAME: Sentinel Lymph Nodes Examined, Regional Nodes Examined (COC)
    public boolean ifn2833(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.sentinelLymphNodesExamined == null || line.regionalNodesExamined == null)
            return true
            
        if (line.regionalNodesExamined == '00')
            return line.sentinelLymphNodesExamined == '00'
        else if (line.regionalNodesExamined == '95')
            return line.sentinelLymphNodesExamined == '95' || line.sentinelLymphNodesExamined == '00'
        else if (line.sentinelLymphNodesExamined >= '01' && line.sentinelLymphNodesExamined <= '90') 
            return ((line.regionalNodesExamined >= '01' && line.regionalNodesExamined <= '90' && line.sentinelLymphNodesExamined <= line.regionalNodesExamined) || line.regionalNodesExamined >= '96' && line.regionalNodesExamined <= '98')
        else if (line.sentinelLymphNodesExamined == '98') 
            return ((line.regionalNodesExamined >= '01' && line.regionalNodesExamined <= '90') || (line.regionalNodesExamined >= '96' && line.regionalNodesExamined <= '98'))     
        else if (line.sentinelLymphNodesExamined == '95')
            return ((line.regionalNodesExamined >= '01' && line.regionalNodesExamined <= '90') || (line.regionalNodesExamined >= '95' && line.regionalNodesExamined <= '98'))
        
        return true
    }

    // ID: IFN2834; NAME: Sentinel Lymph Nodes Positive, Regional Nodes Positive (COC)
    public boolean ifn2834(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.sentinelLymphNodesPositive == null || line.regionalNodesPositive == null)
            return true
        
        if (line.regionalNodesPositive == '00')
            return line.sentinelLymphNodesPositive == '00' || line.sentinelLymphNodesPositive == '98'
        else if (line.regionalNodesPositive == '95')
            return line.sentinelLymphNodesPositive == '95' || line.sentinelLymphNodesPositive == '00' || line.sentinelLymphNodesPositive == '98'
        else if (line.sentinelLymphNodesPositive >= '01' && line.sentinelLymphNodesPositive <= '90')
            return (line.regionalNodesPositive >= '01' && line.regionalNodesPositive <= '90' && line.sentinelLymphNodesPositive <= line.regionalNodesPositive) || line.regionalNodesPositive == '97'
        else if (line.sentinelLymphNodesPositive == '95')
            return functions.matches(line.regionalNodesPositive, /^0[1-9]|[1-8]\d|9[057]$/)
        else if (line.sentinelLymphNodesPositive == '97')
            return functions.matches(line.regionalNodesPositive, /^0[1-9]|[1-8]\d|9[07]$/)
        
        return true
    }

    // ID: IFN2836; NAME: Sentinel Lymph Nodes Ex, Reg Nodes Ex, Date RLN Dissection (NAACCR)
    public boolean ifn2836(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.sentinelLymphNodesExamined == null || line.regionalNodesExamined == null)
            return true
        
        if (line.schemaId != '00470' && line.schemaId != '00480')
            return true
        
        String sentinelNodes = line.sentinelLymphNodesExamined
        String regionalNodes = line.regionalNodesExamined
        if (sentinelNodes == regionalNodes && sentinelNodes != '00' && sentinelNodes != '95' && sentinelNodes != '98' && sentinelNodes != '99')
            return line.dateRegionalLNDissectionYear == null
        
        return true
    }

    // ID: IFN2838; NAME: CS Items, DX Post 2017 (CS)
    public boolean ifn2838(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear <= '2017')
            return true
            
        if (line.csTumorSize != null || line.csExtension != null || line.csTumorSizeExtEval != null || line.csLymphNodes != null || 
            line.csLymphNodesEval != null || line.csMetsAtDx != null || line.csMetsAtDxBone != null || line.csMetsAtDxBrain != null || 
            line.csMetsAtDxLiver != null || line.csMetsAtDxLung != null || line.csMetsEval != null ||
            line.csSiteSpecificFactor1 != null || line.csSiteSpecificFactor2 != null || line.csSiteSpecificFactor3 != null ||
            line.csSiteSpecificFactor4 != null || line.csSiteSpecificFactor5 != null || line.csSiteSpecificFactor6 != null ||
            line.csSiteSpecificFactor7 != null || line.csSiteSpecificFactor8 != null || line.csSiteSpecificFactor9 != null ||
            line.csSiteSpecificFactor10 != null || line.csSiteSpecificFactor11 != null || line.csSiteSpecificFactor12 != null || 
            line.csSiteSpecificFactor13 != null || line.csSiteSpecificFactor14 != null ||line.csSiteSpecificFactor15 != null ||
            line.csSiteSpecificFactor16 != null || line.csSiteSpecificFactor17 != null || line.csSiteSpecificFactor18 != null || 
            line.csSiteSpecificFactor19 != null || line.csSiteSpecificFactor20 != null || line.csSiteSpecificFactor21 != null || 
            line.csSiteSpecificFactor22 != null || line.csSiteSpecificFactor23 != null || line.csSiteSpecificFactor24 != null || 
            line.csSiteSpecificFactor25 != null)
           return false
        
        return true
    }

    // ID: IFN2839; NAME: Derived CS Items, DX Post 2017 (NAACCR)
    public boolean ifn2839(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear <= '2017')
            return true
            
        if (line.derivedAjcc6T != null || line.derivedAjcc6TDescript != null || line.derivedAjcc6N != null || line.derivedAjcc6NDescript != null || 
            line.derivedAjcc6M != null || line.derivedAjcc6MDescript != null || line.derivedAjcc6StageGrp != null ||
            line.derivedAjcc7T != null || line.derivedAjcc7TDescript != null || line.derivedAjcc7N != null ||
            line.derivedAjcc7NDescript != null || line.derivedAjcc7M != null || line.derivedAjcc7MDescript != null ||
            line.derivedAjcc7StageGrp != null || line.derivedSs1977 != null || line.derivedSs2000 != null ||
            line.derivedSs2000Flag != null || line.derivedSs1977Flag != null || line.derivedAjccFlag != null ||
            line.csVersionInputOriginal != null || line.csVersionInputCurrent != null || line.csVersionDerived != null)
           return false
        
        return true
    }

    // ID: IFN2855; NAME: Breslow Tumor Thickness, Schema ID, Required (NAACCR)
    public boolean ifn2855(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
            
        return line.schemaId != '00470' || (line.breslowTumorThickness != null && line.breslowTumorThickness != 'XX.8')
    }

    // ID: IFN2856; NAME: Esophagus and EGJ Tumor Epicenter, Schema ID, Required (NAACCR)
    public boolean ifn2856(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (['0000001565','0000001566'].contains(line.registryId) && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00161' || line.esophagusAndEgjTumorEpicenter != null
    }

    // ID: IFN2861; NAME: Heritable Trait, Schema ID, Required (NAACCR)
    public boolean ifn2861(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear <= '2017' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (line.schemaId == '00680')
            return line.heritableTrait != null
        
        return true
    }

    // ID: IFN2869; NAME: Pleural Effusion, Schema ID, Required (NAACCR)
    public boolean ifn2869(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (line.schemaId == '00370')
            return line.pleuralEffusion != null && line.pleuralEffusion != '8'
        return true
    }

    // ID: IFN2870; NAME: Profound Immune Suppression, Schema ID, Required (NAACCR)
    public boolean ifn2870(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear <= '2017' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00460' || (line.profoundImmuneSuppression != null && line.profoundImmuneSuppression != '8')
    }

    // ID: IFN2871; NAME: Separate Tumor Nodules, Schema ID, Required (NAACCR)
    public boolean ifn2871(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear <= '2017' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00360' || (line.separateTumorNodules != null && line.separateTumorNodules != '8')
    }

    // ID: IFN2872; NAME: Visceral and Parietal Pleural Invasion, Schema ID, Required (NAACCR)
    public boolean ifn2872(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear <= '2017' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00360' || (line.visceralParietalPleuralInvasion != null && line.visceralParietalPleuralInvasion != '8')
    }

    // ID: IFN2873; NAME: Adenopathy, Schema ID, Required (NAACCR)
    public boolean ifn2873(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear <= '2017' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00795' || line.adenopathy != null
    }

    // ID: IFN2874; NAME: Anemia, Schema ID, Required (NAACCR)
    public boolean ifn2874(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear <= '2017' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00795' || line.anemia != null
    }

    // ID: IFN2875; NAME: Bone Invasion, Schema ID, Required (NAACCR)
    public boolean ifn2875(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear <= '2017' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return !functions.matches(line.schemaId, /^004([014]0|5[09]|2[12])$/) || (line.boneInvasion != null && line.boneInvasion != '8')
    }

    // ID: IFN2877; NAME: Estrogen Receptor Summary, Schema ID, Required (NAACCR)
    public boolean ifn2877(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear <= '2017' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        
        return line.schemaId != '00480' || line.estrogenReceptorSummary != null
    }

    // ID: IFN2879; NAME: FIGO Stage, Date DX (NAACCR)
    public boolean ifn2879(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.figoStage != null)
            return false
        
        if (line.dateOfDiagnosisYear < '2021' && line.figoStage == '1B3')
            return false
        
        List validValues = (List)context.FigoStageList
        return  line.figoStage == null || validValues.contains(line.figoStage)
    }

    // ID: IFN2880; NAME: FIGO Stage, Gynecologic, Schema ID (NAACCR)
    public boolean ifn2880(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.figoStage == null || !functions.matches(line.schemaId, /^005([01236]0|4[12]|5[123]|28)|095[02]0$/))
            return true
        
        Map> valueMap = (Map>)context.IFN2880_Table
        return valueMap.get(line.schemaId).contains(line.figoStage)
    }

    // ID: IFN2881; NAME: Gestational Trophoblastic Prognostic Scoring Index, Schema ID, Required (NAACCR)
    public boolean ifn2881(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00560' || line.gestationalTrophoblasticPxIndex != null
    }

    // ID: IFN2883; NAME: Gleason Patterns Clinical, Schema ID, Required (NAACCR)
    public boolean ifn2883(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00580' || (line.gleasonPatternsClinical != null && line.gleasonPatternsClinical != 'X8')
    }

    // ID: IFN2884; NAME: Gleason Patterns Pathological, Schema ID, Required (NAACCR)
    public boolean ifn2884(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00580' || (line.gleasonPatternsPathological != null && line.gleasonPatternsPathological != 'X8')
    }

    // ID: IFN2889; NAME: HER2 Overall Summary, Breast, Schema ID, Required (NAACCR)
    public boolean ifn2889(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        
        return  line.schemaId != '00480' || line.her2OverallSummary != null
    }

    // ID: IFN2890; NAME: Ipsilateral Adrenal Gland Involvement, Date DX (NAACCR)
    public boolean ifn2890(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return line.ipsilateralAdrenalGlandInvolve == null
        
        return line.ipsilateralAdrenalGlandInvolve == null || functions.matches(line.ipsilateralAdrenalGlandInvolve, /^[0-489]$/)
    }

    // ID: IFN2891; NAME: Ipsilateral Adrenal Gland Involvement, Schema ID, Required (NAACCR)
    public boolean ifn2891(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00600' || (line.ipsilateralAdrenalGlandInvolve != null && line.ipsilateralAdrenalGlandInvolve != '8')
    }

    // ID: IFN2893; NAME: Invasion Beyond Capsule, Date DX (NAACCR)
    public boolean ifn2893(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return line.invasionBeyondCapsule == null
        
        return line.invasionBeyondCapsule == null || functions.matches(line.invasionBeyondCapsule, /^[0-589]$/)
    }

    // ID: IFN2894; NAME: Invasion Beyond Capsule, Schema ID, Required (NAACCR)
    public boolean ifn2894(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00600' || (line.invasionBeyondCapsule != null && line.invasionBeyondCapsule != '8')
    }

    // ID: IFN2895; NAME: LDH Level, Myeloma, Schema ID, Required (NAACCR)
    public boolean ifn2895(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        
        if (line.schemaId == '00821') {
            if (line.schemaDiscriminator1 == '0')
                return line.ldhPretreatmentLevel != null && line.ldhPretreatmentLevel != '5'
            else if (line.schemaDiscriminator1 == '1' || line.schemaDiscriminator1 == '9')
                return line.ldhPretreatmentLevel == '5'
        }
        
        return true
    }

    // ID: IFN2897; NAME: LN Head and Neck Levels I-III, Schema ID, Required (NAACCR)
    public boolean ifn2897(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return (line.schemaId != '00060' && line.schemaId != '00140') || (line.lnHeadAndNeckLevels1To3 != null && line.lnHeadAndNeckLevels1To3 != '8')
    }

    // ID: IFN2898; NAME: LN Head and Neck Levels IV-V, Schema ID, Required (NAACCR)
    public boolean ifn2898(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return (line.schemaId != '00060' && line.schemaId != '00140') || (line.lnHeadAndNeckLevels4To5 != null && line.lnHeadAndNeckLevels4To5 != '8')
    }

    // ID: IFN2899; NAME: LN Head and Neck Levels VI-VII, Schema ID, Required (NAACCR)
    public boolean ifn2899(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return (line.schemaId != '00060' && line.schemaId != '00140') || (line.lnHeadAndNeckLevels6To7 != null && line.lnHeadAndNeckLevels6To7 != '8')
    }

    // ID: IFN2900; NAME: LN Head and Neck Other, Schema ID, Required (NAACCR)
    public boolean ifn2900(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return (line.schemaId != '00060' && line.schemaId != '00140') || (line.lnHeadAndNeckOther != null && line.lnHeadAndNeckOther != '8')
    }

    // ID: IFN2901; NAME: LN Isolated Tumor Cells (ITC), Schema ID, Required (NAACCR)
    public boolean ifn2901(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00460' || (line.lnIsolatedTumorCells != null && line.lnIsolatedTumorCells != '8')
    }

    // ID: IFN2902; NAME: LN Laterality, Schema ID, Required (NAACCR)
    public boolean ifn2902(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear <= '2017' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (line.schemaId == '00500' || line.schemaId == '09500')
           return line.lnLaterality != '8' && line.lnLaterality != null 
        
        return true
    }

    // ID: IFN2903; NAME: LN Positive Axillary Level I-II, Schema ID, Required (NAACCR)
    public boolean ifn2903(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear <= '2017' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00480' || (line.lnPositiveAxillaryLevel1To2 != 'X8' && line.lnPositiveAxillaryLevel1To2 != null)
    }

    // ID: IFN2904; NAME: Lymphocytosis, Schema ID, Required (NAACCR)
    public boolean ifn2904(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear <= '2017' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (line.schemaId == '00795')
           return line.lymphocytosis != null 
        
        return true
    }

    // ID: IFN2905; NAME: Major Vein Involvement, Date DX (NAACCR)
    public boolean ifn2905(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return line.majorVeinInvolvement == null
        
        return line.majorVeinInvolvement == null || functions.matches(line.majorVeinInvolvement, /^[0-489]$/)
    }

    // ID: IFN2906; NAME: Major Vein Involvement, Schema ID, Required (NAACCR)
    public boolean ifn2906(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear <= '2017' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00600' || (line.majorVeinInvolvement != '8' && line.majorVeinInvolvement != null)
    }

    // ID: IFN2907; NAME: Mitotic Rate Melanoma, Schema ID, Required (NAACCR)
    public boolean ifn2907(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear <= '2017' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (line.schemaId == '00470')
           return line.mitoticRateMelanoma != 'X8' && line.mitoticRateMelanoma != null 
        
        return true
    }

    // ID: IFN2908; NAME: Multigene Signature Method, Schema ID, Required (NAACCR)
    public boolean ifn2908(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear <= '2017' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00480' || (line.multigeneSignatureMethod != '8' && line.multigeneSignatureMethod != null)
    }

    // ID: IFN2909; NAME: Multigene Signature Results, Schema ID, Required (NAACCR)
    public boolean ifn2909(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' ||  line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (line.schemaId == '00480')
            return line.multigeneSignatureResults != null && line.multigeneSignatureResults != 'X8'
        return true
    }

    // ID: IFN2910; NAME: Number of Cores Examined, Schema ID, Required (NAACCR)
    public boolean ifn2910(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear <= '2017' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00580' || (line.numberOfCoresExamined != null && line.numberOfCoresExamined != 'X8')
    }

    // ID: IFN2911; NAME: Number of Cores Positive, Schema ID, Required (NAACCR)
    public boolean ifn2911(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear <= '2017' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00580' || (line.numberOfCoresPositive != null && line.numberOfCoresPositive != 'X8')
    }

    // ID: IFN2917; NAME: Oncotype Dx Recurrence Score-Invasive, Schema ID, Required (NAACCR)
    public boolean ifn2917(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear <= '2017' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00480' || line.oncotypeDxRecurrenceScoreInvasiv != null
    }

    // ID: IFN2920; NAME: Organomegaly, Schema ID, Required (NAACCR)
    public boolean ifn2920(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00795' || line.organomegaly != null
    }

    // ID: IFN2921; NAME: Peripheral Blood Involvement, Schema ID, Required (NAACCR)
    public boolean ifn2921(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00811' || line.peripheralBloodInvolvement != null
    }

    // ID: IFN2922; NAME: Peritoneal Cytology, Schema ID, Required (NAACCR)
    public boolean ifn2922(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        String schemaId = line.schemaId
        
        if (schemaId == '00530' || schemaId == '00541' || schemaId == '00542' || (line.dateOfDiagnosisYear >= '2021' && schemaId == '00528'))
            return line.peritonealCytology != null && line.peritonealCytology != '8'
        
        return true
    }

    // ID: IFN2924; NAME: Progesterone Receptor Summary, Schema ID, Required (NAACCR)
    public boolean ifn2924(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.schemaId == '00480')
            return line.progesteroneRecepSummary != null
        return true
    }

    // ID: IFN2926; NAME: Residual Tumor Volume Post Cytoreduction, Date DX (NAACCR)
    public boolean ifn2926(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        if (line.dateOfDiagnosisYear < '2018')
            return line.residualTumVolPostCytoreduction == null
        return line.residualTumVolPostCytoreduction == null || functions.matches(line.residualTumVolPostCytoreduction, /^[05-8]0|9[7-9]$/)
    }

    // ID: IFN2927; NAME: Residual Tumor Volume Post Cytoreduction, Schema ID, Required (NAACCR)
    public boolean ifn2927(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (line.schemaId == '00550' || line.schemaId == '00551' || line.schemaId == '00552')
            return line.residualTumVolPostCytoreduction != null && line.residualTumVolPostCytoreduction != '98'
        return true
    }

    // ID: IFN2928; NAME: S Category Clinical, Schema ID, Required (NAACCR)
    public boolean ifn2928(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00590' || line.sCategoryClinical != null
    }

    // ID: IFN2929; NAME: S Category Pathological, Schema ID, Required (NAACCR)
    public boolean ifn2929(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00590' || line.sCategoryPathological != null
    }

    // ID: IFN2930; NAME: Sarcomatoid Features, Date DX (NAACCR)
    public boolean ifn2930(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return line.sarcomatoidFeatures == null
        
        return line.sarcomatoidFeatures == null || functions.matches(line.sarcomatoidFeatures, /^0\d\d|100|R0[1-5]|XX[5-9]$/)
    }

    // ID: IFN2931; NAME: Sarcomatoid Features, Schema ID, Required (NAACCR)
    public boolean ifn2931(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00600' || (line.sarcomatoidFeatures != null && line.sarcomatoidFeatures != 'XX8')
    }

    // ID: IFN2932; NAME: Serum Albumin Pretreatment Level, Schema ID, Required (NAACCR)
    public boolean ifn2932(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (line.schemaId == '00821') {
            if (line.schemaDiscriminator1 == '0')
                return line.serumAlbuminPretreatmentLevel != null && line.serumAlbuminPretreatmentLevel != '5'
            else if (line.schemaDiscriminator1 == '1' || line.schemaDiscriminator1 == '9')
                return line.serumAlbuminPretreatmentLevel == '5'
        }
        return true
    }

    // ID: IFN2933; NAME: Serum Beta-2 Microglobulin Pretreatment Level, Schema ID, Required (NAACCR)
    public boolean ifn2933(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (line.schemaId == '00821') {
            if (line.schemaDiscriminator1 == '0')
                return line.serumBeta2MicroglobulinPretxLvl != null && line.serumBeta2MicroglobulinPretxLvl != '5'
            else if (line.schemaDiscriminator1 == '1' || line.schemaDiscriminator1 == '9')
                return line.serumBeta2MicroglobulinPretxLvl == '5'
        }
        
        return true
    }

    // ID: IFN2934; NAME: LDH Lab Value, Schema ID, Required (NAACCR)
    public boolean ifn2934(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        
        return line.schemaId != '00470' || (line.ldhPretreatmentLabValue != null && line.ldhPretreatmentLabValue != 'XXXXX.8')
    }

    // ID: IFN2935; NAME: Thrombocytopenia, Schema ID, Required (NAACCR)
    public boolean ifn2935(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00795' || line.thrombocytopenia != null
    }

    // ID: IFN2938; NAME: Brain Molecular Markers, Date DX (NAACCR)
    public boolean ifn2938(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
            
        if (line.dateOfDiagnosisYear < '2018')
            return line.brainMolecularMarkers == null
        
        if (functions.matches(line.brainMolecularMarkers, /^1\d|2[0-3]$/))
            return line.dateOfDiagnosisYear >= '2024'
        
        return line.brainMolecularMarkers == null || functions.matches(line.brainMolecularMarkers, /^0[1-9]|8[5-8]|99$/)
    }

    // ID: IFN2939; NAME: B Symptoms, Date DX (NAACCR)
    public boolean ifn2939(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return line.bSymptoms == null
        
        return line.bSymptoms == null || functions.matches(line.bSymptoms, /^[0189]$/)
    }

    // ID: IFN2940; NAME: Methylation of O6-Methylguanine-Methyltransferase, Schema ID, Required (NAACCR)
    public boolean ifn2940(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (line.schemaId == '00721' || line.schemaId == '00722' || (line.dateOfDiagnosisYear >= '2023' && (line.schemaId == '09721' || line.schemaId == '09722')))
            return line.methylationOfO6MGMT != null && line.methylationOfO6MGMT != '8'
            
        return true
    }

    // ID: IFN2941; NAME: Chromosome 1p: Loss of Heterozygosity (LOH), Schema ID, Required (NAACCR)
    public boolean ifn2941(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (line.dateOfDiagnosisYear < '2023') {
            if (['00721','00722'].contains(line.schemaId))
                return line.chromosome1pLossHeterozygosity != null && line.chromosome1pLossHeterozygosity != '8'
        }
        else {
            if (['09721','09722'].contains(line.schemaId))
                return line.chromosome1pLossHeterozygosity != null && line.chromosome1pLossHeterozygosity != '8'
        }
        
            
        return true
    }

    // ID: IFN2942; NAME: Chromosome 19q: Loss of Heterozygosity (LOH), Schema ID, Required (NAACCR)
    public boolean ifn2942(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (line.dateOfDiagnosisYear < '2023') {
            if (['00721','00722'].contains(line.schemaId))
                return line.chromosome19qLossHeterozygosity != null && line.chromosome19qLossHeterozygosity != '8'
        }
        else {
            if (['09721','09722'].contains(line.schemaId))
                return line.chromosome19qLossHeterozygosity != null && line.chromosome19qLossHeterozygosity != '8'
        }
            
        return true
    }

    // ID: IFN2943; NAME: CA-125 Pretreatment Interpretation, Schema ID, Required (NAACCR)
    public boolean ifn2943(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (line.schemaId == '00551' || line.schemaId == '00552' || line.schemaId == '00553')
            return line.ca125PretreatmentInterpretation != null && line.ca125PretreatmentInterpretation != '8'
            
        return true
    }

    // ID: IFN2944; NAME: HIV Status, Schema ID, Required (NAACCR)
    public boolean ifn2944(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (line.schemaId == '00790' || line.schemaId == '00795')
            return line.hivStatus != null && line.hivStatus != '8'
            
        return true
    }

    // ID: IFN2945; NAME: JAK2, Schema ID, Required (NAACCR)
    public boolean ifn2945(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00830' || (line.jak2 != '8' && line.jak2 != null)
    }

    // ID: IFN2946; NAME: NCCN International Prognostic Index (IPI), Schema ID, Required (NAACCR)
    public boolean ifn2946(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (line.schemaId == '00790' || line.schemaId == '00795')
            return line.nccnInternationalPrognosticIndex != null && line.nccnInternationalPrognosticIndex != 'X8'
            
        return true
    }

    // ID: IFN2951; NAME: B Symptoms, Schema ID, Required (NAACCR)
    public boolean ifn2951(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return (line.schemaId != '00790' && line.schemaId != '00795') || (line.bSymptoms != null && line.bSymptoms != '8')
    }

    // ID: IFN2958; NAME: Measured Basal Diameter, Schema ID, Required (NAACCR)
    public boolean ifn2958(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return (line.schemaId != '00671' && line.schemaId != '00672') || (line.measuredBasalDiameter != null && line.measuredBasalDiameter != 'XX.8')
    }

    // ID: IFN2959; NAME: Measured Thickness, Schema ID, Required (NAACCR)
    public boolean ifn2959(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return !functions.matches(line.schemaId, /^006(60|7[12])$/) || (line.measuredThickness != null && line.measuredThickness != 'XX.8')
    }

    // ID: IFN2962; NAME: Perineural Invasion, Schema ID, Required (NAACCR)
    public boolean ifn2962(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        String id = line.schemaId
        if (id == '00150' || id == '00200' || id == '00640' || id == '00690')
            return line.perineuralInvasion != null && line.perineuralInvasion != '8'
        
        return true
    }

    // ID: IFN2965; NAME: Schema ID, Site, Histo, Schema Discriminator 1 (NAACCR)
    public boolean ifn2965(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018')
            return true
        
        if (line.primarySite == null || line.histologicTypeIcdO3 == null)
            return true
        
        Integer siteInt = functions.asInt(line.primarySite.substring(1,4))
        Map contextMap = (Map)context.IFN2965_Table
        if (!contextMap.containsKey(siteInt))
            return line.schemaDiscriminator1 == null
        else {
            Map histologyMap = (Map)contextMap.get(siteInt)
            Integer histInt = functions.asInt(line.histologicTypeIcdO3)
            if (!histologyMap.containsKey(histInt))
                return line.schemaDiscriminator1 == null
            
            List schemaIds = (List)(histologyMap.get(histInt))
            if (schemaIds != null && schemaIds.contains(line.schemaId)) {
                Map discrimMap = (Map)context.IFN2965_Schema_ID_Table
                List validDiscrims = (List)discrimMap.get(line.schemaId)
        
                return validDiscrims.contains(line.schemaDiscriminator1)
            }
            else
                return false
        }
        
        return true
    }

    // ID: IFN2967; NAME: Ulceration, Schema ID, Required (NAACCR)
    public boolean ifn2967(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00470' || (line.ulceration != null && line.ulceration != '8')
    }

    // ID: IFN2968; NAME: Schema ID, EOD Primary Tumor (SEER)
    public boolean ifn2968(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.eodPrimaryTumor == null)
            return true
        
        List validCode = (List)((Map)context.IFN2968_Table).get(line.schemaId)
        
        return validCode == null || validCode.contains(line.eodPrimaryTumor)
    }

    // ID: IFN2969; NAME: Schema ID, EOD Regional Nodes (SEER)
    public boolean ifn2969(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.eodRegionalNodes == null)
            return true
        
        List validCode = (List)((Map)context.IFN2969_Table).get(line.schemaId)
        
        return validCode == null || validCode.contains(line.eodRegionalNodes)
    }

    // ID: IFN2970; NAME: Schema ID, EOD Mets (SEER)
    public boolean ifn2970(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.eodMets == null)
            return true
        
        List validCode = (List)((Map)context.IFN2970_Table).get(line.schemaId)
        
        return validCode == null || validCode.contains(line.eodMets)
    }

    // ID: IFN2972; NAME: AFP Post-Orchiectomy Range, Schema ID, Required (NAACCR)
    public boolean ifn2972(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00590' || (line.afpPostOrchiectomyRange != null && line.afpPostOrchiectomyRange != '8')
    }

    // ID: IFN2978; NAME: hCG Post-Orchiectomy Range, Schema ID, Required (NAACCR)
    public boolean ifn2978(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00590' || (line.hcgPostOrchiectomyRange != null && line.hcgPostOrchiectomyRange != '8')
    }

    // ID: IFN2980; NAME: hCG Pre-Orchiectomy Range, Schema ID, Required (NAACCR)
    public boolean ifn2980(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00590' || (line.hcgPreOrchiectomyRange != null && line.hcgPreOrchiectomyRange != '8')
    }

    // ID: IFN2981; NAME: High Risk Histologic Features, Schema ID, Required (NAACCR)
    public boolean ifn2981(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00150' || (line.highRiskHistologicFeatures != null && line.highRiskHistologicFeatures != '8')
    }

    // ID: IFN2982; NAME: LDH Post-Orchiectomy Range, Schema ID, Required (NAACCR)
    public boolean ifn2982(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00590' || (line.ldhPostOrchiectomyRange != null && line.ldhPostOrchiectomyRange != '8')
    }

    // ID: IFN2983; NAME: LDH Pre-Orchiectomy Range, Schema ID, Required (NAACCR)
    public boolean ifn2983(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00590' || (line.ldhPreOrchiectomyRange != null && line.ldhPreOrchiectomyRange != '8')
    }

    // ID: IFN2987; NAME: EOD2018, Date of Diagnosis (SEER)
    public boolean ifn2987(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || (line.dateOfDiagnosisYear == '2018' && line.registryId == '0000001563'))
            return true
        if ('0000001565' == line.registryId && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if ('0000001566' == line.registryId && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        if (line.dateOfDiagnosisYear < '2018')
            return line.eodPrimaryTumor == null && line.eodRegionalNodes == null && line.eodMets == null
        else
            return line.eodPrimaryTumor != null && line.eodRegionalNodes != null && line.eodMets != null
        
        return true
    }

    // ID: IFN2988; NAME: Adenoid Cystic Basaloid Pattern, Schema ID, Required (NAACCR)
    public boolean ifn2988(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00690' || (line.adenoidCysticBasaloidPattern != null && line.adenoidCysticBasaloidPattern != 'XXX.8')
    }

    // ID: IFN2989; NAME: Circumferential Resection Margin (CRM), Schema ID, Required (NAACCR)
    public boolean ifn2989(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00200' || (line.circumferentialResectionMargin != null && line.circumferentialResectionMargin != 'XX.8')
    }

    // ID: IFN2990; NAME: Microsatellite Instability (MSI), Schema ID, Required (NAACCR)
    public boolean ifn2990(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear <= '2017' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        
        return line.schemaId != '00200' || (line.microsatelliteInstability != '8' && line.microsatelliteInstability != null)
    }

    // ID: IFN2991; NAME: PSA (Prostatic Specific Antigen) Lab Value, Schema ID, Required (NAACCR)
    public boolean ifn2991(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear <= '2017' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
            
        if (line.schemaId == '00580')
           return line.psaLabValue != null 
        
        return true
    }

    // ID: IFN2992; NAME: Tumor Deposits, Schema ID, Required (NAACCR)
    public boolean ifn2992(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018'|| line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (line.schemaId == '00200')
            return line.tumorDeposits != null && line.tumorDeposits != 'X8'
        return true
    }

    // ID: IFN2996; NAME: High Risk Cytogenetics, Schema ID, Required (NAACCR)
    public boolean ifn2996(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (line.schemaId == '00821') {
            if (line.schemaDiscriminator1 == null)
                return false
            else if (line.schemaDiscriminator1 == '0')
                return line.highRiskCytogenetics != null && line.highRiskCytogenetics != '5'
            if (line.schemaDiscriminator1 == '1' || line.schemaDiscriminator1 == '9')
                return line.highRiskCytogenetics == '5'
        }
        return true
    }

    // ID: IFN2997; NAME: KRAS, Schema ID, Required (NAACCR)
    public boolean ifn2997(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear <= '2017' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (line.schemaId == '00200')
           return line.kras != '8' && line.kras != null 
        
        return true
    }

    // ID: IFN2998; NAME: CEA Pretreatment Interpretation, Schema ID, Required (NAACCR)
    public boolean ifn2998(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear <= '2017' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if ((line.schemaId == '00190' && line.dateOfDiagnosisYear < '2023') || (line.schemaId == '09190' && line.dateOfDiagnosisYear >= '2023') || line.schemaId == '00200')
            return (line.ceaPretreatmentInterpretation != '8' && line.ceaPretreatmentInterpretation != null)
        
        return true
    }

    // ID: IFN2999; NAME: CEA Pretreatment Lab Value, Schema ID, Required (NAACCR)
    public boolean ifn2999(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear <= '2017' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if ((line.schemaId == '00190' && line.dateOfDiagnosisYear < '2023') || (line.schemaId == '09190' && line.dateOfDiagnosisYear >= '2023') || line.schemaId == '00200')
            return (line.ceaPretreatmentLabValue != 'XXXX.8' && line.ceaPretreatmentLabValue != null)
        
        return true
    }

    // ID: IFN3001; NAME: Extranodal Extension Head and Neck Pathological, Schema ID, Required (NAACCR)
    public boolean ifn3001(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return !functions.matches(line.schemaId, /^00(0[689]0|07[1-7]|1[034]0|1[1-3][12]|133)$/) || (line.extranodalExtensionHeadNeckPath != null && line.extranodalExtensionHeadNeckPath != 'X.8')
    }

    // ID: IFN3002; NAME: Extranodal Extension Clin (non-Head and Neck), Date DX (NAACCR)
    public boolean ifn3002(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
         
        if (line.dateOfDiagnosisYear < '2018')
            return line.extranodalExtensionClin == null
         
         return line.extranodalExtensionClin == null || functions.matches(line.extranodalExtensionClin, /^[0-247-9]$/)
    }

    // ID: IFN3004; NAME: Extranodal Extension Path (non-Head and Neck), Date DX (NAACCR)
    public boolean ifn3004(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
         
        if (line.dateOfDiagnosisYear < '2018')
            return line.extranodalExtensionPath == null
         
         return line.extranodalExtensionPath == null || functions.matches(line.extranodalExtensionPath, /^[017-9]$/)
    }

    // ID: IFN3006; NAME: Schema Discriminator 2, Date DX (NAACCR)
    public boolean ifn3006(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
            
        if (line.dateOfDiagnosisYear < '2018')
            return line.schemaDiscriminator2 == null
        
        if (line.schemaDiscriminator2 == '8')
            return line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022'
        
        return line.schemaDiscriminator2 == null || functions.matches(line.schemaDiscriminator2, /^[129]$/)
    }

    // ID: IFN3007; NAME: Schema ID, Site, Histo, Schema Discriminator 2 (NAACCR)
    public boolean ifn3007(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.primarySite == null || line.histologicTypeIcdO3 == null)
            return true
        
        Map contextMap = (Map)context.SchemaDiscriminator2Table
        Map histMap = (Map)contextMap.get(line.primarySite)
        if (histMap == null)
            return line.schemaDiscriminator2 == null
        
        int histInt = functions.asInt(line.histologicTypeIcdO3)
        Map discrimMap = (Map)histMap.get(histInt)
        if (discrimMap == null)
            return line.schemaDiscriminator2 == null
        
        // exception case for C111 with schema ID 00090 (Nasopharynx)
        if (line.primarySite == 'C111' && line.schemaId == '00090' && line.schemaDiscriminator2 == null)
            return true
        
        // exception case for C160 with schema ID 00170 (Stomach)
        if (line.primarySite == 'C160' && line.schemaId == '00170' && line.schemaDiscriminator2 == null && line.histologicTypeIcdO3 == '8020')
            return true
        
        List schemaIds = (List)discrimMap.get(line.schemaDiscriminator2)
        if (schemaIds == null)
            return false
        else
            return schemaIds.contains(line.schemaId)
        
        return true
    }

    // ID: IFN3009; NAME: AFP Pre-Orchiectomy Lab Value, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3009(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00590' || (line.afpPreOrchiectomyLabValue != null && line.afpPreOrchiectomyLabValue != 'XXXXX.8')
    }

    // ID: IFN3010; NAME: AJCC ID, Site, Histo, Schema Discriminator 1 (NAACCR)
    public boolean ifn3010(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018')
            return true
        
        if (line.primarySite == null || line.histologicTypeIcdO3 == null || line.behaviorCodeIcdO3 == null)
            return true
        
        String ajccId = line.ajccId
        
        Integer siteInt = functions.asInt(line.primarySite.substring(1,4))
        Map contextMap = (Map)context.IFN3010_Table
        if (!contextMap.containsKey(siteInt))
            return true
        else {
            Map histologyMap = (Map)contextMap.get(siteInt)
            Integer histInt = functions.asInt(line.histologicTypeIcdO3)
            if (!histologyMap.containsKey(histInt))
                return true
                
            Map behaviorMap = (Map)(histologyMap.get(histInt))
            if (!behaviorMap.containsKey(line.behaviorCodeIcdO3))
                return line.ajccId == 'XX'
            
            List ajccIds = (List)(behaviorMap.get(line.behaviorCodeIcdO3))
            if (ajccIds != null && ajccIds.contains(line.ajccId)) {
               if (line.ajccId == 'XX' && line.schemaDiscriminator1 == null)
                   return true
            
                Map ajccIdMap = (Map)context.IFN3010_AJCC_ID_Table
                List validDiscrims = (List)ajccIdMap.get(line.ajccId)
                
                return validDiscrims.contains(line.schemaDiscriminator1)
            }
            else
                return line.ajccId == 'XX'
        }
        
        return true
    }

    // ID: IFN3013; NAME: AJCC ID, Site, Histo, Schema Discriminator 2 (NAACCR)
    public boolean ifn3013(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.primarySite == null || line.histologicTypeIcdO3 == null)
            return true
        
        Map contextMap = (Map)context.AjccIdDiscriminator2Table
        int histInt = functions.asInt(line.histologicTypeIcdO3)
        Map siteHistMap = (Map)((Map)contextMap.get(line.primarySite))?.get(histInt)
        Map discrimMap = (Map)siteHistMap?.get(line.behaviorCodeIcdO3)
        if (discrimMap == null)
            return true
        List ajccId = (List)discrimMap.get(line.schemaDiscriminator2)
        if (ajccId == null) {
            if (line.ajccId == 'XX' || (line.ajccId == '9' && line.primarySite == 'C111') || (line.ajccId == '17' && line.primarySite == 'C160' && line.histologicTypeIcdO3 == '8020'))
                return true
            return false
        }
        
        return ajccId.contains(line.ajccId)
    }

    // ID: IFN3022; NAME: Brain Molecular Markers, Schema ID, Required (NAACCR)
    public boolean ifn3022(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        
        return !['00721','00722','09721','09722','09724'].contains(line.schemaId) || (line.brainMolecularMarkers != null && line.brainMolecularMarkers != '88')
    }

    // ID: IFN3023; NAME: Mets at DX-Bone, EOD Mets (SEER)
    public boolean ifn3023(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018'  || line.eodMets == null || line.eodMets == '88' || line.metsAtDxBone == null)
            return true
            
        return line.metsAtDxBone != '1' || line.eodMets != '00'
    }

    // ID: IFN3024; NAME: Mets at DX-Brain, EOD Mets (SEER)
    public boolean ifn3024(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018'  || line.eodMets == null || line.eodMets == '88' || line.metsAtDxBrain == null)
            return true
            
        return line.metsAtDxBrain != '1' || line.eodMets != '00'
    }

    // ID: IFN3025; NAME: Mets at DX-Distant LN, EOD Mets (SEER)
    public boolean ifn3025(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018'  || line.eodMets == null || line.eodMets == '88' || line.metsAtDxDistantLn == null)
            return true
        
        if (line.schemaId == null || ['00458', '00710', '00811'].contains(line.schemaId))
            return true
        
        return line.metsAtDxDistantLn != '1' || line.eodMets != '00'
    }

    // ID: IFN3026; NAME: Mets at DX-Liver, EOD Mets (SEER)
    public boolean ifn3026(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018'  || line.eodMets == null || line.eodMets == '88' || line.metsAtDxLiver == null)
            return true
            
        return line.metsAtDxLiver != '1' || line.eodMets != '00'
    }

    // ID: IFN3027; NAME: Mets at DX-Lung, EOD Mets (SEER)
    public boolean ifn3027(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018'  || line.eodMets == null || line.eodMets == '88' || line.metsAtDxLung == null)
            return true
            
        return line.metsAtDxLung != '1' || line.eodMets != '00'
    }

    // ID: IFN3028; NAME: Mets at DX-Other, EOD Mets (SEER)
    public boolean ifn3028(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018'  || line.eodMets == null || line.eodMets == '88' || line.metsAtDxOther == null)
            return true
            
        return (line.metsAtDxOther != '1' && line.metsAtDxOther != '2') || line.eodMets != '00'
    }

    // ID: IFN3030; NAME: FIGO Stage, Behavior (NAACCR)
    public boolean ifn3030(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018'  || line.figoStage == null || line.figoStage == '98')
            return true
        
        if (!functions.matches(line.schemaId, /^(005([01236]0|4[12]|5[123]|28)|095[02]0)$/) || line.behaviorCodeIcdO3 == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        if (line.behaviorCodeIcdO3 == '2' && !functions.matches(line.schemaId, /^005(30|5[13])$/))
            return line.figoStage == '97'
        
        if (line.behaviorCodeIcdO3 == '3')
            return line.figoStage != '97'
        
        return true
    }

    // ID: IFN3031; NAME: Serum Markers, Testis, Post-Orchiectomy 03-2022, Range (NAACCR)
    public boolean ifn3031(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.dateOfDiagnosisYear > '2022' || line.schemaId != '00590' || line.rxSummSurgPrimSite == null)
            return true
        
        if ((line.afpPostOrchiectomyRange == null || line.afpPostOrchiectomyRange == '8') && (line.hcgPostOrchiectomyRange == null || line.hcgPostOrchiectomyRange == '8') && 
            (line.ldhPostOrchiectomyRange == null || line.ldhPostOrchiectomyRange == '8') && line.sCategoryPathological == null)
            return true
        
        String surgPrimSite = line.rxSummSurgPrimSite
        if (surgPrimSite == '00' || surgPrimSite == '12' || surgPrimSite == '20' || surgPrimSite == '99')
            return line.afpPostOrchiectomyRange == '9' && line.hcgPostOrchiectomyRange == '9' && line.ldhPostOrchiectomyRange == '9' && line.sCategoryPathological == '9'
        
        return true
    }

    // ID: IFN3032; NAME: Brain Molecular Markers, Morphology ICD-O-3 (NAACCR)
    public boolean ifn3032(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || !['00721', '00722', '09721', '09722', '09724'].contains(line.schemaId) || line.typeOfReportingSource == '7')
            return true
        
        String brainMolecularMarkers = line.brainMolecularMarkers
        String histology = line.histologicTypeIcdO3
        String behavior = line.behaviorCodeIcdO3
        String morph = histology + behavior
        
        String[] morphsPre2024 = ['94003', '94013', '94403', '94503', '94513', '94713', '94783']
        String[] morphs2024AndLater = ['93853', '93963', '94211', '94303', '95003']
        
        if (histology == null || behavior == null || brainMolecularMarkers == null || brainMolecularMarkers == '88')
            return true
        
        if (brainMolecularMarkers == '01' || brainMolecularMarkers == '02')
            if (morph != '94003')
                return false
        
        if (brainMolecularMarkers == '03' || brainMolecularMarkers == '04')
            if (morph != '94013')
                return false
        
        if (brainMolecularMarkers == '05')
            if (morph != '94403')
                return false
            
        if (brainMolecularMarkers == '06')
            if (morph != '94503')
                return false
            
        if (brainMolecularMarkers == '07')
            if (morph != '94513')
                return false
            
        if (brainMolecularMarkers == '08')
            if (morph != '94713')
                return false
        
        if (brainMolecularMarkers == '09')
            if (morph != '94783')
                return false
        
        if (brainMolecularMarkers == '85')
            if (morphsPre2024.contains(morph))
                return false
        
        if (brainMolecularMarkers == '86')
            if (behavior != '0' && behavior != '1')
                return false
        
        if (line.dateOfDiagnosisYear < '2024') {
            if (behavior == '0' || behavior == '1')
                if (brainMolecularMarkers != '86')
                    return false
        }
        if (line.dateOfDiagnosisYear >= '2024') {
            if (['10','11','12','13'].contains(brainMolecularMarkers))
                if (morph != '93853')
                    return false
        
            if (['14','15','16','17','18'].contains(brainMolecularMarkers))
                if (morph != '93963')
                    return false
        
            if (brainMolecularMarkers == '19' || brainMolecularMarkers == '20')
                if (morph != '94211')
                    return false
        
            if (brainMolecularMarkers == '21')
                if (morph != '94303')
                    return false
        
            if (brainMolecularMarkers == '22' || brainMolecularMarkers == '23')
                if (morph != '95003')
                    return false
        
            if (brainMolecularMarkers == '85')
                if (morphs2024AndLater.contains(morph))
                    return false
        
            if (brainMolecularMarkers == '86')
                if ((behavior == '0' || behavior == '1') && morph != '94211')
                    return true
                else
                    return false
        
            if ((behavior == '0' || behavior == '1') && morph != '94211')
                if (brainMolecularMarkers != '86')
                    return false
        }
        
        return true
    }

    // ID: IFN3033; NAME: Breslow Tumor Thickness, Melanoma, Behavior (NAACCR)
    public boolean ifn3033(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId != '00470')
            return true
        
        if (line.breslowTumorThickness == null || line.breslowTumorThickness == 'XX.8')
            return true
        
        return line.behaviorCodeIcdO3 != '2' || line.breslowTumorThickness == 'XX.9'
    }

    // ID: IFN3034; NAME: Circumferential Resection Margin (CRM), Colon, Surg Prim Site 03-2022 (NAACCR)
    public boolean ifn3034(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.dateOfDiagnosisYear > '2022' || line.schemaId != '00200' || line.behaviorCodeIcdO3 == '2')
            return true
        
        if (line.circumferentialResectionMargin == null || line.circumferentialResectionMargin == 'XX.8')
            return true
        
        if ((line.registryId == '0000001565' && line.dateOfDiagnosisYear < '2023')
            || (line.registryId == '0000001566' && line.dateOfDiagnosisYear < '2022'))
            return true
        
        if (functions.matches(line.primarySite, /^C1(8[02-9]|99)$/) && functions.matches(line.rxSummSurgPrimSite, /^00|1[0-4]|2[0-9]$/) && line.circumferentialResectionMargin != 'XX.7')
            return false
        else if (line.primarySite == 'C209' && functions.matches(line.rxSummSurgPrimSite, /^00|1[0-4]|2[0-68]$/) && line.circumferentialResectionMargin != 'XX.7')
            return false
        
        if (functions.matches(line.rxSummSurgPrimSite, /^[3-7]\d|80$/) && line.circumferentialResectionMargin == 'XX.7')
            return false
        
        if (line.rxSummSurgPrimSite == '99' && line.circumferentialResectionMargin != 'XX.9')
            return false
        
        return true
    }

    // ID: IFN3035; NAME: Extranodal Extension Clin/Path, Penis, EOD Regional Nodes (SEER)
    public boolean ifn3035(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.schemaId != '00570' || line.eodRegionalNodes == null)
            return true
        
        String clin = line.extranodalExtensionClin
        String path = line.extranodalExtensionPath
        if ((clin == null || clin == '8') && (path == null || path == '8'))
            return true
        
        if (clin == '7' && path == '7')
            return line.eodRegionalNodes == '000'
        else if (['0', '1', '2', '4'].contains(clin) && path == '7')
            return ['100', '200', '300', '800'].contains(line.eodRegionalNodes)
        else if (path == '0')
            return line.eodRegionalNodes == '400' || line.eodRegionalNodes == '500'
        else if (path == '1')
            return line.eodRegionalNodes == '500'
        
        return true
    }

    // ID: IFN3037; NAME: Gleason Patterns/Score, Clin/Path (NAACCR)
    public boolean ifn3037(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.schemaId != '00580')
            return true
        
        String scorePath = line.gleasonScorePathological
        String scoreClin = line.gleasonScoreClinical
        String patternsPath = line.gleasonPatternsPathological
        String patternsClin = line.gleasonPatternsClinical
        if ((scoreClin == null || scoreClin == 'X8') && (scorePath == null || scorePath == 'X8') && (patternsClin == null || patternsClin == 'X8') && (patternsPath == null || patternsPath == 'X8'))
            return true
        
        if (scoreClin != null && scoreClin != 'X8') {
            if (patternsClin == '11' && scoreClin != '02')
                return false
            else if ((patternsClin == '12' || patternsClin == '21') && scoreClin != '03')
                return false
            else if (['13', '22', '31'].contains(patternsClin) && scoreClin != '04')
                return false
            else if (['14', '23', '32', '41'].contains(patternsClin) && scoreClin != '05')
                return false
            else if (['15', '24', '33', '42', '51'].contains(patternsClin) && scoreClin != '06')
                return false
            else if (['25', '34', '43', '52'].contains(patternsClin) && scoreClin != '07')
                return false
            else if (['35', '44', '53'].contains(patternsClin) && scoreClin != '08')
                return false
            else if ((patternsClin == '45' || patternsClin == '54') && scoreClin != '09')
                return false
            else if (patternsClin == '55' && scoreClin != '10')
                return false
            else if (patternsClin == 'X7' && scoreClin != 'X7')
                return false
        }
        
        if (scorePath != null && scorePath != 'X8') {
            if (patternsPath == '11' && scorePath != '02')
                return false
            else if ((patternsPath == '12' || patternsPath == '21') && scorePath != '03')
                return false
            else if (['13', '22', '31'].contains(patternsPath) && scorePath != '04')
                return false
            else if (['14', '23', '32', '41'].contains(patternsPath) && scorePath != '05')
                return false
            else if (['15', '24', '33', '42', '51'].contains(patternsPath) && scorePath != '06')
                return false
            else if (['25', '34', '43', '52'].contains(patternsPath) && scorePath != '07')
                return false
            else if (['35', '44', '53'].contains(patternsPath) && scorePath != '08')
                return false
            else if ((patternsPath == '45' || patternsPath == '54') && scorePath != '09')
                return false
            else if (patternsPath == '55' && scorePath != '10')
                return false
            else if (patternsPath == 'X7' && scorePath != 'X7')
                return false
        }
        
        return true
    }

    // ID: IFN3042; NAME: LN Distant, Gynecologic, EOD Mets (SEER)
    public boolean ifn3042(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.eodMets == null)
            return true
        
        if (!['00510', '00520', '09520'].contains(line.schemaId))
            return true
        
        String lnStatus = line.lnDistantMediastinalScalene
        if (lnStatus == null || lnStatus == '8')
            return true
        
        if (lnStatus == '1' || lnStatus == '2' || lnStatus == '3')
            return line.eodMets == '10' || line.eodMets == '70'
        
        return true
    }

    // ID: IFN3043; NAME: Extranodal Extension Clin/Path, Merkel Cell, EOD Regional Nodes (SEER)
    public boolean ifn3043(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.schemaId != '00460' || line.eodRegionalNodes == null)
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        String clin = line.extranodalExtensionClin
        String path = line.extranodalExtensionPath
        if ((clin == null || clin == '8') && (path == null || path == '8'))
            return true
        
        if (clin == '7' && path == '7')
            return ['000', '600', '700'].contains(line.eodRegionalNodes)
        else if (['0', '1', '2', '4'].contains(clin) && path == '7')
            return ['100', '200', '650', '800'].contains(line.eodRegionalNodes)
        else if (clin == '7' && (path == '0' || path == '1'))
            return ['300', '350', '500', '750'].contains(line.eodRegionalNodes)
        else if (['0', '1', '2'].contains(clin) && (path == '0' || path == '1'))
            return line.eodRegionalNodes == '400' || line.eodRegionalNodes == '750'
        
        return true
    }

    // ID: IFN3046; NAME: LN Head and Neck Levels, EOD Regional Nodes (SEER)
    public boolean ifn3046(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || !['00060', '00140'].contains(line.schemaId) || line.eodRegionalNodes == null)
            return true
        
        String ln13 = line.lnHeadAndNeckLevels1To3
        String ln45 = line.lnHeadAndNeckLevels4To5
        String ln67 = line.lnHeadAndNeckLevels6To7
        String lnOther = line.lnHeadAndNeckOther
        if ((ln13 == null || ln13 == '8') && (ln45 == null || ln45 == '8') && (ln67 == null || ln67 == '8') && (lnOther == null || lnOther == '8'))
            return true
        
        if (functions.matches(ln13, /^[1-7]$/) || functions.matches(ln45, /^[1-3]$/) || functions.matches(ln67, /^[1-3]$/) || functions.matches(lnOther, /^[1-7]$/))
            return !['000', '800', '999'].contains(line.eodRegionalNodes)
        
        if (ln13 == '9' && ln45 == '9' && ln67 == '9' && lnOther == '9')
            return ['800', '999'].contains(line.eodRegionalNodes)
        
        if (line.dateOfDiagnosisYear > '2020' && !['000', '800', '999'].contains(line.eodRegionalNodes))
            return ln13 != '0' || ln45 != '0' || ln67 != '0' || lnOther != '0'
        
        return true
    }

    // ID: IFN3047; NAME: LN Isolated Tumor Cells (ITC), Merkel Cell, EOD Regional Nodes (SEER)
    public boolean ifn3047(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.schemaId != '00460' || line.eodRegionalNodes == null)
            return true
        
        if (line.lnIsolatedTumorCells == null || line.lnIsolatedTumorCells == '8')
            return true
        
        if (line.lnIsolatedTumorCells == '1')
            return !['000', '600', '700', '999'].contains(line.eodRegionalNodes)
        
        return true
    }

    // ID: IFN3048; NAME: LN Laterality, Vulva, EOD Regional Nodes (SEER)
    public boolean ifn3048(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || (line.schemaId != '00500' && line.schemaId != '09500') || line.eodRegionalNodes == null)
            return true
        
        String lnLaterality = line.lnLaterality
        if (lnLaterality == null || lnLaterality == '8')
            return true
        
        if (lnLaterality == '1' || lnLaterality == '2' || lnLaterality == '3')
            return !['000','040','050','999'].contains(line.eodRegionalNodes)
        
        return true
    }

    // ID: IFN3049; NAME: LN Positive Axillary Level I-II, Breast, EOD Regional Nodes (SEER)
    public boolean ifn3049(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.schemaId != '00480' || line.eodRegionalNodes == null)
            return true
        
        String lnPositiveAxillaryLevel1To2 = line.lnPositiveAxillaryLevel1To2
        if (lnPositiveAxillaryLevel1To2 == null || lnPositiveAxillaryLevel1To2 == 'X8')
            return true
        
        if (functions.matches(lnPositiveAxillaryLevel1To2, /^0[1-9]|[1-9]\d|X[156]$/))
            return !['000','030','050','070','250','400','999'].contains(line.eodRegionalNodes)
        
        return true
    }

    // ID: IFN3050; NAME: LN Size, Head/Neck, EOD Regional Nodes (SEER)
    public boolean ifn3050(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.eodRegionalNodes == null)
            return true
        
        if (!functions.matches(line.schemaId, /^00(0[689]0|07[1-7]|100|1[12][12]|13[0-3]|1[45]0)$/))
            return true
        
        if (line.lnSize == null || line.lnSize == 'XX.8')
            return true
        
        if (line.lnSize != '0.0' && line.lnSize != 'XX.9')
            return line.eodRegionalNodes != '000' && line.eodRegionalNodes != '999'
        
        return true
    }

    // ID: IFN3052; NAME: Major Vein Involvement, Kidney, EOD Primary Tumor (SEER)
    public boolean ifn3052(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.schemaId != '00600' || line.eodPrimaryTumor == null)
            return true
        
        String majorVeinInvolvement = line.majorVeinInvolvement
        if (majorVeinInvolvement == null || majorVeinInvolvement == '8')
            return true
        
        if (majorVeinInvolvement == '1' || majorVeinInvolvement == '3' || majorVeinInvolvement == '4')
            return functions.matches(line.eodPrimaryTumor, /^[2-6]\d\d|700|999$/)
        else if (majorVeinInvolvement == '2')
            return functions.matches(line.eodPrimaryTumor, /^[3-6]\d\d|700|999$/)
        
        return true
    }

    // ID: IFN3053; NAME: Invasion Beyond Capsule, Kidney, EOD Primary Tumor (SEER)
    public boolean ifn3053(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.schemaId != '00600' || line.eodPrimaryTumor == null)
            return true
        
        String invasionBeyondCapsule = line.invasionBeyondCapsule
        if (invasionBeyondCapsule == null || invasionBeyondCapsule == '8')
            return true
        
        if (functions.matches(invasionBeyondCapsule, /^[13-5]$/))
            return functions.matches(line.eodPrimaryTumor, /^[2-6]\d\d|700|999$/)
        
        return true
    }

    // ID: IFN3055; NAME: Oncotype Dx Recurrence Score-Invasive, Breast, Behavior (NAACCR)
    public boolean ifn3055(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId != '00480' || line.oncotypeDxRecurrenceScoreInvasiv == null)
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1' || line.behaviorCodeIcdO3 == null)
            return true
        
        if (line.behaviorCodeIcdO3 == '2')
            return line.oncotypeDxRecurrenceScoreInvasiv == 'XX6'
        
        return line.oncotypeDxRecurrenceScoreInvasiv != 'XX6'
    }

    // ID: IFN3058; NAME: Residual Tumor Volume Post Cytoreduction, Gynecologic, Surg Prim Site 03-2022 (NAACCR)
    public boolean ifn3058(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.dateOfDiagnosisYear > '2022' || !functions.matches(line.schemaId, /^0055[123]$/)
                    || line.rxSummSurgPrimSite == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.residualTumVolPostCytoreduction == null || line.residualTumVolPostCytoreduction == '98')
            return true
        
        boolean schemaConditions = (functions.matches(line.rxSummSurgPrimSite, /^[1-4]\d|5[0-7]$/) && line.schemaId == '00551') || 
                                   (functions.matches(line.rxSummSurgPrimSite, /^[1-3]\d|4[01]$/) && (line.schemaId == '00552' || line.schemaId == '00553'))
        if (line.rxSummSurgPrimSite == '00' || schemaConditions)
            return line.residualTumVolPostCytoreduction == '97'
        
        if (line.rxSummSurgPrimSite == '99')
            return line.residualTumVolPostCytoreduction == '99'
        
        return true
    }

    // ID: IFN3060; NAME: Separate Tumor Nodules, Lung, Behavior (NAACCR)
    public boolean ifn3060(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId != '00360')
            return true
        
        if (line.separateTumorNodules == null || line.separateTumorNodules == '8' || line.behaviorCodeIcdO3 == null || functions.matches(line.behaviorCodeIcdO3, /^([013])$/))
            return true
        
        if (line.dateOfDiagnosisYear < '2023')
            return line.separateTumorNodules == '0' || line.separateTumorNodules == '9'
        
        return line.separateTumorNodules == '0'
    }

    // ID: IFN3062; NAME: Visceral and Parietal Pleural Invasion, Lung, EOD Primary Tumor (SEER)
    public boolean ifn3062(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.schemaId != '00360' || line.eodPrimaryTumor == null)
            return true
        
        String visceralAndParietalPleuralInvasion = line.visceralParietalPleuralInvasion
        if (visceralAndParietalPleuralInvasion == null || visceralAndParietalPleuralInvasion == '8')
            return true
        
        if (functions.matches(visceralAndParietalPleuralInvasion, /^[46]$/))
            return functions.matches(line.eodPrimaryTumor, /^4[5-9]\d|[56]\d\d|700|999$/)
        else if (visceralAndParietalPleuralInvasion == '5')
            return functions.matches(line.eodPrimaryTumor, /^[56]\d\d|700|999$/)
        
        return true
    }

    // ID: IFN3063; NAME: EOD Prostate Pathologic Extension, Schema ID, Required (SEER)
    public boolean ifn3063(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource  == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (line.registryId == '0000001563' && line.dateOfDiagnosisYear == '2018')
            return true
        
        return line.schemaId != '00580' || line.prostatePathologicalExtension != null
    }

    // ID: IFN3065; NAME: Number of Positive/Examined Para-Aortic Nodes, Corpus (NAACCR)
    public boolean ifn3065(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019')
            return true
        
        if (!['00530', '00541', '00542', '00528'].contains(line.schemaId))
            return true
        
        String positiveNodes = line.numberOfPositiveParaAorticNodes
        String examinedNodes = line.numberOfExaminedParaAorticNodes
        if (positiveNodes == null || positiveNodes == 'X8' || examinedNodes == null || examinedNodes == 'X8')
            return true
        
        if (examinedNodes == 'X6' && positiveNodes != 'X6' && positiveNodes != '00' && positiveNodes != 'X9')
            return false
            
        if (examinedNodes == '00' && positiveNodes != 'X9')
            return false
        
        if (functions.matches(examinedNodes, /^0[1-9]|[1-9]\d$/) && positiveNodes != 'X2' && positiveNodes != 'X6' && positiveNodes != 'X9' && positiveNodes > examinedNodes)
            return false
        
        if ((examinedNodes == 'X2' || examinedNodes == 'X1') && !functions.matches(positiveNodes, /^\d\d|X[129]$/))
            return false
            
        if (positiveNodes == 'X1' && examinedNodes != 'X1' && examinedNodes != 'X2')
            return false
        
        return true
    }

    // ID: IFN3066; NAME: Number of Positive/Examined Pelvic Nodes, Corpus (NAACCR)
    public boolean ifn3066(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019')
            return true
        
        if (!['00530', '00541', '00542', '00528'].contains(line.schemaId))
            return true
        
        String positiveNodes = line.numberOfPositivePelvicNodes
        String examinedNodes = line.numberOfExaminedPelvicNodes
        if (positiveNodes == null || positiveNodes == 'X8' || examinedNodes == null || examinedNodes == 'X8')
            return true
        
        if (examinedNodes == 'X6' && positiveNodes != 'X6' && positiveNodes != '00' && positiveNodes != 'X9')
            return false
        
        if (examinedNodes == '00' && positiveNodes != 'X9')
            return false
        
        if (functions.matches(examinedNodes, /^0[1-9]|[1-9]\d$/) && positiveNodes != 'X2' && positiveNodes != 'X9' && positiveNodes != 'X6' && positiveNodes > examinedNodes)
            return false
        
        if ((examinedNodes == 'X2' || examinedNodes == 'X1') && !functions.matches(positiveNodes, /^\d\d|X[129]$/))
            return false
        
        if (positiveNodes == 'X1' && examinedNodes != 'X1' && examinedNodes != 'X2')
            return false
        
        return true
    }

    // ID: IFN3067; NAME: Profound Immune Suppression, Sequence Number--Central (NAACCR)
    public boolean ifn3067(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId != '00460')
            return true
        
        if (line.profoundImmuneSuppression == null || line.profoundImmuneSuppression == '8' || line.sequenceNumberCentral == null)
            return true
             
        if (line.profoundImmuneSuppression == '3' || line.profoundImmuneSuppression == '4')
            return line.sequenceNumberCentral != '00'
            
        return true
    }

    // ID: IFN3068; NAME: _SYS AJCC ID, Site, Histo, Sex (NAACCR)
    public boolean ifn3068(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.sex == null || line.primarySite == null || line.histologicTypeIcdO3 == null)
            return true
        
        String ajccId = line.ajccId
        if (ajccId == '55' && functions.matches(line.primarySite, /^C48[1-8]$/))
            ajccId = '55.B'
        
        if (functions.matches(line.primarySite, /^C48[1-8]$/)) {
            List histList = (List)context.IFN3068_Histologies
            if ((['8806', '8930', '8931'].contains(line.histologicTypeIcdO3) || histList.contains(line.histologicTypeIcdO3)) && line.behaviorCodeIcdO3 == '2')
                return ajccId == 'XX'
            if (['8806', '8930', '8931'].contains(line.histologicTypeIcdO3) && ajccId != '45' && functions.matches(line.sex, /^[13459]$/))
                return false
            if (histList.contains(line.histologicTypeIcdO3) && ajccId != '55.B' && functions.matches(line.sex, /^[26]$/))
                return false
        }
        
        return true
    }

    // ID: IFN3069; NAME: _SYS Schema ID, Site, Histo, Sex (NAACCR)
    public boolean ifn3069(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.sex == null || line.primarySite == null || line.histologicTypeIcdO3 == null)
            return true
        
        String hist = line.histologicTypeIcdO3
        String sex = line.sex
        String schemaId = line.schemaId
        
        if (!functions.matches(line.primarySite, /^C48[1-8]$/) || hist == null)
            return true
        
        int histInt = functions.asInt(hist)
        if (histInt == 8806 || histInt == 8930 || histInt == 8931) {
            if (functions.matches(sex, /^[13459]$/) && schemaId != '00450')
                return false
            if (functions.matches(sex, /^[26]$/) && schemaId != '00552')
                return false
        }
        if ((8000 <= histInt && 8700 >= histInt) || (8720 <= histInt && histInt <= 8790) || functions.matches(hist, /$8822|89(33|[568]0)|90([056789]0|52|71|73|85|91)|91[01]0|970[01]^/)) {
            if (functions.matches(sex, /^[13459]$/) && schemaId != '00440')
                return false
            if (functions.matches(sex, /^[26]$/) && schemaId != '00552')
                return false
        }
        
        return true
    }

    // ID: IFN3082; NAME: Grade, Lymphoma Ocular Adnexa, Histologic Type ICD-O-3 (NAACCR)
    public boolean ifn3082(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId != '00710' || line.histologicTypeIcdO3 == null)
            return true
        
        if (line.gradeClinical == null && line.gradePathological == null)
            return true
        
        boolean gradeClinicalBlankOr9 = line.gradeClinical == null || line.gradeClinical == '9'
        boolean gradePathologicalBlankOr9 = line.gradePathological == null || line.gradePathological == '9'
        
        return functions.matches(line.histologicTypeIcdO3, /^969[0158]$/) || (gradeClinicalBlankOr9 && gradePathologicalBlankOr9)
    }

    // ID: IFN3085; NAME: LN Size, Schema ID, Required (NAACCR)
    public boolean ifn3085(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return !functions.matches(line.schemaId, /^00(0([689]0|7[1-7])|1([03-5]0|[1-3][12]|33))$/) || (line.lnSize != null && line.lnSize != 'XX.8')
    }

    // ID: IFN3087; NAME: Grade, Ovary/PPC/FT, Behavior ICD-O-3 (NAACCR)
    public boolean ifn3087(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || !functions.matches(line.schemaId, /^0055[123]$/) || line.behaviorCodeIcdO3 == null)
            return true
        
        if (line.gradeClinical == null && line.gradePathological == null)
            return true 
        
        return !['2', '3'].contains(line.behaviorCodeIcdO3) || (line.gradeClinical != 'B' && line.gradePathological != 'B')
    }

    // ID: IFN3090; NAME: Extranodal Extension Head and Neck Clin/Path, EOD Regional Nodes (SEER)
    public boolean ifn3090(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.eodRegionalNodes == null)
            return true
        
        if (!functions.matches(line.schemaId, /^00(0[689]0|07[1-7]|100|1[12][12]|13[0-3]|140)$/))
            return true
        
        String clin = line.extranodalExtensionHeadNeckClin
        String path = line.extranodalExtensionHeadNeckPath
        if (clin == null || clin == '8' || path == null || path == 'X.8')
            return true
        
        if (clin == '7' && path == 'X.7')
            return line.eodRegionalNodes == '000'
        if ((clin == '0' || clin == '7') && path == '0.0' && !['00090','00100','00140'].contains(line.schemaId))
            return ['100', '200', '250', '300', '400', '800'].contains(line.eodRegionalNodes)
        if (['1', '2', '4'].contains(clin) && path == 'X.7' && !['00090','00100','00140'].contains(line.schemaId))
            return line.eodRegionalNodes == '450'
        
        return true
    }

    // ID: IFN3092; NAME: High Risk Histologic Features, Skin, Grade (NAACCR)
    public boolean ifn3092(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.schemaId != '00150' || line.highRiskHistologicFeatures == null || line.highRiskHistologicFeatures == '8')
            return true
        
        if (line.gradeClinical == null && line.gradePathological == null)
            return true
        
        if (line.highRiskHistologicFeatures == '2')
            return line.gradeClinical == '3' || line.gradePathological == '3'
        else if (line.highRiskHistologicFeatures == '4')
            return line.gradeClinical == '4' || line.gradePathological == '4'
            
        return true
    }

    // ID: IFN3094; NAME: Grade, Date of Diagnosis (COC)
    public boolean ifn3094(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return line.grade != null
        else
            return line.grade == null
    }

    // ID: IFN3095; NAME: PhI, II, III Radiation Treatment Modality, External Beam Planning Tech (COC)
    public boolean ifn3095(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018')
            return true
        if (line.phase1RadiationTreatmentModality == null && line.phase2RadiationTreatmentModality == null && line.phase3RadiationTreatmentModality == null)
            return true
        if (line.phase1RadiationExternalBeamTech == null && line.phase2RadiationExternalBeamTech == null && line.phase3RadiationExternalBeamTech == null)
            return true
        
        if (line.phase1RadiationTreatmentModality == '02' && !functions.matches(line.phase1RadiationExternalBeamTech, /^0[1-9]|10$/))
            return false
        else if (line.phase1RadiationTreatmentModality == '03' && !functions.matches(line.phase1RadiationExternalBeamTech, /^0[14-6]$/))
            return false
        else if (line.phase1RadiationTreatmentModality == '04' && !functions.matches(line.phase1RadiationExternalBeamTech, /^0[1345]$/))
            return false
        else if (functions.matches(line.phase1RadiationTreatmentModality, /^0[156]$/) && !functions.matches(line.phase1RadiationExternalBeamTech, /^0[1-9]|10|98$/))
            return false
        else if (functions.matches(line.phase1RadiationTreatmentModality, /^0[7-9]||1[013-6]$/) && line.phase1RadiationExternalBeamTech != '88')
            return false
        else if (line.phase1RadiationTreatmentModality == '12' && line.phase1RadiationExternalBeamTech == '88')
            return false
        
        if (line.phase2RadiationTreatmentModality == '02' && !functions.matches(line.phase2RadiationExternalBeamTech, /^0[1-9]|10$/))
            return false
        else if (line.phase2RadiationTreatmentModality == '03' && !functions.matches(line.phase2RadiationExternalBeamTech, /^0[14-6]$/))
            return false
        else if (line.phase2RadiationTreatmentModality == '04' && !functions.matches(line.phase2RadiationExternalBeamTech, /^0[1345]$/))
            return false
        else if (functions.matches(line.phase2RadiationTreatmentModality, /^0[156]$/) && !functions.matches(line.phase2RadiationExternalBeamTech, /^0[1-9]|10|98$/))
            return false
        else if (functions.matches(line.phase2RadiationTreatmentModality, /^0[7-9]||1[013-6]$/) && line.phase2RadiationExternalBeamTech != '88')
            return false
        else if (line.phase2RadiationTreatmentModality == '12' && line.phase2RadiationExternalBeamTech == '88')
            return false
        
        if (line.phase3RadiationTreatmentModality == '02' && !functions.matches(line.phase3RadiationExternalBeamTech, /^0[1-9]|10$/))
            return false
        else if (line.phase3RadiationTreatmentModality == '03' && !functions.matches(line.phase3RadiationExternalBeamTech, /^0[14-6]$/))
            return false
        else if (line.phase3RadiationTreatmentModality == '04' && !functions.matches(line.phase3RadiationExternalBeamTech, /^0[1345]$/))
            return false
        else if (functions.matches(line.phase3RadiationTreatmentModality, /^0[156]$/) && !functions.matches(line.phase3RadiationExternalBeamTech, /^0[1-9]|10|98$/))
            return false
        else if (functions.matches(line.phase3RadiationTreatmentModality, /^0[7-9]||1[013-6]$/) && line.phase3RadiationExternalBeamTech != '88')
            return false
        else if (line.phase3RadiationTreatmentModality == '12' && line.phase3RadiationExternalBeamTech == '88')
            return false
        
        return true
    }

    // ID: IFN3902; NAME: LDH Level, Melanoma, Schema ID, Required (NAACCR)
    public boolean ifn3902(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00470' || line.ldhPretreatmentLevel != null
    }

    // ID: IFN3903; NAME: AFP Post-Orchiectomy Lab Value, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3903(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00590' || (line.afpPostOrchiectomyLabValue != null && line.afpPostOrchiectomyLabValue != 'XXXXX.8')
    }

    // ID: IFN3905; NAME: AFP Pre-Orchiectomy Range, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3905(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.dateOfDiagnosisYear > '2021' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' || line.registryId == '0000001566')
            return true
        
        return line.schemaId != '00590' || (line.afpPreOrchiectomyRange != null && line.afpPreOrchiectomyRange != '8')
    }

    // ID: IFN3906; NAME: AFP Pretreatment Interpretation, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3906(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00220' || (line.afpPretreatmentInterpretation != null && line.afpPretreatmentInterpretation != '8')
    }

    // ID: IFN3907; NAME: AFP Pretreatment Lab Value, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3907(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00220' || (line.afpPretreatmentLabValue != null && line.afpPretreatmentLabValue != 'XXXX.8')
    }

    // ID: IFN3908; NAME: Bilirubin Pretreatment Total Lab Value, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3908(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00220' || (line.bilirubinPretxTotalLabValue != null && line.bilirubinPretxTotalLabValue != 'XXX.8')
    }

    // ID: IFN3909; NAME: Bilirubin Pretreatment Unit of Measure, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3909(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00220' || (line.bilirubinPretxUnitOfMeasure != null && line.bilirubinPretxUnitOfMeasure != '8')
    }

    // ID: IFN3910; NAME: Chromosome 3 Status, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3910(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
                    return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (line.schemaId == '00671' || line.schemaId == '00672')
            return line.chromosome3Status != '8' && line.chromosome3Status != null
        return true
    }

    // ID: IFN3911; NAME: Chromosome 8q Status, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3911(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (line.schemaId == '00671' || line.schemaId == '00672')
            return line.chromosome8qStatus != null && line.chromosome8qStatus != '8'
        return true
    }

    // ID: IFN3912; NAME: Creatinine Pretreatment Lab Value, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3912(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00220' || (line.creatininePretreatmentLabValue != null && line.creatininePretreatmentLabValue != 'XX.8')
    }

    // ID: IFN3913; NAME: Estrogen Receptor Percent Positive or Range, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3913(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00480' || (line.estrogenReceptorPercntPosOrRange != null && line.estrogenReceptorPercntPosOrRange != 'XX8')
    }

    // ID: IFN3915; NAME: Extranodal Extension Clin (non-Head and Neck), Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3915(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.cocAccreditedFlag != '1' || line.schemaId == null)
            return true
        
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        
        return (line.schemaId != '00460' && line.schemaId != '00570') || (line.extranodalExtensionClin != null && line.extranodalExtensionClin != '8')
    }

    // ID: IFN3916; NAME: Extranodal Extension Head and Neck Clinical, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3916(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.cocAccreditedFlag != '1' || line.schemaId == null)
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return !functions.matches(line.schemaId, /^00(0[689]0|07[1-7]|1[034]0|1[1-3][12]|133)$/) || (line.extranodalExtensionHeadNeckClin != null && line.extranodalExtensionHeadNeckClin != '8')
    }

    // ID: IFN3917; NAME: Extranodal Extension Path (non-Head and Neck), Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3917(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.cocAccreditedFlag != '1' || line.schemaId == null)
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return (line.schemaId != '00460' && line.schemaId != '00570') || (line.extranodalExtensionPath != null && line.extranodalExtensionPath != '8')
    }

    // ID: IFN3918; NAME: Extravascular Matrix Patterns, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3918(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (line.schemaId == '00671' || line.schemaId == '00672')
            return line.extravascularMatrixPatterns != '8' && line.extravascularMatrixPatterns != null
        return true
    }

    // ID: IFN3920; NAME: Fibrosis Score, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3920(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.dateOfDiagnosisYear > '2022' || line.cocAccreditedFlag != '1' || line.schemaId == null)
            return true
            
        return (line.schemaId != '00220' && line.schemaId != '00230') || (line.fibrosisScore != null && line.fibrosisScore != '8')
    }

    // ID: IFN3921; NAME: Gleason Score Clinical, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3921(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.dateOfDiagnosisYear > '2022' || line.cocAccreditedFlag != '1' || line.schemaId == null)
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00580' || (line.gleasonScoreClinical != null && line.gleasonScoreClinical != 'X8')
    }

    // ID: IFN3922; NAME: Gleason Score Pathological, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3922(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.dateOfDiagnosisYear > '2022' || line.cocAccreditedFlag != '1' || line.schemaId == null)
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00580' || (line.gleasonScorePathological != null && line.gleasonScorePathological != 'X8')
    }

    // ID: IFN3923; NAME: Gleason Tertiary Pattern, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3923(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.dateOfDiagnosisYear > '2022' || line.cocAccreditedFlag != '1' || line.schemaId == null)
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00580' || (line.gleasonTertiaryPattern != null && line.gleasonTertiaryPattern != 'X8')
    }

    // ID: IFN3924; NAME: hCG Post-Orchiectomy Lab Value, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3924(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.cocAccreditedFlag != '1' || line.schemaId == null)
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00590' || (line.hcgPostOrchiectomyLabValue != null && line.hcgPostOrchiectomyLabValue != 'XXXXX.8')
    }

    // ID: IFN3925; NAME: hCG Pre-Orchiectomy Lab Value, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3925(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (line.schemaId == '00590')
            return line.hcgPreOrchiectomyLabValue != null && line.hcgPreOrchiectomyLabValue != 'XXXXX.8'
            
        return true
    }

    // ID: IFN3926; NAME: International Normalized Ratio Prothrombin Time, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3926(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (line.schemaId == '00220')
            return line.iNRProthrombinTime != null && line.iNRProthrombinTime != 'X.8'
            
        return true
    }

    // ID: IFN3927; NAME: Ki-67, Breast, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3927(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00480' || (line.ki67 != null && line.ki67 != 'XXX.8')
    }

    // ID: IFN3928; NAME: KIT Gene Immunohistochemistry, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3928(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00430' || (line.kitGeneImmunohistochemistry != null && line.kitGeneImmunohistochemistry != '8')
    }

    // ID: IFN3929; NAME: LDH Upper Limits of Normal, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3929(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (line.schemaId == '00470')
            return line.ldhUpperLimitsOfNormal != null && line.ldhUpperLimitsOfNormal != 'XX8'
        return true
    }

    // ID: IFN3930; NAME: LN Assessment Method Femoral-Inguinal, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3930(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (['00500', '00510', '09500'].contains(line.schemaId))
            return line.lnAssessMethodFemoralInguinal != null && line.lnAssessMethodFemoralInguinal != '8'
            
        return true
    }

    // ID: IFN3931; NAME: LN Assessment Method Para-Aortic, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3931(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (['00510', '00520', '09520'].contains(line.schemaId))
            return line.lnAssessMethodParaaortic != null && line.lnAssessMethodParaaortic != '8'
            
        return true
    }

    // ID: IFN3932; NAME: LN Assessment Method Pelvic, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3932(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (['00500', '00510', '00520', '09520', '09500'].contains(line.schemaId))
            return line.lnAssessMethodPelvic != null && line.lnAssessMethodPelvic != '8'
            
        return true
    }

    // ID: IFN3933; NAME: LN Distant Assessment Method, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3933(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (['00510', '00520', '09520'].contains(line.schemaId))
            return line.lnDistantAssessMethod != null && line.lnDistantAssessMethod != '8'
            
        return true
    }

    // ID: IFN3934; NAME: LN Distant: Mediastinal, Scalene, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3934(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (['00510', '00520', '09520'].contains(line.schemaId))
            return line.lnDistantMediastinalScalene != null && line.lnDistantMediastinalScalene != '8'
            
        return true
    }

    // ID: IFN3935; NAME: Microvascular Density, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3935(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (line.schemaId == '00671' || line.schemaId == '00672')
            return line.microvascularDensity != null && line.microvascularDensity != 'X8'
        return true
    }

    // ID: IFN3936; NAME: Mitotic Count Uveal Melanoma, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3936(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (line.schemaId == '00671' || line.schemaId == '00672')
            return line.mitoticCountUvealMelanoma != null && line.mitoticCountUvealMelanoma != 'XX.8'
            
        return true
    }

    // ID: IFN3937; NAME: Number of Examined Para-Aortic Nodes, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3937(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (functions.matches(line.schemaId, /^005(28|30|4[12])$/))
            return line.numberOfExaminedParaAorticNodes != null && line.numberOfExaminedParaAorticNodes != 'X8'
            
        return true
    }

    // ID: IFN3938; NAME: Number of Examined Pelvic Nodes, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3938(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        String schemaId = line.schemaId
        
        if (schemaId == '00530' || schemaId == '00541' || schemaId == '00542' || (line.dateOfDiagnosisYear >= '2021' && schemaId == '00528'))
            return line.numberOfExaminedPelvicNodes != null && line.numberOfExaminedPelvicNodes != 'X8'
            
        return true
    }

    // ID: IFN3939; NAME: Number of Positive Para-Aortic Nodes, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3939(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        String schemaId = line.schemaId
        if (schemaId == '00530' || schemaId == '00541' || schemaId == '00542' || (line.dateOfDiagnosisYear >= '2021' && schemaId == '00528'))
            return line.numberOfPositiveParaAorticNodes != null && line.numberOfPositiveParaAorticNodes != 'X8'
            
        return true
    }

    // ID: IFN3940; NAME: Number of Positive Pelvic Nodes, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3940(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        String schemaId = line.schemaId
        if (schemaId == '00530' || schemaId == '00541' || schemaId == '00542' ||
        (line.dateOfDiagnosisYear >= '2021' && schemaId == '00528'))
            return line.numberOfPositivePelvicNodes != null && line.numberOfPositivePelvicNodes != 'X8'
            
        return true
    }

    // ID: IFN3941; NAME: Oncotype Dx Recurrence Score-DCIS, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3941(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00480' || (line.oncotypeDxRecurrenceScoreDcis != null && line.oncotypeDxRecurrenceScoreDcis != 'XX8')
    }

    // ID: IFN3942; NAME: Oncotype Dx Risk Level-DCIS, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3942(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00480' || (line.oncotypeDxRiskLevelDcis != null && line.oncotypeDxRiskLevelDcis != '8')
    }

    // ID: IFN3943; NAME: Oncotype Dx Risk Level-Invasive, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3943(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00480' || (line.oncotypeDxRiskLevelInvasive != null && line.oncotypeDxRiskLevelInvasive != '8')
    }

    // ID: IFN3944; NAME: Percent Necrosis Post Neoadjuvant, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3944(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return !functions.matches(line.schemaId, /^0038[1-3]$/) || (line.percentNecrosisPostNeoadjuvant != null && line.percentNecrosisPostNeoadjuvant != 'XXX.8')
    }

    // ID: IFN3945; NAME: Progesterone Receptor Percent Positive or Range, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3945(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00480' || (line.progesteroneRecepPrcntPosOrRange != null && line.progesteroneRecepPrcntPosOrRange != 'XX8')
    }

    // ID: IFN3948; NAME: Response to Neoadjuvant Therapy, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn3948(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00480' || (line.responseToNeoadjuvantTherapy != null && line.responseToNeoadjuvantTherapy != '8')
    }

    // ID: IFN3954; NAME: Ipsilateral Adrenal Gland Involvement, Kidney, EOD Tumor, Mets (SEER)
    public boolean ifn3954(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.schemaId != '00600')
            return true
        
        String ipsilateral = line.ipsilateralAdrenalGlandInvolve
        if (ipsilateral == null || ipsilateral == '8')
            return true
        
        if (ipsilateral == '1')
            return functions.matches(line.eodPrimaryTumor, /^6\d\d|700|999$/)
        else if (ipsilateral == '2' || ipsilateral == '3')
            return line.eodMets == '70'
        
        return true
    }

    // ID: IFN3958; NAME: Separate Tumor Nodules, Lung, EOD Primary Tumor (SEER)
    public boolean ifn3958(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.schemaId != '00360' || line.eodPrimaryTumor == null)
            return true
        
        String separateTumorNodules = line.separateTumorNodules
        if (separateTumorNodules == null || separateTumorNodules == '8')
            return true
        
        if (separateTumorNodules == '1' || separateTumorNodules == '4')
            return functions.matches(line.eodPrimaryTumor, /^[56]\d\d|700|999$/)
        else if (separateTumorNodules == '2' || separateTumorNodules == '3')
            return line.eodPrimaryTumor == '700'
        
        return true
    }

    // ID: IFN3960; NAME: Tumor Deposits, Colorectal, EOD Regional Nodes (SEER)
    public boolean ifn3960(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.eodRegionalNodes == null || line.schemaId != '00200')
            return true
        
        String tumorDeposits = line.tumorDeposits
        String eodRegionalNodes = line.eodRegionalNodes
        if (tumorDeposits == null || tumorDeposits == 'X8')
            return true
        
        if (tumorDeposits == '00' || tumorDeposits == 'X9')
            return eodRegionalNodes != '200'
        else if (functions.matches(tumorDeposits, /^0[1-9]|[1-9]\d|X[12]$/))
            return eodRegionalNodes == '200' || eodRegionalNodes == '300' || eodRegionalNodes == '800'
        
        return true
    }

    // ID: IFN3964; NAME: Regional Nodes Positive, Examined, Primary Site, 2018 (NAACCR)
    public boolean ifn3964(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || (line.regionalNodesExamined == null && line.regionalNodesPositive == null) || line.primarySite == null)
            return true
        
        if (line.regionalNodesExamined != '99' || line.regionalNodesPositive != '99') {
            return !(functions.matches(line.primarySite, /^C(42[0134]|589|7[0127]\d|75[123]|76[1-8]|809)$/)
                || ['00790','00795','00830','99999'].contains(line.schemaId)
                || (line.schemaId == '00822' && line.histologicTypeIcdO3 != '9734'))
        }
        
        return true
    }

    // ID: IFN3968; NAME: RX Date Radiation, PhI Radiation Treatment Modality (NAACCR)
    public boolean ifn3968(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018')
                    return true
        
        if (line.phase1RadiationTreatmentModality == '00' || line.phase1RadiationTreatmentModality == '99')
            return line.rxDateRadiationDay == null && line.rxDateRadiationMonth == null && line.rxDateRadiationYear == null
        
        if (line.rxDateRadiationDay != null || line.rxDateRadiationMonth != null || line.rxDateRadiationYear != null)
            return functions.matches(line.phase1RadiationTreatmentModality, /^0[1-9]|1[0-6]|98$/)
        
        return true
                    
    }

    // ID: IFN3969; NAME: Reason for No Radiation, PhI Radiation Treatment Modality (NAACCR)
    public boolean ifn3969(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.phase1RadiationTreatmentModality == null || line.reasonForNoRadiation == null || line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018')
                    return true
        
        if (line.reasonForNoRadiation == '0')
            return functions.matches(line.phase1RadiationTreatmentModality, /^0[1-9]|1[0-6]|98$/)
        
        if (functions.matches(line.reasonForNoRadiation, /^[125-7]$/))
            return line.phase1RadiationTreatmentModality == '00'
        
        if (line.reasonForNoRadiation == '8')
            return line.phase1RadiationTreatmentModality == '00' || line.phase1RadiationTreatmentModality == '99'
        
        if (line.reasonForNoRadiation == '9')
            return line.phase1RadiationTreatmentModality == '99'
        
        return true
    }

    // ID: IFN3970; NAME: Date of Sentinel Lymph Node Biopsy, Date DX (SEER)
    public boolean ifn3970(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return line.dateSentinelLymphNodeBiopsyYear == null
        
        return true
    }

    // ID: IFN3971; NAME: Sentinel Lymph Nodes Pos/Ex, Schema ID, Date DX (SEER)
    public boolean ifn3971(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return line.sentinelLymphNodesExamined == null && line.sentinelLymphNodesPositive == null
        
        if (line.schemaId == '00470' || line.schemaId == '00480')
            return line.sentinelLymphNodesExamined != null && line.sentinelLymphNodesPositive != null
                
        return true
    }

    // ID: IFN3972; NAME: Summary Stage 2018, Date of DX (SEER)
    public boolean ifn3972(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear > '2017' || line.summaryStage2018 == null
    }

    // ID: IFN3975; NAME: Oncotype Dx Risk Level-Invasive, Breast, Behavior (NAACCR)
    public boolean ifn3975(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId != '00480')
        return true
        
        if (line.oncotypeDxRiskLevelInvasive == null || line.oncotypeDxRiskLevelInvasive == '8')
            return true
        
        if (line.behaviorCodeIcdO3 == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true 
        
        if (line.behaviorCodeIcdO3 == '2')
            return line.oncotypeDxRiskLevelInvasive == '6'
            
        return line.oncotypeDxRiskLevelInvasive != '6'
    }

    // ID: IFN3985; NAME: Lymphovascular Invasion, Penis, EOD Primary Tumor (SEER)
    public boolean ifn3985(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.schemaId != '00570' || line.eodPrimaryTumor == null)
            return true
        
        String lymphVascularInvasion = line.lymphVascularInvasion
        if (lymphVascularInvasion == null || lymphVascularInvasion == '8')
            return true
        
        if (functions.matches(lymphVascularInvasion, /^[1-4]$/))
            return functions.matches(line.eodPrimaryTumor, /^200|[456]\d\d|700|999$/)
        
        return true
    }

    // ID: IFN3986; NAME: Lymphovascular Invasion, Testis, EOD Primary Tumor (SEER)
    public boolean ifn3986(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.schemaId != '00590' || line.eodPrimaryTumor == null)
            return true
        
        String lymphVascularInvasion = line.lymphVascularInvasion
        if (lymphVascularInvasion == null || lymphVascularInvasion == '8')
            return true
        
        if (functions.matches(lymphVascularInvasion, /^[1-4]$/) && !functions.matches(line.eodPrimaryTumor, /^[3-6]\d\d|700|999$/))
            return false
        
        if (line.eodPrimaryTumor == '300' && !functions.matches(line.lymphVascularInvasion, /^[1-4]$/))
            return false
        
        if (functions.matches(line.eodPrimaryTumor, /^[12]00|150$/) && !['0','9'].contains(line.lymphVascularInvasion))
            return false
        
        return true
    }

    // ID: IFN3987; NAME: TNM Edition Number, AJCC ID (COC)
    public boolean ifn3987(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.tnmEditionNumber == null || line.ajccId == null || line.typeOfReportingSource == '7')
            return true
            
        if (line.ajccId == 'XX')
            return line.tnmEditionNumber == '88'
        else
            return line.dateOfDiagnosisYear < '2022' || line.tnmEditionNumber != '88'
    }

    // ID: IFN3988; NAME: SEER Site-Specific Fact 1, Date DX (SEER)
    public boolean ifn3988(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
            
        if (line.dateOfDiagnosisYear < '2018')
            return line.seerSiteSpecificFact1 == null 
            
        return line.seerSiteSpecificFact1 == null || functions.matches(line.seerSiteSpecificFact1, /^(1[01]|2[01]|3[01]|4[01]|5[01]|7[01]|9[79])$/)
    }

    // ID: IFN3989; NAME: SEER Site-Specific Fact 1, Schema ID, Required (SEER)
    public boolean ifn3989(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        
        return !functions.matches(line.schemaId, /^00(07[1-7]|100|11[12])$/) || line.seerSiteSpecificFact1 != null
    }

    // ID: IFN3990; NAME: SSDI for Breast, Blank for Other Schemas (NAACCR)
    public boolean ifn3990(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.schemaId == '00480')
            return true
        
        if (line.dateOfDiagnosisYear < '2021' && (line.ki67 != null || line.her2OverallSummary != null))
            return false
        
        boolean isEstrogenBlank = line.estrogenReceptorPercntPosOrRange == null && line.estrogenReceptorSummary == null
        boolean isMultigeneBlank = line.multigeneSignatureMethod == null && line.multigeneSignatureResults == null
        boolean isOncBlank = line.oncotypeDxRecurrenceScoreDcis == null && line.oncotypeDxRecurrenceScoreInvasiv == null && line.oncotypeDxRiskLevelDcis == null && line.oncotypeDxRiskLevelInvasive == null
        boolean isProgBlank = line.progesteroneRecepPrcntPosOrRange == null && line.progesteroneRecepSummary == null
        boolean isOthersBlank = line.lnPositiveAxillaryLevel1To2 == null && line.responseToNeoadjuvantTherapy == null
        
        return isEstrogenBlank && isMultigeneBlank && isOncBlank && isProgBlank && isOthersBlank
    }

    // ID: IFN3991; NAME: SSDI for Prostate, Blank for Other Schemas (NAACCR)
    public boolean ifn3991(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.schemaId == '00580')
            return true
            
        boolean isGleasonBlank = line.gleasonPatternsClinical == null && line.gleasonPatternsPathological == null && line.gleasonScoreClinical == null && line.gleasonScorePathological == null && line.gleasonTertiaryPattern == null
        boolean isnumCoresBlank = line.numberOfCoresExamined == null && line.numberOfCoresPositive == null
        
        return isGleasonBlank && isnumCoresBlank && line.psaLabValue == null
    }

    // ID: IFN3992; NAME: SSDI for Testis, Blank for Other Schemas (NAACCR)
    public boolean ifn3992(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.schemaId == '00590')
            return true
            
        boolean isAfpBlank = line.afpPostOrchiectomyLabValue == null && line.afpPostOrchiectomyRange == null && line.afpPreOrchiectomyLabValue == null && line.afpPreOrchiectomyRange == null
        boolean isHcgBlank = line.hcgPostOrchiectomyLabValue == null && line.hcgPostOrchiectomyRange == null && line.hcgPreOrchiectomyLabValue == null && line.hcgPreOrchiectomyRange == null
        boolean isLdhBlank = line.ldhPostOrchiectomyRange == null && line.ldhPreOrchiectomyRange == null
        boolean isSCatBlank = line.sCategoryClinical == null && line.sCategoryPathological == null
        
        return isAfpBlank && isHcgBlank && isLdhBlank && isSCatBlank
    }

    // ID: IFN3993; NAME: SSDI for Kidney, Blank for Other Schemas (NAACCR)
    public boolean ifn3993(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.schemaId == '00600')
            return true
               
        return line.invasionBeyondCapsule == null && line.ipsilateralAdrenalGlandInvolve == null && line.majorVeinInvolvement == null && line.sarcomatoidFeatures == null
    }

    // ID: IFN3994; NAME: SSDI for Liver & Biliary, Blank for Other Schemas (NAACCR)
    public boolean ifn3994(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null)
            return true
            
        if (line.schemaId != '00220'){
            if (line.afpPretreatmentInterpretation != null || line.afpPretreatmentLabValue != null)
                return false
        
            if (line.bilirubinPretxTotalLabValue != null || line.bilirubinPretxUnitOfMeasure != null)
                return false
        
            if (line.creatininePretreatmentLabValue != null || line.creatininePretxUnitOfMeasure != null || line.iNRProthrombinTime != null)
                return false
        }
            
        if (line.schemaId != '00230' && line.schemaId != '00220' && line.fibrosisScore != null)
            return false
        
        return true
    }

    // ID: IFN3995; NAME: SSDI for Head & Neck, Blank for Other Schemas (NAACCR)
    public boolean ifn3995(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null)
            return true
        
        boolean isBlankLn = line.lnHeadAndNeckLevels1To3 == null && line.lnHeadAndNeckLevels4To5 == null && line.lnHeadAndNeckLevels6To7 == null && line.lnHeadAndNeckOther == null
        boolean isBlankExtranodal = line.extranodalExtensionHeadNeckClin == null && line.extranodalExtensionHeadNeckPath == null
        
        if (line.schemaId != '00060' && line.schemaId != '00140' && !isBlankLn)
            return false
        
        if (!functions.matches(line.schemaId, /^00(07[1-7]|100|11[12])$/) && line.seerSiteSpecificFact1 != null)
            return false
           
        if (!functions.matches(line.schemaId, /^00(0([689]0|7[1-7])|1([034]0|[1-3][12]|33))$/)) {
            if (!isBlankExtranodal)
                return false
            if (line.schemaId != '00150' && line.lnSize != null)
                return false  
        }
        
        return true
    }

    // ID: IFN3996; NAME: SSDI for Esophagus, Blank for Other Schemas (NAACCR)
    public boolean ifn3996(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.schemaId == '00161')
            return true
        
        return line.esophagusAndEgjTumorEpicenter == null
    }

    // ID: IFN3997; NAME: SSDI for Appendix & Colorectal, Blank for Other Schemas (NAACCR)
    public boolean ifn3997(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null)
            return true
            
        if (line.schemaId != '09190' && line.histologicSubtype != null)
            return false
        
        if (line.schemaId != '00200'){
            
            if (line.kras != null || line.circumferentialResectionMargin != null || line.microsatelliteInstability != null || line.tumorDeposits != null)
                return false
            else if (line.brafMutationalAnalysis != null || line.nrasMutationalAnalysis != null)
                return false
            
            if (line.schemaId != '00190' && line.schemaId != '09190' && (line.ceaPretreatmentInterpretation != null || line.ceaPretreatmentLabValue != null))
                return false    
        }
        
        return true
    }

    // ID: IFN3998; NAME: SSDI for Lung & Pleura, Blank for Other Schemas (NAACCR)
    public boolean ifn3998(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null)
            return true
        
        boolean ssdisAreBlank = line.separateTumorNodules == null && line.visceralParietalPleuralInvasion == null && line.alkRearrangement == null && line.egfrMutationalAnalysis == null
        if (line.schemaId != '00360' && !ssdisAreBlank)
            return false
        
        if (line.schemaId != '00370' && line.pleuralEffusion != null)
            return false
        
        return true
    }

    // ID: IFN3999; NAME: SSDI for Bone, Blank for Other Schemas (NAACCR)
    public boolean ifn3999(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null)
            return true
        
        if (!functions.matches(line.schemaId, /^0038[1-3]$/) && line.percentNecrosisPostNeoadjuvant != null)
            return false
        
        return true
    }

    // ID: IFN4000; NAME: SSDI for Soft Tissue, Blank for Other Schemas (NAACCR)
    public boolean ifn4000(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null)
            return true
            
        return functions.matches(line.schemaId, /^004([014]0|2[12]|5[09])$/) || line.boneInvasion == null
    }

    // ID: IFN4001; NAME: SSDI for GIST, Blank for Other Schemas (NAACCR)
    public boolean ifn4001(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.schemaId == '00430')
            return true
            
        return line.kitGeneImmunohistochemistry == null
    }

    // ID: IFN4002; NAME: SSDI for Skin, Blank for Other Schemas (NAACCR)
    public boolean ifn4002(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null)
            return true
            
        if (line.schemaId != '00150' && line.highRiskHistologicFeatures != null)
            return false
            
        if (line.schemaId != '00460' && (line.lnIsolatedTumorCells != null || line.profoundImmuneSuppression != null))
            return false
         
        boolean isBlankLdh = line.ldhPretreatmentLabValue == null && line.ldhUpperLimitsOfNormal == null
        if (line.schemaId != '00470' && (line.breslowTumorThickness != null || line.clinicalMarginWidth != null || line.mitoticRateMelanoma != null || line.ulceration != null || !isBlankLdh))
            return false
            
        return true
    }

    // ID: IFN4003; NAME: SSDI for Vulva, Vagina, Cervix, Blank for Other Schemas (NAACCR)
    public boolean ifn4003(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null)
            return true
            
        if (!['00500', '09500'].contains(line.schemaId) && line.lnLaterality != null)
            return false
        
        if (!['00500', '09500', '00510'].contains(line.schemaId) && (line.lnAssessMethodFemoralInguinal != null || line.lnStatusFemoralInguinal != null))
            return false
             
        if (!['00500', '09500', '00510', '00520', '09520'].contains(line.schemaId) && (line.lnAssessMethodPelvic != null || line.lnStatusPelvic != null))
            return false
            
        boolean ssdisAreBlank = (line.lnAssessMethodParaaortic == null && line.lnDistantAssessMethod == null && line.lnDistantMediastinalScalene == null && line.lnStatusParaAortic == null) 
        if (!['00510', '00520', '09520'].contains(line.schemaId) && !ssdisAreBlank)
            return false
            
        return true
    }

    // ID: IFN4004; NAME: SSDI for Corpus Uteri, Blank for Other Schemas (NAACCR)
    public boolean ifn4004(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null)
            return true
        
        if (!['00530', '00541', '00542', '00528'].contains(line.schemaId))
            return line.numberOfPositiveParaAorticNodes == null && line.numberOfExaminedParaAorticNodes == null && line.numberOfPositivePelvicNodes == null &&
                   line.numberOfExaminedPelvicNodes == null && line.peritonealCytology == null
            
        return true
    }

    // ID: IFN4005; NAME: SSDI for Ovary, Fallopian Tube, Primary Peritoneal, Blank for Other Schemas (NAACCR)
    public boolean ifn4005(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null)
            return true
        
        if (line.schemaId != '00551' && line.schemaId != '00552' && line.schemaId != '00553')
            return line.ca125PretreatmentInterpretation == null && line.residualTumVolPostCytoreduction == null
            
        return true
    }

    // ID: IFN4006; NAME: SSDI for Placenta, Blank for Other Schemas (NAACCR)
    public boolean ifn4006(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.schemaId == '00560')
            return true
            
        return line.gestationalTrophoblasticPxIndex == null
    }

    // ID: IFN4007; NAME: SSDI for Ophthalmic Melanoma, Blank for Other Schemas (NAACCR)
    public boolean ifn4007(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null)
            return true
            
        if (line.schemaId != '00671' && line.schemaId != '00672') {
            if (line.schemaId != '00660' && line.measuredThickness != null)
                return false
                
            if (line.chromosome3Status != null || line.chromosome8qStatus != null || line.extravascularMatrixPatterns != null)
                return false
                
            if (line.measuredBasalDiameter != null || line.microvascularDensity != null || line.mitoticCountUvealMelanoma != null)
                return false
        }
           
        return true
    }

    // ID: IFN4008; NAME: SSDI for Retinoblastoma, Blank for Other Schemas (NAACCR)
    public boolean ifn4008(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null)
            return true
        
        if (line.schemaId != '00680')
            return line.heritableTrait == null
            
        return true
    }

    // ID: IFN4009; NAME: SSDI for Lacrimal Gland, Blank for Other Schemas (NAACCR)
    public boolean ifn4009(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.schemaId == '00690')
            return true
        
        return line.adenoidCysticBasaloidPattern == null
    }

    // ID: IFN4010; NAME: SSDI for Brain, CNS, Blank for Other Schemas (NAACCR)
    public boolean ifn4010(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null)
            return true
        
        if (!['00721','09721','00722','09722','09724'].contains(line.schemaId))
            return line.brainPrimaryTumorLocation == null && line.brainMolecularMarkers == null && line.chromosome1pLossHeterozygosity == null && line.chromosome19qLossHeterozygosity == null && line.methylationOfO6MGMT == null
        if (!['00721','09721','00722','09722'].contains(line.schemaId))
            return line.brainPrimaryTumorLocation == null && line.chromosome1pLossHeterozygosity == null && line.chromosome19qLossHeterozygosity == null && line.methylationOfO6MGMT == null
        if (line.schemaId != '09721')
            return line.brainPrimaryTumorLocation == null
        
        
        return true
    }

    // ID: IFN4011; NAME: SSDI for Lymphoma, Blank for Other Schemas (NAACCR)
    public boolean ifn4011(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null)
            return true
            
        if (line.schemaId != '00790' && line.schemaId != '00795' && (line.bSymptoms != null || line.hivStatus != null || line.nccnInternationalPrognosticIndex != null))
            return false
        if (line.schemaId != '00795' && (line.adenopathy != null || line.anemia != null || line.derivedRaiStage != null || line.lymphocytosis != null || line.organomegaly != null || line.thrombocytopenia != null))
            return false
            
        return true
    }

    // ID: IFN4012; NAME: SSDI for Plasma Cell Myeloma, Blank for Other Schemas (NAACCR)
    public boolean ifn4012(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.schemaId == '00821')
            return true
            
        return line.highRiskCytogenetics == null && line.serumAlbuminPretreatmentLevel == null && line.serumBeta2MicroglobulinPretxLvl == null
    }

    // ID: IFN4013; NAME: SSDI for HemeRetic, Blank for Other Schemas (NAACCR)
    public boolean ifn4013(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.schemaId == '00830')
            return true
            
        return line.jak2 == null
    }

    // ID: IFN4014; NAME: SSDI Perineural Invasion, Blank for Other Schemas (NAACCR)
    public boolean ifn4014(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null)
            return true
            
        String id = line.schemaId    
        return id == '00150' || id == '00200' || id == '00640' || id == '00690' || line.perineuralInvasion == null
    }

    // ID: IFN4015; NAME: SSDI Extranodal Extension non-H&N, Blank for Other Schemas (NAACCR)
    public boolean ifn4015(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null)
            return true
            
        return (line.schemaId == '00460' || line.schemaId == '00570') || (line.extranodalExtensionPath == null && line.extranodalExtensionClin == null)
    }

    // ID: IFN4016; NAME: SSDI LDH Level, Blank for Other Schemas (NAACCR)
    public boolean ifn4016(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null)
            return true
            
        return line.schemaId == '00470' || line.schemaId == '00821' || line.ldhPretreatmentLevel == null
    }

    // ID: IFN4017; NAME: SSDI FIGO Stage, Blank for Other Schemas (NAACCR)
    public boolean ifn4017(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null)
            return true
        
        String[] schemaIds = ['00500','09500','00510','00520','09520','00530','00541','00542','00551','00552','00553','00560','00528']
        if (!schemaIds.contains(line.schemaId))
            return line.figoStage == null
            
        return true
    }

    // ID: IFN4018; NAME: SSDI for Mycosis Fungoides, Blank for Other Schemas (NAACCR)
    public boolean ifn4018(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.schemaId == '00811')
            return true
            
        return line.peripheralBloodInvolvement == null
    }

    // ID: IFN4200; NAME: PhI Radiation External Beam Planning Tech, Date DX, CoC Flag (SEER)
    public boolean ifn4200(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.cocAccreditedFlag != '1' || line.typeOfReportingSource == '7')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        
        if (line.phase1RadiationTreatmentModality == '00' || line.phase1RadiationTreatmentModality == '99')
            return true
        
        return line.phase1RadiationExternalBeamTech != null
    }

    // ID: IFN4201; NAME: PhI, II, III Radiation External Beam Planning Tech (SEER)
    public boolean ifn4201(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018')
            return true
        if (line.phase1RadiationExternalBeamTech == null && line.phase2RadiationExternalBeamTech == null && line.phase3RadiationExternalBeamTech == null)
            return true
        
        if (line.phase2RadiationExternalBeamTech != null && line.phase1RadiationExternalBeamTech == null)
            return false
        if (line.phase1RadiationExternalBeamTech == '00' && line.phase2RadiationExternalBeamTech != '00' && line.phase2RadiationExternalBeamTech != null)
            return false
        if (line.phase3RadiationExternalBeamTech != null && line.phase2RadiationExternalBeamTech == null)
            return false
        if (line.phase2RadiationExternalBeamTech == '00' && line.phase3RadiationExternalBeamTech != '00' && line.phase3RadiationExternalBeamTech != null)
            return false
        
        return true
    }

    // ID: IFN4205; NAME: _SYS AJCC ID, Site, Histo, Age (NAACCR)
    public boolean ifn4205(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.ageAtDiagnosis == null || line.primarySite == null || line.histologicTypeIcdO3 == null)
            return true
        
        if (line.primarySite == 'C421' && functions.matches(line.histologicTypeIcdO3, /^981[1-8]|983[5-7]$/)) {
            Integer ageInt = functions.asInt(line.ageAtDiagnosis)
            if (line.ajccId == '83.2')
                return ageInt == 999 || (0 <= ageInt && ageInt <= 19)
            else if (line.ajccId == '83.3')
                return (20 <= ageInt && ageInt <= 120)
        }
        
        return true
    }

    // ID: IFN4210; NAME: Date Regional Lymph Node Dissection, RX Date Surgery (NAACCR)
    public boolean ifn4210(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.rxDateSurgeryYear == null || line.dateRegionalLNDissectionYear == null || line.dateOfDiagnosisYear < '2019')
            return true
        
        if (line.rxDateSurgeryYear > line.dateRegionalLNDissectionYear)
            return false
        
        if (line.rxDateSurgeryYear < line.dateRegionalLNDissectionYear || line.rxDateSurgeryMonth == null || line.dateRegionalLNDissectionMonth == null)
            return true
        
        if (line.rxDateSurgeryMonth > line.dateRegionalLNDissectionMonth)
            return false
        
        if (line.rxDateSurgeryMonth < line.dateRegionalLNDissectionMonth || line.rxDateSurgeryDay == null || line.dateRegionalLNDissectionDay == null)
            return true
        
        return line.rxDateSurgeryDay <= line.dateRegionalLNDissectionDay
    }

    // ID: IFN4214; NAME: Gleason Score Clinical, Grade Clinical (NAACCR)
    public boolean ifn4214(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId != '00580' || line.gradeClinical == null)
            return true
        
        String gleason = line.gleasonScoreClinical
        if (gleason == null || gleason == 'X8' || gleason == 'X9')
            return true 
        
        if (functions.matches(gleason, /^0[1-6]$/))
            return line.gradeClinical == '1'
        else if (gleason == '07')
            return line.gradeClinical == '2' || line.gradeClinical == '3' || line.gradeClinical == 'E'
        else if (gleason == '08')
            return line.gradeClinical == '4'
        else if (gleason == '09' || gleason == '10')
            return line.gradeClinical == '5'
        
        return true
    }

    // ID: IFN4900; NAME: Summary Stage 2018, Schema ID (NAACCR)
    public boolean ifn4900(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.summaryStage2018 == null)
            return true
        
        List validCode = (List)((Map)context.IFN_SS2018_Table).get(line.schemaId)
        if (validCode == null)
            return functions.matches(line.summaryStage2018, /^[0-479]$/)
        
        return validCode.contains(line.summaryStage2018)
    }

    // ID: IFN4903; NAME: TNM Items, DX Post 2017 (NAACCR)
    public boolean ifn4903(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
            
        boolean clinAllBlank = line.tnmClinT == null && line.tnmClinN == null && line.tnmClinM == null && line.tnmClinStageGroup == null && line.tnmClinDescriptor == null
        
        boolean pathAllBlank = line.tnmPathT == null && line.tnmPathN == null && line.tnmPathM == null && line.tnmPathStageGroup == null && line.tnmPathDescriptor == null
        
        return line.dateOfDiagnosisYear < '2018' || (clinAllBlank && pathAllBlank)
    }

    // ID: IFN4904; NAME: Derived EOD 2018, Date of DX (SEER)
    public boolean ifn4904(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear > '2017')
            return true
        
        return line.derivedEod2018T == null && line.derivedEod2018N == null && line.derivedEod2018M == null && line.derivedEod2018StageGroup == null
    }

    // ID: IFN4906; NAME: Summary Stage 2000, Date of Diagnosis (SEER)
    public boolean ifn4906(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2016')
            return true
        
        if (line.dateOfDiagnosisYear == '2016' || line.dateOfDiagnosisYear == '2017')
            return line.seerSummaryStage2000 != null || line.derivedSs2000 != null
        else if (line.dateOfDiagnosisYear >= '2018')
            return line.seerSummaryStage2000 == null
            
        return true
    }

    // ID: IFN4910; NAME: Derived Summary Stage 2018, Schema ID (SEER)
    public boolean ifn4910(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.derivedSummaryStage2018 == null)
            return true
        
        List validCode = (List)((Map)context.IFN_SS2018_Table).get(line.schemaId)
        if (validCode == null)
            return functions.matches(line.derivedSummaryStage2018, /^[0-479]$/)
        
        return validCode.contains(line.derivedSummaryStage2018)
    }

    // ID: IFN4911; NAME: Histologic Type ICDO3, Primary Site, Date of Diagnosis (NAACCR)
    public boolean ifn4911(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.histologicTypeIcdO3 == null)
            return true
        
        String histology = line.histologicTypeIcdO3
        String site = line.primarySite
        
        if (line.behaviorCodeIcdO3 == '2' && (histology == '8230' || histology == '8032'))
            return true
        
        if (histology == '8510' && site == 'C739')
            return false
        
        if (histology == '8550' && functions.matches(site, /^C34\d$/))
            return false
        
        Integer siteInt = -1
        if (site != null && functions.matches(site, /^C\d\d\d$/))
            siteInt = functions.asInt(site.substring(1,4))
        if (line.dateOfDiagnosisYear >= '2019') {
            if (functions.matches(histology, /^825[3467]$/) && !functions.matches(site, /^C34\d$/))
                return false
        
            if (line.dateOfDiagnosisYear <= '2020' && histology == '9150' && (line.gradeClinical == '4' || line.gradePathological == '4'))
                return true
        
            List invalidHistologies = (List)((Map)context.IFN4911_Table).get(siteInt)
            if (invalidHistologies != null && invalidHistologies.contains(histology))
                return false
        }
        
        if (line.dateOfDiagnosisYear >= '2024') {
            List invalidHistologies = (List)((Map)context.IFN4911_2024_Table).get(siteInt)
            if (invalidHistologies != null && invalidHistologies.contains(histology))
                return false
        }
        
        return true
    }

    // ID: IFN4914; NAME: Grade Path, Grade Post Therapy (NAACCR)
    public boolean ifn4914(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018')
            return true
        
        if (functions.matches(line.schemaId, /^00(79[05]|8[12][12]|830)$/))
            return true
        
        return line.gradePostTherapy == null || line.gradePathological == '9'
    }

    // ID: IFN4928; NAME: PhI, II, III Radiation Treatment Modality (SEER)
    public boolean ifn4928(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018')
            return true
        
        if (line.phase1RadiationTreatmentModality == null && line.phase2RadiationTreatmentModality == null && line.phase3RadiationTreatmentModality == null)
            return true
        
        if (line.phase2RadiationTreatmentModality != null && line.phase1RadiationTreatmentModality == null)
            return false
        
        if (line.phase1RadiationTreatmentModality == '00' && line.phase2RadiationTreatmentModality != null && line.phase2RadiationTreatmentModality != '00')
            return false
        
        if (line.phase3RadiationTreatmentModality != null && line.phase2RadiationTreatmentModality == null)
            return false
        
        if (line.phase2RadiationTreatmentModality == '00' && line.phase3RadiationTreatmentModality != null && line.phase3RadiationTreatmentModality != '00')
            return false
        
        return true
    }

    // ID: IFN4929; NAME: Surgery 03-2022, Phase I Rad, Surg/Rad Seq (SEER)
    public boolean ifn4929(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.dateOfDiagnosisYear > '2022' || line.rxSummSurgPrimSite == null || line.rxSummScopeRegLnSur == null || line.rxSummSurgOthRegDis == null)
            return true
        
        boolean primSiteIndicatesPerformed = functions.matches(line.rxSummSurgPrimSite, /^[1-8]\d|90$/)
        boolean scopeIndicatesPerformed = functions.matches(line.rxSummScopeRegLnSur, /^[3-7]$/) ||
            (line.rxSummScopeRegLnSur == '2' && line.dateOfDiagnosisYear >= '2021') ||
            (line.rxSummScopeRegLnSur == '2' && line.dateOfDiagnosisYear >= '2018' && functions.matches(line.regionalNodesExamined, /^0[1-9]|[1-8]\d|9[0-8]$/))
        boolean othIndicatesPerformed = functions.matches(line.rxSummSurgOthRegDis, /^[1-5]$/)
        
        boolean surgeryPerformed = primSiteIndicatesPerformed || scopeIndicatesPerformed || othIndicatesPerformed
        
        if (surgeryPerformed && functions.matches(line.phase1RadiationTreatmentModality, /^0[1-9]|1[0-6]|98$/))
            return functions.matches(line.rxSummSurgRadSeq, /^[2-79]$/)
        
        boolean surgeryNotPerformed = (line.rxSummSurgPrimSite == '00' || line.rxSummSurgPrimSite == '98' || line.rxSummSurgPrimSite == '99') && (line.rxSummScopeRegLnSur == '0' || (line.rxSummScopeRegLnSur == '1' && line.dateOfDiagnosisYear >= '2021')) && line.rxSummSurgOthRegDis == '0'
        if (surgeryNotPerformed || line.phase1RadiationTreatmentModality == '00' || line.phase1RadiationTreatmentModality == '99')
            return line.rxSummSurgRadSeq == '0'
        
        return true
    }

    // ID: IFN4931; NAME: SSDI, DCO (NAACCR)
    public boolean ifn4931(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource != '7')
            return true
        
        if (line.adenoidCysticBasaloidPattern != null && line.adenoidCysticBasaloidPattern != 'XXX.9')
            return false
        if (line.adenopathy != null && line.adenopathy != '9')
            return false
        if (line.afpPostOrchiectomyLabValue != null && line.afpPostOrchiectomyLabValue != 'XXXXX.9')
            return false
        if (line.afpPostOrchiectomyRange != null && line.afpPostOrchiectomyRange != '9')
            return false
        if (line.afpPreOrchiectomyLabValue != null && line.afpPreOrchiectomyLabValue != 'XXXXX.9')
            return false
        if (line.afpPreOrchiectomyRange != null && line.afpPreOrchiectomyRange != '9')
            return false
        if (line.afpPretreatmentInterpretation != null && line.afpPretreatmentInterpretation != '9')
            return false
        if (line.afpPretreatmentLabValue != null && line.afpPretreatmentLabValue != 'XXXX.9')
            return false
        if (line.alkRearrangement != null && line.alkRearrangement != '9')
            return false
        if (line.anemia != null && line.anemia != '9')
            return false
        if (line.bSymptoms != null && line.bSymptoms != '9')
            return false
        if (line.bilirubinPretxTotalLabValue != null && line.bilirubinPretxTotalLabValue != 'XXX.9')
            return false
        if (line.bilirubinPretxUnitOfMeasure != null && line.bilirubinPretxUnitOfMeasure != '9')
            return false
        if (line.boneInvasion != null && line.boneInvasion != '9')
            return false
        if (line.brafMutationalAnalysis != null && line.brafMutationalAnalysis != '9')
            return false
        if (line.brainMolecularMarkers != null && line.brainMolecularMarkers != '99')
            return false
        if (line.breslowTumorThickness != null && line.breslowTumorThickness != 'XX.9')
            return false
        if (line.ca199PretxLabValue != null && line.ca199PretxLabValue != 'XXXX.9')
            return false
        if (line.ca125PretreatmentInterpretation != null && line.ca125PretreatmentInterpretation != '9')
            return false
        if (line.ceaPretreatmentInterpretation != null && line.ceaPretreatmentInterpretation != '9')
            return false
        if (line.chromosome19qLossHeterozygosity != null && line.chromosome19qLossHeterozygosity != '9')
            return false
        if (line.chromosome1pLossHeterozygosity != null && line.chromosome1pLossHeterozygosity != '9')
            return false
        if (line.chromosome3Status != null && line.chromosome3Status != '9')
            return false
        if (line.chromosome8qStatus != null && line.chromosome8qStatus != '9')
            return false
        if (line.circumferentialResectionMargin != null && line.circumferentialResectionMargin != '9')
            return false
        if (line.clinicalMarginWidth != null && line.clinicalMarginWidth != 'XX.9')
            return false
        if (line.creatininePretreatmentLabValue != null && line.creatininePretreatmentLabValue != 'XX.9')
            return false
        if (line.creatininePretxUnitOfMeasure != null && line.creatininePretxUnitOfMeasure != '9')
            return false
        if (line.derivedRaiStage != null && line.derivedRaiStage != '9')
            return false
        if (line.egfrMutationalAnalysis != null && line.egfrMutationalAnalysis != '9')
            return false
        if (line.esophagusAndEgjTumorEpicenter != null && line.esophagusAndEgjTumorEpicenter != '9')
            return false
        if (line.estrogenReceptorPercntPosOrRange != null && line.estrogenReceptorPercntPosOrRange != 'XX9')
            return false
        if (line.estrogenReceptorSummary != null && line.estrogenReceptorSummary != '9')
            return false
        if (line.extranodalExtensionClin != null && line.extranodalExtensionClin != '9')
            return false
        if (line.extranodalExtensionHeadNeckClin != null && line.extranodalExtensionHeadNeckClin != '9')
            return false
        if (line.extranodalExtensionHeadNeckPath != null && line.extranodalExtensionHeadNeckPath != 'X.9')
            return false
        if (line.extranodalExtensionPath != null && line.extranodalExtensionPath != '9')
            return false
        if (line.extravascularMatrixPatterns != null && line.extravascularMatrixPatterns != '9')
            return false
        if (line.fibrosisScore != null && line.fibrosisScore != '9')
            return false
        if (line.figoStage != null && line.figoStage != '99')
            return false
        if (line.gestationalTrophoblasticPxIndex != null && line.gestationalTrophoblasticPxIndex != 'X9')
            return false
        if (line.gleasonPatternsClinical != null && line.gleasonPatternsClinical != 'X9')
            return false
        if (line.gleasonPatternsPathological != null && line.gleasonPatternsPathological != 'X9')
            return false
        if (line.gleasonScoreClinical != null && line.gleasonScoreClinical != 'X9')
            return false
        if (line.gleasonScorePathological != null && line.gleasonScorePathological != 'X9')
            return false
        if (line.gleasonTertiaryPattern != null && line.gleasonTertiaryPattern != 'X9')
            return false
        if (line.hcgPostOrchiectomyLabValue != null && line.hcgPostOrchiectomyLabValue != 'XXXXX.9')
            return false
        if (line.hcgPostOrchiectomyRange != null && line.hcgPostOrchiectomyRange != '9')
            return false
        if (line.hcgPreOrchiectomyLabValue != null && line.hcgPreOrchiectomyLabValue != 'XXXXX.9')
            return false
        if (line.hcgPreOrchiectomyRange != null && line.hcgPreOrchiectomyRange != '9')
            return false
        if (line.her2OverallSummary != null && line.her2OverallSummary != '9')
            return false
        if (line.heritableTrait != null && line.heritableTrait != '9')
            return false
        if (line.highRiskCytogenetics != null && line.highRiskCytogenetics != '9')
            return false
        if (line.highRiskHistologicFeatures != null && line.highRiskHistologicFeatures != '9')
            return false
        if (line.histologicSubtype != null && line.histologicSubtype != '0')
            return false
        if (line.hivStatus != null && line.hivStatus != '9')
            return false
        if (line.iNRProthrombinTime != null && line.iNRProthrombinTime != 'X.9')
            return false
        if (line.invasionBeyondCapsule != null && line.invasionBeyondCapsule != '9')
            return false
        if (line.ipsilateralAdrenalGlandInvolve != null && line.ipsilateralAdrenalGlandInvolve != '9')
            return false
        if (line.jak2 != null && line.jak2 != '9')
            return false
        if (line.ki67 != null && line.ki67 != 'XXX.9')
            return false
        if (line.kitGeneImmunohistochemistry != null && line.kitGeneImmunohistochemistry != '9')
            return false
        if (line.kras != null && line.kras != '9')
            return false
        if (line.ldhPostOrchiectomyRange != null && line.ldhPostOrchiectomyRange != '9')
            return false
        if (line.ldhPreOrchiectomyRange != null && line.ldhPreOrchiectomyRange != '9')
            return false
        if (line.ldhPretreatmentLabValue != null && line.ldhPretreatmentLabValue != 'XXXXX.9')
            return false
        if (line.ldhPretreatmentLevel != null && line.ldhPretreatmentLevel != '9')
            return false
        if (line.ldhUpperLimitsOfNormal != null && line.ldhUpperLimitsOfNormal != 'XX9')
            return false
        if (line.lnAssessMethodFemoralInguinal != null && line.lnAssessMethodFemoralInguinal != '9')
            return false
        if (line.lnAssessMethodParaaortic != null && line.lnAssessMethodParaaortic != '9')
            return false
        if (line.lnAssessMethodPelvic != null && line.lnAssessMethodPelvic != '9')
            return false
        if (line.lnDistantAssessMethod != null && line.lnDistantAssessMethod != '9')
            return false
        if (line.lnDistantMediastinalScalene != null && line.lnDistantMediastinalScalene != '9')
            return false
        if (line.lnHeadAndNeckLevels1To3 != null && line.lnHeadAndNeckLevels1To3 != '9')
            return false
        if (line.lnHeadAndNeckLevels4To5 != null && line.lnHeadAndNeckLevels4To5 != '9')
            return false
        if (line.lnHeadAndNeckLevels6To7 != null && line.lnHeadAndNeckLevels6To7 != '9')
            return false
        if (line.lnHeadAndNeckOther != null && line.lnHeadAndNeckOther != '9')
            return false
        if (line.lnIsolatedTumorCells != null && line.lnIsolatedTumorCells != '9')
            return false
        if (line.lnLaterality != null && line.lnLaterality != '9')
            return false
        if (line.lnPositiveAxillaryLevel1To2 != null && line.lnPositiveAxillaryLevel1To2 != '9')
            return false
        if (line.lnSize != null && line.lnSize != 'XX.9')
            return false
        if (line.lnStatusFemoralInguinal != null && line.lnStatusFemoralInguinal != '9')
            return false
        if (line.lnStatusParaAortic != null && line.lnStatusParaAortic != '9')
            return false
        if (line.lnStatusPelvic != null && line.lnStatusPelvic != '9')
            return false
        if (line.lymphocytosis != null && line.lymphocytosis != '9')
            return false
        if (line.majorVeinInvolvement != null && line.majorVeinInvolvement != '9')
            return false
        if (line.measuredBasalDiameter != null && line.measuredBasalDiameter != 'XX.9')
            return false
        if (line.measuredThickness != null && line.measuredThickness != 'XX.9')
            return false
        if (line.methylationOfO6MGMT != null && line.methylationOfO6MGMT != '9')
            return false
        if (line.microsatelliteInstability != null && line.microsatelliteInstability != '9')
            return false
        if (line.microvascularDensity != null && line.microvascularDensity != 'X9')
            return false
        if (line.mitoticCountUvealMelanoma != null && line.mitoticCountUvealMelanoma != 'XX.9')
            return false
        if (line.mitoticRateMelanoma != null && line.mitoticRateMelanoma != 'X9')
            return false
        if (line.multigeneSignatureMethod != null && line.multigeneSignatureMethod != '9')
            return false
        if (line.multigeneSignatureResults != null && line.multigeneSignatureResults != 'X9')
            return false
        if (line.nccnInternationalPrognosticIndex != null && line.nccnInternationalPrognosticIndex != 'X9')
            return false
        if (line.nrasMutationalAnalysis != null && line.nrasMutationalAnalysis != '9')
            return false
        if (line.numberOfCoresExamined != null && line.numberOfCoresExamined != 'X9')
            return false
        if (line.numberOfCoresPositive != null && line.numberOfCoresPositive != 'X9')
            return false
        if (line.numberOfExaminedParaAorticNodes != null && line.numberOfExaminedParaAorticNodes != 'X9')
            return false
        if (line.numberOfExaminedPelvicNodes != null && line.numberOfExaminedPelvicNodes != 'X9')
            return false
        if (line.numberOfPositiveParaAorticNodes != null && line.numberOfPositiveParaAorticNodes != 'X9')
            return false
        if (line.numberOfPositivePelvicNodes != null && line.numberOfPositivePelvicNodes != 'X9')
            return false
        if (line.oncotypeDxRecurrenceScoreDcis != null && line.oncotypeDxRecurrenceScoreDcis != 'XX9')
            return false
        if (line.oncotypeDxRecurrenceScoreInvasiv != null && line.oncotypeDxRecurrenceScoreInvasiv != 'XX9')
            return false
        if (line.oncotypeDxRiskLevelDcis != null && line.oncotypeDxRiskLevelDcis != '9')
            return false
        if (line.oncotypeDxRiskLevelInvasive != null && line.oncotypeDxRiskLevelInvasive != '9')
            return false
        if (line.organomegaly != null && line.organomegaly != '9')
            return false
        if (line.p16 != null && line.p16 != '9')
            return false
        if (line.percentNecrosisPostNeoadjuvant != null && line.percentNecrosisPostNeoadjuvant != 'XXX.9')
            return false
        if (line.perineuralInvasion != null && line.perineuralInvasion != '9')
            return false
        if (line.peripheralBloodInvolvement != null && line.peripheralBloodInvolvement != '9')
            return false
        if (line.peritonealCytology != null && line.peritonealCytology != '9')
            return false
        if (line.pleuralEffusion != null && line.pleuralEffusion != '9')
            return false
        if (line.profoundImmuneSuppression != null && line.profoundImmuneSuppression != '9')
            return false
        if (line.progesteroneRecepPrcntPosOrRange != null && line.progesteroneRecepPrcntPosOrRange != 'XX9')
            return false
        if (line.progesteroneRecepSummary != null && line.progesteroneRecepSummary != '9')
            return false
        if (line.psaLabValue != null && line.psaLabValue != 'XXX.9')
            return false
        if (line.residualTumVolPostCytoreduction != null && line.residualTumVolPostCytoreduction != '99')
            return false
        if (line.responseToNeoadjuvantTherapy != null && line.responseToNeoadjuvantTherapy != '9')
            return false
        if (line.sCategoryClinical != null && line.sCategoryClinical != '9')
            return false
        if (line.sCategoryPathological != null && line.sCategoryPathological != '9')
            return false
        if (line.sarcomatoidFeatures != null && line.sarcomatoidFeatures != 'XX9')
            return false
        if (line.seerSiteSpecificFact1 != null && line.seerSiteSpecificFact1 != '99')
            return false
        if (line.separateTumorNodules != null && line.separateTumorNodules != '9')
            return false
        if (line.serumAlbuminPretreatmentLevel != null && line.serumAlbuminPretreatmentLevel != '9')
            return false
        if (line.serumBeta2MicroglobulinPretxLvl != null && line.serumBeta2MicroglobulinPretxLvl != '9')
            return false
        if (line.thrombocytopenia != null && line.thrombocytopenia != '9')
            return false
        if (line.tumorDeposits != null && line.tumorDeposits != 'X9')
            return false
        if (line.ulceration != null && line.ulceration != '9')
            return false
        if (line.visceralParietalPleuralInvasion != null && line.visceralParietalPleuralInvasion != '9')
            return false
        if (line.brainPrimaryTumorLocation != null && line.brainPrimaryTumorLocation != '9')
            return false
        
        return true
    }

    // ID: IFN4933; NAME: Creatinine Pretreatment Unit of Measure, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn4933(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return line.schemaId != '00220' || (line.creatininePretxUnitOfMeasure != null && line.creatininePretxUnitOfMeasure != '8')
    }

    // ID: IFN5000; NAME: Behavior Code ICDO3, Summary Stage 2018, Schema ID (NAACCR)
    public boolean ifn5000(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.schemaId == '99999' || line.behaviorCodeIcdO3 == null || line.summaryStage2018 == null)
            return true
        
        if (line.typeOfReportingSource == '7')
            return true
        
        String behavior = line.behaviorCodeIcdO3
        if (functions.matches(line.schemaId, /^0072[123]|0972[1234]$/)) {
            if ((behavior == '0' || behavior == '1') && line.summaryStage2018 != '8')
                return false
            if (line.summaryStage2018 == '8' && behavior != '0' && behavior != '1')
                return false
        }
        
        if (behavior == '2' && line.summaryStage2018 != '0')
            return false
        
        return behavior != '3' || (line.summaryStage2018 != '0' && line.summaryStage2018 != '8')
    }

    // ID: IFN5016; NAME: RX Summ--Surg Prim Site 03-2022, Primary Site, 2018 (SEER)
    public boolean ifn5016(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.dateOfDiagnosisYear > '2022' || line.primarySite == null || line.rxSummSurgPrimSite == null)
            return true
        boolean primarySiteCondition = functions.matches(line.primarySite, /^C42[0134]|C76[0-8]|C809$/)
        boolean histologyCondition = functions.matches(line.histologicTypeIcdO3, /^9(7(27|32|4[129]|6[1-9]|[789]\d)|8(0\d|2[06]|3[1-4]|[4-9]\d)|9([0-8]\d|9[0-3]))$/)
        if (!primarySiteCondition && histologyCondition && line.dateOfDiagnosisYear <= '2021')
            return true
        
        if (line.typeOfReportingSource == '7' && line.rxSummSurgPrimSite == '99')
            return true
        
        if (primarySiteCondition)
            return line.rxSummSurgPrimSite == '98'
        
        Integer siteInt = functions.asInt(line.primarySite.substring(1, 4))
        Map schemaIdMap = (Map)context.IFN5016_Primary_Site_GroupCode_Table
        Integer groupCode = schemaIdMap.get(siteInt)
        if (groupCode != null) {
            if (groupCode == 30 && line.rxSummSurgPrimSite == '41' && !line.primarySite.startsWith('C69'))
                return false
        
            Map> groupCodeMap = line.dateOfDiagnosisYear > '2021' ?
                (Map>)context.IFN5016_GroupCode_Table_22 :
                (Map>)context.IFN5016_GroupCode_Table_18
        
            if (groupCodeMap.containsKey(groupCode))
                return groupCodeMap.get(groupCode).contains(line.rxSummSurgPrimSite)
        }
        
        return false
    }

    // ID: IFN5017; NAME: Mets at DX-BBDLLO, Schema ID, Primary Site, 2018 (NAACCR)
    public boolean ifn5017(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.primarySite == null || line.typeOfReportingSource == '7')
                    return true
        if (['0', '1', '2'].contains(line.behaviorCodeIcdO3))
            return true
        if (line.metsAtDxBone == null && line.metsAtDxBrain == null && line.metsAtDxDistantLn == null && line.metsAtDxLiver == null && line.metsAtDxLung == null && line.metsAtDxOther == null)
            return true
        if (line.dateOfDiagnosisYear >= '2018' && line.dateOfDiagnosisYear <= '2021' && ['00790', '00795', '00830', '99999'].contains(line.schemaId) &&
            line.metsAtDxBone == '8' && line.metsAtDxBrain == '8' && line.metsAtDxDistantLn == '8' && line.metsAtDxLiver == '8' && line.metsAtDxLung == '8' && line.metsAtDxOther == '8')
            return true
        
        if (line.schemaId == '00822' || ['C420', 'C421', 'C423', 'C424'].contains(line.primarySite))
            return line.metsAtDxBone == '8' && line.metsAtDxBrain == '8' && line.metsAtDxDistantLn == '8' && line.metsAtDxLiver == '8' && line.metsAtDxLung == '8' && line.metsAtDxOther == '8'
        else if (functions.matches(line.primarySite, /^C77\d$/))
            return line.metsAtDxDistantLn == '8' && line.metsAtDxBone != '8' && line.metsAtDxBrain != '8' && line.metsAtDxLiver != '8' && line.metsAtDxLung != '8' && line.metsAtDxOther != '8'
        else
            return line.metsAtDxBone != '8' && line.metsAtDxBrain != '8' && line.metsAtDxDistantLn != '8' && line.metsAtDxLiver != '8' && line.metsAtDxLung != '8' && line.metsAtDxOther != '8'
    }

    // ID: IFN5018; NAME: RX Summ--Surgical Margins, Surg Prim Site 03-2022, Primary Site, 2018 (NAACCR)
    public boolean ifn5018(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
         if(line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.dateOfDiagnosisYear > '2022' || line.primarySite == null)
            return true
        if (line.rxSummSurgicalMargins == null || line.rxSummSurgPrimSite == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.rxSummSurgPrimSite == '98' && line.rxSummSurgicalMargins != '9')
            return false
        
        if (functions.matches(line.primarySite, /^C(42[0134]|76[0-8]|77\d|809)$/)) {
            if (line.rxSummSurgicalMargins != '9')
                return false
        }
        else {
            if (line.rxSummSurgPrimSite == '00' && line.rxSummSurgicalMargins != '8')
                return false
            if (line.rxSummSurgicalMargins == '8' && line.rxSummSurgPrimSite != '00')
                return false
        }
        
        return true 
    }

    // ID: IFN5019; NAME: RX Summ--Scope Reg LN Sur, Primary Site, 2018 (NAACCR)
    public boolean ifn5019(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.rxSummScopeRegLnSur == null || line.primarySite == null)
            return true
        
        if (functions.matches(line.primarySite, /^C(42[0134]|589|7[0127]\d|75[1-3]|76[1-8]|809)$/))
            return line.rxSummScopeRegLnSur == '9'
        
        return true
    }

    // ID: IFN5020; NAME: Autopsy Only, RX 03-2022, Primary Site, 2018 (NPCR)
    public boolean ifn5020(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.dateOfDiagnosisYear > '2022' || line.schemaId == null || line.typeOfReportingSource != '6')
            return true
        
        boolean primarySitesFor2A = functions.matches(line.primarySite, /^C(42[0134]|589|7([0127]\d|5[123]|6[1-8])|809)$/)
        
        if (line.rxSummSurgPrimSite != '00' && line.rxSummSurgPrimSite != '98')
            return false
        
        if (primarySitesFor2A) {
            if (line.rxSummScopeRegLnSur != '9')
                return false
        }
        else if (line.primarySite == 'C760') {
            if (line.rxSummScopeRegLnSur != '0' && line.rxSummScopeRegLnSur != '9')
                return false
        }
        else {
            if (line.rxSummScopeRegLnSur != '0')
                 return false
        }
        
        if (line.rxSummSurgOthRegDis != '0')
            return false
        
        if (line.reasonForNoSurgery != '1' && line.reasonForNoSurgery != '9')
            return false
        
        if (line.rxSummBrm != '00')
            return false
        
        if (line.rxSummChemo != '00')
            return false
        
        if (line.rxSummHormone != '00')
            return false
        
        if (line.rxSummOther != '0')
            return false
        
        if (line.rxSummTransplntEndocr != '00')
            return false
        
        if (line.phase1RadiationTreatmentModality != '00')
            return false
        
        if (line.rxSummSurgRadSeq != '0')
            return false
        
        if (line.rxSummSystemicSurSeq != '0')
            return false
        
        return true
    }

    // ID: IFN5021; NAME: Surgery 03-2022, RX Date Surgery, Primary Site (NAACCR)
    public boolean ifn5021(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.dateOfDiagnosisYear > '2022' || line.schemaId == null)
            return true
        if (line.rxSummSurgPrimSite == null || line.rxSummScopeRegLnSur == null || line.rxSummSurgOthRegDis == null)
            return true
        
        boolean rxDateIsBlank = line.rxDateSurgeryYear == null && line.rxDateSurgeryMonth == null && line.rxDateSurgeryDay == null
        boolean siteCondition = functions.matches(line.primarySite, /^C(42[0134]|589|7[0127]\d|75[1-3]|76[0-8]|809)$/)
        
        //condition 1
        boolean rxSummSurgPrimSiteCondition = line.rxSummSurgPrimSite == '00' || line.rxSummSurgPrimSite == '98'
        boolean rxSummScopeRegLnSurCondition = (line.rxSummScopeRegLnSur == '9' && (siteCondition || line.schemaId == '99999')) ||
            (line.rxSummScopeRegLnSur == '1' && line.dateOfDiagnosisYear >= '2021') || line.rxSummScopeRegLnSur == '0'
        boolean rxSummSurgOthRegDisCondition = line.rxSummSurgOthRegDis == '0'
        
        if (rxSummSurgPrimSiteCondition && rxSummScopeRegLnSurCondition && rxSummSurgOthRegDisCondition)
            return rxDateIsBlank
        
        //condition 2
        rxSummSurgPrimSiteCondition = functions.matches(line.rxSummSurgPrimSite, /^[1-8]\d|90$/)
        boolean rxSummScopeRegLnSurIs2Condition = line.rxSummScopeRegLnSur == '2' && (line.dateOfDiagnosisYear >= '2021' ||
            (line.dateOfDiagnosisYear >= '2018' && functions.matches(line.regionalNodesExamined, /^0[1-9]|[1-8]\d|9[0-8]$/)))
        rxSummScopeRegLnSurCondition = functions.matches(line.rxSummScopeRegLnSur, /^[3-7]$/) || rxSummScopeRegLnSurIs2Condition || (line.rxSummScopeRegLnSur == '1' && line.dateOfDiagnosisYear < '2021')
        
        rxSummSurgOthRegDisCondition = functions.matches(line.rxSummSurgOthRegDis, /^[1-5]$/)
        
        if (!rxDateIsBlank)
            return rxSummSurgPrimSiteCondition || rxSummScopeRegLnSurCondition || rxSummSurgOthRegDisCondition
        
        return true
    }

    // ID: IFN5022; NAME: Date Initial RX SEER, Ca Dir RX 2018-2022 (SEER)
    public boolean ifn5022(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.dateOfDiagnosisYear > '2022')
            return true
        
        boolean siteCondition = functions.matches(line.primarySite, /^C(42[0134]|589|7[0127]\d|75[1-3]|76[0-8]|809)$/) || line.schemaId == '99999'
        
        boolean rxSummScopeRegLnSurYesCondition = false
        if (functions.matches(line.rxSummScopeRegLnSur, /^[3-7]$/))
            rxSummScopeRegLnSurYesCondition = true
        else if (line.rxSummScopeRegLnSur == '1' && line.dateOfDiagnosisYear < '2021')
            rxSummScopeRegLnSurYesCondition = true
        else if (line.rxSummScopeRegLnSur == '2' && line.dateOfDiagnosisYear >= '2018' && line.dateOfDiagnosisYear <= '2020' && functions.matches(line.regionalNodesExamined, /^0[1-9]|[1-8]\d|9[0-8]$/))
            rxSummScopeRegLnSurYesCondition = true
        else if (line.rxSummScopeRegLnSur == '2' && line.dateOfDiagnosisYear >= '2021')
            rxSummScopeRegLnSurYesCondition = true
        
        boolean rxSummScopeNoCondition = false
        
        if (line.rxSummScopeRegLnSur == '9' && siteCondition)
            rxSummScopeNoCondition = true
        else if (line.rxSummScopeRegLnSur == '0')
            rxSummScopeNoCondition = true
        else if (line.rxSummScopeRegLnSur == '1' && line.dateOfDiagnosisYear >= '2021')
            rxSummScopeNoCondition = true
        
        if ((line.rxSummSurgPrimSite == '00' || line.rxSummSurgPrimSite == '98') &&
            rxSummScopeNoCondition &&
            line.rxSummSurgOthRegDis == '0' &&
            (line.phase1RadiationTreatmentModality == '00' || line.phase1RadiationTreatmentModality == '99') &&
            line.rxSummSurgRadSeq == '0' &&
            functions.matches(line.rxSummBrm, /^00|8[25-8]$/) &&
            functions.matches(line.rxSummChemo, /^00|8[25-8]$/) &&
            functions.matches(line.rxSummHormone, /^00|8[25-8]$/) &&
            functions.matches(line.rxSummTransplntEndocr, /^00|8[25-8]$/) &&
            functions.matches(line.rxSummOther, /^[078]$/))
                return line.dateInitialRxSeerYear == null
        
        if (line.dateInitialRxSeerYear != null)
            return functions.matches(line.rxSummSurgPrimSite, /^[1-8]\d|90$/) ||
            rxSummScopeRegLnSurYesCondition ||
            functions.matches(line.rxSummSurgOthRegDis, /^[1-5]$/) ||
            functions.matches(line.phase1RadiationTreatmentModality, /^0[1-9]|1[0-6]|98$/) ||
            functions.matches(line.rxSummSurgRadSeq, /^[2-9]$/) ||
            line.rxSummBrm == '01' ||
            functions.matches(line.rxSummChemo, /^0[1-3]$/) ||
            line.rxSummHormone == '01' ||
            functions.matches(line.rxSummTransplntEndocr, /^1[0-2]|[234]0$/) ||
            functions.matches(line.rxSummOther, /^[1236]$/)
        
        return true
    }

    // ID: IFN5025; NAME: RX Summ--Treatm Stat, Treatment 03-2022 (NAACCR)
    public boolean ifn5025(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.dateOfDiagnosisYear > '2022' || line.rxSummTreatmentStatus == null)
            return true
        
        if (functions.matches(line.rxSummSurgPrimSite, /^[1-8]\d|90$/) || functions.matches(line.rxSummSurgOthRegDis, /^[1-5]$/) || line.rxSummBrm == '01' || 
                functions.matches(line.rxSummChemo, /^0[1-3]$/) || line.rxSummHormone == '01' || functions.matches(line.rxSummTransplntEndocr, /^[1-3]\d|40$/) || functions.matches(line.rxSummOther, /^[1236]$/) || line.reasonForNoRadiation == '0') {
            return line.rxSummTreatmentStatus == '1'
        }
        
        if (line.rxSummTreatmentStatus == '1') {
            // at least one field must be 'treatment given'
            return functions.matches(line.rxSummSurgPrimSite, /^[1-8]\d|90$/) || 
                   (line.dateOfDiagnosisYear < '2021' ? functions.matches(line.rxSummScopeRegLnSur, /^[1-7]$/) : functions.matches(line.rxSummScopeRegLnSur, /^[2-7]$/)) ||
                   functions.matches(line.rxSummSurgOthRegDis, /^[1-5]$/) || 
                   line.rxSummBrm == '01' || 
                   functions.matches(line.rxSummChemo, /^0[1-3]$/) || 
                   line.rxSummHormone == '01' || 
                   functions.matches(line.rxSummTransplntEndocr, /^[1-3]\d|40$/) || 
                   functions.matches(line.rxSummOther, /^[1236]$/) || 
                   line.reasonForNoRadiation == '0'
        }
        else if (line.rxSummTreatmentStatus == '0' || line.rxSummTreatmentStatus == '2') {
            // all fields must be 'no treatment'
            return ((line.rxSummSurgPrimSite == '00' || line.rxSummSurgPrimSite == '98') &&
                    (line.dateOfDiagnosisYear < '2021' || functions.matches(line.rxSummScopeRegLnSur, /^0|[1-7]|9$/)) &&
                    line.rxSummSurgOthRegDis == '0' && 
                    functions.matches(line.rxSummBrm, /^00|8[0-8]$/) && 
                    functions.matches(line.rxSummChemo, /^00|8[0-8]$/) && 
                    functions.matches(line.rxSummHormone, /^00|8[0-8]$/) && 
                    functions.matches(line.rxSummTransplntEndocr, /^00|8[0-8]$/) && 
                    functions.matches(line.rxSummOther, /^[078]$/) &&
                    (functions.matches(line.reasonForNoRadiation, /^[125-9]$/) || line.phase1RadiationTreatmentModality == '00'))
        }
        else if (line.rxSummTreatmentStatus == '9') {
            // at least one field must be 'unknown' (9s)
            if (line.rxSummSurgPrimSite == '99' ||
                    line.rxSummSurgOthRegDis == '9' || line.rxSummBrm == '99' || line.rxSummChemo == '99' || line.rxSummHormone == '99' || 
                    line.rxSummTransplntEndocr == '99' || line.rxSummOther == '9' || line.phase1RadiationTreatmentModality == '99') {
                // all fields must be 'no treatment' or 'unknown'
                return ((line.rxSummSurgPrimSite == '00' || line.rxSummSurgPrimSite == '98' || line.rxSummSurgPrimSite == '99') &&
                    functions.matches(line.rxSummScopeRegLnSur, /^0|[1-7]|9$/) &&
                    (line.rxSummSurgOthRegDis == '0' || line.rxSummSurgOthRegDis == '9') &&
                    functions.matches(line.rxSummBrm, /^00|8[0-8]|99$/) && 
                    functions.matches(line.rxSummChemo, /^00|8[0-8]|99$/) && 
                    functions.matches(line.rxSummHormone, /^00|8[0-8]|99$/) && 
                    functions.matches(line.rxSummTransplntEndocr, /^00|8[0-8]|99$/) && 
                    functions.matches(line.rxSummOther, /^[0789]$/) &&
                    (functions.matches(line.reasonForNoRadiation, /^[89]$/) || line.phase1RadiationTreatmentModality == '00' || line.phase1RadiationTreatmentModality == '99'))
            }
            else
                return false
        }
        
        return true
    }

    // ID: IFN5027; NAME: Grade Clin, Grade Path 03-2022 (NAACCR)
    public boolean ifn5027(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.dateOfDiagnosisYear > '2022')
            return true
        
        if (line.gradePathological == null || line.gradePathological == '9' || line.gradeClinical == null || line.gradeClinical == '8' || line.gradeClinical == '9')
            return true
        
        if (functions.matches(line.schemaId, /^0072[123]$/))
            return true
        
        if (functions.matches(line.rxSummSurgPrimSite, /^[3-8]\d|90$/) && line.gradePostTherapy == null && functions.matches(line.gradeClinical, /^\d$/) && functions.matches(line.gradePathological, /^\d$/))
            return line.gradePathological != '8' && line.gradeClinical <= line.gradePathological
        
        return true
    }

    // ID: IFN5031; NAME: EOD Regional Nodes, Breast, Reg Nodes Positive, Scope Nodes (SEER)
    public boolean ifn5031(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.eodRegionalNodes == null || line.schemaId != '00480' || line.typeOfReportingSource == '7')
            return true
        
        String eodRegNodes = line.eodRegionalNodes
        if (['030', '050', '070'].contains(eodRegNodes)) {
            if (line.regionalNodesPositive != null && line.regionalNodesPositive != '00' && line.regionalNodesPositive != '99')
                return false
        }
        
        if (['200', '250', '300'].contains(eodRegNodes)) {
            if (['00', '98', '99'].contains(line.regionalNodesPositive))
                return false
        }
        
        if (['030', '050', '070', '200', '250', '300'].contains(eodRegNodes) && line.rxSummScopeRegLnSur != null) {
            if (line.typeOfReportingSource == '6')
                return line.rxSummScopeRegLnSur == '0'
            else {
                Integer dolcYear = functions.asInt(line.dateOfLastContactYear)
                Integer dolcMonth = functions.asInt(line.dateOfLastContactMonth)
                Integer dolcDay = functions.asInt(line.dateOfLastContactDay)
                Integer dxYear = functions.asInt(line.dateOfDiagnosisYear)
                Integer dxMonth = functions.asInt(line.dateOfDiagnosisMonth)
                Integer dxDay = functions.asInt(line.dateOfDiagnosisDay)
        
                if (line.vitalStatus == '0' && (Boolean)((Closure)context.compareDatesWithinMonths).call(dolcYear, dolcMonth, dolcDay, dxYear, dxMonth, dxDay, 5))
                    return functions.matches(line.rxSummScopeRegLnSur, /^[0-7]$/)
                else
                    return functions.matches(line.rxSummScopeRegLnSur, /^[1-7]$/)
            }
        }
        
        return true
    }

    // ID: IFN5032; NAME: ER Summary, Breast, ER Percent (NAACCR)
    public boolean ifn5032(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.estrogenReceptorSummary == null)
            return true
        
        if (line.estrogenReceptorPercntPosOrRange == null || line.estrogenReceptorPercntPosOrRange == 'XX8')
            return true
        
        if (functions.matches(line.estrogenReceptorPercntPosOrRange, /^0(0[1-9]|[1-9]\d)|100|R([1-9]\d)$/))
            return line.estrogenReceptorSummary != '0'
        
        return true
    }

    // ID: IFN5033; NAME: PR Summary, Breast, PR Percent (NAACCR)
    public boolean ifn5033(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.progesteroneRecepSummary == null)
            return true
        
        if (line.progesteroneRecepPrcntPosOrRange == null || line.progesteroneRecepPrcntPosOrRange == 'XX8')
            return true
        
        if (functions.matches(line.progesteroneRecepPrcntPosOrRange, /^0(0[1-9]|[1-9]\d)|100|R([1-9]\d)$/))
            return line.progesteroneRecepSummary != '0'
        
        return true
    }

    // ID: IFN5041; NAME: Brain Molecular Markers, Summary Stage 2018 (NAACCR)
    public boolean ifn5041(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.summaryStage2018 == null || line.typeOfReportingSource  == '7')
            return true
            
        if (!['00721','00722','09721','09722','09724'].contains(line.schemaId) || line.brainMolecularMarkers == null || line.brainMolecularMarkers == '88')
            return true
        
        if (line.brainMolecularMarkers == '86')
            return line.summaryStage2018 == '8'
        
        if (line.summaryStage2018 == '8')
            return line.brainMolecularMarkers == '86' || line.brainMolecularMarkers == '99'
        
        return true
    }

    // ID: IFN5042; NAME: Breslow Tumor Thickness, Melanoma, Summary Stage 2018 (NAACCR)
    public boolean ifn5042(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.summaryStage2018 == null || line.typeOfReportingSource  == '7')
            return true
            
        if (line.schemaId != '00470' || line.breslowTumorThickness == null || line.breslowTumorThickness == 'XX.8')
            return true
        
        if (line.summaryStage2018 == '0')
            return line.breslowTumorThickness == 'XX.9'
        
        return true
    }

    // ID: IFN5043; NAME: Tumor Deposits, Colorectal, Summary Stage 2018 (NAACCR)
    public boolean ifn5043(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.summaryStage2018 == null || line.typeOfReportingSource  == '7')
            return true
            
        if (line.schemaId != '00200' || line.tumorDeposits == null || line.tumorDeposits == 'X8')
            return true
        
        if (functions.matches(line.tumorDeposits, /^0[1-9]|[2-9]\d|X[12]$/))
            return !functions.matches(line.summaryStage2018, /^[012]$/)
        
        return true
    }

    // ID: IFN5044; NAME: Extranodal Extension Head and Neck Path, Summary Stage 2018 (NAACCR)
    public boolean ifn5044(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.summaryStage2018 == null || line.typeOfReportingSource  == '7')
            return true
            
        if (!functions.matches(line.schemaId, /^00(0[689]0|07[1-7]|100|1[12][12]|13[0-3]|140)$/) || line.extranodalExtensionHeadNeckPath == null || line.extranodalExtensionHeadNeckPath == 'X.8')
            return true
        
        if (functions.matches(line.extranodalExtensionHeadNeckPath, /^\d\.\d|X\.[1234]$/))
            return !functions.matches(line.summaryStage2018, /^[012]$/)
        
        return true
    }

    // ID: IFN5045; NAME: Extranodal Extension Head and Neck Path, EOD Regional Nodes (SEER)
    public boolean ifn5045(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.eodRegionalNodes == null)
            return true
        
        String path = line.extranodalExtensionHeadNeckPath
        if (!functions.matches(line.schemaId, /^00(0[68]0|07[1-7]|1[12][12]|13[0-3])$/) || path == null || path == 'X.8')
            return true
        
        if (path == '0.0')
            return functions.matches(line.eodRegionalNodes, /^[12348]00|[24]50$/)
        if (functions.matches(path, /^0\.[1-9]|[1-9]\.\d|X\.[1234]$/))
            return functions.matches(line.eodRegionalNodes, /^150|[567]00$/)
        
        return true
    }

    // ID: IFN5046; NAME: Extranodal Extension Clin/Path, Merkel Cell, Summary Stage 2018 (NAACCR)
    public boolean ifn5046(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.schemaId != '00460' || line.summaryStage2018 == null || line.typeOfReportingSource == '7')
            return true
        if ((line.extranodalExtensionClin == null || line.extranodalExtensionClin == '8') && (line.extranodalExtensionPath == null || line.extranodalExtensionPath == '8'))
            return true
        
        if (['0','1','2','4'].contains(line.extranodalExtensionClin) && ['0','1'].contains(line.extranodalExtensionPath) && ['0','1','2'].contains(line.summaryStage2018))
            return false
        return true
    }

    // ID: IFN5047; NAME: Extranodal Extension Clin/Path, Penis, Summary Stage 2018 (NAACCR)
    public boolean ifn5047(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.schemaId != '00570' || line.summaryStage2018 == null || line.typeOfReportingSource == '7')
            return true
        if ((line.extranodalExtensionClin == null || line.extranodalExtensionClin == '8') && (line.extranodalExtensionPath == null || line.extranodalExtensionPath == '8'))
            return true
        
        if (line.extranodalExtensionClin == '7' && line.extranodalExtensionPath == '7' && ['3','4'].contains(line.summaryStage2018))
            return false
        if (['0','1','2','4'].contains(line.extranodalExtensionClin) && ['0','1'].contains(line.extranodalExtensionPath) && ['0','1','2'].contains(line.summaryStage2018))
            return false
        return true
    }

    // ID: IFN5048; NAME: FIGO Stage, Summary Stage 2018 (NAACCR)
    public boolean ifn5048(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.summaryStage2018 == null || line.typeOfReportingSource  == '7')
            return true
            
        if (!functions.matches(line.schemaId, /^(005([01236]0|5[123]|28)|095[02]0)$/) || line.figoStage == null || line.figoStage == '98')
            return true
        
        if (line.summaryStage2018 == '0' && !['00530', '00551', '00553'].contains(line.schemaId) && line.figoStage != '97')
            return false
        
        if (line.figoStage == '97' && line.summaryStage2018 != '0')
            return false
        
        return true
    }

    // ID: IFN5050; NAME: Invasion Beyond Capsule, Kidney, Summary Stage 2018 (NAACCR)
    public boolean ifn5050(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.summaryStage2018 == null || line.typeOfReportingSource  == '7')
            return true
            
        if (line.schemaId != '00600' || line.invasionBeyondCapsule == null || line.invasionBeyondCapsule == '8')
            return true
        
        return !functions.matches(line.invasionBeyondCapsule, /^[13-5]$/) || !functions.matches(line.summaryStage2018, /^[013]$/)
    }

    // ID: IFN5051; NAME: Ipsilateral Adrenal Gland Involvement, Kidney, Summary Stage 2018 (NAACCR)
    public boolean ifn5051(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.summaryStage2018 == null || line.typeOfReportingSource  == '7')
            return true
            
        if (line.schemaId != '00600' || line.ipsilateralAdrenalGlandInvolve == null || line.ipsilateralAdrenalGlandInvolve == '8')
            return true
        
        if (line.ipsilateralAdrenalGlandInvolve == '1')
            return !functions.matches(line.summaryStage2018, /^[013]$/)
        else if (line.ipsilateralAdrenalGlandInvolve == '2' || line.ipsilateralAdrenalGlandInvolve == '3')
            return line.summaryStage2018 == '7'
        
        return true
    }

    // ID: IFN5052; NAME: LN Distant, Gynecologic, Summary Stage 2018 (NAACCR)
    public boolean ifn5052(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.summaryStage2018 == null || line.typeOfReportingSource == '7')
            return true
        if (!['00510','00520','09520'].contains(line.schemaId) || line.lnDistantMediastinalScalene == null || line.lnDistantMediastinalScalene == '8')
            return true
        
        return !['1','2','3'].contains(line.lnDistantMediastinalScalene) || line.summaryStage2018 == '7'
    }

    // ID: IFN5053; NAME: LN Head and Neck Levels, Melanoma Head/Neck, Summary Stage 2018 (NAACCR)
    public boolean ifn5053(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.summaryStage2018 == null || line.schemaId != '00140' || line.typeOfReportingSource  == '7')
            return true
        
        String ln13 = line.lnHeadAndNeckLevels1To3
        String ln45 = line.lnHeadAndNeckLevels4To5
        String ln67 = line.lnHeadAndNeckLevels6To7
        String lnOther = line.lnHeadAndNeckOther
        if ((ln13 == null || ln13 == '8') && (ln45 == null || ln45 == '8') && (ln67 == null || ln67 == '8') && (lnOther == null || lnOther == '8'))
            return true
        
        if (functions.matches(ln13, /^[1-7]$/) || functions.matches(ln45, /^[1-3]$/) || functions.matches(ln67, /^[1-3]$/) || functions.matches(lnOther, /^[1-7]$/))
            if (functions.matches(line.summaryStage2018, /^[012]$/))
                return false
        
        return true
    }

    // ID: IFN5054; NAME: LN Isolated Tumor Cells (ITC), Merkel Cell, Summary Stage 2018 (NAACCR)
    public boolean ifn5054(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.summaryStage2018 == null || line.schemaId != '00460' || line.typeOfReportingSource  == '7')
            return true
        
        if (line.lnIsolatedTumorCells == null || line.lnIsolatedTumorCells == '8')
            return true
        
        if (line.lnIsolatedTumorCells == '1')
            return !functions.matches(line.summaryStage2018, /^[012]$/)
        
        return true
    }

    // ID: IFN5055; NAME: LN Positive Axillary Level I-II, Breast, Summary Stage 2018 (NAACCR)
    public boolean ifn5055(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.summaryStage2018 == null || line.schemaId != '00480' || line.typeOfReportingSource  == '7')
            return true
        
        if (line.lnPositiveAxillaryLevel1To2 == null || line.lnPositiveAxillaryLevel1To2 == 'X8')
            return true
        
        if (functions.matches(line.lnPositiveAxillaryLevel1To2, /^0[1-9]|[1-9]\d|X[156]$/))
            return !functions.matches(line.summaryStage2018, /^[012]$/)
        
        return true
    }

    // ID: IFN5056; NAME: LN Laterality, Vulva, Summary Stage 2018 (NAACCR)
    public boolean ifn5056(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.summaryStage2018 == null || (line.schemaId != '00500' && line.schemaId != '09500')
                    || line.typeOfReportingSource  == '7')
            return true
        
        if (line.lnLaterality == null || line.lnLaterality == '8')
            return true
        
        if (functions.matches(line.lnLaterality, /^[123]$/))
            return !functions.matches(line.summaryStage2018, /^[012]$/)
        
        return true
    }

    // ID: IFN5057; NAME: LN Size, Head/Neck, Summary Stage 2018 (NAACCR)
    public boolean ifn5057(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.summaryStage2018 == null || 
             !functions.matches(line.schemaId, /^00(0[689]0|07[1-7]|100|1[12][12]|13[0-3]|1[45]0)$/) || line.typeOfReportingSource  == '7')
            return true
        
        if (line.lnSize == null || line.lnSize == 'XX.8')
            return true
        
        if (line.lnSize != '0.0' && line.lnSize != 'XX.9')
            return !functions.matches(line.summaryStage2018, /^[012]$/)
        
        return true
    }

    // ID: IFN5059; NAME: Lymphovascular Invasion, Penis, Summary Stage 2018 (NAACCR)
    public boolean ifn5059(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.summaryStage2018 == null || line.schemaId != '00570' || line.typeOfReportingSource  == '7')
            return true
        
        if (line.lymphVascularInvasion == null || line.lymphVascularInvasion == '8')
            return true
        
        return !functions.matches(line.lymphVascularInvasion, /^[1-4]$/) || line.summaryStage2018 != '0'
    }

    // ID: IFN5060; NAME: Lymphovascular Invasion, Testis, Summary Stage 2018 (NAACCR)
    public boolean ifn5060(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.summaryStage2018 == null || line.schemaId != '00590' || line.typeOfReportingSource  == '7')
            return true
        
        if (line.lymphVascularInvasion == null || line.lymphVascularInvasion == '8')
            return true
        
        return !functions.matches(line.lymphVascularInvasion, /^[1-4]$/) || line.summaryStage2018 != '0'
    }

    // ID: IFN6061; NAME: Major Vein Involvement, Kidney, Summary Stage 2018 (NAACCR)
    public boolean ifn6061(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.summaryStage2018 == null || line.schemaId != '00600' || line.typeOfReportingSource  == '7')
            return true
        
        if (line.majorVeinInvolvement == null || line.majorVeinInvolvement == '8')
            return true
        
        return !functions.matches(line.majorVeinInvolvement, /^[1-4]$/) || !functions.matches(line.summaryStage2018, /^[013]$/)
    }

    // ID: IFN6062; NAME: Separate Tumor Nodules, Lung, Summary Stage 2018 (NAACCR)
    public boolean ifn6062(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.summaryStage2018 == null || line.schemaId != '00360' || line.typeOfReportingSource  == '7')
            return true
        
        String separateTumorNodules = line.separateTumorNodules
        if (separateTumorNodules == null || separateTumorNodules == '8')
            return true
        
        if (separateTumorNodules == '1' || separateTumorNodules == '4')
            return !functions.matches(line.summaryStage2018, /^[013]$/)
        else if (separateTumorNodules == '2' || separateTumorNodules == '3')
            return line.summaryStage2018 == '7'
        
        return true
    }

    // ID: IFN6063; NAME: Visceral and Parietal Pleural Invasion, Lung, Summary Stage 2018 (NAACCR)
    public boolean ifn6063(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.summaryStage2018 == null || line.schemaId != '00360' || line.typeOfReportingSource  == '7')
            return true
        
        if (line.visceralParietalPleuralInvasion == null || line.visceralParietalPleuralInvasion == '8')
            return true
        
        return !functions.matches(line.visceralParietalPleuralInvasion, /^[456]$/) || !functions.matches(line.summaryStage2018, /^[013]$/)
    }

    // ID: IFN6073; NAME: Peritoneal Cytology, Gynecologic, Summary Stage 2018 (NAACCR)
    public boolean ifn6073(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.summaryStage2018 == null || !['00530', '00541', '00542', '00528'].contains(line.schemaId))
            return true
        
        if (line.peritonealCytology == null || line.peritonealCytology == '8' || line.typeOfReportingSource  == '7')
            return true
        
        return line.peritonealCytology != '2' || !functions.matches(line.summaryStage2018, /^[013]$/)
    }

    // ID: IFN6074; NAME: Pleural Effusion, Pleura, Summary Stage 2018 (NAACCR)
    public boolean ifn6074(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.summaryStage2018 == null || line.schemaId != '00370' || line.typeOfReportingSource  == '7')
            return true
        
        if (line.pleuralEffusion == null || line.pleuralEffusion == '8')
            return true
        
        return line.pleuralEffusion != '2' || line.summaryStage2018 == '7'
    }

    // ID: IFN6075; NAME: EOD Regional Nodes, Thyroid, Reg Nodes Positive, Scope Nodes (SEER)
    public boolean ifn6075(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.eodRegionalNodes == null || line.regionalNodesPositive == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.schemaId != '00730' && line.schemaId != '00740')
            return true
        
        String positive = line.regionalNodesPositive
        if (line.eodRegionalNodes == '000') {
            if (positive != '00')
                return false
            if (line.rxSummScopeRegLnSur != null) {
                if (line.typeOfReportingSource == '6')
                    return line.rxSummScopeRegLnSur == '0'
                else {
                    Integer dolcYear = functions.asInt(line.dateOfLastContactYear)
                    Integer dolcMonth = functions.asInt(line.dateOfLastContactMonth)
                    Integer dolcDay = functions.asInt(line.dateOfLastContactDay)
                    Integer dxYear = functions.asInt(line.dateOfDiagnosisYear)
                    Integer dxMonth = functions.asInt(line.dateOfDiagnosisMonth)
                    Integer dxDay = functions.asInt(line.dateOfDiagnosisDay)
        
                    if (line.vitalStatus == '0' && (Boolean)((Closure)context.compareDatesWithinMonths).call(dolcYear, dolcMonth, dolcDay, dxYear, dxMonth, dxDay, 5))
                        return functions.matches(line.rxSummScopeRegLnSur, /^[0-7]$/)
                    else
                        return functions.matches(line.rxSummScopeRegLnSur, /^[1-7]$/)
                }
            }
        }
        else if (line.eodRegionalNodes == '050')
            return positive == '98' || positive == '99'
        
        return true
    }

    // ID: IFN6076; NAME: EOD Mets, Type of Reporting Source (SEER)
    public boolean ifn6076(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.eodMets == null || line.typeOfReportingSource == null)
            return true
        
        return line.eodMets != '99' || line.typeOfReportingSource == '7'
    }

    // ID: IFN6077; NAME: SSDIs, Benign Brain and CNS (NAACCR)
    public boolean ifn6077(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || !['00721','00722','09721','09722'].contains(line.schemaId) || line.behaviorCodeIcdO3 == null)
            return true
        
        String behav = line.behaviorCodeIcdO3
        String chrom1p = line.chromosome1pLossHeterozygosity
        String chrom19q = line.chromosome19qLossHeterozygosity
        String methylation = line.methylationOfO6MGMT
        if (chrom1p == '6' && behav != '0' && behav != '1')
            return false
        if (chrom19q == '6' && behav != '0' && behav != '1')
            return false
        if (methylation == '6' && behav != '0' && behav != '1')
            return false
        if (behav == '0' || behav == '1') {
            if (chrom1p != '6' && chrom1p != '8' && chrom1p != null)
                return false
            if (chrom19q != '6' && chrom19q!= '8' && chrom19q != null)
                return false
            if (methylation != '6' && methylation!= '8' && methylation != null)
                return false
        }
        
        return true
    }

    // ID: IFN6078; NAME: Gleason Patterns Pathological, EOD Prostate Pathologic Extension (SEER)
    public boolean ifn6078(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.schemaId != '00580' || line.gleasonPatternsPathological == null || line.prostatePathologicalExtension == null)
            return true
        
        if (line.gleasonPatternsPathological == 'X7') {
            if (line.dateOfDiagnosisYear < '2022')
                return ['900', '950'].contains(line.prostatePathologicalExtension)
            else
                return line.prostatePathologicalExtension == '900'
        }
        if (line.prostatePathologicalExtension == '900')
            return line.gleasonPatternsPathological == 'X7'
        else if (line.prostatePathologicalExtension == '950') {
            if (line.dateOfDiagnosisYear < '2022')
                return line.gleasonPatternsPathological == 'X7' || line.gleasonPatternsPathological == 'X9'
            else
                return line.gleasonPatternsPathological == 'X9'
        }
        
        return true
    }

    // ID: IFN6079; NAME: EOD Regional Nodes, Regional Nodes Positive (SEER)
    public boolean ifn6079(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.eodRegionalNodes == null || line.regionalNodesPositive == null)
            return true
        
        if (line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.schemaId == '00811')
            return line.eodRegionalNodes != '000' || ['00', '98', '99'].contains(line.regionalNodesPositive)
        else
            return !functions.matches(line.eodRegionalNodes, /^0[0357]0$/) || ['00', '98', '99'].contains(line.regionalNodesPositive)
    }

    // ID: IFN6081; NAME: Invasion Beyond Capsule, Kidney, Surgery 03-2022 (SEER)
    public boolean ifn6081(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        
                Integer dolcYear = functions.asInt(line.dateOfLastContactYear)
                Integer dolcMonth = functions.asInt(line.dateOfLastContactMonth)
                Integer dolcDay = functions.asInt(line.dateOfLastContactDay)
                Integer dxYear = functions.asInt(line.dateOfDiagnosisYear)
                Integer dxMonth = functions.asInt(line.dateOfDiagnosisMonth)
                Integer dxDay = functions.asInt(line.dateOfDiagnosisDay)
        
            if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.dateOfDiagnosisYear > '2022' || line.rxSummSurgPrimSite == null || line.schemaId != '00600' || line.typeOfReportingSource == '6' || line.typeOfReportingSource == '7' ||
            (line.vitalStatus == '0' && (Boolean)((Closure)context.compareDatesWithinMonths).call(dolcYear, dolcMonth, dolcDay, dxYear, dxMonth, dxDay, 5)))
            return true
        
        String invasionBeyondCapsule = line.invasionBeyondCapsule
        if (invasionBeyondCapsule == null || invasionBeyondCapsule == '8')
            return true
        
        if (functions.matches(line.rxSummSurgPrimSite, /^00|1[0-5]|2[0-7]|99$/))
            return invasionBeyondCapsule == '9'
        
        return true
    }

    // ID: IFN6082; NAME: Ipsilateral Adrenal Gland Involvement, Kidney, Surgery 03-2022 (SEER)
    public boolean ifn6082(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.dateOfDiagnosisYear > '2022' || line.rxSummSurgPrimSite == null || line.schemaId != '00600' ||
                    line.typeOfReportingSource == '6' || line.typeOfReportingSource == '7')
            return true
        
        Integer dolcYear = functions.asInt(line.dateOfLastContactYear)
        Integer dolcMonth = functions.asInt(line.dateOfLastContactMonth)
        Integer dolcDay = functions.asInt(line.dateOfLastContactDay)
        Integer dxYear = functions.asInt(line.dateOfDiagnosisYear)
        Integer dxMonth = functions.asInt(line.dateOfDiagnosisMonth)
        Integer dxDay = functions.asInt(line.dateOfDiagnosisDay)
        
        if (line.vitalStatus == '0' && (Boolean)((Closure)context.compareDatesWithinMonths).call(dolcYear, dolcMonth, dolcDay, dxYear, dxMonth, dxDay, 5))
            return true
        
        String ipsilateralAdrenalGlandInvolvement = line.ipsilateralAdrenalGlandInvolve
        if (ipsilateralAdrenalGlandInvolvement == null || ipsilateralAdrenalGlandInvolvement == '8')
            return true
        
        if (functions.matches(line.rxSummSurgPrimSite, /^00|1[0-5]|2[0-7]$/) && (line.rxSummSurgOthRegDis == '0' || line.rxSummSurgOthRegDis == '3'))
            return ipsilateralAdrenalGlandInvolvement == '9'
        
        if (line.rxSummSurgPrimSite == '99' && ['0','3','9'].contains(line.rxSummSurgOthRegDis))
            return ipsilateralAdrenalGlandInvolvement == '9'
        
        return true
    }

    // ID: IFN6083; NAME: Major Vein Involvement, Kidney, Surgery 03-2022 (SEER)
    public boolean ifn6083(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.dateOfDiagnosisYear > '2022' ||line.rxSummSurgPrimSite == null || line.schemaId != '00600' ||
                    line.typeOfReportingSource == '6' || line.typeOfReportingSource == '7')
            return true
        
        Integer dolcYear = functions.asInt(line.dateOfLastContactYear)
        Integer dolcMonth = functions.asInt(line.dateOfLastContactMonth)
        Integer dolcDay = functions.asInt(line.dateOfLastContactDay)
        Integer dxYear = functions.asInt(line.dateOfDiagnosisYear)
        Integer dxMonth = functions.asInt(line.dateOfDiagnosisMonth)
        Integer dxDay = functions.asInt(line.dateOfDiagnosisDay)
        
        if (line.vitalStatus == '0' && (Boolean)((Closure)context.compareDatesWithinMonths).call(dolcYear, dolcMonth, dolcDay, dxYear, dxMonth, dxDay, 5))
            return true
        
        String majorVeinInvolvement = line.majorVeinInvolvement
        if (majorVeinInvolvement == null || majorVeinInvolvement == '8')
            return true
        
        if (functions.matches(line.rxSummSurgPrimSite, /^00|1[0-5]|2[0-7]|99$/))
            return majorVeinInvolvement == '9'
        
        return true
    }

    // ID: IFN6084; NAME: Tumor Deposits, Colorectal, Surgery 03-2022 (SEER)
    public boolean ifn6084(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.dateOfDiagnosisYear > '2022' || line.rxSummSurgPrimSite == null
                    || line.schemaId != '00200' || ['6','7'].contains(line.typeOfReportingSource))
            return true
        
        Integer dolcYear = functions.asInt(line.dateOfLastContactYear)
        Integer dolcMonth = functions.asInt(line.dateOfLastContactMonth)
        Integer dolcDay = functions.asInt(line.dateOfLastContactDay)
        Integer dxYear = functions.asInt(line.dateOfDiagnosisYear)
        Integer dxMonth = functions.asInt(line.dateOfDiagnosisMonth)
        Integer dxDay = functions.asInt(line.dateOfDiagnosisDay)
        
        if (line.vitalStatus == '0' && (Boolean)((Closure)context.compareDatesWithinMonths).call(dolcYear, dolcMonth, dolcDay, dxYear, dxMonth, dxDay, 5))
            return true
        
        String tumorDeposits = line.tumorDeposits
        if (tumorDeposits == null || tumorDeposits == 'X8')
            return true
        
        if (functions.matches(line.rxSummSurgPrimSite, /^00|1[0-4]|2\d$/) || line.rxSummSurgPrimSite == '99')
            return tumorDeposits == 'X9'
        
        return true
    }

    // ID: IFN6085; NAME: Percent Necrosis Post Neoadjuvant, Bone, DX Confirm (NAACCR)
    public boolean ifn6085(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.diagnosticConfirmation == null)
            return true
        
        String percentNecrosis = line.percentNecrosisPostNeoadjuvant
        if ((line.schemaId != '00381' && line.schemaId != '00382' && line.schemaId != '00383') || percentNecrosis == null || percentNecrosis == 'XXX.8')
            return true
        
        if (line.diagnosticConfirmation != '1')
            return percentNecrosis == 'XXX.9'
        
        return true
    }

    // ID: IFN6087; NAME: LN Distant, Gynecologic, Mets at DX-Distant LN (NAACCR)
    public boolean ifn6087(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.metsAtDxDistantLn == null)
            return true
        
        String lnDistant = line.lnDistantMediastinalScalene
        if (!['00510', '00520', '09520'].contains(line.schemaId) || lnDistant == null || lnDistant == '8')
            return true
        
        if (lnDistant == '1' || lnDistant == '2' || lnDistant == '3')
            return line.metsAtDxDistantLn == '1'
        
        return true
    }

    // ID: IFN6088; NAME: LN Isolated Tumor Cells (ITC), Merkel Cell, Reg Nodes Positive (NAACCR)
    public boolean ifn6088(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.schemaId != '00460' || line.lnIsolatedTumorCells == null || line.lnIsolatedTumorCells == '8')
            return true
        
        if (line.regionalNodesPositive == null)
            return true
        
        if (line.typeOfReportingSource == '7')
            return true
        
        if (line.lnIsolatedTumorCells == '1' && (line.regionalNodesPositive == '00' || line.regionalNodesPositive == '98' || line.regionalNodesPositive == '99'))
            return false
        
        if (line.lnIsolatedTumorCells == '0' && line.regionalNodesPositive == '98')
            return false
        
        return true
    }

    // ID: IFN6089; NAME: LN Positive Axillary Level I-II, Breast, Reg Nodes Positive (NAACCR)
    public boolean ifn6089(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.schemaId != '00480' || line.lnPositiveAxillaryLevel1To2 == null ||
                    line.lnPositiveAxillaryLevel1To2 == 'X8' || line.typeOfReportingSource == '7' || line.regionalNodesPositive == null)
            return true
        
        if (functions.matches(line.lnPositiveAxillaryLevel1To2, /^0[1-9]|[2-9]\d|X[156]$/) && (line.regionalNodesPositive == '00' || line.regionalNodesPositive == '98' || line.regionalNodesPositive == '99'))
            return false
        
        if (functions.matches(line.lnPositiveAxillaryLevel1To2, /^0[1-9]|[2-9]\d$/) && (line.lnPositiveAxillaryLevel1To2 > line.regionalNodesPositive))
            return false
        
        if (line.regionalNodesPositive == '95' && line.lnPositiveAxillaryLevel1To2 != '00' && line.lnPositiveAxillaryLevel1To2 != 'X9' && line.lnPositiveAxillaryLevel1To2 != 'X6')
            return false
        
        if (line.regionalNodesPositive == '98' && line.lnPositiveAxillaryLevel1To2 != 'X9')
            return false
        
        return true
    }

    // ID: IFN6091; NAME: Extranodal Extension Head and Neck Clin/Path, Summary Stage 2018 (NAACCR)
    public boolean ifn6091(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.summaryStage2018 == null || line.typeOfReportingSource == '7')
            return true
        if (!functions.matches(line.schemaId, /^00(0[689]0|07[1-7]|1[04]0|1[12][12]|13[0-3])$/))
            return true
        if ((line.extranodalExtensionHeadNeckClin == null || line.extranodalExtensionHeadNeckClin == '8') && (line.extranodalExtensionHeadNeckPath == null || line.extranodalExtensionHeadNeckPath == 'X.8'))
            return true
        
        if (line.extranodalExtensionHeadNeckClin == '7' && line.extranodalExtensionHeadNeckPath == 'X.7' && ['3','4'].contains(line.summaryStage2018))
            return false
        if (['0','1','2','4'].contains(line.extranodalExtensionHeadNeckClin) && functions.matches(line.extranodalExtensionHeadNeckPath, /^\d\.\d|X\.[1-4]$/) && ['0','1','2'].contains(line.summaryStage2018))
            return false
        return true
    }

    // ID: IFN6092; NAME: FIGO Stage, Gynecologic, EOD Primary Tumor (SEER)
    public boolean ifn6092(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.figoStage == null || line.eodPrimaryTumor == null)
            return true
        
        if (!functions.matches(line.schemaId, /^(00(5[01236]0|55[123]|528)|095[02]0)$/))
            return true
        
        if (line.figoStage == '97' && line.eodPrimaryTumor != '000')
            return false
        
        if (line.eodPrimaryTumor == '000' && line.figoStage != '97')
            return false
        
        return true
    }

    // ID: IFN6093; NAME: Grade Post Therapy, Gleason Patterns Pathological (NAACCR)
    public boolean ifn6093(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.schemaId != '00580' || line.gradePostTherapy == null)
            return true
        
        if (line.gleasonPatternsPathological == null || line.gleasonPatternsPathological == 'X8')
            return true 
        
        return line.gradePostTherapy == '9' || line.gleasonPatternsPathological == 'X9'
    }

    // ID: IFN6099; NAME: LN Distant Assessment Method, Surgery Other Site (SEER)
    public boolean ifn6099(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.rxSummSurgOthRegDis == null ||
                    line.typeOfReportingSource == '6' || line.typeOfReportingSource  == '7')
            return true
        
        Integer dolcYear = functions.asInt(line.dateOfLastContactYear)
        Integer dolcMonth = functions.asInt(line.dateOfLastContactMonth)
        Integer dolcDay = functions.asInt(line.dateOfLastContactDay)
        Integer dxYear = functions.asInt(line.dateOfDiagnosisYear)
        Integer dxMonth = functions.asInt(line.dateOfDiagnosisMonth)
        Integer dxDay = functions.asInt(line.dateOfDiagnosisDay)
        
        if (line.vitalStatus == '0' && (Boolean)((Closure)context.compareDatesWithinMonths).call(dolcYear, dolcMonth, dolcDay, dxYear, dxMonth, dxDay, 5))
            return true
        
        if (line.lnDistantAssessMethod == null || line.lnDistantAssessMethod == '8' || !['00510', '00520', '09520'].contains(line.schemaId))
            return true
        
        if (line.lnDistantAssessMethod == '2' && line.rxSummSurgOthRegDis != '3' && line.rxSummSurgOthRegDis != '5')
            return false
        
        return true
    }

    // ID: IFN6104; NAME: Summary Stage 2018, Regional Nodes Positive (NAACCR)
    public boolean ifn6104(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.summaryStage2018 == null ||
                    line.regionalNodesPositive == null || line.typeOfReportingSource  == '7')
            return true
        
        return !functions.matches(line.regionalNodesPositive, /^0[1-9]|[1-8]\d|9[0-7]$/) || !functions.matches(line.summaryStage2018, /^[0129]$/)
    }

    // ID: IFN6105; NAME: Grade Post Therapy, Gleason Score Pathological, Tertiary Pattern (NAACCR)
    public boolean ifn6105(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.schemaId != '00580' || line.gradePostTherapy == null)
            return true
        
        if ((line.gleasonPatternsPathological == null || line.gleasonPatternsPathological == 'X8') && (line.gleasonTertiaryPattern == null || line.gleasonTertiaryPattern == 'X8'))
            return true 
        
        if (line.gradePostTherapy != '9') {
            if (line.gleasonPatternsPathological != null && line.gleasonPatternsPathological != 'X8' && line.gleasonPatternsPathological != 'X9')
                return false
            if (line.gleasonTertiaryPattern != null && line.gleasonTertiaryPattern != 'X8' && line.gleasonTertiaryPattern != 'X9')
                return false
        }
        
        return true
    }

    // ID: IFN6107; NAME: Extranodal Extension Head and Neck Path, Head/Neck, Reg Nodes Positive (NAACCR)
    public boolean ifn6107(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.extranodalExtensionHeadNeckPath == null)
            return true
        
        if ( !functions.matches(line.schemaId, /^00(0[689]0|07[1-7]|100|1[12][12]|13[0-3]|140)$/))
            return true
        
        if (line.regionalNodesPositive == null || line.typeOfReportingSource == '7')
            return true
        
        if (functions.matches(line.extranodalExtensionHeadNeckPath, /^\d\.\d|X\.[1-4]$/) && (line.regionalNodesPositive == '00' || line.regionalNodesPositive == '98'))
            return false
        
        if (line.regionalNodesPositive == '00' && line.extranodalExtensionHeadNeckPath != 'X.7' && line.extranodalExtensionHeadNeckPath != 'X.9')
            return false
            
        if (line.regionalNodesPositive == '98' && line.extranodalExtensionHeadNeckPath != 'X.9')
            return false
        
        return true
    }

    // ID: IFN6108; NAME: Extranodal Extension Path (non-Head and Neck), Reg Nodes Positive (NAACCR)
    public boolean ifn6108(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019')
            return true
            
        if (line.extranodalExtensionPath == null || line.extranodalExtensionPath == '8')
            return true
        
        if ((line.schemaId != '00460' && line.schemaId != '00570') || line.regionalNodesPositive == null)
            return true
        
        String extPath = line.extranodalExtensionPath
        String positiveNodes = line.regionalNodesPositive
        if ((extPath == '0' || extPath == '1') && (positiveNodes == '00' || positiveNodes == '98'))
            return false
            
        if (positiveNodes == '00' && extPath != '7' && extPath != '9')
            return false
        
        if (positiveNodes == '98' && extPath != '9')
            return false
        
        return true
    }

    // ID: IFN6110; NAME: Number of Examined Para-Aortic/Pelvic Nodes, Corpus, Reg Nodes Examined (NAACCR)
    public boolean ifn6110(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.regionalNodesExamined == null)
            return true
        
        if (!['00530', '00541', '00542', '00528'].contains(line.schemaId))
            return true
        
        String pelvicNodes = line.numberOfExaminedPelvicNodes
        String paraAorticNodes = line.numberOfExaminedParaAorticNodes
        if ((pelvicNodes == null || pelvicNodes == 'X8') && (paraAorticNodes == null || paraAorticNodes == 'X8'))
            return true
        
        if (line.regionalNodesExamined == '00')
            if ((pelvicNodes != '00' && pelvicNodes != 'X9') || (paraAorticNodes != '00' && paraAorticNodes != 'X9'))
                return false
        
        if (line.regionalNodesExamined == '95')
            if ((pelvicNodes != '00' && pelvicNodes != 'X6' && pelvicNodes != 'X9') || (paraAorticNodes != '00' && paraAorticNodes != 'X6' && paraAorticNodes != 'X9'))
                return false
        
        if ((functions.matches(pelvicNodes, /^0[1-9]|[1-9]\d|X[126]$/) || functions.matches(paraAorticNodes, /^0[1-9]|[1-9]\d|X[126]$/)) && line.regionalNodesExamined == '00')
            return false
        
        return true
    }

    // ID: IFN6111; NAME: Number of Positive Para-Aortic/Pelvic Nodes, Corpus, Reg Nodes Positive (NAACCR)
    public boolean ifn6111(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.regionalNodesPositive == null)
            return true
        
        if (!['00530', '00541', '00542', '00528'].contains(line.schemaId))
            return true
        
        String pelvicNodes = line.numberOfPositivePelvicNodes
        String paraAorticNodes = line.numberOfPositiveParaAorticNodes
        if ((pelvicNodes == null || pelvicNodes == 'X8') && (paraAorticNodes == null || paraAorticNodes == 'X8'))
            return true
        
        if (line.regionalNodesPositive == '00')
            if ((pelvicNodes != '00' && pelvicNodes != 'X9') || (paraAorticNodes != '00' && paraAorticNodes != 'X9'))
                return false
        
        if (line.regionalNodesPositive == '95')
            if ((pelvicNodes != '00' && pelvicNodes != 'X6' && pelvicNodes != 'X9') || (paraAorticNodes != '00' && paraAorticNodes != 'X6' && paraAorticNodes != 'X9'))
                return false
        
        if ((functions.matches(pelvicNodes, /^0[1-9]|[1-9]\d|X[126]$/) || functions.matches(paraAorticNodes, /^0[1-9]|[1-9]\d|X[126]$/)) && line.regionalNodesPositive == '00')
            return false
        
        return true
    }

    // ID: IFN6114; NAME: Number of Cores Positive/Examined, Prostate (NAACCR)
    public boolean ifn6114(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.schemaId != '00580')
            return true
        
        if ((line.numberOfCoresPositive == null || line.numberOfCoresPositive == 'X8') && (line.numberOfCoresExamined == null || line.numberOfCoresExamined == 'X8'))
            return true
        
        if (line.numberOfCoresPositive == 'X7' || line.numberOfCoresExamined == 'X7')
            return line.numberOfCoresPositive == 'X7' && line.numberOfCoresExamined == 'X7'
        
        if (functions.matches(line.numberOfCoresExamined, /^0[1-9]|[1-9]\d$/)) { 
            if (line.numberOfCoresPositive == 'X6')
                return true
            else if (functions.matches(line.numberOfCoresPositive, /^\d\d$/) && line.numberOfCoresExamined >= line.numberOfCoresPositive)
                return true
            return false
        }
        if (functions.matches(line.numberOfCoresExamined, /^X[16]$/) && !functions.matches(line.numberOfCoresPositive, /^\d\d|X[16]$/))
            return false
        
        if (functions.matches(line.numberOfCoresPositive, /^\d\d|X[16]$/) && line.numberOfCoresExamined == 'X9')
            return false
        
        return true
    }

    // ID: IFN6123; NAME: Serum Markers, Testis, Post-Orchiectomy 03-2022, Lab Value (NAACCR)
    public boolean ifn6123(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.dateOfDiagnosisYear >  '2022' || line.rxSummSurgPrimSite == null
                    || line.schemaId != '00590')
            return true
        
        if ((line.afpPostOrchiectomyLabValue == null || line.afpPostOrchiectomyLabValue == 'XXXXX.8') && (line.hcgPostOrchiectomyLabValue == null || line.hcgPostOrchiectomyLabValue == 'XXXXX.8'))
            return true
        
        String primSite = line.rxSummSurgPrimSite
        if (primSite == '00' || primSite == '12' || primSite == '20' || primSite == '99')
            return line.afpPostOrchiectomyLabValue == 'XXXXX.9' && line.hcgPostOrchiectomyLabValue == 'XXXXX.9'
        
        return true
    }

    // ID: IFN6128; NAME: EOD Prostate Pathologic Extension, Blank for Other Schemas (SEER)
    public boolean ifn6128(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.schemaId == '00580')
            return true
        
        return line.prostatePathologicalExtension == null
    }

    // ID: IFN6129; NAME: Tumor Size 998, Schema ID (SEER)
    public boolean ifn6129(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.dateOfDiagnosisYear > '2023' || line.typeOfReportingSource == '7')
            return true
        
        if (line.tumorSizeSummary == '998' || line.tumorSizeClinical == '998' || line.tumorSizePathologic == '998')
            return ((List)context.IFN_6129_SchemaId_List).contains(line.schemaId)
        
        return true
    }

    // ID: IFN6130; NAME: Tumor Size 999, Schema ID, Primary Site (SEER)
    public boolean ifn6130(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.dateOfDiagnosisYear > '2023' || line.schemaId == null)
            return true
        
        if (line.primarySite == null || line.primarySite == 'C422')
            return true
        
        if (((List)context.IFN_6130_SchemaId_List).contains(line.schemaId) || functions.matches(line.primarySite, /^C(42[0134]|77\d|809)$/))
            return ((line.tumorSizeSummary == '999' || line.tumorSizeSummary == null)
            && (line.tumorSizeClinical == '999' || line.tumorSizeClinical == null)
            && (line.tumorSizePathologic == '999' || line.tumorSizePathologic == null))
        
        return true
    }

    // ID: IFN6132; NAME: EOD Primary Tumor, Primary Site NOS (SEER)
    public boolean ifn6132(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.eodPrimaryTumor == null)
            return true
        if (line.typeOfReportingSource == '7' || ['00790','00795','00470'].contains(line.schemaId))
            return true
        if (line.primarySite == null || functions.matches(line.primarySite, /^C(14[0-8]|2(1\d|2[01])|3(0[01]|8[0-8])|4(2[0-4]|8[0-8])|76[0-8])$/))
            return true
        
        return line.eodPrimaryTumor != '800' || line.primarySite.endsWith('9')
    }

    // ID: IFN6134; NAME: Tumor Size, EOD Regional Nodes, Mets (SEER)
    public boolean ifn6134(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.dateOfDiagnosisYear > '2023' || line.typeOfReportingSource == '7')
            return true
        if (line.schemaId == null || ['00458','00671','00672','00790','00795','00821','00822','00830'].contains(line.schemaId))
            return true
        if (line.eodRegionalNodes == null && line.eodMets == null)
            return true
        if (line.tumorSizeClinical == null && line.tumorSizePathologic == null && line.tumorSizeSummary == null)
            return true
        
        if ((line.tumorSizeClinical == '000' && line.tumorSizePathologic == '000') || (line.tumorSizeSummary == '000')) {
            if (line.schemaId == '00480') {
                if (['000', '030', '050', '070'].contains(line.eodRegionalNodes) && ['00', '05'].contains(line.eodMets))
                    return false
            }
            else if (['00500', '09500', '00510', '00520', '00528', '09520', '00530', '00541', '00542', '00551', '00552', '00553'].contains(line.schemaId)) {
                if (['000', '040', '050'].contains(line.eodRegionalNodes) && line.eodMets == '00')
                    return false
            }
            else {
                if (line.eodRegionalNodes == '000' && line.eodMets == '00')
                    return false
            }
        }
        
        return true
    }

    // ID: IFN6135; NAME: Tumor Size, EOD Primary Tumor, Schema ID (SEER)
    public boolean ifn6135(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.dateOfDiagnosisYear > '2023'
                    || (line.tumorSizeClinical == null && line.tumorSizePathologic == null) || line.typeOfReportingSource == '7' || line.eodPrimaryTumor == null)
            return true
        if (line.schemaId == null || ['00458','00671','00672','00790','00795','00821','00822','00830'].contains(line.schemaId))
            return true
        
        if (((List)context.IFN_6135_SchemaId_List).contains(line.schemaId))
            return (line.tumorSizeClinical != '000' || line.tumorSizePathologic != '000') && line.tumorSizeSummary != '000'
        else if (line.schemaId == '00060')
            return (line.tumorSizeClinical == '000' || line.tumorSizePathologic == '000') && (line.tumorSizeSummary == null || line.tumorSizeSummary == '000')
        else if (line.schemaId == '00360') {
            if ((line.tumorSizeClinical == '000' && line.tumorSizePathologic == '000') || line.tumorSizeSummary == '000')
                if (line.eodPrimaryTumor != '800' && line.eodPrimaryTumor != '980')
                    return false
            if (line.eodPrimaryTumor == '800' || line.eodPrimaryTumor == '980')
                return (line.tumorSizeClinical == '000' || line.tumorSizeClinical == '999' || line.tumorSizePathologic == '000' || line.tumorSizePathologic == '999')
                    && (line.tumorSizeSummary == null || line.tumorSizeSummary == '000' || line.tumorSizeSummary == '999')
        }
        else if (line.schemaId == '00580') {
            if (line.tumorSizeClinical == '000' && line.eodPrimaryTumor != '800')
                return false
            if (line.eodPrimaryTumor == '800' && line.tumorSizeClinical != '000' && line.tumorSizeClinical != '999')
                return false
            if (line.tumorSizePathologic == '000' && line.prostatePathologicalExtension != null && line.prostatePathologicalExtension != '800')
                return false
            if (line.prostatePathologicalExtension == '800' && line.tumorSizePathologic != '000' && line.tumorSizePathologic != '999')
                return false
            if (line.tumorSizeClinical == '000' && line.tumorSizePathologic == '000' && line.tumorSizeSummary != null && line.tumorSizeSummary != '000')
                return false
            if (line.tumorSizeClinical != '000' && line.tumorSizeClinical != '999' && line.tumorSizePathologic != '000' && line.tumorSizePathologic != '999')
                return line.tumorSizeSummary != '000' && line.tumorSizeSummary != '999'
        }
        else {
            if ((line.tumorSizeClinical == '000' && line.tumorSizePathologic == '000') || line.tumorSizeSummary == '000') {
                if (line.schemaId != '99999' && line.eodPrimaryTumor != '800')
                    return false
            }
            if (line.eodPrimaryTumor == '800')
                return (line.tumorSizeClinical == '000' || line.tumorSizeClinical == '999' || line.tumorSizePathologic == '000' || line.tumorSizePathologic == '999')
                    && (line.tumorSizeSummary == null || line.tumorSizeSummary == '000' || line.tumorSizeSummary == '999')
        }
        
        
        return true
    }

    // ID: IFN6140; NAME: Behavior Code ICDO3, EOD Tumor/Nodes/Mets, Schema ID (SEER)
    public boolean ifn6140(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.behaviorCodeIcdO3 == null || ['0','1'].contains(line.behaviorCodeIcdO3))
            return true
        if (line.eodPrimaryTumor == null && line.eodRegionalNodes == null && line.eodMets == null)
            return true
            
        boolean schemaIdInList5To10 =
        ((List)context.EOD_SchemaId_List_5).contains(line.schemaId) ||
        ((List)context.EOD_SchemaId_List_6).contains(line.schemaId) ||
        ((List)context.EOD_SchemaId_List_7).contains(line.schemaId) ||
        ((List)context.EOD_SchemaId_List_8).contains(line.schemaId) ||
        ((List)context.EOD_SchemaId_List_9).contains(line.schemaId) ||
        ((List)context.EOD_SchemaId_List_10).contains(line.schemaId)
        if (schemaIdInList5To10 && line.behaviorCodeIcdO3 == '2')
            return false
        
        Map eodValuesMap = (Map)((Map)((Map)context.IFN_6140_Table).get(line.behaviorCodeIcdO3))?.get(line.schemaId)
        Map eodPrimaryTumorValues = (Map)eodValuesMap?.get('eodPrimaryTumor')
        Map eodRegionalNodesValues = (Map)eodValuesMap?.get('eodRegionalNodes')
        Map eodMetsValues = (Map)eodValuesMap?.get('eodMets')
        
        boolean eodPrimaryTumorCondition = line.behaviorCodeIcdO3 == '2'
        boolean eodRegionalNodesCondition = line.behaviorCodeIcdO3 == '2'
        boolean eodMetsCondition = line.behaviorCodeIcdO3 == '2'
        
        if (eodPrimaryTumorValues != null) {
            List eqValues = (List)eodPrimaryTumorValues.get('eq')
            List neValues = (List)eodPrimaryTumorValues.get('ne')
            eodPrimaryTumorCondition = (eqValues == null || (line.eodPrimaryTumor != null && eqValues.contains(line.eodPrimaryTumor))) &&
                (neValues == null || (line.eodPrimaryTumor == null || !neValues.contains(line.eodPrimaryTumor)))
        }
        if (eodRegionalNodesValues != null) {
            List eqValues = (List)eodRegionalNodesValues.get('eq')
            List neValues = (List)eodRegionalNodesValues.get('ne')
            eodRegionalNodesCondition = (eqValues == null || (line.eodRegionalNodes != null && eqValues.contains(line.eodRegionalNodes))) &&
                (neValues == null || (line.eodRegionalNodes == null || !neValues.contains(line.eodRegionalNodes)))
        }
        if (eodMetsValues != null) {
            List eqValues = (List)eodMetsValues.get('eq')
            List neValues = (List)eodMetsValues.get('ne')
            eodMetsCondition = (eqValues == null || (line.eodMets != null && eqValues.contains(line.eodMets))) &&
                (neValues == null || (line.eodMets == null || !neValues.contains(line.eodMets)))
        }
        
        if (eodMetsValues == null && eodRegionalNodesValues == null && eodPrimaryTumorValues == null)
            return true
        
        if (line.behaviorCodeIcdO3 == '2' && (!(eodPrimaryTumorCondition && eodRegionalNodesCondition && eodMetsCondition)))
            return false
        
        if (line.behaviorCodeIcdO3 == '3' && (!(eodPrimaryTumorCondition || eodRegionalNodesCondition || eodMetsCondition)))
            return false
        
        return true
    }

    // ID: IFN6141; NAME: Summary Stage 2018, EOD Tumor/Nodes/Mets, Schema ID (SEER)
    public boolean ifn6141(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.summaryStage2018 == null)
            return true
        if (line.schemaId == null || line.typeOfReportingSource == '7' || ['0', '1'].contains(line.behaviorCodeIcdO3) || line.behaviorCodeIcdO3 == null)
            return true
        if (line.eodPrimaryTumor == null && line.eodRegionalNodes == null && line.eodMets == null)
            return true
        
        boolean passing = true
        
        Map eodValuesMap = (Map)((Map)((Map)context.Summary_Stage_EOD_Table).get(line.summaryStage2018))?.get(line.schemaId)
        Map eodPrimaryTumorValues = (Map)eodValuesMap?.get('eodPrimaryTumor')
        Map eodRegionalNodesValues = (Map)eodValuesMap?.get('eodRegionalNodes')
        Map eodMetsValues = (Map)eodValuesMap?.get('eodMets')
        
        if (eodPrimaryTumorValues != null) {
            List eqValues = (List)eodPrimaryTumorValues.get('eq')
            passing &= (eqValues == null || (line.eodPrimaryTumor != null && eqValues.contains(line.eodPrimaryTumor)))
            List neValues = (List)eodPrimaryTumorValues.get('ne')
            passing &= (neValues == null || (line.eodPrimaryTumor == null || !neValues.contains(line.eodPrimaryTumor)))
        }
        if (eodRegionalNodesValues != null) {
            List eqValues = (List)eodRegionalNodesValues.get('eq')
            passing &= (eqValues == null || (line.eodRegionalNodes != null && eqValues.contains(line.eodRegionalNodes)))
            List neValues = (List)eodRegionalNodesValues.get('ne')
            passing &= (neValues == null || (line.eodRegionalNodes == null || !neValues.contains(line.eodRegionalNodes)))
        }
        if (eodMetsValues != null) {
            List eqValues = (List)eodMetsValues.get('eq')
            passing &= (eqValues == null || (line.eodMets != null && eqValues.contains(line.eodMets)))
            List neValues = (List)eodMetsValues.get('ne')
            passing &= (neValues == null || (line.eodMets == null || !neValues.contains(line.eodMets)))
        }
        
        boolean schemaIdInList5To10 =
        ((List)context.EOD_SchemaId_List_5).contains(line.schemaId) ||
        ((List)context.EOD_SchemaId_List_6).contains(line.schemaId) ||
        ((List)context.EOD_SchemaId_List_7).contains(line.schemaId) ||
        ((List)context.EOD_SchemaId_List_8).contains(line.schemaId) ||
        ((List)context.EOD_SchemaId_List_9).contains(line.schemaId) ||
        ((List)context.EOD_SchemaId_List_10).contains(line.schemaId)
        
        passing &= (!schemaIdInList5To10 || line.summaryStage2018 != '0')
        
        passing &= (line.schemaId != '00060' || !['1', '2', '4'].contains(line.summaryStage2018))
        
        passing &= (!['00721','00722','00723','09721','09722','09723','09724','00790','00795'].contains(line.schemaId) || !['3', '4'].contains(line.summaryStage2018))
        
        boolean eodMetsCondition = (line.eodMets >= '10' && line.eodMets <= '70') || (line.schemaId == '00370' && line.eodMets == '05') || (line.schemaId == '00458' && line.eodRegionalNodes == '700')
        passing &= (!eodMetsCondition || line.summaryStage2018 == '7')
        
        if (line.schemaId == '00790' || line.schemaId == '00795') {
            if (line.summaryStage2018 == '1')
                passing &= ['100', '200'].contains(line.eodPrimaryTumor)
            else if (line.summaryStage2018 == '2')
                passing &= ['300', '400', '500'].contains(line.eodPrimaryTumor)
            else if (line.summaryStage2018 == '7')
                passing &= ['575', '600', '700', '750', '800'].contains(line.eodPrimaryTumor)
        }
        
        return passing
    }

    // ID: IFN6145; NAME: Behavior Code ICDO3, Derived SS 2018, Schema ID (SEER)
    public boolean ifn6145(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if (line.behaviorCodeIcdO3 == null || line.derivedSummaryStage2018 == null)
            return true
        
        if (functions.matches(line.schemaId, /^0072[123]|0972[1-4]$/)) {
            if (['0','1'].contains(line.behaviorCodeIcdO3) && line.derivedSummaryStage2018 != '8')
                return false
            if (line.derivedSummaryStage2018 == '8' && !['0','1'].contains(line.behaviorCodeIcdO3))
                return false
        }
        
        if (line.behaviorCodeIcdO3 == '2')
            return line.derivedSummaryStage2018 == '0'
        else if (line.behaviorCodeIcdO3 == '3')
            return line.derivedSummaryStage2018 != '0' && line.derivedSummaryStage2018 != '8'
        return true
    }

    // ID: IFN6148; NAME: Mets at DX-Distant LN, EOD Mets, Schema ID (SEER)
    public boolean ifn6148(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7' ||
                    line.schemaId == null || line.metsAtDxDistantLn == null || line.eodMets == null)
                        return true
        
        boolean schema50028andYear2021Plus = line.dateOfDiagnosisYear >= '2021' && line.schemaId == '00528'
        if (line.metsAtDxDistantLn == '1' && (functions.matches(line.metsAtDxBone, /^0|9$/) || line.metsAtDxBone == null) && (functions.matches(line.metsAtDxBrain, /^0|9$/) || line.metsAtDxBrain == null) &&
            (functions.matches(line.metsAtDxLiver, /^0|9$/) || line.metsAtDxLiver == null) && (functions.matches(line.metsAtDxLung, /^0|9$/) || line.metsAtDxLung == null) &&
            (functions.matches(line.metsAtDxOther, /^0|9$/) || line.metsAtDxOther == null) && (((List)context.IFN_6148_SchemaId_List).contains(line.schemaId) || schema50028andYear2021Plus))
                return line.eodMets == '10'
        
        if ((((List)context.IFN_6148_SchemaId_List).contains(line.schemaId) || schema50028andYear2021Plus) && line.eodMets == '10')
            return line.metsAtDxDistantLn == '1'
        
        if (line.schemaId == '00230' && (line.eodMets == '50' || line.eodMets == '10'))
            return line.metsAtDxDistantLn == '1'
        
        if (line.schemaId == '00280' && (line.eodMets == '20' || line.eodMets == '10'))
            return line.metsAtDxDistantLn == '1'
        
        return true
    }

    // ID: IFN6149; NAME: Mets at DX-BBLLO, EOD Mets, Schema ID (SEER)
    public boolean ifn6149(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.typeOfReportingSource == '7'
                    || line.eodMets == null || line.eodMets == '88')
            return true
        if (line.metsAtDxBone == null && line.metsAtDxBrain == null && line.metsAtDxLiver == null && line.metsAtDxLung == null && line.metsAtDxOther == null )
            return true
        
        if (line.metsAtDxBone == '1' || line.metsAtDxBrain == '1' || line.metsAtDxLiver == '1' || line.metsAtDxLung == '1' || line.metsAtDxOther == '1' || line.metsAtDxOther == '2')
            if (((List)context.IFN_6149_SchemaId_List).contains(line.schemaId))
                return line.eodMets == '70'
        
        if (line.eodMets == '70' && ((List)context.IFN_6149_SchemaId_List).contains(line.schemaId))
            if (line.metsAtDxBone == '0' && line.metsAtDxBrain == '0' && line.metsAtDxLiver == '0'
                && line.metsAtDxLung == '0' && line.metsAtDxOther == '0')
                return false
        
        
        return true
    }

    // ID: IFN6150; NAME: Esophagus and EGJ Tumor Epicenter, Esophagus, EOD Primary Tumor (SEER)
    public boolean ifn6150(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021')
            return true
        if (line.typeOfReportingSource == '7' || line.schemaId == null || line.schemaId != '00161' || line.esophagusAndEgjTumorEpicenter == null)
            return true
        
        return line.eodPrimaryTumor != '800' || line.esophagusAndEgjTumorEpicenter == '9'
    }

    // ID: IFN6152; NAME: EOD Primary Tumor, Appendix, Histology ICDO3 (SEER)
    public boolean ifn6152(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.eodPrimaryTumor == null)
            return true
        if (line.typeOfReportingSource == '7' || line.schemaId == null || (line.schemaId != '00190' && line.schemaId != '09190') || line.histologicTypeIcdO3 == null)
            return true
        
        return line.eodPrimaryTumor != '600' || ['8480','8481','8490'].contains(line.histologicTypeIcdO3)
    }

    // ID: IFN6153; NAME: EOD Regional Nodes, Appendix, Regional Nodes Positive (SEER)
    public boolean ifn6153(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7' || line.eodRegionalNodes == null)
            return true
        if (line.schemaId == null || (line.schemaId != '00190' && line.schemaId != '09190') || line.regionalNodesPositive == null)
            return true
        
        return line.eodRegionalNodes != '400' || ['00','98','99'].contains(line.regionalNodesPositive)
    }

    // ID: IFN6154; NAME: Mets at DX, Appendix, EOD Mets (SEER)
    public boolean ifn6154(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        if (line.eodMets == null || line.schemaId == null || (line.schemaId != '00190' && line.schemaId != '09190'))
            return true
        if (line.metsAtDxBone == null && line.metsAtDxBrain == null && line.metsAtDxDistantLn == null && line.metsAtDxLiver == null && line.metsAtDxLung == null && line.metsAtDxOther == null)
            return true
        
        boolean metsAtDxBoneCondition = line.metsAtDxBone == null || ['0','9'].contains(line.metsAtDxBone)
        boolean metsAtDxBrainCondition = line.metsAtDxBrain == null || ['0','9'].contains(line.metsAtDxBrain)
        boolean metsAtDxDistantLnCondition = line.metsAtDxDistantLn == null || ['0','9'].contains(line.metsAtDxDistantLn)
        boolean metsAtDxLiverCondition = line.metsAtDxLiver == null || ['0','9'].contains(line.metsAtDxLiver)
        boolean metsAtDxLungCondition = line.metsAtDxLung == null || ['0','9'].contains(line.metsAtDxLung)
        boolean metsAtDxOtherCondition = line.metsAtDxOther == null || ['0','9'].contains(line.metsAtDxOther)
        
        if ((line.metsAtDxOther == '1' && metsAtDxBoneCondition && metsAtDxBrainCondition && metsAtDxDistantLnCondition && metsAtDxLiverCondition && metsAtDxLungCondition) && !['10','30','50'].contains(line.eodMets))
            return false
        if (line.metsAtDxOther == '2' && metsAtDxDistantLnCondition && metsAtDxBoneCondition && metsAtDxBrainCondition && metsAtDxLiverCondition && metsAtDxLungCondition && !['30','50'].contains(line.eodMets))
            return false
        if (line.metsAtDxDistantLn == '1' && metsAtDxBoneCondition && metsAtDxBrainCondition && metsAtDxLiverCondition && metsAtDxLungCondition && metsAtDxOtherCondition && line.eodMets != '40')
            return false
        if (((line.metsAtDxDistantLn == '1' && (line.metsAtDxOther == '1' || line.metsAtDxOther == '2')) || (line.metsAtDxBone == '1' || line.metsAtDxBrain == '1' || line.metsAtDxLiver == '1' || line.metsAtDxLung == '1')) && line.eodMets != '50')
            return false
        if (line.eodMets == '10' && line.metsAtDxOther != '1')
            return false
        if (line.eodMets == '30' && line.metsAtDxOther != '1' && line.metsAtDxOther != '2')
            return false
        if (line.eodMets == '40' && line.metsAtDxDistantLn != '1')
            return false
        return true
    }

    // ID: IFN6155; NAME: Tumor Deposits, Colorectal, EOD Regional Nodes, Regional Nodes Positive (SEER)
    public boolean ifn6155(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.schemaId != '00200' || line.eodRegionalNodes == null ||
                    line.tumorDeposits == null || line.tumorDeposits == 'X8' || line.regionalNodesPositive == null || line.typeOfReportingSource == '7')
                return true
        
        if (functions.matches(line.tumorDeposits, /^0[1-9]|[1-9]\d|X[12]$/) && line.eodRegionalNodes == '200')
            return ['00','98','99'].contains(line.regionalNodesPositive)
        
        return true
    }

    // ID: IFN6156; NAME: Mets at DX, Colon/Rectum, EOD Mets (SEER)
    public boolean ifn6156(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        if (line.eodMets == null || line.schemaId == null || line.schemaId != '00200')
            return true
        if (line.metsAtDxBone == null && line.metsAtDxBrain == null && line.metsAtDxDistantLn == null && line.metsAtDxLiver == null && line.metsAtDxLung == null && line.metsAtDxOther == null)
            return true
        
        boolean metsAtDxBoneCondition = line.metsAtDxBone == null || ['0','9'].contains(line.metsAtDxBone)
        boolean metsAtDxBrainCondition = line.metsAtDxBrain == null || ['0','9'].contains(line.metsAtDxBrain)
        boolean metsAtDxDistantLnCondition = line.metsAtDxDistantLn == null || ['0','9'].contains(line.metsAtDxDistantLn)
        boolean metsAtDxLiverCondition = line.metsAtDxLiver == null || ['0','9'].contains(line.metsAtDxLiver)
        boolean metsAtDxLungCondition = line.metsAtDxLung == null || ['0','9'].contains(line.metsAtDxLung)
        boolean metsAtDxOtherCondition = line.metsAtDxOther == null || ['0','9'].contains(line.metsAtDxOther)
        
        int count = 0
        if (line.metsAtDxBone == '1')
            count++
        if (line.metsAtDxBrain == '1')
            count++
        if (line.metsAtDxLiver == '1')
            count++
        if (line.metsAtDxLung == '1')
            count++
        if (line.metsAtDxOther == '1')
            count++
        
        if (line.metsAtDxDistantLn == '1' && metsAtDxBoneCondition && metsAtDxBrainCondition && metsAtDxLiverCondition && metsAtDxLungCondition && metsAtDxOtherCondition && !['10','30','70'].contains(line.eodMets))
            return false
        if (count == 1 && metsAtDxDistantLnCondition && !['20','40','50'].contains(line.eodMets))
            return false
        if (count == 1 && line.metsAtDxDistantLn == '1' && !['30','40','50'].contains(line.eodMets))
            return false
        if (count > 1 && (line.metsAtDxDistantLn == '1' || metsAtDxDistantLnCondition) && !['40','50'].contains(line.eodMets))
            return false
        if (line.metsAtDxOther == '2' && line.eodMets != '50')
            return false
        if (['10','30'].contains(line.eodMets) && line.metsAtDxDistantLn != '1')
            return false
        if (line.eodMets == '50' && !['1','2'].contains(line.metsAtDxOther))
            return false
        return true
    }

    // ID: IFN6157; NAME: Circumferential Resection Margin (CRM), Colon, Behavior ICDO3 (NAACCR)
    public boolean ifn6157(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
         if(line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.schemaId != '00200' || line.behaviorCodeIcdO3 == null ||
                    line.typeOfReportingSource == '7' || line.circumferentialResectionMargin == null || line.circumferentialResectionMargin == 'XX.8')
                return true
        if (line.behaviorCodeIcdO3 == '2')
            return line.circumferentialResectionMargin == 'XX.9'
        return true
                    
    }

    // ID: IFN6158; NAME: Tumor Deposits, Colorectal, Behavior (NAACCR)
    public boolean ifn6158(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.schemaId != '00200' || line.behaviorCodeIcdO3 == null ||
                    line.tumorDeposits == null || line.tumorDeposits == 'X8' || line.typeOfReportingSource == '7')
                return true
        
        if (functions.matches(line.tumorDeposits, /^0[1-9]|[1-9][0-9]$/) || line.tumorDeposits == 'X1' || line.tumorDeposits == 'X2')
            return line.behaviorCodeIcdO3 != '2'
        
        return true
    }

    // ID: IFN6159; NAME: EOD Regional Nodes, Pancreas/NET Pancreas, Primary Site (SEER)
    public boolean ifn6159(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7' || line.eodRegionalNodes == null)
            return true
        if (line.schemaId == null || !['00280','00340','09340'].contains(line.schemaId) || line.primarySite == null)
            return true
        
        return line.eodRegionalNodes != '700' || ['C251','C252'].contains(line.primarySite)
    }

    // ID: IFN6160; NAME: EOD Mets, Pancreas/NET Pancreas, Primary Site (SEER)
    public boolean ifn6160(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.eodMets == null)
            return true
        
        if (line.schemaId == null || (line.schemaId != '00280' && line.schemaId != '00340' && line.schemaId != '09340'))
            return true
        
        if (line.primarySite == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.schemaId == '00280' && !functions.matches(line.primarySite, /^C25[0-2]$/))
            return line.eodMets != '10'
        
        if ((line.schemaId == '00340' || line.schemaId == '09340') && !functions.matches(line.primarySite, /^C25[0-2]$/))
            return line.eodMets != '20'
        
        return true
    }

    // ID: IFN6161; NAME: Mets at DX, Lung, EOD Mets (SEER)
    public boolean ifn6161(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        if (line.eodMets == null || line.schemaId == null || line.schemaId != '00360')
            return true
        if (line.metsAtDxBone == null && line.metsAtDxBrain == null && line.metsAtDxDistantLn == null && line.metsAtDxLiver == null && line.metsAtDxLung == null && line.metsAtDxOther == null)
            return true
        
        boolean metsAtDxBoneCondition = line.metsAtDxBone == null || ['0','9'].contains(line.metsAtDxBone)
        boolean metsAtDxBrainCondition = line.metsAtDxBrain == null || ['0','9'].contains(line.metsAtDxBrain)
        boolean metsAtDxDistantLnCondition = line.metsAtDxDistantLn == null || ['0','9'].contains(line.metsAtDxDistantLn)
        boolean metsAtDxLiverCondition = line.metsAtDxLiver == null || ['0','9'].contains(line.metsAtDxLiver)
        boolean metsAtDxLungCondition = line.metsAtDxLung == null || ['0','9'].contains(line.metsAtDxLung)
        boolean metsAtDxOtherCondition = line.metsAtDxOther == null || ['0','9'].contains(line.metsAtDxOther)
        
        if (line.metsAtDxLung == '1' && metsAtDxBoneCondition && metsAtDxBrainCondition && metsAtDxDistantLnCondition && metsAtDxLiverCondition && metsAtDxOtherCondition && line.eodMets != '10')
            return false
        if (line.metsAtDxOther == '1' && metsAtDxBoneCondition && metsAtDxBrainCondition && metsAtDxDistantLnCondition && metsAtDxLiverCondition && (metsAtDxLungCondition || line.metsAtDxLung == '1') && !['10','30','50'].contains(line.eodMets))
            return false
        if (line.metsAtDxDistantLn == '1' && metsAtDxBoneCondition && metsAtDxBrainCondition && metsAtDxLiverCondition && (metsAtDxLungCondition || line.metsAtDxLung == '1')  && (metsAtDxOtherCondition || line.metsAtDxOther == '1')  && !['20','50'].contains(line.eodMets))
            return false
        
        int count = 0
        if (line.metsAtDxBone == '1')
            count++
        if (line.metsAtDxBrain == '1')
            count++
        if (line.metsAtDxLiver == '1')
            count++
        if (count == 1 && metsAtDxDistantLnCondition && (metsAtDxLungCondition || line.metsAtDxLung == '1') && (metsAtDxOtherCondition || line.metsAtDxOther == '1') && !['30','50'].contains(line.eodMets))
            return false
        if (line.metsAtDxDistantLn == '1')
            count++
        if ((count > 1 || line.metsAtDxOther == '2') && line.eodMets != '50')
            return false
        
        if (line.eodMets == '20' && line.metsAtDxDistantLn != '1')
            return false
        return true
    }

    // ID: IFN6162; NAME: EOD Primary Tumor, Lung, Primary Site (SEER)
    public boolean ifn6162(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.eodPrimaryTumor == null)
            return true
        if (line.typeOfReportingSource == '7' || line.schemaId == null || line.schemaId != '00360' || line.primarySite == null)
            return true
        
        return line.eodPrimaryTumor != '600' || ['C340','C348','C349'].contains(line.primarySite)
    }

    // ID: IFN6164; NAME: Visceral and Parietal Pleural Invasion, Lung, Behavior (NAACCR)
    public boolean ifn6164(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.schemaId != '00360' || line.behaviorCodeIcdO3 == null ||
                    line.visceralParietalPleuralInvasion == null || line.visceralParietalPleuralInvasion == '8' || line.typeOfReportingSource == '7')
                return true
        
        if (line.behaviorCodeIcdO3 == '2') {
            if (line.dateOfDiagnosisYear < '2023')
                return line.visceralParietalPleuralInvasion == '0' || line.visceralParietalPleuralInvasion == '9'
            else
                return line.visceralParietalPleuralInvasion == '0'
        }
        
        return true
    }

    // ID: IFN6165; NAME: EOD Regional Nodes, Melanoma Skin, Sentinel Lymph Nodes Positive, Regional Nodes Positive (SEER)
    public boolean ifn6165(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7' || line.eodRegionalNodes == null)
            return true
        if (line.schemaId == null || line.schemaId != '00470')
            return true
        
        if (['000','300'].contains(line.eodRegionalNodes)) {
            if (line.sentinelLymphNodesPositive != null && !['00','98','99'].contains(line.sentinelLymphNodesPositive))
                return false
            if (line.regionalNodesPositive != null && !['00','98','99'].contains(line.regionalNodesPositive))
                return false
        }
        else if (line.eodRegionalNodes == '100') {
            if (line.sentinelLymphNodesPositive != null && !functions.matches(line.sentinelLymphNodesPositive, /^0[01]|9[5789]$/))
                return false
            if (line.regionalNodesPositive != null && !['01','95','97'].contains(line.regionalNodesPositive))
                return false
        }
        else if (['200','350','500'].contains(line.eodRegionalNodes)) {
            if (line.sentinelLymphNodesPositive != null && !functions.matches(line.sentinelLymphNodesPositive, /^0[01]|9[5789]$/))
                return false
            if (line.regionalNodesPositive != null && !functions.matches(line.regionalNodesPositive, /^0[01]|9[5789]$/))
                return false
        }
        else if (line.eodRegionalNodes == '400') {
            if (line.sentinelLymphNodesPositive != null && !functions.matches(line.sentinelLymphNodesPositive, /^0[0-3]|9[5789]$/))
                return false
            if (line.regionalNodesPositive != null && !functions.matches(line.regionalNodesPositive, /^0[23]$/))
                return false
        }
        else if (['450','550'].contains(line.eodRegionalNodes)) {
            if (line.sentinelLymphNodesPositive != null && !functions.matches(line.sentinelLymphNodesPositive, /^0[0-3]|9[5789]$/))
                return false
            if (line.regionalNodesPositive != null && !functions.matches(line.regionalNodesPositive, /^0[0-3]|9[5789]$/))
                return false
        }
        else if (line.eodRegionalNodes == '600') {
            if (line.sentinelLymphNodesPositive != null && !functions.matches(line.sentinelLymphNodesPositive, /^[0-8]\d|9[05789]$/))
                return false
            if (line.regionalNodesPositive != null && !functions.matches(line.regionalNodesPositive, /^0[4-9]|[1-8]\d|9[057]$/))
                return false
        }
        else if (line.eodRegionalNodes == '999') {
            if (line.sentinelLymphNodesPositive != null && !['98','99'].contains(line.sentinelLymphNodesPositive))
                return false
            if (line.regionalNodesPositive != null && !['98','99'].contains(line.regionalNodesPositive))
                return false
        }
        
        if (functions.matches(line.sentinelLymphNodesPositive, /^0[1-9]|[1-8]\d|9[0-7]$/) || functions.matches(line.regionalNodesPositive, /^0[1-9]|[1-8]\d|9[0-7]$/))
            return line.eodRegionalNodes != '000'
        return true
    }

    // ID: IFN6166; NAME: Mets at DX, Melanoma Skin, EOD Mets (SEER)
    public boolean ifn6166(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        if (line.eodMets == null || line.schemaId == null || line.schemaId != '00470')
            return true
        if (line.metsAtDxBone == null && line.metsAtDxBrain == null && line.metsAtDxDistantLn == null && line.metsAtDxLiver == null && line.metsAtDxLung == null && line.metsAtDxOther == null)
            return true
        
        boolean metsAtDxBoneCondition = line.metsAtDxBone == null || ['0','9'].contains(line.metsAtDxBone)
        boolean metsAtDxBrainCondition = line.metsAtDxBrain == null || ['0','9'].contains(line.metsAtDxBrain)
        boolean metsAtDxDistantLnCondition = line.metsAtDxDistantLn == null || ['0','9'].contains(line.metsAtDxDistantLn)
        boolean metsAtDxLiverCondition = line.metsAtDxLiver == null || ['0','9'].contains(line.metsAtDxLiver)
        boolean metsAtDxLungCondition = line.metsAtDxLung == null || ['0','9'].contains(line.metsAtDxLung)
        boolean metsAtDxOtherCondition = line.metsAtDxOther == null || ['0','9'].contains(line.metsAtDxOther)
        
        if (line.metsAtDxDistantLn == '1' && metsAtDxBoneCondition && metsAtDxBrainCondition && metsAtDxLiverCondition && metsAtDxLungCondition && metsAtDxOtherCondition && line.eodMets != '10')
            return false
        if (line.metsAtDxBone == '1' && metsAtDxBrainCondition && (metsAtDxDistantLnCondition || line.metsAtDxDistantLn == '1') && metsAtDxLiverCondition && metsAtDxLungCondition && metsAtDxOtherCondition && line.eodMets != '20')
            return false
        if (line.metsAtDxOther == '1' && (metsAtDxBoneCondition || line.metsAtDxBone == '1') && metsAtDxBrainCondition && (metsAtDxDistantLnCondition || line.metsAtDxDistantLn == '1') && metsAtDxLiverCondition && metsAtDxLungCondition && !['20','50'].contains(line.eodMets))
            return false
        if (line.metsAtDxLung == '1' && (metsAtDxBoneCondition || line.metsAtDxBone == '1') && metsAtDxBrainCondition && (metsAtDxDistantLnCondition || line.metsAtDxDistantLn == '1') && metsAtDxLiverCondition && metsAtDxOtherCondition && line.eodMets != '30')
            return false
        if (line.metsAtDxOther == '1' && line.metsAtDxLung == '1' && (metsAtDxBoneCondition || line.metsAtDxBone == '1') && metsAtDxBrainCondition && (metsAtDxDistantLnCondition || line.metsAtDxDistantLn == '1') && metsAtDxLiverCondition && !['30','50'].contains(line.eodMets))
            return false
        if ((line.metsAtDxLiver == '1' || line.metsAtDxOther == '2') && metsAtDxBrainCondition && line.eodMets != '50')
            return false
        if (line.metsAtDxBrain == '1' && line.eodMets != '60')
            return false
        if (line.eodMets == '10' && line.metsAtDxDistantLn != '1')
            return false
        if (line.eodMets == '30' && line.metsAtDxLung != '1')
            return false
        return true
    }

    // ID: IFN6167; NAME: EOD Primary Tumor, Breast, Histology ICDO3 (SEER)
    public boolean ifn6167(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.eodPrimaryTumor == null)
            return true
        if (line.typeOfReportingSource == '7' || line.schemaId == null || line.schemaId != '00480' || line.histologicTypeIcdO3 == null)
            return true
        
        if (line.eodPrimaryTumor == '050' && line.histologicTypeIcdO3 != '8540')
            return false
        if (line.eodPrimaryTumor == '070' && line.histologicTypeIcdO3 != '8543')
            return false
        if (line.histologicTypeIcdO3 == '8541' && line.eodPrimaryTumor < '100')
            return false
        return true
    }

    // ID: IFN6171; NAME: LN Laterality, Vulva, Behavior ICDO3 (NAACCR)
    public boolean ifn6171(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null ||
        !['00500', '09500'].contains(line.schemaId) || line.lnLaterality == null || line.lnLaterality == '8' || line.behaviorCodeIcdO3 == null || line.typeOfReportingSource == '7')
            return true
        if (line.behaviorCodeIcdO3 == '2') {
            if (line.dateOfDiagnosisYear < '2023')
                return line.lnLaterality == '0' || line.lnLaterality == '9'
            else
                return line.lnLaterality == '0'
        }
        return true
    }

    // ID: IFN6174; NAME: Number of Positive Pelvic Nodes/Positive Para-aortic Nodes, Corpus Uteri, EOD Regional Nodes (SEER)
    public boolean ifn6174(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
         if(line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || !['00528', '00530','00541','00542'].contains(line.schemaId) || line.eodRegionalNodes == null || line.typeOfReportingSource == '7')
            return true
        if ((line.numberOfPositivePelvicNodes == null || line.numberOfPositivePelvicNodes == 'X8') && (line.numberOfPositiveParaAorticNodes == null || line.numberOfPositiveParaAorticNodes == 'X8'))
            return true
        
        if (line.schemaId == '00530') {
            if (functions.matches(line.numberOfPositivePelvicNodes, /^0[1-9]|[1-9]\d|X[126]$/) && !functions.between(line.eodRegionalNodes, '100', '600'))
                return false
            if (functions.matches(line.numberOfPositiveParaAorticNodes, /^0[1-9]|[1-9]\d|X[126]$/) && !functions.between(line.eodRegionalNodes, '400', '600'))
                return false
        }
        
        if (['00528', '00541','00542'].contains(line.schemaId))
            if ((functions.matches(line.numberOfPositivePelvicNodes, /^0[1-9]|[1-9]\d|X[126]$/) || functions.matches(line.numberOfPositiveParaAorticNodes, /^0[1-9]|[1-9]\d|X[126]$/)) && line.eodRegionalNodes != '300')
                return false
        
        if (line.eodRegionalNodes == '000')
            return functions.matches(line.numberOfPositiveParaAorticNodes, /^00|X[89]$/) && functions.matches(line.numberOfPositivePelvicNodes, /^00|X[89]$/)
        
        return true 
    }

    // ID: IFN6175; NAME: Number of Positive Pelvic Nodes/Positive Para-aortic Nodes, Corpus, Behavior ICDO3 (NAACCR)
    public boolean ifn6175(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if(line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || !['00530','00541','00542', '00528'].contains(line.schemaId) || line.behaviorCodeIcdO3 == null ||
                    line.typeOfReportingSource == '7' || ((line.numberOfPositivePelvicNodes == null || line.numberOfPositivePelvicNodes == 'X8') &&
                    (line.numberOfPositiveParaAorticNodes == null || line.numberOfPositiveParaAorticNodes == 'X8')))
                return true
        if (line.behaviorCodeIcdO3 == '2')
            return functions.matches(line.numberOfPositiveParaAorticNodes, /^00|X[89]$/) && functions.matches(line.numberOfPositivePelvicNodes, /^00|X[89]$/)
        return true
    }

    // ID: IFN6176; NAME: Mets at DX, Ovarian, EOD Mets (SEER)
    public boolean ifn6176(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        if (line.eodMets == null || line.schemaId == null || !['00551','00552','00553'].contains(line.schemaId))
            return true
        if (line.metsAtDxBone == null && line.metsAtDxBrain == null && line.metsAtDxDistantLn == null && line.metsAtDxLiver == null && line.metsAtDxLung == null && line.metsAtDxOther == null)
            return true
        
        boolean metsAtDxBoneCondition = line.metsAtDxBone == null || ['0','9'].contains(line.metsAtDxBone)
        boolean metsAtDxBrainCondition = line.metsAtDxBrain == null || ['0','9'].contains(line.metsAtDxBrain)
        boolean metsAtDxDistantLnCondition = line.metsAtDxDistantLn == null || ['0','9'].contains(line.metsAtDxDistantLn)
        boolean metsAtDxLiverCondition = line.metsAtDxLiver == null || ['0','9'].contains(line.metsAtDxLiver)
        boolean metsAtDxLungCondition = line.metsAtDxLung == null || ['0','9'].contains(line.metsAtDxLung)
        boolean metsAtDxOtherCondition = line.metsAtDxOther == null || ['0','9'].contains(line.metsAtDxOther)
        
        if (line.metsAtDxOther == '1' && metsAtDxBoneCondition && metsAtDxBrainCondition && metsAtDxDistantLnCondition && metsAtDxLiverCondition && metsAtDxLungCondition && !['10','50'].contains(line.eodMets))
            return false
        if (line.metsAtDxDistantLn == '1' && metsAtDxBoneCondition && metsAtDxBrainCondition && metsAtDxLiverCondition && metsAtDxLungCondition && metsAtDxOtherCondition && line.eodMets != '30')
            return false
        if (line.metsAtDxDistantLn == '1' && line.metsAtDxOther== '1' && metsAtDxBoneCondition && metsAtDxBrainCondition && metsAtDxLiverCondition && metsAtDxLungCondition && !['30','50'].contains(line.eodMets))
            return false
        if ((line.metsAtDxBone == '1' || line.metsAtDxBrain == '1' || line.metsAtDxLiver == '1' || line.metsAtDxLung == '1' || line.metsAtDxOther == '2') && line.eodMets != '50')
            return false
        if (line.eodMets == '10' && line.metsAtDxOther != '1')
            return false
        if (line.eodMets == '30' && line.metsAtDxDistantLn!= '1')
            return false
        return true
    }

    // ID: IFN6177; NAME: Mets at DX, Placenta, EOD Mets (SEER)
    public boolean ifn6177(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        if (line.eodMets == null || line.schemaId == null || line.schemaId != '00560')
            return true
        if (line.metsAtDxBone == null && line.metsAtDxBrain == null && line.metsAtDxDistantLn == null && line.metsAtDxLiver == null && line.metsAtDxLung == null && line.metsAtDxOther == null)
            return true
        
        boolean metsAtDxBoneCondition = line.metsAtDxBone == null || ['0','9'].contains(line.metsAtDxBone)
        boolean metsAtDxBrainCondition = line.metsAtDxBrain == null || ['0','9'].contains(line.metsAtDxBrain)
        boolean metsAtDxDistantLnCondition = line.metsAtDxDistantLn == null || ['0','9'].contains(line.metsAtDxDistantLn)
        boolean metsAtDxLiverCondition = line.metsAtDxLiver == null || ['0','9'].contains(line.metsAtDxLiver)
        boolean metsAtDxLungCondition = line.metsAtDxLung == null || ['0','9'].contains(line.metsAtDxLung)
        boolean metsAtDxOtherCondition = line.metsAtDxOther == null || ['0','9'].contains(line.metsAtDxOther)
        
        if (line.metsAtDxLung == '1' && metsAtDxBoneCondition && metsAtDxBrainCondition && metsAtDxDistantLnCondition && metsAtDxLiverCondition && metsAtDxOtherCondition && line.eodMets != '10')
            return false
        if (line.metsAtDxDistantLn == '1' && metsAtDxBoneCondition && metsAtDxBrainCondition && metsAtDxLiverCondition && (metsAtDxLungCondition || line.metsAtDxLung == '1') && metsAtDxOtherCondition && line.eodMets != '30')
            return false
        
        if ((line.metsAtDxBone == '1' || line.metsAtDxBrain == '1' || line.metsAtDxLiver == '1' || line.metsAtDxOther == '1' || line.metsAtDxOther == '2') && line.eodMets != '50')
            return false
        
        if (line.eodMets == '10' && line.metsAtDxLung != '1')
            return false
        if (line.eodMets == '30' && line.metsAtDxDistantLn != '1')
            return false
        return true
    }

    // ID: IFN6178; NAME: Mets at DX, Prostate, EOD Mets (SEER)
    public boolean ifn6178(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        if (line.eodMets == null || line.schemaId == null || line.schemaId != '00580')
            return true
        if (line.metsAtDxBone == null && line.metsAtDxBrain == null && line.metsAtDxDistantLn == null && line.metsAtDxLiver == null && line.metsAtDxLung == null && line.metsAtDxOther == null)
            return true
        
        boolean metsAtDxBoneCondition = line.metsAtDxBone == null || ['0','9'].contains(line.metsAtDxBone)
        boolean metsAtDxBrainCondition = line.metsAtDxBrain == null || ['0','9'].contains(line.metsAtDxBrain)
        boolean metsAtDxDistantLnCondition = line.metsAtDxDistantLn == null || ['0','9'].contains(line.metsAtDxDistantLn)
        boolean metsAtDxLiverCondition = line.metsAtDxLiver == null || ['0','9'].contains(line.metsAtDxLiver)
        boolean metsAtDxLungCondition = line.metsAtDxLung == null || ['0','9'].contains(line.metsAtDxLung)
        boolean metsAtDxOtherCondition = line.metsAtDxOther == null || ['0','9'].contains(line.metsAtDxOther)
        
        if (line.metsAtDxDistantLn == '1' && metsAtDxBoneCondition && metsAtDxBrainCondition && metsAtDxLiverCondition && metsAtDxLungCondition && metsAtDxOtherCondition && line.eodMets != '10')
            return false
        if (line.metsAtDxBone == '1' && metsAtDxBrainCondition && (metsAtDxDistantLnCondition || line.metsAtDxDistantLn == '1') && metsAtDxLiverCondition && metsAtDxLungCondition && metsAtDxOtherCondition && line.eodMets != '30')
            return false
        
        if ((line.metsAtDxBrain == '1' || line.metsAtDxLiver == '1' || line.metsAtDxLung == '1' || line.metsAtDxOther == '1' || line.metsAtDxOther == '2') && line.eodMets != '50')
            return false
        
        if (line.eodMets == '10' && line.metsAtDxDistantLn != '1')
            return false
        if (line.eodMets == '30' && line.metsAtDxBone != '1')
            return false
        return true
    }

    // ID: IFN6179; NAME: EOD Prostate Pathologic Extension, RX Summ--Surg Prim Site 03-2022 (SEER)
    public boolean ifn6179(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.dateOfDiagnosisYear > '2022' || line.schemaId == null ||
            line.schemaId != '00580' || line.prostatePathologicalExtension == null || line.rxSummSurgPrimSite == null)
            return true
        if (line.typeOfReportingSource == '6' || line.typeOfReportingSource == '7')
            return true
        
        Integer dolcYear = functions.asInt(line.dateOfLastContactYear)
        Integer dolcMonth = functions.asInt(line.dateOfLastContactMonth)
        Integer dolcDay = functions.asInt(line.dateOfLastContactDay)
        Integer dxYear = functions.asInt(line.dateOfDiagnosisYear)
        Integer dxMonth = functions.asInt(line.dateOfDiagnosisMonth)
        Integer dxDay = functions.asInt(line.dateOfDiagnosisDay)
        
        if (line.vitalStatus == '0' && (Boolean)((Closure)context.compareDatesWithinMonths).call(dolcYear, dolcMonth, dolcDay, dxYear, dxMonth, dxDay, 5))
            return true
        
        if (line.rxSummSurgPrimSite == '90' || line.rxSummSurgPrimSite == '99')
            return line.prostatePathologicalExtension == '900' || line.prostatePathologicalExtension == '950' || line.prostatePathologicalExtension == '999'
        
        if (functions.matches(line.rxSummSurgPrimSite, /^[5-7]\d|80$/))
            return functions.matches(line.prostatePathologicalExtension, /^[0-7]\d\d|800|999$/)
        
        if (functions.matches(line.rxSummSurgPrimSite, /^[012]\d|30$/))
            return line.prostatePathologicalExtension == '900' || line.prostatePathologicalExtension == '950'
        
        if (line.prostatePathologicalExtension == '900' || line.prostatePathologicalExtension == '950')
            return functions.matches(line.rxSummSurgPrimSite, /^[012]\d|30|90|99$/)
        
        return true
    }

    // ID: IFN6180; NAME: EOD Primary Tumor, Urinary, Histology ICDO3, Behavior ICDO3 (SEER)
    public boolean ifn6180(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.eodPrimaryTumor == null)
            return true
        if (line.typeOfReportingSource == '7' || line.schemaId == null || !['00610','00620','00631','00633'].contains(line.schemaId))
            return true
        if (line.behaviorCodeIcdO3 == null || line.histologicTypeIcdO3 == null)
            return true
        
        return line.eodPrimaryTumor != '000' || (line.behaviorCodeIcdO3 == '2' && ['8130','8131'].contains(line.histologicTypeIcdO3))
    }

    // ID: IFN6181; NAME: EOD Regional Nodes, Bladder, Regional Nodes Positive (SEER)
    public boolean ifn6181(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7' || line.eodRegionalNodes == null)
            return true
        if (line.schemaId == null || line.schemaId != '00620' || line.regionalNodesPositive == null)
            return true
        
        if (line.eodRegionalNodes == '300' && !['00','01','95','97','98','99'].contains(line.regionalNodesPositive))
            return false
        if (functions.matches(line.regionalNodesPositive, /^0[2-9]|[1-8]\d|90$/) && !['400','700'].contains(line.eodRegionalNodes))
            return false
        return true
    }

    // ID: IFN6182; NAME: Behavior Code ICDO3, EOD Tumor/Mets, CNS (SEER)
    public boolean ifn6182(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021'|| line.typeOfReportingSource == '7' || line.behaviorCodeIcdO3 == null)
            return true
        if (line.schemaId == null || !functions.matches(line.schemaId, /^0072[123]|0972[1234]$/))
            return true
        if (line.eodPrimaryTumor == null && line.eodMets == null)
            return true
        
        if (['0','1'].contains(line.behaviorCodeIcdO3) && !(line.eodPrimaryTumor == '050' && line.eodMets == '00'))
            return false
        if (line.eodPrimaryTumor == '050' && !['0','1'].contains(line.behaviorCodeIcdO3))
            return false
        return true
    }

    // ID: IFN6185; NAME: EOD Regional Nodes, Stomach/NET Stomach, Primary Site (SEER)
    public boolean ifn6185(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7' || line.eodRegionalNodes == null)
            return true
        if (line.schemaId == null || !['00170', '00290', '09290'].contains(line.schemaId) || line.primarySite == null)
            return true
        
        if (line.schemaId == '00170' && line.eodRegionalNodes == '400' && line.primarySite != 'C165')
            return false
        if (['00290', '09290'].contains(line.schemaId) && line.eodRegionalNodes == '700' && line.primarySite != 'C165')
            return false
        return true
    }

    // ID: IFN6188; NAME: EOD Primary Tumor, NET Jejunum and Ileum, Tumor Size (SEER)
    public boolean ifn6188(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.dateOfDiagnosisYear > '2023' || line.eodPrimaryTumor == null)
            return true
        if (line.typeOfReportingSource == '7' || line.schemaId == null || line.schemaId != '00310')
            return true
        if (line.tumorSizeClinical == null && line.tumorSizePathologic == null)
            return true
        
        if (line.eodPrimaryTumor == '100') {
            if (!functions.matches(line.tumorSizeClinical, /^00[1-9]|010|99[09]$/) && !functions.matches(line.tumorSizePathologic, /^00[1-9]|010|99[09]$/))
                return false
            if (line.tumorSizeSummary != null && !functions.matches(line.tumorSizeSummary, /^00[1-9]|010|99[09]$/))
                return false
        }
        return true
    }

    // ID: IFN6189; NAME: Mets at DX, NET Pancreas, EOD Mets (SEER)
    public boolean ifn6189(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        if (line.eodMets == null || line.schemaId == null || (line.schemaId != '00340' && line.schemaId != '09340'))
            return true
        if (line.metsAtDxBone == null && line.metsAtDxBrain == null && line.metsAtDxDistantLn == null && line.metsAtDxLiver == null && line.metsAtDxLung == null && line.metsAtDxOther == null)
            return true
        
        boolean metsAtDxBoneCondition = line.metsAtDxBone == null || ['0','9'].contains(line.metsAtDxBone)
        boolean metsAtDxBrainCondition = line.metsAtDxBrain == null || ['0','9'].contains(line.metsAtDxBrain)
        boolean metsAtDxDistantLnCondition = line.metsAtDxDistantLn == null || ['0','9'].contains(line.metsAtDxDistantLn)
        boolean metsAtDxLiverCondition = line.metsAtDxLiver == null || ['0','9'].contains(line.metsAtDxLiver)
        boolean metsAtDxLungCondition = line.metsAtDxLung == null || ['0','9'].contains(line.metsAtDxLung)
        boolean metsAtDxOtherCondition = line.metsAtDxOther == null || ['0','9'].contains(line.metsAtDxOther)
        
        if (line.metsAtDxLiver == '1' && metsAtDxBoneCondition && metsAtDxBrainCondition && metsAtDxDistantLnCondition && metsAtDxLungCondition && metsAtDxOtherCondition && line.eodMets != '10')
            return false
        if (line.metsAtDxDistantLn == '1' && metsAtDxBoneCondition && metsAtDxBrainCondition && metsAtDxLiverCondition && metsAtDxLungCondition && metsAtDxOtherCondition && !['20','40'].contains(line.eodMets))
            return false
        if (['0','9'].contains(line.metsAtDxLiver) && (line.metsAtDxBone == '1' || line.metsAtDxBrain == '1' || line.metsAtDxLung == '1' || ['1','2'].contains(line.metsAtDxOther)) && line.eodMets != '50')
            return false
        if (line.metsAtDxLiver == '1' && (line.metsAtDxBone == '1' || line.metsAtDxBrain == '1' || line.metsAtDxDistantLn == '1' || line.metsAtDxLung == '1' || ['1','2'].contains(line.metsAtDxOther)) && line.eodMets != '60')
            return false
        
        if (['10','60'].contains(line.eodMets) && line.metsAtDxLiver != '1')
            return false
        if (line.eodMets == '20' && line.metsAtDxDistantLn != '1')
            return false
        return true
    }

    // ID: IFN6190; NAME: EOD Primary Tumor, Penis, Morphology ICDO3 (SEER)
    public boolean ifn6190(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.eodPrimaryTumor == null)
            return true
        if (line.typeOfReportingSource == '7' || line.schemaId == null || line.schemaId != '00570')
            return true
        if (line.histologicTypeIcdO3 == null || line.behaviorCodeIcdO3 == null)
            return true
        
        String morphTypebehavIcdO3 = line.histologicTypeIcdO3 + line.behaviorCodeIcdO3
        return line.eodPrimaryTumor != '070' || morphTypebehavIcdO3 == '80513'
    }

    // ID: IFN6191; NAME: EOD Regional Nodes, Penis, Reg Nodes Positive, Scope Nodes (SEER)
    public boolean ifn6191(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7' || line.eodRegionalNodes == null)
            return true
        if (line.schemaId == null || line.schemaId != '00570')
            return true
        
        if (['400','500'].contains(line.eodRegionalNodes)) {
            if (line.regionalNodesPositive != null && !functions.matches(line.regionalNodesPositive, /^0[1-9]|[1-8]\d|9[057]$/))
                return false
            if (line.typeOfReportingSource == '6') {
                if (line.rxSummScopeRegLnSur != '0')
                    return false
            }
            else {
                Integer dolcYear = functions.asInt(line.dateOfLastContactYear)
                Integer dolcMonth = functions.asInt(line.dateOfLastContactMonth)
                Integer dolcDay = functions.asInt(line.dateOfLastContactDay)
                Integer dxYear = functions.asInt(line.dateOfDiagnosisYear)
                Integer dxMonth = functions.asInt(line.dateOfDiagnosisMonth)
                Integer dxDay = functions.asInt(line.dateOfDiagnosisDay)
        
                if (line.vitalStatus == '0' && (Boolean)((Closure)context.compareDatesWithinMonths).call(dolcYear, dolcMonth, dolcDay, dxYear, dxMonth, dxDay, 5)) {
                    if (!functions.matches(line.rxSummScopeRegLnSur, /^[0-7]$/))
                        return false
                }
                else if (!functions.matches(line.rxSummScopeRegLnSur, /^[1-7]$/))
                    return false
            }
        }
        return true
    }

    // ID: IFN6193; NAME: Extranodal Extension Clin/Path (non-Head and Neck), Behavior (NAACCR)
    public boolean ifn6193(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || !['00460', '00570'].contains(line.schemaId)
        || ((line.extranodalExtensionClin == null || line.extranodalExtensionClin == '8') && (line.extranodalExtensionPath == null || line.extranodalExtensionPath == '8'))  ||  line.typeOfReportingSource == '7')
            return true
        
        if (line.behaviorCodeIcdO3 == '2')
            return (line.extranodalExtensionClin == null || ['7', '8','9'].contains(line.extranodalExtensionClin)) && (line.extranodalExtensionPath == null || ['7', '8','9'].contains(line.extranodalExtensionPath))
        return true
    }

    // ID: IFN6195; NAME: EOD Primary Tumor, Testis, RX Summ--Surg Prim Site 03-2022 (SEER)
    public boolean ifn6195(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.dateOfDiagnosisYear > '2022' || line.eodPrimaryTumor == null || line.rxSummSurgPrimSite == null)
            return true
        if (line.typeOfReportingSource == '7' || line.schemaId == null || line.schemaId != '00590')
            return true
        
        return !functions.matches(line.eodPrimaryTumor, /^[1245]00|150$/) || functions.matches(line.rxSummSurgPrimSite, /^[348]0$/)
    }

    // ID: IFN6196; NAME: EOD Regional Nodes, Testis, Reg Nodes Positive, Scope Nodes (SEER)
    public boolean ifn6196(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7' || line.eodRegionalNodes == null)
            return true
        if (line.schemaId == null || line.schemaId != '00590')
            return true
        
        if (['200','400','500'].contains(line.eodRegionalNodes) && line.regionalNodesPositive != null && !functions.matches(line.regionalNodesPositive, /^0[1-9]|[1-8]\d|9[057]$/))
            return false
        if (['200','400','500'].contains(line.eodRegionalNodes) && line.rxSummScopeRegLnSur != null) {
            if (line.typeOfReportingSource == '6') {
                if (line.rxSummScopeRegLnSur != '0')
                    return false
            }
            else {
                Integer dolcYear = functions.asInt(line.dateOfLastContactYear)
                Integer dolcMonth = functions.asInt(line.dateOfLastContactMonth)
                Integer dolcDay = functions.asInt(line.dateOfLastContactDay)
                Integer dxYear = functions.asInt(line.dateOfDiagnosisYear)
                Integer dxMonth = functions.asInt(line.dateOfDiagnosisMonth)
                Integer dxDay = functions.asInt(line.dateOfDiagnosisDay)
        
                if (line.vitalStatus == '0' && (Boolean)((Closure)context.compareDatesWithinMonths).call(dolcYear, dolcMonth, dolcDay, dxYear, dxMonth, dxDay, 5)) {
                    if (!functions.matches(line.rxSummScopeRegLnSur, /^[0-7]$/))
                        return false
                }
                else if (!functions.matches(line.rxSummScopeRegLnSur, /^[1-7]$/))
                    return false
            }
        }
        return true
    }

    // ID: IFN6198; NAME: Mets at DX, Testis, EOD Mets (SEER)
    public boolean ifn6198(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        if (line.eodMets == null || line.schemaId == null || line.schemaId != '00590')
            return true
        if (line.metsAtDxBone == null && line.metsAtDxBrain == null && line.metsAtDxDistantLn == null && line.metsAtDxLiver == null && line.metsAtDxLung == null && line.metsAtDxOther == null)
            return true
        
        boolean metsAtDxBoneCondition = line.metsAtDxBone == null || ['0','9'].contains(line.metsAtDxBone)
        boolean metsAtDxBrainCondition = line.metsAtDxBrain == null || ['0','9'].contains(line.metsAtDxBrain)
        boolean metsAtDxDistantLnCondition = line.metsAtDxDistantLn == null || ['0','9'].contains(line.metsAtDxDistantLn)
        boolean metsAtDxLiverCondition = line.metsAtDxLiver == null || ['0','9'].contains(line.metsAtDxLiver)
        boolean metsAtDxLungCondition = line.metsAtDxLung == null || ['0','9'].contains(line.metsAtDxLung)
        boolean metsAtDxOtherCondition = line.metsAtDxOther == null || ['0','9'].contains(line.metsAtDxOther)
        
        if (line.metsAtDxDistantLn == '1' && metsAtDxBoneCondition && metsAtDxBrainCondition && metsAtDxLiverCondition && metsAtDxLungCondition && metsAtDxOtherCondition && !['10','30'].contains(line.eodMets))
            return false
        if (line.metsAtDxLung == '1' && metsAtDxBoneCondition && metsAtDxBrainCondition && (metsAtDxDistantLnCondition || line.metsAtDxDistantLn == '1') && metsAtDxLiverCondition && metsAtDxOtherCondition && line.eodMets != '50')
            return false
        
        if ((line.metsAtDxBone == '1' || line.metsAtDxBrain == '1' || line.metsAtDxLiver == '1'|| line.metsAtDxOther == '1' || line.metsAtDxOther == '2') && line.eodMets != '60')
            return false
        
        if (['10','30'].contains(line.eodMets) && line.metsAtDxDistantLn != '1')
            return false
        if (line.eodMets == '50' && line.metsAtDxLung != '1')
            return false
        return true
    }

    // ID: IFN6199; NAME: EOD Regional Nodes, Kidney Renal Pelvis/Urethra, Regional Nodes Positive (SEER)
    public boolean ifn6199(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7' || line.eodRegionalNodes == null)
            return true
        if (line.schemaId == null || !['00610','00631','00633'].contains(line.schemaId) || line.regionalNodesPositive == null)
            return true
        
        if (['200','300'].contains(line.eodRegionalNodes) && !functions.matches(line.regionalNodesPositive, /^0[01]|9[5789]$/))
            return false
        if (functions.matches(line.regionalNodesPositive, /^0[2-9]|[1-8]\d|90$/) && line.eodRegionalNodes != '400')
            return false
        return true
    }

    // ID: IFN6200; NAME: Mets at DX, Thymus, EOD Mets (SEER)
    public boolean ifn6200(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        if (line.eodMets == null || line.schemaId == null || line.schemaId != '00350')
            return true
        if (line.metsAtDxBone == null && line.metsAtDxBrain == null && line.metsAtDxDistantLn == null && line.metsAtDxLiver == null && line.metsAtDxLung == null && line.metsAtDxOther == null)
            return true
        
        boolean metsAtDxBoneCondition = line.metsAtDxBone == null || ['0','9'].contains(line.metsAtDxBone)
        boolean metsAtDxBrainCondition = line.metsAtDxBrain == null || ['0','9'].contains(line.metsAtDxBrain)
        boolean metsAtDxDistantLnCondition = line.metsAtDxDistantLn == null || ['0','9'].contains(line.metsAtDxDistantLn)
        boolean metsAtDxLiverCondition = line.metsAtDxLiver == null || ['0','9'].contains(line.metsAtDxLiver)
        boolean metsAtDxLungCondition = line.metsAtDxLung == null || ['0','9'].contains(line.metsAtDxLung)
        boolean metsAtDxOtherCondition = line.metsAtDxOther == null || ['0','9'].contains(line.metsAtDxOther)
        
        if (line.metsAtDxOther == '1' && metsAtDxBoneCondition && metsAtDxBrainCondition && metsAtDxDistantLnCondition && metsAtDxLiverCondition && metsAtDxLungCondition && !['10','50'].contains(line.eodMets))
            return false
        if (line.metsAtDxDistantLn == '1' && metsAtDxBoneCondition && metsAtDxBrainCondition && metsAtDxLiverCondition && metsAtDxLungCondition && metsAtDxOtherCondition && line.eodMets != '30')
            return false
        if (line.metsAtDxDistantLn == '1' && line.metsAtDxOther== '1' && metsAtDxBoneCondition && metsAtDxBrainCondition && metsAtDxLiverCondition && metsAtDxLungCondition && !['30','50'].contains(line.eodMets))
            return false
        if ((line.metsAtDxBone == '1' || line.metsAtDxBrain == '1' || line.metsAtDxLiver == '1' || line.metsAtDxLung == '1' || line.metsAtDxOther == '2') && line.eodMets != '50')
            return false
        if (line.eodMets == '10' && line.metsAtDxOther != '1')
            return false
        if (line.eodMets == '30' && line.metsAtDxDistantLn!= '1')
            return false
        return true
    }

    // ID: IFN6203; NAME: Mets at DX, Bone, EOD Mets (SEER)
    public boolean ifn6203(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        if (line.eodMets == null || line.schemaId == null || !['00381','00382','00383'].contains(line.schemaId))
            return true
        if (line.metsAtDxBone == null && line.metsAtDxBrain == null && line.metsAtDxDistantLn == null && line.metsAtDxLiver == null && line.metsAtDxLung == null && line.metsAtDxOther == null)
            return true
        
        boolean metsAtDxBoneCondition = line.metsAtDxBone == null || ['0','9'].contains(line.metsAtDxBone)
        boolean metsAtDxBrainCondition = line.metsAtDxBrain == null || ['0','9'].contains(line.metsAtDxBrain)
        boolean metsAtDxDistantLnCondition = line.metsAtDxDistantLn == null || ['0','9'].contains(line.metsAtDxDistantLn)
        boolean metsAtDxLiverCondition = line.metsAtDxLiver == null || ['0','9'].contains(line.metsAtDxLiver)
        boolean metsAtDxLungCondition = line.metsAtDxLung == null || ['0','9'].contains(line.metsAtDxLung)
        boolean metsAtDxOtherCondition = line.metsAtDxOther == null || ['0','9'].contains(line.metsAtDxOther)
        
        if (line.metsAtDxLung == '1' && metsAtDxBoneCondition && metsAtDxBrainCondition && metsAtDxDistantLnCondition && metsAtDxLiverCondition && metsAtDxOtherCondition && line.eodMets != '10')
            return false
        if (line.metsAtDxDistantLn == '1' && metsAtDxBoneCondition && metsAtDxBrainCondition && metsAtDxLiverCondition && (metsAtDxLungCondition || line.metsAtDxLung == '1') && metsAtDxOtherCondition && line.eodMets != '30')
            return false
        if ((line.metsAtDxBone == '1' || line.metsAtDxBrain == '1' || line.metsAtDxLiver == '1' || line.metsAtDxOther == '1' || line.metsAtDxOther == '2') && line.eodMets != '50')
            return false
        if (line.eodMets == '10' && line.metsAtDxLung != '1')
            return false
        if (line.eodMets == '30' && line.metsAtDxDistantLn != '1')
            return false
        return true
    }

    // ID: IFN6204; NAME: EOD Primary Tumor, Lung, Tumor Size (SEER)
    public boolean ifn6204(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.dateOfDiagnosisYear > '2023' || line.eodPrimaryTumor == null)
            return true
        if (line.typeOfReportingSource == '7' || line.schemaId == null || line.schemaId != '00360')
            return true
        if (line.tumorSizeClinical == null && line.tumorSizePathologic == null)
            return true
        
        if (line.eodPrimaryTumor == '100') {
            if (!functions.matches(line.tumorSizeClinical, /^00[1-9]|0[12]\d|030|99[09]$/) && !functions.matches(line.tumorSizePathologic, /^00[1-9]|0[12]\d|030|99[09]$/))
                return false
            if (line.tumorSizeSummary != null && !functions.matches(line.tumorSizeSummary, /^00[1-9]|0[12]\d|030|990$/))
                return false
        }
        return true
    }

    // ID: IFN6205; NAME: EOD Primary Tumor/Nodes/Mets, Lung Occult Carcinoma, Summary Stage 2018 (SEER)
    public boolean ifn6205(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.schemaId != '00360' ||
        (line.eodPrimaryTumor == null && line.eodMets == null && line.eodRegionalNodes == null) || line.typeOfReportingSource == '7')
            return true
        if (line.eodPrimaryTumor == '980')
            return line.eodRegionalNodes == '000' && line.eodMets == '00' && (line.summaryStage2018 == null || line.summaryStage2018 == '9')
        return true
    }

    // ID: IFN6207; NAME: Behavior Code ICDO3, EOD Tumor/Nodes/Mets, Prostate (SEER)
    public boolean ifn6207(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.schemaId != '00580' || line.typeOfReportingSource == '7')
            return true
        if (line.behaviorCodeIcdO3 == null || ['0','1'].contains(line.behaviorCodeIcdO3))
            return true
        if (line.eodPrimaryTumor == null && line.prostatePathologicalExtension == null && line.eodRegionalNodes == null && line.eodMets == null)
            return true
        
        if (line.behaviorCodeIcdO3 == '2') {
            boolean condition1 = line.eodPrimaryTumor == '000' && functions.matches(line.prostatePathologicalExtension, /^[089]00|9(50|99)$/)
            boolean condition2 = ['800','999'].contains(line.eodPrimaryTumor) && line.prostatePathologicalExtension == '000'
        
            return (condition1 || condition2) && line.eodRegionalNodes == '000' && line.eodMets == '00'
        }
        else if (line.behaviorCodeIcdO3 == '3')
            return !['000','800'].contains(line.eodPrimaryTumor) ||
                !['000','800','900','950'].contains(line.prostatePathologicalExtension) ||
                line.eodRegionalNodes != '000' ||
                line.eodMets != '00'
        
        return true
    }

    // ID: IFN6208; NAME: Summary Stage 2018, EOD Tumor/Nodes/Mets, Prostate (SEER)
    public boolean ifn6208(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.summaryStage2018 == null || line.typeOfReportingSource == '7')
            return true
        if (line.eodPrimaryTumor == null && line.prostatePathologicalExtension == null && line.eodRegionalNodes == null && line.eodMets == null)
            return true
        if (line.schemaId == null || line.schemaId != '00580')
            return true
        
        if (line.summaryStage2018 == '0') {
            boolean condition1 = line.eodPrimaryTumor == '000' && functions.matches(line.prostatePathologicalExtension, /^[089]00|950|999$/)
            boolean condition2 = ['800', '999'].contains(line.eodPrimaryTumor) && line.prostatePathologicalExtension == '000'
        
            return (condition1 || condition2) && line.eodRegionalNodes == '000' && line.eodMets == '00'
        }
        else if (line.summaryStage2018 == '1' || line.summaryStage2018 == '2') {
            boolean condition1 = !['000', '800', '999'].contains(line.eodPrimaryTumor)
            boolean condition2 = !functions.matches(line.prostatePathologicalExtension, /^[089]00|950|999$/)
        
            return (condition1 || condition2) && ['000', '999'].contains(line.eodRegionalNodes) && line.eodMets == '00'
        }
        else if (line.summaryStage2018 == '3') {
            return !['000', '999'].contains(line.eodRegionalNodes) && line.eodMets == '00'
        }
        else if (line.summaryStage2018 == '4') {
            boolean condition1 = !['000', '800', '999'].contains(line.eodPrimaryTumor)
            boolean condition2 = !functions.matches(line.prostatePathologicalExtension, /^[089]00|950|999$/)
        
            return (condition1 || condition2) && !['000', '999'].contains(line.eodRegionalNodes) && line.eodMets == '00'
        }
        
        if (functions.matches(line.eodMets, /^[1-6]\d|70$/))
            return line.summaryStage2018 == '7'
        
        return true
    }

    // ID: IFN6210; NAME: Response to Neoadjuvant Therapy, Breast, Behavior (NAACCR)
    public boolean ifn6210(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        if (line.behaviorCodeIcdO3 == null || line.responseToNeoadjuvantTherapy == null || line.responseToNeoadjuvantTherapy == '8')
            return true
        if (line.schemaId == null || line.schemaId != '00480')
            return true
        
        if (line.behaviorCodeIcdO3 == '2')
            return line.responseToNeoadjuvantTherapy == '0' || (line.responseToNeoadjuvantTherapy == '9' && line.dateOfDiagnosisYear < '2023')
        
        return true
    }

    // ID: IFN6211; NAME: LN Distant, Gynecologic, Behavior ICDO3 (NAACCR)
    public boolean ifn6211(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if(line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021'|| !['00510','00520','09520'].contains(line.schemaId) || line.behaviorCodeIcdO3 == null ||
                line.lnDistantMediastinalScalene == null || line.lnDistantMediastinalScalene == '8')
            return true
        if (line.behaviorCodeIcdO3 == '2')
            return line.lnDistantMediastinalScalene == '0' || (line.lnDistantMediastinalScalene == '9' && line.dateOfDiagnosisYear < '2023')
        return true
    }

    // ID: IFN6217; NAME: Estrogen Receptor Summary, Percent Positive, Breast (NAACCR)
    public boolean ifn6217(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if(line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.schemaId != '00480')
            return true
        
        if (line.estrogenReceptorSummary == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.estrogenReceptorPercntPosOrRange == null || functions.matches(line.estrogenReceptorPercntPosOrRange, /^XX[789]$/))
            return true
        
        if (line.estrogenReceptorSummary == '0')
            return line.estrogenReceptorPercntPosOrRange == '000'
        else if (line.estrogenReceptorSummary == '1')
            return functions.matches(line.estrogenReceptorPercntPosOrRange, /^00[1-9]|0[1-9]\d|100|R[1-9]\d$/)
        else if (line.estrogenReceptorSummary == '7' || line.estrogenReceptorSummary == '9')
            return line.estrogenReceptorPercntPosOrRange == 'XX7' || line.estrogenReceptorPercntPosOrRange == 'XX9'
        
        return true
    }

    // ID: IFN6219; NAME: Progesterone Receptor Summary, Percent Positive, Breast (NAACCR)
    public boolean ifn6219(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        if (line.progesteroneRecepSummary == null || line.progesteroneRecepPrcntPosOrRange == null || functions.matches(line.progesteroneRecepPrcntPosOrRange, /^XX[789]$/))
            return true
        if (line.schemaId == null || line.schemaId != '00480')
            return true
        
        if (line.progesteroneRecepSummary == '0')
            return line.progesteroneRecepPrcntPosOrRange == '000'
        else if (line.progesteroneRecepSummary == '1')
            return functions.matches(line.progesteroneRecepPrcntPosOrRange, /^00[1-9]|0[1-9]\d|100|R[1-9]\d$/)
        else if (line.progesteroneRecepSummary == '7' || line.progesteroneRecepSummary == '9')
            return line.progesteroneRecepPrcntPosOrRange == 'XX7' || line.progesteroneRecepPrcntPosOrRange == 'XX9'
        
        return true
    }

    // ID: IFN6223; NAME: NCCN International Prognostic Index (IPI), Lymphoma, Histology (NAACCR)
    public boolean ifn6223(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
         if(line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.schemaId != '00790' || line.histologicTypeIcdO3 == null ||
                    line.typeOfReportingSource == '7' || line.nccnInternationalPrognosticIndex == null || line.nccnInternationalPrognosticIndex == 'X8')
                return true
        if (functions.matches(line.histologicTypeIcdO3, /^96[56]\d$/))
            return line.nccnInternationalPrognosticIndex == 'X9'
        return true
                    
    }

    // ID: IFN6225; NAME: EOD Regional Nodes, Gynecologic, Reg Nodes Positive, Scope Reg LN (SEER)
    public boolean ifn6225(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7' || line.eodRegionalNodes == null)
            return true
        
        if (line.schemaId == null || !functions.matches(line.schemaId, /^005([0-3]0|28|4[12]|5[123])|095(00|20)$/))
            return true
        if (line.eodRegionalNodes == '040' || line.eodRegionalNodes == '050') {
            if (!['00','99'].contains(line.regionalNodesPositive))
                return false
            if (line.typeOfReportingSource == '6')
                return line.rxSummScopeRegLnSur == '0'
            else {
                Integer dolcYear = functions.asInt(line.dateOfLastContactYear)
                Integer dolcMonth = functions.asInt(line.dateOfLastContactMonth)
                Integer dolcDay = functions.asInt(line.dateOfLastContactDay)
                Integer dxYear = functions.asInt(line.dateOfDiagnosisYear)
                Integer dxMonth = functions.asInt(line.dateOfDiagnosisMonth)
                Integer dxDay = functions.asInt(line.dateOfDiagnosisDay)
        
                if (line.vitalStatus == '0' && (Boolean)((Closure)context.compareDatesWithinMonths).call(dolcYear, dolcMonth, dolcDay, dxYear, dxMonth, dxDay, 5))
                    return functions.matches(line.rxSummScopeRegLnSur, /^[0-7]$/)
                else
                    return functions.matches(line.rxSummScopeRegLnSur, /^[1-7]$/)
            }
        }
        return true
    }

    // ID: IFN6226; NAME: EOD Primary Tumor, Corpus Carcinoma, Morphology ICDO3 (SEER)
    public boolean ifn6226(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.eodPrimaryTumor == null)
            return true
        if (line.typeOfReportingSource == '7' || line.schemaId == null || line.schemaId != '00530')
            return true
        if (line.histologicTypeIcdO3 == null || line.behaviorCodeIcdO3 == null)
            return true
        
        String morphTypebehavIcdO3 = line.histologicTypeIcdO3 + line.behaviorCodeIcdO3
        if (morphTypebehavIcdO3 == '83802' && !['000', '050'].contains(line.eodPrimaryTumor))
            return false
        if (morphTypebehavIcdO3 == '84412' && line.eodPrimaryTumor != '050')
            return false
        if (line.eodPrimaryTumor == '050' && !['83802', '84412'].contains(morphTypebehavIcdO3))
            return false
        return true
    }

    // ID: IFN6227; NAME: EOD Primary Tumor, Ovary, Laterality (SEER)
    public boolean ifn6227(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.eodPrimaryTumor == null || line.laterality == null)
            return true
        if (line.typeOfReportingSource == '7' || line.schemaId == null || line.schemaId != '00551')
            return true
        
        return line.laterality != '4' || line.eodPrimaryTumor != '100'
    }

    // ID: IFN6229; NAME: Mets at DX-Distant LN, Kaposi Sarcoma, EOD Regional Nodes (SEER)
    public boolean ifn6229(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId != '00458' || line.metsAtDxDistantLn == null)
                return true
        
        if (line.eodRegionalNodes == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.metsAtDxDistantLn == '1' && line.eodRegionalNodes != '700')
            return false
        
        if (line.eodRegionalNodes == '700' && line.metsAtDxDistantLn != '1')
            return false
        
        return true
    }

    // ID: IFN6231; NAME: ALK Rearrangement, Date DX (NAACCR)
    public boolean ifn6231(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
         if (line.dateOfDiagnosisYear == null)
                        return true
        
        if (line.dateOfDiagnosisYear < '2021')
             return line.alkRearrangement == null
        
        return functions.matches(line.alkRearrangement, /^[0124789]$/) || line.alkRearrangement == null
                    
    }

    // ID: IFN6232; NAME: ALK Rearrangement, Schema ID, Required (NAACCR)
    public boolean ifn6232(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
         if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.typeOfReportingSource == '7')
                        return true
        if (line.registryId == '0000001565' && ['2021','2022'].contains(line.dateOfDiagnosisYear))
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear == '2021')
            return true
        
        if (line.schemaId == '00360')
            return line.alkRearrangement != '8' && line.alkRearrangement != null
        
        return true
    }

    // ID: IFN6233; NAME: EGFR Mutational Analysis, Date DX (NAACCR)
    public boolean ifn6233(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
         if (line.dateOfDiagnosisYear == null)
                return true
        if (line.dateOfDiagnosisYear < '2021')
            return line.egfrMutationalAnalysis == null
        
        else
            return line.egfrMutationalAnalysis == null || functions.matches(line.egfrMutationalAnalysis, /^[0124789]$/)
                    
    }

    // ID: IFN6234; NAME: EGFR Mutational Analysis, Schema ID, Required (NAACCR)
    public boolean ifn6234(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.typeOfReportingSource == '7')
                return true
        if (line.registryId == '0000001565' && ['2021','2022'].contains(line.dateOfDiagnosisYear))
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear == '2021')
            return true
        
        if (line.schemaId == '00360')
            return line.egfrMutationalAnalysis != '8' && line.egfrMutationalAnalysis != null
        
        return true
                    
    }

    // ID: IFN6235; NAME: BRAF Mutational Analysis, Date DX (NAACCR)
    public boolean ifn6235(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        if (line.dateOfDiagnosisYear < '2021')
            return line.brafMutationalAnalysis == null
        
        return line.brafMutationalAnalysis == null || functions.matches(line.brafMutationalAnalysis, /^[0124789]$/)
    }

    // ID: IFN6236; NAME: BRAF Mutational Analysis, Schema ID, Required (NAACCR)
    public boolean ifn6236(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if ((line.registryId == '0000001565' && (line.dateOfDiagnosisYear == '2021' || line.dateOfDiagnosisYear == '2022'))
            || (line.registryId == '0000001566' && line.dateOfDiagnosisYear == '2021'))
            return true
        
        if (line.schemaId == '00200')
            return line.brafMutationalAnalysis != null && line.brafMutationalAnalysis != '8'
        return true
    }

    // ID: IFN6237; NAME: NRAS Mutational Analysis, Date DX (NAACCR)
    public boolean ifn6237(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        if (line.dateOfDiagnosisYear < '2021')
            return line.nrasMutationalAnalysis == null
        return line.nrasMutationalAnalysis == null || functions.matches(line.nrasMutationalAnalysis, /^[0124789]$/)
    }

    // ID: IFN6238; NAME: NRAS Mutational Analysis, Schema ID, Required (NAACCR)
    public boolean ifn6238(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if ((line.registryId == '0000001565' && (line.dateOfDiagnosisYear == '2021' || line.dateOfDiagnosisYear == '2022'))
            || (line.registryId == '0000001566' && line.dateOfDiagnosisYear == '2021'))
            return true
        
        if (line.schemaId == '00200')
            return line.nrasMutationalAnalysis != null && line.nrasMutationalAnalysis != '8'
        return true
    }

    // ID: IFN6239; NAME: CA 19-9 PreTX Lab Value, Date DX (NAACCR)
    public boolean ifn6239(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear ==  null || line.ca199PretxLabValue == null)
        return true
        if (line.dateOfDiagnosisYear <  '2021')
            return line.ca199PretxLabValue == null
        String ca199PretxLabValue = (String)line.ca199PretxLabValue;
        if (ca199PretxLabValue.length() < 3)
            return false
        String decimal = ca199PretxLabValue.substring(ca199PretxLabValue.length() - 2)
        if (decimal.charAt(0) != '.')
            return false
        String digits = ca199PretxLabValue.substring(0, ca199PretxLabValue.length() - 2) + ca199PretxLabValue.substring(ca199PretxLabValue.length() - 1)
        return functions.matches(digits, /^(\d\d)|(\d\d\d)|(\d\d\d\d)|(\d\d\d\d\d)|XXXX(1|2|3|7|8|9)$/)
    }

    // ID: IFN6240; NAME: CA 19-9 PreTX Lab Value, Schema ID, Required (NAACCR)
    public boolean ifn6240(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
        return true
        if (line.registryId == '0000001565' && ['2021','2022'].contains(line.dateOfDiagnosisYear))
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear == '2021')
            return true
        
        if (line.schemaId == '00280')
            return line.ca199PretxLabValue != null && line.ca199PretxLabValue != 'XXXX.8'
            
        return true
    }

    // ID: IFN6244; NAME: SSDI for Breast/Digestive, Blank for Other Schemas (NAACCR)
    public boolean ifn6244(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if(line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || ['00480','00161','00169','00170'].contains(line.schemaId))
                    return true
        return line.her2OverallSummary == null
    }

    // ID: IFN6245; NAME: SSDI for Breast/NET, Blank for Other Schemas (NAACCR)
    public boolean ifn6245(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if(line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null ||
                    ['00290','00301','00302','00310','00320','00330','00340','00480','09290','09301','09302','09310','09320','09330','09340'].contains(line.schemaId))
                    return true
        return line.ki67 == null
    }

    // ID: IFN6246; NAME: EOD Primary Tumor, Testis, Morphology, Tumor Size (SEER)
    public boolean ifn6246(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.dateOfDiagnosisYear > '2023' || line.eodPrimaryTumor == null)
            return true
        if (line.typeOfReportingSource == '7' || line.schemaId == null || line.schemaId != '00590')
            return true
        if (line.tumorSizeClinical == null && line.tumorSizePathologic == null)
            return true
        if (line.histologicTypeIcdO3 == null || line.behaviorCodeIcdO3 == null)
            return true
        
        String morphTypebehavIcdO3 = line.histologicTypeIcdO3 + line.behaviorCodeIcdO3
        if (line.eodPrimaryTumor == '100') {
            if (morphTypebehavIcdO3 != '90613')
                return false
            if (!functions.matches(line.tumorSizeClinical, /^00[1-9]|0[12]\d|99[09]$/) && !functions.matches(line.tumorSizePathologic, /^00[1-9]|0[12]\d|99[09]$/))
                return false
            if (line.tumorSizeSummary != null && !functions.matches(line.tumorSizeSummary, /^00[1-9]|0[12]\d|99[09]$/))
                return false
        }
        else if (line.eodPrimaryTumor == '150') {
            if (morphTypebehavIcdO3 != '90613')
                return false
            if (!functions.matches(line.tumorSizeClinical, /^0[3-9]\d|[1-8]\d\d|9[0-8]\d|999$/) && !functions.matches(line.tumorSizePathologic, /^0[3-9]\d|[1-8]\d\d|9[0-8]\d|999$/))
                return false
            if (line.tumorSizeSummary != null && !functions.matches(line.tumorSizeSummary, /^0[3-9]\d|[1-8]\d\d|9[0-8]\d|999$/))
                return false
        }
        return true
    }

    // ID: IFN6253; NAME: EOD Primary Tumor, Lymphoma (SEER)
    public boolean ifn6253(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.eodPrimaryTumor == null)
            return true
        if (line.typeOfReportingSource == '7' || line.schemaId == null || !['00790','00795'].contains(line.schemaId))
            return true
        
        if (line.eodPrimaryTumor == '100' && !functions.matches(line.primarySite, /^C(0(24|9\d)|111|142|379|422|77[0-59])$/))
            return false
        if (line.eodPrimaryTumor == '200' && functions.matches(line.primarySite, /^C(0(24|9\d)|111|142|379|422|77[0-589])$/))
            return false
        
        if (line.primarySite == 'C778' && line.eodPrimaryTumor < '300')
            return false
        if (line.primarySite == 'C421' && line.eodPrimaryTumor != '750' && line.eodPrimaryTumor != '800')
            return false
        if (line.primarySite == 'C220' && line.eodPrimaryTumor != '800')
            return false
        
        return true
    }

    // ID: IFN6255; NAME: Summary Stage 2018, Derived Summary Stage 2018 (SEER)
    public boolean ifn6255(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.summaryStage2018 == null || line.derivedSummaryStage2018 == null)
            return true
        
        boolean summaryStageLiverCase = false;
        if(line.schemaId == '00220' && ['150','200'].contains(line.eodPrimaryTumor))
            summaryStageLiverCase = (line.summaryStage2018 == '1' && line.derivedSummaryStage2018 == '2') || (line.summaryStage2018 == '3' && line.derivedSummaryStage2018 == '4')
        
        return line.summaryStage2018 == line.derivedSummaryStage2018 || summaryStageLiverCase
    }

    // ID: IFN6256; NAME: Grade, Brain, CNS, Behavior (NAACCR)
    public boolean ifn6256(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.behaviorCodeIcdO3 == null)
            return true
        if (line.gradeClinical == null && line.gradePathological == null)
            return true
        if (!functions.matches(line.schemaId, /^0072[123]|0972[1-4]$/) || line.typeOfReportingSource == '7')
            return true
        
        if (line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') {
            if (!['1','2','3','L','9'].contains(line.gradePathological))
                return false
            if (!['1','2','3','L','9'].contains(line.gradeClinical))
                return false
            return true
        }
        return true
    }

    // ID: IFN6257; NAME: Brain Molecular Markers, Derived SS 2018 (SEER)
    public boolean ifn6257(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.derivedSummaryStage2018 == null || line.typeOfReportingSource  == '7')
            return true
        if (!['00721','00722','09721','09722','09724'].contains(line.schemaId) || line.brainMolecularMarkers == null || line.brainMolecularMarkers == '88')
            return true
        
        if (line.brainMolecularMarkers == '86' && line.derivedSummaryStage2018 != '8')
            return false
        if (line.derivedSummaryStage2018 == '8' && line.brainMolecularMarkers != '86' && line.brainMolecularMarkers != '99')
            return false
        return true
    }

    // ID: IFN6258; NAME: Breslow Tumor Thickness, Melanoma, Derived SS 2018 (SEER)
    public boolean ifn6258(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.derivedSummaryStage2018 == null || line.typeOfReportingSource  == '7')
            return true
        if (line.schemaId != '00470' || line.breslowTumorThickness == null || line.breslowTumorThickness == 'XX.8')
            return true
        
        return (line.derivedSummaryStage2018 != '0' || line.breslowTumorThickness == 'XX.9')
    }

    // ID: IFN6259; NAME: Extranodal Extension Head and Neck Clin/Path, Derived SS 2018 (SEER)
    public boolean ifn6259(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || !((List)context.IFN_6259_SchemaId_List).contains(line.schemaId)
        || ((line.extranodalExtensionHeadNeckClin == null || line.extranodalExtensionHeadNeckClin == '8') && (line.extranodalExtensionHeadNeckPath == null || line.extranodalExtensionHeadNeckPath == 'X.8'))
        || line.derivedSummaryStage2018 == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.extranodalExtensionHeadNeckClin == '7' && line.extranodalExtensionHeadNeckPath == 'X.7')
            return !['3', '4'].contains(line.derivedSummaryStage2018)
        
        if (['0', '1', '2', '4'].contains(line.extranodalExtensionHeadNeckClin) && functions.matches(line.extranodalExtensionHeadNeckPath,  /^\d\.\d|X\.[1-4]$/))
            return !['0', '1', '2'].contains(line.derivedSummaryStage2018)
        return true
    }

    // ID: IFN6261; NAME: Extranodal Extension Clin/Path, Merkel Cell, Derived SS 2018 (SEER)
    public boolean ifn6261(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId != '00460' || line.derivedSummaryStage2018 == null || line.typeOfReportingSource == '7')
            return true
        
        String clin = line.extranodalExtensionClin
        String path = line.extranodalExtensionPath
        if ((clin == null || clin == '8') && (path == null || path == '8'))
            return true
        
        return (!['0', '1', '2', '4'].contains(clin) || !['0', '1'].contains(path) || !['0', '1', '2'].contains(line.derivedSummaryStage2018))
    }

    // ID: IFN6263; NAME: Extranodal Extension Clin/Path, Penis, Derived SS 2018 (SEER)
    public boolean ifn6263(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId != '00570' || ((line.extranodalExtensionClin == null || line.extranodalExtensionClin == '8')
         && (line.extranodalExtensionPath == null || line.extranodalExtensionPath == '8')) || line.derivedSummaryStage2018 == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.extranodalExtensionClin == '7' && line.extranodalExtensionPath == '7' )
            return line.derivedSummaryStage2018 != '3' && line.derivedSummaryStage2018 != '4'
        
        if (['0', '1', '2', '4'].contains(line.extranodalExtensionClin) && ['0', '1'].contains(line.extranodalExtensionPath))
            return !['0', '1', '2'].contains(line.derivedSummaryStage2018)
        return true
    }

    // ID: IFN6264; NAME: FIGO Stage, Derived SS 2018 (SEER)
    public boolean ifn6264(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.figoStage == null || line.figoStage == '98' || line.typeOfReportingSource  == '7')
            return true
        
        if (!functions.matches(line.schemaId, /^(00(5[01236]0|55[123]|528)|095[02]0)$/) || line.derivedSummaryStage2018 == null)
            return true
        
        if (line.figoStage == '97' && line.derivedSummaryStage2018 != '0')
            return false
        
        if (line.derivedSummaryStage2018 == '0' && !['00530', '00551', '00553'].contains(line.schemaId) && line.figoStage != '97')
            return false
        
        return true
    }

    // ID: IFN6265; NAME: Invasion Beyond Capsule, Kidney, Derived SS 2018 (SEER)
    public boolean ifn6265(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.derivedSummaryStage2018 == null || line.typeOfReportingSource  == '7')
            return true
        if (line.schemaId != '00600' || line.invasionBeyondCapsule == null || line.invasionBeyondCapsule == '8')
            return true
        
        return !functions.matches(line.invasionBeyondCapsule, /^[13-5]$/) || !['0','1','3'].contains(line.derivedSummaryStage2018)
    }

    // ID: IFN6266; NAME: Ipsilateral Adrenal Gland Involvement, Kidney, Derived SS 2018 (SEER)
    public boolean ifn6266(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.derivedSummaryStage2018 == null || line.typeOfReportingSource  == '7')
            return true
        if (line.schemaId != '00600' || line.ipsilateralAdrenalGlandInvolve == null || line.ipsilateralAdrenalGlandInvolve == '8')
            return true
        
        if (line.ipsilateralAdrenalGlandInvolve == '1' && ['0','1','3'].contains(line.derivedSummaryStage2018))
            return false
        if (['2','3'].contains(line.ipsilateralAdrenalGlandInvolve) && line.derivedSummaryStage2018 != '7')
            return false
        return true
    }

    // ID: IFN6268; NAME: LN Distant, Gynecologic, Derived SS 2018 (SEER)
    public boolean ifn6268(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if(line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021'|| !['00510','00520','09520'].contains(line.schemaId))
            return true
        if (line.lnDistantMediastinalScalene == null || line.lnDistantMediastinalScalene == '8' || line.derivedSummaryStage2018 == null || line.typeOfReportingSource == '7')
            return true
        
        if (functions.matches(line.lnDistantMediastinalScalene, /^[123]$/))
            return line.derivedSummaryStage2018 == '7'
        return true
    }

    // ID: IFN6269; NAME: LN Head and Neck Levels, Melanoma Head/Neck, Derived SS 2018 (SEER)
    public boolean ifn6269(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.derivedSummaryStage2018 == null || line.schemaId != '00140' || line.typeOfReportingSource  == '7')
            return true
        String ln13 = line.lnHeadAndNeckLevels1To3
        String ln45 = line.lnHeadAndNeckLevels4To5
        String ln67 = line.lnHeadAndNeckLevels6To7
        String lnOther = line.lnHeadAndNeckOther
        if ((ln13 == null || ln13 == '8') && (ln45 == null || ln45 == '8') && (ln67 == null || ln67 == '8') && (lnOther == null || lnOther == '8'))
            return true
        
        Boolean ln13Condition = functions.matches(ln13, /^[1-7]$/)
        Boolean ln45Condition = functions.matches(ln45, /^[123]$/)
        Boolean ln67Condition = functions.matches(ln67, /^[123]$/)
        Boolean lnOtherCondition = functions.matches(lnOther, /^[1-7]$/)
        
        return !(ln13Condition || ln45Condition || ln67Condition || lnOtherCondition) || !['0','1','2'].contains(line.derivedSummaryStage2018)
    }

    // ID: IFN6270; NAME: LN Isolated Tumor Cells (ITC), Merkel Cell, Derived SS 2018 (SEER)
    public boolean ifn6270(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if(line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.schemaId != '00460'
                    || line.lnIsolatedTumorCells == null || line.lnIsolatedTumorCells == '8' || line.derivedSummaryStage2018 == null || line.typeOfReportingSource  == '7')
            return true
        if (line.lnIsolatedTumorCells == '1')
            return !['0', '1', '2'].contains(line.derivedSummaryStage2018)
        return true
    }

    // ID: IFN6271; NAME: LN Laterality, Vulva, Derived SS 2018 (SEER)
    public boolean ifn6271(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null ||
        !['00500', '09500'].contains(line.schemaId) || line.lnLaterality == null || line.lnLaterality == '8' || line.derivedSummaryStage2018 == null || line.typeOfReportingSource  == '7')
            return true
        if (['1', '2', '3'].contains(line.lnLaterality))
            return !['0', '1', '2'].contains(line.derivedSummaryStage2018)
        return true
    }

    // ID: IFN6272; NAME: LN Positive Axillary Level I-II, Breast, Derived SS 2018 (SEER)
    public boolean ifn6272(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.derivedSummaryStage2018 == null || line.typeOfReportingSource  == '7')
            return true
        if (line.schemaId != '00480' || line.lnPositiveAxillaryLevel1To2 == null || line.lnPositiveAxillaryLevel1To2 == 'X8')
            return true
        
        return !functions.matches(line.lnPositiveAxillaryLevel1To2, /^0[1-9]|[1-9]\d|X[156]$/) || !['0','1','2'].contains(line.derivedSummaryStage2018)
    }

    // ID: IFN6273; NAME: LN Size, Head/Neck, Derived SS 2018 (SEER)
    public boolean ifn6273(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear < '2021' || line.dateOfDiagnosisYear == null || line.lnSize == null || line.lnSize == 'XX.8'
                    || line.derivedSummaryStage2018 == null || line.schemaId == null || !functions.matches(line.schemaId, /^(000(60|7[1234567]|80|90))|(001(00|1[12]|2[12]|3[0123]|40|50))$/) || line.typeOfReportingSource  == '7')
            return true
        if (line.lnSize != '0.0' && line.lnSize != 'XX.9')
            return line.derivedSummaryStage2018 != '0' && line.derivedSummaryStage2018 != '1' && line.derivedSummaryStage2018 != '2'
        return true
    }

    // ID: IFN6275; NAME: Lymphovascular Invasion, Penis, Derived SS 2018 (SEER)
    public boolean ifn6275(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' ||  line.schemaId != '00570' || line.lymphVascularInvasion == null
        || line.lymphVascularInvasion == '8' || line.derivedSummaryStage2018 == null || line.typeOfReportingSource == '7')
            return true
        if (functions.matches(line.lymphVascularInvasion, /^[1-4]$/))
            return line.derivedSummaryStage2018 != '0'
        return true
    }

    // ID: IFN6276; NAME: Lymphovascular Invasion, Testis, Derived SS 2018 (SEER)
    public boolean ifn6276(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' ||  line.schemaId != '00590' || line.lymphVascularInvasion == null
        || line.lymphVascularInvasion == '8' || line.derivedSummaryStage2018 == null || line.typeOfReportingSource == '7')
        return true
        if (functions.matches(line.lymphVascularInvasion, /^[1-4]$/))
            return line.derivedSummaryStage2018 != '0'
        return true
    }

    // ID: IFN6277; NAME: Major Vein Involvement, Kidney, Derived SS 2018 (SEER)
    public boolean ifn6277(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.derivedSummaryStage2018 == null || line.typeOfReportingSource  == '7')
            return true
        if (line.schemaId != '00600' || line.majorVeinInvolvement == null || line.majorVeinInvolvement == '8')
            return true
        
        return !['1','2','3','4'].contains(line.majorVeinInvolvement) || !['0','1','3'].contains(line.derivedSummaryStage2018)
    }

    // ID: IFN6278; NAME: Peritoneal Cytology, Gynecologic, Derived SS 2018 (SEER)
    public boolean ifn6278(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.derivedSummaryStage2018 == null || line.typeOfReportingSource  == '7')
            return true
        if (!['00530','00541','00542', '00528'].contains(line.schemaId) || line.peritonealCytology == null || line.peritonealCytology == '8')
            return true
        
        return line.peritonealCytology != '2' || !['0','1','3'].contains(line.derivedSummaryStage2018)
    }

    // ID: IFN6279; NAME: Separate Tumor Nodules, Lung, Derived SS 2018 (SEER)
    public boolean ifn6279(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.derivedSummaryStage2018 == null || line.typeOfReportingSource  == '7')
            return true
        if (line.schemaId != '00360' || line.separateTumorNodules == null || line.separateTumorNodules == '8')
            return true
        
        if (['1','4'].contains(line.separateTumorNodules) && ['0','1','3'].contains(line.derivedSummaryStage2018))
            return false
        if (['2','3'].contains(line.separateTumorNodules) && line.derivedSummaryStage2018 != '7')
            return false
        return true
    }

    // ID: IFN6280; NAME: Derived Summary Stage 2018, Regional Nodes Positive (SEER)
    public boolean ifn6280(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.derivedSummaryStage2018 == null || line.typeOfReportingSource  == '7')
            return true
        
        if (line.schemaId == null || line.regionalNodesPositive == null)
            return true
        
        if (functions.matches(line.regionalNodesPositive, /^0[1-9]|[1-8]\d|9[0-7]$/))
            return !['0','1','2'].contains(line.derivedSummaryStage2018)
        
        return true
    }

    // ID: IFN6281; NAME: Tumor Deposits, Colorectal, Derived SS 2018 (SEER)
    public boolean ifn6281(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.schemaId != '00200' || line.derivedSummaryStage2018 == null ||
                    line.tumorDeposits == null || line.tumorDeposits == 'X8' || line.typeOfReportingSource  == '7')
                return true
        
        if (functions.matches(line.tumorDeposits, /^0[1-9]|[1-9][0-9]$/) || line.tumorDeposits == 'X1' || line.tumorDeposits == 'X2')
            return !functions.matches(line.derivedSummaryStage2018, /^[012]$/)
        
        return true
    }

    // ID: IFN6282; NAME: Visceral and Parietal Pleural Invasion, Lung, Derived SS 2018 (SEER)
    public boolean ifn6282(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.schemaId != '00360' ||
                    line.derivedSummaryStage2018 == null || line.visceralParietalPleuralInvasion == null || line.visceralParietalPleuralInvasion == '8' || line.typeOfReportingSource  == '7')
                return true
        
        if (functions.matches(line.visceralParietalPleuralInvasion, /^[4-6]$/))
            return !functions.matches(line.derivedSummaryStage2018, /^[013]$/)
        
        return true
    }

    // ID: IFN6283; NAME: Pleural Effusion, Pleural Mesothelioma, EOD Mets (SEER)
    public boolean ifn6283(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear < '2021' || line.dateOfDiagnosisYear == null || line.schemaId == null || line.schemaId != '00370'
                    || line.pleuralEffusion == null || line.pleuralEffusion == '8' || line.eodMets == null || line.typeOfReportingSource == '7')
            return true
        if (line.pleuralEffusion == '2')
            return line.eodMets == '70' || line.eodMets == '05'
        return true
            
    }

    // ID: IFN6286; NAME: Extranodal Extension Head and Neck Path, Head/Neck, Derived SS 2018 (SEER)
    public boolean ifn6286(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || !((List)context.IFN_6286_SchemaId_List).contains(line.schemaId)
                    || line.extranodalExtensionHeadNeckPath == null || line.extranodalExtensionHeadNeckPath == 'X.8' || line.derivedSummaryStage2018 == null || line.typeOfReportingSource  == '7')
            return true
        if (functions.matches(line.extranodalExtensionHeadNeckPath, /^\d\.\d|X\.[1-4]$/))
            return !['0', '1', '2'].contains(line.derivedSummaryStage2018)
        return true
    }

    // ID: IFN6287; NAME: EOD Regional Nodes, Head/Neck, Reg Nodes Positive, Scope Nodes (SEER)
    public boolean ifn6287(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7' || line.eodRegionalNodes == null)
            return true
        if (line.schemaId == null || !functions.matches(line.schemaId, /^00(0(60|7[1-7]|80)|1(00|[12][12]|3[0-3]|50))$/))
            return true
        
        if (functions.matches(line.eodRegionalNodes, /^150|[567]00$/)) {
            if (['00','98','99'].contains(line.regionalNodesPositive))
                return false
            if (line.typeOfReportingSource == '6')
                return line.rxSummScopeRegLnSur == '0'
            else {
                Integer dolcYear = functions.asInt(line.dateOfLastContactYear)
                Integer dolcMonth = functions.asInt(line.dateOfLastContactMonth)
                Integer dolcDay = functions.asInt(line.dateOfLastContactDay)
                Integer dxYear = functions.asInt(line.dateOfDiagnosisYear)
                Integer dxMonth = functions.asInt(line.dateOfDiagnosisMonth)
                Integer dxDay = functions.asInt(line.dateOfDiagnosisDay)
        
                if (line.vitalStatus == '0' && (Boolean)((Closure)context.compareDatesWithinMonths).call(dolcYear, dolcMonth, dolcDay, dxYear, dxMonth, dxDay, 5))
                    return functions.matches(line.rxSummScopeRegLnSur, /^[0-7]$/)
                else
                    return functions.matches(line.rxSummScopeRegLnSur, /^[1-7]$/)
            }
        }
        return true
    }

    // ID: IFN6288; NAME: LN Size, Head/Neck, Behavior (NAACCR)
    public boolean ifn6288(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear < '2021' || line.dateOfDiagnosisYear == null || line.lnSize == null || line.lnSize == 'XX.8' || line.behaviorCodeIcdO3 == null
                    || line.typeOfReportingSource == null || line.schemaId == null || !functions.matches(line.schemaId, /^(000(60|7[1234567]|80|90))|(001(00|1[12]|2[12]|3[0123]|40|50))$/))
            return true
        if (line.behaviorCodeIcdO3 == '2')
            return line.lnSize == '0.0' || (line.lnSize == 'XX.9' && line.dateOfDiagnosisYear < '2023')
        return true
    }

    // ID: IFN6289; NAME: EOD Regional Nodes, Breast, Sentinel Nodes Positive, Scope Nodes (SEER)
    public boolean ifn6289(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7' || line.eodRegionalNodes == null)
            return true
        if (line.schemaId == null || line.schemaId != '00480' || line.sentinelLymphNodesPositive == null)
            return true
        
        if (functions.matches(line.eodRegionalNodes, /^0[0357]0$/))
            return ['00','98','99'].contains(line.sentinelLymphNodesPositive)
        else if (['250','300'].contains(line.eodRegionalNodes)) {
            if (['00','98','99'].contains(line.sentinelLymphNodesPositive))
                return false
            if (line.rxSummScopeRegLnSur != null && !['2','6','7'].contains(line.rxSummScopeRegLnSur))
                return false
        }
        return true
    }

    // ID: IFN6290; NAME: Mets at DX, Melanoma Iris/Choroid, EOD Mets (SEER)
    public boolean ifn6290(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        if (line.eodMets == null || line.schemaId == null || !['00671','00672'].contains(line.schemaId))
            return true
        if (line.metsAtDxBone == null && line.metsAtDxBrain == null && line.metsAtDxDistantLn == null && line.metsAtDxLiver == null && line.metsAtDxLung == null && line.metsAtDxOther == null)
            return true
        
        if ((line.metsAtDxBone == '1' || line.metsAtDxBrain == '1' || line.metsAtDxDistantLn == '1' || line.metsAtDxLiver == '1' || line.metsAtDxLung == '1' || line.metsAtDxOther == '1') && !['10','30','50','70'].contains(line.eodMets))
            return false
        if (line.metsAtDxOther == '2' && line.eodMets != '70')
            return false
        return true
    }

    // ID: IFN6291; NAME: Extranodal Extension Head and Neck Clin, Head/Neck, Behavior (NAACCR)
    public boolean ifn6291(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || !((List)context.IFN_6292_SchemaId_List).contains(line.schemaId)
        || line.extranodalExtensionHeadNeckClin == null || line.extranodalExtensionHeadNeckClin == '8' ||  line.behaviorCodeIcdO3 == null ||  line.typeOfReportingSource == '7')
            return true
        if (line.behaviorCodeIcdO3 == '2') {
            if (line.dateOfDiagnosisYear < '2023')
                return ['7','9'].contains(line.extranodalExtensionHeadNeckClin)
            else
                return line.extranodalExtensionHeadNeckClin == '7'
        }
        return true
    }

    // ID: IFN6293; NAME: Extranodal Extension Head and Neck Path, Head/Neck, Behavior (NAACCR)
    public boolean ifn6293(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || !((List)context.IFN_6293_SchemaId_List).contains(line.schemaId)
        || line.extranodalExtensionHeadNeckPath == null || line.extranodalExtensionHeadNeckPath == 'X.8' || line.behaviorCodeIcdO3 == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.behaviorCodeIcdO3 == '2')
            return line.extranodalExtensionHeadNeckPath == 'X.7' || (line.extranodalExtensionHeadNeckPath == 'X.9')
        return true
    }

    // ID: IFN6294; NAME: Extranodal Extension Head and Neck Path, Head/Neck, Scope Nodes (SEER)
    public boolean ifn6294(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || !((List)context.IFN_6294_SchemaId_List).contains(line.schemaId)
        || line.extranodalExtensionHeadNeckPath == null || line.extranodalExtensionHeadNeckPath == 'X.8' || line.rxSummScopeRegLnSur == null || line.typeOfReportingSource == '6' || line.typeOfReportingSource == '7')
            return true
        
        Integer dolcYear = functions.asInt(line.dateOfLastContactYear)
        Integer dolcMonth = functions.asInt(line.dateOfLastContactMonth)
        Integer dolcDay = functions.asInt(line.dateOfLastContactDay)
        Integer dxYear = functions.asInt(line.dateOfDiagnosisYear)
        Integer dxMonth = functions.asInt(line.dateOfDiagnosisMonth)
        Integer dxDay = functions.asInt(line.dateOfDiagnosisDay)
        
        if (line.vitalStatus == '0' && (Boolean)((Closure)context.compareDatesWithinMonths).call(dolcYear, dolcMonth, dolcDay, dxYear, dxMonth, dxDay, 5))
            return true
        
        if (line.extranodalExtensionHeadNeckPath == '0.0')
            return functions.matches(line.rxSummScopeRegLnSur, /^[3-7]$/)
        else if (functions.matches(line.extranodalExtensionHeadNeckPath, /^\d\.\d|X\.[1-7]$/))
            return functions.matches(line.rxSummScopeRegLnSur, /^[2-7]$/)
        
        return true
    }

    // ID: IFN6295; NAME: EOD Regional Nodes, Kaposi Sarcoma, Scope Nodes (SEER)
    public boolean ifn6295(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7' || line.eodRegionalNodes == null)
            return true
        if (line.schemaId == null || line.schemaId != '00458')
            return true
        if (line.rxSummScopeRegLnSur == null)
            return true
        
        if (['200','300'].contains(line.eodRegionalNodes)) {
            if (['00','98','99'].contains(line.regionalNodesPositive))
                return false
        
            Integer dolcYear = functions.asInt(line.dateOfLastContactYear)
            Integer dolcMonth = functions.asInt(line.dateOfLastContactMonth)
            Integer dolcDay = functions.asInt(line.dateOfLastContactDay)
            Integer dxYear = functions.asInt(line.dateOfDiagnosisYear)
            Integer dxMonth = functions.asInt(line.dateOfDiagnosisMonth)
            Integer dxDay = functions.asInt(line.dateOfDiagnosisDay)
        
            if (line.typeOfReportingSource == '6')
                return line.rxSummScopeRegLnSur == '0'
            else if (line.vitalStatus == '0' && (Boolean)((Closure)context.compareDatesWithinMonths).call(dolcYear, dolcMonth, dolcDay, dxYear, dxMonth, dxDay, 5))
                return functions.matches(line.rxSummScopeRegLnSur, /^[0-7]$/)
            else
                return functions.matches(line.rxSummScopeRegLnSur, /^[1-7]$/)
        }
        
        return true
    }

    // ID: IFN6296; NAME: EOD Regional Nodes, Merkel Cell, Reg Nodes Positive, Scope Nodes (SEER)
    public boolean ifn6296(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7' || line.eodRegionalNodes == null)
            return true
        if (line.schemaId == null || line.schemaId != '00460')
            return true
        
        if (line.eodRegionalNodes == '100') {
            if (line.rxSummScopeRegLnSur != null && !['0','9'].contains(line.rxSummScopeRegLnSur))
                return false
            if (line.regionalNodesPositive != null && !['98','99'].contains(line.regionalNodesPositive))
                return false
        }
        else if (line.eodRegionalNodes == '200') {
            if (line.rxSummScopeRegLnSur != null && line.rxSummScopeRegLnSur != '1')
                return false
            if (line.regionalNodesPositive != null && line.regionalNodesPositive != '95')
                return false
        }
        else if (line.eodRegionalNodes == '300') {
            if (line.rxSummScopeRegLnSur != null && !['2','6','7'].contains(line.rxSummScopeRegLnSur))
                return false
            if (line.regionalNodesPositive != null && !functions.matches(line.regionalNodesPositive, /^0[1-9]|[1-8]\d|9[07]$/))
                return false
        }
        else if (line.eodRegionalNodes == '350') {
            if (line.regionalNodesPositive != null && !functions.matches(line.regionalNodesPositive, /^0[1-9]|[1-8]\d|9[07]$/))
                return false
            if (line.typeOfReportingSource == '6') {
                if (line.rxSummScopeRegLnSur != '0')
                    return false
            }
            else {
                Integer dolcYear = functions.asInt(line.dateOfLastContactYear)
                Integer dolcMonth = functions.asInt(line.dateOfLastContactMonth)
                Integer dolcDay = functions.asInt(line.dateOfLastContactDay)
                Integer dxYear = functions.asInt(line.dateOfDiagnosisYear)
                Integer dxMonth = functions.asInt(line.dateOfDiagnosisMonth)
                Integer dxDay = functions.asInt(line.dateOfDiagnosisDay)
        
                if (line.vitalStatus == '0' && (Boolean)((Closure)context.compareDatesWithinMonths).call(dolcYear, dolcMonth, dolcDay, dxYear, dxMonth, dxDay, 5)) {
                    if (!functions.matches(line.rxSummScopeRegLnSur, /^[03-7]$/))
                        return false
                }
                else if (!functions.matches(line.rxSummScopeRegLnSur, /^[3-7]$/))
                    return false
            }
        }
        else if (['400','500','750'].contains(line.eodRegionalNodes)) {
            if (line.regionalNodesPositive != null && !functions.matches(line.regionalNodesPositive, /^0[1-9]|[1-8]\d|9[057]$/))
                return false
            if (line.typeOfReportingSource == '6') {
                if (line.rxSummScopeRegLnSur != '0')
                    return false
            }
            else {
                Integer dolcYear = functions.asInt(line.dateOfLastContactYear)
                Integer dolcMonth = functions.asInt(line.dateOfLastContactMonth)
                Integer dolcDay = functions.asInt(line.dateOfLastContactDay)
                Integer dxYear = functions.asInt(line.dateOfDiagnosisYear)
                Integer dxMonth = functions.asInt(line.dateOfDiagnosisMonth)
                Integer dxDay = functions.asInt(line.dateOfDiagnosisDay)
        
                if (line.vitalStatus == '0' && (Boolean)((Closure)context.compareDatesWithinMonths).call(dolcYear, dolcMonth, dolcDay, dxYear, dxMonth, dxDay, 5)) {
                    if (!functions.matches(line.rxSummScopeRegLnSur, /^[0-7]$/))
                        return false
                }
                else if (!functions.matches(line.rxSummScopeRegLnSur, /^[1-7]$/))
                    return false
            }
        }
        else if (['600','700'].contains(line.eodRegionalNodes) && line.regionalNodesPositive != null && !['00','98','99'].contains(line.regionalNodesPositive))
            return false
        else if (line.eodRegionalNodes == '650' && line.regionalNodesPositive != null && !['00','95','97','98','99'].contains(line.regionalNodesPositive))
            return false
        
        if (['700','750'].contains(line.eodRegionalNodes)) {
            if (line.typeOfReportingSource == '6') {
                if (line.reasonForNoSurgery != '9')
                    return false
            }
            else {
                Integer dolcYear = functions.asInt(line.dateOfLastContactYear)
                Integer dolcMonth = functions.asInt(line.dateOfLastContactMonth)
                Integer dolcDay = functions.asInt(line.dateOfLastContactDay)
                Integer dxYear = functions.asInt(line.dateOfDiagnosisYear)
                Integer dxMonth = functions.asInt(line.dateOfDiagnosisMonth)
                Integer dxDay = functions.asInt(line.dateOfDiagnosisDay)
        
                if (line.vitalStatus == '0' && (Boolean)((Closure)context.compareDatesWithinMonths).call(dolcYear, dolcMonth, dolcDay, dxYear, dxMonth, dxDay, 5)) {
                    if (!functions.matches(line.reasonForNoSurgery, /^[0-25-9]$/))
                        return false
                }
                else if (line.reasonForNoSurgery != '0')
                    return false
            }
        }
        return true
    }

    // ID: IFN6297; NAME: Mets at DX, Merkel Cell, EOD Mets (SEER)
    public boolean ifn6297(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        if (line.eodMets == null || line.schemaId == null || line.schemaId != '00460')
            return true
        if (line.metsAtDxBone == null && line.metsAtDxBrain == null && line.metsAtDxDistantLn == null && line.metsAtDxLiver == null && line.metsAtDxLung == null && line.metsAtDxOther == null)
            return true
        
        boolean metsAtDxBoneCondition = line.metsAtDxBone == null || ['0','9'].contains(line.metsAtDxBone)
        boolean metsAtDxBrainCondition = line.metsAtDxBrain == null || ['0','9'].contains(line.metsAtDxBrain)
        boolean metsAtDxDistantLnCondition = line.metsAtDxDistantLn == null || ['0','9'].contains(line.metsAtDxDistantLn)
        boolean metsAtDxLiverCondition = line.metsAtDxLiver == null || ['0','9'].contains(line.metsAtDxLiver)
        boolean metsAtDxLungCondition = line.metsAtDxLung == null || ['0','9'].contains(line.metsAtDxLung)
        boolean metsAtDxOtherCondition = line.metsAtDxOther == null || ['0','9'].contains(line.metsAtDxOther)
        
        if (line.metsAtDxDistantLn == '1' && metsAtDxBoneCondition && metsAtDxBrainCondition && metsAtDxLiverCondition && metsAtDxLungCondition && metsAtDxOtherCondition && line.eodMets != '10')
            return false
        if (line.metsAtDxBone == '1' && metsAtDxBrainCondition && (metsAtDxDistantLnCondition || line.metsAtDxDistantLn == '1') && metsAtDxLiverCondition && metsAtDxLungCondition && metsAtDxOtherCondition && line.eodMets != '20')
            return false
        if (line.metsAtDxOther == '1' && (metsAtDxBoneCondition || line.metsAtDxBone == '1') && metsAtDxBrainCondition && (metsAtDxDistantLnCondition || line.metsAtDxDistantLn == '1') && metsAtDxLiverCondition && metsAtDxLungCondition && !['20','50'].contains(line.eodMets))
            return false
        if (line.metsAtDxLung == '1' && (metsAtDxBoneCondition || line.metsAtDxBone == '1') && metsAtDxBrainCondition && (metsAtDxDistantLnCondition || line.metsAtDxDistantLn == '1') && metsAtDxLiverCondition && metsAtDxOtherCondition && line.eodMets != '30')
            return false
        if (line.metsAtDxOther == '1' && line.metsAtDxLung == '1' && (metsAtDxBoneCondition || line.metsAtDxBone == '1') && metsAtDxBrainCondition && (metsAtDxDistantLnCondition || line.metsAtDxDistantLn == '1') && metsAtDxLiverCondition && !['30','50'].contains(line.eodMets))
            return false
        if ((line.metsAtDxBrain == '1' || line.metsAtDxLiver == '1' || line.metsAtDxOther == '2') && line.eodMets != '50')
            return false
        if (line.eodMets == '10' && line.metsAtDxDistantLn != '1')
            return false
        if (line.eodMets == '30' && line.metsAtDxLung != '1')
            return false
        return true
    }

    // ID: IFN6298; NAME: LN Isolated Tumor Cells (ITC), Merkel Cell, Behavior (NAACCR)
    public boolean ifn6298(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if(line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.schemaId != '00460'
                    || line.lnIsolatedTumorCells == null || line.lnIsolatedTumorCells == '8' || line.behaviorCodeIcdO3 == null || line.typeOfReportingSource == '7' )
            return true
        if (line.behaviorCodeIcdO3 == '2')
            return line.lnIsolatedTumorCells != '1'
        return true
    }

    // ID: IFN6301; NAME: EOD Regional Nodes, Skin Eyelid, Reg Nodes Positive, Scope Nodes (SEER)
    public boolean ifn6301(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7' || line.eodRegionalNodes == null)
            return true
        if (line.schemaId == null || line.schemaId != '00640')
            return true
        
        if (line.eodRegionalNodes == '200') {
            if (line.regionalNodesPositive != null && !['01','95','97'].contains(line.regionalNodesPositive))
                return false
        }
        else if (line.eodRegionalNodes == '500') {
            if (line.regionalNodesPositive != null && !functions.matches(line.regionalNodesPositive, /^0[2-9]|[1-8]\d|9[057]$/))
            return false
        }
        
        if (['200','500'].contains(line.eodRegionalNodes)) {
            if (line.typeOfReportingSource == '6') {
                if (line.rxSummScopeRegLnSur != '0')
                    return false
            }
            else {
                Integer dolcYear = functions.asInt(line.dateOfLastContactYear)
                Integer dolcMonth = functions.asInt(line.dateOfLastContactMonth)
                Integer dolcDay = functions.asInt(line.dateOfLastContactDay)
                Integer dxYear = functions.asInt(line.dateOfDiagnosisYear)
                Integer dxMonth = functions.asInt(line.dateOfDiagnosisMonth)
                Integer dxDay = functions.asInt(line.dateOfDiagnosisDay)
        
                if (line.vitalStatus == '0' && (Boolean)((Closure)context.compareDatesWithinMonths).call(dolcYear, dolcMonth, dolcDay, dxYear, dxMonth, dxDay, 5)) {
                    if (!functions.matches(line.rxSummScopeRegLnSur, /^[0-7]$/))
                        return false
                }
                else if (!functions.matches(line.rxSummScopeRegLnSur, /^[1-7]$/))
                    return false
            }
        }
        return true
    }

    // ID: IFN6302; NAME: EOD Primary Tumor/Mets, Conjunctiva, Mets at DX-Bone, Brain (SEER)
    public boolean ifn6302(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.schemaId != '00650' ||
        (line.eodPrimaryTumor == null && line.eodMets == null) || (line.metsAtDxBrain == null && line.metsAtDxBone == null)  || line.typeOfReportingSource == '7')
            return true
        if (line.eodPrimaryTumor == '500' && line.eodMets == '00')
            return line.metsAtDxBone == null || line.metsAtDxBone == '0'
        if (line.eodPrimaryTumor == '650' && line.eodMets == '00')
            return line.metsAtDxBrain == null || line.metsAtDxBrain == '0'
        return true
    }

    // ID: IFN6303; NAME: Measured Thickness, Ophthalmic Melanoma, EOD Primary Tumor (SEER)
    public boolean ifn6303(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        if (line.eodPrimaryTumor == null || line.measuredThickness == null || line.measuredThickness == 'XX.8')
            return true
        if (line.schemaId == null || (line.schemaId != '00660' && line.schemaId != '00671' && line.schemaId != '00672'))
            return true
        
        if (line.eodPrimaryTumor == '800')
            return line.measuredThickness == '0.0' || line.measuredThickness == 'XX.9'
        
        return true
    }

    // ID: IFN6304; NAME: Mets at DX, Retinoblastoma, EOD Mets (SEER)
    public boolean ifn6304(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        if (line.eodMets == null || line.schemaId == null || line.schemaId != '00680')
            return true
        if (line.metsAtDxBone == null && line.metsAtDxBrain == null && line.metsAtDxDistantLn == null && line.metsAtDxLiver == null && line.metsAtDxLung == null && line.metsAtDxOther == null)
            return true
        
        boolean metsAtDxBoneCondition = line.metsAtDxBone == null || ['0','9'].contains(line.metsAtDxBone)
        boolean metsAtDxBrainCondition = line.metsAtDxBrain == null || ['0','9'].contains(line.metsAtDxBrain)
        boolean metsAtDxDistantLnCondition = line.metsAtDxDistantLn == null || ['0','9'].contains(line.metsAtDxDistantLn)
        boolean metsAtDxLiverCondition = line.metsAtDxLiver == null || ['0','9'].contains(line.metsAtDxLiver)
        boolean metsAtDxLungCondition = line.metsAtDxLung == null || ['0','9'].contains(line.metsAtDxLung)
        boolean metsAtDxOtherCondition = line.metsAtDxOther == null || ['0','9'].contains(line.metsAtDxOther)
        
        if (line.metsAtDxDistantLn == '1' && metsAtDxBoneCondition && metsAtDxBrainCondition && metsAtDxLiverCondition && metsAtDxLungCondition && metsAtDxOtherCondition && line.eodMets != '10')
            return false
        if ((line.metsAtDxBone == '1' || line.metsAtDxLiver == '1' || line.metsAtDxLung == '1' || line.metsAtDxOther == '2') && (metsAtDxDistantLnCondition || line.metsAtDxDistantLn == '1') && metsAtDxBrainCondition && line.eodMets != '30')
            return false
        if ((line.metsAtDxBone == '1' || line.metsAtDxLiver == '1' || line.metsAtDxLung == '1' || line.metsAtDxOther == '1') && (metsAtDxDistantLnCondition || line.metsAtDxDistantLn == '1') && metsAtDxBrainCondition && !['30','50'].contains(line.eodMets))
            return false
        
        if (line.metsAtDxBrain == '1' && line.eodMets != '50')
            return false
        if (line.eodMets == '10' && line.metsAtDxDistantLn != '1')
            return false
        return true
    }

    // ID: IFN6305; NAME: Mets at DX, Lymphoma Ocular Adnexa, EOD Nodes/Mets (SEER)
    public boolean ifn6305(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        if (line.eodMets == null || line.schemaId == null || line.schemaId != '00710')
            return true
        if (line.metsAtDxBone == null && line.metsAtDxBrain == null && line.metsAtDxDistantLn == null && line.metsAtDxLiver == null && line.metsAtDxLung == null && line.metsAtDxOther == null)
            return true
        
        if ((line.metsAtDxBone == '1' || line.metsAtDxBrain == '1' || line.metsAtDxLiver == '1' || line.metsAtDxLung == '1' || line.metsAtDxOther == '2') && !['10','50'].contains(line.eodMets))
            return false
        if (line.metsAtDxOther == '1' && !['10','30','50'].contains(line.eodMets))
            return false
        if (line.metsAtDxDistantLn == '1' && !['600','700','750'].contains(line.eodRegionalNodes))
            return false
        if (['30','50'].contains(line.eodMets) && line.metsAtDxOther != '1')
            return false
        if (['600','700','750'].contains(line.eodRegionalNodes) && line.metsAtDxDistantLn != '1')
            return false
        return true
    }

    // ID: IFN6306; NAME: Mets at DX, NET Adrenal, EOD Mets (SEER)
    public boolean ifn6306(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        if (line.eodMets == null || line.schemaId == null || line.schemaId != '00770')
            return true
        if (line.metsAtDxBone == null && line.metsAtDxBrain == null && line.metsAtDxDistantLn == null && line.metsAtDxLiver == null && line.metsAtDxLung == null && line.metsAtDxOther == null)
            return true
        
        boolean metsAtDxBoneCondition = line.metsAtDxBone == null || ['0','9'].contains(line.metsAtDxBone)
        boolean metsAtDxBrainCondition = line.metsAtDxBrain == null || ['0','9'].contains(line.metsAtDxBrain)
        boolean metsAtDxDistantLnCondition = line.metsAtDxDistantLn == null || ['0','9'].contains(line.metsAtDxDistantLn)
        boolean metsAtDxLiverCondition = line.metsAtDxLiver == null || ['0','9'].contains(line.metsAtDxLiver)
        boolean metsAtDxLungCondition = line.metsAtDxLung == null || ['0','9'].contains(line.metsAtDxLung)
        boolean metsAtDxOtherCondition = line.metsAtDxOther == null || ['0','9'].contains(line.metsAtDxOther)
        
        if (line.metsAtDxBone == '1' && metsAtDxBrainCondition && metsAtDxDistantLnCondition && metsAtDxLiverCondition && metsAtDxLungCondition && metsAtDxOtherCondition && line.eodMets != '10')
            return false
        if (line.metsAtDxDistantLn == '1' && metsAtDxBoneCondition && metsAtDxBrainCondition && metsAtDxLiverCondition && metsAtDxLungCondition && metsAtDxOtherCondition && line.eodMets != '20')
            return false
        if (['0','9'].contains(line.metsAtDxBone) && (line.metsAtDxBrain == '1' || line.metsAtDxLiver == '1' || line.metsAtDxLung == '1' || ['1','2'].contains(line.metsAtDxOther)) && line.eodMets != '30')
            return false
        if (line.metsAtDxBone == '1' && (line.metsAtDxBrain == '1' || line.metsAtDxDistantLn == '1' || line.metsAtDxLiver == '1' || line.metsAtDxLung == '1' || ['1','2'].contains(line.metsAtDxOther)) && line.eodMets != '50')
            return false
        
        if (['10','50'].contains(line.eodMets) && line.metsAtDxBone != '1')
            return false
        if (line.eodMets == '20' && line.metsAtDxDistantLn != '1')
            return false
        return true
    }

    // ID: IFN6309; NAME: Mets at DX, Lymphoma, EOD Primary Tumor (SEER)
    public boolean ifn6309(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        if (line.eodPrimaryTumor == null || line.schemaId == null || !['00790','00795'].contains(line.schemaId))
            return true
        if (line.metsAtDxBone == null && line.metsAtDxBrain == null && line.metsAtDxLiver == null && line.metsAtDxLung == null && line.metsAtDxOther == null)
            return true
        
        if ((line.metsAtDxBone == '1' || line.metsAtDxBrain == '1' || line.metsAtDxLung == '1' || line.metsAtDxOther == '1' || line.metsAtDxOther == '2') && !['700','800'].contains(line.eodPrimaryTumor))
            return false
        if (line.metsAtDxLiver == '1' && line.eodPrimaryTumor != '800')
            return false
        return true
    }

    // ID: IFN6310; NAME: Summary Stage 2018, Lymphoma, Primary Site (NAACCR)
    public boolean ifn6310(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.summaryStage2018 == null || line.typeOfReportingSource == '7')
            return true
        if (line.schemaId == null || !['00790','00795'].contains(line.schemaId) || line.primarySite == null)
            return true
        
        if (line.primarySite == 'C421')
            return line.summaryStage2018 == '7'
        else if (line.primarySite == 'C778')
            return ['2','7','9'].contains(line.summaryStage2018)
        
        return true
    }

    // ID: IFN6311; NAME: EOD Primary Tumor/Nodes, Plasma Cell Disorders, Histology (SEER)
    public boolean ifn6311(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.schemaId != '00822' || line.histologicTypeIcdO3 == null
        || (line.eodPrimaryTumor == null && line.eodRegionalNodes == null))
            return true
        if (line.histologicTypeIcdO3 == '9731') {
            if (line.typeOfReportingSource == '7')
                return line.eodPrimaryTumor == '999' && (line.eodRegionalNodes == '987' || line.eodRegionalNodes == '999')
            else
                return (line.eodPrimaryTumor == '100' || line.eodPrimaryTumor == '999') && line.eodRegionalNodes == '987'
        }
        else if (line.histologicTypeIcdO3 == '9734') {
            if (line.typeOfReportingSource == '7')
                return line.eodPrimaryTumor == '999' && line.eodRegionalNodes == '999'
            else
                return (line.eodPrimaryTumor == '200' || line.eodPrimaryTumor == '999') && (line.eodRegionalNodes == '000' || line.eodRegionalNodes == '800' || line.eodRegionalNodes == '999')
        }
        else if (line.histologicTypeIcdO3 == '9671' || line.histologicTypeIcdO3 == '9761') {
            if (line.typeOfReportingSource == '7')
                return (line.eodPrimaryTumor == '999' || line.eodPrimaryTumor == '700') && (line.eodRegionalNodes == '999' || line.eodRegionalNodes == '987')
            else
                return line.eodPrimaryTumor == '700' && line.eodRegionalNodes == '987'
        }
        return true
    }

    // ID: IFN6313; NAME: Summary Stage 2018, Plasma Cell Disorders, Histology (NAACCR)
    public boolean ifn6313(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.summaryStage2018 == null || line.typeOfReportingSource == '7')
            return true
        if (line.schemaId == null || line.schemaId != '00822' || line.histologicTypeIcdO3 == null)
            return true
        
        if (line.histologicTypeIcdO3 == '9731')
            return ['1','9'].contains(line.summaryStage2018)
        else if (line.histologicTypeIcdO3 == '9734')
            return ['1','3','9'].contains(line.summaryStage2018)
        else if (line.histologicTypeIcdO3 == '9671' || line.histologicTypeIcdO3 == '9761')
            return line.summaryStage2018 == '7'
        
        return true
    }

    // ID: IFN6315; NAME: EOD Primary Tumor, HemeRetic, Histology (SEER)
    public boolean ifn6315(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.eodPrimaryTumor == null || line.histologicTypeIcdO3 == null)
            return true
        if (line.schemaId == null || line.schemaId != '00830')
            return true
        
        if (functions.matches(line.histologicTypeIcdO3, /^9(7(4[09]|5[15-9])|9(30|71))$/)) {
            if (line.typeOfReportingSource == '7')
                return line.eodPrimaryTumor == '999'
            else
                return ['100','700','999'].contains(line.eodPrimaryTumor)
        }
        else {
            if (line.typeOfReportingSource == '7')
                return ['700','999'].contains(line.eodPrimaryTumor)
            else
                return line.eodPrimaryTumor == '700'
        }
    }

    // ID: IFN6316; NAME: Summary Stage 2018, Plasma Cell Myeloma, Histology (NAACCR)
    public boolean ifn6316(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.summaryStage2018 == null || line.typeOfReportingSource == '7')
            return true
        if (line.schemaId == null || line.schemaId != '00821')
            return true
        
        return line.summaryStage2018 == '7'
    }

    // ID: IFN6318; NAME: Summary Stage 2018, HemeRetic, Histology (NAACCR)
    public boolean ifn6318(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.summaryStage2018 == null || line.typeOfReportingSource == '7')
            return true
        if (line.schemaId == null || line.schemaId != '00830' || line.histologicTypeIcdO3 == null)
            return true
        
        if (functions.matches(line.histologicTypeIcdO3, /^9(7(4[09]|5[15-9])|9(30|71))$/)) {
            if (!['1','7','9'].contains(line.summaryStage2018))
                return false
        }
        else if (line.summaryStage2018 != '7')
            return false
        
        return true
    }

    // ID: IFN6319; NAME: Mets at DX, Mycosis Fungoides, EOD Nodes/Mets (SEER)
    public boolean ifn6319(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        if (line.schemaId == null || line.schemaId != '00811')
            return true
        if (line.metsAtDxBone == null && line.metsAtDxBrain == null && line.metsAtDxDistantLn == null && line.metsAtDxLiver == null && line.metsAtDxLung == null && line.metsAtDxOther == null)
            return true
        
        if (line.eodMets != null) {
            if ((line.metsAtDxBone == '1' || line.metsAtDxBrain == '1' || line.metsAtDxLiver == '1' || line.metsAtDxLung == '1' || line.metsAtDxOther == '1') && line.eodMets != '70')
                return false
            if (line.metsAtDxOther == '2' && !['10','70'].contains(line.eodMets))
                return false
            if (line.eodMets == '10' && line.metsAtDxOther != '2')
                return false
        }
        
        if (line.eodRegionalNodes != null) {
            if (line.metsAtDxDistantLn == '1' && !functions.matches(line.eodRegionalNodes, /^[1-8]00$/))
                return false
        }
        
        return true
    }

    // ID: IFN6321; NAME: Extranodal Extension Path (non-Head and Neck), Scope Nodes (SEER)
    public boolean ifn6321(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        
                Integer dolcYear = functions.asInt(line.dateOfLastContactYear)
                Integer dolcMonth = functions.asInt(line.dateOfLastContactMonth)
                Integer dolcDay = functions.asInt(line.dateOfLastContactDay)
                Integer dxYear = functions.asInt(line.dateOfDiagnosisYear)
                Integer dxMonth = functions.asInt(line.dateOfDiagnosisMonth)
                Integer dxDay = functions.asInt(line.dateOfDiagnosisDay)
        
                if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || !['00460', '00570'].contains(line.schemaId)
        || line.extranodalExtensionPath == null || line.extranodalExtensionPath == '8' || line.rxSummScopeRegLnSur == null || line.typeOfReportingSource == '6'|| line.typeOfReportingSource == '7' ||
        (line.vitalStatus == '0' && (Boolean)((Closure)context.compareDatesWithinMonths).call(dolcYear, dolcMonth, dolcDay, dxYear, dxMonth, dxDay, 5)))
            return true
        
        if (line.extranodalExtensionPath == '0')
            return functions.matches(line.rxSummScopeRegLnSur, /^[3-7]$/)
        else if (['1', '7'].contains(line.extranodalExtensionPath))
            return functions.matches(line.rxSummScopeRegLnSur, /^[2-7]$/)
        
        return true
    }

    // ID: IFN6339; NAME: Neoadjuvant Therapy, Date DX (SEER)
    public boolean ifn6339(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
         if(line.dateOfDiagnosisYear == null || line.neoadjuvantTherapy == null)
                    return true
        if (line.dateOfDiagnosisYear < '2021')
            return false
        else
            return functions.matches(line.neoadjuvantTherapy, /^[01239]$/)
                    
    }

    // ID: IFN6340; NAME: Neoadjuvant Therapy-Clinical Response, Date DX (SEER)
    public boolean ifn6340(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
         if(line.dateOfDiagnosisYear == null || line.neoadjuvTherapyClinicalResponse == null)
                    return true
        if (line.dateOfDiagnosisYear < '2021')
            return false
        return functions.matches(line.neoadjuvTherapyClinicalResponse, /^\d$/)
                    
    }

    // ID: IFN6341; NAME: Neoadjuvant Therapy-Treatment Effect, Date DX (SEER)
    public boolean ifn6341(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
         if(line.dateOfDiagnosisYear == null || line.neoadjuvTherapyTreatmentEffect == null)
                    return true
        if (line.dateOfDiagnosisYear < '2021')
            return false
        return functions.matches(line.neoadjuvTherapyTreatmentEffect, /^[01234679]$/)
                    
    }

    // ID: IFN6344; NAME: Neoadjuvant Therapy, Primary Site, Schema ID (SEER)
    public boolean ifn6344(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
         if(line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.primarySite == null ||
                    line.neoadjuvantTherapy == null || line.typeOfReportingSource == '7')
                return true
        if (functions.matches(line.primarySite, /^C42[0134]|C809$/) || ['00790','00795','00811','00812','00821','00822','00830','99999'].contains(line.schemaId))
            return line.neoadjuvantTherapy == '0'
        return true
                    
    }

    // ID: IFN6345; NAME: Neoadjuvant Therapy-Clinical Response, Primary Site, Schema ID (SEER)
    public boolean ifn6345(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if(line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.primarySite == null ||
                    line.neoadjuvTherapyClinicalResponse == null || line.typeOfReportingSource == '7')
                return true
        if (functions.matches(line.primarySite, /^C42[0134]|C809$/) || ['00790','00795','00811','00812','00821','00822','00830','99999'].contains(line.schemaId))
            return line.neoadjuvTherapyClinicalResponse == '0'
        return true
    }

    // ID: IFN6346; NAME: Neoadjuvant Therapy-Treatment Effect, Primary Site, Schema ID (SEER)
    public boolean ifn6346(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if(line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.primarySite == null ||
                    line.neoadjuvTherapyTreatmentEffect == null || line.typeOfReportingSource == '7')
                return true
        if (functions.matches(line.primarySite, /^C42[0134]|C809$/) || ['00790','00795','00811','00812','00821','00822','00830','99999'].contains(line.schemaId))
            return line.neoadjuvTherapyTreatmentEffect == '0'
        return true
    }

    // ID: IFN6355; NAME: Measured Basal Diameter, Ophthalmic Melanoma, EOD Primary Tumor (SEER)
    public boolean ifn6355(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        if (line.eodPrimaryTumor == null || line.measuredBasalDiameter == null || line.measuredBasalDiameter == 'XX.8')
            return true
        if (line.schemaId == null || (line.schemaId != '00671' && line.schemaId != '00672'))
            return true
        
        if (line.eodPrimaryTumor == '800')
            return line.measuredBasalDiameter == '0.0' || line.measuredBasalDiameter == 'XX.9'
        
        return true
    }

    // ID: IFN6356; NAME: Grade, Ovary/PPC/FT, Morphology (NAACCR)
    public boolean ifn6356(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        if (line.gradeClinical == null && line.gradePathological == null)
            return true
        if (!functions.matches(line.schemaId, /^0055[123]$/))
            return true
        if (line.histologicTypeIcdO3 == null || line.behaviorCodeIcdO3 == null || line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1')
            return true
        
        String morphTypeAndBehIcdO3 = line.histologicTypeIcdO3 + line.behaviorCodeIcdO3
        if (['84412','84413','84603','84613','84743','90803'].contains(morphTypeAndBehIcdO3)) {
            if (line.gradePathological != null && !['L','H','9'].contains(line.gradePathological))
                return false
            if (line.gradeClinical != null && !['L','H','9'].contains(line.gradeClinical))
                return false
        }
        else {
            if (line.gradePathological != null && !['1','2','3','9'].contains(line.gradePathological))
                return false
            if (line.gradeClinical != null && !['1','2','3','9'].contains(line.gradeClinical))
                return false
        }
        return true
    }

    // ID: IFN6357; NAME: Schema Discriminator 1, Urethra, Sex (NAACCR)
    public boolean ifn6357(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
         if(line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || !['00631','00633'].contains(line.schemaId) || line.sex == null)
                return true
        if (line.schemaDiscriminator1 == '2' ||  line.schemaId == '00633')
            return line.sex != '2' && line.sex != '6'
        return true
                    
    }

    // ID: IFN6359; NAME: Mets at DX, NET, EOD Mets (SEER)
    public boolean ifn6359(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        if (line.eodMets == null || line.schemaId == null || !functions.matches(line.schemaId, /^0[09](290|3(0[12]|[123]0))$/))
            return true
        if (line.metsAtDxBone == null && line.metsAtDxBrain == null && line.metsAtDxDistantLn == null && line.metsAtDxLiver == null && line.metsAtDxLung == null && line.metsAtDxOther == null)
            return true
        
        boolean metsAtDxBoneCondition = line.metsAtDxBone == null || ['0','9'].contains(line.metsAtDxBone)
        boolean metsAtDxBrainCondition = line.metsAtDxBrain == null || ['0','9'].contains(line.metsAtDxBrain)
        boolean metsAtDxDistantLnCondition = line.metsAtDxDistantLn == null || ['0','9'].contains(line.metsAtDxDistantLn)
        boolean metsAtDxLiverCondition = line.metsAtDxLiver == null || ['0','9'].contains(line.metsAtDxLiver)
        boolean metsAtDxLungCondition = line.metsAtDxLung == null || ['0','9'].contains(line.metsAtDxLung)
        boolean metsAtDxOtherCondition = line.metsAtDxOther == null || ['0','9'].contains(line.metsAtDxOther)
        
        if (line.metsAtDxLiver == '1' && metsAtDxBoneCondition && metsAtDxBrainCondition && metsAtDxDistantLnCondition && metsAtDxLungCondition && metsAtDxOtherCondition && line.eodMets != '10')
            return false
        if (line.metsAtDxDistantLn == '1' && metsAtDxBoneCondition && metsAtDxBrainCondition && metsAtDxLiverCondition && metsAtDxLungCondition && metsAtDxOtherCondition && line.eodMets != '20')
            return false
        if (['0','9'].contains(line.metsAtDxLiver) && (line.metsAtDxBone == '1' || line.metsAtDxBrain == '1' || line.metsAtDxLung == '1' || ['1','2'].contains(line.metsAtDxOther)) && line.eodMets != '30')
            return false
        if (line.metsAtDxLiver == '1' && (line.metsAtDxBone == '1' || line.metsAtDxBrain == '1' || line.metsAtDxDistantLn == '1' || line.metsAtDxLung == '1' || ['1','2'].contains(line.metsAtDxOther)) && line.eodMets != '50')
            return false
        
        if (['10','50'].contains(line.eodMets) && line.metsAtDxLiver != '1')
            return false
        if (line.eodMets == '20' && line.metsAtDxDistantLn != '1')
            return false
        return true
    }

    // ID: IFN6360; NAME: Mets at DX, Bladder, EOD Mets (SEER)
    public boolean ifn6360(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        if (line.eodMets == null || line.schemaId == null || line.schemaId != '00620')
            return true
        if (line.metsAtDxBone == null && line.metsAtDxBrain == null && line.metsAtDxDistantLn == null && line.metsAtDxLiver == null && line.metsAtDxLung == null && line.metsAtDxOther == null)
            return true
        
        boolean metsAtDxBoneCondition = line.metsAtDxBone == null || ['0','9'].contains(line.metsAtDxBone)
        boolean metsAtDxBrainCondition = line.metsAtDxBrain == null || ['0','9'].contains(line.metsAtDxBrain)
        boolean metsAtDxLiverCondition = line.metsAtDxLiver == null || ['0','9'].contains(line.metsAtDxLiver)
        boolean metsAtDxLungCondition = line.metsAtDxLung == null || ['0','9'].contains(line.metsAtDxLung)
        boolean metsAtDxOtherCondition = line.metsAtDxOther == null || ['0','9'].contains(line.metsAtDxOther)
        
        if (line.metsAtDxDistantLn == '1' && metsAtDxBoneCondition && metsAtDxBrainCondition && metsAtDxLiverCondition && metsAtDxLungCondition && metsAtDxOtherCondition && line.eodMets != '10')
            return false
        if ((line.metsAtDxBone == '1' || line.metsAtDxBrain == '1' || line.metsAtDxLiver == '1' || line.metsAtDxLung == '1' || line.metsAtDxOther == '1' || line.metsAtDxOther == '2') && line.eodMets != '50')
            return false
        if (line.eodMets == '10' && line.metsAtDxDistantLn != '1')
            return false
        return true
    }

    // ID: IFN6361; NAME: Grade Post Therapy, Primary Site, Schema ID (NAACCR)
    public boolean ifn6361(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.primarySite == null || line.typeOfReportingSource == '7')
            return true
        if (line.gradePostTherapyClin == null && line.gradePostTherapy == null)
            return true
        if (line.schemaId == null)
            return true
        
        return (!functions.matches(line.primarySite, /^C(42[0134]|809)$/) &&
            !functions.matches(line.schemaId, /^00(79[05]|8([12][12]|30))|99999$/))
    }

    // ID: IFN6363; NAME: Regional Nodes Examined, RX Summ--Scope Reg LN Sur (NAACCR)
    public boolean ifn6363(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.regionalNodesExamined == null)
            return true
        if (line.rxSummScopeRegLnSur == null || line.typeOfReportingSource == '7')
            return true
        
        if (['00790', '00795', '00822', '00830', '99999'].contains(line.schemaId) && !functions.matches(line.primarySite, /^C42[0134]|C589|C7[012]\d|C75[123]|C76[1-8]|C77\d|C809$/)
            && functions.matches(line.rxSummScopeRegLnSur, /^\d$/))
            return true
        
        if (line.rxSummScopeRegLnSur == '0') {
            Integer dolcYear = functions.asInt(line.dateOfLastContactYear)
            Integer dolcMonth = functions.asInt(line.dateOfLastContactMonth)
            Integer dolcDay = functions.asInt(line.dateOfLastContactDay)
            Integer dxYear = functions.asInt(line.dateOfDiagnosisYear)
            Integer dxMonth = functions.asInt(line.dateOfDiagnosisMonth)
            Integer dxDay = functions.asInt(line.dateOfDiagnosisDay)
        
            if ((line.vitalStatus == '0' && (Boolean)((Closure)context.compareDatesWithinMonths).call(dolcYear, dolcMonth, dolcDay, dxYear, dxMonth, dxDay, 5)) || line.typeOfReportingSource == '6')
                return functions.matches(line.regionalNodesExamined, /^[0-8]\d|9[0678]$/)
        
            else
                return line.regionalNodesExamined == '00'
        }
        else if (line.rxSummScopeRegLnSur == '1' && line.regionalNodesExamined != '95')
            return false
        else if (line.rxSummScopeRegLnSur == '2' && !functions.matches(line.regionalNodesExamined, /^[0-8]\d|9[05-8]$/))
            return false
        else if (line.rxSummScopeRegLnSur == '3' && !functions.matches(line.regionalNodesExamined, /^00|9[678]$/))
            return false
        else if (line.rxSummScopeRegLnSur == '4' && !functions.matches(line.regionalNodesExamined, /^0[123]$/))
            return false
        else if (line.rxSummScopeRegLnSur == '5' && !functions.matches(line.regionalNodesExamined, /^0[4-9]|[1-8]\d|9[0678]$/))
            return false
        else if (['6','7'].contains(line.rxSummScopeRegLnSur) && !functions.matches(line.regionalNodesExamined, /^0[1-9]|[1-8]\d|9[0678]$/))
            return false
        else if (line.rxSummScopeRegLnSur == '9' && line.regionalNodesExamined != '99')
            return false
        return true
    }

    // ID: IFN6366; NAME: EOD Primary Tumor, Retinoblastoma, RX Summ--Surg Prim Site 03-2022 (SEER)
    public boolean ifn6366(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.dateOfDiagnosisYear > '2022' || line.eodPrimaryTumor == null || line.rxSummSurgPrimSite == null)
            return true
        if (line.typeOfReportingSource == '7' || line.schemaId == null || line.schemaId != '00680')
            return true
        
        return !functions.matches(line.eodPrimaryTumor, /^[12]75|[2347]50|[45]00$/) || line.rxSummSurgPrimSite == '41'
    }

    // ID: IFN6367; NAME: RX Summ--Surg Oth Reg/Dis, Schema ID, Primary Site, 2018 (NAACCR)
    public boolean ifn6367(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null)
            return true
        if (line.rxSummSurgOthRegDis == null || line.primarySite == null || line.typeOfReportingSource == '7')
            return true
        
        boolean primarySiteCondition = functions.matches(line.primarySite, /^C(42[0134]|7(6[0-8]|7\d)|809)$/) && line.schemaId != '00060'
        if (primarySiteCondition && !['0','1','9'].contains(line.rxSummSurgOthRegDis))
            return false
        
        return true
    }

    // ID: IFN6368; NAME: Reason for No Surgery, Surg Prim Site 03-2022, Primary Site, 2018 (NAACCR)
    public boolean ifn6368(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.dateOfDiagnosisYear > '2022' || line.rxSummSurgPrimSite == null || line.reasonForNoSurgery == null)
            return true
        
        if (line.typeOfReportingSource == '7' || line.typeOfReportingSource == '6')
            return true
        
        if (functions.matches(line.primarySite, /^C(42[0134]|76[0-8]|809)$/))
            return line.reasonForNoSurgery == '1'
        else if (line.rxSummSurgPrimSite == '00' && !functions.matches(line.reasonForNoSurgery, /^[1-9]$/))
            return false
        else if (functions.matches(line.rxSummSurgPrimSite, /^[1-8]\d|90$/) && line.reasonForNoSurgery != '0')
            return false
        else if (line.rxSummSurgPrimSite == '98' && line.reasonForNoSurgery != '1')
            return false
        else if (line.rxSummSurgPrimSite == '99' && !['8','9'].contains(line.reasonForNoSurgery))
            return false
        return true
    }

    // ID: IFN6371; NAME: SSDI for Pancreas, Blank for Other Schemas (NAACCR)
    public boolean ifn6371(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if(line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.schemaId == '00280')
                    return true
        return line.ca199PretxLabValue == null
    }

    // ID: IFN6373; NAME: HER2 Overall Summary, Esophagus Squamous, Schema ID, Required (NAACCR)
    public boolean ifn6373(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.typeOfReportingSource == '7')
                return true
        if (line.schemaId == '00161')
            return line.her2OverallSummary != null
        
        return true
    }

    // ID: IFN6374; NAME: HER2 Overall Summary, Esophagus, Schema ID, Required (NAACCR)
    public boolean ifn6374(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.typeOfReportingSource == '7')
                return true
        if (line.schemaId == '00169')
            return line.her2OverallSummary != null
        
        return true
    }

    // ID: IFN6375; NAME: HER2 Overall Summary, Stomach, Schema ID, Required (NAACCR)
    public boolean ifn6375(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.typeOfReportingSource == '7')
                return true
        if (line.schemaId == '00170')
            return line.her2OverallSummary != null
        
        return true
    }

    // ID: IFN6376; NAME: Ki-67, NET, Schema ID, Required (NAACCR)
    public boolean ifn6376(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
         if(line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.typeOfReportingSource == '7')
                    return true
        if ('0000001565' == line.registryId && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if ('0000001566' == line.registryId && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        if (['00290','00301','00302','00310','00320','00330','00340','09290','09301','09302','09310','09320','09330','09340'].contains(line.schemaId))
            return line.ki67 != null && line.ki67 != 'XXX.8'
        return true
    }

    // ID: IFN6383; NAME: EOD Primary Tumor, Ovary/Fallopian Tube, Morphology ICDO3 (SEER)
    public boolean ifn6383(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.eodPrimaryTumor == null)
            return true
        if (line.typeOfReportingSource == '7' || line.schemaId == null || !['00551','00553'].contains(line.schemaId))
            return true
        if (line.histologicTypeIcdO3 == null || line.behaviorCodeIcdO3 == null)
            return true
        
        String morphTypebehavIcdO3 = line.histologicTypeIcdO3 + line.behaviorCodeIcdO3
        if (line.schemaId == '00551') {
            if (morphTypebehavIcdO3 == '84412')
                return ['000','050'].contains(line.eodPrimaryTumor)
            if (line.eodPrimaryTumor == '050')
                return morphTypebehavIcdO3 == '84412'
        }
        else if (line.schemaId == '00553') {
            if (morphTypebehavIcdO3 == '84412')
                return ['000','050','070','080'].contains(line.eodPrimaryTumor)
            if (['050','070','080'].contains(line.eodPrimaryTumor))
                return morphTypebehavIcdO3 == '84412'
        }
        return true
    }

    // ID: IFN6385; NAME: Mets at DX-BBDLLO, Behavior Code ICDO3 (NAACCR)
    public boolean ifn6385(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.typeOfReportingSource == '7' || line.behaviorCodeIcdO3 == null)
            return true
        if (line.metsAtDxBone == null && line.metsAtDxBrain == null && line.metsAtDxDistantLn == null  && line.metsAtDxLiver == null  && line.metsAtDxLung == null && line.metsAtDxOther == null)
            return true
        
        boolean areAllMetsZero = line.metsAtDxBone == '0' && line.metsAtDxBrain == '0' && line.metsAtDxDistantLn == '0'  && line.metsAtDxLiver == '0'  && line.metsAtDxLung == '0' && line.metsAtDxOther == '0'
        boolean areAllMetsEight = line.metsAtDxBone == '8' && line.metsAtDxBrain == '8' && line.metsAtDxDistantLn == '8'  && line.metsAtDxLiver == '8'  && line.metsAtDxLung == '8' && line.metsAtDxOther == '8'
        if (line.dateOfDiagnosisYear < '2022' && ['00790', '00795', '00830', '99999'].contains(line.schemaId) && areAllMetsEight)
            return true
        if (line.schemaId == '00822' || functions.matches(line.primarySite, /^C42[0-4]$/))
            return true
        
        if (functions.matches(line.primarySite, /^C7([0-2][0-9]|5[123])$/)) {
            if (['0', '1'].contains(line.behaviorCodeIcdO3) && !(areAllMetsZero || areAllMetsEight))
                return false
        }
        else if (['0', '1', '2'].contains(line.behaviorCodeIcdO3) && !areAllMetsZero)
            return false
        
        return true
    }

    // ID: IFN6396; NAME: Derived Summary Stage 2018, HemeRetic, Histology (SEER)
    public boolean ifn6396(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.derivedSummaryStage2018 == null)
            return true
        
        if (line.schemaId == null || line.schemaId != '00830' || line.histologicTypeIcdO3 == null)
            return true
        
        if (((List)context.IFN6396_Hist_List).contains(line.histologicTypeIcdO3)) {
            if (line.typeOfReportingSource == '7')
                return line.derivedSummaryStage2018 == '9'
            else
                return ['1','7','9'].contains(line.derivedSummaryStage2018)
        }
        else {
            if (line.typeOfReportingSource == '7')
                return ['7','9'].contains(line.derivedSummaryStage2018)
            else
                return line.derivedSummaryStage2018 == '7'
        }
    }

    // ID: IFN6397; NAME: Derived Summary Stage 2018, Lymphoma, Primary Site (SEER)
    public boolean ifn6397(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.derivedSummaryStage2018 == null)
            return true
        
        if (line.schemaId == null || !['00790', '00795'].contains(line.schemaId) || line.primarySite == null)
            return true
        
        if (line.primarySite == 'C421') {
            if (line.typeOfReportingSource == '7')
                return ['7','9'].contains(line.derivedSummaryStage2018)
            else
                return line.derivedSummaryStage2018 == '7'
        }
        else if (line.primarySite == 'C778')
            return ['2','7','9'].contains(line.derivedSummaryStage2018)
        
        return true
    }

    // ID: IFN6398; NAME: Derived Summary Stage 2018, Plasma Cell Disorders, Histology (SEER)
    public boolean ifn6398(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.derivedSummaryStage2018 == null)
            return true
        
        if (line.schemaId == null || line.schemaId != '00822' || line.histologicTypeIcdO3 == null)
            return true
        
        if (line.histologicTypeIcdO3 == '9731') {
            if (line.typeOfReportingSource == '7')
                return line.derivedSummaryStage2018 == '9'
            else
                return ['1','9'].contains(line.derivedSummaryStage2018)
        }
        else if (line.histologicTypeIcdO3 == '9734') {
            if (line.typeOfReportingSource == '7')
                return line.derivedSummaryStage2018 == '9'
            else
                return ['1','3','9'].contains(line.derivedSummaryStage2018)
        }
        else if (['9671','9761'].contains(line.histologicTypeIcdO3)) {
            if (line.typeOfReportingSource == '7')
                return ['7','9'].contains(line.derivedSummaryStage2018)
            else
                return line.derivedSummaryStage2018 == '7'
        }
        return true
    }

    // ID: IFN6399; NAME: Derived Summary Stage 2018, Plasma Cell Myeloma, Histology (SEER)
    public boolean ifn6399(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.derivedSummaryStage2018 == null)
            return true
        
        if (line.schemaId == null || line.schemaId != '00821')
            return true
        
        if (line.typeOfReportingSource == '7')
            return ['7','9'].contains(line.derivedSummaryStage2018)
        else
            return line.derivedSummaryStage2018 == '7'
    }

    // ID: IFN6407; NAME: Mets at DX, Bile Ducts Intrahepatic, EOD Mets (SEER)
    public boolean ifn6407(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        if (line.eodMets == null || line.schemaId == null || line.schemaId != '00230')
            return true
        if (line.metsAtDxBone == null && line.metsAtDxBrain == null && line.metsAtDxDistantLn == null && line.metsAtDxLiver == null && line.metsAtDxLung == null && line.metsAtDxOther == null)
            return true
        
        boolean metsAtDxBoneCondition = line.metsAtDxBone == null || ['0','9'].contains(line.metsAtDxBone)
        boolean metsAtDxBrainCondition = line.metsAtDxBrain == null || ['0','9'].contains(line.metsAtDxBrain)
        boolean metsAtDxLiverCondition = line.metsAtDxLiver == null || ['0','9'].contains(line.metsAtDxLiver)
        boolean metsAtDxLungCondition = line.metsAtDxLung == null || ['0','9'].contains(line.metsAtDxLung)
        boolean metsAtDxOtherCondition = line.metsAtDxOther == null || ['0','9'].contains(line.metsAtDxOther)
        
        if (line.metsAtDxDistantLn == '1' && metsAtDxBoneCondition && metsAtDxBrainCondition && metsAtDxLiverCondition && metsAtDxLungCondition && metsAtDxOtherCondition && !['10','50'].contains(line.eodMets))
            return false
        if ((line.metsAtDxBone == '1' || line.metsAtDxBrain == '1' || line.metsAtDxLiver == '1' || line.metsAtDxLung == '1' || line.metsAtDxOther == '1' || line.metsAtDxOther == '2') && line.eodMets != '70')
            return false
        if (['10','50'].contains(line.eodMets) && line.metsAtDxDistantLn != '1')
            return false
        return true
    }

    // ID: IFN6408; NAME: Mets at DX, Pancreas, EOD Mets (SEER)
    public boolean ifn6408(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        if (line.eodMets == null || line.schemaId == null || line.schemaId != '00280')
            return true
        if (line.metsAtDxBone == null && line.metsAtDxBrain == null && line.metsAtDxDistantLn == null && line.metsAtDxLiver == null && line.metsAtDxLung == null && line.metsAtDxOther == null)
            return true
        
        boolean metsAtDxBoneCondition = line.metsAtDxBone == null || ['0','9'].contains(line.metsAtDxBone)
        boolean metsAtDxBrainCondition = line.metsAtDxBrain == null || ['0','9'].contains(line.metsAtDxBrain)
        boolean metsAtDxLiverCondition = line.metsAtDxLiver == null || ['0','9'].contains(line.metsAtDxLiver)
        boolean metsAtDxLungCondition = line.metsAtDxLung == null || ['0','9'].contains(line.metsAtDxLung)
        boolean metsAtDxOtherCondition = line.metsAtDxOther == null || ['0','9'].contains(line.metsAtDxOther)
        
        if (line.metsAtDxDistantLn == '1' && metsAtDxBoneCondition && metsAtDxBrainCondition && metsAtDxLiverCondition && metsAtDxLungCondition && metsAtDxOtherCondition && !['10','20'].contains(line.eodMets))
            return false
        if ((line.metsAtDxBone == '1' || line.metsAtDxBrain == '1' || line.metsAtDxLiver == '1' || line.metsAtDxLung == '1' || line.metsAtDxOther == '1' || line.metsAtDxOther == '2') && line.eodMets != '70')
            return false
        if (['10','20'].contains(line.eodMets) && line.metsAtDxDistantLn != '1')
            return false
        return true
    }

    // ID: IFN6427; NAME: Neoadjuvant Therapy, Required (SEER)
    public boolean ifn6427(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
         if(line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
                    return true
        if ('0000001565' == line.registryId && line.dateOfDiagnosisYear > '2020' && line.dateOfDiagnosisYear < '2023')
            return true
        if ('0000001566' == line.registryId && line.dateOfDiagnosisYear == '2021')
            return true
        return line.neoadjuvantTherapy != null
    }

    // ID: IFN6428; NAME: Neoadjuvant Therapy-Clinical Response, Required (SEER)
    public boolean ifn6428(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
         if(line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
                    return true
        if ('0000001565' == line.registryId && line.dateOfDiagnosisYear > '2020' && line.dateOfDiagnosisYear < '2023')
            return true
        if ('0000001566' == line.registryId && line.dateOfDiagnosisYear == '2021')
            return true
        return line.neoadjuvTherapyClinicalResponse != null
    }

    // ID: IFN6429; NAME: Neoadjuvant Therapy-Treatment Effect, Required (SEER)
    public boolean ifn6429(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
         if(line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
                    return true
        if ('0000001565' == line.registryId && line.dateOfDiagnosisYear > '2020' && line.dateOfDiagnosisYear < '2023')
            return true
        if ('0000001566' == line.registryId && line.dateOfDiagnosisYear == '2021')
            return true
        return line.neoadjuvTherapyTreatmentEffect != null
    }

    // ID: IFN6432; NAME: Regional Nodes Positive, RX Summ--Scope Reg LN Sur (NAACCR)
    public boolean ifn6432(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.regionalNodesPositive == null)
            return true
        if (line.rxSummScopeRegLnSur == null || line.typeOfReportingSource == '7')
            return true
        
        if (['00790', '00795', '00822', '00830', '99999'].contains(line.schemaId) && !functions.matches(line.primarySite, /^C42[0134]|C589|C7[012]\d|C75[123]|C76[1-8]|C77\d|C809$/)
            && functions.matches(line.rxSummScopeRegLnSur, /^\d$/))
            return true
        
        if (line.rxSummScopeRegLnSur == '0') {
                Integer dolcYear = functions.asInt(line.dateOfLastContactYear)
                Integer dolcMonth = functions.asInt(line.dateOfLastContactMonth)
                Integer dolcDay = functions.asInt(line.dateOfLastContactDay)
                Integer dxYear = functions.asInt(line.dateOfDiagnosisYear)
                Integer dxMonth = functions.asInt(line.dateOfDiagnosisMonth)
                Integer dxDay = functions.asInt(line.dateOfDiagnosisDay)
        
                if ((line.vitalStatus == '0' && (Boolean)((Closure)context.compareDatesWithinMonths).call(dolcYear, dolcMonth, dolcDay, dxYear, dxMonth, dxDay, 5)) || line.typeOfReportingSource == '6')
                    return functions.matches(line.regionalNodesPositive, /^[0-8]\d|9[078]$/)
        
                else
                    return line.regionalNodesPositive == '98'
            }
        else if (line.rxSummScopeRegLnSur == '1' && !['95','00'].contains(line.regionalNodesPositive))
            return false
        else if (functions.matches(line.rxSummScopeRegLnSur, /^[4-7]$/) && line.regionalNodesPositive == '98')
            return false
        return true
    }

    // ID: IFN6436; NAME: RX Summ--Treatm Stat, Date Initial RX SEER (SEER)
    public boolean ifn6436(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        boolean dateInitialRxSeerDateIsBlank = line.dateInitialRxSeerYear == null && line.dateInitialRxSeerMonth == null && line.dateInitialRxSeerDay == null
        
        boolean surgPrimSiteCondition = line.dateOfDiagnosisYear >= '2023' ?
            ['A000', 'B000', 'A980'].contains(line.rxSummSurgPrimSite2023) :
            ['00', '98'].contains(line.rxSummSurgPrimSite)
        
        if (functions.matches(line.rxSummScopeRegLnSur, /^[0-79]$/) &&
            surgPrimSiteCondition &&
            line.rxSummSurgOthRegDis == '0' &&
            functions.matches(line.rxSummBrm, /^00|8[0-8]$/) &&
            functions.matches(line.rxSummChemo, /^00|8[0-8]$/) &&
            functions.matches(line.rxSummHormone, /^00|8[0-8]$/) &&
            functions.matches(line.rxSummTransplntEndocr, /^00|8[0-8]$/) &&
            functions.matches(line.rxSummOther, /^[078]$/) &&
            (line.phase1RadiationTreatmentModality == '00' || functions.matches(line.reasonForNoRadiation, /^[125-9]$/)))
            return true
        
        if (line.dateOfDiagnosisYear < '2024') {
            if ((line.rxSummTreatmentStatus == '0' || line.rxSummTreatmentStatus == '2' || line.rxSummTreatmentStatus == '9') && !dateInitialRxSeerDateIsBlank)
                return false
            if (!dateInitialRxSeerDateIsBlank && line.rxSummTreatmentStatus != '1')
                return false
        }
        
        if (line.dateOfDiagnosisYear > '2023') {
            if (line.rxSummTreatmentStatus == '0' || line.rxSummTreatmentStatus == '9')
                return dateInitialRxSeerDateIsBlank
            if (!dateInitialRxSeerDateIsBlank)
                return line.rxSummTreatmentStatus == '1' || line.rxSummTreatmentStatus == '2'
        }
        
        return true
    }

    // ID: IFN6437; NAME: Lymphovascular Invasion, Schema ID (SEER)
    public boolean ifn6437(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.lymphVascularInvasion == null ||  line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        
        if (['00570', '00590'].contains(line.schemaId))
            return functions.matches(line.lymphVascularInvasion, /^[012349]$/)
        
        if (['00710', '00790', '00795', '00811', '00812', '00821', '00822', '00830'].contains(line.schemaId) || (line.schemaId == '00430' && line.dateOfDiagnosisYear > '2020'))
            return line.lymphVascularInvasion == '8'
        
        if (line.dateOfDiagnosisYear > '2021' && ['00730', '00740', '00760'].contains(line.schemaId))
            return line.lymphVascularInvasion != '1' && line.lymphVascularInvasion != '8'
        
        return true
                    
    }

    // ID: IFN6453; NAME: LN Status Para-Aortic, Date DX (NAACCR)
    public boolean ifn6453(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.lnStatusParaAortic != null)
            return false
        
        return line.lnStatusParaAortic == null || functions.matches(line.lnStatusParaAortic, /^[0189]$/)
    }

    // ID: IFN6455; NAME: LN Status Para-Aortic, Vagina/Cervix, Derived SS 2018 (SEER)
    public boolean ifn6455(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || !['00510','09520'].contains(line.schemaId) || line.lnStatusParaAortic == null ||
        line.lnStatusParaAortic == '8' || line.derivedSummaryStage2018 == null || line.typeOfReportingSource == '7')
            return true
        if (line.lnStatusParaAortic == '1')
            return !['0','1','2'].contains(line.derivedSummaryStage2018)
        return true
                    
    }

    // ID: IFN6456; NAME: LN Status Para-Aortic, Vagina/Cervix, Behavior (NAACCR)
    public boolean ifn6456(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        if (!['00510','09520'].contains(line.schemaId) || line.behaviorCodeIcdO3 == null)
            return true
        if (line.lnStatusParaAortic == null || line.lnStatusParaAortic == '8')
            return true
        
        return line.behaviorCodeIcdO3 != '2' || line.lnStatusParaAortic == '0' || (line.lnStatusParaAortic == '9' && line.dateOfDiagnosisYear < '2023')
    }

    // ID: IFN6457; NAME: LN Status, Cervix, EOD Regional Nodes (SEER)
    public boolean ifn6457(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.typeOfReportingSource == '7' || !['00520','09520'].contains(line.schemaId) || line.eodRegionalNodes == null)
            return true
        if ((line.lnStatusParaAortic == null || line.lnStatusParaAortic == '8') && (line.lnStatusPelvic == null || line.lnStatusPelvic == '8'))
            return true
        
        if (line.schemaId == '00520' && (line.lnStatusPelvic == '1' || line.lnStatusParaAortic == '1') && line.eodRegionalNodes != '300')
            return false
        
        if (line.schemaId == '09520') {
            if (line.lnStatusPelvic == '1' && (functions.matches(line.lnStatusParaAortic, /^[089]$/) || line.lnStatusParaAortic == null) && !['100','200','300'].contains(line.eodRegionalNodes))
                return false
            if (line.lnStatusParaAortic == '1' && !['400','500','600'].contains(line.eodRegionalNodes))
                return false
        }
        if (line.dateOfDiagnosisYear >= '2022') {
            if (line.lnStatusPelvic == '0' && line.lnStatusParaAortic == '0' && !['000','050'].contains(line.eodRegionalNodes))
                return false
            if (['000','050'].contains(line.eodRegionalNodes) && (line.lnStatusParaAortic != '0' || line.lnStatusPelvic != '0'))
                return false
        }
        return true
    }

    // ID: IFN6458; NAME: LN Status Para-Aortic, Vagina/Cervix, Summary Stage 2018 (NAACCR)
    public boolean ifn6458(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.typeOfReportingSource == '7')
            return true
        if (!['00510','00520','09520'].contains(line.schemaId) || line.summaryStage2018 == null)
            return true
        if (line.lnStatusParaAortic == null || line.lnStatusParaAortic == '8')
            return true
        
        return line.lnStatusParaAortic != '1' || !functions.matches(line.summaryStage2018, /^[012]$/)
    }

    // ID: IFN6459; NAME: LN Status Pelvic, Date DX (NAACCR)
    public boolean ifn6459(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.lnStatusPelvic != null)
            return false
        
        return line.lnStatusPelvic == null || functions.matches(line.lnStatusPelvic, /^[0189]$/)
    }

    // ID: IFN6460; NAME: LN Status Pelvic, Gynecologic, Behavior (NAACCR)
    public boolean ifn6460(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        if (!['00500','00510','09520','09500'].contains(line.schemaId) || line.behaviorCodeIcdO3 == null)
            return true
        if (line.lnStatusPelvic == null || line.lnStatusPelvic == '8')
            return true
        
        if (line.behaviorCodeIcdO3 == '2') {
            if (line.dateOfDiagnosisYear == '2021' || line.dateOfDiagnosisYear == '2022')
                return ['0','9'].contains(line.lnStatusPelvic)
            else if (line.dateOfDiagnosisYear >= '2023')
                return line.lnStatusPelvic == '0'
        }
        
        return true
    }

    // ID: IFN6461; NAME: LN Status Pelvic, Gynecologic, Derived SS 2018 (SEER)
    public boolean ifn6461(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        if (!['00500','00510','09520','09500'].contains(line.schemaId) || line.derivedSummaryStage2018 == null)
            return true
        if (line.lnStatusPelvic == null || line.lnStatusPelvic == '8')
            return true
        
        if (line.lnStatusPelvic == '1' && functions.matches(line.derivedSummaryStage2018, /^[012]$/))
            return false
        if (line.lnStatusPelvic == '1' && ['00500', '09500'].contains(line.schemaId) && line.derivedSummaryStage2018 != '7')
            return false
        return true
    }

    // ID: IFN6462; NAME: LN Status Pelvic, Gynecologic, Summary Stage 2018 (NAACCR)
    public boolean ifn6462(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.typeOfReportingSource == '7')
            return true
        if (!['00500','00510','00520','09520','09500'].contains(line.schemaId) || line.summaryStage2018 == null)
            return true
        if (line.lnStatusPelvic == null || line.lnStatusPelvic == '8')
            return true
        
        if (line.lnStatusPelvic == '1' && functions.matches(line.summaryStage2018, /^[012]$/))
            return false
        if (line.lnStatusPelvic == '1' && ['00500', '09500'].contains(line.schemaId) && line.summaryStage2018 != '7')
            return false
        return true
    }

    // ID: IFN6464; NAME: Grade, Breast, Behavior ICD-O-3 (NAACCR)
    public boolean ifn6464(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2022' || line.schemaId != '00480' || line.histologicTypeIcdO3 == null || line.behaviorCodeIcdO3 == null)
            return true
        if (line.typeOfReportingSource == '7')
            return true
        if (line.gradeClinical == null && line.gradePathological == null)
            return true
        
        if (functions.matches(line.gradeClinical, /^[123]$/) && functions.matches(line.gradePathological, /^[LMH]$/))
            return false
        
        boolean summaryStageCondition = line.summaryStage2018 == '1' || line.derivedSummaryStage2018 == '1'
        boolean tnmCondition = (line.ajccTnmClinN == 'cN0' || ['cN0','pN0'].contains(line.ajccTnmPathN)) &&
            (line.ajccTnmClinM == 'cM0' || line.ajccTnmPathM == 'cM0')
        if (line.behaviorCodeIcdO3 == '3' && line.histologicTypeIcdO3 != '8543' && (summaryStageCondition || tnmCondition))
            return !(functions.matches(line.gradeClinical, /^[LMH]$/) && functions.matches(line.gradePathological, /^[LMH]$/))
        
        return true
    }

    // ID: IFN6569; NAME: Regional Nodes Positive, Regional Nodes Examined (NAACCR)
    public boolean ifn6569(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.regionalNodesExamined == null || line.regionalNodesPositive == null)
            return true
        
        if (line.regionalNodesExamined == '00')
            return line.regionalNodesPositive == '98'
        else if (functions.matches(line.regionalNodesExamined, /^0[1-9]|[1-8]\d|90$/)) {
            Integer regionalNodesExaminedInt = functions.asInt(line.regionalNodesExamined)
            Integer regionalNodesPositiveInt = functions.asInt(line.regionalNodesPositive)
            return ['95','97','99'].contains(line.regionalNodesPositive) || regionalNodesPositiveInt <= regionalNodesExaminedInt
        }
        else if (line.regionalNodesExamined == '95')
            return ['00','95','99'].contains(line.regionalNodesPositive)
        else if (['96','97','98'].contains(line.regionalNodesExamined))
            return functions.matches(line.regionalNodesPositive, /^[0-8]\d|9[0579]$/)
        else if (line.regionalNodesExamined == '99')
            return line.regionalNodesPositive == '99'
        return true
    }

    // ID: IFN6574; NAME: Gleason Score Pathological, EOD Prostate Pathologic Extension (SEER)
    public boolean ifn6574(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2022' || line.schemaId != '00580')
            return true
        if (line.prostatePathologicalExtension == null || line.gleasonScorePathological == null)
            return true
        
        if (line.gleasonScorePathological == 'X7' && line.prostatePathologicalExtension != '900')
            return false
        if (line.prostatePathologicalExtension == '900' && line.gleasonScorePathological != 'X7')
            return false
        if (line.prostatePathologicalExtension == '950' && line.gleasonScorePathological != 'X9')
            return false
        
        return true
    }

    // ID: IFN6575; NAME: Gleason Tertiary Pattern, EOD Prostate Pathologic Extension (SEER)
    public boolean ifn6575(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2022' || line.schemaId != '00580')
            return true
        if (line.prostatePathologicalExtension == null || line.gleasonTertiaryPattern == null)
            return true
        
        if (line.gleasonTertiaryPattern == 'X7' && line.prostatePathologicalExtension != '900')
            return false
        if (line.prostatePathologicalExtension == '900' && line.gleasonTertiaryPattern != 'X7')
            return false
        if (line.prostatePathologicalExtension == '950' && line.gleasonTertiaryPattern != 'X9')
            return false
        
        return true
    }

    // ID: IFN6584; NAME: Grade Post Therapy Clin (yc), Grade Post Therapy Path (yp) (NAACCR)
    public boolean ifn6584(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2022' || functions.matches(line.schemaId, /^0072[123]|0972[1-4]$/))
            return true
        if (line.gradePostTherapyClin == null || line.gradePostTherapyClin == '8' || line.gradePostTherapyClin == '9')
            return true
        if (line.gradePostTherapy == null || line.gradePostTherapy == '8' || line.gradePostTherapy == '9')
            return true
        
        Integer gradePostTherapyInt = functions.asInt(line.gradePostTherapy)
        Integer gradePostTherapyClinInt = functions.asInt(line.gradePostTherapyClin)
        
        if (gradePostTherapyInt != null && gradePostTherapyClinInt != null)
            return gradePostTherapyInt >= gradePostTherapyClinInt
        
        return true
    }

    // ID: IFN6585; NAME: LN Status Femoral-Inguinal, Date DX (NAACCR)
    public boolean ifn6585(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2018' && line.lnStatusFemoralInguinal != null)
            return false
        
        return line.lnStatusFemoralInguinal == null || functions.matches(line.lnStatusFemoralInguinal, /^[0189]$/)
    }

    // ID: IFN6587; NAME: LN Status, Vulva, EOD Regional Nodes (SEER)
    public boolean ifn6587(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.typeOfReportingSource == '7')
            return true
        if ((line.schemaId != '00500' && line.schemaId != '09500') || line.eodRegionalNodes == null)
            return true
        if (line.lnStatusFemoralInguinal == null || line.lnStatusFemoralInguinal == '8')
            return true
        
        if (line.lnStatusFemoralInguinal == '1' && ['000','040','050','800','999'].contains(line.eodRegionalNodes))
            return false
        
        if (line.dateOfDiagnosisYear >= '2022') {
            if (line.lnStatusFemoralInguinal == '0' && !['000','040','050'].contains(line.eodRegionalNodes))
                return false
            if (['000','040','050'].contains(line.eodRegionalNodes) && line.lnStatusFemoralInguinal != '0')
                return false
        }
        return true
    }

    // ID: IFN6588; NAME: LN Status Femoral-Inguinal, Vulva/Vagina, Behavior (NAACCR)
    public boolean ifn6588(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        if (!['00500','00510','09500'].contains(line.schemaId) || line.behaviorCodeIcdO3 == null)
            return true
        if (line.lnStatusFemoralInguinal == null || line.lnStatusFemoralInguinal == '8')
            return true
        
        if (line.behaviorCodeIcdO3 == '2') {
            if (line.dateOfDiagnosisYear == '2021' || line.dateOfDiagnosisYear == '2022')
                return ['0','9'].contains(line.lnStatusFemoralInguinal)
            else if (line.dateOfDiagnosisYear >= '2023')
                return line.lnStatusFemoralInguinal == '0'
        }
        
        return true
    }

    // ID: IFN6589; NAME: LN Status Femoral-Inguinal, Vulva/Vagina, Derived SS 2018 (SEER)
    public boolean ifn6589(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        if (!['00500','00510','09500'].contains(line.schemaId) || line.derivedSummaryStage2018 == null)
            return true
        if (line.lnStatusFemoralInguinal == null || line.lnStatusFemoralInguinal == '8')
            return true
        
        return line.lnStatusFemoralInguinal != '1' || !functions.matches(line.derivedSummaryStage2018, /^[012]$/)
    }

    // ID: IFN6590; NAME: LN Status Femoral-Inguinal, Vulva/Vagina, Summary Stage 2018 (NAACCR)
    public boolean ifn6590(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.typeOfReportingSource == '7')
            return true
        if (!['00500','00510','09500'].contains(line.schemaId) || line.summaryStage2018 == null)
            return true
        if (line.lnStatusFemoralInguinal == null || line.lnStatusFemoralInguinal == '8')
            return true
        
        return line.lnStatusFemoralInguinal != '1' || !functions.matches(line.summaryStage2018, /^[012]$/)
    }

    // ID: IFN6592; NAME: LN Status Pelvic, Vulva, EOD Mets (SEER)
    public boolean ifn6592(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.typeOfReportingSource == '7')
            return true
        if (!['00500', '09500'].contains(line.schemaId) || line.eodMets == null)
            return true
        if (line.lnStatusPelvic == null || line.lnStatusPelvic == '8')
            return true
        
        return line.lnStatusPelvic != '1' || ['10','70'].contains(line.eodMets)
    }

    // ID: IFN6593; NAME: Derived Rai Stage, Date DX (NAACCR)
    public boolean ifn6593(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
                    return true
        
        if (line.dateOfDiagnosisYear < '2018')
            return line.derivedRaiStage == null
        
        if (line.primarySite !='C421')
            return line.derivedRaiStage == '8' || line.derivedRaiStage == null
        
        else
            return line.derivedRaiStage == null || functions.matches(line.derivedRaiStage, /^[0-49]$/)
                    
    }

    // ID: IFN6594; NAME: Derived Rai Stage, Schema ID, Required (NAACCR)
    public boolean ifn6594(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        if ('0000001565' == line.registryId && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if ('0000001566' == line.registryId && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        if ('0000001563' == line.registryId && line.dateOfDiagnosisYear == '2018')
            return true
        
        return (line.schemaId != '00795' || line.primarySite != 'C421') || (line.derivedRaiStage != null && line.derivedRaiStage != '8')
    }

    // ID: IFN6595; NAME: Tobacco Use Smoking Status, Date DX (NPCR)
    public boolean ifn6595(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
         if(line.dateOfDiagnosisYear == null)
                    return true
        
        if (line.dateOfDiagnosisYear < '2022')
            return line.tobaccoUseSmokingStatus == null
        
        else
            return line.tobaccoUseSmokingStatus == null || functions.matches(line.tobaccoUseSmokingStatus, /^[01239]$/)
                    
    }

    // ID: IFN6600; NAME: p16, Date DX (NAACCR)
    public boolean ifn6600(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
                    return true
        
        if (line.schemaId == '00210' && line.dateOfDiagnosisYear < '2023')
            return line.p16 == null
        
        if (line.schemaId == '00500' && line.dateOfDiagnosisYear < '2024')
            return line.p16 == null
        
        if (line.dateOfDiagnosisYear < '2021')
            return line.p16 == null
        
        else
            return line.p16 == null || functions.matches(line.p16, /^[0189]$/)
                     
    }

    // ID: IFN6602; NAME: Macroscopic Evaluation of Mesorectum, Date DX (COC)
    public boolean ifn6602(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
                    return true
        
        else
            return line.macroscopicEvalOfTheMesorectum == null || functions.matches(line.macroscopicEvalOfTheMesorectum, /^[01234]0|99$/)
                    
    }

    // ID: IFN6604; NAME: LN Status/Assessment Method Femoral-Inguinal, Vulva/Vagina (NAACCR)
    public boolean ifn6604(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2022' || !['00500','00510','09500'].contains(line.schemaId))
            return true
        if (line.lnStatusFemoralInguinal == null || line.lnAssessMethodFemoralInguinal == null)
            return true
        
        return line.lnStatusFemoralInguinal != '9' || line.lnAssessMethodFemoralInguinal == '9' || line.lnAssessMethodFemoralInguinal == '0'
    }

    // ID: IFN6605; NAME: LN Status/Assessment Method Para-Aortic, Vagina/Cervix (NAACCR)
    public boolean ifn6605(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2022' || !['00510','09520'].contains(line.schemaId))
            return true
        if (line.lnStatusParaAortic == null || line.lnAssessMethodParaaortic == null)
            return true
        
        return line.lnStatusParaAortic != '9' || line.lnAssessMethodParaaortic == '9' || line.lnAssessMethodParaaortic == '0'
    }

    // ID: IFN6606; NAME: LN Status/Assessment Method Pelvic, Gynecologic (NAACCR)
    public boolean ifn6606(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2022' || !['00500','00510','09520','09500'].contains(line.schemaId))
            return true
        if (line.lnStatusPelvic == null || line.lnAssessMethodPelvic == null)
            return true
        
        if (line.lnStatusPelvic == '9')
            return line.lnAssessMethodPelvic == '9' || line.lnAssessMethodPelvic == '0'
        
        return true
    }

    // ID: IFN6608; NAME: Lymphovascular Invasion, Behavior (NAACCR)
    public boolean ifn6608(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2022' || line.behaviorCodeIcdO3 == null)
            return true
        if (line.lymphVascularInvasion == null || line.typeOfReportingSource == '7')
            return true
        if (line.behaviorCodeIcdO3 == '0' && functions.matches(line.primarySite, /^C25\d$/))
            return true
        
        if (functions.matches(line.behaviorCodeIcdO3, /^[012]$/))
            return !functions.matches(line.lymphVascularInvasion, /^[1-49]$/)
        return true
    }

    // ID: IFN6612; NAME: LN Status, Vagina, EOD Regional Nodes/EOD Mets (SEER)
    public boolean ifn6612(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.typeOfReportingSource == '7' || line.schemaId != '00510')
            return true
        if ((line.lnStatusPelvic == null || line.lnStatusPelvic == '8') && (line.lnStatusParaAortic == null || line.lnStatusParaAortic == '8') && (line.lnStatusFemoralInguinal == null || line.lnStatusFemoralInguinal == '8'))
            return true
        if (line.eodRegionalNodes == null && line.eodMets == null)
            return true
        
        if (line.lnStatusFemoralInguinal == '1' && (functions.matches(line.lnStatusParaAortic, /^[089]$/) || line.lnStatusParaAortic == null) && line.eodRegionalNodes != '300')
            return false
        
        if (line.lnStatusPelvic == '1' && (functions.matches(line.lnStatusParaAortic, /^[089$]/) || line.lnStatusParaAortic == null) && line.eodRegionalNodes != '300' && !['10','70'].contains(line.eodMets))
            return false
        
        if (line.lnStatusParaAortic == '1' && line.eodRegionalNodes != '400' && !['10','70'].contains(line.eodMets))
            return false
        
        if (line.dateOfDiagnosisYear >= '2022') {
            if (line.lnStatusFemoralInguinal == '0' && line.lnStatusPelvic == '0' && line.lnStatusParaAortic == '0' && !['000','050'].contains(line.eodRegionalNodes))
                return false
            if (['000','050'].contains(line.eodRegionalNodes) && !['0','9'].contains(line.lnStatusFemoralInguinal))
                return false
            if (line.eodRegionalNodes == '300' && line.lnStatusFemoralInguinal != '1' && line.lnStatusPelvic != '1')
                return false
            if (line.eodRegionalNodes == '400' && line.lnStatusParaAortic != '1')
                return false
        }
        return true
    }

    // ID: IFN6613; NAME: LN Assessment Method, Cervix, Regional Nodes Examined (NAACCR)
    public boolean ifn6613(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || !['00520','09520'].contains(line.schemaId) || line.regionalNodesExamined == null)
            return true
        if ((line.lnAssessMethodParaaortic == null || line.lnAssessMethodParaaortic == '8') && (line.lnAssessMethodPelvic == null || line.lnAssessMethodPelvic == '8'))
            return true
        
        if (line.lnAssessMethodParaaortic == '0' && line.lnAssessMethodPelvic == '0' && line.regionalNodesExamined != '00')
            return false
        if ((line.lnAssessMethodParaaortic == '1' || line.lnAssessMethodPelvic == '1') && !functions.matches(line.lnAssessMethodParaaortic, /^[2789]$/) && !functions.matches(line.lnAssessMethodPelvic, /^[2789]$/)) {
            if (line.regionalNodesExamined != '95')
                return false
        }
        return ((line.lnAssessMethodParaaortic != '2' && line.lnAssessMethodPelvic != '2') || functions.matches(line.regionalNodesExamined, /^0[1-9]|[1-8]\d|9[06-8]$/))
    }

    // ID: IFN6614; NAME: LN Assessment Method, Vulva, Regional Nodes Examined (SEER)
    public boolean ifn6614(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || !['00500', '09500'].contains(line.schemaId) || line.regionalNodesExamined == null
                    || ['6','7'].contains(line.typeOfReportingSource))
            return true
        if (line.lnAssessMethodFemoralInguinal == null || line.lnAssessMethodFemoralInguinal == '8')
            return true
        
        if (line.lnAssessMethodFemoralInguinal == '0' && line.regionalNodesExamined != '00')
            return false
        if (line.lnAssessMethodFemoralInguinal == '1' && line.regionalNodesExamined != '95')
            return false
        if (line.lnAssessMethodFemoralInguinal == '2' && !functions.matches(line.regionalNodesExamined, /^0[1-9]|[1-8]\d|9[06-8]$/))
            return false
        
        return true
    }

    // ID: IFN6619; NAME: PhI Radiation Treatment Modality, DateDX, RPTSRC (SEER)
    public boolean ifn6619(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018')
            return true
        
        if (line.typeOfReportingSource == '6' && line.phase1RadiationTreatmentModality != '00')
            return false
        else if (line.typeOfReportingSource == '7' && line.phase1RadiationTreatmentModality != '99')
            return false
        else if (line.phase1RadiationTreatmentModality == null)
            return false
        return true
    }

    // ID: IFN6620; NAME: RX Summ--Treatment Status, DateDX, RPTSRC (SEER)
    public boolean ifn6620(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if(line.dateOfDiagnosisYear < '2010')
                        return true
            if (line.rxSummTreatmentStatus == null)
                return false
            if (line.typeOfReportingSource == '6')
                return line.rxSummTreatmentStatus == '0'
            if (line.typeOfReportingSource == '7')
                return line.rxSummTreatmentStatus == '9'
        
        return true
    }

    // ID: IFN6621; NAME: RX Summ--Surgical Margins, RPTSRC (SEER)
    public boolean ifn6621(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
         if(line.rxSummSurgicalMargins == null)
                    return true
        
        if (line.typeOfReportingSource == '6')
            return line.rxSummSurgicalMargins == '8' || line.rxSummSurgicalMargins == '9'
        
        if (line.typeOfReportingSource == '7')
            return line.rxSummSurgicalMargins == '9'
        
        return true
    }

    // ID: IFN6622; NAME: Reason for No Radiation, DateDX, RPTSRC (SEER)
    public boolean ifn6622(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018')
                    return true
        
        if (line.typeOfReportingSource == '6')
            return line.reasonForNoRadiation == '1'
        
        if (line.typeOfReportingSource == '7')
            return line.reasonForNoRadiation == '9'
        
        if (line.typeOfReportingSource != null)
            return line.reasonForNoRadiation != null
        
        return true
                    
    }

    // ID: IFN6633; NAME: Gleason Patterns Clinical, Grade Clinical (SEER)
    public boolean ifn6633(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId != '00580' || line.gradeClinical == null)
            return true
        
        String gleason = line.gleasonPatternsClinical
        if (gleason == null || gleason == 'X8')
            return true
        
        if (functions.matches(gleason, /^[123][123]$/))
            return line.gradeClinical == '1'
        else if (gleason == '34')
            return line.gradeClinical == '2'
        else if (gleason == '43')
            return line.gradeClinical == '3'
        else if (gleason == '44' || gleason == '35' || gleason == '53')
            return line.gradeClinical == '4'
        else if (gleason == '45' || gleason == '54' || gleason == '55')
            return line.gradeClinical == '5'
        
        return true
    }

    // ID: IFN6634; NAME: Diagnostic Confirmation, Histology, Genetics (NAACCR)
    public boolean ifn6634(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2022' || line.diagnosticConfirmation == null || line.histologicTypeIcdO3 == null)
            return true
        if (!['00790','00830'].contains(line.schemaId) || line.typeOfReportingSource == '7')
            return true
        
        if (((List)context.IFN6634_List_1).contains(line.histologicTypeIcdO3))
            return line.diagnosticConfirmation == '3'
        if (((List)context.IFN6634_List_2).contains(line.histologicTypeIcdO3))
            return line.diagnosticConfirmation != '3'
        return true
    }

    // ID: IFN6639; NAME: Grade Post Therapy, Treatment Status (NAACCR)
    public boolean ifn6639(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2022' || line.rxSummTreatmentStatus == null)
            return true
        if (line.gradePostTherapyClin == null && line.gradePostTherapy == null)
            return true
        
        if (['0','2','9'].contains(line.rxSummTreatmentStatus))
            return line.gradePostTherapyClin == null && line.gradePostTherapy == null
        return true
    }

    // ID: IFN6640; NAME: Macroscopic Evaluation of Mesorectum, Rectum, Surgery 03-2022 (SEER)
    public boolean ifn6640(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear != '2022' || line.primarySite != 'C209' || line.macroscopicEvalOfTheMesorectum == null ||
                    line.rxSummSurgPrimSite == null || line.typeOfReportingSource == '6' || line.typeOfReportingSource == '7')
            return true
        
        if (functions.matches(line.rxSummSurgPrimSite, /^00|1[0-5]|2[0-8]$/))
            return line.macroscopicEvalOfTheMesorectum == '00'
        
        if (line.rxSummSurgPrimSite == '99')
            return line.macroscopicEvalOfTheMesorectum == '99'
        
        return true
    }

    // ID: IFN6641; NAME: Macroscopic Evaluation of Mesorectum, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn6641(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2022' || line.schemaId == null || line.typeOfReportingSource == '7' || line.cocAccreditedFlag != '1')
            return true
        
        if (line.schemaId == '00200' && line.primarySite == 'C209')
            return line.macroscopicEvalOfTheMesorectum != null
        
        return true
    }

    // ID: IFN6642; NAME: p16, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn6642(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.dateOfDiagnosisYear > '2022'
                    || line.schemaId == null || line.typeOfReportingSource == '7' || line.cocAccreditedFlag != '1')
            return true
        
        if (('0000001565' == line.registryId || '0000001566' == line.registryId) && line.dateOfDiagnosisYear == '2021')
            return true
        
        if (line.schemaId == '09520')
            return line.p16 != null && line.p16 != '8'
        
        return true
    }

    // ID: IFN6643; NAME: LN Status Femoral-Inguinal, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn6643(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7' || line.cocAccreditedFlag != '1')
            return true
        if ('0000001565' == line.registryId && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if ('0000001566' == line.registryId && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return !['00500','00510','09500'].contains(line.schemaId) || (line.lnStatusFemoralInguinal != null && line.lnStatusFemoralInguinal != '8')
    }

    // ID: IFN6646; NAME: LN Status Para-Aortic, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn6646(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7' || line.cocAccreditedFlag != '1')
            return true
        if ('0000001565' == line.registryId && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if ('0000001566' == line.registryId && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return !['00510','00520','09520'].contains(line.schemaId) || (line.lnStatusParaAortic != null && line.lnStatusParaAortic != '8')
    }

    // ID: IFN6651; NAME: LN Status Pelvic, Schema ID, Required, CoC Flag (SEER)
    public boolean ifn6651(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.typeOfReportingSource == '7' || line.cocAccreditedFlag != '1')
            return true
        
        if ('0000001565' == line.registryId && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2023')
            return true
        if ('0000001566' == line.registryId && line.dateOfDiagnosisYear > '2017' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return !['00500','00510','00520','09520','09500'].contains(line.schemaId) || (line.lnStatusPelvic != null && line.lnStatusPelvic != '8')
    }

    // ID: IFN6660; NAME: Recurrence Type--1st, CoC Flag (SEER)
    public boolean ifn6660(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.cocAccreditedFlag != '1')
            return true
        if (line.registryId == '0000001565' && line.dateOfDiagnosisYear < '2023')
            return true
        if (line.registryId == '0000001566' && line.dateOfDiagnosisYear < '2022')
            return true
        
        return ((List)context.IFN6660_List).contains(line.recurrenceType1st)
    }

    // ID: IFN6661; NAME: Recurrence Type--1st, Cancer Status (SEER)
    public boolean ifn6661(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2022')
            return true
        if (line.recurrenceType1st == null || line.cancerStatus == null)
            return true
        
        if (line.recurrenceType1st == '00' && line.cancerStatus != '1')
            return false
        if (line.recurrenceType1st == '70' && line.cancerStatus != '2')
            return false
        return true
    }

    // ID: IFN6662; NAME: Pleural Effusion, Pleura, Derived SS 2018 (SEER)
    public boolean ifn6662(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId != '00370')
            return true
        if (line.derivedSummaryStage2018 == null || line.typeOfReportingSource == '7')
            return true
        
        return line.pleuralEffusion != '2' || line.derivedSummaryStage2018 == '7'
    }

    // ID: IFN6664; NAME: AFP Pre-Orchiectomy Range, Schema ID, Required (SEER)
    public boolean ifn6664(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2022' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.dateOfDiagnosisYear < '2023' && line.registryId == '0000001565')
            return true
        
        return line.schemaId != '00590' || (line.afpPreOrchiectomyRange != null && line.afpPreOrchiectomyRange != '8')
    }

    // ID: IFN6665; NAME: PhII Radiation External Beam Planning Tech, Date DX, CoC Flag (SEER)
    public boolean ifn6665(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.cocAccreditedFlag != '1' || line.typeOfReportingSource == '7')
            return true
        
        return line.phase2RadiationExternalBeamTech != null || line.phase2RadiationTreatmentModality == null || ['00','99'].contains(line.phase2RadiationTreatmentModality)
    }

    // ID: IFN6666; NAME: PhIII Radiation External Beam Planning Tech, Date DX, CoC Flag (SEER)
    public boolean ifn6666(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.cocAccreditedFlag != '1' || line.typeOfReportingSource == '7')
            return true
        
        return line.phase3RadiationExternalBeamTech != null || line.phase3RadiationTreatmentModality == null || ['00','99'].contains(line.phase3RadiationTreatmentModality)
    }

    // ID: IFN6669; NAME: EOD Primary Tumor/Nodes/Mets, Lung Occult Carcinoma, Derived SS 2018 (SEER)
    public boolean ifn6669(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.schemaId != '00360' || line.typeOfReportingSource == '7')
            return true
        if (line.eodPrimaryTumor == null && line.eodRegionalNodes == null && line.eodMets == null)
            return true
        
        if (line.eodPrimaryTumor == '980')
            return line.eodRegionalNodes == '000' && line.eodMets == '00' && line.derivedSummaryStage2018 == '9'
        
        return true
    }

    // ID: IFN6673; NAME: Esophagus and EGJ Tumor Epicenter, Esophagus, Primary Site (NAACCR)
    public boolean ifn6673(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId == null || line.schemaId != '00161')
            return true
        if (line.esophagusAndEgjTumorEpicenter == null || line.typeOfReportingSource == '7')
            return true
        
        return line.primarySite != 'C159' || line.esophagusAndEgjTumorEpicenter == '9'
    }

    // ID: IFN6702; NAME: Date Regional Lymph Node Dissection, Scope Nodes (NAACCR)
    public boolean ifn6702(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        boolean dateRegionalLNDissectionBlank = line.dateRegionalLNDissectionYear == null && line.dateRegionalLNDissectionMonth == null && line.dateRegionalLNDissectionDay == null
        if (dateRegionalLNDissectionBlank || line.rxSummScopeRegLnSur == null || line.dateOfDiagnosisYear < '2023')
            return true
        
        if (!dateRegionalLNDissectionBlank && !functions.matches(line.rxSummScopeRegLnSur, /^[3-7]$/))
            return false
        
        return true
    }

    // ID: IFN6711; NAME: Grade Post Therapy Path (yp), Surgery Sequence (NAACCR)
    public boolean ifn6711(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if ((line.rxSummSystemicSurSeq == null && line.rxSummSurgRadSeq == null) || line.dateOfDiagnosisYear < '2023' || line.dateOfDiagnosisYear == null
                    || line.gradePostTherapy == '8')
            return true
        
        if (line.rxSummSystemicSurSeq == '0' && line.rxSummSurgRadSeq == '0')
            return line.gradePostTherapy == null
        
        return true
    }

    // ID: IFN6712; NAME: Visceral and Parietal Pleural Invasion, Lung, Surg Prim Site 2023 (SEER)
    public boolean ifn6712(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.schemaId != '00360' || line.visceralParietalPleuralInvasion == null
                    || line.visceralParietalPleuralInvasion == '8' || line.rxSummSurgPrimSite2023 == null || line.typeOfReportingSource == '6' || line.typeOfReportingSource == '7' || line.behaviorCodeIcdO3 == '2')
            return true
        
        Integer dolcYear = functions.asInt(line.dateOfLastContactYear)
        Integer dolcMonth = functions.asInt(line.dateOfLastContactMonth)
        Integer dolcDay = functions.asInt(line.dateOfLastContactDay)
        Integer dxYear = functions.asInt(line.dateOfDiagnosisYear)
        Integer dxMonth = functions.asInt(line.dateOfDiagnosisMonth)
        Integer dxDay = functions.asInt(line.dateOfDiagnosisDay)
        
        if (line.vitalStatus == '0' && (Boolean)((Closure)context.compareDatesWithinMonths).call(dolcYear, dolcMonth, dolcDay, dxYear, dxMonth, dxDay, 5))
            return true
        
        if (functions.matches(line.rxSummSurgPrimSite2023, /^(A|B)(1[2-4]\d|150|000|990)$/))
            return line.visceralParietalPleuralInvasion == '9'
        
        return true
    }

    // ID: IFN6714; NAME: Grade Post Therapy, Systemic Treatment (NAACCR)
    public boolean ifn6714(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if ((line.gradePostTherapy == null && line.gradePostTherapyClin == null) || line.dateOfDiagnosisYear < '2023' || line.dateOfDiagnosisYear == null
                    || (line.phase1RadiationTreatmentModality == null && line.rxSummChemo == null && line.rxSummHormone == null && line.rxSummBrm == null && line.rxSummTransplntEndocr == null
                    && line.rxSummOther == null))
            return true
        
        if (functions.matches(line.phase1RadiationTreatmentModality, /^00|99$/) &&
            functions.matches(line.rxSummChemo, /^00|8[25-8]|99$/) &&
            functions.matches(line.rxSummHormone, /^00|8[25-8]|99$/) &&
            functions.matches(line.rxSummBrm, /^00|8[25-8]|99$/) &&
            functions.matches(line.rxSummTransplntEndocr, /^00|8[25-8]|99$/) &&
            functions.matches(line.rxSummOther, /^[07-9]$/))
            return line.gradePostTherapy == null && line.gradePostTherapyClin == null
        
        return true
    }

    // ID: IFN6715; NAME: Grade Post Therapy, Neoadjuvant Therapy (SEER)
    public boolean ifn6715(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if ((line.gradePostTherapy == null && line.gradePostTherapyClin == null) || line.dateOfDiagnosisYear < '2023' || line.dateOfDiagnosisYear == null
                    || line.neoadjuvantTherapy == null)
            return true
        
        if (line.neoadjuvantTherapy == '0' || line.neoadjuvantTherapy == '3' || line.neoadjuvantTherapy == '9')
            return line.gradePostTherapy == null && line.gradePostTherapyClin == null
        
        return true
    }

    // ID: IFN6734; NAME: Clinical Margin Width, Date DX (NAACCR)
    public boolean ifn6734(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2023')
            return line.clinicalMarginWidth == null
        
        return line.clinicalMarginWidth == null || functions.matches(line.clinicalMarginWidth, /^XX\.[189]|\d\.\d$/)
    }

    // ID: IFN6735; NAME: Clinical Margin Width, Schema ID, Required (NAACCR)
    public boolean ifn6735(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        
        return line.schemaId != '00470' || (line.clinicalMarginWidth != null && line.clinicalMarginWidth != 'XX.8')
    }

    // ID: IFN6736; NAME: Clinical Margin Width, Surg Prim Site 2023 (NAACCR)
    public boolean ifn6736(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.schemaId != '00470' || line.clinicalMarginWidth == null
                     || line.rxSummSurgPrimSite2023 == null || line.rxSummSurgPrimSite2023 == 'B600' || line.typeOfReportingSource == '7')
            return true
        
        if (functions.matches(line.rxSummSurgPrimSite2023, /^B([0-2]\d\d|3[0-1]\d|320|900|990)$/))
            return line.clinicalMarginWidth == 'XX.9'
        
        if (functions.matches(line.clinicalMarginWidth, /^(0\.[1-9]|[1-9]\.\d|XX\.1)$/))
            return functions.matches(line.rxSummSurgPrimSite2023, /^B(5[0-3]\d|540)$/)
        
        return true
    }

    // ID: IFN6737; NAME: LN Head and Neck Levels I-III, Melanoma Head/Neck, Behavior (NAACCR)
    public boolean ifn6737(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.schemaId == null || line.schemaId != '00140'
                    || line.lnHeadAndNeckLevels1To3 == null || line.lnHeadAndNeckLevels1To3 == '8' || line.behaviorCodeIcdO3 == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.behaviorCodeIcdO3 == '2')
            return line.lnHeadAndNeckLevels1To3 == '0'
        
        return true
    }

    // ID: IFN6738; NAME: LN Head and Neck Levels IV-V, Melanoma Head/Neck, Behavior (NAACCR)
    public boolean ifn6738(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.schemaId == null || line.schemaId != '00140'
                    || line.lnHeadAndNeckLevels4To5 == null || line.lnHeadAndNeckLevels4To5 == '8' || line.behaviorCodeIcdO3 == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.behaviorCodeIcdO3 == '2')
            return line.lnHeadAndNeckLevels4To5 == '0'
        
        return true
    }

    // ID: IFN6739; NAME: LN Head and Neck Levels VI-VII, Melanoma Head/Neck, Behavior (NAACCR)
    public boolean ifn6739(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.schemaId == null || line.schemaId != '00140'
                    || line.lnHeadAndNeckLevels6To7 == null || line.lnHeadAndNeckLevels6To7 == '8' || line.behaviorCodeIcdO3 == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.behaviorCodeIcdO3 == '2')
            return line.lnHeadAndNeckLevels6To7 == '0'
        
        return true
    }

    // ID: IFN6740; NAME: LN Head and Neck Other, Melanoma Head/Neck, Behavior (NAACCR)
    public boolean ifn6740(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.schemaId == null || line.schemaId != '00140'
                    || line.lnHeadAndNeckOther == null || line.lnHeadAndNeckOther == '8' || line.behaviorCodeIcdO3 == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.behaviorCodeIcdO3 == '2')
            return line.lnHeadAndNeckOther == '0'
        
        return true
    }

    // ID: IFN6741; NAME: High Risk Histologic Features, Carcinoma Skin, Behavior (NAACCR)
    public boolean ifn6741(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear < '2023' || line.dateOfDiagnosisYear == null || line.schemaId != '00150' || line.schemaId == null
                    || line.highRiskHistologicFeatures == null || line.highRiskHistologicFeatures == '8' || line.behaviorCodeIcdO3 == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.behaviorCodeIcdO3 == '2')
            return line.highRiskHistologicFeatures == '0'
        
        return true
    }

    // ID: IFN6742; NAME: Perineural Invasion, Behavior (NAACCR)
    public boolean ifn6742(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear < '2023' || line.dateOfDiagnosisYear == null || !['00150','00200','00640','00690'].contains(line.schemaId) || line.schemaId == null
                    || line.perineuralInvasion == null || line.perineuralInvasion == '8' || line.behaviorCodeIcdO3 == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.behaviorCodeIcdO3 == '2')
            return line.perineuralInvasion == '0'
        
        return true
    }

    // ID: IFN6743; NAME: Residual Tumor Volume Post Cytoreduction, Gynecologic, Behavior (NAACCR)
    public boolean ifn6743(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear < '2023' || line.dateOfDiagnosisYear == null || !['00551','00552','00553'].contains(line.schemaId) || line.schemaId == null
                    || line.residualTumVolPostCytoreduction == null || line.residualTumVolPostCytoreduction == '98' || line.behaviorCodeIcdO3 == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.behaviorCodeIcdO3 == '2')
            return line.residualTumVolPostCytoreduction == '97'
        
        return true
    }

    // ID: IFN6746; NAME: Autopsy Only, RX 2023, Primary Site (NPCR)
    public boolean ifn6746(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.schemaId == null || line.typeOfReportingSource != '6')
            return true
        
        boolean primarySitesFor2A = functions.matches(line.primarySite, /^C(42[0134]|589|7([0127]\d|5[123]|6[1-8])|809)$/)
        
        if (line.rxSummSurgPrimSite2023 != 'A000' && line.rxSummSurgPrimSite2023 != 'B000' && line.rxSummSurgPrimSite2023 != 'A980')
            return false
        
        if (primarySitesFor2A) {
            if (line.rxSummScopeRegLnSur != '9')
                return false
        }
        else {
            if (line.rxSummScopeRegLnSur != '0')
                 return false
        }
        
        if (line.rxSummSurgOthRegDis != '0')
            return false
        
        if (line.reasonForNoSurgery != '1' && line.reasonForNoSurgery != '9')
            return false
        
        if (line.rxSummBrm != '00')
            return false
        
        if (line.rxSummChemo != '00')
            return false
        
        if (line.rxSummHormone != '00')
            return false
        
        if (line.rxSummOther != '0')
            return false
        
        if (line.rxSummTransplntEndocr != '00')
            return false
        
        if (line.phase1RadiationTreatmentModality != '00')
            return false
        
        if (line.rxSummSurgRadSeq != '0')
            return false
        
        if (line.rxSummSystemicSurSeq != '0')
            return false
        
        return true
    }

    // ID: IFN6748; NAME: Circumferential Resection Margin (CRM), Colon, Surg Prim Site 2023 (NAACCR)
    public boolean ifn6748(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.schemaId != '00200' || line.behaviorCodeIcdO3 == '2'
                    || line.typeOfReportingSource == '7')
            return true
        
        if (line.circumferentialResectionMargin == null || line.circumferentialResectionMargin == 'XX.8')
            return true
        
        boolean aCodesCondition = functions.matches(line.rxSummSurgPrimSite2023, /^A000|A1[0-1]\d|A120|A2[0-8]\d|A290$/)
        boolean bCodesCondition = functions.matches(line.rxSummSurgPrimSite2023, /^B[01]00|B2[0-8]\d|B29[01]$/)
        if (functions.matches(line.primarySite, /^C1(8[02-9]|99)$/) && (aCodesCondition || bCodesCondition) && line.circumferentialResectionMargin != 'XX.7')
            return false
        else if (line.primarySite == 'C209' && functions.matches(line.rxSummSurgPrimSite2023, /^A000|A1[0-1]\d|A120|A2[0-5]\d|A260|A280$/) && line.circumferentialResectionMargin != 'XX.7')
            return false
        
        if (functions.matches(line.rxSummSurgPrimSite2023, /^[AB]([3-7]\d\d|800)$/) && line.circumferentialResectionMargin == 'XX.7')
            return false
        
        if ((line.rxSummSurgPrimSite2023 == 'A990' || line.rxSummSurgPrimSite2023 == 'B990') && line.circumferentialResectionMargin != 'XX.9')
            return false
        
        return true
    }

    // ID: IFN6749; NAME: Date Initial RX SEER, Ca Dir RX 2023 (SEER)
    public boolean ifn6749(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023')
            return true
        
        boolean rxSummTreatmentStatusYes = line.rxSummTreatmentStatus == '2' && line.dateOfDiagnosisYear >= '2024'
        boolean rxSummSurgPrimSite2023Yes = functions.matches(line.rxSummSurgPrimSite2023, /^(A|B)([1-8]\d\d|900)$/)
        
        boolean scopeSiteCondition = functions.matches(line.primarySite, /^C(42[0134]|589|7[0127]\d|75[1-3]|76[1-8]|809)$/)
        boolean rxSummSurgScopeRegLnSurYes = functions.matches(line.rxSummScopeRegLnSur, /^[2-7]$/) && !scopeSiteCondition
        
        boolean rxSummSurgOthRegDisYes = functions.matches(line.rxSummSurgOthRegDis, /^[1-5]$/)
        boolean phase1RadiationTreatmentModalityYes = functions.matches(line.phase1RadiationTreatmentModality, /^0[1-9]|1[0-6]|98$/)
        boolean rxSummSurgRadSeqYes = functions.matches(line.rxSummSurgRadSeq, /^[2-9]$/)
        boolean rxSummBrmYes = line.rxSummBrm == '01'
        boolean rxSummChemoYes = functions.matches(line.rxSummChemo, /^0[123]$/)
        boolean rxSummHormoneYes = line.rxSummHormone == '01'
        boolean rxSummTransplntEndocrYes = functions.matches(line.rxSummTransplntEndocr, /^1[012]|[234]0$/)
        boolean rxSummOtherYes = functions.matches(line.rxSummOther, /^[1236]$/)
        
        boolean atLeastOneFieldYes = rxSummTreatmentStatusYes || rxSummSurgPrimSite2023Yes || rxSummSurgScopeRegLnSurYes || rxSummSurgOthRegDisYes || phase1RadiationTreatmentModalityYes ||
            rxSummSurgRadSeqYes || rxSummBrmYes || rxSummChemoYes || rxSummHormoneYes || rxSummTransplntEndocrYes || rxSummOtherYes
        
        return line.dateInitialRxSeerYear == null || atLeastOneFieldYes
    }

    // ID: IFN6751; NAME: EOD Primary Tumor, Retinoblastoma, RX Summ--Surg Prim Site 2023 (SEER)
    public boolean ifn6751(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.eodPrimaryTumor == null || line.rxSummSurgPrimSite2023 == null)
            return true
        if (line.typeOfReportingSource == '7' || line.schemaId == null || line.schemaId != '00680')
            return true
        
        return !functions.matches(line.eodPrimaryTumor, /^[12]75|[2347]50|[45]00$/) || line.rxSummSurgPrimSite2023 == 'A410'
    }

    // ID: IFN6752; NAME: EOD Primary Tumor, Testis, RX Summ--Surg Prim Site 2023 (SEER)
    public boolean ifn6752(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.eodPrimaryTumor == null || line.rxSummSurgPrimSite2023 == null)
            return true
        if (line.typeOfReportingSource == '7' || line.schemaId == null || line.schemaId != '00590')
            return true
        
        return !functions.matches(line.eodPrimaryTumor, /^[1-5]00|150$/) || functions.matches(line.rxSummSurgPrimSite2023, /^A[348]00$/)
    }

    // ID: IFN6753; NAME: EOD Prostate Pathologic Extension, RX Summ--Surg Prim Site 2023 (SEER)
    public boolean ifn6753(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.schemaId == null ||
            line.schemaId != '00580' || line.prostatePathologicalExtension == null || line.rxSummSurgPrimSite2023 == null || line.typeOfReportingSource == '6' || line.typeOfReportingSource == '7')
            return true
        
        Integer dolcYear = functions.asInt(line.dateOfLastContactYear)
        Integer dolcMonth = functions.asInt(line.dateOfLastContactMonth)
        Integer dolcDay = functions.asInt(line.dateOfLastContactDay)
        Integer dxYear = functions.asInt(line.dateOfDiagnosisYear)
        Integer dxMonth = functions.asInt(line.dateOfDiagnosisMonth)
        Integer dxDay = functions.asInt(line.dateOfDiagnosisDay)
        
        if (line.vitalStatus == '0' && (Boolean)((Closure)context.compareDatesWithinMonths).call(dolcYear, dolcMonth, dolcDay, dxYear, dxMonth, dxDay, 5))
            return true
        
        if (line.rxSummSurgPrimSite2023 == 'A900' || line.rxSummSurgPrimSite2023 == 'A990')
            return line.prostatePathologicalExtension == '900' || line.prostatePathologicalExtension == '950' || line.prostatePathologicalExtension == '999'
        
        if (functions.matches(line.rxSummSurgPrimSite2023, /^A[5-7]\d\d|A800$/))
                return functions.matches(line.prostatePathologicalExtension, /^[0-7]\d\d|800|999$/)
        
        if (functions.matches(line.rxSummSurgPrimSite2023, /^A[012]\d\d|A300$/))
                return line.prostatePathologicalExtension == '900' || line.prostatePathologicalExtension == '950'
        
        if (line.prostatePathologicalExtension == '900' || line.prostatePathologicalExtension == '950')
                return functions.matches(line.rxSummSurgPrimSite2023, /^A[012]\d\d|A300|A900|A990$/)
        
        return true
    }

    // ID: IFN6757; NAME: Invasion Beyond Capsule, Kidney, Surgery 2023 (SEER)
    public boolean ifn6757(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        
                Integer dolcYear = functions.asInt(line.dateOfLastContactYear)
                Integer dolcMonth = functions.asInt(line.dateOfLastContactMonth)
                Integer dolcDay = functions.asInt(line.dateOfLastContactDay)
                Integer dxYear = functions.asInt(line.dateOfDiagnosisYear)
                Integer dxMonth = functions.asInt(line.dateOfDiagnosisMonth)
                Integer dxDay = functions.asInt(line.dateOfDiagnosisDay)
        
            if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.rxSummSurgPrimSite2023 == null || line.schemaId != '00600' || line.typeOfReportingSource == '6' || line.typeOfReportingSource == '7' ||
            (line.vitalStatus == '0' && (Boolean)((Closure)context.compareDatesWithinMonths).call(dolcYear, dolcMonth, dolcDay, dxYear, dxMonth, dxDay, 5)))
            return true
        
        if (line.invasionBeyondCapsule == null || line.invasionBeyondCapsule == '8')
            return true
        
        if (functions.matches(line.rxSummSurgPrimSite2023, /^A000|A1[0-4]\d|A150|A2[0-6]\d|A270|A990$/))
            return line.invasionBeyondCapsule == '9'
        
        return true
    }

    // ID: IFN6759; NAME: Ipsilateral Adrenal Gland Involvement, Kidney, Surgery 2023 (SEER)
    public boolean ifn6759(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.rxSummSurgPrimSite2023 == null || line.schemaId != '00600' ||
                    line.typeOfReportingSource == '6' || line.typeOfReportingSource == '7')
            return true
        
        Integer dolcYear = functions.asInt(line.dateOfLastContactYear)
        Integer dolcMonth = functions.asInt(line.dateOfLastContactMonth)
        Integer dolcDay = functions.asInt(line.dateOfLastContactDay)
        Integer dxYear = functions.asInt(line.dateOfDiagnosisYear)
        Integer dxMonth = functions.asInt(line.dateOfDiagnosisMonth)
        Integer dxDay = functions.asInt(line.dateOfDiagnosisDay)
        
        if (line.vitalStatus == '0' && (Boolean)((Closure)context.compareDatesWithinMonths).call(dolcYear, dolcMonth, dolcDay, dxYear, dxMonth, dxDay, 5))
            return true
        
        if (line.ipsilateralAdrenalGlandInvolve == null || line.ipsilateralAdrenalGlandInvolve == '8')
            return true
        
        if (functions.matches(line.rxSummSurgPrimSite2023, /^A000|A1[0-4]\d|A150|A2[0-6]\d|A270$/) && (line.rxSummSurgOthRegDis == '0' || line.rxSummSurgOthRegDis == '3'))
            return line.ipsilateralAdrenalGlandInvolve == '9'
        
        if (line.rxSummSurgPrimSite2023 == 'A990' && ['0','3','9'].contains(line.rxSummSurgOthRegDis))
            return line.ipsilateralAdrenalGlandInvolve == '9'
        
        return true
    }

    // ID: IFN6762; NAME: Major Vein Involvement, Kidney, Surgery 2023 (SEER)
    public boolean ifn6762(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.rxSummSurgPrimSite2023 == null || line.schemaId != '00600' ||
                    line.typeOfReportingSource == '6' || line.typeOfReportingSource == '7')
            return true
        
        Integer dolcYear = functions.asInt(line.dateOfLastContactYear)
        Integer dolcMonth = functions.asInt(line.dateOfLastContactMonth)
        Integer dolcDay = functions.asInt(line.dateOfLastContactDay)
        Integer dxYear = functions.asInt(line.dateOfDiagnosisYear)
        Integer dxMonth = functions.asInt(line.dateOfDiagnosisMonth)
        Integer dxDay = functions.asInt(line.dateOfDiagnosisDay)
        
        if (line.vitalStatus == '0' && (Boolean)((Closure)context.compareDatesWithinMonths).call(dolcYear, dolcMonth, dolcDay, dxYear, dxMonth, dxDay, 5))
            return true
        
        String majorVeinInvolvement = line.majorVeinInvolvement
        if (majorVeinInvolvement == null || majorVeinInvolvement == '8')
            return true
        
        if (functions.matches(line.rxSummSurgPrimSite2023, /^A000|A1[0-4]\d|A150|A2[0-6]\d|A270|A990$/))
            return majorVeinInvolvement == '9'
        
        return true
    }

    // ID: IFN6763; NAME: Reason for No Surgery, Surg Prim Site 2023, Primary Site (NAACCR)
    public boolean ifn6763(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.rxSummSurgPrimSite2023 == null || line.reasonForNoSurgery == null)
            return true
        
        if (line.typeOfReportingSource == '7' || line.typeOfReportingSource == '6')
            return true
        
        if (functions.matches(line.primarySite, /^C(42[0134]|76[0-8]|809)$/))
            return line.reasonForNoSurgery == '1'
        else if ((line.rxSummSurgPrimSite2023 == 'A000' || line.rxSummSurgPrimSite2023 == 'B000') && !functions.matches(line.reasonForNoSurgery, /^[1-9]$/))
            return false
        else if (functions.matches(line.rxSummSurgPrimSite2023, /^A[1-8]\d\d|A900|B[1-8]\d\d|B900$/) && line.reasonForNoSurgery != '0')
            return false
        else if (line.rxSummSurgPrimSite2023 == 'A980' && line.reasonForNoSurgery != '1')
            return false
        else if ((line.rxSummSurgPrimSite2023 == 'A990' || line.rxSummSurgPrimSite2023 == 'B990') && !['8','9'].contains(line.reasonForNoSurgery))
            return false
        return true
    }

    // ID: IFN6764; NAME: Residual Tumor Volume Post Cytoreduction, Gynecologic, Surg Prim Site 2023 (NAACCR)
    public boolean ifn6764(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || !functions.matches(line.schemaId, /^0055[123]$/)
                    || line.rxSummSurgPrimSite2023 == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.residualTumVolPostCytoreduction == null || line.residualTumVolPostCytoreduction == '98')
            return true
        
        boolean schemaConditions = (functions.matches(line.rxSummSurgPrimSite2023, /^A[1-4]\d\d|A5[0-6]\d|A570$/) && line.schemaId == '00551') ||
                                   (functions.matches(line.rxSummSurgPrimSite2023, /^A[1-3]\d\d|A40\d|A410$/) && (line.schemaId == '00552' || line.schemaId == '00553'))
        if (line.rxSummSurgPrimSite2023 == 'A000' || schemaConditions)
            return line.residualTumVolPostCytoreduction == '97'
        
        if (line.rxSummSurgPrimSite2023 == 'A990')
            return line.residualTumVolPostCytoreduction == '99'
        
        return true
    }

    // ID: IFN6769; NAME: RX Summ--Surg Prim Site 2023 (COC)
    public boolean ifn6769(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2023')
            return line.rxSummSurgPrimSite2023 == null
        
        return functions.matches(line.rxSummSurgPrimSite2023, /^[AB]([1-8]\d\d|000|900|990)|A980$/)
    }

    // ID: IFN6771; NAME: RX Summ--Surg Prim Site 2023, DateDX, RPTSRC (SEER)
    public boolean ifn6771(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        if (line.dateOfDiagnosisYear < '2023')
            return line.rxSummSurgPrimSite2023 == null
        
        if (line.typeOfReportingSource == '6')
            return line.rxSummSurgPrimSite2023 == 'A980' || line.rxSummSurgPrimSite2023 == 'A000' || line.rxSummSurgPrimSite2023 == 'B000'
        if (line.typeOfReportingSource == '7')
            return line.rxSummSurgPrimSite2023 == 'A980' || line.rxSummSurgPrimSite2023 == 'A990' || line.rxSummSurgPrimSite2023 == 'B990'
        
        return line.rxSummSurgPrimSite2023 != null
    }

    // ID: IFN6772; NAME: RX Summ--Surg Prim Site 2023, Diag Conf (SEER)
    public boolean ifn6772(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.overRideSurgDxconf == '1' || line.rxSummSurgPrimSite2023 == null || line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023')
                        return true
        
        if (functions.matches(line.rxSummSurgPrimSite2023, /^(A[2-8]\d\d|A900|B[2-8]\d\d|B900)$/) && !(line.diagnosticConfirmation ==~/^[1234]$/))
            return false
        
        return true
    }

    // ID: IFN6773; NAME: RX Summ--Surg Prim Site 2023, Lymphoma (COC)
    public boolean ifn6773(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (!functions.matches(line.primarySite, /^C77\d$/) || line.rxSummSurgPrimSite2023 == null || line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023'
                    || line.ajccTnmPathStageGroup == null || line.ajccTnmPathStageGroup == '88')
                        return true
        
        if (!['A600','A610','A620'].contains(line.rxSummSurgPrimSite2023))
            return line.ajccTnmPathStageGroup == '99'
        
        return true
    }

    // ID: IFN6775; NAME: RX Summ--Surg Prim Site 2023, Primary Site (SEER)
    public boolean ifn6775(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.primarySite == null || line.rxSummSurgPrimSite2023 == null)
            return true
        
        if (line.typeOfReportingSource == '7') {
            if (line.rxSummSurgPrimSite2023 == 'B990' && functions.matches(line.primarySite, /^C44\d$/))
                return true
            if (line.rxSummSurgPrimSite2023 == 'A990' && !functions.matches(line.primarySite, /^C44\d$/))
                return true
        }
        
        if (functions.matches(line.primarySite, /^C(42[0134]|76[0-8]|809)$/))
            return line.rxSummSurgPrimSite2023 == 'A980'
        
        Integer siteInt = functions.asInt(line.primarySite.substring(1, 4))
        Map schemaIdMap = (Map)context.IFN6775_Primary_Site_GroupCode_Table
        Integer groupCode = schemaIdMap.get(siteInt)
        
        if (groupCode != null) {
            if (groupCode == 30 && line.rxSummSurgPrimSite2023 == 'A410')
                return line.primarySite.startsWith('C69')
        
            if (groupCode == 6 && line.rxSummSurgPrimSite2023 == 'B330' && line.dateOfDiagnosisYear >= '2024')
                return line.primarySite == 'C181'
        
            if (line.rxSummSurgPrimSite2023.charAt(0) == 'A' && groupCode != 17) {
                if (!([6, 11, 13, 18, 27].contains(groupCode) && line.dateOfDiagnosisYear >= '2024')) {
                    Map> groupCodeMap = (Map>)context.IFN6775_GroupCode_Table_23A
                    if (groupCodeMap.containsKey(groupCode))
                        return groupCodeMap.get(groupCode).contains(line.rxSummSurgPrimSite2023)
                }
            }
            else if (line.rxSummSurgPrimSite2023.charAt(0) == 'B' && (groupCode == 17 || line.dateOfDiagnosisYear >= '2024')) {
                Map> groupCodeMap = (Map>)context.IFN6775_GroupCode_Table_23B
                if (groupCodeMap.containsKey(groupCode))
                    return groupCodeMap.get(groupCode).contains(line.rxSummSurgPrimSite2023)
            }
        }
        
        return false
    }

    // ID: IFN6776; NAME: RX Summ--Surgical Margins, Surg Prim Site 2023, Primary Site (NAACCR)
    public boolean ifn6776(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
         if(line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.primarySite == null)
            return true
        if (line.rxSummSurgicalMargins == null || line.rxSummSurgPrimSite2023 == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.rxSummSurgPrimSite2023 == 'A980' && line.rxSummSurgicalMargins != '9')
            return false
        
        if (functions.matches(line.primarySite, /^C(42[0134]|76[0-8]|77\d|809)$/)) {
            if (line.rxSummSurgicalMargins != '9')
                return false
        }
        else {
            if ((line.rxSummSurgPrimSite2023 == 'A000' || line.rxSummSurgPrimSite2023 == 'B000') && line.rxSummSurgicalMargins != '8')
                return false
            if (line.rxSummSurgicalMargins == '8' && !(line.rxSummSurgPrimSite2023 == 'A000' || line.rxSummSurgPrimSite2023 == 'B000'))
                return false
        }
        
        return true 
    }

    // ID: IFN6778; NAME: RX Summ--Treatm Stat, Treatment 2023 (NAACCR)
    public boolean ifn6778(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.rxSummTreatmentStatus == null)
            return true
        
        
        boolean isSurgPrimSiteGiven = functions.matches(line.rxSummSurgPrimSite2023, /^[AB]([1-8]\d\d|900)$/)
        boolean isSurgOthRegDisGiven = functions.matches(line.rxSummSurgOthRegDis, /^[1-5]$/)
        boolean isChemoGiven = functions.matches(line.rxSummChemo, /^0[1-3]$/)
        boolean isTransplantGiven = functions.matches(line.rxSummTransplntEndocr, /^[1-3]\d|40$/)
        boolean isSummOtherGiven = functions.matches(line.rxSummOther, /^[1236]$/)
        boolean isTreatmentGivenNoScope = isSurgPrimSiteGiven || isSurgOthRegDisGiven || line.rxSummBrm == '01' || isChemoGiven || line.rxSummHormone == '01' || isTransplantGiven || isSummOtherGiven
            || line.reasonForNoRadiation == '0'
        
        if (isTreatmentGivenNoScope)
            return line.rxSummTreatmentStatus == '1'
        
        if (line.rxSummTreatmentStatus == '1') {
            return isTreatmentGivenNoScope || functions.matches(line.rxSummScopeRegLnSur, /^[2-7]$/)
        }
        else if (line.rxSummTreatmentStatus == '0' || line.rxSummTreatmentStatus == '2') {
            return ['A000','A980','B000'].contains(line.rxSummSurgPrimSite2023) &&
                    functions.matches(line.rxSummScopeRegLnSur, /^0|[1-7]|9$/) &&
                    line.rxSummSurgOthRegDis == '0' &&
                    functions.matches(line.rxSummBrm, /^00|8[0-8]$/) &&
                    functions.matches(line.rxSummChemo, /^00|8[0-8]$/) &&
                    functions.matches(line.rxSummHormone, /^00|8[0-8]$/) &&
                    functions.matches(line.rxSummTransplntEndocr, /^00|8[0-8]$/) &&
                    functions.matches(line.rxSummOther, /^[078]$/) &&
                    (functions.matches(line.reasonForNoRadiation, /^[125-9]$/) || line.phase1RadiationTreatmentModality == '00')
        }
        else if (line.rxSummTreatmentStatus == '9') {
            if (line.rxSummSurgPrimSite2023 == 'A990' || line.rxSummSurgPrimSite2023 == 'B990' ||
                    line.rxSummSurgOthRegDis == '9' || line.rxSummBrm == '99' || line.rxSummChemo == '99' || line.rxSummHormone == '99' ||
                    line.rxSummTransplntEndocr == '99' || line.rxSummOther == '9' || functions.matches(line.reasonForNoRadiation, /^[89]$/) || line.phase1RadiationTreatmentModality == '99') {
                return functions.matches(line.rxSummSurgPrimSite2023, /^[AB](000|990)|A980$/) &&
                    functions.matches(line.rxSummScopeRegLnSur, /^[0-7]|9$/) &&
                    functions.matches(line.rxSummSurgOthRegDis, /^[09]$/) &&
                    functions.matches(line.rxSummBrm, /^00|8[0-8]|99$/) &&
                    functions.matches(line.rxSummChemo, /^00|8[0-8]|99$/) &&
                    functions.matches(line.rxSummHormone, /^00|8[0-8]|99$/) &&
                    functions.matches(line.rxSummTransplntEndocr, /^00|8[0-8]|99$/) &&
                    functions.matches(line.rxSummOther, /^[0789]$/) &&
                    (functions.matches(line.reasonForNoRadiation, /^[89]$/) || functions.matches(line.phase1RadiationTreatmentModality, /^00|99$/))
            }
            else
                return false
        }
        
        return true
    }

    // ID: IFN6780; NAME: Surgery 2023, Phase I Rad, Surg/Rad Seq (SEER)
    public boolean ifn6780(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.rxSummSurgPrimSite2023 == null || line.rxSummScopeRegLnSur == null || line.rxSummSurgOthRegDis == null)
            return true
        
        boolean surgeryPerformed = functions.matches(line.rxSummSurgPrimSite2023, /^[AB]([1-8]\d\d|900)$/) || functions.matches(line.rxSummScopeRegLnSur, /^[2-7]$/)
            || functions.matches(line.rxSummSurgOthRegDis, /^[1-5]$/)
        if (surgeryPerformed && functions.matches(line.phase1RadiationTreatmentModality, /^0[1-9]|1[0-6]|98$/))
            return functions.matches(line.rxSummSurgRadSeq, /^[2-79]$/)
        
        boolean scopeNotPerformed = functions.matches(line.rxSummScopeRegLnSur, /^[01]$/) || (line.rxSummScopeRegLnSur == '9' && (functions.matches(line.primarySite, /^C(42[0134]|589|7[0127]\d|75[123]|76[1-8]|809)$/)))
        boolean surgeryNotPerformed = (functions.matches(line.rxSummSurgPrimSite2023, /^[AB](000|990)|A980$/)) && scopeNotPerformed && line.rxSummSurgOthRegDis == '0'
        if (surgeryNotPerformed || line.phase1RadiationTreatmentModality == '00' || line.phase1RadiationTreatmentModality == '99')
            return line.rxSummSurgRadSeq == '0'
        
        return true
    }

    // ID: IFN6782; NAME: Surgery 2023, Reason for No Surg (SEER)
    public boolean ifn6782(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        
                    if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || ['6','7'].contains(line.typeOfReportingSource))
            return true
        
        if (functions.matches(line.rxSummSurgPrimSite2023, /^[AB](000)|A980$/))
            return functions.matches(line.reasonForNoSurgery, /^[125-8]$/)
        if (functions.matches(line.rxSummSurgPrimSite2023, /^[AB]([1-8]\d\d|900)$/))
            return line.reasonForNoSurgery == '0'
        if (line.rxSummSurgPrimSite2023 == 'A990' || line.rxSummSurgPrimSite2023 == 'B990')
            return line.reasonForNoSurgery != '0'
        
        return true
    }

    // ID: IFN6784; NAME: Surgery 2023, RX Date Surgery, Primary Site (NAACCR)
    public boolean ifn6784(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.schemaId == null)
            return true
        if (line.rxSummSurgPrimSite2023 == null || line.rxSummScopeRegLnSur == null || line.rxSummSurgOthRegDis == null)
            return true
        
        boolean rxDateIsBlank = line.rxDateSurgeryYear == null && line.rxDateSurgeryMonth == null && line.rxDateSurgeryDay == null
        boolean siteCondition = functions.matches(line.primarySite, /^C(42[0134]|589|7[0127]\d|75[1-3]|76[1-8]|809)$/)
        
        //condition 1
        boolean rxSummSurgPrimSiteCondition = line.rxSummSurgPrimSite2023 == 'A000' || line.rxSummSurgPrimSite2023 == 'A980' || line.rxSummSurgPrimSite2023 == 'B000'
        boolean rxSummScopeRegLnSurCondition = (line.rxSummScopeRegLnSur == '9' && siteCondition) || line.rxSummScopeRegLnSur == '1' || line.rxSummScopeRegLnSur == '0'
        
        if (rxSummSurgPrimSiteCondition && rxSummScopeRegLnSurCondition && line.rxSummSurgOthRegDis == '0')
            return rxDateIsBlank
        
        //condition 2
        if (!rxDateIsBlank)
            return functions.matches(line.rxSummSurgPrimSite2023, /^[AB]([1-8]\d\d|900)$/) || functions.matches(line.rxSummScopeRegLnSur, /^[2-7]$/) || functions.matches(line.rxSummSurgOthRegDis, /^[1-5]$/)
        
        return true
    }

    // ID: IFN6785; NAME: Systemic RX, Surgery 2023, Systemic/Sur Seq (COC)
    public boolean ifn6785(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.rxSummSurgPrimSite2023 == null || line.rxSummScopeRegLnSur == null || line.rxSummSurgOthRegDis == null || line.rxSummBrm == null || line.rxSummChemo == null
                    || line.rxSummHormone == null || line.rxSummTransplntEndocr == null || line.rxSummSystemicSurSeq == null || line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023')
            return true
        
        boolean surgeryPerformed = functions.matches(line.rxSummSurgPrimSite2023, /^[AB]([1-8]\d\d|900)$/) || functions.matches(line.rxSummScopeRegLnSur, /^[2-7]$/) || functions.matches(line.rxSummSurgOthRegDis, /^[1-5]$/)
        boolean therapyPerformed = line.rxSummBrm == '01' || functions.matches(line.rxSummChemo, /^0[1-3]$/) || line.rxSummHormone == '01' || functions.matches(line.rxSummTransplntEndocr, /(^[1-3]\d|40$)/)
        
        if (surgeryPerformed && therapyPerformed)
            return functions.matches(line.rxSummSystemicSurSeq, /^[2-7]|9$/)
        
        boolean primarySiteCondition = functions.matches(line.primarySite, /(^C(42[0134]|589|7[0127]\d|75[123]|76[1-8]|809)$)/)
        boolean scopeCondition = line.rxSummScopeRegLnSur == '0' || line.rxSummScopeRegLnSur == '1' || (line.rxSummScopeRegLnSur == '9' && primarySiteCondition)
        boolean surgeryNotPerformed = functions.matches(line.rxSummSurgPrimSite2023, /(^[AB](000|990)$)/) && scopeCondition && line.rxSummSurgOthRegDis == '0'
        boolean surgeryAlsoNotPerformed = line.rxSummSurgPrimSite2023 == 'A980' && line.rxSummScopeRegLnSur == '9' && line.rxSummSurgOthRegDis == '0'
        boolean noTherapy = functions.matches(line.rxSummBrm, /(^00|8[2-8]|99$)/) &&
           functions.matches(line.rxSummChemo, /(^00|8[2-8]|99$)/) &&
           functions.matches(line.rxSummHormone, /(^00|8[2-8]|99$)/) &&
           functions.matches(line.rxSummTransplntEndocr, /(^00|8[2-8]|99$)/)
        
        if (surgeryNotPerformed || surgeryAlsoNotPerformed || noTherapy)
            return line.rxSummSystemicSurSeq == '0'
        
        return true
    }

    // ID: IFN6786; NAME: Serum Markers, Testis, Post-Orchiectomy 2023, Lab Value (NAACCR)
    public boolean ifn6786(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.rxSummSurgPrimSite2023 == null || line.schemaId != '00590'
                    || line.typeOfReportingSource == '7')
            return true
        if ((line.afpPostOrchiectomyLabValue == null || line.afpPostOrchiectomyLabValue == 'XXXXX.8') && (line.hcgPostOrchiectomyLabValue == null || line.hcgPostOrchiectomyLabValue == 'XXXXX.8'))
            return true
        
        if (['A000','A120','A200','A990'].contains(line.rxSummSurgPrimSite2023))
            return line.afpPostOrchiectomyLabValue == 'XXXXX.9' && line.hcgPostOrchiectomyLabValue == 'XXXXX.9'
        
        return true
    }

    // ID: IFN6787; NAME: Serum Markers, Testis, Post-Orchiectomy 2023, Range (NAACCR)
    public boolean ifn6787(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.schemaId != '00590' || line.rxSummSurgPrimSite2023 == null || line.typeOfReportingSource == '7')
            return true
        
        if ((line.afpPostOrchiectomyRange == null || line.afpPostOrchiectomyRange == '8') && (line.hcgPostOrchiectomyRange == null || line.hcgPostOrchiectomyRange == '8') &&
            (line.ldhPostOrchiectomyRange == null || line.ldhPostOrchiectomyRange == '8') && line.sCategoryPathological == null)
            return true
        
        if (['A000','A120','A200','A990'].contains(line.rxSummSurgPrimSite2023))
            return line.afpPostOrchiectomyRange == '9' && line.hcgPostOrchiectomyRange == '9' && line.ldhPostOrchiectomyRange == '9' && line.sCategoryPathological == '9'
        
        return true
    }

    // ID: IFN6789; NAME: Tumor Deposits, Colorectal, Surgery 2023 (SEER)
    public boolean ifn6789(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.rxSummSurgPrimSite2023 == null
                    || line.schemaId != '00200' || ['6','7'].contains(line.typeOfReportingSource))
            return true
        
        Integer dolcYear = functions.asInt(line.dateOfLastContactYear)
        Integer dolcMonth = functions.asInt(line.dateOfLastContactMonth)
        Integer dolcDay = functions.asInt(line.dateOfLastContactDay)
        Integer dxYear = functions.asInt(line.dateOfDiagnosisYear)
        Integer dxMonth = functions.asInt(line.dateOfDiagnosisMonth)
        Integer dxDay = functions.asInt(line.dateOfDiagnosisDay)
        
        if (line.vitalStatus == '0' && (Boolean)((Closure)context.compareDatesWithinMonths).call(dolcYear, dolcMonth, dolcDay, dxYear, dxMonth, dxDay, 5))
            return true
        
        String tumorDeposits = line.tumorDeposits
        if (tumorDeposits == null || tumorDeposits == 'X8')
            return true
        
        if (functions.matches(line.rxSummSurgPrimSite2023, /^[AB]([01]\d\d|2[0-8]\d|290|990)$/))
            return tumorDeposits == 'X9'
        
        return true
    }

    // ID: IFN6790; NAME: Histologic Subtype, Date DX (NAACCR)
    public boolean ifn6790(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2023' && line.histologicSubtype != null)
            return false
        
        return line.histologicSubtype == null || functions.matches(line.histologicSubtype, /^[0-4]$/)
    }

    // ID: IFN6791; NAME: Histologic Subtype, Schema ID, Required (NAACCR)
    public boolean ifn6791(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.schemaId == '09190')
            return line.histologicSubtype != null
        
        return true
    }

    // ID: IFN6792; NAME: Histologic Subtype, Morphology ICDO3 (NAACCR)
    public boolean ifn6792(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.schemaId != '09190' || line.histologicTypeIcdO3 == null
                    || line.behaviorCodeIcdO3 == null || line.histologicSubtype == null || line.typeOfReportingSource == '7')
            return true
        
        String morphIcdO3 = line.histologicTypeIcdO3 + line.behaviorCodeIcdO3
        
        if (morphIcdO3 == '84802' || morphIcdO3 == '84803')
            return functions.matches(line.histologicSubtype, /^[1-4]$/)
        else
            return line.histologicSubtype == '0'
    }

    // ID: IFN6793; NAME: EOD Primary Tumor, Appendix, Histologic Subtype (SEER)
    public boolean ifn6793(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.schemaId != '09190' || line.eodPrimaryTumor == null
                    || line.histologicTypeIcdO3 == null || line.behaviorCodeIcdO3 == null || line.histologicSubtype == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.histologicTypeIcdO3 == '8480') {
            if (line.behaviorCodeIcdO3 == '2') {
                if (line.histologicSubtype == '1')
                    return line.eodPrimaryTumor == '050'
                if (line.eodPrimaryTumor == '050')
                    return line.histologicSubtype == '1'
                if (line.histologicSubtype == '2')
                    return line.eodPrimaryTumor == '000'
                if (line.eodPrimaryTumor == '000')
                    return functions.matches(line.histologicSubtype, /^[234]$/)
            }
            else if (line.behaviorCodeIcdO3 == '3') {
                if (line.histologicSubtype == '1')
                    return !['070','100','200'].contains(line.eodPrimaryTumor)
            }
        }
        
        return true
    }

    // ID: IFN6801; NAME: SSDI p16, Blank for Other Schemas (NAACCR)
    public boolean ifn6801(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear < '2018' || line.dateOfDiagnosisYear == null || ['09210','09520','09500'].contains(line.schemaId) || line.schemaId == null)
            return true
        
        return line.p16 == null
    }

    // ID: IFN6802; NAME: Schema Discriminator 2, Head and Neck, Histology (NAACCR)
    public boolean ifn6802(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear < '2023' || line.dateOfDiagnosisYear == null || line.primarySite == null || line.histologicTypeIcdO3 == null ||
                    line.schemaDiscriminator2 == null || line.typeOfReportingSource == '7')
            return true
        
        if (functions.matches(line.primarySite, /^C(10[0-489]|019|024|09\d|111)$/)) {
            if (line.histologicTypeIcdO3 == '8085')
                return line.schemaDiscriminator2 == '2' || line.schemaDiscriminator2 == '9'
            else if (line.histologicTypeIcdO3 == '8086')
                return line.schemaDiscriminator2 == '1' || line.schemaDiscriminator2 == '9'
            else if (line.histologicTypeIcdO3 == '8070')
                return line.schemaDiscriminator2 == '9'
            else if (line.histologicTypeIcdO3 == '8071')
                return line.schemaDiscriminator2 != '1'
            else if (line.histologicTypeIcdO3 == '8072')
                return line.schemaDiscriminator2 != '2'
        }
        
        return true
    }

    // ID: IFN6806; NAME: EOD Regional Nodes, Ampulla, Regional Nodes Positive (SEER)
    public boolean ifn6806(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear < '2018' || line.dateOfDiagnosisYear == null || line.schemaId != '00270' || line.schemaId == null
                    || line.eodRegionalNodes == null || line.regionalNodesPositive == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.eodRegionalNodes == '300')
            return functions.matches(line.regionalNodesPositive, /^(0[0-3]|9[5789])$/)
        
        if (functions.matches(line.regionalNodesPositive, /^(0[4-9]|[1-8]\d|90)$/))
            return line.eodRegionalNodes == '400'
        
        return true
    }

    // ID: IFN6809; NAME: Multigene Signature Method, Results (NAACCR)
    public boolean ifn6809(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.schemaId != '00480' || line.typeOfReportingSource == '7')
            return true
        
        if (line.multigeneSignatureMethod == null || line.multigeneSignatureMethod == '8' || line.multigeneSignatureResults == null || line.multigeneSignatureResults == 'X8')
            return true
        
        if (functions.matches(line.multigeneSignatureResults, /^\d\d|X[1-4]$/))
            return functions.matches(line.multigeneSignatureMethod, /^[1-6]$/)
        
        if (line.multigeneSignatureResults == 'X7')
            return functions.matches(line.multigeneSignatureMethod, /^[1-7]$/)
        
        if (line.multigeneSignatureResults == 'X9')
            return line.multigeneSignatureMethod == '9'
        
        return true
    }

    // ID: IFN6811; NAME: LN Distant/Assessment Vagina/Cervix (NAACCR)
    public boolean ifn6811(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.lnDistantMediastinalScalene == null || line.lnDistantAssessMethod == null
                    || (line.schemaId != '09520' && line.schemaId != '00510') || line.typeOfReportingSource == '7')
            return true
        
        if (line.lnDistantMediastinalScalene == '9')
            return line.lnDistantAssessMethod == '0' || line.lnDistantAssessMethod == '9'
        
        return true
    }

    // ID: IFN6814; NAME: Perineural Invasion, Surg Prim Site 2023 (NAACCR)
    public boolean ifn6814(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.perineuralInvasion == null || line.perineuralInvasion == '8')
            return true
        
        if (line.rxSummSurgPrimSite2023 == null || line.typeOfReportingSource == '7' || line.behaviorCodeIcdO3 == '2')
            return true
        
        if (line.schemaId == null || !['00150', '00200', '00640', '00690'].contains(line.schemaId))
            return true
        
        if (line.perineuralInvasion == '0')
            return functions.matches(line.rxSummSurgPrimSite2023, /^[AB](900|[3-8]\d\d)$/) || (line.primarySite == 'C209' && functions.matches(line.rxSummSurgPrimSite2023, /^[AB]270$/))
        
        return true
    }

    // ID: IFN6815; NAME: Number of Positive/Examined Nodes, Corpus, Scope Nodes (NAACCR)
    public boolean ifn6815(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.rxSummScopeRegLnSur == null || line.typeOfReportingSource == '7')
            return true
        
        if (!['00528', '00530', '00541', '00542'].contains(line.schemaId))
            return true
        
        if ((line.numberOfPositivePelvicNodes == null || line.numberOfPositivePelvicNodes == 'X8') && (line.numberOfExaminedPelvicNodes == null || line.numberOfExaminedPelvicNodes == 'X8')
            && (line.numberOfPositiveParaAorticNodes == null || line.numberOfPositiveParaAorticNodes == 'X8') && (line.numberOfExaminedParaAorticNodes == null || line.numberOfExaminedParaAorticNodes == 'X8'))
            return true
        
        if (line.rxSummScopeRegLnSur == '0')
            return line.numberOfPositivePelvicNodes == 'X9' && line.numberOfPositiveParaAorticNodes == 'X9' && line.numberOfExaminedPelvicNodes == '00' && line.numberOfExaminedParaAorticNodes == '00'
        
        if (line.rxSummScopeRegLnSur == '1')
            return (line.numberOfPositivePelvicNodes == 'X6' || line.numberOfPositivePelvicNodes == 'X9') && (line.numberOfPositiveParaAorticNodes == 'X6' || line.numberOfPositiveParaAorticNodes == 'X9')
                && (line.numberOfExaminedPelvicNodes == '00' || line.numberOfExaminedPelvicNodes == 'X6') && (line.numberOfExaminedParaAorticNodes == '00' || line.numberOfExaminedParaAorticNodes == 'X6')
        
        if (line.rxSummScopeRegLnSur == '9')
            return line.numberOfPositivePelvicNodes == 'X9' && line.numberOfPositiveParaAorticNodes == 'X9' && line.numberOfExaminedPelvicNodes == 'X9' && line.numberOfExaminedParaAorticNodes == 'X9'
        
        return true
    }

    // ID: IFN6819; NAME: Bilirubin Pretreatment Lab, Unit of Measure, Liver (NAACCR)
    public boolean ifn6819(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.schemaId != '00220' || line.typeOfReportingSource == '7')
            return true
        
        if (line.bilirubinPretxUnitOfMeasure == null || line.bilirubinPretxUnitOfMeasure == '8' || line.bilirubinPretxTotalLabValue == null || line.bilirubinPretxTotalLabValue == 'XXX.8')
            return true
        
        if (line.bilirubinPretxTotalLabValue == 'XXX.7')
            return line.bilirubinPretxUnitOfMeasure == '7'
        
        if (line.bilirubinPretxTotalLabValue == 'XXX.9')
            return line.bilirubinPretxUnitOfMeasure == '9'
        
        return true
    }

    // ID: IFN6820; NAME: Creatinine Pretreatment Lab, Unit of Measure, Liver (NAACCR)
    public boolean ifn6820(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.schemaId == null || line.schemaId != '00220' || line.typeOfReportingSource == '7')
            return true
        if (line.creatininePretreatmentLabValue == null || line.creatininePretreatmentLabValue == 'XX.8' || line.creatininePretxUnitOfMeasure == null || line.creatininePretxUnitOfMeasure == '8')
            return true
        
        if (line.creatininePretreatmentLabValue == 'XX.7')
            return line.creatininePretxUnitOfMeasure == '7'
        
        if (line.creatininePretreatmentLabValue == 'XX.9')
            return line.creatininePretxUnitOfMeasure == '9'
        
        return true
    }

    // ID: IFN6822; NAME: LDH Lab/Upper Limits/LDH Level, Melanoma Skin (NAACCR)
    public boolean ifn6822(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear < '2023' || line.dateOfDiagnosisYear == null || line.schemaId != '00470' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        
        boolean ldhLevelBlankNa = line.ldhPretreatmentLevel == null || line.ldhPretreatmentLevel == '8'
        boolean ldhUpperLimitsOfNormalBlankNa = line.ldhUpperLimitsOfNormal == null || line.ldhUpperLimitsOfNormal == 'XX8'
        boolean ldhLabValueBlankNa = line.ldhPretreatmentLabValue == null || line.ldhPretreatmentLabValue == 'XXXXX.8'
        if (ldhLevelBlankNa && ldhUpperLimitsOfNormalBlankNa && ldhLabValueBlankNa)
            return true
        
        if (!ldhUpperLimitsOfNormalBlankNa) {
            boolean isLabValueValidInt = functions.matches(line.ldhPretreatmentLabValue, /^\d{1,5}\.\d$/)
            boolean isUpperLimitValidInt = functions.matches(line.ldhUpperLimitsOfNormal, /^\d\d\d$/) && line.ldhUpperLimitsOfNormal != '000'
        
            if (isLabValueValidInt && isUpperLimitValidInt) {
                Integer ldhLabValueInt = functions.asInt(line.ldhPretreatmentLabValue.substring(0, line.ldhPretreatmentLabValue.length() - 2))
                Integer ldhUpperLimitInt = functions.asInt(line.ldhUpperLimitsOfNormal)
        
                if (ldhLabValueInt <= ldhUpperLimitInt && line.ldhPretreatmentLevel != '0')
                    return false
                if (ldhLabValueInt > ldhUpperLimitInt && line.ldhPretreatmentLevel != '1')
                    return false
            }
        }
        
        if (line.ldhPretreatmentLabValue == 'XXXXX.1' && line.ldhPretreatmentLevel != '1')
            return false
        
        return true
    }

    // ID: IFN6823; NAME: EOD Primary Tumor, Nasal Cavity, Primary Site (SEER)
    public boolean ifn6823(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear < '2018' || line.dateOfDiagnosisYear == null || line.schemaId != '00122' || line.schemaId == null
                    || line.eodPrimaryTumor == null || line.primarySite == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.eodPrimaryTumor == '150' || line.eodPrimaryTumor == '175')
            return line.primarySite == 'C300'
        
        return true
    }

    // ID: IFN6824; NAME: EOD Primary Tumor, NET Adrenal, Histology (SEER)
    public boolean ifn6824(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear < '2018' || line.dateOfDiagnosisYear == null || line.schemaId != '00770' || line.schemaId == null
                    || line.eodPrimaryTumor == null || line.histologicTypeIcdO3 == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.eodPrimaryTumor == '100')
            return line.histologicTypeIcdO3 == '8700'
        
        if (line.eodPrimaryTumor == '200')
            return ['8680','8690','8692','8693'].contains(line.histologicTypeIcdO3)
        
        return true
    }

    // ID: IFN6827; NAME: EOD Primary Tumor, NET Duodenum, Tumor Size (SEER)
    public boolean ifn6827(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear < '2018' || line.dateOfDiagnosisYear > '2023' || line.dateOfDiagnosisYear == null || line.schemaId != '00301' || line.schemaId == null
                    || line.eodPrimaryTumor == null || line.typeOfReportingSource == '7' || (line.tumorSizeClinical == null && line.tumorSizePathologic == null))
            return true
        
        if (line.eodPrimaryTumor == '100') {
            if (!functions.matches(line.tumorSizePathologic, /^(00[1-9]|010|990|999)$/) && !functions.matches(line.tumorSizeClinical, /^(00[1-9]|010|990|999)$/))
                return false
        
            if (line.tumorSizeSummary != null && !functions.matches(line.tumorSizeSummary, /^(00[1-9]|010|990|999)$/))
                return false
        }
        return true
    }

    // ID: IFN6828; NAME: EOD Primary Tumor, Prostate, RX Summ--Surg Prim Site 2023 (SEER)
    public boolean ifn6828(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.schemaId != '00580' || line.eodPrimaryTumor == null
                    || line.rxSummSurgPrimSite2023 == null || line.typeOfReportingSource == '7')
            return true
        
        if (['100','110','150'].contains(line.eodPrimaryTumor) && functions.matches(line.prostatePathologicalExtension, /^[89]\d\d$/))
            return functions.matches(line.rxSummSurgPrimSite2023, /^A(2[0145]\d|220|260|300)$/)
        
        return true
    }

    // ID: IFN6829; NAME: EOD Primary Tumor, Stomach, Morphology ICDO3 (SEER)
    public boolean ifn6829(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear < '2018' || line.dateOfDiagnosisYear == null || line.schemaId != '00170' || line.schemaId == null
                    || line.eodPrimaryTumor == null || line.histologicTypeIcdO3 == null || line.behaviorCodeIcdO3 == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.histologicTypeIcdO3 == '8142' && line.behaviorCodeIcdO3 == '3')
            return ['400','500','600','650','700','750'].contains(line.eodPrimaryTumor)
        
        return true
    }

    // ID: IFN6830; NAME: Serum Tumor Markers, Testis, RX Summ--Surg Prim Site 2023 (SEER)
    public boolean ifn6830(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.schemaId == null || line.schemaId != '00590' || line.rxSummSurgPrimSite2023 == null
                    || line.typeOfReportingSource == '7')
            return true
        
        if ((line.afpPostOrchiectomyLabValue == null || line.afpPostOrchiectomyLabValue == 'XXXXX.8') && (line.afpPostOrchiectomyRange == null || line.afpPostOrchiectomyRange == '8')
            && (line.hcgPostOrchiectomyLabValue == null || line.hcgPostOrchiectomyLabValue == 'XXXXX.8') && (line.hcgPostOrchiectomyRange == null || line.hcgPostOrchiectomyRange == '8')
            && (line.ldhPostOrchiectomyRange == null || line.ldhPostOrchiectomyRange == '8') && (line.sCategoryPathological == null || line.sCategoryPathological == '9'))
            return true
        
        if (functions.matches(line.afpPostOrchiectomyLabValue, /^XXXXX\.[17]|(0|[1-9]\d{0,4})\.\d$/) || functions.matches(line.afpPostOrchiectomyRange, /^[0-47]$/)
            || functions.matches(line.hcgPostOrchiectomyLabValue, /^XXXXX\.[17]|(0|[1-9]\d{0,4})\.\d$/) || functions.matches(line.hcgPostOrchiectomyRange, /^[0-47]$/)
            || functions.matches(line.ldhPostOrchiectomyRange, /^[0-47]$/) || functions.matches(line.sCategoryPathological, /^[0-3]$/))
            return ['A300','A400','A800'].contains(line.rxSummSurgPrimSite2023)
        
        return true
    }

    // ID: IFN6837; NAME: AFP Pre/Post Treatment Range, Testis (NAACCR)
    public boolean ifn6837(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.schemaId != '00590' || line.typeOfReportingSource == '7')
            return true
        if (line.afpPreOrchiectomyRange == null || line.afpPreOrchiectomyRange == '8' || line.afpPostOrchiectomyRange == null || line.afpPostOrchiectomyRange == '8')
            return true
        
        if (line.afpPostOrchiectomyRange == '5')
            return line.afpPreOrchiectomyRange == '0'
        
        return true
    }

    // ID: IFN6838; NAME: hCG Pre/Post Treatment Range, Testis (NAACCR)
    public boolean ifn6838(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.schemaId != '00590' || line.typeOfReportingSource == '7')
            return true
        if (line.hcgPreOrchiectomyRange == null || line.hcgPreOrchiectomyRange == '8' || line.hcgPostOrchiectomyRange == null || line.hcgPostOrchiectomyRange == '8')
            return true
        
        if (line.hcgPostOrchiectomyRange == '5')
            return line.hcgPreOrchiectomyRange == '0'
        
        return true
    }

    // ID: IFN6839; NAME: LDH Pre/Post Treatment Range, Testis (NAACCR)
    public boolean ifn6839(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.schemaId == null || line.schemaId != '00590' || line.typeOfReportingSource == '7')
            return true
        if (line.ldhPreOrchiectomyRange == null || line.ldhPreOrchiectomyRange == '8' || line.ldhPostOrchiectomyRange == null || line.ldhPostOrchiectomyRange == '8')
            return true
        
        if (line.ldhPostOrchiectomyRange == '5')
            return line.ldhPreOrchiectomyRange == '0'
        
        return true
    }

    // ID: IFN6840; NAME: Date of SLN Biopsy, Date RLN Dissection (NAACCR)
    public boolean ifn6840(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || (line.schemaId != '00470' && line.schemaId != '00480')
                    || line.rxSummScopeRegLnSur == null || line.typeOfReportingSource == '7')
            return true
        if (line.dateSentinelLymphNodeBiopsyYear == null && line.dateSentinelLymphNodeBiopsyMonth == null && line.dateSentinelLymphNodeBiopsyDay == null)
            return true
        if (line.dateRegionalLNDissectionYear == null && line.dateRegionalLNDissectionMonth == null && line.dateRegionalLNDissectionDay == null)
            return true
        
        if (line.dateSentinelLymphNodeBiopsyYear != line.dateRegionalLNDissectionYear || line.dateSentinelLymphNodeBiopsyMonth != line.dateRegionalLNDissectionMonth
            || line.dateSentinelLymphNodeBiopsyDay != line.dateRegionalLNDissectionDay)
            return line.rxSummScopeRegLnSur == '7'
        else
            return line.rxSummScopeRegLnSur == '6'
        
        return true
    }

    // ID: IFN6844; NAME: Grade, Unknown Primary (NAACCR)
    public boolean ifn6844(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.primarySite == null || line.primarySite != 'C809'
                    || (line.gradeClinical == null && line.gradePathological == null) || line.typeOfReportingSource == '7')
            return true
        if (['00790','00795','00811','00821','00822','00830'].contains(line.schemaId))
            return true
        
        return line.gradeClinical == '9' && line.gradePathological == '9' && (line.gradePostTherapyClin == null || line.gradePostTherapyClin == '9')
            && (line.gradePostTherapy == null || line.gradePostTherapy == '9')
    }

    // ID: IFN6846; NAME: Mets at DX, Medulloblastoma, EOD Mets (SEER)
    public boolean ifn6846(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2024' || line.schemaId == null || line.schemaId != '09724' || line.eodMets == null
                    || line.typeOfReportingSource == '7')
            return true
        
        if (line.metsAtDxBone == null && line.metsAtDxBrain == null && line.metsAtDxDistantLn == null && line.metsAtDxLiver == null && line.metsAtDxLung == null && line.metsAtDxOther == null)
            return true
        
        String eodMets = line.eodMets
        if (line.metsAtDxBrain == '1' && !functions.matches(eodMets, /^[1-4]5$/))
            return false
        if (line.metsAtDxBone == '1' && !functions.matches(eodMets, /^[2-4]5$/))
            return false
        if ((line.metsAtDxDistantLn == '1' || line.metsAtDxLiver == '1' || line.metsAtDxLung == '1' || line.metsAtDxOther == '2') && eodMets != '45')
            return false
        
        if (eodMets == '15' )
            return line.metsAtDxBrain == '1' || line.metsAtDxOther == '1'
        else if (eodMets == '35')
            return line.metsAtDxBone == '1' || line.metsAtDxBrain == '1' || line.metsAtDxOther == '1'
        else if (eodMets == '45')
            return line.metsAtDxBone == '1' || line.metsAtDxDistantLn == '1' || line.metsAtDxLiver == '1' || line.metsAtDxLung == '1' || line.metsAtDxOther == '1' || line.metsAtDxOther == '2'
        
        return true
    }

    // ID: IFN6847; NAME: Brain Molecular Markers, Version 9 (NAACCR)
    public boolean ifn6847(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.brainMolecularMarkers == null || line.brainMolecularMarkers == '88'
                    || (line.schemaId != '09721' && line.schemaId != '09724') || line.typeOfReportingSource == '7')
            return true
        
        if (line.brainMolecularMarkers == '08' || line.brainMolecularMarkers == '09')
            return line.schemaId == '09724'
        
        if (functions.matches(line.brainMolecularMarkers, /^(0[1-7]|1\d|2[0-3])$/))
            return line.schemaId != '09724'
        
        return true
    }

    // ID: IFN6879; NAME: EOD Prostate Pathologic Extension, RX Summ--Treatment Status (SEER)
    public boolean ifn6879(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.schemaId == null || line.schemaId != '00580' || line.rxSummTreatmentStatus == null
                    || line.prostatePathologicalExtension == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.rxSummTreatmentStatus == '2')
            return line.prostatePathologicalExtension == '900' || line.prostatePathologicalExtension == '950'
        
        return true
    }

    // ID: IFN6880; NAME: EOD Primary Tumor, Prostate, RX Summ--Surg Prim Site 03-2022 (SEER)
    public boolean ifn6880(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || (line.dateOfDiagnosisYear != '2021' && line.dateOfDiagnosisYear != '2022') || line.schemaId == null || line.schemaId != '00580'
                    || line.eodPrimaryTumor == null || line.rxSummSurgPrimSite == null || line.typeOfReportingSource == '7')
            return true
        
        if (['100','110','150'].contains(line.eodPrimaryTumor) && functions.matches(line.prostatePathologicalExtension, /^[89]\d\d$/))
            return functions.matches(line.rxSummSurgPrimSite, /^2[012456]|30$/)
        
        return true
    }

    // ID: IFN6882; NAME: Fibrosis Score, Schema ID, Required (SEER)
    public boolean ifn6882(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        
        return (line.schemaId != '00220' && line.schemaId != '00230') || (line.fibrosisScore != null && line.fibrosisScore != '8')
    }

    // ID: IFN6883; NAME: Gleason Score Clinical, Schema ID, Required (SEER)
    public boolean ifn6883(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        
        return line.schemaId != '00580' || (line.gleasonScoreClinical != null && line.gleasonScoreClinical != 'X8')
    }

    // ID: IFN6884; NAME: Gleason Score Pathological, Schema ID, Required (SEER)
    public boolean ifn6884(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        
        return line.schemaId != '00580' || (line.gleasonScorePathological != null && line.gleasonScorePathological != 'X8')
    }

    // ID: IFN6886; NAME: p16, Schema ID, Required (SEER)
    public boolean ifn6886(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        
        return (!['09210','09520','09500'].contains(line.schemaId)) || (line.p16 != null && line.p16 != '8')
    }

    // ID: IFN6902; NAME: Grade Clin, Grade Path 2023 (NAACCR)
    public boolean ifn6902(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.gradePathological == null || line.gradePathological == '9'
                    || line.gradeClinical == null || line.gradeClinical == '8' || line.gradeClinical == '9' || ['00721','00722','00723','09721','09722','09723','09724'].contains(line.schemaId))
            return true
        
        boolean isGradeClinValid = functions.matches(line.gradeClinical, /^[0-9]$/)
        boolean isGradePathValid = functions.matches(line.gradePathological, /^[0-9]$/)
        
        if (functions.matches(line.rxSummSurgPrimSite2023, /^A[3-8]\d\d|A900|B[3-8]\d\d|B900$/)) {
            if (line.gradePostTherapy == null && isGradeClinValid && isGradePathValid)
                return line.gradeClinical <= line.gradePathological && line.gradePathological != '8'
        }
        
        return true
    }

    // ID: IFN6904; NAME: Macroscopic Evaluation of Mesorectum, Rectum, Surgery 2023 (SEER)
    public boolean ifn6904(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.primarySite != 'C209' || line.macroscopicEvalOfTheMesorectum == null ||
                    line.rxSummSurgPrimSite2023 == null || line.typeOfReportingSource == '6' || line.typeOfReportingSource == '7')
            return true
        
        if (functions.matches(line.rxSummSurgPrimSite2023, /^A000|A1[0-4]\d|A150|A2[0-7]\d|A280$/))
            return line.macroscopicEvalOfTheMesorectum == '00'
        
        if (line.rxSummSurgPrimSite2023 == 'A990')
            return line.macroscopicEvalOfTheMesorectum == '99'
        
        return true
    }

    // ID: IFN7016; NAME: RX Summ--Surg Prim Site 2023, Breast, Recon Breast (NAACCR)
    public boolean ifn7016(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2024' || line.typeOfReportingSource == '7')
            return true
        if (line.primarySite == null || !functions.matches(line.primarySite, /^C50\d$/))
            return true
        if (line.rxSummSurgPrimSite2023 == null && line.rxSummReconBreast == null)
            return true
        
        if (line.rxSummSurgPrimSite2023 == 'B000' && line.rxSummReconBreast != 'A000')
            return false
        if (line.rxSummSurgPrimSite2023 == 'B990' && line.rxSummReconBreast != 'A990')
            return false
        if (functions.matches(line.rxSummReconBreast, /^A6[0-4]0$/))
            return functions.matches(line.rxSummSurgPrimSite2023, /^B([3-7]\d\d|800)$/)
        return true
    }

    // ID: IFN7022; NAME: RX Summ--Recon Breast, Date DX (NAACCR)
    public boolean ifn7022(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.primarySite == null || !functions.matches(line.primarySite, /^C50\d$/))
            return true
        
        if (line.dateOfDiagnosisYear < '2022')
            return line.rxSummReconBreast == null
        else
            return line.rxSummReconBreast == null || ((List)context.IF7022_List1).contains(line.rxSummReconBreast)
    }

    // ID: IFN7023; NAME: RX Summ--Recon Breast, Required (NAACCR)
    public boolean ifn7023(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2024' || line.typeOfReportingSource == '7')
            return true
        if (line.primarySite == null || !functions.matches(line.primarySite, /^C50\d$/))
            return true
        
        return line.rxSummReconBreast != null
    }

    // ID: IFN7027; NAME: Brain Primary Tumor Location, Date DX (NAACCR)
    public boolean ifn7027(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2024' || line.primarySite != 'C717')
            return line.brainPrimaryTumorLocation == null
        
        if (!['1','2','8','9'].contains(line.brainPrimaryTumorLocation) && line.brainPrimaryTumorLocation != null)
            return false
        
        return true
    }

    // ID: IFN7028; NAME: Brain Primary Tumor Location, Schema ID, Required (NAACCR)
    public boolean ifn7028(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2024' || line.schemaId == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.primarySite == 'C717' && line.schemaId == '09721')
            return line.brainPrimaryTumorLocation != '8' && line.brainPrimaryTumorLocation != null
        
        return true
    }

    // ID: IFN7038; NAME: S Category Clin/Path, Testis (NAACCR)
    public boolean ifn7038(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2021' || line.typeOfReportingSource == '7')
            return true
        if (line.schemaId == null || line.schemaId != '00590')
            return true
        if (line.sCategoryClinical == null || line.sCategoryPathological == null)
            return true
        
        if (line.sCategoryPathological == '5')
            return line.sCategoryClinical == '0'
        return true
    }

    // ID: IFN7039; NAME: Circumferential Resection Margin, Colon, RX Summ--Surgical Margins (NAACCR)
    public boolean ifn7039(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2024' || line.typeOfReportingSource == '7')
            return true
        if (line.schemaId != '00200' || line.behaviorCodeIcdO3 == '2' || line.rxSummSurgicalMargins == null)
            return true
        if (line.circumferentialResectionMargin == null || line.circumferentialResectionMargin == 'XX.8')
            return true
        
        if (line.circumferentialResectionMargin == '0.0')
            if (!['0', '1', '2', '3'].contains(line.rxSummSurgicalMargins))
                return false
        
        if (line.rxSummSurgicalMargins == '0')
            if (!functions.matches(line.circumferentialResectionMargin, /^(\d\.\d|[1-9]\d\.\d|XX\.[0-79])$/))
                return false
        
        if (line.rxSummSurgicalMargins == '7')
            if (!functions.matches(line.circumferentialResectionMargin, /^XX\.[279]$/))
                return false
        
        if (line.rxSummSurgicalMargins == '8')
            if (line.circumferentialResectionMargin != 'XX.7')
                return false
        
        return true
    }

    // ID: IFN7040; NAME: Primary Site, Morphology-Type, Beh ICDO3, 2024 (SEER)
    public boolean ifn7040(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2024')
            return true
        if (line.primarySite == null || line.histologicTypeIcdO3 == null || line.behaviorCodeIcdO3 == null)
            return true
        
        Integer siteNum = functions.asInt(line.primarySite.substring(1))
        Integer histNum = functions.asInt(line.histologicTypeIcdO3)
        Integer behNum = functions.asInt(line.behaviorCodeIcdO3)
        
        Map>> naaccrPathChartTable = (Map>>)context.IFN7040_NAACCR_PathCHART_Table
        Map> siteMap = (Map>)naaccrPathChartTable.get(siteNum);
        Map histMap = (Map)siteMap?.get(histNum)
        String status = histMap?.get(behNum)
        
        if (status == null || status == '2')
            return line.overRideSiteType == '1'
        else if (status == '1')
            return line.overRideSiteType == null
        else if (status == '3')
            return false
        return true
    }

    // ID: IFN7042; NAME: EOD Primary Tumor, Lung, Tumor Size Summary (SEER)
    public boolean ifn7042(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear < '2024' || line.dateOfDiagnosisYear == null || line.schemaId != '00360' || line.schemaId == null
                    || line.eodPrimaryTumor == null || line.tumorSizeSummary == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.eodPrimaryTumor == '100')
            return functions.matches(line.tumorSizeSummary, /^00[1-9]|0[12]\d|030|990$/)
        
        return true
    }

    // ID: IFN7043; NAME: EOD Primary Tumor, NET Duodenum, Tumor Size Summary (SEER)
    public boolean ifn7043(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear < '2024' || line.dateOfDiagnosisYear == null || line.schemaId != '09301' || line.schemaId == null
                    || line.eodPrimaryTumor == null || line.tumorSizeSummary == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.eodPrimaryTumor == '100')
            return functions.matches(line.tumorSizeSummary, /^00[1-9]|010|99[09]$/)
        
        return true
    }

    // ID: IFN7044; NAME: EOD Primary Tumor, NET Jejunum and Ileum, Tumor Size Summary (SEER)
    public boolean ifn7044(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear < '2024' || line.dateOfDiagnosisYear == null || line.schemaId != '09310' || line.schemaId == null
                    || line.eodPrimaryTumor == null || line.tumorSizeSummary == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.eodPrimaryTumor == '100')
            return functions.matches(line.tumorSizeSummary, /^00[1-9]|010|99[09]$/)
        
        return true
    }

    // ID: IFN7045; NAME: EOD Primary Tumor, Testis, Morphology, Tumor Size Summary (SEER)
    public boolean ifn7045(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear < '2024' || line.dateOfDiagnosisYear == null || line.schemaId != '00590' || line.schemaId == null
                    || line.typeOfReportingSource == '7')
            return true
        if  (line.eodPrimaryTumor == null || line.tumorSizeSummary == null || line.histologicTypeIcdO3 == null || line.behaviorCodeIcdO3 == null)
            return true
        
        if (line.eodPrimaryTumor == '100') {
            if (line.histologicTypeIcdO3 != '9061' || line.behaviorCodeIcdO3 != '3')
                return false
            if (!functions.matches(line.tumorSizeSummary, /^00[1-9]|0[12]\d|99[09]$/))
                return false
        }
        
        if (line.eodPrimaryTumor == '150') {
            if (line.histologicTypeIcdO3 != '9061' || line.behaviorCodeIcdO3 != '3')
                return false
            if (!functions.matches(line.tumorSizeSummary, /^0[3-9]\d|[1-8]\d\d|9[0-8]\d|999$/))
                return false
        }
        
        return true
    }

    // ID: IFN7046; NAME: Tumor Size Summary 998, Schema ID (SEER)
    public boolean ifn7046(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2024' || line.typeOfReportingSource == '7')
            return true
        
        if (line.tumorSizeSummary == '998')
            return ((List)context.IFN7046_SchemaId_List).contains(line.schemaId)
        
        return true
    }

    // ID: IFN7047; NAME: Tumor Size Summary 999, Schema ID, Primary Site (SEER)
    public boolean ifn7047(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2024' || line.schemaId == null || line.tumorSizeSummary == null)
            return true
        
        if (line.primarySite == null || line.primarySite == 'C422')
            return true
        
        if (['00458','00671','00672','00790','00795','00821','00822','00830'].contains(line.schemaId) || functions.matches(line.primarySite, /^C(42[0134]|77\d|809)$/))
            return line.tumorSizeSummary == '999' || line.tumorSizeSummary == null
        
        return true
    }

    // ID: IFN7048; NAME: Tumor Size Summary, EOD Primary Tumor, Schema ID (SEER)
    public boolean ifn7048(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2024' || line.tumorSizeSummary == null || line.typeOfReportingSource == '7' || line.eodPrimaryTumor == null)
            return true
        
        if (line.schemaId == null || ['00458','00671','00672','00790','00795','00821','00822','00830'].contains(line.schemaId))
            return true
        
        if (((List)context.IFN7048_SchemaId_List).contains(line.schemaId))
            return line.tumorSizeSummary != '000'
        
        if (line.schemaId == '00060')
            return line.tumorSizeSummary == '000'
        
        if (line.schemaId == '00360') {
            if (line.tumorSizeSummary == '000')
                return line.eodPrimaryTumor == '800' || line.eodPrimaryTumor == '980'
            if (line.eodPrimaryTumor == '800' || line.eodPrimaryTumor == '980')
                return line.tumorSizeSummary == '000' || line.tumorSizeSummary == '999'
        }
        else if (line.schemaId == '00580') {
            if (line.tumorSizeSummary == '000')
                return line.eodPrimaryTumor == '800' && ['800','900','950','999'].contains(line.prostatePathologicalExtension)
            if (line.eodPrimaryTumor == '800' && line.prostatePathologicalExtension == '800')
                return line.tumorSizeSummary == '000' || line.tumorSizeSummary == '999'
        }
        else {
            if (line.tumorSizeSummary == '000' && line.schemaId != '99999')
                return line.eodPrimaryTumor == '800'
            if (line.eodPrimaryTumor == '800')
                return line.tumorSizeSummary == '000' || line.tumorSizeSummary == '999'
        }
        
        return true
    }

    // ID: IFN7049; NAME: Tumor Size Summary, EOD Regional Nodes, Mets (SEER)
    public boolean ifn7049(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2024' || (line.eodRegionalNodes == null && line.eodMets == null) || line.tumorSizeSummary == null
                    || line.typeOfReportingSource == '7')
            return true
        
        if (line.schemaId == null || ['00458','00671','00672','00790','00795','00821','00822','00830'].contains(line.schemaId))
            return true
        
        if (line.tumorSizeSummary == '000') {
            if (line.schemaId == '00480')
                return !['000','030','050','070'].contains(line.eodRegionalNodes) || !['00','05'].contains(line.eodMets)
        
            if (['00500','09500','00510','00520','00528','09520','00530','00541','00542','00551','00552','00553'].contains(line.schemaId))
                return !['000','040','050'].contains(line.eodRegionalNodes) || line.eodMets != '00'
        
            return line.eodRegionalNodes != '000' || line.eodMets != '00'
        }
        
        return true
    }

    // ID: IFN7050; NAME: Tumor Size Summary, Date of Diagnosis (SEER)
    public boolean ifn7050(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2024')
            return true
        
        return line.tumorSizeSummary != null
    }

    // ID: IFN7052; NAME: RX Summ--Surg Prim Site 2023, Breast, Laterality (NAACCR)
    public boolean ifn7052(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2024' || line.primarySite == null || !functions.matches(line.primarySite, /^C50\d$/) ||
                    line.rxSummSurgPrimSite2023 == null || line.typeOfReportingSource == '7')
            return true
        
        if (functions.matches(line.rxSummSurgPrimSite2023, /^A(4[2789]0|5[2789]0|6[2389]0|7[2345]0)|B[3467]20$/))
            return line.laterality != '4'
        
        return true
    }

    // ID: IFN7056; NAME: AFP Pre-Orchiectomy Lab Value, Range, Testis (NAACCR)
    public boolean ifn7056(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2024' || line.schemaId == null || line.schemaId != '00590' || line.typeOfReportingSource == '7')
            return true
        
        if (line.afpPreOrchiectomyLabValue == null || line.afpPreOrchiectomyRange == null || line.afpPreOrchiectomyLabValue == 'XXXXX.8' || line.afpPreOrchiectomyRange == '8')
            return true
        
        if (functions.matches(line.afpPreOrchiectomyLabValue, /^[1-9]\d\d\d\.\d|10000\.0$/))
            return line.afpPreOrchiectomyRange == '2'
        
        if (functions.matches(line.afpPreOrchiectomyLabValue, /^[1-9]\d\d\d\d\.\d|XXXXX\.1$/) && line.afpPreOrchiectomyLabValue != '10000.0')
            return line.afpPreOrchiectomyRange == '3'
        
        return true
    }

    // ID: IFN7057; NAME: AFP Post-Orchiectomy Lab Value, Range, Testis (NAACCR)
    public boolean ifn7057(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2024' || line.schemaId == null || line.schemaId != '00590' || line.typeOfReportingSource == '7')
            return true
        
        if (line.afpPostOrchiectomyLabValue == null || line.afpPostOrchiectomyRange == null || line.afpPreOrchiectomyLabValue == 'XXXXX.8' || line.afpPreOrchiectomyRange == '8')
            return true
        
        if (functions.matches(line.afpPostOrchiectomyLabValue, /^[1-9]\d\d\d\.\d|10000\.0$/))
            return line.afpPostOrchiectomyRange == '2'
        
        if (functions.matches(line.afpPostOrchiectomyLabValue, /^[1-9]\d\d\d\d\.\d|XXXXX\.1$/) && line.afpPreOrchiectomyLabValue != '10000.0')
            return line.afpPostOrchiectomyRange == '3'
        
        if (line.afpPostOrchiectomyRange == '5')
            return line.afpPostOrchiectomyLabValue == 'XXXXX.9'
        
        return true
    }

    // ID: IFN7058; NAME: hCG Pre-Orchiectomy Lab Value, Range, Testis (NAACCR)
    public boolean ifn7058(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2024' || line.schemaId != '00590' || line.typeOfReportingSource == '7')
            return true
        
        if (line.hcgPreOrchiectomyLabValue == null || line.hcgPreOrchiectomyLabValue == 'XXXXX.8')
            return true
        
        if (line.hcgPreOrchiectomyRange == null || line.hcgPreOrchiectomyRange == '8')
            return true
        
        if (functions.matches(line.hcgPreOrchiectomyLabValue, /^([5-9]\d\d\d\.\d)|([1-4]\d\d\d\d\.\d)$/) || line.hcgPreOrchiectomyLabValue == '50000.0')
            return line.hcgPreOrchiectomyRange == '2'
        
        if (line.hcgPreOrchiectomyLabValue != '50000.0' && (functions.matches(line.hcgPreOrchiectomyLabValue, /^[5-9]\d\d\d\d\.\d$/) || line.hcgPreOrchiectomyLabValue == 'XXXXX.1'))
            return line.hcgPreOrchiectomyRange == '3'
        
        return true
    }

    // ID: IFN7059; NAME: hCG Post-Orchiectomy Lab Value, Range, Testis (NAACCR)
    public boolean ifn7059(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2024' || line.schemaId != '00590' || line.typeOfReportingSource == '7')
            return true
        
        if (line.hcgPostOrchiectomyLabValue == null || line.hcgPostOrchiectomyLabValue == 'XXXXX.8')
            return true
        
        if (line.hcgPostOrchiectomyRange == null || line.hcgPostOrchiectomyRange == '8')
            return true
        
        if (functions.matches(line.hcgPostOrchiectomyLabValue, /^([5-9]\d\d\d\.\d)|([1-4]\d\d\d\d\.\d)$/) || line.hcgPostOrchiectomyLabValue == '50000.0')
            return line.hcgPostOrchiectomyRange == '2'
        
        if (line.hcgPostOrchiectomyLabValue != '50000.0' && (functions.matches(line.hcgPostOrchiectomyLabValue, /^[5-9]\d\d\d\d\.\d$/) || line.hcgPostOrchiectomyLabValue == 'XXXXX.1'))
            return line.hcgPostOrchiectomyRange == '3'
        
        if (line.hcgPostOrchiectomyRange == '5')
            return line.hcgPostOrchiectomyLabValue == 'XXXXX.9'
        
        return true
    }

    // ID: IFN7061; NAME: Neoadjuvant Therapy, Clinical Response (SEER)
    public boolean ifn7061(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2024' || line.neoadjuvantTherapy == null || line.neoadjuvTherapyClinicalResponse == null)
            return true
        
        if (line.neoadjuvantTherapy == '0' || line.neoadjuvantTherapy == '3')
            return line.neoadjuvTherapyClinicalResponse == '0'
        if (line.neoadjuvantTherapy == '1' || line.neoadjuvantTherapy == '2')
            return functions.matches(line.neoadjuvTherapyClinicalResponse, /^[1-8]$/)
        if (line.neoadjuvantTherapy == '9')
            return line.neoadjuvTherapyClinicalResponse == '9'
        
        return true
    }

    // ID: IFN7062; NAME: Neoadjuvant Therapy, Treatment Effect, Surgery 2023 (SEER)
    public boolean ifn7062(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2024' || line.neoadjuvantTherapy == null || line.neoadjuvTherapyTreatmentEffect == null)
            return true
        
        if ((line.neoadjuvantTherapy == '0' || line.neoadjuvantTherapy == '3') && line.neoadjuvTherapyTreatmentEffect != '0')
            return false
        
        if ((line.neoadjuvantTherapy == '1' || line.neoadjuvantTherapy == '2') && !functions.matches(line.neoadjuvTherapyTreatmentEffect, /^[1-4679]$/))
            return false
        
        if (functions.matches(line.neoadjuvTherapyTreatmentEffect, /^[1-46]$/) && functions.matches(line.rxSummSurgPrimSite2023, /^(A0\d\d|A1[0-8]\d|A[19]90|B000|B990)$/))
            return false
        
        if (line.neoadjuvantTherapy == '9' && line.neoadjuvTherapyTreatmentEffect != '9')
            return false
        
        return true
    }

    // ID: IFN7063; NAME: Response to Neoadjuvant Therapy, Breast, Neoadjuvant (NAACCR)
    public boolean ifn7063(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2024' || line.schemaId != '00480' || line.responseToNeoadjuvantTherapy == null || line.responseToNeoadjuvantTherapy == '8'
                    || line.neoadjuvTherapyTreatmentEffect == null || line.neoadjuvTherapyTreatmentEffect == '8' || line.typeOfReportingSource == '7')
            return true
        
        if (line.neoadjuvTherapyTreatmentEffect == '0')
            return line.responseToNeoadjuvantTherapy == '0'
        
        if (line.responseToNeoadjuvantTherapy == '0')
            return line.neoadjuvTherapyTreatmentEffect == '0'
        
        if (line.neoadjuvTherapyTreatmentEffect == '9')
            return line.responseToNeoadjuvantTherapy == '9'
        
        return true
    }

    // ID: IFN7068; NAME: EOD Primary Tumor, Bladder, RX Summ--Surg Prim Site 2023 (SEER)
    public boolean ifn7068(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.schemaId != '00620' ||
                    line.eodPrimaryTumor == null || line.rxSummSurgPrimSite2023 == null || line.typeOfReportingSource == '7')
            return true
        
        if (['200', '250', '300', '350'].contains(line.eodPrimaryTumor) && !functions.matches(line.rxSummSurgPrimSite2023, /^A([3-7]\d|80)0$/))
            return false
        
        return !functions.matches(line.rxSummSurgPrimSite2023, /^A([01]\d|2[0-7]|9\d)0$/) || !['200', '250', '300', '350'].contains(line.eodPrimaryTumor)
    }

    // ID: IFN7070; NAME: Prostate, RX Summ--Surg Prim Site 2023, Histologic Type (NAACCR)
    public boolean ifn7070(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2024' || line.primarySite == null || line.primarySite != 'C619' || line.histologicTypeIcdO3 == null ||
                    line.behaviorCodeIcdO3 == null || line.rxSummSurgPrimSite2023 == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.histologicTypeIcdO3 == '8500' && line.behaviorCodeIcdO3 == '3')
            return functions.matches(line.rxSummSurgPrimSite2023, /^A([56]\d\d|700)$/)
        
        return true
    }

    // ID: IFN7084; NAME: SEER SSF1, Schema Discriminator 2, Head and Neck (SEER)
    public boolean ifn7084(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2024' || line.primarySite == null || line.histologicTypeIcdO3 == null ||
                    (line.schemaId != '00100' && line.schemaId != '00111') || line.schemaDiscriminator2 == null || line.typeOfReportingSource == '7')
            return true
        
        if (line.seerSiteSpecificFact1 == '10')
            return line.schemaDiscriminator2 == '1'
        
        if (line.seerSiteSpecificFact1 == '11')
            return line.schemaDiscriminator2 == '2'
        
        return true
    }

    // ID: IFN7089; NAME: EOD Primary Tumor, Bladder, RX Summ--Surg Prim Site 03-2022 (SEER)
    public boolean ifn7089(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.dateOfDiagnosisYear > '2022' || line.schemaId != '00620' ||
                    line.eodPrimaryTumor == null || line.rxSummSurgPrimSite == null || line.typeOfReportingSource == '7')
            return true
        
        if (['200', '250', '300', '350'].contains(line.eodPrimaryTumor) && !functions.matches(line.rxSummSurgPrimSite, /^[3-7]\d|80$/))
            return false
        
        return !functions.matches(line.rxSummSurgPrimSite, /^[01]\d|2[0-7]|9\d$/) || !['200', '250', '300', '350'].contains(line.eodPrimaryTumor)
    }

    // ID: IFN7090; NAME: Grade, Bladder, Morphology (SEER)
    public boolean ifn7090(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.schemaId != '00620' || line.typeOfReportingSource == '7')
            return true
        if (line.gradeClinical == null && line.gradePathological == null && line.gradePostTherapyClin == null && line.gradePostTherapy == null)
            return true
        
        if (['8020', '8031', '8082', '8120', '8122', '8130', '8131'].contains(line.histologicTypeIcdO3)) {
            String[] gradeList = ['L', 'H', '9']
            if (line.gradeClinical != null && !gradeList.contains(line.gradeClinical))
                return false
            if (line.gradePathological != null && !gradeList.contains(line.gradePathological))
                return false
            if (line.gradePostTherapyClin != null && !gradeList.contains(line.gradePostTherapyClin))
                return false
            if (line.gradePostTherapy != null && !gradeList.contains(line.gradePostTherapy))
                return false
        }
        else {
            String[] gradeList = ['1', '2', '3', '9']
            if (line.gradeClinical != null && !gradeList.contains(line.gradeClinical))
                return false
            if (line.gradePathological != null && !gradeList.contains(line.gradePathological))
                return false
            if (line.gradePostTherapyClin != null && !gradeList.contains(line.gradePostTherapyClin))
                return false
            if (line.gradePostTherapy != null && !gradeList.contains(line.gradePostTherapy))
                return false
        }
        
        return true
    }

    // ID: IFN7091; NAME: Grade, Bladder, RX Summ--Surg Prim Site 2023 (SEER)
    public boolean ifn7091(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023' || line.schemaId != '00620' ||
                    line.gradePathological == null || line.rxSummSurgPrimSite2023 == null || line.typeOfReportingSource == '7')
            return true
        
        if (functions.matches(line.rxSummSurgPrimSite2023, /^A([01]\d|2[0-7]|9\d)0$/) && ['00', '99'].contains(line.eodMets))
            return line.gradePathological == '9'
        return true
    }

    // ID: IFN7092; NAME: Grade, Bladder, RX Summ--Surg Prim Site 03-2022 (SEER)
    public boolean ifn7092(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.dateOfDiagnosisYear > '2022' || line.schemaId != '00620' ||
                    line.gradePathological == null || line.rxSummSurgPrimSite == null || line.typeOfReportingSource == '7')
            return true
        
        if (functions.matches(line.rxSummSurgPrimSite, /^[01]\d|2[0-7]|9\d$/) && ['00', '99'].contains(line.eodMets))
            return line.gradePathological == '9'
        return true
    }

    // ID: IFN7093; NAME: Grade, Lymphoma, Brain/CNS (NAACCR)
    public boolean ifn7093(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2024' || line.histologicTypeIcdO3 == null)
            return true
        
        if (!['09721', '09722', '09723'].contains(line.schemaId))
            return true
        
        if (line.gradeClinical == null && line.gradePathological == null && line.gradePostTherapyClin == null && line.gradePostTherapy == null)
            return true
        
        if (functions.between(line.histologicTypeIcdO3, '9590', '9993'))
            return (line.gradeClinical == null || line.gradeClinical == '9') && (line.gradePathological == null || line.gradePathological == '9')
            && (line.gradePostTherapyClin == null || line.gradePostTherapyClin == '9') && (line.gradePostTherapy == null || line.gradePostTherapy == '9')
        
        return true
    }

    // ID: IFN7100; NAME: Grade at Autopsy (SEER)
    public boolean ifn7100(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2024' || line.schemaId == '00580')
            return true
        if (line.gradeClinical == null && line.gradePathological == null)
            return true
        
        if (line.typeOfReportingSource == '6') {
            if (line.gradeClinical != null && !['8', '9'].contains(line.gradeClinical))
                return false
            if (line.gradePathological != null && !['8', '9'].contains(line.gradePathological))
                return false
            if (line.gradePostTherapyClin != null || line.gradePostTherapy != null)
                return false
        }
        return true
    }

    // ID: IFN7103; NAME: Gleason Patterns Pathological, Grade Pathological (SEER)
    public boolean ifn7103(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.schemaId != '00580' || line.typeOfReportingSource == '6')
            return true
        
        String gleason = line.gleasonPatternsPathological
        if (gleason == null || gleason == 'X8')
            return true
        if (line.gradePathological == null || functions.matches(line.gradePathological, /^[ABCDE]$/))
            return true
        
        Integer gradeClinInt = functions.asInt(line.gradeClinical)
        Integer gradePathInt = functions.asInt(line.gradePathological)
        if (gradeClinInt != null && gradePathInt != null && gradeClinInt >= gradePathInt && gradeClinInt != 9)
            return true
        
        Integer dolcYear = functions.asInt(line.dateOfLastContactYear)
        Integer dolcMonth = functions.asInt(line.dateOfLastContactMonth)
        Integer dolcDay = functions.asInt(line.dateOfLastContactDay)
        Integer dxYear = functions.asInt(line.dateOfDiagnosisYear)
        Integer dxMonth = functions.asInt(line.dateOfDiagnosisMonth)
        Integer dxDay = functions.asInt(line.dateOfDiagnosisDay)
        if (line.vitalStatus == '0' && (Boolean)((Closure)context.compareDatesWithinMonths).call(dolcYear, dolcMonth, dolcDay, dxYear, dxMonth, dxDay, 5))
            return true
        
        if (functions.matches(gleason, /^[123][123]$/))
            return line.gradePathological == '1' 
        else if (gleason == '34')
            return line.gradePathological == '2'
        else if (gleason == '43')
            return line.gradePathological == '3'
        else if (gleason == '44' || gleason == '35' || gleason == '53')
            return line.gradePathological == '4'
        else if (gleason == '45' || gleason == '54' || gleason == '55')
            return line.gradePathological == '5'
        
        return true
    }

    // ID: IFN7104; NAME: Gleason Score Pathological, Grade Pathological (SEER)
    public boolean ifn7104(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2019' || line.schemaId != '00580' || line.typeOfReportingSource == '6')
            return true
        
        String gleason = line.gleasonScorePathological
        if (gleason == null || gleason == 'X8' || gleason == 'X9')
            return true
        if (line.gradePathological == null || functions.matches(line.gradePathological, /^[ABCD]$/))
            return true
        
        Integer gradeClinInt = functions.asInt(line.gradeClinical)
        Integer gradePathInt = functions.asInt(line.gradePathological)
        if (gradeClinInt != null && gradePathInt != null && gradeClinInt >= gradePathInt && gradeClinInt != 9)
            return true
        
        Integer dolcYear = functions.asInt(line.dateOfLastContactYear)
        Integer dolcMonth = functions.asInt(line.dateOfLastContactMonth)
        Integer dolcDay = functions.asInt(line.dateOfLastContactDay)
        Integer dxYear = functions.asInt(line.dateOfDiagnosisYear)
        Integer dxMonth = functions.asInt(line.dateOfDiagnosisMonth)
        Integer dxDay = functions.asInt(line.dateOfDiagnosisDay)
        if (line.vitalStatus == '0' && (Boolean)((Closure)context.compareDatesWithinMonths).call(dolcYear, dolcMonth, dolcDay, dxYear, dxMonth, dxDay, 5))
            return true
        
        if (functions.matches(gleason, /^0[1-6]$/))
            return line.gradePathological == '1'
        else if (gleason == '07')
            return line.gradePathological == '2' || line.gradePathological == '3' || line.gradePathological == 'E'
        else if (gleason == '08')
            return line.gradePathological == '4'
        else if (gleason == '09' || gleason == '10')
            return line.gradePathological == '5'
        
        return true
    }

    // ID: IFN7162; NAME: Cancer Items, Type Reporting Source-DCO (SEER)
    public boolean ifn7162(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2018' || line.typeOfReportingSource != '7' || line.schemaId == null)
            return true
        
        if (line.behaviorCodeIcdO3 == '2' || ((line.behaviorCodeIcdO3 == '0' || line.behaviorCodeIcdO3 == '1') && !functions.matches(line.schemaId, /^0072[123]|0972[1-4]$/)))
            return true
        
        if ((line.gradeClinical != null && line.gradeClinical != '8' && line.gradeClinical != '9'))
             return false
        if (line.gradePathological != null && line.gradePathological != '8' && line.gradePathological != '9')
            return false
        if (line.gradePostTherapy != null || line.gradePostTherapyClin != null)
            return false
        if ((line.metsAtDxBone != null && line.metsAtDxBone != '8' && line.metsAtDxBone != '9') || (line.metsAtDxBrain != null && line.metsAtDxBrain != '8' && line.metsAtDxBrain != '9'))
            return false
        if ((line.metsAtDxDistantLn != null && line.metsAtDxDistantLn != '8' && line.metsAtDxDistantLn != '9') || (line.metsAtDxLiver != null && line.metsAtDxLiver != '8' && line.metsAtDxLiver != '9'))
            return false
        if ((line.metsAtDxLung != null && line.metsAtDxLung != '8' && line.metsAtDxLung != '9') || (line.metsAtDxOther != null && line.metsAtDxOther != '8' && line.metsAtDxOther != '9'))
            return false
        if (line.lymphVascularInvasion != null && line.lymphVascularInvasion != '8' && line.lymphVascularInvasion != '9')
            return false
        if ((line.neoadjuvantTherapy != null && line.neoadjuvantTherapy != '9') || (line.neoadjuvTherapyTreatmentEffect != null && line.neoadjuvTherapyTreatmentEffect != '9'))
            return false
        if (line.neoadjuvTherapyClinicalResponse != null && line.neoadjuvTherapyClinicalResponse != '9')
            return false
        if ((line.regionalNodesPositive != null && line.regionalNodesPositive != '99') || (line.regionalNodesExamined != null && line.regionalNodesExamined != '99'))
            return false
        if ((line.tumorSizeClinical != null && line.tumorSizeClinical != '999') || (line.tumorSizePathologic != null && line.tumorSizePathologic != '999'))
            return false
        if (line.tumorSizeSummary != null && line.tumorSizeSummary != '999')
            return false
        if (line.vitalStatus == null || line.vitalStatus != '0')
            return false
        if (line.icdRevisionNumber == null || !functions.matches(line.icdRevisionNumber, /^[1789]$/))
            return false
        if (line.diagnosticConfirmation != null && !['3','9'].contains(line.diagnosticConfirmation))
            return false
        
        if (line.dateOfDiagnosisYear >= '2023' && line.summaryStage2018 != null && line.summaryStage2018 != '9')
            return false
        
        return true
    }

    // ID: IHS_Link; NAME: IHS Link (NPCR)
    public boolean ihs_link(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return  line.ihsLink == null || functions.matches(line.ihsLink, /^([01])$/)
    }

    // ID: Laterality; NAME: Laterality (SEER LATERAL)
    public boolean laterality(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return  functions.matches(line.laterality, /^[0123459]$/)
    }

    // ID: Lymph_vascular_invasion; NAME: Lymphovascular Invasion (SEER)
    public boolean lymph_vascular_invasion(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return  line.lymphVascularInvasion == null || functions.matches(line.lymphVascularInvasion, /^[0-489\s]$/)
    }

    // ID: Marital_Status_at_DX; NAME: Marital Status at DX (SEER MARITAL)
    public boolean marital_status_at_dx(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.maritalStatusAtDx == null || functions.matches(line.maritalStatusAtDx, /^[1234569]$/)
    }

    // ID: Marital_Status_DX_Submission; NAME: SEER Submission Edit 02 (SEER)
    public boolean marital_status_dx_submission(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.registryId == '0000001542' && (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2000'))
            return true
        if (line.registryId == '0000001565' && (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2023'))
            return true
        if (line.registryId == '0000001566' && (line.dateOfDiagnosisYear == null || line.dateOfDiagnosisYear < '2022'))
            return true
        return line.maritalStatusAtDx != null
    }

    // ID: Mets_at_DX_Bone; NAME: Mets at DX-Bone (SEER)
    public boolean mets_at_dx_bone(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.metsAtDxBone == null || functions.matches(line.metsAtDxBone, /^[0189]$/)
    }

    // ID: Mets_at_DX_Brain; NAME: Mets at DX-Brain (SEER)
    public boolean mets_at_dx_brain(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.metsAtDxBrain == null || functions.matches(line.metsAtDxBrain, /^[0189]$/)
    }

    // ID: Mets_at_DX_Distant_LN; NAME: Mets at DX-Distant LN (SEER)
    public boolean mets_at_dx_distant_ln(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.metsAtDxDistantLn == null || functions.matches(line.metsAtDxDistantLn, /^[0189]$/)
    }

    // ID: Mets_at_DX_Liver; NAME: Mets at DX-Liver (SEER)
    public boolean mets_at_dx_liver(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.metsAtDxLiver == null || functions.matches(line.metsAtDxLiver, /^[0189]$/)
    }

    // ID: Mets_at_DX_Lung; NAME: Mets at DX-Lung (SEER)
    public boolean mets_at_dx_lung(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.metsAtDxLung == null || functions.matches(line.metsAtDxLung, /^[0189]$/)
    }

    // ID: Mets_at_DX_Other; NAME: Mets at DX-Other (SEER)
    public boolean mets_at_dx_other(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.metsAtDxOther == null || functions.matches(line.metsAtDxOther, /^[01289]$/)
    }

    // ID: Month_BRM; NAME: RX Date BRM (COC)
    public boolean month_brm(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxDateBrmMonth == null || line.rxDateBrmMonth  ==~ /^(0[1-9]|1[0-2])$/
    }

    // ID: Month_Chemo; NAME: RX Date Chemo (COC)
    public boolean month_chemo(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxDateChemoMonth == null || line.rxDateChemoMonth  ==~ /^(0[1-9]|1[0-2])$/
    }

    // ID: Month_Hormone; NAME: RX Date Hormone (COC)
    public boolean month_hormone(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxDateHormoneMonth == null || line.rxDateHormoneMonth  ==~ /^(0[1-9]|1[0-2])$/
    }

    // ID: Month_Most_Defin_Surg; NAME: RX Date Mst Defn Srg (COC)
    public boolean month_most_defin_surg(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxDateMostDefinSurgMonth == null || functions.matches(line.rxDateMostDefinSurgMonth, /^(0[1-9]|1[0-2])$/)
    }

    // ID: Month_of_Birth; NAME: Date of Birth (NAACCR)
    public boolean month_of_birth(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return  line.dateOfBirthMonth == null || functions.matches(line.dateOfBirthMonth, /^(0[1-9]|1[0-2])$/)
    }

    // ID: Month_of_Diagnosis; NAME: Date of Diagnosis (NAACCR DATEEDIT)
    public boolean month_of_diagnosis(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.dateOfDiagnosisMonth == null || functions.matches(line.dateOfDiagnosisMonth, /^(0[1-9]|1[0-2])$/)
    }

    // ID: Month_of_Initial_RX-SEER; NAME: Date Initial RX SEER (NAACCR)
    public boolean month_of_initial_rxSeer(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.dateInitialRxSeerMonth == null || line.dateInitialRxSeerMonth  ==~ /^(0[1-9]|1[0-2])$/
    }

    // ID: Month_of_Last_Contact; NAME: Date of Last Contact (NAACCR DATEEDIT)
    public boolean month_of_last_contact(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.dateOfLastContactMonth == null || functions.matches(line.dateOfLastContactMonth, /^(0[1-9]|1[0-2])$/)
    }

    // ID: Month_Other; NAME: RX Date Other (COC)
    public boolean month_other(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxDateOtherMonth == null || line.rxDateOtherMonth  ==~ /^(0[1-9]|1[0-2])$/
    }

    // ID: Month_Radiation; NAME: RX Date Radiation (COC)
    public boolean month_radiation(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxDateRadiationMonth == null || line.rxDateRadiationMonth  ==~ /^(0[1-9]|1[0-2])$/
    }

    // ID: Month_Recurrence_Date_1st; NAME: Recurrence Date--1st (COC)
    public boolean month_recurrence_date_1st(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.recurrenceDate1stMonth == null || line.recurrenceDate1stMonth  ==~ /^(0[1-9]|1[0-2])$/
    }

    // ID: Month_Regional_Lymph_Node_Dissection; NAME: Date Regional Lymph Node Dissection (COC)
    public boolean month_regional_lymph_node_dissection(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.dateRegionalLNDissectionMonth == null || line.dateRegionalLNDissectionMonth  ==~ /^(0[1-9]|1[0-2])$/
    }

    // ID: Month_Sentinel_Lymph_Node_Biopsy; NAME: Date of Sentinel Lymph Node Biopsy (COC)
    public boolean month_sentinel_lymph_node_biopsy(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.dateSentinelLymphNodeBiopsyMonth == null || line.dateSentinelLymphNodeBiopsyMonth  ==~ /^(0[1-9]|1[0-2])$/
    }

    // ID: Month_Surgery; NAME: RX Date Surgery (COC)
    public boolean month_surgery(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxDateSurgeryMonth == null || functions.matches(line.rxDateSurgeryMonth, /^(0[1-9]|1[0-2])$/)
    }

    // ID: Month_SurvDateActiveFollowup; NAME: Surv-Date Active Followup (SEER)
    public boolean month_survdateactivefollowup(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.survDateActiveFollowupMonth == null || functions.matches(line.survDateActiveFollowupMonth, /^(0[1-9]|1[0-2])$/)
    }

    // ID: Month_SurvDateDXRecode; NAME: Surv-Date DX Recode (SEER)
    public boolean month_survdatedxrecode(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.survDateDxRecodeMonth == null || functions.matches(line.survDateDxRecodeMonth, /^(0[1-9]|1[0-2])$/)
    }

    // ID: Month_SurvDatePresumedAlive; NAME: Surv-Date Presumed Alive (SEER)
    public boolean month_survdatepresumedalive(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.survDatePresumedAliveMonth == null || functions.matches(line.survDatePresumedAliveMonth, /^(0[1-9]|1[0-2])$/)
    }

    // ID: Month_Systemic; NAME: RX Date Systemic (COC)
    public boolean month_systemic(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxDateSystemicMonth == null || functions.matches(line.rxDateSystemicMonth, /^(0[1-9]|1[0-2])$/)
    }

    // ID: MorphICDO3_P1; NAME: Morphology--Type/Behavior ICDO3 (SEER MORPH)
    public boolean morphicdo3_p1(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null && line.behaviorCodeIcdO3 == null)
            return true
        
        if (line.dateOfDiagnosisYear < '2010' && [9751,9831,9975].contains(functions.asInt(line.histologicTypeIcdO3)) && (line.behaviorCodeIcdO3 == '3' || line.behaviorCodeIcdO3 == '2'))
            return line.overRideHistology == '1' || line.overRideHistology == '3'
        if (line.dateOfDiagnosisYear > '2009' && [9751,9831,9975].contains(functions.asInt(line.histologicTypeIcdO3)) && (line.behaviorCodeIcdO3 == '3' || line.behaviorCodeIcdO3 == '2'))
             return line.overRideHistology == null
        if (line.dateOfDiagnosisYear < '2010' && ((List)context.Morph_ICDO3_2010).contains(functions.asInt(line.histologicTypeIcdO3)))
            return false
        
        if (line.dateOfDiagnosisYear < '2018' && [8213,8311,8825,8842,8983,9302,9341].contains(functions.asInt(line.histologicTypeIcdO3)) && line.behaviorCodeIcdO3 == '3')
            return line.overRideHistology == '1' || line.overRideHistology == '3'
        if (line.dateOfDiagnosisYear > '2017' && [8213,8311,8825,8842,8983,9302,9341].contains(functions.asInt(line.histologicTypeIcdO3)) && line.behaviorCodeIcdO3 == '3')
             return line.overRideHistology == null
        if (line.dateOfDiagnosisYear < '2018' && ((List)context.Morph_ICDO3_2018).contains(functions.asInt(line.histologicTypeIcdO3)))
            return false
        
        if (line.dateOfDiagnosisYear < '2021' && [8158,8681,8682,8690,9766].contains(functions.asInt(line.histologicTypeIcdO3)) && line.behaviorCodeIcdO3 == '3')
            return line.overRideHistology == '1' || line.overRideHistology == '3'
        if (line.dateOfDiagnosisYear > '2020' && [8158,8681,8682,8690,9766].contains(functions.asInt(line.histologicTypeIcdO3)) && line.behaviorCodeIcdO3 == '3')
             return line.overRideHistology == null
        if (line.dateOfDiagnosisYear < '2021' && ((List)context.Morph_ICDO3_2021).contains(functions.asInt(line.histologicTypeIcdO3)))
            return false
        
        if (line.dateOfDiagnosisYear < '2022' && line.histologicTypeIcdO3 == '9222' && line.behaviorCodeIcdO3 == '3')
            return line.overRideHistology == '1' || line.overRideHistology == '3'
        if (line.dateOfDiagnosisYear > '2021' && line.histologicTypeIcdO3 == '9222' && line.behaviorCodeIcdO3 == '3')
             return line.overRideHistology == null
        if (line.dateOfDiagnosisYear < '2022' && ((List)context.Morph_ICDO3_2022).contains(functions.asInt(line.histologicTypeIcdO3)))
            return false
        
        if (line.dateOfDiagnosisYear < '2023' && [9174,9509].contains(functions.asInt(line.histologicTypeIcdO3)) && line.behaviorCodeIcdO3 == '3')
            return line.overRideHistology == '1' || line.overRideHistology == '3' || line.overRideSiteType == '1'
        if (line.dateOfDiagnosisYear > '2022' && [9174,9509].contains(functions.asInt(line.histologicTypeIcdO3)) && line.behaviorCodeIcdO3 == '3')
            return line.overRideHistology == null
        if (line.dateOfDiagnosisYear < '2023' && ((line.histologicTypeIcdO3 == '9509' && line.behaviorCodeIcdO3 == '0') || (line.histologicTypeIcdO3 == '9749' && line.behaviorCodeIcdO3 == '1')))
            return false
        
        if (line.dateOfDiagnosisYear < '2024' && line.histologicTypeIcdO3 == '9104' && line.behaviorCodeIcdO3 == '3')
            return line.overRideHistology == '1' || line.overRideHistology == '3' || line.overRideSiteType == '1'
        if (line.dateOfDiagnosisYear > '2023' && line.histologicTypeIcdO3 == '9104' && line.behaviorCodeIcdO3 == '3')
            return line.overRideHistology == null
        
        return true
    }

    // ID: MorphICDO3_P3; NAME: Histologic Type ICD-O-3, Behavior, Grade (SEER)
    public boolean morphicdo3_p3(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null || line.behaviorCodeIcdO3 == null || line.grade == null || (line.dateOfDiagnosisYear != null && line.dateOfDiagnosisYear > '2017'))
            return true
        
        if (functions.between(line.grade, '5', '8') && !functions.between(line.histologicTypeIcdO3, '9590', '9992'))
            return false
        
        // Grade of 9 is allowed for some histologies with unknown primary site
        if (['8020', '8021', '9082', '9083'].contains(line.histologicTypeIcdO3) && '3' == line.behaviorCodeIcdO3 && 'C809' == line.primarySite && '9' == line.grade)
            return true
        
        if (line.behaviorCodeIcdO3 == '3' && ((Map)context.Morph_ICD03_Grade_Hists).containsKey(line.histologicTypeIcdO3))
            if (line.grade != (String)((Map)context.Morph_ICD03_Grade_Hists).getOrDefault(line.histologicTypeIcdO3, ''))
                return false
        
        return true
    }

    // ID: MorphICDO3_P4; NAME: Morphology--Type/Behavior ICDO3 (SEER MORPH)
    public boolean morphicdo3_p4(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.histologicTypeIcdO3 == null && line.behaviorCodeIcdO3 == null)
           return true
        
        if (line.histologicTypeIcdO3 == '9421') {
            if (line.behaviorCodeIcdO3 == '1')
                return line.dateOfDiagnosisYear >= '2023' || (line.primarySite == 'C723' && line.dateOfDiagnosisYear >= '2018')
            return line.behaviorCodeIcdO3 == '3'
        }
        
        if (line.histologicTypeIcdO3 == '8077')
            return line.behaviorCodeIcdO3 != '3'
        
        if (line.histologicTypeIcdO3 == '8343' && line.behaviorCodeIcdO3 == '2' && line.dateOfDiagnosisYear < '2017')
            return line.overRideHistology == '1' || line.overRideHistology == '3'
        
        if (line.histologicTypeIcdO3 == '8519')
            return line.behaviorCodeIcdO3 == '2'
        
        if (line.histologicTypeIcdO3 == '9540' && line.dateOfDiagnosisYear > '2017')
            return line.behaviorCodeIcdO3 != '1'
        
        if (line.behaviorCodeIcdO3 == '2') {
            if (line.dateOfDiagnosisYear >= '2023' && line.histologicTypeIcdO3 == '9050')
                return true
            else if (line.overRideHistology != '1' && line.overRideHistology != '3')
                return !((List)((Map)context.SpecInSituEdit).getOrDefault('Invalid_ICD_O_3_Histology_for_In_Situ_(Morph_3)', [])).contains(functions.asInt(line.histologicTypeIcdO3))
        }
        
        if (line.behaviorCodeIcdO3 == '3' && line.dateOfDiagnosisYear >= '2021' && line.overRideHistology != '1' && line.overRideHistology != '3')
           return ![8833, 9725, 9260, 9971].contains(functions.asInt(line.histologicTypeIcdO3))
        
        return true
    }

    // ID: NCDB--COVID19--Tx_Impact; NAME: NCDB--COVID19--Tx Impact (COC)
    public boolean ncdbCovid19Tx_impact(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.ncdbCovid19TxImpact == null || functions.matches(line.ncdbCovid19TxImpact, /^[1-59]$/)
    }

    // ID: NCDB--SARSCoV2--Pos; NAME: NCDB--SARSCoV2--Pos (COC)
    public boolean ncdbSarscov2Pos(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.ncdbSarsCov2Pos == null || line.ncdbSarsCov2Pos == '0' || line.ncdbSarsCov2Pos == '1' || line.ncdbSarsCov2Pos == '9'
    }

    // ID: NCDB--SARSCoV2--Pos_Date; NAME: NCDB--SARSCoV2--Pos Date (COC)
    public boolean ncdbSarscov2Pos_date(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.ncdbSarsCov2PosDateYear== null)
           return (line.ncdbSarsCov2PosDateMonth == null && line.ncdbSarsCov2PosDateDay == null)
        
        if (line.ncdbSarsCov2PosDateYear < '2019')
            return false
        
        Integer year = functions.asInt(line.ncdbSarsCov2PosDateYear)
        Integer month = functions.asInt(line.ncdbSarsCov2PosDateMonth)
        Integer day = functions.asInt(line.ncdbSarsCov2PosDateDay)
        
        Integer yearCur  = functions.getCurrentYear()
        Integer monthCur = functions.getCurrentMonth()
        Integer dayCur = functions.getCurrentDay()
        
        if ((line.ncdbSarsCov2PosDateMonth == null && line.ncdbSarsCov2PosDateDay != null) || (month > 12 || (line.ncdbSarsCov2PosDateMonth != null && month < 1)))
           return false
        
        if (!functions.between(year, 1930, yearCur))
            return false
        
        if (line.ncdbSarsCov2PosDateMonth == null) //by now year fits and day is null if month is null
            return true
        
        if (year == yearCur && month > monthCur)
            return false
        
        if (line.ncdbSarsCov2PosDateDay == null) //by now year and month fit
            return true
        
        if (year == yearCur && month == monthCur && day > dayCur)
            return false
        
        Calendar cal = new GregorianCalendar(year, month - 1, 1)
        return cal != null && day <= cal.getActualMaximum(Calendar.DAY_OF_MONTH)
    }

    // ID: NCDB--SARSCoV2--Test; NAME: NCDB--SARSCoV2--Test (COC)
    public boolean ncdbSarscov2Test(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.ncdbSarsCov2Test == null || line.ncdbSarsCov2Test == '0' || line.ncdbSarsCov2Test == '1' || line.ncdbSarsCov2Test == '9'
    }

    // ID: NHIA_Data_Element; NAME: NHIA Derived Hisp Origin (NAACCR)
    public boolean nhia_data_element(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.nhiaDerivedHispOrigin == null || functions.matches(line.nhiaDerivedHispOrigin, /^[0-8]$/)
    }

    // ID: NHIA_Derived_Hisp_Origin_Submission; NAME: SEER Submission Edit 01 (SEER)
    public boolean nhia_derived_hisp_origin_submission(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.nhiaDerivedHispOrigin != null
    }

    // ID: Number_of_Phases_of_Rad_Treament_to_This_Volume; NAME: Number of Phases of Rad Treatment to This Volume (COC)
    public boolean number_of_phases_of_rad_treament_to_this_volume(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.numberPhasesOfRadTxToVolume == null || line.dateOfDiagnosisYear == null)
            return true
        
        if (line.dateOfDiagnosisYear >= '2021')
            return functions.matches(line.numberPhasesOfRadTxToVolume, /^[0-9][0-9]$/)
        
        return functions.matches(line.numberPhasesOfRadTxToVolume, /^0[0-4]|99$/)
    }

    // ID: Over-ride_Age-Site-Morph; NAME: Edit Over-rides (SEER REVIEWFL)
    public boolean overRide_ageSiteMorph(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return  line.overRideAgeSiteMorph == null || functions.matches(line.overRideAgeSiteMorph, /^[123\s]$/)
    }

    // ID: Over-ride_Histology; NAME: Edit Over-rides (SEER REVIEWFL)
    public boolean overRide_histology(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.overRideHistology == null || functions.matches(line.overRideHistology, /^[123\s]$/)
    }

    // ID: Over-ride_Ill-defined_Site; NAME: Edit Over-rides (SEER REVIEWFL)
    public boolean overRide_illDefined_site(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.overRideIllDefineSite == null || functions.matches(line.overRideIllDefineSite, /^[1\s]$/)
    }

    // ID: Over-ride_Leuk_Lymphoma; NAME: Edit Over-rides (SEER REVIEWFL)
    public boolean overRide_leuk_lymphoma(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.overRideLeukLymphoma == null || functions.matches(line.overRideLeukLymphoma, /^[1\s]$/)
    }

    // ID: Over-ride_Report_Source; NAME: Edit Over-rides (SEER REVIEWFL)
    public boolean overRide_report_source(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.overRideReportSource == null || functions.matches(line.overRideReportSource, /^[1\s]$/)
    }

    // ID: Over-ride_Seqno-Dxconf; NAME: Edit Over-rides (SEER REVIEWFL)
    public boolean overRide_seqnoDxconf(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.overRideSeqnoDxconf == null || functions.matches(line.overRideSeqnoDxconf, /^[1]$/)
    }

    // ID: Over-ride_Site-Behavior; NAME: Edit Over-rides (SEER REVIEWFL)
    public boolean overRide_siteBehavior(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return  line.overRideSiteBehavior == null || functions.matches(line.overRideSiteBehavior, /^[1\s]$/)
    }

    // ID: Over-ride_Site-EOD-DX_Dt; NAME: Edit Over-rides (SEER REVIEWFL)
    public boolean overRide_siteEodDx_dt(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.overRideSiteEodDxDt == null || functions.matches(line.overRideSiteEodDxDt, /^[1\s]$/)
    }

    // ID: Over-ride_Site-Lat-EOD; NAME: Edit Over-rides (SEER REVIEWFL)
    public boolean overRide_siteLatEod(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.overRideSiteLatEod == null || functions.matches(line.overRideSiteLatEod, /^[1\s]$/)
    }

    // ID: Over-ride_Site-Lat-Morph; NAME: Edit Over-rides (SEER REVIEWFL)
    public boolean overRide_siteLatMorph(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.overRideSiteLatMorph == null || functions.matches(line.overRideSiteLatMorph, /^[1\s]$/)
    }

    // ID: Over-ride_Site-Lat-Seqno; NAME: Edit Over-rides (SEER REVIEWFL)
    public boolean overRide_siteLatSeqno(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.overRideSiteLatSeqno == null || functions.matches(line.overRideSiteLatSeqno, /^[1\s]$/)
    }

    // ID: Over-ride_Site-Type; NAME: Edit Over-rides (SEER REVIEWFL)
    public boolean overRide_siteType(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.overRideSiteType == null || functions.matches(line.overRideSiteType, /^[1\s]$/)
    }

    // ID: Over-ride_Surg-Dxconf; NAME: Edit Over-rides (SEER REVIEWFL)
    public boolean overRide_surgDxconf(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.overRideSurgDxconf == null || functions.matches(line.overRideSurgDxconf, /^[1\s]$/)
    }

    // ID: Patient_ID_Number; NAME: Patient ID Number (SEER CASENUM)
    public boolean patient_id_number(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.patientIdNumber != null && functions.matches(line.patientIdNumber, /^[0-9]{8}$/)
    }

    // ID: PhIII_Dose_per_Fraction; NAME: PhIII Dose per Fraction (COC)
    public boolean phiii_dose_per_fraction(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.phase3DosePerFraction == null || functions.matches(line.phase3DosePerFraction, /^\d{5}$/)
    }

    // ID: PhIII_Number_of_Fractions; NAME: PhIII Number of Fractions (COC)
    public boolean phiii_number_of_fractions(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.phase3NumberOfFractions == null || functions.matches(line.phase3NumberOfFractions, /^\d{3}$/)
    }

    // ID: PhIII_Radiation_External_Beam_Planning_Tech; NAME: PhIII Radiation External Beam Planning Tech (COC)
    public boolean phiii_radiation_external_beam_planning_tech(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.phase3RadiationExternalBeamTech == null || functions.matches(line.phase3RadiationExternalBeamTech, /^0\d|10|88|98|99$/)
    }

    // ID: PhIII_Radiation_Primary_Treatment_Volume; NAME: PhIII Radiation Primary Treatment Volume (COC)
    public boolean phiii_radiation_primary_treatment_volume(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.phase3RadiationPrimaryTxVolume == null || functions.matches(line.phase3RadiationPrimaryTxVolume, /^0[0-79]|1[0-4]|2[0-69]|3[0-29]|4[0-2]|5\d|6[0-8]|7[0-3]|8[0-68]|9[0-689]$/)
    }

    // ID: PhIII_Radiation_to_Draining_Lymph_Nodes; NAME: PhIII Radiation to Draining Lymph Nodes (COC)
    public boolean phiii_radiation_to_draining_lymph_nodes(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.phase3RadiationToDrainingLN == null || functions.matches(line.phase3RadiationToDrainingLN, /^0[0-8]|88|99$/)
    }

    // ID: PhIII_Radiation_Treatment_Modality; NAME: PhIII Radiation Treatment Modality (COC)
    public boolean phiii_radiation_treatment_modality(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.phase3RadiationTreatmentModality == null || functions.matches(line.phase3RadiationTreatmentModality, /^0\d|1[0-6]|98|99$/)
    }

    // ID: PhIII_Total_Dose; NAME: PhIII Total Dose (COC)
    public boolean phiii_total_dose(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.phase3TotalDose == null || functions.matches(line.phase3TotalDose, /^\d{6}$/)
    }

    // ID: PhII_Dose_per_Fraction; NAME: PhII Dose per Fraction (COC)
    public boolean phii_dose_per_fraction(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.phase2DosePerFraction == null || functions.matches(line.phase2DosePerFraction, /^\d{5}$/)
    }

    // ID: PhII_Number_of_Fractions; NAME: PhII Number of Fractions (COC)
    public boolean phii_number_of_fractions(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.phase2NumberOfFractions == null || functions.matches(line.phase2NumberOfFractions, /^\d{3}$/)
    }

    // ID: PhII_Radiation_External_Beam_Planning_Tech; NAME: PhII Radiation External Beam Planning Tech (COC)
    public boolean phii_radiation_external_beam_planning_tech(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.phase2RadiationExternalBeamTech == null || functions.matches(line.phase2RadiationExternalBeamTech, /^0\d|10|88|98|99$/)
    }

    // ID: PhII_Radiation_Primary_Treatment_Volume; NAME: PhII Radiation Primary Treatment Volume (COC)
    public boolean phii_radiation_primary_treatment_volume(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.phase2RadiationPrimaryTxVolume == null || functions.matches(line.phase2RadiationPrimaryTxVolume, /^0[0-79]|1[0-4]|2[0-69]|3[0-29]|4[0-2]|[59]\d|6[0-8]|7[0-3]|8[0-68]$/)
    }

    // ID: PhII_Radiation_to_Draining_Lymph_Nodes; NAME: PhII Radiation to Draining Lymph Nodes (COC)
    public boolean phii_radiation_to_draining_lymph_nodes(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.phase2RadiationToDrainingLN == null || functions.matches(line.phase2RadiationToDrainingLN, /^0[0-8]|88|99$/)
    }

    // ID: PhII_Radiation_Treatment_Modality; NAME: PhII Radiation Treatment Modality (COC)
    public boolean phii_radiation_treatment_modality(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.phase2RadiationTreatmentModality == null || functions.matches(line.phase2RadiationTreatmentModality, /^0\d|1[0-6]|98|99$/)
    }

    // ID: PhII_Total_Dose; NAME: PhII Total Dose (COC)
    public boolean phii_total_dose(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.phase2TotalDose == null || functions.matches(line.phase2TotalDose, /^\d{6}$/)
    }

    // ID: PhI_Dose_per_Fraction; NAME: PhI Dose per Fraction (COC)
    public boolean phi_dose_per_fraction(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.phase1DosePerFraction == null || functions.matches(line.phase1DosePerFraction, /^\d{5}$/)
    }

    // ID: PhI_Number_of_Fractions; NAME: PhI Number of Fractions (COC)
    public boolean phi_number_of_fractions(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.phase1NumberOfFractions == null || functions.matches(line.phase1NumberOfFractions, /^\d{3}$/)
    }

    // ID: PhI_Radiation_External_Beam_Planning_Tech; NAME: PhI Radiation External Beam Planning Tech (COC)
    public boolean phi_radiation_external_beam_planning_tech(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.phase1RadiationExternalBeamTech == null || functions.matches(line.phase1RadiationExternalBeamTech, /^0\d|10|88|98|99$/)
    }

    // ID: PhI_Radiation_Primary_Treatment_Volume; NAME: PhI Radiation Primary Treatment Volume (COC)
    public boolean phi_radiation_primary_treatment_volume(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.phase1RadiationPrimaryTxVolume == null || functions.matches(line.phase1RadiationPrimaryTxVolume, /^0[0-79]|1[0-4]|2[0-69]|3[0-29]|4[0-2]|[59]\d|6[0-8]|7[0-3]|8[0-68]$/)
    }

    // ID: PhI_Radiation_to_Draining_Lymph_Nodes; NAME: PhI Radiation to Draining Lymph Nodes (COC)
    public boolean phi_radiation_to_draining_lymph_nodes(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.phase1RadiationToDrainingLN == null || functions.matches(line.phase1RadiationToDrainingLN, /^0[0-8]|88|99$/)
    }

    // ID: PhI_Radiation_Treatment_Modality; NAME: PhI Radiation Treatment Modality (COC)
    public boolean phi_radiation_treatment_modality(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.phase1RadiationTreatmentModality == null || functions.matches(line.phase1RadiationTreatmentModality, /^0\d|1[0-6]|98|99$/)
    }

    // ID: PhI_Total_Dose; NAME: PhI Total Dose (COC)
    public boolean phi_total_dose(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.phase1TotalDose == null || functions.matches(line.phase1TotalDose, /^\d{6}$/)
    }

    // ID: Place_of_Death_Country; NAME: Place of Death--Country (NAACCR)
    public boolean place_of_death_country(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.placeOfDeathCountry == null || ((Map)context.Country_State).containsKey(line.placeOfDeathCountry)
    }

    // ID: Place_of_Death_State; NAME: Place of Death--State (NAACCR)
    public boolean place_of_death_state(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.placeOfDeathState == null || ((Map)context.State).containsKey(line.placeOfDeathState)
    }

    // ID: Primary_Payer_at_DX; NAME: Primary Payer at DX (NPCR)
    public boolean primary_payer_at_dx(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.primaryPayerAtDx == null || functions.matches(line.primaryPayerAtDx, /(^0[12]$)|(^10$)|(^2[01]$)|(^3[15]$)|(^6[0-8]$)|(^99$)/)
    }

    // ID: Primary_Site; NAME: Primary Site (SEER SITE)
    public boolean primary_site(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (functions.matches(line.primarySite, /^C\d\d\d$/))
            return ((List)context.Primary_Site_Table).contains(functions.asInt(line.primarySite.substring(1)))
        
        return false
    }

    // ID: Race_1; NAME: Race 1 (SEER RACE)
    public boolean race_1(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.race1 != null && functions.matches(line.race1, /(^0[1-8]$)|(^1[0-7]$)|(^2[0125678]$)|(^3[012]$)|(^9[6789]$)/)
    }

    // ID: Race_2; NAME: Race 2 (NAACCR)
    public boolean race_2(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.race2 == null || functions.matches(line.race2, /(^0[1-8]$)|(^1[0-7]$)|(^2[0125678]$)|(^3[012]$)|(^88$)|(^9[6789]$)|(^\s\s$)/)
    }

    // ID: Race_3; NAME: Race 3 (NAACCR)
    public boolean race_3(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return  line.race3 == null || functions.matches(line.race3, /(^0[1-8]$)|(^1[0-7]$)|(^2[0125678]$)|(^3[012]$)|(^88$)|(^9[6789]$)|(^\s\s$)/)
    }

    // ID: Race_4; NAME: Race 4 (NAACCR)
    public boolean race_4(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.race4 == null || functions.matches(line.race4, /(^0[1-8]$)|(^1[0-7]$)|(^2[0125678]$)|(^3[012]$)|(^88$)|(^9[6789]$)|(^\s\s$)/)
    }

    // ID: Race_5; NAME: Race 5 (NAACCR)
    public boolean race_5(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return  line.race5 == null || functions.matches(line.race5, /(^0[1-8]$)|(^1[0-7]$)|(^2[0125678]$)|(^3[012]$)|(^88$)|(^9[6789]$)|(^\s\s$)/)
    }

    // ID: Race_NAPIIA; NAME: Race--NAPIIA(derived API) (NAACCR)
    public boolean race_napiia(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.raceNapiia == null || functions.matches(line.raceNapiia, /(^0[1-8]$)|(^1[0-7]$)|(^2[0125678]$)|(^3[012]$)|(^9[6789]$)/)
    }

    // ID: Radiation_Treatment_Discontinued_Early; NAME: Radiation Treatment Discontinued Early (COC)
    public boolean radiation_treatment_discontinued_early(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.radiationTxDiscontinuedEarly == null || functions.matches(line.radiationTxDiscontinuedEarly, /^0[0-7]|99$/)
    }

    // ID: Reason_for_No_Radiation; NAME: Reason for No Radiation (NAACCR)
    public boolean reason_for_no_radiation(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.reasonForNoRadiation == null || functions.matches(line.reasonForNoRadiation, /^[0-25-9]$/)
    }

    // ID: Reason_for_No_Surgery; NAME: Reason for No Surgery (NPCR)
    public boolean reason_for_no_surgery(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.reasonForNoSurgery == null || functions.matches(line.reasonForNoSurgery, /^[0125-9]$/)
    }

    // ID: Record_Number_Recode; NAME: Record Number Recode (NAACCR)
    public boolean record_number_recode(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.recordNumberRecode == null || functions.matches(line.recordNumberRecode, /^[1-9]\d|0[1-9]$/)
    }

    // ID: Record_Number_Recode_Submission; NAME: Record Number Recode Submission
    public boolean record_number_recode_submission(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return  line.recordNumberRecode != null
    }

    // ID: Record_Type; NAME: Record Type (NAACCR)
    public boolean record_type(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return functions.matches(line.recordType, /^[ICAUM]$/)
    }

    // ID: Recurrence_Type_1st; NAME: Recurrence Type--1st (NAACCR)
    public boolean recurrence_type_1st(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.recurrenceType1st == null)
            return true
        return functions.matches(line.recurrenceType1st, /^0[046]|1[03-7]|2[0-25-7]|[34][06]|5[1-9]|60|62|70|88|99$/)
    }

    // ID: RecurrenceDate1stEdit; NAME: Recurrence Date--1st (COC)
    public boolean recurrencedate1stedit(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer year = functions.asInt(line.recurrenceDate1stYear)
        Integer month = functions.asInt(line.recurrenceDate1stMonth)
        Integer day = functions.asInt(line.recurrenceDate1stDay)
        
        Integer yearCur  = functions.getCurrentYear()
        Integer monthCur = functions.getCurrentMonth()
        Integer dayCur = functions.getCurrentDay()
        
        if (line.recurrenceDate1stYear == null)
           return (line.recurrenceDate1stMonth == null && line.recurrenceDate1stDay == null)
        
        if ((line.recurrenceDate1stMonth == null && line.recurrenceDate1stDay != null) || (month > 12 || (line.recurrenceDate1stMonth != null && month < 1)))
           return false
        
        if (!functions.between(year, 1930, yearCur))
            return false
        
        if (line.recurrenceDate1stMonth == null) //by now year fits and day is null if month is null
            return true
        
        if (year == yearCur && month > monthCur)
            return false
        
        if (line.recurrenceDate1stDay == null) //by now year and month fit
            return true
        
        if (year == yearCur && month == monthCur && day > dayCur)
            return false
        
        Calendar cal = new GregorianCalendar(year, month - 1, 1)
        return cal != null && day <= cal.getActualMaximum(Calendar.DAY_OF_MONTH)
    }

    // ID: RegCounty; NAME: County (SEER IFCOUNTY)
    public boolean regcounty(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return ((List)((Map)context.registry_county).getOrDefault(functions.asInt(line.registryId), [])).contains(functions.asInt(line.countyAtDxAnalysis))
    }

    // ID: Regional_Nodes_Examined; NAME: Regional Nodes Examined (NAACCR)
    public boolean regional_nodes_examined(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.regionalNodesExamined == null || functions.matches(line.regionalNodesExamined, /(^[0-8][0-9]|9[05-9]$)/)
    }

    // ID: Regional_Nodes_Positive; NAME: Regional Nodes Positive (NAACCR)
    public boolean regional_nodes_positive(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.regionalNodesPositive == null || functions.matches(line.regionalNodesPositive, /^[0-8][0-9]|9[057-9]$/)
    }

    // ID: Registry_ID; NAME: Registry ID (NAACCR)
    public boolean registry_id(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return ((List)context.Registry_ID_Table).contains(functions.asInt(line.registryId))
    }

    // ID: RUCA_2000; NAME: RUCA 2000 (NAACCR)
    public boolean ruca_2000(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.ruca2000 == null || functions.matches(line.ruca2000, /^[129ABCD]$/)
    }

    // ID: RUCA_2010; NAME: RUCA 2010 (NAACCR)
    public boolean ruca_2010(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.ruca2010 == null || functions.matches(line.ruca2010, /^[129ABCD]$/)
    }

    // ID: RuralUrban_Continuum_2013; NAME: RuralUrban Continuum 2013 (NAACCR)
    public boolean ruralurban_continuum_2013(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        line.ruralurbanContinuum2013 == null || functions.matches(line.ruralurbanContinuum2013, /^0[1-9]|98|99$/)
    }

    // ID: RXDateBRMEdit; NAME: RX Date BRM (COC)
    public boolean rxdatebrmedit(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer year = functions.asInt(line.rxDateBrmYear)
        Integer month = functions.asInt(line.rxDateBrmMonth)
        Integer day = functions.asInt(line.rxDateBrmDay)
        
        Integer yearCur = functions.getCurrentYear()
        Integer monthCur = functions.getCurrentMonth()
        Integer dayCur = functions.getCurrentDay()
        
        if (line.rxDateBrmYear == null)
            return (line.rxDateBrmMonth == null && line.rxDateBrmDay == null)
        
        if ((line.rxDateBrmMonth == null && line.rxDateBrmDay != null) || (month > 12 || (line.rxDateBrmMonth != null && month < 1)))
            return false
        
        if (!functions.between(year, 1930, yearCur))
            return false
        
        if (line.rxDateBrmMonth == null) //by now year fits and day is null if month is null
            return true
        
        if (year == yearCur && month > monthCur)
            return false
        
        if (line.rxDateBrmDay == null) //by now year and month fit
            return true
        
        if (year == yearCur && month == monthCur && day > dayCur)
            return false
        
        Calendar cal = new GregorianCalendar(year, month - 1, 1)
        return cal != null && day <= cal.getActualMaximum(Calendar.DAY_OF_MONTH)
    }

    // ID: RXDateChemoEdit; NAME: RX Date Chemo (COC)
    public boolean rxdatechemoedit(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer year = functions.asInt(line.rxDateChemoYear)
        Integer month = functions.asInt(line.rxDateChemoMonth)
        Integer day = functions.asInt(line.rxDateChemoDay)
        
        Integer yearCur = functions.getCurrentYear()
        Integer monthCur = functions.getCurrentMonth()
        Integer dayCur = functions.getCurrentDay()
        
        if (line.rxDateChemoYear == null)
         return (line.rxDateChemoMonth == null && line.rxDateChemoDay == null)
        
        if ((line.rxDateChemoMonth == null && line.rxDateChemoDay != null) || (month > 12 || (line.rxDateChemoMonth != null && month < 1)))
         return false
        
        if (!functions.between(year, 1930, yearCur))
            return false
        
        if (line.rxDateChemoMonth == null) //by now year fits and day is null if month is null
            return true
        
        if (year == yearCur && month > monthCur)
            return false
        
        if (line.rxDateChemoDay == null) //by now year and month fit
            return true
        
        if (year == yearCur && month == monthCur && day > dayCur)
            return false
        
        Calendar cal = new GregorianCalendar(year, month - 1, 1)
        return cal != null && day <= cal.getActualMaximum(Calendar.DAY_OF_MONTH)
    }

    // ID: RXDateHormoneEdit; NAME: RX Date Hormone (COC)
    public boolean rxdatehormoneedit(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer year = functions.asInt(line.rxDateHormoneYear)
        Integer month = functions.asInt(line.rxDateHormoneMonth)
        Integer day = functions.asInt(line.rxDateHormoneDay)
        
        Integer yearCur = functions.getCurrentYear()
        Integer monthCur = functions.getCurrentMonth()
        Integer dayCur = functions.getCurrentDay()
        
        if (line.rxDateHormoneYear == null)
             return (line.rxDateHormoneMonth == null && line.rxDateHormoneDay == null)
        
        if ((line.rxDateHormoneMonth == null && line.rxDateHormoneDay != null) || (month > 12 || (line.rxDateHormoneMonth != null && month < 1)))
             return false
        
        if (!functions.between(year, 1930, yearCur))
            return false
        
        if (line.rxDateHormoneMonth == null) //by now year fits and day is null if month is null
            return true
        
        if (year == yearCur && month > monthCur)
            return false
        
        if (line.rxDateHormoneDay == null) //by now year and month fit
            return true
        
        if (year == yearCur && month == monthCur && day > dayCur)
            return false
        
        Calendar cal = new GregorianCalendar(year, month - 1, 1)
        return cal != null && day <= cal.getActualMaximum(Calendar.DAY_OF_MONTH)
    }

    // ID: RXDateMostDefinSurgEdit; NAME: RX Date Mst Defn Srg (COC)
    public boolean rxdatemostdefinsurgedit(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer year = functions.asInt(line.rxDateMostDefinSurgYear)
        Integer month = functions.asInt(line.rxDateMostDefinSurgMonth)
        Integer day = functions.asInt(line.rxDateMostDefinSurgDay)
        
        Integer yearCur = functions.getCurrentYear()
        Integer monthCur = functions.getCurrentMonth()
        Integer dayCur = functions.getCurrentDay()
        
        if (line.rxDateMostDefinSurgYear == null)
            return (line.rxDateMostDefinSurgMonth == null && line.rxDateMostDefinSurgDay == null)
        
        if ((line.rxDateMostDefinSurgMonth == null && line.rxDateMostDefinSurgDay != null) || (month > 12 || (line.rxDateMostDefinSurgMonth != null && month < 1)))
            return false
        
        if (!functions.between(year, 1930, yearCur))
            return false
        
        if (line.rxDateMostDefinSurgMonth == null) //by now year fits and day is null if month is null
            return true
        
        if (year == yearCur && month > monthCur)
            return false
        
        if (line.rxDateMostDefinSurgDay == null) //by now year and month fit
            return true
        
        if (year == yearCur && month == monthCur && day > dayCur)
            return false
        
        Calendar cal = new GregorianCalendar(year, month - 1, 1)
        return cal != null && day <= cal.getActualMaximum(Calendar.DAY_OF_MONTH)
    }

    // ID: RXDateOtherEdit; NAME: RX Date Other (COC)
    public boolean rxdateotheredit(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer year = functions.asInt(line.rxDateOtherYear)
        Integer month = functions.asInt(line.rxDateOtherMonth)
        Integer day = functions.asInt(line.rxDateOtherDay)
        
        Integer yearCur = functions.getCurrentYear()
        Integer monthCur = functions.getCurrentMonth()
        Integer dayCur = functions.getCurrentDay()
        
        if (line.rxDateOtherYear == null)
            return (line.rxDateOtherMonth == null && line.rxDateOtherDay == null)
        
        if ((line.rxDateOtherMonth == null && line.rxDateOtherDay != null) || (month > 12 || (line.rxDateOtherMonth != null && month < 1)))
             return false
         
        if (!functions.between(year, 1930, yearCur))
            return false
        
        if (line.rxDateOtherMonth == null) //by now year fits and day is null if month is null
            return true
        
        if (year == yearCur && month > monthCur)
            return false
        
        if (line.rxDateOtherDay == null) //by now year and month fit
            return true
        
        if (year == yearCur && month == monthCur && day > dayCur)
            return false
        
        Calendar cal = new GregorianCalendar(year, month - 1, 1)
        return cal != null && day <= cal.getActualMaximum(Calendar.DAY_OF_MONTH)
    }

    // ID: RXDateRadiationEdit; NAME: RX Date Radiation (COC)
    public boolean rxdateradiationedit(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer year = functions.asInt(line.rxDateRadiationYear)
        Integer month = functions.asInt(line.rxDateRadiationMonth)
        Integer day = functions.asInt(line.rxDateRadiationDay)
        
        Integer yearCur  = functions.getCurrentYear()
        Integer monthCur = functions.getCurrentMonth()
        Integer dayCur = functions.getCurrentDay()
        
        if (line.rxDateRadiationYear == null)
           return (line.rxDateRadiationMonth == null && line.rxDateRadiationDay == null)
        
        if ((line.rxDateRadiationMonth == null && line.rxDateRadiationDay != null) || (month > 12 || (line.rxDateRadiationMonth != null && month < 1)))
           return false
        
        if (!functions.between(year, 1930, yearCur))
            return false
        
        if (line.rxDateRadiationMonth == null) //by now year fits and day is null if month is null
            return true
        
        if (year == yearCur && month > monthCur)
            return false
        
        if (line.rxDateRadiationDay == null) //by now year and month fit
            return true
        
        if (year == yearCur && month == monthCur && day > dayCur)
            return false
        
        Calendar cal = new GregorianCalendar(year, month - 1, 1)
        return cal != null && day <= cal.getActualMaximum(Calendar.DAY_OF_MONTH)
    }

    // ID: RXDateSurgeryEdit; NAME: RX Date Surgery (COC)
    public boolean rxdatesurgeryedit(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer year = functions.asInt(line.rxDateSurgeryYear)
        Integer month = functions.asInt(line.rxDateSurgeryMonth)
        Integer day = functions.asInt(line.rxDateSurgeryDay)
        
        Integer yearCur = functions.getCurrentYear()
        Integer monthCur = functions.getCurrentMonth()
        Integer dayCur = functions.getCurrentDay()
        
        if (line.rxDateSurgeryYear == null)
            return (line.rxDateSurgeryMonth == null && line.rxDateSurgeryDay == null)
        
        if ((line.rxDateSurgeryMonth == null && line.rxDateSurgeryDay != null) || (month > 12 || (line.rxDateSurgeryMonth != null && month < 1)))
            return false
        
        if (!functions.between(year, 1930, yearCur))
            return false
        
        if (line.rxDateSurgeryMonth == null) //by now year fits and day is null if month is null
            return true
        
        if (year == yearCur && month > monthCur)
            return false
        
        if (line.rxDateSurgeryDay == null) //by now year and month fit
            return true
        
        if (year == yearCur && month == monthCur && day > dayCur)
            return false
        
        Calendar cal = new GregorianCalendar(year, month - 1, 1)
        return cal != null && day <= cal.getActualMaximum(Calendar.DAY_OF_MONTH)
    }

    // ID: RXDateSystemicEdit; NAME: RX Date Systemic (COC)
    public boolean rxdatesystemicedit(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer year = functions.asInt(line.rxDateSystemicYear)
        Integer month = functions.asInt(line.rxDateSystemicMonth)
        Integer day = functions.asInt(line.rxDateSystemicDay)
        
        Integer yearCur = functions.getCurrentYear()
        Integer monthCur = functions.getCurrentMonth()
        Integer dayCur = functions.getCurrentDay()
        
        if (line.rxDateSystemicYear == null)
            return (line.rxDateSystemicMonth == null && line.rxDateSystemicDay == null)
        
        if ((line.rxDateSystemicMonth == null && line.rxDateSystemicDay != null) || (month > 12 || (line.rxDateSystemicMonth != null && month < 1)))
            return false
        
        if (!functions.between(year, 1930, yearCur))
            return false
        
        if (line.rxDateSystemicMonth == null) //by now year fits and day is null if month is null
            return true
        
        if (year == yearCur && month > monthCur)
            return false
        
        if (line.rxDateSystemicDay == null) //by now year and month fit
            return true
        
        if (year == yearCur && month == monthCur && day > dayCur)
            return false
        
        Calendar cal = new GregorianCalendar(year, month - 1, 1)
        return cal != null && day <= cal.getActualMaximum(Calendar.DAY_OF_MONTH)
    }

    // ID: RX_Summ--BRM; NAME: RX Summ--BRM (NPCR)
    public boolean rx_summBrm(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxSummBrm == null || functions.matches(line.rxSummBrm, /(^0[01]$)|(^8[25678]$)|(^99$)/)
    }

    // ID: RX_Summ--Chemo; NAME: RX Summ--Chemo (NPCR)
    public boolean rx_summChemo(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxSummChemo == null || functions.matches(line.rxSummChemo, /(^0[0-3]$)|(^8[25678]$)|(^99$)/)
    }

    // ID: RX_Summ--Hormone; NAME: RX Summ--Hormone (NPCR)
    public boolean rx_summHormone(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxSummHormone == null || functions.matches(line.rxSummHormone, /(^0[01]$)|(^8[25678]$)|(^99$)/)
    }

    // ID: RX_Summ--Other; NAME: RX Summ--Other (NPCR)
    public boolean rx_summOther(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxSummOther == null || functions.matches(line.rxSummOther, /^[01236789]$/)
    }

    // ID: RX_Summ--Radiation; NAME: RX Summ--Radiation (SEER RADIATN)
    public boolean rx_summRadiation(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxSummRadiation == null || functions.matches(line.rxSummRadiation, /^[0-9]$/)
    }

    // ID: RX_Summ--Rad_to_CNS; NAME: RX Summ--Rad to CNS (SEER RBCNSYS)
    public boolean rx_summRad_to_cns(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxSummRadToCns == null || functions.matches(line.rxSummRadToCns, /^[01789]$/)
    }

    // ID: RX_Summ--Reg_LN_Examined; NAME: RX Summ--Reg LN Examined (SEER SURGNODE)
    public boolean rx_summReg_ln_examined(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxSummRegLnExamined == null || functions.matches(line.rxSummRegLnExamined, /(^[0-8][0-9]$)|(^9[05-9]$)|(^\s\s$)/)
    }

    // ID: RX_Summ--Scope_Reg_98-02; NAME: RX Summ--Scope Reg 98-02 (COC)
    public boolean rx_summScope_reg_9802(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxSummScopeReg9802 == null || functions.matches(line.rxSummScopeReg9802, /^[0-9\s]$/)
    }

    // ID: RX_Summ--Scope_Reg_LN_Sur; NAME: RX Summ--Scope Reg LN Sur (SEER SCOPE)
    public boolean rx_summScope_reg_ln_sur(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxSummScopeRegLnSur == null || functions.matches(line.rxSummScopeRegLnSur, /^[0-79\s]$/)
    }

    // ID: RX_Summ--Surg-Rad_Seq; NAME: RX Summ--Surg/Rad Seq (NPCR)
    public boolean rx_summSurgRad_seq(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxSummSurgRadSeq == null || functions.matches(line.rxSummSurgRadSeq, /^[02345679]$/)
    }

    // ID: RX_Summ--Surgery_Type; NAME: RX Summ--Surgery Type (SEER SURGRX)
    public boolean rx_summSurgery_type(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxSummSurgeryType == null  || functions.matches(line.rxSummSurgeryType, /(^[0-9][0-9]$)|(^\s\s$)/)
    }

    // ID: RX_Summ--Surgical_Margins; NAME: RX Summ--Surgical Margins (NAACCR)
    public boolean rx_summSurgical_margins(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxSummSurgicalMargins == null || functions.matches(line.rxSummSurgicalMargins, /^[0123789]$/)
    }

    // ID: RX_Summ--Surg_Oth_98-02; NAME: RX Summ--Surg Oth 98-02 (COC)
    public boolean rx_summSurg_oth_9802(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxSummSurgOth9802 == null || functions.matches(line.rxSummSurgOth9802, /^[0-9\s]$/)
    }

    // ID: RX_Summ--Surg_Oth_Reg-Dis; NAME: RX Summ--Surg Oth Reg/Dis (SEER SURGOTH)
    public boolean rx_summSurg_oth_regDis(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxSummSurgOthRegDis == null || functions.matches(line.rxSummSurgOthRegDis, /^[0-59\s]$/)
    }

    // ID: RX_Summ--Surg_Prim_Site; NAME: RX Summ--Surg Prim Site 03-2022 (SEER SURGPRIM)
    public boolean rx_summSurg_prim_site(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxSummSurgPrimSite == null || functions.matches(line.rxSummSurgPrimSite, /(^00$)|(^[1-8][0-9]$)|(^9[089]$)|(^\s\s$)/)
    }

    // ID: RX_Summ--Systemic_Sur_Seq; NAME: RX Summ--Systemic/Sur Seq (COC)
    public boolean rx_summSystemic_sur_seq(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxSummSystemicSurSeq == null  || functions.matches(line.rxSummSystemicSurSeq, /^[02345679]$/)
    }

    // ID: RX_Summ--Transplnt-Endocr; NAME: RX Summ--Transplnt/Endocr (NPCR)
    public boolean rx_summTransplntEndocr(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxSummTransplntEndocr == null || functions.matches(line.rxSummTransplntEndocr, /(^00$)|(^1[012]$)|(^[234]0$)|(^8[25678]$)|(^99$)/)
    }

    // ID: RX_Summ--Treatment_Status; NAME: RX Summ--Treatment Status (COC)
    public boolean rx_summTreatment_status(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.rxSummTreatmentStatus == null || functions.matches(line.rxSummTreatmentStatus, /(^[0129]$)/)
    }

    // ID: SEER_Cause-Specific_COD; NAME: SEER Cause-Specific COD (NAACCR)
    public boolean seer_causeSpecific_cod(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.seerCauseSpecificCod == null || functions.matches(line.seerCauseSpecificCod, /^[0189]$/)
    }

    // ID: SEER_IR01A; NAME: Verify Birthplace-State Same on All Records for a Patient
    public boolean seer_ir01a(Binding binding, Map context, StagingContextFunctions functions, List> lines) throws Exception {
        if (lines.isEmpty())
            return true
        
        String birthPlaceState = lines[0].birthplaceState
        for (line in lines) {
            if (birthPlaceState != line.birthplaceState) {
                functions.forceFailureOnEntity(binding, lines[0])
                functions.forceFailureOnEntity(binding, line)
                return false
            }
        }
        
        return true
    }

    // ID: SEER_IR01B; NAME: Verify Birthplace-Country Same on All Records for a Patient
    public boolean seer_ir01b(Binding binding, Map context, StagingContextFunctions functions, List> lines) throws Exception {
        if (lines.isEmpty())
            return true
        
        String birthPlaceCountry = lines[0].birthplaceCountry
        for (line in lines) {
            if (birthPlaceCountry != line.birthplaceCountry) {
                functions.forceFailureOnEntity(binding, lines[0])
                functions.forceFailureOnEntity(binding, line)
                return false
            }
        }
        
        return true
    }

    // ID: SEER_IR02; NAME: Birth Date not Consistent for Patient (SEER IR02)
    public boolean seer_ir02(Binding binding, Map context, StagingContextFunctions functions, List> lines) throws Exception {
        if (lines.isEmpty())
            return true
        
        for (line in lines) {
            if (line.dateOfBirthYear != null && !functions.between(line.dateOfBirthYear, 1800, functions.getCurrentYear() ) )
                return true
            if (line.dateOfBirthMonth != null && !(functions.matches(line.dateOfBirthMonth, /^(0?[1-9]|1[0-2])$/) ) )
                return true
            if (line.dateOfBirthDay != null && !(line.dateOfBirthDay  ==~ /^(0?[1-9]|[12][0-9]|3[01]|\s\s)$/) )
                return true
        }
        
        String day = lines[0].dateOfBirthDay
        String month = lines[0].dateOfBirthMonth
        String year = lines[0].dateOfBirthYear
        
        for (line in lines) {
            if (day != line.dateOfBirthDay || month != line.dateOfBirthMonth || year != line.dateOfBirthYear) {
                functions.forceFailureOnEntity(binding, lines[0])
                functions.forceFailureOnEntity(binding, line)
                return false
            }
        }
        
        return true
    }

    // ID: SEER_IR03A; NAME: Age at DX and Sequence Number 00 to 59 not Consistent for Patient (SEER IR03A)
    public boolean seer_ir03a(Binding binding, Map context, StagingContextFunctions functions, List> lines) throws Exception {
        List filteredLines = (List)((Closure)context.SEER_IR03A_Filter).call(lines)
        
        if (filteredLines.size() < 2)
            return true
        
        // sort tumors by sequence number (null seq go to the end of the list)
        filteredLines.sort(true, (Comparator)context.seqComparator)
        
        int index = 1
        Map currLine = filteredLines.get(0)
        Integer currAge = functions.asInt(currLine.ageAtDiagnosis)
        while (index < filteredLines.size()) {
            Map line = filteredLines.get(index)
            Integer nextAge = functions.asInt(line.ageAtDiagnosis)
        
            if (currAge > nextAge) {
                functions.forceFailureOnEntity(binding, currLine, 'line.sequenceNumberCentral', 'line.ageAtDiagnosis')
                functions.forceFailureOnEntity(binding, line, 'line.sequenceNumberCentral', 'line.ageAtDiagnosis')
                return false
            }
        
            currLine = line
            currAge = nextAge
            index += 1
        }
        
        return true
    }

    // ID: SEER_IR03B; NAME: Age at Dx and Sequence Number 60 to 87 not Consistent for Patient (SEER IR03B)
    public boolean seer_ir03b(Binding binding, Map context, StagingContextFunctions functions, List> lines) throws Exception {
        List filteredLines = (List)((Closure)context.SEER_IR03B_Filter).call(lines)
        
        if (filteredLines.size() < 2)
            return true
        
        // sort tumors by sequence number (null seq go to the end of the list)
        filteredLines.sort(true, (Comparator)context.seqComparator)
        
        int index = 1
        Map currLine = filteredLines.get(0)
        Integer currAge = functions.asInt(currLine.ageAtDiagnosis)
        while (index < filteredLines.size()) {
            Map line = filteredLines.get(index)
            Integer nextAge = functions.asInt(line.ageAtDiagnosis)
        
            if (currAge > nextAge) {
                functions.forceFailureOnEntity(binding, currLine, 'line.sequenceNumberCentral', 'line.ageAtDiagnosis')
                functions.forceFailureOnEntity(binding, line, 'line.sequenceNumberCentral', 'line.ageAtDiagnosis')
                return false
            }
        
            currLine = line
            currAge = nextAge
            index += 1
        }
        
        return true
    }

    // ID: SEER_IR04; NAME: Race 1 thru 5 not Consistent for Patient (SEER IR04)
    public boolean seer_ir04(Binding binding, Map context, StagingContextFunctions functions, List> lines) throws Exception {
        if (lines.isEmpty())
            return true
        
        String race1 = lines[0].race1
        String race2 = lines[0].race2
        String race3 = lines[0].race3
        String race4 = lines[0].race4
        String race5 = lines[0].race5
        
        for (line in lines) {
            if (line.race1 != race1 || line.race2 != race2 || line.race3 != race3 || line.race4 != race4 || line.race5 != race5) {
                functions.forceFailureOnEntity(binding, lines[0])
                functions.forceFailureOnEntity(binding, line)
                return false
            }
        }
        
        return true
    }

    // ID: SEER_IR05; NAME: Sex not Consistent for Patient (SEER IR05)
    public boolean seer_ir05(Binding binding, Map context, StagingContextFunctions functions, List> lines) throws Exception {
        if (lines.isEmpty())
            return true
        
        String sex = lines[0].sex
        for (line in lines) {
            if (sex != line.sex) {
                functions.forceFailureOnEntity(binding, lines[0])
                functions.forceFailureOnEntity(binding, line)
                return false
            }
        }
        
        return true
    }

    // ID: SEER_IR06A; NAME: Seq-num (00 to 59) and Date Dx not Consistent for Patient (SEER IR06)
    public boolean seer_ir06a(Binding binding, Map context, StagingContextFunctions functions, List> lines) throws Exception {
        List filteredLines = (List)((Closure)context.SEER_IR06A_Filter).call(lines)
        
        if (filteredLines.size() < 2)
            return true
        
        for (line in filteredLines) {
            if ( line.dateOfDiagnosisYear != null && !(functions.matches(line.dateOfDiagnosisYear, /^[12]\d\d\d$/)) && !functions.between(line.dateOfDiagnosisYear, 1930, functions.getCurrentYear()) )
                 return true
            if ( line.dateOfDiagnosisMonth != null && !(functions.matches(line.dateOfDiagnosisMonth, /^(0?[1-9]|1[0-2])$/) ) )
                 return true
            if ( line.dateOfDiagnosisDay != null && !(functions.matches(line.dateOfDiagnosisDay, /^(0[1-9]|[12][0-9]|3[01]|\s\s)$/)) )
                 return true
        }
        
        // sort tumors by sequence number (null seq go to the end of the list)
        filteredLines.sort(true, (Comparator)context.seqComparator)
        
        int index = 1
        Map currLine = filteredLines.get(0)
        Integer currYearDx = functions.asInt(currLine.dateOfDiagnosisYear)
        Integer currMonthDx = functions.asInt(currLine.dateOfDiagnosisMonth)
        Integer currDayDx = functions.asInt(currLine.dateOfDiagnosisDay)
        while (index < filteredLines.size()) {
            Map line = filteredLines.get(index)
            Integer nextYearDx = functions.asInt(line.dateOfDiagnosisYear)
            Integer nextMonthDx = functions.asInt(line.dateOfDiagnosisMonth)
            Integer nextDayDx = functions.asInt(line.dateOfDiagnosisDay)
        
            if (((Integer)((Closure)context.compareDate).call(currYearDx, currMonthDx, currDayDx, nextYearDx, nextMonthDx, nextDayDx)) > 0) {
                functions.forceFailureOnEntity(binding, currLine, 'line.sequenceNumberCentral', 'line.dateOfDiagnosisYear', 'line.dateOfDiagnosisMonth', 'line.dateOfDiagnosisDay')
                functions.forceFailureOnEntity(binding, line, 'line.sequenceNumberCentral', 'line.dateOfDiagnosisYear', 'line.dateOfDiagnosisMonth', 'line.dateOfDiagnosisDay')
                return false
            }
        
            currLine = line
            if (nextDayDx != '99' && nextDayDx != null) {
                currYearDx = nextYearDx
                currMonthDx = nextMonthDx
                currDayDx = nextDayDx
            }
            else if (nextMonthDx != 99 && nextMonthDx != null) {
                if (nextMonthDx > currMonthDx || nextYearDx > currYearDx) {
                    currYearDx = nextYearDx
                    currMonthDx = nextMonthDx
                    currDayDx = 0
                }
            }
            else if (nextYearDx != 99 && nextYearDx != null) {
                if (nextYearDx > currYearDx) {
                    currYearDx = nextYearDx
                    currMonthDx = 0
                    currDayDx = 0
                }
            }
            index += 1
        }
        
        return true
    }

    // ID: SEER_IR06B; NAME: Seq-num (60 to 87) and Date Dx not Consistent for Patient (SEER IR06)
    public boolean seer_ir06b(Binding binding, Map context, StagingContextFunctions functions, List> lines) throws Exception {
        List filteredLines = (List)((Closure)context.SEER_IR06B_Filter).call(lines)
        
        if (filteredLines.size() < 2)
            return true
        
        // sort tumors by sequence number (null seq go to the end of the list)
        filteredLines.sort(true, (Comparator)context.seqComparator)
        
        int index = 1
        Map currLine = filteredLines.get(0)
        Integer currYearDx = functions.asInt(currLine.dateOfDiagnosisYear)
        Integer currMonthDx = functions.asInt(currLine.dateOfDiagnosisMonth)
        Integer currDayDx = functions.asInt(currLine.dateOfDiagnosisDay)
        while (index < filteredLines.size()) {
            Map line = filteredLines.get(index)
            Integer nextYearDx = functions.asInt(line.dateOfDiagnosisYear)
            Integer nextMonthDx = functions.asInt(line.dateOfDiagnosisMonth)
            Integer nextDayDx = functions.asInt(line.dateOfDiagnosisDay)
        
            if (((Integer)((Closure)context.compareDate).call(currYearDx, currMonthDx, currDayDx, nextYearDx, nextMonthDx, nextDayDx)) > 0) {
                functions.forceFailureOnEntity(binding, currLine, 'line.sequenceNumberCentral', 'line.dateOfDiagnosisYear', 'line.dateOfDiagnosisMonth', 'line.dateOfDiagnosisDay')
                functions.forceFailureOnEntity(binding, line, 'line.sequenceNumberCentral', 'line.dateOfDiagnosisYear', 'line.dateOfDiagnosisMonth', 'line.dateOfDiagnosisDay')
                return false
            }
        
            currLine = line
            if (nextDayDx != '99' && nextDayDx != null) {
                currYearDx = nextYearDx
                currMonthDx = nextMonthDx
                currDayDx = nextDayDx
            }
            else if (nextMonthDx != 99 || nextMonthDx != null) {
                if (nextMonthDx > currMonthDx || nextYearDx > currYearDx) {
                    currYearDx = nextYearDx
                    currMonthDx = nextMonthDx
                    currDayDx = 0
                }
            }
            else if (nextYearDx != 99 || nextYearDx != null) {
                if (nextYearDx > currYearDx) {
                    currYearDx = nextYearDx
                    currMonthDx = 0
                    currDayDx = 0
                }
            }
            index += 1
        }
        
        return true
    }

    // ID: SEER_IR07A; NAME: Sequence Number 00 to 59 not Consistent for Patient (SEER IR07)
    public boolean seer_ir07a(Binding binding, Map context, StagingContextFunctions functions, List> lines) throws Exception {
        List filteredLines = (List)((Closure)context.SEER_IR07A_Filter).call(lines)
        
        if (filteredLines.size() < 2)
            return true
        
        // sort tumors by sequence number (null seq go to the end of the list)
        filteredLines.sort(true, (Comparator)context.seqComparator)
        
        int outerIndex = 0
        while (outerIndex < filteredLines.size()) {
            int innerIndex = outerIndex + 1
        
            if (filteredLines.get(outerIndex).sequenceNumberCentral == '00' || filteredLines.get(outerIndex).sequenceNumberCentral == '99') {
                functions.forceFailureOnEntity(binding, filteredLines.get(outerIndex), 'line.sequenceNumberCentral')
                functions.forceFailureOnEntity(binding, filteredLines.get(outerIndex == 0 ? 1 : 0), 'line.sequenceNumberCentral')
                return false
            }
        
            while (innerIndex < filteredLines.size()) {
                if (filteredLines.get(innerIndex).sequenceNumberCentral == filteredLines.get(outerIndex).sequenceNumberCentral) {
                    functions.forceFailureOnEntity(binding, filteredLines.get(innerIndex), 'line.sequenceNumberCentral')
                    functions.forceFailureOnEntity(binding, filteredLines.get(outerIndex), 'line.sequenceNumberCentral')
                    return false
                }
        
                innerIndex += 1
            }
        
            outerIndex += 1
        }
        
        return true
    }

    // ID: SEER_IR07B; NAME: Sequence Number 60 to 88 not Consistent for Patient (SEER IR07)
    public boolean seer_ir07b(Binding binding, Map context, StagingContextFunctions functions, List> lines) throws Exception {
        List filteredLines = (List)((Closure)context.SEER_IR07B_Filter).call(lines)
        
        if (filteredLines.size() < 2)
            return true
        
        // sort tumors by sequence number (null seq go to the end of the list)
        filteredLines.sort(true, (Comparator)context.seqComparator)
        
        int outerIndex = 0
        while (outerIndex < filteredLines.size()) {
            int innerIndex = outerIndex + 1
        
            if (filteredLines.get(outerIndex).sequenceNumberCentral == '60' || filteredLines.get(outerIndex).sequenceNumberCentral == '88') {
                functions.forceFailureOnEntity(binding, filteredLines.get(outerIndex), 'line.sequenceNumberCentral')
                functions.forceFailureOnEntity(binding, filteredLines.get(outerIndex == 0 ? 1 : 0), 'line.sequenceNumberCentral')
                return false
            }
        
            while (innerIndex < filteredLines.size()) {
                if (filteredLines.get(innerIndex).sequenceNumberCentral == filteredLines.get(outerIndex).sequenceNumberCentral) {
                    functions.forceFailureOnEntity(binding, filteredLines.get(innerIndex), 'line.sequenceNumberCentral')
                    functions.forceFailureOnEntity(binding, filteredLines.get(outerIndex), 'line.sequenceNumberCentral')
                    return false
                }
        
                innerIndex += 1
            }
        
            outerIndex += 1
        }
        
        return true
    }

    // ID: SEER_IR08; NAME: Date of Last Contact not Consistent for Patient (SEER IR08)
    public boolean seer_ir08(Binding binding, Map context, StagingContextFunctions functions, List> lines) throws Exception {
        if (lines.isEmpty())
            return true
        
        for (line in lines) {
            if ( line.dateOfLastContactYear != null && !(functions.matches(line.dateOfLastContactYear, /^[12]\d\d\d$/)) && !functions.between(line.dateOfLastContactYear, 1930, functions.getCurrentYear()) )
                 return true
            if ( line.dateOfLastContactMonth != null && !(functions.matches(line.dateOfLastContactMonth, /^(0?[1-9]|1[0-2])$/) ) )
                 return true
            if ( line.dateOfLastContactDay != null && !(line.dateOfLastContactDay  ==~ /^(0?[1-9]|[12][0-9]|3[01]|\s\s)$/) )
                 return true
        }
        
        String day = lines[0].dateOfLastContactDay
        String month = lines[0].dateOfLastContactMonth
        String year = lines[0].dateOfLastContactYear
        
        for (line in lines) {
            if (day != line.dateOfLastContactDay || month != line.dateOfLastContactMonth || year != line.dateOfLastContactYear) {
                functions.forceFailureOnEntity(binding, lines[0])
                functions.forceFailureOnEntity(binding, line)
                return false
            }
        }
        
        return true
    }

    // ID: SEER_IR09_3; NAME: Site and Laterality ICD-O-3 not Consistent for Patient (SEER IR09_3)
    public boolean seer_ir09_3(Binding binding, Map context, StagingContextFunctions functions, List> lines) throws Exception {
        if (lines.size() < 2)
            return true
        
        for (line in lines)
            if (line.histologicTypeIcdO3 == null)
                 return true
        
        //Define the properties we want to report
        //We don't always want to report laterality and ignoring properties doesn't work when forcing entity failures
        Closure getPropertiesToFail = { String site1, String site2 ->
            if (!((List)context.IR09_PAIRED_ORGAN_Table).contains(functions.asInt(site1.substring(1,4))) && !((List)context.IR09_PAIRED_ORGAN_Table).contains(functions.asInt(site2.substring(1,4))))
                return ['line.histologicTypeIcdO3', 'line.primarySite', 'line.behaviorCodeIcdO3', 'line.overRideSiteLatSeqno'] as String[]
            else
                return ['line.histologicTypeIcdO3', 'line.primarySite', 'line.behaviorCodeIcdO3', 'line.overRideSiteLatSeqno', 'line.laterality'] as String[]
        }
        
        int index1 = 0
        while ( index1 < lines.size() ) {
            Map line1 = lines.get(index1)
            int index2 = index1 + 1
            String site1 = line1.primarySite
            String hist1 = line1.histologicTypeIcdO3
            String behav1 = line1.behaviorCodeIcdO3
            String lat1 = line1.laterality
        
            if (line1.overRideSiteLatSeqno != '1' && site1 != null && behav1 != null &&
                site1.length() == 4 && hist1.length() == 4 && hist1 < '9590') {
                while ( index2 < lines.size() ) {
                    Map line2 = lines.get(index2)
                    String site2 = line2.primarySite
                    String hist2 = line2.histologicTypeIcdO3
                    String behav2 = line2.behaviorCodeIcdO3
                    String lat2 = line2.laterality
        
                    if (line2.overRideSiteLatSeqno != '1' && site2 != null && hist2 != null && behav2 != null &&
                       site2.length() == 4 && hist2.length() == 4 && hist2 < '9590') {
                        if (     hist2.startsWith(hist1.substring(0,3))
                            && (behav1 == '3' && behav1 == behav2)
                            &&!(((List)context.IR09_PAIRED_ORGAN_Table).contains(functions.asInt(site1.substring(1,4)))
                            &&  ((List)context.IR09_PAIRED_ORGAN_Table).contains(functions.asInt(site2.substring(1,4)))
                            &&  lat1 != lat2 &&  lat1 != '9' &&  lat2 != '9' && lat1 != '5' && lat2 != '5')) {
                            Integer year1 = functions.asInt(line1.dateOfDiagnosisYear) ?: 9999
                            Integer month1 = functions.asInt(line1.dateOfDiagnosisMonth) ?: 99
                            Integer day1 = functions.asInt(line1.dateOfDiagnosisDay) ?: 99
                            Integer year2 = functions.asInt(line2.dateOfDiagnosisYear) ?: 9999
                            Integer month2 = functions.asInt(line2.dateOfDiagnosisMonth) ?: 99
                            Integer day2 = functions.asInt(line2.dateOfDiagnosisDay) ?: 99
                            boolean fiveYearsApart = !((((Integer)((Closure)context.compareDate).call(year1 +5, month1, day1, year2, month2, day2)) >= 0) && (((Integer)((Closure)context.compareDate).call(year1 -5, month1, day1, year2, month2, day2)) <= 0))
                            boolean oneYearApart = !((((Integer)((Closure)context.compareDate).call(year1 + 1, month1, day1, year2, month2, day2)) >= 0) && (((Integer)((Closure)context.compareDate).call(year1 - 1, month1, day1, year2, month2, day2)) <= 0))
                            boolean siteExceptionBreast = (site1 ==~ /^C50\d$/ && site2 ==~ /^C50\d$/ && fiveYearsApart)
                            boolean siteExceptionColon = (site1 ==~ /^C18[0-8]$/ && site2 ==~ /^C18[0-8]$/ && oneYearApart)
                            boolean siteExceptionHeadNeck = (site1 ==~ /^C(0\d\d|1[0-3]\d|14[0-8]|3[012]\d)$/ && site2 ==~ /^C(0\d\d|1[0-3]\d|14[0-8]|3[012]\d)$/ && fiveYearsApart)
        
                            if (!((siteExceptionBreast || siteExceptionColon || siteExceptionHeadNeck) && (year1 > 2006 || year2 > 2006))) {
                                if ((  site1 ==~ /^C\d\d(8)$/ || site2 ==~ /^C\d\d(8)$/)
                                    && !(site1 ==~ /^C(168|538|718)$/) && !(site2 ==~ /^C(16|53|71)\d$/)
                                    && !(site2 ==~ /^C(168|538|718)$/) && !(site1 ==~ /^C(16|53|71)\d$/)
                                    && site2.startsWith(site1.substring(0,3))) {
                                        functions.forceFailureOnEntity(binding, line1, getPropertiesToFail(site1, site2))
                                        functions.forceFailureOnEntity(binding, line2, getPropertiesToFail(site1, site2))
                                        return false
                                }
                                if ((  site1 ==~ /^C\d\d9$/ || site2 ==~ /^C\d\d9$/)
                                    && site2.startsWith(site1.substring(0,3))) {
                                        functions.forceFailureOnEntity(binding, line1, getPropertiesToFail(site1, site2))
                                        functions.forceFailureOnEntity(binding, line2, getPropertiesToFail(site1, site2))
                                        return false
                                }
                                if (((Map)context.IR09_NOS_SPEC_Table).containsKey(site1)
                                    && ((List)((Map)context.IR09_NOS_SPEC_Table).getOrDefault(site1, [])).contains(functions.asInt(site2.substring(1,4)))) {
                                        functions.forceFailureOnEntity(binding, line1, getPropertiesToFail(site1, site2))
                                        functions.forceFailureOnEntity(binding, line2, getPropertiesToFail(site1, site2))
                                        return false
                                }
                                if (((Map)context.IR09_NOS_SPEC_Table).containsKey(site2)
                                    && ((List)((Map)context.IR09_NOS_SPEC_Table).getOrDefault(site2, [])).contains(functions.asInt(site1.substring(1,4)))) {
                                        functions.forceFailureOnEntity(binding, line1, getPropertiesToFail(site1, site2))
                                        functions.forceFailureOnEntity(binding, line2, getPropertiesToFail(site1, site2))
                                        return false
                                }
                            }
                        }
                    }
                    index2++
                }
            }
            index1++
        }
        return true
    }

    // ID: SEER_IR10; NAME: Vital Status not Consistent for Patient (SEER IR10)
    public boolean seer_ir10(Binding binding, Map context, StagingContextFunctions functions, List> lines) throws Exception {
        if (lines.isEmpty())
            return true
        
        String vitalStatus = lines[0].vitalStatus
        for (line in lines) {
            if (vitalStatus != line.vitalStatus) {
                functions.forceFailureOnEntity(binding, lines[0])
                functions.forceFailureOnEntity(binding, line)
                return false
            }
        }
        
        return true
    }

    // ID: SEER_IR11; NAME: Cause of Death not Consistent for Patient (SEER IR11)
    public boolean seer_ir11(Binding binding, Map context, StagingContextFunctions functions, List> lines) throws Exception {
        if (lines.isEmpty())
            return true
        
        String causeOfDeath = lines[0].causeOfDeath
        for (line in lines) {
            if (causeOfDeath != line.causeOfDeath) {
                functions.forceFailureOnEntity(binding, lines[0])
                functions.forceFailureOnEntity(binding, line)
                return false
            }
        }
        
        return true
    }

    // ID: SEER_IR12; NAME: Record Number not Consistent for Patient (SEER IR12)
    public boolean seer_ir12(Binding binding, Map context, StagingContextFunctions functions, List> lines) throws Exception {
        
        if (lines.isEmpty() || lines.size() < 2)
            return true
        
        // Check to see if any records have the same Record Number Recode. Fail all records that have duplicates.
        Map linesByRecordNumberRecode = [:].withDefault{[]}
        lines.each { line ->
            linesByRecordNumberRecode.get(line.recordNumberRecode) << line
        }
        
        Boolean containsDuplicates = false
        linesByRecordNumberRecode.each { recordNumberRecode, duplicates ->
            if (duplicates.size() > 1) {
                duplicates.each { line ->
                    functions.forceFailureOnEntity(binding, line)
                }
                containsDuplicates = true
            }
        }
        return !containsDuplicates
    }

    // ID: SEER_IR13A; NAME: Duplicate Bladder Primaries for Patient (SEER IR13A)
    public boolean seer_ir13a(Binding binding, Map context, StagingContextFunctions functions, List> lines) throws Exception {
        if (lines.size() < 2)
            return true
        
        List allHist = (List)context.IR13A_Histologies
        List group1Hist = (List)[8020,8022,8031,8120,8122,8130]
        
        int outerIndex = 0
        while ( outerIndex < lines.size() ) {
            int innerIndex = outerIndex + 1
            Map outerLine = lines.get(outerIndex)
            Integer outerHistInt = functions.asInt(outerLine.histologicTypeIcdO3)
        
            if ( allHist.contains(outerHistInt) && functions.between(outerLine.primarySite, 'C670', 'C679') ) {
                while (innerIndex < lines.size() ) {
                    Map innerLine = lines.get(innerIndex)
                    Integer innerHistInt = functions.asInt(innerLine.histologicTypeIcdO3)
        
                    if ( allHist.contains(innerHistInt) && functions.between(innerLine.primarySite, 'C670', 'C679')
                            &&  (    (outerLine.behaviorCodeIcdO3 == innerLine.behaviorCodeIcdO3)
                                  || (outerLine.behaviorCodeIcdO3 == '2' && innerLine.behaviorCodeIcdO3 == '3' && innerLine.dateOfDiagnosisYear < '1995'))
                       ) {
                        boolean innerGroup1 = group1Hist.contains(innerHistInt) || (innerHistInt == 8082 && innerLine.dateOfDiagnosisYear > '2017')
                        boolean innerGroup2 = innerLine.histologicTypeIcdO3 == '8131'
                        boolean outerGroup1 = group1Hist.contains(outerHistInt) || (outerHistInt == 8082 && outerLine.dateOfDiagnosisYear > '2017')
                        boolean outerGroup2 = outerLine.histologicTypeIcdO3 == '8131'
                        if ((innerLine.dateOfDiagnosisYear < '2018' && outerLine.dateOfDiagnosisYear < '2018') || !((innerGroup1 && outerGroup2) || (innerGroup2 && outerGroup1))) {
                            functions.forceFailureOnEntity(binding, innerLine)
                            functions.forceFailureOnEntity(binding, outerLine)
                            return false
                        }
                    }
        
                    innerIndex += 1
                }
            }
        
            outerIndex += 1
        }
        
        return true
    }

    // ID: SEER_IR13B; NAME: Duplicate Prostate Primaries for Patient (SEER IR13B)
    public boolean seer_ir13b(Binding binding, Map context, StagingContextFunctions functions, List> lines) throws Exception {
        if (lines.size() < 2)
            return true
        
        for (line in lines) {
            if ( line.dateOfDiagnosisYear != null && !(functions.matches(line.dateOfDiagnosisYear, /^[12]\d\d\d$/)) && !functions.between(line.dateOfDiagnosisYear, 1930, functions.getCurrentYear()) )
                 return true
        }
        
        int outerIndex = 0
        while ( outerIndex < lines.size() ) {
            int innerIndex = outerIndex + 1
            Map outerLine = lines.get(outerIndex)
        
            if (outerLine.histologicTypeIcdO3 == '8140' && outerLine.primarySite == 'C619' && outerLine.behaviorCodeIcdO3 == '3') {
                while (innerIndex < lines.size() ) {
                    Map innerLine = lines.get(innerIndex)
        
                    if (innerLine.histologicTypeIcdO3 == '8140' && innerLine.primarySite == 'C619' && innerLine.behaviorCodeIcdO3 == '3' && innerLine.dateOfDiagnosisYear > '1987') {
                        functions.forceFailureOnEntity(binding, innerLine)
                        functions.forceFailureOnEntity(binding, outerLine)
                        return false
                    }
        
                    innerIndex += 1
                }
            }
        
            outerIndex += 1
        }
        
        return true
    }

    // ID: SEER_IR13C; NAME: Duplicate Kaposi Sarcoma Primaries for Patient (SEER IR13C)
    public boolean seer_ir13c(Binding binding, Map context, StagingContextFunctions functions, List> lines) throws Exception {
        if (lines.size() < 2)
            return true
        
        for (line in lines) {
            if ( line.dateOfDiagnosisYear != null && !(functions.matches(line.dateOfDiagnosisYear, /^[12]\d\d\d$/)) && !functions.between(line.dateOfDiagnosisYear, 1930, functions.getCurrentYear()) )
                 return true
        }
        
        int outerIndex = 0
        while ( outerIndex < lines.size() ) {
            int innerIndex = outerIndex + 1
            Map outerLine = lines.get(outerIndex)
        
            if (outerLine.histologicTypeIcdO3 == '9140' && outerLine.behaviorCodeIcdO3 == '3') {
                while (innerIndex < lines.size() ) {
                    Map innerLine = lines.get(innerIndex)
        
                    if (innerLine.histologicTypeIcdO3 == '9140' && innerLine.behaviorCodeIcdO3 == '3' && innerLine.dateOfDiagnosisYear > '1987') {
                        functions.forceFailureOnEntity(binding, innerLine)
                        functions.forceFailureOnEntity(binding, outerLine)
                        return false
                    }
        
                    innerIndex += 1
                }
            }
        
            outerIndex += 1
        }
        
        return true
    }

    // ID: SEER_IR15; NAME: NHIA Derived Hisp Origin not Consistent for Patient (SEER IR15)
    public boolean seer_ir15(Binding binding, Map context, StagingContextFunctions functions, List> lines) throws Exception {
        if (lines.isEmpty())
            return true
        
        String nhia = lines[0].nhiaDerivedHispOrigin
        for (line in lines) {
            if (nhia != line.nhiaDerivedHispOrigin) {
                functions.forceFailureOnEntity(binding, lines[0])
                functions.forceFailureOnEntity(binding, line)
                return false
            }
        }
        
        return true
    }

    // ID: SEER_IR16; NAME: Duplicate Heme Cases for Patient (SEER IR16)
    public boolean seer_ir16(Binding binding, Map context, StagingContextFunctions functions, List> lines) throws Exception {
        if (lines.size() < 2)
            return true
        
        for (line in lines) {
            if (line.dateOfDiagnosisYear != null && !(functions.matches(line.dateOfDiagnosisYear, /^[12]\d\d\d$/) && functions.between(line.dateOfDiagnosisYear, 1930, functions.getCurrentYear())))
                 return true
        }
        
        int outerIndex = 0
        while (outerIndex < lines.size()) {
            int innerIndex = outerIndex + 1
            Map outerLine = lines.get(outerIndex)
        
            Integer outerHistInt = functions.asInt(outerLine.histologicTypeIcdO3)
            boolean outerHeme95909993 = functions.between(outerHistInt, 9590, 9993) && outerHistInt != 9699;
            boolean outerHeme9699group1 = outerHistInt == 9699 && functions.matches(outerLine.primarySite, /^C(024|09\d|111|142|379|422|77\d)$/)
            boolean outerHeme9699group2 = outerHistInt == 9699 && !outerHeme9699group1
        
            if (outerHeme95909993 || outerHeme9699group1 || outerHeme9699group2) {
                while (innerIndex < lines.size()) {
                    Map innerLine = lines.get(innerIndex)
                    if (outerLine.dateOfDiagnosisYear > '2009' || innerLine.dateOfDiagnosisYear > '2009') {
        
                        Integer innerHistInt = functions.asInt(innerLine.histologicTypeIcdO3)
                        boolean innerHeme95909993 = functions.between(innerHistInt, 9590, 9993) && innerHistInt != 9699;
                        boolean innerHeme9699group1 = innerHistInt == 9699 && functions.matches(innerLine.primarySite, /^C(024|09\d|111|142|379|422|77\d)$/)
                        boolean innerHeme9699group2 = innerHistInt == 9699 && !innerHeme9699group1
        
                        if ((outerHeme9699group1 && innerHeme9699group1) || (innerHeme9699group2 && outerHeme9699group2) || (outerHistInt == innerHistInt && outerHistInt != 9699)) {
                            functions.forceFailureOnEntity(binding, innerLine)
                            functions.forceFailureOnEntity(binding, outerLine)
                            return false
                        }
                    }
        
                    innerIndex += 1
                }
            }
        
            outerIndex += 1
        }
        
        return true
    }

    // ID: SEER_Other_COD; NAME: SEER Other COD (NAACCR)
    public boolean seer_other_cod(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.seerOtherCod == null || functions.matches(line.seerOtherCod, /^[0189]$/)
    }

    // ID: Sentinel_Lymph_Nodes_Examined; NAME: Sentinel Lymph Nodes Examined (COC)
    public boolean sentinel_lymph_nodes_examined(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return  line.sentinelLymphNodesExamined == null || line.sentinelLymphNodesExamined ==~ /^[0-8]\d|9[0589]$/
    }

    // ID: Sentinel_Lymph_Nodes_Positive; NAME: Sentinel Lymph Nodes Positive (COC)
    public boolean sentinel_lymph_nodes_positive(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return  line.sentinelLymphNodesPositive == null || line.sentinelLymphNodesPositive ==~ /^[0-8]\d|9[05789]$/
    }

    // ID: Sequence_Number--central; NAME: Sequence Number--Central (SEER SEQUENC)
    public boolean sequence_numberCentral(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return  line.sequenceNumberCentral != null && functions.matches(line.sequenceNumberCentral, /(^[0-7][0-9]$)|(^8[0-8]$)|(^9[89]$)/)
    }

    // ID: Sex; NAME: Sex (SEER Sex)
    public boolean sex(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.sex != null && functions.matches(line.sex, /^[1234569]$/)
    }

    // ID: State_at_DX_Geocode_1970-80-90; NAME: State at DX Geocode 1970/80/90 (NAACCR)
    public boolean state_at_dx_geocode_19708090(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.stateAtDxGeocode19708090 == null || ((List)context.FIPS_CODES).contains(line.stateAtDxGeocode19708090)
    }

    // ID: State_at_DX_Geocode_2000; NAME: State at DX Geocode 2000 (NAACCR)
    public boolean state_at_dx_geocode_2000(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.stateAtDxGeocode2000 == null || ((List)context.FIPS_CODES).contains(line.stateAtDxGeocode2000)
    }

    // ID: State_at_DX_Geocode_2010; NAME: State at DX Geocode 2010 (NAACCR)
    public boolean state_at_dx_geocode_2010(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.stateAtDxGeocode2010 == null || ((List)context.FIPS_CODES).contains(line.stateAtDxGeocode2010)
    }

    // ID: State_at_DX_Geocode_2020; NAME: State at DX Geocode 2020 (NAACCR)
    public boolean state_at_dx_geocode_2020(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.stateAtDxGeocode2020 == null || ((List)context.FIPS_CODES).contains(line.stateAtDxGeocode2020)
    }

    // ID: Summary_Stage_1977; NAME: Summary Stage 1977 (NAACCR)
    public boolean summary_stage_1977(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.seerSummaryStage1977 == null || functions.matches(line.seerSummaryStage1977, /^[012345789\s]$/)
    }

    // ID: Summary_Stage_2000; NAME: Summary Stage 2000 (NAACCR)
    public boolean summary_stage_2000(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.seerSummaryStage2000 == null || functions.matches(line.seerSummaryStage2000, /^[01234579\s]$/) ||
                    (line.seerSummaryStage2000 == '8' && line.dateOfDiagnosisYear >= '2004')
    }

    // ID: Summary_Stage_2018; NAME: Summary Stage 2018 (NAACCR)
    public boolean summary_stage_2018(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.summaryStage2018 == null || functions.matches(line.summaryStage2018, /^[0-47-9]$/)
    }

    // ID: Surv-Flag_Active_Followup; NAME: Surv-Flag Active Followup (SEER)
    public boolean survFlag_active_followup(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.survFlagActiveFollowup == null || functions.matches(line.survFlagActiveFollowup, /^[0-389]$/)
    }

    // ID: Surv-Flag_Presumed_Alive; NAME: Surv-Flag Presumed Alive (SEER)
    public boolean survFlag_presumed_alive(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.survFlagPresumedAlive == null || functions.matches(line.survFlagPresumedAlive, /^[0-389]$/)
    }

    // ID: Surv-Mos_Active_Followup; NAME: Surv-Mos Active Followup (SEER)
    public boolean survMos_active_followup(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.survMosActiveFollowup == null || functions.matches(line.survMosActiveFollowup, /^\d\d\d\d$/)
    }

    // ID: Surv-Mos_Presumed_Alive; NAME: Surv-Mos Presumed Alive (SEER)
    public boolean survMos_presumed_alive(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.survMosPresumedAlive == null || functions.matches(line.survMosPresumedAlive, /^\d\d\d\d$/)
    }

    // ID: SurvDateActiveFollowupEdit; NAME: Surv-Date Active Followup (SEER)
    public boolean survdateactivefollowupedit(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer year = functions.asInt(line.survDateActiveFollowupYear)
        Integer month = functions.asInt(line.survDateActiveFollowupMonth)
        Integer day = functions.asInt(line.survDateActiveFollowupDay)
        Integer yearCur = functions.getCurrentYear()
        Integer monthCur = functions.getCurrentMonth()
        Integer dayCur = functions.getCurrentDay()
        
        if (line.survDateActiveFollowupYear == null && line.survDateActiveFollowupMonth == null && line.survDateActiveFollowupDay == null)
            return true
        
        if (line.survDateActiveFollowupYear == null || line.survDateActiveFollowupMonth == null)
            return false
        
        if (!functions.between(year, 1930, yearCur) || month < 1 || month > 12 || (year == yearCur && month > monthCur))
            return false
        
        if (year == yearCur && month == monthCur && day > dayCur)
            return false
        
        Calendar cal = new GregorianCalendar(year, month - 1, 1)
        return cal != null && day <= cal.getActualMaximum(Calendar.DAY_OF_MONTH)
    }

    // ID: SurvDateDXRecodeEdit; NAME: Surv-Date DX Recode (SEER)
    public boolean survdatedxrecodeedit(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer year = functions.asInt(line.survDateDxRecodeYear)
        Integer month = functions.asInt(line.survDateDxRecodeMonth)
        Integer day = functions.asInt(line.survDateDxRecodeDay)
        Integer yearCur = functions.getCurrentYear()
        Integer monthCur = functions.getCurrentMonth()
        Integer dayCur = functions.getCurrentDay()
        
        if (line.survDateDxRecodeYear == null && line.survDateDxRecodeMonth == null && line.survDateDxRecodeDay == null)
            return true
        
        if (line.survDateDxRecodeYear == null || line.survDateDxRecodeMonth == null)
            return false
        
        if (!functions.between(year, 1930, yearCur) || month < 1 || month > 12 || (year == yearCur && month > monthCur))
            return false
        
        if (year == yearCur && month == monthCur && day > dayCur)
            return false
        
        Calendar cal = new GregorianCalendar(year, month - 1, 1)
        return cal != null && day <= cal.getActualMaximum(Calendar.DAY_OF_MONTH)
    }

    // ID: SurvDatePresumedAliveEdit; NAME: Surv-Date Presumed Alive (SEER)
    public boolean survdatepresumedaliveedit(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        Integer year = functions.asInt(line.survDatePresumedAliveYear)
        Integer month = functions.asInt(line.survDatePresumedAliveMonth)
        Integer day = functions.asInt(line.survDatePresumedAliveDay)
        Integer yearCur = functions.getCurrentYear()
        Integer monthCur = functions.getCurrentMonth()
        Integer dayCur = functions.getCurrentDay()
        
        if (line.survDatePresumedAliveYear == null && line.survDatePresumedAliveMonth == null && line.survDatePresumedAliveDay == null)
            return true
        
        if (line.survDatePresumedAliveYear == null || line.survDatePresumedAliveMonth == null)
            return false
        
        if (!functions.between(year, 1930, yearCur) || month < 1 || month > 12 || (year == yearCur && month > monthCur))
            return false
        
        if (year == yearCur && month == monthCur && day > dayCur)
            return false
        
        Calendar cal = new GregorianCalendar(year, month - 1, 1)
        return cal != null && day <= cal.getActualMaximum(Calendar.DAY_OF_MONTH)
    }

    // ID: TNM_Clin_Descriptor; NAME: TNM Clin Descriptor (COC)
    public boolean tnm_clin_descriptor(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.tnmClinDescriptor == null || functions.matches(line.tnmClinDescriptor, /^[0-359]$/)
    }

    // ID: TNM_Clin_M; NAME: TNM Clin M (SEER)
    public boolean tnm_clin_m(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.tnmClinM == null || ((List)context.TNM_Clin_M_All_Table).contains(line.tnmClinM)
    }

    // ID: TNM_Clin_N; NAME: TNM Clin N (SEER)
    public boolean tnm_clin_n(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.tnmClinN == null || ((List)context.TNM_Clin_N_Table).contains(line.tnmClinN)
    }

    // ID: TNM_Clin_T; NAME: TNM Clin T (SEER)
    public boolean tnm_clin_t(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.tnmClinT == null || ((List)context.TNM_Clin_T_Table).contains(line.tnmClinT)
    }

    // ID: TNM_Edition_Number; NAME: TNM Edition Number (SEER)
    public boolean tnm_edition_number(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.tnmEditionNumber == null || functions.matches(line.tnmEditionNumber, /^0[0-9]|88|99|U7$/)
    }

    // ID: TNM_Path_Descriptor; NAME: TNM Path Descriptor (COC)
    public boolean tnm_path_descriptor(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.tnmPathDescriptor == null || functions.matches(line.tnmPathDescriptor, /^[0-69]$/)
    }

    // ID: TNM_Path_M; NAME: TNM Path M (SEER)
    public boolean tnm_path_m(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.tnmPathM == null || ((List)context.TNM_Path_M_All_Table).contains(line.tnmPathM)
    }

    // ID: TNM_Path_N; NAME: TNM Path N (SEER)
    public boolean tnm_path_n(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.tnmPathN == null || ((List)context.TNM_Path_N_Table).contains(line.tnmPathN)
    }

    // ID: TNM_Path_T; NAME: TNM Path T (SEER)
    public boolean tnm_path_t(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.tnmPathT == null || ((List)context.TNM_Path_T_Table).contains(line.tnmPathT)
    }

    // ID: Tobacco_Use_Smoking_Status; NAME: Tobacco Use Smoking Status (NAACCR)
    public boolean tobacco_use_smoking_status(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.tobaccoUseSmokingStatus == null || functions.matches(line.tobaccoUseSmokingStatus, /^[0-39]$/)
    }

    // ID: Total_Dose; NAME: Total Dose (COC)
    public boolean total_dose(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.totalDose == null || functions.matches(line.totalDose, /^\d{6}$/)
    }

    // ID: Tumor_Marker_1; NAME: Tumor Marker 1 (SEER TUMMARK1)
    public boolean tumor_marker_1(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.tumorMarker1 == null || functions.matches(line.tumorMarker1, /^[0-689]$/)
    }

    // ID: Tumor_Marker_2; NAME: Tumor Marker 2 (SEER TUMMARK2)
    public boolean tumor_marker_2(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.tumorMarker2 == null || functions.matches(line.tumorMarker2, /^[0-689]$/)
    }

    // ID: Tumor_Marker_3; NAME: Tumor Marker 3 (SEER TUMMARK3)
    public boolean tumor_marker_3(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.tumorMarker3 == null || functions.matches(line.tumorMarker3, /^[0-689]$/)
    }

    // ID: Tumor_Size_Clinical; NAME: Tumor Size Clinical (SEER)
    public boolean tumor_size_clinical(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.tumorSizeClinical == null || functions.matches(line.tumorSizeClinical, /^[0-8]\d\d|9[0-8]\d|99[089]$/)
    }

    // ID: Tumor_Size_Pathologic; NAME: Tumor Size Pathologic (SEER)
    public boolean tumor_size_pathologic(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.tumorSizePathologic == null || functions.matches(line.tumorSizePathologic, /^[0-8]\d\d|9[0-8]\d|99[089]$/)
    }

    // ID: Tumor_Size_Summary; NAME: Tumor Size Summary (NPCR)
    public boolean tumor_size_summary(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.tumorSizeSummary == null || functions.matches(line.tumorSizeSummary, /^[0-8]\d\d|9[0-8]\d|99[089]$/)
    }

    // ID: Type_of_Reporting_Source; NAME: Type of Reporting Source (SEER RPRTSRC)
    public boolean type_of_reporting_source(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return  functions.matches(line.typeOfReportingSource, /^[12345678]$/)
    }

    // ID: URIC_2000; NAME: URIC 2000 (NAACCR)
    public boolean uric_2000(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.uric2000 == null || functions.matches(line.uric2000, /^[12349ABCD]$/)
    }

    // ID: URIC_2010; NAME: URIC 2010 (NAACCR)
    public boolean uric_2010(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.uric2010 == null || functions.matches(line.uric2010, /^[12349ABCD]$/)
    }

    // ID: Vital_Status; NAME: Vital Status (COC)
    public boolean vital_status(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return  functions.matches(line.vitalStatus, /^[01]$/)
    }

    // ID: Vital_Status_Recode; NAME: Vital Status Recode (NAACCR)
    public boolean vital_status_recode(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.vitalStatusRecode == null || functions.matches(line.vitalStatusRecode, /^[01]$/)
    }

    // ID: Year_BRM; NAME: RX Date BRM (COC)
    public boolean year_brm(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return (line.rxDateBrmYear == null || (functions.matches(line.rxDateBrmYear, /^[12]\d\d\d$/) && functions.between(line.rxDateBrmYear, 1930, functions.getCurrentYear()) ) )
    }

    // ID: Year_Chemo; NAME: RX Date Chemo (COC)
    public boolean year_chemo(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return (line.rxDateChemoYear == null || (functions.matches(line.rxDateChemoYear, /^[12]\d\d\d$/) && functions.between(line.rxDateChemoYear, 1930, functions.getCurrentYear()) ) )
    }

    // ID: Year_Hormone; NAME: RX Date Hormone (COC)
    public boolean year_hormone(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return (line.rxDateHormoneYear == null || (functions.matches(line.rxDateHormoneYear, /^[12]\d\d\d$/) && functions.between(line.rxDateHormoneYear, 1930, functions.getCurrentYear()) ) )
    }

    // ID: Year_Most_Defin_Surg; NAME: RX Date Mst Defn Srg (COC)
    public boolean year_most_defin_surg(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return (line.rxDateMostDefinSurgYear == null || (functions.matches(line.rxDateMostDefinSurgYear, /^[12]\d\d\d$/) && functions.between(line.rxDateMostDefinSurgYear, 1930, functions.getCurrentYear()) ) )
    }

    // ID: Year_of_Birth; NAME: Date of Birth (NAACCR)
    public boolean year_of_birth(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return functions.between(line.dateOfBirthYear, 1800, functions.getCurrentYear()) || line.dateOfBirthYear == null
    }

    // ID: Year_of_Diagnosis; NAME: Date of Diagnosis (NAACCR DATEEDIT)
    public boolean year_of_diagnosis(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return ( line.dateOfDiagnosisYear == null ||
           ( functions.matches(line.dateOfDiagnosisYear, /^[12]\d\d\d$/) && functions.between(line.dateOfDiagnosisYear, 1930, functions.getCurrentYear()) ) )
    }

    // ID: Year_of_Initial_RX-SEER; NAME: Date Initial RX SEER (NAACCR)
    public boolean year_of_initial_rxSeer(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return (line.dateInitialRxSeerYear == null || (functions.matches(line.dateInitialRxSeerYear, /^[12]\d\d\d$/) && functions.between(line.dateInitialRxSeerYear, 1930, functions.getCurrentYear()) ) )
    }

    // ID: Year_of_Last_Contact; NAME: Date of Last Contact (NAACCR DATEEDIT)
    public boolean year_of_last_contact(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.dateOfLastContactYear == null || ((functions.matches(line.dateOfLastContactYear, /^[12]\d\d\d$/)) &&
                    functions.between(line.dateOfLastContactYear, 1930, functions.getCurrentYear()) )
    }

    // ID: Year_of_Last_Contact_Submission; NAME: Year of Last Contact for Submission
    public boolean year_of_last_contact_submission(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        if (line.dateOfLastContactYear == null)
            return false
        return true
    }

    // ID: Year_Other; NAME: RX Date Other (COC)
    public boolean year_other(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return (line.rxDateOtherYear == null || (functions.matches(line.rxDateOtherYear, /^[12]\d\d\d$/) && functions.between(line.rxDateOtherYear, 1930, functions.getCurrentYear()) ) )
    }

    // ID: Year_Radiation; NAME: RX Date Radiation (COC)
    public boolean year_radiation(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return ( line.rxDateRadiationYear == null || ( functions.matches(line.rxDateRadiationYear, /^[12]\d\d\d$/) &&
                functions.between(line.rxDateRadiationYear, 1930, functions.getCurrentYear()) ) )
    }

    // ID: Year_Recurrence_Date_1st; NAME: Recurrence Date--1st (COC)
    public boolean year_recurrence_date_1st(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return ( line.recurrenceDate1stYear == null || ( functions.matches(line.recurrenceDate1stYear, /^[12]\d\d\d$/) &&
                functions.between(line.recurrenceDate1stYear, 1930, functions.getCurrentYear()) ) )
    }

    // ID: Year_Regional_Lymph_Node_Dissection; NAME: Date Regional Lymph Node Dissection (COC)
    public boolean year_regional_lymph_node_dissection(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return ( line.dateRegionalLNDissectionYear == null || ( functions.matches(line.dateRegionalLNDissectionYear, /^[12]\d\d\d$/) &&
                functions.between(line.dateRegionalLNDissectionYear, 1930, functions.getCurrentYear()) ) )
    }

    // ID: Year_Sentinel_Lymph_Node_Biopsy; NAME: Date of Sentinel Lymph Node Biopsy (COC)
    public boolean year_sentinel_lymph_node_biopsy(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return ( line.dateSentinelLymphNodeBiopsyYear == null || ( functions.matches(line.dateSentinelLymphNodeBiopsyYear, /^[12]\d\d\d$/) &&
                functions.between(line.dateSentinelLymphNodeBiopsyYear, 1930, functions.getCurrentYear()) ) )
    }

    // ID: Year_Surgery; NAME: RX Date Surgery (COC)
    public boolean year_surgery(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return (line.rxDateSurgeryYear == null || (functions.matches(line.rxDateSurgeryYear, /^[12]\d\d\d$/) &&
                functions.between(line.rxDateSurgeryYear, 1930, functions.getCurrentYear()) ) )
    }

    // ID: Year_SurvDateActiveFollowup; NAME: Surv-Date Active Followup (SEER)
    public boolean year_survdateactivefollowup(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.survDateActiveFollowupYear == null || ((functions.matches(line.survDateActiveFollowupYear, /^[12]\d\d\d$/)) &&
                functions.between(line.survDateActiveFollowupYear, 1930, functions.getCurrentYear()) )
    }

    // ID: Year_SurvDateDXRecode; NAME: Surv-Date DX Recode (SEER)
    public boolean year_survdatedxrecode(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.survDateDxRecodeYear == null || ((functions.matches(line.survDateDxRecodeYear, /^[12]\d\d\d$/)) &&
                    functions.between(line.survDateDxRecodeYear, 1930, functions.getCurrentYear()) )
    }

    // ID: Year_SurvDatePresumedAlive; NAME: Surv-Date Presumed Alive (SEER)
    public boolean year_survdatepresumedalive(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return line.survDatePresumedAliveYear == null || ((functions.matches(line.survDatePresumedAliveYear, /^[12]\d\d\d$/)) &&
                functions.between(line.survDatePresumedAliveYear, 1930, functions.getCurrentYear()) )
    }

    // ID: Year_Systemic; NAME: RX Date Systemic (COC)
    public boolean year_systemic(Binding binding, Map context, StagingContextFunctions functions, List> lines, Map line) throws Exception {
        return (line.rxDateSystemicYear == null || (functions.matches(line.rxDateSystemicYear, /^[12]\d\d\d$/) &&
                functions.between(line.rxDateSystemicYear, 1930, functions.getCurrentYear()) ) )
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy