Patient_data varchar size

tmccormi wrote on Friday, December 04, 2015:

I’ve run into this quite a few times…

When doing a upgrade to a system where users have added extra fields to the patient_data via LBF the upgrade fails with an error like what follows:

ERROR: query failed: ALTER TABLE patient_data ADD COLUMN email_direct varchar(255) NOT NULL default ‘’
Error: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. You have to change some columns to TEXT or BLOBs

The solution above works or you can just reduce the size of several of the fields that are set to VARCHAR(255) for no good (ie: legacy) reasons. like …

title varchar(255) NOT NULL default ‘’,
language varchar(255) NOT NULL default ‘’,
financial varchar(255) NOT NULL default ‘’,
fname varchar(255) NOT NULL default ‘’,
lname varchar(255) NOT NULL default ‘’,
mname varchar(255) NOT NULL default ‘’,
DOB date default NULL,
street varchar(255) NOT NULL default ‘’,
… and on and on

The database.sql file should be updated for new installs to use reasonable length VARCHARS. no reason for the names and postal codes to be 255, they should reflect the actual needed size. I don’t think this needs to be in upgrades as well, but it could be with some care.

and on that note. We should never be using VARCHAR for text fields that, from the UI, look like unlimited notes boxes, those should the type TEXT. More than 255 characters typed in a field set with VARCHAR(255) are silently truncated if the box itself has not had the max-length set, very bad for medical records.

Just some thoughts …

bradymiller wrote on Friday, December 04, 2015:

Hi,

Check out this post for some background on this issue:
http://ehc.ac/p/openemr/discussion/202506/thread/a3097c3c/?limit=25&page=1#fcb3

-brady
OpenEMR

tmccormi wrote on Friday, December 04, 2015:

I read that a while back, it address (in a cheesy way) future adds to patient_data by end users, but does not address that fact that having a 255 character postal code field (for example) is just goofy. Do you know anyone with a combined first/middle/last name that comes close to 700+ characters long?

The database.sql file could easily be tweaked for new installs to use reasonable field lengths going forward.

LBF shoud have field type selection and size based on Length entered for the field not default to TEXT for new text types (for the performance reasons mentioned). TEXT type should be an option for those fields not the default, I think.

bradymiller wrote on Sunday, December 06, 2015:

Hi,
I wouldn’t really call it a cheesy way. More of a simple and global fix for a complicated problem. Note that the lbf forms dump all data into a TEXT sql column(since it’s a vertical table, all data goes into one TEXT column in the lbf_data table).
-brady
OpenEMR

bradymiller wrote on Sunday, December 06, 2015:

Also agree it makes sense to shorten pertinent fields for new installs (and also remove some fields like the usertext_ and userlist_ fields).
-brady
OpenEMR