Column 'Date' specified twice

juggernautsei wrote on Wednesday, August 04, 2010:

I was working on customizing the > Patient/Client > Medical Record > History form when I ran into this error message when I try to save. The error says Column ‘Date’ specified twice. Below is the entire error message. I can not find where the second date is coming from.
Any help would be greatly appreciated.

ERROR: insert failed: insert into history_data set `id` = ‘’, `last_breast_exam` = ‘’, `last_gynocological_exam` = ‘’, `last_rectal_exam` = ‘’, `last_prostate_exam` = ‘’, `last_physical_exam` = ‘’, `last_sigmoidoscopy_colonoscopy` = ‘’, `last_ecg` = ‘’, `last_cardiac_echo` = ‘’, `last_retinal` = ‘’, `last_fluvax` = ‘’, `last_pneuvax` = ‘’, `last_ldl` = ‘’, `last_hemoglobin` = ‘’, `last_exam_results` = ‘’, `history_mother` = ‘’, `history_father` = ‘’, `history_siblings` = ‘’, `history_offspring` = ‘’, `history_spouse` = ‘’, `relatives_cancer` = ‘’, `relatives_tuberculosis` = ‘single’, `relatives_diabetes` = ‘’, `relatives_high_blood_pressure` = ‘’, `relatives_heart_problems` = ‘’, `relatives_stroke` = ‘’, `relatives_epilepsy` = ‘’, `relatives_mental_illness` = ‘’, `relatives_suicide` = ‘’, `cataract_surgery` = ‘’, `tonsillectomy` = ‘’, `cholecystestomy` = ‘’, `heart_surgery` = ‘’, `hysterectomy` = ‘’, `hernia_repair` = ‘’, `hip_replacement` = ‘’, `knee_replacement` = ‘’, `appendectomy` = ‘’, `pid` = ‘646’, `usertext12` = ‘’, `usertext13` = ‘’, `usertext14` = ‘’, `usertext15` = ‘’, `usertext16` = ‘’, `usertext17` = ‘’, `usertext18` = ‘’, `usertext19` = ‘’, `usertext20` = ‘’, `usertext21` = ‘’, `usertext22` = ‘’, `usertext23` = ‘’, `usertext24` = ‘’, `usertext25` = ‘’, `usertext26` = ‘’, `usertext27` = ‘’, `usertext28` = ‘’, `usertext29` = ‘’, `usertext30` = ‘’, `userdate11` = ‘’, `userdate12` = ‘’, `userdate13` = ‘’, `userdate14` = ‘’, `userdate15` = ‘’, `Past_Current` = ‘’, `Drug_Allergies` = ‘’, `eye_exam` = ‘’, `eye_results` = ‘’, `Last_Colonoscopy` = ‘’, `colon_result` = ‘’, `mammogram_results` = ‘’, `Last_PAP` = ‘’, `PAP_results` = ‘’, `medication_current` = ‘’, `history_problem` = ‘’, `hpi_history` = ‘’, `ros_history` = ‘’, `pfsh_history` = ‘’, `Constitutional` = ‘’, `Skin` = ‘’, `All_Imm` = ‘’, `ENT` = ‘’, `Resp` = ‘’, `CV` = ‘’, `GI` = ‘’, `GU` = ‘’, `Endo` = ‘’, `Musclosk` = ‘’, `Neuro` = ‘’, `Psych` = ‘’, `Hemo` = ‘’, `All_Other` = ‘’, `Name` = ‘’, `Reviewed` = ‘’, `Patient_Name` = ‘Harry Hippy’, `D_O_B` = ‘’, `Complaint` = ‘now’, `Ref_Doc` = ‘’, `OS_EVAL` = ‘’, `Temp` = ‘’, `P` = ‘’, `WT` = ‘’, `Height` = ‘’, `Blood_Pressure` = ‘’, `BP_Standing` = ‘’, `BP_Lying` = ‘’, `HPI` = ‘’, `Last_Foot` = ‘’, `Last_Eye` = ‘’, `Eye_Result` = ‘’, `Foot_Results` = ‘’, `Results_PSA` = ‘’, `ESS` = ‘’, `Berlin` = ‘’, `Date` = ‘’, `date` = ‘’+NOW()+’’

Error: Column ‘Date’ specified twice

bradymiller wrote on Thursday, August 05, 2010:

hey,

There is already a date column(`date` = ‘’+NOW()) that is bult in. It looks like you’ve tried to create another column in layouts with date (`Date` = ‘’). Mysql will trhough an error when you do this since it can not contain idential columns (note not case sensitive). So you’ll need to change your ‘Date’ ID entry to something else.

-brady

juggernautsei wrote on Thursday, August 05, 2010:

Thank you for your response.
That sounds reasonable but the form that I am referring to, I did not create from scratch. It is a built in form that was in the program before I got a hold of it. I have been going through the code in the …\interface\patient_file\history folder.  I have been trying to find what is making the  `date` = ‘’+NOW()+’’ insert. I cannot find it in any of  the files that are in that folder. Is there any documentation on how the …/interface/patient_file/history/history_full.php file works. Any hints would be greatly appreciated.

Regards,

visolveemr wrote on Thursday, August 05, 2010:

Hi,

The history data are inserted/updated using the function updateHistoryData and** newHistoryData** in openemr/library/patient.inc.
Code for insertion in history_data is present in the functions mentioned.

Thanks,
Vicareplus Team,
services@vicareplus.com

juggernautsei wrote on Friday, August 06, 2010:

Vicareplus Team,

Thanks! That got me to where I could put a temperary patch in place by commenting out the Date there but that does not fix the original issue. If you could help me once more by telling the location of the History Form. When I go to Administration > Layout and select History. Where is this form actually located is what I am after. I think that when I originally started to modify this layout. The “date” that I put in there has not been taken out even though I have removed it from the layout in the form editor. I don’t think that it is gone from the stored form so when the form is being saved, it throws an error because the “History Form” has a date and the Patient.inc is inserting a date also. So, if you can help me locate the History Form I may  be able to solve the problem the right way and then the patient.inc file can do its proper job. Question, is it the history_full.php file?

visolveemr wrote on Saturday, August 07, 2010:

Hi,

The fields specified in the layout->history are stored in the table layout_options and history_full.php displays it.Data entered in the history form are stored in history_data table.

Once you delete a field from layout->history, automatically the fields are removed from the above said tables. Am not sure, why you are getting error even after deleting the date field from layout ->history. Try deleting the field in the mentioned tables manually.

Thanks,
Vicareplus Team,
services@vicareplus.com

juggernautsei wrote on Saturday, August 07, 2010:

Thanks for the reply.

I tried to remove the “data” column from the history_data table. But when I try to access the history form I get this error message.
ERROR: query failed: select * from history_data where pid=‘646’ order by date DESC limit 0,1

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

I tried to delete the 646 row but it won’t let me. Thank you for your help in this matter.

Sherwin

visolveemr wrote on Monday, August 09, 2010:

Hi,

I suppose you have deleted both the “date” columns and hence query got failed while trying to fetch the default date column. Insert date column again and try.
Hope this will rectify the error.

Thanks,
Vicareplus Team,
services@vicareplus.com