Пример #1
0
 public function generateArray($value)
 {
     if ($value == "General") {
         $columntype = array("Patients" => "Patients");
     }
     if ($value == "Marital Status") {
         $columntype = array("Married" => "Married", "Cohabit" => "Cohabit", "Single-never married" => "Single-never married", "Widowed" => "Widowed", "Separated/Divorced" => "Separated/Divorced");
     }
     if ($value == "HIV Status") {
         $columntype = array('' => 'Unknown', 'Negative' => 'Negative', 'Positive' => 'Positive');
     }
     if ($value == "CD4 Count") {
         $columntype = array('0-200' => '0-200', '200-400' => '200-400', '400-600' => '400-600', '600-1000' => '600-1000', '1000-1500' => '1000-1500');
     }
     if ($value == "HIV Test  Results") {
         $columntype = array('test' => 'Tests', 'Positive' => 'Positive', 'Negative' => 'Negative');
     }
     if ($value == "Decline Reason") {
         $columntype = array('Counselling not offered' => 'Counselling not offered', 'Patient declined test' => 'Patient declined test', 'Test kits shortage' => 'Test kits shortage', 'Other' => 'Other');
     }
     if ($value == "Pap Smear Findings") {
         $columntype = PapsmearResult::all()->lists('name', 'id');
     }
     if ($value == "Pap Smear Status") {
         $columntype = array('yes' => 'Pap Smear Done', 'no' => 'Pap Smear Not Done');
     }
     if ($value == "Colposcopy Findings") {
         $columntype = ColposcopyResult::all()->lists('name', 'id');
     }
     if ($value == "Colposcopy Status") {
         $columntype = array('yes' => 'Colposcopy Done', 'no' => 'Colposcopy Not Done');
     }
     if ($value == "Contraceptive History") {
         $columntype = array('yes' => 'Using Contraceptive', 'no' => 'Not Using Contraceptive');
     }
     if ($value == "Via Counseling") {
         $columntype = array('no' => 'Counseling Not Done', 'yes' => 'Counseling Done');
     }
     if ($value == "Via Tests") {
         $columntype = array('yes' => 'Test Done', 'no' => 'Test Not Done');
     }
     if ($value == "Via Test Result") {
         $columntype = array('Normal cervix (Negative)' => 'Normal cervix (Negative)', 'Abnormal cervix (Positive)' => 'Abnormal cervix (Positive)');
     }
     if ($value == "Via No Test Reason") {
         $columntype = array('SCJ not seen' => 'SCJ not seen', 'Heavy menses' => 'Heavy menses', 'Suspicious of cancer' => 'Suspicious of cancer', 'Massive endocervical discharge (cervicitis)' => 'Massive endocervical discharge (cervicitis)', 'pregnancy' => 'pregnancy');
     }
     if ($value == "Contraceptive Type") {
         $columntype = ContraceptiveResult::all()->lists('name', 'id');
     }
     if ($value == "Menarche") {
         $columntype = array('8-10' => '8-10', '10-12' => '10-12', '12-14' => '12-14', '14-16' => '14-16', '16-18' => '18-20', '20-30' => '20-30', '30-40' => '30-40');
     }
     if ($value == "Total Number of Pregnancy") {
         $columntype = array('0-2' => '0-2', '4-6' => '4-6', '6-8' => '6-8', '8-10' => '8-10', '10-12' => '10-12', '12-14' => '12-14', '14-16' => '14-16');
     }
     if ($value == "Parity") {
         $columntype = array('0-2' => '0-2', '4-6' => '4-6', '6-8' => '6-8', '8-10' => '8-10', '10-12' => '10-12', '12-14' => '12-14', '14-16' => '14-16');
     }
     if ($value == "Number of sexual partners") {
         $columntype = array('0-2' => '0-2', '4-6' => '4-6', '6-8' => '6-8', '8-10' => '8-10', '10-12' => '10-12', '12-14' => '12-14', '14-16' => '14-16');
     }
     if ($value == "Age At first Marriage") {
         $columntype = array('8-15' => '8-15', '15-20' => '15-20', '20-22' => '20-22', '22-24' => '22-24', '24-26' => '24-26', '26-30' => '26-30', '30-40' => '30-40', '40-50' => '40-50');
     }
     if ($value == "Age At Sexual Debut") {
         $columntype = array('0-8' => '0-8', '8-15' => '8-15', '15-20' => '15-20', '20-22' => '20-22', '22-24' => '22-24', '24-26' => '24-26', '26-30' => '26-30', '30-40' => '30-40', '40-50' => '40-50');
     }
     return $columntype;
 }
    public function makeLine()
    {
        $title = "";
        $pat = false;
        $row = "categories: [";
        $column = "";
        if (Input::get("show") == "Findings") {
            $columntype = ColposcopyResult::all()->lists('name', 'id');
        } elseif (Input::get("show") == "Colposcopy Status") {
            $columnhistory = array('yes' => 'Colposcopy Done', 'no' => 'Colposcopy Not Done');
        }
        if (Input::get("vertical") == "Patients") {
            $pat = true;
        } 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', ColposcopyStatus::where('result_id', $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', ColposcopyStatus::where('result_id', $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($columnhistory)) {
                foreach ($columnhistory 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', ColposcopyStatus::where('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', ColposcopyStatus::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($columnhistory) ? "]}," : "]}";
                    $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', ColposcopyStatus::where('result_id', $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', ColposcopyStatus::where('result_id', $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($columnhistory)) {
                foreach ($columnhistory 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);
                        if ($pat) {
                            $que = $query[0]->whereIn('id', ColposcopyStatus::where('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', ColposcopyStatus::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($columnhistory) ? "]}," : "]}";
                    $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', ColposcopyStatus::where('result_id', $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($columnhistory)) {
                foreach ($columnhistory 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[0]->whereIn('id', ColposcopyStatus::where('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($columnhistory) ? "]}," : "]}";
                    $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 
    }