Skip to content

Repository files navigation

smart-order

Smart Order REST API.

Purpose

Given a shopping basket of article codes (GTIN/EAN or Pharmacode), the service returns each article enriched with pricing, stock and shipping status, plus a ranked list of therapeutic alternatives. Data is read from SQLite databases and CSV/JSON input files; output is JSON.

Requirements

  • Java 8 — the build uses Play 2.5.3 / sbt 0.13.17 / Scala 2.11.7 and does not run on newer JDKs.
  • sbt (or the bundled ./bin/activator)
  • Node.js — only needed to regenerate the swagger file

Input files

The application reads all its data from the rose/ directory at startup, and reloads individual files automatically when they change. Most of these are not part of this repository and have to be added:

  • rose_db_new_full.db — article database
  • rose_db_new_atc_only.db — ATC-indexed database, used to find alternatives
  • rose_conditions_new.json — customers and their preferences
  • rose_ids.json (or rose_ids.ser.clear) — customer id ↔ GLN code
  • rose_nota.json (or rose_nota.ser.clear) — open back-order (nota) positions
  • rose_auth_keys.txt — valid authkey values
  • rose_stock.csvpharmacode;rose_stock;voigt_stock
  • rose_settings.json — zur Rose generic preferences
  • Grippeimpfstoff.json — pharma codes to be reported as not deliverable
  • rose_direct_subst.json — pharma code → replacement pharma code

The cockpit/ directory holds the static JSON files served under /cockpit/, generated by ymeteor.

Orders are logged to orders/<glncode>/order_log_<glncode>.csv.

Build and run

export JAVA_HOME=/path/to/jdk8
sbt run          # development mode, listens on port 9001
sbt test

For a packaged build:

./smartorder.sh  # clean stage, copy rose/ into the staged directory and start the server

Endpoints

All endpoints require a valid authkey. The main entry point is:

GET /smart/full?pretty=on&authkey=KEY&glncode=GLN&basket=(7680623190048,10)
GET /smart/compact?...     # same, but at most 2 alternatives per article
POST /smart/full           # same parameters as form data

Optional parameters: nota=de|fr builds the basket from the customer's open back-order positions, override=dm returns all alternatives.

See swagger.yml for the full specification.

Generate swagger file

You should get the schema folder from ymeteor.

swagger.yml is generated — edit swagger.yml.template instead.

./bin/update-swagger [path to schema folder]
# E.g.
./bin/update-swagger ../ymeteor/public/schema

License

GPLv3.0

Contact

  • Zeno R.R. Davatz
  • zdavatz at ywesee dot com

About

Smart Order REST API

Topics

Resources

Stars

3 stars

Watchers

4 watching

Forks

Releases

Packages

Used by

Contributors

Languages