r11099: add error checking
[umlisp.git] / parse-rrf.lisp
index 0f89b148b4e3b3b5476dce43714f1d7aea515ad7..0842d97135ebc174d7bf9b67be8a384a26816745 100644 (file)
@@ -11,7 +11,7 @@
 ;;;; $Id$
 ;;;;
 ;;;; This file, part of UMLisp, is
-;;;;    Copyright (c) 2000-2004 by Kevin M. Rosenberg, M.D.
+;;;;    Copyright (c) 2000-2006 by Kevin M. Rosenberg, M.D.
 ;;;;
 ;;;; UMLisp users are granted the rights to distribute and use this software
 ;;;; as governed by the terms of the GNU General Public License.
   (defun make-preparse-hash-table ()
     (if sui-lrl-hash
        (progn
-         (clrhash pfstr-hash)
-         (clrhash cui-lrl-hash)
-         (clrhash lui-lrl-hash)
-         (clrhash sui-lrl-hash)
-         (clrhash cuisui-lrl-hash)
-         (clrhash sab-srl-hash))
+          (clrhash pfstr-hash)
+          (clrhash cui-lrl-hash)
+          (clrhash lui-lrl-hash)
+          (clrhash sui-lrl-hash)
+          (clrhash cuisui-lrl-hash)
+          (clrhash sab-srl-hash))
       (setf
          pfstr-hash (make-hash-table :size 800000)
          cui-lrl-hash (make-hash-table :size 800000)
@@ -49,8 +49,7 @@
     
   (defun ensure-preparse (&optional (force-read nil))
     (when (or force-read (not *preparse-hash-init?*))
-      (make-preparse-hash-table)
-      (setq *preparse-hash-init?* t))
+      (make-preparse-hash-table))
     (with-umls-file (line "MRCONSO.RRF")
       (let ((cui (parse-ui (nth 0 line)))
            (lui (parse-ui (nth 3 line)))
@@ -69,7 +68,8 @@
         (multiple-value-bind (val found) (gethash sab sab-srl-hash)
           (declare (ignore val))
           (unless found
-            (setf (gethash sab sab-srl-hash) srl))))))
+            (setf (gethash sab sab-srl-hash) srl)))))
+    (setq *preparse-hash-init?* t))
   
   (defun pfstr-hash (cui) (gethash cui pfstr-hash))
   (defun cui-lrl (cui)    (gethash cui cui-lrl-hash))
 (defparameter +col-datatypes+
     '(("AV" sql-f) ("BTS" sql-i) ("CLS" sql-i) ("COF" sql-i) ("CUI1" sql-u)
       ("AUI" sql-u) ("AUI1" sql-u) ("AUI2" sql-u) ("PCUI" sql-u)
-      ("PLUI" sql-u)
+      ("PLUI" sql-u) ("PAUI" sql-u)
       ("CUI2" sql-u) ("CUI" sql-u) ("CXN" sql-s) ("FR" sql-i) ("LRL" sql-s)
       ("LUI" sql-u) ("MAX" sql-s) ("MIN" sql-s) ("RANK" sql-s) ("REF" sql-c)
       ("RNK" sql-s) ("RWS" sql-i) ("SRL" sql-s) ("SUI" sql-u) ("TUI" sql-u)
+      ("MAPRANK" sql-s)
       ;;; Custom columns
       ("KCUISUI" sql-l) ("KCUILUI" sql-l) ("KCUILRL" sql-i) ("KLUILRL" sql-i)
       ("KSUILRL" sql-i)
       ("UI" sql-u) ("UI2" sql-u) ("UI3" sql-u)
       ;; New fields for 2002AD
       ("RCUI" sql-u) ("VCUI" sql-u) ("CFR" sql-i) ("TFR" sql-i)
+      ;; New fields for 2004AA
       ("MAPSETCUI" sql-u)
       ) 
     "SQL data types for each non-string column")
       ("UI" "SRSTRE1") ("UI2" "SRSTRE1") ("UI3" "SRSTRE1") 
       ("STY_RL" "SRDEF") ("RT" "SRDEF") ("STY_RL" "SRSTR") ("STY_RL2" "SRSTR")
       ("RL" "SRSTR")
+      
       ("SRL" "MRSAB") ("RSAB" "MRSAB") ("VSAB" "MRSAB") ("RCUI" "MRSAB")
-      ("VCUI" "MRSAB") ("LAT" "MRSAB"))
+      ("VCUI" "MRSAB") ("LAT" "MRSAB") ("MAPSETCUI" "MRMAP")  ("MAPSETCUI" "MRSMAP")
+      ("CUI" "MRHIER") ("AUI" "MRHIER") ("PAUI" "MRHIER"))
   "Columns in files to index")