     )
 )
 
+;; private functions
+(defn- to-sql-timestamp [date]
+  (if date
+    (java.sql.Date. (.getTime date))
+    nil))
+
+(defn- current-sql-timestamp []
+  (java.sql.Date. (java.util.Date.)))
+
+(defn- remove-nil-values [map-data]
+  (flatten (filter (fn [x] (nth x 1) ) map-data) ))
+
+;; public functions
 (defn get-event [event_id]
-  (first (select event (with tracker) (with event-location) (with event-extension-value) (where {:id event_id})))
+  (first (select event
+                 (with tracker)
+                 (with event-location)
+                 (with event-extension-value)
+                 (where {:id event_id})))
   )
 
-(defn get-tracker [tracker-identifier]
+(defn get-tracker [id]
+  (first (select tracker
+                 (where {:id id}))))
+
+(defn get-tracker-by-identifier [tracker-identifier]
   (first (select tracker
                  (where {:tracker_identifier tracker-identifier}))))
 
-(defn get-tracker! [tracker-identifier & tracker-name]
-  (let [existing-tracker (get-tracker tracker-identifier)]
+(defn get-tracker-by-identifier! [tracker-identifier & tracker-name]
+  (let [existing-tracker (get-tracker-by-identifier tracker-identifier)]
     (if existing-tracker
       existing-tracker
       (insert tracker (values {:tracker_identifier tracker-identifier
-                              :name tracker-name}))
+                              :name (or tracker-name tracker-identifier)}))
       )))
 
 (defn get-extension-type-by-name [type-name]

                               :satellite_count (:satellite_count data)
                               :altitude (:altitude data)}))
      )
    (doseq [key extension-keys]
      (insert event-extension-value
              (values

  (defentity event-extension-type
    (table :event_extension_types)
    (pk :id)
    (entity-fields :name :description)
    )

  (defentity event-extension-value
    (table :event_extension_values)
    (pk :id)
    (entity-fields :value)
    (belongs-to event-extension-type {:fk :event_extension_type_id})
    )

