From ae85b7b00d91bb9763fc5af9693572a3fe159e33 Mon Sep 17 00:00:00 2001 From: gered Date: Wed, 3 Sep 2014 09:17:09 -0400 Subject: [PATCH] add function for following contained resource references --- src/clj_hl7_fhir/core.clj | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/clj_hl7_fhir/core.clj b/src/clj_hl7_fhir/core.clj index c8d2de2..7b8214b 100644 --- a/src/clj_hl7_fhir/core.clj +++ b/src/clj_hl7_fhir/core.clj @@ -356,6 +356,19 @@ (filter #(= search-url (:id %))) (first))))) +(defn get-contained + "returns a resource contained in a parent resource, where the contained resource + is identified by an internal reference id. + + reference: + contained resources: http://www.hl7.org/implement/standards/fhir/references.html#contained" + [containing-resource ref-id] + (if-not (str/blank? ref-id) + (if-let [parsed-id (if (.startsWith ref-id "#") (subs ref-id 1))] + (->> (:contained containing-resource) + (filter #(= parsed-id (:id %))) + (first))))) + (defn fetch-all "for resources that are returned over more then one page, this will automatically fetch all pages of resources and them into a single bundle that contains all of