From a6023b1b8c05ec570f40248687e8bcc3aee41f8d Mon Sep 17 00:00:00 2001
From: bradymiller
Date: Sat, 22 Dec 2012 13:57:32 -0800
Subject: [PATCH] MU2 certification support (smoking and clinical terms), final
revision.
-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.
---
custom/code_types.inc.php | 29 ++++++++--
interface/code_systems/list_installed.php | 23 ++++++--
interface/code_systems/list_staged.php | 49 +++++++++++++++--
interface/code_systems/snomed_howto.php | 1 +
interface/code_systems/standard_tables_manage.php | 17 ++++--
interface/patient_file/history/history_full.php | 2 +-
interface/super/edit_list.php | 65 +++++++++++++++++------
library/standard_tables_capture.inc | 11 ++--
sql/4_1_1-to-4_1_2_upgrade.sql | 38 +++++++++++++
sql/database.sql | 39 ++++++++------
version.php | 2 +-
11 files changed, 220 insertions(+), 56 deletions(-)
diff --git a/custom/code_types.inc.php b/custom/code_types.inc.php
index 17c98bccb..58744583b 100644
--- a/custom/code_types.inc.php
+++ b/custom/code_types.inc.php
@@ -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
*
*
* Copyright (C) 2006-2010 Rod Roark
@@ -68,6 +70,7 @@ while ($ctrow = sqlFetchArray($ctres)) {
'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'];
}
@@ -85,6 +88,7 @@ $cd_external_options = array(
'6' => xl('ICD10 Procedure/Service'),
'2' => xl('SNOMED (RF1) Diagnosis'),
'3' => xl('SNOMED (RF2) Diagnosis'),
+ '7' => xl('SNOMED Clinical Term')
);
/**
@@ -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
*/
@@ -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
}
@@ -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
@@ -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 " .
@@ -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)) ) {
diff --git a/interface/code_systems/list_installed.php b/interface/code_systems/list_installed.php
index 476a2f1bf..11540e0a2 100644
--- a/interface/code_systems/list_installed.php
+++ b/interface/code_systems/list_installed.php
@@ -45,17 +45,30 @@ if (!acl_check('admin', 'super')) {
$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)) {
?>
+
+
+
+
+
-
-
-
+
+
+
diff --git a/interface/code_systems/list_staged.php b/interface/code_systems/list_staged.php
index 3097eef4c..36ab2f0f3 100644
--- a/interface/code_systems/list_staged.php
+++ b/interface/code_systems/list_staged.php
@@ -148,6 +148,18 @@ if (is_dir($mainPATH)) {
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
}
@@ -206,6 +218,15 @@ if ($supported_file === 1) {
$success_flag=1;
+ // Only allow 1 staged revision for the SNOMED and RXNORM imports
+ if ( ($db=="SNOMED" || $db=="RXNORM") && (count($revisions) > 1) ) {
+ ?>
+
+
@@ -286,9 +319,19 @@ if ($supported_file === 1) {
$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)
+ ?>
+
+