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 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
;
20 $facilityService = new FacilityService();
24 /* Inserting New facility */
25 if (isset($_POST["mode"]) && $_POST["mode"] == "facility" && $_POST["newmode"] != "admin_facility") {
27 "name" => trim(isset($_POST["facility"]) ?
$_POST["facility"] : ''),
28 "phone" => trim(isset($_POST["phone"]) ?
$_POST["phone"] : ''),
29 "fax" => trim(isset($_POST["fax"]) ?
$_POST["fax"] : ''),
30 "street" => trim(isset($_POST["street"]) ?
$_POST["street"] : ''),
31 "city" => trim(isset($_POST["city"]) ?
$_POST["city"] : ''),
32 "state" => trim(isset($_POST["state"]) ?
$_POST["state"] : ''),
33 "postal_code" => trim(isset($_POST["postal_code"]) ?
$_POST["postal_code"] : ''),
34 "country_code" => trim(isset($_POST["country_code"]) ?
$_POST["country_code"] : ''),
35 "federal_ein" => trim(isset($_POST["federal_ein"]) ?
$_POST["federal_ein"] : ''),
36 "website" => trim(isset($_POST["website"]) ?
$_POST["website"] : ''),
37 "email" => trim(isset($_POST["email"]) ?
$_POST["email"] : ''),
38 "color" => trim(isset($_POST["ncolor"]) ?
$_POST["ncolor"] : ''),
39 "service_location" => trim(isset($_POST["service_location"]) ?
$_POST["service_location"] : ''),
40 "billing_location" => trim(isset($_POST["billing_location"]) ?
$_POST["billing_location"] : ''),
41 "accepts_assignment" => trim(isset($_POST["accepts_assignment"]) ?
$_POST["accepts_assignment"] : ''),
42 "pos_code" => trim(isset($_POST["pos_code"]) ?
$_POST["pos_code"] : ''),
43 "domain_identifier" => trim(isset($_POST["domain_identifier"]) ?
$_POST["domain_identifier"] : ''),
44 "attn" => trim(isset($_POST["attn"]) ?
$_POST["attn"] : ''),
45 "tax_id_type" => trim(isset($_POST["tax_id_type"]) ?
$_POST["tax_id_type"] : ''),
46 "primary_business_entity" => trim(isset($_POST["primary_business_entity"]) ?
$_POST["primary_business_entity"] : ''),
47 "facility_npi" => trim(isset($_POST["facility_npi"]) ?
$_POST["facility_npi"] : ''),
48 "facility_taxonomy" => trim(isset($_POST["facility_taxonomy"]) ?
$_POST["facility_taxonomy"] : ''),
49 "facility_code" => trim(isset($_POST["facility_id"]) ?
$_POST["facility_id"] : '')
52 $insert_id = $facilityService->insert($newFacility);
53 exit(); // sjp 12/20/17 for ajax save
56 /* Editing existing facility */
57 if (isset($_POST["mode"]) && $_POST["mode"] == "facility" && $_POST["newmode"] == "admin_facility") {
59 "fid" => trim(isset($_POST["fid"]) ?
$_POST["fid"] : ''),
60 "name" => trim(isset($_POST["facility"]) ?
$_POST["facility"] : ''),
61 "phone" => trim(isset($_POST["phone"]) ?
$_POST["phone"] : ''),
62 "fax" => trim(isset($_POST["fax"]) ?
$_POST["fax"] : ''),
63 "street" => trim(isset($_POST["street"]) ?
$_POST["street"] : ''),
64 "city" => trim(isset($_POST["city"]) ?
$_POST["city"] : ''),
65 "state" => trim(isset($_POST["state"]) ?
$_POST["state"] : ''),
66 "postal_code" => trim(isset($_POST["postal_code"]) ?
$_POST["postal_code"] : ''),
67 "country_code" => trim(isset($_POST["country_code"]) ?
$_POST["country_code"] : ''),
68 "federal_ein" => trim(isset($_POST["federal_ein"]) ?
$_POST["federal_ein"] : ''),
69 "website" => trim(isset($_POST["website"]) ?
$_POST["website"] : ''),
70 "email" => trim(isset($_POST["email"]) ?
$_POST["email"] : ''),
71 "color" => trim(isset($_POST["ncolor"]) ?
$_POST["ncolor"] : ''),
72 "service_location" => trim(isset($_POST["service_location"]) ?
$_POST["service_location"] : ''),
73 "billing_location" => trim(isset($_POST["billing_location"]) ?
$_POST["billing_location"] : ''),
74 "accepts_assignment" => trim(isset($_POST["accepts_assignment"]) ?
$_POST["accepts_assignment"] : ''),
75 "pos_code" => trim(isset($_POST["pos_code"]) ?
$_POST["pos_code"] : ''),
76 "domain_identifier" => trim(isset($_POST["domain_identifier"]) ?
$_POST["domain_identifier"] : ''),
77 "attn" => trim(isset($_POST["attn"]) ?
$_POST["attn"] : ''),
78 "tax_id_type" => trim(isset($_POST["tax_id_type"]) ?
$_POST["tax_id_type"] : ''),
79 "primary_business_entity" => trim(isset($_POST["primary_business_entity"]) ?
$_POST["primary_business_entity"] : ''),
80 "facility_npi" => trim(isset($_POST["facility_npi"]) ?
$_POST["facility_npi"] : ''),
81 "facility_taxonomy" => trim(isset($_POST["facility_taxonomy"]) ?
$_POST["facility_taxonomy"] : ''),
82 "facility_code" => trim(isset($_POST["facility_id"]) ?
$_POST["facility_id"] : '')
85 $facilityService->update($newFacility);
87 // Update facility name for all users with this facility.
88 // This is necassary because some provider based code uses facility name for lookups instead of facility id.
90 $facilityService->updateUsersFacility($newFacility['name'], $newFacility['fid']);
91 exit(); // sjp 12/20/17 for ajax save
99 <title
><?php
echo xlt("Facilities") ; ?
></title
>
101 <?php Header
::setupHeader(['common', 'jquery-ui']); ?
>
103 <script type
="text/javascript">
105 function refreshme() {
106 top
.restoreSession();
107 document
.location
.reload();
109 $
(document
).ready(function(){
111 $
(".medium_modal").on('click', function(e
) {
112 e
.preventDefault();e
.stopPropagation();
113 dlgopen('', '', 700, 590, '', '', {
115 allowDrag
: true, // note these default to true if not defined here. left as example.
117 url
: $
(this
).attr('href')
121 $
(".addfac_modal").on('click', function(e
) {
122 e
.preventDefault();e
.stopPropagation();
123 dlgopen('', '', 700, 620, '', '', {
127 url
: $
(this
).attr('href')
136 <body
class="body_top">
138 <div
class="container-fluid">
140 <div
class="col-xs-12">
141 <div
class="page-header clearfix">
142 <h2
class="clearfix"><?php
echo xlt("Facilities") ; ?
></h2
>
144 <a href
="facilities_add.php" class="addfac_modal btn btn-default btn-add"><span
><?php
echo xlt('Add Facility');?
></span
></a
>
149 <div
class="col-xs-12">
150 <div
class="table-responsive">
151 <table
class="table table-striped">
154 <th
><?php
echo xlt('Name'); ?
></th
>
155 <th
><?php
echo xlt('Address'); ?
></th
>
156 <th
><?php
echo xlt('Phone'); ?
></th
>
162 $fres = $facilityService->getAll();
165 for ($iter3 = 0; $iter3 < sizeof($fres); $iter3++
) {
166 $result2[$iter3] = $fres[$iter3];
169 foreach ($result2 as $iter3) {
170 $varstreet="";//these are assigned conditionally below,blank assignment is done so that old values doesn't get propagated to next level.
173 $varstreet=$iter3["street"];
174 if ($iter3["street"]!="") {
175 $varstreet=$iter3["street"].",";
178 if ($iter3["city"]!="") {
179 $varcity=$iter3["city"].",";
182 if ($iter3["state"]!="") {
183 $varstate=$iter3["state"].",";
187 <td valign
="top" class="text"><b
><a href
="facility_admin.php?fid=<?php echo attr($iter3["id
"]); ?>" class="medium_modal"><span
><?php
echo text($iter3["name"]);?
></span
></a
></b
> 
;</td
>
188 <td valign
="top" class="text"><?php
echo text($varstreet.$varcity.$varstate.$iter3["country_code"]." ".$iter3["postal_code"]); ?
> 
;</td
>
189 <td
><?php
echo text($iter3["phone"]);?
> 
;</td
>
195 if (count($result2)<=0) {?
>
197 <td colspan
="3" style
="text-align:center;font-weight:bold;"> <?php
echo xlt("Currently there are no facilities."); ?
></td
>
206 </div
><!-- end of div container
-->
207 <script language
="JavaScript">
209 if ($alertmsg = trim($alertmsg)) {
210 echo "alert('$alertmsg');\n";