<commit_before><%@ include file="/WEB-INF/template/include.jsp" %>
<%--
Parameters:
	showDecoration (boolean): whether or not to put this in a box
	showLastThreeEncounters (boolean): whether or not to show a snippet of encounters
	returnUrl (String): where to go back to when a form has been cancelled or successfully filled out
--%>

<openmrs:htmlInclude file="/scripts/jquery/jquery-1.3.2.min.js" />
<openmrs:htmlInclude file="/scripts/jquery/dataTables/css/dataTables.css" />
<openmrs:htmlInclude file="/scripts/jquery/dataTables/js/jquery.dataTables.min.js" />

<%-- hack because calling a portlet clears parameters --%>
<c:set var="showDecorationProp" value="${model.showDecoration}" />

<c:if test="${model.showLastThreeEncounters}">
	<openmrs:hasPrivilege privilege="View Encounters">
		<openmrs:portlet url="patientEncounters" id="patientDashboardEncounters" patientId="${patient.patientId}" parameters="num=3|hideHeader=true|title=Encounter.last.encounters|hideFormEntry=true" />
		<br/>
	</openmrs:hasPrivilege>
</c:if>

<c:if test="${showDecorationProp}">
	<div class="boxHeader${model.patientVariation}"><spring:message code="FormEntry.fillOutForm"/></div>
	<div class="box${model.patientVariation}">
</c:if>

<c:if test="${!model.anyUpdatedFormEntryModules}">
	<span class="error"><spring:message code="FormEntry.noModulesInstalled"/></span>
	<br/><br/>
</c:if>

<c:if test="${model.anyUpdatedFormEntryModules}">
	
	<%--
		goBackOnEntry == 'true' means have the browser go back to the find patient page after starting to enter a form
	--%>
	<openmrs:globalProperty key="FormEntry.patientForms.goBackOnEntry" var="goBackOnEntry" defaultValue="false"/>
	
	<script type="text/javascript">
		var $j = jQuery.noConflict();
		$j(document).ready(function() {
			/* the parent selector here only only allows one datatable call per formEntryTable.
			   without that selector, the .dialog() call for the popup was calling this twice */
			$j("#formEntryTableParent${model.id} > #formEntryTable${model.id}").dataTable({
				"bPaginate": false,
				"bSort": false,
				"bAutoWidth": false
			});
		});
		function startDownloading() {
			<c:if test="${goBackOnEntry}">
				timeOut = setTimeout("goBackToPatientSearch()", 30000);
			</c:if>
		}
		
		function goBackToPatientSearch() {
			document.location='findPatient.htm';
		}
	</script>
	<div id="formEntryTableParent${model.id}">
	<table id="formEntryTable${model.id}">
		<thead>
			<tr>
				<th><spring:message code="general.name"/></th>
				<th><spring:message code="Form.version"/></th>
			</tr>
		</thead>
		<tbody>
			<c:forEach var="entry" items="${model.formToEntryUrlMap}">
				<openmrs:hasPrivilege privilege="${entry.value.requiredPrivilege}">
					<c:url var="formUrl" value="${entry.value.formEntryUrl}">
						<c:param name="personId" value="${model.personId}"/>
						<c:param name="patientId" value="${model.patientId}"/>
						<c:param name="returnUrl" value="${model.returnUrl}"/>
						<c:param name="formId" value="${entry.key.formId}"/>
					</c:url>
					<tr>
						<td>
							<a href="${formUrl}" onclick="startDownloading();">${entry.key.name}</a>
						</td>
						<td>
							${entry.key.version}
							<c:if test="${!entry.key.published}"><i>(<spring:message code="Form.unpublished"/>)</i></c:if><commit_msg>Added ability to sort on encounter type in form entry list - #1171 Author: Knoll_Frank<commit_after><%@ include file="/WEB-INF/template/include.jsp" %>
<%--
Parameters:
	showDecoration (boolean): whether or not to put this in a box
	showLastThreeEncounters (boolean): whether or not to show a snippet of encounters
	returnUrl (String): where to go back to when a form has been cancelled or successfully filled out
--%>

<style type="text/css">
	.EncounterTypeClass {
		color: lightgrey;
	}
</style>
		
