Exemplo n.º 1
0
 function display_consults()
 {
     if (func_num_args() > 0) {
         $arg_list = func_get_args();
         $report_date = $arg_list[0];
         $patient_id = $arg_list[1];
         //a handler for the patient ID
         $end_report_date = $arg_list[2];
     }
     $arr_contents = array();
     $sql = "select c.patient_id, c.consult_id, " . "concat(p.patient_lastname, ', ', p.patient_firstname,' ',p.patient_middle) patient_name, " . "round((to_days(c.consult_date)-to_days(p.patient_dob))/365,1) patient_age, " . "p.patient_gender,date_format(c.consult_date,'%Y-%m-%d') as consult_date " . "from m_consult c, m_patient p " . "where c.patient_id = p.patient_id " . "and c.consult_date BETWEEN '{$report_date} 00:00:00' AND '{$end_report_date} 23:59:00' ORDER by c.consult_date ASC";
     $result = mysql_query($sql) or die("Cannot query: 456 " . mysql_error());
     if ($result) {
         if (mysql_num_rows($result)) {
             $header = array('PATIENT ID', 'PATIENT NAME / SEX / AGE', 'CONSULT DATE / ELAPSED TIME', 'ADDRESS', 'BRGY', 'FAMILY ID', 'PHILHEALTH ID', 'VITAL SIGNS', 'COMPLAINTS', 'DIAGNOSIS', 'TREATMENT');
             $contents = array();
             //print "<a href='../chits_query/pdf_reports/dailyservice_report.php'>PRINTER FRIENDLY VERSION</a><br/>";
             print "<b><center>CONSULTS</center></b><br/>";
             print "<table width='1000' cellspacing='0' cellpadding='2' style='border: 1px solid #000000'>";
             print "<tr bgcolor='#FFCC33'>";
             print "<td class='tinylight' valign='middle' align=center><b>{$header['0']}</b></td>";
             print "<td class='tinylight' valign='middle' align=center><b>{$header['1']}</b></td>";
             print "<td class='tinylight' valign='middle' align=center><b>{$header['2']}</b></td>";
             print "<td class='tinylight' valign='middle' align=center><b>{$header['3']}</b></td>";
             print "<td class='tinylight' valign='middle' align=center><b>{$header['4']}</b></td>";
             print "<td class='tinylight' valign='middle' align=center><b>{$header['5']}</b></td>";
             print "<td class='tinylight' valign='middle' align=center><b>{$header['6']}</b></td>";
             print "<td class='tinylight' valign='middle' align=center><b>{$header['7']}</b></td>";
             print "<td class='tinylight' valign='middle' align=center><b>{$header['8']}</b></td>";
             print "<td class='tinylight' valign='middle' align=center><b>{$header['9']}</b></td>";
             print "<td class='tinylight' valign='middle' align=center><b>{$header['10']}</b></td>";
             print "</tr>";
             while (list($pid, $consult_id, $pname, $age, $sex, $consult_date) = mysql_fetch_array($result)) {
                 $inner_record = array();
                 if ($fid = family::get_family_id($pid)) {
                     $addr = family::get_family_address($fid);
                     $barangay_id = family::barangay_id($family_id);
                 } else {
                     $fid = 0;
                     $barangay_id = 0;
                     $addr = family::get_family_address($fid);
                 }
                 $phid = philhealth::get_philhealth_id($pid);
                 $cc = notes::get_complaints($pid, $consult_date);
                 $dx = notes::get_diagnosis_list($pid, $consult_date);
                 $tx = notes::get_plan($pid, $consult_date);
                 $q_brgy = mysql_query("SELECT c.barangay_name FROM m_family_members a, m_family_address b, m_lib_barangay c WHERE a.patient_id='{$pid}' AND a.family_id=b.family_id AND b.barangay_id=c.barangay_id") or die("Cannot query 451 " . mysql_error());
                 list($brgy) = mysql_fetch_array($q_brgy);
                 //for displaying the vitals signs
                 $selvitals = mysql_query("SELECT vitals_weight,vitals_temp,vitals_systolic,vitals_diastolic,vitals_heartrate,\n\t\t    vitals_resprate, a.consult_id FROM m_consult a, m_consult_vitals b WHERE a.patient_id='{$pid}' AND a.consult_date BETWEEN '{$report_date}' AND '{$end_report_date}' AND  a.consult_id=b.consult_id") or die(mysql_error());
                 $sel_elapsed = mysql_query("SELECT date_format(consult_date,'%m/%d/%Y %h:%i %p') as consult_start,date_format(consult_end,'%m/%d/%Y %h:%i %p') as consult_end, round((unix_timestamp(consult_end)-unix_timestamp(consult_date))/60,2) as consult_minutes FROM m_consult WHERE consult_id='{$consult_id}'") or die("Cannot query 531 " . mysql_error());
                 list($start, $end, $elapsed) = mysql_fetch_array($sel_elapsed);
                 $elapsed_time = $this->get_str_elapsed($start, $end, $elapsed);
                 $select_brgy = mysql_query("SELECT barangay_name from m_lib_barangay WHERE barangay_id='{$bgy}'") or die(mysql_error());
                 $resbrgy = mysql_fetch_array($select_brgy);
                 $res_vitals = mysql_fetch_array($selvitals);
                 $bp = empty($res_vitals[vitals_systolic]) && empty($res_vitals[vitals_diastolic]) ? '-' : $res_vitals[vitals_systolic] . '/' . $res_vitals[vitals_diastolic];
                 $count = mysql_num_rows($selvitals);
                 $bgcolor = $bgcolor == "#FFFF99" ? "white" : "#FFFF99";
                 print "<tr bgcolor='{$bgcolor}'>";
                 print "<td class='tinylight' align=center>" . $pid . "</td>";
                 print "<td class='tinylight' align=center>" . $pname . " / " . $sex . " / " . $age . "</td>";
                 print "<td class='tinylight' align=center>" . $elapsed_time . "</td>";
                 print "<td class='tinylight' align=center>" . $addr . "</td>";
                 //print "<td class='tinylight' align=center>".$resbrgy[barangay_name]."</td>";
                 print "<td class='tinylight' align=center>" . $brgy . "</td>";
                 print "<td class='tinylight' align=center>" . ($fid == 0 ? "-" : $fid) . "</td>";
                 print "<td class='tinylight' align=center>" . ($phid == 0 ? "-" : $phid) . "</td>";
                 print "<td class='tinylight' align=center>BP: {$bp},\n\t\t    HR: {$res_vitals['vitals_heartrate']},RR: {$res_vitals['vitals_resprate']},<br>\n\t\t    Wt: {$res_vitals['vitals_weight']} kg,Temp: {$res_vitals['vitals_temp']}</td>";
                 // display the vital signs
                 print "<td class='tinylight' align=center>" . $cc . "</td>";
                 print "<td class='tinylight' align=center>" . $dx . "</td>";
                 print "<td class='tinylight' align=center>" . $tx . "</td>";
                 print "</tr>";
                 $vitals_sign = "BP: " . $bp . ", HR: " . $res_vitals[vitals_heartrate] . ",RR: " . $res_vitals[vitals_resprate] . ", Wt: " . $res_vitals[vitals_weight] . "kg, Temp: " . $res_vitals[vitals_temp];
                 //array_push($inner_record,array($pid,$pname." / ".$sex." / ".$age,$addr,$resbrgy[barangay_name],$brgy,$fid,$phid,'BP: '.$bp.', '.
                 //'HR: '.$res_vitals[vitals_heartrate].', RR: '. $res_vitals[vitals_resprate].', Wt:' $res_vitals[vitals_weight] kg.', Temp:'. $res_vitals[vitals_temp],$cc,$dx,$tx));
                 array_push($inner_record, array($pid, $pname . " / " . $sex . " / " . $age, $elapsed_time, $addr, $brgy, $fid, $phid, $vitals_sign, $cc, $dx, $tx));
                 array_push($contents, $inner_record);
             }
             print "</table>";
             $_SESSION[tbl_header] = $header;
             $_SESSION[daily_service_contents] = $contents;
             $_SESSION[record_count] = mysql_num_rows($result);
             array_push($arr_contents, $header, $contents, mysql_num_rows($result));
         }
     }
     return $arr_contents;
 }
    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);
                }
            }
        }
    }
