Ejemplo n.º 1
0
 function form_visitdetails() {
 //
 // shows list of patient groups and complaints
 // on the left side under VISIT 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];
         $validuser = $arg_list[3];
         $isadmin = $arg_list[4];
         //print_r($arg_list);
     }
     $patient_id = $this->get_patient_id($get_vars["consult_id"]);
     $age = patient::get_age($patient_id);
     $gender = patient::get_gender($patient_id);
     print "<table width='300'>";
     print "<form action = '".$_SERVER["SELF"]."?page=CONSULTS&menu_id=$menu_id&consult_id=".$get_vars["consult_id"]."&ptmenu=DETAILS' name='form_patient' method='post'>";
     print "<tr valign='top'><td>";
     print "<span class='boxtitle'>".LBL_PTGROUP."</span><br> ";
     print ptgroup::checkbox_ptgroup($age, $gender);
     print "<br>";
     print "</td></tr>";
     /*
     print "<tr valign='top'><td>";
     print "<span class='boxtitle'>".LBL_COMPLAINTCAT."</span><br> ";
     print complaint::checkbox_complaintcat($age, $gender);
     print "<br>";
     print "</td></tr>";
     */
     print "<tr valign='top'><td>";
     print "<span class='boxtitle'>".LBL_SEE_DOCTOR."?</span><br> ";
     print "<input type='radio' name='see_doctor_flag' value='Y'/> Will see physician<br/>";
     print "<input type='radio' name='see_doctor_flag' value='N'/> Will not see physician<br/>";
     print "</td></tr>";
     print "<tr><td>";
     print "<br><input type='submit' value = 'Save Details' class='textbox' name='submitdetails' style='border: 1px solid #000000'><br>";
     print "</td></tr>";
     print "</form>";
     print "</table><br>";
 }
 function form_fp_obs()
 {
     $pxid = healthcenter::get_patient_id($_GET[consult_id]);
     $q_fp = $this->check_fprec();
     $px_gender = patient::get_gender($pxid);
     list($fp_id) = mysql_fetch_array($q_fp);
     if ($px_gender == 'F') {
         if (mysql_num_rows($q_fp) != 0) {
             $sel_obgyn = mysql_query("SELECT fpal,date_format(date_last_delivery,'%m/%d/%Y') as date_delivery,type_last_delivery,date_format(past_menstrual_date,'%m/%d/%Y') as past_mens, duration_bleeding,date_format(last_menstrual_period,'%m/%d/%Y') as lmp FROM m_patient_fp_obgyn_details WHERE fp_id='{$fp_id}'") or die("Cannot query : 1371" . mysql_error());
             if (mysql_num_rows($sel_obgyn) != 0) {
                 list($fpal, $delivery_date, $outcome_name, $past_mens, $duration_bleeding, $patient_lmp) = mysql_fetch_array($sel_obgyn);
             } else {
                 //check if the patient has a maternal record in CHITS
                 echo "<p align='justify'><font size='3' class='boxtitle'>Note: This form is connected to the Maternal Care record of the patient. Default values here are based on most recent MC record entered for this patient.</font>";
                 $q_mc = mysql_query("SELECT obscore_fpal, date_format(delivery_date,'%m/%d/%Y'), outcome_id, date_format(patient_lmp,'%m/%d/%Y') FROM m_patient_mc a WHERE a.patient_id='{$pxid}' ORDER by patient_lmp DESC LIMIT 1") or die("Cannot query 1303: " . mysql_error());
                 $q_fp_obs = mysql_query("SELECT duration_bleeding,date_format(past_menstrual_date,'%m/%d/%Y') FROM m_patient_fp_obgyn_details WHERE fp_id='{$fp_id}'") or die("Cannot query 1312: " . mysql_error());
                 list($duration_bleeding, $past_mens) = mysql_fetch_array($q_fp_obs);
                 if (mysql_num_rows($q_mc) != 0) {
                     list($fpal, $delivery_date, $outcome_id, $patient_lmp) = mysql_fetch_array($q_mc);
                     if ($delivery_date == '0000-00-00') {
                         $delivery_date = '';
                         echo "<br><font size='2' color='red' class='boxtitle'><b>This patient has an existing record in CHITS. Patient is presently pregnant based on records.</b></font>";
                     } else {
                         echo "<br><font size='2' color='red' class='boxtitle'><b>This patient has an existing record in CHITS. Patient's pregnancy and delivery was previously been recorded.</b></font>";
                     }
                     $q_outcome = mysql_query("SELECT outcome_name FROM m_lib_mc_outcome WHERE outcome_id='{$outcome_id}'") or die("Cannot query 1315" . mysql_error());
                     if (mysql_num_rows($q_outcome) != 0) {
                         list($outcome_name) = mysql_fetch_array($q_outcome);
                     } else {
                         $outcome_name = '';
                     }
                 }
                 $q_outcome = mysql_query("SELECT outcome_name FROM m_lib_mc_outcome WHERE outcome_id='{$outcome_id}'") or die("Cannot query 1315" . mysql_error());
                 if (mysql_num_rows($q_outcome) != 0) {
                     list($outcome_name) = mysql_fetch_array($q_outcome);
                 } else {
                     $outcome_name = '';
                 }
             }
             echo "<form action='{$_SERVER['PHP_SELF']}?page={$_GET['page']}&menu_id={$_GET['menu_id']}&consult_id={$_GET['consult_id']}&ptmenu={$_GET['ptmenu']}&module={$_GET['module']}&fp=OBS#obs' method='POST' name='form_fp_obs'>";
             echo "<input type='hidden' name='fp_id' value='{$fp_id}'></input>";
             echo "<a name='obs'></a>";
             echo "<table bgcolor='#66FF66'>";
             echo "<thead><td colspan='2' align='center' bgcolor='#339966' class='whitetext'><b>OBSTECTRICAL HISTORY</b></td></thead>";
             echo "<tr><td class='boxtitle'>Number of Pregnancies (FPAL)</td>";
             echo "<td class='boxtitle'><input type='text' name='txt_fp_fpal' size='3' maxlength='4' value='{$fpal}'></td></tr>";
             echo "<tr><td class='boxtitle'>Date of Last Delivery</td><td><input type='text' name='txt_last_delivery' size='8' maxlength='11' value='{$delivery_date}'>";
             echo "<a href=\"javascript:show_calendar4('document.form_fp_obs.txt_last_delivery', document.form_fp_obs.txt_last_delivery.value);\"><img src='../images/cal.gif' width='16' height='16' border='0' alt='Click here to pick up date'></a>";
             echo "</input></td></tr>";
             echo "<tr><td class='boxtitle'>TYPE OF LAST DELIVERY</td><td><input type='text' name='txt_type_delivery' size='20' value='{$outcome_name}'></td></tr>";
             echo "<tr><td class='boxtitle'>PAST MENSTRUAL PERIOD</td><td><input type='text' name='txt_past_mens' size='8' maxlength='11' value='{$past_mens}'>";
             echo "<a href=\"javascript:show_calendar4('document.form_fp_obs.txt_past_mens', document.form_fp_obs.txt_past_mens.value);\"><img src='../images/cal.gif' width='16' height='16' border='0' alt='Click here to pick up date'></a>";
             echo "</input></td></tr>";
             echo "<tr><td class='boxtitle'>LAST MENSTRUAL PERIOD</td><td><input type='text' name='txt_last_mens' size='8' maxlength='11' value='{$patient_lmp}'>";
             echo "<a href=\"javascript:show_calendar4('document.form_fp_obs.txt_last_mens', document.form_fp_obs.txt_last_mens.value);\"><img src='../images/cal.gif' width='16' height='16' border='0' alt='Click here to pick up date'></a>";
             echo "</input></td></tr>";
             echo "<tr><td class='boxtitle'>Duration and Character of Menstrual Bleeding</td><td><input type='text' name='txt_mens_bleed' size='3' value='{$duration_bleeding}'></input> days</td></tr>";
             echo "<tr><td colspan='2' align='center'><input type='submit' name='submit_fp' value='Save Obstectrical History' style='border: 1px solid #000000'></td></tr>";
             echo "</table>";
             echo "</form>";
         } else {
             $this->no_fp_msg();
         }
     } else {
         echo "<br><br><font color='red'>Obstetrical history is only for female patients</font><br><br>";
     }
 }
