예제 #1
0
    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/>";
            }
        }
    }