         :not-found
         (str "Failed to retrieve concept " concept-id "/" revision-id " from metadata-db: " (:body response))))))
 
-(deftracefn get-latest-concept
+(defn get-latest-concept
   "Retrieve the latest version of the concept"
   [context concept-id]
   (let [conn (config/context->app-connection context :metadata-db)

                                    " "
                                    response))))))

(deftracefn get-collection-concept-id
  "Search metadata db and return the collection-concept-id that matches the search params"
  [context search-params]
  (let [conn (config/context->app-connection context :metadata-db)
        request-url (str (conn/root-url conn) "/concepts/search/collections")
        response (client/get request-url {:accept :json
                                          :query-params search-params
                                          :headers (ch/context->http-headers context)
                                          :throw-exceptions false
                                          :connection-manager (conn/conn-mgr conn)})
        status (:status response)
        body (cheshire/decode (:body response))]
    (case status
      404
      (let [err-msg (str "Unable to find collection-concept-id for search params: " search-params)]
        (errors/throw-service-error :not-found err-msg))

      200
      (get (first body) "concept-id")

      ;; default
      (let [errors-str (cheshire/generate-string (flatten (get body "errors")))
            err-msg (str "Collection concept id fetch failed. MetadataDb app response status code: "  status)]
        (errors/internal-error! (str err-msg  " " errors-str))))))


(deftracefn save-concept
  "Saves a concept in metadata db and index."
  [context concept]
  (let [conn (config/context->app-connection context :metadata-db)

            err-msg (str "Concept id fetch failed. MetadataDb app response status code: "  status)]
        (errors/internal-error! (str err-msg  " " errors-str))))))

(defn get-concept-revisions
  "Search metadata db and return the concepts given by the concept-id, revision-id tuples."
  ([context concept-tuples]
   (get-concept-revisions context concept-tuples false))