Ejemplo n.º 3
0
 function form_fp_obs()
 {
     $pxid = healthcenter::get_patient_id($_GET[consult_id]);
     $q_fp = $this->check_fprec();
     $px_gender = patient::get_gender($pxid);
     if ($px_gender == 'F') {
         if (mysql_num_rows($q_fp) != 0) {
             echo "<form action='{$_SERVER['PHP_SELF']}' method='POST' name='form_fp_obs'>";
             echo "<a name='obs'></a>";
             echo "<table>";
             echo "<thead><td colspan='2'>OBSTETRICAL HISTORY</td></thead>";
             echo "<tr><td>Number of Pregnancies (FPAL)</td>";
             echo "<td><input type='text' name='txt_fp_fpal' size='3' maxlength='4'></td></tr>";
             echo "<tr><td>Date of Last Delivery</td><td><input type='text' name='txt_last_delivery' size='7' maxlength='11'>";
             echo "<a href=\"javascript:show_calendar4('document.form_fp_obs.txt_last_delivery', document.form_fp_obs.txt_last_delivery.value);\"><img src='../images/cal.gif' width='16' height='16' border='0' alt='Click here to pick up date'></a>";
             echo "</input></td></tr>";
             echo "<tr><td>TYPE OF LAST DELIVERY</td><td><input type='text' name='txt_type_delivery' size='10'></td></tr>";
             echo "<tr><td>PAST MENSTRUAL PERIOD</td><td><input type='text' name='txt_past_mens' size='7' maxlength='11'>";
             echo "<a href=\"javascript:show_calendar4('document.form_fp_obs.txt_past_mens', document.form_fp_obs.txt_past_mens.value);\"><img src='../images/cal.gif' width='16' height='16' border='0' alt='Click here to pick up date'></a>";
             echo "</input></td></tr>";
             echo "<tr><td>LAST MENSTRUAL PERIOD</td><td><input type='text' name='txt_last_mens' size='7' maxlength='11'>";
             echo "<a href=\"javascript:show_calendar4('document.form_fp_obs.txt_last_mens', document.form_fp_obs.txt_last_mens.value);\"><img src='../images/cal.gif' width='16' height='16' border='0' alt='Click here to pick up date'></a>";
             echo "</input></td></tr>";
             echo "<tr><td>Duration and Character of Menstrual Bleeding</td><td><input type='text' name='txt_mens_bleed' size='3'></input> days</td></tr>";
             echo "<tr><td colspan='2' align='center'><input type='submit' name='submit_fp' value='Save Obstectrical History'></td></tr>";
             echo "</table>";
             echo "</form>";
         } else {
             $this->no_fp_msg();
         }
     } else {
         echo "<br><br><font color='red'>Obstetrical history is only for female patients</font><br><br>";
     }
 }
