Unknown column 'date' in 'order clause'

careso wrote on Tuesday, December 20, 2011:

I was working in Layouts, Demografics, Misc group; and I erased the two first fields “deceased_date” and “deceased_reason”. When I went to search for a patient I could not access them, I was asked if I wanted to delete it, so I did. Still I couldn’t even create a new patient. So I went back and create the fields I had deleted, but I got the following message:

ERROR: query failed: select *, DATE_FORMAT(DOB,’%Y-%m-%d’) as DOB_YMD from patient_data where pid=? order by date DESC limit 0,1

Error: Unknown column ‘date’ in ‘order clause’

Now I can’t access nor create a patient…… please help, thank-you!

bradymiller wrote on Wednesday, December 21, 2011:

Hi,
Wonder if there is a bug here that ended up also removing the ‘date’ field (note this is not in the Layout, but is in the patient_data table). Do you see a ‘date’ entry at Administration->Database->(click ‘patient_data’ at left screen) and now look at the entries to the right. Is there a ‘date’ field; it should be right above the ‘sex’ field. Also, in future (after get this fixed) rec not removing stuff from the layouts; safer to simply maked it ‘unused’ in the UOR column.
-brady

careso wrote on Wednesday, December 21, 2011:

Hi bradymiller:
I checked for a “date” entry as you instructed, but didn’t find one. Didn’t find a ‘sex’ field either and when I compared it to the OpenEMR demo fields, there are quite a few fields that I also did not find. Is this supposed to be that way? How could I fix this?

careso wrote on Wednesday, December 21, 2011:

Today I cannot even access the patient list. I get this error message when I press “search” for a patient.

ERROR: query failed: SELECT *, DATE_FORMAT(DOB,’%m/%d/%Y’) as DOB_TS FROM patient_data WHERE 1 = 1 ORDER BY lname ASC, fname ASC LIMIT 0, 100

Error: Unknown column ‘DOB’ in ‘field list’

In the patient_data fields, this is one of the fields that does not appear.

bradymiller wrote on Wednesday, December 21, 2011:

Hi,

That doesn’t sound very good. Do you have a backup? Also, the following will help:
OpenEMR version?
OpenEMR package?
Operating system?

-brady

careso wrote on Wednesday, December 21, 2011:

Hi,

OMG! This gets worse every minute, now I don’t see the “Who” option on my screen, don’t have access to messages,  calendar,  and at the botton part of the screen I have the following message:

ERROR: query failed: SELECT pnotes.id, pnotes.user, pnotes.pid, pnotes.title, pnotes.date, pnotes.message_status, IF(pnotes.user != pnotes.pid,users.fname,patient_data.fname), IF(pnotes.user != pnotes.pid,users.lname,patient_data.lname), patient_data.fname, patient_data.lname FROM ((pnotes LEFT JOIN users ON pnotes.user = users.username) JOIN patient_data ON pnotes.pid = patient_data.pid) WHERE pnotes.message_status != ‘Done’ AND pnotes.deleted != ‘1’ AND pnotes.assigned_to LIKE ?

Error: Unknown column ‘patient_data.fname’ in ‘field list’

The Open EMR version is: 4.1.0
What do you mean by OpenEMR package?
Operating system? Windows 7 Profesional

My IT dept. says they could install one from Oct, I’ll lose a lot of set-up work.

bradymiller wrote on Wednesday, December 21, 2011:

Hi,

For the OpenEMR package, did you use the OpenEMR-XAMPP package or install XAMPP and mysql separately?

Can you paste your patient_data table structure here (to see if can see any patterns?. From what you’re saying, it appears you will need to go to a backup. Before doing this, suggest looking for (and fixing) mysql database corruption via mysqlcheck command:
http://dev.mysql.com/doc/refman/5.0/en/mysqlcheck.html

Also very important to have a backup mechanism (preferrably automated).

-brady

bradymiller wrote on Wednesday, December 21, 2011:

Hi,
If you do need to restore, note it’s just the mysql database that needs to be restored. So, if you made any changes in the codebase (web directory), no need to restore that.
-brady

anonymous wrote on Saturday, August 04, 2012:

I have the same problem.  Deleted migrant worker / deceased fields.  The specific error I have is

ERROR: query failed: SELECT *, DATE_FORMAT(DOB,’%m/%d/%Y’) as DOB_TS FROM patient_data WHERE allow_health_info_ex like ? or allow_imm_info_share like ? or allow_imm_reg_use like ? or allow_patient_portal like ? or CHILDREN like ? or city like ? or contact_relationship like ? or country_code like ? or deceased_date like ? or deceased_reason like ? or DOB like ? or drivers_license like ? or email like ? or ethnicity like ? or expires like ? or family_size like ? or fname like ? or genericname1 like ? or genericname2 like ? or genericval1 like ? or genericval2 like ? or guardiansname like ? or hipaa_allowemail like ? or hipaa_allowsms like ? or hipaa_mail like ? or hipaa_message like ? or homeless like ? or hopsital_id like ? or language like ? or Lat like ? or lname like ? or LONG like ? or migrantseasonal like ? or mname like ? or mothersname like ? or pharmacy_id like ? or phone_biz like ? or phone_cell like ? or phone_contact like ? or phone_home like ? or postal_code like ? or providerID like ? or pubpid like ? or referral_source like ? or regdate like ? or sex like ? or ss like ? or state like ? or status like ? or street like ? or title like ? or userlist1 like ? or userlist2 like ? or userlist3 like ? or userlist4 like ? or userlist5 like ? or userlist6 like ? or userlist7 like ? or usertext2 like ? or usertext6 like ? or usertext7 like ? or usertext8 like ? ORDER BY lname ASC, fname ASC limit 0, 100

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LONG like ‘%123%’ or migrantseasonal like ‘%123%’ or mname like ‘%123%’ or ’ at line 1

Except, the field “date” is in my patient_data table. 

Seems to be a bug related to deleting the standard fields. 

marka1211 wrote on Tuesday, August 14, 2012:

I’m not sure I would call it a ‘bug’ if the program stops working correctly because you have deleted standard fields from the database.