Skip to content

Commit 1a598ac

Browse files
committed
Reorganize sections
1 parent fc680ae commit 1a598ac

1 file changed

Lines changed: 70 additions & 50 deletions

File tree

filter_engine.py

Lines changed: 70 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import marimo
22

3-
__generated_with = "0.20.2"
3+
__generated_with = "0.14.16"
44
app = marimo.App(
55
width="medium",
66
app_title="Open Syndrome Definition - Data Browser",
@@ -100,9 +100,7 @@ def groupped_bar(_df_filtered, definitions, group_by_column="code", top_n=10):
100100

101101
@app.cell
102102
def _(mo):
103-
mo.md(r"""
104-
# Open Syndrome Definition 👩🏽‍🔬
105-
""")
103+
mo.md(r"""# Open Syndrome Definition 👩🏽‍🔬""")
106104
return
107105

108106

@@ -225,7 +223,7 @@ def _(df_selected, initial_date_column, initial_yaml, mo):
225223

226224
mo.vstack(
227225
[
228-
mo.md("### **Mapping your data to the format**"),
226+
mo.md("### Mapping your data to the format"),
229227
mo.md(
230228
"Edit the YAML below to map your dataset columns to OSD concepts, "
231229
"then click **Submit**. "
@@ -296,14 +294,6 @@ def _(get_definition_dir):
296294
return (definition_options,)
297295

298296

299-
@app.cell
300-
def _(definition_options, json):
301-
def load_definition(name: str) -> dict:
302-
return json.loads(definition_options[name].read_text())
303-
304-
return (load_definition,)
305-
306-
307297
@app.cell
308298
def _(definition_options, mo):
309299
definitions_dropdown = mo.ui.multiselect(
@@ -312,6 +302,30 @@ def _(definition_options, mo):
312302
return (definitions_dropdown,)
313303

314304

305+
@app.cell
306+
def _(mo):
307+
mo.md(r"""### Data sample""")
308+
return
309+
310+
311+
@app.cell
312+
def _(df_selected):
313+
df_selected.sample(10)
314+
return
315+
316+
317+
@app.cell
318+
def _(mo):
319+
mo.md(r"""---""")
320+
return
321+
322+
323+
@app.cell
324+
def _(mo):
325+
mo.md(r"""## Data & Definitions""")
326+
return
327+
328+
315329
@app.cell
316330
def _(definitions_dropdown, mo):
317331
mo.hstack([mo.md("**::lucide:filter:: Filters:**"), definitions_dropdown])
@@ -365,40 +379,16 @@ def _(definitions, df_filtered, df_selected, mo):
365379
),
366380
]
367381

368-
_title = "## Data with Open Syndrome Definitions"
369-
370-
mo.vstack(
371-
[
372-
mo.md(_title),
373-
mo.hstack(_cards, widths="equal", align="center"),
374-
]
375-
)
382+
mo.hstack(_cards, widths="equal", align="center")
376383
return
377384

378385

379386
@app.cell
380-
def _(definitions, load_definition, mo):
381-
mo.stop(definitions is None)
387+
def _(definition_options, json):
388+
def load_definition(name: str) -> dict:
389+
return json.loads(definition_options[name].read_text())
382390

383-
mo.vstack(
384-
[
385-
mo.md("### Definitions details"),
386-
mo.md(
387-
"This section shows the definitions used to filter the data. You can use them to understand how the data was filtered and what criteria were applied. 🔎"
388-
),
389-
mo.accordion(
390-
{
391-
"JSONs": mo.accordion(
392-
{
393-
definition: mo.json(load_definition(definition))
394-
for definition in definitions
395-
}
396-
),
397-
},
398-
),
399-
]
400-
)
401-
return
391+
return (load_definition,)
402392

403393

404394
@app.cell
@@ -424,7 +414,7 @@ def _(
424414

425415
if code_column:
426416
diagnosis_chart = [
427-
mo.md("## Codes comparison per syndromic indicator"),
417+
mo.md("### Codes comparison per syndromic indicator"),
428418
top_n.left(),
429419
groupped_bar(
430420
df_filtered,
@@ -436,20 +426,50 @@ def _(
436426
else:
437427
diagnosis_chart = []
438428

429+
timeseries = [
430+
mo.md("### Time series"),
431+
plot_cases(
432+
df_filtered,
433+
definitions,
434+
date_column=date_column,
435+
date_format=date_format_input.value,
436+
),
437+
]
438+
439439
mo.vstack(
440440
[
441-
mo.md("## Time series"),
442-
plot_cases(
443-
df_filtered,
444-
definitions,
445-
date_column=date_column,
446-
date_format=date_format_input.value,
447-
),
441+
mo.md("## Findings from the data 📊"),
442+
*timeseries,
448443
*diagnosis_chart,
449444
]
450445
)
451446
return
452447

453448

449+
@app.cell
450+
def _(definitions, load_definition, mo):
451+
mo.stop(definitions is None)
452+
453+
mo.vstack(
454+
[
455+
mo.md("### Definitions details"),
456+
mo.md(
457+
"Here the definitions used to filter the data. See here what criteria were applied. 🔎"
458+
),
459+
mo.accordion(
460+
{
461+
"JSONs": mo.accordion(
462+
{
463+
definition: mo.json(load_definition(definition))
464+
for definition in definitions
465+
}
466+
),
467+
},
468+
),
469+
]
470+
)
471+
return
472+
473+
454474
if __name__ == "__main__":
455475
app.run()

0 commit comments

Comments
 (0)