generated from opensafely/research-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sro_key_measures.py
50 lines (33 loc) · 1.43 KB
/
sro_key_measures.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import streamlit
from app import measures
def main():
repository = measures.OSJobsRepository()
selected_measure_name = streamlit.selectbox("Select a measure:", repository.list())
measure = repository.get(selected_measure_name)
streamlit.markdown(f"# {measure.name}")
streamlit.markdown(
"The codes used for this measure"
f"are available in [this codelist]({measure.codelist_url})."
)
with streamlit.expander("What is it and why does it matter?"):
streamlit.markdown(measure.explanation)
with streamlit.expander("Caveats"):
streamlit.markdown(measure.caveats)
streamlit.altair_chart(measure.deciles_chart, use_container_width=True)
streamlit.markdown(f"**Most common codes ([codelist]({measure.codelist_url}))**")
streamlit.dataframe(measure.top_5_codes_table)
streamlit.markdown(
"Total patients: "
f"**{measure.unique_patients:,}** "
f"({measure.total_events:,} events)"
)
for from_year, to_year in [(2019, 2020), (2019, 2021)]:
from_val, to_val, pct_change = measure.change_in_median(from_year, to_year, 4)
streamlit.markdown(
f"Change in median from April {from_year} ({from_val:.2f}) "
f"to April {to_year} ({to_val:.2f}): "
f"**{pct_change:.2%}**"
)
streamlit.markdown(f"Overall classification: **{measure.classification}**")
if __name__ == "__main__":
main()