Do you use or administer OpenEMR? Take the General Satisfaction Survey to help improve the product

LBF Form - Query Error - Can't add or change information

Situation
I was editing an LBF form and came across the error below when trying to add a new field. Now I can’t add or edit any more info unless its in the initial group that was created when the form was created or the default group. Can anyone explain this?: Query Error

ERROR: query failed: INSERT INTO layout_options ( form_id, source, field_id, title, group_id, seq, uor, fld_length, fld_rows, titlecols, datacols, data_type, edit_options, default_value, description, max_length, list_id, list_backup_id ) VALUES ( ‘LBF_PMR_exam’,’’,’’,’’,’’,’’,’’,’’,’’,’’,’’,’’,’’,’’,’’,’’,’’,’’ )

Error: Duplicate entry ‘LBF_PMR_exam–0’ for key ‘PRIMARY’

/var/www/html/openemr/interface/super/edit_layout.php at 428:sqlStatement

OpenEMR Version
I’m using OpenEMR version 5.0.1

Browser:
I’m using: Chrome

Operating System
I’m using: Windows 10 x64

Logs


|---|---|---|---|---|---|---|---|---|
|2019-03-05 01:11|other-insert|other|chris|Chris Hodak|Default|0|0|INSERT INTO layout_options ( form_id, source, field_id, title, group_id, seq, uor, fld_length, fld_rows, titlecols, datacols, data_type, edit_options, default_value, description, max_length, list_id, list_backup_id ) VALUES ( 'LBF_PMR_exam','','','','','','','','','','','','','','','','','' )|

|2019-03-05 01:13|other-update|other|chris|Chris Hodak|Default|0|1|UPDATE layout_options SET field_id = 'newdx', source = 'F', title = 'New dx', group_id = '', seq = '0', uor = '1', fld_length = '', fld_rows = '', max_length = '0', titlecols = '0', datacols = '0', data_type= '3', list_id= '', list_backup_id= '', edit_options = '', default_value = '', description = '', conditions = '', validation = '' WHERE form_id = 'LBF_PMR_exam' AND field_id = ''|

|2019-03-05 01:13|other-update|other|chris|Chris Hodak|Default|0|1|UPDATE layout_options SET field_id = 'sub_nochange', source = 'F', title = 'Unchanged From Prior Eval', group_id = '1', seq = '10', uor = '1', fld_length = '0', fld_rows = '', max_length = '0', titlecols = '1', datacols = '1', data_type= '21', list_id= '', list_backup_id= '', edit_options = '', default_value = '', description = '', conditions = '', validation = '' WHERE form_id = 'LBF_PMR_exam' AND field_id = 'sub_nochange'|

Shameless self bump.

Hi @chodak sorry I’m late to the party. I had this error, and searched the forum for a solution but there was none, so I thought I would post the solution in hopes of helping others.

The issue here is that your web server (Apache) is truncating the request based on the php.ini variable max_input_vars. Not all of the required data is making it to the SQL statement resulting in this error. This setting defaults to 1000, but large LBFs can easily get up to 30-40K input variables.

In this screen shot of my Firefox DevTools, you can see the headers on my request when I click “save” after adding a new field to my large LBF. You can see that the content length highlighted in blue (number of input variables) is around 66k, and my max_input_vars setting in php.ini was 50000, which resulted in the error you describe.

The solution is to open your php.ini file and change the setting for max_input_vars to a number larger than what you see in your request header. You could try 100000 as a test if you don’t want to look at your devtools.

On Linux, the config files are located in /etc/php/…

Don’t forget to restart apache, or if your php module is running as a service, you have to restart the service. Otherwise you will continue to see the same error.

sudo service apache2 restart

if needed…

sudo service php7.3-fpm restart

Thanks,
Ken
mi-squared [dot] com