cobertura de protocolos en multiplot

parent 2504b1af
...@@ -2,6 +2,7 @@ import pandas as pd ...@@ -2,6 +2,7 @@ import pandas as pd
from dash import Dash, Input, Output, dcc, html from dash import Dash, Input, Output, dcc, html
import plotly.graph_objects as go import plotly.graph_objects as go
import plotly.express as px import plotly.express as px
from plotly.subplots import make_subplots
import requests import requests
import numpy as np import numpy as np
import flask import flask
...@@ -395,26 +396,30 @@ def update_datos_por_paciente(etapa, fuente): ...@@ -395,26 +396,30 @@ def update_datos_por_paciente(etapa, fuente):
Output("cobertura_protocolo","figure"), Output("cobertura_protocolo","figure"),
Input("select_vis_protocolo", "value") Input("select_vis_protocolo", "value")
) )
def update_por_protocol(visita): def update_por_protocolo(visita):
lcol = 1
lrow = 1
df1 = visitas_datos[visita-1] df1 = visitas_datos[visita-1]
protocolos = { protocolos = {
"pyhsiological" : ["pass", "pad", "ipaq", "stress", "hadsa", "hadsd"], "pyhsiological" : ["pas", "pad", "ipaq", "stress", "hadsa", "hadsd"],
"tolerance_curves" : ["Pan", "Gelatina", "Glucosa"], "tolerance_curves" : ["Pan", "Gelatina", "Glucosa"],
"corporal_composition" : ["mmkg", "mmekg", "mgkg", "mlgkg", "percent_mg", "gv"], "corporal_composition" : ["mmkg", "mmekg", "mgkg", "mlgkg", "percent_mg", "gv"],
"biochemical" :["hba1c", "glucose", "ct", "tag", "ldl", "hdl", "pcr","alt", "ast","homa", "insuline" ], "biochemical" :["hba1c", "glucose", "ct", "tag", "ldl", "hdl", "pcr","alt", "ast","homa", "insuline" ],
"antropometric" : ["imc", "weight", "waist_circunference"] "antropometric" : ["imc", "weight", "waist_circumference"]
}
cuentas = 100 * df1.replace("",np.nan).count() / len(df1)
figura = {
"data": [
{
"x": cuentas.index,
"y": cuentas,
"type": "bar",
}
],
} }
figura = make_subplots(rows=2, cols=3, vertical_spacing=0.25)
for protocolo in protocolos.keys():
columnas = list(set(df1.columns).intersection(set(protocolos[protocolo])))
cuentas = 100 * df1[columnas].replace("",np.nan).count() / len(df1)
figura.add_trace(
go.Bar(x=cuentas.index, y=cuentas),
row = lrow,
col = lcol,
)
lcol = lcol + 1
if lcol > 3:
lcol = 1
lrow = lrow + 1
return figura return figura
@app.callback( @app.callback(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment