This is a very early, rough start at making a django app that does cool stuff with the prescriptions dataset.

It was written quickly with no real idea of a point, so there is a high chance it's broken or wrong in some way.

Throwing it up here in the hope it turns in to something cool one day.

:)

Examples

You will be able to see awesomer & awesomer examples at http://prescriptions.openhealthcare.org.uk

http://prescriptions.openhealthcare.org.uk/examples/group/statins/

API

http://prescriptions.openhealthcare.org.uk/api/drug/

=> All drugs in the prescribing list

http://prescriptions.openhealthcare.org.uk/api/drug/?name=Rosuvastatin

=> [{name:'Rosuvastatin'...}]

http://prescriptions.openhealthcare.org.uk/api/drug/?name=Rosuvastatin Calcium,Fluvastatin Sodium"

(Must be exact names as returned by the drug list here)

=> [{name:'Rosuvastatin'...},{name: 'Fluvastatin'...}]

http://prescriptions.openhealthcare.org.uk/api/drug/habits/?name=Fluvastatin

=> [{"code": "0212000M0", "name": "Fluvastatin Sodium", "habit": [{"total": 13668, "period": 201202}, ...]]

/api/drug/habits/

=> Don't do this, it will aggregate the entire multiple gig dataset, not particularly efficiently, and return all historical aggregate data for all drugs.

http://prescriptions.openhealthcare.org.uk/api/practice/

=> All practice data

Installishes

General Postgis dance... General download data dance...

$ pip install -r requirements.txt

$ python manage.py syncdb

$ python manage.py migrate practices

$ python manage.py migrate

$ cat your_practices_file.csv | python manage.py import_practices

$ python manage.py import_prescriptions your_csv_file.csv

$ ./manage.py load_ccgs -f ../data/ccg_data_file.csv

$ ./manage.py bind_practices

Note - your database user must be a superuser to import prescriptions.

The Postcode data can be obtained from Ordnance Survey

http://www.ordnancesurvey.co.uk/oswebsite/products/code-point-open/index.html

The Django management command to import postcodes is

python manage.py mapit_import_postcodes --coord-field-lon 3 --coord-field-lat 4 /tmp/postcodes.csv

...where we assume that postcodes.csv is our combined csv of all of the codepoint stuff.