<!doctype html>

<html lang="en-US">
<head>
  <meta charset="utf-8">
  <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

  <link rel="stylesheet" href="<?php echo $publicUri; ?>css/bootstrap.min.css">
  <link rel="stylesheet" href="<?php echo $publicUri; ?>css/style.css?t=<?php echo time(); ?>">
  <link rel="stylesheet" href="<?php echo $publicUri; ?>css/fonts.css">
<style media="screen">
  .text_info{color: #777777}
  .borderless td, .borderless th {
    border: none;
  }
.border-right {border-right:1px solid #cccccc !important}
.text-health{font-size: 18px}
h5{margin:0px;padding:0px !important}
hr{margin-top:1px}

    @media screen {
      .page {
          page-break-after: always !important;
            }
    }

</style>
</head>

<body>

  <div class="container">
    <div class="container-page-wrapper">
      <div class="container-page-container">
    <div class="row">
      <div class="col" style="width:100%;padding:0px;margin:0px">
        <table class="table borderless table-sm" style="width:100%;padding:0px;margin:0px; border: 1px solid #cccccc">
          <tr style="text-align:center">
            <td class="border-right" style="width:32%; border-bottom:1px solid #cccccc" colspan="2"><b><?php echo strtoupper(_('Patient_data')); ?></b></td>
            <td class="border-right" style="width:31%; border-bottom:1px solid #cccccc" colspan="2"><b><?php echo strtoupper(_('Request specialist')); ?></b></td>
            <td class="border-right" style="width:37%; border-bottom:1px solid #cccccc" colspan="2"><b><?php echo strtoupper(_('Teleconsultation')); ?></b></td>
          </tr>

          <!-- RIGA 1 -->
          <tr>
            <td style="width:9%" class="text_info"><?php echo _('Name'); ?></td>
            <td class="border-right" style="width:25%">
              <b>
                <?php if($this->view->requestData['request_anonymous'] == '0'): ?>
                  <?php echo $this->view->requestData['patient_name']; ?>
                <?php else: ?>
                  <?php echo '...' ?>
                <?php endif; ?>
              </b>
            </td>
            <td style="text-align:center">
              <?php if(is_array($this->view->requestMedicalSpecialties)): ?>
                <?php $i = 1 ?>
                <?php foreach($this->view->requestMedicalSpecialties as $item): ?>
                  <?php if($i == 1): ?>
                    <b><?php echo $item['description']; ?></b>
                  <?php endif; ?>
                  <?php $i++ ?>
                <?php endforeach; ?>
              <?php endif; ?>
            </td>
            <td style="text-align:center" class="border-right">
              <?php if(is_array($this->view->requestMedicalSpecialties)): ?>
                <?php $i = 1 ?>
                <?php foreach($this->view->requestMedicalSpecialties as $item): ?>
                  <?php if($i == 2): ?>
                    <b><?php echo $item['description']; ?></b>
                  <?php endif; ?>
                  <?php $i++ ?>
                <?php endforeach; ?>
              <?php endif; ?>
            </td>
            <td style="width:10%" class="text_info"><?php echo _('Number ID'); ?></td>
            <td class="border-right" style="width:25%"><b><?php echo $this->actionTitlePDF; ?></b></td>
          </tr>

          <!-- RIGA 2 -->
          <tr>
            <td style="width:8%" class="text_info"><?php echo _('Surname'); ?></td>
            <td class="border-right">
              <b>
                <?php if($this->view->requestData['request_anonymous'] == '0'): ?>
                  <?php echo $this->view->requestData['patient_surname']; ?>
                <?php else: ?>
                  <?php echo '...' ?>
                <?php endif; ?>
              </b>
            </td>
            <td style="text-align:center">
              <?php if(is_array($this->view->requestMedicalSpecialties)): ?>
                <?php $i = 1 ?>
                <?php foreach($this->view->requestMedicalSpecialties as $item): ?>
                  <?php if($i == 3): ?>
                    <b><?php echo $item['description']; ?></b>
                  <?php endif; ?>
                  <?php $i++ ?>
                <?php endforeach; ?>
              <?php endif; ?>
            </td>
            <td style="text-align:center" class="border-right">
              <?php if(is_array($this->view->requestMedicalSpecialties)): ?>
                <?php $i = 1 ?>
                <?php foreach($this->view->requestMedicalSpecialties as $item): ?>
                  <?php if($i == 4): ?>
                    <b><?php echo $item['description']; ?></b>
                  <?php endif; ?>
                  <?php $i++ ?>
                <?php endforeach; ?>
              <?php endif; ?>
            </td>
            <td style="width:15%" class="text_info"><?php echo _('Health Center'); ?></td>
            <td class="border-right" ><b><?php echo $this->view->requestData['center_description']; ?></b></td>
          </tr>

          <!-- RIGA 3 -->
          <tr>
            <td style="width:8%" class="text_info"><?php echo _('Gender'); ?></td>
            <td class="border-right">
              <b>
                <?php if($this->view->requestData['gender'] == 'm'): ?>
                  <?php echo _('Male') ?>
                <?php else: ?>
                  <?php echo _('Female') ?>
                <?php endif; ?>
              </b>
            </td>
            <td style="text-align:center">
              <?php if(is_array($this->view->requestMedicalSpecialties)): ?>
              <?php $i = 1 ?>
              <?php foreach($this->view->requestMedicalSpecialties as $item): ?>
                <?php if($i == 5): ?>
                  <b><?php echo $item['description']; ?></b>
                <?php endif; ?>
                <?php $i++ ?>
              <?php endforeach; ?>
            <?php endif; ?>
          </td>
          <td style="text-align:center" class="border-right">
            <?php if(is_array($this->view->requestMedicalSpecialties)): ?>
            <?php $i = 1 ?>
            <?php foreach($this->view->requestMedicalSpecialties as $item): ?>
              <?php if($i == 6): ?>
                <b><?php echo $item['description']; ?></b>
              <?php endif; ?>
              <?php $i++ ?>
            <?php endforeach; ?>
          <?php endif; ?>
        </td>
          <td  style="width:10%" class="text_info"><?php echo _('Request date'); ?></td>
          <td class="border-right" ><b><?php echo date('d/m/Y H:i', strtotime($this->view->requestData['created_at'])); ?></b></td>
        </tr>
        <!-- RIGA 4 -->
        <tr>
          <td style="width:8%" class="text_info"><?php echo _('Age'); ?></td>
          <td class="border-right">
            <b>
              <?php echo $this->helper->patient_age(['anonymous'=>$this->view->requestData['request_anonymous'], 'ageYears'=>$this->view->requestData['age_years'], 'ageMonths'=>$this->view->requestData['age_months'], 'ageDays'=>$this->view->requestData['age_days']]); ?></td>
            </b>
          </td>
          <td style="text-align:center">
            <?php if(is_array($this->view->requestMedicalSpecialties)): ?>
              <?php $i = 1 ?>
              <?php foreach($this->view->requestMedicalSpecialties as $item): ?>
                <?php if($i == 7): ?>
                  <?php echo $item['description']; ?>
                <?php endif; ?>
                <?php $i++ ?>
              <?php endforeach; ?>
            <?php endif; ?>
          </td>
          <td style="text-align:center" class="border-right">
            <?php if(is_array($this->view->requestMedicalSpecialties)): ?>
              <?php $i = 1 ?>
              <?php foreach($this->view->requestMedicalSpecialties as $item): ?>
                <?php if($i == 8): ?>
                  <?php echo $item['description']; ?>
                <?php endif; ?>
                <?php $i++ ?>
              <?php endforeach; ?>
            <?php endif; ?>
          </td>
          <td class="text_info"><?php echo _('Requester'); ?></td>
          <td class="border-right"><b><?php echo $this->view->requestData['sender_surname'].' '.$this->view->requestData['sender_name']; ?></b></td>
        </tr>
      </table>
    </div>
  </div>

  <!-- FINE TRE COLONNE PRINCIPALI -->

  <div class="card-body">
    <?php if(trim($this->view->requestData['medical_history']) != ''): ?>
      <h5><?php echo _('Medical History'); ?></h5>
      <hr>
      <?php echo $this->helper->hashtag(nl2br(trim(strip_tags($this->view->requestData['medical_history'])))); ?>
    <?php endif; ?>

    <h5 class="mt-4"><?php echo _('Medical Remarks'); ?></h5>
    <hr style="margin-bottom:0px">

    <div class="row mt-2 mb-2">

	   <?php if ((float)$this->view->requestData['min_arterial_pressure'] > 0 && (float)$this->view->requestData['max_arterial_pressure'] > 0): ?>
      <div class="col text-center">
        <div class="text-health"><small><?php echo _('Blood Pressure'); ?></small><b class="ml-3"><?php echo $this->view->requestData['max_arterial_pressure']; ?>/<?php echo $this->view->requestData['min_arterial_pressure']; ?></b> <sup>mmHg</sup></div>
      </div>
      <?php endif; ?>

      <?php if ((float)$this->view->requestData['heart_rate'] > 0): ?>
      <div class="col text-center">
        <div class="text-health"><small><?php echo _('Heart Rate'); ?></small><b class="ml-3"><?php echo $this->view->requestData['heart_rate']; ?></b> <sup>bpm</sup></div>
      </div>
      <?php endif; ?>

      <?php if ((float)$this->view->requestData['saturation'] > 0): ?>
      <div class="col text-center">
        <div class="text-health"><small><?php echo vsprintf(_('%s Sat.'), 'O<sub>2</sub>'); ?></small><b class="ml-3">
          <?php if($this->view->requestData['saturation'] == '0'): ?>
            <?php echo '-'; ?>
          <?php else: ?>
            <?php echo $this->view->requestData['saturation']; ?> <sup>%</sup>
          <?php endif; ?>
        </b>
      </div>
      <?php endif; ?>

    </div>

  </div>
  <hr>
  <?php echo nl2br(trim(strip_tags($this->view->requestData['clinical_remarks']))); ?>


</div>


<?php if(is_array($this->view->symptoms) && !empty($this->view->symptoms)): ?>
  <div class="card margin-top-10">
    <div class="card-body">
      <h5 class="card-title"><?php echo _('ICD-10'); ?></h5>
      <ol class="list-no-margin-bottom">
        <?php foreach($this->view->symptoms as $symptom): ?>
          <li><?php echo ucfirst($symptom['symptom_label']); ?></li>
        <?php endforeach; ?>
      </ol>
    </div>
  </div>
<?php endif; ?>

<?php if(is_array($this->view->wizards)): ?>
  <?php foreach($this->view->wizards as $type => $items): ?>
    <div class="card margin-top-10">
      <div class="card-body">
        <h5 class="card-title"><?php echo isset($this->view->wizardTitles[$type]) ? $this->view->wizardTitles[$type] : '-'; ?></h5>
        <ol class="list-no-margin-bottom">
          <?php foreach($items as $item): ?>
            <li><?php echo $item['description']; ?></li>
          <?php endforeach; ?>

        </ol>

        <?php if($type == 'derma'): ?>
          <?php if(is_array($this->view->dermaPositions)): ?>
            <div><b><?php echo _('Position'); ?></b></div>
            <ol>
              <?php foreach($this->view->dermaPositions as $positionType => $positionData): ?>
                <li><?php echo isset($this->view->dermaPositionLabels[$positionData['position_type']]) ? $this->view->dermaPositionLabels[$positionData['position_type']] : '-'; ?></li>
              <?php endforeach; ?>
            </ol>
          <?php endif; ?>
        <?php endif; ?>
      </div>
    </div>
  <?php endforeach; ?>
<?php endif; ?>

<!-- <div class="page"></div> -->
<div class="mb-1">&nbsp;</div>

<!-- DOMANDA -->
<table class="table table-sm" style="border-top: none !important;">
  <tr>
    <td style="border-top:4px solid gray; border-bottom:4px solid gray" colspan="2"><b><?php echo _('Question'); ?></b></td>
  </tr>
  <tr>
    <td style="border-top: none !important" ><?php echo _('From'); ?>:&nbsp;<b><?php echo $this->view->requestData['sender_surname'].' '.$this->view->requestData['sender_name']; ?></b></td>
    <td style="border-top: none !important; width:25%; text-align:right"><?php echo date('d/m/Y H:i', strtotime($this->view->requestData['created_at'])); ?></td>
  </tr>
  <tr>
    <td colspan="2"><?php echo $this->helper->hashtag($this->view->requestData['request_question']); ?></td>
  </tr>
</table>
<!-- FINE DOMANDA -->

<!-- LISTA COMMENTI -->
<div id="request-comment-wrapper">



    <?php echo $this->partial('Request/comment-list-pdf', ['comments'=>$this->view->comments]); ?>

</div>
<!-- FINE COMMENTI -->

<hr>
<!-- <div class="page"></div> -->
<!-- ATTACHMENT -->
<?php if(is_array($this->view->groupedAttachments) && !empty($this->view->groupedAttachments)): ?>
  <div class="mb-1">&nbsp;</div>
  <div class="card margin-top-10">
    <div class="card-body">
      <h5 class="card-title"><?php echo _('Attachments'); ?></h5>

      <?php foreach($this->view->groupedAttachments as $created_at => $attachments): ?>
        <label class="label-main"><?php echo date('d/m/Y H:i', strtotime($created_at)); ?></label>
        <ul class="list-no-type margin-bottom-10">
          <?php foreach($attachments as $attach): ?>
            <li class="list-no-type padding-left-10">
              <?php echo $this->helper->getDocName($attach); ?>
            </li>
          <?php endforeach; ?>
        </ul>
      <?php endforeach; ?>
    </div>
  </div>
<?php endif; ?>

</div>
</div>
</div>


<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script src="<?php echo $publicUri; ?>js/bootstrap.min.js"></script>

</body>
</html>
