Commit Graph

67 Commits

Author SHA1 Message Date
edgar 0a8e3577a1 feat(fhir): publish the Wilson interval of a proportion's score
A proportion's measureScore now carries its 95 % Wilson interval in the ic-bajo and ic-alto extensions,
as proportions, the way durations carry their quartiles. Nothing is published without a denominator.
2026-11-22 00:23:09 -06:00
edgar e44f0c84b3 Governance: run the notebooks kept in the code; plotly in the lock for the survival reports
GET /governance/notebook-templates?domain= lists the notebooks under models/<domain>/<scenario>/notebooks/ with the
scenarios each can run for (models.reports.templates: its folder's and any whose model.toml lists a module of it, so
CaCu's PIM subgroup report serves cin2_pim and its post-colposcopy and post-treatment scenarios). POST
/governance/experiments takes `template` (that id) instead of `file`: the notebook is read from the code, never from
the request, and runs like an upload (its page sandboxed, its hash on the run). A template for a scenario it doesn't
serve, an id outside the templates, or a file and a template together are refused.

uv.lock adds plotly 7.1.0: models' `survival-curves` extra now draws the CaCu subgroup reports (models:
cacu-survival/integration).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HmQxVJVNR5FYkPAregGEQ7
2026-11-22 00:23:04 -06:00
rockdrigo 4cc2ce83ac CaMa: scenario menus and risk-factor rows for the survival and recurrence analyses 2026-11-21 14:43:46 -06:00
rockdrigo d185aba364 Merge remote-tracking branch 'origin/dev' into dev-mvp 2026-11-21 13:53:57 -06:00
rockdrigo 2c4bfa5691 Recurrence figures for a patient; governance trains scenarios with external data; lifelines in the lock 2026-11-21 13:34:56 -06:00
rockdrigo a53179aa2e Live survival: the scenarios of a patient and the figure of one scenario 2026-11-21 13:14:06 -06:00
rockdrigo 3b192207fd Live survival: no options route 2026-11-21 13:03:19 -06:00
Angel Capetillo Zavala 26631bd564 Merge feature/tea-eeg-analysis into dev (TEA age norm and ADOS-2 relation) 2026-11-21 12:23:28 -06:00
rockdrigo 57947d4131 Live survival: score with the rehydrated production model 2026-11-21 12:15:22 -06:00
rockdrigo eeb4c1fbd5 CaMa survival: live options and selection routes over the production model 2026-11-21 12:07:21 -06:00
alberto 31ab347347 feat(tea): import the ADOS-2 association model and serve it as a RiskAssessment in the patient summary 2026-11-21 11:17:58 -06:00
alberto 46473bb106 feat(tea): each EEG metric's age-norm curve and the age at the EEG in the patient summary 2026-11-21 11:17:48 -06:00
rockdrigo 8b379db28b Governance trains TEA's EEG on a local reference folder when one is configured 2026-11-21 04:48:43 -06:00
rockdrigo dab78ad55e Merge remote-tracking branch 'origin/dev' into dev-mvp 2026-11-21 04:00:00 -06:00
rockdrigo 2d71fe1103 Lesion size extracted from pathology reports; development record route; scenario catalog and background training jobs in governance 2026-11-21 03:28:13 -06:00
rockdrigo 6b011df0fd Merge the CaMa survival cohort support 2026-11-21 02:07:54 -06:00
rockdrigo e2ecaa027c CaMa: individual risk and population curves served, and the cycle estimates with any scenario in production
webapi/fhir/risk.py builds a patient's RiskAssessment for CaCu and CaMa; GET /cama/modelo/curvas serves the production
version's survival curves; the cycle's estimator is generic by scenario; silver persona carries the date of death for CaMa;
the import schema accepts it; the CaMa risk batches can be confirmed and voided.
2026-11-21 02:07:34 -06:00
rockdrigo 9b617db9d0 CaMa: two clinical scenarios, post-treatment and under observation, with the follow-up list's scenario column and filter 2026-11-21 01:55:04 -06:00
Angel Capetillo Zavala c2b18d9969 feat(fhir): publish optional category groups and stratum captions of compositions 2026-11-21 01:29:31 -06:00
edgar 26f2b35338 Retire GET /cacu/pacientes/<id>/riesgo: the record reads the FHIR RiskAssessment
The WebApp patient record now reads GET /cacu/fhir/RiskAssessment?subject=Patient/<pac_id> (WebApp
feature/cohorts-dbt-canonical), so the custom route, its blueprint and its tests go; the risk batches and the
follow-up list point to the FHIR search.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HmQxVJVNR5FYkPAregGEQ7
2026-11-20 23:15:55 -06:00
edgar 0c1b383da2 CaCu's individual risk as a FHIR RiskAssessment, and each risk's index date
GET /cacu/fhir/RiskAssessment?subject=Patient/<pac_id> (DEV only, tagged simulado, a searchset validated with R4B, as
TEA's patient resources): the patient's current batch, one prediction per horizon with its outcome, probability and
whenPeriod from the risk's index date, the confidence interval in an extension; declared in the CapabilityStatement.
GET /cacu/pacientes/<id>/riesgo adds riesgo.fecha_indice. Tests and the risk-band fixture carry the index date.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HmQxVJVNR5FYkPAregGEQ7
2026-11-20 23:02:46 -06:00
edgar 7d06f9db9d The cycle builds the cohorts dbt defines; models' moved modules
The `cohorts` and `estimate` steps take the project's cohorts from dbt's manifest (`cohort_urls`) and build each one
with models' `build_of` over dbt's queries, instead of the Python-frame TOMLs in models/cohorts, which are gone; without
a manifest a project has no cohort steps. The recruitment window and cut-off are dbt's vars. The live estimator reads
cin2_logistic through `Scenario` and `KitBuild`, and governance imports `models.reports.experiment`, where models now
keeps it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HmQxVJVNR5FYkPAregGEQ7
2026-11-20 20:18:00 -06:00
rockdrigo 8130f86f3a Silver persona carries the date of death in CaCu and CaMa; tests for it and for CaMa's birth and death on the timeline 2026-11-20 18:46:40 -06:00
rockdrigo ca0f02aa0c A coded catalog result may name the code system of its values; the histological type comes out as its ICD-O-3 code 2026-11-20 17:03:38 -06:00
AlbertoPMDM d35e8bbae9 feat(tea): EEG analysis before the silver load, and its verdict, quality checks and baselines through silver and FHIR 2026-11-19 15:43:27 -06:00
Erick ivan 7101913fff revert(auth): remove the session login from the API
The API no longer authenticates: no /auth routes, no session cookie and no before_request lock. An external service that reads and writes data was hitting the 401, so the endpoint is open again.

The interface keeps its login and the per-account domains, now resolved in the browser. WEBAPI_USUARIO(S) and WEBAPI_SECRET_KEY are gone from the Dockerfile and .env.example.
2026-11-19 10:32:22 -06:00
Erick ivan 084fe2e8d3 feat(auth): session login with per-domain scope
Cookie session with /auth/login, /auth/logout and /auth/me. Four accounts come from WEBAPI_USUARIOS (admin plus one per domain) and a second before_request answers 403 when an account asks for another domain.

The data suites run with WEBAPI_AUTH_REQUIRED=0; test_auth.py turns the lock back on and covers both hooks. The Dockerfile normalises the entrypoint so a Windows checkout still starts the container.
2026-11-19 09:35:25 -06:00
Angel Capetillo Zavala b1bbbc25b4 Integrate CaMa follow-up, descriptive analysis and L3 with dev
Preserve dev risk batches and governance, individual patient selection, optional access and explicit cohort reader overrides. Register one CaMa implementation and retain legacy Python blueprint consumers. Validated with 681 WebApi tests on the integrated parent and submodules.
2026-11-17 10:44:07 -06:00
Roberto Treviño Cervantes 0571b5e6af wording fixes 2026-11-17 02:17:31 -06:00
Roberto Treviño Cervantes 9737b5a67f The follow-up list identifies each patient by the platform's pac_id, the key the risk route takes; TEA keeps its salted pseudonym 2026-11-15 05:40:08 -06:00
Roberto Treviño Cervantes 854a2e9c55 The recomputation worker estimates with the models in production and wakes on the marker directory; the scanned test form carries a birth date 2026-11-15 05:37:50 -06:00
Roberto Treviño Cervantes b8045e7481 dbt's manifest compiled at start-up for the deployment's engine; the image carries the dbt environments 2026-11-15 00:47:38 -06:00
Roberto Treviño Cervantes 6dce665d93 Merge remote-tracking branch 'origin/feature/163-tea-redesign' into feature/kit-exit-integration
# Conflicts:
#	Dockerfile
#	README.md
#	tests/staging/cama.py
#	tests/test_fhir_measures.py
#	tests/test_fhir_tea.py
#	tests/test_orquestacion_oro.py
#	tests/test_orquestacion_plata.py
#	uv.lock
#	webapi/__init__.py
#	webapi/fhir/__init__.py
#	webapi/fhir/measures.py
#	webapi/follow_up/routes.py
#	webapi/imports/schemas/tea/ordenes_estudio.py
#	webapi/metrics.py
#	webapi/orchestration/cycle.py
#	webapi/orchestration/reference/catalogs.py
#	webapi/orchestration/repositories.py
#	webapi/orchestration/silver/cama.py
#	webapi/orchestration/silver/orders_and_notes.py
2026-11-15 00:44:31 -06:00
rockdrigo 461d651805 TEA FHIR: an episode's _include brings its ADOS-2 observation 2026-11-13 17:03:23 -06:00
rockdrigo 73cbf0cfb8 The catalog step seeds each domain's mappings, and a mapping is written only if the function still holds
How: `catalog_rows` turns the TOML's study codes, captions and each value's code, label and aliases into the
`catalogo` system's rows; the `catalogs` step adds the system and the forms with no row yet
(`mapeos_nuevos`). `register` normalizes the form and adds the row through `SourceMappingRepository.add`
with `check_stored`, which runs `check_function` on the stored rows of the same form; captions aren't
checked, since one caption may introduce several results. `ctx.repos.silver.mappings` is the domain's
repository.

Implications: the database keeps every mapping across deploys; a person's change is never overwritten, and
a second code for a form in force is refused before it's written. Loads still read the TOML's aliases.
2026-11-13 15:31:21 -06:00
rockdrigo 64d3d721e3 Source forms as a partial, non-injective function into the catalog's codes, checked on the catalog
How: `reference.source_mapping` keys a mapping by source system, result, normalized form and validity;
`check_function` rejects a form that gives two codes while both mappings are in force, and `resolve` gives
the code in force on a date, or none when nothing or two disagreeing mappings match. The catalog's own
check of spellings (`_claves_de_extraccion`) now runs `check_function` on each result's codes, labels and
aliases.

Implications: the same rule serves the TOML today and any store of mappings with systems and dates; every
catalog passes it.
2026-11-13 15:29:52 -06:00
rockdrigo 113b792a7b The import's catalog matching and commit read the WebApi's catalog, silver batch and table maps; add_resultado moves here
How: `catalog_matching`, `catalog_commit_service` and the imports blueprint import `Catalogo`,
`catalogo_desde_toml`, `ruta_de_catalogo`, `CatalogoInvalido`, `LotePlata`, `valor_de_observacion` and
`tablas_de` from `webapi.orchestration`; the commit writes through `carga_repository.save_load` and
`catalog_repository.sync`. `add_resultado` and its tests come over unchanged from the indicator kit.

Implications: the import path no longer needs the indicator kit, which isn't a dependency.
2026-11-13 15:24:02 -06:00
rockdrigo f183e495fb A timeline stratum read by the event cut-off, and labels for a timeline stratum's values
How: `linea_de_tiempo_al_corte` is `linea_de_tiempo_al_inicio_del_periodo` with what the timeline held by the
question's event cut-off (all of it without one) instead of before the period's start. FHIR's `_label` reads a
timeline stratum's labels from its `valores` entries and `resto_etiqueta`. Tests cover CaMa's tumour stratifiers:
the facts dbt derives, the surrogate subtype's rules, CAMA_BIRADS_CANCER_INVASOR broken down by them, and the
cut-off.

Implications: a patient's characteristic learned after the fact that put her in the period (a cancer's stage or
subtype, written after its biopsy) can stratify a measure, and stays reproducible through the cut-offs. CaMa
publishes eight measures and five strata.
2026-11-13 15:14:46 -06:00
rockdrigo 9775a22c57 CaMa's silver load reads results from the reports' text, mapped by the catalog
How: `silver.extracted.DesdeTexto` turns the catalog's `etiquetas_fuente` and each value's `alias` into
Extraction's field specs and into derived columns of a `DeStaging`. CaMa reads density and lesion size from the
mammography interpretation, histology, grade, receptors, HER2 and Ki-67 from the pathology PDF's text layer (no
OCR at load time), and the clinical stage from the note's texts. `resultados_extraibles` reads and checks the new
keys: captions are a non-empty list, aliases need captions, and no spelling names two values.

