Skip to content

Instantly share code, notes, and snippets.

@favila
Created April 16, 2014 00:05
Show Gist options
  • Save favila/10791297 to your computer and use it in GitHub Desktop.
Save favila/10791297 to your computer and use it in GitHub Desktop.
Create HumanName.text from a HumanName
(defn nametext [hn]
(->> [:fhir-attr/HumanName.prefix :fhir-attr/HumanName.given
:fhir-attr/HumanName.family :fhir-attr/HumanName.suffix]
(mapcat #(get hn %))
(filter not-empty)
(interpose \space)
(apply str)))
(defn humanname-text-tx [d]
(->> (d/datoms d :avet :phi.element/type "fhir-type/HumanName")
(map :e)
(map #(d/entity d %))
(map (juxt :db/id nametext))
(map (fn [[k v]] (do [:db/add k :fhir-attr/HumanName.text v])))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment