 
<?php $__env->startSection('title', 'Client Registration Mapping'); ?>
<?php $__env->startSection('content'); ?>  
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>  
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/js/bootstrap-datepicker.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/css/select2.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.7.14/css/bootstrap-datetimepicker.min.css">

<?php 
    $getstatecodedata = DB::table('state_master')->get();
    $getdistrictcodedata = DB::table('district_master')->get();

    $adminstatecode = auth()->user()->state_code;
    $admindistcode = auth()->user()->dist_code;
    $art_centre_code = auth()->user()->art_centre_code;
    $role_name  = auth()->user()->roles->pluck('name');
    if($role_name[0] == "Super Admin" || $role_name[0] == "Admin")
    {
        $getpatregdata = DB::table('patient_register')->get();
    }
    else
    {
        $art_centre_code = explode(', ',$art_centre_code);
        $getpatregdata = DB::table('patient_register')->whereIn('art_centre_code',$art_centre_code)->get();
    }
?>

<div class="container-fluid">
    <div class="page-header">
        <div class="row align-items-end">
            <div class="col-lg-8">
                <div class="page-header-title">
                    <i class="ik ik-edit bg-blue"></i>
                    <div class="d-inline">
                        <h5><?php echo e(__('Client Mapping Form')); ?></h5>
                    </div>
                </div>
            </div>
            <div class="col-lg-4">
                <nav class="breadcrumb-container" aria-label="breadcrumb">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item">
                            <a href="<?php echo e(route('dashboard')); ?>"><i class="ik ik-home"></i></a>
                        </li>
                        <li class="breadcrumb-item"><a href="#"><?php echo e(__('Forms')); ?></a></li>
                    </ol>
                </nav>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-md-7 mx-auto">
            <div class="card">
                <div class="card-header">
                    <div class="col-md-9 pl-0">
                        <h3><?php echo e(__('Client Mapping Form')); ?></h3>
                    </div>
                    <div class="col-md-3 text-right">
                        <a href="<?php echo e('upload-patient-mapping'); ?>" class='btn btn-primary'><?php echo e(__('Import Client Mapping')); ?></a>
                    </div>
                </div>
                <div class="card-body">
                    <form class="forms-sample"  method='POST' <?php if(!empty($showdata)): ?> action="<?php echo e(url('updatepatientmapping')); ?>" <?php else: ?> action="<?php echo e(url('insertpatientmapping')); ?>" <?php endif; ?> name='patientregister'>
                        <?php echo csrf_field(); ?>
                        
                        <?php if(session()->has('error')): ?>
                        <div class="alert alert-danger" role="alert">
                            <?php echo e(session()->get('error')); ?>

                        </div>
                        <?php endif; ?>
                        <?php if(!empty($showdata)): ?>
                        <input type='hidden' name='id' value='<?php echo e($showdata[0]->id); ?>'>
                        <?php endif; ?>

                        <input type="hidden" class="form-control" id="state_code" name='state_code' <?php if(!empty($showdata)){ ?> value='<?php echo e($showdata[0]->state_code); ?>' <?php } else{?> value='<?php echo e(auth()->user()->state_code); ?>'<?php } ?> placeholder="Enter State code" readonly>
                        <input type="hidden" class="form-control" id="dist_code" name='dist_code' <?php if(!empty($showdata)){ ?> value='<?php echo e($showdata[0]->dist_code); ?>' <?php } else{?> value='<?php echo e(auth()->user()->dist_code); ?>'<?php } ?> placeholder="Enter District code" readonly>
                        <input type="hidden" class="form-control" id="emp_code" name='emp_code' <?php if(!empty($showdata)){ ?> value='<?php echo e($showdata[0]->emp_code); ?>' <?php } else{?> value='<?php echo e(auth()->user()->emp_code); ?>'<?php } ?> placeholder="Enter Staff code" readonly>
                        <input type="hidden" class="form-control" id="art_centre_code" name='art_centre_code' <?php if(!empty($showdata)){ ?> value='<?php echo e($showdata[0]->art_centre_code); ?>' <?php } else{?> value='<?php echo e(auth()->user()->art_centre_code); ?>'<?php } ?> placeholder="Enter Staff code" readonly>

                        <?php if(!empty($showdata)): ?>
                        <?php
                        $patdata = DB::table('patient_register')->where('id',$showdata[0]->pat_uid)->first();
                        ?>
                        <?php endif; ?>

                        <div class="form-group">
                            <label for="pat_uid"><?php echo e(__('Client UID')); ?></label>
                            <select name='pat_uid' id='pat_uid' class='form-control' required>
                                <option value="">Select Client UID</option>
                                <?php foreach($getpatregdata as $getpatreg){ ?>
                                 <option value='<?php echo $getpatreg->id; ?>' <?php if(!empty($showdata)): ?><?php echo e($patdata->pat_uid == $getpatreg->pat_uid ? 'selected' : ''); ?> <?php endif; ?>><?php echo $getpatreg->pre_art_reg_num.' | '.$getpatreg->art_reg_num.' | '.$getpatreg->pat_name; ?></option>
                                 <?php } ?>
                            </select>
                        </div>
                        <div class="form-group">
                            <label for="art_centre"><?php echo e(__('ART Center Code')); ?></label>
                            <input type="text" class="form-control" id="art_centre" name='art_centre' <?php if(!empty($showdata)){ ?> value='<?php echo e($patdata->art_centre); ?>' <?php } ?> placeholder="Enter ART Center Name" readonly>
                        </div>
                        <div class="form-group">
                            <label for="art_centre_name"><?php echo e(__('ART Center Name')); ?></label>
                            <input type="text" class="form-control" id="art_centre_name" name='art_centre_name' <?php if(!empty($showdata)){ ?> value='<?php echo e($patdata->art_centre_name); ?>' <?php } ?> placeholder="Enter ART Center Name" readonly>
                        </div>
                        <div class="form-group">
                            <label for="pre_art_reg_num"><?php echo e(__('Pre ART REG Number')); ?></label>
                            <input type="text" class="form-control" id="pre_art_reg_num" name='pre_art_reg_num' <?php if(!empty($showdata)){ ?> value='<?php echo e($patdata->pre_art_reg_num); ?>' <?php } ?> placeholder="Enter Pre ART REG Number" readonly>
                        </div>
                        <div class="form-group">
                            <label for="art_reg_num"><?php echo e(__('ART REG Number')); ?></label>
                            <input type="text" class="form-control" id="art_reg_num" name='art_reg_num' <?php if(!empty($showdata)){ ?> value='<?php echo e($patdata->art_reg_num); ?>' <?php } ?> placeholder="Enter ART REG Number" readonly>                            
                        </div>
                        <div class="form-group">
                            <label for="pat_name"><?php echo e(__('Client Name')); ?></label>
                            <input type="text" class="form-control" id="pat_name" name='pat_name' <?php if(!empty($showdata)){ ?> value='<?php echo e($patdata->pat_name); ?>' <?php } ?> placeholder="Enter Client Name" readonly>
                        </div>
                        <div class="form-group">
                            <label for="pat_age"><?php echo e(__('Client Age')); ?></label>
                            <input type="number" class="form-control" id="pat_age" name='pat_age' <?php if(!empty($showdata)){ ?> value='<?php echo e($patdata->pat_age); ?>' <?php } ?> placeholder="Enter Client Age" readonly>
                        </div>
                        <div class="form-group">
                            <label for="pat_sex"><?php echo e(__('Client Sex')); ?></label>
                            <input type="text" class="form-control" id="pat_sex" name='pat_sex' <?php if(!empty($showdata)){ ?> value='<?php echo e($patdata->pat_sex); ?>' <?php } ?> placeholder="Enter Client Sex" readonly>
                        </div>
                        
                        <div class="form-group">
                            <label for="linelist_date"><?php echo e(__('Linelist Received Date')); ?></label>
                            <div class='input-group date datetimepicker'>
                                <input type='text' id='linelist_date' <?php if(!empty($showdata)): ?> value='<?php echo e($showdata[0]->linelist_date); ?>' <?php endif; ?> class="form-control" name="linelist_date" placeholder="dd-mm-yyyy" required/>
                                <span class="input-group-addon">
                                  <span class="glyphicon glyphicon-calendar"></span>
                                </span>
                            </div>
                        </div>
                        
                        <div class="form-group">
                            <label for="linelist_type"><?php echo e(__('Linelist Type')); ?></label>
                            <select name='linelist_type' id='linelist_type' class='form-control'>
                                <option value="">Select Reason for Calling/Visit</option>
                                <option value='1' <?php if(!empty($showdata)): ?><?php echo e($showdata[0]->linelist_type == 1 ? 'selected' : ''); ?> <?php endif; ?>>Outreach</option>
                                <option value='2' <?php if(!empty($showdata)): ?><?php echo e($showdata[0]->linelist_type == 2 ? 'selected' : ''); ?> <?php endif; ?>>Calling</option>
                                <option value='3' <?php if(!empty($showdata)): ?><?php echo e($showdata[0]->linelist_type == 3 ? 'selected' : ''); ?> <?php endif; ?>>EAC</option>
                            </select>
                        </div>

                        <div class="form-group outreach_outcome">
                            <label for="outreach_outcome"><?php echo e(__('Outcome of Outreach Input')); ?></label>
                            <select name='linelist_reason_1' class='form-control'>
                                <option value="">Select Reason for Outreach/Visit</option>
                                <option value='1' <?php if(!empty($showdata)): ?><?php echo e($showdata[0]->outreach_outcome == 1 ? 'selected' : ''); ?> <?php endif; ?>>LFU</option>
                                <option value='2' <?php if(!empty($showdata)): ?><?php echo e($showdata[0]->outreach_outcome == 2 ? 'selected' : ''); ?> <?php endif; ?>>MIS</option>
                                <option value='3' <?php if(!empty($showdata)): ?><?php echo e($showdata[0]->outreach_outcome == 3 ? 'selected' : ''); ?> <?php endif; ?>>Home Delivery</option>
                                <option value='4' <?php if(!empty($showdata)): ?><?php echo e($showdata[0]->outreach_outcome == 4 ? 'selected' : ''); ?> <?php endif; ?>>VL</option>
                            </select>
                        </div>

                        <div class="form-group calling_outcome">
                            <label for="calling_outcome"><?php echo e(__('Outcome of Calling Input')); ?></label>
                            <select name='linelist_reason_2' class='form-control'>
                                <option value="">Select Reason for Calling/Visit</option>
                                <option value='6' <?php if(!empty($showdata)): ?><?php echo e($showdata[0]->calling_outcome == 6 ? 'selected' : ''); ?> <?php endif; ?>>LFU</option>
                                <option value='7' <?php if(!empty($showdata)): ?><?php echo e($showdata[0]->calling_outcome == 7 ? 'selected' : ''); ?> <?php endif; ?>>MIS</option>
                                <option value='8' <?php if(!empty($showdata)): ?><?php echo e($showdata[0]->calling_outcome == 8 ? 'selected' : ''); ?> <?php endif; ?>>CD4</option>
                                <option value='9' <?php if(!empty($showdata)): ?><?php echo e($showdata[0]->calling_outcome == 9 ? 'selected' : ''); ?> <?php endif; ?>>TLD</option>
                                <option value='10' <?php if(!empty($showdata)): ?><?php echo e($showdata[0]->calling_outcome == 10 ? 'selected' : ''); ?> <?php endif; ?>>Due Date Call</option>
                                <option value='11' <?php if(!empty($showdata)): ?><?php echo e($showdata[0]->calling_outcome == 11 ? 'selected' : ''); ?> <?php endif; ?>>TB Follow up</option>
                            </select>
                        </div>

                        <!-- <div class="form-group eac_outcome">
                            <label for="eac"><?php echo e(__('Outcome of EAC Input')); ?></label>
                            <select name='linelist_reason_3' class='form-control'>
                                <option value="">Select Reason for EAC Input</option>
                                <option value='1' <?php if(!empty($showdata)): ?><?php echo e($showdata[0]->eac == 1 ? 'selected' : ''); ?> <?php endif; ?>>Barrier to Adherence</option>
                                <option value='2' <?php if(!empty($showdata)): ?><?php echo e($showdata[0]->eac == 2 ? 'selected' : ''); ?> <?php endif; ?>>Intervention</option>
                                <option value='3' <?php if(!empty($showdata)): ?><?php echo e($showdata[0]->eac == 3 ? 'selected' : ''); ?> <?php endif; ?>>Adherence</option>
                                <option value='4' <?php if(!empty($showdata)): ?><?php echo e($showdata[0]->eac == 4 ? 'selected' : ''); ?> <?php endif; ?>>Support Provided By Accelarate</option>
                            </select>
                        </div> -->

                        <div class="form-group">
                            <label for="linelist_status"><?php echo e(__('Linelist Status')); ?></label>
                            <input type="text" class="form-control" id="linelist_status" name='linelist_status' <?php if(!empty($showdata)){ ?> value='<?php echo e($showdata[0]->linelist_status); ?>' <?php } else{?> value='Open' <?php } ?> placeholder="Enter Linelist Status" readonly>
                        </div>

                        <br><br>
                        <button type="submit" id="submit" class="btn btn-primary mr-2"><?php echo e(__('Submit')); ?></button>
                        <?php if(empty($showdata)): ?>
                        <a href="<?php echo e('outreach-input-data'); ?>" class="btn btn-light"><?php echo e(__('Cancel')); ?></a>
                        <?php endif; ?>
                      </form>
                </div>
            </div>
        </div>
    </div>
