Permalink
Browse files

Bug fix to show problems in the CCR/CCD reports

  • Loading branch information...
1 parent 880132c commit cc0113cc653fe314b6aef236d05dcccb85c20b90 @bradymiller bradymiller committed Sep 6, 2012
Showing with 16 additions and 9 deletions.
  1. +1 −0 ccr/createCCR.php
  2. +1 −1 ccr/createCCRProblem.php
  3. +14 −8 library/sql-ccr.inc
View
@@ -52,6 +52,7 @@
require_once(dirname(__FILE__) . "/../interface/globals.php");
require_once(dirname(__FILE__) . "/../library/sql-ccr.inc");
require_once(dirname(__FILE__) . "/uuid.php");
+require_once(dirname(__FILE__) . "/../custom/code_types.inc.php");
function createCCR($action,$raw="no"){
View
@@ -66,7 +66,7 @@
$e_Description = $ccr->createElement('Description' );
$e_Problem->appendChild($e_Description);
- $e_Text = $ccr->createElement('Text', $row['code_text']);
+ $e_Text = $ccr->createElement('Text', lookup_code_descriptions($row['diagnosis']));
$e_Description->appendChild($e_Text);
$e_Code = $ccr->createElement('Code');
View
@@ -292,35 +292,41 @@ function getProcedureData() {
function getProblemData() {
+ # Note we are hard-coding (only allowing) problems that have been coded to ICD9. Would
+ # be easy to upgrade this to other codesets in future (ICD10,SNOMED) by using already
+ # existant flags in the code_types table.
+ # Additionally, only using problems that have one diagnosis code set in diagnosis field.
+ # Note OpenEMR allows multiple codes set per problem, but will limit to showing only
+ # problems with one diagnostic code set in order to maintain previous behavior
+ # (this will likely need to be dealt with at some point; ie. support multiple dx codes per problem).
+
global $pid,$set,$start,$end;
if($set == "on"){
$sql = "
SELECT fe.encounter, fe.reason, fe.provider_id, u.title, u.fname, u.lname,
fe.facility_id, f.street, f.city, f.state, ie.list_id, l.pid, l.title AS prob_title, l.diagnosis,
- l.outcome, l.groupname, l.begdate, l.enddate, l.type, l.comments , l.date, cd.code_text
+ l.outcome, l.groupname, l.begdate, l.enddate, l.type, l.comments , l.date
FROM lists AS l
LEFT JOIN issue_encounter AS ie ON ie.list_id = l.id
LEFT JOIN form_encounter AS fe ON fe.encounter = ie.encounter
LEFT JOIN facility AS f ON fe.facility_id = f.id
LEFT JOIN users AS u ON fe.provider_id = u.id
- LEFT JOIN codes AS cd ON cd.code = SUBSTRING(l.diagnosis, LOCATE(':',l.diagnosis)+1)
- LEFT JOIN code_types AS ct ON ct.ct_id = cd.code_type
- WHERE l.type = 'medical_problem' AND l.pid=? AND ct.ct_key = SUBSTRING(l.diagnosis, 1, LOCATE(':',l.diagnosis)-1)
+ WHERE l.type = 'medical_problem' AND l.pid=? AND l.diagnosis LIKE 'ICD9:%'
+ AND l.diagnosis NOT LIKE '%;%'
AND l.date BETWEEN ? AND ?";
$result = sqlStatement($sql, array($pid,$start,$end) );
}else{
$sql = "
SELECT fe.encounter, fe.reason, fe.provider_id, u.title, u.fname, u.lname,
fe.facility_id, f.street, f.city, f.state, ie.list_id, l.pid, l.title AS prob_title, l.diagnosis,
- l.outcome, l.groupname, l.begdate, l.enddate, l.type, l.comments , l.date, cd.code_text
+ l.outcome, l.groupname, l.begdate, l.enddate, l.type, l.comments , l.date
FROM lists AS l
LEFT JOIN issue_encounter AS ie ON ie.list_id = l.id
LEFT JOIN form_encounter AS fe ON fe.encounter = ie.encounter
LEFT JOIN facility AS f ON fe.facility_id = f.id
LEFT JOIN users AS u ON fe.provider_id = u.id
- LEFT JOIN codes AS cd ON cd.code = SUBSTRING(l.diagnosis, LOCATE(':',l.diagnosis)+1)
- LEFT JOIN code_types AS ct ON ct.ct_id = cd.code_type
- WHERE l.type = 'medical_problem' AND l.pid=? AND ct.ct_key = SUBSTRING(l.diagnosis, 1, LOCATE(':',l.diagnosis)-1)";
+ WHERE l.type = 'medical_problem' AND l.pid=? AND l.diagnosis LIKE 'ICD9:%'
+ AND l.diagnosis NOT LIKE '%;%'";
$result = sqlStatement($sql, array($pid) );
}
return $result;

0 comments on commit cc0113c

Please sign in to comment.