Configuracion ImViewer4 desde .env
This commit is contained in:
9
.env
9
.env
@ -22,6 +22,15 @@ ADJUNTOS_CLAVE=1nf0rm3
|
|||||||
acceso_ed=IDSTUDY
|
acceso_ed=IDSTUDY
|
||||||
IDENTIFIERFIELD=IDSTUDY
|
IDENTIFIERFIELD=IDSTUDY
|
||||||
|
|
||||||
|
# ImViewer4
|
||||||
|
# Si es 1, se usa imViewer4, si es 0 se usa el viewer viejo
|
||||||
|
imViewer4=0
|
||||||
|
# Si usa ImViewer4, se debe agregar el dominio sin https://
|
||||||
|
# Ejemplo: imViewer4_host=informesmedicos.apross.gov.ar
|
||||||
|
# imViewer4_host=informesmedicos.apross.gov.ar
|
||||||
|
# Si usa ImViewer4, se debe agregar el uid del cliente
|
||||||
|
# imViewer4_uid=aab2741a-6b94-4c72-ad29-bf0ca8e492f7
|
||||||
|
|
||||||
# Datos SMTP/Mailer
|
# Datos SMTP/Mailer
|
||||||
#SMTP_USER=informes@ciem.com.ar
|
#SMTP_USER=informes@ciem.com.ar
|
||||||
#SMTP_PASS=OC{j9YZ0PB-x
|
#SMTP_PASS=OC{j9YZ0PB-x
|
||||||
|
@ -139,23 +139,30 @@ defmodule ApiWeb.IndexLive do
|
|||||||
Repo.all(query)
|
Repo.all(query)
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_token(idstudy, patientid) do
|
def generate_token(studyidentifier_type, studyidentifier, patientid) do
|
||||||
Envar.load(".env")
|
idstudy = if studyidentifier_type == "IDSTUDY" do
|
||||||
Envar.require_env_file(".env")
|
# El tipo es IDSTUDY
|
||||||
# Paso 1: Armar json con fecha de vencimiento (puse 2 días)
|
studyidentifier
|
||||||
json = if Envar.get("IDENTIFIERFIELD") == "IDSTUDY" do
|
|
||||||
%{
|
|
||||||
idstudy: Integer.to_string(idstudy),
|
|
||||||
patientid: patientid,
|
|
||||||
vencimiento: DateTime.add(DateTime.utc_now(), 2 * 24 * 60 * 60, :second)
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
%{
|
# El tipo es ACCESSIONNUMBER
|
||||||
accessionnumber: idstudy,
|
query = from s in "study",
|
||||||
patientid: patientid,
|
where: s.accessionnumber == ^studyidentifier,
|
||||||
vencimiento: DateTime.add(DateTime.utc_now(), 2 * 24 * 60 * 60, :second)
|
select: s.idstudy
|
||||||
}
|
|
||||||
|
case Repo.one(query) do
|
||||||
|
nil -> {:error, "No se encontró idstudy para el acccessionnumer: #{studyidentifier}"}
|
||||||
|
idstudy -> idstudy
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Paso 1: Armar json con fecha de vencimiento (puse 2 días)
|
||||||
|
json =
|
||||||
|
%{
|
||||||
|
idstudy: Integer.to_string(idstudy),
|
||||||
|
patientid: patientid,
|
||||||
|
vencimiento: DateTime.add(DateTime.utc_now(), 2 * 24 * 60 * 60, :second)
|
||||||
|
}
|
||||||
|
|
||||||
# Paso 2: Convertir json a string
|
# Paso 2: Convertir json a string
|
||||||
json_string = Jason.encode!(json)
|
json_string = Jason.encode!(json)
|
||||||
|
|
||||||
@ -168,6 +175,65 @@ defmodule ApiWeb.IndexLive do
|
|||||||
token
|
token
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def generate_token_imv4(studyidentifier_type, studyidentifier, username) do
|
||||||
|
idstudy = if studyidentifier_type == "IDSTUDY" do
|
||||||
|
# El tipo es IDSTUDY
|
||||||
|
studyidentifier
|
||||||
|
else
|
||||||
|
# El tipo es ACCESSIONNUMBER
|
||||||
|
query = from s in "study",
|
||||||
|
where: s.accessionnumber == ^studyidentifier,
|
||||||
|
select: s.idstudy
|
||||||
|
|
||||||
|
case Repo.one(query) do
|
||||||
|
nil -> {:error, "No se encontró idstudy para el acccessionnumer: #{studyidentifier}"}
|
||||||
|
idstudy -> Logger.info("idstudy encontrado: #{idstudy}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
json = %{
|
||||||
|
idstudy: Integer.to_string(idstudy),
|
||||||
|
username: username,
|
||||||
|
vencimiento: DateTime.add(DateTime.utc_now(), 2 * 24 * 60 * 60, :second)
|
||||||
|
}
|
||||||
|
|
||||||
|
json_string_64 = Jason.encode!(json) |> Base.encode64()
|
||||||
|
query_json = "select encrypt('#{json_string_64}'::bytea, '1nf0rm3', 'aes')::text"
|
||||||
|
token = Repo.query!(query_json).rows |> hd() |> hd()
|
||||||
|
token = String.replace_prefix(token, "\\x", "")
|
||||||
|
token
|
||||||
|
end
|
||||||
|
|
||||||
|
def open_viewer(idstudy, accessionnumber, patientid, assigns) do
|
||||||
|
Envar.load(".env")
|
||||||
|
Envar.require_env_file(".env")
|
||||||
|
studyidentifier_ed = Envar.get("acceso_ed")
|
||||||
|
viewer = Envar.get("imViewer4")
|
||||||
|
viewer_host = Envar.get("imViewer4_host")
|
||||||
|
viewer_uid = Envar.get("imViewer4_uid")
|
||||||
|
|
||||||
|
studyidentifier = if studyidentifier_ed == "IDSTUDY" do
|
||||||
|
idstudy
|
||||||
|
else
|
||||||
|
accessionnumber
|
||||||
|
end
|
||||||
|
|
||||||
|
query =
|
||||||
|
from u in "users",
|
||||||
|
select: %{
|
||||||
|
username: u.username
|
||||||
|
},
|
||||||
|
limit: 1
|
||||||
|
|
||||||
|
username = Repo.one(query)
|
||||||
|
|
||||||
|
case viewer do
|
||||||
|
"1" -> "https://#{viewer_host}/viewer/#{viewer_uid}/#{generate_token_imv4(studyidentifier_ed, studyidentifier, username)}"
|
||||||
|
"0" -> "https://estudio.informemedico.com.ar/#/#{assigns.idsite}/#{generate_token(studyidentifier_ed, studyidentifier, patientid)}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def render(assigns) do
|
def render(assigns) do
|
||||||
~H"""
|
~H"""
|
||||||
<body class="m-0 p-0 bg-[rgb(228, 228, 228)]">
|
<body class="m-0 p-0 bg-[rgb(228, 228, 228)]">
|
||||||
@ -281,14 +347,14 @@ defmodule ApiWeb.IndexLive do
|
|||||||
</a>
|
</a>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= if assigns.idstudyfield == true do %>
|
<%= if assigns.idstudyfield == true do %>
|
||||||
<a href={"https://estudio.informemedico.com.ar/#/#{assigns.idsite}/#{generate_token(study.idstudy, @dni)}"} target="_blank" class="ml-2 flex items-center" style="flex-direction: column;">
|
<a href={open_viewer(study.idstudy, study.accession, @dni, assigns)} target="_blank" class="ml-2 flex items-center" style="flex-direction: column;">
|
||||||
<svg class="w-12 h-12 text-[#297177] hover:text-[#4d9aa2]" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
<svg class="w-12 h-12 text-[#297177] hover:text-[#4d9aa2]" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||||
<path fill-rule="evenodd" d="M9 2.221V7H4.221a2 2 0 0 1 .365-.5L8.5 2.586A2 2 0 0 1 9 2.22ZM11 2v5a2 2 0 0 1-2 2H4v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2h-7Zm.394 9.553a1 1 0 0 0-1.817.062l-2.5 6A1 1 0 0 0 8 19h8a1 1 0 0 0 .894-1.447l-2-4A1 1 0 0 0 13.2 13.4l-.53.706-1.276-2.553ZM13 9.5a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0Z" clip-rule="evenodd"/>
|
<path fill-rule="evenodd" d="M9 2.221V7H4.221a2 2 0 0 1 .365-.5L8.5 2.586A2 2 0 0 1 9 2.22ZM11 2v5a2 2 0 0 1-2 2H4v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2h-7Zm.394 9.553a1 1 0 0 0-1.817.062l-2.5 6A1 1 0 0 0 8 19h8a1 1 0 0 0 .894-1.447l-2-4A1 1 0 0 0 13.2 13.4l-.53.706-1.276-2.553ZM13 9.5a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0Z" clip-rule="evenodd"/>
|
||||||
</svg>
|
</svg>
|
||||||
<p class="text-[12px]">Imágenes</p>
|
<p class="text-[12px]">Imágenes</p>
|
||||||
</a>
|
</a>
|
||||||
<% else %>
|
<% else %>
|
||||||
<a href={"https://estudio.informemedico.com.ar/#/#{assigns.idsite}/#{generate_token(study.accession, @dni)}"} target="_blank" class="ml-2 flex items-center" style="flex-direction: column;">
|
<a href={open_viewer(study.idstudy, study.accession, @dni, assigns)} target="_blank" class="ml-2 flex items-center" style="flex-direction: column;">
|
||||||
<svg class="w-12 h-12 text-[#297177] hover:text-[#4d9aa2]" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
<svg class="w-12 h-12 text-[#297177] hover:text-[#4d9aa2]" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||||
<path fill-rule="evenodd" d="M9 2.221V7H4.221a2 2 0 0 1 .365-.5L8.5 2.586A2 2 0 0 1 9 2.22ZM11 2v5a2 2 0 0 1-2 2H4v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2h-7Zm.394 9.553a1 1 0 0 0-1.817.062l-2.5 6A1 1 0 0 0 8 19h8a1 1 0 0 0 .894-1.447l-2-4A1 1 0 0 0 13.2 13.4l-.53.706-1.276-2.553ZM13 9.5a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0Z" clip-rule="evenodd"/>
|
<path fill-rule="evenodd" d="M9 2.221V7H4.221a2 2 0 0 1 .365-.5L8.5 2.586A2 2 0 0 1 9 2.22ZM11 2v5a2 2 0 0 1-2 2H4v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2h-7Zm.394 9.553a1 1 0 0 0-1.817.062l-2.5 6A1 1 0 0 0 8 19h8a1 1 0 0 0 .894-1.447l-2-4A1 1 0 0 0 13.2 13.4l-.53.706-1.276-2.553ZM13 9.5a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0Z" clip-rule="evenodd"/>
|
||||||
</svg>
|
</svg>
|
||||||
@ -314,13 +380,13 @@ defmodule ApiWeb.IndexLive do
|
|||||||
</td>
|
</td>
|
||||||
<td class="px-6 py-4 whitespace-nowrap hidden md:block md:table-cell">
|
<td class="px-6 py-4 whitespace-nowrap hidden md:block md:table-cell">
|
||||||
<%= if assigns.idstudyfield == true do %>
|
<%= if assigns.idstudyfield == true do %>
|
||||||
<a href={"https://estudio.informemedico.com.ar/#/#{assigns.idsite}/#{generate_token(study.idstudy, @dni)}"} target="_blank">
|
<a href={open_viewer(study.idstudy, study.accession, @dni, assigns)} target="_blank">
|
||||||
<svg class="w-12 h-12 text-[#297177] hover:text-[#4d9aa2]" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24">
|
<svg class="w-12 h-12 text-[#297177] hover:text-[#4d9aa2]" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24">
|
||||||
<path fill-rule="evenodd" d="M9 2.221V7H4.221a2 2 0 0 1 .365-.5L8.5 2.586A2 2 0 0 1 9 2.22ZM11 2v5a2 2 0 0 1-2 2H4v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2h-7Zm.394 9.553a1 1 0 0 0-1.817.062l-2.5 6A1 1 0 0 0 8 19h8a1 1 0 0 0 .894-1.447l-2-4A1 1 0 0 0 13.2 13.4l-.53.706-1.276-2.553ZM13 9.5a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0Z" clip-rule="evenodd"/>
|
<path fill-rule="evenodd" d="M9 2.221V7H4.221a2 2 0 0 1 .365-.5L8.5 2.586A2 2 0 0 1 9 2.22ZM11 2v5a2 2 0 0 1-2 2H4v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2h-7Zm.394 9.553a1 1 0 0 0-1.817.062l-2.5 6A1 1 0 0 0 8 19h8a1 1 0 0 0 .894-1.447l-2-4A1 1 0 0 0 13.2 13.4l-.53.706-1.276-2.553ZM13 9.5a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0Z" clip-rule="evenodd"/>
|
||||||
</svg>
|
</svg>
|
||||||
</a>
|
</a>
|
||||||
<% else %>
|
<% else %>
|
||||||
<a href={"https://estudio.informemedico.com.ar/#/#{assigns.idsite}/#{generate_token(study.accession, @dni)}"} target="_blank">
|
<a href={open_viewer(study.idstudy, study.accession, @dni, assigns)} target="_blank">
|
||||||
<svg class="w-12 h-12 text-[#297177] hover:text-[#4d9aa2]" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24">
|
<svg class="w-12 h-12 text-[#297177] hover:text-[#4d9aa2]" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24">
|
||||||
<path fill-rule="evenodd" d="M9 2.221V7H4.221a2 2 0 0 1 .365-.5L8.5 2.586A2 2 0 0 1 9 2.22ZM11 2v5a2 2 0 0 1-2 2H4v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2h-7Zm.394 9.553a1 1 0 0 0-1.817.062l-2.5 6A1 1 0 0 0 8 19h8a1 1 0 0 0 .894-1.447l-2-4A1 1 0 0 0 13.2 13.4l-.53.706-1.276-2.553ZM13 9.5a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0Z" clip-rule="evenodd"/>
|
<path fill-rule="evenodd" d="M9 2.221V7H4.221a2 2 0 0 1 .365-.5L8.5 2.586A2 2 0 0 1 9 2.22ZM11 2v5a2 2 0 0 1-2 2H4v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2h-7Zm.394 9.553a1 1 0 0 0-1.817.062l-2.5 6A1 1 0 0 0 8 19h8a1 1 0 0 0 .894-1.447l-2-4A1 1 0 0 0 13.2 13.4l-.53.706-1.276-2.553ZM13 9.5a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0Z" clip-rule="evenodd"/>
|
||||||
</svg>
|
</svg>
|
||||||
|
Reference in New Issue
Block a user