;;;; Author: Kevin M. Rosenberg
;;;; Date Started: Apr 2000
;;;;
-;;;; $Id: sql-classes.lisp,v 1.71 2003/05/06 01:34:57 kevin Exp $
+;;;; $Id: sql-classes.lisp,v 1.75 2003/05/07 22:53:36 kevin Exp $
;;;;
;;;; This file, part of UMLisp, is
;;;; Copyright (c) 2000-2002 by Kevin M. Rosenberg, M.D.
'string
(format nil "select ~A~{~:@(~A~)~^,~} from ~:@(~A~)"
(if distinct "distinct " "") fields table)
+ (if where-name (format nil " where ~:@(~A~)" where-name) "")
(if where-name
(format nil
(typecase where-value
- (number " where ~A=~D")
- (null " where ~A is null")
+ (number "=~D")
+ (null " is null")
(t
- (if like
- " where ~A like '%~A%'"
- " where ~A='~A'")))
- where-name where-value)
+ (if like " like '%~A%""='~A'")))
+ where-value)
"")
(if srl (format nil " and ~:@(~A~)<=~D" lrl srl) "")
(if order (format nil " order by ~{~:@(~A~) ~(~A~)~^,~}" order) "")
:mg mg :pfstr2 kpfstr2)))
(defun find-ucon-rel-cui2 (cui2 &key (srl *current-srl*))
- (mapcar
- #'(lambda (cui) (find-ucon-cui cui :srl srl))
- (remove-duplicates (mapcar #'cui1 (find-urel-cui2 cui2 :srl srl)))))
+ (loop for cui in (remove-duplicates
+ (mapcar #'cui1 (find-urel-cui2 cui2 :srl srl)))
+ collect (find-ucon-cui cui :srl srl)))
(defun find-ucoc-cui (cui &key (srl *current-srl*))
"Return a list of ucoc for cui"
(with-umlisp-query (mrcoc (cui2 soc cot cof coa kpfstr2) srl cui1
- (parse-cui cui) :lrl "KSRL" :order (cof asc))
+ (parse-cui cui) :lrl klrl :order (cof asc))
(setq cui2 (ensure-integer cui2))
(when (zerop cui2) (setq cui2 nil))
(make-instance 'ucoc :cui1 (parse-cui cui) :cui2 (ensure-integer cui2)
(defun find-ucoc-cui2 (cui2 &key (srl *current-srl*))
"Return a list of ucoc for cui2"
(with-umlisp-query (mrcoc (cui1 soc cot cof coa kpfstr2) srl cui2
- (parse-cui cui2) :lrl "KSRL" :order (cof asc))
+ (parse-cui cui2) :lrl klrl :order (cof asc))
(setq cui2 (ensure-integer cui2))
(when (zerop cui2) (setq cui2 nil))
(make-instance 'ucoc :cui1 (ensure-integer cui1) :cui2 (parse-cui cui2)
(make-instance 'ulo :isn isn :fr (ensure-integer fr) :un un
:sui (ensure-integer sui) :sna sna :soui soui)))
-(defgeneric suistr (lo))
-(defmethod suistr ((lo ulo))
- "Return the string for a ulo object"
- (find-string-sui (sui lo)))
-
(defun find-uatx-cui (cui &key (srl *current-srl*))
"Return a list of uatx for cui"
(with-umlisp-query (mratx (sab rel atx) srl cui (parse-cui cui) :lrl ksrl)
:order (cui asc sui asc))
(find-ustr-cuisui (ensure-integer cui) (ensure-integer sui) :srl srl)))
+(defun find-ucon-noneng-word (word &key (srl *current-srl*) (like nil))
+ "Return list of ucons that match non-english word"
+ (with-umlisp-query-eval ('mrxw_noneng '(cui) srl 'wd word :like like
+ :distinct t :lrl 'klrl :order '(cui asc))
+ (find-ucon-cui cui :srl srl)))
+
+(defun find-ustr-noneng-word (word &key (srl *current-srl*))
+ "Return list of ustrs that match non-english word"
+ (with-umlisp-query (mrxw_noneng (cui sui) srl wd word :lrl klrl
+ :order (cui asc sui asc))
+ (find-ustr-cuisui (ensure-integer cui) (ensure-integer sui) :srl srl)))
+
;; Special tables
(defun find-usrl-all ()