Skip to content

Commit

Permalink
MU2 certification support (smoking and clinical terms), final revision.
Browse files Browse the repository at this point in the history
 -Support for MU2 requirements for smoking status
 -Support for broad SNOMED clinical terms
   -A new code type was added to support this
 -Support for Clinical Term Code(s) mapping in Administration->Lists
 -Added ability to import the SNOMED US extension pack
   -The size of the code columns in codes table was increased to
    support these longer SNOMED codes.
  • Loading branch information
bradymiller committed Dec 28, 2012
1 parent 94456a5 commit a6023b1
Show file tree
Hide file tree
Showing 11 changed files with 220 additions and 56 deletions.
29 changes: 24 additions & 5 deletions custom/code_types.inc.php
Expand Up @@ -27,6 +27,8 @@
* 4 for storing codes in external ICD9 Diagnosis tables
* 5 for storing codes in external ICD9 Procedure/Service tables
* 6 for storing codes in external ICD10 Procedure/Service tables
* 7 for storing codes in external SNOMED Clinical Term tables
* term - 1 if this code type is used as a clinical term
* </pre>
*
* Copyright (C) 2006-2010 Rod Roark <rod@sunsetsystems.com>
Expand Down Expand Up @@ -68,6 +70,7 @@
'external'=> $ctrow['ct_external'],
'claim' => $ctrow['ct_claim'],
'proc' => $ctrow['ct_proc'],
'term' => $ctrow['ct_term']
);
if ($default_search_type === '') $default_search_type = $ctrow['ct_key'];
}
Expand All @@ -85,6 +88,7 @@
'6' => xl('ICD10 Procedure/Service'),
'2' => xl('SNOMED (RF1) Diagnosis'),
'3' => xl('SNOMED (RF2) Diagnosis'),
'7' => xl('SNOMED Clinical Term')
);

