Mateo Ferreyra commited on
Commit
cbc2d86
·
1 Parent(s): 7f24904

BORRAR cosas de otro modulo

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. DesarrolloAPPS2-BE-main/.gitignore +0 -29
  2. DesarrolloAPPS2-BE-main/.mvn/wrapper/maven-wrapper.properties +0 -3
  3. DesarrolloAPPS2-BE-main/.vscode/settings.json +0 -3
  4. DesarrolloAPPS2-BE-main/AGENTS.md +0 -70
  5. DesarrolloAPPS2-BE-main/CLAUDE.md +0 -64
  6. DesarrolloAPPS2-BE-main/README.md +0 -219
  7. DesarrolloAPPS2-BE-main/docs/integracion-modulo-6.md +0 -201
  8. DesarrolloAPPS2-BE-main/docs/integracion-modulo-8.md +0 -215
  9. DesarrolloAPPS2-BE-main/mvnw +0 -295
  10. DesarrolloAPPS2-BE-main/mvnw.cmd +0 -189
  11. DesarrolloAPPS2-BE-main/pom.xml +0 -108
  12. DesarrolloAPPS2-BE-main/postman/modulo-facturacion-manual.postman_collection.json +0 -560
  13. DesarrolloAPPS2-BE-main/scripts/crear_db_postgres.sql +0 -12
  14. DesarrolloAPPS2-BE-main/scripts/crear_tablas_compras.sql +0 -65
  15. DesarrolloAPPS2-BE-main/scripts/datos_prueba.sql +0 -962
  16. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/ModuloFacturacionApplication.java +0 -12
  17. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/client/Modulo1Client.java +0 -53
  18. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/config/RestTemplateConfig.java +0 -14
  19. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/config/WebConfig.java +0 -19
  20. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/CajaController.java +0 -46
  21. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/ComprasController.java +0 -90
  22. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/ConvenioArancelController.java +0 -115
  23. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/EntidadFinanciadoraController.java +0 -102
  24. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/FacturaEmitidaController.java +0 -73
  25. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/FacturaRecibidaController.java +0 -100
  26. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/FrontendController.java +0 -13
  27. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/IntegracionController.java +0 -134
  28. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/InternacionWebhookController.java +0 -32
  29. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/PlanController.java +0 -108
  30. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/PrestacionFacturableController.java +0 -166
  31. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/PrestacionNomencladorController.java +0 -106
  32. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/ActoMedicoM1Response.java +0 -30
  33. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/ActosMedicosM1Response.java +0 -15
  34. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/AdjudicarOrdenCompraItemRequest.java +0 -13
  35. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/AdjudicarOrdenCompraRequest.java +0 -16
  36. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/CajaResumenResponse.java +0 -9
  37. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/CallbackAdjudicacionRequest.java +0 -14
  38. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/CallbackItemAdjudicadoRequest.java +0 -9
  39. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/CallbackProveedorAdjudicadoRequest.java +0 -5
  40. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/CamaUtilizadaM6Request.java +0 -26
  41. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/CoberturaPacienteM1Response.java +0 -35
  42. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/ConvenioArancelRequest.java +0 -15
  43. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/ConvenioArancelResponse.java +0 -18
  44. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/CopagoItemResponse.java +0 -16
  45. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/EntidadFinanciadoraRequest.java +0 -11
  46. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/EntidadFinanciadoraResponse.java +0 -12
  47. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/EpisodioM1Response.java +0 -32
  48. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/FacturaEmitidaResponse.java +0 -17
  49. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/FacturaRecibidaResponse.java +0 -20
  50. DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/GenerarFacturaCopagoRequest.java +0 -17
