Pg_pconnect error with OpenEMR & sql-ledger

rpl122 wrote on Monday, August 13, 2007:

After several hours of playing around, I got the current (08/12/2007) cvs download of OpenEMR working on a brand new intallation of Ubuntu (feisty).  All the packages except for OpenEMR files came from Ubuntu packages.  Trouble is this:

When I go to the "billing" screen and click either [Reports] or [EOBs] I get this response:

Fatal error:  Call to undefined function pg_pconnect() in /var/www/openemr/library/sql-ledger.inc on line 34

These things work OK:

OpenEMR itself seems to work OK.

I can log into SQL-Ledger directly and through the [SQL-Ledger] button on the OpenEMR billing menu.

I can connect properly to the databases with mysql and psql from the command line.

I suppose the possibilities are that I left out some package that has the pg_pconnect functionality, but what that could be I have no clue.  Or maybe it’s there but has permissions that make it invisible in this context.  At this point, I’ve run out of steam.  Any ideas?

I’m running:
     SQL Ledger 2.6.22 (Ubuntu package)
     postgresql-8.2
     MySQL 5.0.38

rpl122 wrote on Monday, August 13, 2007:

Just an update –

I restarted apache2 web server and now I’m getting a less ominous, but still puzzling, error message cut and pasted below:

Warning: pg_pconnect() [function.pg-pconnect]: Unable to connect to PostgreSQL server: FATAL: password authentication failed for user "sql-ledger" in /var/www/openemr/library/sql-ledger.inc on line 34
Failed to connect to SQL-Ledger database.

I think I have the usernames and passwords specified correctly in the configuration file for OpenEMR and have even tried different combinations without success. 

BTW the user specified in my OpenEMR configuration file is “openemr.”  Apparently the setup with ./sql-ledger/admin.pl passwords and users aliased openemr to sql-ledger.  Just so I wouldn’t make mistakes, I made all the passwords the same.  (I know that’s bad for security, but maybe good for avoiding confusion and getting things working.)

bklambdin wrote on Monday, August 13, 2007:

Look at openemr\includes\config.php

Brian

sunsetsystems wrote on Monday, August 13, 2007:

make sure you have PostgreSQL configured for password (MD5) authentication in pg_hba.conf.  Then you might try using psql from the command line to see if you can connect to the database.

Rod
www.sunsetsystems.com

rpl122 wrote on Monday, August 13, 2007:

I can log into the postgresql server from the postgres user prompt using psql openemr or psql sql-ledger.  Either way it asks for password and lets me see databases and tables etc.

I can also see sql-ledger login screen by using browser at http://localhost/sql-ledger/login.pl.  Again, I can log into the sql-ledger program as either of these users.

I have set up http://localhost/sql-ledger/admin.pl administrative password and have created database openemr and users etc.

The problem seems to arise when openemr is passing information through sql-ledger to postgresql.

Here is my /etc/postgresql/8.2/main/pg_hba.conf file:

=====================================================================

# PostgreSQL Client Authentication Configuration File
# ===================================================
#
# Refer to the "Client Authentication" section in the
# PostgreSQL documentation for a complete description
# of this file.  A short synopsis follows.
#
# This file controls: which hosts are allowed to connect, how clients
# are authenticated, which PostgreSQL user names they can use, which
# databases they can access.  Records take one of these forms:
#
# local      DATABASE  USER  METHOD  [OPTION]
# host       DATABASE  USER  CIDR-ADDRESS  METHOD  [OPTION]
# hostssl    DATABASE  USER  CIDR-ADDRESS  METHOD  [OPTION]
# hostnossl  DATABASE  USER  CIDR-ADDRESS  METHOD  [OPTION]
#
# (The uppercase items must be replaced by actual values.)
#
# The first field is the connection type: "local" is a Unix-domain socket,
# "host" is either a plain or SSL-encrypted TCP/IP socket, "hostssl" is an
# SSL-encrypted TCP/IP socket, and "hostnossl" is a plain TCP/IP socket.
#
# DATABASE can be "all", "sameuser", "samerole", a database name, or
# a comma-separated list thereof.
#
# USER can be "all", a user name, a group name prefixed with "+", or
# a comma-separated list thereof.  In both the DATABASE and USER fields
# you can also write a file name prefixed with "@" to include names from
# a separate file.
#
# CIDR-ADDRESS specifies the set of hosts the record matches.
# It is made up of an IP address and a CIDR mask that is an integer
# (between 0 and 32 (IPv4) or 128 (IPv6) inclusive) that specifies
# the number of significant bits in the mask.  Alternatively, you can write
# an IP address and netmask in separate columns to specify the set of hosts.
#
# METHOD can be "trust", "reject", "md5", "crypt", "password",
# "krb5", "ident", "pam" or "ldap".  Note that "password" sends passwords
# in clear text; "md5" is preferred since it sends encrypted passwords.
#
# OPTION is the ident map or the name of the PAM service, depending on METHOD.
#
# Database and user names containing spaces, commas, quotes and other special
# characters must be quoted. Quoting one of the keywords "all", "sameuser" or
# "samerole" makes the name lose its special character, and just match a
# database or username with that name.
#
# This file is read on server startup and when the postmaster receives
# a SIGHUP signal.  If you edit the file on a running system, you have
# to SIGHUP the postmaster for the changes to take effect.  You can use
# "pg_ctl reload" to do that.

# Put your actual configuration here
# ----------------------------------
#
# If you want to allow non-local connections, you need to add more
# "host" records. In that case you will also need to make PostgreSQL listen
# on a non-local interface via the listen_addresses configuration parameter,
# or via the -i or -h command line switches.
#

# DO NOT DISABLE!
# If you change this first entry you will need to make sure that the
# database
# super user can access the database using some other method.
# Noninteractive
# access to all databases is required during automatic maintenance
# (autovacuum, daily cronjob, replication, and similar tasks).
#
# Database administrative login by UNIX sockets
local   all         postgres                          ident sameuser

# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD

# "local" is for Unix domain socket connections only
local   all         all                               ident sameuser
# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
# IPv6 local connections:
host    all         all         ::1/128               md5

===========================================================================

rpl122 wrote on Monday, August 13, 2007:

Here is the /openemr/includes/config.php file.  The only changes I made were in the ws_accounting section.

=============================================================================

<?php
/* $Id: config.php,v 1.15 2007/08/03 01:52:37 sunsetsystems Exp $ */
//  ------------------------------------------------------------------------ //
//                OpenEMR Electronic Medical Records System                  //
//                    Copyright (c) 2005 oemr.org                            //
//                       <http://www.oemr.org/>                              //
//  ------------------------------------------------------------------------ //
//  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.                                      //
//                                                                           //
//  You may not change or alter any portion of this comment or credits       //
//  of supporting developers from this source code or any supporting         //
//  source code which is considered copyrighted (c) material of the          //
//  original comment or credit authors.                                      //
//                                                                           //
//  This program is distributed in the hope that it will be useful,          //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
//  GNU General Public License for more details.                             //
//                                                                           //
//  You should have received a copy of the GNU General Public License        //
//  along with this program; if not, write to the Free Software              //
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
//  ------------------------------------------------------------------------ //

