The indicator sheet reads the Measure's ficha, figure texts, references and population descriptions
This commit is contained in:
@@ -9,13 +9,14 @@ import { HttpTestingController, provideHttpClientTesting } from '@angular/common
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
import { Bundle, resources } from './fhir';
|
||||
import {
|
||||
cajaDeDatos, datosDeReportes, FhirIndicadoresPeriodos, FhirIndicadoresService, indicadorDeMeasure, Measure, periodoIniciado,
|
||||
cajaDeDatos, datosDeReportes, FhirIndicadoresPeriodos, FhirIndicadoresService, indicadorDeMeasure, Measure, metadatosDeMeasure,
|
||||
periodoIniciado,
|
||||
periodosDesde, Report,
|
||||
} from './indicadores-fhir';
|
||||
import * as fx from './indicadores-fhir.fixtures';
|
||||
import { c1AlterationFigure } from './indicadores-c1-alteraciones';
|
||||
import { c2Figure } from './indicadores-c2-adapter';
|
||||
import { datosValidos } from './indicadores.service';
|
||||
import { datosValidos, metadatosValidos } from './indicadores.service';
|
||||
import { FhirTeaSeguimientoService, mapaDeElectrodos } from './tea-seguimiento-fhir';
|
||||
import { IndicadorDatos } from './indicadores.models';
|
||||
|
||||
@@ -33,6 +34,30 @@ describe('Indicadores sobre FHIR', () => {
|
||||
expect(catalog.find(i => i.id === 'M25_dias_mchat_diagnostico')).toMatchObject({ contrato: 'C3r', sentido: 'menor_mejor' });
|
||||
});
|
||||
|
||||
it('la ficha técnica sale de las extensiones y citas de la Measure, y sin ellas de su código y descripción', () => {
|
||||
// Pins down: `ficha`, `figura-detalle`, `relatedArtifact` and the populations' descriptions become the sheet,
|
||||
// references, figure texts and populations the page reads; a Measure without them keeps its code, unit and
|
||||
// description as the sheet. Fails if `metadatosDeMeasure` stops reading one of them or drops the fallback.
|
||||
const url = 'https://isssteleon.org/fhir/StructureDefinition/';
|
||||
const written: Measure = {
|
||||
resourceType: 'Measure', id: 'CACU-EU7', version: '0.3.3', description: 'Descripción',
|
||||
extension: [
|
||||
{ url: url + 'ficha', extension: [{ url: 'para', valueString: 'Médico' }, { url: 'pregunta', valueString: '¿Cómo?' }, { url: 'codigo', valueString: 'EU7' }] },
|
||||
{ url: url + 'figura-detalle', extension: [{ url: 'figura', valueString: 'fig_c2_donas' }, { url: 'descripcion', valueString: 'Dona' }, { url: 'como-leer', valueString: 'Uno' }, { url: 'como-leer', valueString: 'Dos' }] },
|
||||
],
|
||||
relatedArtifact: [{ type: 'citation', display: 'Guía europea', citation: 'indicador 7' }],
|
||||
group: [{ population: [{ code: { coding: [{ code: 'initial-population' }] }, description: 'Pacientes del periodo', criteria: { expression: 'cacu_eu7' } }] }],
|
||||
};
|
||||
const sheet = metadatosValidos(metadatosDeMeasure(written));
|
||||
expect(sheet.ficha).toEqual({ codigo: 'EU7', unidad: null, definicion: 'Descripción', para: 'Médico', pregunta: '¿Cómo?' });
|
||||
expect(sheet.referencias).toEqual([{ tipo: 'citation', etiqueta: 'Guía europea', ref: 'indicador 7' }]);
|
||||
expect(sheet.figuras_detalle).toEqual([{ figura: 'fig_c2_donas', descripcion: 'Dona', como_leer: ['Uno', 'Dos'] }]);
|
||||
expect(sheet.poblaciones).toEqual([{ grupo: 'poblacion', codigo: 'cacu_eu7', descripcion: 'Pacientes del periodo' }]);
|
||||
const bare = metadatosValidos(metadatosDeMeasure(measure('M21-diagnosticados-con-eeg')));
|
||||
expect(bare.ficha?.codigo).toBe('M21');
|
||||
expect(bare.referencias).toEqual([]);
|
||||
expect(bare.figuras_detalle).toEqual([]);
|
||||
});
|
||||
it('los grupos de M30 llegan como filas por alteración y dibujan sus barras', () => {
|
||||
// Pins down: a report's extra groups become one row each under the group's code, labelled by the Measure, and
|
||||
// that is what `fig_c1_barras_alteracion` draws. The report is written here in the WebApi's shape (the fixtures
|
||||
|
||||
@@ -23,6 +23,7 @@ interface Group { code?: Concept; population?: Population[]; measureScore?: Scor
|
||||
export interface Measure extends Resource {
|
||||
url?: string; version?: string; name?: string; title?: string; description?: string;
|
||||
scoring?: Concept; subjectCodeableConcept?: Concept; improvementNotation?: Concept; group?: Group[];
|
||||
relatedArtifact?: { type?: string; display?: string; citation?: string }[];
|
||||
}
|
||||
export interface Report extends Resource {
|
||||
measure?: string; date?: string; period?: { start: string; end: string }; group?: Group[];
|
||||
@@ -84,21 +85,36 @@ export function indicadorDeMeasure(measure: Measure): Indicador & Record<string,
|
||||
};
|
||||
}
|
||||
|
||||
const FICHA_FIELDS = ['codigo', 'para', 'unidad', 'pregunta', 'definicion', 'nota'] as const;
|
||||
|
||||
// The technical sheet: the measure's `ficha` extension when it has one, and without it its code, unit and description.
|
||||
export function metadatosDeMeasure(measure: Measure): IndicadorMetadatos {
|
||||
const unidad = code(measure.subjectCodeableConcept) ?? null;
|
||||
const sheet = extensions(measure, 'ficha')[0];
|
||||
const written = Object.fromEntries(FICHA_FIELDS.flatMap(f => {
|
||||
const value = extension(sheet, f)?.valueString;
|
||||
return value ? [[f, value]] : [];
|
||||
}));
|
||||
return {
|
||||
id: indicadorId(measure.id ?? ''),
|
||||
version: measure.version,
|
||||
descripcion: measure.description ?? null,
|
||||
ficha: { codigo: (measure.id ?? '').split('-')[0], unidad, definicion: measure.description ?? null },
|
||||
ficha: { codigo: (measure.id ?? '').split('-')[0], unidad, definicion: measure.description ?? null, ...written },
|
||||
unidad,
|
||||
referencias: [],
|
||||
referencias: (measure.relatedArtifact ?? []).filter(a => !!a.display)
|
||||
.map(a => ({ tipo: a.type ?? 'citation', etiqueta: a.display!, ref: a.citation ?? null })),
|
||||
poblaciones: (measure.group?.[0]?.population ?? []).map(p => ({
|
||||
grupo: POPULATION_GROUP[code(p.code) ?? ''] ?? code(p.code) ?? '',
|
||||
codigo: p.criteria?.expression ?? code(p.code) ?? '',
|
||||
descripcion: p.description ?? '',
|
||||
})),
|
||||
figuras_detalle: [],
|
||||
figuras_detalle: extensions(measure, 'figura-detalle').flatMap(e => {
|
||||
const figura = extension(e, 'figura')?.valueString;
|
||||
return figura ? [{
|
||||
figura, descripcion: extension(e, 'descripcion')?.valueString ?? null,
|
||||
como_leer: extensions(e, 'como-leer').map(l => l.valueString).filter((l): l is string => !!l),
|
||||
}] : [];
|
||||
}),
|
||||
categorias: categorias(measure),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user