Commit ·
5c502c9
1
Parent(s): 16f89c2
fix: Restore keywords summary
Browse files
lib/medical_transcription/transcriptions.ex
CHANGED
|
@@ -200,6 +200,23 @@ defmodule Medicode.Transcriptions do
|
|
| 200 |
|> Repo.all()
|
| 201 |
end
|
| 202 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
@doc """
|
| 204 |
Creates a transcription.
|
| 205 |
|
|
|
|
| 200 |
|> Repo.all()
|
| 201 |
end
|
| 202 |
|
| 203 |
+
@doc """
|
| 204 |
+
Collect transcription keywords and order by score.
|
| 205 |
+
"""
|
| 206 |
+
def list_transcription_summary_keywords(transcription_id) do
|
| 207 |
+
query =
|
| 208 |
+
from(
|
| 209 |
+
k in TranscriptionChunkKeyword,
|
| 210 |
+
join: c in TranscriptionChunk, on: k.transcription_chunk_id == c.id,
|
| 211 |
+
where: c.transcription_id == ^transcription_id,
|
| 212 |
+
group_by: k.keyword,
|
| 213 |
+
select: %{keyword: k.keyword, score: sum(k.score)},
|
| 214 |
+
order_by: [desc: sum(k.score)]
|
| 215 |
+
)
|
| 216 |
+
|
| 217 |
+
Repo.all(query)
|
| 218 |
+
end
|
| 219 |
+
|
| 220 |
@doc """
|
| 221 |
Creates a transcription.
|
| 222 |
|
lib/medical_transcription_web/components/components.ex
CHANGED
|
@@ -124,16 +124,15 @@ defmodule MedicodeWeb.Components do
|
|
| 124 |
<div class="px-4 pt-2 pb-10 flex flex-col gap-2">
|
| 125 |
<p class="leading-normal font-bold text-type-black-primary uppercase">Summary Keywords</p>
|
| 126 |
|
| 127 |
-
<
|
| 128 |
-
class="text-sm leading-normal text-type-black-tertiary"
|
| 129 |
id="keyword_list"
|
| 130 |
-
class="flex flex-col gap-14"
|
| 131 |
>
|
| 132 |
<!-- coronary, artery, disease, unstable, angina, admitted -->
|
| 133 |
<%= for keyword <- format_keywords(@summary_keywords) do %>
|
| 134 |
-
<span class="" title={keyword.score}><%= keyword.
|
| 135 |
<% end %>
|
| 136 |
-
</
|
| 137 |
</div>
|
| 138 |
</div>
|
| 139 |
"""
|
|
|
|
| 124 |
<div class="px-4 pt-2 pb-10 flex flex-col gap-2">
|
| 125 |
<p class="leading-normal font-bold text-type-black-primary uppercase">Summary Keywords</p>
|
| 126 |
|
| 127 |
+
<div
|
| 128 |
+
class="flex flex-row items-center divide-x divide-black/15 text-sm leading-normal text-type-black-tertiary"
|
| 129 |
id="keyword_list"
|
|
|
|
| 130 |
>
|
| 131 |
<!-- coronary, artery, disease, unstable, angina, admitted -->
|
| 132 |
<%= for keyword <- format_keywords(@summary_keywords) do %>
|
| 133 |
+
<span class="px-2" title={keyword.score}><%= keyword.keyword %></span>
|
| 134 |
<% end %>
|
| 135 |
+
</div>
|
| 136 |
</div>
|
| 137 |
</div>
|
| 138 |
"""
|
lib/medical_transcription_web/live/transcriptions_live/show.ex
CHANGED
|
@@ -19,12 +19,14 @@ defmodule MedicodeWeb.TranscriptionsLive.Show do
|
|
| 19 |
|
| 20 |
transcription_chunk_ids = Enum.map(transcription.chunks, &%{id: &1.id})
|
| 21 |
|
|
|
|
|
|
|
| 22 |
initial_state = %{
|
| 23 |
current_recording_id: 0,
|
| 24 |
uploaded_file_name: nil,
|
| 25 |
status: :pending,
|
| 26 |
audio_pipeline: nil,
|
| 27 |
-
summary_keywords:
|
| 28 |
transcription: transcription,
|
| 29 |
transcriptions: list_transcriptions(session["current_user"]),
|
| 30 |
finalized_codes: []
|
|
@@ -149,10 +151,13 @@ defmodule MedicodeWeb.TranscriptionsLive.Show do
|
|
| 149 |
def handle_info({:transcription_updated, %{id: chunk_id}}, socket) do
|
| 150 |
transcription = get_transcription(socket.assigns.transcription.id)
|
| 151 |
|
|
|
|
|
|
|
| 152 |
socket =
|
| 153 |
socket
|
| 154 |
|> stream_insert(:chunk_ids, %{id: chunk_id})
|
| 155 |
|> assign(:transcription, transcription)
|
|
|
|
| 156 |
|
| 157 |
{:noreply, socket}
|
| 158 |
end
|
|
@@ -160,11 +165,13 @@ defmodule MedicodeWeb.TranscriptionsLive.Show do
|
|
| 160 |
def handle_info({:transcription_updated, transcription_id}, socket) do
|
| 161 |
transcription = get_transcription(transcription_id)
|
| 162 |
transcriptions = list_transcriptions(socket.assigns.current_user)
|
|
|
|
| 163 |
|
| 164 |
socket =
|
| 165 |
socket
|
| 166 |
|> assign(:transcription, transcription)
|
| 167 |
|> assign(:transcriptions, transcriptions)
|
|
|
|
| 168 |
|
| 169 |
{:noreply, socket}
|
| 170 |
end
|
|
|
|
| 19 |
|
| 20 |
transcription_chunk_ids = Enum.map(transcription.chunks, &%{id: &1.id})
|
| 21 |
|
| 22 |
+
summary_keywords = Transcriptions.list_transcription_summary_keywords(transcription.id)
|
| 23 |
+
|
| 24 |
initial_state = %{
|
| 25 |
current_recording_id: 0,
|
| 26 |
uploaded_file_name: nil,
|
| 27 |
status: :pending,
|
| 28 |
audio_pipeline: nil,
|
| 29 |
+
summary_keywords: summary_keywords,
|
| 30 |
transcription: transcription,
|
| 31 |
transcriptions: list_transcriptions(session["current_user"]),
|
| 32 |
finalized_codes: []
|
|
|
|
| 151 |
def handle_info({:transcription_updated, %{id: chunk_id}}, socket) do
|
| 152 |
transcription = get_transcription(socket.assigns.transcription.id)
|
| 153 |
|
| 154 |
+
summary_keywords = Transcriptions.list_transcription_summary_keywords(transcription.id)
|
| 155 |
+
|
| 156 |
socket =
|
| 157 |
socket
|
| 158 |
|> stream_insert(:chunk_ids, %{id: chunk_id})
|
| 159 |
|> assign(:transcription, transcription)
|
| 160 |
+
|> assign(:summary_keywords, summary_keywords)
|
| 161 |
|
| 162 |
{:noreply, socket}
|
| 163 |
end
|
|
|
|
| 165 |
def handle_info({:transcription_updated, transcription_id}, socket) do
|
| 166 |
transcription = get_transcription(transcription_id)
|
| 167 |
transcriptions = list_transcriptions(socket.assigns.current_user)
|
| 168 |
+
summary_keywords = Transcriptions.list_transcription_summary_keywords(transcription.id)
|
| 169 |
|
| 170 |
socket =
|
| 171 |
socket
|
| 172 |
|> assign(:transcription, transcription)
|
| 173 |
|> assign(:transcriptions, transcriptions)
|
| 174 |
+
|> assign(:summary_keywords, summary_keywords)
|
| 175 |
|
| 176 |
{:noreply, socket}
|
| 177 |
end
|