Well, I have actually been waiting on a toolkit collaborator to pop up. It think I already guessed it would probably be you. Let me just say that we can do what you are asking pretty darn easily in practice…but that would be just practicing! What we want to do is write this to some sort of standard. That standard would come with the PDO connection functions that will soon be implemented. These, in of themselves, are also not a big deal, but the person(s) doing them will get to make those decisions, and we get to follow their queue. After that, we simply write a script to connect to the Toolkit database, run some queries, then display them on the screen (or any other similar dual-direction functions). I am not sure about displaying NPAPI applets within the iframes of the EHR these days, but anything that is done on any webpage anywhere can be done in the EHR…cause it’s just a web-page…nothing more really. You like a piece out of it? Grab it, or scrape its HTML output and use it somewhere else. There aren’t many restrictions there.
PDO is a PHP data Object. Basically it is a database driver. Currently, we have been using two others, mysql extension(deprecated), and mysqli (which is the preferred). PDO syntax is different than mySQLi, so we are not going to totally replace the use of mySQLi (re-write everything). Doing so would be a huge effort, and frankly mySQLi is faster and more feature-rich in many many ways than the PDO thingie.
To invite discussion on how this affects these future Post-June (June and Judy!) plans, I am going to kind of go over where I think we are based on getting data from one system to another. I will start this off by going on and on for a while about the PDO thingie, because those decisions affect us more immediately.
The PDO thingie
PDO can’t do everything, because it is sort of like a generic (or linux) video driver. It works for a lot of things and and all, but doesn’t give you any of the deep features like mySQLi. What we want is to start using BOTH simultaneously, but in a careful and well documented way. The Pros of PDO are the following:
-
Can connect to 12 different flavors of database. This is useful for possible database neutrality in the future…but that is a lofty goal due to SQL differences.
-
Can name and make multiple connections to multiple databases (even of different types) simultaneously.
-
Allows named data objects (named parameters specifically) in queries.
I think that all three of these will be useful in the future. The last one on the list would take care of a number of issues for integrating with other tools in an async sort of way. Look at the following:
public function test( PQRSPatient $patient, $beginDate, $endDate )
{
$query =
“SELECT COUNT(b1.code) as count “.
" FROM billing AS b1”.
" JOIN form_encounter AS fe ON (b1.encounter = fe.encounter)”.
" INNER JOIN billing AS b2 ON (b2.pid = b1.pid)“.
" INNER JOIN pqrs_efcc3 AS codelist_a ON (b2.code = codelist_a.code)”.
" WHERE b1.pid = ? “.
" AND fe.provider_id = '”.$this->_reportOptions[‘provider’].“'”.
" AND fe.date BETWEEN ‘“.$beginDate.”’ AND ‘“.$endDate.”’ ".
" AND (b2.code = codelist_a.code AND codelist_a.type = ‘pqrs_0249_a’) ".
" AND b1.code = ‘88305’; ";
$result = sqlFetchArray(sqlStatementNoLog($query, array($patient->id)));
if ($result[‘count’]> 0){ return true;} else {return false;}
}
The question mark in " WHERE b1.pid = ? ". is from the first parameter (argument) passed to this function, which is $patient.
" AND fe.date BETWEEN ‘“.$beginDate.”’ AND ‘“.$endDate.”’ ". could have been said like this:
" AND fe.date BETWEEN ? AND ? ". …because these are the second and third argument passed to it. The problem is, you have to make sure you have everything in order right, or things get really scary wonky, so sometimes we chicken out and just use the variable name with a whole mess of quotes and concatenations.
Another way we pass arguments to construct a query is like " AND fe.provider_id = ‘“.$this->_reportOptions[‘provider’].”’". where we have stored the values in an object’s instance state and made it accessible.
So, here in a single function we have three ways we have used to construct a string for a query in this test function. After writing a few thousand test queries, you stop worrying if it is pretty and just want it to work. With PDO, we can bind the parameters (arguments) by name instead of with question marks keyed to the order described in the function. This will both allow us to connect both systems together without FHIR, and help us keep the integration methods between the two standardized with strict parameter naming conventions.