Import Patient Data (CVS file)

blizki wrote on Tuesday, April 13, 2010:

Openerm version 3.2.0

I have a list of patient export from old database to excel then to CVS format.  Row 1 is the label which matched patient_data label:

id lname fname mname street city state postal_code phone_home phone_cell Phone_biz ss

when I try to import the cvs file, I get an error: “Invalid field count in CSV input on line 1.”

is there a format that I must set-up in the file before try to import?

Thanks!

tmccormi wrote on Tuesday, April 13, 2010:

It’s a bit more complicated than that, I’m afraid.  Unless you write a specific import program (see the custom/ import*) for some examples then you need to (at least) match the number of columns to the full patient_data table.  The field names don’t matter,  when doing an import for phpMyadmin or the MySQL command line, the incoming data has to be in same order as the table.

Also, don’t use the ID field, leave that blank so the system can auto assign an internal ID.  I would put your external ID in the pid and pubpid columns.

Other’s may have other opinions…
-Tony

blankev wrote on Tuesday, April 13, 2010:

If you have a clean OpenEMR installation do the following:

Make three clients with as much field-information included as possible in the new installed OpenEMR
New Patient => save …… New Patient Save …. etc.

Via Administration => Other =>   Database

Find  patient_data table

Click on patient_data table and export as CSV file (or if you are comfortable with SQL use this zipped,) to your local system.

Next Empty patient_data
(DO NOT USE DROP because than the whole table will be gone with all relevant information for functioning of OpenEMR)

Make you own Patient file compatible with the three rows of OpenEMR downloaded CSV file

Delete the first three rows of  your New Local File used for comparison Save as patient_data.CSV file

Import NEW patient_data.CSV into the Patient_data table (Don’t exceed the maximum of Mb to import of mentioned at the end of the import field your system)

If this doesn’t work please read the manuals en different topics of importing and exporting data for OpenEMR.

At least one column in the CSV spreadsheet is a key column and should be numbered in ascending order, With the tree rows of OpenEMR as example, this should be clear. You can skip numbers in the key column, but duplicates are a well known source of trouble.

Any patient related information like insurance and history are stored in a different tables and CAN BE imported on the same way, but only with very careful evaluation and comparison.

A little bit of luck and a lot of patience should give good results!

Remember you can Import and Export as many times as needed to learn this trick, but always remember to Empty the table before import or be sure to delete the duplicates.

You can do this for Users too. But be sure to KEEP the table of OpenEMR in place. If you delete the “Admin User” without a reasonable backup system, you CAN NOT enter OpenEMR! So I make three users with administration rights and I do not use the 1, 2, 3, unique-keys in my comparable CSV USER file. This did not give any problems while importing Table_data for Users.

All other tables can be imported, but keep a secure eye on the relation of the different tables, OpenEMR is definitely a relational database.

Pimm