/**
Expand Down Expand Up @@ -158,7 +162,7 @@ function convert_type_id_to_key($id) {
* as 1) an array and as 2) a comma-separated lists that has been
* process by urlencode() in order to place into URL address safely.
*
* @param string $category category of code types('diagnosis' or 'procedure')
* @param string $category category of code types('diagnosis', 'procedure' or 'clinical_term')
* @param string $return_format format or returned code types ('array' or 'csv')
* @return string/array
*/
Expand All @@ -180,6 +184,11 @@ function collect_codetypes($category,$return_format="array") {
array_push($return,$ct_key);
}
}
else if ($category == "clinical_term") {
if ($ct_arr['term']) {
array_push($return,$ct_key);
}
}
else {
//return nothing since no supported category was chosen
}
Expand Down Expand Up @@ -316,7 +325,16 @@ function code_set_search($form_code_type,$search_term="",$count=false,$active=tr
$res = sqlStatement($query,$sql_bind_array);
}
}
else if ($code_types[$form_code_type]['external'] == 2 ) { // Search from SNOMED (RF1) diagnosis codeset tables
else if ($code_types[$form_code_type]['external'] == 2 || $code_types[$form_code_type]['external'] == 7) {
// Search from SNOMED (RF1) diagnosis codeset tables OR Search from SNOMED (RF1) clinical terms codeset tables
if ($code_types[$form_code_type]['external'] == 2) {
// Search from SNOMED (RF1) diagnosis codeset tables
$diagnosis_sql_specific = " ref.FullySpecifiedName LIKE '%(disorder)' ";
}
else {
// Search from SNOMED (RF1) clinical terms codeset tables
$diagnosis_sql_specific = " 1=1 ";
}
if ($active) {
// Only filter for active codes
// If there is no entry in codes sql table, then default to active
Expand All @@ -336,11 +354,11 @@ function code_set_search($form_code_type,$search_term="",$count=false,$active=tr
"ON ref.ConceptId = c.code AND c.code_type = ? ";
array_push($sql_bind_array,$code_types[$form_code_type]['id']);
if ($return_only_one) {
$query .= "WHERE (ref.ConceptId = ? AND ref.FullySpecifiedName LIKE '%(disorder)') $active_query $query_filter_elements ";
$query .= "WHERE (ref.ConceptId = ? AND $diagnosis_sql_specific) $active_query $query_filter_elements ";
array_push($sql_bind_array,$search_term);
}
else {
$query .= "WHERE ((ref.FullySpecifiedName LIKE ? OR ref.ConceptId LIKE ?) AND ref.FullySpecifiedName LIKE '%(disorder)') $active_query $query_filter_elements ";
$query .= "WHERE ((ref.FullySpecifiedName LIKE ? OR ref.ConceptId LIKE ?) AND $diagnosis_sql_specific ) $active_query $query_filter_elements ";
array_push($sql_bind_array,"%".$search_term."%","%".$search_term."%");
}
$query .= "AND ref.ConceptStatus = 0 " .
Expand Down Expand Up @@ -511,7 +529,8 @@ function lookup_code_descriptions($codes) {
}
}
}
else if ($code_types[$codetype]['external'] == 2) { // Collect from SNOMED (RF1) Diagnosis codeset tables
else if ($code_types[$codetype]['external'] == 2 || $code_types[$codetype]['external'] == 7) {
// Collect from SNOMED (RF1) Diagnosis codeset tables OR Search from SNOMED (RF1) clinical terms codeset tables
// Ensure the sct_concepts sql table exists
$check_table = sqlQuery("SHOW TABLES LIKE 'sct_concepts'");
if ( !(empty($check_table)) ) {
Expand Down
23 changes: 18 additions & 5 deletions interface/code_systems/list_installed.php
Expand Up @@ -45,17 +45,30 @@
$db = isset($_GET['db']) ? $_GET['db'] : '0';

// For now, only order by the revision_date. When have different formats of a code type (such as WHO vs CMS for ICD10 or different languages for SNOMED, then will incorporate this field)
$sqlReturn = sqlQuery("SELECT DATE_FORMAT(`revision_date`,'%Y-%m-%d') as `revision_date`, `revision_version`, `name` FROM `standardized_tables_track` WHERE upper(`name`) = ? ORDER BY `revision_date` DESC", array($db) );
$rez = sqlStatement("SELECT DATE_FORMAT(`revision_date`,'%Y-%m-%d') as `revision_date`, `revision_version`, `name` FROM `standardized_tables_track` WHERE upper(`name`) = ? ORDER BY `revision_date` DESC", array($db) );
for($iter=0; $row=sqlFetchArray($rez); $iter++) {
$sqlReturn[$iter]=$row;
}

if (empty($sqlReturn)) {
?>
<div class="stg"><?php echo xlt("Not installed"); ?></div>
<?php
} else {
$notInstalled = 0;
if ($sqlReturn[0]['name'] == 'SNOMED' && $sqlReturn[0]['revision_version'] == 'US Extension') {
// If using the SNOMED US Extension package, then show the preceding SNOMED International Package information first
?>
<div class="atr"><?php echo xlt("Name") . ": " . text($sqlReturn[1]['name']); ?> </div>
<div class="atr"><?php echo xlt("Revision") . ": " . text($sqlReturn[1]['revision_version']); ?> </div>
<div class="atr"><?php echo xlt("Release Date") . ": " . text($sqlReturn[1]['revision_date']); ?> </div>
<br>
<?php
}
// Always show the first item of query results
?>
<div class="atr"><?php echo xlt("Name") . ": " . text($sqlReturn['name']); ?> </div>
<div class="atr"><?php echo xlt("Revision") . ": " . text($sqlReturn['revision_version']); ?> </div>
<div class="atr"><?php echo xlt("Release Date") . ": " . text($sqlReturn['revision_date']); ?> </div>
<div class="atr"><?php echo xlt("Name") . ": " . text($sqlReturn[0]['name']); ?> </div>
<div class="atr"><?php echo xlt("Revision") . ": " . text($sqlReturn[0]['revision_version']); ?> </div>
<div class="atr"><?php echo xlt("Release Date") . ": " . text($sqlReturn[0]['revision_date']); ?> </div>
<?php
}
?>
49 changes: 46 additions & 3 deletions interface/code_systems/list_staged.php
Expand Up @@ -148,6 +148,18 @@
array_push($revisions,$temp_date);
$supported_file = 1;
}
else if (preg_match("/SnomedCT_Release_US[0-9]*_([0-9]{8}).zip/",$file,$matches)) {

// This is the SNOMED US extension pack which can only be installed on top
// of a International SNOMED version.
// Hard code this version SNOMED feed to be US Extension
//
$version = "US Extension";
$date_release = substr($matches[1],0,4)."-".substr($matches[1],4,-2)."-".substr($matches[1],6);
$temp_date = array('date'=>$date_release, 'version'=>$version, 'path'=>$mainPATH."/".$matches[0]);
array_push($revisions,$temp_date);
$supported_file = 1;
}
else {
// nothing
}
Expand Down Expand Up @@ -206,6 +218,15 @@

$success_flag=1;

// Only allow 1 staged revision for the SNOMED and RXNORM imports
if ( ($db=="SNOMED" || $db=="RXNORM") && (count($revisions) > 1) ) {
?>
<div class="error_msg"><?php echo xlt("The number of staged files is incorrect. Only place the file that you wish to install/upgrade to."); ?></div>
<div class="stg msg"><?php echo xlt("Follow these instructions for installing or upgrading the following database") . ": " . text($db); ?><span class="msg" id="<?php echo attr($db); ?>_instrmsg">?</span></div>
<?php
$success_flag=0;
}

// Ensure all release dates and revisions are the same for multiple file imports
// and collect the date and revision. Also collect a checksum and path.
$file_revision_date = '';
Expand All @@ -219,7 +240,7 @@
$file_revision_date = $temp_file_revision_date;
}
else {
if ($file_revision_date != $temp_file_revision_date) {
if ( ($file_revision_date != $temp_file_revision_date) && ($success_flag === 1) ) {
?>
<div class="error_msg"><?php echo xlt("The staged files release dates are not all from the same release."); ?></div>
<div class="stg msg"><?php echo xlt("Follow these instructions for installing or upgrading the following database") . ": " . text($db); ?><span class="msg" id="<?php echo attr($db); ?>_instrmsg">?</span></div>
Expand All @@ -233,7 +254,7 @@
$file_revision = $temp_file_revision;
}
else {
if ($file_revision != $temp_file_revision) {
if ( ($file_revision != $temp_file_revision) && ($success_flag === 1) ) {
?>
<div class="error_msg"><?php echo xlt("The staged files revisions are not all from the same release."); ?></div>
<div class="stg msg"><?php echo xlt("Follow these instructions for installing or upgrading the following database") . ": " . text($db); ?><span class="msg" id="<?php echo attr($db); ?>_instrmsg">?</span></div>
Expand Down Expand Up @@ -279,16 +300,38 @@
<div class="error_msg"><?php echo xlt("The installed version is a more recent version than the staged files."); ?></div>
<div class="stg msg"><?php echo xlt("Follow these instructions for installing or upgrading the following database") . ": " . text($db); ?><span class="msg" id="<?php echo attr($db); ?>_instrmsg">?</span></div>
<?php
} else if ($current_name=="SNOMED" && $current_version=="US Extension" && $file_revision=="US Extension") {
// The Staged US Extension SNOMED package has already been installed
?>
<div class="error_msg"><?php echo xlt("The compatible staged US Extension SNOMED package has already been installed."); ?></div>
<div class="stg msg"><?php echo xlt("Follow these instructions for installing or upgrading the following database") . ": " . text($db); ?><span class="msg" id="<?php echo attr($db); ?>_instrmsg">?</span></div>
<?php
} else if ( ($current_name=="SNOMED" && $file_revision=="US Extension") && (strtotime($current_revision." +4 month") < strtotime($file_revision_date)) ) {
// The Staged US Extension SNOMED file is not compatible with the current SNOMED International Package (ie. the International package is outdated)
?>
<div class="error_msg"><?php echo xlt("The installed International SNOMED version is out of date and not compatible with the staged US Extension SNOMED file."); ?></div>
<div class="stg msg"><?php echo xlt("Follow these instructions for installing or upgrading the following database") . ": " . text($db); ?><span class="msg" id="<?php echo attr($db); ?>_instrmsg">?</span></div>
<?php
} else {
?>
<div class="stg"><?php echo text(basename($file_revision_path)); ?> <?php echo xlt("is a more recent version of the following database") . ": " . text($db); ?></div>
<?php
$action=xl("UPGRADE");
}
} else {
if (count($files_array) > 0) {
if ($db=="SNOMED" && $file_revision=="US Extension") {
// The Staged US Extension SNOMED package can not be installed by itself (it is done after the international package is installed)
?>
<div class="error_msg"><?php echo xlt("The staged US Extension SNOMED package can not be installed until after the International SNOMED package has been installed."); ?></div>
<div class="stg msg"><?php echo xlt("Follow these instructions for installing or upgrading the following database") . ": " . text($db); ?><span class="msg" id="<?php echo attr($db); ?>_instrmsg">?</span></div>
<?php
}
else if (count($files_array) > 0) {
$action=xl("INSTALL");
}
else {
//do nothing
}
}
if (strlen($action) > 0) {
?>
Expand Down
1 change: 1 addition & 0 deletions interface/code_systems/snomed_howto.php
Expand Up @@ -41,5 +41,6 @@
</li>
</ol>
<h5 class="error_msg"><?php echo xlt("NOTE: Only the Biannual International Snomed Release is currently supported"); ?></h5>
<h5 class="error_msg"><?php echo "(" . xlt("Additionally, the corresponding US Snomed Extension Package can be imported separately after installing the International Snomed Release") . ")"; ?></h5>
</p>
</div>
17 changes: 13 additions & 4 deletions interface/code_systems/standard_tables_manage.php
Expand Up @@ -76,10 +76,19 @@
exit;
}
} else if ( $db == 'SNOMED') {
if (!snomed_import()) {
echo htmlspecialchars( xl('ERROR: Unable to load the file into the database.'), ENT_NOQUOTES)."<br>";
temp_dir_cleanup($db);
exit;
if ($version == "US Extension") {
if (!snomed_import(TRUE)) {
echo htmlspecialchars( xl('ERROR: Unable to load the file into the database.'), ENT_NOQUOTES)."<br>";
temp_dir_cleanup($db);
exit;
}
}
else { //$version is not "US Extension"
if (!snomed_import(FALSE)) {
echo htmlspecialchars( xl('ERROR: Unable to load the file into the database.'), ENT_NOQUOTES)."<br>";
temp_dir_cleanup($db);
exit;
}
}
}
else { //$db == 'ICD'
Expand Down
2 changes: 1 addition & 1 deletion interface/patient_file/history/history_full.php
Expand Up @@ -92,7 +92,7 @@ function submit_history() {
//function for selecting the smoking status in radio button based on the selection of drop down list.
function radioChange(rbutton)
{
if (rbutton == 1 || rbutton == 2)
if (rbutton == 1 || rbutton == 2 || rbutton == 15 || rbutton == 16)
{
document.getElementById('radio_tobacco[current]').checked = true;
}
Expand Down

0 comments on commit a6023b1

Please sign in to comment.