<?php include('accesscheck2.php'); 
require_once('Connections/courier.php');
require_once('functions/functions.php');
//error_reporting(0);
list($id, $process_claim_no, $patient_no) = explode("@@@", $_POST['id']);
?>


                            <div class="portlet light tasks-widget bordered" style="min-height: 400px;">
                                <div class="portlet-title">
                                    <div class="caption">
                                        <i class="icon-share font-dark hide"></i>
                                        <span class="caption-subject font-dark bold uppercase"> <span class="badge badge-danger"> <i class="fa fa-leaf"></i> </span> ALLERGIES</span>
                                    </div>
                                    
                                    <div class="actions">
                                        <a onclick="$('#add_new_vital_information').slideToggle(function(){if($(this).is(':hidden')) {$('.title_for').html('Add New Allergy');}else{$('.title_for').html('List of Patient Allegies');}});$('#list_patient_vitals').slideToggle();" href="#" class="btn btn-circle red-sunglo btn-sm">
                                            <i class="fa fa-bolt"></i> <span class="title_for">Add New Allergy</span> </a>
                                            <div class="btn-group">
                                            <a class="btn green btn-circle btn-sm" href="javascript:;" data-toggle="dropdown" aria-expanded="false">
                                                <i class="fa fa-user"></i> Actions
                                                <i class="fa fa-angle-down"></i>
                                            </a>
                                           <?php include 'patient_sub_menus.php';?>
                                        </div>
                                    </div>
                                    
                                    
                                </div>
                                <div class="portlet-body form">
                                   <form name="form" id="form" method="post" class="form-horizontal">
    <div id="add_new_vital_information" class="row" style="display: none;margin-top: -10px;">  
    <div class="col-md-12">
        <div class="form-body">
            <div class="col-md-12 col-sm-12">
                <div class="row">
                <div class="col-md-6">
                    <div class="row">
                        <div class="form-group">
                            <label class="col-md-5 control-label" style="">Allergy Name</label>
                            <div class="col-md-7">
                                <select onchange="if(this.value == 'other'){$('.other_allergy').show();}" name="allergy_name" class="form-control">
                                    <?php
                                    $allergies = list_all_allergies('allergy_data', $courier);
                                    foreach ($allergies as $a) { ?>
                                    <option value="<?php echo $a['allergy_name'];?>"><?php echo $a['allergy_name'] ;?> - <?php echo strtoupper($a['group_name']);?> ALLERGY</option>
                                    <?php } ?>
                                         <option value="other">Other Allergy</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-5 control-label other_allergy" style=";display: none;">New Allergy Name</label>
                            <div class="col-md-7 other_allergy" style="display: none;">
                                <input type="text" class="form-control" name="other_allergy" id="other_allergy">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-5 control-label" style="">Reactions</label>
                            <div class="col-md-7">
                                <select onchange="AddChronicDisease('allergy_reaction', this.value);" name="allergy_reaction_selected" id="allergy_reaction_selected" class="form-control">
                                    <?php
                                    $allergies = list_all_allergy_reactions($courier);
                                    foreach ($allergies as $a) { ?>
                                         <option value="<?php echo $a['allergy_reaction'];?>"><?php echo $a['allergy_reaction'] ;?></option>
                                    <?php } ?>
                            </select>
                            </div>
                        </div>
                         <div class="form-group">
                            <label class="col-md-5 control-label" style=""> Reactions Selected </label>
                            <div class="col-md-7">
                                <textarea name="allergy_reaction" id="allergy_reaction" class="form-control"></textarea>
                            </div>
                        </div>
                    </div>
                </div>
                
                 <div class="col-md-6">
                    <div class="row">
                        <div class="form-group">
                            <label class="col-md-5 control-label" style=""> Severity</label>
                            <div class="col-md-7">
                                <select class="form-control" name="severity" id="severity">
                                    <option value="MILD">MILD</option>
                                    <option value="MODERATE">MODERATE</option>
                                    <option value="SEVERE">SEVERE</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-5 control-label" style="">Comment</label>
                            <div class="col-md-7">
                                <input type="text" class="form-control" name="comment" id="comment">
                            </div>
                        </div>
                       
                    </div>
                </div>
                    
            </div>
            </div>
           
        </div><br>
             <div class="row" style="padding-top:20px;">
                                                <div class="col-md-offset-6 col-md-6">
                                                    <button onclick="patient_menu_info('save_allergies','<?php echo $id;?>');return false;" class="btn green">Save <i class="icon-ok"></i></button>
                                                    <button type="reset" class="btn default">Reset</button>
                                                </div>
                                            </div>
    </div>
</div>
                                    </form>
                                    
                                    <div class="task-content task-list" id="list_patient_vitals">
                                        <div class="row">
                        <div class="col-md-12">
                                <div class="portlet-body">
                                   <?php
                       $i=1;
                       $med_his = mysql_query("select * from allergies where patient_id = '$id' order by id desc", $courier);
                       if(mysql_num_rows($med_his) > 0){
                       while($med_row = mysql_fetch_assoc($med_his)){ ?>
                               <div class="mt-comments" style="cursor: pointer;">
                                        <div class="mt-comment" style="background-color: #FAFAFA;border: 1px solid #eee;">
                                                    <div class="mt-comment-img"><?php echo $i;?>.</div>
                                                    <div class="mt-comment-body">
                                                        <div class="mt-comment-info">
                                                            <span class="mt-comment-author"> <?php echo $med_row['allergy_name'];?> </span>
                                                            <span class="mt-comment-date"><?php echo date('jS F, Y', strtotime($med_row['date']));?></span>
                                                        </div>
                                                        <div class="mt-comment-text"> 
                                                            <div>  <span style="font-weight: bold;"> Reactions </span> :  <?php echo $med_row['reaction']; ?></div>
                                                            <div>  <span style="font-weight: bold;"> Severity </span> : <?php echo $med_row['severity']; ?></div>
                                                            <div>  <span style="font-weight: bold;"> Comment </span> :  <?php echo $med_row['comments']; ?></div>
                                                        </div>
                                                        <div class="mt-comment-details">
                                                            <ul class="mt-comment-actions" style="display: block">
                                                                <li>
                                                                    <a style="color: red;" onclick="patient_menu_info('delete_allergies','<?php echo $id;?>','<?php echo $med_row['id'];?>');return false;" href="#"><i class="icon-trash"></i></a>
                                                                </li>
                                                            </ul>
                                                        </div>
                                                    </div>
                                                </div>
                                    </div>
                       <?php $i++; } } else{ ?>
                                    <div class="mt-comments" style="cursor: pointer;">
                                        <div class="mt-comment" style="background-color: #FAFAFA;border: 1px solid #eee;">
                                                    <div class="mt-comment-img"></div>
                                                    <div class="mt-comment-body">
                                                        <div class="mt-comment-info">
                                                            <span class="mt-comment-author" style="color: red;"> NO ALLERGIES FOUND </span>
                                                            <span class="mt-comment-date"></span>
                                                        </div>
                                                        <div class="mt-comment-text"></div>
                                                        <div class="mt-comment-details"></div>
                                                    </div>
                                                </div>
                                    </div>
                       <?php  } ?>
                                    
                                </div>
                                        </div>
                                        </div>
                                        </div>
                                    </div>
                                    </div>
                                    <div class="task-footer">
                                        <div class="btn-arrow-link pull-right">
                                        </div>
                                    </div>
                               