Ejemplo n.º 1
0
    function _consult() {
    //
    // main consult API
    // executes with menu choice "Today's Patients"
    //

        static $patient;
        static $notes;
        static $lab;

        // always check dependencies
        if ($exitinfo = $this->missing_dependencies('healthcenter')) {
            return print($exitinfo);
        }
        
        mysql_query("ALTER TABLE `m_consult` DROP PRIMARY KEY , ADD PRIMARY KEY (`consult_id`)");
        
        
        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);
        }
        if (!isset($patient)) {
            $patient = new patient;
            $notes = new notes;
            $lab = new lab;
            $drug = new drug;
        }
        if ($get_vars["patient_id"] && $get_vars["consult_id"]) {
            print "<table>";
            print "<tr valign='top'><td>";
            $this->patient_info($menu_id, $post_vars, $get_vars);
            print "</td></tr>";
            print "</table>";
        } else {
            if ($post_vars["submitpatient"]) {
                // processes form_patient and immediately
                // starts consult
                $patient->process_patient($menu_id, $post_vars, $get_vars);
                $this->process_consult($menu_id, $post_vars, $get_vars);
                header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]);
            }
            // check if we are loading patient records or validating entry for
            //   an existing patient in today's consult list
            if ($post_vars["submitconsult"] || $get_vars["enter_consult"] || $post_vars["confirm_add_consult"]) {
                //$post_vars["consult_id"] = $get_vars["enter_consult"];
                // confirms consult for found patients		                
		$this->process_consult($menu_id, $post_vars, $get_vars);
            }
            if ($post_vars["submitsearch"]) {
                // lists down search results for patient
                $this->process_search($menu_id, $post_vars, $get_vars);
            }
            print "<table width='600'>";
            if ($get_vars["consult_id"]) {
                print "<tr valign='top'><td colspan='2'>";
                $this->patient_info($menu_id, $post_vars, $get_vars);
                print "</td></tr>";
                print "<tr valign='top'><td colspan='2'>";
                $this->patient_menu($menu_id, $post_vars, $get_vars);
                print "</td></tr>";
                print "<tr valign='top'><td>";
                // column 1
                switch ($get_vars["ptmenu"]) {
                case "APPTS":
                    appointment::_consult_appointment($menu_id, $post_vars, $get_vars);
                    break;
                case "LABS":
                    if ($post_vars["submitlab"] || $get_vars["delete_id"]) {
                        $lab->process_send_request($menu_id, $post_vars, $get_vars);
                    }
                    $lab->form_send_request($menu_id, $post_vars, $get_vars);
                    break;
                case "DETAILS":
                    if ($get_vars["module"]) {
                        $module_method = $get_vars["module"]."::_consult_".$get_vars["module"]."(\$menu_id, \$post_vars, \$get_vars);";
                        if (class_exists($get_vars["module"])) {
                            eval("$module_method");
                        }
                    } else {
                        if ($post_vars["submitdetails"]) {
                            $this->process_details($menu_id, $post_vars, $get_vars);
                        }
                        $this->form_visitdetails($menu_id, $post_vars, $get_vars);
                    }
                    break;
                case "VITALS":
                    //$this->show_vitalsigns($menu_id, $post_vars, $get_vars);
                    if ($post_vars["submitvitals"]) {
                        $this->process_vitalsigns($menu_id, $post_vars, $get_vars, $_SESSION["userid"]);
                    }
                    $this->form_vitalsigns($menu_id, $post_vars, $get_vars);
                    break;
                case "NOTES":
                    $notes->_consult_notes($menu_id, $post_vars, $get_vars);
                    break;
                case "DRUGS":
                    $drug->_consult_drug($menu_id, $post_vars, $get_vars);
                    break;
                case "CONSULT":
                    $this->_consult_housekeeping($menu_id, $post_vars, $get_vars);
                    break;
                }
                print "</td><td>";
                // column 2
                switch ($get_vars["ptmenu"]) {
                case "APPTS":
                    appointment::display_consult_appointments($menu_id, $post_vars, $get_vars);
                    break;
                case "LABS":
                    // lab requests for this consult
                    // flag if done
                    $lab->display_requests($menu_id, $post_vars, $get_vars);
                    break;
                case "VITALS":
                    $this->display_vitals($menu_id, $post_vars, $get_vars);
                    break;
                case "DETAILS":
                    if ($get_vars["module"]) {
                        // construct eval string
                        $module_method = $get_vars["module"]."::_details_".$get_vars["module"]."(\$menu_id, \$post_vars, \$get_vars);";
                        if (class_exists($get_vars["module"])) {
                            eval("$module_method");
                        }
                    } else {
                        $this->show_visitdetails($menu_id, $post_vars, $get_vars);
                        $this->display_consults($menu_id, $post_vars, $get_vars);
                    }
                    break;
                case "NOTES":
                    $notes->_details_notes($menu_id, $post_vars, $get_vars, $validuser, $isadmin);
                    break;
                case "DRUGS":
                    $drug->_details_drug($menu_id, $post_vars, $get_vars, $validuser, $isadmin);
                    break;
                }
                print "</td></tr>";
                print "<tr valign='top'><td colspan='2'>";
                // display all patients confirmed with consults
                // CONSULTS TODAY DISPLAYED AT THE BOTTOM
                $this->consult_info($menu_id, $post_vars, $get_vars);
                print "</td></tr>";
            } else {
                print "<tr valign='top'><td colspan='2'>";
                // display all patients confirmed with consults
                print "<table>";
                print "<tr><td>";
                // CONSULTS TODAY
                $this->consult_info($menu_id, $post_vars, $get_vars);
                print "</td></tr>";
                /*
                print "<tr><td>";
                // REGISTERED PATIENTS TODAY
                $patient->patient_info($menu_id, $post_vars, $get_vars);
                print "</td></tr>";
                */
                print "</table>";
                print "</td></tr>";
                print "<tr valign='top'><td>";
                $patient->newsearch($menu_id, $post_vars, $get_vars);
                print "</td><td>";
                $patient->form_patient($menu_id, $post_vars, $get_vars);
                print "</td></tr>";
            }
            print "</table>";
        }
    }