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

com.imsweb.algorithms.seersiterecode.SeerSiteRecode2023Algorithm Maven / Gradle / Ivy

Go to download

Java implementation of cancer-related algorithms (NHIA, NAPIIA, Survival Time, etc...)

There is a newer version: 4.11
Show newest version
/*
 * Copyright (C) 2020 Information Management Services, Inc.
 */
package com.imsweb.algorithms.seersiterecode;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.imsweb.algorithms.AbstractAlgorithm;
import com.imsweb.algorithms.AlgorithmInput;
import com.imsweb.algorithms.AlgorithmOutput;
import com.imsweb.algorithms.Algorithms;
import com.imsweb.algorithms.internal.Utils;

import static com.imsweb.algorithms.Algorithms.FIELD_BEHAV_O3;
import static com.imsweb.algorithms.Algorithms.FIELD_DX_DATE;
import static com.imsweb.algorithms.Algorithms.FIELD_HIST_O3;
import static com.imsweb.algorithms.Algorithms.FIELD_PRIMARY_SITE;
import static com.imsweb.algorithms.Algorithms.FIELD_SEER_SITE_RECODE;
import static com.imsweb.algorithms.Algorithms.FIELD_SEER_SITE_RECODE_2023;
import static com.imsweb.algorithms.Algorithms.FIELD_SEER_SITE_RECODE_2023_EXPANDED;
import static com.imsweb.algorithms.Algorithms.FIELD_TUMORS;

public class SeerSiteRecode2023Algorithm extends AbstractAlgorithm {

    public SeerSiteRecode2023Algorithm() {
        super(Algorithms.ALG_SEER_SITE_RECODE_2023, SeerSiteRecodeUtils.ALG_NAME, SeerSiteRecodeUtils.VERSION_2023);

        _url = "https://seer.cancer.gov/siterecode/icdo3_2023/";

        _inputFields.add(Algorithms.getField(FIELD_PRIMARY_SITE));
        _inputFields.add(Algorithms.getField(FIELD_HIST_O3));
        _inputFields.add(Algorithms.getField(FIELD_BEHAV_O3));
        _inputFields.add(Algorithms.getField(FIELD_DX_DATE));

        _outputFields.add(Algorithms.getField(FIELD_SEER_SITE_RECODE_2023));
        _outputFields.add(Algorithms.getField(FIELD_SEER_SITE_RECODE_2023_EXPANDED));

        _unknownValues.put(FIELD_SEER_SITE_RECODE, Collections.singletonList(SeerSiteRecodeUtils.UNKNOWN_RECODE_2023));
    }

    @Override
    public AlgorithmOutput execute(AlgorithmInput input) {
        Map outputPatient = new HashMap<>();
        List> outputTumors = new ArrayList<>();
        outputPatient.put(FIELD_TUMORS, outputTumors);

        for (Map inputTumor : Utils.extractTumors(Utils.extractPatient(input))) {
            String site = (String)inputTumor.get(FIELD_PRIMARY_SITE);
            String hist = (String)inputTumor.get(FIELD_HIST_O3);
            String beh = (String)inputTumor.get(FIELD_BEHAV_O3);
            String dxYear = Utils.extractYear((String)inputTumor.get(FIELD_DX_DATE));

            Map outputTumor = new HashMap<>();
            outputTumor.put(FIELD_SEER_SITE_RECODE_2023, SeerSiteRecodeUtils.calculateSiteRecode(SeerSiteRecodeUtils.VERSION_2023, site, hist, beh, dxYear));
            outputTumor.put(FIELD_SEER_SITE_RECODE_2023_EXPANDED, SeerSiteRecodeUtils.calculateSiteRecode(SeerSiteRecodeUtils.VERSION_2023_EXPANDED, site, hist, beh, dxYear));
            outputTumors.add(outputTumor);
        }

        return AlgorithmOutput.of(outputPatient);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy