Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/tm/controller/localidad.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import { MatchingAndes } from '@andes/match/lib/matchingAndes.class';
const { MatchingAndes } = require('@andes/match');
import * as localidad from '../schemas/localidad';
import * as provincia from '../schemas/provincia_model';
import { ZonaSanitaria } from '../schemas/zonaSanitarias';
Expand Down
4 changes: 2 additions & 2 deletions core/tm/schemas/ocupacion.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as mongoose from 'mongoose';

const schema = new mongoose.Schema({
export const schema = new mongoose.Schema({ // Export the schema itself
codigo: {
type: String
},
nombre: {
type: String
}
});
// export let ocupacionSchema = schema;

export const model = mongoose.model('ocupaciones', schema, 'ocupaciones');
183 changes: 178 additions & 5 deletions modules/descargas/informe-rup/informe-body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,144 @@ export class InformeRupBody extends HTMLComponent {
{{{this}}}
{{/each}}
</div>

{{#if informeEstadistico}}
<div class="registros">
<h4 class="bolder">DATOS DE INGRESO</h4>
<div class="contenedor-secundario">
<div class="contenedor-bloque-texto">
<h6 class="bolder">Fecha Ingreso</h6>
<h6>{{ informeEstadistico.ingreso.fecha }}</h6>
</div>
<div class="contenedor-bloque-texto">
<h6 class="bolder">Origen hospitalización</h6>
<h6>{{ informeEstadistico.ingreso.origen }}</h6>
</div>
<div class="contenedor-bloque-texto">
<h6 class="bolder">Motivo de ingreso</h6>
<h6>{{ informeEstadistico.ingreso.motivo }}</h6>
</div>
<div class="contenedor-bloque-texto">
<h6 class="bolder">Ocupación habitual</h6>
<h6>{{ informeEstadistico.ingreso.ocupacion }}</h6>
</div>
<div class="contenedor-bloque-texto">
<h6 class="bolder">Situación laboral</h6>
<h6>{{ informeEstadistico.ingreso.situacionLaboral.nombre }}</h6>
</div>
<div class="contenedor-bloque-texto">
<h6 class="bolder">Nivel instrucción</h6>
<h6>{{ informeEstadistico.ingreso.nivelInstruccion.nombre }}</h6>
</div>
<div class="contenedor-bloque-texto">
<h6 class="bolder">Obra social</h6>
<h6>{{ informeEstadistico.ingreso.obraSocial.nombre }}</h6>
</div>
<div class="contenedor-bloque-texto">
<h6 class="bolder">Asociado</h6>
<h6>{{ informeEstadistico.ingreso.asociado }}</h6>
</div>
</div>

{{#if informeEstadistico.egreso}}
<h4 class="bolder mt-2">ALTA DEL PACIENTE</h4>
<div class="contenedor-secundario">
<div class="contenedor-bloque-texto">
<h6 class="bolder">Fecha de egreso</h6>
<h6>{{ informeEstadistico.egreso.fecha }}</h6>
</div>
<div class="contenedor-bloque-texto">
<h6 class="bolder">Días de estada</h6>
<h6>{{ informeEstadistico.egreso.diasEstada }}</h6>
</div>
<div class="contenedor-bloque-texto">
<h6 class="bolder">Tipo de egreso</h6>
<h6>{{ informeEstadistico.egreso.tipoEgreso }}</h6>
</div>
</div>

{{#if informeEstadistico.egreso.causaExterna}}
<h4 class="bolder mt-2">CAUSA EXTERNA</h4>
<div class="contenedor-secundario">
{{#if informeEstadistico.egreso.causaExterna.comoSeProdujo}}
<div class="contenedor-bloque-texto">
<h6 class="bolder">Cómo se produjo</h6>
<h6>{{ informeEstadistico.egreso.causaExterna.comoSeProdujo }}</h6>
</div>
{{/if}}
{{#if informeEstadistico.egreso.causaExterna.producidaPor}}
<div class="contenedor-bloque-texto">
<h6 class="bolder">Producido por</h6>
<h6>{{ informeEstadistico.egreso.causaExterna.producidaPor }}</h6>
</div>
{{/if}}
{{#if informeEstadistico.egreso.causaExterna.lugar}}
<div class="contenedor-bloque-texto">
<h6 class="bolder">Lugar donde ocurrió</h6>
<h6>{{ informeEstadistico.egreso.causaExterna.lugar }}</h6>
</div>
{{/if}}
</div>
{{/if}}
{{/if}}
</div>
{{/if}}

{{#if movimientos}}
<div class="registros">
<h4 class="bolder">MOVIMIENTOS DE INTERNACIÓN</h4>
<table class="table table-striped">
<thead>
<tr>
<th>
<small class="font-weight-bold">
FECHA
</small>
</th>
<th>
<small class="font-weight-bold">
CAMA
</small>
</th>
<th>
<small class="font-weight-bold">
UNIDAD ORGANIZATIVA
</small>
</th>
</tr>
</thead>
<tbody>
{{#each movimientos}}
<tr>
<td>
<small>
{{ fecha }}
</small>
</td>
<td>
<small>
{{#if extras.ingreso}}
INGRESO <br>
{{/if}}
{{#if extras.egreso}}
EGRESO <br>
{{/if}}
{{#unless idSalaComun}}
{{ nombre }} <br> ({{ sectorName }})
{{/unless}}
</small>
</td>
<td>
<small>
{{ unidadOrganizativa }}
</small>
</td>
</tr>
{{/each}}
</tbody>
</table>
</div>
{{/if}}
{{#if firmaHTML}}
{{{ firmaHTML }}}
{{/if}}
Expand Down Expand Up @@ -87,27 +225,62 @@ export class InformeRupBody extends HTMLComponent {
const registros = await Promise.all(ps);
const firmaHTML = await this.getFirmaHTML();

const movimientos = (this as any).movimientos?.map(mov => {
return {
...mov,
fecha: moment(mov.fecha).format('DD/MM/YYYY HH:mm'),
unidadOrganizativa: mov.unidadOrganizativa?.term || mov.unidadOrganizativas?.[0]?.term || ''
};
});

const informeEstadistico = this.prestacion.informeEstadistico ? {
ingreso: {
...this.prestacion.informeEstadistico.ingreso,
fecha: this.prestacion.informeEstadistico.ingreso.fecha && moment(this.prestacion.informeEstadistico.ingreso.fecha).format('DD/MM/YYYY HH:mm'),
obraSocial: this.prestacion.informeEstadistico.ingreso.obraSocial || 'sin obra social'
},
egreso: this.prestacion.informeEstadistico.egreso ? {
...this.prestacion.informeEstadistico.egreso,
fecha: this.prestacion.informeEstadistico.egreso.fecha && moment(this.prestacion.informeEstadistico.egreso.fecha).format('DD/MM/YYYY HH:mm')
} : null
} : null;


this.data = {

fechaEjecucion: fechaEjecucion && moment(fechaEjecucion).format('DD/MM/YYYY HH:mm'),
fechaValidacion: fechaValidacion && moment(fechaValidacion).format('DD/MM/YYYY HH:mm'),
fechaPrestacion: fechaPrestacion && moment(fechaPrestacion).format('DD/MM/YYYY HH:mm'),
titulo: this.prestacion.solicitud.tipoPrestacion.term,
registros,
movimientos,
informeEstadistico,
esValidada,
firmaHTML
};
}

async getFirmaHTML() {
if (this.validada()) {
const prof = this.prestacion.estadoActual.createdBy;
const firmaHTMLComponent = new InformeRupFirma(prof, this.prestacion.solicitud.organizacion);
const prof =
this.prestacion.estadoActual.createdBy ||
this.prestacion.estadoActual.updatedBy;

if (!prof) {
return null;
}

const firmaHTMLComponent = new InformeRupFirma(
prof,
this.prestacion.solicitud.organizacion
);

await firmaHTMLComponent.process();
return firmaHTMLComponent.profesional ? firmaHTMLComponent.render() : null;
} else {
return null;
return firmaHTMLComponent.profesional
? firmaHTMLComponent.render()
: null;
}
return null;
}

getFechaEstado(tipo: 'validada' | 'ejecucion') {
Expand Down
18 changes: 14 additions & 4 deletions modules/descargas/informe-rup/informe-firma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ export class InformeRupFirma extends HTMLComponent {

if (this.profesional) {
firma = await this.getFirma(this.profesional);

matriculas = await this.getMatriculas();

detalle = this.profesional.apellido + ', ' + this.profesional.nombre;
}
const detalle2 = this.organizacion.nombre.substring(0, this.organizacion.nombre.indexOf('-'));
Expand All @@ -55,22 +57,30 @@ export class InformeRupFirma extends HTMLComponent {
private async getFirma(profesional) {
const FirmaSchema = makeFsFirma();
const idProfesional = String(profesional.id);
const file = await FirmaSchema.findOne({ 'metadata.idProfesional': idProfesional });

const file = await FirmaSchema.findOne({
'metadata.idProfesional': idProfesional
});

if (file && file._id) {
const stream = await FirmaSchema.readFile({ _id: file._id });
const base64 = await streamToBase64(stream);
return base64;
}

return null;
}

private async getMatriculas() {

const infoMatriculas = await searchMatriculas(this.profesional.id);

if (!infoMatriculas) {
return null;
}
const grado = infoMatriculas.formacionGrado.map(e => `${e.nombre} MP ${e.numero}`);
const posgrado = infoMatriculas.formacionPosgrado.map(e => `${e.nombre} ME ${e.numero}`);

return [...grado, ...posgrado].join('<br>');

const result = [...grado, ...posgrado].join('<br>');
return result;
}
}
34 changes: 29 additions & 5 deletions modules/descargas/informe-rup/informe-header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class InformeRupHeader extends HTMLComponent {
<h6 class="bolder">
Internación
</h6>
{{ubicacion}}
{{{ubicacion}}}
</div>
</div>
{{/if}}
Expand Down Expand Up @@ -145,10 +145,9 @@ export class InformeRupHeader extends HTMLComponent {
{{/unless}}
`;

constructor(public prestacion, public paciente, public organizacion, public cama) {
constructor(public prestacion, public paciente, public organizacion, public cama, public movimientos = []) {
super();

// [TODO] helpers date formats en Handlerbars

const fechaNacimiento = paciente.fechaNacimiento ? moment(paciente.fechaNacimiento).format('DD/MM/YYYY') : 's/d';
const fechaPrestacion = moment(prestacion.ejecucion.fecha);
Expand All @@ -159,7 +158,7 @@ export class InformeRupHeader extends HTMLComponent {
const fechaSolicitud = this.prestacion.solicitud.fecha;

// [TODO] metodo getCarpeta en paciente
const numeroCarpeta = paciente.carpetaEfectores.find(x => String(x.organizacion._id) === organizacionId);
const numeroCarpeta = paciente.carpetaEfectores.find(x => x.organizacion && String(x.organizacion._id) === organizacionId);
const consultaValidada = (prestacion.estados[prestacion.estados.length - 1].tipo === 'validada');
const provincia = configPrivate.provincia || 'neuquen';
this.data = {
Expand Down Expand Up @@ -213,8 +212,33 @@ export class InformeRupHeader extends HTMLComponent {
}

ubicacionName() {
if (this.movimientos?.length > 0) {
// Ordenamos por fecha ascendente para mostrar Ingreso -> Movimientos -> Egreso
const sortedMovs = [...this.movimientos].sort((a, b) => new Date(a.fecha).getTime() - new Date(b.fecha).getTime());
return sortedMovs.map(mov => {
const fecha = moment(mov.fecha).format('DD/MM/YYYY HH:mm');
let label = '';
if (mov.extras?.ingreso) {
label = 'INGRESO: ';
} else if (mov.extras?.egreso) {
label = 'EGRESO: ';
} else {
label = 'MOVIMIENTO: ';
}
const bedName = mov.nombre || '';
const sector = mov.sectorName ? ` (${mov.sectorName})` : '';
return `${label}${bedName}${sector} - ${fecha}`;
}).join('<br>');
}

if (this.cama) {
return `${this.cama.nombre}, ${this.cama.sectorName}`;
const fecha = moment(this.prestacion.ejecucion.fecha).format('DD/MM/YYYY HH:mm');
let name = `${this.cama.nombre}, ${this.cama.sectorName}<br>${fecha}`;
if (this.cama.unidadOrganizativa) {
const unit = typeof this.cama.unidadOrganizativa === 'object' ? (this.cama.unidadOrganizativa.term || this.cama.unidadOrganizativa.nombre) : this.cama.unidadOrganizativa;
name += `<br>(${unit})`;
}
return name;
}
return null;
}
Expand Down
Loading
Loading