<?php
declare(strict_types=1);

require __DIR__ . '/../app/bootstrap.php';
$pdo = app_db();

$pageTitle = 'NIH/NLM Research Links | Medical Tracker';
$activePage = 'research';
$studies = db_all($pdo, 'SELECT * FROM research_studies ORDER BY category, related_medicine, title');
$photo = 'https://upload.wikimedia.org/wikipedia/commons/thumb/4/45/Jogging_Woman_in_Grass.jpg/1280px-Jogging_Woman_in_Grass.jpg';
require __DIR__ . '/partials/site-header.php';
?>
<main>
    <section class="detail-hero">
        <div>
            <p class="site-eyebrow">NIH/NLM research links</p>
            <h1>Connect medications and conditions to study-search starting points.</h1>
            <p>Use curated categories and links into NIH/NLM systems to begin research on studies related to the medicines listed in the catalog.</p>
            <a class="site-primary" href="/medical.php">Open terminology database</a>
        </div>
        <figure>
            <img src="<?= htmlspecialchars($photo, ENT_QUOTES) ?>" alt="Runner training outdoors">
            <figcaption>
                Photo: <a href="https://commons.wikimedia.org/wiki/File:Jogging_Woman_in_Grass.jpg">Jogging Woman in Grass</a>
                by Mike Baird, <a href="https://creativecommons.org/licenses/by/2.0/">CC BY 2.0</a>.
            </figcaption>
        </figure>
    </section>

    <section class="admin-public-shell">
        <div class="term-table">
            <?php foreach ($studies as $study): ?>
                <article>
                    <div>
                        <h3><?= htmlspecialchars($study['title'], ENT_QUOTES) ?></h3>
                        <span><?= htmlspecialchars($study['category'] . ' / ' . $study['related_medicine'], ENT_QUOTES) ?></span>
                    </div>
                    <p><?= htmlspecialchars($study['summary'], ENT_QUOTES) ?></p>
                    <p><?= htmlspecialchars($study['study_type'], ENT_QUOTES) ?></p>
                    <div class="source-links">
                        <a href="<?= htmlspecialchars($study['source_url'], ENT_QUOTES) ?>"><?= htmlspecialchars($study['nih_source'], ENT_QUOTES) ?></a>
                        <a href="<?= htmlspecialchars($study['pubmed_url'], ENT_QUOTES) ?>">PubMed</a>
                        <a href="<?= htmlspecialchars($study['clinicaltrials_url'], ENT_QUOTES) ?>">ClinicalTrials.gov</a>
                    </div>
                </article>
            <?php endforeach; ?>
        </div>
    </section>
</main>
<?php require __DIR__ . '/partials/site-footer.php'; ?>