</div>
    
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/js/select2.full.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.15.1/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.7.14/js/bootstrap-datetimepicker.min.js"></script>
<script>  
    $(function() {  
        $("select").select2();

        $('.outreach_outcome').css('display','none');
        $('.calling_outcome').css('display','none');
        $('.eac_outcome').css('display','none');

        var default_date=  new Date();
        $('.datetimepicker').datetimepicker({  
           format: 'DD-MM-YYYY', 
            useCurrent:false, 
            defaultDate: default_date
        });
    });  

    function isNumber(evt)
    {
        evt = (evt) ? evt : window.event;
        var charCode = (evt.which) ? evt.which : evt.keyCode;
        if (charCode > 31 && (charCode < 48 || charCode > 57)) {
            return false;
        }
        return true; 
    }

    $( "#pat_uid" ).change(function() { 
        var pat_uid = $(this).val();
        $.ajax({
            type: "POST",
            url: "<?php echo e(url('checkpatdata')); ?>",
            data: {pat_uid:pat_uid, _token: '<?php echo e(csrf_token()); ?>' },
            dataType: "json",
            success: function(res) { 
                var art_centre = res.showdata.art_centre;
                var art_centre_name = res.showdata.art_centre_name;
                var pre_art_reg_num = res.showdata.pre_art_reg_num;
                var art_reg_num = res.showdata.art_reg_num;
                var pat_name = res.showdata.pat_name;
                var pat_age = res.showdata.pat_age;
                var pat_sex = res.showdata.pat_sex;
                $('#art_centre').val(art_centre);
                $('#art_centre_name').val(art_centre_name);
                $('#pre_art_reg_num').val(pre_art_reg_num);
                $('#art_reg_num').val(art_reg_num);
                $('#pat_name').val(pat_name);
                $('#pat_age').val(pat_age);
                $('#pat_sex').val(pat_sex);
            },
            error: function (jqXHR, exception) {

            }
        });
    });

    $( "#linelist_type" ).change(function() { 
        var linelist_type = $(this).val();
        if(linelist_type == 1)
        {
            $('.outreach_outcome').css('display','block');
            $('.calling_outcome').css('display','none');
            $('.eac_outcome').css('display','none');
        }
        else if(linelist_type == 2)
        {
           $('.calling_outcome').css('display','block'); 
           $('.outreach_outcome').css('display','none'); 
           $('.eac_outcome').css('display','none'); 
        }
        else
        {
            $('.eac_outcome').css('display','block'); 
            $('.calling_outcome').css('display','none'); 
            $('.outreach_outcome').css('display','none'); 
        }
    });
</script>
<?php $__env->startPush('script'); ?>
    <script src="<?php echo e(asset('js/form-components.js')); ?>"></script>
<?php $__env->stopPush(); ?>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.main', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/yrgdmc/public_html/treatment/resources/views/pages/patient-mapping.blade.php ENDPATH**/ ?>