6 * @link http://www.open-emr.org
7 * @author Brady Miller <brady.g.miller@gmail.com>
8 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
9 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 require_once("../globals.php");
14 require_once("../../library/acl.inc");
15 require_once("$srcdir/options.inc.php");
16 require_once("$srcdir/erx_javascript.inc.php");
18 use OpenEMR\Core\Header
;
19 use OpenEMR\Services\FacilityService
;
21 $facilityService = new FacilityService();
27 <?php Header
::setupHeader(['opener', 'jquery-ui']); ?
>
28 <script type
="text/javascript" src
="../main/calendar/modules/PostCalendar/pnincludes/AnchorPosition.js"></script
>
29 <script type
="text/javascript" src
="../main/calendar/modules/PostCalendar/pnincludes/PopupWindow.js"></script
>
30 <script type
="text/javascript" src
="../main/calendar/modules/PostCalendar/pnincludes/ColorPicker2.js"></script
>
32 <!-- validation library
-->
33 <!--//Not lbf forms use the new validation, please make sure you have the corresponding values in the list Page validation-->
34 <?php
$use_validate_js = 1;?
>
35 <?php
require_once($GLOBALS['srcdir'] . "/validation/validation_script.js.php"); ?
>
37 //Gets validation rules from Page Validation list.
38 //Note that for technical reasons, we are bypassing the standard validateUsingPageRules() call.
39 $collectthis = collectValidationPageRules("/interface/usergroup/facilities_add.php");
40 if (empty($collectthis)) {
41 $collectthis = "undefined";
43 $collectthis = json_sanitize($collectthis["facility-add"]["rules"]);
46 // Old Browser comp trigger on js
48 if (isset($_POST["mode"]) && $_POST["mode"] == "facility") {
50 <script type="text/javascript">
59 <script type
="text/javascript">
60 /// todo, move this to a common library
62 var collectvalidation
= <?php
echo $collectthis; ?
>;
64 function submitform() {
66 var valid
= submitme(1, undefined
, 'facility-add', collectvalidation
);
69 <?php
if ($GLOBALS['erx_enable']) { ?
>
72 for(i
=0;i
<f
.length
;i++
){
73 if(f
[i
].type
=='text' && f
[i
].value
)
75 if(f
[i
].name
== 'facility' || f
[i
].name
== 'Washington')
77 alertMsg +
= checkLength(f
[i
].name
,f
[i
].value
,35);
78 alertMsg +
= checkFacilityName(f
[i
].name
,f
[i
].value
);
80 else if(f
[i
].name
== 'street')
82 alertMsg +
= checkLength(f
[i
].name
,f
[i
].value
,35);
83 alertMsg +
= checkAlphaNumeric(f
[i
].name
,f
[i
].value
);
85 else if(f
[i
].name
== 'phone' || f
[i
].name
== 'fax')
87 alertMsg +
= checkPhone(f
[i
].name
,f
[i
].value
);
89 else if(f
[i
].name
== 'federal_ein')
91 alertMsg +
= checkLength(f
[i
].name
,f
[i
].value
,10);
92 alertMsg +
= checkFederalEin(f
[i
].name
,f
[i
].value
);
103 top
.restoreSession();
105 let post_url
= $
("#facility-add").attr("action");
106 let request_method
= $
("#facility-add").attr("method");
107 let form_data
= $
("#facility-add").serialize();
111 type
: request_method
,
113 }).done(function (r
) { //
114 dlgclose('refreshme', false);
119 function toggle( target
, div
) {
121 $mode = $
(target
).find(".indicator").text();
122 if ( $mode == "collapse" ) {
123 $
(target
).find(".indicator").text( "expand" );
126 $
(target
).find(".indicator").text( "collapse" );
134 $
("#dem_view").click( function() {
135 toggle( $
(this
), "#DEM" );
141 $
("#cancel").click(function() {
146 * add required/star sign to required form fields
148 for (var prop in collectvalidation
) {
149 //if (collectvalidation[prop].requiredSign)
150 if (collectvalidation
[prop
].presence
)
151 jQuery("input[name='" + prop +
"']").after('*');
154 var cp
= new ColorPicker('window');
155 // Runs when a color is clicked
156 function pickColor(color
) {
157 document
.getElementById('ncolor').value
= color
;
160 function pick(anchorname
,target
) {
161 var cp
= new ColorPicker('window');
165 function displayAlert()
167 if(document
.getElementById('primary_business_entity').checked
==false)
168 alert(<?php
echo xlj('Primary Business Entity tax id is used as account id for NewCrop ePrescription. Changing the facility will affect the working in NewCrop.'); ?
>);
169 else if(document
.getElementById('primary_business_entity').checked
==true)
170 alert(<?php
echo xlj('Once the Primary Business Facility is set, it should not be changed. Changing the facility will affect the working in NewCrop ePrescription.'); ?
>);
173 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
176 <body
class="body_top">
179 <span
class="title"><?php
echo xlt('Add Facility'); ?
></span
> 
; 
; 
;</td
>
180 <td colspan
=5 align
=center style
="padding-left:2px;">
181 <a onclick
="submitform();" class="css_button large_button" name
='form_save' id
='form_save' href
='#'>
182 <span
class='css_button_span large_button_span'><?php
echo xlt('Save'); ?
></span
>
184 <a
class="css_button large_button" id
='cancel' href
='#' >
185 <span
class='css_button_span large_button_span'><?php
echo xlt('Cancel'); ?
></span
>
192 <form name
='facility-add' id
='facility-add' method
='post' action
="facilities.php">
193 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(collectCsrfToken()); ?>" />
194 <input type
=hidden name
=mode value
="facility">
195 <table border
=0 cellpadding
=0 cellspacing
=0>
197 <td
><span
class="text"><?php
echo xlt('Name'); ?
>: </span
></td
><td
><input type
=entry name
=facility size
=20 value
=""></td
>
198 <td width
=20> 
;</td
>
199 <td
><span
class="text"><?php
echo xlt('Phone'); ?
>: </span
></td
><td
><input type
=entry name
=phone size
=20 value
=""></td
>
202 <td
><span
class="text"><?php
echo xlt('Address'); ?
>: </span
></td
><td
><input type
=entry size
=20 name
=street value
=""></td
>
204 <td
><span
class="text"><?php
echo xlt('Fax'); ?
>: </span
></td
><td
><input type
=entry name
=fax size
=20 value
=""></td
>
207 <td
><span
class="text"><?php
echo xlt('City'); ?
>: </span
></td
><td
><input type
=entry size
=20 name
=city value
=""></td
>
209 <td
><span
class="text"><?php
echo xlt('Zip Code'); ?
>: </span
></td
><td
><input type
=entry size
=20 name
=postal_code value
=""></td
>
212 <td
><span
class="text"><?php
echo xlt('State'); ?
>: </span
></td
><td
><input type
=entry size
=20 name
=state value
=""></td
>
214 <td
><span
class="text"><?php
echo xlt('Tax ID'); ?
>: </span
></td
><td
><select name
=tax_id_type
><option value
="EI"><?php
echo xlt('EIN'); ?
></option
><option value
="SY"><?php
echo xlt('SSN'); ?
></option
></select
><input type
=entry size
=11 name
=federal_ein value
=""></td
>
217 <td height
="22"><span
class="text"><?php
echo xlt('Country'); ?
>: </span
></td
><td
><input type
=entry size
=20 name
=country_code value
=""></td
>
219 <td
><span
class="text"><?php
echo ($GLOBALS['simplified_demographics'] ?
xlt('Facility Code') : xlt('Facility NPI')); ?
>:
220 </span
></td
><td
><input type
=entry size
=20 name
=facility_npi value
=""></td
>
223 <td
> 
;</td
><td
> 
;</td
><td width
="20"></td
><td
><span
class=text
><?php
echo xlt('Facility Taxonomy'); ?
>:</span
></td
>
224 <td
><input type
=entry size
=20 name
=facility_taxonomy value
=""></td
>
227 <td
><span
class="text"><?php
echo xlt('Website'); ?
>: </span
></td
><td
><input type
=entry size
=20 name
=website value
=""></td
>
229 <td
><span
class="text"><?php
echo xlt('Email'); ?
>: </span
></td
><td
><input type
=entry size
=20 name
=email value
=""></td
>
233 <td
><span
class='text'><?php
echo xlt('Billing Location'); ?
>: </span
></td
><td
><input type
='checkbox' name
='billing_location' value
= '1'></td
>
235 <td
><span
class='text'><?php
echo xlt('Accepts Assignment'); ?
><br
>(<?php
echo xlt('only if billing location'); ?
>): </span
></td
> <td
><input type
='checkbox' name
='accepts_assignment' value
= '1'></td
>
238 <td
><span
class='text'><?php
echo xlt('Service Location'); ?
>: </span
></td
> <td
><input type
='checkbox' name
='service_location' value
= '1'></td
>
240 <td
><span
class='text'><?php
echo xlt('Color'); ?
>: </span
></td
> <td
><input type
=entry name
=ncolor id
=ncolor size
=20 value
=""><span
>[<a href
="javascript:void(0);" onClick
="pick('pick','newcolor');return false;" NAME
="pick" ID
="pick"><?php
echo xlt('Pick'); ?
></a
>]</span
></td
>
244 $resPBE = $facilityService->getPrimaryBusinessEntity(array("excludedId" => $my_fid));
245 if (!empty($resPBE) && sizeof($resPBE)>0) {
246 $disabled='disabled';
250 <td
><span
class='text'><?php
echo xlt('Primary Business Entity'); ?
>: </span
></td
>
251 <td
><input type
='checkbox' name
='primary_business_entity' id
='primary_business_entity' value
='1' <?php
echo ($facility['primary_business_entity'] == 1) ?
'checked' : ''; ?
>
252 <?php
if ($GLOBALS['erx_enable']) { ?
>
253 onchange
='return displayAlert()'
254 <?php
} ?
> <?php
echo $disabled;?
>></td
>
258 <td
><span
class=text
><?php
echo xlt('POS Code'); ?
>: </span
></td
>
260 <select name
="pos_code">
264 foreach ($pc->get_pos_ref() as $pos) {
265 echo "<option value=\"" . attr($pos["code"]) . "\" ";
266 echo ">" . text($pos['code']) . ": ". text($pos['title']);
275 <td
><span
class="text"><?php
echo xlt('Billing Attn'); ?
>:</span
></td
>
276 <td colspan
="4"><input type
="entry" name
="attn" size
="45"></td
>
279 <td
><span
class="text"><?php
echo xlt('CLIA Number'); ?
>:</span
></td
>
280 <td colspan
="4"><input type
="entry" name
="domain_identifier" size
="45"></td
>
283 <td
><span
class="text"><?php
echo xlt('Facility ID'); ?
>:</span
></td
>
284 <td colspan
="4"><input type
="entry" name
="facility_id" size
="20"></td
>
288 <span
class="text"><?php
echo xlt('OID'); ?
>: </span
>
291 <input type
="entry" size
="20" name
="oid" value
="<?php echo attr($facility["oid
"]) ?>">
301 <label
><?php
echo xlt('Mailing Address'); ?
>: </label
>
304 <input type
="entry" size
="20" name
="mail_street" value
="<?php echo attr($facility["mail_street
"]) ?>">
310 <label
><?php
echo xlt('Dept'); ?
>: </label
>
313 <input type
="entry" size
="20" name
="mail_street2" value
="<?php echo attr($facility["mail_street2
"]) ?>">
319 <label
><?php
echo xlt('City'); ?
>: </label
>
322 <input type
="entry" size
="20" name
="mail_city" value
="<?php echo attr($facility["mail_city
"]) ?>">
327 <label
><?php
echo xlt('State'); ?
>: </label
>
330 <input type
="entry" size
="20" name
="mail_state" value
="<?php echo attr($facility["mail_state
"]) ?>">
335 <label
><?php
echo xlt('Zip'); ?
>: </label
>
338 <input type
="entry" size
="20" name
="mail_zip" value
="<?php echo attr($facility["mail_zip
"]) ?>">
341 <tr height
="25" style
="valign:bottom;">
342 <td
><font
class="mandatory">*</font
><span
class="text"> <?php
echo xlt('Required'); ?
></span
></td
><td
> 
;</td
><td
> 
;</td
>
343 <td
> 
;</td
><td
> 
;</td
>
348 <script language
="JavaScript">
350 if ($alertmsg = trim($alertmsg)) {
351 echo "alert(" . js_escape($alertmsg) . ");\n";