<html><head>
<meta charset="utf-8"></head>
<body>

	
    <!--script src="bah_json2.js" type="text/javascript"></script-->
	
    
	<link href="css/esrpartstyle.css" rel="stylesheet" type="text/css">
	<script src="../../ClientGlobalContext.js.aspx" type="text/javascript"></script>
	<!--script src="../../bah_jquery1.4.1.min.js" type="text/javascript"></script-->
	<script src="../../bah_jquery_3_2_1.js" type="text/javascript"></script>
<script src="../../bah_json2.js" type="text/javascript"></script>
	<script src="../../bah_SDK.REST.js" type="text/javascript"></script>
	<script src="../../bah_via_library.js" type="text/javascript"></script>
	<script src="../../bah_VeteranAlerts.js" type="text/javascript"></script>
	<script src="../../bah_bootstrap.js" type="text/javascript"></script>
	<script src="../../XrmPage-vsdoc.js"></script>
    <script src="../../XrmPageTemplate.js"></script>
	
	<script>
	    var _esrObj = null;

	    function buildQueryFilter(field, value, and) {
	        if (value == '') {
	            if (and) {
	                return " and " + field + " eq null";
	            } else {
	                return field + " eq null";
	            }
	        }
	        else {
	            if (and) {
	                return " and " + field + " eq '" + value + "'";
	            } else {
	                return field + " eq '" + value + "'";
	            }
	        }
	    }

	    function getParameterByName(name, url) {
	        if (!url) url = window.location.href;
	        name = name.replace(/[\[\]]/g, "\\$&");
	        var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
                results = regex.exec(url);
	        if (!results) return null;
	        if (!results[2]) return '';
	        return decodeURIComponent(results[2].replace(/\+/g, " "));
	    }

	    function doPageLoad() {
	        var esrEndpoint = "";
	        var datavalue = getParameterByName('data');
	        if (datavalue != null) {
	            var params = decodeURIComponent(datavalue).split("&");
	            for (var i in params) {
	                params[i] = params[i].replace(/\+/g, " ").split("=");
	                if (params[i][0] == "esr") {
	                    esrEndpoint = params[i][1];
	                }
	            }
	        }
	        if (esrEndpoint != "") {
	            $.ajax({
	                url: esrEndpoint,
	                dataType: 'json',
	                timeout: 4000,
	                error: function (error) {
	                    _esrObj = null;
						writeToConsole(error);
	                    outputData();
	                },
	                success: function (result) {
	                    _esrObj = result;
	                    outputData();
	                }
	            });
	        }
	    }

	    function outputData() {
	        //reset display fields
	        $("#MaritalStatus").text("--");
	        $("#DataSource").text("--");
	        $("#DeathDate").text("--");
	        $("#DeathReportDate").text("--");
	        $("#FacilityReceived").text("--");

	        //set display fields
	        if (_esrObj != null) {
	            if (!_esrObj.ErrorOccurred) {
	                if ("Demographics" in _esrObj.Data) {
	                    if (_esrObj.Data.Demographics != null) {
	                        if (_esrObj.Data.Demographics.MaritalStatus != null) { $("#MaritalStatus").text(_esrObj.Data.Demographics.MaritalStatus); }
	                    }
	                }

				<!-- if(_esrObj.Data.SensitivityInfo.SensityFlag !=null) { -->
                    <!-- var sensitivityFlag = _esrObj.Data.SensitivityInfo.SensityFlag; -->
					<!-- _isSensitive = (sensitivityFlag.toLowerCase() == "true"); -->
                <!-- } -->
				
	                <!-- if (_esrObj.Data.DeathRecond != null) { -->

	                    <!-- if (_esrObj.Data.DeathRecond.DataSource != null) { -->
	                        <!-- $("#DataSource").text(_esrObj.Data.DeathRecond.DataSource); -->
	                        <!-- // Date of Death -->
	                        <!-- var formattedDeathDate = _esrObj.Data.DeathRecond.DeathDate.substr(4, 2) + "/" + _esrObj.Data.DeathRecond.DeathDate.substr(6, 2) + "/" + _esrObj.Data.DeathRecond.DeathDate.substr(0, 4); -->
	                        <!-- $("#DeathDate").text(formattedDeathDate); -->
	                        <!-- _deathDate=_esrObj.Data.DeathRecond.DeathDate; -->
	                        <!-- // Death Report Date -->
	                        <!-- var formattedDeathReportDate = _esrObj.Data.DeathRecond.DeathReportDate.substr(5, 2) + "/" + _esrObj.Data.DeathRecond.DeathReportDate.substr(8, 2) + "/" + _esrObj.Data.DeathRecond.DeathReportDate.substr(0, 4); -->
	                        <!-- $("#DeathReportDate").text(formattedDeathReportDate); -->
	                        
	                        <!-- $("#FacilityReceived").text(_esrObj.Data.DeathRecond.FacilityReceived); -->
							<!-- // IsDeceased flag - required for sensitive vet check: -->
							<!-- var deathInfoNode = _esrObj.Data.DeathRecond; //the DeathRecond node contains data such as DeathDate, DataSource, FacilityReceived, DeathDate -->
							<!-- _isDeceased = deathInfoNode.DeathDate !=null || deathInfoNode.DataSource!=null || deathInfoNode.DeathDate!=null || deathInfoNode.FacilityReceived!=null; -->
							

	                    <!-- } -->
	                <!-- } -->
	            <!-- } -->
				//alert("doing sensitive vet check"); 
				//doSensitiveVetCheck(); // added 5/19/17 CMcK
	        } 
			else {
				// cannot do sensitive vet check - write to console
				writeToConsole("no ESR, unable to do sensitive vet check"); 
			}
	    }
		<!-- function doSensitiveVetCheck() { -->
			<!-- var doc = window.parent.Xrm.Page;  -->
			 <!-- var fname = doc.getAttribute('firstname').getValue()  -->
			 <!-- var lname = doc.getAttribute('lastname').getValue();  -->
			<!-- __MVI_FullName = fname + ' ' + lname;  -->
			<!-- _contactId = doc.data.entity.getId(); // ('contactid');  -->
			<!-- //alert(_contactid) ; -->
			<!-- /// Sensitive Vet Interruption -- if user elects to not see this vet, we need to redirect back to referring page -->
			<!-- var sensitiveVetCheck = handleSensitiveVet(_isDeceased, _isSensitive, _deathDate, null, null); // this is VeteranAlerts.js (last 2 params not required at this time) CMcK 5/19/17 -->
			<!-- //alert("sensitive vet check results: " + sensitiveVetCheck + " - " + __MVI_FullName); -->

			<!-- if (!sensitiveVetCheck){ -->
				<!-- // consider adding an informational message here -->
				<!-- window.history.back(); -->
			<!-- } -->
			<!-- /// end sensitive Vet check -->

		}

	    $(function () {
	        doPageLoad();

	    });
</script>

<div class="panel panel-primary" id="container">
    <div class="panel-heading">Demographics</div>
    <div class="panel-body">
	    <div class="column-left">
	      <div class="row-div"><span class="attribute-label">Marital Status:</span> <span class="attribute-value" id="MaritalStatus">--</span></div>
	      <div class="row-div"><span class="attribute-label">Date of Death:</span> <span class="attribute-value" id="DeathDate">--</span></div>
	      <div class="row-div"><span class="attribute-label">Death Notification Source:</span> <span class="attribute-value" id="DataSource">--</span></div>
	      <div class="row-div"><span class="attribute-label">Death Notification Site:</span> <span class="attribute-value" id="FacilityReceived">--</span></div>
	      <div class="row-div"><span class="attribute-label">Death Report Date:</span> <span class="attribute-value" id="DeathReportDate">--</span></div>
	    </div>
    </div>
</div>
</body></html>