File size: 2,708 Bytes
8e844df
8b893c4
8e844df
11bd726
 
 
1b8f14b
07f4fdf
e9cfc22
4468aa8
01dd0c9
e9cfc22
d729ec6
4468aa8
37259df
2f6133f
 
8b893c4
 
 
 
 
 
 
1ba86d2
8b893c4
 
 
 
093c97f
8b893c4
dda69c9
5c68510
 
 
 
8ea4a62
8b893c4
cd0701a
c36e6e4
a1a70b7
bb8fcd0
5c68510
 
 
8e844df
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import streamlit as st
import pandas as pd 

for k, v in st.session_state.items():
    st.session_state[k] = v

#st.title("📘SBS mapper")
st.header("Map internal descriptions to SBS codes V2.0")
#st.image("images/SBS_Chapter_Index.png", use_container_width=True) 
st.subheader("Select specific Chapter for quicker results")
st.subheader("Demo currently limited to Chapter 20: Imaging services; (Work in progress)")
df_chapters = pd.read_csv("SBS_V2_Chapter_Index.csv")
df_chapters.iloc[25] = {"Chapter": 26, "Chapter title": "ALL CHAPTERS (will take more time)", "Blocks": "Total", "No. Codes": 10081}
#st.dataframe(df_chapters, hide_index=True) # redundant, as dataframe will be displayed by below function

def dataframe_with_selections(df_chapters: pd.DataFrame, init_value: bool = False) -> pd.DataFrame:
    df_with_selections = df_chapters.copy()
    df_with_selections.insert(0, "Select", init_value)

    # Get dataframe row-selections from user with st.data_editor
    edited_df = st.data_editor(
        df_with_selections,
        hide_index=True,
        column_config={"Select": st.column_config.CheckboxColumn(required=True)},
        disabled=df_chapters.columns,
    )

    # Filter the dataframe using the temporary column, then drop the column
    selected_rows = edited_df[edited_df.Select]
    return selected_rows.drop('Select', axis=1)

if "selected_chapters" not in st.session_state:
    st.session_state['selected_chapters'] = []

selected_chapters_list = st.session_state.selected_chapters

selected_chapters = dataframe_with_selections(df_chapters)
st.write("Your selection:")
st.write(selected_chapters)
selected_chapters_list = selected_chapters.iloc[:,0].tolist()
#st.write("ZZZZZZZZZZ: ", selected_chapters_list)

if selected_chapters is not None:
    st.session_state.selected_chapters = selected_chapters_list

#'Procedures on nervous system'
#'Procedures on endocrine system'
#'Procedures on eye and adnexa'
#'Procedures on ear and mastoid process'
#'Procedures on nose, mouth and pharynx'
#'Dental services'
#'Procedures on respiratory system'
#'Procedures on cardiovascular system'
#'Procedures on blood and blood-forming organs'
#'Procedures on digestive system'
#'Procedures on urinary system'
#'Procedures on male genital organs'
#'Gynaecological procedures'
#'Obstetric procedures'
#'Procedures on musculoskeletal system'
#'Dermatological and plastic procedures'
#'Procedures on breast'
#'Radiation oncology procedures'
#'Non-invasive, cognitive and other interventions, not elsewhere classified'
#'Imaging services'
#'Laboratory and Pathology Services'
#'Ambulance and Transport Services'
#'KSA Service Codes'
#'Emergency Medical Services (EMS)'
#'Mortuary Services'