diff --git a/README.md b/README.md index f8975f4..1c0b876 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,159 @@ -# Api +# 馃摝 Instalaci贸n API V2 -To start your Phoenix server: +## 馃О Paso 1: Verificar el sistema operativo - * Run `mix setup` to install and setup dependencies - * Start Phoenix endpoint with `mix phx.server` or inside IEx with `iex -S mix phx.server` +Asegurarse de conocer la versi贸n del sistema operativo del cliente (por ejemplo, FreeBSD 13.1). Para poder elegir el compilado correcto. -Now you can visit [`localhost:4000`](http://localhost:4000) from your browser. +En ese caso el c贸digo fuente estar谩 en: -Ready to run in production? Please [check our deployment guides](https://hexdocs.pm/phoenix/deployment.html). +```bash +ssh -p 2229 informemedico@gitea.informemedico.com.ar -## Learn more +cd /home/informemedico/api-13-4/api-v2/ - * Official website: https://www.phoenixframework.org/ - * Guides: https://hexdocs.pm/phoenix/overview.html - * Docs: https://hexdocs.pm/phoenix - * Forum: https://elixirforum.com/c/phoenix-forum - * Source: https://github.com/phoenixframework/phoenix +``` + +--- + +## 馃搧 Paso 2: Copiar ejecutables al servidor del cliente + +Ejecutar el siguiente comando desde el servidor del cliente para copiar los archivos necesarios: + +```bash +rsync -av -e "ssh -p 2229" informemedico@gitea.informemedico.com.ar:'/home/informemedico/api-13-4/api-v2/_build/prod/rel/api/*' /home/informemedico/api/ +``` + +--- + +## 鈿欙笍 Paso 3: Crear archivo `.env` + +Ubicarse en: + +```bash +cd /home/informemedico/api/bin/ +``` + +Y crear un archivo `.env` con las siguientes variables (reemplazar con los datos correctos): + +```dotenv +# Datos de compilaci贸n +SECRET_KEY_BASE=9EtSIp/X8RGSgHIznn5J5GDxdwUr5oWMjRgK4tOLGIoh2IitPoI7yHx2ZIlLyGnv +DATABASE_URL=ecto://postgres:1nf0rm3@127.0.0.1/dicomscp +CHECK_ORIGIN=https://clinicadelsol.informemedico.com.ar:4443 +PHX_PORT=4001 +PHX_HOST=127.0.0.1 +ROOT_PATH=/api +#PORT=443 +SCHEME=https + +# Datos consultas +PYTHON_EXECUTABLE=/usr/local/bin/python3.11 +PYTHON_SCRIPT=/home/informemedico/cgi/soffice/generar_pdf_ed.py +TEMPLATE_NAME=con membrete +pr2_statusname=FINAL +IDSITE=226 +ESCANEADOS=https://clinicadelsol.informemedico.com.ar:4443/# +acceso_ed=IDSTUDY +IDENTIFIERFIELD=IDSTUDY + +# Datos SMTP/Mailer +#SMTP_USER= +#SMTP_PASS= +#SMTP_RELAY= +#EMAIL_BODY_PATH= +#SERVER_NAME_INDICATION= +FROM=Clinica del Sol # Esta se usa para el title de la p谩gina + +# Imagenes +LOGO=https://clinicadelsol.informemedico.com.ar:4443/cgi-bin/impacs.bf/get_logo +LOGO_SM=https://clinicadelsol.informemedico.com.ar:4443/api/images/clinsol_logo_sm.png +``` + +--- + +## 馃悕 Paso 4: Copiar y adaptar script `generar_pdf.py` + +Copiar el script que usa **imPACS** a la nueva ubicaci贸n: + +```bash +cp /ruta/soffice/generar_pdf.py /ruta/soffice/generar_pdf_api.py +``` + +Editar `generar_pdf_api.py` y agregar un `break`: + +```python +# Se compone el stdin en un 煤nico texto +input = "" +for line in sys.stdin: + input = input + line + break # <- agregar esta l铆nea +``` + +--- + +## 馃殌 Paso 5: Iniciar el api y agregar al crontab + +Ejecutar: + +```bash +sudo ./api daemon +``` + +Contenido del script `server`: + +```bash +#!/bin/sh +set -eu + +cd -P -- "$(dirname -- "$0")" +PHX_SERVER=true exec ./api start +``` + +Agregar al `crontab`: + +```bash +@reboot /home/informemedico/api/bin/server +``` + +--- + +## 馃寪 Paso 6: Configuraci贸n Apache + +Agregar lo siguiente en la configuraci贸n del VirtualHost: + +```apache + # CORS + Header set Access-Control-Allow-Origin "*" + Header set Access-Control-Allow-Headers "origin, x-requested-with, content-type" + Header set Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS" + + # WebSocket + RewriteEngine On + + RewriteCond %{HTTP:Connection} upgrade [NC] + RewriteCond %{HTTP:Upgrade} websocket [NC] + RewriteRule /(.*) "ws://127.0.0.1:4001/$1" [P,L] + + # /api + ProxyPass /api http://127.0.0.1:4001/api + ProxyPassReverse /api http://127.0.0.1:4001/api + + ProxyPass /api/live ws://127.0.0.1:4001/api/live + ProxyPassReverse /api/live ws://127.0.0.1:4001/api/live + + ProxyPass /pacientes http://127.0.0.1:4001/api/pacientes + ProxyPassReverse /pacientes http://127.0.0.1:4001/api/pacientes +``` + +--- + +## 馃敡 Activaci贸n de rutas V2 en Admin + +1. Cambiar la versi贸n de API a `2`. +2. Reemplazar las nuevas rutas en el sistema: + +| T铆tulo Ruta | Nueva URL | +|-------------------------|-----------------------------------------------------| +| **Document list URL** | `https://dominio/api/study/{{accession}}` | +| **PDF downloads URL** | `https://dominio/api/downloadpdf/{{iddocument}}` | +| **Studies URL** | `https://dominio/api/studies` |