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

import gov.nih.nci.cabig.caaers.domain.*;
import gov.nih.nci.cabig.caaers.domain.expeditedfields.ExpeditedReportSection;
import gov.nih.nci.cabig.caaers.utils.ConfigProperty;
import gov.nih.nci.cabig.caaers.web.fields.*;
import static gov.nih.nci.cabig.caaers.web.fields.InputFieldFactory.createTextField;
import static gov.nih.nci.cabig.caaers.web.fields.InputFieldFactory.createSelectField;
import static gov.nih.nci.cabig.caaers.web.fields.InputFieldFactory.createPastDateField;
import gov.nih.nci.cabig.caaers.web.utils.WebUtils;
import static gov.nih.nci.cabig.caaers.web.utils.WebUtils.collectOptions;
import gov.nih.nci.cabig.caaers.dao.ExpeditedAdverseEventReportDao;
import gov.nih.nci.cabig.ctms.domain.DomainObject;

import javax.servlet.http.HttpServletRequest;
import java.util.*;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.validation.Errors;
import org.springframework.beans.factory.annotation.Required;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * @author <NAME>
 */

public class StudyInterventionsTab extends AeTab {
    private static final Log log = LogFactory.getLog(StudyInterventionsTab.class);
    protected ExpeditedAdverseEventReportDao expeditedAdverseEventReportDao;

    Map<String, String> methodNameMap = new HashMap<String, String>();
    private ConfigProperty configurationProperty;
    private static final String STUDY_INTERVENTION_SURGERY = "surgery";
    private static final String STUDY_INTERVENTION_DEVICE = "device";
    private static final String STUDY_INTERVENTION_RADIATION = "radiation";
    private static final String STUDY_INTERVENTION_AGENT = "agent";

    public StudyInterventionsTab() {
        super("Study Interventions", ExpeditedReportSection.STUDY_INTERVENTIONS.getDisplayName(), "ae/studyInterventions");
        methodNameMap.put("add" + STUDY_INTERVENTION_SURGERY, "addSurgery");
        methodNameMap.put("remove" + STUDY_INTERVENTION_SURGERY, "removeSurgery");        
        methodNameMap.put("add" + STUDY_INTERVENTION_RADIATION, "addRadiation");
        methodNameMap.put("remove" + STUDY_INTERVENTION_RADIATION, "removeRadiation");        
        methodNameMap.put("add" + STUDY_INTERVENTION_DEVICE, "addDevice");
        methodNameMap.put("remove" + STUDY_INTERVENTION_DEVICE, "removeDevice");        
        methodNameMap.put("add" + STUDY_INTERVENTION_AGENT, "addAgent");
        methodNameMap.put("remove" + STUDY_INTERVENTION_AGENT, "removeAgent");        
    }

    private void createRadiationFieldGroups(AeInputFieldCreator creator, ExpeditedAdverseEventInputCommand command){
        Map<Object, Object> statusOpts = new LinkedHashMap<Object, Object>();
        statusOpts.put("", "Please select");
        statusOpts.putAll(collectOptions(Arrays.asList(RadiationAdministration.values()), null, "displayName"));
        InputField doseUOMField = InputFieldFactory.createSelectField("dosageUnit", "Unit of measure", false, WebUtils.sortMapByKey(WebUtils.collectOptions(configurationProperty.getMap().get("radiationDoseUMORefData"), "code", "desc", "Please Select"), true));
        InputField fractionNumberField = createTextField("fractionNumber", "Schedule number of fractions", false);
        fractionNumberField.getAttributes().put(InputField.HELP, "ae.radiationIntervention.aeReport.radiationInterventions.fractionNumber");

        creator.createRepeatingFieldGroup("radiationIntervention", "radiationInterventions", new SimpleNumericDisplayNameCreator("Radiation"),
                createSelectField("administration", "Type of radiation administration", false, statusOpts),
                createTextField("dosage", "Total dose (to date)", false),
                doseUOMField,
                createPastDateField("lastTreatmentDate", "Date of last treatment", false),
                fractionNumberField,
                createTextField("daysElapsed", " Number of elapsed days", false),
                createSelectField("adjustment", "Adjustment", false, WebUtils.collectOptions(configurationProperty.getMap().get("radiationAdjustmentRefData"), "code","desc", "Please Select")));
    }

