|
defmodule MedicodeWeb.Storybook.TranscriptionTextComponent do |
|
use PhoenixStorybook.Story, :live_component |
|
|
|
import Ecto.Query |
|
|
|
alias Medicode.Accounts.User |
|
alias Medicode.Coding.CodeVector |
|
alias Medicode.Feedback.CodeFeedback |
|
alias Medicode.Transcriptions.TranscriptionChunk |
|
alias Medicode.Transcriptions.TranscriptionChunkCodeVector |
|
|
|
def component, do: MedicodeWeb.Components.TranscriptionTextComponent |
|
|
|
def variations do |
|
query = |
|
from chunk in TranscriptionChunk, |
|
order_by: [desc: chunk.inserted_at], |
|
limit: 1 |
|
|
|
chunk = Medicode.Repo.one(query) |
|
|
|
query = from user in User, limit: 1 |
|
user = Medicode.Repo.one(query) |
|
|
|
if is_nil(chunk) do |
|
[] |
|
else |
|
[ |
|
%Variation{ |
|
id: :default, |
|
attributes: %{ |
|
chunk_id: chunk.id, |
|
chunk: chunk, |
|
current_user: user, |
|
myself: Ecto.UUID.generate(), |
|
code_vectors_with_feedback: [ |
|
{ |
|
%TranscriptionChunkCodeVector{ |
|
code_vector: %CodeVector{ |
|
id: 1, |
|
code: "74685", |
|
description: "Coronary artery anomaly" |
|
} |
|
}, |
|
feedback: nil |
|
} |
|
], |
|
start_mark: "00:00:00", |
|
end_mark: "00:00:07", |
|
text: |
|
"This 55-year-old man with known coronary artery disease comes for a follow-up visit today. ", |
|
on_feedback: fn -> nil end, |
|
on_remove_code: fn -> nil end, |
|
on_finalize_code: fn -> nil end |
|
} |
|
} |
|
] |
|
end |
|
end |
|
end |
|
|