function process_consult_lab_sputum() { 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); } //print_r($arg_list); if ($post_vars["submitlab"]) { $patient_id = healthcenter::get_patient_id($get_vars["consult_id"]); switch($post_vars["submitlab"]) { case "Update Lab Exam": // enforce transaction // specimen 1 if ($post_vars["sp1_collection_date"]) { list($month,$day,$year) = explode("/", $post_vars["sp1_collection_date"]); $sp1_collection_date = $year."-".str_pad($month, 2, "0", STR_PAD_LEFT)."-".str_pad($day, 2, "0", STR_PAD_LEFT); } // specimen 2 if ($post_vars["sp2_collection_date"]) { list($month,$day,$year) = explode("/", $post_vars["sp2_collection_date"]); $sp2_collection_date = $year."-".str_pad($month, 2, "0", STR_PAD_LEFT)."-".str_pad($day, 2, "0", STR_PAD_LEFT); } // specimen 3 if ($post_vars["sp3_collection_date"]) { list($month,$day,$year) = explode("/", $post_vars["sp3_collection_date"]); $sp3_collection_date = $year."-".str_pad($month, 2, "0", STR_PAD_LEFT)."-".str_pad($day, 2, "0", STR_PAD_LEFT); } $release_flag = ($post_vars["release_flag"]?"Y":"N"); mysql_query("SET autocommit=0;") or die(mysql_error()); mysql_query("START TRANSACTION;") or die(mysql_error()); if ($release_flag=="Y") { if(empty($_POST["lab_diagnosis"])): echo "<script language='Javascript'>"; echo "window.alert('Cannot close / release sputum exam yet. Please indicate LAB DIAGNOSIS!')"; echo "</script>"; elseif(empty($_POST["sputum_period"])): echo "<script language='Javascript'>"; echo "window.alert('Cannot close / release sputum exam yet. Please indicate PERIOD OF SPUTUM EXAMS!')"; echo "</script>"; else: $sql = "update m_consult_lab set ". "done_timestamp = sysdate(), ". "request_done = 'Y', ". "done_user_id = '".$_SESSION["userid"]."' ". "where request_id = '".$post_vars["request_id"]."'"; if ($result = mysql_query($sql)) { // successful.. so just go to next SQL statement in // transaction set } else { mysql_query("ROLLBACK;") or die(mysql_error()); mysql_query("SET autocommit=1;") or die(mysql_error()); header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&consult_id=".$get_vars["consult_id"]."&module=".$get_vars["module"]."&request_id=".$post_vars["request_id"]."&lab_id=".$get_vars["lab_id"]."&ptmenu=LABS"); } endif; } // try insert first, will fail if previous request has been inserted // because of primary key constraint - then it will cascade to update below... $sql_sputum = "insert into m_consult_lab_sputum (consult_id, request_id, patient_id, ". "lab_timestamp, sp1_collection_date, sp2_collection_date, sp3_collection_date, ". "sp1_appearance, sp2_appearance, sp3_appearance, ". "sp1_reading, sp2_reading, sp3_reading, lab_diag1, lab_diag2, lab_diag3, lab_diagnosis, sputum_period, ". "user_id, release_flag) values ('".$get_vars["consult_id"]."', '".$post_vars["request_id"]."', ". "'$patient_id', sysdate(), '$sp1_collection_date', '$sp2_collection_date', '$sp3_collection_date', ". "'".$post_vars["sp1_appearance"]."', '".$post_vars["sp2_appearance"]."', '".$post_vars["sp3_appearance"]."', ". "'".$post_vars["sp1_reading"]."', '".$post_vars["sp2_reading"]."', '".$post_vars["sp3_reading"]."', ". "'".$post_vars["lab_diag1"]."', '".$post_vars["lab_diag2"]."', '".$post_vars["lab_diag3"]."', ". "'".$post_vars["lab_diagnosis"]."', '".$post_vars["sputum_period"]."', '".$_SESSION["userid"]."', '$release_flag')"; if ($result_sputum = mysql_query($sql_sputum)) { mysql_query("COMMIT;") or die(mysql_error()); mysql_query("SET autocommit=1;") or die(mysql_error()); //header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&consult_id=".$get_vars["consult_id"]."&module=".$get_vars["module"]."&request_id=".$get_vars["request_id"]."&lab_id=".$get_vars["lab_id"]."&ptmenu=LABS"); } else { $sql_update = "update m_consult_lab_sputum set ". "lab_timestamp = sysdate(), ". "sp1_collection_date = '$sp1_collection_date', ". "sp2_collection_date = '$sp2_collection_date', ". "sp3_collection_date = '$sp3_collection_date', ". "sp1_appearance = '".$post_vars["sp1_appearance"]."', ". "sp2_appearance = '".$post_vars["sp2_appearance"]."', ". "sp3_appearance = '".$post_vars["sp3_appearance"]."', ". "sp1_reading = '".$post_vars["sp1_reading"]."', ". "sp2_reading = '".$post_vars["sp2_reading"]."', ". "sp3_reading = '".$post_vars["sp3_reading"]."', ". "lab_diag1 = '".$post_vars["lab_diag1"]."', ". "lab_diag2 = '".$post_vars["lab_diag2"]."', ". "lab_diag3 = '".$post_vars["lab_diag3"]."', ". "lab_diagnosis = '".$post_vars["lab_diagnosis"]."', ". "sputum_period = '".$post_vars["sputum_period"]."', ". "user_id = '".$_SESSION["userid"]."', ". "release_flag = '$release_flag' ". "where request_id = '".$post_vars["request_id"]."'"; if ($result_update = mysql_query($sql_update)) { mysql_query("COMMIT;") or die(mysql_error()); mysql_query("SET autocommit=1;") or die(mysql_error()); header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&consult_id=".$get_vars["consult_id"]."&module=".$get_vars["module"]."&ptmenu=LABS"."&module=sputum"."&request_id=".$get_vars["request_id"]."#sputum"); } else { mysql_query("ROLLBACK;") or die(mysql_error()); mysql_query("SET autocommit=1;") or die(mysql_error()); header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&consult_id=".$get_vars["consult_id"]."&module=".$get_vars["module"]."&ptmenu=LABS"."&module=sputum"."&request_id=".$get_vars["request_id"]."#sputum"); } } break; case "Delete Lab Exam": if (module::confirm_delete($menu_id, $post_vars, $get_vars)) { $sql = "delete from m_consult_lab where request_id = '".$post_vars["request_id"]."'"; if ($result = mysql_query($sql)) { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&consult_id=".$get_vars["consult_id"]."&module=".$get_vars["module"]."&ptmenu=LABS"); } } else { if ($post_vars["confirm_delete"]=="No") { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&consult_id=".$get_vars["consult_id"]."&module=".$get_vars["module"]."&ptmenu=LABS"); } } break; } } }
function process_template() { // // called from _sms_template() // 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); } if ($post_vars["submittemplate"]) { if ($post_vars["appointment"] && $post_vars["template_text"]) { switch ($post_vars["submittemplate"]) { case "Add Template": $sql = "insert into m_lib_reminder_sms_template (appointment_id, template_text) " . "values ('" . $post_vars["appointment"] . "', '" . addslashes($post_vars["template_text"]) . "')"; if ($result = mysql_query($sql)) { header("location: " . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&menu_id=" . $get_vars["menu_id"]); } break; case "Update Template": $sql = "update m_lib_reminder_sms_template set " . "template_text = '" . addslashes($post_vars["template_text"]) . "' " . "where appointment_id = '" . $post_vars["appointment"] . "'"; if ($result = mysql_query($sql)) { header("location: " . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&menu_id=" . $get_vars["menu_id"]); } break; case "Delete Template": if (module::confirm_delete($menu_id, $post_vars, $get_vars)) { $sql = "delete from m_lib_reminder_sms_template " . "where appointment_id = '" . $post_vars["appointment"] . "'"; if ($result = mysql_query($sql)) { header("location: " . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&menu_id=" . $get_vars["menu_id"]); } } else { if ($post_vars["confirm_delete"] == "No") { header("location: " . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&menu_id=" . $get_vars["menu_id"]); } } break; } } } }
function process_content() { 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 ($get_vars["delete_id"]) { if (module::confirm_delete($menu_id, $post_vars, $get_vars)) { $sql = "delete from content where module_id = '" . $post_vars["module_id"] . "'"; if ($result = mysql_query($sql)) { header("location: " . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&method=" . $get_vars["method"]); } } } switch ($post_vars["submitmodule"]) { case "Add Module": if ($post_vars["module"] && $post_vars["mod_column"] && $post_vars["mod_level"]) { $sql = "insert into content (content_module, content_column, content_level, content_active) " . "values ('" . $post_vars["module"] . "', '" . $post_vars["mod_column"] . "', '" . $post_vars["mod_level"] . "', 'Y')"; if ($result = mysql_query($sql)) { header("location: " . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&method=" . $get_vars["method"]); } } break; case "Update Module": if ($post_vars["module"] && $post_vars["mod_column"] && $post_vars["mod_level"]) { $sql = "update content set content_module = '" . $post_vars["module"] . "', " . "content_column = '" . $post_vars["mod_column"] . "', " . "content_level = '" . $post_vars["mod_level"] . "' " . "where content_id = '" . $post_vars["content_id"] . "'"; if ($result = mysql_query($sql)) { header("location: " . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&method=" . $get_vars["method"]); } } break; case "Delete Module": if (module::confirm_delete($menu_id, $post_vars, $get_vars)) { $sql = "delete from content where content_id = '" . $post_vars["content_id"] . "'"; if ($result = mysql_query($sql)) { header("location: " . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&method=" . $get_vars["method"]); } } else { if ($post_vars["confirm_delete"] == "No") { header("location: " . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&method=" . $get_vars["method"]); } } break; } }
function process_question() { if (func_num_args()) { $arg_list = func_get_args(); $menu_id = $arg_list[0]; $post_vars = $arg_list[1]; $get_vars = $arg_list[2]; print_r($arg_list); } switch ($post_vars["submitquestion"]) { case "New Category": header("location: " . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&menu_id=" . $get_vars["menu_id"]); break; case "Add Question": if ($post_vars["question_text"] && $post_vars["type_id"]) { $alert = $post_vars["alert_flag"] ? "Y" : "N"; $sql = "insert into m_lib_questions (question_text, answer_type, alert_flag, question_cat) " . "values ('" . addslashes($post_vars["question_text"]) . "', '" . $post_vars["type_id"] . "', '{$alert}', '" . $post_vars["cat_id"] . "')"; if ($result = mysql_query($sql)) { header("location: " . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&menu_id=" . $get_vars["menu_id"]); } } break; case "Update Question": if ($post_vars["question_text"] && $post_vars["type_id"]) { $alert = $post_vars["alert_flag"] ? "Y" : "N"; $sql = "update m_lib_questions set " . "question_text = '" . addslashes($post_vars["question_text"]) . "', " . "answer_type = '" . $post_vars["type_id"] . "', " . "question_cat = '" . $post_vars["cat_id"] . "', " . "alert_flag = '{$alert}' " . "where question_id = '" . $post_vars["question_id"] . "'"; if ($result = mysql_query($sql)) { header("location: " . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&menu_id=" . $get_vars["menu_id"]); } } break; case "Delete Question": if (module::confirm_delete($menu_id, $post_vars, $get_vars)) { $sql = "delete from m_lib_questions where question_id = '" . $post_vars["question_id"] . "'"; if ($result = mysql_query($sql)) { header("location: " . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&menu_id=" . $get_vars["menu_id"]); } } else { if ($post_vars["confirm_delete"] == "No") { header("location: " . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&menu_id=" . $get_vars["menu_id"]); } } break; } }
function process_drug() { 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 ($post_vars["submitdrug"]) { if ($post_vars["drugcat"] && $post_vars["drugprep"] && $post_vars["drugform"] && $post_vars["drugman"] && $post_vars["drug_name"]) { switch($post_vars["submitdrug"]) { case "Add Drug": print $sql = "insert into m_lib_drugs (drug_cat, drug_name, drug_preparation, drug_formulation, manufacturer_id, drug_source, admin_desc) ". "values ('".$post_vars["drugcat"]."', ". "'".ucwords($post_vars["drug_name"])."', ". "'".$post_vars["drugprep"]."', ". "'".$post_vars["drugform"]."', ". "'".$post_vars["drugman"]."', ". "'".$post_vars["drugsource"]."', ". "'".ucfirst($post_vars["admin_desc"])."')"; if ($result = mysql_query($sql)) { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]); } break; case "Update Drug": $sql = "update m_lib_drugs set ". "drug_name = '".ucwords($post_vars["drug_name"])."', ". "drug_cat = '".$post_vars["drugcat"]."', ". "drug_formulation = '".$post_vars["drugform"]."', ". "manufacturer_id = '".$post_vars["drugman"]."', ". "drug_source = '".$post_vars["drugsource"]."', ". "admin_desc = '".ucfirst($post_vars["admin_desc"])."' ". "where drug_id = '".$post_vars["drug_id"]."'"; if ($result = mysql_query($sql)) { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]); } break; case "Delete Drug": if (module::confirm_delete($menu_id, $post_vars, $get_vars)) { $sql = "delete from m_lib_drugs where drug_id = '".$post_vars["drug_id"]."'"; if ($result = mysql_query($sql)) { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]); } } else { if ($post_vars["confirm_delete"]=="No") { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]); } } break; } } else { print "<font color='red'>Please complete entries.</font><br>"; } } }
function process_riskfactor() { 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($post_vars); } if ($post_vars["submitriskfactor"]) { if ($post_vars["risk_name"]) { $hospital_flag = ($post_vars["hospital_flag"]?"Y":"N"); $monitor_flag = ($post_vars["monitor_flag"]?"Y":"N"); switch($post_vars["submitriskfactor"]) { case "Add Risk Factor": $sql = "insert into m_lib_mc_risk_factors (risk_name, hospital_flag, monitor_flag) ". "values ('".$post_vars["risk_name"]."', '$hospital_flag', '$monitor_flag')"; if ($result = mysql_query($sql)) { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=$menu_id"); } break; case "Update Risk Factor": $sql = "update m_lib_mc_risk_factors set ". "hospital_flag = '$hospital_flag', ". "monitor_flag = '$monitor_flag', ". "risk_name = '".$post_vars["risk_name"]."' ". "where risk_id = '".$post_vars["risk_id"]."'"; if ($result = mysql_query($sql)) { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=$menu_id"); } break; case "Delete Risk Factor": if (module::confirm_delete($menu_id, $post_vars, $get_vars)) { $sql = "delete from m_lib_mc_risk_factors where risk_id = '".$post_vars["risk_id"]."'"; if ($result = mysql_query($sql)) { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=$menu_id"); } } else { if ($post_vars["confirm_delete"]=="No") { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]); } } break; } } } }
function show_visitdetails() { // // data shown on the right side when DETAILS is clicked // 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 = healthcenter::get_patient_id($get_vars["consult_id"]); print "<b>".FTITLE_PATIENT_GROUP."</b><br/>"; if ($get_vars["deletets"] && $get_vars["deletegroup"]) { if (module::confirm_delete($menu_id, $post_vars, $get_vars)) { $sql_delete = "delete from m_consult_ptgroup where consult_id = '".$get_vars["consult_id"]."' and ptgroup_timestamp = '".$get_vars["deletets"]."' and ptgroup_id = '".$get_vars["deletegroup"]."'"; if ($result_delete = mysql_query($sql_delete)) { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&consult_id=".$get_vars["consult_id"]."&ptmenu=DETAILS"); } } else { if ($post_vars["confirm_delete"]=="No") { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&consult_id=".$get_vars["consult_id"]."&ptmenu=DETAILS"); } } } $sql_ptgroup = "select g.ptgroup_name, g.ptgroup_module, c.ptgroup_timestamp, c.ptgroup_id from m_consult_ptgroup c, m_lib_ptgroup g ". "where g.ptgroup_id = c.ptgroup_id and c.consult_id = '".$get_vars["consult_id"]."'"; if ($result = mysql_query($sql_ptgroup)) { if (mysql_num_rows($result)) { while (list($name, $mod, $ts, $grp) = mysql_fetch_array($result)) { print "<img src='../images/arrow_redwhite.gif' border='0'/> <a href='".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&consult_id=".$get_vars["consult_id"]."&ptmenu=".$get_vars["ptmenu"]."&module=$mod'>$name</a> "; print "<a href='".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&consult_id=".$get_vars["consult_id"]."&ptmenu=DETAILS&deletets=$ts&deletegroup=$grp'><img src='../images/delete.png' border='0'/></a><br/>"; } } else { print "<font color='red'>none</font><br/>"; } } print "<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 = '$patient_id' ". "group by c.ptgroup_id"; if ($result = mysql_query($sql_ptgroup)) { if (mysql_num_rows($result)) { print "<span class='tinylight'>"; 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/> "; } print "</span>"; } else { print "<font color='red'>No records.</font><br/>"; } } /* print "<br/>"; print "<b>".FTITLE_CONSULT_COMPLAINTS."</b><br/>"; // process delete here if ($get_vars["deletets"] && $get_vars["deletecomplaint"]) { if (module::confirm_delete($menu_id, $post_vars, $get_vars)) { $sql_delete = "delete from m_consult_complaint where consult_id = '".$get_vars["consult_id"]."' and complaint_timestamp = '".$get_vars["deletets"]."' and complaint_id = '".$get_vars["deletecomplaint"]."'"; if ($result_delete = mysql_query($sql_delete)) { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&consult_id=".$get_vars["consult_id"]."&ptmenu=DETAILS"); } } else { if ($post_vars["confirm_delete"]=="No") { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&consult_id=".$get_vars["consult_id"]."&ptmenu=DETAILS"); } } } $sql_complaint = "select l.complaint_name, l.complaint_module, c.complaint_timestamp, c.complaint_id from m_consult_complaint c, m_lib_complaint l ". "where l.complaint_id = c.complaint_id and c.consult_id = '".$get_vars["consult_id"]."'"; if ($result = mysql_query($sql_complaint)) { if (mysql_num_rows($result)) { while (list($name, $mod, $ts, $comp) = mysql_fetch_array($result)) { print "<img src='../images/arrow_redwhite.gif' border='0'/> <a href='".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&consult_id=".$get_vars["consult_id"]."&ptmenu=".$get_vars["ptmenu"]."&module=$mod'>$name</a> "; print "<a href='".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&consult_id=".$get_vars["consult_id"]."&ptmenu=DETAILS&deletets=$ts&deletecomplaint=$comp'><img src='../images/delete.png' border='0'/></a><br/>"; } } else { print "<font color='red'>none</font><br/>"; } } */ print "<br/>"; print "<b>".FTITLE_CONSULT_MODULES."</b><br/>"; $sql_modules = "select m.module_desc, h.module_id ". "from m_healthcenter_modules h, modules m ". "where h.module_id = m.module_id"; if ($result = mysql_query($sql_modules)) { if (mysql_num_rows($result)) { while (list($desc, $mod) = mysql_fetch_array($result)) { // remove the CHITS prefix $desc = ereg_replace("CHITS ","", $desc); print "<img src='../images/arrow_redwhite.gif' border='0'/> <a href='".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&consult_id=".$get_vars["consult_id"]."&ptmenu=DETAILS&module=$mod'>$desc</a><br/> "; } } else { print "<font color='red'>none</font><br/>"; } } print "<br/>"; }
function process_patient() { 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]; $patient = $arg_list[3]; //print_r($post_vars); } list($month, $day, $year) = explode("/", $post_vars["patient_dob"]); $dob = $year . "-" . str_pad($month, 2, "0", STR_PAD_LEFT) . "-" . str_pad($day, 2, "0", STR_PAD_LEFT); $post_vars["conv_dob"] = $dob; switch ($post_vars["submitpatient"]) { case "Add Patient": if ($post_vars["patient_lastname"] && $post_vars["patient_firstname"] && $post_vars["patient_gender"] && $post_vars["patient_dob"] && $post_vars["patient_mother"]) { // check for duplicates $threshold = 93; $sim_index = $this->get_duplicates($post_vars, $threshold); if ($sim_index < $threshold) { /*$sql = "insert into m_patient (patient_lastname, patient_firstname, patient_middle, patient_dob, patient_gender, registration_date, user_id, healthcenter_id, patient_mother,patient_cellphone) ". "values ('".ucwords($post_vars["patient_lastname"])."', '".ucwords($post_vars["patient_firstname"])."', '".ucwords($post_vars["patient_middle"])."', ". "'$dob', '".$post_vars["patient_gender"]."', sysdate(), '".$_SESSION["userid"]."', '".$_SESSION["datanode"]["code"]."', '".ucwords($post_vars["patient_mother"])."','".$post_vars["patient_cellphone"]."')"; */ //$sql = 'insert into m_patient (patient_lastname,patient_firstname, patient_middle, patient_dob, patient_gender, registration_date, user_id, healthcenter_id, patient_mother,patient_cellphone) values('.ucwords($post_vars["patient_lastname"]).','.ucwords($post_vars["patient_firstname"]).','.ucwords($post_vars["patient_middle"]).','.$dob.','.$post_vars["patient_gender"].','.'sysdate()'.','.$_SESSION["userid"].','.$_SESSION["datanode"]["code"].','.ucwords($post_vars["patient_mother"]).','.$post_vars["patient_cellphone"].')'; $get_last = mysql_query("SELECT patient_id FROM m_patient ORDER by patient_id DESC LIMIT 1") or die("Cannot query: 387" . mysql_error()); list($pxid) = mysql_fetch_array($get_last); $next_id = $pxid + 1; $sql = "insert into m_patient set patient_id='{$next_id}',patient_lastname='" . ucwords($post_vars[patient_lastname]) . "', patient_firstname='" . ucwords($post_vars[patient_firstname]) . "',patient_middle='" . ucwords($post_vars[patient_middle]) . "',patient_dob='{$dob}',patient_gender='{$post_vars['patient_gender']}',registration_date=sysdate(),user_id='{$_SESSION['userid']}',healthcenter_id='{$_SESSION['datanode']}[code]',patient_mother='" . ucwords($post_vars[patient_mother]) . "',patient_cellphone='{$post_vars['patient_cellphone']}'"; //print_r($post_vars); $result = mysql_query($sql) or die(mysql_error()); if ($result) { echo "<script language=\"Javascript\">"; echo "alert('Patient {$post_vars['patient_firstname']}, {$post_vars['patient_lastname']} was successfully added!')"; //header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]); echo "</script>"; } } else { echo "<script language=\"Javascript\">"; echo "alert('Patient was not added due to similarity with existing records!')"; echo "</script>"; print "<font size='5' color='red'><b>Duplicate detected " . round($sim_index, 2) . "%.</b></font><br/>"; } } else { echo "<script language=\"Javascript\">"; echo "alert('Patient was not added due to missing fields!')"; echo "</script>"; $this->display_inc($post_vars); //return; } break; case "Update Patient": if ($post_vars["patient_lastname"] && $post_vars["patient_firstname"] && $post_vars["patient_gender"] && $post_vars["patient_mother"]) { $sql = "update m_patient set " . "patient_firstname = '" . ucwords($post_vars["patient_firstname"]) . "', " . "patient_middle = '" . ucwords($post_vars["patient_middle"]) . "', " . "patient_lastname = '" . ucwords($post_vars["patient_lastname"]) . "', " . "user_id = '" . $_SESSION["userid"] . "', " . "patient_gender = '" . $post_vars["patient_gender"] . "', " . "patient_mother = '" . $post_vars["patient_mother"] . "', " . "patient_cellphone = '" . $post_vars["patient_cellphone"] . "', " . "patient_dob = '{$dob}' " . "where patient_id = '" . $post_vars["patient_id"] . "'"; $result = mysql_query($sql) or die(mysql_error()); if ($result) { echo "<script language=\"Javascript\">"; echo "alert('Record of patient {$post_vars['patient_firstname']} {$post_vars['patient_lastname']} was successfully been updated.')"; echo "</script>"; //header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]); } else { echo "<script language=\"Javascript\">"; } //echo "alert('Record of patient $post_vars[patient_firstname] $post_vars[patient_lastname] was not updated.')"; echo "</script>"; } break; case "Delete Patient": if (module::confirm_delete($menu_id, $post_vars, $get_vars)) { $sql = "delete from m_patient where patient_id = '" . $post_vars["patient_id"] . "'"; if ($result = mysql_query($sql)) { header("location: " . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&menu_id=" . $get_vars["menu_id"]); } } else { if ($post_vars["confirm_delete"] == "No") { header("location: " . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&menu_id=" . $get_vars["menu_id"]); } } break; case "Cancel": empty($post_vars["patient_firstname"]); unset($patient["patient_firstname"]); //header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=657"); break; } }
function unassign_brgy() { if (func_num_args() > 0) { $arr = func_get_args(); $postvars = $arr[0]; $getvars = $arr[1]; } if ($getvars["action"] == 'delete') { $q_brgy = mysql_query("SELECT barangay_id,barangay_name FROM m_lib_barangay WHERE barangay_id='{$getvars['brgy_id']}'") or die("Cannot query: 176 " . mysql_error()); $q_facility = mysql_query("SELECT facility_name FROM m_lib_health_facility WHERE facility_id='{$getvars['facility_id']}'") or die("Cannot query: 178 " . mysql_error()); list($facility_name) = mysql_fetch_array($q_facility); if (mysql_num_rows($q_brgy) != 0) { list($brgy_id, $brgy_name) = mysql_fetch_array($q_brgy); //echo "You are about to unassign <b>".$brgy_name."</b> from <b>".$facility_name."</b><br>"; if (module::confirm_delete($getvars["menu_id"], $postvars, $getvars)) { $delete_brgy = mysql_query("DELETE FROM m_lib_health_facility_barangay WHERE barangay_id='{$getvars['brgy_id']}'") or die("Cannot query 188 " . mysql_error()); if ($delete_brgy) { echo "<script language='Javascript'>"; echo "window.alert('The barangay {$brgy_name} was successfully been unassigned from the {$facility_name}!')"; echo "</script>"; } } else { } } else { echo "<script language='Javascript'>"; echo "window.alert('Cannot delete. The barangay ID does not exists!')"; echo "</script>"; } } }
function process_notifiable_disease() { 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 ($post_vars["submitdisease"]) { if ($post_vars["disease_id"] && $post_vars["disease_name"]) { switch ($post_vars["submitdisease"]) { case "Delete ICD Codes": if ($post_vars["deletecode"]) { foreach ($post_vars["deletecode"] as $key => $value) { $sql = "delete from m_lib_disease_icdcode " . "where disease_id = '" . $post_vars["disease_id"] . "' and " . "icd_code = '{$value}'"; $result = mysql_query($sql); } header("location: " . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&menu_id={$menu_id}"); } break; case "Search": // dummy entry // processing code is process_search() break; case "Add Disease": $sql = "insert into m_lib_disease_notifiable (disease_id, disease_name) " . "values ('" . strtoupper($post_vars["disease_id"]) . "', '" . $post_vars["disease_name"] . "')"; if ($result = mysql_query($sql)) { header("location: " . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&menu_id={$menu_id}"); } break; case "Update Disease": $sql = "update m_lib_disease_notifiable set " . "disease_name = '" . $post_vars["disease_name"] . "' " . "where disease_id = '" . $post_vars["disease_id"] . "'"; if ($result = mysql_query($sql)) { foreach ($post_vars["code"] as $key => $value) { $sql_icd = "insert into m_lib_disease_icdcode (disease_id, icd_code) " . "values ('" . $post_vars["disease_id"] . "', '{$value}')"; $result_icd = mysql_query($sql_icd); } header("location: " . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&menu_id={$menu_id}"); } break; case "Delete Disease": if (module::confirm_delete($menu_id, $post_vars, $get_vars)) { $sql = "delete from m_lib_disease_notifiable where disease_id = '" . $post_vars["disease_id"] . "'"; if ($result = mysql_query($sql)) { header("location: " . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&menu_id={$menu_id}"); } } else { if ($post_vars["confirm_delete"] == "No") { header("location: " . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&menu_id=" . $get_vars["menu_id"]); } } break; } } } }
/** * Process Patient * * Process the operation being performed on the patient information * @param string $menu_id * @param array $past_vars * @param array $get_vars * @param boolean $validuser * @param booleam $isadmin */ function process_patient() { 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($post_vars); } list($month,$day,$year) = explode("/", $post_vars["patient_dob"]); $dob = $year."-".str_pad($month, 2, "0", STR_PAD_LEFT)."-".str_pad($day, 2, "0", STR_PAD_LEFT); $post_vars["conv_dob"] = $dob; switch ($post_vars["submitpatient"]) { case "Add Patient": if ($post_vars["patient_lastname"] && $post_vars["patient_firstname"] && $post_vars["patient_gender"] && $post_vars["patient_dob"] && $post_vars["patient_mother"]) { // check for duplicates $threshold = 93; $sim_index = $this->get_duplicates($post_vars, $threshold); if ($sim_index<$threshold) { $sql = "insert into m_patient (patient_lastname, patient_firstname, patient_middle, patient_dob, patient_gender, registration_date, user_id, healthcenter_id, patient_mother) ". "values ('".ucwords($post_vars["patient_lastname"])."', '".ucwords($post_vars["patient_firstname"])."', '".ucwords($post_vars["patient_middle"])."', ". "'$dob', '".$post_vars["patient_gender"]."', sysdate(), '".$_SESSION["userid"]."', '".$_SESSION["datanode"]["code"]."', '".ucwords($post_vars["patient_mother"])."')"; if ($result = mysql_query($sql)) { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]); } } else { print "<font size='5' color='red'><b>Duplicate detected ".round($sim_index,2)."%.</b></font><br/>"; } } else { return; } break; case "Update Patient": if ($post_vars["patient_lastname"] && $post_vars["patient_firstname"] && $post_vars["patient_gender"]) { $sql = "update m_patient set ". "patient_firstname = '".ucwords($post_vars["patient_firstname"])."', ". "patient_middle = '".ucwords($post_vars["patient_middle"])."', ". "patient_lastname = '".ucwords($post_vars["patient_lastname"])."', ". "user_id = '".$_SESSION["userid"]."', ". "patient_dob = '$dob' ". "where patient_id = '".$post_vars["patient_id"]."'"; if ($result = mysql_query($sql)) { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]); } } break; case "Delete Patient": if (module::confirm_delete($menu_id,$post_vars,$get_vars)) { $sql = "delete from m_patient where patient_id = '".$post_vars["patient_id"]."'"; if ($result = mysql_query($sql)) { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]); } } else { if ($post_vars["confirm_delete"]=="No") { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]); } } break; } }
function display_consult_icd10() { 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); } // process delete here if ($get_vars["delete_icd10_code"]) { if (module::confirm_delete($menu_id, $post_vars, $get_vars)) { $sql = "delete from m_consult_icd10 " . "where consult_id = '" . $get_vars["consult_id"] . "' and " . "diagnosis_code = '" . $get_vars["delete_icd10_code"] . "'"; if ($result = mysql_query($sql)) { header("location: " . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&menu_id=" . $get_vars["menu_id"] . "&consult_id=" . $get_vars["consult_id"] . "&ptmenu=DETAILS&module=icd10"); } } else { if ($post_vars["confirm_delete"] == "No") { header("location: " . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&menu_id=" . $get_vars["menu_id"] . "&consult_id=" . $get_vars["consult_id"] . "&ptmenu=DETAILS&module=icd10"); } } } $patient_id = healthcenter::get_patient_id($get_vars["consult_id"]); $patient_name = patient::get_name($get_vars["patient_id"]); print "<table width='300'>"; print "<tr valign='top'><td>"; print "<b>" . FTITLE_CONSULT_ICD10 . "</b><br>"; print "</td></tr>"; $sql = "select h.consult_id, h.diagnosis_code, l.description " . "from m_lib_icd10_en l, m_consult_icd10 h " . "where l.diagnosis_code = h.diagnosis_code and h.consult_id = '" . $get_vars["consult_id"] . "' " . "order by h.diagnosis_code"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { print "<tr valign='top'><td>"; while (list($cid, $icd, $name) = mysql_fetch_array($result)) { print "<img src='../images/arrow_redwhite.gif' border='0'/> "; print "<b>{$icd}</b> {$name} "; if ($_SESSION["priv_delete"]) { print "<a href='" . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&menu_id=" . $get_vars["menu_id"] . "&consult_id=" . $get_vars["consult_id"] . "&ptmenu=DETAILS&module=icd10&&delete_icd10_code={$icd}'><img src='../images/delete.png' border='0' /></a> "; } print "<br/>"; } print "</td></tr>"; } else { print "<tr valign='top'><td><font color='red'>No records.</font></td></tr>"; } } print "</table><br>"; }
function process_ptgroup() { 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 ($post_vars["submitptgroup"]) { if ($post_vars["group_id"] && $post_vars["group_name"]) { switch ($post_vars["submitptgroup"]) { case "Add Group": $sql = "insert into m_lib_ptgroup (ptgroup_id, ptgroup_name, ptgroup_module, ptgroup_condition) " . "values ('" . $post_vars["group_id"] . "', '" . $post_vars["group_name"] . "', '" . $post_vars["module"] . "', '" . $post_vars["group_condition"] . "')"; if ($result = mysql_query($sql)) { header("location: " . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&menu_id={$menu_id}"); } break; case "Update Group": $sql = "update m_lib_ptgroup set " . "ptgroup_name = '" . $post_vars["group_name"] . "', " . "ptgroup_module = '" . $post_vars["module"] . "', " . "ptgroup_condition = '" . $post_vars["group_condition"] . "' " . "where ptgroup_id = '" . $post_vars["group_id"] . "'"; if ($result = mysql_query($sql)) { header("location: " . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&menu_id={$menu_id}"); } break; case "Delete Group": if (module::confirm_delete($menu_id, $post_vars, $get_vars)) { $sql = "delete from m_lib_ptgroup where ptgroup_id = '" . $post_vars["group_id"] . "'"; if ($result = mysql_query($sql)) { header("location: " . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&menu_id={$menu_id}"); } } else { if ($post_vars["confirm_delete"] == "No") { header("location: " . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&menu_id=" . $get_vars["menu_id"]); } } break; } } } }
function process_patient() { 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]; $patient = $arg_list[3]; //print_r($post_vars); } list($month, $day, $year) = explode("/", $post_vars["patient_dob"]); $dob = $year . "-" . str_pad($month, 2, "0", STR_PAD_LEFT) . "-" . str_pad($day, 2, "0", STR_PAD_LEFT); $post_vars["conv_dob"] = $dob; $q_sms_enroll = mysql_query("SELECT menu_id FROM module_menu WHERE menu_id='1370'") or die("Cannot quer 535: " . mysql_error()); if (mysql_num_rows($q_sms_enroll) != 0) { $arr_sms = $_POST['sms_prog']; } switch ($post_vars["submitpatient"]) { case "Add Patient": if ($post_vars["patient_lastname"] && $post_vars["patient_middle"] && $post_vars["patient_firstname"] && $post_vars["patient_gender"] && $post_vars["patient_dob"] && $post_vars["patient_mother"] && $post_vars['patient_cellphone'] == $post_vars['confirm_cellphone']) { // check for duplicates $threshold = 93; $sim_index = $this->get_duplicates($post_vars, $threshold); if ($sim_index < $threshold) { $get_last = mysql_query("SELECT patient_id FROM m_patient ORDER by patient_id DESC LIMIT 1") or die("Cannot query: 387" . mysql_error()); list($pxid) = mysql_fetch_array($get_last); $next_id = $pxid + 1; if (in_array('pwd', $post_vars['p_group'])) { $pwd = 'Y'; } if (in_array('ind', $post_vars['p_group'])) { $ind = 'Y'; } $sql = "insert into m_patient set patient_id='{$next_id}',patient_lastname='" . ucwords($post_vars[patient_lastname]) . "', patient_firstname='" . ucwords($post_vars[patient_firstname]) . "',patient_middle='" . ucwords($post_vars[patient_middle]) . "',patient_dob='{$dob}',patient_gender='{$post_vars['patient_gender']}',registration_date=sysdate(),user_id='{$_SESSION['userid']}',healthcenter_id='{$_SESSION['datanode']}[code]',patient_mother='" . ucwords($post_vars[patient_mother]) . "',patient_cellphone='{$post_vars['patient_cellphone']}',pwd_flag='{$pwd}',ind_flag='{$ind}' "; //print_r($post_vars); $result = mysql_query($sql) or die(mysql_error()); $pxid = mysql_insert_id(); if (isset($arr_sms) && !empty($post_vars['patient_cellphone'])) { $this->sms_patient_enroll($pxid, $arr_sms); } else { echo "<script language=\"Javascript\">"; echo "alert('Patient {$post_vars['patient_firstname']} {$post_vars['patient_lastname']} was not enrolled for SMS alert.')"; //header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]); echo "</script>"; } if ($result) { //echo "<script>"; echo "<script>alert('Patient {$post_vars['patient_firstname']} {$post_vars['patient_lastname']} was successfully added!')</script>"; echo "<script>window.location = '{$_SERVER['PHP_SELF']}?page=PATIENTS&menu_id=691'</script>"; //echo "}"; //echo "</script>"; //header("location: $_SERVER[PHP_SELF]?page=PATIENTS&menu_id=691"); } } else { echo "<script language=\"Javascript\">"; echo "alert('Patient was not added due to similarity with existing records!')"; echo "</script>"; print "<font size='5' color='red'><b>Duplicate detected " . round($sim_index, 2) . "%.</b></font><br/>"; } } else { echo "<script language=\"Javascript\">"; echo "alert('Patient was not added due to missing fields!')"; echo "</script>"; $this->display_inc($post_vars); //return; } break; case "Update Patient": if ($post_vars["patient_lastname"] && $post_vars["patient_middle"] && $post_vars["patient_firstname"] && $post_vars["patient_gender"] && $post_vars["patient_mother"] && $post_vars['patient_cellphone'] == $post_vars['confirm_cellphone']) { if (in_array('pwd', $post_vars['p_group'])) { $pwd = 'Y'; } if (in_array('ind', $post_vars['p_group'])) { $ind = 'Y'; } $sql = "update m_patient set " . "patient_firstname = '" . ucwords($post_vars["patient_firstname"]) . "', " . "patient_middle = '" . ucwords($post_vars["patient_middle"]) . "', " . "patient_lastname = '" . ucwords($post_vars["patient_lastname"]) . "', " . "user_id = '" . $_SESSION["userid"] . "', " . "patient_gender = '" . $post_vars["patient_gender"] . "', " . "patient_mother = '" . $post_vars["patient_mother"] . "', " . "patient_cellphone = '" . $post_vars["patient_cellphone"] . "', " . "patient_dob = '{$dob}', " . "pwd_flag='{$pwd}', " . "ind_flag='{$ind}' " . "where patient_id = '" . $post_vars["patient_id"] . "'"; $result = mysql_query($sql) or die(mysql_error()); if ($result) { if (isset($arr_sms) && !empty($post_vars["patient_cellphone"])) { $this->sms_patient_enroll($post_vars["patient_id"], $arr_sms, ''); //else: //$this->sms_patient_enroll($post_vars["patient_id"],$arr_sms,'no'); } echo "<script language=\"Javascript\">"; echo "alert('Record of patient {$post_vars['patient_firstname']} {$post_vars['patient_lastname']} was successfully been updated.')"; echo "</script>"; //header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]); } else { echo "<script language=\"Javascript\">"; } //echo "alert('Record of patient $post_vars[patient_firstname] $post_vars[patient_lastname] was not updated.')"; echo "</script>"; } break; case "Delete Patient": if (module::confirm_delete($menu_id, $post_vars, $get_vars)) { $sql = "delete from m_patient where patient_id = '" . $post_vars["patient_id"] . "'"; if ($result = mysql_query($sql)) { header("location: " . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&menu_id=" . $get_vars["menu_id"]); } } else { if ($post_vars["confirm_delete"] == "No") { header("location: " . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&menu_id=" . $get_vars["menu_id"]); } } break; case "Cancel": empty($post_vars["patient_firstname"]); unset($patient["patient_firstname"]); //header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=657"); break; } }
function process_patient() { 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]; } list($month,$day,$year) = explode("/", $post_vars["patient_dob"]); $dob = $year."-".str_pad($month, 2, "0", STR_PAD_LEFT)."-".str_pad($day, 2, "0", STR_PAD_LEFT); switch ($post_vars["submitpatient"]) { case "Remove Patient": if (module::confirm_delete($menu_id, $post_vars, $get_vars)) { $sql = "delete from m_family_members where patient_id = '".$get_vars["patient_id"]."' and family_id='".$get_vars["family_id"]."'"; if ($result = mysql_query($sql)) { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]); } } else { if ($post_vars["confirm_delete"]=="No") { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]); } } break; case "Add Patient": if ($post_vars["patient_lastname"] && $post_vars["patient_firstname"] && $post_vars["patient_gender"]) { $sql = "insert into m_patient (patient_lastname, patient_firstname, patient_middle, patient_dob, patient_age, patient_gender) ". "values ('".ucwords($post_vars["patient_lastname"])."', '".ucwords($post_vars["patient_firstname"])."', '".ucwords($post_vars["patient_middle"])."', ". "'$dob', '".$post_vars["patient_age"]."', '".$post_vars["patient_gender"]."')"; $result = mysql_query($sql); } else { return; } break; } }
function process_complaint() { 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]; } switch ($post_vars["submitcomplaint"]) { case "Add Complaint": if ($post_vars["complaint_id"] && $post_vars["complaint_name"]) { $sql = "insert into m_lib_complaint (complaint_id, complaint_name, complaint_module) " . "values ('" . $post_vars["complaint_id"] . "', '" . $post_vars["complaint_name"] . "', '" . $post_vars["module"] . "')"; if ($result = mysql_query($sql)) { header("location: " . $_SERVER["PHP_SELF"] . "?page=LIBRARIES&menu_id=" . $get_vars["menu_id"]); } } break; case "Update Complaint": if ($post_vars["complaint_id"] && $post_vars["complaint_name"]) { $sql = "update m_lib_complaint set " . "complaint_name = '" . $post_vars["complaint_name"] . "', " . "complaint_module = '" . $post_vars["module"] . "' " . "where complaint_id = '" . $post_vars["complaint_id"] . "'"; if ($result = mysql_query($sql)) { header("location: " . $_SERVER["PHP_SELF"] . "?page=LIBRARIES&menu_id=" . $get_vars["menu_id"]); } } break; case "Delete Complaint": if ($post_vars["complaint_id"]) { if (module::confirm_delete($menu_id, $post_vars, $get_vars)) { $sql = "delete from m_lib_complaint where complaint_id = '" . $post_vars["complaint_id"] . "'"; if ($result = mysql_query($sql)) { header("location: " . $_SERVER["PHP_SELF"] . "?page=LIBRARIES&menu_id=" . $get_vars["menu_id"]); } } else { if ($post_vars["confirm_delete"] == "No") { header("location: " . $_SERVER["PHP_SELF"] . "?page=LIBRARIES&menu_id=" . $get_vars["menu_id"]); } } } break; } }
function process_dxclass() { 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 ($post_vars["submitclass"]) { if ($post_vars["class_name"]) { switch($post_vars["submitclass"]) { case "Add Diagnosis": $sql = "insert into m_lib_notes_dxclass (class_name) ". "values ('".$post_vars["class_name"]."')"; if ($result = mysql_query($sql)) { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]); } break; case "Update Diagnosis": $sql = "update m_lib_notes_dxclass set ". "class_name = '".$post_vars["class_name"]."' ". "where class_id = '".$post_vars["class_id"]."'"; if ($result = mysql_query($sql)) { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]); } break; case "Delete Diagnosis": if (module::confirm_delete($menu_id, $post_vars, $get_vars)) { $sql = "delete from m_lib_notes_dxclass where class_id = '".$post_vars["class_id"]."'"; if ($result = mysql_query($sql)) { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]); } } else { if ($post_vars["confirm_delete"]=="No") { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]); } } break; } } } }
function process_consult_lab_fecalysis() { 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 ($post_vars["submitlab"]) { $patient_id = healthcenter::get_patient_id($get_vars["consult_id"]); switch($post_vars["submitlab"]) { case "Update Lab Exam": // enforce transaction // specimen 1 if ($post_vars["fec_collection_date"]) { list($month,$day,$year) = explode("/", $post_vars["fec_collection_date"]); $sp1_collection_date = $year."-".str_pad($month, 2, "0", STR_PAD_LEFT)."-".str_pad($day, 2, "0", STR_PAD_LEFT); } $release_flag = ($post_vars["release_flag"]?"Y":"N"); mysql_query("SET autocommit=0;") or die(mysql_error()); mysql_query("START TRANSACTION;") or die(mysql_error()); if ($release_flag=="Y") { $sql = "update m_consult_lab set ". "done_timestamp = sysdate(), ". "request_done = 'Y', ". "done_user_id = '".$_SESSION["userid"]."' ". "where request_id = '".$post_vars["request_id"]."'"; if ($result = mysql_query($sql)) { // successful.. so just go to next SQL statement in // transaction set } else { mysql_query("ROLLBACK;") or die(mysql_error()); mysql_query("SET autocommit=1;") or die(mysql_error()); header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&consult_id=".$get_vars["consult_id"]."&module=".$get_vars["module"]."&request_id=".$post_vars["request_id"]."&lab_id=".$get_vars["lab_id"]); } } // try insert first, will fail if previous request has been inserted // because of primary key constraint - then it will cascade to update below... $sql_fecalysis = "insert into m_consult_lab_fecalysis (consult_id, request_id, patient_id, ". "lab_timestamp, fec_collection_date, ". "fec_macro_findings, ". "fec_micro_findings, ". "user_id, release_flag) values ('".$get_vars["consult_id"]."', '".$post_vars["request_id"]."', ". "'$patient_id', sysdate(), '$fec_collection_date', ". "'".$post_vars["fec_macro_findings"]."', ". "'".$post_vars["fec_micro_findings"]."', ". "'".$_SESSION["userid"]."', '$release_flag')"; if ($result_fecalysis = mysql_query($sql_fecalysis)) { mysql_query("COMMIT;") or die(mysql_error()); mysql_query("SET autocommit=1;") or die(mysql_error()); header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&consult_id=".$get_vars["consult_id"]."&module=".$get_vars["module"]."&request_id=".$get_vars["request_id"]."&lab_id=".$get_vars["lab_id"]); } else { $sql_update = "update m_consult_lab_fecalysis set ". "lab_timestamp = sysdate(), ". "fec_collection_date = '$fec_collection_date', ". "fec_macro_findings = '".$post_vars["fec_macro_findings"]."', ". "fec_micro_findings = '".$post_vars["fec_micro_findings"]."', ". "user_id = '".$_SESSION["userid"]."', ". "release_flag = '$release_flag' ". "where request_id = '".$post_vars["request_id"]."'"; if ($result_update = mysql_query($sql_update)) { mysql_query("COMMIT;") or die(mysql_error()); mysql_query("SET autocommit=1;") or die(mysql_error()); //header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&consult_id=".$get_vars["consult_id"]."&module=".$get_vars["module"]); } else { mysql_query("ROLLBACK;") or die(mysql_error()); mysql_query("SET autocommit=1;") or die(mysql_error()); header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&consult_id=".$get_vars["consult_id"]."&module=".$get_vars["module"]); } } break; case "Delete Lab Exam": if (module::confirm_delete($menu_id, $post_vars, $get_vars)) { $sql = "delete from m_consult_lab where request_id = '".$post_vars["request_id"]."'"; if ($result = mysql_query($sql)) { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&consult_id=".$get_vars["consult_id"]."&module=".$get_vars["module"]); } } else { if ($post_vars["confirm_delete"]=="No") { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&consult_id=".$get_vars["consult_id"]."&module=".$get_vars["module"]); } } break; } } }
function process_education() { 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 ($post_vars["submiteducation"]) { if ($post_vars["educ_id"] && $post_vars["educ_name"]) { switch($post_vars["submiteducation"]) { case "Add Education": $sql = "insert into m_lib_education (educ_id, educ_name) ". "values ('".strtoupper($post_vars["educ_id"])."', '".$post_vars["educ_name"]."')"; if ($result = mysql_query($sql)) { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=$menu_id"); } break; case "Update Education": $sql = "update m_lib_education set ". "educ_name = '".$post_vars["educ_name"]."' ". "where educ_id = '".$post_vars["educ_id"]."'"; if ($result = mysql_query($sql)) { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=$menu_id"); } break; case "Delete Education": if (module::confirm_delete($menu_id, $post_vars, $get_vars)) { $sql = "delete from m_lib_education where educ_id = '".$post_vars["educ_id"]."'"; if ($result = mysql_query($sql)) { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=$menu_id"); } } else { if ($post_vars["confirm_delete"]=="No") { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]); } } break; } } } }
function process_news() { // // called from _vaccine() // 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); } if ($post_vars["submitnews"]) { $active = ($post_vars["news_active"]?"Y":"N"); if ($post_vars["news_title"] && $post_vars["news_lead"]) { switch($post_vars["submitnews"]) { case "Add News": $sql = "insert into m_news (news_timestamp, news_title, news_lead, news_text, ". "news_author, news_active) ". "values (sysdate(), ". "'".addslashes(ucwords($post_vars["news_title"]))."', ". "'".addslashes($post_vars["news_lead"])."', ". " '".addslashes($post_vars["news_text"])."', ". " '".$post_vars["user_id"]."', ". " '$active') "; if ($result = mysql_query($sql)) { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]); } break; case "Update News": print $sql = "update m_news set ". "news_title = '".addslashes(ucwords($post_vars["news_title"]))."', ". "news_author = '".$post_vars["user_id"]."', ". "news_lead = '".addslashes($post_vars["news_lead"])."', ". "news_text = '".addslashes($post_vars["news_text"])."', ". "news_active= '$active' ". "where news_id = '".$post_vars["news_id"]."'"; if ($result = mysql_query($sql)) { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]); } break; case "Delete News": if (module::confirm_delete($menu_id, $post_vars, $get_vars)) { $sql = "delete from m_news ". "where news_id = '".$post_vars["news_id"]."'"; if ($result = mysql_query($sql)) { //header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]); } } else { if ($post_vars["confirm_delete"]=="No") { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]); } } break; } } } }
function process_linegraph() { 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 ($post_vars["submitgraph"]) { if ($post_vars["graph_title"] && $post_vars["graph_width"] && $post_vars["graph_height"] && $post_vars["graph_sql"]) { switch($post_vars["submitgraph"]) { case "Add Graph": if ($post_vars["graph_type"]=="S") { $sql = "insert into m_lib_graph_linegraph (graph_title, graph_width, graph_height, graph_type, ". "graph_xlabel, graph_y1label, graph_barcolor, graph_sql, graph_flag, module_id) ". "values ('".$post_vars["graph_title"]."', '".$post_vars["graph_width"]."', ". "'".$post_vars["graph_height"]."', '".$post_vars["graph_type"]."', '".$post_vars["graph_xlabel"]."', ". "'".$post_vars["graph_y1label"]."', '".$post_vars["graph_barcolor"]."', '".$post_vars["graph_sql"]."', ". "'".$post_vars["graph_flag"]."', '".$post_vars["module"]."')"; } else { print $sql = "insert into m_lib_graph_linegraph (graph_title, graph_width, graph_height, graph_type, ". "graph_xlabel, graph_y1label, graph_y2label, graph_barcolor, graph_sql, graph_flag, module_id) ". "values ('".$post_vars["graph_title"]."', '".$post_vars["graph_width"]."', ". "'".$post_vars["graph_height"]."', '".$post_vars["graph_type"]."', '".$post_vars["graph_xlabel"]."', ". "'".$post_vars["graph_y1label"]."', '".$post_vars["graph_y2label"]."', '".$post_vars["graph_barcolor"]."', '".$post_vars["graph_sql"]."', ". "'".$post_vars["graph_flag"]."', '".$post_vars["module"]."')"; } if ($result = mysql_query($sql)) { //header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&report_menu=GRAPHS&graph=LINE"); } break; case "Update Graph": if ($post_vars["graph_type"]=="S") { $sql = "update m_lib_graph_linegraph set ". "graph_title = '".$post_vars["graph_title"]."', ". "graph_type = '".$post_vars["graph_type"]."', ". "graph_xlabel = '".$post_vars["graph_xlabel"]."', ". "graph_y1label = '".$post_vars["graph_y1label"]."', ". "graph_barcolor = '".$post_vars["graph_barcolor"]."', ". "graph_height = '".$post_vars["graph_height"]."', ". "graph_width = '".$post_vars["graph_width"]."', ". "graph_flag = '".$post_vars["graph_flag"]."', ". "graph_sql = '".$post_vars["graph_sql"]."' ". "where graph_id = '".$post_vars["graph_id"]."'"; } else { $sql = "update m_lib_graph_linegraph set ". "graph_title = '".$post_vars["graph_title"]."', ". "graph_type = '".$post_vars["graph_type"]."', ". "graph_xlabel = '".$post_vars["graph_xlabel"]."', ". "graph_y1label = '".$post_vars["graph_y1label"]."', ". "graph_y2label = '".$post_vars["graph_y2label"]."', ". "graph_barcolor = '".$post_vars["graph_barcolor"]."', ". "graph_height = '".$post_vars["graph_height"]."', ". "graph_width = '".$post_vars["graph_width"]."', ". "graph_flag = '".$post_vars["graph_flag"]."', ". "graph_sql = '".$post_vars["graph_sql"]."' ". "where graph_id = '".$post_vars["graph_id"]."'"; } if ($result = mysql_query($sql)) { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&report_menu=GRAPHS&graph=LINE"); } break; case "Delete Graph": if (module::confirm_delete($menu_id, $post_vars, $get_vars)) { $sql = "delete from m_lib_graph_linegraph where graph_id = '".$post_vars["graph_id"]."'"; if ($result = mysql_query($sql)) { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&report_menu=GRAPHS&graph=LINE"); } } else { if ($post_vars["confirm_delete"]=="No") { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&report_menu=GRAPHS&graph=LINE"); } } break; } } } }
function process_vaccine() { // // called from _vaccine() // 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]; } if ($post_vars["submitvaccine"]) { if ($post_vars["vaccine_id"] && $post_vars["vaccine_name"]) { $vaccine_required = $post_vars["vaccine_required_flag"] ? "Y" : "N"; switch ($post_vars["submitvaccine"]) { case "Add Vaccine": $sql = "insert into m_lib_vaccine (vaccine_id, vaccine_name, vaccine_interval, vaccine_required, vaccine_desc) " . "values ('" . strtoupper($post_vars["vaccine_id"]) . "', '" . ucfirst($post_vars["vaccine_name"]) . "', '" . $post_vars["vaccine_interval"] . "', '{$vaccine_required}', '" . $post_vars["vaccine_desc"] . "')"; if ($result = mysql_query($sql)) { header("location: " . $_SERVER["PHP_SELF"] . "?page=LIBRARIES&menu_id={$menu_id}"); } break; case "Update Vaccine": $sql = "update m_lib_vaccine set " . "vaccine_name = '" . ucfirst($post_vars["vaccine_name"]) . "', " . "vaccine_interval = '" . $post_vars["vaccine_interval"] . "', " . "vaccine_required = '{$vaccine_required}', " . "vaccine_desc = '" . $post_vars["vaccine_desc"] . "' " . "where vaccine_id = '" . $post_vars["vaccine_id"] . "'"; if ($result = mysql_query($sql)) { header("location: " . $_SERVER["PHP_SELF"] . "?page=LIBRARIES&menu_id={$menu_id}"); } break; case "Delete Vaccine": if (module::confirm_delete($menu_id, $post_vars, $get_vars)) { $sql = "delete from m_lib_vaccine " . "where vaccine_id = '" . $post_vars["vaccine_id"] . "'"; if ($result = mysql_query($sql)) { header("location: " . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&menu_id=" . $get_vars["menu_id"]); } } else { if ($post_vars["confirm_delete"] == "No") { header("location: " . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&menu_id=" . $get_vars["menu_id"]); } } break; } } } }
function process_location() { if (func_num_args()) { $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]; } switch ($post_vars["submitlocation"]) { case "Add Location": if ($post_vars["location_id"] && $post_vars["location_name"]) { $sql = "insert into location (location_id, location_name) ". "values ('".$post_vars["location_id"]."', '".$post_vars["location_name"]."')"; $result = mysql_query($sql); } break; case "Update Location": if ($post_vars["location_id"] && $post_vars["location_name"]) { $sql = "update location set ". "location_name = '".$post_vars["location_name"]."' ". "where location_id = '".$post_vars["location_id"]."'"; $result = mysql_query($sql); } break; case "Delete Location": if (module::confirm_delete($menu_id, $post_vars, $get_vars)) { $sql = "delete from location where location_id = '".$post_vars["location_id"]."'"; $result = mysql_query($sql); } break; } header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&method=LOC"); }
function process_philhealth_lab() { 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); } switch ($post_vars["submitlab"]) { case "Add Lab Exam": if ($post_vars["lab_exam"]) { foreach($post_vars["lab_exam"] as $key=>$value) { print $sql = "insert into m_lib_philhealth_labs (lab_id) ". "values ('$value')"; $result = mysql_query($sql); } header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]); } break; case "Delete Lab Exam": if (module::confirm_delete($menu_id, $post_vars, $get_vars)) { if ($post_vars["lab_exam"]) { print $sql = "delete from m_lib_philhealth_labs where lab_id = '".$post_vars["lab_exam"]."'"; $result = mysql_query($sql); header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]); } } else { if ($post_vars["confirm_delete"]=="No") { header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]); } } break; } }