<?php $__env->startSection('content'); ?>

<style type="text/css">
    thead{
    height: 30px;
    
    border:solid 1px #F68634; 
    border-radius:5px;
}

thead tr th{
    text-align: center;
    border:solid 1px #F68634; 
    border-radius:5px;
}

tbody tr td{
    text-align: center;

    border:solid 1px #F68634; 
    border-radius:5px;

    padding: 10px 0px;
}

tfoot tr td{
    text-align: center;

    border:solid 1px #F68634; 
    border-radius:5px;

    padding: 10px 0px;
}
</style>



    <div class="row">
        <?php if(Session::has('errorNotification')): ?>
        <div class="row" class="errors">
          <div class="columns small-12">
            <div data-alert class="alert-box alert">
              <p class="lead"><?php echo Session::get('errorNotification'); ?></p>
              <a href="#" class="close">&times;</a>
            </div>
          </div>
        </div>
        <?php endif; ?>

        <div class="large-12 columns">
            <div class="row">
                <div class="small-12 medium-12 large-12 columns">
                    <h4>Results Review</h4>
                </div>
            </div>
            <div class="row">
                <div class="small-12 medium-12 large-12 columns">
                    <p>This screen summarizes patient cholinesterase testing information and contains notification commands. </p>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="large-6 columns">
            <div class="row">
                <div class="large-12 columns">
                    <h5>Patient: <?php echo e($patientData->fname . " " . $patientData->lname); ?></h5>
                </div>
            </div>

            <div class="row">
                <div class="large-12 columns">
                    <h5>Employer: <?php if(isset($employer->name)){echo $employer->name;}else{echo "Information needs to be updated";}?></h5>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="large-6 columns">
            <form id="actionForm" action="<?php echo e(URL::to('/patients/'. $patientData->pid .'/lab/order')); ?>" method="GET">
                <div class="row">
                    <div class="large-12 columns">
                        <button class="expand" type="submit">Order Laboratory Test</button>

                    </div>
                </div>
                <div class="row">
                    <div class="large-12 columns">  
                          <label><input type="radio" name="restriction" value="1" checked> Baseline test</label>
                          <label><input type="radio" name="restriction" value="2"> Initial test with history of recent prior exposure  (“working baseline” or “reference test”) </label>
                          <label><input type="radio" name="restriction" value="3"> Routine follow-up test</label>
                          <label><input type="radio" name="restriction" value="4"> Evaluation of suspected illness</label>
                          <label><input type="radio" name="restriction" value="5"> Recovery Monitoring</label>
                    
                    </div>
                </div>
            </form>
        </div>
        <div class="large-6 columns">
            <div class="row">
                <div class="large-12 columns">
                    <a href="<?php echo e(URL::to('/patients/'. $patientData->pid .'/results-review/graph')); ?>" class="button expand">Graph</a>
                </div>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="small-12 medium-12 large-12 columns">
            <div class="row">
                <div class="small-12 medium-12 large-6 columns">
                    <div class="row">
                        <div class="large-12 columns">
                            <hr>
                            <h5>Baseline Testing Results</h5>
                            <table>
                                <thead>
                                    <tr>
                                        <th>Date</th>
                                        <th>RBC (AChE) Cholinesterase</th>
                                        <th>Serum (BuChE) Cholinesterase</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php foreach($baseLine as $base): ?>
                                        <tr>
                                            <td><?php echo e(date("jS, F Y - H:i:s", strtotime($base->test_date))); ?></td>
                                            <td><?php echo e($base->plasma); ?></td>
                                            <td><?php echo e($base->rbc); ?></td>
                                        </tr>
                                    <?php endforeach; ?>
                                </tbody>
                                <tfoot>
                                    <tr>
                                        <td>Average</td>
                                        <td></td>
                                        <td></td>
                                    </tr>
                                </tfoot>
                            </table>                    
                        </div>
                    </div>
                    <div class="row">
                        <form id="actionForm" action="<?php echo e(URL::to('patients/' . $patientData->pid . '/manual/notification/preview')); ?>" method="GET">
                        <div class="row">
                            <div class="large-12 columns">
                                <div class="row">
                                    <div class="small-12 medium-6 large-12 columns">
                                        <hr>
                                        <h5>Notifications - Restrictions and Follow-up</h5>
                                        <div class="row">
                                            <div class="large-12 columns">
                                                <p>
                                                    <label>
                                                        <input type="radio" id="restriction" name="restriction" value="1" checked/>
                                                        Release to work with no restrictions
                                                    </label>
                                                </p>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="large-12 columns">
                                                <p>
                                                    <label>
                                                        <input type="radio" id="restriction" name="restriction" value="2"/>
                                                        Release to work with no restrictions, Employee investigation required
                                                    </label>
                                                </p>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="large-12 columns">
                                                <p>
                                                    <label><input type="radio" id="restriction" name="restriction" value="3"/>
                                                    No handling of ChE inhibiting pesticides until after follow-up testing</label>
                                                </p>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="large-12 columns">
                                                <textarea id="customDate" name="customDate" rows="4" cols="20" placeholder="Please specify test date or approximate interval"></textarea>
                                            </div>
                                        </div>

                                    </div>

                                </div>
                                
                            </div>
                        </div>
                    </div>

                        <div class="row">
                            <div class="small-12 large-6 columns">
                                <button class="button expand" href=" <?php echo e(URL::to('patients/' . $patientData->pid . '/notification')); ?> ">Send Notification</button>
                            </div>
                            <div class="small-6 medium-4 large-6 end columns">
                                <a href="<?php echo e(URL::to('patients/'.$patientData->pid)); ?>" class="button expand">Cancel</a>
                            </div>
                        </div>
                    </form> 
                </div>


                <div class="small-12 medium-12 large-6 columns">
                    <hr>
                    <h5>Follow-up Testing</h5>
                    <table>
                        <thead>
                            <tr>
                                <th>Date</th>
                                <th>RBC (AChE) Cholinesterase</th>
                                <th>Serum (BuChE) Cholinesterase</th>
                                <th>% Change RBC</th>
                                <th>% Change Serum</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php foreach($followUp as $follow): ?>
                                <tr>
                                    <td><?php echo e(date("jS, F Y - H:i:s", strtotime($follow->test_date))); ?></td>
                                    <td><?php echo e($follow->plasma); ?></td>
                                    <td><?php echo e($follow->rbc); ?></td>
                                    <?php 
                                        if(!isset($base)){
                                            $baseplasma = 1;
                                            $baserbc = 1;
                                        }else{
                                            $baseplasma = $base->plasma;
                                            $baserbc = $base->rbc; 
                                        }
                                    ?>
                                    <td><?php echo e(round(100 - (($follow->plasma / $baseplasma ) * 100))); ?>%</td>
                                    <td><?php echo e(round(100 - (($follow->rbc/ $baserbc) * 100))); ?>%</td>
                                </tr>
                            <?php endforeach; ?>
                        </tbody>                            
                    </table>
                </div>
            </div>
    </div>

    <div id="myModal" class="reveal-modal" data-reveal aria-labelledby="modalTitle" aria-hidden="true" role="dialog">
        <form id="actionForm" action="" method="POST">
            <input hidden name="pid" value="<?php echo e($patientData->pid); ?>" />
            <input hidden name="examType" value="followUp" />
        </form>
        <form id="signForm" action="" method="GET">
            <div class="row">
              <div class="large-6 columns">
                <label for="password">Please type your digital signature password</label>
                <input type="password" name="password">
                <button class="button">Sign</button>
              </div>
            </div>
        </form>
      <a class="close-reveal-modal" aria-label="Close">&#215;</a>
    </div>

    <script>

    $(document).ready(function(){
        $('#signForm').submit(function(e) {
            e.preventDefault();
            var url = '<?php echo URL::to("sign"); ?>';
            var passvalue = $("#signForm").find( "input[name='password']" ).val();
            var formData = {};
            $("#signForm").find("input[name='password']").each(function (index, node) {
                formData[node.name] = node.value;
            });
            $.ajax({
              type: "POST",
              url: url,
              contentType: "application/x-www-form-urlencoded; charset=UTF-8",
              data: formData
            }).done(function(response) {
              if(response==='true'){
                  $("#actionForm").attr("action", $('a.digital-signature').attr("href"));
                  $("#actionForm").submit();
              }
            });
        });
        $('a.digital-signature').on('click', function(e) {
            e.preventDefault();
            $('#myModal').foundation('reveal','open');
        });

       $('#close').foundation('reveal', 'close');
    });

    </script>

    <!-- pizza.js -->
    
    
<?php $__env->stopSection(); ?>
<?php echo $__env->make('master', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>