-
Notifications
You must be signed in to change notification settings - Fork 26
API calls for the analyse page
Peter Inglesby edited this page Oct 31, 2018
·
6 revisions
Here's a list of the API calls that get made when showing different charts on the analyse page:
-
cerazette vs nothing, highlighting nothing
-
bnf_code
- exact: true
- q: 0703021Q0BB,
-
spending_by_ccg
- code: 0703021Q0BB
-
org_details
- keys: nothing
- org_type: ccg
-
org_location
- org_type: ccg
-
bnf_code
-
cerazette vs nothing, highlighting a CCG
-
org_code
- exact: true
- q: 11M,
-
bnf_code
- exact: true
- q: 0703021Q0BB,
-
spending_by_ccg
- code: 0703021Q0BB
-
org_details
- keys: nothing
- org_type: ccg
-
org_location
- org_type: ccg
-
org_code
-
cerazette vs nothing, highlighting practices in a CCG
-
org_code
- exact: true
- q: 11M,
-
bnf_code
- exact: true
- q: 0703021Q0BB,
-
spending_by_practice
- code: 0703021Q0BB
- org: 11M
-
org_details
- keys: nothing
- org: 11M
- org_type: practice
-
org_location
- org_type: practice
- q: 11M,
-
org_code
-
cerazette vs nothing, highlighting one practice in a CCG
-
org_code
- exact: true
- q: L84613,
-
bnf_code
- exact: true
- q: 0703021Q0BB,
-
spending_by_practice
- code: 0703021Q0BB
- org: 11M
-
org_details
- keys: nothing
- org: 11M
- org_type: practice
-
org_location
- org_type: practice
- q: 11M,
-
org_code
-
cerazette vs desogestrel, highlighting nothing
-
bnf_code
- exact: true
- q: 0703021Q0BB,
-
bnf_code
- exact: true
- q: 0703021Q0,
-
spending_by_ccg
- code: 0703021Q0BB
-
spending_by_ccg
- code: 0703021Q0
-
org_location
- org_type: ccg
-
bnf_code
-
cerazette vs desogestrel, highlighting a CCG
-
org_code
- exact: true
- q: 11M,
-
bnf_code
- exact: true
- q: 0703021Q0BB,
-
bnf_code
- exact: true
- q: 0703021Q0,
-
spending_by_ccg
- code: 0703021Q0BB
-
spending_by_ccg
- code: 0703021Q0
-
org_location
- org_type: ccg
-
org_code
-
cerazette vs desogestrel, highlighting practices in a CCG
-
org_code
- exact: true
- q: 11M,
-
bnf_code
- exact: true
- q: 0703021Q0BB,
-
bnf_code
- exact: true
- q: 0703021Q0,
-
spending_by_practice
- code: 0703021Q0BB
- org: 11M
-
spending_by_practice
- code: 0703021Q0
- org: 11M
-
org_location
- org_type: practice
- q: 11M,
-
org_code
-
cerazette vs desogestrel, highlighting one practice in a CCG
-
org_code
- exact: true
- q: L84613,
-
bnf_code
- exact: true
- q: 0703021Q0BB,
-
bnf_code
- exact: true
- q: 0703021Q0,
-
spending_by_practice
- code: 0703021Q0BB
- org: 11M
-
spending_by_practice
- code: 0703021Q0
- org: 11M
-
org_location
- org_type: practice
- q: 11M,
-
org_code
-
cerazette vs total list size, highlighting nothing
-
bnf_code
- exact: true
- q: 0703021Q0BB,
-
spending_by_ccg
- code: 0703021Q0BB
-
org_details
- keys: total_list_size
- org_type: ccg
-
org_location
- org_type: ccg
-
bnf_code
-
cerazette vs total list size, highlighting a CCG
-
org_code
- exact: true
- q: 11M,
-
bnf_code
- exact: true
- q: 0703021Q0BB,
-
spending_by_ccg
- code: 0703021Q0BB
-
org_details
- keys: total_list_size
- org_type: ccg
-
org_location
- org_type: ccg
-
org_code
-
cerazette vs total list size, highlighting practices in a CCG
-
org_code
- exact: true
- q: 11M,
-
bnf_code
- exact: true
- q: 0703021Q0BB,
-
spending_by_practice
- code: 0703021Q0BB
- org: 11M
-
org_details
- keys: total_list_size
- org: 11M
- org_type: practice
-
org_location
- org_type: practice
- q: 11M,
-
org_code
-
cerazette vs total list size, highlighting one practice in a CCG
-
org_code
- exact: true
- q: L84613,
-
bnf_code
- exact: true
- q: 0703021Q0BB,
-
spending_by_practice
- code: 0703021Q0BB
- org: 11M
-
org_details
- keys: total_list_size
- org: 11M
- org_type: practice
-
org_location
- org_type: practice
- q: 11M,
-
org_code
-
cerazette vs STAR-PUs, highlighting nothing
-
bnf_code
- exact: true
- q: 0703021Q0BB,
-
spending_by_ccg
- code: 0703021Q0BB
-
org_details
- keys: star_pu.oral_antibacterials_item
- org_type: ccg
-
org_location
- org_type: ccg
-
bnf_code
-
cerazette vs STAR-PUs, highlighting a CCG
-
org_code
- exact: true
- q: 11M,
-
bnf_code
- exact: true
- q: 0703021Q0BB,
-
spending_by_ccg
- code: 0703021Q0BB
-
org_details
- keys: star_pu.oral_antibacterials_item
- org_type: ccg
-
org_location
- org_type: ccg
-
org_code
-
cerazette vs STAR-PUs, highlighting practices in a CCG
-
org_code
- exact: true
- q: 11M,
-
bnf_code
- exact: true
- q: 0703021Q0BB,
-
spending_by_practice
- code: 0703021Q0BB
- org: 11M
-
org_details
- keys: star_pu.oral_antibacterials_item
- org: 11M
- org_type: practice
-
org_location
- org_type: practice
- q: 11M,
-
org_code
-
cerazette vs STAR-PUs, highlighting one practice in a CCG
-
org_code
- exact: true
- q: L84613,
-
bnf_code
- exact: true
- q: 0703021Q0BB,
-
spending_by_practice
- code: 0703021Q0BB
- org: 11M
-
org_details
- keys: star_pu.oral_antibacterials_item
- org: 11M
- org_type: practice
-
org_location
- org_type: practice
- q: 11M,
-
org_code
And here's a list of the charts that make each API call:
- bnf_code/?format=json&exact=true&q=0703021Q0,
-
bnf_code/?format=json&exact=true&q=0703021Q0BB,
- cerazette vs nothing, highlighting nothing
- cerazette vs nothing, highlighting a CCG
- cerazette vs nothing, highlighting practices in a CCG
- cerazette vs nothing, highlighting one practice in a CCG
- cerazette vs desogestrel, highlighting nothing
- cerazette vs desogestrel, highlighting a CCG
- cerazette vs desogestrel, highlighting practices in a CCG
- cerazette vs desogestrel, highlighting one practice in a CCG
- cerazette vs total list size, highlighting nothing
- cerazette vs total list size, highlighting a CCG
- cerazette vs total list size, highlighting practices in a CCG
- cerazette vs total list size, highlighting one practice in a CCG
- cerazette vs STAR-PUs, highlighting nothing
- cerazette vs STAR-PUs, highlighting a CCG
- cerazette vs STAR-PUs, highlighting practices in a CCG
- cerazette vs STAR-PUs, highlighting one practice in a CCG
-
org_code/?format=json&exact=true&q=11M,
- cerazette vs nothing, highlighting a CCG
- cerazette vs nothing, highlighting practices in a CCG
- cerazette vs desogestrel, highlighting a CCG
- cerazette vs desogestrel, highlighting practices in a CCG
- cerazette vs total list size, highlighting a CCG
- cerazette vs total list size, highlighting practices in a CCG
- cerazette vs STAR-PUs, highlighting a CCG
- cerazette vs STAR-PUs, highlighting practices in a CCG
- org_code/?format=json&exact=true&q=L84613,
- org_details/?format=json&org_type=ccg&keys=nothing
- org_details/?format=json&org_type=ccg&keys=star_pu.oral_antibacterials_item
- org_details/?format=json&org_type=ccg&keys=total_list_size
- org_details/?format=json&org_type=practice&keys=nothing&org=11M
- org_details/?format=json&org_type=practice&keys=star_pu.oral_antibacterials_item&org=11M
- org_details/?format=json&org_type=practice&keys=total_list_size&org=11M
-
org_location/?format=json&org_type=ccg
- cerazette vs nothing, highlighting nothing
- cerazette vs nothing, highlighting a CCG
- cerazette vs desogestrel, highlighting nothing
- cerazette vs desogestrel, highlighting a CCG
- cerazette vs total list size, highlighting nothing
- cerazette vs total list size, highlighting a CCG
- cerazette vs STAR-PUs, highlighting nothing
- cerazette vs STAR-PUs, highlighting a CCG
-
org_location/?format=json&org_type=practice&q=11M,
- cerazette vs nothing, highlighting practices in a CCG
- cerazette vs nothing, highlighting one practice in a CCG
- cerazette vs desogestrel, highlighting practices in a CCG
- cerazette vs desogestrel, highlighting one practice in a CCG
- cerazette vs total list size, highlighting practices in a CCG
- cerazette vs total list size, highlighting one practice in a CCG
- cerazette vs STAR-PUs, highlighting practices in a CCG
- cerazette vs STAR-PUs, highlighting one practice in a CCG
- spending_by_ccg/?format=json&code=0703021Q0
-
spending_by_ccg/?format=json&code=0703021Q0BB
- cerazette vs nothing, highlighting nothing
- cerazette vs nothing, highlighting a CCG
- cerazette vs desogestrel, highlighting nothing
- cerazette vs desogestrel, highlighting a CCG
- cerazette vs total list size, highlighting nothing
- cerazette vs total list size, highlighting a CCG
- cerazette vs STAR-PUs, highlighting nothing
- cerazette vs STAR-PUs, highlighting a CCG
- spending_by_practice/?format=json&code=0703021Q0&org=11M
-
spending_by_practice/?format=json&code=0703021Q0BB&org=11M
- cerazette vs nothing, highlighting practices in a CCG
- cerazette vs nothing, highlighting one practice in a CCG
- cerazette vs desogestrel, highlighting practices in a CCG
- cerazette vs desogestrel, highlighting one practice in a CCG
- cerazette vs total list size, highlighting practices in a CCG
- cerazette vs total list size, highlighting one practice in a CCG
- cerazette vs STAR-PUs, highlighting practices in a CCG
- cerazette vs STAR-PUs, highlighting one practice in a CCG
This was generated with the following:
import subprocess
from collections import defaultdict
numerators = [
('cerazette', 'numIds=0703021Q0BB'),
]
denominators = [
('nothing', 'denom=nothing'),
('desogestrel', 'denomIds=0703021Q0'),
('total list size', 'denom=total_list_size'),
('STAR-PUs', 'denom=star_pu.oral_antibacterials_item'),
]
highlights = [
('nothing', 'org=CCG'),
('a CCG', 'org=CCG&orgIds=11M'),
('practices in a CCG', 'org=practice&orgIds=11M'),
('one practice in a CCG', 'org=practice&orgIds=L84613'),
]
chart_to_api_calls = defaultdict(list)
api_call_to_charts = defaultdict(list)
for numerator in numerators:
for denominator in denominators:
for highlight in highlights:
title = f'{numerator[0]} vs {denominator[0]}, highlighting {highlight[0]}'
url = f'https://openprescribing.net/analyse/#{highlight[1]}&{numerator[1]}&{denominator[1]}&selectedTab=summary'
chart = (title, url)
output = subprocess.check_output(['phantomjs', 'show-api-calls.js', url])
for line in output.decode('utf8').splitlines() :
if 'https://openprescribing.net/api/1.0/' not in line:
continue
assert '/?format=json&' in line
chart_to_api_calls[chart].append(line)
api_call_to_charts[line].append(chart)
for chart, api_calls in chart_to_api_calls.items():
title, url = chart
print(f'* [{title}]({url})')
for api_call in api_calls:
view_name = api_call.split('/')[-2]
qs = api_call.split('/?format=json&')[-1]
print(f' * [{view_name}]({api_call})')
for kv in sorted(qs.split('&')):
k, v = kv.split('=')
print(f' * {k}: {v}')
print()
print()
print()
for api_call, charts in sorted(api_call_to_charts.items()):
path = api_call.split('1.0/')[1]
print(f'* [{path}]({api_call})')
for chart in charts:
title, url = chart
print(f' * [{title}]({url})')