diff --git a/lib/api_web/controllers/get_hash.ex b/lib/api_web/controllers/get_hash.ex index e3f67a9..158b1ff 100644 --- a/lib/api_web/controllers/get_hash.ex +++ b/lib/api_web/controllers/get_hash.ex @@ -4,18 +4,22 @@ defmodule ApiWeb.GetHash do import Ecto.Query require Logger - def index(conn, %{"study" => study}) do + def index(conn, %{"study" => accessionnumber}) do Envar.load(".env") Envar.require_env_file(".env") + Logger.info("Accession get hash -> #{accessionnumber}") + studyidentifier = Envar.get("IDENTIFIERFIELD") || "IDSTUDY" + # En caso de recibir idstudy en get hash -> where: s.accessionnumber == ^String.to_integer(accessionnumber), + query = if studyidentifier == "IDSTUDY" do from s in "study", join: p in "patient", on: p.idpatient == s.idpatient, - where: s.idstudy == ^String.to_integer(study), + where: s.accessionnumber == ^accessionnumber, select: %{ idstudy: s.idstudy, patientid: p.patientid @@ -24,7 +28,7 @@ defmodule ApiWeb.GetHash do from s in "study", join: p in "patient", on: p.idpatient == s.idpatient, - where: s.accessionnumber == ^study, + where: s.accessionnumber == ^accessionnumber, select: %{ accessionnumber: s.accessionnumber, patientid: p.patientid