예제 #1
0
 public function processHivCd4Count($patientquery, $visitquery, $value, $title = "")
 {
     if ($value != "all") {
         $arr = explode("-", $value);
         $title .= " With Cd4 Between " . $arr[0] . " And " . $arr[1];
         $patientquery->whereIn('id', HivStatus::where('unknown_reason', $value)->get()->lists('patient_id') + array('0'));
         $visitquery->whereIn('id', HivStatus::where('unknown_reason', $value)->get()->lists('visit_id') + array('0'));
     }
     return array($patientquery, $visitquery, $title);
 }
예제 #2
0
 public function checkCondition($query, $pat, $key1)
 {
     switch (Input::get('show')) {
         case "General":
             $pat ? $que = $query[0]->where('id', '!=', $key1) : ($que = $query[1]->where('id', '!=', $key1));
             break;
         case "Marital Status":
             $pat ? $que = $query[0]->whereIn('id', PatientReport::where('marital_status', $key1)->get()->lists('patient_id') + array('0')) : ($que = $query[1]->whereIn('id', GynecologicalHistory::where('marital_status', $key1)->get()->lists('visit_id') + array('0')));
             break;
         case "HIV Status":
             $pat ? $que = $query[0]->whereIn('id', PatientReport::where('HIV_status', $key1)->get()->lists('patient_id') + array('0')) : ($que = $query[1]->whereIn('id', HivStatus::where('status', $key1)->get()->lists('visit_id') + array('0')));
             break;
         case "HIV Test  Results":
             if ($pat) {
                 $key1 == 'test' ? $que = $query[1]->whereIn('id', HivStatus::where('pitc_agreed', "yes")->get()->lists('visit_id') + array('0')) : ($que = $query[1]->whereIn('id', HivStatus::where('pitc_result', $key1)->get()->lists('visit_id') + array('0')));
             } else {
                 $key1 == 'test' ? $que = $query[1]->whereIn('id', HivStatus::where('pitc_agreed', "yes")->get()->lists('visit_id') + array('0')) : ($que = $query[1]->whereIn('id', HivStatus::where('pitc_result', $key1)->get()->lists('visit_id') + array('0')));
             }
             break;
         case "CD4 Count":
             $arr = explode("-", $key1);
             $pat ? $que = $query[0]->whereIn('id', PatientReport::whereBetween('cd4_count', array($arr[0], $arr[1]))->get()->lists('patient_id') + array('0')) : ($que = $query[1]->whereIn('id', HivStatus::whereBetween('pitc_cd4_count', array($arr[0], $arr[1]))->get()->lists('visit_id') + ContraceptiveHistory::where('current_status', $key1)->get()->lists('visit_id') + array('0')));
             break;
         case "Decline Reason":
             $pat ? $que = $query[0]->whereIn('id', HivStatus::where('unknown_reason', $key1)->get()->lists('patient_id') + array('0')) : ($que = $query[1]->whereIn('id', HivStatus::where('unknown_reason', $key1)->get()->lists('visit_id')));
             break;
         case "Pap Smear Findings":
             $pat ? $que = $query[0]->whereIn('id', PapsmearStatus::where('result_id', $key1)->get()->lists('patient_id') + array('0')) : ($que = $query[1]->whereIn('id', PapsmearStatus::where('result_id', $key1)->get()->lists('visit_id') + array('0')));
             break;
         case "Pap Smear Status":
             $pat ? $que = $query[0]->whereIn('id', PapsmearStatus::where('status', $key1)->get()->lists('patient_id') + array('0')) : ($que = $query[1]->whereIn('id', PapsmearStatus::where('status', $key1)->get()->lists('visit_id') + array('0')));
             break;
         case "Colposcopy Findings":
             $pat ? $que = $query[0]->whereIn('id', ColposcopyStatus::where('result_id', $key1)->get()->lists('patient_id') + array('0')) : ($que = $query[1]->whereIn('id', ColposcopyStatus::where('result_id', $key1)->get()->lists('visit_id') + array('0')));
             break;
         case "Colposcopy Status":
             $pat ? $que = $query[0]->whereIn('id', ColposcopyStatus::where('status', $key1)->get()->lists('patient_id') + array('0')) : ($que = $query[1]->whereIn('id', ColposcopyStatus::where('status', $key1)->get()->lists('visit_id') + array('0')));
             break;
         case "Contraceptive History":
             $pat ? $que = $query[0]->whereIn('id', ContraceptiveHistory::where('previous_status', $key1)->get()->lists('patient_id') + ContraceptiveHistory::where('current_status', $key1)->get()->lists('patient_id') + array('0')) : ($que = $query[1]->whereIn('id', ContraceptiveHistory::where('previous_status', $key1)->get()->lists('visit_id') + ContraceptiveHistory::where('current_status', $key1)->get()->lists('visit_id') + array('0')));
             break;
         case "Contraceptive Type":
             $pat ? $que = $query[0]->whereIn('id', ContraceptiveHistory::where('previous_contraceptive_id', $key1)->get()->lists('patient_id') + ContraceptiveHistory::where('current_contraceptive_id', $key1)->get()->lists('patient_id') + array('0')) : ($que = $query[1]->whereIn('id', ContraceptiveHistory::where('previous_contraceptive_id', $key1)->get()->lists('visit_id') + ContraceptiveHistory::where('current_contraceptive_id', $key1)->get()->lists('visit_id') + array('0')));
             break;
         case "Via Counseling":
             $pat ? $que = $query[0]->whereIn('id', ViaStatus::where('via_counselling_status', $key1)->get()->lists('patient_id') + array('0')) : ($que = $query[1]->whereIn('id', ViaStatus::where('via_counselling_status', $key1)->get()->lists('visit_id') + array('0')));
             break;
         case "Via Tests":
             $pat ? $que = $query[0]->whereIn('id', ViaStatus::where('via_test_status', $key1)->get()->lists('patient_id') + array('0')) : ($que = $query[1]->whereIn('id', ViaStatus::where('via_test_status', $key1)->get()->lists('visit_id') + array('0')));
             break;
         case "Via Test Result":
             $pat ? $que = $query[0]->whereIn('id', ViaStatus::where('via_result', $key1)->get()->lists('patient_id') + array('0')) : ($que = $query[1]->whereIn('id', ViaStatus::where('via_result', $key1)->get()->lists('visit_id') + array('0')));
             break;
         case "Via No Test Reason":
             $pat ? $que = $query[0]->whereIn('id', ViaStatus::where('reject_reason', $key1)->get()->lists('patient_id') + array('0')) : ($que = $query[1]->whereIn('id', ViaStatus::where('reject_reason', $key1)->get()->lists('visit_id') + array('0')));
             break;
         case "Menarche":
             $arr = explode("-", $key1);
             $pat ? $que = $query[0]->whereIn('id', PatientReport::whereBetween('menarche', array($arr[0], $arr[1]))->get()->lists('patient_id') + array('0')) : ($que = $query[1]->whereIn('id', GynecologicalHistory::whereBetween('menarche', array($arr[0], $arr[1]))->get()->lists('visit_id') + array('0')));
             break;
         case "Total Number of Pregnancy":
             $arr = explode("-", $key1);
             $pat ? $que = $query[0]->whereIn('id', PatientReport::whereBetween('number_of_pregnancy', array($arr[0], $arr[1]))->get()->lists('patient_id') + array('0')) : ($que = $query[1]->whereIn('id', GynecologicalHistory::whereBetween('number_of_pregnancy', array($arr[0], $arr[1]))->get()->lists('visit_id') + array('0')));
             break;
         case "Parity":
             $arr = explode("-", $key1);
             $pat ? $que = $query[0]->whereIn('id', PatientReport::whereBetween('parity', array($arr[0], $arr[1]))->get()->lists('patient_id') + array('0')) : ($que = $query[1]->whereIn('id', GynecologicalHistory::whereBetween('parity', array($arr[0], $arr[1]))->get()->lists('visit_id') + array('0')));
             break;
         case "Age At first Marriage":
             $arr = explode("-", $key1);
             $pat ? $que = $query[0]->whereIn('id', PatientReport::whereBetween('first_marriage', array($arr[0], $arr[1]))->get()->lists('patient_id') + array('0')) : ($que = $query[1]->whereIn('id', GynecologicalHistory::whereBetween('age_at_first_marriage', array($arr[0], $arr[1]))->get()->lists('visit_id') + array('0')));
             break;
         case "Number of sexual partners":
             $arr = explode("-", $key1);
             $pat ? $que = $query[0]->whereIn('id', PatientReport::whereBetween('partners', array($arr[0], $arr[1]))->get()->lists('patient_id') + array('0')) : ($que = $query[1]->whereIn('id', GynecologicalHistory::whereBetween('sexual_partner', array($arr[0], $arr[1]))->get()->lists('visit_id') + array('0')));
             break;
         case "Age At Sexual Debut":
             $arr = explode("-", $key1);
             $pat ? $que = $query[0]->whereIn('id', PatientReport::whereBetween('age_at_sexual_debut', array($arr[0], $arr[1]))->get()->lists('patient_id') + array('0')) : ($que = $query[1]->whereIn('id', GynecologicalHistory::whereBetween('age_at_sexual_debut', array($arr[0], $arr[1]))->get()->lists('visit_id') + array('0')));
             break;
     }
     return $que;
 }
