Commit ·
27f0329
1
Parent(s): 8eda717
chore: Remove unused HomeLive LV
Browse files
lib/medicode_web/live/home_live/index.ex
DELETED
|
@@ -1,101 +0,0 @@
|
|
| 1 |
-
defmodule MedicodeWeb.HomeLive.Index do
|
| 2 |
-
use MedicodeWeb, :live_view
|
| 3 |
-
|
| 4 |
-
alias Medicode.Transcriptions
|
| 5 |
-
|
| 6 |
-
@impl Phoenix.LiveView
|
| 7 |
-
def mount(_params, session, socket) do
|
| 8 |
-
if connected?(socket) do
|
| 9 |
-
Phoenix.PubSub.subscribe(:medicode_pubsub, "medicode:#{session["current_user"].id}")
|
| 10 |
-
end
|
| 11 |
-
|
| 12 |
-
socket =
|
| 13 |
-
socket
|
| 14 |
-
|> assign(:current_user, session["current_user"])
|
| 15 |
-
|> allow_upload(:audio, accept: ~w(.mp3), max_entries: 1)
|
| 16 |
-
|
| 17 |
-
{:ok, socket}
|
| 18 |
-
end
|
| 19 |
-
|
| 20 |
-
@impl Phoenix.LiveView
|
| 21 |
-
def render(assigns) do
|
| 22 |
-
~H"""
|
| 23 |
-
<div class="min-h-[calc(100vh-56px)] flex gap-5">
|
| 24 |
-
<.live_component
|
| 25 |
-
id="sidebar"
|
| 26 |
-
module={MedicodeWeb.Components.SidebarComponent}
|
| 27 |
-
current_user={@current_user}
|
| 28 |
-
/>
|
| 29 |
-
|
| 30 |
-
<main class="flex-1 pl-16 pr-16 pt-[25px]">
|
| 31 |
-
<div class="flex flex-col h-full mx-auto max-w-5xl">
|
| 32 |
-
<div class="flex-1 flex flex-col space-y-6">
|
| 33 |
-
<div class="flex-1 flex flex-col justify-center items-center gap-4">
|
| 34 |
-
<img src={~p"/images/logo.svg"} width="106" />
|
| 35 |
-
<p class="text-2xl leading-normal font-semibold">MediCode</p>
|
| 36 |
-
</div>
|
| 37 |
-
<.upload_form audio_upload={@uploads.audio} />
|
| 38 |
-
</div>
|
| 39 |
-
</div>
|
| 40 |
-
</main>
|
| 41 |
-
</div>
|
| 42 |
-
"""
|
| 43 |
-
end
|
| 44 |
-
|
| 45 |
-
@impl true
|
| 46 |
-
def handle_event("validate", _params, socket) do
|
| 47 |
-
{:noreply, socket}
|
| 48 |
-
end
|
| 49 |
-
|
| 50 |
-
def handle_event("save", _params, socket) do
|
| 51 |
-
if socket.assigns.uploads.audio.entries == [] do
|
| 52 |
-
{:noreply, put_flash(socket, :error, "Please select an audio file")}
|
| 53 |
-
else
|
| 54 |
-
_filename =
|
| 55 |
-
socket.assigns.uploads.audio.entries
|
| 56 |
-
|> Enum.at(0)
|
| 57 |
-
|> Map.get(:client_name)
|
| 58 |
-
|
| 59 |
-
uploaded_files =
|
| 60 |
-
consume_uploaded_entries(socket, :audio, fn %{path: path}, _entry ->
|
| 61 |
-
dest = Path.join(System.tmp_dir(), Path.basename(path))
|
| 62 |
-
File.cp!(path, dest)
|
| 63 |
-
{:ok, dest}
|
| 64 |
-
end)
|
| 65 |
-
|
| 66 |
-
{:ok, transcription} =
|
| 67 |
-
Transcriptions.create_transcription(%{
|
| 68 |
-
user_id: socket.assigns.current_user.id,
|
| 69 |
-
filename: Enum.at(uploaded_files, 0)
|
| 70 |
-
})
|
| 71 |
-
|
| 72 |
-
Phoenix.PubSub.broadcast(
|
| 73 |
-
:medicode_pubsub,
|
| 74 |
-
"medicode:#{socket.assigns.current_user.id}",
|
| 75 |
-
{:transcription_created, transcription.id}
|
| 76 |
-
)
|
| 77 |
-
|
| 78 |
-
Transcriptions.transcribe_audio(transcription)
|
| 79 |
-
|
| 80 |
-
{:noreply, push_navigate(socket, to: ~p"/transcriptions/#{transcription.id}")}
|
| 81 |
-
end
|
| 82 |
-
end
|
| 83 |
-
|
| 84 |
-
@impl true
|
| 85 |
-
def handle_info({:transcription_updated, transcription_id}, socket) do
|
| 86 |
-
transcription = get_transcription(transcription_id)
|
| 87 |
-
|
| 88 |
-
socket =
|
| 89 |
-
socket
|
| 90 |
-
|> assign(:transcription, transcription)
|
| 91 |
-
|
| 92 |
-
{:noreply, socket}
|
| 93 |
-
end
|
| 94 |
-
|
| 95 |
-
def error_to_string(:too_large), do: "Too large"
|
| 96 |
-
def error_to_string(:not_accepted), do: "You have selected an unacceptable file type"
|
| 97 |
-
|
| 98 |
-
defp get_transcription(id) do
|
| 99 |
-
Transcriptions.get_transcription(id, true)
|
| 100 |
-
end
|
| 101 |
-
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/medicode_web/live/home_live/sample_results.ex
DELETED
|
@@ -1,94 +0,0 @@
|
|
| 1 |
-
defmodule MedicodeWeb.HomeLive.Index.SampleResults do
|
| 2 |
-
@moduledoc """
|
| 3 |
-
Contains sample data that can be displayed in HomeLive for prototyping UI.
|
| 4 |
-
|
| 5 |
-
To test the success UI, replace the status assignment with:
|
| 6 |
-
|
| 7 |
-
status: :success
|
| 8 |
-
|
| 9 |
-
And the `chunks` stream with:
|
| 10 |
-
|
| 11 |
-
|> stream(:chunks, MedicodeWeb.HomeLive.Index.SampleResults.get_sample_results())
|
| 12 |
-
"""
|
| 13 |
-
|
| 14 |
-
alias AudioTagger.Structs.TagResult
|
| 15 |
-
|
| 16 |
-
def get_sample_results do
|
| 17 |
-
[
|
| 18 |
-
%{
|
| 19 |
-
id: 0,
|
| 20 |
-
start_mark: "00:00:00",
|
| 21 |
-
end_mark: "00:00:07",
|
| 22 |
-
text:
|
| 23 |
-
"This 55-year-old man with known coronary artery disease comes for a follow-up visit today.",
|
| 24 |
-
tags: [
|
| 25 |
-
%TagResult{
|
| 26 |
-
code: "74685",
|
| 27 |
-
label: "Coronary artery anomaly",
|
| 28 |
-
score: 0.892520010471344
|
| 29 |
-
},
|
| 30 |
-
%TagResult{
|
| 31 |
-
code: "41412",
|
| 32 |
-
label: "Dissection of coronary artery",
|
| 33 |
-
score: 0.8386646509170532
|
| 34 |
-
},
|
| 35 |
-
%TagResult{
|
| 36 |
-
code: "V717",
|
| 37 |
-
label: "Observation for suspected cardiovascular disease",
|
| 38 |
-
score: 0.8203237056732178
|
| 39 |
-
},
|
| 40 |
-
%TagResult{
|
| 41 |
-
code: "41400",
|
| 42 |
-
label: "Coronary atherosclerosis of unspecified type of vessel, native or graft",
|
| 43 |
-
score: 0.8200777173042297
|
| 44 |
-
},
|
| 45 |
-
%TagResult{
|
| 46 |
-
code: "V812",
|
| 47 |
-
label: "Screening for other and unspecified cardiovascular conditions",
|
| 48 |
-
score: 0.8076164722442627
|
| 49 |
-
}
|
| 50 |
-
]
|
| 51 |
-
},
|
| 52 |
-
%{
|
| 53 |
-
id: 1,
|
| 54 |
-
start_mark: "00:00:07",
|
| 55 |
-
end_mark: "00:00:11",
|
| 56 |
-
text: "Last month he was admitted to our hospital with unstable angina.",
|
| 57 |
-
tags: [
|
| 58 |
-
%TagResult{code: "4381", label: "Angiopathy in other dis", score: 0.8538626432418823},
|
| 59 |
-
%TagResult{code: "131", label: "Prinzmetal angina", score: 0.8411313891410828},
|
| 60 |
-
%TagResult{code: "130", label: "Angina decubitus", score: 0.8362892270088196},
|
| 61 |
-
%TagResult{code: "6985", label: "Angio intes w hmrhg", score: 0.8048261404037476},
|
| 62 |
-
%TagResult{code: "139", label: "Angina pectoris NEC/NOS", score: 0.7996218800544739}
|
| 63 |
-
]
|
| 64 |
-
},
|
| 65 |
-
%{
|
| 66 |
-
id: 2,
|
| 67 |
-
start_mark: "00:00:11",
|
| 68 |
-
end_mark: "00:00:15",
|
| 69 |
-
text: "He underwent heart catheterization on November 15th, 2007.",
|
| 70 |
-
tags: [
|
| 71 |
-
%TagResult{code: "8716", label: "FB post heart catheter", score: 0.8772457242012024},
|
| 72 |
-
%TagResult{code: "8705", label: "Acc cut/hem w catheteriz", score: 0.8552037477493286},
|
| 73 |
-
%TagResult{code: "5881", label: "Fit/adj vascular cathetr", score: 0.8404607772827148},
|
| 74 |
-
%TagResult{code: "6112", label: "Heart laceration-open", score: 0.834895133972168},
|
| 75 |
-
%TagResult{code: "6102", label: "Heart laceration-closed", score: 0.8253614902496338}
|
| 76 |
-
]
|
| 77 |
-
},
|
| 78 |
-
%{
|
| 79 |
-
id: 3,
|
| 80 |
-
start_mark: "00:00:15",
|
| 81 |
-
end_mark: "00:00:22",
|
| 82 |
-
text:
|
| 83 |
-
"At that time he was found to have a tight 99% proxmost enosis, total occlusion and collateralization",
|
| 84 |
-
tags: [
|
| 85 |
-
%TagResult{code: "641", label: "No proc/contraindication", score: 0.8215043544769287},
|
| 86 |
-
%TagResult{code: "643", label: "No proc for reasons NEC", score: 0.8145027160644531},
|
| 87 |
-
%TagResult{code: "416", label: "Proteus infection NOS", score: 0.8083868622779846},
|
| 88 |
-
%TagResult{code: "019", label: "Prostatitis NOS", score: 0.8061345815658569},
|
| 89 |
-
%TagResult{code: "5270", label: "Prolapsed arm-unspec", score: 0.8031538128852844}
|
| 90 |
-
]
|
| 91 |
-
}
|
| 92 |
-
]
|
| 93 |
-
end
|
| 94 |
-
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/medicode_web/router.ex
CHANGED
|
@@ -83,7 +83,6 @@ defmodule MedicodeWeb.Router do
|
|
| 83 |
on_mount: [{MedicodeWeb.UserAuth, :ensure_authenticated}] do
|
| 84 |
live "/users/settings", UserSettingsLive, :edit
|
| 85 |
live "/users/settings/confirm_email/:token", UserSettingsLive, :confirm_email
|
| 86 |
-
# live "/", HomeLive.Index
|
| 87 |
live "/", TranscriptionsLive.Show
|
| 88 |
live "/transcriptions/:id", TranscriptionsLive.Show
|
| 89 |
end
|
|
|
|
| 83 |
on_mount: [{MedicodeWeb.UserAuth, :ensure_authenticated}] do
|
| 84 |
live "/users/settings", UserSettingsLive, :edit
|
| 85 |
live "/users/settings/confirm_email/:token", UserSettingsLive, :confirm_email
|
|
|
|
| 86 |
live "/", TranscriptionsLive.Show
|
| 87 |
live "/transcriptions/:id", TranscriptionsLive.Show
|
| 88 |
end
|
test/medicode_web/live/home_live_test.exs
DELETED
|
@@ -1,64 +0,0 @@
|
|
| 1 |
-
defmodule MedicodeWeb.HomeLiveTest do
|
| 2 |
-
use MedicodeWeb.ConnCase, async: true
|
| 3 |
-
|
| 4 |
-
import Ecto.Query
|
| 5 |
-
import Medicode.AccountsFixtures
|
| 6 |
-
import Phoenix.LiveViewTest
|
| 7 |
-
|
| 8 |
-
alias Medicode.Repo
|
| 9 |
-
alias Medicode.Transcriptions.Transcription
|
| 10 |
-
|
| 11 |
-
setup %{conn: conn} do
|
| 12 |
-
password = valid_user_password()
|
| 13 |
-
user = user_fixture(%{password: password})
|
| 14 |
-
%{conn: log_in_user(conn, user), current_user: user}
|
| 15 |
-
end
|
| 16 |
-
|
| 17 |
-
describe "/" do
|
| 18 |
-
test "renders upload screen", %{conn: conn, current_user: current_user} do
|
| 19 |
-
# 1. Find file input
|
| 20 |
-
# 2. Upload file
|
| 21 |
-
# 3. Click submit
|
| 22 |
-
# 4. Assert we see text
|
| 23 |
-
# 5. Assert we see codes alongside text
|
| 24 |
-
|
| 25 |
-
# TODO: Ensure that we're testing both the non-live and live versions here.
|
| 26 |
-
conn = get(conn, "/")
|
| 27 |
-
assert html_response(conn, 200) =~ "MediCode"
|
| 28 |
-
|
| 29 |
-
{:ok, view, html} = live(conn)
|
| 30 |
-
assert html =~ "Audio file can be .mp3"
|
| 31 |
-
|
| 32 |
-
sample_file =
|
| 33 |
-
__DIR__
|
| 34 |
-
|> Path.join("../../../medasrdemo-Paul.mp3")
|
| 35 |
-
|> Path.expand()
|
| 36 |
-
|
| 37 |
-
audio =
|
| 38 |
-
file_input(view, "#audio-form", :audio, [
|
| 39 |
-
%{
|
| 40 |
-
last_modified: 1_594_171_879_000,
|
| 41 |
-
name: "sample.mp3",
|
| 42 |
-
content: File.read!(sample_file),
|
| 43 |
-
size: 992_980,
|
| 44 |
-
type: "audio/mp3"
|
| 45 |
-
}
|
| 46 |
-
])
|
| 47 |
-
|
| 48 |
-
render_upload(audio, "sample.mp3")
|
| 49 |
-
|
| 50 |
-
view
|
| 51 |
-
|> form("#audio-form")
|
| 52 |
-
|> render_submit()
|
| 53 |
-
|
| 54 |
-
transcription =
|
| 55 |
-
Transcription
|
| 56 |
-
|> where([t], t.user_id == ^current_user.id)
|
| 57 |
-
|> order_by(desc: :inserted_at)
|
| 58 |
-
|> limit(1)
|
| 59 |
-
|> Repo.one()
|
| 60 |
-
|
| 61 |
-
assert_redirected(view, ~p"/transcriptions/#{transcription.id}")
|
| 62 |
-
end
|
| 63 |
-
end
|
| 64 |
-
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|