Implications: a code comes with the spelling it matched as `valor_fuente`; an unknown spelling is kept as
`valor_fuente` with no code, counted as out of catalog, and becomes a code on the next load once its alias is in
the catalog. Nothing is renamed in the stored data and no table or column changes. The synthetic CaMa staging
gains a mammography text, a pathology PDF and a note with a stage.
2026-11-13 15:14:46 -06:00
alberto 7d5c79f520 TEA: an answer as of a knowledge cut-off reads each child's version known then, and the measures waiting for a validation stay hidden outside FHIR too 2026-11-13 15:14:46 -06:00
edgar e224b8b2aa TEA on its new staging: silver load, ten measures answered on request with the status at the period's end, several groups and column strata, and FHIR R4 endpoints for measures, follow-up and patient summary 2026-11-13 15:14:46 -06:00
edgar 4fc822d5c7 The kit's silver load, reference tables, table maps and follow-up list move into the WebApi; the kit is no longer a dependency 2026-11-13 15:14:29 -06:00
edgar 73b1db1121 English names: orchestration (cycle, context, runner, repositories), its steps, fields and CLI, recomputation, follow_up and reports 2026-11-13 15:13:52 -06:00
edgar ea228da7b4 CaCu's and CaMa's measures answered on request from dbt's semantic layer as FHIR MeasureReports, with the period and both cut-offs in the question; the route is /<domain>/indicadores 2026-11-13 15:13:27 -06:00
alberto e19121bc42 TEA: an order carries its study's report as a PDF through the import 2026-11-13 15:03:02 -06:00
Roberto Treviño Cervantes 8f84253205 updating nlp policies; more robust recognition beyond rules 2026-11-13 11:52:36 -06:00
Roberto Treviño Cervantes ce67de17bc fix governance reqs; allow for sandboxed jupyter notebooks for testing 2026-11-13 11:52:36 -06:00
Roberto Treviño Cervantes e41a2b7127 improve ingestion system to match isssteleon setup 2026-11-13 11:52:36 -06:00
alberto 0f9433949f TEA: an answer as of a knowledge cut-off reads each child's version known then, and the measures waiting for a validation stay hidden outside FHIR too 2026-11-12 19:47:19 -06:00
edgar a0407e41d6 TEA on its new staging: silver load, ten measures answered on request with the status at the period's end, several groups and column strata, and FHIR R4 endpoints for measures, follow-up and patient summary 2026-11-12 15:21:25 -06:00