<html>
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>Web Service Tester</title>  
		<script type="text/javascript" src="../../ClientGlobalContext.js.aspx"></script>
		<script type="text/javascript" src="../JScript/SDK.REST.js"></script>
		<script type="text/javascript" src="..\JScript\jquery.1.11.min.js"></script>
		<script type="text/javascript" src="..\WebServiceSecurityLib\js\WebServiceSecurityLibrary.js" ></script>
		<script type="text/javascript" src="..\WebServiceTester\js\WebServiceTester.js" ></script>
		<style type="text/css">
			#loadingGifDiv{
				background-color: rgba(255,255,255,.8);
				margin: -17px 0px 0px 0px;
				font-size: 15px;
				z-index: 1010;
				width: 100%;
				height: 100%;
				position: absolute;
				display: block;
				cursor: wait;
			}
			.autoWidth{
				width:100%;
			}
			#MVISearchContainer{
				display: block;
			}
			#retrievedSettingsContainer{
				display: block;
			}
			#testQueryBuilderContainer{
				display: block;
			}
			#testResultContainer{
				display: block;
			}
			#facilitySelectionDiv{
				display: none;
			}
			#retrievedSettingsTable {
				font-size:10px;
			}
			#retrievedSettingsTable input[type="text"]{
				font-size:10px;
			}
			
		</style>
	</head>
	<body onload="">
		<div id="loadingGifDiv" align="middle" align="center">
			<table height="100%" width="100%">
				<tr>
					<td align="middle" align="center">
						<img alt="" id="progressImg" src="/_imgs/AdvFind/progress.gif"/>
						<div/>
						<p id="progressText"></p>
					</td>
				</tr>
			</table>
		</div>
		
		<div>
			<h1>Web Service Tester</h1>
		</div>
		<div id="MVISearchContainer">
			<h2>MVI Search Criteria</h2>
			<table>
				<tr>
					<td>SSN <input id="mviSSN" type="text" placeholder="SSN" tabindex="1" size="9" maxlength="9" onkeyup="checkSubmitMVI(event)"></td>
					<td>First Name <input id="mviFirstName" type="text" placeholder="First Name" tabindex="2" onkeyup="checkSubmitMVI(event)"/></td>
					<td>Last Name <input id="mviLastName" type="text" placeholder="Last Name" tabindex="3" onkeyup="checkSubmitMVI(event)"></input></td>
					<td>DOB
						<input id="mviDOBMonth" type="text" placeholder="MM" size="2" maxlength="2" tabindex="4" onkeyup="checkSubmitMVI(event)"></input>
						<input id="mviDOBDate" type="text" placeholder="DD" size="2" maxlength="2" tabindex="5" onkeyup="checkSubmitMVI(event)"></input>
						<input id="mviDOBYear" type="text" placeholder="YYYY" size="4" maxlength="4" tabindex="6" onkeyup="checkSubmitMVI(event)"></input>
					</td>
				</tr>
				<tr>
					<td><button id="btn_searchMVI" onclick="searchMVI()">Search MVI</button></td>
				</tr>
			</table>
			<h2>MVI Search Results</h2>
			<table id="MVISearchResultsTable">
				<thead>
					<th></th>
					<th>Name</th>
					<th>DOB</th>
					<th>Stations</th>
				</thead>
			</table>
			
			<h2>Identifier Results</h2>
			<table>
				<tr><td>ICN</td><td><input id="ICN" type="text" onchange="icn_onChange();" placeholder="ICN"></input></td></tr>
				<tr><td>National ID</td><td><input id="nationalId" type="text" onchange="nationalId_onChange();" placeholder="National ID"></input></td></tr>
				<tr><td>EDIPI (from 200DOD)</td><td><input id="edipi" type="text" onchange="edipi_onChange();" placeholder="EDIPI"></input></td></tr>
				<tr>
					<td>Selected Facility Code (from MVI)</td><td><input id="selectedMVIFacilityCode" type="text" onchange="selectedMVIFacilityCode_onChange();"></input></td>
					<td>DFN at this facility</td><td><input id="selectedMVIFacilityCodeDFN" type="text" onchange="selectedMVIFacilityCodeDFN_onChange();"></input></td>
				</tr>
				<tr>
					<td>Preferred Facility Code (from ESR)</td><td><input id="preferredFacilityCodeFromESR" type="text" onchange="preferredFacilityCodeFromESR_onChange();"></input></td>
					<td>DFN at this facility</td><td><input id="preferredFacilityCodeFromESRDFN" type="text" onchange="preferredFacilityCodeFromESRDFN_onChange();"></input></td>
				</tr>
			</table>
		</div>
		<div id="retrievedSettingsContainer">
			<h2>Active Settings</h2>
			<button id="btn_refreshSettings" title="Refresh Active Settings from CRM" onclick="getActiveSettings()">Refresh Active Settings from CRM</button>
			<table id="retrievedSettingsTable" border="1"></table>
		</div>
		<div id="testQueryBuilderContainer">
			<h2>URL builder</h2>
			<h3 id="queryBuilderCurrentSettingLabel"></h3>
			<div id="facilitySelectionDiv">
				<input id="useMVISelectedFacility" name="facilitySelection" type="radio" value="mvi" checked onchange="setupQueryBuilder()"/><label for="useMVISelectedFacility">Use veteran facility from MVI</label><br/>
				<input id="useESRPreferredFacility" name="facilitySelection" type="radio" value="esr" onchange="setupQueryBuilder()"/><label for="useESRPreferredFacility">Use veteran preferred facility from ESR (if present)</label><br/>
			</div>
			<br/>
			<div id="userFacilityInfo">
				<h3>User Facility Info</h3>
				<button id="btn_impersonateLoriNicholls" onclick="setupImpersonation()">Impersonate Lori Nicholls</button>
				<button id="btn_useCRMUser" onclick="getUserFromCRM()">Use CRM user details</button><br/>
				User First Name <input id="userFirstName" type="text" placeholder="from CRM or manual" onchange="userFirstName_onChange()"></input>
				User Last Name <input id="userLastName" type="text" placeholder="from CRM or manual" onchange="userLastName_onChange()"></input>
				User facility code <input id="userFacilityCode" type="text" placeholder="from CRM or manual" onchange="userFacilityCode_onChange()"></input><br/>
				<button id="btn_getVistaUsers" onclick="retrieveVistaUsers()">Get IEN for User</button>
				<br/>
				<div title="" class="ms-crm-RefreshDialog-Footer" id="vistaUsersListFormContainer"></div>
				<br/>
				<div id="userIENDiv">
					User IEN for the above facility code <input id="userIEN" type="text" placeholder="IEN from VistA" onchange="userIEN_onChange()"></input>
				</div>
			</div>
			<br/>
			<button id="btn_testGo" onclick="beginTest()">Test!</button><br/>
			<input class="autoWidth" id="urlToTest" type="text" value="" onkeyup="checkSubmitTest(event)"></input>
		</div>
		<div id="testResultContainer">
			<h2>Test results</h2>
			<button id="btn_testReset" onclick="resetTestResultContainer()">Reset Test Area</button><br/>
			<iframe title="IFrame placeholder" class="autoWidth" style="height:600px;" id="displayframe"></iframe>
		</div>
	</body>
</html>