emvecchi commited on
Commit
0d6498e
·
verified ·
1 Parent(s): 65944da

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -8
app.py CHANGED
@@ -122,16 +122,16 @@ fields: List[Field] = [
122
  Field(name="dialogue_name", type="input_col", title=""),
123
  ]),
124
 
125
- Field(type="container", title="### Session-/Patient-Specific Properties", children=[
126
  Field(name="to_moderate", type="likert_radio",
127
  title="Explicit mention of clinical diagnosis?", other_params={'labels': mentioned_y_n}, mandatory=True),
128
  Field(name="priority_level", type="likert_radio",
129
  title="Level of priority", other_params={'labels': priority_labels}, mandatory=True),
130
  ]),
131
 
132
- Field(type="container", title="### Rupture Markers", children=[
133
  Field(type="expander", title="**Overview of rupture markers** *(expand)*", children=[
134
- Field(name="rupture_marker_overview", type="input_col", title=""),
135
  ]),
136
  Field(name="rupture_markers", type="rupture_markers",
137
  title="Select rupture markers noted in the session, include line numbers where rupture is found.", mandatory=False),
@@ -142,7 +142,7 @@ fields: List[Field] = [
142
  # Field(name="rupture_marker_other", type="text", title="*If Other, please specify:*", mandatory=False),
143
  ]),
144
 
145
- Field(type="container", title="### True-To-Patient-Prompt Features", children=[
146
  Field(name="helpful", type="y_n_radio",
147
  title="Did the patient remain true to the provided patient prompt?", mandatory=True,
148
  following_mandatory_values=[1]),
@@ -442,22 +442,30 @@ def show_field(f: Field, index: int, data_collected):
442
  st.session_state.following_mandatory = False
443
  match f.type:
444
  case 'input_col':
 
 
 
 
445
  value = st.session_state.data.iloc[index][f.name]
446
  if value and value is not np.nan:
447
  st.write(f.title)
448
  if f.name == 'image_name':
449
  display_image(os.path.join(input_repo_path, 'images', value))
450
  elif f.name == 'dialogue_name':
451
- #display_dialogue(os.path.join(input_repo_path, 'dialogues', value))
452
  render_dialogue(os.path.join(input_repo_path, 'dialogues', value), width_chars=115, height_px=520, show_border=False)
453
- elif f.name == 'rupture_marker_overview':
454
- display_dialogue(os.path.join(input_repo_path, 'rupture_marker_overview.md'))
455
  elif f.name == 'patient':
456
  st.markdown(f"## Patient:  {value}")
457
  else:
458
  st.write(value)
459
  case 'markdown':
460
- st.markdown(f.title)
 
 
 
 
 
461
  case 'expander' | 'container':
462
  with (st.expander(f.title) if f.type == 'expander' else st.container(border=True)):
463
  if f.type == 'container':
 
122
  Field(name="dialogue_name", type="input_col", title=""),
123
  ]),
124
 
125
+ Field(type="container", title="#### Session-/Patient-Specific Properties", children=[
126
  Field(name="to_moderate", type="likert_radio",
127
  title="Explicit mention of clinical diagnosis?", other_params={'labels': mentioned_y_n}, mandatory=True),
128
  Field(name="priority_level", type="likert_radio",
129
  title="Level of priority", other_params={'labels': priority_labels}, mandatory=True),
130
  ]),
131
 
132
+ Field(type="container", title="#### Rupture Markers", children=[
133
  Field(type="expander", title="**Overview of rupture markers** *(expand)*", children=[
134
+ Field(type="markdown", title="", other_params={"path": "rupture_marker_overview.md"}),
135
  ]),
136
  Field(name="rupture_markers", type="rupture_markers",
137
  title="Select rupture markers noted in the session, include line numbers where rupture is found.", mandatory=False),
 
142
  # Field(name="rupture_marker_other", type="text", title="*If Other, please specify:*", mandatory=False),
143
  ]),
144
 
145
+ Field(type="container", title="#### True-To-Patient-Prompt Features", children=[
146
  Field(name="helpful", type="y_n_radio",
147
  title="Did the patient remain true to the provided patient prompt?", mandatory=True,
148
  following_mandatory_values=[1]),
 
442
  st.session_state.following_mandatory = False
443
  match f.type:
444
  case 'input_col':
445
+ #if f.name and f.name in st.session_state.data.columns:
446
+ # value = st.session_state.data.iloc[index][f.name]
447
+ #else:
448
+ # value = None
449
  value = st.session_state.data.iloc[index][f.name]
450
  if value and value is not np.nan:
451
  st.write(f.title)
452
  if f.name == 'image_name':
453
  display_image(os.path.join(input_repo_path, 'images', value))
454
  elif f.name == 'dialogue_name':
 
455
  render_dialogue(os.path.join(input_repo_path, 'dialogues', value), width_chars=115, height_px=520, show_border=False)
456
+ #elif f.name == 'rupture_marker_overview':
457
+ # display_dialogue(os.path.join(input_repo_path, 'rupture_marker_overview.md'))
458
  elif f.name == 'patient':
459
  st.markdown(f"## Patient:  {value}")
460
  else:
461
  st.write(value)
462
  case 'markdown':
463
+ path = f.other_params.get("path") if f.other_params else None
464
+ if path:
465
+ content = load_text(os.path.join(input_repo_path, path))
466
+ st.markdown(content, unsafe_allow_html=True)
467
+ else:
468
+ st.markdown(f.title)
469
  case 'expander' | 'container':
470
  with (st.expander(f.title) if f.type == 'expander' else st.container(border=True)):
471
  if f.type == 'container':