function generate_summary() { if (func_num_args()>0) { $arg_list = func_get_args(); $menu_id = $arg_list[0]; $post_vars = $arg_list[1]; $get_vars = $arg_list[2]; $validuser = $arg_list[3]; $isadmin = $arg_list[4]; //print_r($arg_list); } list($month, $day, $year) = explode("/", $post_vars["report_date"]); $report_date = $year."-".str_pad($month, 2, "0", STR_PAD_LEFT)."-".str_pad($day, 2, "0", STR_PAD_LEFT); // STEP 1. empty report table for given date print $sql_delete = "delete from m_consult_report_dailyservice where service_date = '$report_date'"; $result_delete = mysql_query($sql_delete); // STEP 2. get all consults for specified report date // records are unique for patient_id and service_date $sql_patient = "select c.patient_id, concat(p.patient_lastname, ', ', p.patient_firstname) patient_name, ". "round((to_days(c.consult_date)-to_days(p.patient_dob))/365,2) patient_age, ". "p.patient_gender ". "from m_consult c, m_patient p ". "where c.patient_id = p.patient_id ". "and to_days(c.consult_date) = to_days('$report_date')"; if ($result_patient = mysql_query($sql_patient)) { if (mysql_num_rows($result_patient)) { while ($patient = mysql_fetch_array($result_patient)) { // get family and address if ($family_id = family::get_family_id($patient["patient_id"])) { $patient_address = family::get_family_address($family_id); $barangay_name = family::barangay_name($family_id); } else { $family_id = 0; $patient_address = reminder::get_home_address($patient_id); $barangay_name = reminder::get_barangay($patient_id); } // get chief complaint from notes $complaints = notes::get_complaints($patient["patient_id"], $report_date); // get notes dx list or icd10 list if (!$dx_list = icd10::get_icd10_list($patient["patient_id"], $report_date)) { $dx_list = notes::get_diagnosis_list($patient["patient_id"], $report_date); } // get treatment data from notes $plans = notes::get_plan($patient["patient_id"], $report_date); $sql_insert = "insert into m_consult_report_dailyservice (patient_id, patient_name, patient_gender, ". "patient_age, patient_address, patient_bgy, family_id, notes_cc, notes_dx, notes_tx, service_date) ". "values ('".$patient["patient_id"]."', '".$patient["patient_name"]."', ". "'".$patient["patient_gender"]."', '".$patient["patient_age"]."', ". "'$patient_address', '$barangay_name', '$family_id', '$complaints', ". "'$dx_list', '$plans', '$report_date')"; $result_insert = mysql_query($sql_insert); } } } }
function generate_summary() { if (func_num_args() > 0) { $arg_list = func_get_args(); $menu_id = $arg_list[0]; $post_vars = $arg_list[1]; $get_vars = $arg_list[2]; $validuser = $arg_list[3]; $isadmin = $arg_list[4]; //print_r($arg_list); } list($month, $day, $year) = explode("/", $post_vars["report_date"]); $report_date = $year . "-" . str_pad($month, 2, "0", STR_PAD_LEFT) . "-" . str_pad($day, 2, "0", STR_PAD_LEFT); // STEP 1. empty report tables for given date $sql_delete = "delete from m_consult_report_dailyservice where service_date = '{$report_date}'"; $result_delete = mysql_query($sql_delete); $sql_delete = "delete from m_consult_ccdev_report_dailyservice where service_date = '{$report_date}'"; $result_delete = mysql_query($sql_delete); $sql_delete = "delete from m_consult_mc_report_dailyservice where service_date = '{$report_date}'"; $result_delete = mysql_query($sql_delete); // STEP 2. get all consults for specified report date // records are unique for patient_id and service_date $sql_patient = "select c.patient_id, c.consult_id, " . "concat(p.patient_lastname, ', ', p.patient_firstname) patient_name, " . "round((to_days(c.consult_date)-to_days(p.patient_dob))/365,2) patient_age, " . "p.patient_gender " . "from m_consult c, m_patient p " . "where c.patient_id = p.patient_id " . "and to_days(c.consult_date) = to_days('{$report_date}')"; if ($result_patient = mysql_query($sql_patient)) { if (mysql_num_rows($result_patient)) { while ($patient = mysql_fetch_array($result_patient)) { // get family and address if ($family_id = family::get_family_id($patient["patient_id"])) { $patient_address = family::get_family_address($family_id); $barangay_name = family::barangay_name($family_id); } else { $family_id = 0; $patient_address = reminder::get_home_address($patient_id); $barangay_name = reminder::get_barangay($patient_id); } // get chief complaint and diagnosis from notes $complaints = notes::get_complaints($patient["patient_id"], $report_date); $diagnosis = notes::get_diagnosis_list($patient["patient_id"], $report_date); $treatment = notes::get_plan($patient["patient_id"], $report_date); //get vaccines $vaccines = $this->get_vaccines($patient["patient_id"], $report_date); $services = $this->get_services($patient["consult_id"], $patient["patient_id"], $report_date); $ptgroup = $this->get_ptgroup($patient["consult_id"], $report_date); $aog = $this->get_aog($patient["patient_id"], $report_date); $visit_seq = healthcenter::get_total_visits($patient["patient_id"]); if ($mc_id = mc::registry_record_exists($patient["patient_id"])) { $pp_weeks = mc::get_pp_weeks($mc_id, $patient["consult_id"]); //$visit_sequence = mc::get_ppvisit_sequence($mc_id, $patient["consult_id"]); } if ($complaints != '' || $diagnosis != '' || $treatment != '') { $sql_insert = "insert into m_consult_report_dailyservice (patient_id, patient_name, " . "patient_gender, patient_age, patient_address, patient_bgy, family_id, " . "notes_cc, notes_dx, notes_tx, service_date) values " . "('" . $patient["patient_id"] . "', '" . $patient["patient_name"] . "', " . "'" . $patient["patient_gender"] . "', '" . $patient["patient_age"] . "', " . "'{$patient_address}', '{$barangay_name}', '{$family_id}', " . "'{$complaints}', '{$diagnosis}', '{$treatment}', '{$report_date}')"; $result_insert = mysql_query($sql_insert); } if ($vaccines != '' || $services != '') { if ($ptgroup == 'CHILD') { $sql_insert = "insert into m_consult_ccdev_report_dailyservice (patient_id, " . "patient_name, patient_gender, patient_age, patient_address, patient_bgy, " . "family_id, service_given, vaccine_given, service_date) values " . "('" . $patient["patient_id"] . "', '" . $patient["patient_name"] . "', " . "'" . $patient["patient_gender"] . "', '" . $patient["patient_age"] . "', " . "'{$patient_address}', '{$barangay_name}', '{$family_id}', " . "'{$services}', '{$vaccines}', '{$report_date}')"; $result_insert = mysql_query($sql_insert); } if ($ptgroup == 'MATERNAL') { $sql_insert = "insert into m_consult_mc_report_dailyservice (patient_id, " . "patient_name, patient_gender, patient_age, aog_weeks, postpartum_weeks, patient_address, " . "patient_bgy, family_id, visit_sequence, service_given, vaccine_given, " . "service_date) values " . "('" . $patient["patient_id"] . "', '" . $patient["patient_name"] . "', " . "'" . $patient["patient_gender"] . "', '" . $patient["patient_age"] . "', " . "'{$aog}', '{$pp_weeks}', '{$patient_address}', '{$barangay_name}', '{$family_id}', '{$visit_seq}', " . "'{$services}', '{$vaccines}', '{$report_date}')"; $result_insert = mysql_query($sql_insert); } } } } } //STEP 3. display daily service report print "<br/>"; print "<b>DAILY SERVICE REPORT</b><br/>"; print "REPORT DATE : <b>" . $post_vars["report_date"] . "</b><br/><br/>"; $this->display_consults($report_date); $this->display_ccdev($report_date); $this->display_mc($report_date); $sql = "select count(distinct(patient_id)) from m_consult where " . "to_days(consult_date) = to_days('{$report_date}') and patient_id != '0'"; $result = mysql_result(mysql_query($sql), 0); print "<br/>"; print "Total No. of Today's Patients : {$result}"; }
function process_inclusive_dates() { if (func_num_args()>0) { $arg_list = func_get_args(); $menu_id = $arg_list[0]; $post_vars = $arg_list[1]; $get_vars = $arg_list[2]; $validuser = $arg_list[3]; $isadmin = $arg_list[4]; print_r($arg_list); } // loop through m_consult_disease_notifiable $sql = "select p.patient_id, c.consult_id, concat(p.patient_lastname, ', ', p.patient_firstname) patient_name, c.onset_date, ". "round((to_days(now())-to_days(p.patient_dob))/365 , 1) patient_age, p.patient_gender, c.disease_id ". "from m_consult_disease_notifiable c, m_patient p ". "where c.patient_id = p.patient_id"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { while ($report = mysql_fetch_array($result)) { // blank variables $family_id = 0; $patient_address = ''; $barangay_name = ''; $disease_name = ''; $icd_code = ''; // retrieve other data $family_id = family::get_family_id($report["patient_id"]); if ($family_id) { $patient_address = family::show_address($family_id); $barangay_name = family::barangay_name($family_id); } $disease_name = notifiable::get_notifiable_disease_name($report["disease_id"]); $icd_code = notifiable_report::get_disease_icdcode($report["disease_id"]); // insert data into tcl $sql_insert = "insert into m_patient_notifiable_tcl (consult_id, patient_id, ". "patient_name, onset_date, patient_age, patient_gender, patient_address, ". "barangay_name, diagnosis, icd10) ". "values ('".$report["consult_id"]."', '".$report["patient_id"]."', ". "'".$report["patient_name"]."', '".$report["onset_date"]."', '".$report["patient_age"]."', ". "'".$report["patient_gender"]."', '$patient_address', '$barangay_name', ". "'$disease_name', '$icd_code')"; $result_insert = mysql_query($sql_insert); } // while print $sql = "select patient_name, onset_date, patient_age, patient_gender, ". "patient_address, barangay_name, diagnosis, icd10 ". "from m_patient_notifiable_tcl order by diagnosis"; $pdf = new PDF('P','pt','A4'); $pdf->SetFont('Arial','',10); $pdf->AliasNbPages(); $pdf->connect('localhost','root','kambing','game'); $attr=array('titleFontSize'=>14,'titleText'=>'NOTIFIABLE DISEASE REGISTER'); $pdf->mysql_report($sql,false,$attr, "../modules/_uploads/ntp_tcl.pdf"); header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&report_menu=TCL"); } } }
function process_inclusive_dates() { if (func_num_args() > 0) { $arg_list = func_get_args(); $menu_id = $arg_list[0]; $post_vars = $arg_list[1]; $get_vars = $arg_list[2]; $validuser = $arg_list[3]; $isadmin = $arg_list[4]; //print_r($arg_list); } $sql_delete = "delete from m_patient_notifiable_tcl"; $result_delete = mysql_query($sql_delete) or die(mysql_error()); list($month, $day, $year) = explode("/", $post_vars["start_date"]); $start_date = $year . "-" . str_pad($month, 2, "0", STR_PAD_LEFT) . "-" . str_pad($day, 2, "0", STR_PAD_LEFT); list($month, $day, $year) = explode("/", $post_vars["end_date"]); $end_date = $year . "-" . str_pad($month, 2, "0", STR_PAD_LEFT) . "-" . str_pad($day, 2, "0", STR_PAD_LEFT); // loop through m_consult_disease_notifiable $sql = "select p.patient_id, c.consult_id, " . "concat(p.patient_lastname, ', ', p.patient_firstname) patient_name, c.onset_date, " . "round((to_days(now())-to_days(p.patient_dob))/365 , 1) patient_age, p.patient_gender, " . "c.disease_id from m_consult_disease_notifiable c, m_patient p " . "where c.patient_id = p.patient_id and to_days(c.disease_timestamp) >= to_days('{$start_date}') " . "and to_days(c.disease_timestamp) <= to_days('{$end_date}')"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { while ($report = mysql_fetch_array($result)) { // blank variables $family_id = 0; $patient_address = ''; $barangay_name = ''; $disease_name = ''; $icd_code = ''; // retrieve other data $family_id = family::get_family_id($report["patient_id"]); if ($family_id) { $patient_address = family::show_address($family_id); $barangay_name = family::barangay_name($family_id); } $disease_name = notifiable::get_notifiable_disease_name($report["patient_id"], $report[consult_id]); $icd_code = notifiable_report::get_disease_icdcode($report["patient_id"], $report[consult_id]); // insert data into tcl $sql_insert = "insert into m_patient_notifiable_tcl (consult_id, patient_id, " . "patient_name, onset_date, patient_age, patient_gender, patient_address, " . "barangay_name, diagnosis, icd10) " . "values ('" . $report["consult_id"] . "', '" . $report["patient_id"] . "', " . "'" . $report["patient_name"] . "', '" . $report["onset_date"] . "', '" . $report["patient_age"] . "', " . "'" . $report["patient_gender"] . "', '{$patient_address}', '{$barangay_name}', " . "'{$disease_name}', '{$icd_code}')"; $result_insert = mysql_query($sql_insert); } // while $sql = "select concat(patient_name,' / ',patient_gender,' / ',patient_age) " . "'PATIENT NAME / GENDER / AGE', patient_address 'ADDRESS', " . "barangay_name 'BARANGAY', onset_date 'ONSET DATE', " . "diagnosis 'DIAGNOSIS', icd10 'ICD10'" . "from m_patient_notifiable_tcl order by barangay_name, diagnosis"; $pdf = new PDF('P', 'pt', 'A4'); $pdf->SetFont('Arial', '', 10); $pdf->AliasNbPages(); $pdf->connect('localhost', 'root', 'root', 'chits'); $attr = array('titleFontSize' => 14, 'titleText' => 'TARGET CLIENT LIST FOR NOTIFIABLE DISEASES (' . $post_vars["start_date"] . ' - ' . $post_vars["end_date"] . ')'); $pdf->mysql_report($sql, false, $attr, "../modules/_uploads/notifiable_tcl.pdf"); header("location: " . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&menu_id=" . $get_vars["menu_id"] . "&report_menu=TCL"); } } }
function display_appointment_details() { if (func_num_args()>0) { $arg_list = func_get_args(); $menu_id = $arg_list[0]; $post_vars = $arg_list[1]; $get_vars = $arg_list[2]; //print_r($arg_list); } $sql = "select schedule_id, visit_date, consult_id, date_format(schedule_timestamp, '%a %d %b %Y, %h:%i%p') schedule_timestamp, user_id, ". "patient_id, appointment_id, reminder_flag, actual_date, to_days(visit_date)- to_days(actual_date) variance ". "from m_consult_appointments where schedule_id = '".$get_vars["schedule_id"]."'"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { $appt = mysql_fetch_array($result); print "<a name='detail'>"; print "<table width='600' cellpadding='1'><tr valign='top'><td>"; // column 1 print "<form method='post' action='".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&patient_id=".$get_vars["patient_id"]."&schedule_id=".$appt["schedule_id"]."&year=".$get_vars["year"]."&month=".$get_vars["month"]."&day=".$get_vars["day"]."&s=0'>"; print "<table width='300' bgcolor='#FFFFCC' cellpadding='3'><tr><td>"; print "<span class='PATIENT'>".strtoupper(patient::get_name($appt["patient_id"]))."</span><br/><br/>"; print "VISIT DATE: <font color='red'><b>".$appt["visit_date"]."</b></font><br/>"; print "ACTUAL DATE: <font color='red'><b>".($appt["actual_date"]=="0000-00-00"?"No visit yet":$appt["actual_date"])."</b></font><br/>"; if ($appt["actual_date"]<>"0000-00-00") { print "VARIANCE, DAYS: ".($appt["variance"]<0?"<font color='red'><b>".$appt["variance"]."</b></font>":$appt["variance"])."<br/>"; } print "REMINDER: ".$appt["reminder_flag"]."<br/>"; print "APPT SET BY: ".user::get_username($appt["user_id"])."<br/><br/>"; print "<span class='boxtitle'>APPT CODE</span><br/> ".appointment::get_appointment_name($appt["appointment_id"])."<br/><br/>"; /* print "<span class='boxtitle'>ACTUAL FOLLOWUP DATE</span><br/>"; if ($injury["injury_date"]) { list($year, $month, $day) = explode("-", $injury["injury_date"]); $injury_date = "$month/$day/$year"; } print "<input type='text' size='15' maxlength='10' class='textbox' name='injury_date' value='".($injury_date?$injury_date:$post_vars["injury_date"])."' style='border: 1px solid #000000'> "; print "<a href=\"javascript:show_calendar4('document.form_consult_injury.injury_date', document.form_consult_injury.injury_date.value);\"><img src='../images/cal.gif' width='16' height='16' border='0' alt='Click Here to Pick up the date'></a><br>"; print "<small>Click on the calendar icon to select date. Otherwise use MM/DD/YYYY format.</small><br>"; print "<br/>"; */ if ($appt["actual_date"]=="0000-00-00") { print "<span class='boxtitle'>".LBL_DEFER_CONSULT."?</span><br/>"; print "<input type='checkbox' name='defer_consult' checked value='1'/> ".INSTR_DEFER_CONSULT."<br/><br/>"; } if ($_SESSION["priv_add"]) { if ($appt["actual_date"]=="0000-00-00") { print "<input type='submit' class='textbox' name='submitsked' value='Arrived' style='border: 1px solid black'/> "; } } if ($_SESSION["priv_delete"]) { print "<input type='submit' class='textbox' name='submitsked' value='Delete' style='border: 1px solid black'/> "; } print "<input type='hidden' name='schedule_id' value='".$get_vars["schedule_id"]."'/>"; print "<input type='hidden' name='consult_patient_id' value='".$appt["patient_id"]."'/>"; print "</td></tr></table></form>"; print "</td><td width='50%'>"; // column 2 // followup history // compute only for those who have followed up print "<b>".LBL_FOLLOW_UP_BEHAVIOR."</b><br/>"; $sql_hx = "select case when (to_days(visit_date)-to_days(actual_date)) >= 0 and actual_date <> '0000-00-00' then 'on time' ". "when (to_days(visit_date)-to_days(actual_date)) < 0 and actual_date <> '0000-00-00' then 'not on time' ". "when actual_date = '0000-00-00' then 'no follow up' ". "end status, count(schedule_id) times, round(avg(to_days(visit_date)-to_days(actual_date)),2) variance ". "from m_consult_appointments ". "where patient_id = ".$appt["patient_id"]." and ". "actual_date <> '0000-00-00' group by status"; if ($result_hx = mysql_query($sql_hx)) { if (mysql_num_rows($result_hx)) { print "<table width='300'>"; print "<tr valign='top'><td class='tinylight'><b>STATUS</b></td><td class='tinylight'><b>FREQUENCY</b></td><td class='tinylight'><b>AVE VARIANCE</b></td></tr>"; while (list($status, $times, $variance) = mysql_fetch_array($result_hx)) { print "<tr valign='top'><td class='tinylight'>$status</td><td class='tinylight'>$times</td><td class='tinylight'>$variance</td></tr>"; } print "</table><br/>"; } else { print "<font color='red'>No records to process</font><br/><br/>"; } } print "<b>".LBL_PATIENT_DETAILS."</b><br/><br/>"; print "<span class='tinylight'>"; print "<b>".FTITLE_FAMILY_INFO."</b><br/>"; $family_id = family::get_family_id($appt["patient_id"]); if ($family_id) { print "FAMILY ID: $family_id<br/>"; print "ADDRESS: ".family::get_family_address($family_id)."<br/>"; print "BARANGAY: ".family::barangay_name($family_id)."<br/>"; print "MEMBERS:<br/>".family::get_family_members($family_id)."<br/>"; } else { print "<font color='red'>No family record.</font><br/><br/>"; } print "<b>".FTITLE_PATIENT_GROUP_HX."</b><br/>"; $sql_ptgroup = "select count(c.ptgroup_id), g.ptgroup_name, g.ptgroup_module, c.ptgroup_id, c.consult_id ". "from m_consult_ptgroup c, m_lib_ptgroup g, m_consult h ". "where g.ptgroup_id = c.ptgroup_id and ". "h.consult_id = c.consult_id and ". "h.patient_id = '".$appt["patient_id"]."' ". "group by c.ptgroup_id"; if ($result = mysql_query($sql_ptgroup)) { if (mysql_num_rows($result)) { while (list($count, $name, $mod, $grp, $cid) = mysql_fetch_array($result)) { print "<img src='../images/arrow_redwhite.gif' border='0'/> "; print "$name: $count ".($count>1?" visits":"visit")."<br/> "; } } else { print "<font color='red'>No records.</font><br/>"; } } print "</span>"; print "</td></tr></table><br/>"; } } }
function process_inclusive_dates() { if (func_num_args() > 0) { $arg_list = func_get_args(); $menu_id = $arg_list[0]; $post_vars = $arg_list[1]; //$start_date = $arg_list[1]; //$end_date = $arg_list[2]; $get_vars = $arg_list[2]; $validuser = $arg_list[3]; $isadmin = $arg_list[4]; //print_r($arg_list); } $sql_delete = "delete from m_patient_epi_tcl"; $result_delete = mysql_query($sql_delete); list($month, $day, $year) = explode("/", $post_vars["start_date"]); $start_date = $year . "-" . str_pad($month, 2, "0", STR_PAD_LEFT) . "-" . str_pad($day, 2, "0", STR_PAD_LEFT); list($month, $day, $year) = explode("/", $post_vars["end_date"]); $end_date = $year . "-" . str_pad($month, 2, "0", STR_PAD_LEFT) . "-" . str_pad($day, 2, "0", STR_PAD_LEFT); // loop through m_consult_vaccine $sql = "select p.patient_id, p.patient_dob, concat(p.patient_lastname, ', ', p.patient_firstname) " . "patient_name, p.patient_mother, " . "date_format(adddate(p.patient_dob, interval 1 year), '%m-%Y') month_reaches_age1, m.fully_immunized_date " . "from m_patient p, m_patient_ccdev m " . "where p.patient_id = m.patient_id and " . "to_days(p.patient_dob) >= to_days('{$start_date}') and " . "to_days(p.patient_dob) <= to_days('{$end_date}') order by p.patient_dob "; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { while ($report = mysql_fetch_array($result)) { // blank variables $family_id = 0; $patient_address = ''; $barangay_name = ''; //$vaccines = ''; //$icd_code = ''; // retrieve other data $family_id = family::get_family_id($report["patient_id"]); if ($family_id) { $patient_address = family::show_address($family_id); $barangay_name = family::barangay_name($family_id); } // insert data into tcl $sql_insert = "insert into m_patient_epi_tcl (patient_id, patient_dob, family_id, patient_name, " . "patient_mother, patient_address, barangay_name, month_reaches_age1, " . "fully_immunized_date) values ('" . $report["patient_id"] . "', " . "'" . $report["patient_dob"] . "', '{$family_id}', '" . $report["patient_name"] . "', " . "'" . $report["patient_mother"] . "', '{$patient_address}', '{$barangay_name}', " . "'" . $report["month_reaches_age1"] . "', '" . $report["fully_immunized_date"] . "')"; $result_insert = mysql_query($sql_insert) or die(mysql_error()); $this->get_vaccine_date($report["patient_id"], $start_date, $end_date); } // while $sql = "select * from m_patient_epi_tcl " . "order by barangay_name, patient_dob "; $pdf = new PDF('L', 'pt', 'Legal'); $pdf->SetFont('Arial', '', 10); $pdf->AliasNbPages(); $pdf->connect('localhost', 'root', 'root', 'lagrosa'); $attr = array('titleFontSize' => 14, 'titleText' => 'EPI REGISTER'); $pdf->mysql_report($sql, false, $attr, "../modules/_uploads/epi_tcl.pdf"); header("location: " . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&menu_id=" . $get_vars["menu_id"] . "&report_menu=TCL"); } } }