<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Laboratory Report</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 40px;
            line-height: 1.6;
        }
        .header {
            text-align: center;
            border-bottom: 2px solid #333;
            padding-bottom: 10px;
            margin-bottom: 20px;
        }
        .logo {
            text-align: center;
            margin-bottom: 15px;
            font-size: 24px;
            font-weight: bold;
        }
        .section {
            margin-bottom: 20px;
        }
        .section-title {
            font-weight: bold;
            margin-bottom: 5px;
            background-color: #f2f2f2;
            padding: 5px;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 20px;
        }
        table, th, td {
            border: 1px solid #ddd;
        }
        th, td {
            padding: 8px;
            text-align: left;
        }
        th {
            background-color: #f2f2f2;
        }
        .footer {
            text-align: center;
            font-size: 12px;
            margin-top: 40px;
            border-top: 1px solid #ddd;
            padding-top: 10px;
        }
        .flagged {
            color: red;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <div class="logo">HEALTHCARE LABORATORY SERVICES</div>
    
    <div class="header">
        <h2>LABORATORY TEST REPORT</h2>
    </div>
    
    <div class="section">
        <div class="section-title">REPORT INFORMATION</div>
        <p>
            <strong>Lab ID:</strong> {{ lab_id }}<br>
            <strong>Collection Date:</strong> {{ collection_date }}<br>
            <strong>Report Date:</strong> {{ report_date }}
        </p>
    </div>
    
    <div class="section">
        <div class="section-title">PATIENT INFORMATION</div>
        <p>
            <strong>Patient ID:</strong> {{ patient_id }}<br>
            <strong>Ordering Physician:</strong> {{ ordering_physician }}
        </p>
    </div>
    
    <div class="section">
        <div class="section-title">TEST RESULTS</div>
        <table>
            <tr>
                <th>Test</th>
                <th>Category</th>
                <th>Result</th>
                <th>Reference Range</th>
                <th>Units</th>
                <th>Interpretation</th>
            </tr>
            <tr>
                <td>{{ test_name }}</td>
                <td>{{ test_category }}</td>
                <td class="{% if is_flagged %}flagged{% endif %}">{{ result_value }}</td>
                <td>{{ reference_range }}</td>
                <td>{{ unit }}</td>
                <td>{{ interpretation }}</td>
            </tr>
        </table>
    </div>
    
    <div class="section">
        <div class="section-title">PERFORMING LABORATORY</div>
        <p>{{ performing_lab }}</p>
    </div>
    
    <div class="footer">
        <p>This report contains confidential medical information and is intended only for the named recipient.<br>
        Testing performed by {{ performing_lab }} in accordance with laboratory standards and regulatory requirements.</p>
    </div>
</body>
</html>
