-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(HUDS-104): Implementar descarga en PDF de laboratorios
- Loading branch information
1 parent
c9083f7
commit 11cf769
Showing
8 changed files
with
282 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { HTMLComponent } from '../model/html-component.class'; | ||
import * as moment from 'moment'; | ||
|
||
export class FarmaciaBody extends HTMLComponent { | ||
template = ` | ||
<main> | ||
<table border="1" width="100%" class="tabla-header"> | ||
<tr> | ||
<td width="35%"><b>Paciente: </b>{{encabezado.data.apellido }} {{encabezado.data.nombre}}</td> | ||
<td width="15%"><b>Fecha de Nacimiento: </b>{{encabezado.data.fechanacimiento}}</td> | ||
<td width="15%"><b>Género: </b>{{encabezado.data.sexo}}</td> | ||
<td width="15%"><b>DNI: </b>{{encabezado.data.documento}}</td> | ||
</tr> | ||
<tr> | ||
<td width="35%"><b>Solicitante: </b>{{encabezado.data.medicoSolicitante}}</td> | ||
<td width="15%"><b>Orden Nro: </b> {{encabezado.data.numero}}</td> | ||
<td width="15%"><b>Fecha: </b>{{encabezado.data.fecha}}</td> | ||
<td width="15%"><b>Origen: </b>{{encabezado.data.origen}}</td> | ||
</tr> | ||
<td colspan="1"><b>Efector solicitante: </b>{{encabezado.data.efectorSolicitante}}</td> | ||
<td colspan="3"><b>Laboratorio: </b>{{encabezado.data.Laboratorio}}</td> | ||
</table> | ||
{{#each areas}} | ||
<div class="tituloGeneral"><u>{{area}}</u> </div> | ||
{{#each grupos}} | ||
<div class="tituloSecundario"><b> {{grupo}}</b></div> | ||
{{#each items}} | ||
{{#if esTitulo}} | ||
<div class="tituloTabla"><u>{{nombre}}</u></div> | ||
{{else}} | ||
<table class="tituloTabla"> | ||
<tr> | ||
<td width="25%">{{nombre}}</td> | ||
<td width="25%"><i>{{resultado }}{{ unidadMedida}}</i></td> | ||
<td width="25%">{{valorReferencia }}{{metodo}}</td> | ||
<td width="25%"><i>{{userValida}}</i></td> | ||
</tr> | ||
</table> | ||
{{/if}} | ||
{{/each}} | ||
{{/each}} | ||
{{/each}} | ||
</main> | ||
`; | ||
|
||
constructor(public encabezado, public paciente, public detalle) { | ||
super(); | ||
} | ||
|
||
public async process() { | ||
const setAreas = new Set(this.detalle.map(d => d.area)); | ||
const areasStr = Array.from(setAreas); | ||
|
||
const areas = []; | ||
areasStr.forEach(area => { | ||
const detallesArea = this.detalle.filter(d => d.area === area); | ||
const setGrupos = new Set(detallesArea.map(d => d.grupo)); | ||
const grupos = Array.from(setGrupos); | ||
|
||
const item = { | ||
area, | ||
grupos: grupos.map(g => { | ||
const detallesAreaGrupo = detallesArea.filter(da => da.grupo === g); | ||
const res: any = {}; | ||
const toItem = (e) => ({ | ||
nombre: e.item, | ||
esTitulo: e.esTitulo === 'True' ? true : false, | ||
resultado: e.resultado, | ||
metodo: e.Metodo, | ||
valorReferencia: e.valorReferencia, | ||
unidadMedida: e.unidadMedida, | ||
userValida: e.userValida | ||
}); | ||
if (detallesAreaGrupo.length === 1 && detallesAreaGrupo[0].grupo === g) { | ||
res.item = toItem(detallesAreaGrupo[0]); | ||
} else { | ||
res.grupo = g; | ||
res.items = detallesAreaGrupo.map(toItem); | ||
} | ||
|
||
return res; | ||
}) | ||
}; | ||
|
||
areas.push(item); | ||
}); | ||
|
||
this.encabezado.data.fecha = moment(this.encabezado.data.fecha).format('DD-MM-YYYY'); | ||
this.encabezado.data.fechanacimiento = moment(this.encabezado.data.fechanacimiento).format('DD-MM-YYYY'); | ||
this.encabezado.data.sexo = this.paciente[0].genero; | ||
if (this.paciente[0].alias) { | ||
this.encabezado.data.nombre = this.paciente[0].alias; | ||
} | ||
this.data = { | ||
areas, | ||
encabezado: this.encabezado | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { HTMLComponent } from '../model/html-component.class'; | ||
import * as moment from 'moment'; | ||
|
||
export class LaboratorioFooter extends HTMLComponent { | ||
template = ` | ||
<hr> | ||
<div class="foot"> Fecha y hora de impresión: {{fecha}} </div> | ||
<div class="foot"> Impreso por: {{usuario}} </div> | ||
`; | ||
|
||
constructor(public usuario) { | ||
super(); | ||
this.data = { | ||
fecha: moment().format('DD/MM/YYYY HH:mm:ss'), | ||
usuario | ||
}; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { HTMLComponent } from '../model/html-component.class'; | ||
|
||
export class FarmaciaHeader extends HTMLComponent { | ||
template = ` | ||
<div class="contenedor-secundario"> | ||
Resultados de Laboratorio | ||
<h3>{{encabezado.data.Laboratorio}}"</h3> | ||
</div> | ||
<div class="contenedor-secundario"> | ||
<hr/> | ||
`; | ||
|
||
constructor(public encabezado) { | ||
super(); | ||
} | ||
|
||
public async process() { | ||
this.data = { | ||
encabezado: this.encabezado | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { InformePDF, getAssetsURL } from '../model/informe.class'; | ||
import { FarmaciaBody } from './laboratorio-body'; | ||
import { FarmaciaHeader } from './laboratorio-header'; | ||
import { LaboratorioFooter } from './laboratorio-footer'; | ||
|
||
export class Laboratorio extends InformePDF { | ||
constructor(private encabezado, private detalle, private paciente, private usuario) { | ||
super(); | ||
} | ||
|
||
stylesUrl = [ | ||
getAssetsURL('templates/laboratorio/laboratorio.scss') | ||
]; | ||
|
||
public async process() { | ||
this.header = new FarmaciaHeader(this.encabezado); | ||
this.body = new FarmaciaBody(this.encabezado, this.paciente, this.detalle); | ||
this.footer = new LaboratorioFooter(this.usuario); | ||
|
||
await super.process(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { services } from './../../services'; | ||
|
||
export async function search(data) { | ||
let params; | ||
const service = 'get-LABAPI'; | ||
if (data.idProtocolo) { | ||
params = { | ||
parametros: `nombre=LABAPI_GetResultadoProtocolo¶metros=${data.idProtocolo}` | ||
}; | ||
} else { | ||
params = { | ||
parametros: `nombre=LABAPI_GetProtocolos¶metros=${data.estado}|${data.dni}|${data.fechaNac}|${data.apellido}|${data.fechaDesde}|${data.fechaHasta}` | ||
}; | ||
} | ||
const response = await services.get(service).exec(params); | ||
return response; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
.contenedor-secundario { | ||
display: block; | ||
text-align: center; | ||
font-size: .25cm; | ||
} | ||
|
||
.tabla-header { | ||
border-color: black; | ||
border-collapse: collapse; | ||
font-size: .25cm; | ||
} | ||
|
||
td { | ||
text-align: left; | ||
} | ||
|
||
.tabla-header { | ||
border-color: black; | ||
border-collapse: collapse; | ||
font-size: .20cm; | ||
} | ||
|
||
.tituloGeneral { | ||
text-align: left; | ||
margin-top: 20px; | ||
font-size: .25cm; | ||
} | ||
|
||
.tituloSecundario { | ||
text-align: left; | ||
margin-top: 8px; | ||
font-size: .25cm; | ||
} | ||
|
||
.tituloTabla { | ||
text-align: left; | ||
margin-top: 8px; | ||
margin-left: 20px; | ||
font-size: .25cm; | ||
} | ||
|
||
body { | ||
padding-left: 0.5cm; | ||
padding-right: 0.5cm; | ||
font-family: Arial, sans-serif; | ||
} | ||
|
||
.foot { | ||
font-family: Arial, sans-serif; | ||
font-size: 10px; | ||
} |