DesarrolloAPPS2-BE-main/.gitignore DELETED
@@ -1,29 +0,0 @@
1
- # Maven / build
2
- target/
3
- *.log
4
-
5
- # Java
6
- *.class
7
- *.jar
8
- *.war
9
- *.ear
10
-
11
- # IDEs
12
- .idea/
13
- *.iml
14
- .project
15
- .classpath
16
- .settings/
17
-
18
- # VS Code
19
- .vscode/*
20
- !.vscode/extensions.json
21
- !.vscode/settings.json
22
-
23
- # OS
24
- Thumbs.db
25
- Desktop.ini
26
- .DS_Store
27
-
28
- # Local configuration with secrets
29
- /application-local.properties
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/.mvn/wrapper/maven-wrapper.properties DELETED
@@ -1,3 +0,0 @@
1
- wrapperVersion=3.3.4
2
- distributionType=only-script
3
- distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
 
 
 
 
DesarrolloAPPS2-BE-main/.vscode/settings.json DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "java.compile.nullAnalysis.mode": "automatic"
3
- }
 
 
 
 
DesarrolloAPPS2-BE-main/AGENTS.md DELETED
@@ -1,70 +0,0 @@
1
- # AGENTS.md
2
-
3
- Practical instructions for AI coding agents working in this repository.
4
-
5
- ## Scope
6
-
7
- This is a Spring Boot backend for billing and insurer workflows (modulo facturacion).
8
- Use these instructions as the first-stop guide, then follow project docs:
9
-
10
- - [README.md](README.md)
11
- - [postman/modulo-facturacion-manual.postman_collection.json](postman/modulo-facturacion-manual.postman_collection.json)
12
- - [scripts/crear_db_postgres.sql](scripts/crear_db_postgres.sql)
13
- - [scripts/datos_prueba.sql](scripts/datos_prueba.sql)
14
-
15
- ## Quick Start Commands
16
-
17
- - Start app: `mvn spring-boot:run`
18
- - Run tests: `mvn test`
19
- - Create local DB (PostgreSQL):
20
- `psql -U postgres -h localhost -p 5432 -f scripts/crear_db_postgres.sql`
21
-
22
- Runtime defaults are configured in:
23
-
24
- - [src/main/resources/application.properties](src/main/resources/application.properties)
25
- - [src/test/resources/application.properties](src/test/resources/application.properties)
26
-
27
- ## Stack And Boundaries
28
-
29
- - Java 17 + Spring Boot 3.4.x + Spring Web + Spring Data JPA + Validation.
30
- - Layered structure under `src/main/java/com/grupo7/modulofacturacion`:
31
- - `controller`: HTTP endpoints
32
- - `service`: business logic and transactions
33
- - `repository`: JPA access
34
- - `model`: entities and enums
35
- - `controller/dto`: HTTP DTOs
36
- - `event` and `event/dto`: integration event contracts
37
- - `exception`: centralized API error handling
38
-
39
- ## Code Conventions To Preserve
40
-
41
- - Reuse service layer patterns before introducing new abstractions:
42
- see [src/main/java/com/grupo7/modulofacturacion/service/BaseService.java](src/main/java/com/grupo7/modulofacturacion/service/BaseService.java).
43
- - Keep REST error behavior aligned with global handler:
44
- see [src/main/java/com/grupo7/modulofacturacion/exception/GlobalExceptionHandler.java](src/main/java/com/grupo7/modulofacturacion/exception/GlobalExceptionHandler.java).
45
- - Prefer `@Valid` on request DTO inputs for new write/update endpoints.
46
- - Keep naming aligned with existing Spanish domain terms (entities, fields, routes).
47
- - Preserve transactional boundaries in service methods (`@Transactional` where business workflows mutate state).
48
-
49
- ## Known Pitfalls
50
-
51
- - README mentions auto-loading sample data, but SQL init is disabled (`spring.sql.init.mode=never`).
52
- Do not assume `scripts/datos_prueba.sql` is auto-executed.
53
- - Event interfaces exist for incoming/outgoing saga integration, but concrete bus adapters may be outside this repo.
54
- - Static frontend in [src/main/resources/static](src/main/resources/static) uses same-origin API assumptions.
55
-
56
- ## Where To Start Reading
57
-
58
- - [README.md](README.md)
59
- - [pom.xml](pom.xml)
60
- - [src/main/resources/application.properties](src/main/resources/application.properties)
61
- - [src/main/java/com/grupo7/modulofacturacion/ModuloFacturacionApplication.java](src/main/java/com/grupo7/modulofacturacion/ModuloFacturacionApplication.java)
62
- - [src/main/java/com/grupo7/modulofacturacion/controller](src/main/java/com/grupo7/modulofacturacion/controller)
63
- - [src/main/java/com/grupo7/modulofacturacion/service](src/main/java/com/grupo7/modulofacturacion/service)
64
-
65
- ## Change Checklist For Agents
66
-
67
- - Keep controller-service-repository separation clear.
68
- - Add or update tests when behavior changes.
69
- - Avoid broad refactors unrelated to the requested task.
70
- - Validate with `mvn test` after non-trivial changes.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/CLAUDE.md DELETED
@@ -1,64 +0,0 @@
1
- # CLAUDE.md
2
-
3
- This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
-
5
- ## Project Overview
6
-
7
- Backend Spring Boot del módulo 7 de **Health Grid**: Facturación y Obras Sociales. Java 17, Spring Boot 3.4, PostgreSQL (prod) / H2 (tests).
8
-
9
- ## Commands
10
-
11
- ```bash
12
- # Run the application
13
- mvn spring-boot:run
14
-
15
- # Run all tests (uses H2 in-memory, no PostgreSQL needed)
16
- mvn test
17
-
18
- # Run a single test class
19
- mvn test -Dtest=CajaServiceTest
20
-
21
- # Run a single test method
22
- mvn test -Dtest=CajaServiceTest#debeRegistrarIngreso
23
-
24
- # Build without running tests
25
- mvn package -DskipTests
26
- ```
27
-
28
- ## Database Setup (local)
29
-
30
- ```bash
31
- # Create the database (PostgreSQL must be running)
32
- psql -U postgres -h localhost -p 5432 -f scripts/crear_db_postgres.sql
33
- ```
34
-
35
- Default connection: `jdbc:postgresql://localhost:5432/grupo7_db`, user `postgres`, password `postgres`. Override with env vars `DB_URL`, `DB_USERNAME`, `DB_PASSWORD`. Hibernate auto-creates/updates tables on startup (`ddl-auto=update`). Test data lives in `scripts/datos_prueba.sql`.
36
-
37
- Swagger UI is available at `http://localhost:8080/swagger-ui.html` once running.
38
-
39
- ## Architecture
40
-
41
- The package structure is `com.grupo7.modulofacturacion` with these layers:
42
-
43
- - **`model/`** — JPA entities, all extend `BaseEntity` (auto-id). Key entities: `PrestacionNomenclador`, `Plan`, `EntidadFinanciadora`, `ConvenioArancel`, `PrestacionFacturable`, `FacturaEmitida`, `FacturaRecibida`, `MovimientoCaja`.
44
- - **`repository/`** — Spring Data JPA repositories.
45
- - **`service/`** — Business logic. `BaseService<T>` provides generic CRUD. Specialized services: `LiquidacionService`, `CajaService`, `AuditoriaService`, `IntegracionService`.
46
- - **`controller/`** — REST controllers under `/api/*`. DTOs (request/response records) live in `controller/dto/`.
47
- - **`event/`** — Inter-module saga pattern. `FacturaRecibidaConsumer` (abstract base) processes incoming payment events; `SagaEventPublisher` (interface) publishes compensatory events when treasury rejects a payment.
48
- - **`exception/`** — `ResourceNotFoundException`, `DuplicateResourceException`, `GlobalExceptionHandler`.
49
-
50
- ## Key Domain Flows
51
-
52
- **Billing a patient (copago):** External module calls `POST /api/integracion/prestaciones` → `IntegracionService` creates a `PrestacionFacturable` linked to a `Plan` + `ConvenioArancel` (applies `valorCubierto` and `valorCopago`). Auditor then calls `PATCH /api/prestaciones-facturables/{id}/auditoria` to approve/reject. Once approved, `POST /api/facturas-emitidas/copagos` triggers `LiquidacionService.generarFacturaCopago()` which groups approved prestaciones into a `FacturaEmitida` and calls `CajaService.registrarIngreso()`.
53
-
54
- **Billing an insurance company (liquidación):** `POST /api/facturas-emitidas/liquidaciones/aseguradoras` triggers `LiquidacionService.generarLiquidacionAseguradora()` — consolidates all approved, unfactured `PrestacionFacturable` rows for a given `EntidadFinanciadora` up to a cut-off date.
55
-
56
- **Receiving invoices from other modules (saga):** Other modules send a `FacturaRecibidaEventDTO` to a concrete subclass of `FacturaRecibidaConsumer`. `CajaService.procesarEgreso()` checks current balance; if sufficient it approves and records an `EGRESO` movement, otherwise it fires `SagaEventPublisher.publicarRechazoDePago()` as a compensatory event. The `SagaEventPublisher` interface must be implemented per-transport (e.g., in-memory, Kafka) when integrating with other modules.
57
-
58
- **Caja (treasury):** Balance is computed as the algebraic sum of all `MovimientoCaja` rows (INGRESO positive, EGRESO negative). `GET /api/caja` returns current balance + paginated history.
59
-
60
- ## Testing Conventions
61
-
62
- Controller tests use `MockMvcBuilders.standaloneSetup(...)` with `@ExtendWith(MockitoExtension.class)` — no Spring context loaded. Service tests use H2 via `@SpringBootTest` or plain unit tests with Mockito. The `src/test/resources/application.properties` points to H2 with `MODE=PostgreSQL`.
63
-
64
- A Postman collection is available at `postman/modulo-facturacion-manual.postman_collection.json`.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/README.md DELETED
@@ -1,219 +0,0 @@
1
- # Modulo 7 - Facturacion y Obras Sociales
2
-
3
- Backend Spring Boot del Modulo 7 de Health Grid para la segunda entrega de Desarrollo de Aplicaciones II.
4
-
5
- ## Descripcion
6
-
7
- El modulo implementa la facturacion de prestaciones medicas, administracion de obras sociales/prepagas, planes, convenios, nomenclador, auditoria, liquidaciones, copagos, caja e integraciones mockeadas con otros modulos.
8
-
9
- Arquitectura principal:
10
-
11
- - Java 17 y Spring Boot.
12
- - API REST.
13
- - PostgreSQL local.
14
- - JPA/Hibernate.
15
- - Swagger/OpenAPI para documentacion interactiva.
16
- - Servicios por dominio: planes, financiadores, nomenclador, prestaciones, liquidacion, caja, compras e integraciones.
17
- - Integraciones mockeadas o preparadas con M1/HCE, M3/Farmacia, M6/Internacion, M8/Portal del Paciente y futura integracion con M10/Core.
18
-
19
- ## URLs locales
20
-
21
- - API base: `http://localhost:8080`
22
- - Swagger UI: `http://localhost:8080/swagger-ui/index.html`
23
- - OpenAPI JSON: `http://localhost:8080/v3/api-docs`
24
-
25
- ## Requisitos
26
-
27
- - Java 17.
28
- - PostgreSQL local.
29
- - Maven Wrapper incluido en el repo.
30
-
31
- ## Crear la base de datos
32
-
33
- Con PostgreSQL instalado y corriendo:
34
-
35
- ```powershell
36
- psql -U postgres -h localhost -p 5432 -f scripts/crear_db_postgres.sql
37
- ```
38
-
39
- Configuracion por defecto:
40
-
41
- ```text
42
- Host: localhost
43
- Puerto: 5432
44
- Base: grupo7_db
45
- Usuario: postgres
46
- Password por defecto: postgres
47
- ```
48
-
49
- Si tu instalacion usa otra password:
50
-
51
- ```powershell
52
- $env:DB_USERNAME="postgres"
53
- $env:DB_PASSWORD="tu_password"
54
- ```
55
-
56
- ## Levantar backend
57
-
58
- ```powershell
59
- .\mvnw.cmd spring-boot:run
60
- ```
61
-
62
- En Linux/macOS:
63
-
64
- ```bash
65
- ./mvnw spring-boot:run
66
- ```
67
-
68
- ## Cargar datos de prueba
69
-
70
- La configuracion actual tiene `spring.sql.init.mode=never`, por lo que Spring no carga automaticamente `scripts/datos_prueba.sql`.
71
-
72
- Para cargar datos demo manualmente:
73
-
74
- ```powershell
75
- psql -U postgres -h localhost -p 5432 -d grupo7_db -f scripts/datos_prueba.sql
76
- ```
77
-
78
- El script es idempotente y puede correrse mas de una vez sin duplicar los datos principales.
79
-
80
- ## Ejecutar tests
81
-
82
- ```powershell
83
- .\mvnw.cmd test
84
- ```
85
-
86
- Los tests usan H2 en memoria y no requieren PostgreSQL levantado.
87
-
88
- ## Postman
89
-
90
- La coleccion manual esta en:
91
-
92
- ```text
93
- postman/modulo-facturacion-manual.postman_collection.json
94
- ```
95
-
96
- Variable recomendada:
97
-
98
- ```text
99
- base_url=http://localhost:8080
100
- ```
101
-
102
- ## Flujo recomendado para demo
103
-
104
- 1. Abrir Swagger en `http://localhost:8080/swagger-ui/index.html`.
105
- 2. Mostrar catalogos:
106
- - `GET /api/entidades-financiadoras`
107
- - `GET /api/planes`
108
- - `GET /api/prestaciones-nomenclador`
109
- - `GET /api/convenios-aranceles`
110
- 3. Mostrar prestaciones y auditoria:
111
- - `GET /api/prestaciones-facturables`
112
- - `PATCH /api/prestaciones-facturables/{id}/auditoria`
113
- 4. Generar una liquidacion de obra social:
114
- - `POST /api/facturas-emitidas/liquidaciones/aseguradoras`
115
- 5. Consultar caja:
116
- - `GET /api/caja`
117
- 6. Simular aprobacion de facturas recibidas:
118
- - `POST /api/facturas-recibidas/simular`
119
- 7. Mostrar integracion M3/Farmacia:
120
- - crear, adjudicar, rechazar o reenviar callback de OC.
121
- 8. Mostrar integracion M6/Internacion:
122
- - `POST /api/v1/webhooks/internacion/cama-lista`
123
- - `POST /api/integracion/internacion/cierre-episodio`
124
- 9. Mostrar integracion M8/Portal:
125
- - `GET /api/integracion/copago/paciente/10500`
126
- - `POST /api/integracion/pagos/notificacion`
127
-
128
- ## Integraciones mockeadas
129
-
130
- ### M1 - Historia Clinica Electronica
131
-
132
- M7 consume:
133
-
134
- - `GET /api/v1/patients/{idPaciente}/insurance`
135
- - `GET /api/v1/patients/{idPaciente}/episodes/{idEpisodio}`
136
- - `GET /api/v1/patients/{idPaciente}/episodes/{idEpisodio}/medical-acts`
137
-
138
- M7 usa esos datos para obtener cobertura, `entidadFinanciadoraId`, `planId`, episodio y actos medicos facturables.
139
-
140
- Importante: M7 es duenio del ABM de entidades financiadoras, planes, convenios y nomenclador. Por eso M1 debe devolver los IDs reales de M7:
141
-
142
- - `entidadFinanciadoraId`
143
- - `planId`
144
-
145
- Si M1 no devuelve esos IDs, M7 deja el evento en `RECIBIDO_PENDIENTE_PLAN_M1` y no factura automaticamente.
146
-
147
- ### M3 - Farmacia
148
-
149
- M3 llama:
150
-
151
- - `POST /api/compras/ordenes-compra`
152
-
153
- M7 ofrece:
154
-
155
- - `GET /api/compras/ordenes-compra`
156
- - `GET /api/compras/ordenes-compra/{id}`
157
- - `POST /api/compras/ordenes-compra/{id}/adjudicar`
158
- - `POST /api/compras/ordenes-compra/{id}/rechazar`
159
- - `POST /api/compras/ordenes-compra/{id}/reenviar-callback`
160
-
161
- Cuando M7 adjudica o rechaza una OC, intenta informar el resultado a M3 mediante callback. En demo se documenta como integracion mockeada.
162
-
163
- ### M6 - Internacion y Gestion de Camas
164
-
165
- M6 llama:
166
-
167
- - `POST /api/v1/webhooks/internacion/cama-lista`
168
- - `POST /api/integracion/internacion/cierre-episodio`
169
-
170
- Los payloads deben usar `idPacienteExterno` numerico. Las internaciones de varios dias se informan con `fechaIngreso`, `fechaAlta` y `camasUtilizadas`.
171
-
172
- `/api/integracion/prestaciones` registra actos medicos puntuales con `fechaAtencion`. Para estadias multi-dia, usar los endpoints de internacion.
173
-
174
- ### M8 - Portal del Paciente
175
-
176
- M8 consume:
177
-
178
- - `GET /api/integracion/copago/paciente/{pacienteId}`
179
-
180
- M8 llama:
181
-
182
- - `POST /api/integracion/pagos/notificacion`
183
-
184
- Si el pago esta `APROBADO`, M7 genera factura de copago y movimiento de caja. Si esta `RECHAZADO`, `PENDIENTE` o en error, M7 registra la notificacion y conserva la deuda.
185
-
186
- ### M10 - Core
187
-
188
- Para esta entrega, autenticacion y permisos quedan mockeados. Para la integracion con Core, M7 debera informar:
189
-
190
- - URL base del servicio.
191
- - Endpoints ofrecidos.
192
- - Endpoints consumidos.
193
- - Roles/permisos sugeridos.
194
- - Eventos/colas previstos.
195
-
196
- Roles sugeridos:
197
-
198
- - `FACTURACION_ADMIN`
199
- - `FACTURACION_AUDITOR`
200
- - `FACTURACION_CAJA`
201
- - `FACTURACION_LECTURA`
202
-
203
- ## Documentacion adicional
204
-
205
- - `docs/integracion-modulo-6.md`
206
- - `docs/integracion-modulo-8.md`
207
-
208
- ## Preparar ZIP de entrega
209
-
210
- Incluir codigo fuente, scripts, README, docs y coleccion Postman.
211
-
212
- No incluir:
213
-
214
- - `target/`
215
- - `.mvn/wrapper/dists/`
216
- - `.idea/`
217
- - archivos `.jar` o `.war`
218
- - logs o archivos generados localmente
219
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/docs/integracion-modulo-6.md DELETED
@@ -1,201 +0,0 @@
1
- # Integracion Modulo 6 con Modulo 7 y Modulo 1
2
-
3
- Este documento describe la integracion local entre Modulo 6 - Internacion y Gestion de Camas, Modulo 7 - Facturacion y Obras Sociales, y Modulo 1 - HCE.
4
-
5
- Todavia no hay deploy ni dominios definitivos. Para desarrollo local se asume:
6
-
7
- - `M7_FACTURACION_URL=http://localhost:8080`
8
- - `modulo1.hce.url=http://localhost:8001`
9
-
10
- ## Flujo general
11
-
12
- ```txt
13
- M6 -> M7 -> M1 -> M7 factura
14
- ```
15
-
16
- 1. M6 informa a M7 el cierre de una internacion o que una cama quedo lista.
17
- 2. M7 recibe el evento y lo persiste con idempotencia.
18
- 3. Si M6 informa `idPacienteExterno` e `idEpisodioExterno`, M7 consulta a M1/HCE.
19
- 4. M1 devuelve cobertura, detalle del episodio y actos medicos.
20
- 5. M7 factura usando sus propios catalogos: nomenclador, planes, entidades financiadoras y convenios.
21
-
22
- ## Responsabilidades
23
-
24
- ```txt
25
- M6: informa cierre de internacion, paciente, episodio, fechas y camas.
26
- M1: informa cobertura, planId, entidadFinanciadoraId, episodio y actos medicos.
27
- M7: factura usando su nomenclador, convenios y reglas.
28
- ```
29
-
30
- M7 es duenio del ABM de entidades financiadoras, obras sociales, prepagas, planes, convenios y nomenclador. Por eso M1 debe guardar o devolver los IDs reales de M7:
31
-
32
- - `entidadFinanciadoraId`
33
- - `planId`
34
-
35
- No se debe usar `codigo_plan` como mecanismo principal para resolver cobertura en M7. Puede servir como dato descriptivo o de auditoria, pero la integracion automatica requiere IDs reales de M7.
36
-
37
- ## Catalogos de M7 para M1
38
-
39
- M1 puede consumir estos endpoints de M7 al asignar o sincronizar cobertura de un paciente:
40
-
41
- ```http
42
- GET http://localhost:8080/api/entidades-financiadoras
43
- GET http://localhost:8080/api/entidades-financiadoras/{id}
44
- GET http://localhost:8080/api/planes
45
- GET http://localhost:8080/api/planes/{id}
46
- GET http://localhost:8080/api/planes?entidadFinanciadoraId={id}
47
- ```
48
-
49
- Los endpoints de listado y busqueda por ID estan expuestos en los controllers de M7 y documentados con OpenAPI/Swagger. `GET /api/planes` permite filtrar por `entidadFinanciadoraId`, que es el caso recomendado para que M1 obtenga los planes asociados a una obra social/prepaga antes de guardar la cobertura del paciente.
50
-
51
- Ejemplo:
52
-
53
- ```bash
54
- curl http://localhost:8080/api/entidades-financiadoras
55
- curl "http://localhost:8080/api/planes?entidadFinanciadoraId=1"
56
- ```
57
-
58
- ## Endpoint compatible con M6 actual
59
-
60
- ```http
61
- POST http://localhost:8080/api/v1/webhooks/internacion/cama-lista
62
- ```
63
-
64
- Payload minimo:
65
-
66
- ```json
67
- {
68
- "evento": "CAMA_LISTA",
69
- "cama_id": 101,
70
- "paciente_id": 10500,
71
- "timestamp_evento": "2026-06-25T10:00:00Z"
72
- }
73
- ```
74
-
75
- Este endpoint acepta camelCase y snake_case para los campos principales. Si no llega `idEpisodioExterno`, M7 persiste el evento y lo deja en estado `RECIBIDO_PENDIENTE_DATOS`.
76
-
77
- ## Endpoint recomendado
78
-
79
- ```http
80
- POST http://localhost:8080/api/integracion/internacion/cierre-episodio
81
- ```
82
-
83
- Payload recomendado:
84
-
85
- ```json
86
- {
87
- "evento": "CIERRE_INTERNACION",
88
- "idEventoExterno": "M6-CIERRE-INT-000123",
89
- "idInternacionExterna": "INT-000123",
90
- "idEpisodioExterno": "700",
91
- "idPacienteExterno": "10500",
92
- "fechaIngreso": "2026-06-20T14:30:00Z",
93
- "fechaAlta": "2026-06-25T10:00:00Z",
94
- "tipoAlta": "ALTA_MEDICA",
95
- "medicoFirmanteId": "42",
96
- "camasUtilizadas": [
97
- {
98
- "camaId": 101,
99
- "sector": "SALA_COMUN",
100
- "tipoCama": "SALA_COMUN",
101
- "desde": "2026-06-20T14:30:00Z",
102
- "hasta": "2026-06-22T09:00:00Z"
103
- }
104
- ],
105
- "timestampEvento": "2026-06-25T10:05:00Z"
106
- }
107
- ```
108
-
109
- ## Config local M6 hacia M7
110
-
111
- ```env
112
- M7_FACTURACION_URL=http://localhost:8080
113
- MOCK_EXTERNAL_SERVICES=false
114
- ```
115
-
116
- ## Config local M7 hacia M1
117
-
118
- ```properties
119
- modulo1.hce.url=http://localhost:8001
120
- ```
121
-
122
- Tambien puede configurarse por variable de entorno:
123
-
124
- ```env
125
- MODULO1_HCE_URL=http://localhost:8001
126
- ```
127
-
128
- ## Endpoints reales de M1 consumidos por M7
129
-
130
- ```http
131
- GET http://localhost:8001/api/v1/patients/{idPaciente}/insurance
132
- GET http://localhost:8001/api/v1/patients/{idPaciente}/episodes/{idEpisodio}
133
- GET http://localhost:8001/api/v1/patients/{idPaciente}/episodes/{idEpisodio}/medical-acts
134
- ```
135
-
136
- Ejemplos locales:
137
-
138
- ```http
139
- GET http://localhost:8001/api/v1/patients/10500/insurance
140
- GET http://localhost:8001/api/v1/patients/10500/episodes/700
141
- GET http://localhost:8001/api/v1/patients/10500/episodes/700/medical-acts
142
- ```
143
-
144
- ## Cobertura esperada desde M1
145
-
146
- ```json
147
- {
148
- "id_paciente": 10500,
149
- "entidadFinanciadoraId": 1,
150
- "planId": 1,
151
- "id_obra_social": 15,
152
- "nombre_obra_social": "OSDE",
153
- "codigo_plan": "OSDE-210",
154
- "numero_afiliado": "1234567890",
155
- "vigente_desde": "2024-01-01",
156
- "vigente_hasta": null
157
- }
158
- ```
159
-
160
- Campos obligatorios para facturacion automatica:
161
-
162
- - `entidadFinanciadoraId`
163
- - `planId`
164
-
165
- Si M1 devuelve cobertura pero no devuelve `planId` y `entidadFinanciadoraId`, M7 deja el evento en estado:
166
-
167
- ```txt
168
- RECIBIDO_PENDIENTE_PLAN_M1
169
- ```
170
-
171
- En ese caso M7 no factura automaticamente. El evento queda persistido para correccion de datos o reintento.
172
-
173
- ## Actos medicos esperados desde M1
174
-
175
- M7 usa cada acto medico recibido para construir internamente un `RegistrarPrestacionExternaRequest` y llama al metodo existente `registrarPrestacionExterna`.
176
-
177
- Mapeo principal:
178
-
179
- - `moduloOrigen = "MODULO_1_HCE"`
180
- - `pacienteIdExterno = idPacienteExterno`
181
- - `profesionalIdExterno = id_profesional`
182
- - `planId = planId`
183
- - `codigoPrestacion = codigo_nomenclador`
184
- - `numeroAfiliadoInformado = numero_afiliado`
185
- - `fechaAtencion = fecha_realizacion`
186
- - `cantidad = cantidad`, default `1`
187
- - `idEpisodioExterno = idEpisodioExterno`
188
- - `idActoMedicoExterno = id_acto_medico`
189
- - `observaciones = observaciones + " | Registrado por cierre de internacion M6"`
190
-
191
- La idempotencia de prestaciones queda dada por `moduloOrigen + idActoMedicoExterno`, que ya valida M7.
192
-
193
- ## Estados relevantes
194
-
195
- - `RECIBIDO_PENDIENTE_DATOS`: M6 no envio datos minimos para avanzar, por ejemplo `idEpisodioExterno`.
196
- - `RECIBIDO_PENDIENTE_CONSULTA_M1`: M1 no respondio o hubo error de conexion.
197
- - `RECIBIDO_PENDIENTE_PLAN_M1`: M1 respondio cobertura, pero no envio `planId` o `entidadFinanciadoraId`.
198
- - `RECIBIDO_PENDIENTE_ACTOS_MEDICOS`: M1 respondio cobertura valida, pero no envio actos medicos.
199
- - `PROCESADO`: M7 registro las prestaciones facturables.
200
- - `DUPLICADO`: M7 ya habia recibido el mismo evento.
201
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/docs/integracion-modulo-8.md DELETED
@@ -1,215 +0,0 @@
1
- # Integracion Modulo 7 con Modulo 8
2
-
3
- Este documento describe la integracion local entre el Modulo 7 - Facturacion y Obras Sociales y el Modulo 8 - Portal del Paciente y Telemedicina para el flujo de pagos online de coseguros/copagos.
4
-
5
- Todavia no hay deploy ni dominios definitivos. Para desarrollo local se asume:
6
-
7
- - `MODULO_7_BASE_URL=http://localhost:8080`
8
- - `MODULO_8_BASE_URL=http://localhost:3008`
9
-
10
- ## Objetivo
11
-
12
- Modulo 7 expone la deuda real de copagos del paciente, recibe la notificacion de pago enviada por Modulo 8 y, cuando el pago queda aprobado, registra la factura emitida y el ingreso de caja.
13
-
14
- Modulo 8 muestra las deudas al paciente, procesa o simula el pago online y notifica el resultado a Modulo 7.
15
-
16
- ## Flujo esperado
17
-
18
- 1. Modulo 8 consulta en Modulo 7 los copagos pendientes del paciente.
19
- 2. Modulo 8 muestra esas deudas en el portal.
20
- 3. El paciente paga o simula el pago en Modulo 8.
21
- 4. Modulo 8 notifica el resultado del pago a Modulo 7.
22
- 5. Modulo 7 valida paciente, prestaciones, monto, moneda, origen y estado.
23
- 6. Si el pago esta aprobado, Modulo 7 genera la factura de copago, vincula las prestaciones e ingresa el movimiento de caja.
24
- 7. Si el pago esta rechazado, pendiente o en error, Modulo 7 registra la notificacion y mantiene la deuda pendiente.
25
-
26
- ## Endpoint: consultar copagos pendientes
27
-
28
- `GET /api/integracion/copago/paciente/{pacienteId}`
29
-
30
- Ejemplo:
31
-
32
- ```bash
33
- curl -X GET http://localhost:8080/api/integracion/copago/paciente/10500
34
- ```
35
-
36
- Response:
37
-
38
- ```json
39
- [
40
- {
41
- "prestacionFacturableId": 1,
42
- "pacienteIdExterno": 10500,
43
- "codigoPrestacion": "42.01.01",
44
- "descripcionPrestacion": "Consulta medica en consultorio",
45
- "fechaAtencion": "2026-04-08T09:30:00",
46
- "montoCopagoAplicado": 2500.00,
47
- "moneda": "ARS",
48
- "estado": "PENDIENTE"
49
- }
50
- ]
51
- ```
52
-
53
- Una prestacion aparece como pendiente si:
54
-
55
- - pertenece al paciente consultado;
56
- - esta aprobada por auditoria;
57
- - tiene copago mayor a cero;
58
- - no tiene factura emitida asociada.
59
-
60
- ## Endpoint: notificar pago desde Modulo 8
61
-
62
- `POST /api/integracion/pagos/notificacion`
63
-
64
- Request:
65
-
66
- ```json
67
- {
68
- "pacienteIdExterno": 10500,
69
- "prestacionesFacturablesIds": [1],
70
- "montoPagado": 2500,
71
- "moneda": "ARS",
72
- "medioPago": "TARJETA",
73
- "estadoPago": "APROBADO",
74
- "idTransaccionExterna": "M8-PAGO-TEST-001",
75
- "fechaPago": "2026-06-19T18:30:00",
76
- "moduloOrigen": "MODULO_8"
77
- }
78
- ```
79
-
80
- Response para pago aprobado:
81
-
82
- ```json
83
- {
84
- "ok": true,
85
- "mensaje": "Pago registrado correctamente",
86
- "facturaEmitidaId": 10,
87
- "numeroComprobante": "COP-20260619183000001",
88
- "estado": "PAGADO"
89
- }
90
- ```
91
-
92
- Response si la transaccion ya habia sido procesada:
93
-
94
- ```json
95
- {
96
- "ok": true,
97
- "mensaje": "Pago ya registrado previamente",
98
- "facturaEmitidaId": 10,
99
- "numeroComprobante": "COP-20260619183000001",
100
- "estado": "PAGADO"
101
- }
102
- ```
103
-
104
- Response para monto incorrecto:
105
-
106
- ```json
107
- {
108
- "ok": false,
109
- "mensaje": "El monto pagado no coincide con el monto pendiente",
110
- "facturaEmitidaId": null,
111
- "numeroComprobante": null,
112
- "estado": "ERROR"
113
- }
114
- ```
115
-
116
- ## Estados soportados
117
-
118
- - `APROBADO`: valida deuda, registra pago, genera factura de copago, vincula prestaciones y registra ingreso de caja.
119
- - `RECHAZADO`: registra la notificacion, no genera factura, no registra caja y mantiene la deuda pendiente.
120
- - `ERROR`: registra la notificacion, no genera factura, no registra caja y mantiene la deuda pendiente.
121
- - `PENDIENTE`: registra la notificacion, no genera factura, no registra caja y mantiene la deuda pendiente.
122
-
123
- ## Validaciones en Modulo 7
124
-
125
- - `pacienteIdExterno` obligatorio.
126
- - `prestacionesFacturablesIds` obligatorio, no vacio, sin nulos y sin repetidos.
127
- - `montoPagado` obligatorio y mayor a cero.
128
- - `estadoPago` reconocido.
129
- - `idTransaccionExterna` obligatorio y unico.
130
- - `fechaPago` usa la fecha recibida o la fecha actual si no se informa.
131
- - `moneda` debe ser `ARS`.
132
- - `moduloOrigen` debe ser `MODULO_8`.
133
- - Todas las prestaciones deben existir.
134
- - Todas las prestaciones deben pertenecer al paciente informado.
135
- - Para pagos aprobados, todas las prestaciones deben estar aprobadas por auditoria, tener copago mayor a cero y no estar facturadas.
136
- - Para pagos aprobados, la suma de copagos pendientes debe coincidir con `montoPagado`.
137
-
138
- ## Idempotencia
139
-
140
- Modulo 7 guarda cada notificacion en `pagos_integracion_m8` con constraint unico sobre `id_transaccion_externa`.
141
-
142
- Si Modulo 8 reintenta una notificacion con el mismo `idTransaccionExterna`, Modulo 7 devuelve la informacion ya registrada y no genera otra factura ni otro movimiento de caja.
143
-
144
- ## Responsabilidades
145
-
146
- Modulo 7:
147
-
148
- - publicar copagos pendientes reales;
149
- - validar la notificacion de pago;
150
- - persistir la transaccion externa;
151
- - generar factura solo cuando el pago este aprobado;
152
- - registrar caja solo cuando el pago este aprobado;
153
- - garantizar idempotencia.
154
-
155
- Modulo 8:
156
-
157
- - consumir `GET /api/integracion/copago/paciente/{pacienteId}`;
158
- - mostrar deudas al paciente;
159
- - procesar o simular el pago;
160
- - enviar una unica `idTransaccionExterna` estable por intento de pago;
161
- - reintentar con el mismo `idTransaccionExterna` si necesita confirmar el resultado.
162
-
163
- ## Pruebas manuales
164
-
165
- Consultar deuda:
166
-
167
- ```bash
168
- curl -X GET http://localhost:8080/api/integracion/copago/paciente/10500
169
- ```
170
-
171
- Notificar pago aprobado:
172
-
173
- ```bash
174
- curl -X POST http://localhost:8080/api/integracion/pagos/notificacion \
175
- -H "Content-Type: application/json" \
176
- -d '{
177
- "pacienteIdExterno": 10500,
178
- "prestacionesFacturablesIds": [1],
179
- "montoPagado": 2500,
180
- "moneda": "ARS",
181
- "medioPago": "TARJETA",
182
- "estadoPago": "APROBADO",
183
- "idTransaccionExterna": "M8-PAGO-TEST-001",
184
- "fechaPago": "2026-06-19T18:30:00",
185
- "moduloOrigen": "MODULO_8"
186
- }'
187
- ```
188
-
189
- Repetir la misma transaccion para probar idempotencia:
190
-
191
- ```bash
192
- curl -X POST http://localhost:8080/api/integracion/pagos/notificacion \
193
- -H "Content-Type: application/json" \
194
- -d '{
195
- "pacienteIdExterno": 10500,
196
- "prestacionesFacturablesIds": [1],
197
- "montoPagado": 2500,
198
- "moneda": "ARS",
199
- "medioPago": "TARJETA",
200
- "estadoPago": "APROBADO",
201
- "idTransaccionExterna": "M8-PAGO-TEST-001",
202
- "fechaPago": "2026-06-19T18:30:00",
203
- "moduloOrigen": "MODULO_8"
204
- }'
205
- ```
206
-
207
- La segunda llamada debe responder con la factura ya creada y no debe duplicar factura ni caja.
208
-
209
- ## Pendiente del lado de Modulo 8
210
-
211
- - Configurar `MODULO_7_BASE_URL` apuntando al backend local o al dominio real cuando exista.
212
- - Mapear el paciente autenticado del portal contra `pacienteIdExterno`.
213
- - Consumir la lista de copagos pendientes.
214
- - Enviar la notificacion de pago con `idTransaccionExterna` idempotente.
215
- - Manejar respuestas `ok=false` mostrando el error al usuario o reintentando segun corresponda.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/mvnw DELETED
@@ -1,295 +0,0 @@
1
- #!/bin/sh
2
- # ----------------------------------------------------------------------------
3
- # Licensed to the Apache Software Foundation (ASF) under one
4
- # or more contributor license agreements. See the NOTICE file
5
- # distributed with this work for additional information
6
- # regarding copyright ownership. The ASF licenses this file
7
- # to you under the Apache License, Version 2.0 (the
8
- # "License"); you may not use this file except in compliance
9
- # with the License. You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing,
14
- # software distributed under the License is distributed on an
15
- # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
- # KIND, either express or implied. See the License for the
17
- # specific language governing permissions and limitations
18
- # under the License.
19
- # ----------------------------------------------------------------------------
20
-
21
- # ----------------------------------------------------------------------------
22
- # Apache Maven Wrapper startup batch script, version 3.3.4
23
- #
24
- # Optional ENV vars
25
- # -----------------
26
- # JAVA_HOME - location of a JDK home dir, required when download maven via java source
27
- # MVNW_REPOURL - repo url base for downloading maven distribution
28
- # MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
29
- # MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output
30
- # ----------------------------------------------------------------------------
31
-
32
- set -euf
33
- [ "${MVNW_VERBOSE-}" != debug ] || set -x
34
-
35
- # OS specific support.
36
- native_path() { printf %s\\n "$1"; }
37
- case "$(uname)" in
38
- CYGWIN* | MINGW*)
39
- [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")"
40
- native_path() { cygpath --path --windows "$1"; }
41
- ;;
42
- esac
43
-
44
- # set JAVACMD and JAVACCMD
45
- set_java_home() {
46
- # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched
47
- if [ -n "${JAVA_HOME-}" ]; then
48
- if [ -x "$JAVA_HOME/jre/sh/java" ]; then
49
- # IBM's JDK on AIX uses strange locations for the executables
50
- JAVACMD="$JAVA_HOME/jre/sh/java"
51
- JAVACCMD="$JAVA_HOME/jre/sh/javac"
52
- else
53
- JAVACMD="$JAVA_HOME/bin/java"
54
- JAVACCMD="$JAVA_HOME/bin/javac"
55
-
56
- if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then
57
- echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2
58
- echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2
59
- return 1
60
- fi
61
- fi
62
- else
63
- JAVACMD="$(
64
- 'set' +e
65
- 'unset' -f command 2>/dev/null
66
- 'command' -v java
67
- )" || :
68
- JAVACCMD="$(
69
- 'set' +e
70
- 'unset' -f command 2>/dev/null
71
- 'command' -v javac
72
- )" || :
73
-
74
- if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then
75
- echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2
76
- return 1
77
- fi
78
- fi
79
- }
80
-
81
- # hash string like Java String::hashCode
82
- hash_string() {
83
- str="${1:-}" h=0
84
- while [ -n "$str" ]; do
85
- char="${str%"${str#?}"}"
86
- h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296))
87
- str="${str#?}"
88
- done
89
- printf %x\\n $h
90
- }
91
-
92
- verbose() { :; }
93
- [ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; }
94
-
95
- die() {
96
- printf %s\\n "$1" >&2
97
- exit 1
98
- }
99
-
100
- trim() {
101
- # MWRAPPER-139:
102
- # Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds.
103
- # Needed for removing poorly interpreted newline sequences when running in more
104
- # exotic environments such as mingw bash on Windows.
105
- printf "%s" "${1}" | tr -d '[:space:]'
106
- }
107
-
108
- scriptDir="$(dirname "$0")"
109
- scriptName="$(basename "$0")"
110
-
111
- # parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties
112
- while IFS="=" read -r key value; do
113
- case "${key-}" in
114
- distributionUrl) distributionUrl=$(trim "${value-}") ;;
115
- distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;;
116
- esac
117
- done <"$scriptDir/.mvn/wrapper/maven-wrapper.properties"
118
- [ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
119
-
120
- case "${distributionUrl##*/}" in
121
- maven-mvnd-*bin.*)
122
- MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/
123
- case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in
124
- *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;;
125
- :Darwin*x86_64) distributionPlatform=darwin-amd64 ;;
126
- :Darwin*arm64) distributionPlatform=darwin-aarch64 ;;
127
- :Linux*x86_64*) distributionPlatform=linux-amd64 ;;
128
- *)
129
- echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2
130
- distributionPlatform=linux-amd64
131
- ;;
132
- esac
133
- distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip"
134
- ;;
135
- maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;;
136
- *) MVN_CMD="mvn${scriptName#mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;;
137
- esac
138
-
139
- # apply MVNW_REPOURL and calculate MAVEN_HOME
140
- # maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
141
- [ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}"
142
- distributionUrlName="${distributionUrl##*/}"
143
- distributionUrlNameMain="${distributionUrlName%.*}"
144
- distributionUrlNameMain="${distributionUrlNameMain%-bin}"
145
- MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}"
146
- MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")"
147
-
148
- exec_maven() {
149
- unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || :
150
- exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD"
151
- }
152
-
153
- if [ -d "$MAVEN_HOME" ]; then
154
- verbose "found existing MAVEN_HOME at $MAVEN_HOME"
155
- exec_maven "$@"
156
- fi
157
-
158
- case "${distributionUrl-}" in
159
- *?-bin.zip | *?maven-mvnd-?*-?*.zip) ;;
160
- *) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;;
161
- esac
162
-
163
- # prepare tmp dir
164
- if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then
165
- clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; }
166
- trap clean HUP INT TERM EXIT
167
- else
168
- die "cannot create temp dir"
169
- fi
170
-
171
- mkdir -p -- "${MAVEN_HOME%/*}"
172
-
173
- # Download and Install Apache Maven
174
- verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
175
- verbose "Downloading from: $distributionUrl"
176
- verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
177
-
178
- # select .zip or .tar.gz
179
- if ! command -v unzip >/dev/null; then
180
- distributionUrl="${distributionUrl%.zip}.tar.gz"
181
- distributionUrlName="${distributionUrl##*/}"
182
- fi
183
-
184
- # verbose opt
185
- __MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR=''
186
- [ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v
187
-
188
- # normalize http auth
189
- case "${MVNW_PASSWORD:+has-password}" in
190
- '') MVNW_USERNAME='' MVNW_PASSWORD='' ;;
191
- has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;;
192
- esac
193
-
194
- if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then
195
- verbose "Found wget ... using wget"
196
- wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl"
197
- elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then
198
- verbose "Found curl ... using curl"
199
- curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl"
200
- elif set_java_home; then
201
- verbose "Falling back to use Java to download"
202
- javaSource="$TMP_DOWNLOAD_DIR/Downloader.java"
203
- targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName"
204
- cat >"$javaSource" <<-END
205
- public class Downloader extends java.net.Authenticator
206
- {
207
- protected java.net.PasswordAuthentication getPasswordAuthentication()
208
- {
209
- return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() );
210
- }
211
- public static void main( String[] args ) throws Exception
212
- {
213
- setDefault( new Downloader() );
214
- java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() );
215
- }
216
- }
217
- END
218
- # For Cygwin/MinGW, switch paths to Windows format before running javac and java
219
- verbose " - Compiling Downloader.java ..."
220
- "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java"
221
- verbose " - Running Downloader.java ..."
222
- "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")"
223
- fi
224
-
225
- # If specified, validate the SHA-256 sum of the Maven distribution zip file
226
- if [ -n "${distributionSha256Sum-}" ]; then
227
- distributionSha256Result=false
228
- if [ "$MVN_CMD" = mvnd.sh ]; then
229
- echo "Checksum validation is not supported for maven-mvnd." >&2
230
- echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
231
- exit 1
232
- elif command -v sha256sum >/dev/null; then
233
- if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c - >/dev/null 2>&1; then
234
- distributionSha256Result=true
235
- fi
236
- elif command -v shasum >/dev/null; then
237
- if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then
238
- distributionSha256Result=true
239
- fi
240
- else
241
- echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2
242
- echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
243
- exit 1
244
- fi
245
- if [ $distributionSha256Result = false ]; then
246
- echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2
247
- echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2
248
- exit 1
249
- fi
250
- fi
251
-
252
- # unzip and move
253
- if command -v unzip >/dev/null; then
254
- unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip"
255
- else
256
- tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar"
257
- fi
258
-
259
- # Find the actual extracted directory name (handles snapshots where filename != directory name)
260
- actualDistributionDir=""
261
-
262
- # First try the expected directory name (for regular distributions)
263
- if [ -d "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" ]; then
264
- if [ -f "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/bin/$MVN_CMD" ]; then
265
- actualDistributionDir="$distributionUrlNameMain"
266
- fi
267
- fi
268
-
269
- # If not found, search for any directory with the Maven executable (for snapshots)
270
- if [ -z "$actualDistributionDir" ]; then
271
- # enable globbing to iterate over items
272
- set +f
273
- for dir in "$TMP_DOWNLOAD_DIR"/*; do
274
- if [ -d "$dir" ]; then
275
- if [ -f "$dir/bin/$MVN_CMD" ]; then
276
- actualDistributionDir="$(basename "$dir")"
277
- break
278
- fi
279
- fi
280
- done
281
- set -f
282
- fi
283
-
284
- if [ -z "$actualDistributionDir" ]; then
285
- verbose "Contents of $TMP_DOWNLOAD_DIR:"
286
- verbose "$(ls -la "$TMP_DOWNLOAD_DIR")"
287
- die "Could not find Maven distribution directory in extracted archive"
288
- fi
289
-
290
- verbose "Found extracted Maven distribution directory: $actualDistributionDir"
291
- printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$actualDistributionDir/mvnw.url"
292
- mv -- "$TMP_DOWNLOAD_DIR/$actualDistributionDir" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME"
293
-
294
- clean || :
295
- exec_maven "$@"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/mvnw.cmd DELETED
@@ -1,189 +0,0 @@
1
- <# : batch portion
2
- @REM ----------------------------------------------------------------------------
3
- @REM Licensed to the Apache Software Foundation (ASF) under one
4
- @REM or more contributor license agreements. See the NOTICE file
5
- @REM distributed with this work for additional information
6
- @REM regarding copyright ownership. The ASF licenses this file
7
- @REM to you under the Apache License, Version 2.0 (the
8
- @REM "License"); you may not use this file except in compliance
9
- @REM with the License. You may obtain a copy of the License at
10
- @REM
11
- @REM http://www.apache.org/licenses/LICENSE-2.0
12
- @REM
13
- @REM Unless required by applicable law or agreed to in writing,
14
- @REM software distributed under the License is distributed on an
15
- @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
- @REM KIND, either express or implied. See the License for the
17
- @REM specific language governing permissions and limitations
18
- @REM under the License.
19
- @REM ----------------------------------------------------------------------------
20
-
21
- @REM ----------------------------------------------------------------------------
22
- @REM Apache Maven Wrapper startup batch script, version 3.3.4
23
- @REM
24
- @REM Optional ENV vars
25
- @REM MVNW_REPOURL - repo url base for downloading maven distribution
26
- @REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
27
- @REM MVNW_VERBOSE - true: enable verbose log; others: silence the output
28
- @REM ----------------------------------------------------------------------------
29
-
30
- @IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0)
31
- @SET __MVNW_CMD__=
32
- @SET __MVNW_ERROR__=
33
- @SET __MVNW_PSMODULEP_SAVE=%PSModulePath%
34
- @SET PSModulePath=
35
- @FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @(
36
- IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B)
37
- )
38
- @SET PSModulePath=%__MVNW_PSMODULEP_SAVE%
39
- @SET __MVNW_PSMODULEP_SAVE=
40
- @SET __MVNW_ARG0_NAME__=
41
- @SET MVNW_USERNAME=
42
- @SET MVNW_PASSWORD=
43
- @IF NOT "%__MVNW_CMD__%"=="" ("%__MVNW_CMD__%" %*)
44
- @echo Cannot start maven from wrapper >&2 && exit /b 1
45
- @GOTO :EOF
46
- : end batch / begin powershell #>
47
-
48
- $ErrorActionPreference = "Stop"
49
- if ($env:MVNW_VERBOSE -eq "true") {
50
- $VerbosePreference = "Continue"
51
- }
52
-
53
- # calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties
54
- $distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl
55
- if (!$distributionUrl) {
56
- Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
57
- }
58
-
59
- switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) {
60
- "maven-mvnd-*" {
61
- $USE_MVND = $true
62
- $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip"
63
- $MVN_CMD = "mvnd.cmd"
64
- break
65
- }
66
- default {
67
- $USE_MVND = $false
68
- $MVN_CMD = $script -replace '^mvnw','mvn'
69
- break
70
- }
71
- }
72
-
73
- # apply MVNW_REPOURL and calculate MAVEN_HOME
74
- # maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
75
- if ($env:MVNW_REPOURL) {
76
- $MVNW_REPO_PATTERN = if ($USE_MVND -eq $False) { "/org/apache/maven/" } else { "/maven/mvnd/" }
77
- $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace "^.*$MVNW_REPO_PATTERN",'')"
78
- }
79
- $distributionUrlName = $distributionUrl -replace '^.*/',''
80
- $distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$',''
81
-
82
- $MAVEN_M2_PATH = "$HOME/.m2"
83
- if ($env:MAVEN_USER_HOME) {
84
- $MAVEN_M2_PATH = "$env:MAVEN_USER_HOME"
85
- }
86
-
87
- if (-not (Test-Path -Path $MAVEN_M2_PATH)) {
88
- New-Item -Path $MAVEN_M2_PATH -ItemType Directory | Out-Null
89
- }
90
-
91
- $MAVEN_WRAPPER_DISTS = $null
92
- if ((Get-Item $MAVEN_M2_PATH).Target[0] -eq $null) {
93
- $MAVEN_WRAPPER_DISTS = "$MAVEN_M2_PATH/wrapper/dists"
94
- } else {
95
- $MAVEN_WRAPPER_DISTS = (Get-Item $MAVEN_M2_PATH).Target[0] + "/wrapper/dists"
96
- }
97
-
98
- $MAVEN_HOME_PARENT = "$MAVEN_WRAPPER_DISTS/$distributionUrlNameMain"
99
- $MAVEN_HOME_NAME = ([System.Security.Cryptography.SHA256]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join ''
100
- $MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME"
101
-
102
- if (Test-Path -Path "$MAVEN_HOME" -PathType Container) {
103
- Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME"
104
- Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"
105
- exit $?
106
- }
107
-
108
- if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) {
109
- Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl"
110
- }
111
-
112
- # prepare tmp dir
113
- $TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile
114
- $TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir"
115
- $TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null
116
- trap {
117
- if ($TMP_DOWNLOAD_DIR.Exists) {
118
- try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
119
- catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
120
- }
121
- }
122
-
123
- New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null
124
-
125
- # Download and Install Apache Maven
126
- Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
127
- Write-Verbose "Downloading from: $distributionUrl"
128
- Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
129
-
130
- $webclient = New-Object System.Net.WebClient
131
- if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) {
132
- $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD)
133
- }
134
- [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
135
- $webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null
136
-
137
- # If specified, validate the SHA-256 sum of the Maven distribution zip file
138
- $distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum
139
- if ($distributionSha256Sum) {
140
- if ($USE_MVND) {
141
- Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties."
142
- }
143
- Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash
144
- if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) {
145
- Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property."
146
- }
147
- }
148
-
149
- # unzip and move
150
- Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null
151
-
152
- # Find the actual extracted directory name (handles snapshots where filename != directory name)
153
- $actualDistributionDir = ""
154
-
155
- # First try the expected directory name (for regular distributions)
156
- $expectedPath = Join-Path "$TMP_DOWNLOAD_DIR" "$distributionUrlNameMain"
157
- $expectedMvnPath = Join-Path "$expectedPath" "bin/$MVN_CMD"
158
- if ((Test-Path -Path $expectedPath -PathType Container) -and (Test-Path -Path $expectedMvnPath -PathType Leaf)) {
159
- $actualDistributionDir = $distributionUrlNameMain
160
- }
161
-
162
- # If not found, search for any directory with the Maven executable (for snapshots)
163
- if (!$actualDistributionDir) {
164
- Get-ChildItem -Path "$TMP_DOWNLOAD_DIR" -Directory | ForEach-Object {
165
- $testPath = Join-Path $_.FullName "bin/$MVN_CMD"
166
- if (Test-Path -Path $testPath -PathType Leaf) {
167
- $actualDistributionDir = $_.Name
168
- }
169
- }
170
- }
171
-
172
- if (!$actualDistributionDir) {
173
- Write-Error "Could not find Maven distribution directory in extracted archive"
174
- }
175
-
176
- Write-Verbose "Found extracted Maven distribution directory: $actualDistributionDir"
177
- Rename-Item -Path "$TMP_DOWNLOAD_DIR/$actualDistributionDir" -NewName $MAVEN_HOME_NAME | Out-Null
178
- try {
179
- Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null
180
- } catch {
181
- if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) {
182
- Write-Error "fail to move MAVEN_HOME"
183
- }
184
- } finally {
185
- try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
186
- catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
187
- }
188
-
189
- Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/pom.xml DELETED
@@ -1,108 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4
- <modelVersion>4.0.0</modelVersion>
5
-
6
- <groupId>com.grupo7</groupId>
7
- <artifactId>moduloFacturacion</artifactId>
8
- <version>0.0.1-SNAPSHOT</version>
9
-
10
- <name>moduloFacturacion</name>
11
- <description>Módulo de facturación y obras sociales</description>
12
-
13
- <parent>
14
- <groupId>org.springframework.boot</groupId>
15
- <artifactId>spring-boot-starter-parent</artifactId>
16
- <version>3.4.4</version>
17
- <relativePath/> <!-- lookup parent from repository -->
18
- </parent>
19
-
20
- <url/>
21
- <licenses>
22
- <license/>
23
- </licenses>
24
- <developers>
25
- <developer/>
26
- </developers>
27
- <scm>
28
- <connection/>
29
- <developerConnection/>
30
- <tag/>
31
- <url/>
32
- </scm>
33
- <properties>
34
- <java.version>17</java.version>
35
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
36
- </properties>
37
- <dependencies>
38
-
39
- <dependency>
40
- <groupId>org.springframework.boot</groupId>
41
- <artifactId>spring-boot-starter-web</artifactId>
42
- </dependency>
43
-
44
- <dependency>
45
- <groupId>org.springframework.boot</groupId>
46
- <artifactId>spring-boot-starter-data-jpa</artifactId>
47
- </dependency>
48
-
49
- <dependency>
50
- <groupId>org.springframework.boot</groupId>
51
- <artifactId>spring-boot-starter-validation</artifactId>
52
- </dependency>
53
-
54
- <dependency>
55
- <groupId>org.springdoc</groupId>
56
- <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
57
- <version>2.8.8</version>
58
- </dependency>
59
-
60
- <dependency>
61
- <groupId>org.postgresql</groupId>
62
- <artifactId>postgresql</artifactId>
63
- </dependency>
64
-
65
- <dependency>
66
- <groupId>org.projectlombok</groupId>
67
- <artifactId>lombok</artifactId>
68
- <version>1.18.38</version>
69
- <scope>provided</scope>
70
- </dependency>
71
-
72
- <dependency>
73
- <groupId>org.springframework.boot</groupId>
74
- <artifactId>spring-boot-starter-test</artifactId>
75
- <scope>test</scope>
76
- </dependency>
77
-
78
- <dependency>
79
- <groupId>com.h2database</groupId>
80
- <artifactId>h2</artifactId>
81
- <scope>test</scope>
82
- </dependency>
83
-
84
- </dependencies>
85
-
86
- <build>
87
- <plugins>
88
- <plugin>
89
- <groupId>org.apache.maven.plugins</groupId>
90
- <artifactId>maven-compiler-plugin</artifactId>
91
- <configuration>
92
- <annotationProcessorPaths>
93
- <path>
94
- <groupId>org.projectlombok</groupId>
95
- <artifactId>lombok</artifactId>
96
- <version>1.18.38</version>
97
- </path>
98
- </annotationProcessorPaths>
99
- </configuration>
100
- </plugin>
101
- <plugin>
102
- <groupId>org.springframework.boot</groupId>
103
- <artifactId>spring-boot-maven-plugin</artifactId>
104
- </plugin>
105
- </plugins>
106
- </build>
107
-
108
- </project>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/postman/modulo-facturacion-manual.postman_collection.json DELETED
@@ -1,560 +0,0 @@
1
- {
2
- "info": {
3
- "_postman_id": "7a2fd4f6-7c80-4b91-94c5-8f0f70d4f5e2",
4
- "name": "Modulo 7 - Facturacion y Obras Sociales",
5
- "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
6
- "description": "Coleccion demo para segunda entrega. Usa {{base_url}} = http://localhost:8080. Los patientId se envian como numeros."
7
- },
8
- "variable": [
9
- {
10
- "key": "base_url",
11
- "value": "http://localhost:8080"
12
- }
13
- ],
14
- "item": [
15
- {
16
- "name": "00 - Smoke / Swagger",
17
- "item": [
18
- {
19
- "name": "GET Swagger UI",
20
- "request": {
21
- "method": "GET",
22
- "header": [],
23
- "url": "{{base_url}}/swagger-ui/index.html"
24
- }
25
- },
26
- {
27
- "name": "GET OpenAPI JSON",
28
- "request": {
29
- "method": "GET",
30
- "header": [],
31
- "url": "{{base_url}}/v3/api-docs"
32
- }
33
- }
34
- ]
35
- },
36
- {
37
- "name": "01 - Entidades Financiadoras",
38
- "item": [
39
- {
40
- "name": "GET Listar activas",
41
- "request": {
42
- "method": "GET",
43
- "header": [],
44
- "url": "{{base_url}}/api/entidades-financiadoras"
45
- }
46
- },
47
- {
48
- "name": "GET Listar incluyendo inactivas",
49
- "request": {
50
- "method": "GET",
51
- "header": [],
52
- "url": "{{base_url}}/api/entidades-financiadoras?incluirInactivas=true"
53
- }
54
- },
55
- {
56
- "name": "GET Por ID",
57
- "request": {
58
- "method": "GET",
59
- "header": [],
60
- "url": "{{base_url}}/api/entidades-financiadoras/1"
61
- }
62
- }
63
- ]
64
- },
65
- {
66
- "name": "02 - Planes",
67
- "item": [
68
- {
69
- "name": "GET Listar activos",
70
- "request": {
71
- "method": "GET",
72
- "header": [],
73
- "url": "{{base_url}}/api/planes"
74
- }
75
- },
76
- {
77
- "name": "GET Por entidad financiadora",
78
- "request": {
79
- "method": "GET",
80
- "header": [],
81
- "url": "{{base_url}}/api/planes?entidadFinanciadoraId=1"
82
- }
83
- },
84
- {
85
- "name": "GET Incluyendo inactivos",
86
- "request": {
87
- "method": "GET",
88
- "header": [],
89
- "url": "{{base_url}}/api/planes?incluirInactivos=true"
90
- }
91
- },
92
- {
93
- "name": "GET Por ID",
94
- "request": {
95
- "method": "GET",
96
- "header": [],
97
- "url": "{{base_url}}/api/planes/1"
98
- }
99
- }
100
- ]
101
- },
102
- {
103
- "name": "03 - Nomenclador Medico",
104
- "item": [
105
- {
106
- "name": "GET Listar activas",
107
- "request": {
108
- "method": "GET",
109
- "header": [],
110
- "url": "{{base_url}}/api/prestaciones-nomenclador"
111
- }
112
- },
113
- {
114
- "name": "GET Incluir inactivas",
115
- "request": {
116
- "method": "GET",
117
- "header": [],
118
- "url": "{{base_url}}/api/prestaciones-nomenclador?incluirInactivas=true"
119
- }
120
- },
121
- {
122
- "name": "GET Por codigo",
123
- "request": {
124
- "method": "GET",
125
- "header": [],
126
- "url": "{{base_url}}/api/prestaciones-nomenclador/codigo/80.01.01"
127
- }
128
- }
129
- ]
130
- },
131
- {
132
- "name": "04 - Convenios y Aranceles",
133
- "item": [
134
- {
135
- "name": "GET Listar",
136
- "request": {
137
- "method": "GET",
138
- "header": [],
139
- "url": "{{base_url}}/api/convenios-aranceles"
140
- }
141
- },
142
- {
143
- "name": "GET Por ID",
144
- "request": {
145
- "method": "GET",
146
- "header": [],
147
- "url": "{{base_url}}/api/convenios-aranceles/1"
148
- }
149
- }
150
- ]
151
- },
152
- {
153
- "name": "05 - Prestaciones Facturables",
154
- "item": [
155
- {
156
- "name": "GET Listar",
157
- "request": {
158
- "method": "GET",
159
- "header": [],
160
- "url": "{{base_url}}/api/prestaciones-facturables"
161
- }
162
- },
163
- {
164
- "name": "POST Crear manual pendiente",
165
- "request": {
166
- "method": "POST",
167
- "header": [
168
- {
169
- "key": "Content-Type",
170
- "value": "application/json"
171
- }
172
- ],
173
- "body": {
174
- "mode": "raw",
175
- "raw": "{\n \"pacienteIdExterno\": 4004,\n \"profesionalIdExterno\": \"PROF-2004\",\n \"planId\": 1,\n \"prestacionId\": 1,\n \"convenioArancelId\": 1,\n \"numeroAfiliadoInformado\": \"AF-112233\",\n \"fechaAtencion\": \"2026-04-10T14:30:00\",\n \"cantidad\": 1,\n \"estadoAuditoria\": \"PENDIENTE\",\n \"montoCubiertoAplicado\": 15000.00,\n \"montoCopagoAplicado\": 2500.00,\n \"montoTotalAplicado\": 17500.00,\n \"observaciones\": \"Prestacion cargada manualmente desde Postman\"\n}"
176
- },
177
- "url": "{{base_url}}/api/prestaciones-facturables"
178
- }
179
- },
180
- {
181
- "name": "POST Integracion prestaciones HCE",
182
- "request": {
183
- "method": "POST",
184
- "header": [
185
- {
186
- "key": "Content-Type",
187
- "value": "application/json"
188
- }
189
- ],
190
- "body": {
191
- "mode": "raw",
192
- "raw": "{\n \"moduloOrigen\": \"HCE\",\n \"pacienteIdExterno\": 10500,\n \"profesionalIdExterno\": \"42\",\n \"planId\": 1,\n \"codigoPrestacion\": \"42.01.01\",\n \"numeroAfiliadoInformado\": \"1234567890\",\n \"fechaAtencion\": \"2026-06-13T10:30:00\",\n \"cantidad\": 1,\n \"idEpisodioExterno\": \"700\",\n \"idActoMedicoExterno\": \"9001-DEMO\",\n \"observaciones\": \"Acto medico registrado desde HCE\"\n}"
193
- },
194
- "url": "{{base_url}}/api/integracion/prestaciones"
195
- }
196
- }
197
- ]
198
- },
199
- {
200
- "name": "06 - Auditoria",
201
- "item": [
202
- {
203
- "name": "PATCH Aprobar prestacion",
204
- "request": {
205
- "method": "PATCH",
206
- "header": [
207
- {
208
- "key": "Content-Type",
209
- "value": "application/json"
210
- }
211
- ],
212
- "body": {
213
- "mode": "raw",
214
- "raw": "{\n \"estadoAuditoria\": \"APROBADO\",\n \"observaciones\": \"Autorizada por auditoria\"\n}"
215
- },
216
- "url": "{{base_url}}/api/prestaciones-facturables/1/auditoria"
217
- }
218
- },
219
- {
220
- "name": "PATCH Rechazar prestacion",
221
- "request": {
222
- "method": "PATCH",
223
- "header": [
224
- {
225
- "key": "Content-Type",
226
- "value": "application/json"
227
- }
228
- ],
229
- "body": {
230
- "mode": "raw",
231
- "raw": "{\n \"estadoAuditoria\": \"RECHAZADO\",\n \"observaciones\": \"Documentacion insuficiente\"\n}"
232
- },
233
- "url": "{{base_url}}/api/prestaciones-facturables/1/auditoria"
234
- }
235
- }
236
- ]
237
- },
238
- {
239
- "name": "07 - Facturas Emitidas",
240
- "item": [
241
- {
242
- "name": "GET Listar",
243
- "request": {
244
- "method": "GET",
245
- "header": [],
246
- "url": "{{base_url}}/api/facturas-emitidas"
247
- }
248
- },
249
- {
250
- "name": "POST Liquidacion aseguradora",
251
- "request": {
252
- "method": "POST",
253
- "header": [
254
- {
255
- "key": "Content-Type",
256
- "value": "application/json"
257
- }
258
- ],
259
- "body": {
260
- "mode": "raw",
261
- "raw": "{\n \"idObraSocial\": \"1\",\n \"periodoHasta\": \"2026-12-31\"\n}"
262
- },
263
- "url": "{{base_url}}/api/facturas-emitidas/liquidaciones/aseguradoras"
264
- }
265
- },
266
- {
267
- "name": "POST Factura copago manual",
268
- "request": {
269
- "method": "POST",
270
- "header": [
271
- {
272
- "key": "Content-Type",
273
- "value": "application/json"
274
- }
275
- ],
276
- "body": {
277
- "mode": "raw",
278
- "raw": "{\n \"idPaciente\": 10500,\n \"idsPrestaciones\": [1]\n}"
279
- },
280
- "url": "{{base_url}}/api/facturas-emitidas/copagos"
281
- }
282
- }
283
- ]
284
- },
285
- {
286
- "name": "08 - Facturas Recibidas",
287
- "item": [
288
- {
289
- "name": "GET Listar",
290
- "request": {
291
- "method": "GET",
292
- "header": [],
293
- "url": "{{base_url}}/api/facturas-recibidas"
294
- }
295
- },
296
- {
297
- "name": "POST Simular factura recibida",
298
- "request": {
299
- "method": "POST",
300
- "header": [
301
- {
302
- "key": "Content-Type",
303
- "value": "application/json"
304
- }
305
- ],
306
- "body": {
307
- "mode": "raw",
308
- "raw": "{\n \"moduloOrigen\": \"MODULO_3_FARMACIA\",\n \"idTransaccionOrigen\": \"FR-DEMO-POSTMAN-001\",\n \"cuitProveedor\": \"30-11111111-1\",\n \"razonSocialProveedor\": \"Proveedor Demo\",\n \"tipoComprobante\": \"FACTURA_A\",\n \"numeroComprobante\": \"A-0001-00000001\",\n \"fechaEmision\": \"2026-06-20\",\n \"fechaVencimiento\": \"2026-07-20\",\n \"conceptoResumido\": \"Compra de insumos mockeada\",\n \"montoTotal\": 10000.00\n}"
309
- },
310
- "url": "{{base_url}}/api/facturas-recibidas/simular"
311
- }
312
- }
313
- ]
314
- },
315
- {
316
- "name": "09 - Caja",
317
- "item": [
318
- {
319
- "name": "GET Saldo e historial",
320
- "request": {
321
- "method": "GET",
322
- "header": [],
323
- "url": "{{base_url}}/api/caja"
324
- }
325
- }
326
- ]
327
- },
328
- {
329
- "name": "10 - Integracion M1 / HCE",
330
- "item": [
331
- {
332
- "name": "POST Registrar acto medico facturable",
333
- "request": {
334
- "method": "POST",
335
- "header": [
336
- {
337
- "key": "Content-Type",
338
- "value": "application/json"
339
- }
340
- ],
341
- "body": {
342
- "mode": "raw",
343
- "raw": "{\n \"moduloOrigen\": \"MODULO_1_HCE\",\n \"pacienteIdExterno\": 10500,\n \"profesionalIdExterno\": \"PROF-100\",\n \"planId\": 1,\n \"codigoPrestacion\": \"42.01.01\",\n \"numeroAfiliadoInformado\": \"1234567890\",\n \"fechaAtencion\": \"2026-06-24T15:30:00\",\n \"cantidad\": 1,\n \"idEpisodioExterno\": \"700\",\n \"idActoMedicoExterno\": \"ACT-POSTMAN-001\",\n \"observaciones\": \"Acto medico desde HCE\"\n}"
344
- },
345
- "url": "{{base_url}}/api/integracion/prestaciones"
346
- }
347
- }
348
- ]
349
- },
350
- {
351
- "name": "11 - Integracion M3 / Farmacia",
352
- "item": [
353
- {
354
- "name": "POST Recibir orden compra",
355
- "request": {
356
- "method": "POST",
357
- "header": [
358
- {
359
- "key": "Content-Type",
360
- "value": "application/json"
361
- }
362
- ],
363
- "body": {
364
- "mode": "raw",
365
- "raw": "{\n \"ordenCompraId\": \"OC-POSTMAN-001\",\n \"solicitudCompraId\": \"SC-POSTMAN-001\",\n \"prioridad\": \"NORMAL\",\n \"proveedorSugeridoId\": \"PROV-001\",\n \"proveedorSugeridoRazonSocial\": \"Proveedor Salud Demo\",\n \"proveedorSugeridoCuit\": \"30-11111111-1\",\n \"motivo\": \"Reposicion de farmacia\",\n \"fechaGeneracion\": \"2026-06-25T10:00:00\",\n \"callbackUrl\": \"http://localhost:3003/api/callbacks/compras\",\n \"items\": [\n {\n \"productoId\": \"PARA-500\",\n \"nombre\": \"Paracetamol 500mg\",\n \"cantidadSolicitada\": 100,\n \"unidad\": \"caja\",\n \"especificaciones\": \"Blister x 10\"\n }\n ]\n}"
366
- },
367
- "url": "{{base_url}}/api/compras/ordenes-compra"
368
- }
369
- },
370
- {
371
- "name": "GET Listar OC",
372
- "request": {
373
- "method": "GET",
374
- "header": [],
375
- "url": "{{base_url}}/api/compras/ordenes-compra"
376
- }
377
- },
378
- {
379
- "name": "POST Adjudicar OC",
380
- "request": {
381
- "method": "POST",
382
- "header": [
383
- {
384
- "key": "Content-Type",
385
- "value": "application/json"
386
- }
387
- ],
388
- "body": {
389
- "mode": "raw",
390
- "raw": "{\n \"proveedorAdjudicadoRazonSocial\": \"Proveedor Salud Demo\",\n \"proveedorAdjudicadoCuit\": \"30-11111111-1\",\n \"fechaEntregaEstimada\": \"2026-07-05T10:00:00\",\n \"observaciones\": \"Adjudicacion demo\",\n \"items\": [\n {\n \"productoId\": \"PARA-500\",\n \"cantidadAprobada\": 100,\n \"precioUnitario\": 100.00\n }\n ]\n}"
391
- },
392
- "url": "{{base_url}}/api/compras/ordenes-compra/1/adjudicar"
393
- }
394
- },
395
- {
396
- "name": "POST Rechazar OC",
397
- "request": {
398
- "method": "POST",
399
- "header": [
400
- {
401
- "key": "Content-Type",
402
- "value": "application/json"
403
- }
404
- ],
405
- "body": {
406
- "mode": "raw",
407
- "raw": "{\n \"motivoRechazo\": \"Presupuesto rechazado en demo\"\n}"
408
- },
409
- "url": "{{base_url}}/api/compras/ordenes-compra/1/rechazar"
410
- }
411
- },
412
- {
413
- "name": "POST Reenviar callback",
414
- "request": {
415
- "method": "POST",
416
- "header": [],
417
- "url": "{{base_url}}/api/compras/ordenes-compra/1/reenviar-callback"
418
- }
419
- }
420
- ]
421
- },
422
- {
423
- "name": "12 - Integracion M6 / Internacion",
424
- "item": [
425
- {
426
- "name": "POST Cama lista payload minimo",
427
- "request": {
428
- "method": "POST",
429
- "header": [
430
- {
431
- "key": "Content-Type",
432
- "value": "application/json"
433
- }
434
- ],
435
- "body": {
436
- "mode": "raw",
437
- "raw": "{\n \"evento\": \"CAMA_LISTA\",\n \"cama_id\": 101,\n \"paciente_id\": 10500,\n \"timestamp_evento\": \"2026-06-25T10:00:00Z\"\n}"
438
- },
439
- "url": "{{base_url}}/api/v1/webhooks/internacion/cama-lista"
440
- }
441
- },
442
- {
443
- "name": "POST Cierre episodio completo",
444
- "request": {
445
- "method": "POST",
446
- "header": [
447
- {
448
- "key": "Content-Type",
449
- "value": "application/json"
450
- }
451
- ],
452
- "body": {
453
- "mode": "raw",
454
- "raw": "{\n \"evento\": \"CIERRE_INTERNACION\",\n \"idEventoExterno\": \"M6-CIERRE-INT-000123\",\n \"idInternacionExterna\": \"INT-000123\",\n \"idEpisodioExterno\": \"700\",\n \"idPacienteExterno\": 10500,\n \"fechaIngreso\": \"2026-06-20T14:30:00Z\",\n \"fechaAlta\": \"2026-06-25T10:00:00Z\",\n \"tipoAlta\": \"ALTA_MEDICA\",\n \"medicoFirmanteId\": \"42\",\n \"camasUtilizadas\": [\n {\n \"camaId\": 101,\n \"sector\": \"SALA_COMUN\",\n \"tipoCama\": \"SALA_COMUN\",\n \"desde\": \"2026-06-20T14:30:00Z\",\n \"hasta\": \"2026-06-22T09:00:00Z\"\n }\n ],\n \"timestampEvento\": \"2026-06-25T10:05:00Z\"\n}"
455
- },
456
- "url": "{{base_url}}/api/integracion/internacion/cierre-episodio"
457
- }
458
- },
459
- {
460
- "name": "POST Cierre duplicado",
461
- "request": {
462
- "method": "POST",
463
- "header": [
464
- {
465
- "key": "Content-Type",
466
- "value": "application/json"
467
- }
468
- ],
469
- "body": {
470
- "mode": "raw",
471
- "raw": "{\n \"evento\": \"CIERRE_INTERNACION\",\n \"idEventoExterno\": \"M6-CIERRE-INT-000123\",\n \"idEpisodioExterno\": \"700\",\n \"idPacienteExterno\": 10500,\n \"timestampEvento\": \"2026-06-25T10:05:00Z\"\n}"
472
- },
473
- "url": "{{base_url}}/api/integracion/internacion/cierre-episodio"
474
- }
475
- },
476
- {
477
- "name": "POST Invalido sin paciente",
478
- "request": {
479
- "method": "POST",
480
- "header": [
481
- {
482
- "key": "Content-Type",
483
- "value": "application/json"
484
- }
485
- ],
486
- "body": {
487
- "mode": "raw",
488
- "raw": "{\n \"evento\": \"CAMA_LISTA\",\n \"cama_id\": 101,\n \"timestamp_evento\": \"2026-06-25T10:00:00Z\"\n}"
489
- },
490
- "url": "{{base_url}}/api/v1/webhooks/internacion/cama-lista"
491
- }
492
- }
493
- ]
494
- },
495
- {
496
- "name": "13 - Integracion M8 / Portal y Pagos",
497
- "item": [
498
- {
499
- "name": "GET Copagos paciente 10500",
500
- "request": {
501
- "method": "GET",
502
- "header": [],
503
- "url": "{{base_url}}/api/integracion/copago/paciente/10500"
504
- }
505
- },
506
- {
507
- "name": "POST Pago aprobado",
508
- "request": {
509
- "method": "POST",
510
- "header": [
511
- {
512
- "key": "Content-Type",
513
- "value": "application/json"
514
- }
515
- ],
516
- "body": {
517
- "mode": "raw",
518
- "raw": "{\n \"pacienteIdExterno\": 10500,\n \"prestacionesFacturablesIds\": [1],\n \"montoPagado\": 2500.00,\n \"moneda\": \"ARS\",\n \"medioPago\": \"TARJETA\",\n \"estadoPago\": \"APROBADO\",\n \"idTransaccionExterna\": \"M8-PAGO-POSTMAN-APROBADO-001\",\n \"fechaPago\": \"2026-06-25T18:30:00\",\n \"moduloOrigen\": \"MODULO_8\"\n}"
519
- },
520
- "url": "{{base_url}}/api/integracion/pagos/notificacion"
521
- }
522
- },
523
- {
524
- "name": "POST Pago rechazado",
525
- "request": {
526
- "method": "POST",
527
- "header": [
528
- {
529
- "key": "Content-Type",
530
- "value": "application/json"
531
- }
532
- ],
533
- "body": {
534
- "mode": "raw",
535
- "raw": "{\n \"pacienteIdExterno\": 10500,\n \"prestacionesFacturablesIds\": [1],\n \"montoPagado\": 2500.00,\n \"moneda\": \"ARS\",\n \"medioPago\": \"TARJETA\",\n \"estadoPago\": \"RECHAZADO\",\n \"idTransaccionExterna\": \"M8-PAGO-POSTMAN-RECHAZADO-001\",\n \"fechaPago\": \"2026-06-25T18:45:00\",\n \"moduloOrigen\": \"MODULO_8\"\n}"
536
- },
537
- "url": "{{base_url}}/api/integracion/pagos/notificacion"
538
- }
539
- },
540
- {
541
- "name": "POST Pago duplicado",
542
- "request": {
543
- "method": "POST",
544
- "header": [
545
- {
546
- "key": "Content-Type",
547
- "value": "application/json"
548
- }
549
- ],
550
- "body": {
551
- "mode": "raw",
552
- "raw": "{\n \"pacienteIdExterno\": 10500,\n \"prestacionesFacturablesIds\": [1],\n \"montoPagado\": 2500.00,\n \"moneda\": \"ARS\",\n \"medioPago\": \"TARJETA\",\n \"estadoPago\": \"APROBADO\",\n \"idTransaccionExterna\": \"M8-PAGO-POSTMAN-APROBADO-001\",\n \"fechaPago\": \"2026-06-25T18:30:00\",\n \"moduloOrigen\": \"MODULO_8\"\n}"
553
- },
554
- "url": "{{base_url}}/api/integracion/pagos/notificacion"
555
- }
556
- }
557
- ]
558
- }
559
- ]
560
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/scripts/crear_db_postgres.sql DELETED
@@ -1,12 +0,0 @@
1
- -- Ejecutar conectado a la base postgres con un usuario que tenga permisos para crear bases.
2
- -- Ejemplo con psql en Windows:
3
- -- "C:\Program Files\PostgreSQL\17\bin\psql.exe" -U postgres -d postgres -h localhost -p 5432 -f scripts/crear_db_postgres.sql
4
- --
5
- -- Si ejecutas esto desde una herramienta que no soporta \gexec, corre manualmente:
6
- -- CREATE DATABASE grupo7_db OWNER postgres ENCODING 'UTF8';
7
-
8
- SELECT 'CREATE DATABASE grupo7_db OWNER postgres ENCODING ''UTF8'''
9
- WHERE NOT EXISTS (
10
- SELECT FROM pg_database WHERE datname = 'grupo7_db'
11
- )
12
- \gexec
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/scripts/crear_tablas_compras.sql DELETED
@@ -1,65 +0,0 @@
1
- -- ============================================================
2
- -- Módulo 7 — Tablas de integración con Módulo 3 Farmacia
3
- -- Ejecutar contra la base grupo7_db luego de crear_db_postgres.sql
4
- -- ============================================================
5
-
6
- -- Orden de compra recibida desde Farmacia
7
- CREATE TABLE IF NOT EXISTS ordenes_compra_farmacia (
8
- id BIGSERIAL PRIMARY KEY,
9
- orden_compra_id VARCHAR(100) NOT NULL,
10
- solicitud_compra_id VARCHAR(100) NOT NULL,
11
- prioridad VARCHAR(20) NOT NULL,
12
- proveedor_sugerido_id VARCHAR(100),
13
- proveedor_sugerido_razon_social VARCHAR(200),
14
- proveedor_sugerido_cuit VARCHAR(20),
15
- motivo VARCHAR(500),
16
- fecha_generacion TIMESTAMP,
17
- callback_url VARCHAR(500) NOT NULL,
18
- referencia_externa VARCHAR(30),
19
- estado_orden_compra VARCHAR(20) NOT NULL DEFAULT 'RECIBIDA',
20
- estado_callback VARCHAR(20) NOT NULL DEFAULT 'PENDIENTE',
21
- proveedor_adjudicado_razon_social VARCHAR(200),
22
- proveedor_adjudicado_cuit VARCHAR(20),
23
- fecha_aprobacion TIMESTAMP,
24
- fecha_entrega_estimada TIMESTAMP,
25
- observaciones VARCHAR(1000),
26
- monto_total_adjudicado NUMERIC(12, 2),
27
- error_callback VARCHAR(1000),
28
- fecha_ultimo_callback TIMESTAMP,
29
- fecha_recepcion TIMESTAMP NOT NULL
30
- );
31
-
32
- -- Unique constraints
33
- ALTER TABLE ordenes_compra_farmacia
34
- ADD CONSTRAINT uk_ocf_orden_compra_id UNIQUE (orden_compra_id);
35
-
36
- ALTER TABLE ordenes_compra_farmacia
37
- ADD CONSTRAINT uk_ocf_referencia_externa UNIQUE (referencia_externa);
38
-
39
- -- Indexes for common query patterns
40
- CREATE INDEX IF NOT EXISTS idx_ocf_estado_orden ON ordenes_compra_farmacia (estado_orden_compra);
41
- CREATE INDEX IF NOT EXISTS idx_ocf_estado_callback ON ordenes_compra_farmacia (estado_callback);
42
- CREATE INDEX IF NOT EXISTS idx_ocf_fecha_recepcion ON ordenes_compra_farmacia (fecha_recepcion DESC);
43
-
44
- -- ============================================================
45
- -- Ítems de la orden de compra
46
- -- ============================================================
47
-
48
- CREATE TABLE IF NOT EXISTS ordenes_compra_items (
49
- id BIGSERIAL PRIMARY KEY,
50
- orden_compra_farmacia_id BIGINT NOT NULL,
51
- producto_id VARCHAR(100) NOT NULL,
52
- nombre VARCHAR(200) NOT NULL,
53
- cantidad_solicitada INTEGER NOT NULL,
54
- unidad VARCHAR(50),
55
- especificaciones VARCHAR(500),
56
- cantidad_aprobada INTEGER,
57
- precio_unitario NUMERIC(12, 2),
58
- subtotal NUMERIC(12, 2),
59
-
60
- CONSTRAINT fk_oci_orden FOREIGN KEY (orden_compra_farmacia_id)
61
- REFERENCES ordenes_compra_farmacia (id)
62
- ON DELETE CASCADE
63
- );
64
-
65
- CREATE INDEX IF NOT EXISTS idx_oci_orden_id ON ordenes_compra_items (orden_compra_farmacia_id);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/scripts/datos_prueba.sql DELETED
@@ -1,962 +0,0 @@
1
- -- ============================================================
2
- -- Datos de prueba para el modulo de facturacion
3
- -- Compatible con PostgreSQL local.
4
- -- La app tambien lo ejecuta automaticamente al iniciar.
5
- --
6
- -- El script intenta ser idempotente: si lo corres dos veces,
7
- -- no deberia duplicar los datos principales.
8
- -- ============================================================
9
-
10
- -- ============================================================
11
- -- 1. Entidades financiadoras
12
- -- ============================================================
13
- INSERT INTO entidades_financiadoras (nombre, cuit, tipo_financiador, activa)
14
- SELECT 'OSDE', '30-12345678-9', 'PREPAGA', TRUE
15
- WHERE NOT EXISTS (
16
- SELECT 1
17
- FROM entidades_financiadoras
18
- WHERE cuit = '30-12345678-9'
19
- );
20
-
21
- INSERT INTO entidades_financiadoras (nombre, cuit, tipo_financiador, activa)
22
- SELECT 'IOMA', '30-87654321-0', 'OBRA_SOCIAL', TRUE
23
- WHERE NOT EXISTS (
24
- SELECT 1
25
- FROM entidades_financiadoras
26
- WHERE cuit = '30-87654321-0'
27
- );
28
-
29
- INSERT INTO entidades_financiadoras (nombre, cuit, tipo_financiador, activa)
30
- SELECT 'Cobertura Publica Provincial', '30-11223344-5', 'ESTATAL', TRUE
31
- WHERE NOT EXISTS (
32
- SELECT 1
33
- FROM entidades_financiadoras
34
- WHERE cuit = '30-11223344-5'
35
- );
36
-
37
- -- ============================================================
38
- -- 2. Planes
39
- -- ============================================================
40
- INSERT INTO planes (entidad_financiadora_id, nombre, codigo, activo)
41
- SELECT ef.id, 'Plan 210', '210', TRUE
42
- FROM entidades_financiadoras ef
43
- WHERE ef.cuit = '30-12345678-9'
44
- AND NOT EXISTS (
45
- SELECT 1
46
- FROM planes p
47
- WHERE p.entidad_financiadora_id = ef.id
48
- AND p.codigo = '210'
49
- );
50
-
51
- INSERT INTO planes (entidad_financiadora_id, nombre, codigo, activo)
52
- SELECT ef.id, 'Plan 310', '310', TRUE
53
- FROM entidades_financiadoras ef
54
- WHERE ef.cuit = '30-12345678-9'
55
- AND NOT EXISTS (
56
- SELECT 1
57
- FROM planes p
58
- WHERE p.entidad_financiadora_id = ef.id
59
- AND p.codigo = '310'
60
- );
61
-
62
- INSERT INTO planes (entidad_financiadora_id, nombre, codigo, activo)
63
- SELECT ef.id, 'Afiliados Generales', 'AG', TRUE
64
- FROM entidades_financiadoras ef
65
- WHERE ef.cuit = '30-87654321-0'
66
- AND NOT EXISTS (
67
- SELECT 1
68
- FROM planes p
69
- WHERE p.entidad_financiadora_id = ef.id
70
- AND p.codigo = 'AG'
71
- );
72
-
73
- INSERT INTO planes (entidad_financiadora_id, nombre, codigo, activo)
74
- SELECT ef.id, 'Cobertura Basica', 'CB', TRUE
75
- FROM entidades_financiadoras ef
76
- WHERE ef.cuit = '30-11223344-5'
77
- AND NOT EXISTS (
78
- SELECT 1
79
- FROM planes p
80
- WHERE p.entidad_financiadora_id = ef.id
81
- AND p.codigo = 'CB'
82
- );
83
-
84
- -- ============================================================
85
- -- 3. Prestaciones del nomenclador
86
- -- ============================================================
87
- INSERT INTO prestaciones_nomenclador (codigo_nomenclador, descripcion, tipo_prestacion, activa)
88
- SELECT '42.01.01', 'Consulta medica en consultorio', 'CONSULTA', TRUE
89
- WHERE NOT EXISTS (
90
- SELECT 1
91
- FROM prestaciones_nomenclador
92
- WHERE codigo_nomenclador = '42.01.01'
93
- );
94
-
95
- INSERT INTO prestaciones_nomenclador (codigo_nomenclador, descripcion, tipo_prestacion, activa)
96
- SELECT '42.02.15', 'Electrocardiograma', 'PRACTICA', TRUE
97
- WHERE NOT EXISTS (
98
- SELECT 1
99
- FROM prestaciones_nomenclador
100
- WHERE codigo_nomenclador = '42.02.15'
101
- );
102
-
103
- INSERT INTO prestaciones_nomenclador (codigo_nomenclador, descripcion, tipo_prestacion, activa)
104
- SELECT '55.10.03', 'Hemograma completo', 'LABORATORIO', TRUE
105
- WHERE NOT EXISTS (
106
- SELECT 1
107
- FROM prestaciones_nomenclador
108
- WHERE codigo_nomenclador = '55.10.03'
109
- );
110
-
111
- INSERT INTO prestaciones_nomenclador (codigo_nomenclador, descripcion, tipo_prestacion, activa)
112
- SELECT '70.00.10', 'Kit de curacion descartable', 'INSUMO', TRUE
113
- WHERE NOT EXISTS (
114
- SELECT 1
115
- FROM prestaciones_nomenclador
116
- WHERE codigo_nomenclador = '70.00.10'
117
- );
118
-
119
- INSERT INTO prestaciones_nomenclador (codigo_nomenclador, descripcion, tipo_prestacion, activa)
120
- SELECT '80.01.01', 'Dia cama sala comun', 'PRACTICA', TRUE
121
- WHERE NOT EXISTS (
122
- SELECT 1
123
- FROM prestaciones_nomenclador
124
- WHERE codigo_nomenclador = '80.01.01'
125
- );
126
-
127
- INSERT INTO prestaciones_nomenclador (codigo_nomenclador, descripcion, tipo_prestacion, activa)
128
- SELECT '80.01.02', 'Dia cama UTI', 'PRACTICA', TRUE
129
- WHERE NOT EXISTS (
130
- SELECT 1
131
- FROM prestaciones_nomenclador
132
- WHERE codigo_nomenclador = '80.01.02'
133
- );
134
-
135
- INSERT INTO prestaciones_nomenclador (codigo_nomenclador, descripcion, tipo_prestacion, activa)
136
- SELECT '80.01.03', 'Uso de quirofano', 'PRACTICA', TRUE
137
- WHERE NOT EXISTS (
138
- SELECT 1
139
- FROM prestaciones_nomenclador
140
- WHERE codigo_nomenclador = '80.01.03'
141
- );
142
-
143
- -- ============================================================
144
- -- 4. Convenios / aranceles
145
- -- ============================================================
146
- INSERT INTO convenios_aranceles (
147
- plan_id,
148
- prestacion_id,
149
- valor_cubierto,
150
- valor_copago,
151
- fecha_vigencia_desde,
152
- fecha_vigencia_hasta,
153
- activo
154
- )
155
- SELECT p.id, pn.id, 15000.00, 2500.00, '2026-01-01 00:00:00', NULL, TRUE
156
- FROM planes p
157
- JOIN entidades_financiadoras ef ON ef.id = p.entidad_financiadora_id
158
- JOIN prestaciones_nomenclador pn ON pn.codigo_nomenclador = '42.01.01'
159
- WHERE ef.cuit = '30-12345678-9'
160
- AND p.codigo = '210'
161
- AND NOT EXISTS (
162
- SELECT 1
163
- FROM convenios_aranceles ca
164
- WHERE ca.plan_id = p.id
165
- AND ca.prestacion_id = pn.id
166
- AND ca.fecha_vigencia_desde = '2026-01-01 00:00:00'
167
- );
168
-
169
- INSERT INTO convenios_aranceles (
170
- plan_id,
171
- prestacion_id,
172
- valor_cubierto,
173
- valor_copago,
174
- fecha_vigencia_desde,
175
- fecha_vigencia_hasta,
176
- activo
177
- )
178
- SELECT p.id, pn.id, 22000.00, 3500.00, '2026-01-01 00:00:00', NULL, TRUE
179
- FROM planes p
180
- JOIN entidades_financiadoras ef ON ef.id = p.entidad_financiadora_id
181
- JOIN prestaciones_nomenclador pn ON pn.codigo_nomenclador = '42.02.15'
182
- WHERE ef.cuit = '30-12345678-9'
183
- AND p.codigo = '210'
184
- AND NOT EXISTS (
185
- SELECT 1
186
- FROM convenios_aranceles ca
187
- WHERE ca.plan_id = p.id
188
- AND ca.prestacion_id = pn.id
189
- AND ca.fecha_vigencia_desde = '2026-01-01 00:00:00'
190
- );
191
-
192
- INSERT INTO convenios_aranceles (
193
- plan_id,
194
- prestacion_id,
195
- valor_cubierto,
196
- valor_copago,
197
- fecha_vigencia_desde,
198
- fecha_vigencia_hasta,
199
- activo
200
- )
201
- SELECT p.id, pn.id, 12000.00, 0.00, '2026-01-01 00:00:00', NULL, TRUE
202
- FROM planes p
203
- JOIN entidades_financiadoras ef ON ef.id = p.entidad_financiadora_id
204
- JOIN prestaciones_nomenclador pn ON pn.codigo_nomenclador = '42.01.01'
205
- WHERE ef.cuit = '30-87654321-0'
206
- AND p.codigo = 'AG'
207
- AND NOT EXISTS (
208
- SELECT 1
209
- FROM convenios_aranceles ca
210
- WHERE ca.plan_id = p.id
211
- AND ca.prestacion_id = pn.id
212
- AND ca.fecha_vigencia_desde = '2026-01-01 00:00:00'
213
- );
214
-
215
- INSERT INTO convenios_aranceles (
216
- plan_id,
217
- prestacion_id,
218
- valor_cubierto,
219
- valor_copago,
220
- fecha_vigencia_desde,
221
- fecha_vigencia_hasta,
222
- activo
223
- )
224
- SELECT p.id, pn.id, 9000.00, 0.00, '2026-01-01 00:00:00', NULL, TRUE
225
- FROM planes p
226
- JOIN entidades_financiadoras ef ON ef.id = p.entidad_financiadora_id
227
- JOIN prestaciones_nomenclador pn ON pn.codigo_nomenclador = '55.10.03'
228
- WHERE ef.cuit = '30-11223344-5'
229
- AND p.codigo = 'CB'
230
- AND NOT EXISTS (
231
- SELECT 1
232
- FROM convenios_aranceles ca
233
- WHERE ca.plan_id = p.id
234
- AND ca.prestacion_id = pn.id
235
- AND ca.fecha_vigencia_desde = '2026-01-01 00:00:00'
236
- );
237
-
238
- -- ============================================================
239
- -- 5. Prestaciones facturables
240
- -- ============================================================
241
- INSERT INTO prestaciones_facturables (
242
- paciente_id_externo,
243
- profesional_id_externo,
244
- plan_id,
245
- prestacion_id,
246
- convenio_arancel_id,
247
- numero_afiliado_informado,
248
- fecha_atencion,
249
- cantidad,
250
- estado_auditoria,
251
- monto_cubierto_aplicado,
252
- monto_copago_aplicado,
253
- monto_total_aplicado,
254
- observaciones
255
- )
256
- SELECT
257
- '10500',
258
- 'PROF-2001',
259
- p.id,
260
- pn.id,
261
- ca.id,
262
- 'AF-778899',
263
- '2026-04-08 09:30:00',
264
- 1,
265
- 'APROBADO',
266
- 15000.00,
267
- 2500.00,
268
- 17500.00,
269
- 'Consulta de control ambulatorio aprobada para prueba de copago M8'
270
- FROM planes p
271
- JOIN entidades_financiadoras ef ON ef.id = p.entidad_financiadora_id
272
- JOIN prestaciones_nomenclador pn ON pn.codigo_nomenclador = '42.01.01'
273
- JOIN convenios_aranceles ca ON ca.plan_id = p.id AND ca.prestacion_id = pn.id
274
- WHERE ef.cuit = '30-12345678-9'
275
- AND p.codigo = '210'
276
- AND ca.fecha_vigencia_desde = '2026-01-01 00:00:00'
277
- AND NOT EXISTS (
278
- SELECT 1
279
- FROM prestaciones_facturables pf
280
- WHERE pf.paciente_id_externo = '10500'
281
- AND pf.profesional_id_externo = 'PROF-2001'
282
- AND pf.fecha_atencion = '2026-04-08 09:30:00'
283
- );
284
-
285
- INSERT INTO prestaciones_facturables (
286
- paciente_id_externo,
287
- profesional_id_externo,
288
- plan_id,
289
- prestacion_id,
290
- convenio_arancel_id,
291
- numero_afiliado_informado,
292
- fecha_atencion,
293
- cantidad,
294
- estado_auditoria,
295
- monto_cubierto_aplicado,
296
- monto_copago_aplicado,
297
- monto_total_aplicado,
298
- observaciones
299
- )
300
- SELECT
301
- '2002',
302
- 'PROF-2002',
303
- p.id,
304
- pn.id,
305
- ca.id,
306
- 'IOMA-452211',
307
- '2026-04-08 10:15:00',
308
- 1,
309
- 'APROBADO',
310
- 12000.00,
311
- 0.00,
312
- 12000.00,
313
- 'Consulta auditada y aprobada'
314
- FROM planes p
315
- JOIN entidades_financiadoras ef ON ef.id = p.entidad_financiadora_id
316
- JOIN prestaciones_nomenclador pn ON pn.codigo_nomenclador = '42.01.01'
317
- JOIN convenios_aranceles ca ON ca.plan_id = p.id AND ca.prestacion_id = pn.id
318
- WHERE ef.cuit = '30-87654321-0'
319
- AND p.codigo = 'AG'
320
- AND ca.fecha_vigencia_desde = '2026-01-01 00:00:00'
321
- AND NOT EXISTS (
322
- SELECT 1
323
- FROM prestaciones_facturables pf
324
- WHERE pf.paciente_id_externo = '2002'
325
- AND pf.profesional_id_externo = 'PROF-2002'
326
- AND pf.fecha_atencion = '2026-04-08 10:15:00'
327
- );
328
-
329
- INSERT INTO prestaciones_facturables (
330
- paciente_id_externo,
331
- profesional_id_externo,
332
- plan_id,
333
- prestacion_id,
334
- convenio_arancel_id,
335
- numero_afiliado_informado,
336
- fecha_atencion,
337
- cantidad,
338
- estado_auditoria,
339
- monto_cubierto_aplicado,
340
- monto_copago_aplicado,
341
- monto_total_aplicado,
342
- observaciones
343
- )
344
- SELECT
345
- '3003',
346
- 'PROF-2003',
347
- p.id,
348
- pn.id,
349
- ca.id,
350
- 'PUB-90001',
351
- '2026-04-09 08:00:00',
352
- 1,
353
- 'RECHAZADO',
354
- 9000.00,
355
- 0.00,
356
- 9000.00,
357
- 'Prestacion observada por falta de documentacion respaldatoria'
358
- FROM planes p
359
- JOIN entidades_financiadoras ef ON ef.id = p.entidad_financiadora_id
360
- JOIN prestaciones_nomenclador pn ON pn.codigo_nomenclador = '55.10.03'
361
- JOIN convenios_aranceles ca ON ca.plan_id = p.id AND ca.prestacion_id = pn.id
362
- WHERE ef.cuit = '30-11223344-5'
363
- AND p.codigo = 'CB'
364
- AND ca.fecha_vigencia_desde = '2026-01-01 00:00:00'
365
- AND NOT EXISTS (
366
- SELECT 1
367
- FROM prestaciones_facturables pf
368
- WHERE pf.paciente_id_externo = '3003'
369
- AND pf.profesional_id_externo = 'PROF-2003'
370
- AND pf.fecha_atencion = '2026-04-09 08:00:00'
371
- );
372
-
373
- -- ============================================================
374
- -- 6. Facturas emitidas (liquidaciones ya procesadas)
375
- -- ============================================================
376
- INSERT INTO facturas_emitidas (
377
- numero_comprobante,
378
- tipo_comprobante,
379
- entidad_pagadora_id,
380
- fecha_emision,
381
- fecha_vencimiento,
382
- monto_total
383
- )
384
- SELECT 'LIQ-2026-0001', 'LIQUIDACION', 'OSDE', '2026-03-01', '2026-03-31', 87500.00
385
- WHERE NOT EXISTS (
386
- SELECT 1 FROM facturas_emitidas WHERE numero_comprobante = 'LIQ-2026-0001'
387
- );
388
-
389
- INSERT INTO facturas_emitidas (
390
- numero_comprobante,
391
- tipo_comprobante,
392
- entidad_pagadora_id,
393
- fecha_emision,
394
- fecha_vencimiento,
395
- monto_total
396
- )
397
- SELECT 'LIQ-2026-0002', 'LIQUIDACION', 'IOMA', '2026-03-01', '2026-03-31', 60000.00
398
- WHERE NOT EXISTS (
399
- SELECT 1 FROM facturas_emitidas WHERE numero_comprobante = 'LIQ-2026-0002'
400
- );
401
-
402
- INSERT INTO facturas_emitidas (
403
- numero_comprobante,
404
- tipo_comprobante,
405
- entidad_pagadora_id,
406
- fecha_emision,
407
- fecha_vencimiento,
408
- monto_total
409
- )
410
- SELECT 'COP-2026-0001', 'COPAGO', '10500', '2026-04-10', '2026-04-30', 12500.00
411
- WHERE NOT EXISTS (
412
- SELECT 1 FROM facturas_emitidas WHERE numero_comprobante = 'COP-2026-0001'
413
- );
414
-
415
- -- ============================================================
416
- -- 7. Movimientos de caja (INGRESO de las facturas anteriores)
417
- -- ============================================================
418
- INSERT INTO movimientos_caja (
419
- fecha_movimiento,
420
- tipo_movimiento,
421
- monto,
422
- concepto,
423
- entidad_referencia_id
424
- )
425
- SELECT
426
- '2026-03-15 10:00:00',
427
- 'INGRESO',
428
- 87500.00,
429
- 'Cobro liquidacion OSDE marzo 2026 - LIQ-2026-0001',
430
- fe.id
431
- FROM facturas_emitidas fe
432
- WHERE fe.numero_comprobante = 'LIQ-2026-0001'
433
- AND NOT EXISTS (
434
- SELECT 1 FROM movimientos_caja mc WHERE mc.entidad_referencia_id = fe.id AND mc.tipo_movimiento = 'INGRESO'
435
- );
436
-
437
- INSERT INTO movimientos_caja (
438
- fecha_movimiento,
439
- tipo_movimiento,
440
- monto,
441
- concepto,
442
- entidad_referencia_id
443
- )
444
- SELECT
445
- '2026-03-20 11:30:00',
446
- 'INGRESO',
447
- 60000.00,
448
- 'Cobro liquidacion IOMA marzo 2026 - LIQ-2026-0002',
449
- fe.id
450
- FROM facturas_emitidas fe
451
- WHERE fe.numero_comprobante = 'LIQ-2026-0002'
452
- AND NOT EXISTS (
453
- SELECT 1 FROM movimientos_caja mc WHERE mc.entidad_referencia_id = fe.id AND mc.tipo_movimiento = 'INGRESO'
454
- );
455
-
456
- INSERT INTO movimientos_caja (
457
- fecha_movimiento,
458
- tipo_movimiento,
459
- monto,
460
- concepto,
461
- entidad_referencia_id
462
- )
463
- SELECT
464
- '2026-04-10 09:00:00',
465
- 'INGRESO',
466
- 12500.00,
467
- 'Cobro copago paciente 10500 - COP-2026-0001',
468
- fe.id
469
- FROM facturas_emitidas fe
470
- WHERE fe.numero_comprobante = 'COP-2026-0001'
471
- AND NOT EXISTS (
472
- SELECT 1 FROM movimientos_caja mc WHERE mc.entidad_referencia_id = fe.id AND mc.tipo_movimiento = 'INGRESO'
473
- );
474
-
475
- -- ============================================================
476
- -- 8. Datos demo segunda entrega
477
- -- ============================================================
478
-
479
- INSERT INTO entidades_financiadoras (nombre, cuit, tipo_financiador, activa)
480
- SELECT 'Prepaga Demo Inactiva', '30-99887766-5', 'PREPAGA', FALSE
481
- WHERE NOT EXISTS (
482
- SELECT 1 FROM entidades_financiadoras WHERE cuit = '30-99887766-5'
483
- );
484
-
485
- INSERT INTO planes (entidad_financiadora_id, nombre, codigo, activo)
486
- SELECT ef.id, 'Plan Demo Inactivo', 'DEMO-INACTIVO', FALSE
487
- FROM entidades_financiadoras ef
488
- WHERE ef.cuit = '30-12345678-9'
489
- AND NOT EXISTS (
490
- SELECT 1 FROM planes p WHERE p.entidad_financiadora_id = ef.id AND p.codigo = 'DEMO-INACTIVO'
491
- );
492
-
493
- INSERT INTO prestaciones_nomenclador (codigo_nomenclador, descripcion, tipo_prestacion, activa)
494
- SELECT '99.99.99', 'Prestacion inactiva para demo', 'PRACTICA', FALSE
495
- WHERE NOT EXISTS (
496
- SELECT 1 FROM prestaciones_nomenclador WHERE codigo_nomenclador = '99.99.99'
497
- );
498
-
499
- INSERT INTO convenios_aranceles (
500
- plan_id,
501
- prestacion_id,
502
- valor_cubierto,
503
- valor_copago,
504
- fecha_vigencia_desde,
505
- fecha_vigencia_hasta,
506
- activo
507
- )
508
- SELECT p.id, pn.id, 45000.00, 5000.00, '2026-01-01 00:00:00', NULL, TRUE
509
- FROM planes p
510
- JOIN entidades_financiadoras ef ON ef.id = p.entidad_financiadora_id
511
- JOIN prestaciones_nomenclador pn ON pn.codigo_nomenclador = '80.01.01'
512
- WHERE ef.cuit = '30-12345678-9'
513
- AND p.codigo = '210'
514
- AND NOT EXISTS (
515
- SELECT 1
516
- FROM convenios_aranceles ca
517
- WHERE ca.plan_id = p.id
518
- AND ca.prestacion_id = pn.id
519
- AND ca.fecha_vigencia_desde = '2026-01-01 00:00:00'
520
- );
521
-
522
- INSERT INTO convenios_aranceles (
523
- plan_id,
524
- prestacion_id,
525
- valor_cubierto,
526
- valor_copago,
527
- fecha_vigencia_desde,
528
- fecha_vigencia_hasta,
529
- activo
530
- )
531
- SELECT p.id, pn.id, 80000.00, 10000.00, '2026-01-01 00:00:00', NULL, TRUE
532
- FROM planes p
533
- JOIN entidades_financiadoras ef ON ef.id = p.entidad_financiadora_id
534
- JOIN prestaciones_nomenclador pn ON pn.codigo_nomenclador = '80.01.02'
535
- WHERE ef.cuit = '30-12345678-9'
536
- AND p.codigo = '210'
537
- AND NOT EXISTS (
538
- SELECT 1
539
- FROM convenios_aranceles ca
540
- WHERE ca.plan_id = p.id
541
- AND ca.prestacion_id = pn.id
542
- AND ca.fecha_vigencia_desde = '2026-01-01 00:00:00'
543
- );
544
-
545
- INSERT INTO convenios_aranceles (
546
- plan_id,
547
- prestacion_id,
548
- valor_cubierto,
549
- valor_copago,
550
- fecha_vigencia_desde,
551
- fecha_vigencia_hasta,
552
- activo
553
- )
554
- SELECT p.id, pn.id, 30000.00, 0.00, '2025-01-01 00:00:00', '2025-12-31 23:59:59', FALSE
555
- FROM planes p
556
- JOIN entidades_financiadoras ef ON ef.id = p.entidad_financiadora_id
557
- JOIN prestaciones_nomenclador pn ON pn.codigo_nomenclador = '42.02.15'
558
- WHERE ef.cuit = '30-12345678-9'
559
- AND p.codigo = '210'
560
- AND NOT EXISTS (
561
- SELECT 1
562
- FROM convenios_aranceles ca
563
- WHERE ca.plan_id = p.id
564
- AND ca.prestacion_id = pn.id
565
- AND ca.fecha_vigencia_desde = '2025-01-01 00:00:00'
566
- );
567
-
568
- INSERT INTO prestaciones_facturables (
569
- modulo_origen,
570
- paciente_id_externo,
571
- profesional_id_externo,
572
- id_episodio_externo,
573
- id_acto_medico_externo,
574
- plan_id,
575
- prestacion_id,
576
- convenio_arancel_id,
577
- numero_afiliado_informado,
578
- fecha_atencion,
579
- cantidad,
580
- estado_auditoria,
581
- monto_cubierto_aplicado,
582
- monto_copago_aplicado,
583
- monto_total_aplicado,
584
- observaciones
585
- )
586
- SELECT
587
- 'MODULO_1_HCE',
588
- '10500',
589
- '42',
590
- '700',
591
- 'ACT-DEMO-10500-001',
592
- p.id,
593
- pn.id,
594
- ca.id,
595
- '1234567890',
596
- '2026-06-24 15:30:00',
597
- 1,
598
- 'PENDIENTE',
599
- ca.valor_cubierto,
600
- ca.valor_copago,
601
- ca.valor_cubierto + ca.valor_copago,
602
- 'Acto medico HCE pendiente de auditoria para demo'
603
- FROM planes p
604
- JOIN entidades_financiadoras ef ON ef.id = p.entidad_financiadora_id
605
- JOIN prestaciones_nomenclador pn ON pn.codigo_nomenclador = '42.02.15'
606
- JOIN convenios_aranceles ca ON ca.plan_id = p.id AND ca.prestacion_id = pn.id AND ca.activo = TRUE
607
- WHERE ef.cuit = '30-12345678-9'
608
- AND p.codigo = '210'
609
- AND NOT EXISTS (
610
- SELECT 1 FROM prestaciones_facturables pf WHERE pf.modulo_origen = 'MODULO_1_HCE' AND pf.id_acto_medico_externo = 'ACT-DEMO-10500-001'
611
- );
612
-
613
- INSERT INTO prestaciones_facturables (
614
- paciente_id_externo,
615
- profesional_id_externo,
616
- plan_id,
617
- prestacion_id,
618
- convenio_arancel_id,
619
- numero_afiliado_informado,
620
- fecha_atencion,
621
- cantidad,
622
- estado_auditoria,
623
- monto_cubierto_aplicado,
624
- monto_copago_aplicado,
625
- monto_total_aplicado,
626
- observaciones
627
- )
628
- SELECT
629
- '4004',
630
- 'PROF-4004',
631
- p.id,
632
- pn.id,
633
- ca.id,
634
- 'AF-4004',
635
- '2026-04-12 11:00:00',
636
- 1,
637
- 'APROBADO',
638
- ca.valor_cubierto,
639
- ca.valor_copago,
640
- ca.valor_cubierto + ca.valor_copago,
641
- 'Prestacion aprobada lista para liquidar aseguradora'
642
- FROM planes p
643
- JOIN entidades_financiadoras ef ON ef.id = p.entidad_financiadora_id
644
- JOIN prestaciones_nomenclador pn ON pn.codigo_nomenclador = '42.02.15'
645
- JOIN convenios_aranceles ca ON ca.plan_id = p.id AND ca.prestacion_id = pn.id AND ca.activo = TRUE
646
- WHERE ef.cuit = '30-12345678-9'
647
- AND p.codigo = '210'
648
- AND NOT EXISTS (
649
- SELECT 1 FROM prestaciones_facturables pf WHERE pf.paciente_id_externo = '4004' AND pf.fecha_atencion = '2026-04-12 11:00:00'
650
- );
651
-
652
- INSERT INTO facturas_recibidas (
653
- modulo_origen,
654
- id_transaccion_origen,
655
- cuit_proveedor,
656
- razon_social_proveedor,
657
- numero_comprobante,
658
- fecha_emision,
659
- fecha_vencimiento,
660
- concepto,
661
- monto_total,
662
- estado_aprobacion
663
- )
664
- SELECT 'MODULO_3_FARMACIA', 'FR-DEMO-PENDIENTE', '30-55555555-5', 'Proveedor Demo Pendiente', 'FC-PEND-001', '2026-06-01', '2026-06-30', 'Factura pendiente de aprobacion', 25000.00, 'PENDIENTE'
665
- WHERE NOT EXISTS (SELECT 1 FROM facturas_recibidas WHERE id_transaccion_origen = 'FR-DEMO-PENDIENTE');
666
-
667
- INSERT INTO facturas_recibidas (
668
- modulo_origen,
669
- id_transaccion_origen,
670
- cuit_proveedor,
671
- razon_social_proveedor,
672
- numero_comprobante,
673
- fecha_emision,
674
- fecha_vencimiento,
675
- concepto,
676
- monto_total,
677
- estado_aprobacion
678
- )
679
- SELECT 'MODULO_3_FARMACIA', 'FR-DEMO-APROBADA', '30-66666666-6', 'Proveedor Demo Aprobado', 'FC-APR-001', '2026-06-02', '2026-07-02', 'Factura aprobada de insumos', 15000.00, 'APROBADA'
680
- WHERE NOT EXISTS (SELECT 1 FROM facturas_recibidas WHERE id_transaccion_origen = 'FR-DEMO-APROBADA');
681
-
682
- INSERT INTO facturas_recibidas (
683
- modulo_origen,
684
- id_transaccion_origen,
685
- cuit_proveedor,
686
- razon_social_proveedor,
687
- numero_comprobante,
688
- fecha_emision,
689
- fecha_vencimiento,
690
- concepto,
691
- monto_total,
692
- estado_aprobacion
693
- )
694
- SELECT 'MODULO_3_FARMACIA', 'FR-DEMO-RECHAZADA', '30-77777777-7', 'Proveedor Demo Rechazado', 'FC-RECH-001', '2026-06-03', '2026-07-03', 'Factura rechazada por saldo insuficiente', 999999.00, 'RECHAZADA'
695
- WHERE NOT EXISTS (SELECT 1 FROM facturas_recibidas WHERE id_transaccion_origen = 'FR-DEMO-RECHAZADA');
696
-
697
- INSERT INTO movimientos_caja (fecha_movimiento, tipo_movimiento, monto, concepto, entidad_referencia_id)
698
- SELECT '2026-06-05 09:00:00', 'EGRESO', 15000.00, 'Egreso compra adjudicada Farmacia - OC-DEMO-ADJUDICADA', NULL
699
- WHERE NOT EXISTS (
700
- SELECT 1 FROM movimientos_caja WHERE concepto = 'Egreso compra adjudicada Farmacia - OC-DEMO-ADJUDICADA'
701
- );
702
-
703
- INSERT INTO ordenes_compra_farmacia (
704
- orden_compra_id,
705
- solicitud_compra_id,
706
- prioridad,
707
- proveedor_sugerido_id,
708
- proveedor_sugerido_razon_social,
709
- proveedor_sugerido_cuit,
710
- motivo,
711
- fecha_generacion,
712
- callback_url,
713
- referencia_externa,
714
- estado_orden_compra,
715
- estado_callback,
716
- proveedor_adjudicado_razon_social,
717
- proveedor_adjudicado_cuit,
718
- fecha_aprobacion,
719
- fecha_entrega_estimada,
720
- observaciones,
721
- monto_total_adjudicado,
722
- error_callback,
723
- fecha_ultimo_callback,
724
- fecha_recepcion
725
- )
726
- SELECT 'OC-DEMO-RECIBIDA', 'SC-DEMO-001', 'NORMAL', 'PROV-001', 'Proveedor Salud Demo', '30-11111111-1', 'Reposicion de insumos para demo', '2026-06-10 09:00:00', 'http://localhost:3003/api/callbacks/compras', 'OCF-DEMO-001', 'RECIBIDA', 'PENDIENTE', NULL, NULL, NULL, NULL, 'Lista para adjudicar en demo', NULL, NULL, NULL, '2026-06-10 09:05:00'
727
- WHERE NOT EXISTS (SELECT 1 FROM ordenes_compra_farmacia WHERE orden_compra_id = 'OC-DEMO-RECIBIDA');
728
-
729
- INSERT INTO ordenes_compra_farmacia (
730
- orden_compra_id,
731
- solicitud_compra_id,
732
- prioridad,
733
- proveedor_sugerido_id,
734
- proveedor_sugerido_razon_social,
735
- proveedor_sugerido_cuit,
736
- motivo,
737
- fecha_generacion,
738
- callback_url,
739
- referencia_externa,
740
- estado_orden_compra,
741
- estado_callback,
742
- proveedor_adjudicado_razon_social,
743
- proveedor_adjudicado_cuit,
744
- fecha_aprobacion,
745
- fecha_entrega_estimada,
746
- observaciones,
747
- monto_total_adjudicado,
748
- error_callback,
749
- fecha_ultimo_callback,
750
- fecha_recepcion
751
- )
752
- SELECT 'OC-DEMO-ADJUDICADA', 'SC-DEMO-002', 'ALTA', 'PROV-002', 'Insumos Criticos SRL', '30-22222222-2', 'Compra adjudicada demo', '2026-06-11 10:00:00', 'http://localhost:3003/api/callbacks/compras', 'OCF-DEMO-002', 'ADJUDICADA', 'ENVIADO', 'Insumos Criticos SRL', '30-22222222-2', '2026-06-11 11:00:00', '2026-06-18 11:00:00', 'Adjudicada para demo', 15000.00, NULL, '2026-06-11 11:05:00', '2026-06-11 10:05:00'
753
- WHERE NOT EXISTS (SELECT 1 FROM ordenes_compra_farmacia WHERE orden_compra_id = 'OC-DEMO-ADJUDICADA');
754
-
755
- INSERT INTO ordenes_compra_farmacia (
756
- orden_compra_id,
757
- solicitud_compra_id,
758
- prioridad,
759
- proveedor_sugerido_id,
760
- proveedor_sugerido_razon_social,
761
- proveedor_sugerido_cuit,
762
- motivo,
763
- fecha_generacion,
764
- callback_url,
765
- referencia_externa,
766
- estado_orden_compra,
767
- estado_callback,
768
- proveedor_adjudicado_razon_social,
769
- proveedor_adjudicado_cuit,
770
- fecha_aprobacion,
771
- fecha_entrega_estimada,
772
- observaciones,
773
- monto_total_adjudicado,
774
- error_callback,
775
- fecha_ultimo_callback,
776
- fecha_recepcion
777
- )
778
- SELECT 'OC-DEMO-RECHAZADA', 'SC-DEMO-003', 'BAJA', 'PROV-003', 'Descartables Demo SA', '30-33333333-3', 'Compra rechazada demo', '2026-06-12 10:00:00', 'http://localhost:3003/api/callbacks/compras', 'OCF-DEMO-003', 'RECHAZADA', 'ENVIADO', NULL, NULL, NULL, NULL, 'Rechazada por presupuesto', NULL, NULL, '2026-06-12 10:30:00', '2026-06-12 10:05:00'
779
- WHERE NOT EXISTS (SELECT 1 FROM ordenes_compra_farmacia WHERE orden_compra_id = 'OC-DEMO-RECHAZADA');
780
-
781
- INSERT INTO ordenes_compra_farmacia (
782
- orden_compra_id,
783
- solicitud_compra_id,
784
- prioridad,
785
- proveedor_sugerido_id,
786
- proveedor_sugerido_razon_social,
787
- proveedor_sugerido_cuit,
788
- motivo,
789
- fecha_generacion,
790
- callback_url,
791
- referencia_externa,
792
- estado_orden_compra,
793
- estado_callback,
794
- proveedor_adjudicado_razon_social,
795
- proveedor_adjudicado_cuit,
796
- fecha_aprobacion,
797
- fecha_entrega_estimada,
798
- observaciones,
799
- monto_total_adjudicado,
800
- error_callback,
801
- fecha_ultimo_callback,
802
- fecha_recepcion
803
- )
804
- SELECT 'OC-DEMO-CALLBACK-ERROR', 'SC-DEMO-004', 'URGENTE', 'PROV-004', 'Red Local Caida SA', '30-44444444-4', 'Callback con error para reenviar', '2026-06-13 10:00:00', 'http://localhost:3999/api/callbacks/compras', 'OCF-DEMO-004', 'ADJUDICADA', 'ERROR', 'Red Local Caida SA', '30-44444444-4', '2026-06-13 11:00:00', '2026-06-20 11:00:00', 'Caso para reenviar callback', 12000.00, 'Connection refused', '2026-06-13 11:05:00', '2026-06-13 10:05:00'
805
- WHERE NOT EXISTS (SELECT 1 FROM ordenes_compra_farmacia WHERE orden_compra_id = 'OC-DEMO-CALLBACK-ERROR');
806
-
807
- INSERT INTO ordenes_compra_items (
808
- orden_compra_farmacia_id,
809
- producto_id,
810
- nombre,
811
- cantidad_solicitada,
812
- unidad,
813
- especificaciones,
814
- cantidad_aprobada,
815
- precio_unitario,
816
- subtotal
817
- )
818
- SELECT oc.id, 'PARA-500', 'Paracetamol 500mg', 100, 'caja', 'Blister x 10', NULL, NULL, NULL
819
- FROM ordenes_compra_farmacia oc
820
- WHERE oc.orden_compra_id = 'OC-DEMO-RECIBIDA'
821
- AND NOT EXISTS (SELECT 1 FROM ordenes_compra_items oi WHERE oi.orden_compra_farmacia_id = oc.id AND oi.producto_id = 'PARA-500');
822
-
823
- INSERT INTO ordenes_compra_items (
824
- orden_compra_farmacia_id,
825
- producto_id,
826
- nombre,
827
- cantidad_solicitada,
828
- unidad,
829
- especificaciones,
830
- cantidad_aprobada,
831
- precio_unitario,
832
- subtotal
833
- )
834
- SELECT oc.id, 'GUANTE-L', 'Guantes descartables talle L', 50, 'caja', 'Caja x 100 unidades', 50, 120.00, 6000.00
835
- FROM ordenes_compra_farmacia oc
836
- WHERE oc.orden_compra_id = 'OC-DEMO-ADJUDICADA'
837
- AND NOT EXISTS (SELECT 1 FROM ordenes_compra_items oi WHERE oi.orden_compra_farmacia_id = oc.id AND oi.producto_id = 'GUANTE-L');
838
-
839
- INSERT INTO ordenes_compra_items (
840
- orden_compra_farmacia_id,
841
- producto_id,
842
- nombre,
843
- cantidad_solicitada,
844
- unidad,
845
- especificaciones,
846
- cantidad_aprobada,
847
- precio_unitario,
848
- subtotal
849
- )
850
- SELECT oc.id, 'SOL-FIS-500', 'Solucion fisiologica 500ml', 60, 'unidad', 'Bolsa 500ml', 60, 150.00, 9000.00
851
- FROM ordenes_compra_farmacia oc
852
- WHERE oc.orden_compra_id = 'OC-DEMO-ADJUDICADA'
853
- AND NOT EXISTS (SELECT 1 FROM ordenes_compra_items oi WHERE oi.orden_compra_farmacia_id = oc.id AND oi.producto_id = 'SOL-FIS-500');
854
-
855
- INSERT INTO ordenes_compra_items (
856
- orden_compra_farmacia_id,
857
- producto_id,
858
- nombre,
859
- cantidad_solicitada,
860
- unidad,
861
- especificaciones,
862
- cantidad_aprobada,
863
- precio_unitario,
864
- subtotal
865
- )
866
- SELECT oc.id, 'JERINGA-10', 'Jeringas 10ml', 100, 'unidad', 'Esteriles', NULL, NULL, NULL
867
- FROM ordenes_compra_farmacia oc
868
- WHERE oc.orden_compra_id = 'OC-DEMO-CALLBACK-ERROR'
869
- AND NOT EXISTS (SELECT 1 FROM ordenes_compra_items oi WHERE oi.orden_compra_farmacia_id = oc.id AND oi.producto_id = 'JERINGA-10');
870
-
871
- INSERT INTO integraciones_internacion_m6 (
872
- idempotency_key,
873
- evento,
874
- cama_id,
875
- id_paciente_externo,
876
- id_internacion_externa,
877
- id_episodio_externo,
878
- fecha_ingreso,
879
- fecha_alta,
880
- tipo_alta,
881
- medico_firmante_id,
882
- diagnostico_ingreso,
883
- timestamp_evento,
884
- estado,
885
- mensaje,
886
- liquidacion_id,
887
- payload_original,
888
- created_at,
889
- updated_at
890
- )
891
- SELECT 'MODULO_6:M6-CIERRE-INT-000700', 'CIERRE_INTERNACION', '101', '10500', 'INT-000700', '700', '2026-06-20 14:30:00+00', '2026-06-25 10:00:00+00', 'ALTA_MEDICA', '42', 'Neumonia', '2026-06-25 10:05:00+00', 'PROCESADO', 'Evento procesado correctamente desde M1/HCE', NULL, '{"camasUtilizadas":[{"camaId":101,"sector":"SALA_COMUN","tipoCama":"SALA_COMUN","desde":"2026-06-20T14:30:00Z","hasta":"2026-06-22T09:00:00Z"}]}', NOW(), NOW()
892
- WHERE NOT EXISTS (SELECT 1 FROM integraciones_internacion_m6 WHERE idempotency_key = 'MODULO_6:M6-CIERRE-INT-000700');
893
-
894
- INSERT INTO integraciones_internacion_m6 (
895
- idempotency_key,
896
- evento,
897
- cama_id,
898
- id_paciente_externo,
899
- id_internacion_externa,
900
- id_episodio_externo,
901
- fecha_ingreso,
902
- fecha_alta,
903
- tipo_alta,
904
- medico_firmante_id,
905
- diagnostico_ingreso,
906
- timestamp_evento,
907
- estado,
908
- mensaje,
909
- liquidacion_id,
910
- payload_original,
911
- created_at,
912
- updated_at
913
- )
914
- SELECT 'MODULO_6:M6-CIERRE-PENDIENTE-M1', 'CIERRE_INTERNACION', '201', '10500', 'INT-000701', '701', '2026-06-21 08:00:00+00', '2026-06-23 09:30:00+00', 'ALTA_MEDICA', '42', 'Control postquirurgico', '2026-06-23 09:35:00+00', 'RECIBIDO_PENDIENTE_CONSULTA_M1', 'No se pudo consultar M1/HCE. Pendiente reintento.', NULL, '{"motivo":"M1 no disponible en demo"}', NOW(), NOW()
915
- WHERE NOT EXISTS (SELECT 1 FROM integraciones_internacion_m6 WHERE idempotency_key = 'MODULO_6:M6-CIERRE-PENDIENTE-M1');
916
-
917
- INSERT INTO pagos_integracion_m8 (
918
- paciente_id_externo,
919
- monto_pagado,
920
- moneda,
921
- medio_pago,
922
- estado_pago,
923
- id_transaccion_externa,
924
- fecha_pago,
925
- modulo_origen,
926
- factura_emitida_id,
927
- mensaje_error,
928
- created_at,
929
- updated_at
930
- )
931
- SELECT '10500', 2500.00, 'ARS', 'TARJETA', 'APROBADO', 'M8-PAGO-DEMO-APROBADO', '2026-06-19 18:30:00', 'MODULO_8', fe.id, NULL, NOW(), NOW()
932
- FROM facturas_emitidas fe
933
- WHERE fe.numero_comprobante = 'COP-2026-0001'
934
- AND NOT EXISTS (SELECT 1 FROM pagos_integracion_m8 WHERE id_transaccion_externa = 'M8-PAGO-DEMO-APROBADO');
935
-
936
- INSERT INTO pagos_integracion_m8 (
937
- paciente_id_externo,
938
- monto_pagado,
939
- moneda,
940
- medio_pago,
941
- estado_pago,
942
- id_transaccion_externa,
943
- fecha_pago,
944
- modulo_origen,
945
- factura_emitida_id,
946
- mensaje_error,
947
- created_at,
948
- updated_at
949
- )
950
- SELECT '10500', 1.00, 'ARS', 'TARJETA', 'RECHAZADO', 'M8-PAGO-DEMO-RECHAZADO', '2026-06-19 18:45:00', 'MODULO_8', NULL, 'Pago rechazado por monto insuficiente o prestacion invalida', NOW(), NOW()
951
- WHERE NOT EXISTS (SELECT 1 FROM pagos_integracion_m8 WHERE id_transaccion_externa = 'M8-PAGO-DEMO-RECHAZADO');
952
-
953
- -- ============================================================
954
- -- 9. Consultas rapidas para verificar la carga
955
- -- ============================================================
956
- SELECT * FROM entidades_financiadoras;
957
- SELECT * FROM planes;
958
- SELECT * FROM prestaciones_nomenclador;
959
- SELECT * FROM convenios_aranceles;
960
- SELECT * FROM prestaciones_facturables;
961
- SELECT * FROM facturas_emitidas;
962
- SELECT * FROM movimientos_caja;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/ModuloFacturacionApplication.java DELETED
@@ -1,12 +0,0 @@
1
- package com.grupo7.modulofacturacion;
2
-
3
- import org.springframework.boot.SpringApplication;
4
- import org.springframework.boot.autoconfigure.SpringBootApplication;
5
-
6
- @SpringBootApplication
7
- public class ModuloFacturacionApplication {
8
-
9
- public static void main(String[] args) {
10
- SpringApplication.run(ModuloFacturacionApplication.class, args);
11
- }
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/client/Modulo1Client.java DELETED
@@ -1,53 +0,0 @@
1
- package com.grupo7.modulofacturacion.client;
2
-
3
- import com.grupo7.modulofacturacion.controller.dto.ActosMedicosM1Response;
4
- import com.grupo7.modulofacturacion.controller.dto.CoberturaPacienteM1Response;
5
- import com.grupo7.modulofacturacion.controller.dto.EpisodioM1Response;
6
- import org.springframework.beans.factory.annotation.Value;
7
- import org.springframework.stereotype.Component;
8
- import org.springframework.web.client.RestTemplate;
9
- import org.springframework.web.util.UriComponentsBuilder;
10
-
11
- @Component
12
- public class Modulo1Client {
13
-
14
- private final RestTemplate restTemplate;
15
- private final String baseUrl;
16
-
17
- public Modulo1Client(
18
- RestTemplate restTemplate,
19
- @Value("${modulo1.hce.url:http://localhost:8001}") String baseUrl
20
- ) {
21
- this.restTemplate = restTemplate;
22
- this.baseUrl = baseUrl;
23
- }
24
-
25
- public CoberturaPacienteM1Response obtenerCoberturaPaciente(Long idPaciente) {
26
- return restTemplate.getForObject(
27
- buildUrl("/api/v1/patients/{idPaciente}/insurance", idPaciente),
28
- CoberturaPacienteM1Response.class
29
- );
30
- }
31
-
32
- public EpisodioM1Response obtenerEpisodio(Long idPaciente, String idEpisodio) {
33
- return restTemplate.getForObject(
34
- buildUrl("/api/v1/patients/{idPaciente}/episodes/{idEpisodio}", idPaciente, idEpisodio),
35
- EpisodioM1Response.class
36
- );
37
- }
38
-
39
- public ActosMedicosM1Response obtenerActosMedicos(Long idPaciente, String idEpisodio) {
40
- return restTemplate.getForObject(
41
- buildUrl("/api/v1/patients/{idPaciente}/episodes/{idEpisodio}/medical-acts", idPaciente, idEpisodio),
42
- ActosMedicosM1Response.class
43
- );
44
- }
45
-
46
- private String buildUrl(String path, Object... uriVariables) {
47
- return UriComponentsBuilder
48
- .fromUriString(baseUrl)
49
- .path(path)
50
- .buildAndExpand(uriVariables)
51
- .toUriString();
52
- }
53
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/config/RestTemplateConfig.java DELETED
@@ -1,14 +0,0 @@
1
- package com.grupo7.modulofacturacion.config;
2
-
3
- import org.springframework.context.annotation.Bean;
4
- import org.springframework.context.annotation.Configuration;
5
- import org.springframework.web.client.RestTemplate;
6
-
7
- @Configuration
8
- public class RestTemplateConfig {
9
-
10
- @Bean
11
- public RestTemplate restTemplate() {
12
- return new RestTemplate();
13
- }
14
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/config/WebConfig.java DELETED
@@ -1,19 +0,0 @@
1
- package com.grupo7.modulofacturacion.config;
2
-
3
- import org.springframework.context.annotation.Configuration;
4
- import org.springframework.web.servlet.config.annotation.CorsRegistry;
5
- import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
6
-
7
- @Configuration
8
- public class WebConfig implements WebMvcConfigurer {
9
-
10
- @Override
11
- public void addCorsMappings(CorsRegistry registry) {
12
- registry.addMapping("/api/**")
13
- .allowedOriginPatterns("*")
14
- .allowedMethods("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS")
15
- .allowedHeaders("*")
16
- .allowCredentials(false)
17
- .maxAge(3600);
18
- }
19
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/CajaController.java DELETED
@@ -1,46 +0,0 @@
1
- package com.grupo7.modulofacturacion.controller;
2
-
3
- import com.grupo7.modulofacturacion.controller.dto.CajaResumenResponse;
4
- import com.grupo7.modulofacturacion.controller.dto.MovimientoCajaResponse;
5
- import com.grupo7.modulofacturacion.controller.dto.PageResponse;
6
- import com.grupo7.modulofacturacion.model.MovimientoCaja;
7
- import com.grupo7.modulofacturacion.service.CajaService;
8
- import io.swagger.v3.oas.annotations.tags.Tag;
9
- import org.springframework.data.domain.Page;
10
- import org.springframework.data.domain.Pageable;
11
- import org.springframework.data.web.PageableDefault;
12
- import org.springframework.web.bind.annotation.GetMapping;
13
- import org.springframework.web.bind.annotation.RequestMapping;
14
- import org.springframework.web.bind.annotation.RestController;
15
-
16
- @RestController
17
- @RequestMapping("/api/caja")
18
- @Tag(name = "Caja", description = "Saldo e historial de ingresos/egresos generados por facturacion y compras.")
19
- public class CajaController {
20
-
21
- private final CajaService cajaService;
22
-
23
- public CajaController(CajaService cajaService) {
24
- this.cajaService = cajaService;
25
- }
26
-
27
- @GetMapping
28
- public CajaResumenResponse obtenerEstadoDeCaja(@PageableDefault(size = 20) Pageable pageable) {
29
- Page<MovimientoCaja> historial = cajaService.obtenerHistorial(pageable);
30
- return new CajaResumenResponse(
31
- cajaService.obtenerSaldoActual(),
32
- PageResponse.from(historial, this::toResponse)
33
- );
34
- }
35
-
36
- private MovimientoCajaResponse toResponse(MovimientoCaja movimiento) {
37
- return new MovimientoCajaResponse(
38
- movimiento.getId(),
39
- movimiento.getFechaMovimiento(),
40
- movimiento.getTipoMovimiento(),
41
- movimiento.getMonto(),
42
- movimiento.getConcepto(),
43
- movimiento.getEntidadReferenciaId()
44
- );
45
- }
46
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/ComprasController.java DELETED
@@ -1,90 +0,0 @@
1
- package com.grupo7.modulofacturacion.controller;
2
-
3
- import com.grupo7.modulofacturacion.controller.dto.AdjudicarOrdenCompraRequest;
4
- import com.grupo7.modulofacturacion.controller.dto.OrdenCompraAcuseResponse;
5
- import com.grupo7.modulofacturacion.controller.dto.OrdenCompraFarmaciaRequest;
6
- import com.grupo7.modulofacturacion.controller.dto.OrdenCompraResponse;
7
- import com.grupo7.modulofacturacion.controller.dto.RechazarOrdenCompraRequest;
8
- import com.grupo7.modulofacturacion.service.ComprasService;
9
- import io.swagger.v3.oas.annotations.Operation;
10
- import io.swagger.v3.oas.annotations.tags.Tag;
11
- import jakarta.validation.Valid;
12
- import java.util.List;
13
- import org.springframework.http.HttpStatus;
14
- import org.springframework.web.bind.annotation.GetMapping;
15
- import org.springframework.web.bind.annotation.PathVariable;
16
- import org.springframework.web.bind.annotation.PostMapping;
17
- import org.springframework.web.bind.annotation.RequestBody;
18
- import org.springframework.web.bind.annotation.RequestMapping;
19
- import org.springframework.web.bind.annotation.ResponseStatus;
20
- import org.springframework.web.bind.annotation.RestController;
21
-
22
- @RestController
23
- @RequestMapping("/api/compras/ordenes-compra")
24
- @Tag(name = "Compras Farmacia / Modulo 3", description = "Integracion con Modulo 3 Farmacia para gestion de ordenes de compra")
25
- public class ComprasController {
26
-
27
- private final ComprasService comprasService;
28
-
29
- public ComprasController(ComprasService comprasService) {
30
- this.comprasService = comprasService;
31
- }
32
-
33
- @PostMapping
34
- @ResponseStatus(HttpStatus.CREATED)
35
- @Operation(
36
- summary = "Recibir orden de compra desde Farmacia",
37
- description = "Endpoint receptor que Farmacia llama al crear una OC. "
38
- + "Registra la orden con estado RECIBIDA y devuelve acuse inmediato. "
39
- + "Si la OC ya existe (mismo ordenCompraId) devuelve la referenciaExterna original sin duplicar."
40
- )
41
- public OrdenCompraAcuseResponse recibirOrdenCompra(@Valid @RequestBody OrdenCompraFarmaciaRequest request) {
42
- return comprasService.recibirOrdenCompra(request);
43
- }
44
-
45
- @GetMapping
46
- @Operation(summary = "Listar ordenes de compra", description = "Devuelve todas las OC ordenadas por fecha de recepcion descendente.")
47
- public List<OrdenCompraResponse> listar() {
48
- return comprasService.listarOrdenes();
49
- }
50
-
51
- @GetMapping("/{id}")
52
- @Operation(summary = "Obtener detalle de una orden de compra")
53
- public OrdenCompraResponse obtener(@PathVariable Long id) {
54
- return comprasService.obtenerOrden(id);
55
- }
56
-
57
- @PostMapping("/{id}/adjudicar")
58
- @Operation(
59
- summary = "Adjudicar orden de compra",
60
- description = "Registra proveedor adjudicado, precios y cantidades aprobadas. "
61
- + "Valida saldo de caja, registra el egreso y notifica a Farmacia mediante callback."
62
- )
63
- public OrdenCompraResponse adjudicar(
64
- @PathVariable Long id,
65
- @Valid @RequestBody AdjudicarOrdenCompraRequest request
66
- ) {
67
- return comprasService.adjudicarOrden(id, request);
68
- }
69
-
70
- @PostMapping("/{id}/rechazar")
71
- @Operation(
72
- summary = "Rechazar orden de compra",
73
- description = "Marca la OC como RECHAZADA y notifica a Farmacia mediante callback."
74
- )
75
- public OrdenCompraResponse rechazar(
76
- @PathVariable Long id,
77
- @Valid @RequestBody RechazarOrdenCompraRequest request
78
- ) {
79
- return comprasService.rechazarOrden(id, request);
80
- }
81
-
82
- @PostMapping("/{id}/reenviar-callback")
83
- @Operation(
84
- summary = "Reenviar callback a Farmacia",
85
- description = "Reintenta el callback si estadoCallback = ERROR. Util cuando la red del Modulo 3 tuvo un fallo transitorio."
86
- )
87
- public OrdenCompraResponse reenviarCallback(@PathVariable Long id) {
88
- return comprasService.reenviarCallback(id);
89
- }
90
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/ConvenioArancelController.java DELETED
@@ -1,115 +0,0 @@
1
- package com.grupo7.modulofacturacion.controller;
2
-
3
- import com.grupo7.modulofacturacion.controller.dto.ConvenioArancelRequest;
4
- import com.grupo7.modulofacturacion.controller.dto.ConvenioArancelResponse;
5
- import com.grupo7.modulofacturacion.model.ConvenioArancel;
6
- import com.grupo7.modulofacturacion.service.ConvenioArancelService;
7
- import com.grupo7.modulofacturacion.service.PlanService;
8
- import com.grupo7.modulofacturacion.service.PrestacionNomencladorService;
9
- import io.swagger.v3.oas.annotations.tags.Tag;
10
- import java.math.BigDecimal;
11
- import java.util.List;
12
- import org.springframework.http.HttpStatus;
13
- import org.springframework.web.bind.annotation.DeleteMapping;
14
- import org.springframework.web.bind.annotation.GetMapping;
15
- import org.springframework.web.bind.annotation.PathVariable;
16
- import org.springframework.web.bind.annotation.PostMapping;
17
- import org.springframework.web.bind.annotation.PutMapping;
18
- import org.springframework.web.bind.annotation.RequestBody;
19
- import org.springframework.web.bind.annotation.RequestMapping;
20
- import org.springframework.web.bind.annotation.ResponseStatus;
21
- import org.springframework.web.bind.annotation.RestController;
22
-
23
- @RestController
24
- @RequestMapping("/api/convenios-aranceles")
25
- @Tag(name = "Convenios y Aranceles", description = "Valores cubiertos y copagos por plan y prestacion.")
26
- public class ConvenioArancelController {
27
-
28
- private final ConvenioArancelService convenioArancelService;
29
- private final PlanService planService;
30
- private final PrestacionNomencladorService prestacionNomencladorService;
31
-
32
- public ConvenioArancelController(
33
- ConvenioArancelService convenioArancelService,
34
- PlanService planService,
35
- PrestacionNomencladorService prestacionNomencladorService
36
- ) {
37
- this.convenioArancelService = convenioArancelService;
38
- this.planService = planService;
39
- this.prestacionNomencladorService = prestacionNomencladorService;
40
- }
41
-
42
- @GetMapping
43
- public List<ConvenioArancelResponse> listar() {
44
- return convenioArancelService.listarTodos().stream()
45
- .map(this::toResponse)
46
- .toList();
47
- }
48
-
49
- @GetMapping("/{id}")
50
- public ConvenioArancelResponse obtenerPorId(@PathVariable Long id) {
51
- return toResponse(convenioArancelService.obtenerPorId(id));
52
- }
53
-
54
- @PostMapping
55
- @ResponseStatus(HttpStatus.CREATED)
56
- public ConvenioArancelResponse crear(@RequestBody ConvenioArancelRequest request) {
57
- ConvenioArancel convenioArancel = new ConvenioArancel();
58
- applyRequest(convenioArancel, request);
59
- validatePrestacionActiva(convenioArancel);
60
- return toResponse(convenioArancelService.guardar(convenioArancel));
61
- }
62
-
63
- @PutMapping("/{id}")
64
- public ConvenioArancelResponse actualizar(@PathVariable Long id, @RequestBody ConvenioArancelRequest request) {
65
- ConvenioArancel convenioArancel = convenioArancelService.obtenerPorId(id);
66
- applyRequest(convenioArancel, request);
67
- validatePrestacionActiva(convenioArancel);
68
- return toResponse(convenioArancelService.guardar(convenioArancel));
69
- }
70
-
71
- @DeleteMapping("/{id}")
72
- @ResponseStatus(HttpStatus.NO_CONTENT)
73
- public void eliminar(@PathVariable Long id) {
74
- convenioArancelService.eliminarPorId(id);
75
- }
76
-
77
- private void applyRequest(ConvenioArancel convenioArancel, ConvenioArancelRequest request) {
78
- if (request.planId() != null) {
79
- convenioArancel.setPlan(planService.obtenerPorId(request.planId()));
80
- }
81
- if (request.prestacionId() != null) {
82
- convenioArancel.setPrestacion(prestacionNomencladorService.obtenerActivaPorId(request.prestacionId()));
83
- }
84
- convenioArancel.setValorCubierto(request.valorCubierto() != null ? request.valorCubierto() : BigDecimal.ZERO);
85
- convenioArancel.setValorCopago(request.valorCopago() != null ? request.valorCopago() : BigDecimal.ZERO);
86
- if (request.fechaVigenciaDesde() != null) {
87
- convenioArancel.setFechaVigenciaDesde(request.fechaVigenciaDesde());
88
- }
89
- convenioArancel.setFechaVigenciaHasta(request.fechaVigenciaHasta());
90
- if (request.activo() != null) {
91
- convenioArancel.setActivo(request.activo());
92
- }
93
- }
94
-
95
- private void validatePrestacionActiva(ConvenioArancel convenioArancel) {
96
- convenioArancel.setPrestacion(
97
- prestacionNomencladorService.validarActivaParaUso(convenioArancel.getPrestacion())
98
- );
99
- }
100
-
101
- private ConvenioArancelResponse toResponse(ConvenioArancel convenioArancel) {
102
- return new ConvenioArancelResponse(
103
- convenioArancel.getId(),
104
- convenioArancel.getPlan().getId(),
105
- convenioArancel.getPlan().getNombre(),
106
- convenioArancel.getPrestacion().getId(),
107
- convenioArancel.getPrestacion().getCodigoNomenclador(),
108
- convenioArancel.getValorCubierto(),
109
- convenioArancel.getValorCopago(),
110
- convenioArancel.getFechaVigenciaDesde(),
111
- convenioArancel.getFechaVigenciaHasta(),
112
- convenioArancel.isActivo()
113
- );
114
- }
115
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/EntidadFinanciadoraController.java DELETED
@@ -1,102 +0,0 @@
1
- package com.grupo7.modulofacturacion.controller;
2
-
3
- import com.grupo7.modulofacturacion.controller.dto.EntidadFinanciadoraRequest;
4
- import com.grupo7.modulofacturacion.controller.dto.EntidadFinanciadoraResponse;
5
- import com.grupo7.modulofacturacion.model.EntidadFinanciadora;
6
- import com.grupo7.modulofacturacion.service.EntidadFinanciadoraService;
7
- import io.swagger.v3.oas.annotations.Operation;
8
- import io.swagger.v3.oas.annotations.Parameter;
9
- import io.swagger.v3.oas.annotations.tags.Tag;
10
- import java.util.List;
11
- import org.springframework.http.HttpStatus;
12
- import org.springframework.web.bind.annotation.DeleteMapping;
13
- import org.springframework.web.bind.annotation.GetMapping;
14
- import org.springframework.web.bind.annotation.PathVariable;
15
- import org.springframework.web.bind.annotation.PostMapping;
16
- import org.springframework.web.bind.annotation.PutMapping;
17
- import org.springframework.web.bind.annotation.RequestBody;
18
- import org.springframework.web.bind.annotation.RequestMapping;
19
- import org.springframework.web.bind.annotation.RequestParam;
20
- import org.springframework.web.bind.annotation.ResponseStatus;
21
- import org.springframework.web.bind.annotation.RestController;
22
-
23
- @RestController
24
- @RequestMapping("/api/entidades-financiadoras")
25
- @Tag(name = "Entidades Financiadoras", description = "ABM de obras sociales, prepagas y financiadores administrados por Modulo 7.")
26
- public class EntidadFinanciadoraController {
27
-
28
- private final EntidadFinanciadoraService entidadFinanciadoraService;
29
-
30
- public EntidadFinanciadoraController(EntidadFinanciadoraService entidadFinanciadoraService) {
31
- this.entidadFinanciadoraService = entidadFinanciadoraService;
32
- }
33
-
34
- @GetMapping
35
- @Operation(
36
- summary = "Listar entidades financiadoras",
37
- description = "Por defecto devuelve solo entidades activas. Use incluirInactivas=true para devolver todas."
38
- )
39
- public List<EntidadFinanciadoraResponse> listar(
40
- @Parameter(description = "Cuando es true incluye entidades inactivas; por defecto solo devuelve activas.")
41
- @RequestParam(name = "incluirInactivas", defaultValue = "false") boolean incluirInactivas
42
- ) {
43
- return entidadFinanciadoraService.listar(incluirInactivas).stream()
44
- .map(this::toResponse)
45
- .toList();
46
- }
47
-
48
- @GetMapping("/{id}")
49
- @Operation(
50
- summary = "Obtener entidad financiadora por ID",
51
- description = "Permite a otros modulos consultar los datos de una obra social, prepaga o financiador usando el ID real de Modulo 7."
52
- )
53
- public EntidadFinanciadoraResponse obtenerPorId(@PathVariable Long id) {
54
- return toResponse(entidadFinanciadoraService.obtenerPorId(id));
55
- }
56
-
57
- @PostMapping
58
- @ResponseStatus(HttpStatus.CREATED)
59
- public EntidadFinanciadoraResponse crear(@RequestBody EntidadFinanciadoraRequest request) {
60
- EntidadFinanciadora entidadFinanciadora = new EntidadFinanciadora();
61
- applyRequest(entidadFinanciadora, request);
62
- return toResponse(entidadFinanciadoraService.guardar(entidadFinanciadora));
63
- }
64
-
65
- @PutMapping("/{id}")
66
- public EntidadFinanciadoraResponse actualizar(@PathVariable Long id, @RequestBody EntidadFinanciadoraRequest request) {
67
- EntidadFinanciadora entidadFinanciadora = entidadFinanciadoraService.obtenerPorId(id);
68
- applyRequest(entidadFinanciadora, request);
69
- return toResponse(entidadFinanciadoraService.guardar(entidadFinanciadora));
70
- }
71
-
72
- @DeleteMapping("/{id}")
73
- @ResponseStatus(HttpStatus.NO_CONTENT)
74
- public void eliminar(@PathVariable Long id) {
75
- entidadFinanciadoraService.eliminarPorId(id);
76
- }
77
-
78
- private void applyRequest(EntidadFinanciadora entity, EntidadFinanciadoraRequest request) {
79
- if (request.nombre() != null) {
80
- entity.setNombre(request.nombre());
81
- }
82
- if (request.cuit() != null) {
83
- entity.setCuit(request.cuit());
84
- }
85
- if (request.tipoFinanciador() != null) {
86
- entity.setTipoFinanciador(request.tipoFinanciador());
87
- }
88
- if (request.activa() != null) {
89
- entity.setActiva(request.activa());
90
- }
91
- }
92
-
93
- private EntidadFinanciadoraResponse toResponse(EntidadFinanciadora entity) {
94
- return new EntidadFinanciadoraResponse(
95
- entity.getId(),
96
- entity.getNombre(),
97
- entity.getCuit(),
98
- entity.getTipoFinanciador(),
99
- entity.isActiva()
100
- );
101
- }
102
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/FacturaEmitidaController.java DELETED
@@ -1,73 +0,0 @@
1
- package com.grupo7.modulofacturacion.controller;
2
-
3
- import com.grupo7.modulofacturacion.controller.dto.FacturaEmitidaResponse;
4
- import com.grupo7.modulofacturacion.controller.dto.GenerarFacturaCopagoRequest;
5
- import com.grupo7.modulofacturacion.controller.dto.GenerarLiquidacionAseguradoraRequest;
6
- import com.grupo7.modulofacturacion.model.FacturaEmitida;
7
- import com.grupo7.modulofacturacion.service.FacturaEmitidaService;
8
- import com.grupo7.modulofacturacion.service.LiquidacionService;
9
- import io.swagger.v3.oas.annotations.tags.Tag;
10
- import jakarta.validation.Valid;
11
- import java.util.List;
12
- import org.springframework.http.HttpStatus;
13
- import org.springframework.web.bind.annotation.GetMapping;
14
- import org.springframework.web.bind.annotation.PathVariable;
15
- import org.springframework.web.bind.annotation.PostMapping;
16
- import org.springframework.web.bind.annotation.RequestBody;
17
- import org.springframework.web.bind.annotation.RequestMapping;
18
- import org.springframework.web.bind.annotation.RequestParam;
19
- import org.springframework.web.bind.annotation.ResponseStatus;
20
- import org.springframework.web.bind.annotation.RestController;
21
-
22
- @RestController
23
- @RequestMapping("/api/facturas-emitidas")
24
- @Tag(name = "Facturas Emitidas", description = "Liquidaciones a financiadores y facturas de copago.")
25
- public class FacturaEmitidaController {
26
-
27
- private final LiquidacionService liquidacionService;
28
- private final FacturaEmitidaService facturaEmitidaService;
29
-
30
- public FacturaEmitidaController(LiquidacionService liquidacionService, FacturaEmitidaService facturaEmitidaService) {
31
- this.liquidacionService = liquidacionService;
32
- this.facturaEmitidaService = facturaEmitidaService;
33
- }
34
-
35
- @PostMapping("/liquidaciones/aseguradoras")
36
- @ResponseStatus(HttpStatus.CREATED)
37
- public FacturaEmitidaResponse generarLiquidacionAseguradora(
38
- @Valid @RequestBody GenerarLiquidacionAseguradoraRequest request
39
- ) {
40
- return toResponse(liquidacionService.generarLiquidacionAseguradora(request.idObraSocial(), request.periodoHasta()));
41
- }
42
-
43
- @PostMapping("/copagos")
44
- @ResponseStatus(HttpStatus.CREATED)
45
- public FacturaEmitidaResponse generarFacturaCopago(@Valid @RequestBody GenerarFacturaCopagoRequest request) {
46
- return toResponse(liquidacionService.generarFacturaCopago(request.idPaciente(), request.idsPrestaciones()));
47
- }
48
-
49
- @GetMapping
50
- public List<FacturaEmitidaResponse> listar(@RequestParam(required = false) String entidadPagadoraId) {
51
- return facturaEmitidaService.listarFacturasGeneradas(entidadPagadoraId).stream()
52
- .map(this::toResponse)
53
- .toList();
54
- }
55
-
56
- @GetMapping("/{id}")
57
- public FacturaEmitidaResponse obtenerPorId(@PathVariable Long id) {
58
- return toResponse(facturaEmitidaService.obtenerPorId(id));
59
- }
60
-
61
- private FacturaEmitidaResponse toResponse(FacturaEmitida factura) {
62
- return new FacturaEmitidaResponse(
63
- factura.getId(),
64
- factura.getNumeroComprobante(),
65
- factura.getTipoComprobante(),
66
- factura.getEntidadPagadoraId(),
67
- factura.getFechaEmision(),
68
- factura.getFechaVencimiento(),
69
- factura.getMontoTotal(),
70
- factura.getPrestaciones().stream().map(prestacion -> prestacion.getId()).toList()
71
- );
72
- }
73
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/FacturaRecibidaController.java DELETED
@@ -1,100 +0,0 @@
1
- package com.grupo7.modulofacturacion.controller;
2
-
3
- import com.grupo7.modulofacturacion.controller.dto.FacturaRecibidaResponse;
4
- import com.grupo7.modulofacturacion.controller.dto.SimularFacturaRecibidaRequest;
5
- import com.grupo7.modulofacturacion.event.dto.FacturaRecibidaEventDTO;
6
- import com.grupo7.modulofacturacion.exception.ResourceNotFoundException;
7
- import com.grupo7.modulofacturacion.model.FacturaRecibida;
8
- import com.grupo7.modulofacturacion.repository.FacturaRecibidaRepository;
9
- import com.grupo7.modulofacturacion.service.CajaService;
10
- import io.swagger.v3.oas.annotations.tags.Tag;
11
- import jakarta.validation.Valid;
12
- import java.util.List;
13
- import java.util.Map;
14
- import org.springframework.http.HttpStatus;
15
- import org.springframework.web.bind.annotation.GetMapping;
16
- import org.springframework.web.bind.annotation.PathVariable;
17
- import org.springframework.web.bind.annotation.PostMapping;
18
- import org.springframework.web.bind.annotation.RequestBody;
19
- import org.springframework.web.bind.annotation.RequestMapping;
20
- import org.springframework.web.bind.annotation.ResponseStatus;
21
- import org.springframework.web.bind.annotation.RestController;
22
-
23
- @RestController
24
- @RequestMapping("/api/facturas-recibidas")
25
- @Tag(name = "Facturas Recibidas", description = "Facturas de proveedores e integracion mockeada para aprobacion por caja.")
26
- public class FacturaRecibidaController {
27
-
28
- private final FacturaRecibidaRepository facturaRecibidaRepository;
29
- private final CajaService cajaService;
30
-
31
- public FacturaRecibidaController(
32
- FacturaRecibidaRepository facturaRecibidaRepository,
33
- CajaService cajaService
34
- ) {
35
- this.facturaRecibidaRepository = facturaRecibidaRepository;
36
- this.cajaService = cajaService;
37
- }
38
-
39
- @GetMapping
40
- public List<FacturaRecibidaResponse> listar() {
41
- return facturaRecibidaRepository.findAll().stream()
42
- .sorted((a, b) -> b.getId().compareTo(a.getId()))
43
- .map(this::toResponse)
44
- .toList();
45
- }
46
-
47
- @GetMapping("/{id}")
48
- public FacturaRecibidaResponse obtenerPorId(@PathVariable Long id) {
49
- FacturaRecibida factura = facturaRecibidaRepository.findById(id)
50
- .orElseThrow(() -> new ResourceNotFoundException("Factura recibida no encontrada con id " + id));
51
- return toResponse(factura);
52
- }
53
-
54
- /**
55
- * Endpoint de simulacion para la entrega parcial (integraciones mockeadas).
56
- * Permite disparar manualmente el mismo flujo que en produccion ejecutaria
57
- * el consumer del bus de eventos al recibir una factura de otro modulo.
58
- * En la entrega final este endpoint puede deshabilitarse una vez que el
59
- * bus de eventos este configurado.
60
- */
61
- @PostMapping("/simular")
62
- @ResponseStatus(HttpStatus.CREATED)
63
- public Map<String, Object> simular(@Valid @RequestBody SimularFacturaRecibidaRequest request) {
64
- FacturaRecibidaEventDTO evento = new FacturaRecibidaEventDTO(
65
- request.moduloOrigen(),
66
- request.idTransaccionOrigen(),
67
- request.cuitProveedor(),
68
- request.razonSocialProveedor(),
69
- request.tipoComprobante(),
70
- request.numeroComprobante(),
71
- request.fechaEmision(),
72
- request.fechaVencimiento(),
73
- request.conceptoResumido(),
74
- request.montoTotal()
75
- );
76
- boolean aprobado = cajaService.procesarEgreso(evento);
77
- return Map.of(
78
- "aprobado", aprobado,
79
- "mensaje", aprobado
80
- ? "Pago procesado correctamente. Egreso registrado en caja."
81
- : "Pago rechazado por saldo insuficiente en caja."
82
- );
83
- }
84
-
85
- private FacturaRecibidaResponse toResponse(FacturaRecibida factura) {
86
- return new FacturaRecibidaResponse(
87
- factura.getId(),
88
- factura.getModuloOrigen(),
89
- factura.getIdTransaccionOrigen(),
90
- factura.getCuitProveedor(),
91
- factura.getRazonSocialProveedor(),
92
- factura.getNumeroComprobante(),
93
- factura.getFechaEmision(),
94
- factura.getFechaVencimiento(),
95
- factura.getConcepto(),
96
- factura.getMontoTotal(),
97
- factura.getEstadoAprobacion()
98
- );
99
- }
100
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/FrontendController.java DELETED
@@ -1,13 +0,0 @@
1
- package com.grupo7.modulofacturacion.controller;
2
-
3
- import org.springframework.stereotype.Controller;
4
- import org.springframework.web.bind.annotation.GetMapping;
5
-
6
- @Controller
7
- public class FrontendController {
8
-
9
- @GetMapping("/")
10
- public String index() {
11
- return "forward:/index.html";
12
- }
13
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/IntegracionController.java DELETED
@@ -1,134 +0,0 @@
1
- package com.grupo7.modulofacturacion.controller;
2
-
3
- import com.grupo7.modulofacturacion.controller.dto.CopagoItemResponse;
4
- import com.grupo7.modulofacturacion.controller.dto.InternacionM6Request;
5
- import com.grupo7.modulofacturacion.controller.dto.InternacionM6Response;
6
- import com.grupo7.modulofacturacion.controller.dto.PagoM8NotificacionRequest;
7
- import com.grupo7.modulofacturacion.controller.dto.PagoM8NotificacionResponse;
8
- import com.grupo7.modulofacturacion.controller.dto.PrestacionFacturableResponse;
9
- import com.grupo7.modulofacturacion.controller.dto.RegistrarPrestacionExternaRequest;
10
- import com.grupo7.modulofacturacion.model.PrestacionFacturable;
11
- import com.grupo7.modulofacturacion.service.IntegracionService;
12
- import com.grupo7.modulofacturacion.service.IntegracionService.RegistroPrestacionExternaResult;
13
- import io.swagger.v3.oas.annotations.Operation;
14
- import io.swagger.v3.oas.annotations.tags.Tag;
15
- import jakarta.validation.Valid;
16
- import java.util.List;
17
- import org.springframework.http.HttpStatus;
18
- import org.springframework.http.ResponseEntity;
19
- import org.springframework.web.bind.annotation.GetMapping;
20
- import org.springframework.web.bind.annotation.PathVariable;
21
- import org.springframework.web.bind.annotation.PostMapping;
22
- import org.springframework.web.bind.annotation.RequestBody;
23
- import org.springframework.web.bind.annotation.RequestMapping;
24
- import org.springframework.web.bind.annotation.RestController;
25
-
26
- /**
27
- * Endpoints de integracion que expone el modulo de Facturacion para que otros modulos del sistema
28
- * puedan registrar prestaciones facturables y consultar copagos pendientes.
29
- */
30
- @RestController
31
- @RequestMapping("/api/integracion")
32
- @Tag(name = "Integraciones M1-HCE", description = "Registro de actos medicos externos facturables.")
33
- @Tag(name = "Integracion M6 Internacion", description = "Recepcion de cierres de internacion con idempotencia.")
34
- @Tag(name = "Integracion M8 Portal/Pagos", description = "Consulta de copagos y notificaciones de pago.")
35
- public class IntegracionController {
36
-
37
- private final IntegracionService integracionService;
38
-
39
- public IntegracionController(IntegracionService integracionService) {
40
- this.integracionService = integracionService;
41
- }
42
-
43
- /**
44
- * Endpoint consumido por modulos externos (Internacion, Laboratorio, Imagenes, etc.)
45
- * para registrar un acto medico facturable en nombre de un paciente.
46
- */
47
- @PostMapping("/prestaciones")
48
- @Operation(
49
- tags = "Integraciones M1-HCE",
50
- summary = "Registrar prestacion externa",
51
- description = "Valida plan activo, entidad activa, prestacion activa y convenio vigente. profesionalIdExterno e idActoMedicoExterno son obligatorios. Si ya existe moduloOrigen + idActoMedicoExterno, devuelve la prestacion previamente registrada sin crear duplicados."
52
- )
53
- public ResponseEntity<PrestacionFacturableResponse> registrarPrestacion(
54
- @Valid @RequestBody RegistrarPrestacionExternaRequest request
55
- ) {
56
- RegistroPrestacionExternaResult result = integracionService.registrarPrestacionExterna(request);
57
- PrestacionFacturableResponse response = toResponse(result.prestacion());
58
- return result.yaRegistrada()
59
- ? ResponseEntity.ok(response)
60
- : ResponseEntity.status(HttpStatus.CREATED).body(response);
61
- }
62
-
63
- /**
64
- * Endpoint consumido por el Portal del Paciente para obtener los copagos
65
- * pendientes de pago de un paciente dado su ID externo.
66
- */
67
- @GetMapping("/copago/paciente/{pacienteId}")
68
- @Operation(
69
- tags = "Integracion M8 Portal/Pagos",
70
- summary = "Consultar copagos pendientes por paciente",
71
- description = "Usado por Modulo 8. El paciente externo se informa como ID numerico."
72
- )
73
- public List<CopagoItemResponse> obtenerCopagosPendientes(@PathVariable Long pacienteId) {
74
- return integracionService.obtenerCopagosPendientes(pacienteId);
75
- }
76
-
77
- /**
78
- * Endpoint consumido por el Portal del Paciente para informar pagos online
79
- * de copagos/coseguros realizados o simulados por el paciente.
80
- */
81
- @PostMapping("/pagos/notificacion")
82
- @Operation(
83
- tags = "Integracion M8 Portal/Pagos",
84
- summary = "Notificar pago desde Modulo 8",
85
- description = "Registra pagos del Portal del Paciente con idempotencia por idTransaccionExterna. Solo estado APROBADO genera factura de copago e ingreso de caja."
86
- )
87
- public PagoM8NotificacionResponse notificarPagoM8(
88
- @Valid @RequestBody PagoM8NotificacionRequest request
89
- ) {
90
- return integracionService.procesarNotificacionPagoM8(request);
91
- }
92
-
93
- @PostMapping("/internacion/cierre-episodio")
94
- @Operation(
95
- tags = "Integracion M6 Internacion",
96
- summary = "Recibir cierre de episodio desde Modulo 6",
97
- description = "Persiste el evento de internacion con idempotencia. Si recibe paciente y episodio, consulta M1/HCE para registrar actos medicos facturables."
98
- )
99
- public ResponseEntity<InternacionM6Response> recibirCierreEpisodioM6(
100
- @Valid @RequestBody InternacionM6Request request
101
- ) {
102
- return ResponseEntity
103
- .status(HttpStatus.ACCEPTED)
104
- .body(integracionService.procesarEventoInternacionM6(request));
105
- }
106
-
107
- private PrestacionFacturableResponse toResponse(PrestacionFacturable pf) {
108
- return new PrestacionFacturableResponse(
109
- pf.getId(),
110
- pf.getModuloOrigen(),
111
- parsePacienteId(pf.getPacienteIdExterno()),
112
- pf.getProfesionalIdExterno(),
113
- pf.getIdEpisodioExterno(),
114
- pf.getIdActoMedicoExterno(),
115
- pf.getPlan().getId(),
116
- pf.getPlan().getNombre(),
117
- pf.getPrestacion().getId(),
118
- pf.getPrestacion().getCodigoNomenclador(),
119
- pf.getConvenioArancel().getId(),
120
- pf.getNumeroAfiliadoInformado(),
121
- pf.getFechaAtencion(),
122
- pf.getCantidad(),
123
- pf.getEstadoAuditoria(),
124
- pf.getMontoCubiertoAplicado(),
125
- pf.getMontoCopagoAplicado(),
126
- pf.getMontoTotalAplicado(),
127
- pf.getObservaciones()
128
- );
129
- }
130
-
131
- private Long parsePacienteId(String pacienteIdExterno) {
132
- return pacienteIdExterno != null ? Long.valueOf(pacienteIdExterno) : null;
133
- }
134
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/InternacionWebhookController.java DELETED
@@ -1,32 +0,0 @@
1
- package com.grupo7.modulofacturacion.controller;
2
-
3
- import com.grupo7.modulofacturacion.controller.dto.InternacionM6Request;
4
- import com.grupo7.modulofacturacion.controller.dto.InternacionM6Response;
5
- import com.grupo7.modulofacturacion.service.IntegracionService;
6
- import io.swagger.v3.oas.annotations.tags.Tag;
7
- import jakarta.validation.Valid;
8
- import org.springframework.http.HttpStatus;
9
- import org.springframework.http.ResponseEntity;
10
- import org.springframework.web.bind.annotation.PostMapping;
11
- import org.springframework.web.bind.annotation.RequestBody;
12
- import org.springframework.web.bind.annotation.RestController;
13
-
14
- @RestController
15
- @Tag(name = "Integracion M6 Internacion", description = "Webhook compatible con Modulo 6 para cama lista y cierre de internacion.")
16
- public class InternacionWebhookController {
17
-
18
- private final IntegracionService integracionService;
19
-
20
- public InternacionWebhookController(IntegracionService integracionService) {
21
- this.integracionService = integracionService;
22
- }
23
-
24
- @PostMapping("/api/v1/webhooks/internacion/cama-lista")
25
- public ResponseEntity<InternacionM6Response> recibirCamaListaM6(
26
- @Valid @RequestBody InternacionM6Request request
27
- ) {
28
- return ResponseEntity
29
- .status(HttpStatus.ACCEPTED)
30
- .body(integracionService.procesarEventoInternacionM6(request));
31
- }
32
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/PlanController.java DELETED
@@ -1,108 +0,0 @@
1
- package com.grupo7.modulofacturacion.controller;
2
-
3
- import com.grupo7.modulofacturacion.controller.dto.PlanRequest;
4
- import com.grupo7.modulofacturacion.controller.dto.PlanResponse;
5
- import com.grupo7.modulofacturacion.model.Plan;
6
- import com.grupo7.modulofacturacion.service.EntidadFinanciadoraService;
7
- import com.grupo7.modulofacturacion.service.PlanService;
8
- import io.swagger.v3.oas.annotations.Operation;
9
- import io.swagger.v3.oas.annotations.Parameter;
10
- import io.swagger.v3.oas.annotations.tags.Tag;
11
- import java.util.List;
12
- import org.springframework.http.HttpStatus;
13
- import org.springframework.web.bind.annotation.DeleteMapping;
14
- import org.springframework.web.bind.annotation.GetMapping;
15
- import org.springframework.web.bind.annotation.PathVariable;
16
- import org.springframework.web.bind.annotation.PostMapping;
17
- import org.springframework.web.bind.annotation.PutMapping;
18
- import org.springframework.web.bind.annotation.RequestBody;
19
- import org.springframework.web.bind.annotation.RequestMapping;
20
- import org.springframework.web.bind.annotation.RequestParam;
21
- import org.springframework.web.bind.annotation.ResponseStatus;
22
- import org.springframework.web.bind.annotation.RestController;
23
-
24
- @RestController
25
- @RequestMapping("/api/planes")
26
- @Tag(name = "Planes", description = "Planes asociados a entidades financiadoras. M1 debe guardar estos IDs reales para informar cobertura.")
27
- public class PlanController {
28
-
29
- private final PlanService planService;
30
- private final EntidadFinanciadoraService entidadFinanciadoraService;
31
-
32
- public PlanController(PlanService planService, EntidadFinanciadoraService entidadFinanciadoraService) {
33
- this.planService = planService;
34
- this.entidadFinanciadoraService = entidadFinanciadoraService;
35
- }
36
-
37
- @GetMapping
38
- @Operation(
39
- summary = "Listar planes",
40
- description = "Por defecto devuelve solo planes activos. Permite filtrar por entidadFinanciadoraId y usar incluirInactivos=true para incluir planes inactivos."
41
- )
42
- public List<PlanResponse> listar(
43
- @Parameter(description = "Filtra planes por entidad financiadora.")
44
- @RequestParam(name = "entidadFinanciadoraId", required = false) Long entidadFinanciadoraId,
45
- @Parameter(description = "Cuando es true incluye planes inactivos; por defecto solo devuelve activos.")
46
- @RequestParam(name = "incluirInactivos", defaultValue = "false") boolean incluirInactivos
47
- ) {
48
- return planService.listar(entidadFinanciadoraId, incluirInactivos).stream()
49
- .map(this::toResponse)
50
- .toList();
51
- }
52
-
53
- @GetMapping("/{id}")
54
- @Operation(
55
- summary = "Obtener plan por ID",
56
- description = "Permite a otros modulos consultar un plan usando el ID real de Modulo 7."
57
- )
58
- public PlanResponse obtenerPorId(@PathVariable Long id) {
59
- return toResponse(planService.obtenerPorId(id));
60
- }
61
-
62
- @PostMapping
63
- @ResponseStatus(HttpStatus.CREATED)
64
- public PlanResponse crear(@RequestBody PlanRequest request) {
65
- Plan plan = new Plan();
66
- applyRequest(plan, request);
67
- return toResponse(planService.guardar(plan));
68
- }
69
-
70
- @PutMapping("/{id}")
71
- public PlanResponse actualizar(@PathVariable Long id, @RequestBody PlanRequest request) {
72
- Plan plan = planService.obtenerPorId(id);
73
- applyRequest(plan, request);
74
- return toResponse(planService.guardar(plan));
75
- }
76
-
77
- @DeleteMapping("/{id}")
78
- @ResponseStatus(HttpStatus.NO_CONTENT)
79
- public void eliminar(@PathVariable Long id) {
80
- planService.eliminarPorId(id);
81
- }
82
-
83
- private void applyRequest(Plan plan, PlanRequest request) {
84
- if (request.entidadFinanciadoraId() != null) {
85
- plan.setEntidadFinanciadora(entidadFinanciadoraService.obtenerPorId(request.entidadFinanciadoraId()));
86
- }
87
- if (request.nombre() != null) {
88
- plan.setNombre(request.nombre());
89
- }
90
- if (request.codigo() != null) {
91
- plan.setCodigo(request.codigo());
92
- }
93
- if (request.activo() != null) {
94
- plan.setActivo(request.activo());
95
- }
96
- }
97
-
98
- private PlanResponse toResponse(Plan plan) {
99
- return new PlanResponse(
100
- plan.getId(),
101
- plan.getEntidadFinanciadora().getId(),
102
- plan.getEntidadFinanciadora().getNombre(),
103
- plan.getNombre(),
104
- plan.getCodigo(),
105
- plan.isActivo()
106
- );
107
- }
108
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/PrestacionFacturableController.java DELETED
@@ -1,166 +0,0 @@
1
- package com.grupo7.modulofacturacion.controller;
2
-
3
- import com.grupo7.modulofacturacion.controller.dto.PrestacionFacturableAuditoriaRequest;
4
- import com.grupo7.modulofacturacion.controller.dto.PrestacionFacturableRequest;
5
- import com.grupo7.modulofacturacion.controller.dto.PrestacionFacturableResponse;
6
- import com.grupo7.modulofacturacion.model.PrestacionFacturable;
7
- import com.grupo7.modulofacturacion.model.enums.EstadoAuditoria;
8
- import com.grupo7.modulofacturacion.service.ConvenioArancelService;
9
- import com.grupo7.modulofacturacion.service.PlanService;
10
- import com.grupo7.modulofacturacion.service.PrestacionFacturableService;
11
- import com.grupo7.modulofacturacion.service.PrestacionNomencladorService;
12
- import io.swagger.v3.oas.annotations.tags.Tag;
13
- import jakarta.validation.Valid;
14
- import java.math.BigDecimal;
15
- import java.util.List;
16
- import org.springframework.http.HttpStatus;
17
- import org.springframework.web.bind.annotation.DeleteMapping;
18
- import org.springframework.web.bind.annotation.GetMapping;
19
- import org.springframework.web.bind.annotation.PatchMapping;
20
- import org.springframework.web.bind.annotation.PathVariable;
21
- import org.springframework.web.bind.annotation.PostMapping;
22
- import org.springframework.web.bind.annotation.PutMapping;
23
- import org.springframework.web.bind.annotation.RequestBody;
24
- import org.springframework.web.bind.annotation.RequestMapping;
25
- import org.springframework.web.bind.annotation.ResponseStatus;
26
- import org.springframework.web.bind.annotation.RestController;
27
-
28
- @RestController
29
- @RequestMapping("/api/prestaciones-facturables")
30
- @Tag(name = "Prestaciones Facturables / Auditoria", description = "Prestaciones registradas, auditoria y base para liquidaciones.")
31
- public class PrestacionFacturableController {
32
-
33
- private final PrestacionFacturableService prestacionFacturableService;
34
- private final PlanService planService;
35
- private final PrestacionNomencladorService prestacionNomencladorService;
36
- private final ConvenioArancelService convenioArancelService;
37
-
38
- public PrestacionFacturableController(
39
- PrestacionFacturableService prestacionFacturableService,
40
- PlanService planService,
41
- PrestacionNomencladorService prestacionNomencladorService,
42
- ConvenioArancelService convenioArancelService
43
- ) {
44
- this.prestacionFacturableService = prestacionFacturableService;
45
- this.planService = planService;
46
- this.prestacionNomencladorService = prestacionNomencladorService;
47
- this.convenioArancelService = convenioArancelService;
48
- }
49
-
50
- @GetMapping
51
- public List<PrestacionFacturableResponse> listar() {
52
- return prestacionFacturableService.listarTodos().stream()
53
- .map(this::toResponse)
54
- .toList();
55
- }
56
-
57
- @GetMapping("/{id}")
58
- public PrestacionFacturableResponse obtenerPorId(@PathVariable Long id) {
59
- return toResponse(prestacionFacturableService.obtenerPorId(id));
60
- }
61
-
62
- @PostMapping
63
- @ResponseStatus(HttpStatus.CREATED)
64
- public PrestacionFacturableResponse crear(@RequestBody PrestacionFacturableRequest request) {
65
- PrestacionFacturable prestacionFacturable = new PrestacionFacturable();
66
- applyRequest(prestacionFacturable, request);
67
- validatePrestacionActiva(prestacionFacturable);
68
- return toResponse(prestacionFacturableService.guardar(prestacionFacturable));
69
- }
70
-
71
- @PutMapping("/{id}")
72
- public PrestacionFacturableResponse actualizar(@PathVariable Long id, @RequestBody PrestacionFacturableRequest request) {
73
- PrestacionFacturable prestacionFacturable = prestacionFacturableService.obtenerPorId(id);
74
- applyRequest(prestacionFacturable, request);
75
- validatePrestacionActiva(prestacionFacturable);
76
- return toResponse(prestacionFacturableService.guardar(prestacionFacturable));
77
- }
78
-
79
- @DeleteMapping("/{id}")
80
- @ResponseStatus(HttpStatus.NO_CONTENT)
81
- public void eliminar(@PathVariable Long id) {
82
- prestacionFacturableService.eliminarPorId(id);
83
- }
84
-
85
- @PatchMapping("/{id}/auditoria")
86
- public PrestacionFacturableResponse cambiarEstadoAuditoria(
87
- @PathVariable Long id,
88
- @Valid @RequestBody PrestacionFacturableAuditoriaRequest request
89
- ) {
90
- return toResponse(prestacionFacturableService.cambiarEstadoAuditoria(
91
- id,
92
- request.estadoAuditoria(),
93
- request.observaciones()
94
- ));
95
- }
96
-
97
- private void applyRequest(PrestacionFacturable prestacionFacturable, PrestacionFacturableRequest request) {
98
- if (request.pacienteIdExterno() != null) {
99
- prestacionFacturable.setPacienteIdExterno(request.pacienteIdExterno().toString());
100
- }
101
- if (request.profesionalIdExterno() != null) {
102
- prestacionFacturable.setProfesionalIdExterno(request.profesionalIdExterno());
103
- }
104
- if (request.planId() != null) {
105
- prestacionFacturable.setPlan(planService.obtenerPorId(request.planId()));
106
- }
107
- if (request.prestacionId() != null) {
108
- prestacionFacturable.setPrestacion(prestacionNomencladorService.obtenerActivaPorId(request.prestacionId()));
109
- }
110
- if (request.convenioArancelId() != null) {
111
- prestacionFacturable.setConvenioArancel(convenioArancelService.obtenerPorId(request.convenioArancelId()));
112
- }
113
- prestacionFacturable.setNumeroAfiliadoInformado(request.numeroAfiliadoInformado());
114
- if (request.fechaAtencion() != null) {
115
- prestacionFacturable.setFechaAtencion(request.fechaAtencion());
116
- }
117
- prestacionFacturable.setCantidad(request.cantidad() != null ? request.cantidad() : 1);
118
- prestacionFacturable.setEstadoAuditoria(
119
- request.estadoAuditoria() != null ? request.estadoAuditoria() : EstadoAuditoria.PENDIENTE
120
- );
121
- prestacionFacturable.setMontoCubiertoAplicado(
122
- request.montoCubiertoAplicado() != null ? request.montoCubiertoAplicado() : BigDecimal.ZERO
123
- );
124
- prestacionFacturable.setMontoCopagoAplicado(
125
- request.montoCopagoAplicado() != null ? request.montoCopagoAplicado() : BigDecimal.ZERO
126
- );
127
- prestacionFacturable.setMontoTotalAplicado(
128
- request.montoTotalAplicado() != null ? request.montoTotalAplicado() : BigDecimal.ZERO
129
- );
130
- prestacionFacturable.setObservaciones(request.observaciones());
131
- }
132
-
133
- private void validatePrestacionActiva(PrestacionFacturable prestacionFacturable) {
134
- prestacionFacturable.setPrestacion(
135
- prestacionNomencladorService.validarActivaParaUso(prestacionFacturable.getPrestacion())
136
- );
137
- }
138
-
139
- private PrestacionFacturableResponse toResponse(PrestacionFacturable prestacionFacturable) {
140
- return new PrestacionFacturableResponse(
141
- prestacionFacturable.getId(),
142
- prestacionFacturable.getModuloOrigen(),
143
- parsePacienteId(prestacionFacturable.getPacienteIdExterno()),
144
- prestacionFacturable.getProfesionalIdExterno(),
145
- prestacionFacturable.getIdEpisodioExterno(),
146
- prestacionFacturable.getIdActoMedicoExterno(),
147
- prestacionFacturable.getPlan().getId(),
148
- prestacionFacturable.getPlan().getNombre(),
149
- prestacionFacturable.getPrestacion().getId(),
150
- prestacionFacturable.getPrestacion().getCodigoNomenclador(),
151
- prestacionFacturable.getConvenioArancel().getId(),
152
- prestacionFacturable.getNumeroAfiliadoInformado(),
153
- prestacionFacturable.getFechaAtencion(),
154
- prestacionFacturable.getCantidad(),
155
- prestacionFacturable.getEstadoAuditoria(),
156
- prestacionFacturable.getMontoCubiertoAplicado(),
157
- prestacionFacturable.getMontoCopagoAplicado(),
158
- prestacionFacturable.getMontoTotalAplicado(),
159
- prestacionFacturable.getObservaciones()
160
- );
161
- }
162
-
163
- private Long parsePacienteId(String pacienteIdExterno) {
164
- return pacienteIdExterno != null ? Long.valueOf(pacienteIdExterno) : null;
165
- }
166
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/PrestacionNomencladorController.java DELETED
@@ -1,106 +0,0 @@
1
- package com.grupo7.modulofacturacion.controller;
2
-
3
- import com.grupo7.modulofacturacion.controller.dto.PrestacionNomencladorEstadoRequest;
4
- import com.grupo7.modulofacturacion.controller.dto.PrestacionNomencladorRequest;
5
- import com.grupo7.modulofacturacion.controller.dto.PrestacionNomencladorResponse;
6
- import com.grupo7.modulofacturacion.model.PrestacionNomenclador;
7
- import com.grupo7.modulofacturacion.model.enums.TipoPrestacion;
8
- import com.grupo7.modulofacturacion.service.PrestacionNomencladorService;
9
- import io.swagger.v3.oas.annotations.tags.Tag;
10
- import io.swagger.v3.oas.annotations.Operation;
11
- import io.swagger.v3.oas.annotations.Parameter;
12
- import jakarta.validation.Valid;
13
- import java.util.List;
14
- import org.springframework.http.HttpStatus;
15
- import org.springframework.web.bind.annotation.GetMapping;
16
- import org.springframework.web.bind.annotation.PatchMapping;
17
- import org.springframework.web.bind.annotation.PathVariable;
18
- import org.springframework.web.bind.annotation.PostMapping;
19
- import org.springframework.web.bind.annotation.PutMapping;
20
- import org.springframework.web.bind.annotation.RequestBody;
21
- import org.springframework.web.bind.annotation.RequestMapping;
22
- import org.springframework.web.bind.annotation.RequestParam;
23
- import org.springframework.web.bind.annotation.ResponseStatus;
24
- import org.springframework.web.bind.annotation.RestController;
25
-
26
- @RestController
27
- @RequestMapping("/api/prestaciones-nomenclador")
28
- @Tag(name = "Nomenclador Medico", description = "Catalogo de prestaciones facturables administrado por Modulo 7.")
29
- public class PrestacionNomencladorController {
30
-
31
- private final PrestacionNomencladorService prestacionNomencladorService;
32
-
33
- public PrestacionNomencladorController(PrestacionNomencladorService prestacionNomencladorService) {
34
- this.prestacionNomencladorService = prestacionNomencladorService;
35
- }
36
-
37
- @GetMapping
38
- @Operation(
39
- summary = "Listar prestaciones del nomenclador",
40
- description = "Por defecto devuelve solo prestaciones activas. Use incluirInactivas=true para incluir inactivas; con activa puede filtrar estado explicitamente cuando se incluyen inactivas."
41
- )
42
- public List<PrestacionNomencladorResponse> listar(
43
- @RequestParam(name = "codigo", required = false) String codigo,
44
- @RequestParam(name = "descripcion", required = false) String descripcion,
45
- @RequestParam(name = "tipoPrestacion", required = false) TipoPrestacion tipoPrestacion,
46
- @RequestParam(name = "activa", required = false) Boolean activa,
47
- @Parameter(description = "Cuando es true incluye prestaciones inactivas; por defecto solo devuelve activas.")
48
- @RequestParam(name = "incluirInactivas", defaultValue = "false") boolean incluirInactivas
49
- ) {
50
- Boolean filtroActiva = incluirInactivas ? activa : Boolean.TRUE;
51
- return prestacionNomencladorService.listar(codigo, descripcion, tipoPrestacion, filtroActiva).stream()
52
- .map(PrestacionNomencladorResponse::fromEntity)
53
- .toList();
54
- }
55
-
56
- @GetMapping("/codigo/{codigoNomenclador}")
57
- @Operation(
58
- summary = "Obtener prestacion activa por codigo",
59
- description = "Para uso externo de facturacion: si el codigo no existe o la prestacion esta inactiva, devuelve un error claro y no la expone como facturable."
60
- )
61
- public PrestacionNomencladorResponse obtenerPorCodigo(@PathVariable String codigoNomenclador) {
62
- return PrestacionNomencladorResponse.fromEntity(
63
- prestacionNomencladorService.obtenerActivaPorCodigoOrThrow(codigoNomenclador)
64
- );
65
- }
66
-
67
- @GetMapping("/{id}")
68
- public PrestacionNomencladorResponse obtenerPorId(@PathVariable Long id) {
69
- return PrestacionNomencladorResponse.fromEntity(prestacionNomencladorService.obtenerPorId(id));
70
- }
71
-
72
- @PostMapping
73
- @ResponseStatus(HttpStatus.CREATED)
74
- public PrestacionNomencladorResponse crear(@Valid @RequestBody PrestacionNomencladorRequest request) {
75
- PrestacionNomenclador prestacion = new PrestacionNomenclador();
76
- applyRequest(prestacion, request);
77
- return PrestacionNomencladorResponse.fromEntity(prestacionNomencladorService.crear(prestacion));
78
- }
79
-
80
- @PutMapping("/{id}")
81
- public PrestacionNomencladorResponse actualizar(
82
- @PathVariable Long id,
83
- @Valid @RequestBody PrestacionNomencladorRequest request
84
- ) {
85
- PrestacionNomenclador prestacion = new PrestacionNomenclador();
86
- applyRequest(prestacion, request);
87
- return PrestacionNomencladorResponse.fromEntity(prestacionNomencladorService.actualizar(id, prestacion));
88
- }
89
-
90
- @PatchMapping("/{id}/estado")
91
- public PrestacionNomencladorResponse cambiarEstado(
92
- @PathVariable Long id,
93
- @Valid @RequestBody PrestacionNomencladorEstadoRequest request
94
- ) {
95
- return PrestacionNomencladorResponse.fromEntity(
96
- prestacionNomencladorService.cambiarEstado(id, request.activa())
97
- );
98
- }
99
-
100
- private void applyRequest(PrestacionNomenclador prestacion, PrestacionNomencladorRequest request) {
101
- prestacion.setCodigoNomenclador(request.codigoNomenclador());
102
- prestacion.setDescripcion(request.descripcion());
103
- prestacion.setTipoPrestacion(request.tipoPrestacion());
104
- prestacion.setActiva(request.activaOrDefault());
105
- }
106
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/ActoMedicoM1Response.java DELETED
@@ -1,30 +0,0 @@
1
- package com.grupo7.modulofacturacion.controller.dto;
2
-
3
- import com.fasterxml.jackson.annotation.JsonProperty;
4
- import java.time.OffsetDateTime;
5
-
6
- public record ActoMedicoM1Response(
7
- @JsonProperty("id_acto_medico")
8
- String idActoMedico,
9
-
10
- @JsonProperty("id_episodio")
11
- String idEpisodio,
12
-
13
- @JsonProperty("codigo_nomenclador")
14
- String codigoNomenclador,
15
-
16
- String descripcion,
17
-
18
- String tipo,
19
-
20
- @JsonProperty("id_profesional")
21
- String idProfesional,
22
-
23
- @JsonProperty("fecha_realizacion")
24
- OffsetDateTime fechaRealizacion,
25
-
26
- Integer cantidad,
27
-
28
- String observaciones
29
- ) {
30
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/ActosMedicosM1Response.java DELETED
@@ -1,15 +0,0 @@
1
- package com.grupo7.modulofacturacion.controller.dto;
2
-
3
- import com.fasterxml.jackson.annotation.JsonProperty;
4
- import java.util.List;
5
-
6
- public record ActosMedicosM1Response(
7
- @JsonProperty("id_episodio")
8
- String idEpisodio,
9
-
10
- Integer total,
11
-
12
- @JsonProperty("actos_medicos")
13
- List<ActoMedicoM1Response> actosMedicos
14
- ) {
15
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/AdjudicarOrdenCompraItemRequest.java DELETED
@@ -1,13 +0,0 @@
1
- package com.grupo7.modulofacturacion.controller.dto;
2
-
3
- import jakarta.validation.constraints.DecimalMin;
4
- import jakarta.validation.constraints.Min;
5
- import jakarta.validation.constraints.NotBlank;
6
- import jakarta.validation.constraints.NotNull;
7
- import java.math.BigDecimal;
8
-
9
- public record AdjudicarOrdenCompraItemRequest(
10
- @NotBlank String productoId,
11
- @NotNull @Min(1) Integer cantidadAprobada,
12
- @NotNull @DecimalMin(value = "0.01") BigDecimal precioUnitario
13
- ) {}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/AdjudicarOrdenCompraRequest.java DELETED
@@ -1,16 +0,0 @@
1
- package com.grupo7.modulofacturacion.controller.dto;
2
-
3
- import jakarta.validation.Valid;
4
- import jakarta.validation.constraints.NotBlank;
5
- import jakarta.validation.constraints.NotEmpty;
6
- import jakarta.validation.constraints.NotNull;
7
- import java.time.OffsetDateTime;
8
- import java.util.List;
9
-
10
- public record AdjudicarOrdenCompraRequest(
11
- @NotBlank String proveedorAdjudicadoRazonSocial,
12
- String proveedorAdjudicadoCuit,
13
- @NotNull OffsetDateTime fechaEntregaEstimada,
14
- String observaciones,
15
- @NotEmpty @Valid List<AdjudicarOrdenCompraItemRequest> items
16
- ) {}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/CajaResumenResponse.java DELETED
@@ -1,9 +0,0 @@
1
- package com.grupo7.modulofacturacion.controller.dto;
2
-
3
- import java.math.BigDecimal;
4
-
5
- public record CajaResumenResponse(
6
- BigDecimal saldoActual,
7
- PageResponse<MovimientoCajaResponse> historial
8
- ) {
9
- }
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/CallbackAdjudicacionRequest.java DELETED
@@ -1,14 +0,0 @@
1
- package com.grupo7.modulofacturacion.controller.dto;
2
-
3
- import java.time.LocalDateTime;
4
- import java.util.List;
5
-
6
- public record CallbackAdjudicacionRequest(
7
- boolean aprobado,
8
- String referenciaExterna,
9
- CallbackProveedorAdjudicadoRequest proveedorAdjudicado,
10
- List<CallbackItemAdjudicadoRequest> itemsAdjudicados,
11
- LocalDateTime fechaAprobacion,
12
- LocalDateTime fechaEntregaEstimada,
13
- String observaciones
14
- ) {}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/CallbackItemAdjudicadoRequest.java DELETED
@@ -1,9 +0,0 @@
1
- package com.grupo7.modulofacturacion.controller.dto;
2
-
3
- import java.math.BigDecimal;
4
-
5
- public record CallbackItemAdjudicadoRequest(
6
- String productoId,
7
- Integer cantidadAprobada,
8
- BigDecimal precioUnitario
9
- ) {}
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/CallbackProveedorAdjudicadoRequest.java DELETED
@@ -1,5 +0,0 @@
1
- package com.grupo7.modulofacturacion.controller.dto;
2
-
3
- public record CallbackProveedorAdjudicadoRequest(
4
- String razonSocial
5
- ) {}
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/CamaUtilizadaM6Request.java DELETED
@@ -1,26 +0,0 @@
1
- package com.grupo7.modulofacturacion.controller.dto;
2
-
3
- import com.fasterxml.jackson.annotation.JsonAlias;
4
- import io.swagger.v3.oas.annotations.media.Schema;
5
- import java.time.OffsetDateTime;
6
-
7
- @Schema(description = "Tramo de uso de cama informado por Modulo 6.")
8
- public record CamaUtilizadaM6Request(
9
- @JsonAlias("cama_id")
10
- @Schema(example = "101")
11
- String camaId,
12
-
13
- @Schema(example = "SALA_COMUN")
14
- String sector,
15
-
16
- @JsonAlias("tipo_cama")
17
- @Schema(example = "SALA_COMUN")
18
- String tipoCama,
19
-
20
- @Schema(example = "2026-06-20T14:30:00Z")
21
- OffsetDateTime desde,
22
-
23
- @Schema(example = "2026-06-22T09:00:00Z")
24
- OffsetDateTime hasta
25
- ) {
26
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/CoberturaPacienteM1Response.java DELETED
@@ -1,35 +0,0 @@
1
- package com.grupo7.modulofacturacion.controller.dto;
2
-
3
- import com.fasterxml.jackson.annotation.JsonAlias;
4
- import com.fasterxml.jackson.annotation.JsonProperty;
5
- import java.time.LocalDate;
6
-
7
- public record CoberturaPacienteM1Response(
8
- @JsonProperty("id_paciente")
9
- Long idPaciente,
10
-
11
- @JsonProperty("id_obra_social")
12
- String idObraSocial,
13
-
14
- @JsonProperty("nombre_obra_social")
15
- String nombreObraSocial,
16
-
17
- @JsonProperty("codigo_plan")
18
- String codigoPlan,
19
-
20
- @JsonProperty("numero_afiliado")
21
- String numeroAfiliado,
22
-
23
- @JsonProperty("vigente_desde")
24
- LocalDate vigenteDesde,
25
-
26
- @JsonProperty("vigente_hasta")
27
- LocalDate vigenteHasta,
28
-
29
- @JsonAlias("entidad_financiadora_id")
30
- Long entidadFinanciadoraId,
31
-
32
- @JsonAlias("plan_id")
33
- Long planId
34
- ) {
35
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/ConvenioArancelRequest.java DELETED
@@ -1,15 +0,0 @@
1
- package com.grupo7.modulofacturacion.controller.dto;
2
-
3
- import java.math.BigDecimal;
4
- import java.time.LocalDateTime;
5
-
6
- public record ConvenioArancelRequest(
7
- Long planId,
8
- Long prestacionId,
9
- BigDecimal valorCubierto,
10
- BigDecimal valorCopago,
11
- LocalDateTime fechaVigenciaDesde,
12
- LocalDateTime fechaVigenciaHasta,
13
- Boolean activo
14
- ) {
15
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/ConvenioArancelResponse.java DELETED
@@ -1,18 +0,0 @@
1
- package com.grupo7.modulofacturacion.controller.dto;
2
-
3
- import java.math.BigDecimal;
4
- import java.time.LocalDateTime;
5
-
6
- public record ConvenioArancelResponse(
7
- Long id,
8
- Long planId,
9
- String planNombre,
10
- Long prestacionId,
11
- String codigoPrestacion,
12
- BigDecimal valorCubierto,
13
- BigDecimal valorCopago,
14
- LocalDateTime fechaVigenciaDesde,
15
- LocalDateTime fechaVigenciaHasta,
16
- boolean activo
17
- ) {
18
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/CopagoItemResponse.java DELETED
@@ -1,16 +0,0 @@
1
- package com.grupo7.modulofacturacion.controller.dto;
2
-
3
- import java.math.BigDecimal;
4
- import java.time.LocalDateTime;
5
-
6
- public record CopagoItemResponse(
7
- Long prestacionFacturableId,
8
- Long pacienteIdExterno,
9
- String codigoPrestacion,
10
- String descripcionPrestacion,
11
- LocalDateTime fechaAtencion,
12
- BigDecimal montoCopagoAplicado,
13
- String moneda,
14
- String estado
15
- ) {
16
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/EntidadFinanciadoraRequest.java DELETED
@@ -1,11 +0,0 @@
1
- package com.grupo7.modulofacturacion.controller.dto;
2
-
3
- import com.grupo7.modulofacturacion.model.enums.TipoFinanciador;
4
-
5
- public record EntidadFinanciadoraRequest(
6
- String nombre,
7
- String cuit,
8
- TipoFinanciador tipoFinanciador,
9
- Boolean activa
10
- ) {
11
- }
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/EntidadFinanciadoraResponse.java DELETED
@@ -1,12 +0,0 @@
1
- package com.grupo7.modulofacturacion.controller.dto;
2
-
3
- import com.grupo7.modulofacturacion.model.enums.TipoFinanciador;
4
-
5
- public record EntidadFinanciadoraResponse(
6
- Long id,
7
- String nombre,
8
- String cuit,
9
- TipoFinanciador tipoFinanciador,
10
- boolean activa
11
- ) {
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/EpisodioM1Response.java DELETED
@@ -1,32 +0,0 @@
1
- package com.grupo7.modulofacturacion.controller.dto;
2
-
3
- import com.fasterxml.jackson.annotation.JsonProperty;
4
- import java.time.OffsetDateTime;
5
-
6
- public record EpisodioM1Response(
7
- @JsonProperty("id_episodio")
8
- String idEpisodio,
9
-
10
- @JsonProperty("id_paciente")
11
- Long idPaciente,
12
-
13
- String tipo,
14
-
15
- String estado,
16
-
17
- @JsonProperty("id_sede")
18
- String idSede,
19
-
20
- @JsonProperty("id_medico_responsable")
21
- String idMedicoResponsable,
22
-
23
- @JsonProperty("diagnostico_principal")
24
- String diagnosticoPrincipal,
25
-
26
- @JsonProperty("fecha_apertura")
27
- OffsetDateTime fechaApertura,
28
-
29
- @JsonProperty("fecha_cierre")
30
- OffsetDateTime fechaCierre
31
- ) {
32
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/FacturaEmitidaResponse.java DELETED
@@ -1,17 +0,0 @@
1
- package com.grupo7.modulofacturacion.controller.dto;
2
-
3
- import java.math.BigDecimal;
4
- import java.time.LocalDate;
5
- import java.util.List;
6
-
7
- public record FacturaEmitidaResponse(
8
- Long id,
9
- String numeroComprobante,
10
- String tipoComprobante,
11
- String entidadPagadoraId,
12
- LocalDate fechaEmision,
13
- LocalDate fechaVencimiento,
14
- BigDecimal montoTotal,
15
- List<Long> prestacionesIds
16
- ) {
17
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/FacturaRecibidaResponse.java DELETED
@@ -1,20 +0,0 @@
1
- package com.grupo7.modulofacturacion.controller.dto;
2
-
3
- import com.grupo7.modulofacturacion.model.enums.EstadoAprobacionFacturaRecibida;
4
- import java.math.BigDecimal;
5
- import java.time.LocalDate;
6
-
7
- public record FacturaRecibidaResponse(
8
- Long id,
9
- String moduloOrigen,
10
- String idTransaccionOrigen,
11
- String cuitProveedor,
12
- String razonSocialProveedor,
13
- String numeroComprobante,
14
- LocalDate fechaEmision,
15
- LocalDate fechaVencimiento,
16
- String concepto,
17
- BigDecimal montoTotal,
18
- EstadoAprobacionFacturaRecibida estadoAprobacion
19
- ) {
20
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DesarrolloAPPS2-BE-main/src/main/java/com/grupo7/modulofacturacion/controller/dto/GenerarFacturaCopagoRequest.java DELETED
@@ -1,17 +0,0 @@
1
- package com.grupo7.modulofacturacion.controller.dto;
2
-
3
- import io.swagger.v3.oas.annotations.media.Schema;
4
- import jakarta.validation.constraints.NotEmpty;
5
- import jakarta.validation.constraints.NotNull;
6
- import java.util.List;
7
-
8
- @Schema(description = "Solicitud manual para generar una factura de copago.")
9
- public record GenerarFacturaCopagoRequest(
10
- @Schema(example = "10500")
11
- @NotNull(message = "El id del paciente es obligatorio")
12
- Long idPaciente,
13
- @Schema(example = "[1, 2]")
14
- @NotEmpty(message = "Debe indicar al menos una prestacion")
15
- List<Long> idsPrestaciones
16
- ) {
17
- }