Exemplo n.º 1
0
def build_multidrop_card(id, m, content_dict, language):
    title_mapping = get_title_mapping()
    insert_data = \
            [
                dbc.Col(
                    html.Div([
                        dcc.Dropdown(
                            options=[{'label': title_mapping[language][x], 'value': x} for x in content_dict['vals']],
                            value=[],
                            id={
                                'type': 'mortality' if m else 'infection',
                                'index': "calc-multidrop-{}".format(id)
                            },
                            multi=True,
                        )],
                        id = "calc-multidrop-{}-wrapper".format(id),
                    )
                ),
            ]
    card = [
        dbc.Row(insert_data),
        dbc.Tooltip(
            content_dict['explanation'],
            target="calc-multidrop-{}-wrapper".format(id),
        ),
    ]
    return card
Exemplo n.º 2
0
def build_multidrop_card(_id, m, content_dict, language):
    """Used to select multiple from chronic diseases at bottom of mortality calculator"""
    title_mapping = get_title_mapping()
    insert_data = [
        dbc.Col(
            html.Div(
                id="calc-multidrop-{}-wrapper".format(_id),
                children=dcc.Dropdown(options=[{
                    'label':
                    title_mapping[language][x],
                    'value':
                    x
                } for x in content_dict['vals']],
                                      value=[],
                                      id={
                                          'type':
                                          'mortality' if m else 'infection',
                                          'index':
                                          "calc-multidrop-{}".format(_id)
                                      },
                                      className="dcc_dropdown",
                                      multi=True),
            )),
    ]
    card = [
        dbc.Row(insert_data),
        dbc.Tooltip(
            content_dict['explanation'],
            target="calc-multidrop-{}-wrapper".format(_id),
        ),
    ]
    return card
Exemplo n.º 3
0
def build_feature_cards(features, m=True, labs=False, language=0):
    """This builds all the feature cards"""
    card_content = []
    cards = []
    inputs = features["numeric"]
    dropdowns = features["categorical"]
    multidrop = features["multidrop"]
    title_mapping = get_title_mapping()
    for _id, content_dict in enumerate(dropdowns):
        card_content.append((content_dict['name'],
                             build_dropdown_card(str(_id), m, content_dict,
                                                 language)))
    for _id, content_dict in enumerate(inputs):
        if not labs and title_mapping[0][content_dict['name']] == oxygen:
            card_content.append((content_dict['name'],
                                 build_oxygen_card(str(_id), labs, m,
                                                   content_dict, language)))
        else:
            card_content.append((content_dict['name'],
                                 build_input_card(str(_id), m, content_dict)))
    if m:
        for _id, content_dict in enumerate(multidrop):
            card_content.append((content_dict['name'],
                                 build_multidrop_card(str(_id), m,
                                                      content_dict, language)))

    for name, c in card_content:
        content = dbc.Card([
            dbc.CardHeader(title_mapping[language][name],
                           style={"fontWeight": "bold"}),
            dbc.CardBody(c, className="feat-options-body")
        ],
                           className="feat-options")

        if name == "Comorbidities":
            w2 = 12
            w1 = 12
        elif not labs and title_mapping[0][name] == oxygen:
            w2 = 6
            w1 = 12
        else:
            w2 = 3
            w1 = 6
        card = dbc.Col(
            [content],
            style={
                'paddingBottom': 20,
                'borderColor': 'red'
            },
            xs=w1,
            sm=w1,
            md=w1,
            lg=w2,
        )
        cards.append(card)
    return cards
Exemplo n.º 4
0
def build_feature_cards(m=True, labs=False, language=0):
    if m:
        if labs:
            with open('assets/risk_calculators/mortality/labs_json.pkl',
                      'rb') as file:
                features_pickle = pickle.load(file)
        else:
            with open(
                    'assets/risk_calculators/mortality/without_labs_json.pkl',
                    'rb') as file:
                features_pickle = pickle.load(file)
    else:
        if labs:
            with open('assets/risk_calculators/infection/labs_json.pkl',
                      'rb') as file:
                features_pickle = pickle.load(file)
        else:
            with open(
                    'assets/risk_calculators/infection/without_labs_json.pkl',
                    'rb') as file:
                features_pickle = pickle.load(file)
    features = features_pickle["json"]
    card_content = []
    cards = []
    inputs = features["numeric"]
    dropdowns = features["categorical"]
    multidrop = features["multidrop"]
    title_mapping = get_title_mapping()
    for id, content_dict in enumerate(dropdowns):
        card_content.append((content_dict['name'],
                             build_dropdown_card(str(id), m, content_dict,
                                                 language)))
    for id, content_dict in enumerate(inputs):
        if not labs and title_mapping[0][content_dict['name']] == oxygen:
            card_content.append((content_dict['name'],
                                 build_oxygen_card(str(id), labs, m,
                                                   content_dict, language)))
        else:
            card_content.append((content_dict['name'],
                                 build_input_card(str(id), m, content_dict)))
    if m:
        for id, content_dict in enumerate(multidrop):
            card_content.append((content_dict['name'],
                                 build_multidrop_card(str(id), m, content_dict,
                                                      language)))

    for name, c in card_content:
        content = dbc.Card([
            dbc.CardHeader(title_mapping[language][name],
                           style={"fontWeight": "bold"}),
            dbc.CardBody(c, className="feat-options-body")
        ],
                           className="feat-options")
        if name == "Comorbidities":
            w2 = 12
            w1 = 12
        elif not labs and title_mapping[0][name] == oxygen:
            w2 = 6
            w1 = 12
        else:
            w2 = 3
            w1 = 6
        card = \
            dbc.Col([content],
            style={
                'paddingBottom':20,
                'borderColor':'red'
                },
            xs=w1,
            sm=w1,
            md=w1,
            lg=w2,
            )
        cards.append(card)
    return cards