Seleccionar idstudy segun identifierfield para redirect
This commit is contained in:
@ -12,13 +12,6 @@ defmodule ApiWeb.Redirect do
|
||||
viewer_uid = Envar.get("imViewer4_uid")
|
||||
gethash = Envar.get("imViewer4_gethash")
|
||||
idsite = Envar.get("IDSITE")
|
||||
studyidentifier_ed = Envar.get("acceso_ed")
|
||||
|
||||
accession = studyidentifier = if studyidentifier_ed == "IDSTUDY" do
|
||||
String.to_integer(accession)
|
||||
else
|
||||
accession
|
||||
end
|
||||
|
||||
Logger.info("parametros: #{inspect(accession)}")
|
||||
|
||||
@ -79,7 +72,37 @@ defmodule ApiWeb.Redirect do
|
||||
defp open_imviewer4(v, accession, expiration) do
|
||||
url = v.gethash <> v.client_uuid
|
||||
|
||||
case Req.post(url, json: %{"accessionnumber" => accession, "expiration" => expiration}) do
|
||||
studyidentifier = Envar.get("IDENTIFIERFIELD") || "IDSTUDY"
|
||||
|
||||
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
|
||||
}
|
||||
end
|
||||
|
||||
idstudy = case Repo.one(query) do
|
||||
nil ->
|
||||
"nil"
|
||||
res ->
|
||||
res.idstudy
|
||||
end
|
||||
|
||||
idstudy_str = to_string(idstudy)
|
||||
|
||||
case Req.post(url, json: %{"idstudy" => idstudy_str, "expiration" => expiration}) do
|
||||
{:ok, %Req.Response{status: 200, body: %{"hash" => hash}}} ->
|
||||
{:ok, hash}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user