function _consult_lab_urinalysis() { 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]; } if ($exitinfo = $this->missing_dependencies('urinalysis')) { return print $exitinfo; } $u = new urinalysis(); if ($_POST["submitlab"]) { //print_r($_POST); $q_request = mysql_query("SELECT request_id FROM m_consult_lab_urinalysis WHERE request_id='{$_POST['request_id']}'") or die("Cannot query 94:" . mysql_error()); if ($_POST["release_flag"] == 1) { $release = 'Y'; $release_date = date('Y-m-d H:i:s'); $q_update_lab = mysql_query("UPDATE m_consult_lab SET request_done='{$release}',done_timestamp='{$release_date}',done_user_id='{$_SESSION['userid']}' WHERE request_id='{$_POST['request_id']}' AND lab_id='{$_GET['lab_id']}'") or die("Cannot query 99" . mysql_error()); } else { $release = 'N'; $release_date = ''; } $pxid = healthcenter::get_patient_id($_GET[consult_id]); list($m, $d, $y) = explode('/', $_POST[urinalysis_date]); $date_lab_exam = $y . '-' . $m . '-' . $d; if (mysql_num_rows($q_request) != 0) { $update_urinalysis = mysql_query("UPDATE m_consult_lab_urinalysis SET consult_id='{$_GET['consult_id']}',patient_id='{$pxid}',date_lab_exam='{$date_lab_exam}',physical_color='{$_POST['sel_color']}',physical_reaction='{$_POST['sel_reaction']}',physical_transparency='{$_POST['sel_transparency']}',physical_gravity='{$_POST['sel_gravity']}',physical_ph='{$_POST['sel_ph']}',chem_albumin='{$_POST['sel_albumin']}',chem_sugar='{$_POST['sel_sugar']}',chem_pregnancy='{$_POST['sel_pregnancy']}',sediments_rbc='{$_POST['txt_red']}',sediments_pus='{$_POST['txt_pus']}',sediments_epithelial='{$_POST['txt_epithelial']}',sediments_urates='{$_POST['txt_amorphous']}',sediments_calcium='{$_POST['txt_calcium_oxelates']}',sediments_fat='{$_POST['txt_fat']}',sediments_phosphate='{$_POST['txt_triple']}',sediments_uric='{$_POST['txt_uric']}',sediments_amorphous='{$_POST['txt_amorphouse_phosphate']}',sediments_carbonates='{$_POST['txt_calcium_carb']}',sediments_bacteria='{$_POST['txt_bacteria']}',sediments_mucus='{$_POST['txt_mucus']}',cast_coarsely='{$_POST['txt_granular']}',cast_pus='{$_POST['txt_pus_cast']}',cast_hyaline='{$_POST['txt_hyaline']}',cast_finely='{$_POST['txt_finely_cast']}',cast_redcell='{$_POST['txt_red_cell']}',cast_waxy='{$_POST['txt_wax']}',release_flag='{$release}',release_date='{$release_date}',user_id='{$_SESSION['userid']}' WHERE request_id='{$_POST['request_id']}'") or die("Cannot query 114" . mysql_error()); //update the db contents of urinalysis form } else { $update_urinalysis = mysql_query("INSERT INTO m_consult_lab_urinalysis SET consult_id='{$_GET['consult_id']}',request_id='{$_POST['request_id']}',patient_id='{$pxid}',date_lab_exam='{$date_lab_exam}',physical_color='{$_POST['sel_color']}',physical_reaction='{$_POST['sel_reaction']}',physical_transparency='{$_POST['sel_transparency']}',physical_gravity='{$_POST['sel_gravity']}',physical_ph='{$_POST['sel_ph']}',chem_albumin='{$_POST['sel_albumin']}',chem_sugar='{$_POST['sel_sugar']}',chem_pregnancy='{$_POST['sel_pregnancy']}',sediments_rbc='{$_POST['txt_red']}',sediments_pus='{$_POST['txt_pus']}',sediments_epithelial='{$_POST['txt_epithelial']}',sediments_urates='{$_POST['txt_amorphous']}',sediments_calcium='{$_POST['txt_calcium_oxelates']}',sediments_fat='{$_POST['txt_fat']}',sediments_phosphate='{$_POST['txt_triple']}',sediments_uric='{$_POST['txt_uric']}',sediments_amorphous='{$_POST['txt_amorphouse_phosphate']}',sediments_carbonates='{$_POST['txt_calcium_carb']}',sediments_bacteria='{$_POST['txt_bacteria']}',sediments_mucus='{$_POST['txt_mucus']}',cast_coarsely='{$_POST['txt_granular']}',cast_pus='{$_POST['txt_pus_cast']}',cast_hyaline='{$_POST['txt_hyaline']}',cast_finely='{$_POST['txt_finely_cast']}',cast_redcell='{$_POST['txt_red_cell']}',cast_waxy='{$_POST['txt_wax']}',release_flag='{$release}',release_date='{$release_date}',user_id='{$_SESSION['userid']}'") or die("Cannot query 116" . mysql_error()); //insert into the db the contents of urinalysis form } if ($update_urinalysis) { echo "<script language='Javascript'>"; echo "window.alert('Urinalysis data was successfully been saved.')"; echo "</script>"; } } $u->form_consult_lab_urinalysis($menu_id, $post_vars, $get_vars); }
function _consult_lab_hematology() { 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]; } if ($exitinfo = $this->missing_dependencies('hematology')) { return print $exitinfo; } //print_r($); $h = new hematology(); if ($_POST["submitlab"] == 'Update Lab Exam') { $q_request = mysql_query("SELECT request_id FROM m_consult_lab_hematology WHERE request_id='{$_POST['request_id']}'") or die("Cannot query 94:" . mysql_error()); if ($_POST["release_flag"] == 1) { $release = 'Y'; $release_date = date('Y-m-d H:i:s'); $q_update_lab = mysql_query("UPDATE m_consult_lab SET request_done='{$release}',done_timestamp='{$release_date}',done_user_id='{$_SESSION['userid']}' WHERE request_id='{$_POST['request_id']}'") or die("Cannot query 99" . mysql_error()); } else { $release = 'N'; $release_date = ''; } $pxid = healthcenter::get_patient_id($_GET[consult_id]); list($m, $d, $y) = explode('/', $_POST[hematology_date]); $date_lab_exam = $y . '-' . $m . '-' . $d; if (mysql_num_rows($q_request) != 0) { $update_hematology = mysql_query("UPDATE m_consult_lab_hematology SET consult_id='{$_GET['consult_id']}',request_id='{$_POST['request_id']}',patient_id='{$pxid}',date_lab_exam='{$date_lab_exam}',hemoglobin='{$_POST['txt_hemoglobin']}',hematocrit='{$_POST['txt_hemocrit']}',rbc='{$_POST['txt_rbc']}',rbc_mcv='{$_POST['txt_mcv']}',rbc_mchc='{$_POST['txt_mchc']}',rbc_mch='{$_POST['txt_mch']}',wbc='{$_POST['txt_wbc']}',wbc_polys='{$_POST['txt_polys']}',wbc_lympho='{$_POST['txt_lympho']}',wbc_mxd='{$_POST['txt_mxd']}',wbc_mono='{$_POST['txt_mono']}',wbc_eosin='{$_POST['txt_eosin']}',wbc_baso='{$_POST['txt_baso']}',platelet='{$_POST['txt_platelet']}',reticulocytes='{$_POST['txt_reticulocytes']}',esr='{$_POST['txt_esr']}',clotting_time='{$_POST['txt_clot']}',bleeding_time='{$_POST['txt_bleeding']}',malaria='{$_POST['txt_malaria']}',slit_smear='{$_POST['txt_slit_smear']}',fbs='{$_POST['txt_fbs']}',blood_type='{$_POST['sel_bloodtype']}',release_flag='{$release}',release_date='{$release_date}',user_id='{$_SESSION['userid']}',others='{$_POST['txt_others']}',rh='{$_POST['sel_rh']}',stabs='{$_POST['txt_stabs']}' WHERE request_id='{$_GET['request_id']}'") or die("Cannot query 99: " . mysql_error()); } else { $update_hematology = mysql_query("INSERT INTO m_consult_lab_hematology SET consult_id='{$_GET['consult_id']}',request_id='{$_POST['request_id']}',patient_id='{$pxid}',date_lab_exam='{$date_lab_exam}',hemoglobin='{$_POST['txt_hemoglobin']}',hematocrit='{$_POST['txt_hemocrit']}',rbc='{$_POST['txt_rbc']}',rbc_mcv='{$_POST['txt_mcv']}',rbc_mchc='{$_POST['txt_mchc']}',rbc_mch='{$_POST['txt_mch']}',wbc='{$_POST['txt_wbc']}',wbc_polys='{$_POST['txt_polys']}',wbc_lympho='{$_POST['txt_lympho']}',wbc_mxd='{$_POST['txt_mxd']}',wbc_mono='{$_POST['txt_mono']}',wbc_eosin='{$_POST['txt_eosin']}',wbc_baso='{$_POST['txt_baso']}',platelet='{$_POST['txt_platelet']}',reticulocytes='{$_POST['txt_reticulocytes']}',esr='{$_POST['txt_esr']}',clotting_time='{$_POST['txt_clot']}',bleeding_time='{$_POST['txt_bleeding']}',malaria='{$_POST['txt_malaria']}',slit_smear='{$_POST['txt_slit_smear']}',fbs='{$_POST['txt_fbs']}',blood_type='{$_POST['sel_bloodtype']}',release_flag='{$release}',release_date='{$release_date}',user_id='{$_SESSION['userid']}',others='{$_POST['txt_others']}',rh='{$_POST['sel_rh']}',stabs='{$_POST['txt_stabs']}'") or die("Cannot query 102: " . mysql_error()); } //print_r($_POST); if ($update_hematology) { echo "<script language='Javascript'>"; echo "window.alert('Hematology data was successfully been saved.')"; echo "</script>"; } } $h->form_consult_lab_hematology($menu_id, $post_vars, $get_vars); }
function display_service_record() { 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_id = healthcenter::get_patient_id($get_vars["consult_id"]); $sql = "select ccdev_id, service_id, date_format(ccdev_timestamp,'%a %d %b %Y') service_date, ccdev_timestamp ". "from m_consult_ccdev_services ". "where patient_id = '$patient_id' order by service_id, ccdev_timestamp desc"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { while (list($cid, $service, $sdate, $ts) = mysql_fetch_array($result)) { print "<img src='../images/arrow_redwhite.gif' border='0'/> "; print "<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=ccdev&ccdev=SVC&service_id=$service&sts=$ts&ccdev_id=$cid#detail'>".ccdev::get_service_name($service)."</a> $sdate<br/>"; if ($get_vars["service_id"]==$service && $get_vars["ts"]=$ts && $get_vars["ccdev_id"] = $cid) { ccdev::show_service_details($menu_id, $post_vars, $get_vars); } } } else { print "<font color='red'>No records</font><br/>"; } } }
function process_consult() { 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); } // make sure you catch where patient_id is coming from if ($post_vars["consult_patient_id"]) { $patient_id = $post_vars["consult_patient_id"]; } elseif ($get_vars["enter_consult"]) { $patient_id = $get_vars["enter_consult"]; } elseif ($post_vars["patient_id"]) { $patient_id = $post_vars["patient_id"]; } // check if consult records for today contain // patient id to avoid possible duplicate consults // limitation of this software enforced constraint // is if consult exceeds one day (not possible in health centers) if (healthcenter::is_patient_in_consult($patient_id)) { $post_vars["patient_id"] = $patient_id; if (healthcenter::confirm_add_consult($menu_id, $post_vars, $get_vars)) { $sql = "insert into m_consult (patient_id, user_id, healthcenter_id, consult_date) ". "values ('$patient_id', '".$_SESSION["userid"]."', '".$_SESSION["datanode"]["code"]."', sysdate())"; if ($result = mysql_query($sql)) { // get insert_id into header $insert_id = mysql_insert_id(); // if patient comes from appointment page // update appointment table if ($post_vars["schedule_id"]) { $sql_appt = "update m_consult_appointments set ". "actual_date = sysdate(), ". "visit_done = 'Y' ". "where schedule_id = '".$post_vars["schedule_id"]."'"; $result_appt = mysql_query($sql_appt); header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&patient_id=".$get_vars["patient_id"]."&schedule_id=".$get_vars["schedule_id"]."&year=".$get_vars["year"]."&month=".$get_vars["month"]."&day=".$get_vars["day"]."&s=0#detail"); } else { header("location: ".$_SERVER["PHP_SELF"]."?page=CONSULTS&menu_id=".$get_vars["menu_id"]."&consult_id=$insert_id&ptmenu=DETAILS"); } } } else { if ($post_vars["confirm_add_consult"]=="No") { header("location: ".$_SERVER["PHP_SELF"]."?page=CONSULTS&menu_id=".$get_vars["menu_id"]."&consult_id=$insert_id&ptmenu=DETAILS"); } } } else { // insert into consult table if there are no // possible duplicate entries $sql = "insert into m_consult (patient_id, user_id, healthcenter_id, consult_date) ". "values ('$patient_id', '".$_SESSION["userid"]."', '".$_SESSION["datanode"]["code"]."', sysdate())"; if ($result = mysql_query($sql)) { // get insert_id into header $insert_id = mysql_insert_id(); // if patient comes from appointment page // update appointment table if ($post_vars["schedule_id"]) { $sql_appt = "update m_consult_appointments set ". "actual_date = sysdate(), ". "visit_done = 'Y' ". "where schedule_id = '".$post_vars["schedule_id"]."'"; $result_appt = mysql_query($sql_appt); header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&patient_id=".$get_vars["patient_id"]."&schedule_id=".$get_vars["schedule_id"]."&year=".$get_vars["year"]."&month=".$get_vars["month"]."&day=".$get_vars["day"]."&s=0#detail"); } else { header("location: ".$_SERVER["PHP_SELF"]."?page=CONSULTS&menu_id=".$get_vars["menu_id"]."&consult_id=$insert_id&ptmenu=DETAILS"); } } } }
function process_consult_notes() { 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"]); $consult_date = healthcenter::get_consult_date($get_vars["consult_id"]); switch($post_vars["submitnotes"]) { case "Create Notes": $sql = "insert into m_consult_notes (consult_id, patient_id, user_id, notes_timestamp) ". "values ('".$get_vars["consult_id"]."', '$patient_id', '".$_SESSION["userid"]."', sysdate())"; if ($result = mysql_query($sql)) { $insert_id = mysql_insert_id(); header("location: ".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&consult_id=".$get_vars["consult_id"]."&ptmenu=NOTES&module=notes¬es=NOTES¬es_id=$insert_id"); } break; case "Save Complaint": if ($post_vars["complaintcat"]) { foreach ($post_vars["complaintcat"] as $key=>$value) { $sql = "insert into m_consult_notes_complaint (notes_id, consult_id, patient_id, complaint_id, complaint_date, user_id, complaint_timestamp) ". "values ('".$get_vars["notes_id"]."', '".$get_vars["consult_id"]."', '$patient_id', '$value', '$consult_date', '".$_SESSION["userid"]."', sysdate())"; $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=NOTES&module=notes¬es=CC¬es_id=".$get_vars["notes_id"]); } break; case "Save History": if ($post_vars["history_text"]) { $sql = "update m_consult_notes set ". "notes_history = '".addslashes($post_vars["history_text"])."' ". "where notes_id = '".$get_vars["notes_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"]."&ptmenu=NOTES&module=notes¬es=HX¬es_id=".$get_vars["notes_id"]); } } break; case "Save PE": if ($post_vars["pe_text"]) { $sql = "update m_consult_notes set ". "notes_physicalexam = '".addslashes($post_vars["pe_text"])."' ". "where notes_id = '".$get_vars["notes_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"]."&ptmenu=NOTES&module=notes¬es=PE¬es_id=".$get_vars["notes_id"]); } } break; case "Save Diagnosis Class": if ($post_vars["dxclass"]) { foreach($post_vars["dxclass"] as $key=>$value) { $sql = "insert into m_consult_notes_dxclass (notes_id, consult_id, patient_id, class_id, diagnosis_date, user_id, diagnosis_timestamp) ". "values ('".$get_vars["notes_id"]."', '".$get_vars["consult_id"]."', '$patient_id', '$value', '$consult_date', '".$_SESSION["userid"]."', sysdate())"; $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=NOTES&module=notes¬es=DX¬es_id=".$get_vars["notes_id"]); } break; case "Save Plan": if ($post_vars["plan_text"]) { $sql = "update m_consult_notes set ". "notes_plan = '".addslashes($post_vars["plan_text"])."' ". "where notes_id = '".$get_vars["notes_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"]."&ptmenu=NOTES&module=notes¬es=TX¬es_id=".$get_vars["notes_id"]); } } break; } }
function disp_form_diag(){ 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]; $disease = $arg_list[5]; endif; $patient_id = healthcenter::get_patient_id($get_vars["consult_id"]); switch($disease){ case "anemia": if($post_vars["submit_diagdetails"]=="Save Anemia Tx Info"): $anemia_tx_sdate = (!empty($post_vars["txt_iron_started"]))?$this->convert_date($post_vars["txt_iron_started"]):'0000-00-00'; $anemia_tx_cdate = (!empty($post_vars["txt_iron_completed"]))?$this->convert_date($post_vars["txt_iron_completed"]):'0000-00-00'; $anemia_sdate_ok = $this->get_age_diff($anemia_tx_sdate,$get_vars,$patient_id); $anemia_edate_ok = $this->get_age_diff($anemia_tx_cdate,$get_vars,$patient_id); if($anemia_sdate_ok==1 && $anemia_edate_ok==1): $update_anemia = mysql_query("UPDATE m_consult_notes SET anemia_start_date='$anemia_tx_sdate',anemia_completed_date='$anemia_tx_cdate' WHERE consult_id='$get_vars[consult_id]'") or die("Cannot query: 1378"); else: echo "<font color='red' size='2'>Anemia Tx Info not saved.One of the date of intakes should occur on or after this consultation.</font>"; endif; endif; $q_anemia = mysql_query("SELECT anemia_start_date,anemia_completed_date FROM m_consult_notes WHERE consult_id='$get_vars[consult_id]'") or die("Cannot query: 1386"); list($anemia_sdate,$anemia_cdate) = mysql_fetch_array($q_anemia); $anemia_sdate = ($anemia_sdate!='0000-00-00')?$this->convert_date_cal($anemia_sdate):''; $anemia_cdate = ($anemia_cdate!='0000-00-00')?$this->convert_date_cal($anemia_cdate):''; echo "<form method='post' name='form_anemia'>"; echo "<span class='boxtitle'>ANEMIC CHILDREN GIVEN IRON SUPPLEMENTATION</span>"; echo "<table>"; echo "<tr><td class='tinylight'><b>DATE STARTED</b></td><td><input type='text' size='7' name='txt_iron_started' value='$anemia_sdate'></input>"; echo " <a href=\"javascript:show_calendar4('document.form_anemia.txt_iron_started', document.form_anemia.txt_iron_started.value);\"><img src='../images/cal.gif' width='16' height='16' border='0' alt='Click Here to Pick up the date'></a>"; echo "<td></tr>"; echo "<tr><td class='tinylight'><b>DATE COMPLETED</b></td><td><input type='text' size='7' name='txt_iron_completed' value='$anemia_cdate'></input>"; echo " <a href=\"javascript:show_calendar4('document.form_anemia.txt_iron_completed', document.form_anemia.txt_iron_completed.value);\"><img src='../images/cal.gif' width='16' height='16' border='0' alt='Click Here to Pick up the date'></a>"; echo "<td></tr>"; echo "<tr align='center'><td colspan='2'>"; echo "<input type='submit' name='submit_diagdetails' value='Save Anemia Tx Info' class='tinylight' style='border: 1px solid black'></input>"; echo "</td></tr>"; echo "</table>"; echo "</form>"; break; case "diarrhea": if($post_vars["submit_diagdetails"]=="Save Diarrhea Tx Info"): $ort = (!empty($post_vars["date_ort_given"]))?$this->convert_date($post_vars["date_ort_given"]):'0000-00-00'; $ors = (!empty($post_vars["date_ors_given"]))?$this->convert_date($post_vars["date_ors_given"]):'0000-00-00'; $orswz = (!empty($post_vars["date_orswz_given"]))?$this->convert_date($post_vars["date_orswz_given"]):'0000-00-00'; $ort_ok = $this->get_age_diff($ort,$get_vars,$patient_id); $ors_ok = $this->get_age_diff($ors,$get_vars,$patient_id); $orswz_ok = $this->get_age_diff($orswz,$get_vars,$patient_id); if($ort_ok==1 && $ors_ok==1 && $orswz_ok==1): $update_diarrhea_tx = mysql_query("UPDATE m_consult_notes SET diarrhea_ort='$ort',diarrhea_ors='$ors',diarrhea_orswz='$orswz' WHERE consult_id='$get_vars[consult_id]'") or die("Cannot query: 1445"); else: echo "<font color='red' size='2'>Diarrhea Tx Info cannot be saved. One of the dates occured before this consultation.</font>"; endif; endif; $q_diarrhea = mysql_query("SELECT diarrhea_ort,diarrhea_ors,diarrhea_orswz FROM m_consult_notes WHERE consult_id='$get_vars[consult_id]'") or die("Cannot query: 1406"); list($date_ort,$date_ors,$date_orswz) = mysql_fetch_array($q_diarrhea); $date_ort = ($date_ort!='0000-00-00')?$this->convert_date_cal($date_ort):''; $date_ors = ($date_ors!='0000-00-00')?$this->convert_date_cal($date_ors):''; $date_orswz = ($date_orswz!='0000-00-00')?$this->convert_date_cal($date_orswz):''; echo "<form method='post' name='form_diarrhea'>"; echo "<span class='boxtitle'>DIARRHEA TREAMENT INFORMATION</span>"; echo "<table>"; echo "<tr><td class='tinylight'><b>DATE ORT WAS GIVEN</b></td><td><input type='text' size='7' name='date_ort_given' value='$date_ort'></input>"; echo " <a href=\"javascript:show_calendar4('document.form_diarrhea.date_ort_given', document.form_diarrhea.date_ort_given.value);\"><img src='../images/cal.gif' width='16' height='16' border='0' alt='Click Here to Pick up the date'></a>"; echo "</td></tr>"; echo "<tr><td class='tinylight'><b>DATE ORS WAS GIVEN</b></td><td><input type='text' size='7' name='date_ors_given' value='$date_ors'></input>"; echo " <a href=\"javascript:show_calendar4('document.form_diarrhea.date_ors_given', document.form_diarrhea.date_ors_given.value);\"><img src='../images/cal.gif' width='16' height='16' border='0' alt='Click Here to Pick up the date'></a>"; echo "</td></tr>"; echo "<tr><td class='tinylight'><b>DATE ORS WITH ZINC WAS GIVEN</b></td><td><input type='text' size='7' name='date_orswz_given' value='$date_orswz'></input>"; echo " <a href=\"javascript:show_calendar4('document.form_diarrhea.date_orswz_given', document.form_diarrhea.date_orswz_given.value);\"><img src='../images/cal.gif' width='16' height='16' border='0' alt='Click Here to Pick up the date'></a>"; echo "</td></tr>"; echo "<tr align='center'><td colspan='2'><input type='submit' name='submit_diagdetails' value='Save Diarrhea Tx Info' class='tinylight' style='border: 1px solid black'></input></td></tr>"; echo "</table>"; echo "</form>"; break; case "pneumonia": if($post_vars["submit_diagdetails"]=="Save Pneumonia Tx Info"): $pneumonia_tx = (!empty($post_vars["date_pneu_given"]))?$this->convert_date($post_vars["date_pneu_given"]):'0000-00-00'; $pneumonia_ok = $this->get_age_diff($pneumonia_tx,$get_vars,$patient_id); if($pneumonia_ok==1): $update_pneumonia = mysql_query("UPDATE m_consult_notes SET pneumonia_date_given='$pneumonia_tx' WHERE consult_id='$get_vars[consult_id]'") or die(mysql_error()); else: echo "<font color='red'>Pneumonia Tx Info cannot be saved. Date of treatment should occur on or after this consultation.</font>"; endif; endif; $q_pneumonia = mysql_query("SELECT pneumonia_date_given FROM m_consult_notes WHERE consult_id='$get_vars[consult_id]'") or die("Cannot query: 1477"); list($pneu_date) = mysql_fetch_array($q_pneumonia); $pneu_date = ($pneu_date!='0000-00-00')?$this->convert_date_cal($pneu_date):''; echo "<form method='post' name='form_pneumonia'>"; echo "<span class='boxtitle'>PNEUMONIA TREATMENT INFORMATION</span>"; echo "<table>"; echo "<tr><td class='tinylight'><b>DATE TREATMENT GIVEN</b></td><td><input type='text' size='7' name='date_pneu_given' value='$pneu_date'></input>"; echo " <a href=\"javascript:show_calendar4('document.form_pneumonia.date_pneu_given', document.form_pneumonia.date_pneu_given.value);\"><img src='../images/cal.gif' width='16' height='16' border='0' alt='Click Here to Pick up the date'></a>"; echo "</td></tr>"; echo "<tr align='center'><td colspan='2'><input type='submit' name='submit_diagdetails' value='Save Pneumonia Tx Info' class='tinylight' style='border: 1px solid black'></input></td></tr>"; echo "</table>"; echo "</form>"; break; default: break; } }
function process_send_request() { 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"]); switch ($post_vars["submitlab"]) { case "Send Request": mysql_query("ALTER TABLE `m_consult_lab` DROP PRIMARY KEY, ADD PRIMARY KEY(`request_id`)"); if ($post_vars["lab_exam"]) { foreach ($post_vars["lab_exam"] as $key => $value) { $sql = "insert into m_consult_lab (consult_id, patient_id, lab_id, request_timestamp, request_user_id) " . "values ('" . $get_vars["consult_id"] . "', '{$patient_id}', '{$value}', sysdate(), '" . $_SESSION["userid"] . "')"; 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=" . $get_vars["ptmenu"]); } } } break; case "Print Referral": break; case "Edit Lab Exam": $q_lab = mysql_query("UPDATE m_consult_lab SET request_done='N' WHERE request_id='{$_GET['request_id']}'") or die("Cannot query: 362 " . mysql_error()); break; case "Print Lab Result": header("Location: ../chits_query/pdf_reports/lab_result.php"); break; default: break; } }
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 display_service_record() { 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($get_vars); echo "<br>";*/ $patient_id = healthcenter::get_patient_id($get_vars["consult_id"]); $sql = "select ccdev_id, service_id, date_format(ccdev_timestamp,'%a %d %b %Y') service_date, ccdev_timestamp,date_format(ccdev_service_date,'%a %d %b %Y') actual_service_date,ccdev_service_date " . "from m_consult_ccdev_services " . "where patient_id = '{$patient_id}' order by service_id, ccdev_timestamp desc"; $result = mysql_query($sql) or die(mysql_error()); if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { while (list($cid, $service, $sdate, $ts, $actual_service_date, $serv_date) = mysql_fetch_array($result)) { print "<img src='../images/arrow_redwhite.gif' border='0'/> "; print "<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=ccdev&ccdev=SVC&service_id={$service}&sts={$ts}&ccdev_id={$cid}#detail'>" . ccdev::get_service_name($service) . "</a> "; echo $serv_date == '0000-00-00' ? $sdate . " <font color='red' size='2'><b>(pls update actual service date)</b></font>" : $actual_service_date; echo "<br/>"; if ($get_vars["service_id"] == $service && $get_vars["sts"] == $ts && $get_vars["ccdev_id"] == $cid) { //this was '=' instead of '==' before ccdev::show_service_details($menu_id, $post_vars, $get_vars); } } } else { print "<font color='red'>No records</font><br/>"; } } }
function edit_surgical_history() { if (func_num_args() > 0) { $arg_list = func_get_args(); $post_vars = $arg_list[0]; $get_vars = $arg_list[1]; } print "<script>\n\t\t\t\tfunction change(value)\n\t\t\t\t{\n\t\t\t\t\tdocument.getElementById(\"operation\").value= value.operation;\n\t\t\t\t\tdocument.getElementById(\"operationdate\").value= value.date;\n\t\t\t\t\tdocument.getElementById(\"save\").value= value.text;\n\t\t\t\t\tdocument.getElementById(\"recordID\").value= value.id;\n\t\t\t\t}\n\t\t\t\t</script>"; $patient_id = healthcenter::get_patient_id($_GET["consult_id"]); $sql = "select record_id, operation, operation_date from m_patient_history_surgical where patient_id = '{$patient_id}' order by operation_date desc"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { print "<br/><br/>"; print "<table width='320px' style='border: 1px solid black;border-collapse:collapse'>"; print "<tr class='tinylight'>"; print "<th width='170px' style='border: 1px solid black'>Operation</th>"; print "<th width='70px' style='border: 1px solid black'>Date</th>"; print "<th width='50px' style='border: 1px solid black'>Action</th>"; print "</tr>"; while (list($id, $operation, $operation_date) = mysql_fetch_array($result)) { $date = date("m/d/Y", strtotime($operation_date)); print "<tr>"; print "<td style='border: 1px solid black'>{$operation}</td>"; print "<td style='border: 1px solid black; text-align:center;'>{$operation_date}</td>"; print "<td style='border: 1px solid black; text-align:center;'><input id='edit' type='button' name='edit' value='Edit' onclick=\"change({operation:'{$operation}',date:'{$date}',text:'Update Surgical History',id:'{$id}'})\"></td>"; print "</tr>"; } print "</table>"; } } }
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 _details_imci() { 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); } // check if age correct $patient_id = healthcenter::get_patient_id($get_vars["consult_id"]); if (!ptgroup::is_child(patient::get_age($patient_id))) { return print "<font color='red'>Module inappropriate for age.</font><br/>"; } }
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); } list($month, $day, $year) = explode("/", $post_vars["report_date"]); $report_date = $year . "-" . str_pad($month, 2, "0", STR_PAD_LEFT) . "-" . str_pad($day, 2, "0", STR_PAD_LEFT); // STEP 1. empty report tables for given date $sql_delete = "delete from m_consult_report_dailyservice where service_date = '{$report_date}'"; $result_delete = mysql_query($sql_delete); $sql_delete = "delete from m_consult_ccdev_report_dailyservice where service_date = '{$report_date}'"; $result_delete = mysql_query($sql_delete); $sql_delete = "delete from m_consult_mc_report_dailyservice where service_date = '{$report_date}'"; $result_delete = mysql_query($sql_delete); // STEP 2. get all consults for specified report date // records are unique for patient_id and service_date $sql_patient = "select c.patient_id, c.consult_id, " . "concat(p.patient_lastname, ', ', p.patient_firstname) patient_name, " . "round((to_days(c.consult_date)-to_days(p.patient_dob))/365,2) patient_age, " . "p.patient_gender " . "from m_consult c, m_patient p " . "where c.patient_id = p.patient_id " . "and to_days(c.consult_date) = to_days('{$report_date}')"; if ($result_patient = mysql_query($sql_patient)) { if (mysql_num_rows($result_patient)) { while ($patient = mysql_fetch_array($result_patient)) { // get family and address if ($family_id = family::get_family_id($patient["patient_id"])) { $patient_address = family::get_family_address($family_id); $barangay_name = family::barangay_name($family_id); } else { $family_id = 0; $patient_address = reminder::get_home_address($patient_id); $barangay_name = reminder::get_barangay($patient_id); } // get chief complaint and diagnosis from notes $complaints = notes::get_complaints($patient["patient_id"], $report_date); $diagnosis = notes::get_diagnosis_list($patient["patient_id"], $report_date); $treatment = notes::get_plan($patient["patient_id"], $report_date); //get vaccines $vaccines = $this->get_vaccines($patient["patient_id"], $report_date); $services = $this->get_services($patient["consult_id"], $patient["patient_id"], $report_date); $ptgroup = $this->get_ptgroup($patient["consult_id"], $report_date); $aog = $this->get_aog($patient["patient_id"], $report_date); $visit_seq = healthcenter::get_total_visits($patient["patient_id"]); if ($mc_id = mc::registry_record_exists($patient["patient_id"])) { $pp_weeks = mc::get_pp_weeks($mc_id, $patient["consult_id"]); //$visit_sequence = mc::get_ppvisit_sequence($mc_id, $patient["consult_id"]); } if ($complaints != '' || $diagnosis != '' || $treatment != '') { $sql_insert = "insert into m_consult_report_dailyservice (patient_id, patient_name, " . "patient_gender, patient_age, patient_address, patient_bgy, family_id, " . "notes_cc, notes_dx, notes_tx, service_date) values " . "('" . $patient["patient_id"] . "', '" . $patient["patient_name"] . "', " . "'" . $patient["patient_gender"] . "', '" . $patient["patient_age"] . "', " . "'{$patient_address}', '{$barangay_name}', '{$family_id}', " . "'{$complaints}', '{$diagnosis}', '{$treatment}', '{$report_date}')"; $result_insert = mysql_query($sql_insert); } if ($vaccines != '' || $services != '') { if ($ptgroup == 'CHILD') { $sql_insert = "insert into m_consult_ccdev_report_dailyservice (patient_id, " . "patient_name, patient_gender, patient_age, patient_address, patient_bgy, " . "family_id, service_given, vaccine_given, service_date) values " . "('" . $patient["patient_id"] . "', '" . $patient["patient_name"] . "', " . "'" . $patient["patient_gender"] . "', '" . $patient["patient_age"] . "', " . "'{$patient_address}', '{$barangay_name}', '{$family_id}', " . "'{$services}', '{$vaccines}', '{$report_date}')"; $result_insert = mysql_query($sql_insert); } if ($ptgroup == 'MATERNAL') { $sql_insert = "insert into m_consult_mc_report_dailyservice (patient_id, " . "patient_name, patient_gender, patient_age, aog_weeks, postpartum_weeks, patient_address, " . "patient_bgy, family_id, visit_sequence, service_given, vaccine_given, " . "service_date) values " . "('" . $patient["patient_id"] . "', '" . $patient["patient_name"] . "', " . "'" . $patient["patient_gender"] . "', '" . $patient["patient_age"] . "', " . "'{$aog}', '{$pp_weeks}', '{$patient_address}', '{$barangay_name}', '{$family_id}', '{$visit_seq}', " . "'{$services}', '{$vaccines}', '{$report_date}')"; $result_insert = mysql_query($sql_insert); } } } } } //STEP 3. display daily service report print "<br/>"; print "<b>DAILY SERVICE REPORT</b><br/>"; print "REPORT DATE : <b>" . $post_vars["report_date"] . "</b><br/><br/>"; $this->display_consults($report_date); $this->display_ccdev($report_date); $this->display_mc($report_date); $sql = "select count(distinct(patient_id)) from m_consult where " . "to_days(consult_date) = to_days('{$report_date}') and patient_id != '0'"; $result = mysql_result(mysql_query($sql), 0); print "<br/>"; print "Total No. of Today's Patients : {$result}"; }
function display_notifiable_diseases_hx() { // // displays notifiable diseases // entered for all consults // 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"]); $patient_name = patient::get_name($get_vars["patient_id"]); print "<table width='300'>"; print "<tr valign='top'><td>"; print "<b>" . FTITLE_NOTIFIABLE_DISEASES_CONSULT_HX . "</b><br>"; print "</td></tr>"; $sql = "select distinct h.consult_id, h.disease_id, l.disease_name, h.onset_date " . "from m_lib_disease_notifiable l, m_consult_disease_notifiable h " . "where l.disease_id = h.disease_id and h.patient_id = '{$patient_id}'"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { print "<tr valign='top'><td>"; while (list($cid, $did, $name, $onset) = mysql_fetch_array($result)) { print "<img src='../images/arrow_redwhite.gif' border='0'/> "; print "<a href='" . $_SERVER["SELF"] . "?page=" . $get_vars["page"] . "&menu_id=" . $get_vars["menu_id"] . "&consult_id=" . $get_vars["consult_id"] . "&ptmenu=DETAILS&module=philhealth&philhealth=LABS&pid={$hid}'>{$hid}</a> {$name} ({$onset}) <br/>"; } print "</td></tr>"; } else { print "<tr valign='top'><td><font color='red'>No records.</font></td></tr>"; } } print "</table><br>"; }
} } if (file_exists('../modules/graph/class.graph.php')) { include '../modules/graph/class.graph.php'; $graph = new graph; if (!$module->activated('graph') && $initmod) { $graph->init_sql(); $graph->init_menu(); $graph->init_deps(); $graph->init_lang(); $graph->init_help(); } } if (file_exists('../modules/healthcenter/class.healthcenter.php')) { include '../modules/healthcenter/class.healthcenter.php'; $healthcenter = new healthcenter; if (!$module->activated('healthcenter') && $initmod) { $healthcenter->init_sql(); $healthcenter->init_menu(); $healthcenter->init_deps(); $healthcenter->init_lang(); $healthcenter->init_help(); } } if (file_exists('../modules/icd10/class.icd10.php')) { include '../modules/icd10/class.icd10.php'; $icd10 = new icd10; if (!$module->activated('icd10') && $initmod) { $icd10->init_sql(); $icd10->init_menu(); $icd10->init_deps();
function check_if_vacc_exist() { $arr_old_vacc = array('DPT1', 'DPT2', 'DPT3', 'HEPB1', 'HEPB2', 'HEPB3'); $arr_new_vacc = array('PENTA1', 'PENTA2', 'PENTA3'); $patient_id = healthcenter::get_patient_id($_GET["consult_id"]); $type = ''; foreach ($_POST["vaccine"] as $key => $value) { if (in_array($value, $arr_old_vacc)) { $type = 'old'; } elseif (in_array($value, $arr_new_vacc)) { $type = 'new'; } else { } } if ($type != '') { if ($type == 'old') { $arr_new = array(); foreach ($arr_new_vacc as $key => $value) { array_push($arr_new, "'" . $value . "'"); } $str_new = implode(",", $arr_new); $q_vacc = mysql_query("SELECT consult_id FROM m_consult_vaccine WHERE patient_id='{$patient_id}' AND vaccine_id IN ( {$str_new} )") or die("Cannot query 1976: " . mysql_error()); if (mysql_num_rows($q_vacc) != 0) { echo "<script language=\"Javascript\">"; echo "alert('The client was vaccinated with pentavalent (5 in 1) vaccines already. Please record the succeeding pentavalent vaccine rounds instead.')"; echo "</script>"; return 0; } else { return 1; } } elseif ($type == 'new') { $arr_old = array(); foreach ($arr_old_vacc as $key => $value) { array_push($arr_old, "'" . $value . "'"); } $str_old = implode(",", $arr_old); $q_vacc = mysql_query("SELECT consult_id FROM m_consult_vaccine WHERE patient_id='{$patient_id}' AND vaccine_id IN ( {$str_old} )") or die("Cannot query 1980: " . mysql_error()); if (mysql_num_rows($q_vacc) != 0) { echo "<script language=\"Javascript\">"; echo "alert('The client was vaccinated with the traditional set of vaccines (non-pentavalent) already. Please record the succeeding vaccinations (non-pentavalent) according to the regular sequence.')"; echo "</script>"; return 0; } else { return 1; } } } else { return 1; } }
function _consult_dental() { echo "<form name='form_dental' action='$_POST[PHP_SELF]' method='POST'>"; $dental = new dental; $dental->toothnumber = 0; $dental->condition[$dental->toothnumber] = 'Y'; $dental->consult_id = $_GET['consult_id']; $dental->patient_id = healthcenter::get_patient_id($_GET['consult_id']); $dental->patient_age = healthcenter::get_patient_age($_GET['consult_id']); $dental->dentist = $_SESSION['userid']; // The following codes will initialize hidden textboxes and their values echo "<input type='hidden' name='h_patient_id' value='{$dental->patient_id}'></input>"; echo "<input type='hidden' name='h_consult_id' value='{$dental->consult_id}'></input>"; echo "<input type='hidden' name='h_dentist' value='{$dental->dentist}'></input>"; if (@$_POST['h_save_flag'] == 'GO') { $dental->new_dental_record(); print " "; $dental->show_message_if_patient_is_pregnant($dental->patient_id, date("Y-m-d")); echo " "; $dental->show_date_of_oral(); $dental->get_teeth_conditions($dental->patient_age); //echo " "; //$dental->select_tooth_and_condition($dental->patient_age); //echo " "; //$dental->show_teeth_conditions($dental->patient_age); print " "; $dental->show_teeth_conditions_v02(); echo " "; $dental->show_ohc_table_a($dental->patient_id); echo " "; $dental->show_ohc_table_b($dental->patient_id); echo " "; $dental->show_services_monitoring_chart($dental->patient_id); print " "; $dental->show_other_dental_services($dental->patient_id); echo " "; $dental->show_tooth_legends($dental->patient_age); } else { $dental->init_primary_keys(); print " "; $dental->show_message_if_patient_is_pregnant($dental->patient_id, date("Y-m-d")); echo " "; $dental->show_date_of_oral(); $dental->get_teeth_conditions($dental->patient_age); //echo " "; //$dental->select_tooth_and_condition($dental->patient_age); //echo " "; //$dental->show_teeth_conditions($dental->patient_age); print " "; $dental->show_teeth_conditions_v02(); echo " "; $dental->show_ohc_table_a($dental->patient_id); echo " "; $dental->show_ohc_table_b($dental->patient_id); echo " "; $dental->show_services_monitoring_chart($dental->patient_id); print " "; $dental->show_other_dental_services($dental->patient_id); echo " "; $dental->show_tooth_legends($dental->patient_age); } echo "<input type='hidden' name='h_save_flag' value='GO'></input>"; echo "</form>"; }
function unenroll_fp_px() { $pxid = healthcenter::get_patient_id($_GET[consult_id]); $delete_fp_method = mysql_query("DELETE FROM m_patient_fp_method WHERE fp_px_id='{$_POST['fp_px_id']}' AND patient_id='{$pxid}'") or die("Cannot query 1781 " . mysql_error()); $delete_fp_method_services = mysql_query("DELETE FROM m_patient_fp_method_service WHERE fp_px_id='{$_POST['fp_px_id']}' and patient_id='{$pxid}'") or die("Cannot query 1782 " . mysql_error()); if ($delete_fp_method && $delete_fp_method_services) { echo "<script language='Javascript'>"; echo "window.alert('Patient was unenrolled from this FP method.')"; echo "</script>"; } }
function display_vaccine_record_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 = healthcenter::get_patient_id($get_vars["consult_id"]); $sql = "select consult_id, user_id, patient_id, vaccine_timestamp, date_format(vaccine_timestamp, '%a %d %b %Y, %h:%i%p'), " . "vaccine_id, adr_flag, actual_vaccine_date, source_module " . "from m_consult_vaccine where " . "vaccine_id = '" . $get_vars["vaccine"] . "' and patient_id = '{$patient_id}' and " . "vaccine_timestamp = '" . $get_vars["ts"] . "'"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { list($cid, $uid, $pid, $vstamp, $vdate, $vid, $adr, $actual_date, $source) = mysql_fetch_array($result); print "<a name='detail'>"; print "<table width='250' cellpadding='3' style='border:1px dashed black'><tr><td>"; print "<form name='form_vaccine_detail' method='post' action='" . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&menu_id=" . $get_vars["menu_id"] . "&consult_id=" . $get_vars["consult_id"] . "&ptmenu=" . $get_vars["ptmenu"] . "&module=vaccine&vaccine={$vid}&ts={$vstamp}&actual={$actual_vdate}'>"; print "<span class='tinylight'>"; print "PATIENT: " . patient::get_name($pid) . "<br/>"; print "DATA SOURCE: " . strtoupper($source) . "<br/>"; print "VACCINE: " . vaccine::get_vaccine_name($vid) . "<br/>"; print "REPORT DATE: {$vdate}<br/>"; print "RECORDED BY: " . user::get_username($uid) . "<br/>"; print "ACTUAL VACCINE DATE:<br/>"; if ($actual_date != "0000-00-00") { list($year, $month, $day) = explode("-", $actual_date); $conv_date = "{$month}/{$day}/{$year}"; } print "<input type='text' size='10' maxlength='10' class='tinylight' name='actual_vaccine_date' value='" . ($conv_date ? $conv_date : $post_vars["actual_vaccine_date"]) . "' style='border: 1px solid #000000'> "; print "<a href=\"javascript:show_calendar4('document.form_vaccine_detail.actual_vaccine_date', document.form_vaccine_detail.actual_vaccine_date.value);\"><img src='../images/cal.gif' width='16' height='16' border='0' alt='Click Here to Pick up the date'></a><br>"; print "<input type='checkbox' name='adr_flag' " . ($adr == "Y" ? "checked" : "") . " value='1'/> " . INSTR_ADVERSE_VACCINE_REACTION . "<br/>"; print "<input type='hidden' name='vaccine' value='" . $get_vars["vaccine"] . "'/>"; print "<input type='hidden' name='vaccine_consult_id' value='{$cid}'/>"; print "<input type='hidden' name='ts' value='" . $get_vars["ts"] . "'/>"; if ($_SESSION["priv_delete"]) { print "<input type='submit' name='submitdetail' value='Delete Record' class='tinylight' style='border: 1px solid black'/> "; } if ($_SESSION["priv_update"]) { print "<input type='submit' name='submitdetail' value='Update Record' class='tinylight' style='border: 1px solid black'/> "; } print "</span>"; print "</form>"; print "</td></tr></table>"; } } }
function _consult_fp() { // // main submodule for family planning consults // // always check dependencies if ($exitinfo = $this->missing_dependencies('fp')) { return print $exitinfo; } 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); } $fp = new fp(); $fp->fp_menu($menu_id, $post_vars, $get_vars); if ($post_vars[submitfp]) { $fp->process_fp($menu_id, $post_vars, $get_vars); } $patient_id = healthcenter::get_patient_id($get_vars[consult_id]); switch ($get_vars[fp]) { case "VISIT1": if (!$fp->registry_record_exists($patient_id) || $post_vars[submitfp] == 'Update Visit 1') { $fp->form_fp_firstvisit($menu_id, $post_vars, $get_vars, $validuser, $isadmin); } break; case "HX": $fp->form_fp_medhx($menu_id, $post_vars, $get_vars); break; case "PE": $fp->form_fp_pe($menu_id, $post_vars, $get_vars); break; case "PELVIC": $fp->form_fp_pe($menu_id, $post_vars, $get_vars); break; case "SVC": default: $fp->form_fp_services($menu_id, $post_vars, $get_vars, $validuser, $isadmin); break; } }
function _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]; } if ($exitinfo = $this->missing_dependencies('fecalysis')) { return print $exitinfo; } $f = new fecalysis(); if ($_POST["submitlab"] == 'Update Lab Exam') { //print_r($_POST); $q_request = mysql_query("SELECT request_id FROM m_consult_lab_fecalysis WHERE request_id='{$_POST['request_id']}'") or die("Cannot query 101 " . mysql_error()); if ($_POST[release_flag] == 1) { $release = 'Y'; $release_date = date('Y-m-d H:i:s'); $q_update_lab = mysql_query("UPDATE m_consult_lab SET request_done='{$release}',done_timestamp='{$release_date}',done_user_id='{$_SESSION['userid']}' WHERE request_id='{$_POST['request_id']}' AND lab_id='{$_GET['lab_id']}'") or die("Cannot query 107 " . mysql_error()); } else { $release = 'N'; $release_date = ''; } $pxid = healthcenter::get_patient_id($_GET[consult_id]); list($m, $d, $y) = explode('/', $_POST[fecal_date]); $date_lab_exam = $y . '-' . $m . '-' . $d; if (mysql_num_rows($q_request) != 0) { $update_fecal = mysql_query("UPDATE m_consult_lab_fecalysis SET date_lab_exam='{$date_lab_exam}',fecal_color='{$_POST['fecal_color']}',fecal_consistency='{$_POST['fecal_consistency']}',fecal_occultblood='{$_POST['fecal_blood']}',fecal_ova='{$_POST['fecal_ova']}',fecal_wbc='{$_POST['fecal_wbc']}',fecal_rbc='{$_POST['fecal_rbc']}',fecal_bacteria='{$_POST['fecal_bacteria']}',fecal_fat='{$_POST['fecal_fat']}',fecal_starch='{$_POST['fecal_starch']}',fecal_others='{$_POST['fecal_others']}',release_flag='{$release}',release_date='{$release_date}' WHERE request_id='{$_GET['request_id']}'") or die("Cannot query 120 " . mysql_error()); } else { $insert_fecal = mysql_query("INSERT INTO m_consult_lab_fecalysis SET consult_id='{$_GET['consult_id']}', request_id='{$_POST['request_id']}', patient_id='{$pxid}', date_lab_exam='{$date_lab_exam}', fecal_color='{$_POST['fecal_color']}', fecal_consistency='{$_POST['fecal_consistency']}', fecal_occultblood='{$_POST['fecal_blood']}',fecal_ova='{$_POST['fecal_ova']}',fecal_wbc='{$_POST['fecal_wbc']}',fecal_rbc='{$_POST['fecal_rbc']}',fecal_bacteria='{$_POST['fecal_bacteria']}', fecal_fat='{$_POST['fecal_fat']}',fecal_starch='{$_POST['fecal_starch']}',fecal_others='{$_POST['fecal_others']}',user_id='{$_SESSION['userid']}',release_flag='{$release}',release_date='{$release_date}'") or die("Cannot query 106" . mysql_error()); } if ($update_fecal || $insert_fecal) { echo "<script language='Javascript'>"; echo "window.alert('Fecalysis data was successfully been saved.')"; echo "</script>"; } } $f->form_consult_lab_fecalysis($menu_id, $post_vars, $get_vars); }
function _family() { // // main program for family module // 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); } // always check dependencies if ($exitinfo = $this->missing_dependencies('family')) { return print($exitinfo); } mysql_query("ALTER TABLE `m_consult_notes` DROP PRIMARY KEY , ADD PRIMARY KEY (`notes_id`)"); print "<span class='patient'>".FTITLE_FAMILY_RECORDS."</span><br/>"; print "<table width='600' cellpadding='2'>"; print "<tr valign='top'><td width='50%'>"; // column 1 print "<b>".LBL_FOLDER_HOWTO."</b><br/>"; print "<ol>"; print "<li>If you are creating a new family folder, type in address and ". "barangay then click on the <b>Create Folder</b> button. Famiy numbers ". "are created sequentially and automatically.</li>"; print "<li>If you are looking for an existing family folder, ". "type in the name of a family member. Important - The patient ". "account to be included in ". "a family must be created first.</li>"; print "</ol>"; if ($post_vars["submitfolder"]) { $this->process_folder($menu_id, $post_vars, $get_vars); } if ($_SESSION["priv_add"]) { $this->form_folder($menu_id, $post_vars, $get_vars); } // end of column 1 print "</td><td>"; // column 2 if ($get_vars["delete_family_id"]) { $this->process_stats($menu_id, $post_vars, $get_vars); } $this->family_stats($menu_id, $post_vars, $get_vars); if ($get_vars["family_id"]) { $this->process_member($menu_id, $post_vars, $get_vars); $this->family_info($menu_id, $post_vars, $get_vars); } if ($post_vars["submitsearch"]) { $this->process_search($menu_id, $post_vars, $get_vars); } else { $this->familysearch($menu_id, $post_vars, $get_vars); } // end of column 2 print "</td></tr>"; print "<tr><td colspan='2'>"; healthcenter::consult_info($menu_id, $post_vars, $get_vars); print "</td></tr>"; print "</table>"; }
function check_fprec() { //function shall check if there exists an FP Service Record $pxid = healthcenter::get_patient_id($_GET[consult_id]); $q_fp = mysql_query("SELECT fp_id, plan_more_children, no_of_living_children_actual, no_of_living_children_desired, birth_interval_desired,educ_id, occup_id, spouse_name, spouse_educ_id, spouse_occup_id, ave_monthly_income FROM m_patient_fp WHERE patient_id='{$pxid}'") or die("Cannot query in form_fp_visit1: line 625"); return $q_fp; //returns a resource identifier }
function generate_summary() { if (func_num_args() > 0) { $arg_list = func_get_args(); $menu_id = $arg_list[0]; $post_vars = $arg_list[1]; $get_vars = $arg_list[2]; $validuser = $arg_list[3]; $isadmin = $arg_list[4]; //print_r($arg_list); } list($month, $day, $year) = explode("/", $post_vars["report_date"]); //$report_date = $year."-".str_pad($month, 2, "0", STR_PAD_LEFT)."-".str_pad($day, 2, "0", STR_PAD_LEFT); $report_date = $year . '-' . $month . '-' . str_pad($day, 2, "0", STR_PAD_LEFT); list($end_month, $end_day, $end_year) = explode("/", $post_vars["end_report_date"]); //$end_report_date = $end_year."-".str_pad($end_month, 2, "0", STR_PAD_LEFT)."-".str_pad($day, 2, "0", STR_PAD_LEFT); $end_report_date = $end_year . '-' . $end_month . '-' . str_pad($end_day, 2, "0", STR_PAD_LEFT); $_SESSION[report_date] = $report_date; $_SESSION[end_report_date] = $end_report_date; // STEP 1. empty report tables for given date $sql_delete = "delete from m_consult_report_dailyservice where service_date BETWEEN '{$report_date}' AND '{$end_report_date}'"; $result_delete = mysql_query($sql_delete); $sql_delete = "delete from m_consult_ccdev_report_dailyservice where service_date BETWEEN '{$report_date}' AND '{$end_report_date}'"; $result_delete = mysql_query($sql_delete); $sql_delete = "delete from m_consult_mc_report_dailyservice where service_date BETWEEN '{$report_date}' AND '{$end_report_date}'"; $result_delete = mysql_query($sql_delete); // STEP 2. get all consults for specified report date // records are unique for patient_id and service_date /*$sql_patient = "select c.patient_id, c.consult_id, ". "concat(p.patient_lastname, ', ', p.patient_firstname) patient_name, ". "round((to_days(c.consult_date)-to_days(p.patient_dob))/365,2) patient_age, ". "p.patient_gender ". "from m_consult c, m_patient p ". "where c.patient_id = p.patient_id ". "and to_days(c.consult_date) = to_days('$report_date')"; */ $sql_patient = "select c.patient_id, c.consult_id, " . "concat(p.patient_lastname, ', ', p.patient_firstname, ' ',p.patient_middle) patient_name, " . "round((to_days(c.consult_date)-to_days(p.patient_dob))/365,2) patient_age, " . "p.patient_gender,date_format(c.consult_date,'%h:%i %p') as consult_start,date_format(c.consult_end,'%h:%i %p') as consult_end, round((unix_timestamp(c.consult_end)-unix_timestamp(c.consult_date))/60,2) as consult_minutes, elapsed_time " . "from m_consult c, m_patient p " . "where c.patient_id = p.patient_id " . "and c.consult_date BETWEEN '{$report_date}' AND '{$end_report_date}'"; $result_patient = mysql_query($sql_patient) or die("Cannot query: 305 " . mysql_error()); if ($result_patient) { if (mysql_num_rows($result_patient)) { while ($patient = mysql_fetch_array($result_patient)) { // get family and address if ($family_id = family::get_family_id($patient["patient_id"])) { $patient_address = family::get_family_address($family_id); $barangay_id = family::barangay_id($family_id); } else { $family_id = 0; $barangay_id = 0; $patient_address = reminder::get_home_address($patient_id); //$barangay_name = reminder::get_barangay($patient_id); } // get chief complaint and diagnosis from notes $complaints = notes::get_complaints($patient["patient_id"], $report_date); $diagnosis = notes::get_diagnosis_list($patient["patient_id"], $report_date); $treatment = notes::get_plan($patient["patient_id"], $report_date); //get vaccines $vaccines = $this->get_vaccines($patient["patient_id"], $report_date, $end_report_date); $services = $this->get_services($patient["consult_id"], $patient["patient_id"], $report_date, $end_report_date); $ptgroup = $this->get_ptgroup($patient["consult_id"], $report_date, $end_report_date); $aog = $this->get_aog($patient["patient_id"], $report_date, $end_report_date); $visit_seq = healthcenter::get_total_visits($patient["patient_id"]); $philhealth_id = philhealth::get_philhealth_id($patient["patient_id"]); //get elapsed time and data and time started $elapsed_time = $this->get_str_elapsed($patient["consult_start"], $patient["consult_end"], $patient["elapsed_time"]); if ($mc_id = mc::registry_record_exists($patient["patient_id"])) { $pp_weeks = mc::get_pp_weeks($mc_id, $patient["consult_id"]); //$visit_sequence = mc::get_ppvisit_sequence($mc_id, $patient["consult_id"]); } if ($complaints != '' || $diagnosis != '' || $treatment != '') { $sql_insert = "insert into m_consult_report_dailyservice (patient_id, patient_name, " . "patient_gender, patient_age, patient_address, patient_bgy, family_id, philhealth_id, " . "notes_cc, notes_dx, notes_tx, service_date) values " . "('" . $patient["patient_id"] . "', '" . $patient["patient_name"] . "', " . "'" . $patient["patient_gender"] . "', '" . $patient["patient_age"] . "', " . "'{$patient_address}', '{$barangay_id}', '{$family_id}', '{$philhealth_id}', " . "'{$complaints}', '{$diagnosis}', '{$treatment}', '{$report_date}')"; $result_insert = mysql_query($sql_insert); } if ($vaccines != '' || $services != '') { if ($ptgroup == 'CHILD') { $sql_insert = "insert into m_consult_ccdev_report_dailyservice (patient_id, " . "patient_name, patient_gender, patient_age, patient_address, patient_bgy, " . "family_id, philhealth_id, service_given, vaccine_given, service_date) values " . "('" . $patient["patient_id"] . "', '" . $patient["patient_name"] . "', " . "'" . $patient["patient_gender"] . "', '" . $patient["patient_age"] . "', " . "'{$patient_address}', '{$barangay_id}', '{$family_id}', '{$philhealth_id}', " . "'{$services}', '{$vaccines}', '{$report_date}')"; $result_insert = mysql_query($sql_insert); } if ($ptgroup == 'MATERNAL') { $sql_insert = "insert into m_consult_mc_report_dailyservice (patient_id, " . "patient_name, patient_gender, patient_age, aog_weeks, postpartum_weeks, patient_address, " . "patient_bgy, family_id, philhealth_id, visit_sequence, service_given, vaccine_given, " . "service_date) values " . "('" . $patient["patient_id"] . "', '" . $patient["patient_name"] . "', " . "'" . $patient["patient_gender"] . "', '" . $patient["patient_age"] . "', " . "'{$aog}', '{$pp_weeks}', '{$patient_address}', '{$barangay_id}', '{$family_id}', '{$philhealth_id}', " . "'{$visit_seq}', '{$services}', '{$vaccines}', '{$report_date}')"; $result_insert = mysql_query($sql_insert); } } } /*$sql = "select patient_id 'PATIENT ID', concat(patient_name,' / ',patient_gender,' / ',patient_age) ". "'NAME / SEX / AGE', patient_address 'ADDRESS', patient_bgy 'BRGY', family_id 'FAMILY ID', ". "philhealth_id 'PHILHEALTH ID', notes_cc 'COMPLAINTS', notes_dx 'DIAGNOSIS', notes_tx 'TREATMENT' ". "from m_consult_report_dailyservice where service_date = '$report_date' order by patient_name "; $pdf = new PDF('L','pt','A4'); $pdf->SetFont('Arial','',12); $pdf->AliasNbPages(); $pdf->connect('localhost','$_SESSION[dbuser]','$_SESSION[dbpass]','$_SESSION[dbname]'); $attr=array('titleFontSize'=>14,'titleText'=>'DAILY SERVICE REGISTER - CONSULTS'); $pdf->mysql_report($sql,false,$attr,"../modules/_uploads/consult_reg.pdf"); header("location:".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&report_menu=SUMMARY"); //$sql = "select patient_id 'PATIENT ID', concat(patient_name,' / ',patient_gender,' / ',patient_age) ". // "'NAME / SEX / AGE', patient_address 'ADDRESS', patient_bgy 'BRGY', family_id 'FAMILY ID', ". // "philhealth_id 'PHILHEALTH ID', vaccine_given 'VACCINE(S) GIVEN', service_given 'SERVICE(S) GIVEN' " // "from m_consult_ccdev_report_dailyservice where service_date = '$report_date' order by patient_name "; //$pdf = new PDF('L','pt','A4'); //$pdf->SetFont('Arial','',12); //$pdf->AliasNbPages(); //$pdf->connect('localhost','$_SESSION[dbuser]','$_SESSION[dbpass]','$_SESSION[dbname]'); //$attr=array('titleFontSize'=>14,'titleText'=>'DAILY SERVICE REGISTER - CHILD CARE SERVICES'); //$pdf->mysql_report($sql,false,$attr,"../modules/_uploads/consult_ccdev_reg.pdf"); //header("location:".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&report_menu=SUMMARY"); $sql = "select patient_id 'PATIENT ID', concat(patient_name,' / ',patient_gender,' / ',patient_age) ". "'NAME / SEX / AGE', aog_weeks 'AOG (wks)', postpartum_weeks 'POSTPARTUM WK', ". "patient_address 'ADDRESS', patient_bgy 'BRGY', family_id 'FAMILY ID', ". "philhealth_id 'PHILHEALTH ID', visit_sequence 'VISIT SEQ.', vaccine_given 'VACCINE(S) GIVEN', ". "service_given 'SERVICE(S) GIVEN' ". "from m_consult_mc_report_dailyservice where service_date = '$report_date' order by patient_name "; $pdf = new PDF('L','pt','A4'); $pdf->SetFont('Arial','',12); $pdf->AliasNbPages(); $pdf->connect('localhost','$_SESSION[dbuser]','$_SESSION[dbpass]','$_SESSION[dbname]'); $attr=array('titleFontSize'=>14,'titleText'=>'DAILY SERVICE REGISTER - MATERNAL CARE SERVICES'); $pdf->mysql_report($sql,false,$attr,"../modules/_uploads/consult_mc_reg.pdf"); header("location:".$_SERVER["PHP_SELF"]."?page=".$get_vars["page"]."&menu_id=".$get_vars["menu_id"]."&report_menu=SUMMARY"); */ } } //STEP 3. display daily service report print "<br/>"; print "<b>DAILY SERVICE REPORT</b><br/>"; print "REPORT DATE : <b>" . $post_vars["report_date"] . " to " . $post_vars["end_report_date"] . "</b><br/><br/>"; print "PRINTER FRIENDLY VERSION: <a href='../chits_query/pdf_reports/dailyservice_report.php?arr=consult' target='new'>CONSULTS</a> "; print "<a href='../chits_query/pdf_reports/dailyservice_report.php?arr=ccdev' target='new'>CHILD CARE</a> "; print "<a href='../chits_query/pdf_reports/dailyservice_report.php?arr=mc' target='new'>MATERNAL CARE</a><br />"; $_SESSION["arr_consult"] = $this->display_consults($report_date, "patient_id", $end_report_date); //pass the report_date and patient_id $_SESSION["arr_ccdev"] = $this->display_ccdev($report_date, $end_report_date); $_SESSION["arr_mc"] = $this->display_mc($report_date, $end_report_date); $sql = "select count(distinct(patient_id)) from m_consult where " . "to_days(consult_date) = to_days('{$report_date}') and patient_id != '0'"; $result = mysql_result(mysql_query($sql), 0); print "<br/>"; print "Total No. of Today's Patients : {$result}"; }
function display_reminder_data() { 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 "<form method='post' action='" . $_SERVER["PHP_SELF"] . "?page=" . $get_vars["page"] . "&menu_id=" . $get_vars["menu_id"] . "&consult_id=" . $get_vars["consult_id"] . "&ptmenu=DETAILS&module=reminder&reminder=DATA'>"; print "<table width='300' cellpadding='2' style='border: 1px dotted black'><tr><td>"; $patient_id = healthcenter::get_patient_id($get_vars["consult_id"]); print "<b>NAME: " . strtoupper(patient::get_name($patient_id)) . "</b><br/>"; $sql = "select patient_id, cellular_phone, home_phone, " . "office_phone, email_address, home_address, " . "barangay, reg_timestamp, user_id " . "from m_patient_reminder_data " . "where patient_id = {$patient_id}"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { $reminder = mysql_fetch_array($result); print "<span class='tinylight'>"; if (strlen($reminder["cellular_phone"]) > 0) { print "CELLULAR PHONE: " . $reminder["cellular_phone"] . "<br/>"; } if (strlen($reminder["home_phone"]) > 0) { print "HOME PHONE: " . $reminder["home_phone"] . "<br/>"; } if (strlen($reminder["office_phone"]) > 0) { print "OFFICE PHONE: " . $reminder["office_phone"] . "<br/>"; } if (strlen($reminder["email_address"]) > 0) { print "EMAIL ADDRESS: " . $reminder["email_address"] . "<br/>"; } if (strlen($reminder["home_address"]) > 0) { print "HOME ADDRESS: " . $reminder["home_address"] . "<br/>"; } if ($reminder["barangay"]) { print "BARANGAY: " . barangay::barangay_name($reminder["barangay"]) . "<br/>"; } print "<br/></span>"; print "<input type='hidden' name='patient_id' value='" . $reminder["patient_id"] . "' />"; if ($_SESSION["priv_update"] || $_SESSION["priv_delete"]) { print "<input type='submit' name='submitdetail' value='Edit Reminder Data' class='tinylight' style='border: 1px solid black' />"; } } else { print "<font color='red'>No reminder data</font><br/>"; } } print "</td></tr></table>"; print "</form>"; }
function display_service_record() { 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 "<br/>"; print "<b>".FTITLE_SERVICE_RECORD."</b><br/>"; $patient_id = healthcenter::get_patient_id($get_vars["consult_id"]); $sql = "select mc_id, service_id, date_format(mc_timestamp,'%a %d %b %Y') service_date, mc_timestamp,actual_service_date, date_format(actual_service_date,'%a %d %b %Y') actual_sdate, service_qty ". "from m_consult_mc_services ". "where patient_id = '$patient_id' order by service_id, actual_service_date desc"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { while (list($cid, $service, $sdate, $ts, $actual_service_date, $actual_sdate, $qty) = mysql_fetch_array($result)) { print "<img src='../images/arrow_redwhite.gif' border='0'/> "; $disp_date = ($actual_service_date=='0000-00-00')?$sdate:$actual_sdate; print "<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=mc&mc=SVC&service_id=$service&sts=$ts&mc_id=$cid&actual_vdate=$actual_service_date#service' name='service'>".mc::get_service_name($service)." ($qty)</a> $disp_date<br/>"; if ($get_vars["service_id"]==$service && $get_vars["actual_vdate"]==$actual_service_date && $get_vars["sts"]==$ts) { mc::display_service_record_details($menu_id, $post_vars, $get_vars); } } } else { print "<font color='red'>No records</font><br/>"; } } }
function process_send_request() { 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"]); switch ($post_vars["submitlab"]) { case "Send Request": if ($post_vars["lab_exam"]) { foreach ($post_vars["lab_exam"] as $key => $value) { $sql = "insert into m_consult_lab (consult_id, patient_id, lab_id, request_timestamp, request_user_id) " . "values ('" . $get_vars["consult_id"] . "', '{$patient_id}', '{$value}', sysdate(), '" . $_SESSION["userid"] . "')"; 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=" . $get_vars["ptmenu"]); } } } break; case "Print Referral": break; } }
function _consult_leprosy() { echo "<form name='form_leprosy' action='{$_POST['PHP_SELF']}' method='POST'>"; $leprosy = new leprosy(); $leprosy->consult_id = $_GET['consult_id']; $leprosy->patient_id = healthcenter::get_patient_id($_GET['consult_id']); //$leprosy->patient_age = healthcenter::get_patient_age($_GET['consult_id']); $leprosy->userid = $_SESSION['userid']; //The following codes will initialize hidden textboxes and their values echo "<input type='hidden' name='h_consult_id' value='{$leprosy->consult_id}'></input>"; echo "<input type='hidden' name='h_patient_id' value='{$leprosy->patient_id}'></input>"; echo "<input type='hidden' name='h_userid' value='{$leprosy->userid}'></input>"; if (@$_POST['h_save_flag'] == 'GO') { print " "; $leprosy->new_leprosy_record(); // test wether it still needed to initialize primary keys after a POST. //$leprosy->init_primary_keys(); print " "; $leprosy->show_NLCPForm1(); } else { print " "; $leprosy->init_primary_keys(); print " "; $leprosy->show_NLCPForm1(); } echo "<input type='hidden' name='h_save_flag' value='GO'></input>"; echo "</form>"; }
function display_consult_icd10_hx() { 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 $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_HX . "</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.patient_id = '{$patient_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} "; print "<br/>"; } print "</td></tr>"; } else { print "<tr valign='top'><td><font color='red'>No records.</font></td></tr>"; } } print "</table><br>"; }