;;;; *************************************************************************
;;;; FILE IDENTIFICATION
;;;;
-;;;; Name: sql-classes.lisp
-;;;; Purpose: Routines for reading UMLS objects from SQL database
-;;;; Author: Kevin M. Rosenberg
-;;;; Date Started: Apr 2000
+;;;; Name: sql-classes.lisp
+;;;; Purpose: Routines for reading UMLS objects from SQL database
+;;;; Author: Kevin M. Rosenberg
+;;;; Created: Apr 2000
;;;;
;;;; $Id$
;;;;
,@(when %%where
`((typecase ,where-value
(fixnum
- (prefixed-fixnum-string ,where-value #\= 10))
+ (concatenate 'string "='" (prefixed-fixnum-string ,where-value #\0 10) "'"))
(number
- (concatenate 'string "=" (write-to-string ,where-value)))
+ (concatenate 'string "='" (write-to-string ,where-value) "'"))
(null
" is null")
(t
(collect-umlisp-query (mrcoc (cui2 soc cot cof coa kpfstr2) srl cui1
cui :lrl klrl :order (cof asc))
(setq cui2 (ensure-integer cui2))
- (when (zerop cui2) (setq cui2 nil))
+ (when (eql 0 cui2) (setq cui2 nil))
(make-instance 'ucoc :cui1 cui :cui2 (ensure-integer cui2)
:soc soc :cot cot :cof (ensure-integer cof) :coa coa
:pfstr2 kpfstr2)))
(ensure-sui-integer sui)
(let ((ls "select CODE,ATN,SAB,ATV from MRSAT where "))
(cond
- (sui (string-append ls "KCUISUI="
- (integer-string (make-cuisui cui sui) 14)))
- (lui (string-append ls "KCUILUI="
+ (sui (string-append ls "KCUISUI='"
+ (integer-string (make-cuisui cui sui) 14)
+ "'"))
+ (lui (string-append ls "KCUILUI='"
(integer-string (make-cuilui cui lui) 14)
- " and sui=0"))
- (t (string-append ls "cui=" (prefixed-fixnum-string cui nil 7)
- " and lui=0 and sui=0")))
+ "' and sui='0'"))
+ (t (string-append ls "cui='" (prefixed-fixnum-string cui nil 7)
+ "' and lui='0' and sui='0'")))
(when srl
(string-append ls " and KSRL<=" (prefixed-fixnum-string srl nil 3)))
(loop for tuple in (mutex-sql-query ls) collect
(defun make-ustats ()
(with-sql-connection (conn)
- (sql-execute "drop table if exists USTATS" conn)
+ (ignore-errors (sql-execute "drop table USTATS" conn))
(sql-execute "create table USTATS (NAME varchar(160), COUNT bigint, SRL integer)" conn)
(dotimes (srl 4)
conn))
(defun find-ustats-all (&key (srl *current-srl*))
- (collect-umlisp-query (ustats (name count srl) nil srl srl
- :order (name asc))
- (make-instance 'ustats :name name :hits (ensure-integer count)
- :srl (ensure-integer srl))))
-
+ (if srl
+ (collect-umlisp-query (ustats (name count srl) nil srl srl
+ :order (name asc))
+ (make-instance 'ustats :name name
+ :hits (ensure-integer count)
+ :srl (ensure-integer srl)))
+ (collect-umlisp-query (ustats (name count srl) nil nil nil
+ :order (name asc))
+ (make-instance 'ustats :name name
+ :hits (ensure-integer count)
+ :srl (ensure-integer srl)))))
+
(defun find-ustats-srl (srl)
(collect-umlisp-query (ustats (name count) nil srl srl :order (name asc))
(make-instance 'ustats :name name :hits (ensure-integer count))))