{# home.html #}
{% extends "base.html" %}

{% block content %}

    <div>
        <h1>Main menu</h1>

        {% if safety_catch_on and user.is_superuser %}
            <div class="warning">Safety catch on: routing e-mails to
                {{ developer_email }}</div>
        {%  endif %}

        <h2>Research database</h2>
        <ul>
            <li><b>Main query functions:</b>
                {% include "query_nav.html" %}</li>

            <li>
                <b>SQL helpers:</b>
                <ul>
                    <li><a href="{% url 'sqlhelper_text_anywhere' %}">Find
                    string in any text field</a></li>
                </ul>
            </li>

            <li>
                View research database structure:
                <ul>
                    <li><a href="{% url 'structure_table_paginated' %}">online
                    in paginated tabular format</a></li>

                    <li><a href="{% url 'structure_table_long' %}">online
                    in single-page tabular format</a>
                    (WARNING: slow)</li>

                    <li><a href="{% url 'structure_tree' %}">online
                    in collapsible tree form</a> (WARNING: slow)</li>

                    {% comment %}
                    <li><a href="{% url 'structure_tsv' %}">download in
                    tab-separated values (TSV) format</a></li>
                    {% endcomment %}

                    <li><a href="{% url 'structure_excel' %}">download in
                    Excel (.XLSX) format</a></li>
                </ul>
            </li>

            <li><a href="{%  url 'structure_help' %}">Help on
            local database structure</a></li>
        </ul>

        <h2>Contacting patients</h2>
        <ul>
            <li>
                <a href="{% url 'resadmin:index' %}">Researcher administration</a>:
                <ul>
                    <li>View your studies</li>
                    <li>View contact requests for your studies</li>
                    <li>View letters/e-mails to researchers for your studies</li>
                    <li>View master leaflets</li>
                </ul>
            </li>
            <li><a href="{% url 'submit_contact_request' %}">Submit a contact request</a></li>
        </ul>

        {%  if is_clinician %}
        <h2>Privileged operations for clinicians</h2>
        <ul>
            <li><a href="{% url 'all_text_from_pid' %}">Search all text for an identified patient</a></li>
        </ul>
        {% endif %}

        {% comment %}
            <h2>Leaflets</h2>
            <ul>
                {% for leaflet in leaflets %}
                    <li><a href="{% url 'leaflet' leaflet.key %}">{{ leaflet.name }}</a></li>
                {% endfor %}
            </ul>
        {% endcomment %}

        {% if user.is_superuser %}
            <h2>Administrative functions for Research Database manager</h2>
            <ul>
                <li><a href="{% url 'mgradmin:index' %}"><b>RDBM
                administration</b></a>: user management, query audits,
                and consent-to-contact admin functions</li>

                <li><a href="{% url 'pidlookup' %}">Look up patient ID (PID) from
                research ID (RID)</a></li>

                <li><a href="{% url 'charity_report' %}">Charity payment
                report</a></li>

                <li><a href="{% url 'exclusion_report' %}">Report patients to
                be excluded entirely from anonymised database</a></li>

                <li><a href="{% url 'test_email_rdbm' %}">Test message queue
                by sending an e-mail to the RDBM</a></li>
            </ul>
        {% endif %}

        {% if is_developer %}
            <h2>Extra functions for developers</h2>
            <ul>
                <li><a href="{% url 'devadmin:index' %}"><b>Developer
                admin</b></a>: more detailed inspection of database
                objects</li>

                <li><a href="{% url 'generate_fake_nhs' %}">Generate fake NHS
                numbers for testing</a></li>

                <li><a href="{% url 'test_patient_lookup' %}">Test patient
                lookup without saving data</a></li>

                <li>Test templates.



                    <ul>
                        <li>You can use URL query parameters like
                            <b>?age=40;age_months=2;consent_mode=yellow;request_direct_approach=1;consent_after_discharge=0</b>.
                            For consent_mode, use 'red', 'yellow', 'green', or
                            anything else for None.
                            The flag consent_after_discharge is now irrelevant.</li>

                        <li><a href="{% url 'draft_traffic_light_decision_form' -1 'pdf' %}">
                            Traffic-light decision form (PDF)</a></li>

                        <li><a href="{% url 'draft_traffic_light_decision_form' -1 'html' %}">
                            Traffic-light decision form (HTML)</a></li>

                        <li><a href="{% url 'draft_clinician_email' -1 %}">
                            E-mail to clinician</a></li>

                        <li><a href="{% url 'draft_letter_clinician_to_pt_re_study' -1 'html' %}">
                            Letter from clinician to patient re study (HTML)</a></li>

                        <li><a href="{% url 'draft_letter_clinician_to_pt_re_study' -1 'pdf' %}">
                            Letter from clinician to patient re study (PDF)</a></li>

                        <li><a href="{% url 'decision_form_to_pt_re_study' -1 'html' %}">
                            Decision form to patient re study (HTML)</a></li>

                        <li><a href="{% url 'decision_form_to_pt_re_study' -1 'pdf' %}">
                            Decision form to patient re study (PDF)</a></li>

                        <li><a href="{% url 'draft_approval_letter' -1 'html' %}">
                            Approval letter to researcher (HTML)</a></li>

                        <li><a href="{% url 'draft_approval_letter' -1 'pdf' %}">
                            Approval letter to researcher (PDF)</a></li>

                        <li><a href="{% url 'draft_approval_email' -1 %}">
                            Approval covering e-mail to researcher</a></li>

                        <li><a href="{% url 'draft_withdrawal_letter' -1 'html' %}">
                            Withdrawal letter to researcher (HTML)</a></li>

                        <li><a href="{% url 'draft_withdrawal_letter' -1 'pdf' %}">
                            Withdrawal letter to researcher (PDF)</a></li>

                        <li><a href="{% url 'draft_withdrawal_email' -1 %}">
                            Withdrawal covering e-mail to researcher</a></li>

                    </ul>
                </li>
            </ul>
        {% endif %}

        <h2>Your settings</h2>
        <ul>
            <li><a href="{% url 'edit_profile' %}">Change your settings</a></li>

            <li><a href="{% url 'password_change' %}">Change password</a></li>
        </ul>

        <h2>About</h2>
        <ul>
            <li><a href="{% url 'about' %}">About CRATE</a></li>
        </ul>
    </div>
{% endblock %}