예제 #3
0
    public function makeLine()
    {
        $title = "";
        $pat = false;
        $row = "categories: [";
        $column = "";
        if (Input::get("show") == "HIV Status") {
            $columntype = array('Unknown' => 'Unknown', 'Negative' => 'Negative', 'Positive' => 'Positive');
        } elseif (Input::get("show") == "CD4 Count") {
            $columcd4 = array('0' => '0-200', '200' => '200-400', '400' => '400-600', '600' => '600-1000', '1000' => '1000-1500');
        }
        if (Input::get("vertical") == "Patients") {
            $pat = true;
        } elseif (Input::get("show") == "Test  Results") {
            $columresult = array('yes' => 'Tests', 'Positive' => 'Positive', 'Negative' => 'Negative');
        } elseif (Input::get("show") == "Decline Reason") {
            $columreason = array('Counselling not offered' => 'Counselling not offered', 'Patient declined test' => 'Patient declined test', 'Test kits shortage' => 'Test kits shortage', 'Other' => 'Other');
        } elseif (Input::get("vertical") == "Visits") {
            $vis = true;
        }
        if (Input::get("horizontal") == "Year") {
            $row1 = array("01" => "jan", "02" => "feb", "03" => "mar", "04" => "apr", "05" => "may", "06" => "jun", "07" => "jul", "08" => "aug", "09" => "sep", "10" => "oct", "11" => "nov", "12" => "dec");
            $j = 1;
            foreach ($row1 as $value) {
                $row .= $j < count($row1) ? "'" . $value . "'," : "'" . $value . "'";
                $j++;
            }
            $col = 1;
            if (isset($columntype)) {
                foreach ($columntype as $key1 => $value1) {
                    $column .= "{ name: '" . $value1 . "', data: [ ";
                    $i = 1;
                    foreach ($row1 as $key => $value) {
                        $from = Input::get('year') . "-" . $key . "-01";
                        $to = Input::get('year') . "-" . $key . "-31";
                        $patientquery = DB::table('patient');
                        $visitquery = DB::table('visit');
                        $query = $this->processQuery($patientquery, $visitquery);
                        if ($pat) {
                            $que = $query[0]->whereIn('id', PatientReport::where('HIV_status', $key1)->get()->lists('patient_id') + array('0'))->whereBetween('created_at', array($from, $to));
                            $column .= $i < count($row1) ? $que->count() . "," : $que->count();
                        } elseif ($vis) {
                            $que = $query[1]->whereIn('id', HivStatus::where('status', $key1)->get()->lists('visit_id') + array('0'))->whereBetween('created_at', array($from, $to));
                            $column .= $i < count($row1) ? $que->count() . "," : $que->count();
                        }
                        $i++;
                    }
                    $column .= $col < count($columntype) ? "]}," : "]}";
                    $col++;
                }
            } elseif (isset($columcd4)) {
                foreach ($columcd4 as $key1 => $value1) {
                    $arr = explode("-", $value1);
                    $column .= "{ name: '" . $value1 . "', data: [ ";
                    $i = 1;
                    foreach ($row1 as $key => $value) {
                        $from = Input::get('year') . "-" . $key . "-01";
                        $to = Input::get('year') . "-" . $key . "-31";
                        $patientquery = DB::table('patient');
                        $visitquery = DB::table('visit');
                        $query = $this->processQuery($patientquery, $visitquery);
                        if ($pat) {
                            $que = $query[0]->whereIn('id', PatientReport::whereBetween('cd4_count', array($arr[0], $arr[1]))->get()->lists('patient_id') + array('0'))->whereBetween('created_at', array($from, $to));
                            $column .= $i < count($row1) ? $que->count() . "," : $que->count();
                        } elseif ($vis) {
                            $que = $query[1]->whereIn('id', HivStatus::whereBetween('pitc_cd4', array($arr[0], $arr[1]))->get()->lists('visit_id') + ContraceptiveHistory::where('current_status', $key1)->get()->lists('visit_id') + array('0'))->whereBetween('created_at', array($from, $to));
                            $column .= $i < count($row1) ? $que->count() . "," : $que->count();
                        }
                        $i++;
                    }
                    $column .= $col < count($columcd4) ? "]}," : "]}";
                    $col++;
                }
            } elseif (isset($columresult)) {
                $count = 0;
                foreach ($columresult as $key1 => $value1) {
                    $column .= "{ name: '" . $value1 . "', data: [ ";
                    $i = 1;
                    foreach ($row1 as $key => $value) {
                        $from = Input::get('year') . "-" . $key . "-01";
                        $to = Input::get('year') . "-" . $key . "-31";
                        $patientquery = DB::table('patient');
                        $visitquery = DB::table('visit');
                        $query = $this->processQuery($patientquery, $visitquery);
                        $count == 0 ? $que = $query[1]->whereIn('id', HivStatus::where('pitc_agreed', "yes")->get()->lists('visit_id') + array('0'))->whereBetween('created_at', array($from, $to)) : ($que = $query[1]->whereIn('id', HivStatus::where('pitc_result', $key1)->get()->lists('visit_id') + array('0'))->whereBetween('created_at', array($from, $to)));
                        $column .= $i < count($row1) ? $que->count() . "," : $que->count();
                        $i++;
                    }
                    $count++;
                    $column .= $col < count($columresult) ? "]}," : "]}";
                    $col++;
                }
            } elseif (isset($columreason)) {
                foreach ($columreason as $key1 => $value1) {
                    $column .= "{ name: '" . $value1 . "', data: [ ";
                    $i = 1;
                    foreach ($row1 as $key => $value) {
                        $from = Input::get('year') . "-" . $key . "-01";
                        $to = Input::get('year') . "-" . $key . "-31";
                        $patientquery = DB::table('patient');
                        $visitquery = DB::table('visit');
                        $query = $this->processQuery($patientquery, $visitquery);
                        $que = $query[1]->whereIn('id', HivStatus::where('unknown_reason', $key1)->get()->lists('visit_id') + array('0'))->whereBetween('created_at', array($from, $to));
                        $column .= $i < count($row1) ? $que->count() . "," : $que->count();
                        $i++;
                    }
                    $column .= $col < count($columreason) ? "]}," : "]}";
                    $col++;
                }
            }
            $title = Input::get('vertical') . " " . $query[2] . " " . Input::get('Year');
        } elseif (Input::get("horizontal") == "Years") {
            $row1 = range(Input::get('start'), Input::get('end'));
            $j = 1;
            foreach ($row1 as $value) {
                $row .= $j < count($row1) ? "'" . $value . "'," : "'" . $value . "'";
                $j++;
            }
            $col = 1;
            if (isset($columntype)) {
                foreach ($columntype as $key1 => $value1) {
                    $column .= "{ name: '" . $value1 . "', data: [ ";
                    $i = 1;
                    foreach ($row1 as $key => $value) {
                        $from = $value . "-01-01";
                        $to = $value . "-12-31";
                        $patientquery = DB::table('patient');
                        $visitquery = DB::table('visit');
                        $query = $this->processQuery($patientquery, $visitquery);
                        if ($pat) {
                            $que = $query[0]->whereIn('id', PatientReport::where('HIV_status', $key1)->get()->lists('patient_id') + array('0'))->whereBetween('created_at', array($from, $to));
                            $column .= $i < count($row1) ? $que->count() . "," : $que->count();
                        } elseif ($vis) {
                            $que = $query[1]->whereIn('id', HivStatus::where('status', $key1)->get()->lists('visit_id') + array('0'))->whereBetween('created_at', array($from, $to));
                            $column .= $i < count($row1) ? $que->count() . "," : $que->count();
                        }
                        $i++;
                    }
                    $column .= $col < count($columntype) ? "]}," : "]}";
                    $col++;
                }
            } elseif (isset($columcd4)) {
                foreach ($columcd4 as $key1 => $value1) {
                    $arr = explode("-", $value1);
                    $column .= "{ name: '" . $value1 . "', data: [ ";
                    $i = 1;
                    foreach ($row1 as $value) {
                        $from = $value . "-01-01";
                        $to = $value . "-12-31";
                        $patientquery = DB::table('patient');
                        $visitquery = DB::table('visit');
                        $query = $this->processQuery($patientquery, $visitquery);
                        if ($pat) {
                            $que = $query[0]->whereIn('id', PatientReport::whereBetween('cd4_count', array($arr[0], $arr[1]))->get()->lists('patient_id') + array('0'))->whereBetween('created_at', array($from, $to));
                            $column .= $i < count($row1) ? $que->count() . "," : $que->count();
                        } elseif ($vis) {
                            $que = $query[1]->whereIn('id', HivStatus::whereBetween('pitc_cd4', array($arr[0], $arr[1]))->get()->lists('visit_id') + ContraceptiveHistory::where('current_status', $key1)->get()->lists('visit_id') + array('0'))->whereBetween('created_at', array($from, $to));
                            $column .= $i < count($row1) ? $que->count() . "," : $que->count();
                        }
                        $i++;
                    }
                    $column .= $col < count($columcd4) ? "]}," : "]}";
                    $col++;
                }
            } elseif (isset($columresult)) {
                $count = 0;
                foreach ($columresult as $key1 => $value1) {
                    $column .= "{ name: '" . $value1 . "', data: [ ";
                    $i = 1;
                    foreach ($row1 as $value) {
                        $from = $value . "-01-01";
                        $to = $value . "-12-31";
                        $patientquery = DB::table('patient');
                        $visitquery = DB::table('visit');
                        $query = $this->processQuery($patientquery, $visitquery);
                        $count == 0 ? $que = $query[1]->whereIn('id', HivStatus::where('pitc_agreed', "yes")->get()->lists('visit_id') + array('0'))->whereBetween('created_at', array($from, $to)) : ($que = $query[1]->whereIn('id', HivStatus::where('pitc_result', $key1)->get()->lists('visit_id') + array('0'))->whereBetween('created_at', array($from, $to)));
                        $column .= $i < count($row1) ? $que->count() . "," : $que->count();
                        $i++;
                    }
                    $count++;
                    $column .= $col < count($columresult) ? "]}," : "]}";
                    $col++;
                }
            } elseif (isset($columreason)) {
                foreach ($columreason as $key1 => $value1) {
                    $column .= "{ name: '" . $value1 . "', data: [ ";
                    $i = 1;
                    foreach ($row1 as $value) {
                        $from = $value . "-01-01";
                        $to = $value . "-12-31";
                        $patientquery = DB::table('patient');
                        $visitquery = DB::table('visit');
                        $query = $this->processQuery($patientquery, $visitquery);
                        $que = $query[1]->whereIn('id', HivStatus::where('unknown_reason', $key1)->get()->lists('visit_id') + array('0'))->whereBetween('created_at', array($from, $to));
                        $column .= $i < count($row1) ? $que->count() . "," : $que->count();
                        $i++;
                    }
                    $column .= $col < count($columreason) ? "]}," : "]}";
                    $col++;
                }
            }
            $title = Input::get('vertical') . " " . $query[2] . " " . Input::get('Year');
        } elseif (Input::get("horizontal") == "Age Range") {
            //setting the limits
            if (parent::maxAge() % Input::get('age') == 0) {
                $limit = parent::maxAge();
            } else {
                $limit = parent::maxAge() - parent::maxAge() % Input::get('age') + Input::get('age');
            }
            //making a loop for values
            //year iterator
            $k = 0;
            //getting age
            $range = Input::get('age');
            $yeardate = date("Y") + 1;
            $yaerdate1 = $yeardate . "-01-01";
            //creating title
            $j = 1;
            for ($i = $range; $i <= $limit; $i += $range) {
                $row .= $i < $limit ? "'" . $k . " - " . $i . "'," : "'" . $k . " - " . $i . "'";
                $k = $i;
            }
            $col = 1;
            if (isset($columntype)) {
                foreach ($columntype as $key1 => $value1) {
                    $column .= "{ name: '" . $value1 . "', data: [ ";
                    $i = 1;
                    for ($i = $range; $i <= $limit; $i += $range) {
                        //start year
                        $time = $k * 365 * 24 * 3600;
                        $today = date("Y-m-d");
                        $timerange = strtotime($today) - $time;
                        $start = date("Y", $timerange) + 1 . "-01-01";
                        //end year
                        $time1 = $i * 365 * 24 * 3600;
                        $timerange1 = strtotime($today) - $time1;
                        $end = date("Y", $timerange1) . "-01-01";
                        $patientquery = DB::table('patient');
                        $visitquery = DB::table('visit');
                        $query = $this->processQuery($patientquery, $visitquery);
                        $que = $query[0]->whereIn('id', PatientReport::where('HIV_status', $key1)->get()->lists('patient_id') + array('0'))->whereBetween('birth_date', array($end, $start));
                        $column .= $i < $limit ? $que->count() . "," : $que->count();
                        $k = $i;
                    }
                    $column .= $col < count($columntype) ? "]}," : "]}";
                    $col++;
                }
            } elseif (isset($columcd4)) {
                foreach ($columcd4 as $key1 => $value1) {
                    $arr = explode("-", $value1);
                    $column .= "{ name: '" . $value1 . "', data: [ ";
                    for ($i = $range; $i <= $limit; $i += $range) {
                        //start year
                        $time = $k * 365 * 24 * 3600;
                        $today = date("Y-m-d");
                        $timerange = strtotime($today) - $time;
                        $start = date("Y", $timerange) + 1 . "-01-01";
                        //end year
                        $time1 = $i * 365 * 24 * 3600;
                        $timerange1 = strtotime($today) - $time1;
                        $end = date("Y", $timerange1) . "-01-01";
                        $patientquery = DB::table('patient');
                        $visitquery = DB::table('visit');
                        $query = $this->processQuery($patientquery, $visitquery);
                        $que = $query[0]->whereIn('id', PatientReport::whereBetween('cd4_count', array($arr[0], $arr[1]))->get()->lists('patient_id') + array('0'))->whereBetween('birth_date', array($end, $start));
                        $column .= $i < $limit ? $que->count() . "," : $que->count();
                        $k = $i;
                    }
                    $column .= $col < count($columcd4) ? "]}," : "]}";
                    $col++;
                }
            } elseif (isset($columresult)) {
                $count = 0;
                foreach ($columresult as $key1 => $value1) {
                    $column .= "{ name: '" . $value1 . "', data: [ ";
                    for ($i = $range; $i <= $limit; $i += $range) {
                        //start year
                        $time = $k * 365 * 24 * 3600;
                        $today = date("Y-m-d");
                        $timerange = strtotime($today) - $time;
                        $start = date("Y", $timerange) + 1 . "-01-01";
                        //end year
                        $time1 = $i * 365 * 24 * 3600;
                        $timerange1 = strtotime($today) - $time1;
                        $end = date("Y", $timerange1) . "-01-01";
                        $patientquery = DB::table('patient');
                        $visitquery = DB::table('visit');
                        $query = $this->processQuery($patientquery, $visitquery);
                        $count == 0 ? $que = $query[1]->whereIn('id', HivStatus::where('pitc_agreed', "yes")->get()->lists('visit_id') + array('0'))->whereIn('patient_id', Patient::whereBetween('birth_date', array($end, $start))->get()->lists('id') + array('0')) : ($que = $query[1]->whereIn('id', HivStatus::where('pitc_result', $key1)->get()->lists('visit_id') + array('0'))->whereIn('patient_id', Patient::whereBetween('birth_date', array($end, $start))->get()->lists('id') + array('0')));
                        $column .= $i < $limit ? $que->count() . "," : $que->count();
                        $k = $i;
                    }
                    $count++;
                    $column .= $col < count($columresult) ? "]}," : "]}";
                    $col++;
                }
            } elseif (isset($columreason)) {
                foreach ($columreason as $key1 => $value1) {
                    $column .= "{ name: '" . $value1 . "', data: [ ";
                    for ($i = $range; $i <= $limit; $i += $range) {
                        //start year
                        $time = $k * 365 * 24 * 3600;
                        $today = date("Y-m-d");
                        $timerange = strtotime($today) - $time;
                        $start = date("Y", $timerange) + 1 . "-01-01";
                        //end year
                        $time1 = $i * 365 * 24 * 3600;
                        $timerange1 = strtotime($today) - $time1;
                        $end = date("Y", $timerange1) . "-01-01";
                        $patientquery = DB::table('patient');
                        $visitquery = DB::table('visit');
                        $query = $this->processQuery($patientquery, $visitquery);
                        $que = $query[1]->whereIn('id', HivStatus::where('unknown_reason', $key1)->get()->lists('visit_id') + array('0'))->whereIn('patient_id', Patient::whereBetween('birth_date', array($end, $start))->get()->lists('id') + array('0'));
                        $column .= $i < $limit ? $que->count() . "," : $que->count();
                        $k = $i;
                    }
                    $column .= $col < count($columreason) ? "]}," : "]}";
                    $col++;
                }
            }
            $title = Input::get('vertical') . " Age Range " . $query[2] . " ";
        }
        $row .= "]";
        ?>
        <script type="text/javascript">
            $(function () {
                $('#chartarea').highcharts({
                    title: {
                        text: '<?php 
        echo $title;
        ?>
'
                    },
                    xAxis: {
                        <?php 
        echo $row;
        ?>
                    },
                    yAxis: {
                        title: {
                            text: '<?php 
        echo Input::get('vertical');
        ?>
'
                        },
                        plotLines: [{
                            value: 0,
                            width: 1,
                            color: '#808080'
                        }]
                    },
                    tooltip: {
                        valueSuffix: '<?php 
        Input::get('vertical');
        ?>
'
                    },
                    legend: {
                        layout: 'vertical',
                        align: 'right',
                        verticalAlign: 'middle',
                        borderWidth: 0
                    },
                    series: [<?php 
        echo $column;
        ?>
]
                });
            });
        </script>
    <?php 
    }