Data migration

gutiersa wrote on Monday, March 10, 2008:

I just started using OpenEmr in a window environment. It is finally working fine. I attempted to tansfer my patient pictures from my previous emr to OpenEmr by populating the tables, but was unsuccessful. Here is what I did:

- I created new folder in C:\Program Files\xampp\htdocs\openemr\documents for each patient chart
- I copied each patient picture to the corresponding folder using the same naming pattern i noted openemr uses ie: id#.jpg
- then I populated the documents table with the following command at the mysql promt (I used a LOAD INFILE command):

302    file_url    \N    2008-03-08 01:11:00    file://C:\\Program Files\\xampp\\htdocs\\openemr\\documents/19/19.jpg    image/jpeg    \N    \N    2008-03-08 01:11:00    19    2008-03-08 01:11:00    0

The table populated fine, except for the file size which I had to leave as null, because I don’t know how to automate that.
But when I went to the pt chart, the picture was not in demographics, and the picture file was not uploaded in the picture folder.

What am I missing?? Is it possible to migrate the scanned pt documents from my previous emr to openemr??

thanks for any help!!!

andres_paglayan wrote on Tuesday, March 11, 2008:

it’s 100% possible,

What I’d do is,
1./ start small, try the script for a single file, (meaning read it from one site, copy it to another) php can tell how big the file is as well,
2./ not sure about this as I am unfamiliar with oemr on win, but check the direction of all slashes, you might to replace / by ,

gutiersa wrote on Friday, March 14, 2008:

thanks for reply

actually I figured out what I was missing. I need to populate the categories_to_document table, to tell the program which document category the scanned document goes into.

here is where I am stuck:

I would like openemr to see if category autonumbering is used in the filename, and if so to strip out the autonumber part as it does for the patient_id autonumbering in C_Document.class.php line 331.

the format of my file names is:        xxx_x_restoffilename.pdf
where xxx is patient_id and x is category_id.

To that end I would like to add something like the following after line 335 of C_Document.class.php

              //see if category autonumbering is used in this filename, if so strip out the autonumber part
              preg_match("/^([0-9]+)_/",basename($fname),$category_match);
              if ($category_match[1] == $file[‘category_id’]) {
                  $fname = preg_replace("/^([0-9]+)_/","",$fname);
              }

but I don’t know how to figure out the $category_match part

Please help!