<commit_before><%@include file="/WEB-INF/views/taglibs.jsp"%>

<html>
<head>
    <title>${tab.longTitle}</title>
    <tags:dwrJavascriptLink objects="createAE,routingAndReview"/>
	<tags:slider renderComments="${command.associatedToWorkflow }" renderAlerts="${command.associatedToLabAlerts}" reports="${command.selectedReportsAssociatedToWorkflow}" 
		display="${(command.associatedToWorkflow or command.associatedToLabAlerts) ? '' : 'none'}" workflowType="report">
    	<jsp:attribute name="labs">
    		<div id="labs-id" style="display:none;">
    			<tags:labs labs="${command.assignment.labLoads}"/>
    		</div>
    	</jsp:attribute>
    </tags:slider>
    
    
    <script type="text/javascript">
    	var routingHelper = new RoutingAndReviewHelper(createAE, 'aeReport');
    
        var NAME_FIELDS = [
            'firstName', 'middleName', 'lastName','title', 'address.street', 'address.city', 'address.state', 'address.zip'
        ]
        var PERSON_FIELDS = NAME_FIELDS.concat([
            'contactMechanisms[e-mail]', 'contactMechanisms[phone]', 'contactMechanisms[fax]'
        ])

        function chooseStaff() {
            var id = document.getElementById("staff").value;
            if (id == '') {
                clear('reporter');

            } else {
                if (document.getElementById("reporter_site_research_staff_" + id) != null) {
                    var siteResearchStaffId = document.getElementById("reporter_site_research_staff_" + id).value;
                    createAE.getSiteResearchStaff(siteResearchStaffId, updateReporterFromStaff)
                } else if (document.getElementById("reporter_site_investigator_" + id) != null) {
                    var siteInvestigatorId = document.getElementById("reporter_site_investigator_" + id).value;
                    createAE.getSiteInvestigator(siteInvestigatorId, updateReporterFromStaff)
                }
            }
        }

        function choosePhysician(){
			var id = document.getElementById("physician").value;
			if (id == '') {
                clear('physician');
               
            } else {
                var siteInvestigatorId=document.getElementById("physician_site_investigator_"+id).value;
                createAE.getSiteInvestigator(siteInvestigatorId, updatePhysicianFromInvestigator)
            }
        }
		/* IE7 fix:- null text is displayed when staff[field] is empty or null*/
        function updateReporterFromStaff(staff) {
			updateUserData('aeReport.reporter', staff);			
        }
        
        function updatePhysicianFromInvestigator(investigator) {
            updateUserData('aeReport.physician', investigator);
        }

        function updateUserData(prefix, user) {
            NAME_FIELDS.each(function(field) {
            	if(user[field] != null) {
                    updateFieldValue(prefix + '.' + field, user[field]);
                }
            })
            
            if(user['emailAddress'] != null) {
                updateFieldValue(prefix + '.' + 'contactMechanisms[e-mail]',user['emailAddress']);
            }else{
            	updateFieldValue(prefix + '.' + 'contactMechanisms[e-mail]', '');
            }

            if(user['phoneNumber'] != null) {
                updateFieldValue(prefix + '.' + 'contactMechanisms[phone]',user['phoneNumber']);
            }else{
            	updateFieldValue(prefix + '.' + 'contactMechanisms[phone]', '');
            }

            if(user['faxNumber'] != null) {
                updateFieldValue(prefix + '.' + 'contactMechanisms[fax]',user['faxNumber']);
            }else{
            	updateFieldValue(prefix + '.' + 'contactMechanisms[fax]', '');
            }
            
            if(user['address'] != null){
            	updateFieldValue(prefix + '.' + 'address.street', user['address'].street);
            	updateFieldValue(prefix + '.' + 'address.city', user['address'].city);
            	updateFieldValue(prefix + '.' + 'address.state', user['address'].state);
            	updateFieldValue(prefix + '.' + 'address.zip', user['address'].zip);
            }else{
            	updateFieldValue(prefix + '.' + 'address.street', '');
            	updateFieldValue(prefix + '.' + 'address.city', '');
            	updateFieldValue(prefix + '.' + 'address.state', '');
            	updateFieldValue(prefix + '.' + 'address.zip', '');
            }
        }

        function clear(person) {
            PERSON_FIELDS.each(function (field) {
            	updateFieldValue('aeReport.' + person + '.' + field, '');
                ValidationManager.doFieldValidation($('aeReport.' + person + '.' + field));
            })
        }



        function updateFieldValue(uiField, value){
			var f = $(uiField);
			if (f){
				f.value = value;
			}
            ValidationManager.doFieldValidation(f);
        }

        Event.observe(window, "load", function() {
            $('staff').observe("change", chooseStaff)
            $('physician').observe("change", choosePhysician)
            <commit_msg>CAAERS-5999: Null values are fixed in Report Address.<commit_after><%@include file="/WEB-INF/views/taglibs.jsp"%>

<html>
<head>
    <title>${tab.longTitle}</title>
    <tags:dwrJavascriptLink objects="createAE,routingAndReview"/>
	<tags:slider renderComments="${command.associatedToWorkflow }" renderAlerts="${command.associatedToLabAlerts}" reports="${command.selectedReportsAssociatedToWorkflow}" 
		display="${(command.associatedToWorkflow or command.associatedToLabAlerts) ? '' : 'none'}" workflowType="report">
    	<jsp:attribute name="labs">
    		<div id="labs-id" style="display:none;">
    			<tags:labs labs="${command.assignment.labLoads}"/>
    		</div>
    	</jsp:attribute>
    </tags:slider>
    
    
    <script type="text/javascript">
    	var routingHelper = new RoutingAndReviewHelper(createAE, 'aeReport');
    
        var NAME_FIELDS = [
            'firstName', 'middleName', 'lastName','title', 'address.street', 'address.city', 'address.state', 'address.zip'
        ]
        var PERSON_FIELDS = NAME_FIELDS.concat([
            'contactMechanisms[e-mail]', 'contactMechanisms[phone]', 'contactMechanisms[fax]'
        ])

        function chooseStaff() {
            var id = document.getElementById("staff").value;
            if (id == '') {
                clear('reporter');

            } else {
                if (document.getElementById("reporter_site_research_staff_" + id) != null) {
                    var siteResearchStaffId = document.getElementById("reporter_site_research_staff_" + id).value;
                    createAE.getSiteResearchStaff(siteResearchStaffId, updateReporterFromStaff)
                } else if (document.getElementById("reporter_site_investigator_" + id) != null) {
                    var siteInvestigatorId = document.getElementById("reporter_site_investigator_" + id).value;
                    createAE.getSiteInvestigator(siteInvestigatorId, updateReporterFromStaff)
                }
            }
        }

        function choosePhysician(){
			var id = document.getElementById("physician").value;
			if (id == '') {
                clear('physician');
               
            } else {
                var siteInvestigatorId=document.getElementById("physician_site_investigator_"+id).value;
                createAE.getSiteInvestigator(siteInvestigatorId, updatePhysicianFromInvestigator)
            }
        }
		/* IE7 fix:- null text is displayed when staff[field] is empty or null*/
        function updateReporterFromStaff(staff) {
			updateUserData('aeReport.reporter', staff);			
        }
        
        function updatePhysicianFromInvestigator(investigator) {
            updateUserData('aeReport.physician', investigator);
        }

        function updateUserData(prefix, user) {
            NAME_FIELDS.each(function(field) {
            	if(user[field] != null) {
                    updateFieldValue(prefix + '.' + field, user[field]);
                }
            })
            
            if(user['emailAddress'] != null) {
                updateFieldValue(prefix + '.' + 'contactMechanisms[e-mail]',user['emailAddress']);
            }else{
            	updateFieldValue(prefix + '.' + 'contactMechanisms[e-mail]', '');
            }

            if(user['phoneNumber'] != null) {
                updateFieldValue(prefix + '.' + 'contactMechanisms[phone]',user['phoneNumber']);
            }else{
            	updateFieldValue(prefix + '.' + 'contactMechanisms[phone]', '');
            }

            if(user['faxNumber'] != null) {
                updateFieldValue(prefix + '.' + 'contactMechanisms[fax]',user['faxNumber']);
            }else{
            	updateFieldValue(prefix + '.' + 'contactMechanisms[fax]', '');
            }
            
            if(user['address'] != null){
            	if ( user['address'].street != null ) {
            		updateFieldValue(prefix + '.' + 'address.street', user['address'].street);
            	}
            	if (user['address'].city  != null ) {
            		updateFieldValue(prefix + '.' + 'address.city', user['address'].city);
            	}
            	if ( user['address'].state != null ) {
            		updateFieldValue(prefix + '.' + 'address.state', user['address'].state);
            	}
            	if ( user['address'].zip != null ) {
            		updateFieldValue(prefix + '.' + 'address.zip', user['address'].zip);
            	}
            }else{
            	updateFieldValue(prefix + '.' + 'address.street', '');
            	updateFieldValue(prefix + '.' + 'address.city', '');
            	updateFieldValue(prefix + '.' + 'address.state', '');
            	updateFieldValue(prefix + '.' + 'address.zip', '');
            }
        }

        function clear(person) {
            PERSON_FIELDS.each(function (field) {
            	updateFieldValue('aeReport.' + person + '.' + field, '');
                ValidationManager.doFieldValidation($('aeReport.' + person + '.' + field));
            })
        }



        function updateFieldValue(uiField, value){
			var f = $(uiField);
			if (f){
				f.value = value;
			}
            ValidationManager.doFieldValidation(f);
        }

        Event.observe(window, "load", function() {
            $('staff').observe("change", chooseStaff)
            $('physician').observe("change", choosePhysician)
            
{'fraction_non_alphanumeric': 0.14452371770150405, 'fraction_numerical': 0.0005784805244890089, 'mean_word_length': 2.2234307022995647, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, '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': '2369654', 'n_tokens_mistral': 3034, 'n_tokens_neox': 2816, 'n_words': 403}