<openmrs:htmlInclude file="/scripts/jquery/jquery-1.3.2.min.js" />
<openmrs:htmlInclude file="/scripts/jquery/dataTables/css/dataTables.css" />
<openmrs:htmlInclude file="/scripts/jquery/dataTables/js/jquery.dataTables.min.js" />

<%-- hack because calling a portlet clears parameters --%>
<c:set var="showDecorationProp" value="${model.showDecoration}" />

<c:if test="${model.showLastThreeEncounters}">
	<openmrs:hasPrivilege privilege="View Encounters">
		<openmrs:portlet url="patientEncounters" id="patientDashboardEncounters" patientId="${patient.patientId}" parameters="num=3|hideHeader=true|title=Encounter.last.encounters|hideFormEntry=true" />
		<br/>
	</openmrs:hasPrivilege>
</c:if>

<c:if test="${showDecorationProp}">
	<div class="boxHeader${model.patientVariation}"><spring:message code="FormEntry.fillOutForm"/></div>
	<div class="box${model.patientVariation}">
</c:if>

<c:if test="${!model.anyUpdatedFormEntryModules}">
	<span class="error"><spring:message code="FormEntry.noModulesInstalled"/></span>
	<br/><br/>
</c:if>

<c:if test="${model.anyUpdatedFormEntryModules}">
	
	<%--
		goBackOnEntry == 'true' means have the browser go back to the find patient page after starting to enter a form
	--%>
	<openmrs:globalProperty key="FormEntry.patientForms.goBackOnEntry" var="goBackOnEntry" defaultValue="false"/>
	
	<script type="text/javascript">
		var $j = jQuery.noConflict();
		$j(document).ready(function() {
			/* the parent selector here only only allows one datatable call per formEntryTable.
			   without that selector, the .dialog() call for the popup was calling this twice */
			$j("#formEntryTableParent${model.id} > #formEntryTable${model.id}").dataTable({
				"bPaginate": false,
				"bAutoWidth": false,
				"aaSorting": [[0, 'asc']],
				"aoColumns":
					[
						{ "iDataSort": 1 },
						{ "bVisible": false, "sType": "numeric" },
						null,
						{ "sClass": "EncounterTypeClass" }
					]
			});
		});
		function startDownloading() {
			<c:if test="${goBackOnEntry}">
				timeOut = setTimeout("goBackToPatientSearch()", 30000);
			</c:if>
		}
		
		function goBackToPatientSearch() {
			document.location='findPatient.htm';
		}
	</script>
	<div id="formEntryTableParent${model.id}">
	<table id="formEntryTable${model.id}" cellspacing="0" cellpadding="3">
		<thead>
			<tr>
				<th><spring:message code="general.name"/></th>
				<th><!-- Hidden column for sorting previous column --></th>
				<th><spring:message code="Form.version"/></th>
				<th class="EncounterTypeClass"><spring:message code="Encounter.type"/></th>
			</tr>
		</thead>
		<tbody>
			<c:forEach var="entry" items="${model.formToEntryUrlMap}" varStatus="rowCounter">
				<openmrs:hasPrivilege privilege="${entry.value.requiredPrivilege}">
					<c:url var="formUrl" value="${entry.value.formEntryUrl}">
						<c:param name="personId" value="${model.personId}"/>
						<c:param name="patientId" value="${model.patientId}"/>
						<c:param name="returnUrl" value="${model.returnUrl}"/>
						<c:param name="formId" value="${entry.key.formId}"/>
					</c:url>
					<tr>
						<td>
							<a href="${formUrl}" onclick="startDownloading();">${entry.key.name}</a>
						</td>
						<td>
							${rowCounter.count}
						</td>
						<td>
							${entry.key.version}
							<c:if test="${!entry.key.published}"><i>(<spring:message code="Form.unpublished"/>)</i></c:if>
						</td>
						<td>
							${entry.key.encounterType.name}
{'fraction_non_alphanumeric': 0.18110018013024803, 'fraction_numerical': 0.003602604960509907, 'mean_word_length': 4.714964370546318, 'pattern_counts': {'":': 11, '<': 145, '<?xml version=': 0, '>': 147, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3861786', 'n_tokens_mistral': 2735, 'n_tokens_neox': 2386, 'n_words': 465}