Giter Club home page Giter Club logo

ministryofjustice.prison-estate's Introduction

prison-estate

CircleCI API docs

Self-contained fat-jar micro-service to publish mappings between prisons and GP Prescribe Codes

Code Style & Formatting

./gradlew ktlintApplyToIdea addKtlintFormatGitPreCommitHook

will apply ktlint styles to intellij and also add a pre-commit hook to format all changed kotlin files.

Building

./gradlew build

Running

./gradlew bootRun

Health

  • /health/ping: will respond with status UP to all requests. This should be used by dependent systems to check connectivity to prison-estate, rather than calling the /health endpoint.
  • /health: provides information about the application health and its dependencies. This should only be used by prison-estate health monitoring (e.g. pager duty) and not other systems who wish to find out the state of prison-estate.
  • /info: provides information about the version of deployed application.

Updating prison information

Use Prison API to make a call to {{prisonapihost}}/api/agencies/type/INST?activeOnly=false to get the list of institutions. Save this as all-prisons.json, then run:

jq -r '.[] | "INSERT INTO prison VALUES (@" + .agencyId + "@, @" + .description + "@, " + (.active|tostring) + ");"' all-prisons.json | tr @ "'" | sort -k6 > new_prisons.sql

This will generate insert statements for each prison, ordered by description.

Now grab all the existing data from the insert statements:

sort -k6 *insert_prisons.sql | grep 'INSERT INTO prison ' > old_prisons.sql

and compare:

diff -iw old_prisons.sql new_prisons.sql

Output the differences to a the new file VX_X__insert_prisons.sql.

Updating GP information

Normally the information will come through in a spreadsheet containing all the prison / gp mappings, not just the new ones. Export the provider code and prison code columns to a new file called codes.csv. Then run:

awk '{print "INSERT INTO prison_gp_practice VALUES (@" $2 "@, @" $1 "@);"}' codes.csv | sort -k 2 | tr @ "'"  > new_gp_practice.sql

This will generate insert statements from the codes into new_gp_practice.sql.

Now grab all the existing data from the insert statements:

sort -k5 *insert*.sql | grep 'INSERT INTO prison_gp' > old_gp_practice.sql

Then compare to see what's changed:

diff old_gp_practice.sql new_gp_practice.sql

ministryofjustice.prison-estate's People

Contributors

dnyanesh-sonwane avatar mattops avatar mikehalmamoj avatar petergphillips avatar simonmitchellmoj 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.