    [% META title="Request Error" %]
<!-- BEGIN [% template.name %]  -->
    [% # PROCESS dumper.tt dump = data %]
    [% # PROCESS dumper.tt dump = codes_in_use %]

    [% request_error_dfv_js %]

    [% INCLUDE record/patient_summary.tt %]

    <h3 class="header">Request Errors</h3>

    [% IF dfv_errors %]
    <dl>
        <dt class="error">[% c.cfg('msg').dfv_errors %]</dt>
        [% IF error_error_group %]
            <dd>Error or LIC [% error_error_group %]</dd>[% END %]
    </dl>
    [% END %]

	[% IF data.size %]
        <table class="indent">
            <tr>
                <th>Day</th>
                <th>Date</th>
                <th>Time</th>
                <th>UserID</th>
                <th>Code</th>
                <th>Description</th>
                <th>Details</th>
                <td class="borderless"></td>
            </tr>
            [% FOREACH entry IN data; # PROCESS dumper.tt dump = entry.as_tree %]
            <tr>
                <td>[% entry.time.strftime('%a') %]</td>
                <td>[% entry.time.strftime('%d.%b.%Y') %]</td>
                <td>[% entry.time.strftime('%T') %]</td>
				<td>[% entry.user.username | upper %]</td>
                <td align="center">
                    [% entry.error_code.code | upper %]
                </td>
                <td>[% entry.error_code.description | html %]</td>
                <td>[% entry.error_detail.details | html %]</td>
                <td>
                    <a href=[% app_url %]/error/edit/[% request.id %]/[% entry.id %]>
                        Edit
                    </a>
                </td>
            </tr>
            [% END %]
        </table>

		<p class="title">New:</p>
    [% END %]

    <form action="[% app_url %]/error/update/[% request.id %]" method="post"
        [% request_error_onsubmit %] name="error" id="error">

	<table class="indent">
        <tr>
            <th scope="col">Error</th>
            <th scope="col">LIC</th>
        </tr>
        <tr>
            <td>
                <select name="error_code_id">
                    <option value=""></option>
                [%
                    FOREACH item IN error_codes; # skip any unique codes in use:
                    NEXT IF codes_in_use.item(item.error_code_id)
                        AND item.error_code.is_unique.match('yes');
                %]
                    <option value="[% item.error_code_id %]">
                        [[% item.error_code.code | upper %]]
						[% item.error_code.description | html %]
                    </option>
                 [% END %]
                </select>
            </td>
            <td>
                <input type="checkbox" name="LIC" value="1" />
            </td>
        </tr>
        <tr>
            <th colspan="2">Details (optional)</th>
        </tr>
        <tr>
            <td colspan="2">
                <textarea name="error_details" rows="3" cols="60"
                    style="vertical-align: top" class="expand20-200">[%
                    error_details # DO NOT WRAP THIS %]</textarea>
            </td>
        </tr>
        <tr>
            <td colspan="3" class="borderless" align="center">
                [% site.html.submit %]
                [% site.html.reset %]
            </td>
        </tr>
    </table>
    </form>
<!-- END [% template.name %]  -->
