instalacion de api v2
This commit is contained in:
		
							
								
								
									
										165
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										165
									
								
								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 | Asegurarse de conocer la versión del sistema operativo del cliente (por ejemplo, FreeBSD 13.1). Para poder elegir el compilado correcto. | ||||||
|   * Start Phoenix endpoint with `mix phx.server` or inside IEx with `iex -S mix phx.server` |  | ||||||
|  |  | ||||||
| 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`                      | | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user