<?php require __DIR__.'/includes/bootstrap.php';$st=$pdo->prepare("SELECT d.*,c.name category_name FROM drugs d LEFT JOIN categories c ON c.id=d.category_id WHERE d.slug=:s AND d.status='published'");$st->execute(['s'=>$_GET['slug']??'']);$d=$st->fetch();if(!$d){http_response_code(404);$pageTitle='Medicine not found';require __DIR__.'/includes/header.php';echo '<div class="empty"><h1>Medicine not found</h1><a href="'.e(url()).'">Back to library</a></div>';require __DIR__.'/includes/footer.php';exit;}$seo=seo_drug_status($d);$robots=seo_robots_meta($seo['index']);$pageTitle=$d['name'].' – Uses, Dosage & Side Effects';$description=excerpt($d['summary']?:$d['uses']);$canonical=url('drug/'.$d['slug']);require __DIR__.'/includes/header.php';$sections=['Overview'=>'summary','What is it used for?'=>'uses','Active ingredients'=>'active_ingredients','How it works'=>'how_it_works','Dosage and administration'=>'dosage','Contraindications'=>'contraindications','Warnings and precautions'=>'warnings','Side effects'=>'side_effects','Drug interactions'=>'interactions','Pregnancy and breastfeeding'=>'pregnancy_lactation','Overdose information'=>'overdose','Storage'=>'storage'];?><div class="crumb"><a href="<?=e(url())?>">WikiDrug</a> / <?=e($d['category_name']?:'Medicine')?> / <?=e($d['name'])?></div>
<header class="drug-heading">
  <label>MEDICINE PROFILE</label>
  <h1><?=e($d['name'])?></h1>
</header>
<div class="detail drug-detail-layout">
  <article class="drug-article">
    <?php foreach($sections as $heading=>$field):if(trim((string)$d[$field])==='')continue;?>
      <section id="<?=e(slug($heading))?>">
        <h2><?=e($heading)?></h2>
        <div class="medical-content"><?=medical_html($d[$field])?></div>
      </section>
    <?php endforeach;?>
    <?php $manufacturerList=manufacturer_names($d['manufacturer']??''); if($manufacturerList):?>
      <section class="manufacturer-section">
        <h2>Manufacturer(s)</h2>
        <div class="manufacturer-links">
          <?php foreach($manufacturerList as $mn):?>
            <a class="manufacturer-link" href="<?=e(url('manufacturer/'.manufacturer_slug($mn)))?>"><?=e($mn)?></a>
          <?php endforeach;?>
        </div>
      </section>
    <?php endif;?>
    <section class="medical-references">
      <h2>Medical references</h2>
      <ul>
        <li>U.S. National Library of Medicine – DailyMed</li>
        <li>Official prescribing information</li>
        <li>Other authoritative medical references, where applicable</li>
      </ul>
      <p class="reference-note">References are used to support the medical information presented on this page.</p>
    </section>
    <section class="medical-disclaimer">
      <h2>Medical information disclaimer</h2>
      <p>The information on WikiDrug is provided for educational and informational purposes only. It is not intended to replace professional medical advice, diagnosis, or treatment. Always consult a qualified healthcare professional before making decisions about medication use.</p>
    </section>
    <p class="drug-updated">Last updated <?=e(date('F j, Y',strtotime($d['updated_at'])))?></p>
  </article>
  <aside class="panel facts drug-facts-panel">
    <?php if(!empty($d['image_path']) && is_file(__DIR__.'/'.$d['image_path'])):?>
      <figure class="drug-package-photo">
        <img src="<?=e(url($d['image_path']))?>" alt="<?=e($d['name'])?> medicine packaging" loading="eager" decoding="async">
      </figure>
    <?php endif;?>
    <label>AT A GLANCE</label>
    <h3>Quick facts</h3>
    <?php foreach(['Generic name'=>'generic_name','Dosage form'=>'dosage_form','Strength'=>'strength','RxNorm ID'=>'rxnorm_rxcui','ATC code'=>'atc_code'] as $k=>$f):if($d[$f]):?>
      <small><?=e($k)?></small>
      <b><?=e($d[$f])?></b>
    <?php endif;endforeach;?>
    <?php
      $cq=$pdo->prepare('SELECT c.name,c.slug FROM drug_class_map m JOIN drug_classes c ON c.id=m.drug_class_id WHERE m.drug_id=? ORDER BY m.is_primary DESC,c.name');
      $cq->execute([$d['id']]);$classes=$cq->fetchAll();
      if($classes):
    ?>
      <small>Drug classes</small>
      <?php foreach($classes as $cl):?><b><a href="<?=e(url('drug-class/'.$cl['slug']))?>"><?=e($cl['name'])?></a></b><?php endforeach;?>
    <?php elseif($d['drug_class']):?>
      <small>Drug class</small><b><?=e($d['drug_class'])?></b>
    <?php endif;?>
  </aside>
</div>
<?php require __DIR__.'/includes/footer.php';?>
