forked from openemr/openemr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
facilities.php
257 lines (227 loc) · 12.4 KB
/
facilities.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
<?php
/**
* Facilities.
*
* @package OpenEMR
* @link http:https://www.open-emr.org
* @author Ranganath Pathak <[email protected]>
* @author Brady Miller <[email protected]>
* @copyright Copyright (c) 2017 Ranganath Pathak <[email protected]>
* @copyright Copyright (c) 2017-2018 Brady Miller <[email protected]>
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/
require_once("../globals.php");
use OpenEMR\Common\Csrf\CsrfUtils;
use OpenEMR\Core\Header;
use OpenEMR\Services\FacilityService;
if (!empty($_POST)) {
if (!CsrfUtils::verifyCsrfToken($_POST["csrf_token_form"])) {
CsrfUtils::csrfNotVerified();
}
}
$facilityService = new FacilityService();
$alertmsg = '';
/* Inserting New facility */
if (isset($_POST["mode"]) && $_POST["mode"] == "facility" && $_POST["newmode"] != "admin_facility") {
$newFacility = array(
"name" => trim(isset($_POST["facility"]) ? $_POST["facility"] : ''),
"phone" => trim(isset($_POST["phone"]) ? $_POST["phone"] : ''),
"fax" => trim(isset($_POST["fax"]) ? $_POST["fax"] : ''),
"street" => trim(isset($_POST["street"]) ? $_POST["street"] : ''),
"city" => trim(isset($_POST["city"]) ? $_POST["city"] : ''),
"state" => trim(isset($_POST["state"]) ? $_POST["state"] : ''),
"postal_code" => trim(isset($_POST["postal_code"]) ? $_POST["postal_code"] : ''),
"country_code" => trim(isset($_POST["country_code"]) ? $_POST["country_code"] : ''),
"federal_ein" => trim(isset($_POST["federal_ein"]) ? $_POST["federal_ein"] : ''),
"website" => trim(isset($_POST["website"]) ? $_POST["website"] : ''),
"email" => trim(isset($_POST["email"]) ? $_POST["email"] : ''),
"color" => trim(isset($_POST["ncolor"]) ? $_POST["ncolor"] : ''),
"service_location" => trim(isset($_POST["service_location"]) ? $_POST["service_location"] : ''),
"billing_location" => trim(isset($_POST["billing_location"]) ? $_POST["billing_location"] : ''),
"accepts_assignment" => trim(isset($_POST["accepts_assignment"]) ? $_POST["accepts_assignment"] : ''),
"pos_code" => trim(isset($_POST["pos_code"]) ? $_POST["pos_code"] : ''),
"domain_identifier" => trim(isset($_POST["domain_identifier"]) ? $_POST["domain_identifier"] : ''),
"attn" => trim(isset($_POST["attn"]) ? $_POST["attn"] : ''),
"tax_id_type" => trim(isset($_POST["tax_id_type"]) ? $_POST["tax_id_type"] : ''),
"primary_business_entity" => trim(isset($_POST["primary_business_entity"]) ? $_POST["primary_business_entity"] : ''),
"facility_npi" => trim(isset($_POST["facility_npi"]) ? $_POST["facility_npi"] : ''),
"facility_taxonomy" => trim(isset($_POST["facility_taxonomy"]) ? $_POST["facility_taxonomy"] : ''),
"facility_code" => trim(isset($_POST["facility_id"]) ? $_POST["facility_id"] : ''),
"mail_street" => trim(isset($_POST["mail_street"]) ? $_POST["mail_street"] : ''),
"mail_street2" => trim(isset($_POST["mail_street2"]) ? $_POST["mail_street2"] : ''),
"mail_city" => trim(isset($_POST["mail_city"]) ? $_POST["mail_city"] : ''),
"mail_state" => trim(isset($_POST["mail_state"]) ? $_POST["mail_state"] : ''),
"mail_zip" => trim(isset($_POST["mail_zip"]) ? $_POST["mail_zip"] : ''),
"oid" => trim(isset($_POST["oid"]) ? $_POST["oid"] : ''),
"iban" => trim(isset($_POST["iban"]) ? $_POST["iban"] : ''),
"info" => trim(isset($_POST["info"]) ? $_POST["info"] : '')
);
$insert_id = $facilityService->insertFacility($newFacility);
exit(); // sjp 12/20/17 for ajax save
}
/* Editing existing facility */
if (isset($_POST["mode"]) && $_POST["mode"] == "facility" && $_POST["newmode"] == "admin_facility") {
$newFacility = array(
"id" => trim(isset($_POST["fid"]) ? $_POST["fid"] : ''),
"name" => trim(isset($_POST["facility"]) ? $_POST["facility"] : ''),
"phone" => trim(isset($_POST["phone"]) ? $_POST["phone"] : ''),
"fax" => trim(isset($_POST["fax"]) ? $_POST["fax"] : ''),
"street" => trim(isset($_POST["street"]) ? $_POST["street"] : ''),
"city" => trim(isset($_POST["city"]) ? $_POST["city"] : ''),
"state" => trim(isset($_POST["state"]) ? $_POST["state"] : ''),
"postal_code" => trim(isset($_POST["postal_code"]) ? $_POST["postal_code"] : ''),
"country_code" => trim(isset($_POST["country_code"]) ? $_POST["country_code"] : ''),
"federal_ein" => trim(isset($_POST["federal_ein"]) ? $_POST["federal_ein"] : ''),
"website" => trim(isset($_POST["website"]) ? $_POST["website"] : ''),
"email" => trim(isset($_POST["email"]) ? $_POST["email"] : ''),
"color" => trim(isset($_POST["ncolor"]) ? $_POST["ncolor"] : ''),
"service_location" => trim(isset($_POST["service_location"]) ? $_POST["service_location"] : ''),
"billing_location" => trim(isset($_POST["billing_location"]) ? $_POST["billing_location"] : ''),
"accepts_assignment" => trim(isset($_POST["accepts_assignment"]) ? $_POST["accepts_assignment"] : ''),
"pos_code" => trim(isset($_POST["pos_code"]) ? $_POST["pos_code"] : ''),
"domain_identifier" => trim(isset($_POST["domain_identifier"]) ? $_POST["domain_identifier"] : ''),
"attn" => trim(isset($_POST["attn"]) ? $_POST["attn"] : ''),
"tax_id_type" => trim(isset($_POST["tax_id_type"]) ? $_POST["tax_id_type"] : ''),
"primary_business_entity" => trim(isset($_POST["primary_business_entity"]) ? $_POST["primary_business_entity"] : ''),
"facility_npi" => trim(isset($_POST["facility_npi"]) ? $_POST["facility_npi"] : ''),
"facility_taxonomy" => trim(isset($_POST["facility_taxonomy"]) ? $_POST["facility_taxonomy"] : ''),
"facility_code" => trim(isset($_POST["facility_id"]) ? $_POST["facility_id"] : ''),
"mail_street" => trim(isset($_POST["mail_street"]) ? $_POST["mail_street"] : ''),
"mail_street2" => trim(isset($_POST["mail_street2"]) ? $_POST["mail_street2"] : ''),
"mail_city" => trim(isset($_POST["mail_city"]) ? $_POST["mail_city"] : ''),
"mail_state" => trim(isset($_POST["mail_state"]) ? $_POST["mail_state"] : ''),
"mail_zip" => trim(isset($_POST["mail_zip"]) ? $_POST["mail_zip"] : ''),
"oid" => trim(isset($_POST["oid"]) ? $_POST["oid"] : ''),
"iban" => trim(isset($_POST["iban"]) ? $_POST["iban"] : ''),
"info" => trim(isset($_POST["info"]) ? $_POST["info"] : '')
);
$facilityService->updateFacility($newFacility);
// Update facility name for all users with this facility.
// This is necassary because some provider based code uses facility name for lookups instead of facility id.
//
$facilityService->updateUsersFacility($newFacility['name'], $newFacility['fid']);
exit(); // sjp 12/20/17 for ajax save
}
?>
<!DOCTYPE html >
<html>
<head>
<title><?php echo xlt("Facilities") ; ?></title>
<?php Header::setupHeader(['common']); ?>
<script>
function refreshme() {
top.restoreSession();
document.location.reload();
}
$(function () {
$(".medium_modal").on('click', function(e) {
e.preventDefault();e.stopPropagation();
dlgopen('', '', 700, 590, '', '', {
allowResize: false,
allowDrag: true, // note these default to true if not defined here. left as example.
type: 'iframe',
url: $(this).attr('href')
});
});
$(".addfac_modal").on('click', function(e) {
e.preventDefault();e.stopPropagation();
dlgopen('', '', 700, 620, '', '', {
allowResize: false,
allowDrag: true,
type: 'iframe',
url: $(this).attr('href')
});
});
});
</script>
</head>
<body class="body_top">
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="page-header clearfix">
<h2 class="clearfix"><?php echo xlt("Facilities") ; ?></h2>
</div>
<a href="facilities_add.php" class="addfac_modal btn btn-secondary btn-add"><?php echo xlt('Add Facility');?></a>
</div>
</div>
<br />
<div class="row">
<div class="col-12">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th><?php echo xlt('Name'); ?></th>
<th><?php echo xlt('Billing Address'); ?></th>
<th><?php echo xlt('Mailing Address'); ?></th>
<th><?php echo xlt('Phone'); ?></th>
</tr>
</thead>
<tbody>
<?php
$fres = 0;
$fres = $facilityService->getAllFacility();
if ($fres) {
$result2 = array();
for ($iter3 = 0; $iter3 < sizeof($fres); $iter3++) {
$result2[$iter3] = $fres[$iter3];
}
foreach ($result2 as $iter3) {
$varstreet = "";//these are assigned conditionally below,blank assignment is done so that old values doesn't get propagated to next level.
$varcity = "";
$varstate = "";
$varmstreet = "";
$varmcity = "";
$varmstate = "";
$varstreet = $iter3["street"];
if ($iter3["street"] != "") {
$varstreet = $iter3["street"] . ",";
}
if ($iter3["city"] != "") {
$varcity = $iter3["city"] . ",";
}
if ($iter3["state"] != "") {
$varstate = $iter3["state"] . ",";
}
$varmstreet = $iter3["mail_street"];
if ($iter3["mail_street"] != "") {
$varmstreet = $iter3["mail_street"] . ",";
}
if ($iter3["mail_city"] != "") {
$varmcity = $iter3["mail_city"] . ",";
}
if ($iter3["mail_state"] != "") {
$varmstate = $iter3["mail_state"] . ",";
}
?>
<tr height="22">
<td valign="top" class="text"><strong><a href="facility_admin.php?fid=<?php echo attr_url($iter3["id"]); ?>" class="medium_modal"><span><?php echo xlt($iter3["name"]);?></span></a></strong> </td>
<td valign="top" class="text"><?php echo text($varstreet . $varcity . $varstate . $iter3["country_code"] . " " . $iter3["postal_code"]); ?> </td>
<td valign="top" class="text"><?php echo text($varmstreet . $varmcity . $varmstate . $iter3['mail_zip']); ?></td>
<td><?php echo text($iter3["phone"]);?> </td>
</tr>
<?php
}
}
if (count($result2) <= 0) {?>
<tr height="25">
<td colspan="3" class="text-center font-weight-bold"> <?php echo xlt("Currently there are no facilities."); ?></td>
</tr>
<?php
} ?>
</tbody>
</table>
</div>
</div>
</div>
</div><!-- end of div container -->
<script>
<?php
if ($alertmsg = trim($alertmsg)) {
echo "alert(" . js_escape($alertmsg) . ");\n";
}
?>
</script>
</body>
</html>