prison-estate
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 statusUP
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