Agrega distribución de VPH por genotipo en CaCu
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
-- Una fila por procedimiento de reporte VPH vinculado a su toma.
|
||||
with observaciones as (
|
||||
select o.procedimiento_id,
|
||||
max(case when resultado_id = 'vph.resultado' then coalesce(valor_id, valor_fuente) end) as resultado,
|
||||
max(case when resultado_id = 'vph.genotipo_16' then valor_numerico end) as g16,
|
||||
max(case when resultado_id = 'vph.genotipo_18' then valor_numerico end) as g18,
|
||||
max(k.inicio) as observaciones_conocidas_en
|
||||
from {{ source('silver', 'observacion_clinica') }} o
|
||||
join {{ source('silver', 'carga') }} k on k.carga_id = o.carga_id
|
||||
where resultado_id in ('vph.resultado', 'vph.genotipo_16', 'vph.genotipo_18')
|
||||
group by o.procedimiento_id
|
||||
)
|
||||
select r.procedimiento_id, t.pac_id, t.fecha as fecha_toma, r.fecha as fecha_reporte,
|
||||
kt.inicio as toma_conocida_en,
|
||||
case when o.observaciones_conocidas_en > kr.inicio then o.observaciones_conocidas_en
|
||||
else kr.inicio end as reporte_conocido_en,
|
||||
case
|
||||
when o.g16 not in (0, 1) or o.g18 not in (0, 1) then 'INCONSISTENTE'
|
||||
when o.resultado = 'NEGATIVO' and (o.g16 = 1 or o.g18 = 1) then 'INCONSISTENTE'
|
||||
when o.resultado = 'NEGATIVO' then 'NEGATIVO'
|
||||
when o.resultado = 'INDETERMINADO' and (o.g16 = 1 or o.g18 = 1) then 'INCONSISTENTE'
|
||||
when o.resultado = 'INDETERMINADO' then 'INDETERMINADO'
|
||||
when o.resultado = 'POSITIVO' and o.g16 = 1 and o.g18 = 1 then 'POSITIVO_16_18'
|
||||
when o.resultado = 'POSITIVO' and o.g16 = 1 and o.g18 = 0 then 'POSITIVO_16'
|
||||
when o.resultado = 'POSITIVO' and o.g16 = 0 and o.g18 = 1 then 'POSITIVO_18'
|
||||
when o.resultado = 'POSITIVO' and o.g16 = 0 and o.g18 = 0 then 'POSITIVO_SIN_16_18'
|
||||
when o.resultado = 'POSITIVO' then 'POSITIVO_INCOMPLETO'
|
||||
else 'INCONSISTENTE'
|
||||
end as categoria
|
||||
from {{ source('silver', 'procedimiento') }} r
|
||||
join {{ source('silver', 'procedimiento') }} t
|
||||
on r.padre_id = t.procedimiento_id and r.pac_id = t.pac_id
|
||||
join {{ source('silver', 'carga') }} kt on kt.carga_id = t.carga_id
|
||||
join {{ source('silver', 'carga') }} kr on kr.carga_id = r.carga_id
|
||||
left join observaciones o on o.procedimiento_id = r.procedimiento_id
|
||||
where r.estudio_id = 'vph' and r.clase = 'reporte'
|
||||
and t.estudio_id = 'citologia' and t.clase = 'toma'
|
||||
and t.fecha is not null and r.fecha is not null and r.fecha >= t.fecha
|
||||
@@ -0,0 +1,65 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: cacu_reportes_vph
|
||||
description: "Reportes VPH vinculados a una toma. Clasificación provisional."
|
||||
config:
|
||||
materialized: view
|
||||
semantic_models:
|
||||
- name: cacu_reportes_vph
|
||||
model: ref('cacu_reportes_vph')
|
||||
defaults:
|
||||
agg_time_dimension: fecha_toma
|
||||
entities:
|
||||
- {name: reporte_vph, type: primary, expr: procedimiento_id}
|
||||
dimensions:
|
||||
- name: fecha_toma
|
||||
type: time
|
||||
type_params: {time_granularity: day}
|
||||
- name: fecha_reporte
|
||||
type: time
|
||||
type_params: {time_granularity: day}
|
||||
- name: toma_conocida_en
|
||||
type: time
|
||||
type_params: {time_granularity: day}
|
||||
- name: reporte_conocido_en
|
||||
type: time
|
||||
type_params: {time_granularity: day}
|
||||
- {name: categoria, type: categorical}
|
||||
measures:
|
||||
- {name: reportes_vph, agg: count_distinct, expr: procedimiento_id}
|
||||
metrics:
|
||||
- name: cacu_vph_genotipo
|
||||
label: "Resultados de VPH por genotipo"
|
||||
description: "Distribución provisional por reporte VPH vinculado a toma, asignado al periodo de la toma."
|
||||
type: simple
|
||||
type_params: {measure: reportes_vph}
|
||||
config:
|
||||
meta:
|
||||
measure_url: cacu/CACU_VPH_GENOTIPO
|
||||
version: 0.1.0
|
||||
scoring: composition
|
||||
basis: examen
|
||||
grupo: TOTAL
|
||||
contrato: C2
|
||||
tipos_periodo: [semestre, mes]
|
||||
figuras: [fig_c2_donas]
|
||||
poblaciones_fhir: [measure-observation]
|
||||
conocida_en: [toma_conocida_en]
|
||||
categoria:
|
||||
valor: categoria
|
||||
sin_dato: INCONSISTENTE
|
||||
elige: ultimo_valido
|
||||
valido: "{% raw %}{{ Dimension('reporte_vph__categoria') }} is not null{% endraw %}"
|
||||
admite: "{% raw %}{{ Dimension('reporte_vph__categoria') }} is not null{% endraw %}"
|
||||
fechada_en: [fecha_reporte]
|
||||
conocida_en: [reporte_conocido_en]
|
||||
orden: [fecha_reporte]
|
||||
etiquetas:
|
||||
NEGATIVO: {etiqueta: "Negativo", color: "#9DBFE3"}
|
||||
POSITIVO_16: {etiqueta: "Positivo 16 exclusivamente", color: "#2F6DB3"}
|
||||
POSITIVO_18: {etiqueta: "Positivo 18 exclusivamente", color: "#E8C28E"}
|
||||
POSITIVO_16_18: {etiqueta: "Positivo 16 y 18", color: "#D98E4A"}
|
||||
POSITIVO_SIN_16_18: {etiqueta: "Positivo sin detección de 16/18", color: "#B55A1F"}
|
||||
POSITIVO_INCOMPLETO: {etiqueta: "Positivo con genotipificación incompleta", color: "#7A2E0E"}
|
||||
INDETERMINADO: {etiqueta: "Indeterminado", color: "#A0A0A0"}
|
||||
INCONSISTENTE: {etiqueta: "No clasificable o inconsistente", color: "#C9CDD2"}
|
||||
Reference in New Issue
Block a user