Smart Order REST API.
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.
- 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
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 databaserose_db_new_atc_only.db— ATC-indexed database, used to find alternativesrose_conditions_new.json— customers and their preferencesrose_ids.json(orrose_ids.ser.clear) — customer id ↔ GLN coderose_nota.json(orrose_nota.ser.clear) — open back-order (nota) positionsrose_auth_keys.txt— validauthkeyvaluesrose_stock.csv—pharmacode;rose_stock;voigt_stockrose_settings.json— zur Rose generic preferencesGrippeimpfstoff.json— pharma codes to be reported as not deliverablerose_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.
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
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.
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
GPLv3.0
- Zeno R.R. Davatz
- zdavatz at ywesee dot com