From 93edbd8b386a766a884e64d86be794b40db0713d Mon Sep 17 00:00:00 2001 From: bradymiller Date: Tue, 29 Jan 2013 15:34:50 -0800 Subject: [PATCH] Snomed support improvements and bug fixes (take 3): -Supports import of snomed Spanish International code set -Searching function will support any snomed language international code set -Supports importing of snomed US extension set that procedes the main snomed English International set -Supports filename of the 03-01-2012 snomed US extension code set -Added a snomed procedure code type This has been fully tested, however am awaiting completion of project discussed in following thread before committing this into the official codebase (note there will need to be some integration work in custom/code_types.inc.php that is dependent on that project): http://sourceforge.net/projects/openemr/forums/forum/202506/topic/6686760 Merged into above forum code for testing 2-5-2013. --- interface/code_systems/list_installed.php | 4 +- interface/code_systems/list_staged.php | 73 ++++++++++++++++++++++++++----- interface/code_systems/snomed_howto.php | 4 +- sql/4_1_1-to-4_1_2_upgrade.sql | 11 +++++ sql/database.sql | 1 + version.php | 2 +- 6 files changed, 79 insertions(+), 16 deletions(-) diff --git a/interface/code_systems/list_installed.php b/interface/code_systems/list_installed.php index 11540e0a2..69d9d1c42 100644 --- a/interface/code_systems/list_installed.php +++ b/interface/code_systems/list_installed.php @@ -44,8 +44,8 @@ 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) -$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) ); +// Ordering by the imported_date with tiebreaker being the revision_date +$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 `imported_date` DESC, `revision_date` DESC", array($db) ); for($iter=0; $row=sqlFetchArray($rez); $iter++) { $sqlReturn[$iter]=$row; } diff --git a/interface/code_systems/list_staged.php b/interface/code_systems/list_staged.php index 952d1c87e..0255c2cc4 100644 --- a/interface/code_systems/list_staged.php +++ b/interface/code_systems/list_staged.php @@ -76,8 +76,9 @@ $current_revision = ''; $current_version = ''; $current_name = ''; $current_checksum = ''; -// 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`, `file_checksum` FROM `standardized_tables_track` WHERE upper(`name`) = ? ORDER BY `revision_date` DESC", array($db) ); + +// Ordering by the imported_date with tiebreaker being the revision_date +$sqlReturn = sqlQuery("SELECT DATE_FORMAT(`revision_date`,'%Y-%m-%d') as `revision_date`, `revision_version`, `name`, `file_checksum` FROM `standardized_tables_track` WHERE upper(`name`) = ? ORDER BY `imported_date` DESC, `revision_date` DESC", array($db) ); if (!empty($sqlReturn)) { $installed_flag = 1; $current_name = $sqlReturn['name']; @@ -160,6 +161,28 @@ if (is_dir($mainPATH)) { array_push($revisions,$temp_date); $supported_file = 1; } + else if (preg_match("/sct1_National_US_([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 if (preg_match("/SnomedCT_Release-es_INT_([0-9]{8}).zip/",$file,$matches)) { + + // Hard code this SNOMED version feed to be International:Spanish + // + $version = "International:Spanish"; + $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 } @@ -289,28 +312,54 @@ if ($supported_file === 1) { if ($success_flag === 1) { $action = ""; if ($installed_flag === 1) { - if (strtotime($current_revision) == strtotime($file_revision_date)) { - ?> -
-
?
- strtotime($file_revision_date)) { + if ($current_name=="SNOMED" && $current_version!=$file_revision && $file_revision!="US Extension" && $current_version=="US Extension") { + // The US extension for snomed has been previosly installed, so will allow to Replace with installation of any international set. ?> -
-
?
+
+
+
?
+
+
?
+ 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) ?>
?
+
+ +
+
?
+ strtotime($file_revision_date) ) { + // Note the exception here when installing US Extension + ?> +
+
?
+
diff --git a/interface/code_systems/snomed_howto.php b/interface/code_systems/snomed_howto.php index a633dee12..9e0e365e0 100644 --- a/interface/code_systems/snomed_howto.php +++ b/interface/code_systems/snomed_howto.php @@ -41,6 +41,8 @@ require_once("../../interface/globals.php");
-
+
: ,
+
+

diff --git a/sql/4_1_1-to-4_1_2_upgrade.sql b/sql/4_1_1-to-4_1_2_upgrade.sql index 3858cc38f..ac61248c6 100644 --- a/sql/4_1_1-to-4_1_2_upgrade.sql +++ b/sql/4_1_1-to-4_1_2_upgrade.sql @@ -270,3 +270,14 @@ ALTER TABLE procedure_report ADD COLUMN `report_notes` text NOT NULL DEFAULT '' COMMENT 'Notes from the lab'; #EndIf +#IfNotRow code_types ct_key SNOMED-PR +DROP TABLE IF EXISTS `temp_table_one`; +CREATE TABLE `temp_table_one` ( + `id` int(11) NOT NULL DEFAULT '0', + `seq` int(11) NOT NULL DEFAULT '0' +) ENGINE=MyISAM ; +INSERT INTO `temp_table_one` (`id`, `seq`) VALUES ( IF( ((SELECT MAX(`ct_id`) FROM `code_types`)>=100), ((SELECT MAX(`ct_id`) FROM `code_types`) + 1), 100 ) , IF( ((SELECT MAX(`ct_seq`) FROM `code_types`)>=100), ((SELECT MAX(`ct_seq`) FROM `code_types`) + 1), 100 ) ); +INSERT INTO code_types (ct_key, ct_id, ct_seq, ct_mod, ct_just, ct_fee, ct_rel, ct_nofs, ct_diag, ct_active, ct_label, ct_external, ct_claim, ct_proc, ct_term ) VALUES ('SNOMED-PR' , (SELECT MAX(`id`) FROM `temp_table_one`), (SELECT MAX(`seq`) FROM `temp_table_one`), 0, 'SNOMED', 1, 0, 0, 0, 0, 'SNOMED Procedure', 9, 1, 1, 0); +DROP TABLE `temp_table_one`; +#EndIf + diff --git a/sql/database.sql b/sql/database.sql index 52040490e..26d63c4ff 100644 --- a/sql/database.sql +++ b/sql/database.sql @@ -5501,6 +5501,7 @@ INSERT INTO code_types (ct_key, ct_id, ct_seq, ct_mod, ct_just, ct_fee, ct_rel, INSERT INTO code_types (ct_key, ct_id, ct_seq, ct_mod, ct_just, ct_fee, ct_rel, ct_nofs, ct_diag, ct_active, ct_label, ct_external, ct_claim, ct_proc, ct_term ) VALUES ('ICD9-SG' , 105, 105, 12, 'ICD9', 1, 0, 0, 0, 0, 'ICD9 Procedure/Service', 5, 1, 1, 0); INSERT INTO code_types (ct_key, ct_id, ct_seq, ct_mod, ct_just, ct_fee, ct_rel, ct_nofs, ct_diag, ct_active, ct_label, ct_external, ct_claim, ct_proc, ct_term ) VALUES ('ICD10-PCS' , 106, 106, 12, 'ICD10', 1, 0, 0, 0, 0, 'ICD10 Procedure/Service', 6, 1, 1, 0); INSERT INTO code_types (ct_key, ct_id, ct_seq, ct_mod, ct_just, ct_fee, ct_rel, ct_nofs, ct_diag, ct_active, ct_label, ct_external, ct_claim, ct_proc, ct_term ) VALUES ('SNOMED-CT' , 107, 107, 0, '', 0, 0, 1, 0, 0, 'SNOMED Clinical Term', 7, 0, 0, 1); +INSERT INTO code_types (ct_key, ct_id, ct_seq, ct_mod, ct_just, ct_fee, ct_rel, ct_nofs, ct_diag, ct_active, ct_label, ct_external, ct_claim, ct_proc, ct_term ) VALUES ('SNOMED-PR' , 108, 108, 0, 'SNOMED', 1, 0, 0, 0, 0, 'SNOMED Procedure', 9, 1, 1, 0); INSERT INTO list_options ( list_id, option_id, title, seq ) VALUES ('lists', 'code_types', 'Code Types', 1); diff --git a/version.php b/version.php index 88cdb1948..2bfc22715 100644 --- a/version.php +++ b/version.php @@ -17,7 +17,7 @@ $v_realpatch = '0'; // is a database change in the course of development. It is used // internally to determine when a database upgrade is needed. // -$v_database = 86; +$v_database = 87; // Access control version identifier, this is to be incremented whenever there // is a access control change in the course of development. It is used -- 2.11.4.GIT