Commit
•
65843fa
1
Parent(s):
628c254
feat: Highlight weighted feedback
Browse files
lib/medical_transcription/coding.ex
CHANGED
@@ -78,19 +78,25 @@ defmodule MedicalTranscription.Coding do
|
|
78 |
relevant_feedback =
|
79 |
Enum.find(past_feedbacks, &(&1.code_vector_id == code_vector_match.id))
|
80 |
|
81 |
-
|
82 |
case relevant_feedback do
|
83 |
nil ->
|
84 |
-
|
85 |
|
86 |
%{response: true} ->
|
87 |
-
|
|
|
|
|
|
|
88 |
|
89 |
%{response: false} ->
|
90 |
-
|
|
|
|
|
|
|
91 |
end
|
92 |
|
93 |
-
|
94 |
end)
|
95 |
end
|
96 |
|
|
|
78 |
relevant_feedback =
|
79 |
Enum.find(past_feedbacks, &(&1.code_vector_id == code_vector_match.id))
|
80 |
|
81 |
+
new_attributes =
|
82 |
case relevant_feedback do
|
83 |
nil ->
|
84 |
+
%{weighting: :none}
|
85 |
|
86 |
%{response: true} ->
|
87 |
+
%{
|
88 |
+
cosine_similarity: cosine_similarity * @positive_response_factor,
|
89 |
+
weighting: :positive
|
90 |
+
}
|
91 |
|
92 |
%{response: false} ->
|
93 |
+
%{
|
94 |
+
cosine_similarity: cosine_similarity * @negative_response_factor,
|
95 |
+
weighting: :negative
|
96 |
+
}
|
97 |
end
|
98 |
|
99 |
+
Map.merge(code_vector_match, new_attributes)
|
100 |
end)
|
101 |
end
|
102 |
|
lib/medical_transcription/coding/code_vector_match.ex
CHANGED
@@ -2,5 +2,5 @@ defmodule MedicalTranscription.Coding.CodeVectorMatch do
|
|
2 |
@moduledoc """
|
3 |
Represents a vector match found in the database, along with its similarity score.
|
4 |
"""
|
5 |
-
defstruct [:id, :code, :description, :cosine_similarity]
|
6 |
end
|
|
|
2 |
@moduledoc """
|
3 |
Represents a vector match found in the database, along with its similarity score.
|
4 |
"""
|
5 |
+
defstruct [:id, :code, :description, :cosine_similarity, :weighting]
|
6 |
end
|
lib/medical_transcription_web/components/components.ex
CHANGED
@@ -159,8 +159,8 @@ defmodule MedicalTranscriptionWeb.Components do
|
|
159 |
<div class="w-1 h-full border-l border-[#444444]/20"></div>
|
160 |
<div
|
161 |
class={"flex flex-col gap-1 font-secondary text-type-black-primary ml-4 p-1 rounded
|
162 |
-
#{if @
|
163 |
-
#{if @
|
164 |
"}
|
165 |
title={"Similarity score: #{trunc(@score * 100) / 100}"}
|
166 |
>
|
|
|
159 |
<div class="w-1 h-full border-l border-[#444444]/20"></div>
|
160 |
<div
|
161 |
class={"flex flex-col gap-1 font-secondary text-type-black-primary ml-4 p-1 rounded
|
162 |
+
#{if @weighting == :positive, do: "bg-emerald-200"}
|
163 |
+
#{if @weighting == :negative, do: "bg-red-200"}
|
164 |
"}
|
165 |
title={"Similarity score: #{trunc(@score * 100) / 100}"}
|
166 |
>
|
lib/medical_transcription_web/components/transcription_text_component.ex
CHANGED
@@ -56,14 +56,14 @@ defmodule MedicalTranscriptionWeb.Components.TranscriptionTextComponent do
|
|
56 |
</div>
|
57 |
|
58 |
<div class="flex-1 flex flex-col items-stretch gap-3">
|
59 |
-
<%= for %CodeVectorMatch{id: id, code: code, description: label, cosine_similarity: score} <- @row.tags do %>
|
60 |
<.tag_result
|
61 |
code_vector_id={id}
|
62 |
code={code}
|
63 |
label={label}
|
64 |
score={score}
|
65 |
text={@row.text}
|
66 |
-
|
67 |
/>
|
68 |
<% end %>
|
69 |
</div>
|
|
|
56 |
</div>
|
57 |
|
58 |
<div class="flex-1 flex flex-col items-stretch gap-3">
|
59 |
+
<%= for %CodeVectorMatch{id: id, code: code, description: label, cosine_similarity: score, weighting: weighting} <- @row.tags do %>
|
60 |
<.tag_result
|
61 |
code_vector_id={id}
|
62 |
code={code}
|
63 |
label={label}
|
64 |
score={score}
|
65 |
text={@row.text}
|
66 |
+
weighting={weighting}
|
67 |
/>
|
68 |
<% end %>
|
69 |
</div>
|