<?php include('accesscheck2.php'); 
require_once('Connections/courier.php');
require_once('functions/functions.php');

mysql_select_db($database_courier, $courier);

$query_rsodest_patient = "SELECT * FROM patient_information where id='$id'";
$rsodest_patient = mysql_query($query_rsodest_patient, $courier) or die(mysql_error());
$row_rsodest_patient = mysql_fetch_assoc($rsodest_patient); ?>

<div class="portlet-title">
    <div class="caption caption-md">
        <i class="icon-globe theme-font hide"></i>
        <span class="caption-subject font-blue-madison bold uppercase">PATIENT DETAILS</span>
    </div>
</div>
<div class="portlet-body form">
    <div id="success_error_info_display"></div>
    <form role="form" action="#" id="edit_patient_info_form">
        <div class="form-body">
            
            <div class="col-lg-12 col-xs-12 col-md-12">
                <div class="form-group">
                    <label class="control-label">Title</label>
                    <select name="title" id="title" class="form-control">
                        <option <?php if($title['title'] == $row_rsodest_patient['title']){ echo 'selected=""';} ?> value="">No Title</option>
                        <?php
                        $titles = mysql_query("SELECT * FROM title");
                        while($title = mysql_fetch_assoc($titles)){ ?>
                            <option <?php if($title['title'] == $row_rsodest_patient['title']){ echo 'selected=""';} ?> value="<?php echo $title['title']; ?>"><?php echo $title['title']; ?></option>
                        <?php } ?>
                    </select>
                </div>
            </div>
            <div class="row">
                <div class="col-lg-12 col-xs-12 col-md-12">
                    <div class="col-md-6">
                        <div class="form-group">
                            <label class="control-label">Patient No</label>
                            <input type="text" readonly="" value="<?php echo $row_rsodest_patient['card_number'] ?>" class="form-control">
                            <input type="hidden" id="filepath0"  value="<?php echo $row_rsodest_patient['picpath']?>" name="filepath0">
                        </div>
                        <div class="form-group">
                            <label class="control-label">Surname</label>
                            <input type="text" name="surname" id="surname" value="<?php echo $row_rsodest_patient['surname'] ?>" class="form-control"> </div>
                            <div class="form-group">
                                <label class="control-label">Date Of Birth</label>
                                <input readonly type="text" name="dateofbirth" value="<?php echo $row_rsodest_patient['dateofbirth'] ?>" type="text" id="dateofbirth" class="form-control date_time_picker"> </div>
                                <div class="form-group">
                                    <label class="control-label">Sex</label>
                                    <select name="sex" id="sex" class="form-control"  onchange="showpreg(this.value)">
                                        <option value="">-------- SELECT -------</option>
                                        <option value="Male" <?php if($row_rsodest_patient['sex']=='Male'){?> selected="selected" <?php } ?>>Male</option>
                                        <option value="Female" <?php if($row_rsodest_patient['sex']=='Female'){?> selected="selected" <?php } ?>>Female</option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label class="control-label">Email</label>
                                    <input type="text" value="<?php echo $row_rsodest_patient['email'];?>" type="text" name="email" id="email" class="form-control"> </div>
                                    <div class="form-group hide">
                                        <label class="control-label">Country of Origin</label>
                                        <select name="country_of_origin"  id="country_of_origin" class="form-control">
                                          <option value="">-------- SELECT -------</option>
                                          <?php
                                          $query_rsodestship_country = "SELECT * FROM countrylist order by country";
                                          $rsodestship_country = mysql_query($query_rsodestship_country, $courier) or die(mysql_error());
                                          $row_rsodestship_country = mysql_fetch_assoc($rsodestship_country);
                                          $totalRows_rsodestship_country = mysql_num_rows($rsodestship_country);
                                          do {  
                                            ?>
                                            <option value="<?php echo $row_rsodestship_country['country']; ?>" <?php if($row_rsodest_patient['country_of_origin']==$row_rsodestship_country['country']){ ?>selected="selected"<?php }?>><?php echo $row_rsodestship_country['country']?></option>
                                            <?php
                                        } while ($row_rsodestship_country = mysql_fetch_assoc($rsodestship_country));
                                        $rows = mysql_num_rows($rsodestship_country);
                                        if($rows > 0) {
                                          mysql_data_seek($rsodestship_country, 0);
                                          $row_rsodestship_country = mysql_fetch_assoc($rsodestship_country);
                                      }
                                      ?>
                                  </select>
                              </div>
                              <div class="form-group hide">
                                <label class="control-label">Residential Address</label>
                                <input type="text" class="form-control" name="radd" id="radd" value="<?php echo $row_rsodest_patient['home_address'];?>"> 
                            </div>
                            <div class="form-group hide">
                                <label class="control-label">Referer's Relationship</label>
                                <select class="form-control" name="referer_relationship" id="referer_relationship">
                                    <option value="">-------- SELECT -------</option>
                                    <?php
                                    $query_rsodestship_country = "SELECT * FROM refer_relationship order by relationship";
                                    $rsodestship_country = mysql_query($query_rsodestship_country, $courier) or die(mysql_error());
                                    $row_rsodestship_country = mysql_fetch_assoc($rsodestship_country);
                                    $totalRows_rsodestship_country = mysql_num_rows($rsodestship_country);
                                    do {
                                        ?>
                                        <option value="<?php echo $row_rsodestship_country['relationship']; ?>" <?php if ($row_rsodest_patient['referer_relationship'] == $row_rsodestship_country['relationship']) { ?>selected="selected"<?php } ?>><?php echo $row_rsodestship_country['relationship'] ?></option>
                                        <?php
                                    } while ($row_rsodestship_country = mysql_fetch_assoc($rsodestship_country));
                                    $rows = mysql_num_rows($rsodestship_country);
                                    if ($rows > 0) {
                                        mysql_data_seek($rsodestship_country, 0);
                                        $row_rsodestship_country = mysql_fetch_assoc($rsodestship_country);
                                    }
                                    ?>
                                </select> 
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group hide">
                                <label class="control-label">Old Card No</label>
                                <input type="text" name="oldcard" id="oldcard" class="form-control" value="<?php echo $row_rsodest_patient['old_card_no']; ?>"> </div>
                                <div class="form-group">
                                    <label class="control-label">Other Names</label>
                                    <input type="text" value="<?php echo $row_rsodest_patient['othernames']; ?>" name="othernames" id="othernames" class="form-control"> </div>
                                    <div class="form-group hide">
                                        <label class="control-label">Marital Status</label>
                                        <select name="marital_status" id="marital_status" class="form-control">
                                          <option value="">-------- SELECT -------</option>
                                          <option value="DIVORCED" <?php if($row_rsodest_patient['marital_status']=='DIVORCED'){?> selected="selected" <?php } ?> >DIVORCED</option>
                                          <option value="MARRIED" <?php if($row_rsodest_patient['marital_status']=='MARRIED'){?> selected="selected" <?php } ?>>MARRIED</option>
                                          <option value="SEPARATED" <?php if($row_rsodest_patient['marital_status']=='SEPARATED'){?> selected="selected" <?php } ?>>SEPARATED</option>
                                          <option value="SINGLE" <?php if($row_rsodest_patient['marital_status']=='SINGLE'){?> selected="selected" <?php } ?>>SINGLE</option>
                                          <option value="WIDOW" <?php if($row_rsodest_patient['marital_status']=='WIDOW'){?> selected="selected" <?php } ?>>WIDOW</option>
                                          <option value="WIDOWER" <?php if($row_rsodest_patient['marital_status']=='WIDOWER'){?> selected="selected" <?php } ?>>WIDOWER</option>
                                      </select>
                                  </div>
                                  <div class="form-group">
                                    <label class="control-label">Primary Phone No.</label>
                                    <input type="text" value="<?php echo $row_rsodest_patient['tel'];?>" name="tel" id="tel" class="form-control"> 
                                </div>
                                <div class="form-group">
                                    <label class="control-label">Secondary Phone No.</label>
                                    <input type="text" value="<?php echo $row_rsodest_patient['tel2'];?>" name="tel2" id="tel2" class="form-control"> 
                                </div>
                                <div class="form-group hide">
                                    <label class="control-label">Home Language</label>
                                    <select name="home_language" id="home_language" class="form-control">
                                        <option value="">-------- SELECT -------</option>
                                        <?php
                                        $query_rsodestship_country = "SELECT * FROM home_language order by home_language";
                                        $rsodestship_country = mysql_query($query_rsodestship_country, $courier) or die(mysql_error());
                                        $row_rsodestship_country = mysql_fetch_assoc($rsodestship_country);
                                        $totalRows_rsodestship_country = mysql_num_rows($rsodestship_country);
                                        do {
                                            ?>
                                            <option value="<?php echo $row_rsodestship_country['home_language']; ?>"<?php if ($row_rsodest_patient['home_language'] == $row_rsodestship_country['home_language']) { ?> selected="selected" <?php } ?>><?php echo $row_rsodestship_country['home_language'] ?></option>
                                            <?php
                                        } while ($row_rsodestship_country = mysql_fetch_assoc($rsodestship_country));
                                        $rows = mysql_num_rows($rsodestship_country);
                                        if ($rows > 0) {
                                            mysql_data_seek($rsodestship_country, 0);
                                            $row_rsodestship_country = mysql_fetch_assoc($rsodestship_country);
                                        }
                                        ?>
                                    </select>
                                </div>
                                <div class="form-group hide">
                                    <label class="control-label">Postal Address</label>
                                    <input type="text" name="paddress" id="paddress" class="form-control" value="<?php echo $row_rsodest_patient['postal_address'];?>"/>
                                </div>
                                <div class="form-group">
                                    <label class="control-label">Referred By</label>
                                    <input type="text" name="referred_by" id="referred_by" value="<?php echo $row_rsodest_patient['referred_by'];?>" class="form-control"> 
                                </div>
                                <div class="form-group">
                                    <label class="control-label">Tel of Referer</label>
                                    <input type="text" name="tel_of_referer" id="tel_of_referer" value="<?php echo $row_rsodest_patient['tel_of_referer'];?>" class="form-control"> 
                                </div>
                            </div>
                        </div>
                        
                        
                        
                    </div>
                    
                    <hr>
                    <div class="row">
                        <div class="col-md-12">
                            <div class="col-md-6">
                                <!--<h6 style="font-size:15px;" class="page-title"> Nearest/Family Friend </h6>-->
                                <div class="form-group">
                                    <label class="control-label">Name</label>
                                    <input type="text" value="<?php echo $row_rsodest_patient['next_of_kin_name'];?>" type="text" name="next_of_kin_name" id="next_of_kin_name" class="form-control"> 
                                </div>
                                <div class="form-group">
                                    <label class="control-label">Relationship</label>
                                    <select class="form-control" name="next_of_kin_relationship" id="next_of_kin_relationship">
                                        <option value="">--SELECT--</option>
                                        <?php
                                        $query_rsodestship_country = "SELECT * FROM relationship order by relationship";
                                        $rsodestship_country = mysql_query($query_rsodestship_country, $courier) or die(mysql_error());
                                        $row_rsodestship_country = mysql_fetch_assoc($rsodestship_country);
                                        $totalRows_rsodestship_country = mysql_num_rows($rsodestship_country);
                                        do {
                                            ?>
                                            <option value="<?php echo $row_rsodestship_country['relationship']; ?>" <?php if ($row_rsodest_patient['next_of_kin_relationship'] == $row_rsodestship_country['relationship']) { ?> selected="selected")<?php } ?>><?php echo $row_rsodestship_country['relationship'] ?></option>
