<commit_before>package gov.nih.nci.cabig.caaers.web.ae;

import gov.nih.nci.cabig.caaers.domain.Attribution;
import gov.nih.nci.cabig.caaers.domain.ExpeditedAdverseEventReport;
import gov.nih.nci.cabig.caaers.domain.attribution.AdverseEventAttribution;
import gov.nih.nci.cabig.caaers.domain.expeditedfields.ExpeditedReportSection;
import gov.nih.nci.cabig.caaers.domain.report.ReportDefinition;
import gov.nih.nci.cabig.caaers.validation.ValidationErrors;
import gov.nih.nci.cabig.caaers.web.fields.DefaultInputFieldGroup;
import gov.nih.nci.cabig.caaers.web.fields.InputField;
import gov.nih.nci.cabig.caaers.web.fields.InputFieldFactory;
import gov.nih.nci.cabig.caaers.web.fields.InputFieldGroup;
import gov.nih.nci.cabig.caaers.web.utils.WebUtils;
import gov.nih.nci.cabig.ctms.domain.DomainObject;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

/**
 * @author <NAME>
 */
public class AttributionTab extends AeTab {
    private static final Map<Object, Object> ATTRIBUTION_OPTIONS = collectAttributionOptions();

    protected AttributionTab() {
        super("Attribution", ExpeditedReportSection.ATTRIBUTION_SECTION.getDisplayName(),"ae/attribution");
    }

    @Override
    protected void createFieldGroups(AeInputFieldCreator creator, ExpeditedAdverseEventInputCommand command) {
        List<AttributionBlock> blocks = createBlocks(command.getAeReport());
        for (AttributionBlock block : blocks) {
            for (InputFieldGroup group : block.getRows()) {
                creator.addUnprocessedFieldGroup(group);
            }
        }
    }

