-
Notifications
You must be signed in to change notification settings - Fork 4
Misc feedback on v1.b5 #18
Copy link
Copy link
Open
Description
Some typos on the "Run the Quaero Explorer" documentation
- The data argument might be missing in the code block from the "What is the saved format?" part.
- There is a "return" without any function defined in the code block from the "Assemble everything" part.
Feature Request
- Once a factory is instantiated, we cannot overwrite this factory with other parameters. It might be interesting to add a boolean overwrite parameter to DatasetExplorerWidgetFactory. This could be useful for tests or even if we did a mistake in the data dict.
- It might be interesting to add the possibility to instantiate the scheme of entites annotation in the case where we don't want to pre-annotate texts
- In table cells, it might be interesting to add the possibility to have choices in a drop-down menu and the possibility to have multiple mutually exclusive boxes.
Bug
Description
The "scroll" feature works the first time, and once a button was clicked, it does not work any more.
How to reproduce the bug
def on_note_selected_in_table(
row_id: str, row_idx: int, col: str, mode: str, cause: str
):
if row_id is None:
return
top_level_state["note_id"] = row_id
note_text_handle.current["set_doc_by_id"](row_id)
note_form_handle.current["set_row_id"](row_id)
def on_patient_selected_in_table(
row_id: str, row_idx: int, col: str, mode: str, cause: str
):
if row_id is None:
return
top_level_state["person_id"] = row_id
note_id = [note for note in notes if note["person_id"] == row_id][0]["note_id"]
top_level_state["note_id"] = note_id
notes_table_handle.current["set_filter"]("person_id", str(row_id))
notes_table_handle.current["scroll_to_row_id"](note_id)
notes_table_handle.current["scroll_to_row_idx"](note_id)
notes_table_handle.current["set_highlighted"]([note_id])
note_text_handle.current["set_doc_by_id"](note_id)
note_form_handle.current["set_row_id"](note_id)
def on_pt_row_hovered(person_id: str, person_idx: int, mod_keys: List[str]):
patients_table_handle.current["set_highlighted"]([str(person_id)])
@component
def NoteTextHeader():
note_id = use_store_snapshot(top_level_state)["note_id"]
return f"Note {note_id}" if note_id else "Note"
@component
def NotesHeader():
person_id = use_store_snapshot(top_level_state)["person_id"]
return f"Notes from patient {person_id}" if person_id else "Notes"
data = edsnlp.data.read_parquet(
notes_path,
span_setter="entities",
notes_as_span_attribute="cui",
)
patients_dict = {}
notes = []
init_labels_dict = {label: False for label in labels}
for idx, doc in enumerate(data):
notes.append(
{
"note_id": str(doc["note_id"]),
"note_datetime": str(doc["note_datetime"]),
"note_class_source_value": str(doc["note_class_source_value"]),
"visit_occurrence_id": str(doc["visit_occurrence_id"]),
"care_site_id": str(doc["care_site_id"]),
"note_title": str(doc["note_title"]),
"row_status_source_value": str(doc["row_status_source_value"]),
"note_text": doc["note_text"],
"person_id": str(doc["person_id"]),
"interesting": False,
"seen": False,
}
)
if str(doc["person_id"]) not in patients_dict:
d1 = {"person_id": str(doc["person_id"]), "seen": False}
patients_dict[str(doc["person_id"])] = dict(
chain.from_iterable(d.items() for d in (d1, init_labels_dict))
)
patients = list(patients_dict.values())
notes = sorted(notes, key=lambda d: d["note_datetime"])
factory = DatasetExplorerWidgetFactory(
{
"notes": notes,
"patients": patients,
},
sync=annotations_path,
)
data = factory.data
notes_table_handle: RefType[TableWidgetHandle] = use_ref()
patients_table_handle: RefType[TableWidgetHandle] = use_ref()
note_text_handle: RefType[TextWidgetHandle] = use_ref()
note_form_handle: RefType[FormWidgetHandle] = use_ref()
top_level_state = create_store(
{
"note_id": notes[0]["note_id"] if notes else None,
"person_id": patients[0]["person_id"] if patients else None,
}
)
notes_view = factory.create_table_widget(
store_key="notes",
primary_key="note_id",
first_keys=[
"note_id",
"seen",
"interesting",
"note_datetime",
"note_title",
"note_class_source_value",
],
id_keys=["note_id"],
editable_keys=["seen", "interesting"],
categorical_keys=["seen", "interesting"],
hidden_keys=[],
style={"--min-notebook-height": "300px"},
handle=notes_table_handle,
on_position_change=on_note_selected_in_table,
)
note_form_view = factory.create_form_widget(
store_key="notes",
primary_key="note_id",
first_keys=[
"note_id",
"note_datetime",
"note_title",
"note_class_source_value",
],
hidden_keys=["note_text", "seen", "interesting"],
style={
"--min-notebook-height": "300px",
"margin": "10px",
"alignItems": "flex-start",
},
handle=note_form_handle,
)
patients_view = factory.create_table_widget(
store_key="patients",
primary_key="person_id",
first_keys=["person_id", "seen"] + labels,
id_keys=["person_id"],
editable_keys=["seen"] + labels,
categorical_keys=["seen"] + labels,
style={"--min-notebook-height": "300px"},
handle=patients_table_handle,
on_position_change=on_patient_selected_in_table,
on_mouse_hover_row=on_pt_row_hovered,
)
note_text_view = factory.create_text_widget(
store_text_key="notes",
handle=note_text_handle,
text_key="note_text",
text_primary_key="note_id",
spans_primary_key="ent_id",
style={"--min-notebook-height": "300px"},
)
layout = div(
Layout(
Panel(patients_view, key="Patients"),
Panel(notes_view, header=NotesHeader(), key="Notes"),
Panel(note_form_view, header=NoteTextHeader(), key="Note Form"),
Panel(note_text_view, header=NoteTextHeader(), key="Note Text"),
default_config={
"kind": "row",
"children": [
"Patients",
["Notes", "Note Form"],
"Note Text",
],
},
),
style={
"background": "var(--joy-palette-background-level2, #f0f0f0)",
"width": "100%",
"height": "100%",
"minHeight": "300px",
"--sd-background-color": "transparent",
},
)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels