Demographics

drbowen wrote on Sunday, December 28, 2008:

I am trying to insert some data in the openemr patient_data file and when I view the demographics I get an error:

On clicking the "demographics back" button that executes the following query:

http://localhost/openemr/interface/patient_file/summary/demographics.php

I get the following error message:

*****

ERROR: query failed: select documents.url, documents.id from documents join categories_to_documents on documents.id = categories_to_documents.document_id join categories on categories.id = categories_to_documents.category_id where categories.name like ‘Patient Photograph’ and documents.foreign_id =

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 ‘’ at line 1

*****

I am running:

Gentoo (64 bit)
Apache: 2.2.9
PHP:  5.2.6_rc4
MySQL: 5.0
OpenEMR 2.9.1-dev

I am running a test version and there is nothing in the documents directory.

Anyone have this or a similar problem?

Sam Bowen, MD

gutiersa wrote on Monday, December 29, 2008:

If there is nothing in documents directory this makes sense. Openemr is looking for the pt picture and cannot find it so it generates an error message. Disable this feature in globals.php, or populate your documents folder.

drbowen wrote on Monday, December 29, 2008:

Thanks,

I don’t use the documents directory.

The problem went away after I uploaded some more demographics data in patient_data.

Sam Bowen, MD

drbowen wrote on Monday, December 29, 2008:

Thanks,

I don’t use the documents directory.

The problem went away after I uploaded some more demographics data in patient_data.

Sam Bowen, MD

markleeds wrote on Tuesday, December 30, 2008:

I am trying to reproduce this error and I can’t do it so far.  Based on the description, it is coming from the following file:

http://localhost/openemr/interface/patient_file/summary/patient_picture.php

For this error to occur, I think that $_SESSION[‘pid’] would have to be unset or equal to ‘’.  This would require getting to the demographics screen without having an Active Patient.  I can’t figure out how to do this with normal use.

The patient picture feature should do nothing and go unnoticed if it is not used, even if there is nothing in the documents directory.

drbowen wrote on Tuesday, December 30, 2008:

I didn’t say it was normal use. :wink:

I said I was "inserting some data".

I wrote a script that uploads CSV data from a foreign practice management system (Kareo) and inserts all of the patient demographics into openemr:patient_data at the same time.  (Saved a lot of man hours for the practice involved.)

I am trying to write a tool that will let us upload external CSV formatted data so that it is easier for new practices to convert over to openemr.

Sam Bowen, MD

thephil2005 wrote on Sunday, February 08, 2009:

I just now posed a question to Rod Roark about this very thing.

Can you shed some light on how to go about moving demographic information into OpenEMR?

Thanks.

I’ve ‘woodshedded’ a sample export file, based on basic components to the patient record in OEMR, and now I’d like to find a way to get the data across.

cfapress wrote on Monday, February 09, 2009:

Hi Phil,

I think that any mass import of demographic information would need to be handled on a case-by-case basis. Or, perhaps, another developer could write a script that clearly defines a file format and takes a CVS file of information and imports it. That way you’d need to match your exported patient data to the standard defined by the import script.

Jason

drbowen wrote on Monday, February 09, 2009:

I have a couple of scripts that I have been working on that import data from  CSV file.  The data was to exported from a Kareo system to OpenEMR.  This worked pretty well but still has a couple of small bugs.  For instance if the incoming sex is "M" that is what gets loaded.  Whereas I believe that OpenEMR really wants "male" for this drop down list to work correctly.

All scripts like this have to be customized to some extent (unless you happen to be running Kareo).  The variables like $data[1] refer to the field number in the CSV script.

I created a directory:

/openemr/interface/patient_file/history/kareo/

and placed the CSV file and the script in the same directory.

[Code starts here]
<?php
/*
   Copyright (C) 2008 Sam Bowen, MD <drbowen@charter.net>
  
   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License
   as published by the Free Software Foundation; either version 2
   of the License, or (at your option) any later version.

/*
/* UploadKareo.php takes the demographinc information from a CSV file exported from
   the Kareo office management Software and uploads it into the OpenEMR patient_data table.

   The arguments on the command line are the name of the script "Kareo_upload.php
   followed by the name of the file to upload such as KareoPatientDate.csv.
*/

include_once("…/…/…/globals.php");
include_once("…/…/…/…/library/adodb/adodb.inc.php");

$userauthorized =0;
$count=18;

$file=0;
$file="./KareoPtDataSample.csv";

//open the csv file from the command line with the file name as the second field
$handle = fopen($file, “r”) or die (“can’t open file”);

//call fgetcsv the first time to read the first line containing the field names.
//fgetcsv conveniently stores the column names with underscores inserted into the
//field names that contain spaces in the test CSV file.
//
//currently this just resets the pointer to the second line of the csv file.
$data = fgetcsv($handle, 100000);