Exemplo n.º 3
0
    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);
        $report_date = $year.'-'.$month.'-'.str_pad($day, 2, "0", STR_PAD_LEFT);
        
        list($end_month, $end_day, $end_year) = explode("/", $post_vars["end_report_date"]);
        //$end_report_date = $end_year."-".str_pad($end_month, 2, "0", STR_PAD_LEFT)."-".str_pad($day, 2, "0", STR_PAD_LEFT);
        $end_report_date = $end_year.'-'.$end_month.'-'.str_pad($end_day, 2, "0", STR_PAD_LEFT);
        
        $_SESSION[report_date] = $report_date;
        $_SESSION[end_report_date] = $end_report_date;
        
        // 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')"; */
        
        
        $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 c.consult_date BETWEEN '$report_date' AND '$end_report_date'";
        
        $result_patient = mysql_query($sql_patient) or die("Cannot query: 305 ".mysql_error());
                        
        if ($result_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_id = family::barangay_id($family_id);
                    } else {
                        $family_id = 0;
                        $barangay_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"]);
		    $philhealth_id = philhealth::get_philhealth_id($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, philhealth_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_id', '$family_id', '$philhealth_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, philhealth_id, service_given, vaccine_given, service_date) values ".
					  "('".$patient["patient_id"]."', '".$patient["patient_name"]."', ". 
					  "'".$patient["patient_gender"]."', '".$patient["patient_age"]."', ".
					  "'$patient_address', '$barangay_id', '$family_id', '$philhealth_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, philhealth_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_id', '$family_id', '$philhealth_id', ".
					  "'$visit_seq', '$services', '$vaccines', '$report_date')";
			    $result_insert = mysql_query($sql_insert);
			}
		    }
                }
                /*$sql = "select patient_id 'PATIENT ID', concat(patient_name,' / ',patient_gender,' / ',patient_age) ".
                       "'NAME / SEX / AGE', patient_address 'ADDRESS', patient_bgy 'BRGY', family_id 'FAMILY ID', ".  
                       "philhealth_id 'PHILHEALTH ID', notes_cc 'COMPLAINTS', notes_dx 'DIAGNOSIS', notes_tx 'TREATMENT' ".
                       "from m_consult_report_dailyservice where service_date = '$report_date' order by patient_name ";
                 
                $pdf = new PDF('L','pt','A4');
                $pdf->SetFont('Arial','',12); 
                $pdf->AliasNbPages();
                $pdf->connect('localhost','root','kambing','game');
                $attr=array('titleFontSize'=>14,'titleText'=>'DAILY SERVICE REGISTER - CONSULTS');
		$pdf->mysql_report($sql,false,$attr,"../modules/_uploads/consult_reg.pdf");
		header("location:".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&report_menu=SUMMARY");

                //$sql = "select patient_id 'PATIENT ID', concat(patient_name,' / ',patient_gender,' / ',patient_age) ".
                //       "'NAME / SEX / AGE', patient_address 'ADDRESS', patient_bgy 'BRGY', family_id 'FAMILY ID', ".  
                //       "philhealth_id 'PHILHEALTH ID', vaccine_given 'VACCINE(S) GIVEN', service_given 'SERVICE(S) GIVEN' "
                //       "from m_consult_ccdev_report_dailyservice where service_date = '$report_date' order by patient_name ";
        
                //$pdf = new PDF('L','pt','A4');
                //$pdf->SetFont('Arial','',12); 
                //$pdf->AliasNbPages();
                //$pdf->connect('localhost','root','kambing','game');
                //$attr=array('titleFontSize'=>14,'titleText'=>'DAILY SERVICE REGISTER - CHILD CARE SERVICES');
		//$pdf->mysql_report($sql,false,$attr,"../modules/_uploads/consult_ccdev_reg.pdf");
		//header("location:".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&report_menu=SUMMARY");

                $sql = "select patient_id 'PATIENT ID', concat(patient_name,' / ',patient_gender,' / ',patient_age) ".
                       "'NAME / SEX / AGE', aog_weeks 'AOG (wks)', postpartum_weeks 'POSTPARTUM WK', ". 
                       "patient_address 'ADDRESS', patient_bgy 'BRGY', family_id 'FAMILY ID', ".
                       "philhealth_id 'PHILHEALTH ID', visit_sequence 'VISIT SEQ.', vaccine_given 'VACCINE(S) GIVEN', ".
                       "service_given 'SERVICE(S) GIVEN' ".
                       "from m_consult_mc_report_dailyservice where service_date = '$report_date' order by patient_name ";

                $pdf = new PDF('L','pt','A4');
                $pdf->SetFont('Arial','',12); 
                $pdf->AliasNbPages();
                $pdf->connect('localhost','root','kambing','game');
                $attr=array('titleFontSize'=>14,'titleText'=>'DAILY SERVICE REGISTER - MATERNAL CARE SERVICES');
		$pdf->mysql_report($sql,false,$attr,"../modules/_uploads/consult_mc_reg.pdf");
		header("location:".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&report_menu=SUMMARY");
                */
            }
        }

	//STEP 3. display daily service report
	print "<br/>";
	print "<b>DAILY SERVICE REPORT</b><br/>";
	print "REPORT DATE : <b>".$post_vars["report_date"]." to ".$post_vars["end_report_date"]."</b><br/><br/>";
	$this->display_consults($report_date,"patient_id",$end_report_date); //pass the report_date and patient_id
	$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 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}";
 }