Liking cljdoc? Tell your friends :D

Clojars Project Clojure Version Tests Status

ehr-adapter

A Clojure library for declarative, data-driven EHR integrations.

Installation

Add the following dependency to your deps.edn:

io.github.samuelcarriles/ehr-adapter {:mvn/version "1.0.0"}

Or to your project.clj:

[io.github.samuelcarriles/ehr-adapter "1.0.0"]

Core Concepts

  1. Data-Driven Architecture: Define your entire adapter using Clojure maps. No classes, no hidden state.
  2. Partial Resolution: Use :ref/ keywords to create reusable templates. Static values resolve at initialization; dynamic values resolve at runtime.
  3. Thread-Safe Auth: Built-in proactive token refresh with Leader/Follower concurrency pattern.
  4. Strict Validation: Runtime validation via Malli ensures your configuration is correct before execution.
  5. Extensible: Add custom authentication strategies or middlewares using Clojure's multimethods.

Quick Start

This is how explicit, robust, and readable an adapter configuration looks using Babashka's HTTP client as the core transportation layer:

(require '[ehr-adapter.core :as ehr]
         '[babashka.http-client :as http]
         '[ehr-adapter.middleware.bb-http-client :as bb-middleware])

(def eclinicalworks-adapter-config
  {:domain :eclinicalworks/tenant-beta

   :base-url "https://staging-fhir.ecw.com/fhir/r4"

   :middlewares [bb-middleware/wrap-request-handler]

   :network-config {:request-handler http/request}

   :auth {:initial [{:type :oauth2
                     :token-url "https://staging-fhir.ecw.com/fhir/oauth2/token"
                     :grant-type "client_credentials"
                     :client-id "prod-client-id-xyz"
                     :scopes ["patient/*.read"]
                     :client-secret "super-secure-secret"}]}

   :operations [{:name :get-patient-by-id
                 :method :get
                 :path ["Patient" :ref/patientId]
                 :description "Retrieve a patient by their unique identifier."}]})

;; Initialize the engine
(def adapter (ehr/initialize eclinicalworks-adapter-config))

;; Invoke the operation
(ehr/invoke adapter :get-patient-by-id {:patientId "12345"
                                        :request {:as :json}})
;; => {:status 200, :body {:resourceType "Patient", ...}}

Complete Configuration Guide

To understand the exact structure of the configuration map, the data types supported by the validator, the behavior of the network resiliency engine, and the exhaustive breakdown of each authentication strategy (including advanced usage of :bindings), please check the official technical reference guide at: Configuration Reference Guide

License

Copyright © 2024 Samuel Carriles

Distributed under the MIT License.

Can you improve this documentation?Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close