Ficha: mostrar el VPH como estudio aparte
This commit is contained in:
@@ -27,7 +27,7 @@ import { HttpClient } from '@angular/common/http';
|
||||
import type { Parameters as FhirParameters } from 'fhir/r4';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
import { ApiConfiguration } from '../api/api-configuration';
|
||||
import { ANTECEDENTS, Fact, group, split } from './record-groups';
|
||||
import { ANTECEDENTS, Fact, group, hpvApart, split } from './record-groups';
|
||||
import { eligibilityFailure, eligibilityView, type EligibilityState } from './eligibility';
|
||||
import { ineligibility } from './ineligibility';
|
||||
import { parseSeries, RiskSeries, Series } from './risk-series';
|
||||
@@ -277,14 +277,15 @@ export class Paciente {
|
||||
protected readonly tests = computed(() => {
|
||||
const d = this.data.value();
|
||||
if (!d) return [];
|
||||
return d.reports.map((r) => {
|
||||
return d.reports.flatMap((r) => {
|
||||
const results = (r.result ?? [])
|
||||
.map((x) => d.observations.get(x.reference?.split('/')[1]))
|
||||
.filter((o) => !!o) as Observation[];
|
||||
// the study's own results; the form's antecedents are in their own section and the extra
|
||||
// findings are collapsed (record-groups)
|
||||
const found = group(facts(results));
|
||||
return {
|
||||
const { hpv, rest } = hpvApart(facts(results));
|
||||
const found = group(rest);
|
||||
const row = {
|
||||
date: r.effectiveDateTime ?? '',
|
||||
reported: ext(r, 'report-date')?.valueDate,
|
||||
kind: label(r.code),
|
||||
@@ -292,6 +293,10 @@ export class Paciente {
|
||||
results: found.results,
|
||||
findings: found.findings,
|
||||
};
|
||||
// an HPV result is a study of its own: its own row, only when there is one
|
||||
return hpv.length
|
||||
? [row, { ...row, kind: 'Prueba de VPH', results: group(hpv).results, findings: [] }]
|
||||
: [row];
|
||||
});
|
||||
});
|
||||
/** CaCu: what each cytology's form declares (her antecedents and the exploration), the one she was
|
||||
|
||||
@@ -46,3 +46,11 @@ export function group(facts: Fact[]) {
|
||||
}
|
||||
return { antecedents, results, findings };
|
||||
}
|
||||
|
||||
const HPV_FIELDS = ['hpv', 'hpv_16', 'hpv_18'];
|
||||
|
||||
/** The cytology report's HPV results, apart from the cytology's own facts. */
|
||||
export function hpvApart(facts: Fact[]) {
|
||||
const isHpv = (f: Fact) => f.study === 'cervical_cytology' && HPV_FIELDS.includes(f.field);
|
||||
return { hpv: facts.filter(isHpv), rest: facts.filter((f) => !isHpv(f)) };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user