<?php 
if (!isset($_SESSION)){
  session_start();
}
require_once("Connections/courier.php");

$typesearch = "Item_Name";
$typesearch2 = "Item_Id";
$searchtext = mysql_real_escape_string(trim($_POST["item_search"]));
$searchfacility=$_SESSION['provider_id'];
$disease_grp = mysql_real_escape_string($_POST['disease_grp']);

if ($searchtext != "") {
    if ($disease_grp == 'diseases') {
        $disease_name = 'Disease';
        $disease_code = 'Code';
        $disease_id = 'DiseaseID';
    } else if ($disease_grp == 'diseases_stg') {
        $disease_name = 'tg_disease_name';
        $disease_code = 'icd_10_Code';
        $disease_id = 'id';
    } else if($disease_grp == 'diseases_facility'){
        $disease_name = 'facility_disease_name';
        $disease_code = 'icd_10_Code';
        $disease_id = 'id';
    }
    $queryItems = "SELECT * FROM $disease_grp WHERE ($disease_name LIKE '%$searchtext%' OR $disease_code LIKE '%$searchtext%') ORDER BY $disease_name ASC limit 0,100";
    $resultItems = mysql_query($queryItems) or die(mysql_error());
    $arrayItems = mysql_fetch_assoc($resultItems);
    $totalRows = mysql_num_rows($resultItems);
}
?>

                       <div id="view_items_response_query_diagnosis">
                           <ul class="task-list">
                                                <li style="display: none;" id="new_diagnosis_name">
                                                    <div class="row">
                                                        <div class="col-md-12">
                                                        <div class="col-md-9 col-sm-8 col-xs-8">
                                                            <div class="task-title">
                                                                <span class="task-title-sp"> 
                                                                    <input class="form-control" placeholder="Enter Diagnosis Name" type="text" name="query_dignosis_name" id="query_dignosis_name">
                                                                </span>
                                                            </div>
                                                        </div>

                                                        <div class="col-md-3 col-sm-4 col-xs-4">
                                                            <div class="pull-right">
                                                                <button onclick="searchItemsName('save_new_query_diagnosis_name','#claimsno_query_diagnosis','');$('#new_diagnosis_name').hide();return false;" class="btn btn green"> Save </button>
                                                            </div>
                                                        </div>
                                                    </div>
                                                 </div>
                                                </li> 
                                                       <?php if ($totalRows> 0) { ?>                    
                                                    <?php
					         $i = 0;
                                                    do { $i = $i + 1; ?>
                        <li onclick="searchItemsName('query_diagnosis_edit_claim_details','#claimsno_query_diagnosis','<?php echo $arrayItems[$disease_id]; ?>','no_field');" onkeypress="javascript: if(isEnterKey(event)){ searchItemsName('query_diagnosis_edit_claim_details','#claimsno_query_diagnosis','<?php echo $arrayItems[$disease_id]; ?>','no_field'); }" onfocus="javascript: document.getElementById('sell_tr').style.color = 'red';" tabindex="2">
                                    <div style="font-size: 12px;" class="task-title">
                                        <span class="task-title-sp"><?php echo strtoupper($arrayItems[$disease_name]); ?></span>
                                    </div>
                                    <div style="margin-top: -20px;color: red;" class="pull-right">
                                        <i id="plus_<?php echo $arrayItems[$disease_id]; ?>" class="fa fa-plus"></i>
                                        <i style="display: none;" id="spin_refresh_plus_<?php echo $arrayItems[$disease_id]; ?>" class="fa fa-refresh fa-spin fa-fw"></i>
                                    </div>
                                </li>
                                      <?php } while ($arrayItems = mysql_fetch_assoc($resultItems)); ?>
                                     <?php }else{ ?>
                                <li>
                                    <div class="task-checkbox"> </div>
                                    <div class="task-title">
                                        <span class="task-title-sp"> <b> No Disease Found </b></span>
                                    </div>
                                    
                                    <?php if($disease_grp == 'diseases_facility'){ ?>
                                    <div style="margin-top: -20px;" class="pull-right">
                                        <b onclick="$('#query_dignosis_name').val($('#searchtext_query_diagnosis').val());$('#new_diagnosis_name').slideToggle();" style="color:blue;cursor: pointer;">Add New</b>
                                    </div>
                                     <?php } ?>
                                </li>
                                      <?php }?>
                                            </ul>
                 
                 </div>

         
        

