<?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-success"> <i class="fa fa-ambulance"></i> </span> Chronic Diseases</span>
                                    </div>
                                    
                                    <div class="actions">
                                        <a onclick="$('#add_new_vital_information').slideToggle(function(){if($(this).is(':hidden')) {$('.title_for').html('Add New Chronic Disease');}else{$('.title_for').html('List of Patient Chronic Diseases');}});$('#list_patient_vitals').slideToggle();" href="#" class="btn btn-circle red-sunglo btn-sm">
                                            <i class="fa fa-plus"></i> <span class="title_for">Add New Chronic Disease</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">
                                   
    <div id="add_new_vital_information" class="row" style="display: none;margin-top: -10px;">  
        
        <form class="form-horizontal" role="form">
            
            <div class="form-body">
                <div class="form-group">
                <label class="col-md-3 control-label">Disease Group</label>
                <div class="col-md-9">
                    <div class="mt-radio-inline">
                        <label onclick="$('.hide_grps').hide();$('#disease_who').show();" class="mt-radio">
                            <input value="who" type="radio" name="disease_grp" id="disease_grp" checked=""> WHO
                            <span></span>
                        </label>
                        <label onclick="$('.hide_grps').hide();$('#disease_stg').show();" class="mt-radio">
                            <input value="stg" type="radio" name="disease_grp" id="disease_grp_2"> STG
                            <span></span>
                        </label>
                        <label onclick="$('.hide_grps').hide();$('#disease_facility').show();" class="mt-radio">
                            <input value="facility" type="radio" name="disease_grp" id="disease_grp_3"> FACILITY
                            <span></span>
                        </label>
                    </div>
                </div>
            </div>
                <div class="form-group hide_grps" id="disease_who" style="margin-top:-10px;">
                    <label class="col-md-3 control-label">Disease Name</label>
                    <div class="col-md-6">
                        <?php $drugs = list_all_drugs('diseases', 'Disease', $courier);?>
                        <select class="form-control" onchange="AddChronicDisease('chronicdisease', this.value);">
                            <?php
                                foreach ($drugs as $d) { ?>
                                     <option value="<?php echo $d['Disease'];?>"><?php echo $d['Disease'] ;?></option>
                               <?php } ?>
                        </select>
                    </div>
                </div>
                <div class="form-group hide_grps" id="disease_stg" style="margin-top:-10px;display: none;">
                    <label class="col-md-3 control-label">Disease Name</label>
                    <div class="col-md-6">
                        <?php $drugs = list_all_drugs('diseases_stg', 'tg_disease_name', $courier);?>
                        <select class="form-control" onchange="AddChronicDisease('chronicdisease', this.value);">
                            <?php
                                foreach ($drugs as $d) { ?>
                                     <option value="<?php echo $d['tg_disease_name'];?>"><?php echo $d['tg_disease_name'] ;?></option>
                               <?php } ?>
                        </select>
                    </div>
                </div>
                <div class="form-group hide_grps" id="disease_facility" style="margin-top:-10px;display: none;">
                    <label class="col-md-3 control-label">Disease Name</label>
                    <div class="col-md-6">
                        <select class="form-control" onchange="AddChronicDisease('chronicdisease', this.value);">
                            
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-3 control-label">Selected Diseases</label>
                    <div class="col-md-6">
                        <input type="text" id="chronicdisease" name="chronicdisease" class="form-control"> 
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-3 control-label">Carrier</label>
                    <div class="col-md-6">
                        <select class="form-control" onchange="if(this.value == 'other'){$('.other_carrier').show();}" name="carrier" id="carrier">
                            <option value="">--Select--</option>
                            <option value="Mother">Mother</option>
                            <option value="Father">Father</option>
                            <option value="Sister">Sister</option>
                            <option value="Brother">Brother</option>
                            <option value="other">Other</option>
                        </select> 
                    </div>
                </div>
                <div class="form-group other_carrier" style="display: none;">
                    <label class="col-md-3 control-label">Please Specify</label>
                    <div class="col-md-6">
                        <input type="text" class="form-control" name="other_carrier" id="other_carrier">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-3 control-label">Comments</label>
                    <div class="col-md-6">
                        <textarea name="comment" id="comment" class="form-control" rows="3"></textarea> 
                    </div>
                </div>
                
            </div>
            <div class="form-actions">
                <div class="row">
                    <div class="col-md-offset-3 col-md-9">
                        <button onclick="patient_menu_info('save_chronic_disease','<?php echo $id;?>');return false;" type="submit" class="btn green">Submit</button>
                        <button type="reset" class="btn default">Reset</button>
                    </div>
                </div>
            </div>
        </form>
        
</div>
                                   
                                    
                                    <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 chronic_diseases 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['disease_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;"> Carrier </span> : <?php echo $med_row['carrier']; ?></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_chronic_disease','<?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 CHRONIC DISEASES 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>
                               