6 * @link http://www.open-emr.org
7 * @author Ranganath Pathak <pathak01@hotmail.com>
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2017 Ranganath Pathak <pathak01@hotmail.com>
10 * @copyright Copyright (c) 2017-2018 Brady Miller <brady.g.miller@gmail.com>
11 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
14 require_once("../globals.php");
15 require_once("../../library/acl.inc");
17 use OpenEMR\Core\Header
;
18 use OpenEMR\Services\FacilityService
;
21 if (!verifyCsrfToken($_POST["csrf_token_form"])) {
26 $facilityService = new FacilityService();
30 /* Inserting New facility */
31 if (isset($_POST["mode"]) && $_POST["mode"] == "facility" && $_POST["newmode"] != "admin_facility") {
33 "name" => trim(isset($_POST["facility"]) ?
$_POST["facility"] : ''),
34 "phone" => trim(isset($_POST["phone"]) ?
$_POST["phone"] : ''),
35 "fax" => trim(isset($_POST["fax"]) ?
$_POST["fax"] : ''),
36 "street" => trim(isset($_POST["street"]) ?
$_POST["street"] : ''),
37 "city" => trim(isset($_POST["city"]) ?
$_POST["city"] : ''),
38 "state" => trim(isset($_POST["state"]) ?
$_POST["state"] : ''),
39 "postal_code" => trim(isset($_POST["postal_code"]) ?
$_POST["postal_code"] : ''),
40 "country_code" => trim(isset($_POST["country_code"]) ?
$_POST["country_code"] : ''),
41 "federal_ein" => trim(isset($_POST["federal_ein"]) ?
$_POST["federal_ein"] : ''),
42 "website" => trim(isset($_POST["website"]) ?
$_POST["website"] : ''),
43 "email" => trim(isset($_POST["email"]) ?
$_POST["email"] : ''),
44 "color" => trim(isset($_POST["ncolor"]) ?
$_POST["ncolor"] : ''),
45 "service_location" => trim(isset($_POST["service_location"]) ?
$_POST["service_location"] : ''),
46 "billing_location" => trim(isset($_POST["billing_location"]) ?
$_POST["billing_location"] : ''),
47 "accepts_assignment" => trim(isset($_POST["accepts_assignment"]) ?
$_POST["accepts_assignment"] : ''),
48 "pos_code" => trim(isset($_POST["pos_code"]) ?
$_POST["pos_code"] : ''),
49 "domain_identifier" => trim(isset($_POST["domain_identifier"]) ?
$_POST["domain_identifier"] : ''),
50 "attn" => trim(isset($_POST["attn"]) ?
$_POST["attn"] : ''),
51 "tax_id_type" => trim(isset($_POST["tax_id_type"]) ?
$_POST["tax_id_type"] : ''),
52 "primary_business_entity" => trim(isset($_POST["primary_business_entity"]) ?
$_POST["primary_business_entity"] : ''),
53 "facility_npi" => trim(isset($_POST["facility_npi"]) ?
$_POST["facility_npi"] : ''),
54 "facility_taxonomy" => trim(isset($_POST["facility_taxonomy"]) ?
$_POST["facility_taxonomy"] : ''),
55 "facility_code" => trim(isset($_POST["facility_id"]) ?
$_POST["facility_id"] : ''),
56 "mail_street" => trim(isset($_POST["mail_street"]) ?
$_POST["mail_street"] : ''),
57 "mail_street2" => trim(isset($_POST["mail_street2"]) ?
$_POST["mail_street2"] : ''),
58 "mail_city" => trim(isset($_POST["mail_city"]) ?
$_POST["mail_city"] : ''),
59 "mail_state" => trim(isset($_POST["mail_state"]) ?
$_POST["mail_state"] : ''),
60 "mail_zip" => trim(isset($_POST["mail_zip"]) ?
$_POST["mail_zip"] : ''),
61 "oid" => trim(isset($_POST["oid"]) ?
$_POST["oid"] : '')
64 $insert_id = $facilityService->insert($newFacility);
65 exit(); // sjp 12/20/17 for ajax save
68 /* Editing existing facility */
69 if (isset($_POST["mode"]) && $_POST["mode"] == "facility" && $_POST["newmode"] == "admin_facility") {
71 "fid" => trim(isset($_POST["fid"]) ?
$_POST["fid"] : ''),
72 "name" => trim(isset($_POST["facility"]) ?
$_POST["facility"] : ''),
73 "phone" => trim(isset($_POST["phone"]) ?
$_POST["phone"] : ''),
74 "fax" => trim(isset($_POST["fax"]) ?
$_POST["fax"] : ''),
75 "street" => trim(isset($_POST["street"]) ?
$_POST["street"] : ''),
76 "city" => trim(isset($_POST["city"]) ?
$_POST["city"] : ''),
77 "state" => trim(isset($_POST["state"]) ?
$_POST["state"] : ''),
78 "postal_code" => trim(isset($_POST["postal_code"]) ?
$_POST["postal_code"] : ''),
79 "country_code" => trim(isset($_POST["country_code"]) ?
$_POST["country_code"] : ''),
80 "federal_ein" => trim(isset($_POST["federal_ein"]) ?
$_POST["federal_ein"] : ''),
81 "website" => trim(isset($_POST["website"]) ?
$_POST["website"] : ''),
82 "email" => trim(isset($_POST["email"]) ?
$_POST["email"] : ''),
83 "color" => trim(isset($_POST["ncolor"]) ?
$_POST["ncolor"] : ''),
84 "service_location" => trim(isset($_POST["service_location"]) ?
$_POST["service_location"] : ''),
85 "billing_location" => trim(isset($_POST["billing_location"]) ?
$_POST["billing_location"] : ''),
86 "accepts_assignment" => trim(isset($_POST["accepts_assignment"]) ?
$_POST["accepts_assignment"] : ''),
87 "pos_code" => trim(isset($_POST["pos_code"]) ?
$_POST["pos_code"] : ''),
88 "domain_identifier" => trim(isset($_POST["domain_identifier"]) ?
$_POST["domain_identifier"] : ''),
89 "attn" => trim(isset($_POST["attn"]) ?
$_POST["attn"] : ''),
90 "tax_id_type" => trim(isset($_POST["tax_id_type"]) ?
$_POST["tax_id_type"] : ''),
91 "primary_business_entity" => trim(isset($_POST["primary_business_entity"]) ?
$_POST["primary_business_entity"] : ''),
92 "facility_npi" => trim(isset($_POST["facility_npi"]) ?
$_POST["facility_npi"] : ''),
93 "facility_taxonomy" => trim(isset($_POST["facility_taxonomy"]) ?
$_POST["facility_taxonomy"] : ''),
94 "facility_code" => trim(isset($_POST["facility_id"]) ?
$_POST["facility_id"] : ''),
95 "mail_street" => trim(isset($_POST["mail_street"]) ?
$_POST["mail_street"] : ''),
96 "mail_street2" => trim(isset($_POST["mail_street2"]) ?
$_POST["mail_street2"] : ''),
97 "mail_city" => trim(isset($_POST["mail_city"]) ?
$_POST["mail_city"] : ''),
98 "mail_state" => trim(isset($_POST["mail_state"]) ?
$_POST["mail_state"] : ''),
99 "mail_zip" => trim(isset($_POST["mail_zip"]) ?
$_POST["mail_zip"] : ''),
100 "oid" => trim(isset($_POST["oid"]) ?
$_POST["oid"] : '')
103 $facilityService->update($newFacility);
105 // Update facility name for all users with this facility.
106 // This is necassary because some provider based code uses facility name for lookups instead of facility id.
108 $facilityService->updateUsersFacility($newFacility['name'], $newFacility['fid']);
109 exit(); // sjp 12/20/17 for ajax save
117 <title
><?php
echo xlt("Facilities") ; ?
></title
>
119 <?php Header
::setupHeader(['common', 'jquery-ui']); ?
>
121 <script type
="text/javascript">
123 function refreshme() {
124 top
.restoreSession();
125 document
.location
.reload();
129 $
(".medium_modal").on('click', function(e
) {
130 e
.preventDefault();e
.stopPropagation();
131 dlgopen('', '', 700, 590, '', '', {
133 allowDrag
: true, // note these default to true if not defined here. left as example.
135 url
: $
(this
).attr('href')
139 $
(".addfac_modal").on('click', function(e
) {
140 e
.preventDefault();e
.stopPropagation();
141 dlgopen('', '', 700, 620, '', '', {
145 url
: $
(this
).attr('href')
154 <body
class="body_top">
156 <div
class="container-fluid">
158 <div
class="col-xs-12">
159 <div
class="page-header clearfix">
160 <h2
class="clearfix"><?php
echo xlt("Facilities") ; ?
></h2
>
162 <a href
="facilities_add.php" class="addfac_modal btn btn-default btn-add"><span
><?php
echo xlt('Add Facility');?
></span
></a
>
167 <div
class="col-xs-12">
168 <div
class="table-responsive">
169 <table
class="table table-striped">
172 <th
><?php
echo xlt('Name'); ?
></th
>
173 <th
><?php
echo xlt('Billing Address'); ?
></th
>
174 <th
><?php
echo xlt('Mailing Address'); ?
></th
>
175 <th
><?php
echo xlt('Phone'); ?
></th
>
181 $fres = $facilityService->getAll();
184 for ($iter3 = 0; $iter3 < sizeof($fres); $iter3++
) {
185 $result2[$iter3] = $fres[$iter3];
188 foreach ($result2 as $iter3) {
189 $varstreet="";//these are assigned conditionally below,blank assignment is done so that old values doesn't get propagated to next level.
195 $varstreet=$iter3["street"];
196 if ($iter3["street"]!="") {
197 $varstreet=$iter3["street"].",";
200 if ($iter3["city"]!="") {
201 $varcity=$iter3["city"].",";
204 if ($iter3["state"]!="") {
205 $varstate=$iter3["state"].",";
208 $varmstreet=$iter3["mail_street"];
209 if ($iter3["mail_street"] !="") {
210 $varmstreet=$iter3["mail_street"].",";
213 if ($iter3["mail_city"]!="") {
214 $varmcity=$iter3["mail_city"].",";
217 if ($iter3["mail_state"]!="") {
218 $varmstate=$iter3["mail_state"].",";
222 <td valign
="top" class="text"><b
><a href
="facility_admin.php?fid=<?php echo attr_url($iter3["id
"]); ?>" class="medium_modal"><span
><?php
echo xlt($iter3["name"]);?
></span
></a
></b
> 
;</td
>
223 <td valign
="top" class="text"><?php
echo text($varstreet.$varcity.$varstate.$iter3["country_code"]." ".$iter3["postal_code"]); ?
> 
;</td
>
224 <td valign
="top" class="text"><?php
echo text($varmstreet.$varmcity.$varmstate.$iter3['mail_zip']); ?
></td
>
225 <td
><?php
echo text($iter3["phone"]);?
> 
;</td
>
231 if (count($result2)<=0) {?
>
233 <td colspan
="3" style
="text-align:center;font-weight:bold;"> <?php
echo xlt("Currently there are no facilities."); ?
></td
>
242 </div
><!-- end of div container
-->
243 <script language
="JavaScript">
245 if ($alertmsg = trim($alertmsg)) {
246 echo "alert(" . js_escape($alertmsg) . ");\n";