public function store_followup($id) { $patient = Patient::find($id); $patient->first_name = Input::get("firstname"); $patient->middle_name = Input::get("middlename"); $patient->last_name = Input::get("lastname"); $patient->birth_date = Input::get("dob"); $patient->hospital_id = Input::get("hosp_no"); $patient->phone = Input::get("phone"); $patient->facility_id = Input::get("facility"); $patient->save(); //adding patient visit info $visit = Visit::create(array("patient_id" => $patient->id, "visit_date" => date('Y-m-d'), "server_status" => 'not', "user" => Auth::user()->firstname . " " . Auth::user()->middlename . " " . Auth::user()->lastname)); //adding address information PatientInfo::create(array("patient_id" => $patient->id, "visit_id" => $visit->id, "hospital_id" => "somenumber", "region" => Input::get("region"), "district" => Input::get("district"), "ward" => Input::get("ward"), "ten_cell_leader" => Input::get("t_cell_leadr"))); //adding gynecological history inforamtion for a visit GynecologicalHistory::create(array("patient_id" => $patient->id, "visit_id" => $visit->id, "parity" => Input::get("parity"), "number_of_pregnancy" => Input::get("number_of_preg"), "menarche" => Input::get("menarche"), "age_at_sexual_debut" => Input::get("start_sex_age"), "marital_status" => Input::get("marital"), "age_at_first_marriage" => Input::get("first_marriage"), "sexual_partner" => Input::get("sexual_partner"), "partner_sexual_partner" => Input::get("partner_sexual_partner"))); //adding contraceptive history ContraceptiveHistory::create(array("patient_id" => $patient->id, "visit_id" => $visit->id, "current_status" => Input::get("current_on_contra"), "current_contraceptive_id" => Input::has("current_contra") ? Input::get("current_contra") : "")); //adding HIV status HivStatus::create(array("patient_id" => $patient->id, "visit_id" => $visit->id, "status" => Input::has("hiv_status") ? Input::get("hiv_status") : "", "test_status" => Input::has("hiv_test_status") ? Input::get("hiv_test_status") : "", "unknown_reason" => Input::has("unknown_reason") ? Input::get("unknown_reason") : "", "years_since_first_diagnosis" => Input::has("year_since_diagnosis") ? Input::get("year_since_diagnosis") : "", "year_of_last_test" => Input::has("last_test") ? Input::get("last_test") : "", "art_status" => Input::has("art_status") ? Input::get("art_status") : "", "current_art_status" => Input::has("current_art_status") ? Input::get("current_art_status") : "", "pitc_offered" => Input::get("test_again") == "yes" ? "yes" : "no", "pitc_agreed" => Input::has("test_again") ? Input::get("test_again") : "", "pitc_result" => Input::has("current_test_result") ? Input::get("current_test_result") : "", "pitc_cd4_count" => Input::has("current_cd4") ? Input::get("current_cd4") : "", "prev_cd4_count" => Input::has("prev_cd4") ? Input::get("prev_cd4") : "")); //adding VIA Status ViaStatus::create(array("patient_id" => $patient->id, "visit_id" => $visit->id, "via_counselling_status" => Input::get("via_counceling"), "via_test_status" => Input::get("via_test"), "reject_reason" => Input::has("via_reason") ? Input::get("via_reason") : "", "via_result" => Input::has("via_results") ? Input::get("via_results") : "")); //adding colposcopy ColposcopyStatus::create(array("patient_id" => $patient->id, "visit_id" => $visit->id, "status" => Input::get("colposcopy_status"), "result_id" => Input::has("colpo_result") ? Input::get("colpo_result") : "")); //adding Pap smear result PapsmearStatus::create(array("patient_id" => $patient->id, "visit_id" => $visit->id, "status" => Input::get("pap_status"), "result_id" => Input::has("pap_result") ? Input::get("pap_result") : "")); //adding intervetion status Intervention::create(array("patient_id" => $patient->id, "visit_id" => $visit->id, "type_id" => Input::has("intervention") ? Input::get("intervention") : "", "indicator_id" => Input::has("indicator") ? Input::get("indicator") : "", "histology_id" => Input::has("histology") ? Input::get("histology") : "", "cancer_id" => Input::has("cancer") ? Input::get("cancer") : "", "grade" => Input::has("hist_grade") ? Input::get("hist_grade") : "", "stages" => Input::has("stages") ? Input::get("stages") : "", "differentiation" => Input::has("differentiation") ? Input::get("differentiation") : "")); $report = PatientReport::where('patient_id', $patient->id)->first(); $report->region = Input::get("region"); $report->district = Input::get("district"); $report->number_of_pregnancy = Input::get("number_of_preg"); $report->marital_status = Input::get("marital"); $report->first_marriage = Input::get("first_marriage"); $report->partners = Input::get("sexual_partner"); $report->partners_partner = Input::get("partner_sexual_partner"); $report->contraceptive_status = Input::get("current_on_contra"); $report->facility_id = Input::get("facility"); if (Input::has("current_contra")) { $report->contraceptive_type = Input::get("current_contra"); } if (Input::has("hiv_status")) { $report->HIV_status = Input::get("hiv_status"); } if (Input::has("current_cd4")) { $report->cd4_count = Input::get("current_cd4"); } elseif (Input::has("prev_cd4")) { $report->cd4_count = Input::has("prev_cd4"); } $report->save(); if (Input::get("next_visit") != "") { Notification::create(array("patient_id" => $patient->id, "message" => "Kumbuka Kwenda katika kituo ulichopimwa mara ya mwisho saratani ya shingo ya kizazi. Tafadhali fika bila kukosa tarehe " . Input::get('next_visit'), "status" => "pending", "phone_number" => $patient->phone, "next_visit" => Input::get('next_visit'))); } Logs::create(array("user_id" => Auth::user()->id, "action" => "Patient followup for " . $patient->first_name . " " . $patient->last_name)); $msg = "Patient followup stored successfull"; return View::make('visit.index', compact('patient', "msg")); }
public function processViaNoTest($patientquery, $visitquery, $value, $title = "") { if ($value != "all") { $title .= " Not Received VIA Test Because " . $value; $patientquery->whereIn('id', ViaStatus::where('reject_reason', $value)->get()->lists('patient_id') + array('0')); $visitquery->whereIn('id', ViaStatus::where('reject_reason', $value)->get()->lists('visit_id') + array('0')); } return array($patientquery, $visitquery, $title); }
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; }
public function makeLine() { $title = ""; $pat = false; $row = "categories: ["; $column = ""; if (Input::get("show") == "VIA Counseling Status") { $columntype = array("yes" => "Via Counseling Done", "no" => "Via Counseling Not Done"); } elseif (Input::get("show") == "VIA Test Status") { $columnhistory = array('yes' => 'VIA Test Done', 'no' => 'VIA Test Not Done'); } elseif (Input::get("show") == "Test Results") { $columnhistory1 = array('Normal cervix (Negative)' => 'Normal cervix (Negative)', 'Abnormal cervix (Positive)' => 'Abnormal cervix (Positive)'); } elseif (Input::get("show") == "Reason") { $columnhistory2 = 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 (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', ViaStatus::where('via_counselling_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', ViaStatus::where('via_counselling_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($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', ViaStatus::where('via_test_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', ViaStatus::where('via_test_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++; } } elseif (isset($columnhistory1)) { foreach ($columnhistory1 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', ViaStatus::where('via_result', $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', ViaStatus::where('via_result', $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++; } } elseif (isset($columnhistory2)) { foreach ($columnhistory2 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', ViaStatus::where('reject_reason', $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', ViaStatus::where('reject_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($columnhistory2) ? "]}," : "]}"; $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', ViaStatus::where('via_counselling_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', ViaStatus::where('via_counselling_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($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', ViaStatus::where('via_test_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', ViaStatus::where('via_test_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++; } } elseif (isset($columnhistory1)) { foreach ($columnhistory1 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', ViaStatus::where('via_result', $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', ViaStatus::where('via_result', $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($columnhistory1) ? "]}," : "]}"; $col++; } } elseif (isset($columnhistory2)) { foreach ($columnhistory2 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', ViaStatus::where('reject_reason', $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', ViaStatus::where('reject_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($columnhistory2) ? "]}," : "]}"; $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', ViaStatus::where('via_counselling_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($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', ViaStatus::where('via_test_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++; } } elseif (isset($columnhistory1)) { foreach ($columnhistory1 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', ViaStatus::where('via_result', $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($columnhistory1) ? "]}," : "]}"; $col++; } } elseif (isset($columnhistory2)) { foreach ($columnhistory2 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', ViaStatus::where('reject_reason', $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($columnhistory2) ? "]}," : "]}"; $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 }