Exemplo n.º 1
1
 public static function checker()
 {
     $username = $_SESSION["username"];
     $password = $_SESSION["password"];
     $code = $_SESSION["code"];
     $a = mc::encrypt(session_id(), $_SESSION["username"], $_SESSION["password"]);
     if ($a == $code) {
         $sql = "select * from users where username= ? and password = ?";
         $pdo = new PDO(dsn, username, password);
         $db = $pdo->prepare($sql);
         $db->bindValue(1, $username);
         $db->bindValue(2, $password);
         $db->execute();
         if ($db->rowCount() == 1) {
             return 1;
         }
     }
     return 0;
 }
Exemplo n.º 2
0
 /**
  * read image contents from cached
  * @param $urlArray
  * @return mixed
  */
 public static function fetchImagesCache($urlArray)
 {
     !static::$mc && (static::$mc = new mc());
     $fileNameArray = array_map(function ($url) {
         return basename($url);
     }, $urlArray);
     return static::$mc->batchGet($fileNameArray);
 }
Exemplo n.º 3
0
 /**
  * Load a message file for a PocketMine plugin.  Only uses .ini files.
  *
  * @param Plugin $plugin - owning plugin
  * @param str $path - output of $plugin->getFile()
  */
 public static function plugin_init($plugin, $path)
 {
     if (file_exists($plugin->getDataFolder() . "messages.ini")) {
         self::load($plugin->getDataFolder() . "messages.ini");
         return;
     }
     $msgs = $path . "resources/messages/" . $plugin->getServer()->getProperty("settings.language") . ".ini";
     if (!file_exists($msgs)) {
         return;
     }
     mc::load($msgs);
 }
Exemplo n.º 4
0
 function _mc_risk_factors() {
 //
 // main submodule for maternal risk factors
 // calls form_riskfactor()
 //       display_riskfactor()
 //       process_riskfactor()
 //
     // always check dependencies
     if ($exitinfo = $this->missing_dependencies('mc')) {
         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);
     }
     $m = new mc;
     if ($post_vars["submitriskfactor"]) {
         $m->process_riskfactor($menu_id, $post_vars, $get_vars);
     }
     $m->display_riskfactor($menu_id, $post_vars, $get_vars);
     $m->form_riskfactor($menu_id, $post_vars, $get_vars);
 }
Exemplo n.º 5
0
 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>&nbsp;&nbsp;&nbsp;";
     print "<a href='../chits_query/pdf_reports/dailyservice_report.php?arr=ccdev' target='new'>CHILD CARE</a>&nbsp;&nbsp;&nbsp;";
     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}";
 }
Exemplo n.º 6
0
 public static function handle($url, $packImages = false)
 {
     $postParam = static::parseUrlParam($url);
     $quickInfo = null;
     # try to process it
     try {
         # a valid tumblr url given
         if ($postParam) {
             $cachedInfo = Input::fetchQuickInfoCache($postParam);
             # quick response info found
             if ($cachedInfo) {
                 # make just header response
                 if ($_SERVER['REQUEST_METHOD'] === 'HEAD') {
                     syslog(LOG_INFO, "HEAD Response.");
                     foreach ($cachedInfo['headers'] as $header) {
                         header($header);
                     }
                 } else {
                     syslog(LOG_INFO, "Content Response.");
                     $content = $cachedInfo['content'];
                     switch ($cachedInfo['type']) {
                         case 'html':
                             Output::echoHtmlFile($content);
                             break;
                         case 'video':
                         case 'singlePhoto':
                             Output::redirect($content);
                             break;
                         case 'htmlZip':
                             Output::echoZipFile($content);
                             break;
                         case 'error':
                             Output::echoTxtFile($content);
                             break;
                     }
                 }
             } else {
                 $postJSON = Input::fetchPostInfoCache($postParam) ?: Input::queryTumblrApi($postParam);
                 # post json gotten
                 if ($postJSON) {
                     # save post info to memcached
                     Output::setPostInfoCache($postParam, $postJSON);
                     $postInfo = $postJSON['posts'][0];
                     $postType = Content::parsePostType($postInfo);
                     $parserName = 'parse' . ucfirst($postType);
                     switch ($postType) {
                         case 'audio':
                         case 'answer':
                         case 'conversation':
                         case 'link':
                         case 'regular':
                         case 'quote':
                             $output = Content::$parserName($postInfo);
                             $zipStr = Content::getHtmlZipPack($output);
                             Output::echoZipFile($zipStr);
                             $quickInfo = ['type' => 'htmlZip', 'content' => $zipStr];
                             break;
                         case 'video':
                             $output = Content::$parserName($postInfo);
                             # video source parsed
                             if ($output) {
                                 Output::redirect($output);
                                 $quickInfo = ['type' => 'video', 'content' => $output];
                             } else {
                                 $errMsg = "Can't not parse video post, maybe it's too complicated to get the video source out.";
                                 throw new Exception($errMsg);
                             }
                             break;
                         case 'unknow':
                         case 'photo':
                         default:
                             $photoUrls = Content::$parserName($postInfo);
                             $photoCount = count($photoUrls);
                             # photo found
                             if ($photoCount > 0) {
                                 # one photo
                                 if ($photoCount === 1) {
                                     Output::redirect($photoUrls[0]);
                                     $quickInfo = ['type' => 'singlePhoto', 'content' => $photoUrls[0]];
                                 } else {
                                     # to make a images pack
                                     if ($packImages) {
                                         $imagesCache = Input::fetchImagesCache($photoUrls);
                                         $total = count($photoUrls);
                                         $cached = count($imagesCache);
                                         $fetched = 0;
                                         $startTime = microtime(true);
                                         # get images
                                         $imagesCont = array_fill_keys($photoUrls, null);
                                         $randomOrder = array_values($photoUrls);
                                         shuffle($randomOrder);
                                         foreach ($randomOrder as $imgUrl) {
                                             $fileName = basename($imgUrl);
                                             # image in cache found
                                             if (isset($imagesCache[$fileName])) {
                                                 $imagesCont[$imgUrl] =& $imagesCache[$fileName];
                                             } else {
                                                 $imagesCont[$imgUrl] = Input::fetchImage($imgUrl);
                                                 # fetch from network
                                                 $imagesCont[$imgUrl] && static::$mc->singleSet($fileName, $imagesCont[$imgUrl]);
                                                 # write to cache
                                                 $fetched++;
                                             }
                                         }
                                         # output
                                         $zipPack = Content::getImagesZipPack($imagesCont);
                                         Output::echoZipFile($zipPack);
                                         # statement record
                                         $timeUsed = number_format(microtime(true) - $startTime, 3, '.', '');
                                         syslog(LOG_INFO, "Total: {$total}, From cache: {$cached}, From network: {$fetched}, Time used: {$timeUsed}s");
                                         # refresh cache
                                         static::$mc->touchKeys(array_keys($imagesCache));
                                         # Output::writeImagesToCache($images, array_keys($imagesCache));
                                         $quickInfo = ['HEADOnly' => true, 'headers' => []];
                                     } else {
                                         $page = Content::getImagesDownPage($photoUrls);
                                         $readme = "Sever overloading all the time so no more images packing, open the htm file with google chrome and DIY thank you.\r\n服务器扛不住,取消图片打包,请使用谷歌浏览器打开htm文件自行下载,靴靴。";
                                         $zipStr = Content::getHtmlZipPack($page, null, $readme);
                                         Output::echoZipFile($zipStr);
                                         $quickInfo = ['type' => 'htmlZip', 'content' => $zipStr];
                                     }
                                 }
                             } else {
                                 $errMsg = "No images found in the tumblr post.";
                                 throw new Exception($errMsg);
                             }
                             break;
                     }
                 } else {
                     $postParam = false;
                     # don't write quick response
                     $errMsg = 'No post info back from Tumblr.';
                     throw new Exception($errMsg);
                 }
             }
         } else {
             $errMsg = "Not a valid tumblr URL.";
             throw new Exception($errMsg);
         }
     } catch (Exception $e) {
         $errText = Content::getErrorText($e->getMessage());
         $quickInfo = ['type' => 'error', 'content' => $errText];
         Output::echoTxtFile($errText);
     } finally {
         if ($postParam && $quickInfo) {
             $quickInfo['headers'] = headers_list();
             Output::setQuickInfoCache($postParam, $quickInfo);
         }
     }
     return true;
 }
 function update_method_visit()
 {
     if (empty($_POST["txt_date_reg"])) {
         echo "<script language='javascript'>";
         echo "alert('Date of registration cannot be empty.')";
         echo "</script>";
     } elseif ($_POST["sel_dropout"] != 0 && empty($_POST["txt_date_dropout"])) {
         // make a check that when dropping a patient, there should be a date of drop out
         echo "<script language='javascript'>";
         echo "alert('Cannot drop patient from this method. Indicate a date of drop out.')";
         echo "</script>";
     } else {
         $q_date = mysql_query("SELECT date_service FROM m_patient_fp_method_service WHERE fp_px_id='{$_POST['fp_px_id']}'") or die("Cannot query: 1469");
         $greater = 0;
         $greater_drop = 0;
         while ($r_date = mysql_fetch_array($q_date)) {
             list($y, $m, $d) = explode('-', $r_date["date_service"]);
             $date_r = $m . '/' . $d . '/' . $y;
             $diff = mc::get_day_diff($date_r, $_POST["txt_date_reg"]);
             $greater = $diff < 0 ? $greater + 1 : $greater;
             if (!empty($_POST["txt_date_dropout"])) {
                 $diff_drop = mc::get_day_diff($_POST["txt_date_dropout"], $date_r);
                 $greater_drop = $diff_drop < 0 ? $greater_drop + 1 : $greater_drop;
             }
         }
         if ($greater != 0) {
             echo "<script language='javascript'>";
             echo "alert('There is a conflict between the date of treatment and one of the date of services. Date of treatment should be on or before any date of service.')";
             echo "</script>";
         } elseif ($greater_drop != 0) {
             echo "<script language='javascript'>";
             echo "alert('There is a conflict between the date of drop out and one of the date of services. Date of drop out should be on or after any date of service.')";
             echo "</script>";
         } else {
             if ($_POST["sel_dropout"] != 0 && !empty($_POST["txt_date_dropout"])) {
                 // this indicates that a drop out is being made
                 $diff_drop_reg = mc::get_day_diff($_POST["txt_date_dropout"], $_POST["txt_date_reg"]);
                 if ($diff_drop_reg < 0) {
                     echo "<script language='javascript'>";
                     echo "alert('Date of drop out should be after the date of registration!')";
                     echo "</script>";
                 } else {
                     $_SESSION["dropout_info"] = $_POST;
                     echo "<font color='red'><b>Are you sure you wanted to drop this patient?</b></font>&nbsp;";
                     echo "<a href='{$_SERVER['PHP_SELF']}?page={$_GET['page']}&menu_id={$_GET['menu_id']}&consult_id={$_GET['consult_id']}&ptmenu={$_GET['ptmenu']}&module={$_GET['module']}&action=drop&fp=METHODS#methods'>Yes</a>&nbsp;&nbsp;&nbsp;";
                     echo "<a href='' onclick='history.go(-1)'>No</a>";
                 }
             } else {
                 //   a simple edit of date of registration, type of client and treatment partner
                 list($m, $d, $y) = explode('/', $_POST["txt_date_reg"]);
                 $date_reg = $y . '-' . $m . '-' . $d;
                 $update_fp_method = mysql_query("UPDATE m_patient_fp_method SET date_registered='{$date_reg}', treatment_partner='{$_POST['txt_treatment_partner']}',client_code='{$_POST['sel_clients']}',permanent_reason='{$_POST['txt_reason']}' WHERE fp_px_id='{$_POST['fp_px_id']}'") or die("Cannot query: 1546");
                 if ($update_fp_method) {
                     echo "<script language='javascript'>";
                     echo "alert('FP method was successfully been edited')";
                     echo "</script>";
                 }
             }
         }
     }
 }
Exemplo n.º 8
0
 function get_cpab_status($ccdev_id, $pxid)
 {
     $q_mother = mysql_query("SELECT a.date_registered,date_format(a.ccdev_timestamp,'%Y-%m-%d') date_stamp,a.mother_px_id,b.patient_lastname,b.patient_firstname FROM m_patient_ccdev a, m_patient b WHERE a.patient_id='{$pxid}' AND b.patient_id=a.mother_px_id AND b.patient_gender='F'") or die(mysql_error());
     $get_bday = mysql_query("SELECT patient_dob from m_patient where patient_id='{$pxid}'") or die("cannot query: 581");
     list($px_dob) = mysql_fetch_array($get_bday);
     if (mysql_num_rows($q_mother) != 0) {
         list($actual_date, $datestamp, $mother_id, $lname, $fname) = mysql_fetch_array($q_mother);
         $status = mc::get_tt_status(0, $mother_id, $px_dob);
         echo "<font color='red'>" . $status . "</font>";
     } else {
         echo "<font color='red'>Unknown (mother's ID does not exists)</font>";
     }
 }
Exemplo n.º 9
0
	}
}
if (file_exists('../modules/leprosy/class.leprosy.php')) {
	include '../modules/leprosy/class.leprosy.php';
	$leprosy = new leprosy;
	if (!$module->activated('leprosy') && $initmod) {
		$leprosy->init_sql();
		$leprosy->init_menu();
		$leprosy->init_deps();
		$leprosy->init_lang();
		$leprosy->init_help();
	}
}
if (file_exists('../modules/mc/class.mc.php')) {
	include '../modules/mc/class.mc.php';
	$mc = new mc;
	if (!$module->activated('mc') && $initmod) {
		$mc->init_sql();
		$mc->init_menu();
		$mc->init_deps();
		$mc->init_lang();
		$mc->init_help();
	}
}
if (file_exists('../modules/mc_report/class.mc_report.php')) {
	include '../modules/mc_report/class.mc_report.php';
	$mc_report = new mc_report;
	if (!$module->activated('mc_report') && $initmod) {
		$mc_report->init_sql();
		$mc_report->init_menu();
		$mc_report->init_deps();
Exemplo n.º 10
0
 function update_method_visit()
 {
     if (empty($_POST["txt_date_reg"])) {
         echo "<script language='javascript'>";
         echo "alert('Date of registration cannot be empty.')";
         echo "</script>";
     } elseif ($_POST["sel_dropout"] != 0 && empty($_POST["txt_date_dropout"])) {
         // make a check that when dropping a patient, there should be a date of drop out
         echo "<script language='javascript'>";
         echo "alert('Cannot drop patient from this method. Indicate a date of drop out.')";
         echo "</script>";
     } else {
         $q_date = mysql_query("SELECT date_service FROM m_patient_fp_method_service WHERE fp_px_id='{$_POST['fp_px_id']}'") or die("Cannot query: 1469");
         $greater = 0;
         $greater_drop = 0;
         while ($r_date = mysql_fetch_array($q_date)) {
             list($y, $m, $d) = explode('-', $r_date["date_service"]);
             $date_r = $m . '/' . $d . '/' . $y;
             $diff = mc::get_day_diff($date_r, $_POST["txt_date_reg"]);
             $greater = $diff < 0 ? $greater + 1 : $greater;
             if (!empty($_POST["txt_date_dropout"])) {
                 $diff_drop = mc::get_day_diff($_POST["txt_date_dropout"], $date_r);
                 $greater_drop = $diff_drop < 0 ? $greater_drop + 1 : $greater_drop;
             }
         }
         if ($greater != 0) {
             echo "<script language='javascript'>";
             echo "alert('There is a conflict between the date of treatment and one of the date of services. Date of treatment should be on or before any date of service.')";
             echo "</script>";
         } elseif ($greater_drop != 0) {
             echo "<script language='javascript'>";
             echo "alert('There is a conflict between the date of drop out and one of the date of services. Date of drop out should be on or after any date of service.')";
             echo "</script>";
         } else {
             if ($_POST["sel_dropout"] != 0 && !empty($_POST["txt_date_dropout"])) {
                 // this indicates that a drop out is being made
                 $diff_drop_reg = mc::get_day_diff($_POST["txt_date_dropout"], $_POST["txt_date_reg"]);
                 if ($diff_drop_reg < 0) {
                     echo "<script language='javascript'>";
                     echo "alert('Date of drop out should be after the date of registration!')";
                     echo "</script>";
                 } else {
                     echo "<script language='javascript'>";
                     echo "confirm_dropout(this.form);";
                     /*echo "if(window.confirm('You are about to drop this patient from this method ($_POST[method_id]). By doing so,  you will not be able to further update this record and the services that have been provided connected with this method. Are you sure you wanted to drop this patient?')){";															
                     		echo "}else{";												
                     		echo "}"; */
                     echo "</script>";
                 }
             } else {
                 //   a simple edit of date of registration and treatment partner
             }
         }
     }
 }
Exemplo n.º 11
0
 function mc_alarms()
 {
     if (func_num_args() > 0) {
         $arr = func_get_args();
         $family_id = $arr[0];
         $members = $arr[1];
         $program_id = $arr[2];
     }
     $arr_px = array();
     //will contain patient id of family_members with any of the cases under indicators
     $arr_fam = array();
     /*the function will accept the family id and family_members
     		1).navigate through the mc tables using the patient id of the family. each indicator has its own SQL.
     		2). execute on SQL for the indicator, 
     		3). pushed the patient_id, indicator id and the consult id to an array back to the calling function (get_indicator_instance)
     		4). retrun value is an array of format family_id=>array(patient_id1=>array(indicator_id1=>array(consult_id1,consult_id2,...consult_id[n]),indicator_id2=>array(consult_id1,consult_id2,...,consult_id[n])),patient_id2...);
     		*/
     foreach ($members as $key => $patient_id) {
         $arr_px = array();
         $arr_indicator = array();
         //this will contain indicator_id and array of consult_id
         $q_mc_indicators = mysql_query("SELECT alert_indicator_id,sub_indicator FROM m_lib_alert_indicators WHERE main_indicator='{$program_id}' ORDER by sub_indicator ASC") or die("Cannot query 475: " . mysql_error());
         //$arr_case_id = array(); //this will contain the consult_id and enrollment id's
         while (list($indicator_id, $sub_indicator) = mysql_fetch_array($q_mc_indicators)) {
             $arr_case_id = array();
             //this will contain the consult_id and enrollment id's
             $arr_definition = $this->get_alert_definition($indicator_id);
             //composed of defition id, days before and after.
             $alert_id = $arr_definition[0];
             $days_before = $arr_definition[1];
             $days_after = $arr_definition[2];
             $date_today = date('Y-m-d');
             //echo $indicator_id.' '.$days_before.'<br>';
             switch ($indicator_id) {
                 case '1':
                     //indicator id for quality prenatal visit
                     $q_mc = mysql_query("SELECT mc_id,trimester1_date,trimester2_date,trimester3_date FROM m_patient_mc WHERE patient_id='{$patient_id}' AND end_pregnancy_flag='N' AND delivery_date='0000-00-00' AND patient_edc >= NOW()") or die("Cannot query 510 " . mysql_error());
                     if (mysql_num_rows($q_mc) != 0) {
                         list($mc_id, $tri1, $tri2, $tri3) = mysql_fetch_array($q_mc);
                         $reference_date = date('Y-m-d') <= $tri1 ? $tri1 : (date('Y-m-d') <= $tri2 ? $tri2 : (date('Y-m-d') <= $tri3 ? $tri3 : ''));
                         $trimester = $reference_date == $tri1 ? 1 : ($reference_date == $tri2 ? 2 : 3);
                         //echo $reference_date.'/'.$mc_id.'/'.$trimester;
                         if ($reference_date) {
                             array_push($arr_case_id, $mc_id, $reference_date);
                             //push if the present date is on or before the reference prenatal visit date
                         }
                     }
                     break;
                     //end case
                 //end case
                 case '2':
                     //indicator id for EDC
                     $q_mc = mysql_query("SELECT mc_id, patient_edc FROM m_patient_mc WHERE patient_id='{$patient_id}' AND end_pregnancy_flag='N' AND delivery_date='0000-00-00' AND '{$date_today}' BETWEEN patient_lmp AND patient_edc AND (to_days(patient_edc)-to_days('{$date_today}')) <= '{$days_before}'") or die("Cannot query 562 " . mysql_error());
                     if (mysql_num_rows($q_mc) != 0) {
                         list($mc_id, $patient_edc) = mysql_fetch_array($q_mc);
                         array_push($arr_case_id, $mc_id, $patient_edc);
                     } else {
                     }
                     break;
                 case '3':
                     //indicator id for postpartum visit
                     //refence date will be the date of delivery. message will appear as long as the duration set in the days_after value (0 - persistent, n - days)
                     $q_mc = mysql_query("SELECT mc_id,delivery_date FROM m_patient_mc WHERE patient_id='{$patient_id}' AND delivery_date!='0000-00-00' AND (to_days('{$date_today}')-to_days(delivery_date)) >= 0") or die("Cannot query 580 " . mysql_error());
                     if (mysql_num_rows($q_mc) != 0) {
                         list($mc_id, $delivery_date) = mysql_fetch_row($q_mc);
                         $q_postpartum = mysql_query("SELECT mc_id FROM m_consult_mc_postpartum WHERE mc_id='{$mc_id}'") or die("Cannot query 586 " . mysql_error());
                         //check if the patient has visited during postpartum period
                         if (mysql_num_rows($q_postpartum) < 2) {
                             //at least 2 postpartum visits are required. if not satisfied, set 1 to alert flag
                             array_push($arr_case_id, $mc_id, $delivery_date);
                         }
                     }
                     break;
                 case '4':
                     //tetanus toxoid intake (CPAB)
                     //determine if the patient has an active pregnancy.
                     $q_mc = mysql_query("SELECT mc_id, patient_edc FROM m_patient_mc WHERE patient_id='{$patient_id}' AND end_pregnancy_flag='N' AND delivery_date='0000-00-00' AND patient_edc >= NOW()") or die("Cannot query 596 " . mysql_error());
                     //if it does, determine the status of the tetanus toxoid
                     if (mysql_num_rows($q_mc) != 0) {
                         list($mc_id, $patient_edc) = mysql_fetch_array($q_mc);
                         $tt_status = mc::get_tt_status($mc_id, $patient_id, $patient_edc);
                         if (eregi('not', $tt_status)) {
                             // a not substring means that the tt is not active
                             array_push($arr_case_id, $mc_id, $patient_edc);
                         }
                     }
                     break;
                 case '5':
                     //vitamin A intake (200,000 units)
                     $q_mc = mysql_query("SELECT mc_id, patient_edc FROM m_patient_mc WHERE patient_id='{$patient_id}' AND end_pregnancy_flag='N' AND delivery_date='0000-00-00' AND patient_edc >= NOW()") or die("Cannot query 596 " . mysql_error());
                     if (mysql_num_rows($q_mc) != 0) {
                         list($mc_id, $patient_edc) = mysql_fetch_array($q_mc);
                         // sql here to determine the vitamin A quantity intake
                         $q_vit = mysql_query("SELECT SUM(service_qty) as sum_vita FROM m_consult_mc_services WHERE mc_id='{$mc_id}' AND service_id='VITA'") or die("Cannot query 615 " . mysql_error());
                         list($sum_vita) = mysql_fetch_array($q_vit);
                         if ($sum_vita < 200000) {
                             //throw to the arr_case_id if the sum is less than 200000 units of vitamin A
                             array_push($arr_case_id, $mc_id, $patient_edc);
                         }
                     }
                     break;
                 case '6':
                     //iron with folic acid intake
                     $q_mc = mysql_query("SELECT mc_id, patient_edc FROM m_patient_mc WHERE patient_id='{$patient_id}' AND end_pregnancy_flag='N' AND delivery_date='0000-00-00' AND patient_edc >= NOW()") or die("Cannot query 596 " . mysql_error());
                     if (mysql_num_rows($q_mc) != 0) {
                         list($mc_id, $patient_edc) = mysql_fetch_array($q_mc);
                         $q_iron = mysql_query("SELECT SUM(service_qty) as sum_iron FROM m_consult_mc_services WHERE mc_id='{$mc_id}' AND service_id='IRON'") or die("Cannot query 633 " . mysql_error());
                         list($sum_iron) = mysql_fetch_array($q_iron);
                         if ($sum_iron == 0) {
                             //push the mc_id to the arr_case_id if no ironintake
                             array_push($arr_case_id, $mc_id, $patient_edc);
                         }
                     }
                     break;
                 case '40':
                     //post trimester alert. patient didn't attended any prenatal visits
                     $q_mc = mysql_query("SELECT mc_id,trimester1_date,trimester2_date,trimester3_date FROM m_patient_mc WHERE patient_id='{$patient_id}' AND end_pregnancy_flag='N' AND delivery_date='0000-00-00' AND patient_edc >= NOW()") or die("Cannot query 510 " . mysql_error());
                     if (mysql_num_rows($q_mc) != 0) {
                         list($mc_id, $tri1, $tri2, $tri3, ) = mysql_fetch_array($q_mc);
                         $trimester = $this->get_trimester($mc_id, date('Y-m-d'));
                         $tri_date = $trimester == '2' ? $tri1 : ($trimester == '3' ? $tri2 : '');
                         if ($tri_date != '') {
                             $q_prenatal = mysql_query("SELECT date_until FROM m_lib_alert_type WHERE alert_indicator_id=1") or die("Cannot query 975: " . mysql_error());
                             if (mysql_num_rows($q_prenatal) != 0) {
                                 list($date_until) = mysql_fetch_array($q_prenatal);
                                 if ($date_until == $this->get_date_diff_days($tri_date, date('Y-m-d'))) {
                                     //echo $trimester.'/'.$tri1.'/'.$tri2.'/'.$tri3.'/'.$tri_date.'/'.$this->get_date_diff_days($tri_date,date('Y-m-d')).'<br>';
                                     array_push($arr_case_id, $mc_id, date('Y-m-d'));
                                 }
                             } else {
                             }
                         }
                     } else {
                     }
                 default:
                     break;
             }
             //end switch for case id's
             if (!empty($arr_case_id)) {
                 array_push($arr_indicator, array($indicator_id => $arr_case_id));
             }
         }
         //end while for indicators
         if (!empty($arr_indicator)) {
             array_push($arr_px, array($patient_id => $arr_indicator));
             array_push($arr_fam, $arr_px);
         }
     }
     //end foreach for patient id's
     return $arr_fam;
 }
Exemplo n.º 12
0
 /**
  * cache processed result data
  * @param array $postParam array('post_domain' => 'xx.tumblr.com', 'post_id' => xxxx)
  * @param mixed $postInfo processed result data
  * @return bool
  */
 public static function setQuickInfoCache($postParam, $postInfo)
 {
     !static::$mc && (static::$mc = new mc());
     $key = "{$postParam['post_domain']}|{$postParam['post_id']}|QuickResponse";
     return static::$mc->setInfo($key, $postInfo);
 }
Exemplo n.º 13
0
	function show_message_if_patient_is_pregnant($p_id, $consultation_date) {
		if(mc::check_if_pregnant($p_id, $consultation_date) == 'Y') {
			print "<table border=3 bordercolor='red' align='center'>";
				print "<tr>";
					print "<th align='left' bgcolor='yellow'> ".
						"Advisory: According to our records, as of {$consultation_date}, ".
						"your patient is PREGNANT.</th>";
				print "</tr>";
			print "</table>";
		} 
	}
 function generate_summary()
 {
     if (func_num_args() > 0) {
         $arg_list = func_get_args();
         $menu_id = $arg_list[0];
         $post_vars = $arg_list[1];
         $get_vars = $arg_list[2];
         $validuser = $arg_list[3];
         $isadmin = $arg_list[4];
         //print_r($arg_list);
     }
     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}";
 }
Exemplo n.º 15
0
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<?php 
include 'jm.php';
//$_SESSION["username"]='******';
//$_SESSION["password"]='******';
//$_SESSION['code'] =mc::encrypt(session_id(), $_SESSION["username"],$_SESSION["password"]);
if (mc::checker()) {
    header("Location:a.php");
}
?>

</body>
</html>