Ejemplo n.º 4
0
    function _wtforage() {
    //
    // main method for wtforage
    // caution -> use only for age 5 and below
    // call method:
    // $wt_class = wtforage ($age_month, $gender, $actual_weight);
    // where $age_month = age of patient
    //              can be obtained from m_patient
    //       $gender = patient gender (M or F)
    //                 can be obtained from m_patient
    //       $weight = actual patient weight
    //                 can be obtained from m_consult_vitals
    // $wt_class: BELOW NORMAL (Very Low), BELOW NORMAL (Low), NORMAL, ABOVE NORMAL
    //
        // always check dependencies
        if ($exitinfo = $this->missing_dependencies('wtforage')) {
            return print($exitinfo);
        }
        if (func_num_args()>0) {
            $arg_list = func_get_args();
            $consult_id = $arg_list[0];
		}
        $patient_id = healthcenter::get_patient_id($consult_id);
		$age_month = round((ccdev::get_age_weeks($patient_id))/4.33,0);
		$gender = patient::get_gender($patient_id);
		$actual_weight = wtforage::get_body_weight($consult_id);
        /*
		print $sql = "select wt_class from m_lib_wtforage where age_month='$age_month' AND gender='$gender' ".
		 		"AND weight_min <= '$actual_weight' AND weight_max >= '$actual_weight'";
		if ($result = mysql_query($sql)) {
            if (mysql_num_rows($result)) {
                list($wt_class) = mysql_fetch_array($result);
				return $wt_class;
  		}
        */
        $sql = "select weight_min, weight_max, wt_class ".
               "from m_lib_wtforage ".
               "where age_month = '$age_month' and gender = '$gender'";
        if ($result = mysql_query($sql)) {
            if (mysql_num_rows($result)) {
                while (list($min, $max, $class) = mysql_fetch_array($result)) {
                    if ($max > $min) {
                        if ($actual_weight >= $min && $actual_weight <= $max) {
                            //print "Min $min<br/>";
                            //print "Max $max<br/>";
                            //print "Class $class<br/>";
                            $ret_val = array ($min, $max, $class);
                        }
                    }
                    if ($min === $max) {
                        if ($actual_weight >= $max) {
                            //print "Min $min<br/>";
                            //print "Max $max<br/>";
                            //print "Class $class<br/>";
                            $ret_val = array ($min, $max, $class);
                        }
                    }
                }
                return $ret_val;
            }
        }

	}
    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);
        }
        // STEP 1. empty report table
        $sql_delete = "delete from m_consult_disease_notifiable_report";
        $result_delete = mysql_query($sql_delete);

        // STEP 2. insert diseases from lib in report table
        // records are unique for disease_id so you can enter only one set of
        // notifiable diseases for a given start consult date
        $sql_lib = "select disease_id from m_lib_disease_notifiable order by disease_name";
        if ($result_lib = mysql_query($sql_lib)) {
            if (mysql_num_rows($result_lib)) {
                while (list($disease_id) = mysql_fetch_array($result_lib)) {
                    $sql_insert = "insert into m_consult_disease_notifiable_report (disease_id) ".
                                  "values ('$disease_id')";
                    $result_insert = mysql_query($sql_insert);
                }
            }
        }
        // STEP 3. loop through notifiable disease consult records and
        // update report table by disease id and age group
        // start date
        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);
        // end date
        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);

        $sql_consult = "select patient_id, disease_id ".
                       "from m_consult_disease_notifiable ".
                       "where to_days(disease_timestamp) >= to_days('$start_date') and ".
                       "to_days(disease_timestamp) <= to_days('$end_date')";
        if ($result_consult = mysql_query($sql_consult)) {
            if (mysql_num_rows($result_consult)) {
                while (list($patient_id, $disease_id) = mysql_fetch_array($result_consult)) {
                    $patient_age = patient::get_age($patient_id);
                    $gender = patient::get_gender($patient_id);
                    if ($patient_age < 1) {
                        $sql_update = "update m_consult_disease_notifiable_report set ".
                                      $gender."less1 = ".$gender."less1+1 ".
                                      "where disease_id = '$disease_id'";
                        $result_update = mysql_query($sql_update);
                    }
                    if ($patient_age >= 1 && $patient_age <= 4) {
                        $sql_update = "update m_consult_disease_notifiable_report set ".
                                      $gender."_1to4 = ".$gender."_1to4 + 1 ".
                                      "where disease_id = '$disease_id'";
                        $result_update = mysql_query($sql_update);
                    }
                    if ($patient_age >= 5 && $patient_age <= 14) {
                        $sql_update = "update m_consult_disease_notifiable_report set ".
                                      $gender."_5to14 = ".$gender."_5to14 + 1 ".
                                      "where disease_id = '$disease_id'";
                        $result_update = mysql_query($sql_update);
                    }
                    if ($patient_age >= 15 && $patient_age <= 49) {
                        $sql_update = "update m_consult_disease_notifiable_report set ".
                                      $gender."_15to49 = ".$gender."_15to49 + 1 ".
                                      "where disease_id = '$disease_id'";
                        $result_update = mysql_query($sql_update);
                    }
                    if ($patient_age >= 50 && $patient_age <= 64) {
                        $sql_update = "update m_consult_disease_notifiable_report set ".
                                      $gender."_50to64 = ".$gender."_50to64 + 1 ".
                                      "where disease_id = '$disease_id'";
                        $result_update = mysql_query($sql_update);
                    }
                    if ($patient_age >= 65) {
                        $sql_update = "update m_consult_disease_notifiable_report set ".
                                      $gender."_65plus = ".$gender."_65plus + 1 ".
                                      "where disease_id = '$disease_id'";
                        $result_update = mysql_query($sql_update);
                    }
                    $sql_update = "update m_consult_disease_notifiable_report set ".
                                  $gender."_total = ".$gender."_total + 1 ".
                                  "where disease_id = '$disease_id'";
                    $result_update = mysql_query($sql_update);
                }
            }
        }
        // STEP 4. display
        $sql = "select l.disease_name, c.* ".
               "from m_consult_disease_notifiable_report c, m_lib_disease_notifiable l ".
               "where l.disease_id = c.disease_id order by l.disease_name";
        if ($result = mysql_query($sql)) {
            if (mysql_num_rows($result)) {
                print "<br/>";
                print "<b>NOTIFIABLE DISEASE REPORT</b><br/><br/>";
                print "START: ".$post_vars["start_date"]."<br/>";
                print "END: ".$post_vars["end_date"]."<br/><br/>";
                print "<table width='500' cellspacing='0' cellpadding='2' style='border: 1px solid black'>";
                print "<tr bgcolor='#FFCC33'>";
                print "<td class='tinylight' rowspan='2' valign='bottom'><b>DISEASE</b></td>";
                print "<td class='tinylight' colspan='2' width='10%'><b>&lt;1</b></td>";
                print "<td class='tinylight' colspan='2' width='10%'><b>1-4</b></td>";
                print "<td class='tinylight' colspan='2' width='10%'><b>5-14</b></td>";
                print "<td class='tinylight' colspan='2' width='10%'><b>15-49</b></td>";
                print "<td class='tinylight' colspan='2' width='10%'><b>50-64</b></td>";
                print "<td class='tinylight' colspan='2' width='10%'><b>65+</b></td>";
                print "<td class='tinylight' colspan='2' width='10%'><b>TOTAL</b></td>";
                print "</tr>";
                print "<tr bgcolor='#FFCC33'>";
                print "<td class='tinylight'><b>M</b></td>"; // &lt;1
                print "<td class='tinylight'><b>F</b></td>"; // &lt;1
                print "<td class='tinylight'><b>M</b></td>"; // 1-4
                print "<td class='tinylight'><b>F</b></td>"; // 1-4
                print "<td class='tinylight'><b>M</b></td>"; // 5-14
                print "<td class='tinylight'><b>F</b></td>"; // 5-14
                print "<td class='tinylight'><b>M</b></td>"; // 15-49
                print "<td class='tinylight'><b>F</b></td>"; // 15-49
                print "<td class='tinylight'><b>M</b></td>"; // 50-64
                print "<td class='tinylight'><b>F</b></td>"; // 50-64
                print "<td class='tinylight'><b>M</b></td>"; // 65+
                print "<td class='tinylight'><b>F</b></td>"; // 65+
                print "<td class='tinylight'><b>M</b></td>"; // TOTAL
                print "<td class='tinylight'><b>F</b></td>"; // TOTAL
                print "</tr>";
                while ($report = mysql_fetch_array($result)) {
                    $bgcolor=($bgcolor=="#FFFF99"?"white":"#FFFF99");
                    print "<tr bgcolor='$bgcolor'>";
                    print "<td class='tinylight'>".$report["disease_name"]."</td>";
                    print "<td class='tinylight'>".($report["M_less1"]==0?"-":$report["M_less1"])."</td>";
                    print "<td class='tinylight'>".($report["F_less1"]==0?"-":$report["F_less1"])."</td>";
                    print "<td class='tinylight'>".($report["M_1to4"]==0?"-":$report["M_1to4"])."</td>";
                    print "<td class='tinylight'>".($report["F_1to4"]==0?"-":$report["F_1to4"])."</td>";
                    print "<td class='tinylight'>".($report["M_5to14"]==0?"-":$report["M_5to14"])."</td>";
                    print "<td class='tinylight'>".($report["F_5to14"]==0?"-":$report["F_5to14"])."</td>";
                    print "<td class='tinylight'>".($report["M_15to49"]==0?"-":$report["M_15to49"])."</td>";
                    print "<td class='tinylight'>".($report["F_15to49"]==0?"-":$report["F_15to49"])."</td>";
                    print "<td class='tinylight'>".($report["M_50to64"]==0?"-":$report["M_50to64"])."</td>";
                    print "<td class='tinylight'>".($report["F_50to64"]==0?"-":$report["F_50to64"])."</td>";
                    print "<td class='tinylight'>".($report["M_65plus"]==0?"-":$report["F_50to64"])."</td>";
                    print "<td class='tinylight'>".($report["F_65plus"]==0?"-":$report["F_65plus"])."</td>";
                    print "<td class='tinylight'>".($report["M_total"]==0?"-":$report["M_total"])."</td>";
                    print "<td class='tinylight'>".($report["F_total"]==0?"-":$report["F_total"])."</td>";
                    print "</tr>";
                }
                print "</table>";
            }
        }
    }
 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);
     }
     // STEP 1. empty report table
     $sql_delete = "delete from m_consult_injury_report";
     $result_delete = mysql_query($sql_delete);
     // STEP 2. insert injury codes from injury lib in report table
     // records are unique for injury_id so you can enter only one set of
     // notifiable diseases for a given start consult date
     $sql_lib = "select disease_id from m_lib_disease_notifiable order by disease_name";
     if ($result_lib = mysql_query($sql_lib)) {
         if (mysql_num_rows($result_lib)) {
             while (list($disease_id) = mysql_fetch_array($result_lib)) {
                 $sql_insert = "insert into m_consult_disease_notifiable_report (disease_id) " . "values ('{$disease_id}')";
                 $result_insert = mysql_query($sql_insert);
             }
         }
     }
     // STEP 3. loop through notifiable disease consult records and
     // update report table by disease id and age group
     $sql_consult = "select patient_id, disease_id from m_consult_disease_notifiable";
     if ($result_consult = mysql_query($sql_consult)) {
         if (mysql_num_rows($result_consult)) {
             while (list($patient_id, $disease_id) = mysql_fetch_array($result_consult)) {
                 $patient_age = patient::get_age($patient_id);
                 $gender = patient::get_gender($patient_id);
                 if ($patient_age < 1) {
                     $sql_update = "update m_consult_disease_notifiable_report set " . $gender . "less1 = " . $gender . "less1+1 " . "where disease_id = '{$disease_id}'";
                     $result_update = mysql_query($sql_update);
                 }
                 if ($patient_age >= 1 && $patient_age <= 4) {
                     $sql_update = "update m_consult_disease_notifiable_report set " . $gender . "_1to4 = " . $gender . "_1to4 + 1 " . "where disease_id = '{$disease_id}'";
                     $result_update = mysql_query($sql_update);
                 }
                 if ($patient_age >= 5 && $patient_age <= 14) {
                     $sql_update = "update m_consult_disease_notifiable_report set " . $gender . "_5to14 = " . $gender . "_5to14 + 1 " . "where disease_id = '{$disease_id}'";
                     $result_update = mysql_query($sql_update);
                 }
                 if ($patient_age >= 15 && $patient_age <= 49) {
                     $sql_update = "update m_consult_disease_notifiable_report set " . $gender . "_15to49 = " . $gender . "_15to49 + 1 " . "where disease_id = '{$disease_id}'";
                     $result_update = mysql_query($sql_update);
                 }
                 if ($patient_age >= 50 && $patient_age <= 64) {
                     $sql_update = "update m_consult_disease_notifiable_report set " . $gender . "_50to64 = " . $gender . "_50to64 + 1 " . "where disease_id = '{$disease_id}'";
                     $result_update = mysql_query($sql_update);
                 }
                 if ($patient_age >= 65) {
                     $sql_update = "update m_consult_disease_notifiable_report set " . $gender . "_65plus = " . $gender . "_65plus + 1 " . "where disease_id = '{$disease_id}'";
                     $result_update = mysql_query($sql_update);
                 }
                 $sql_update = "update m_consult_disease_notifiable_report set " . $gender . "_total = " . $gender . "_total + 1 " . "where disease_id = '{$disease_id}'";
                 $result_update = mysql_query($sql_update);
             }
         }
     }
     // STEP 4. display
     $sql = "select l.injury_name, c.* " . "from m_consult_injury_report c, m_lib_injury l " . "where l.injury_id = c.injury_id order by l.injury_name";
     if ($result = mysql_query($sql)) {
         if (mysql_num_rows($result)) {
             print "<br/>";
             print "<b>INJURY REPORT</b><br/><br/>";
             print "<table width='500' cellspacing='0' cellpadding='2' style='border: 1px solid black'>";
             print "<tr bgcolor='#FFCC33'>";
             print "<td class='tinylight' rowspan='2' valign='bottom'><b>INJURY</b></td>";
             print "<td class='tinylight' colspan='2' width='10%'><b>&lt;1</b></td>";
             print "<td class='tinylight' colspan='2' width='10%'><b>1-4</b></td>";
             print "<td class='tinylight' colspan='2' width='10%'><b>5-14</b></td>";
             print "<td class='tinylight' colspan='2' width='10%'><b>15-49</b></td>";
             print "<td class='tinylight' colspan='2' width='10%'><b>50-64</b></td>";
             print "<td class='tinylight' colspan='2' width='10%'><b>65+</b></td>";
             print "<td class='tinylight' colspan='2' width='10%'><b>TOTAL</b></td>";
             print "</tr>";
             print "<tr bgcolor='#FFCC33'>";
             print "<td class='tinylight'><b>M</b></td>";
             // &lt;1
             print "<td class='tinylight'><b>F</b></td>";
             // &lt;1
             print "<td class='tinylight'><b>M</b></td>";
             // 1-4
             print "<td class='tinylight'><b>F</b></td>";
             // 1-4
             print "<td class='tinylight'><b>M</b></td>";
             // 5-14
             print "<td class='tinylight'><b>F</b></td>";
             // 5-14
             print "<td class='tinylight'><b>M</b></td>";
             // 15-49
             print "<td class='tinylight'><b>F</b></td>";
             // 15-49
             print "<td class='tinylight'><b>M</b></td>";
             // 50-64
             print "<td class='tinylight'><b>F</b></td>";
             // 50-64
             print "<td class='tinylight'><b>M</b></td>";
             // 65+
             print "<td class='tinylight'><b>F</b></td>";
             // 65+
             print "<td class='tinylight'><b>M</b></td>";
             // TOTAL
             print "<td class='tinylight'><b>F</b></td>";
             // TOTAL
             print "</tr>";
             while ($report = mysql_fetch_array($result)) {
                 $bgcolor = $bgcolor == "#FFFF99" ? "white" : "#FFFF99";
                 print "<tr bgcolor='{$bgcolor}'>";
                 print "<td class='tinylight'>" . $report["injury_name"] . "</td>";
                 print "<td class='tinylight'>" . $report["M_less1"] . "</td>";
                 print "<td class='tinylight'>" . $report["F_less1"] . "</td>";
                 print "<td class='tinylight'>" . $report["M_1to4"] . "</td>";
                 print "<td class='tinylight'>" . $report["F_1to4"] . "</td>";
                 print "<td class='tinylight'>" . $report["M_5to14"] . "</td>";
                 print "<td class='tinylight'>" . $report["F_5to14"] . "</td>";
                 print "<td class='tinylight'>" . $report["M_15to49"] . "</td>";
                 print "<td class='tinylight'>" . $report["F_15to49"] . "</td>";
                 print "<td class='tinylight'>" . $report["M_50to64"] . "</td>";
                 print "<td class='tinylight'>" . $report["F_50to64"] . "</td>";
                 print "<td class='tinylight'>" . $report["M_65plus"] . "</td>";
                 print "<td class='tinylight'>" . $report["F_65plus"] . "</td>";
                 print "<td class='tinylight'>" . $report["M_total"] . "</td>";
                 print "<td class='tinylight'>" . $report["F_total"] . "</td>";
                 print "</tr>";
             }
             print "</table>";
         }
     }
 }