<?php
} while ($row_rsodestship_country = mysql_fetch_assoc($rsodestship_country));
$rows = mysql_num_rows($rsodestship_country);
if ($rows > 0) {
    mysql_data_seek($rsodestship_country, 0);
    $row_rsodestship_country = mysql_fetch_assoc($rsodestship_country);
}
?>
</select>
</div>
<div class="form-group">
    <label class="control-label">Tel/Mobile</label>
    <input type="text" value="<?php echo $row_rsodest_patient['next_of_kin_tel'];?>" name="next_of_kin_tel" id="next_of_kin_tel" class="form-control"> 
</div>
<div class="form-group hide">
    <label class="control-label">Address</label>
    <input type="text" name="next_of_kin_address" value="<?php echo $row_rsodest_patient['next_of_kin_address'];?>" id="next_of_kin_address" class="form-control"> 
</div>
</div>

<div class="col-md-6">
    <div class="form-group">
        <label class="control-label">Type of Client</label>
        <select name="type_of_client" id="type_of_client" onchange="showtext(this.value);" class="form-control">
            <option value="">-------- SELECT --------</option>
            <option value="cash" <?php if ($row_rsodest_patient['type_of_client'] == 'cash') { ?>selected="selected"<?php } ?>>CASH</option>
            <option value="insurance" <?php if ($row_rsodest_patient['type_of_client'] == 'insurance') { ?>selected="selected"<?php } ?>>INSURANCE</option>
            <option value="company" <?php if ($row_rsodest_patient['type_of_client'] == 'company') { ?>selected="selected"<?php } ?>>COMPANY</option>
            <option value="staff" <?php if ($row_rsodest_patient['type_of_client'] == 'staff') { ?>selected="selected"<?php } ?>>STAFF</option>
        </select> 
    </div>
    <div id="cashbox" style="display:<?php if($row_rsodest_patient['type_of_client']=='cash'){ echo "block";}else{echo "none";}?>">
        <div class="form-group">
            <label class="control-label">Employer</label>
            <input type="text" value="<?php echo $row_rsodest_patient['employer'];?>" name="employer" id="employer" class="form-control"> 
        </div>
        <div class="form-group">
            <label class="control-label">Occupation</label>
            <input type="text" name="occupation" value="<?php echo $row_rsodest_patient['occupation'];?>" id="occupation" class="form-control"> 
        </div>
    </div>
    <div id="insurance" style="display:<?php if($row_rsodest_patient['type_of_client']=='insurance'){ echo "block";}else{echo "none";}?>">
        <div class="form-group">
            <label class="control-label">Insurance Company</label>
            <select name="insurance_com1" id="insurance_com1" class="form-control">
                <option value="">--Select Insurance Company --</option>
                <?php
                $query_rsodestship_company_name = "SELECT * FROM insurance_company where status='Active' and type='insurance' order by company_name";
                $rsodestship_company_name = mysql_query($query_rsodestship_company_name, $courier) or die(mysql_error());
                $row_rsodestship_company_name = mysql_fetch_assoc($rsodestship_company_name);
                $totalRows_rsodestship_company_name = mysql_num_rows($rsodestship_company_name);
                do {
                    ?>
                    <option value="<?php echo $row_rsodestship_company_name['company_code']; ?>" <?php if ($row_rsodest_patient['insurance_company1'] == $row_rsodestship_company_name['company_code']) {
                        echo "selected";
                    } ?>><?php echo strtoupper($row_rsodestship_company_name['company_name']); ?></option>
                    <?php
                } while ($row_rsodestship_company_name = mysql_fetch_assoc($rsodestship_company_name));
                $rows = mysql_num_rows($rsodestship_company_name);
                if ($rows > 0) {
                    mysql_data_seek($rsodestship_company_name, 0);
                    $row_rsodestship_company_name = mysql_fetch_assoc($rsodestship_company_name);
                }
                ?>
            </select> 
        </div>
        <div class="form-group">
            <label class="control-label">Insurance No.</label>
            <input type="text" value="<?php echo $row_rsodest_patient['insurance_no1']; ?>" name="insurance_no1" id="insurance_no1" class="form-control"> 
        </div>
    </div>
    
    <div id="staff" style="display:<?php if($row_rsodest_patient['type_of_client']=='staff'){ echo "block";}else{echo "none";}?>">
       <div class="form-group">
        <label class="control-label">Staff No.</label>
        <input type="text" name="staff_no" value="<?php echo $row_rsodest_patient['medifem_staff_no']; ?>" id="staff_no" class="form-control"> 
    </div>
