Seleccionar idstudy segun identifierfield para redirect

This commit is contained in:
2025-10-28 09:46:50 -03:00
parent 513bdcbb67
commit 5c0d6cf828

View File

@ -1,6 +1,8 @@
defmodule ApiWeb.Redirect do
use ApiWeb, :controller
require Logger
alias Api.Repo
import Ecto.Query
def index(conn, %{"accession" => accession}) do
Envar.load(".env")
@ -77,16 +79,12 @@ defmodule ApiWeb.Redirect do
query =
if studyidentifier == "IDSTUDY" do
from s in "study",
join: p in "patient",
on: p.idpatient == s.idpatient,
where: s.accessionnumber == ^accessionnumber,
select: %{
idstudy: s.idstudy
}
else
from s in "study",
join: p in "patient",
on: p.idpatient == s.idpatient,
where: s.accessionnumber == ^accessionnumber,
select: %{
idstudy: s.idstudy