    private void createSurgeryFieldGroups(AeInputFieldCreator creator, ExpeditedAdverseEventInputCommand command){
        String code = command.getAeReport().getTreatmentInformation().getTreatmentAssignment() != null ? command .getAeReport().getTreatmentInformation().getTreatmentAssignment().getCode() : null;
        String description = code != null ? command.getAeReport().getTreatmentInformation().getTreatmentAssignmentDescription() : command.getAeReport().getTreatmentInformation().getTreatmentDescription();
        InputField descField = InputFieldFactory.createTextArea("description", "Treatment arm description", false);
        InputFieldAttributes.setColumns(descField, 45);
        InputFieldAttributes.setDetails(descField, description);
        InputField codeField = createTextField("treatmentArm", "Treatment arm", false);
        InputFieldAttributes.setDetails(codeField, code);<commit_msg>CAAERS-294<commit_after>package gov.nih.nci.cabig.caaers.web.ae;

import gov.nih.nci.cabig.caaers.domain.*;
import gov.nih.nci.cabig.caaers.domain.expeditedfields.ExpeditedReportSection;
import gov.nih.nci.cabig.caaers.utils.ConfigProperty;
import gov.nih.nci.cabig.caaers.web.fields.*;
import gov.nih.nci.cabig.caaers.web.fields.validators.FieldValidator;
import static gov.nih.nci.cabig.caaers.web.fields.InputFieldFactory.createTextField;
import static gov.nih.nci.cabig.caaers.web.fields.InputFieldFactory.createSelectField;
import static gov.nih.nci.cabig.caaers.web.fields.InputFieldFactory.createPastDateField;
import gov.nih.nci.cabig.caaers.web.utils.WebUtils;
import static gov.nih.nci.cabig.caaers.web.utils.WebUtils.collectOptions;
import gov.nih.nci.cabig.caaers.dao.ExpeditedAdverseEventReportDao;
import gov.nih.nci.cabig.ctms.domain.DomainObject;

import javax.servlet.http.HttpServletRequest;
import java.util.*;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.validation.Errors;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.beans.BeanWrapper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * @author <NAME>
 */

public class StudyInterventionsTab extends AeTab {
    private static final Log log = LogFactory.getLog(StudyInterventionsTab.class);
    protected ExpeditedAdverseEventReportDao expeditedAdverseEventReportDao;

    Map<String, String> methodNameMap = new HashMap<String, String>();
    private ConfigProperty configurationProperty;
    private static final String STUDY_INTERVENTION_SURGERY = "surgery";
    private static final String STUDY_INTERVENTION_DEVICE = "device";
    private static final String STUDY_INTERVENTION_RADIATION = "radiation";
    private static final String STUDY_INTERVENTION_AGENT = "agent";

    public StudyInterventionsTab() {
        super("Study Interventions", ExpeditedReportSection.STUDY_INTERVENTIONS.getDisplayName(), "ae/studyInterventions");
        methodNameMap.put("add" + STUDY_INTERVENTION_SURGERY, "addSurgery");
        methodNameMap.put("remove" + STUDY_INTERVENTION_SURGERY, "removeSurgery");        
        methodNameMap.put("add" + STUDY_INTERVENTION_RADIATION, "addRadiation");
        methodNameMap.put("remove" + STUDY_INTERVENTION_RADIATION, "removeRadiation");        
        methodNameMap.put("add" + STUDY_INTERVENTION_DEVICE, "addDevice");
        methodNameMap.put("remove" + STUDY_INTERVENTION_DEVICE, "removeDevice");        
        methodNameMap.put("add" + STUDY_INTERVENTION_AGENT, "addAgent");
        methodNameMap.put("remove" + STUDY_INTERVENTION_AGENT, "removeAgent");        
    }

    private void createRadiationFieldGroups(AeInputFieldCreator creator, ExpeditedAdverseEventInputCommand command){
        Map<Object, Object> statusOpts = new LinkedHashMap<Object, Object>();
        statusOpts.put("", "Please select");
        statusOpts.putAll(collectOptions(Arrays.asList(RadiationAdministration.values()), null, "displayName"));
        InputField doseUOMField = InputFieldFactory.createSelectField("dosageUnit", "Unit of measure", false, WebUtils.sortMapByKey(WebUtils.collectOptions(configurationProperty.getMap().get("radiationDoseUMORefData"), "code", "desc", "Please Select"), true));
        InputField fractionNumberField = createTextField("fractionNumber", "Schedule number of fractions", false);
        fractionNumberField.getAttributes().put(InputField.HELP, "ae.radiationIntervention.aeReport.radiationInterventions.fractionNumber");

        creator.createRepeatingFieldGroup("radiationIntervention", "radiationInterventions", new SimpleNumericDisplayNameCreator("Radiation"),
                createSelectField("administration", "Type of radiation administration", false, statusOpts),
                createTextField("dosage", "Total dose (to date)", FieldValidator.NUMBER_VALIDATOR),
                doseUOMField,
                createPastDateField("lastTreatmentDate", "Date of last treatment", false),
                fractionNumberField,
                createTextField("daysElapsed", " Number of elapsed days", false),
                createSelectField("adjustment", "Adjustment", false, WebUtils.collectOptions(configurationProperty.getMap().get("radiationAdjustmentRefData"), "code","desc", "Please Select")));
    }

    private void createSurgeryFieldGroups(AeInputFieldCreator creator, ExpeditedAdverseEventInputCommand command){
        String code = command.getAeReport().getTreatmentInformation().getTreatmentAssignment() != null ? command .getAeReport().getTreatmentInformation().getTreatmentAssignment().getCode() : null;
        String description = code != null ? command.getAeReport().getTreatmentInformation().getTreatmentAssignmentDescription() : command.getAeReport().getTreatmentInformation().getTreatmentDescription();
        InputField descField = InputFieldFactory.createTextArea("description", "Treatment arm description", false);
        InputFieldAttributes.setColumns(descField, 45);
        InputFieldAttributes.setDetails(descField, description);
        InputField codeField = createTextField("treatmentArm", "Treatment arm", false);
        InputFieldAttributes.setDetails(codeField, code);
{'fraction_non_alphanumeric': 0.10760650062506011, 'fraction_numerical': 0.0006731416482354072, 'mean_word_length': 5.24249699879952, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '683685', 'n_tokens_mistral': 3046, 'n_tokens_neox': 2923, 'n_words': 479}