</div>

<div id="company" style="display:<?php if($row_rsodest_patient['type_of_client']=='company'){ echo "block";}else{echo "none";}?>">
 <div class="form-group">
    <label class="control-label">Company</label>
    <select name="company_name" id="company_name" class="form-control" >
        <option value="">--Select Company --</option>
        <?php
        $query_rsodestship_company_name = "SELECT * FROM insurance_company where status='Active' and type='company' order by company_name";
        $rsodestship_company_name = mysql_query($query_rsodestship_company_name, $courier) or die(mysql_error());
        $row_rsodestship_company_name = mysql_fetch_assoc($rsodestship_company_name);
        $totalRows_rsodestship_company_name = mysql_num_rows($rsodestship_company_name);
        do {
            ?>
            <option value="<?php echo $row_rsodestship_company_name['company_code']; ?>" <?php if ($row_rsodest_patient['insurance_company1'] == $row_rsodestship_company_name['company_code']) {
                echo "selected";
            } ?>><?php echo strtoupper($row_rsodestship_company_name['company_name']); ?></option>
            <?php
        } while ($row_rsodestship_company_name = mysql_fetch_assoc($rsodestship_company_name));
        $rows = mysql_num_rows($rsodestship_company_name);
        if ($rows > 0) {
            mysql_data_seek($rsodestship_company_name, 0);
            $row_rsodestship_company_name = mysql_fetch_assoc($rsodestship_company_name);
        }
        ?>
    </select>
</div> 
<div class="form-group">
    <label class="control-label">Company Staff No.</label>
    <input type="text" name="staff_no" value="<?php echo $row_rsodest_patient['insurance_no1']; ?>" id="staff_no" class="form-control"> 
</div>
<div class="form-group">
    <label class="control-label">Department Name</label>
    <input type="text" name="department_name" value="<?php echo $row_rsodest_patient['department_name']; ?>" id="department_name" class="form-control"> 
</div>
</div>
</div>

</div>
</div>
</div>
<div class="form-actions right">
    <button type="reset" class="btn default"> Reset </button>
    <a class="btn green" onclick="saveInformation('records_edit_patient','#success_error_info_display','<?php echo $id;?>');return false;"> Save Changes </a>
</div>
</form>
</div>