//open the csv file again and loop through the contents
//$data is an array containing each field of the CSV which is read one line
//at a time.
while (($data = fgetcsv($handle, 100000)) !== FALSE) {

//Start the new ADODB connection to the database
$db = ADONewConnection(‘mysql’);
$db->debug = off;
$db->Connect($host,$login,$pass,$dbase);
//$db->Connect($host,$login,$dbase);
if (!$db) die(“Connection failed”);

   $sql = "INSERT INTO patient_data  (
           id,
          title,
           language,
           financial,
           fname,
           lname,
           mname,
           DOB,
           street,
           postal_code,
           city,
           state,
           country_code,
           drivers_license,
           ss,
           occupation,
           phone_home,
           phone_biz,
           phone_contact,
           phone_cell,
           pharmacy_id,
           status,
           contact_relationship,
           date,
           sex,
           referrer,
           referrerID,
           providerID,
           email,
           ethnoracial,
           interpretter,
           migrantseasonal,
           family_size,
           monthly_income,
           homeless,
           financial_review,
           pubpid,
           pid,
           genericname1,
           genericval1,
           genericname2,
           genericval2,
           hipaa_mail,
           hipaa_voice,
           hipaa_notice,
           hipaa_message,
           hipaa_allowsms,
           hipaa_allowemail,
           squad,
           fitness,
           referral_source,
           usertext1,
           usertext2,
           usertext3,
           usertext4,
           usertext5,
           usertext6,
           usertext7,
           usertext8,
           userlist1,
           userlist2,
           userlist3,
           userlist4,
           userlist5,
           userlist6,
           userlist7,
           pricelevel,
           regdate,
           contrastart)

            values (
       
         ‘".$count."’,
         ‘".$data[2]."’,
           ‘English’,
           ‘".$data[0]."’,
           ‘".$data[3]."’,
           ‘".$data[5]."’,
           ‘".$data[4]."’,
           ‘".$data[8]."’,
           ‘".$data[17]." “.$data[18].”’,
           ‘".$data[22]."’,
           ‘".$data[19]."’,
           ‘".$data[20]."’,
           ‘US’,
           ‘’,
           ‘".$data[7]."’,
           ‘".$data[13]."’,
           ‘".$data[23]."’,
           ‘".$data[25]."’,
           ‘’,
           ‘".$data[27]."’,
           ‘’,
           ‘".$data[12]."’,
           ‘’,
           ‘".$data[0]."’,
           ‘".$data[10]."’,
           ‘".$data[32]."’,
           0,
           1,
           ‘".$data[29]."’,
           ‘’,
           ‘’,
           ‘’,
           ‘’,
           ‘’,
           ‘’,
           ‘’,
           ‘".$data[1]."’,
           ‘".$data[1]."’,
           ‘’,
           ‘’,
           ‘’,
           ‘’,
           ‘YES’,
           ‘YES’,
           ‘YES’,
           ‘NO’,
           ‘NO’,
           ‘NO’,
           0,
           0,
           ‘".$data[32]."’,
           0,
           ‘".$data[11]."’,
           ‘".$data[33]."’,
           ‘".$data[31]."’,
           ‘’,
           ‘’,
           ‘’,
           ‘’,
           ‘’,
           ‘’,
           ‘’,
           ‘’,
           ‘’,
           ‘’,
           ‘’,
           ‘Standard’,
           ‘".$data[0]."’,
           ‘’)";
  
   $db->Execute($sql);

//change the pointer to the next row of the csv file.
$count++;
$row++;

}

//close the csv file
fclose($handle) or die (“can’t close file”);

exit;
?>
[/code stops here]

This script could be modified pretty easily to be run from the command line if desired.  There are some idiosyncrasies of the MySQL connection that vary from one operating system to another and would have to be adjusted for your system.

Sincerely,

Sam Bowen, MD

ideaman911 wrote on Tuesday, February 10, 2009:

Dr Bowen was good enough to create his loader for my needs, which helped a whole lot.  There turned out to be a few kinks all should be aware of, but the process is pretty simple if the data is mapped at all well.

I found that it was easiest to make the data into the format which was “desired” by OpenEMR, rather than taking a chance.  So I used an intermediary spreadsheet software (Excel in my case - don’t shoot me ;-), since that can “find and replace” pretty well.

But you will want to know that all the data which was put into fields for which there were "drop-down" lists defined caused them to display a "Fix This" error whenever the Demographics was put into Edit mode.  The autoloaded value had asterisks placed on either side of it in that data box, even though no such thing showed up when the MySQL data was looked at directly.

One other, and far more critical, problem occurred with the Insurance load attempt.  I wound up having to completely remove all that and re enter it manually.  The problem stems from the fact that Insurance_Companies database is used by two different areas, and they do not view the data similarly.  So, although I built a limiter to prevent duplications, NONE of the autoloaded showed up at the Admin - Practice - Insurance Companies listing, and further entries were prevented.

Best advice: test on a backup system thoroughly after any autoload.  The myriad programming approaches used in OpenEMR are not all tolerant of "outside the package" additions.

Joe Holzer  im@holzernt.com

I am trying to transition a practice from Kareo to Openemr as well. Is there any way to transfer all data including encounter/note data?