7 * @link https://www.open-emr.org
8 * @author Ranganath Pathak <pathak01@hotmail.com>
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @author Stephen Waite <stephen.waite@cmsvt.com>
11 * @copyright Copyright (c) 2017 Ranganath Pathak <pathak01@hotmail.com>
12 * @copyright Copyright (c) 2017-2018 Brady Miller <brady.g.miller@gmail.com>
13 * @copyright Copyright (c) 2021 Stephen Waite <stephen.waite@cmsvt.com>
14 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
17 require_once("../globals.php");
19 use OpenEMR\Common\Acl\AclMain
;
20 use OpenEMR\Common\Csrf\CsrfUtils
;
21 use OpenEMR\Common\Twig\TwigContainer
;
22 use OpenEMR\Core\Header
;
23 use OpenEMR\Services\FacilityService
;
25 if (!AclMain
::aclCheckCore('admin', 'users')) {
26 echo (new TwigContainer(null, $GLOBALS['kernel']))->getTwig()->render('core/unauthorized.html.twig', ['pageTitle' => xl("Facilities")]);
31 if (!CsrfUtils
::verifyCsrfToken($_POST["csrf_token_form"])) {
32 CsrfUtils
::csrfNotVerified();
36 $facilityService = new FacilityService();
47 "postal_code" => true,
48 "country_code" => true,
49 "federal_ein" => true,
53 "service_location" => true,
54 "billing_location" => true,
55 "accepts_assignment" => true,
57 "domain_identifier" => true,
59 "tax_id_type" => true,
60 "primary_business_entity" => true,
61 "facility_npi" => true,
62 "facility_taxonomy" => true,
63 "facility_code" => "facility_id",
64 "mail_street" => true,
65 "mail_street2" => true,
76 // Populate the $values array with a associative array of column names => $_POST value
77 foreach ($columns as $c => $v) {
78 // Ensure form fields that have a different name from the column gets corrected
79 $k = ($columns[$c] !== true) ?
$v : $c;
80 $values[$c] = trim($_POST[$k] ??
'');
83 /* Inserting New facility */
84 if (($_POST["mode"] ??
"") == "facility" && (empty($_POST["newmode"]) ||
($_POST["newmode"] != "admin_facility"))) {
85 $insert_id = $facilityService->insertFacility($values);
86 exit(); // sjp 12/20/17 for ajax save
89 /* Editing existing facility */
90 if (($_POST["mode"] ??
"") == "facility" && $_POST["newmode"] == "admin_facility") {
91 // Since it's an edit, add in the facility ID
92 $values["id"] = trim($_POST['fid'] ??
'');
93 $facilityService->updateFacility($values);
95 // Update facility name for all users with this facility.
96 // This is necessary because some provider based code uses facility name for lookups instead of facility id.
98 $facilityService->updateUsersFacility($values['name'], $values['id']);
99 exit(); // sjp 12/20/17 for ajax save
106 <title
><?php
echo xlt("Facilities") ; ?
></title
>
107 <?php Header
::setupHeader(['common']); ?
>
109 function refreshme() {
110 top
.restoreSession();
111 document
.location
.reload();
114 $
(".medium_modal").on('click', function(e
) {
117 dlgopen('', '', 1020, 900, '', '', {
119 allowDrag
: true, // note these default to true if not defined here. left as example.
121 url
: $
(this
).attr('href')
125 $
(".addfac_modal").on('click', function(e
) {
126 e
.preventDefault();e
.stopPropagation();
127 dlgopen('', '', 1020, 620, '', '', {
131 url
: $
(this
).attr('href')
135 $
("#form_inactive").on('click', function(e
) {
136 $
(".inactive").toggleClass('d-none');
137 $
("#form_inactive i").toggleClass("fa-square-check");
138 $
("#form_inactive i").toggleClass("fa-square");
146 <div
class="container">
148 <div
class="col-12 my-2 justify-content-between d-flex align-items-center">
149 <a href
="facilities_add.php" class="addfac_modal btn btn-text btn-add"><?php
echo xlt('Add Facility');?
></a
>
150 <div
class="form-check d-flex align-items-center">
151 <input
class="form-check-input" type
="checkbox" value
="" id
="form_inactive">
152 <label
class="form-check-label" for="form_inactive">
153 <?php
echo xlt('Include Inactive Facilities'); ?
>
160 <div
class="table-responsive">
161 <table
class="table table-striped">
164 <th scope
="col"><?php
echo xlt('Name'); ?
></th
>
165 <th scope
="col"><?php
echo xlt('Tax ID'); ?
></th
>
166 <th scope
="col"><?php
echo xlt('NPI'); ?
></th
>
167 <th scope
="col"><?php
echo xlt('Billing Address'); ?
></th
>
168 <th scope
="col"><?php
echo xlt('Mailing Address'); ?
></th
>
169 <th scope
="col"><?php
echo xlt('Phone'); ?
></th
>
175 $fres = $facilityService->getAllFacility();
178 for ($iter3 = 0; $iter3 < sizeof($fres); $iter3++
) {
179 $result2[$iter3] = $fres[$iter3];
182 foreach ($result2 as $iter3) {
183 $varstreet = "";//these are assigned conditionally below,blank assignment is done so that old values doesn't get propagated to next level.
189 $varstreet = $iter3["street"];
190 if ($iter3["street"] != "") {
191 $varstreet = $iter3["street"] . " ";
194 if ($iter3["city"] != "") {
195 $varcity = $iter3["city"] . ", ";
198 if ($iter3["state"] != "") {
199 $varstate = $iter3["state"] . " ";
202 $varmstreet = $iter3["mail_street"];
203 if ($iter3["mail_street"] != "") {
204 $varmstreet = $iter3["mail_street"] . " ";
207 if ($iter3["mail_city"] != "") {
208 $varmcity = $iter3["mail_city"] . ", ";
211 if ($iter3["mail_state"] != "") {
212 $varmstate = $iter3["mail_state"] . " ";
215 <tr
class="<?php echo ($iter3['inactive']) ? 'inactive text-muted d-none' : '';?>">
216 <td valign
="top" class="text">
217 <a
class="font-weight-bold medium_modal" href
="facility_admin.php?fid=<?php echo attr_url($iter3["id
"]); ?>"><?php
echo xlt($iter3["name"]);?
></a
>
218 <?php
echo ($iter3['inactive']) ?
"<br>(" . xlt("Inactive") . ")" : ''; ?
>
220 <td valign
="top" class="text"><?php
echo text($iter3["federal_ein"]); ?
> 
;</td
>
221 <td valign
="top" class="text"><?php
echo text($iter3["facility_npi"]); ?
> 
;</td
>
222 <td valign
="top" class="text"><?php
echo text($varstreet) . "<br>" . text($varcity) . text($varstate) . text($iter3["country_code"]) . " " . text($iter3["postal_code"]); ?
></td
>
223 <td valign
="top" class="text"><?php
echo text($varmstreet) . "<br>" . text($varmcity) . text($varmstate) . " " . text($iter3['mail_zip']); ?
></td
>
224 <td
><?php
echo text($iter3["phone"]);?
> 
;</td
>
230 if (count($result2) <= 0) {?
>
232 <td colspan
="3" class="text-center font-weight-bold"> <?php
echo xlt("Currently there are no facilities."); ?
></td
>
241 </div
><!-- end of div container
-->
244 if ($alertmsg = trim($alertmsg)) {
245 echo "alert(" . js_escape($alertmsg) . ");\n";