$GLOBALS[‘oer_config’][‘freeb’][‘claim_file_dir’]     = “/usr/share/freeb/public/”;
//currently can be pdf or txt
$GLOBALS[‘oer_config’][‘freeb’][‘default_format’]     = “pdf”;
$GLOBALS[‘oer_config’][‘freeb’][‘username’]         = “freeb”;
$GLOBALS[‘oer_config’][‘freeb’][‘password’]         = “12345”;
$GLOBALS[‘oer_config’][‘freeb’][‘print_command’]     = “/usr/bin/lpr”;
$GLOBALS[‘oer_config’][‘freeb’][‘printer_name’]     = “HP_LaserJet4L”;
// This does not seem useful for PDF HCFAs, see freeb/targetbin/ascii2pdf instead:
$GLOBALS[‘oer_config’][‘freeb’][‘printer_extras’]     = “-o PageSize=Letter -o portrait”;
// Set this to make an additional copy of HCFA PDFs in the specified directory,
// e.g. for an external billing service. You must end this path with a slash:
$GLOBALS[‘oer_config’][‘freeb’][‘copy_pdfs_to’] = ‘’;

//used differently by different applications, intuit programs only like numbers
$GLOBALS[‘oer_config’][‘ofx’][‘bankid’]     = “123456789”;

//you can use this to match to an existing account in you accounting application
$GLOBALS[‘oer_config’][‘ofx’][‘acctid’]     = “123456789”;

//use FL for FLORIDA compatible format, leave blank for default
$GLOBALS[‘oer_config’][‘prescriptions’][‘format’] = “”;

//Document storage repository document root, if it does not begin with a slash it is set relative to the file root
//you must include a trailing slash in either case
$GLOBALS[‘oer_config’][‘documents’][‘repopath’] = “documents/”;
$GLOBALS[‘oer_config’][‘documents’][‘file_command_path’] = “/usr/bin/file”;

//Name of prescription graphic in interface/pic/ directory without preceding slash. Can be JPEG or PNG, normally 3 inches wide.
$GLOBALS[‘oer_config’][‘prescriptions’][‘logo_pic’] = “prescription_logo.png”;

// Name of signature graphic in interface/pic/ directory without preceding
// slash. Normally 3 inches wide.  This filename may include the string
// “{userid}” to indicate the numeric ID of the user, so that prescriptions
// can print with the correct provider’s signature if you have multiple
// providers.  Also signature images are used only for faxed prescriptions,
// not printed prescriptions.

$GLOBALS[‘oer_config’][‘prescriptions’][‘sig_pic’] = “sig.png”;
//Option to used signature graphic or not
$GLOBALS[‘oer_config’][‘prescriptions’][‘use_signature’] = false;

// To print the prescription medication area on a grey background:
$GLOBALS[‘oer_config’][‘prescriptions’][‘shading’] = false;

// only works with hylafax sendfax client, and sendfax must be in PATH
// assign ‘sendfax’ to turn fax sending on
$GLOBALS[‘oer_config’][‘prescriptions’][‘sendfax’] = ‘’;

// asign a value here if there is any prefix needed to get dialing tone
// you can also append a comma to add a one second delay
// i.e. 9, will dial 9 for external tone, and wait a second.
$GLOBALS[‘oer_config’][‘prescriptions’][‘prefix’] = ‘’;

// select paper size for prescription printing
// see library/classes/class.ezpdf.php for complete list of paper sizes
// ex. “LETTER”, “A4”, “LEGAL” …
$GLOBALS[‘oer_config’][‘prescriptions’][‘paper_size’] = “LETTER”;

// change page margins for prescription printing
// note, values are in pixels (72 dots per inch)
// to convert from centimeters use the following: (centimeters / 2.54 ) * 72;
$GLOBALS[‘oer_config’][‘prescriptions’][‘left’]   = 30;
$GLOBALS[‘oer_config’][‘prescriptions’][‘right’]  = 30;
$GLOBALS[‘oer_config’][‘prescriptions’][‘top’]    = 72;
$GLOBALS[‘oer_config’][‘prescriptions’][‘bottom’] = 30;

// Similarly for bottle labels if you are dispensing drugs.  Note that paper
// size here or for prescriptions may be an array (0, 0, width, height).
// As above, these measurements are in points.
$GLOBALS[‘oer_config’][‘druglabels’][‘paper_size’] = array(0, 0, 216, 216);
$GLOBALS[‘oer_config’][‘druglabels’][‘left’]   = 18;
$GLOBALS[‘oer_config’][‘druglabels’][‘right’]  = 18;
$GLOBALS[‘oer_config’][‘druglabels’][‘top’]    = 18;
$GLOBALS[‘oer_config’][‘druglabels’][‘bottom’] = 18;
$GLOBALS[‘oer_config’][‘druglabels’][‘logo_pic’] = ‘druglogo.png’;
$GLOBALS[‘oer_config’][‘druglabels’][‘disclaimer’] =
  'Caution: Federal law prohibits dispensing without a prescription. ’ .
  ‘Use only as directed.’;

//accounting system web services integration
//whether to use the system
$GLOBALS[‘oer_config’][‘ws_accounting’][‘enabled’] = true;
$GLOBALS[‘oer_config’][‘ws_accounting’][‘server’] = “localhost”;
$GLOBALS[‘oer_config’][‘ws_accounting’][‘port’] = “80”;
$GLOBALS[‘oer_config’][‘ws_accounting’][‘url’] = “/sql-ledger/ws_server.pl”;
$GLOBALS[‘oer_config’][‘ws_accounting’][‘username’] = “openemr”;
$GLOBALS[‘oer_config’][‘ws_accounting’][‘password’] = “23xxxxxx”;
$GLOBALS[‘oer_config’][‘ws_accounting’][‘url_path’] = “http://” .
  $_SERVER[“SERVER_NAME”] . “/sql-ledger/login.pl”;
$GLOBALS[‘oer_config’][‘ws_accounting’][‘income_acct’] = “4320”;

//don’t alter below this line unless you are an advanced user and know what you are doing

$GLOBALS[‘oer_config’][‘prescriptions’][‘logo’] = dirname(__FILE__) .
  “/…/interface/pic/” . $GLOBALS[‘oer_config’][‘prescriptions’][‘logo_pic’];
$GLOBALS[‘oer_config’][‘prescriptions’][‘signature’] = dirname(__FILE__) .
  “/…/interface/pic/” . $GLOBALS[‘oer_config’][‘prescriptions’][‘sig_pic’];
// $GLOBALS[‘oer_config’][‘prescriptions’][‘signature’] = ‘’; // What was this for???

$GLOBALS[‘oer_config’][‘druglabels’][‘logo’] = dirname(__FILE__) .
  “/…/interface/pic/” . $GLOBALS[‘oer_config’][‘druglabels’][‘logo_pic’];

$GLOBALS[‘oer_config’][‘documents’][‘repository’] = $GLOBALS[‘oer_config’][‘documents’][‘repopath’];
if (strpos($GLOBALS[‘oer_config’][‘documents’][‘repository’],"/") !== 0) {
    $GLOBALS[‘oer_config’][‘documents’][‘repository’] = realpath(dirname(__FILE__) . “/…/” . $GLOBALS[‘oer_config’][‘documents’][‘repository’]) . “/”;
}
?>

sunsetsystems wrote on Monday, August 13, 2007:

Be aware that $sl_dbuser and $sl_dbpass in globals.php refer to the database login, not a SQL-Ledger user login.

Also note that there are two different ways to connect to a PostgreSQL database: Unix domain sockets, and TCP/IP.  OpenEMR uses TCP/IP, in which case MD5 authentication is used and your database users must have suitable passwords for that.  It’s all a bit complicated, but there’s good documentation at www.postgresql.org.

Rod
www.sunsetsystems.com

rpl122 wrote on Monday, August 13, 2007:

Thank you, Rod.  I changed the “md5” to “trust” on the IPv4 line for 127.0.0.1 connections and it works properly.  Trouble is that I was trying to install the new cvs software by following instructions for the 2.8.2 Mandrake virtual machine.  And it didn’t help that I had no idea what I was doing!

But it seems OK now.