Merge origin/dashboard-test: CaMa wired to the published catalog, with the mock's views kept

dashboard-test is the base for every CaMa feature both branches built; this
branch's TEA and CaCu work (from the TEA mock) and its later CaMa views are
kept on top of it.

How:
- From dashboard-test: the opportunity strip with pending cards
  (camaKpiCards, CAMA_OPORTUNIDAD_KPIS), the histopathology view drawn from
  the published BI-RADS matrix, the pending histopathology card, the
  follow-up table component (app-seguimiento-tabla), the paired BI-RADS
  counts, the deferred domain selector in the header, the compact filter row
  for CaMa, the quiet «Disponible» state and the stricter KPI rules (no rate
  without a denominator, no median without observations).
- Kept from this branch: the single-period filters and the indicator
  selector of every domain (instead of the side navigation and «Modalidad»),
  TEA's Histórico grouping and summary paragraph, CaCu's views, the
  catalog-driven scenario and confirmation pickers, the Análisis tab, no
  pins or figure count below five indicators, and no representation
  selector on the cards.
- Histórico: this branch's component, which serves TEA and CaMa, with
  dashboard-test's fixed CaMa panel list (HISTORICO_CAMA) and pending
  panels; figures merged (dashboard-test's stricter series rules plus the
  shared scales, EEG colours and in-process chart of TEA).
- Specs: this branch's for shared components; dashboard-test's for its CaMa
  components. Expectations that contradicted the kept design (TEA without
  Histórico, «Modalidad», side navigation, four entries in
  KPI_BY_DOMAIN.cama) now state the merged behaviour.

Implications:
- CaMa search and pins never show; its cards are what the summary draws.
- The four CaMa opportunity cards are pending until the catalog publishes
  their indicator; the mock publishes all four.
- The histopathology view still has its label buttons and inner labels;
  this branch's expandable donut for CaMa is no longer used.
This commit is contained in:
rockdrigo
2026-11-12 13:35:39 -06:00
98 changed files with 5383 additions and 1106 deletions
@@ -18,7 +18,8 @@ import { IndicadoresService } from './indicadores.service';
import { applyGlobal, domainTypes, GlobalFilterState, IndicadoresMemory, pending, validDraft } from './indicadores-memory';
import { IndicadorPeriodFilters } from './indicador-period-filters';
import { IndicadorCatalogCard } from './indicador-catalog-card';
import { CACU_RESULTADO_KPI, KPI_BY_DOMAIN, KPI_RESUMEN_TEA } from './indicadores-kpi';
import { CACU_RESULTADO_KPI, CAMA_FUERA_DEL_RESUMEN, ID_HISTOPATOLOGIA_CAMA, KPI_BY_DOMAIN, KPI_RESUMEN_TEA, KpiCardSlot, camaKpiCards } from './indicadores-kpi';
import { IndicadorHistopatologiaPendiente } from './indicador-histopatologia-pendiente';
import { TeaResumenPeriodo } from './tea-resumen-periodo';
import { IndicadorKpiPanel } from './indicador-kpi-panel';
import { IndicadorKpiCard } from './indicador-kpi-card';
@@ -48,7 +49,7 @@ const ANALISIS_SECTIONS: readonly { id: DashboardSection; label: string }[] = [.
@Component({
selector: 'app-indicadores-page',
imports: [FormsModule, MatButtonModule, MatCardModule, MatFormFieldModule, MatInputModule, MatIconModule, MatSelectModule, MatProgressBarModule, IndicadorCatalogCard, IndicadorKpiPanel, IndicadorKpiCard, IndicadorPeriodFilters, IndicadoresDefinitions, IndicadoresTracking, IndicadoresHistorico, IndicadoresAnalisis, TeaResumenPeriodo],
imports: [FormsModule, MatButtonModule, MatCardModule, MatFormFieldModule, MatInputModule, MatIconModule, MatSelectModule, MatProgressBarModule, IndicadorCatalogCard, IndicadorKpiPanel, IndicadorKpiCard, IndicadorHistopatologiaPendiente, IndicadorPeriodFilters, IndicadoresDefinitions, IndicadoresTracking, IndicadoresHistorico, IndicadoresAnalisis, TeaResumenPeriodo],
templateUrl: './indicadores-page.html',
styleUrl: './indicadores-page.scss',
})
@@ -310,20 +311,35 @@ export class IndicadoresPage {
return [...definitions.slice(0, diagnosis < 0 ? definitions.length : diagnosis), CACU_RESULTADO_KPI,
...definitions.slice(diagnosis < 0 ? definitions.length : diagnosis)];
}
// What the KPI grid draws. CaMa adds explicit pending cards for opportunity indicators the catalog does not publish.
get kpiCards(): KpiCardSlot[] {
if (this.dominio === 'cama') return camaKpiCards(id => this.catalog().some(item => item.id === id));
return this.opportunityKpis.map(definition => ({ definition, pending: false }));
}
// CaMa's histopathology card keeps its place, as pending, while the catalog does not publish its indicator.
get histopatologiaPendiente() {
return this.dominio === 'cama' && !this.catalogLoading() && !this.catalogError() && this.catalog().length > 0
&& !this.catalog().some(item => item.id === ID_HISTOPATOLOGIA_CAMA);
}
private readonly catalogRequests = new Subject<void>();
readonly catalog = signal<Indicador[]>([]);
// Ids of the indicators to render; null shows the whole catalog.
readonly indicatorSelection = signal<string[] | null>(null);
// With a few indicators every card is in view; the selector only pays off from MIN_BUSQUEDA on.
readonly searchVisible = computed(() => this.catalogOrder().length >= MIN_BUSQUEDA);
// With a few indicators every card is in view; the selector only pays off from MIN_BUSQUEDA on. CaMa follows its
// mockup: no search and no pins. The catalog is read first: `dominio` is not a signal, so a short-circuit before
// the read would leave this computed without dependencies, and it would never change after a visit to CaMa.
readonly searchVisible = computed(() => { const total = this.catalogOrder().length; return this.dominio !== 'cama' && total >= MIN_BUSQUEDA; });
// Stable presentation priority; pins still take precedence in the grid.
readonly catalogOrder = computed(() => {
const catalog = this.catalog();
// The interactive views go first.
// A paired partner is drawn on its pair's card, not on one of its own.
const ids = catalog.map(item => item.id);
const resumen = catalog.filter(item => (!item.vistas || item.vistas.includes('resumen')) && !esSocioConteos(this.dominio, item.id, ids));
const primero = (item: Indicador) => !!vistaEscenario(this.dominio, item);
// CaMa's summary leaves out the indicators drawn as KPI cards or only in Histórico.
const fuera = (item: Indicador) => this.dominio === 'cama' && CAMA_FUERA_DEL_RESUMEN.includes(item.id);
const resumen = catalog.filter(item => (!item.vistas || item.vistas.includes('resumen')) && !esSocioConteos(this.dominio, item.id, ids) && !fuera(item));
// CaMa's histopathology card keeps its place, first, whether pending or published.
const primero = (item: Indicador) => !!vistaEscenario(this.dominio, item) || item.id === ID_HISTOPATOLOGIA_CAMA;
return [...resumen.filter(primero), ...resumen.filter(item => !primero(item))];
});
readonly selectedIndicators = computed(() => this.indicatorSelection() ?? this.catalog().map(item => item.id));