Skip to content

Commit dc45695

Browse files
committed
ref(MISC): reemplaza libreria de creacion de pdf y agrega resizer
1 parent 7c9d5e9 commit dc45695

21 files changed

Lines changed: 16864 additions & 37010 deletions

File tree

modules/cda/routes/cda.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ router.post('/createInformeCDA', Auth.authenticate(), async (req: any, res, next
2626
}
2727
try {
2828
const informe = new InformeCDA(req.body, req.user.usuario);
29-
const fileName = await informe.informe();
30-
return res.download(fileName);
29+
const pdfBuffer = await informe.informe();
30+
31+
res.setHeader('Content-Type', 'application/pdf');
32+
res.setHeader('Content-Disposition', 'inline; filename="informe.pdf"');
33+
return res.send(pdfBuffer);
3134
} catch (err) {
3235
return next(err);
3336
}

modules/descargas/ficha-epidemiologica/ficha-body.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@ export class FichaEpidemiologicaBody extends HTMLComponent {
44
template = `
55
<main>
66
<p class="texto-centrado">FICHA {{tipo}}</p>
7-
{{#each arreSecciones}}
8-
<h6><u>{{seccionNombre}}:</u></h6>
9-
{{#each arreFields}}
10-
{{#if fieldValor.nombre}}
11-
<p><b>{{fieldNombre}}:</b> {{fieldValor.nombre}}</p>
12-
{{else}}
13-
<p><b>{{fieldNombre}}:</b> {{fieldValor}}</p>
14-
{{/if}}
7+
<section class="contenedor-secundario">
8+
{{#each arreSecciones}}
9+
<h6><u>{{seccionNombre}}:</u></h6>
10+
{{#each arreFields}}
11+
{{#if fieldValor.nombre}}
12+
<p><b>{{fieldNombre}}:</b> {{fieldValor.nombre}}</p>
13+
{{else}}
14+
<p><b>{{fieldNombre}}:</b> {{fieldValor}}</p>
15+
{{/if}}
16+
{{/each}}
1517
{{/each}}
16-
{{/each}}
18+
</section>
1719
</main>
1820
`;
1921

modules/descargas/ficha-epidemiologica/ficha-footer.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import * as moment from 'moment';
44
export class FichaEpidemiologicaFooter extends HTMLComponent {
55
template = `
66
<hr>
7-
<div class="foot"> <b>Fecha y hora de impresión: </b>{{fecha}} </div>
8-
<div class="foot"> <b>Impreso por: </b>{{usuario}} </div>
7+
<span class="foot">
8+
<p><b>Fecha y hora de impresión: </b>{{fecha}}</p>
9+
<p><b>Impreso por: </b>{{usuario}}</p>
10+
</span>
911
`;
1012

1113
constructor(public usuario) {

modules/descargas/informe-censo/censo-body.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export class CensoBody extends HTMLComponent {
66
<!-- Body -->
77
<main>
88
<section class="contenedor-informe">
9-
<table class="table table-bordered">
9+
<table class="resumen table table-bordered">
1010
<thead>
1111
<tr>
1212
<th>Paciente</th>
@@ -81,45 +81,45 @@ export class CensoBody extends HTMLComponent {
8181
<thead>
8282
<tr>
8383
<th rowspan="2">
84-
<h6>Existencia a las 0 hs</h6>
84+
Existencia a las 0 hs
8585
</th>
8686
<th rowspan="2">
87-
<h6>Ingresos</h6>
87+
Ingresos
8888
</th>
8989
<th rowspan="2">
90-
<h6>Pases de</h6>
90+
Pases de
9191
</th>
9292
<th colspan="2">
93-
<h6>Egreso</h6>
93+
Egreso
9494
</th>
9595
<th rowspan="2">
96-
<h6>Pases A</h6>
96+
Pases A
9797
</th>
9898
<th rowspan="2">
99-
<h6>Existencia a las 24 hs</h6>
99+
Existencia a las 24 hs
100100
</th>
101101
<th rowspan="2">
102-
<h6>Ingresos y egresos del día</h6>
102+
Ingresos y egresos del día
103103
</th>
104104
<th rowspan="2">
105-
<h6>Pacientes día</h6>
105+
Pacientes día
106106
</th>
107107
<!-- <th rowspan="2">
108-
<h6>Camas disponibles a las 0hs</h6>
108+
Camas disponibles a las 0hs
109109
</th> -->
110110
<th rowspan="2">
111-
<h6>Días estada</h6>
111+
Días estada
112112
</th>
113113
<th rowspan="2">
114-
<h6>Camas disponibles a las 24hs</h6>
114+
Camas disponibles a las 24hs
115115
</th>
116116
</tr>
117117
<tr>
118118
<th>
119-
<h6>Altas</h6>
119+
Altas
120120
</th>
121121
<th>
122-
<h6>Defunciones</h6>
122+
Defunciones
123123
</th>
124124
</tr>
125125
</thead>

modules/descargas/informe-censo/censo-header.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ export class CensoHeader extends HTMLComponent {
1616
{{/if}}
1717
</span>
1818
<span class="contenedor-logos-secundarios">
19-
<img class="logo-adicional" src="data:image/png;base64,{{ logos.logoAdicional }}">
20-
<img class="logo-andes" src="data:image/png;base64,{{ logos.logoAndes }}">
19+
<img class="logo-adicional" src="data:image/png;base64,{{ logos.adicional }}">
20+
<img class="logo-andes" src="data:image/png;base64,{{ logos.andes }}">
2121
</span>
2222
</section>
2323
<section class="contenedor-data-origen">
24+
<hr>
2425
<span class="contenedor-principal-data">
2526
<div class="contenedor-secundario">
2627
<h4>
@@ -34,6 +35,7 @@ export class CensoHeader extends HTMLComponent {
3435
</h5>
3536
</div>
3637
</span>
38+
<hr>
3739
</section>
3840
`;
3941

modules/descargas/informe-censo/censo-mensual-body.ts

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,45 +10,45 @@ export class CensoMensualBody extends HTMLComponent {
1010
<thead>
1111
<tr>
1212
<th rowspan="2">
13-
<h6>Fecha</h6>
13+
Fecha
1414
</th>
1515
<th rowspan="2">
16-
<h6>Existencia 0 hs</h6>
16+
Existencia 0 hs
1717
</th>
1818
<th rowspan="2">
19-
<h6>Ingresos</h6>
19+
Ingresos
2020
</th>
2121
<th rowspan="2">
22-
<h6>Pases de</h6>
22+
Pases de
2323
</th>
2424
<th colspan="2">
25-
<h6>Egreso</h6>
25+
Egreso
2626
</th>
2727
<th rowspan="2">
28-
<h6>Pases A</h6>
28+
Pases A
2929
</th>
3030
<th rowspan="2">
31-
<h6>Existencia 24 hs</h6>
31+
Existencia 24 hs
3232
</th>
3333
<th rowspan="2">
34-
<h6>Ingresos- Egresos día</h6>
34+
Ingresos- Egresos día
3535
</th>
3636
<th rowspan="2">
37-
<h6>Pacientes día</h6>
37+
Pacientes día
3838
</th>
3939
<th rowspan="2">
40-
<h6>Camas disponibles 24hs</h6>
40+
Camas disponibles 24hs
4141
</th>
4242
<th rowspan="2">
43-
<h6>Días de estada</h6>
43+
Días de estada
4444
</th>
4545
</tr>
4646
<tr>
4747
<th>
48-
<h6>Altas</h6>
48+
Altas
4949
</th>
5050
<th>
51-
<h6>Defunciones</h6>
51+
Defunciones
5252
</th>
5353
</tr>
5454
</thead>
@@ -90,26 +90,26 @@ export class CensoMensualBody extends HTMLComponent {
9090
<table class="resumen table">
9191
<thead>
9292
<tr>
93-
<th>
94-
<h6>Días de funcionamiento del servicio</h6>
93+
<th rowspan="2">
94+
Días de funcionamiento del servicio
9595
</th>
96-
<th>
97-
<h6>Promedio diario de camas disponibles</h6>
96+
<th rowspan="2">
97+
Promedio diario de camas disponibles
9898
</th>
99-
<th>
100-
<h6>Promedio diario de paciente día</h6>
99+
<th rowspan="2">
100+
Promedio diario de paciente día
101101
</th>
102-
<th>
103-
<h6>Tasa de mortalidad hospitalaria</h6>
102+
<th rowspan="2">
103+
Tasa de mortalidad hospitalaria
104104
</th>
105-
<th>
106-
<h6>Promedio de permanencia</h6>
105+
<th rowspan="2">
106+
Promedio de permanencia
107107
</th>
108-
<th>
109-
<h6>Giro Cama</h6>
108+
<th rowspan="2">
109+
Giro Cama
110110
</th>
111-
<th>
112-
<h6>Promedio días de estada</h6>
111+
<th rowspan="2">
112+
Promedio días de estada
113113
</th>
114114
</tr>
115115
</thead>

modules/descargas/informe-censo/censo-mensual-header.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ export class CensoMensualHeader extends HTMLComponent {
1818
{{/if}}
1919
</span>
2020
<span class="contenedor-logos-secundarios">
21-
<img class="logo-adicional" src="data:image/png;base64,{{ logos.logoAdicional }}">
22-
<img class="logo-andes" src="data:image/png;base64,{{ logos.logoAndes }}">
21+
<img class="logo-adicional" src="data:image/png;base64,{{ logos.adicional }}">
22+
<img class="logo-andes" src="data:image/png;base64,{{ logos.andes }}">
2323
</span>
2424
</section>
2525
<section class="contenedor-data-origen">
26+
<hr>
2627
<span class="contenedor-principal-data">
2728
<div class="contenedor-secundario">
2829
<h3>
@@ -39,6 +40,7 @@ export class CensoMensualHeader extends HTMLComponent {
3940
</h5>
4041
</div>
4142
</span>
43+
<hr>
4244
</section>
4345
</header>
4446
<!-- END Header -->

modules/descargas/informe-rup/elementos-rup/adjuntar-documento.component.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { HTMLComponent } from '../../model/html-component.class';
22
import * as mime from 'mime-types';
33
import { streamToBase64, readFile } from '../../../../core/tm/controller/file-storage';
44
import { getArchivoAdjunto } from '../../../../modules/rup/controllers/rup';
5+
import { streamToJpegDataUri } from '../../../../utils/pdf/puppeteer';
56

67

78
export class AdjuntarDocumentoComponent extends HTMLComponent {
@@ -17,7 +18,7 @@ export class AdjuntarDocumentoComponent extends HTMLComponent {
1718
{{#each documentos}}
1819
<div class="subregistro">
1920
<p> {{ term }}: </p>
20-
<img class="w-25 archivo-adjunto" src="data:image/png;base64,{{img}}">
21+
<img class="w-50 archivo-adjunto" src="{{img}}">
2122
</div>
2223
{{/each}}
2324
</div>
@@ -45,8 +46,21 @@ export class AdjuntarDocumentoComponent extends HTMLComponent {
4546
return new Promise(async (resolve, reject) => {
4647
if (documento.id) {
4748
const stream = await getArchivoAdjunto(documento.id);
48-
const base64 = await streamToBase64(stream);
49-
return resolve({ img: base64, term: documento?.descripcion?.term });
49+
const img = await streamToJpegDataUri(stream, { maxWidth: 1600, quality: 75 });
50+
return resolve({ img, term: documento?.descripcion?.term });
51+
52+
53+
// const stream = await getArchivoAdjunto(documento.id);
54+
// const dataUri = await streamToOptimizedDataUri(stream, {
55+
// format: 'jpeg', // o 'webp' si necesitás alpha
56+
// quality: 75,
57+
// maxWidth: 1600,
58+
// });
59+
// return resolve({ img: dataUri, term: documento?.descripcion?.term });
60+
61+
62+
// const base64 = await streamToBase64(stream);
63+
// return resolve({ img: base64, term: documento?.descripcion?.term });
5064
}
5165
return;
5266
});

modules/descargas/informe-rup/informe-body.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,47 @@ import { InformeRupFirma } from './informe-firma';
66
export class InformeRupBody extends HTMLComponent {
77
template = `
88
<main>
9+
<hr>
910
<section class="contenedor-informe">
10-
<article class="cabezal-conceptos horizontal">
11-
<div class="contenedor-bloque-texto w-3/4" >
11+
<span class="cabezal-conceptos horizontal">
12+
<div class="contenedor-bloque-texto w-50">
1213
<div class="tipo-prestacion">
1314
{{ titulo }}
1415
</div>
1516
</div>
16-
1717
<div class="contenedor-bloque-texto">
18-
<h6 class="bolder">
19-
Fecha Consulta
18+
<h6>
19+
<b>Fecha Consulta</b>
2020
</h6>
2121
<h6>
2222
{{ fechaEjecucion }}hs
2323
</h6>
2424
</div>
2525
<div class="contenedor-bloque-texto">
2626
{{#if esValidada}}
27-
<h6 class="bolder">
28-
Fecha Validación
27+
<h6>
28+
<b>Fecha Validación</b>
2929
</h6>
3030
<h6>
3131
{{ fechaValidacion }}hs
3232
</h6>
3333
{{else}}
34-
<h6 class="bolder">
35-
Sin validar
34+
<h6>
35+
<b>Sin validar</b>
3636
</h6>
3737
{{/if}}
3838
</div>
3939
<div class="contenedor-bloque-texto">
40-
<h6 class="bolder">
41-
Inicio de Prestación
40+
<h6>
41+
<b>Inicio de Prestación</b>
4242
</h6>
4343
<h6>
4444
{{ fechaPrestacion }}hs
4545
</h6>
4646
</div>
47-
</article>
47+
</span>
4848
<hr>
49+
<br>
4950
<div class="registros">
5051
{{#each registros}}
5152
{{{this}}}

modules/descargas/informe-rup/informe-firma.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Profesional } from '../../../core/tm/schemas/profesional';
66

77
export class InformeRupFirma extends HTMLComponent {
88
template = `
9-
<footer id="last">
9+
<section id="last">
1010
<!-- Firmas -->
1111
<span class="contenedor-firmas">
1212
<div class="contenedor-bloque-texto">
@@ -24,7 +24,7 @@ export class InformeRupFirma extends HTMLComponent {
2424
{{/if}}
2525
</div>
2626
</span>
27-
</footer>
27+
</section>
2828
`;
2929

3030
constructor(public profesional, public organizacion) {

0 commit comments

Comments
 (0)