integrating latest dashboard changes
This commit is contained in:
+6
-2
@@ -1,6 +1,6 @@
|
||||
# Build context is the repo root (see docker-compose.yml) so the sibling
|
||||
# packages Core/, Persistance/, Extraction/, models/ and indicadores_kit/
|
||||
# can be copied.
|
||||
# packages Core/, Persistance/, Extraction/, models/, indicadores_kit/ and
|
||||
# Orquestacion/ can be copied.
|
||||
FROM python:3.12-slim
|
||||
|
||||
# Tesseract (with Spanish data) for scanned documents; pytesseract only wraps the binary.
|
||||
@@ -16,12 +16,16 @@ COPY Persistance/ Persistance/
|
||||
COPY Extraction/ Extraction/
|
||||
COPY models/ models/
|
||||
COPY indicadores_kit/ indicadores_kit/
|
||||
COPY Orquestacion/ Orquestacion/
|
||||
COPY WebApi/ WebApi/
|
||||
|
||||
# Migrations need the MySQL/PostgreSQL drivers when *_DATABASE_URL points there.
|
||||
RUN cd Persistance && uv sync --no-dev --extra drivers
|
||||
# Drivers for the SQL import sources (MySQL/MariaDB, PostgreSQL, SQL Server).
|
||||
RUN cd WebApi && uv sync --no-dev --extra sql-drivers
|
||||
# The indicator pipeline (staging -> facts -> reports), run with
|
||||
# `python -m orquestacion ciclo <proyecto> ...` after an import.
|
||||
RUN cd Orquestacion && uv sync --no-dev --extra drivers
|
||||
|
||||
ENV CACU_DATABASE_URL=sqlite:////data/cacu.db
|
||||
ENV CAMA_DATABASE_URL=sqlite:////data/cama.db
|
||||
|
||||
@@ -3,6 +3,13 @@ set -e
|
||||
|
||||
mkdir -p /data
|
||||
|
||||
# SQLite won't create a missing parent directory for its database file.
|
||||
for url in "$CACU_DATABASE_URL" "$CAMA_DATABASE_URL" "$TEA_DATABASE_URL" "$GOVERNANCE_DATABASE_URL"; do
|
||||
case "$url" in
|
||||
sqlite:///*) mkdir -p "$(dirname "${url#sqlite:///}")" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# --no-sync: the image's environments were synced at build time; syncing at
|
||||
# startup would try to reach the package index (and pull dev deps).
|
||||
cd /app/Persistance
|
||||
|
||||
@@ -159,11 +159,31 @@ def test_commit_on_conflict_reject_then_upsert(client):
|
||||
|
||||
|
||||
def test_commit_upsert_rejected_for_target_without_natural_key(client):
|
||||
source = _json_source([{"pac_id_hospital": "T-NOKEY-1"}], target="tea.Pacientes")
|
||||
source = _json_source(
|
||||
[{"psi_pac_id": 1}], target="tea.EvaluacionPsicologica", column_mapping={"psi_pac_id": "psi_pac_id"}
|
||||
)
|
||||
response = client.post("/imports/commit", json={"sources": [source], "on_conflict": "upsert"})
|
||||
assert response.status_code == 400
|
||||
|
||||
|
||||
def test_tea_patient_keeps_the_source_id_and_reimport_updates_it(client):
|
||||
mapping = {"pac_id": "pac_id", "pac_id_hospital": "pac_id_hospital", "pac_sexo": "pac_sexo"}
|
||||
first = _json_source([{"pac_id": 9001, "pac_id_hospital": "T-SRC-1", "pac_sexo": "F"}],
|
||||
target="tea.Pacientes", column_mapping=mapping)
|
||||
body = client.post("/imports/commit", json={"sources": [first], "on_conflict": "upsert"}).get_json()
|
||||
assert body["results"][0]["created"] == 1
|
||||
|
||||
again = _json_source([{"pac_id": 9001, "pac_id_hospital": "T-SRC-1", "pac_sexo": "M"}],
|
||||
target="tea.Pacientes", column_mapping=mapping)
|
||||
body = client.post("/imports/commit", json={"sources": [again], "on_conflict": "upsert"}).get_json()
|
||||
assert body["results"][0]["created"] == 0
|
||||
assert body["results"][0]["updated"] == 1
|
||||
|
||||
paciente = client.get("/tea/pacientes/9001").get_json()
|
||||
assert paciente["pac_id_hospital"] == "T-SRC-1"
|
||||
assert paciente["pac_sexo"] == "M"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sql_source_db(tmp_path):
|
||||
db_path = tmp_path / "external_source.db"
|
||||
|
||||
@@ -114,7 +114,8 @@ ENTITY_REGISTRY: dict[str, EntitySpec] = {
|
||||
schema=PacientesImportSchema,
|
||||
model=TeaPacientes,
|
||||
repository=tea_pacientes_repository,
|
||||
conflict_fields=None,
|
||||
# The source's own id; TEA's child tables reference it directly.
|
||||
conflict_fields=("pac_id",),
|
||||
),
|
||||
"cacu.OrdenesEstudio": EntitySpec(
|
||||
schema=CacuOrdenesEstudioImportSchema,
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
"""Import schema for `core.tea.models.Pacientes`. All fields optional, like TEA's
|
||||
Core; system-managed `pac_created_at`/`pac_updated_at`/`pac_fuente_sistema` are excluded."""
|
||||
Core; system-managed `pac_created_at`/`pac_updated_at`/`pac_fuente_sistema` are excluded.
|
||||
|
||||
`pac_id` is importable: every other TEA table references the patient by the
|
||||
source system's integer id, so it has to be kept, not renumbered."""
|
||||
from datetime import date
|
||||
from typing import Optional
|
||||
|
||||
@@ -14,6 +17,7 @@ _PARENTESCO_CATALOG = Catalog(Parentesco)
|
||||
|
||||
|
||||
class PacientesImportSchema(ImportSchema):
|
||||
pac_id: Optional[int] = None
|
||||
pac_id_hospital: Optional[str] = None
|
||||
pac_id_titular: Optional[str] = None
|
||||
pac_parentesco: CatalogValue(_PARENTESCO_CATALOG) = None
|
||||
|
||||
Reference in New Issue
Block a user