    private List<AttributionBlock> createBlocks(ExpeditedAdverseEventReport report) {
        List<AttributionBlock> blocks = new ArrayList<AttributionBlock>();
        String studyPurpose =  report.getAssignment().getStudySite().getStudy().getStudyPurpose();
        boolean isStudyForTreatment = (studyPurpose != null && studyPurpose.equals("Treatment"));
        if (studyPurpose == null || isStudyForTreatment) blocks.add(new AttributionBlock("Disease", createGroups(CauseAndAttributionAccessor.DISEASE, report)));
        blocks.add(new AttributionBlock("Study Agent", "Agents", createGroups(CauseAndAttributionAccessor.COURSE_AGENT, report)));
        blocks.add(new AttributionBlock("Surgery", createGroups(CauseAndAttributionAccessor.SURGERY, report)));
        blocks.add(new AttributionBlock("Other Interventions", createGroups(CauseAndAttributionAccessor.OTHER_INTERVENTION, report)));
        blocks.add(new AttributionBlock("Biological Interventions", createGroups(CauseAndAttributionAccessor.BIOLOGICAL_INTERVENTION, report)));
        blocks.add(new AttributionBlock("Behavioral Interventions", createGroups(CauseAndAttributionAccessor.BEHAVIORAL_INTERVENTION, report)));
        blocks.add(new AttributionBlock("Genetic Interventions", createGroups(CauseAndAttributionAccessor.GENETIC_INTERVENTION, report)));
        blocks.add(new AttributionBlock("Dietary Supplement Interventions", createGroups(CauseAndAttributionAccessor.DIETARY_INTERVENTION, report)));
        blocks.add(new AttributionBlock("Radiation", createGroups(CauseAndAttributionAccessor.RADIATION, report)));
        blocks.add(new AttributionBlock("Medical device", createGroups(CauseAndAttributionAccessor.DEVICE, report)));
        blocks.add(new AttributionBlock("Concomitant medication", createGroups(CauseAndAttributionAccessor.CONCOMITANT_MEDICATION, report)));
        blocks.add(new AttributionBlock("Other cause", createGroups(CauseAndAttributionAccessor.OTHER_CAUSE, report)));<commit_msg>Disease Attribution do not shows up.<commit_after>package gov.nih.nci.cabig.caaers.web.ae;

import gov.nih.nci.cabig.caaers.domain.Attribution;
import gov.nih.nci.cabig.caaers.domain.ExpeditedAdverseEventReport;
import gov.nih.nci.cabig.caaers.domain.attribution.AdverseEventAttribution;
import gov.nih.nci.cabig.caaers.domain.expeditedfields.ExpeditedReportSection;
import gov.nih.nci.cabig.caaers.domain.report.ReportDefinition;
import gov.nih.nci.cabig.caaers.validation.ValidationErrors;
import gov.nih.nci.cabig.caaers.web.fields.DefaultInputFieldGroup;
import gov.nih.nci.cabig.caaers.web.fields.InputField;
import gov.nih.nci.cabig.caaers.web.fields.InputFieldFactory;
import gov.nih.nci.cabig.caaers.web.fields.InputFieldGroup;
import gov.nih.nci.cabig.caaers.web.utils.WebUtils;
import gov.nih.nci.cabig.ctms.domain.DomainObject;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

/**
 * @author <NAME>
 */
public class AttributionTab extends AeTab {
    private static final Map<Object, Object> ATTRIBUTION_OPTIONS = collectAttributionOptions();

    protected AttributionTab() {
        super("Attribution", ExpeditedReportSection.ATTRIBUTION_SECTION.getDisplayName(),"ae/attribution");
    }

    @Override
    protected void createFieldGroups(AeInputFieldCreator creator, ExpeditedAdverseEventInputCommand command) {
        List<AttributionBlock> blocks = createBlocks(command.getAeReport());
        for (AttributionBlock block : blocks) {
            for (InputFieldGroup group : block.getRows()) {
                creator.addUnprocessedFieldGroup(group);
            }
        }
    }

    private List<AttributionBlock> createBlocks(ExpeditedAdverseEventReport report) {
        List<AttributionBlock> blocks = new ArrayList<AttributionBlock>();
        blocks.add(new AttributionBlock("Disease", createGroups(CauseAndAttributionAccessor.DISEASE, report)));
        blocks.add(new AttributionBlock("Study Agent", "Agents", createGroups(CauseAndAttributionAccessor.COURSE_AGENT, report)));
        blocks.add(new AttributionBlock("Surgery", createGroups(CauseAndAttributionAccessor.SURGERY, report)));
        blocks.add(new AttributionBlock("Other Interventions", createGroups(CauseAndAttributionAccessor.OTHER_INTERVENTION, report)));
        blocks.add(new AttributionBlock("Biological Interventions", createGroups(CauseAndAttributionAccessor.BIOLOGICAL_INTERVENTION, report)));
        blocks.add(new AttributionBlock("Behavioral Interventions", createGroups(CauseAndAttributionAccessor.BEHAVIORAL_INTERVENTION, report)));
        blocks.add(new AttributionBlock("Genetic Interventions", createGroups(CauseAndAttributionAccessor.GENETIC_INTERVENTION, report)));
        blocks.add(new AttributionBlock("Dietary Supplement Interventions", createGroups(CauseAndAttributionAccessor.DIETARY_INTERVENTION, report)));
        blocks.add(new AttributionBlock("Radiation", createGroups(CauseAndAttributionAccessor.RADIATION, report)));
        blocks.add(new AttributionBlock("Medical device", createGroups(CauseAndAttributionAccessor.DEVICE, report)));
        blocks.add(new AttributionBlock("Concomitant medication", createGroups(CauseAndAttributionAccessor.CONCOMITANT_MEDICATION, report)));
        blocks.add(new AttributionBlock("Other cause", createGroups(CauseAndAttributionAccessor.OTHER_CAUSE, report)));
{'fraction_non_alphanumeric': 0.10567624386825508, 'fraction_numerical': 0.0, 'mean_word_length': 5.776828110161444, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5715100', 'n_tokens_mistral': 2251, 'n_tokens_neox': 2091, 'n_words': 300}