<commit_before>'use strict';
import React, {PropTypes} from 'react';
import { Form, FormMixin, Input } from '../../../libs/bootstrap/form';
import { RestMixin } from '../../rest';
import * as curator from '../../curator';
import * as evidenceCodes from './mapping/evidence_code.json';

var EvaluationSummary = module.exports.EvaluationSummary = React.createClass({
    mixins: [FormMixin, RestMixin],

    propTypes: {
        interpretation: React.PropTypes.object,
        updateInterpretationObj: React.PropTypes.func,
        setProvisionalEvaluation: React.PropTypes.func,
        calculatedAssertion: React.PropTypes.string,
        provisionalPathogenicity: React.PropTypes.string,
        provisionalReason: React.PropTypes.string,
        provisionalInterpretation: React.PropTypes.bool,
        disabledProvisionalCheckbox: React.PropTypes.bool
    },

    getInitialState: function() {
        return {
            interpretation: this.props.interpretation,
            calculatedAssertion: this.props.calculatedAssertion,
            autoClassification: null,
            modifiedPathogenicity: null,
            provisionalPathogenicity: this.props.provisionalPathogenicity,
            provisionalReason: this.props.provisionalReason,
            provisionalInterpretation: this.props.provisionalInterpretation,
            disabledCheckbox: this.props.disabledProvisionalCheckbox,
            disabledFormSumbit: false,
            submitBusy: false, // spinner for Save button
            updateMsg: null // status message for Save/Update button
        };
    },

    componentWillReceiveProps: function(nextProps) {
        if (nextProps.interpretation && this.props.interpretation) {
            this.setState({interpretation: nextProps.interpretation});
        }
        if (nextProps.calculatedAssertion && this.props.calculatedAssertion) {
            this.setState({calculatedAssertion: nextProps.calculatedAssertion});
        }
        if (nextProps.provisionalPathogenicity) {
            this.setState({provisionalPathogenicity: nextProps.provisionalPathogenicity});
        }
        if (nextProps.provisionalReason) {
            this.setState({provisionalReason: nextProps.provisionalReason});
        }
        this.setState({
            provisionalInterpretation: nextProps.provisionalInterpretation,
            disabledCheckbox: nextProps.disabledProvisionalCheckbox
        });
    },

    // Handle value changes in provisional form
    handleChange: function(ref, e) {
        // Handle modified pathogenicity dropdown
        if (ref === 'provisional-pathogenicity') {
            if (this.refs[ref].getValue()) {
                this.setState({provisionalPathogenicity: this.refs[ref].getValue()}, () => {
                    // Pass dropdown state change back to parent component
                    this.props.setProvisionalEvaluation('provisional-pathogenicity', this.state.provisionalPathogenicity);
                    // Disable save button if a reason is not provided for the modification
                    if (!this.state.provisionalReason) {
                        this.setState({disabledFormSumbit: true});
                    } else {
                        this.setState({disabledFormSumbit: false});
                    }
                });
            } else {
                this.setState({provisionalPathogenicity: null}, () => {
                    // Pass null dropdown state change back to parent component
                    this.props.setProvisionalEvaluation('provisional-pathogenicity', this.state.provisionalPathogenicity);
                    // Disable save button if a reason is provided without the modification
                    if (this.state.provisionalReason) {
                        this.setState({disabledFormSumbit: true});
                    } else {
                        this.setState({disabledFormSumbit: false});
                    }
                });
            }
        }
        // Handle reason/explanation for pathogenicity modification/change
        if (ref === 'provisional-reason') {
            if (this.refs[ref].getValue()) {
                this.setState({provisionalReason: this.refs[ref].getValue()}, () => {
                    // Pass textarea state change back to parent component
                    this.props.setProvisionalEvaluation('provisional-reason', this.state.provisionalReason);
                    // Disable save button if a modification is not provided for the reason
                    if (!this.state.provisionalPathogenicity) {
                        this.setState({disabledFormSumbit: true});
                    } else {
                        this.setState({disabledFormSumbit: false});
                    }
                });
            } else {
                this.setState({provisionalReason: null}, () => {
                    // Pass null textarea state change back to parent component
                    this.props.setProvisionalEvaluation('provisional-reason', this.state.provisionalReason);
                    // Disable save button if a modification is provided without the reason
                    if (this.state.provisionalPathogenicity) {
                        this.setState({disabledFormSumbit: true});<commit_msg>Updated code to handle provisional interpretation checkbox within the component itself with the help of componentDidMount lifecycle method<commit_after>'use strict';
import React, {PropTypes} from 'react';
import { Form, FormMixin, Input } from '../../../libs/bootstrap/form';
import { RestMixin } from '../../rest';
import * as curator from '../../curator';
import * as evidenceCodes from './mapping/evidence_code.json';

var EvaluationSummary = module.exports.EvaluationSummary = React.createClass({
    mixins: [FormMixin, RestMixin],

    propTypes: {
        interpretation: React.PropTypes.object,
        updateInterpretationObj: React.PropTypes.func,
        setProvisionalEvaluation: React.PropTypes.func,
        calculatedAssertion: React.PropTypes.string,
        provisionalPathogenicity: React.PropTypes.string,
        provisionalReason: React.PropTypes.string,
        provisionalInterpretation: React.PropTypes.bool
    },

    getInitialState: function() {
        return {
            interpretation: this.props.interpretation,
            calculatedAssertion: this.props.calculatedAssertion,
            autoClassification: null,
            modifiedPathogenicity: null,
            provisionalPathogenicity: this.props.provisionalPathogenicity,
            provisionalReason: this.props.provisionalReason,
            provisionalInterpretation: this.props.provisionalInterpretation,
            disabledCheckbox: false,
            disabledFormSumbit: false,
            submitBusy: false, // spinner for Save button
            updateMsg: null // status message for Save/Update button
        };
    },

    componentDidMount: function() {
        if (this.props.interpretation && this.props.calculatedAssertion) {
            this.handleProvisionalCheckBox(this.state.provisionalPathogenicity);
        }
    },

    componentWillReceiveProps: function(nextProps) {
        if (nextProps.interpretation) {
            this.setState({interpretation: nextProps.interpretation});
        }
        if (nextProps.calculatedAssertion) {
            this.setState({calculatedAssertion: nextProps.calculatedAssertion});
        }
        if (nextProps.provisionalPathogenicity) {
            this.setState({provisionalPathogenicity: nextProps.provisionalPathogenicity});
        }
        if (nextProps.provisionalReason) {
            this.setState({provisionalReason: nextProps.provisionalReason});
        }
        this.setState({
            provisionalInterpretation: nextProps.provisionalInterpretation
        });
    },

    // Method to set provisional checkbox state given the modified or calculated pathogenicity
    handleProvisionalCheckBox: function(pathogenicity) {
        if (!this.props.interpretation.disease) {
            let assertion = this.props.calculatedAssertion;
            if (assertion === 'Likely pathogenic' || assertion === 'Pathogenic') {
                if(pathogenicity === 'Benign' ||
                   pathogenicity === 'Likely benign' ||
                   pathogenicity === 'Uncertain significance') {
                    this.setState({disabledCheckbox: false});
                } else {
                    this.setState({disabledCheckbox: true});
                }
            } else {
                if(pathogenicity === 'Likely pathogenic' ||
                   pathogenicity === 'Pathogenic') {
                    this.setState({disabledCheckbox: true});
                } else {
                    this.setState({disabledCheckbox: false});
                }
            }
        } else {
            this.setState({disabledCheckbox: false});
        }
    },

    // Handle value changes in provisional form
    handleChange: function(ref, e) {
        // Handle modified pathogenicity dropdown
        if (ref === 'provisional-pathogenicity') {
            if (this.refs[ref].getValue()) {
                this.setState({provisionalPathogenicity: this.refs[ref].getValue()}, () => {
                    // Pass dropdown state change back to parent component
                    this.props.setProvisionalEvaluation('provisional-pathogenicity', this.state.provisionalPathogenicity);
                    // Disable save button if a reason is not provided for the modification
                    if (!this.state.provisionalReason) {
                        this.setState({disabledFormSumbit: true});
                    } else {
                        this.setState({disabledFormSumbit: false});
                    }
                    // If no disease is associated, we disable provisional checkbox
                    // when modified pathogenicity is either 'Likely pathogenic' or 'Pathogenic'
                    this.handleProvisionalCheckBox(this.state.provisionalPathogenicity);
                });
            } else {
                this.setState({provisionalPathogenicity: null}, () => {
                    // Pass null dropdown state change back to parent component
                    this.props.setProvisionalEvaluation('provisional-pathogenicity', this.state.provisionalPathogenicity);
                    // Disable save button if a reason is provided without the modification
                    if (this.state.provisionalReason) {
                        this.setState({disabledFormSumbit: true});
                    } else {
                        this.setState({disabledFormSumbit: false});
                    }
                    // If no disease is associated, we disable provisional checkbox
                    // when modified pathogenicity is either 'Likely pathogenic' or 'Pathogenic'
                    this.handleProvisionalCheckBox(this.state.provisionalPathogenicity);
                });
            }
        }
        // Handle reason/explanation for pathogenicity modification/change
        if (ref === 'provisional-reason') {
            if (this.refs[ref].getValue()) {
                this.setState({provisionalReason: this.refs[ref].getValue()}, () => {
                    // Pass textarea state change back to parent component
                    this.props.setProvisionalEvaluation('provisional-reason', this.state.provisionalReason);
                    // Disable save button if a modification is not provided for the reason
                    if (!this.state.provisionalPathogenicity) {
                        this.setState({disabledFormSumbit: true});
                    } else {
                        this.setState({disabledFormSumbit: false});
                    }
                });
            } else {
                this.setState({provisionalReason: null}, () => {
                    // Pass null textarea state change back to parent component
                    this.props.setProvisionalEvaluation('provisional-reason', this.state.provisionalReason);
                    // Disable save button if a modification is provided without the reason
                    if (this.state.provisionalPathogenicity) {
                        this.setState({disabledFormSumbit: true});
{'fraction_non_alphanumeric': 0.0921812708485884, 'fraction_numerical': 0.0, 'mean_word_length': 2.013483696984555, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '377585', 'n_tokens_mistral': 3023, 'n_tokens_neox': 2846, 'n_words': 628}