Code Monkey home page Code Monkey logo

pia-server's Introduction

pia-server

FIXME

Usage

Getting Started

  • install Clojure
brew install clojure/tools/clojure
git clone git+ssh://[email protected]/precisely/pia-server.git```
  • configure secrets:
    • copy .env.sample to .env, update any auth tokens & secrets
    • NOTE: the pia-developer user in our AWS dev-precisely account has minimal permissions for retrieving the longterm library from our S3 bucket
    • env.edn is in .gitignore

Database setup

Install Postgres

brew install postgresql

Create dbs

createdb pia_runstore
createdb test_pia_runstore
createdb hl7
createdb test_hl7

Migrations

Migrations should run automatically on PIA server startup, but can also manually run like this:

lein run -m scripts/create-db

IntelliJ tips:

  • Install Cursive
  • Create Configuration "Clojure REPL" (if it doesn't exist)
    • Type: nREPL, How to Run it: Run with Leiningen
  • Create a REPL command: Tools > REPL > Add New REPL Command
    • Name it "Run All Tests" and add the following code
(letfn [(list-sources [test-dir]
          (map #(clojure.string/replace (second (re-matches (re-pattern (str test-dir "/(.*)\\.clj?$")) (.getPath %))) "/" ".")
               (filter #(.isFile %) (file-seq (java.io.File. test-dir)))))]

  (run! #(require (symbol %))
        (list-sources "test"))
    (clojure.test/run-all-tests #"pia-server.*test.*"))

Run the application locally

Start the app

REPL mode

Recommended for development. Allows hot reloading code with your development environment.

(start)

Command line mode

With this approach, you will need to stop and restart the server if you change any files in pia-server, but you avoid having to start a REPL. This might be useful if you want to start pia-server from a script.

lein run

View the API

Point your browser at http://localhost:8080 for a peak at the Swagger interface.

Endpoints

The API is available at /api

Run endpoint

Start a flow (create a run)

POST /api/runs/start/{flow} Body is a JSON array of arguments Returns a run

Continue a run

POST /api/runs/continue/{uuid} Body is a JSON object with input and permit keys Returns a run

Get a run

GET /api/runs/{uuid} Returns a run

Find runs

GET /api/runs/find Returns an array of Runs * Query one or more keys /api/runs/find?state=running - active runs * Limit results /api/runs/find?state=running&limit=3 * Query nested keys using dot-separated keys. /api/runs/find?index.patient-id=123 - all runs involving patient 123 * Test for text in a JSON array by appending $ to the key name. /api/runs/find?index.roles$=doctor&index.patient-id=123&state=running - the current doctor activities for patient 123

Run the tests

lein test

Packaging and running as standalone jar

lein do clean, ring uberjar
java -jar target/server.jar

Packaging as war

lein ring uberwar

pia-server's People

Contributors

aneilbaboo avatar oiiio avatar axyyu avatar gcv avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.