update selected facility pos code when facility is changed in encounter.
[openemr.git] / library / ajax / facility_ajax_code.php
blob8921035ad9f9ffe9c92f7798bf18eca47d1af835
1 <?php
2 /**
3 * While creating new encounter this code is used to change the "Billing Facility:".
4 * This happens on change of the "Facility:" field.
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Eldho Chacko <eldho@zhservices.com>
9 * @author Jacob T.Paul <jacob@zhservices.com>
10 * @author Brady Miller <brady.g.miller@gmail.com>
11 * @copyright Copyright (c) 2011 Z&H Consultancy Services Private Limited <sam@zhservices.com>
12 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
13 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
17 require_once("../../interface/globals.php");
18 require_once("$srcdir/options.inc.php");
20 if (!verifyCsrfToken($_POST["csrf_token_form"])) {
21 csrfNotVerified();
24 if ($_REQUEST['mode'] == 'get_pos') {
25 // put here for encounter facility changes sjp
27 $fid = $_REQUEST['facility_id'] ? (int)$_REQUEST['facility_id'] : exit('0');
28 $pos = sqlQueryNoLog("SELECT pos_code FROM facility WHERE id = ?", array($fid));
29 echo ((int)$pos['pos_code'] < 10) ? ("0" . $pos['pos_code']) : $pos['pos_code'];
30 exit();
33 $pid = $_POST['pid'];
34 $facility = $_POST['facility'];
35 $date = $_POST['date'];
36 $q = sqlStatement("SELECT pc_billing_location FROM openemr_postcalendar_events WHERE pc_pid=? AND pc_eventDate=? AND pc_facility=?", array($pid, $date, $facility));
37 $row = sqlFetchArray($q);
38 billing_facility('billing_facility', $row['pc_billing_location']);