Noah Settersten commited on
Commit ·
bade74c
1
Parent(s): a4478d7
feat: Create component for displaying %TagResult{}
Browse files
lib/medical_transcription_web.ex
CHANGED
|
@@ -85,6 +85,7 @@ defmodule MedicalTranscriptionWeb do
|
|
| 85 |
import Phoenix.HTML
|
| 86 |
# Core UI components and translation
|
| 87 |
import MedicalTranscriptionWeb.CoreComponents
|
|
|
|
| 88 |
import MedicalTranscriptionWeb.Gettext
|
| 89 |
|
| 90 |
# Shortcut for generating JS commands
|
|
|
|
| 85 |
import Phoenix.HTML
|
| 86 |
# Core UI components and translation
|
| 87 |
import MedicalTranscriptionWeb.CoreComponents
|
| 88 |
+
import MedicalTranscriptionWeb.Components
|
| 89 |
import MedicalTranscriptionWeb.Gettext
|
| 90 |
|
| 91 |
# Shortcut for generating JS commands
|
lib/medical_transcription_web/components/components.ex
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
defmodule MedicalTranscriptionWeb.Components do
|
| 2 |
+
use Phoenix.Component
|
| 3 |
+
|
| 4 |
+
def tag_result_chip(assigns) do
|
| 5 |
+
~H"""
|
| 6 |
+
<div class="group flex items-start gap-1 px-1.5 py-0.5 rounded text-slate-800 text-sm bg-slate-200 border border-slate-300">
|
| 7 |
+
<span class="font-bold">
|
| 8 |
+
<%= @code %>:
|
| 9 |
+
</span>
|
| 10 |
+
<div>
|
| 11 |
+
<%= @label %>
|
| 12 |
+
<p class="hidden group-hover:inline">
|
| 13 |
+
<%= "(#{trunc(@score * 100)})" %>
|
| 14 |
+
</p>
|
| 15 |
+
</div>
|
| 16 |
+
</div>
|
| 17 |
+
"""
|
| 18 |
+
end
|
| 19 |
+
end
|
lib/medical_transcription_web/live/home_live/index.ex
CHANGED
|
@@ -43,14 +43,20 @@ defmodule MedicalTranscriptionWeb.HomeLive.Index do
|
|
| 43 |
</div>
|
| 44 |
<% end %>
|
| 45 |
|
| 46 |
-
<.table
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
<:col :let={row} label="Start"><%= row.start_mark %></:col>
|
| 48 |
<:col :let={row} label="End"><%= row.end_mark %></:col>
|
| 49 |
<:col :let={row} label="Text"><%= row.text %></:col>
|
| 50 |
<:col :let={row} label="Codes">
|
| 51 |
-
<
|
| 52 |
-
<%=
|
| 53 |
-
|
|
|
|
|
|
|
| 54 |
</:col>
|
| 55 |
</.table>
|
| 56 |
</div>
|
|
|
|
| 43 |
</div>
|
| 44 |
<% end %>
|
| 45 |
|
| 46 |
+
<.table
|
| 47 |
+
id="streamed_result"
|
| 48 |
+
rows={@streams.transcription_rows}
|
| 49 |
+
row_item={fn {dom_id, row} -> Map.put(row, :dom_id, dom_id) end}
|
| 50 |
+
>
|
| 51 |
<:col :let={row} label="Start"><%= row.start_mark %></:col>
|
| 52 |
<:col :let={row} label="End"><%= row.end_mark %></:col>
|
| 53 |
<:col :let={row} label="Text"><%= row.text %></:col>
|
| 54 |
<:col :let={row} label="Codes">
|
| 55 |
+
<div class="w-max flex flex-col items-stretch gap-2">
|
| 56 |
+
<%= for %TagResult{code: code, label: label, score: score} <- row.tags do %>
|
| 57 |
+
<.tag_result_chip code={code} label={label} score={score} />
|
| 58 |
+
<% end %>
|
| 59 |
+
</div>
|
| 60 |
</:col>
|
| 61 |
</.table>
|
| 62 |
</div>
|