From ef6a8b5a3b1dd67503bc7566d5faa0927d230879 Mon Sep 17 00:00:00 2001 From: sunsetsystems Date: Tue, 14 Jul 2009 20:39:05 +0000 Subject: [PATCH] separating facility from user maintenance, improved support for multiple facilities from Bill Himmelstoss, and a bit of cleanup --- interface/globals.php | 4 + interface/main/calendar/add_edit_event.php | 74 +++++++- interface/main/calendar/find_appt_popup.php | 6 + interface/main/calendar/index.php | 19 ++ .../default/views/day/ajax_template.html | 46 +++-- .../default/views/day/orig_default.html | 40 +++- .../default/views/month/ajax_template.html | 17 +- .../default/views/week/ajax_template.html | 20 +- .../calendar/modules/PostCalendar/pnuserapi.php | 8 +- interface/main/ippf_export.php | 16 +- interface/main/left_nav.php | 2 + interface/patient_file/encounter/cash_receipt.php | 5 +- interface/patient_file/front_payment.php | 14 +- interface/patient_file/report/custom_report.php | 9 + .../patient_file/report/print_custom_report.php | 18 +- interface/usergroup/facilities.php | 118 ++++++++++++ interface/usergroup/facility_admin.php | 2 +- interface/usergroup/user_admin.php | 136 +++++++------- interface/usergroup/usergroup_admin.php | 203 +++++---------------- interface/usergroup/usergroup_navigation.php | 12 +- library/calendar.inc | 17 +- library/formdata.inc.php | 12 ++ library/patient.inc | 10 +- sql/3_0_1-to-3_0_2_upgrade.sql | 9 + sql/database.sql | 8 + 25 files changed, 560 insertions(+), 265 deletions(-) create mode 100644 interface/usergroup/facilities.php create mode 100644 library/formdata.inc.php diff --git a/interface/globals.php b/interface/globals.php index 9c0fb0b7e..a91b1d3f8 100644 --- a/interface/globals.php +++ b/interface/globals.php @@ -395,6 +395,10 @@ $GLOBALS['ignore_pnotes_authorization'] = true; // Everyone should want this, but for now it's optional. $GLOBALS['full_new_patient_form'] = true; +// Restrict non-authorized users to the "Schedule Facilities" (aka user_facilities table) +// set in User admin. +$GLOBALS['restrict_user_facility'] = false; + // If you want Hylafax support then uncomment and customize the following // statements, and also customize custom/faxcover.txt: // diff --git a/interface/main/calendar/add_edit_event.php b/interface/main/calendar/add_edit_event.php index 1536c4c48..02e7eccc6 100644 --- a/interface/main/calendar/add_edit_event.php +++ b/interface/main/calendar/add_edit_event.php @@ -145,7 +145,8 @@ if ( $eid ) { FROM openemr_postcalendar_events LEFT JOIN facility ON (openemr_postcalendar_events.pc_facility = facility.id) WHERE pc_eid = $eid"); - if ( !$facility['pc_facility'] ) { + // if ( !$facility['pc_facility'] ) { + if ( is_array($facility) && !$facility['pc_facility'] ) { $qmin = sqlQuery("SELECT facility_id as minId, facility FROM users WHERE id = ".$facility['pc_aid']); $min = $qmin['minId']; $min_name = $qmin['facility']; @@ -161,8 +162,13 @@ if ( $eid ) { $e2f = $min; $e2f_name = $min_name; } else { + // not edit event + if (!$facility['pc_facility'] && ($_SESSION['pc_facility'] || $_COOKIE['pc_facility'])) { + $e2f = $_SESSION['pc_facility'] ? $_SESSION['pc_facility'] : $_COOKIE['pc_facility']; + } else { $e2f = $facility['pc_facility']; $e2f_name = $facility['name']; + } } } // EOS E2F @@ -640,7 +646,9 @@ if ($_POST['form_action'] == "save") { $_POST['form_provider'] . "'"); $username = $tmprow['username']; $facility = $tmprow['facility']; - $facility_id = $tmprow['facility_id']; + // $facility_id = $tmprow['facility_id']; + // use the session facility if it is set, otherwise the one from the provider. + $facility_id = $_SESSION['pc_facility'] ? $_SESSION['pc_facility'] : $tmprow['facility_id']; $conn = $GLOBALS['adodb']['db']; $encounter = $conn->GenID("sequences"); addForm($encounter, "New Patient Encounter", @@ -649,7 +657,8 @@ if ($_POST['form_action'] == "save") { "onset_date = '$event_date', " . "reason = '" . $_POST['form_comments'] . "', " . "facility = '$facility', " . - "facility_id = '$facility_id', " . + // "facility_id = '$facility_id', " . + "facility_id = '" . (int)$_POST['facility'] . "', " . "pid = '" . $_POST['form_pid'] . "', " . "encounter = '$encounter'" ), @@ -828,7 +837,28 @@ if ($_POST['form_action'] == "save") { //(CHEMED) //Set default facility for a new event based on the given 'userid' if ($userid) { + /************************************************************* $pref_facility = sqlFetchArray(sqlStatement("SELECT facility_id, facility FROM users WHERE id = $userid")); + *************************************************************/ + if ($_SESSION['pc_facility']) { + $pref_facility = sqlFetchArray(sqlStatement(sprintf(" + SELECT f.id as facility_id, + f.name as facility + FROM facility f + WHERE f.id = %d + ", + $_SESSION['pc_facility'] + ))); + } else { + $pref_facility = sqlFetchArray(sqlStatement(" + SELECT u.facility_id, + f.name as facility + FROM users u + LEFT JOIN facility f on (u.facility_id = f.id) + WHERE u.id = $userid + ")); + } + /************************************************************/ $e2f = $pref_facility['facility_id']; $e2f_name = $pref_facility['facility']; } @@ -1053,6 +1083,7 @@ if ( $GLOBALS['dutchpc'] ) { ?> var c = document.forms[0].form_category; var formDate = document.forms[0].form_date; dlgopen('find_appt_popup.php?providerid=' + s + + '&facility=' + f.options[f.selectedIndex].value + '&catid=' + c.options[c.selectedIndex].value + '&startdate=' + formDate.value, '_blank', 500, 400); //END (CHEMED) modifications @@ -1279,10 +1310,22 @@ if ( $GLOBALS['dutchpc'] ) { // EVENTS TO FACILITIES //(CHEMED) added service_location WHERE clause // get the facilities + /*************************************************************** $qsql = sqlStatement("SELECT * FROM facility WHERE service_location != 0"); + ***************************************************************/ + $facils = getUserFacilities($_SESSION['authId']); + $qsql = sqlStatement("SELECT id, name FROM facility WHERE service_location != 0"); + /**************************************************************/ while ($facrow = sqlFetchArray($qsql)) { + /************************************************************* $selected = ( $facrow['id'] == $e2f ) ? 'selected="selected"' : '' ; echo ""; + *************************************************************/ + if ($_SESSION['authorizedUser'] || in_array($facrow, $facils)) { + $selected = ( $facrow['id'] == $e2f ) ? 'selected="selected"' : '' ; + echo ""; + } + /************************************************************/ } // EOS E2F // =========================== @@ -1368,6 +1411,7 @@ if ($GLOBALS['select_multi_providers']) { } else { // this is a new event so smartly choose a default provider + /***************************************************************** if ($userid) { // Provider already given to us as a GET parameter. $defaultProvider = $userid; @@ -1395,6 +1439,30 @@ if ($GLOBALS['select_multi_providers']) { echo "\n"; } echo ""; + *****************************************************************/ + // default to the currently logged-in user + $defaultProvider = $_SESSION['authUserID']; + // or, if we have chosen a provider in the calendar, default to them + // choose the first one if multiple have been selected + if (count($_SESSION['pc_username']) >= 1) { + // get the numeric ID of the first provider in the array + $pc_username = $_SESSION['pc_username']; + $firstProvider = sqlFetchArray(sqlStatement("select id from users where username='".$pc_username[0]."'")); + $defaultProvider = $firstProvider['id']; + } + // if we clicked on a provider's schedule to add the event, use THAT. + if ($userid) $defaultProvider = $userid; + } + echo ""; + /****************************************************************/ } ?> diff --git a/interface/main/calendar/find_appt_popup.php b/interface/main/calendar/find_appt_popup.php index 52bd9b856..c163ee6cd 100644 --- a/interface/main/calendar/find_appt_popup.php +++ b/interface/main/calendar/find_appt_popup.php @@ -101,6 +101,12 @@ "WHERE pc_aid = '$providerid' AND " . "((pc_endDate >= '$sdate' AND pc_eventDate < '$edate') OR " . "(pc_endDate = '0000-00-00' AND pc_eventDate >= '$sdate' AND pc_eventDate < '$edate'))"; + // phyaura whimmel facility filtering + if ($_REQUEST['facility'] > 0 ) { + $facility = $_REQUEST['facility']; + $query .= " AND pc_facility = $facility"; + } + // end facility filtering whimmel 29apr08 $res = sqlStatement($query); while ($row = sqlFetchArray($res)) { diff --git a/interface/main/calendar/index.php b/interface/main/calendar/index.php index aeb2bc118..0b601f6cc 100644 --- a/interface/main/calendar/index.php +++ b/interface/main/calendar/index.php @@ -52,8 +52,27 @@ if ($_GET['framewidth']) $_SESSION['pc_framewidth'] = $_GET['framewidth']; // FACILITY FILTERING (lemonsoftware) (CHEMED) $_SESSION['pc_facility'] = 0; + +/********************************************************************* if ($_POST['pc_facility']) $_SESSION['pc_facility'] = $_POST['pc_facility']; +*********************************************************************/ +if (isset($_COOKIE['pc_facility'])) $_SESSION['pc_facility'] = $_COOKIE['pc_facility']; +// override the cookie if the user doesn't have access to that facility any more +if ($_SESSION['userauthorized'] != 1 && $GLOBALS['restrict_user_facility']) { + $facilities = getUserFacilities($_SESSION['authId']); + // use the first facility the user has access to, unless... + $_SESSION['pc_facility'] = $facilities[0]['id']; + // if the cookie is in the users' facilities, use that. + foreach ($facilities as $facrow) { + if ($facrow['id'] == $_COOKIE['pc_facility']) + $_SESSION['pc_facility'] = $_COOKIE['pc_facility']; + } +} +if (isset($_POST['pc_facility'])) $_SESSION['pc_facility'] = $_POST['pc_facility']; +/********************************************************************/ + if ($_GET['pc_facility']) $_SESSION['pc_facility'] = $_GET['pc_facility']; +setcookie("pc_facility", $_SESSION['pc_facility'], time() + (3600 * 365)); // allow tracking of current viewtype -- JRM if ($_GET['viewtype']) $_SESSION['viewtype'] = $_GET['viewtype']; diff --git a/interface/main/calendar/modules/PostCalendar/pntemplates/default/views/day/ajax_template.html b/interface/main/calendar/modules/PostCalendar/pntemplates/default/views/day/ajax_template.html index 3c7679b2b..f06d2cb87 100644 --- a/interface/main/calendar/modules/PostCalendar/pntemplates/default/views/day/ajax_template.html +++ b/interface/main/calendar/modules/PostCalendar/pntemplates/default/views/day/ajax_template.html @@ -130,15 +130,19 @@ $timeslotHeightUnit="px"; $MULTIDAY = count($A_EVENTS) > 1; - //================================== - //FACILITY FILTERING (CHEMED) - if ( $_SESSION['pc_facility'] ) { - $provinfo = getProviderInfo('%', true, $_SESSION['pc_facility']); - } else { - $provinfo = getProviderInfo(); - } - //EOS FACILITY FILTERING (CHEMED) - //================================== +//================================== +//FACILITY FILTERING (CHEMED) +$facilities = getUserFacilities($_SESSION['authId']); // from users_facility +if (count($facilities) == 1 || !$_SESSION['pc_facility']) { + $_SESSION['pc_facility'] = $facilities[0]['id']; +} +if ( $_SESSION['pc_facility'] ) { + $provinfo = getProviderInfo('%', true, $_SESSION['pc_facility']); +} else { + $provinfo = getProviderInfo(); +} +//EOS FACILITY FILTERING (CHEMED) +//================================== [-/php-] @@ -290,11 +294,22 @@ Providers [-php-] // ============================== // FACILITY FILTERING (lemonsoftware) +/********************************************************************* $facilities = getFacilities(); +*********************************************************************/ +if ($_SESSION['authorizeduser'] == 1) { + $facilities = getFacilities(); +} else { + $facilities = getUserFacilities($_SESSION['authId']); // from users_facility + if (count($facilities) == 1) + $_SESSION['pc_facility'] = key($facilities); +} +/********************************************************************/ if (count($facilities) > 1) { echo " \n"; +/********************************************************************* // ============================== // FACILITY FILTERING (lemonsoftware) $facilities = getFacilities(); @@ -193,6 +202,28 @@ div.tiny { width:1px; height:1px; font-size:1px; } echo " \n"; } echo " \n"; +*********************************************************************/ +// ============================== +// FACILITY FILTERING (lemonsoftware) +if ($_SESSION['authorizeduser'] == 1) { + $facilities = getFacilities(); +} else { + $facilities = getUserFacilities($_SESSION['authId']); // from users_facility + if (count($facilities) == 1) + $_SESSION['pc_facility'] = ($facilities[0]['id']); +} +if (count($facilities) > 1) { + echo " \n"; +} +/********************************************************************/ + // EOS FF // ============================== @@ -494,7 +525,8 @@ if ($MULTIDAY) { } else { // some sort of patient appointment $content .= ""; - $content .= $starth . ':' . $startm . htmlspecialchars($event['apptstatus']) . ""; + // $content .= $starth . ':' . $startm . htmlspecialchars($event['apptstatus']) . ""; + $content .= $starth . ':' . $startm . ' ' . htmlspecialchars($event['apptstatus']) . " "; $content .= ""; if ($catid == 1) $content .= ""; $content .= $lname; diff --git a/interface/main/calendar/modules/PostCalendar/pntemplates/default/views/month/ajax_template.html b/interface/main/calendar/modules/PostCalendar/pntemplates/default/views/month/ajax_template.html index fd17041eb..c4c2e9672 100644 --- a/interface/main/calendar/modules/PostCalendar/pntemplates/default/views/month/ajax_template.html +++ b/interface/main/calendar/modules/PostCalendar/pntemplates/default/views/month/ajax_template.html @@ -127,6 +127,10 @@ $timeslotHeightUnit="px"; //================================== //FACILITY FILTERING (CHEMED) + $facilities = getUserFacilities($_SESSION['authId']); // from users_facility + if (count($facilities) == 1 || !$_SESSION['pc_facility']) { + $_SESSION['pc_facility'] = $facilities[0]['id']; + } if ( $_SESSION['pc_facility'] ) { $provinfo = getProviderInfo('%', true, $_SESSION['pc_facility']); } else { @@ -270,11 +274,20 @@ Providers [-php-] // ============================== // FACILITY FILTERING (lemonsoftware) -$facilities = getFacilities(); +// $facilities = getFacilities(); +if ($_SESSION['authorizeduser'] == 1) { + $facilities = getFacilities(); +} else { + $facilities = getUserFacilities($_SESSION['authId']); // from users_facility + if (count($facilities) == 1) + $_SESSION['pc_facility'] = key($facilities); +} if (count($facilities) > 1) { echo " \n"; if ( !$_SESSION['pc_facility'] ) $selected = "selected='selected'"; - echo " \n"; + // echo " \n"; + if (!$GLOBALS['restrict_user_facility']) echo " \n"; foreach ($facilities as $fa) { $selected = ( $_SESSION['pc_facility'] == $fa['id']) ? "selected='selected'" : "" ; echo " \n"; @@ -399,7 +411,9 @@ foreach ($providers as $provider) { $slotendmins = $starttimeh * 60 + $starttimem + $interval; echo ""; - echo ""; +// echo ""; + echo ""; + //echo $slottime['hour'] * 60 + $slottime['minute']; echo "$disptimeh:$starttimem"; echo "\n"; diff --git a/interface/main/calendar/modules/PostCalendar/pnuserapi.php b/interface/main/calendar/modules/PostCalendar/pnuserapi.php index cd2696dad..d0fe6b0a0 100644 --- a/interface/main/calendar/modules/PostCalendar/pnuserapi.php +++ b/interface/main/calendar/modules/PostCalendar/pnuserapi.php @@ -999,15 +999,15 @@ function &postcalendar_userapi_pcQueryEvents($args) //FACILITY FILTERING (lemonsoftware)(CHEMED) if ( $_SESSION['pc_facility'] ) { $pc_facility = $_SESSION['pc_facility']; - $sql .= " AND a.pc_facility = $pc_facility + $sql .= " AND a.pc_facility = $pc_facility "; /* AND u.facility_id = $pc_facility - AND u2.facility_id = $pc_facility "; + AND u2.facility_id = $pc_facility "; */ } else if ($pc_facility) { // pc_facility could be provided in the search arguments -- JRM March 2008 - $sql .= " AND a.pc_facility = $pc_facility". + $sql .= " AND a.pc_facility = $pc_facility "; /*. " AND u.facility_id = $pc_facility". - " AND u2.facility_id = $pc_facility "; + " AND u2.facility_id = $pc_facility "; */ } //EOS FACILITY FILTERING (lemonsoftware) //================================== diff --git a/interface/main/ippf_export.php b/interface/main/ippf_export.php index 90c39ee27..c0927c093 100644 --- a/interface/main/ippf_export.php +++ b/interface/main/ippf_export.php @@ -271,7 +271,8 @@ if (!empty($form_submit)) { "billing_location DESC, id ASC LIMIT 1"); OpenTag('IMS_eMRUpload_Point'); Add('ServiceDeliveryPointName' , $facrow['name']); - Add('EmrServiceDeliveryPointId', $facrow['id']); + // Add('EmrServiceDeliveryPointId', $facrow['id']); + Add('EmrServiceDeliveryPointId', $facrow['facility_npi']); Add('Channel' , '01'); Add('Latitude' , '222222'); // TBD: Add this to facility attributes Add('Longitude' , '433333'); // TBD: Add this to facility attributes @@ -316,6 +317,17 @@ if (!empty($form_submit)) { $last_pid = $row['pid']; + // Compute education: 0 = none, 1 = some, 9 = unassigned. + // The MAs should be told to use "none" for no education. + $education = 9; + if (!empty($row['education'])) { + if (preg_match('/^il/i', $row['education']) || + preg_match('/^no/i', $row['education'])) + $education = 0; + else + $education = 1; + } + // Get most recent contraceptive issue. $crow = sqlQuery("SELECT l.begdate, c.new_method " . "FROM lists AS l, lists_ippf_con AS c WHERE " . @@ -358,7 +370,7 @@ if (!empty($form_submit)) { Add('Pregnancies', 0 + getTextListValue($hrow['genobshist'],'npreg')); // number of pregnancies Add('Children' , 0 + getTextListValue($hrow['genobshist'],'nlc')); // number of living children Add('Abortions' , 0 + getTextListValue($hrow['genabohist'],'nia')); // number of induced abortions - Add('Education' , empty($row['education']) ? 0 : $row['education']); + Add('Education' , $education); Add('Demo5' , Sex($row['sex'])); // Dump all visits for this patient at this facility. diff --git a/interface/main/left_nav.php b/interface/main/left_nav.php index 3686ba82d..16c9c27c4 100644 --- a/interface/main/left_nav.php +++ b/interface/main/left_nav.php @@ -754,6 +754,7 @@ function genPopupsList($style='') {
    • + @@ -830,6 +831,7 @@ function genPopupsList($style='') {
      • + diff --git a/interface/patient_file/encounter/cash_receipt.php b/interface/patient_file/encounter/cash_receipt.php index 1a005dcba..8ef9d1d7a 100644 --- a/interface/patient_file/encounter/cash_receipt.php +++ b/interface/patient_file/encounter/cash_receipt.php @@ -36,7 +36,10 @@ } $titleres = getPatientData($pid, "fname,lname,providerID"); - $sql = "select * from facility where billing_location = 1"; + // $sql = "select * from facility where billing_location = 1"; + $sql = "select f.* from facility f ". + "LEFT JOIN form_encounter fe on fe.facility_id = f.id ". + "where fe.encounter = " . $encounter; $db = $GLOBALS['adodb']['db']; $results = $db->Execute($sql); $facility = array(); diff --git a/interface/patient_file/front_payment.php b/interface/patient_file/front_payment.php index 1f02de398..441294504 100644 --- a/interface/patient_file/front_payment.php +++ b/interface/patient_file/front_payment.php @@ -252,13 +252,25 @@ if ($_POST['form_save'] || $_REQUEST['receipt']) { "MAX(method) AS method, " . "MAX(source) AS source, " . "MAX(dtime) AS dtime, " . - "MAX(user) AS user " . + // "MAX(user) AS user " . + "MAX(user) AS user, " . + "MAX(encounter) as encounter ". "FROM payments WHERE " . "pid = '$form_pid' AND dtime = '$timestamp'"); // Create key for deleting, just in case. $payment_key = $form_pid . '.' . preg_replace('/[^0-9]/', '', $timestamp); + // get facility from encounter + $tmprow = sqlQuery(sprintf(" + SELECT facility_id + FROM form_encounter + WHERE encounter = '%s'", + $payrow['encounter'] + )); + $frow = sqlQuery(sprintf("SELECT * FROM facility " . + " WHERE id = '%s'",$tmprow['facility_id'])); + // Now proceed with printing the receipt. ?> diff --git a/interface/patient_file/report/custom_report.php b/interface/patient_file/report/custom_report.php index 3aecdcf5c..0eca89d78 100644 --- a/interface/patient_file/report/custom_report.php +++ b/interface/patient_file/report/custom_report.php @@ -56,8 +56,17 @@ if (sizeof($_GET) > 0) { $ar = $_GET; } else { $ar = $_POST; } if ($printable) { + /******************************************************************* $titleres = getPatientData($pid, "fname,lname,providerID"); $sql = "SELECT * FROM facility ORDER BY billing_location DESC LIMIT 1"; + *******************************************************************/ + $titleres = getPatientData($pid, "fname,lname,providerID,DATE_FORMAT(DOB,'%m/%d/%Y') as DOB_TS"); + if ($_SESSION['pc_facility']) { + $sql = "select * from facility where id=" . $_SESSION['pc_facility']; + } else { + $sql = "SELECT * FROM facility ORDER BY billing_location DESC LIMIT 1"; + } + /******************************************************************/ $db = $GLOBALS['adodb']['db']; $results = $db->Execute($sql); $facility = array(); diff --git a/interface/patient_file/report/print_custom_report.php b/interface/patient_file/report/print_custom_report.php index 0983ed695..e204c7664 100644 --- a/interface/patient_file/report/print_custom_report.php +++ b/interface/patient_file/report/print_custom_report.php @@ -1,4 +1,4 @@ - - +

        - 0) { $ar = $_GET; } else { $ar = $_POST; } - $titleres = getPatientData($pid, "fname,lname,providerID"); - $sql = "select * from facility where billing_location = 1"; + $titleres = getPatientData($pid, "fname,lname,providerID"); + /******************************************************************** + $sql = "select * from facility where billing_location = 1"; + ********************************************************************/ + if ($_SESSION['pc_facility']) { + $sql = "select * from facility where id=" . $_SESSION['pc_facility']; + } else { + $sql = "select * from facility where billing_location = 1"; + } + /*******************************************************************/ $db = $GLOBALS['adodb']['db']; $results = $db->Execute($sql); $facility = array(); diff --git a/interface/usergroup/facilities.php b/interface/usergroup/facilities.php new file mode 100644 index 000000000..2ce552932 --- /dev/null +++ b/interface/usergroup/facilities.php @@ -0,0 +1,118 @@ + + + + + + + + + + + +

        + + + + + + + + +
        + +
        + +: +
        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        : :
          :
        : :
        : :
        : :
          : +
           >
        + +
        +
        + +: + + + +()
        + + +
        + + + + + diff --git a/interface/usergroup/facility_admin.php b/interface/usergroup/facility_admin.php index 594ee7213..8b4dbdd7e 100644 --- a/interface/usergroup/facility_admin.php +++ b/interface/usergroup/facility_admin.php @@ -122,7 +122,7 @@ if (isset($_POST["fid"])) {    -  

        >   [] +  

        >   [] diff --git a/interface/usergroup/user_admin.php b/interface/usergroup/user_admin.php index 6eaf86875..06f8ae002 100644 --- a/interface/usergroup/user_admin.php +++ b/interface/usergroup/user_admin.php @@ -8,91 +8,93 @@ require_once("../globals.php"); require_once("../../library/acl.inc"); require_once("$srcdir/md5.js"); require_once("$srcdir/sql.inc"); +require_once("$srcdir/calendar.inc"); +require_once("$srcdir/formdata.inc.php"); require_once(dirname(__FILE__) . "/../../library/classes/WSProvider.class.php"); -?> - - - - - - - - - - -

        - + + -// =========================== -// DBC DUTCH SYSTEM -if ($GLOBALS['dutchpc']) { - $beroep = sqlStatement("SELECT * FROM cl_user_beroep WHERE cl_beroep_userid={$_GET["id"]}"); - $rowberoep = sqlFetchArray($beroep); -} -// EOS DBC -// =========================== + + + + + + +

        -?>

        - + @@ -183,6 +181,30 @@ foreach($result as $iter2) { + + + + + + @@ -202,22 +224,10 @@ foreach($result as $iter2) { ?> + - - - - - - - - + diff --git a/interface/usergroup/usergroup_admin.php b/interface/usergroup/usergroup_admin.php index 7c6d7992e..981522831 100644 --- a/interface/usergroup/usergroup_admin.php +++ b/interface/usergroup/usergroup_admin.php @@ -1,77 +1,59 @@ - +

        : " disabled>  : * : *
          + +
        : "> : ">
        : ">: ">Beroep: ">
        - - - - - -
        - - - -: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        : :
          :
        : :
        : :
        : :
          : -
           >
        - -
        -
        - - - -: - - - -()
        - - -
        @@ -237,8 +143,8 @@ if ($fres) {
        - - + + - - - - - - - - + @@ -357,7 +250,7 @@ if ( !$GLOBALS['dutchpc']) { ?> :

        -> +> @@ -375,7 +268,7 @@ if ( !$GLOBALS['dutchpc']) { ?> :     : - : - + + + + diff --git a/library/calendar.inc b/library/calendar.inc index d297bb2dc..46770f1da 100644 --- a/library/calendar.inc +++ b/library/calendar.inc @@ -76,6 +76,21 @@ function getUsername($uID) { return ""; } +// returns an array of facility id and names +function getUserFacilities($uID) { + $rez = sqlStatement(" + select uf.facility_id as id, f.name + from users_facility uf + left join facility f on (uf.facility_id = f.id) + where uf.tablename='users' + and uf.table_id = '$uID' + "); + $returnVal = array(); + while ($row = sqlFetchArray($rez)) + $returnVal[] = $row; + return $returnVal; +} + //retrieve the name based on the username function getNamefromUsername($username) { $query = "select * from users where username like '$username' and username != ''"; @@ -83,7 +98,6 @@ function getNamefromUsername($username) { return $res; } - //retrieve calendar information from calendar id function getCalendarfromID ($calid) { @@ -91,7 +105,6 @@ function getCalendarfromID ($calid) { //return sqlQuery("select * from calendar where id='$calid'"); } - //get calendar dates in a range of dates function getCalendarRanges ($fromdate, $todate, $username) { $rez = sqlStatement("select * from calendar where time>='$fromdate' and time<'$todate' and owner like '$username' order by time"); diff --git a/library/formdata.inc.php b/library/formdata.inc.php new file mode 100644 index 000000000..8cda90d9d --- /dev/null +++ b/library/formdata.inc.php @@ -0,0 +1,12 @@ + diff --git a/library/patient.inc b/library/patient.inc index 9f03610a9..1fe3e6ad8 100644 --- a/library/patient.inc +++ b/library/patient.inc @@ -151,7 +151,15 @@ function getProviderInfo($providerID = "%", $providers_only = true, $facility = //(CHEMED) facility filter $param2 = ""; if ($facility) { - $param2 = " AND facility_id = $facility "; + // $param2 = " AND facility_id = $facility "; + $param2 = " AND (facility_id = $facility + OR $facility IN + (select facility_id + from users_facility + where tablename = 'users' + and table_id = id) + ) + "; } //-------------------------------- diff --git a/sql/3_0_1-to-3_0_2_upgrade.sql b/sql/3_0_1-to-3_0_2_upgrade.sql index b3a5fdba2..651a9caa7 100644 --- a/sql/3_0_1-to-3_0_2_upgrade.sql +++ b/sql/3_0_1-to-3_0_2_upgrade.sql @@ -193,3 +193,12 @@ ALTER TABLE `drugs` ADD `active` TINYINT(1) DEFAULT 1 COMMENT '0 = inactive, 1 = active'; #EndIf +#IfNotTable users_facility +CREATE TABLE `users_facility` ( + `tablename` varchar(64) NOT NULL, + `table_id` int(11) NOT NULL, + `facility_id` int(11) NOT NULL, + PRIMARY KEY (`tablename`,`table_id`,`facility_id`) +) ENGINE=InnoDB COMMENT='joins users or patient_data to facility table'; +#EndIf + diff --git a/sql/database.sql b/sql/database.sql index 9118283db..4e18e5fd5 100644 --- a/sql/database.sql +++ b/sql/database.sql @@ -2874,3 +2874,11 @@ CREATE TABLE ar_activity ( PRIMARY KEY (pid, encounter, sequence_no), KEY session_id (session_id) ) ENGINE=MyISAM; + +CREATE TABLE `users_facility` ( + `tablename` varchar(64) NOT NULL, + `table_id` int(11) NOT NULL, + `facility_id` int(11) NOT NULL, + PRIMARY KEY (`tablename`,`table_id`,`facility_id`) +) ENGINE=InnoDB COMMENT='joins users or patient_data to facility table'; + -- 2.11.4.GIT
        :  : :  :
        : @@ -295,20 +201,7 @@ if ($fres) {
        : : Beroep:
        : " . $iter{"username"} . "(" . xl('Edit') . ")" . diff --git a/interface/usergroup/usergroup_navigation.php b/interface/usergroup/usergroup_navigation.php index 676e0e2fd..3e8a0e4be 100644 --- a/interface/usergroup/usergroup_navigation.php +++ b/interface/usergroup/usergroup_navigation.php @@ -18,9 +18,17 @@ include_once("../../library/acl.inc"); -    + title="Add or Edit Facilities">  +