Skip to content

Commit

Permalink
Merge pull request #167 from prefeitura-rio/datalake/remove-dimension…
Browse files Browse the repository at this point in the history
…-tables-from-smsrio

Datalake/remove dimension tables from smsrio
  • Loading branch information
TanookiVerde committed Jul 26, 2024
2 parents eb74622 + 2fc7b5d commit b0c1938
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 50 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# Prontuários Integrados
# Histórico Clínico Integrado (HCI)
- Responsável de Infraestrutura: Gabriel Milan (Escritório de Dados)
- Administrador: Pedro Marques (SMS)

## Resumo
- O sistema de Prontuários Integrados possui dois componentes:
## O que é o HCI
- O HCI tem como objetivo integrar os dados de saúde municipais de diferentes unidades de saúde, seja da atenção primária, hospitalar, etc.
- Existem diferentes tipos de prontuário sendo utilizados nas unidades, o que faz com que existem diferentes fonte, com formatos e dados diferentes.
- Precisamos ler dados destas fontes e integrá-los em um formato consistente, que atenda os profissionais da área de saúde.

### O Sistema
- O HCI possui dois componentes:
- API (desenvolvida em Fast API, Python 3.11)
- Banco de Dados (PostgreSQL)

Expand Down
22 changes: 1 addition & 21 deletions api/app/datalake/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
from typing import List
from app.datalake.utils import flatten, register_formatter
from app.datalake.models import (
SMSRioCnsProvisorio,
SMSRioPaciente,
SMSRioTelefone,
VitacarePaciente,
VitacarePacienteHistorico,
VitacareAtendimento,
Expand All @@ -28,26 +26,8 @@ def format_smsrio_patient(raw_record: dict) -> List:
raw_record['source_updated_at'] = str(raw_record['source_updated_at'])

flattened_patient = flatten(raw_record)
rows = [SMSRioPaciente(**flattened_patient)]

for field_name, FieldModel in [
('telefones', SMSRioTelefone),
('cns_provisorio', SMSRioCnsProvisorio)
]:
# If field not in record, skip
if field_name not in raw_record['data']:
continue

for value in raw_record['data'].pop(field_name) or []:
rows.append(
FieldModel(
value=value,
patient_cpf=raw_record.get("patient_cpf"),
source_updated_at=raw_record.get("source_updated_at")
)
)

return rows
return [SMSRioPaciente(**flattened_patient)]


@register_formatter(system="vitacare", entity="patientrecords")
Expand Down
26 changes: 0 additions & 26 deletions api/app/datalake/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,32 +54,6 @@ class Config:
dataset_is_public = False


class SMSRioTelefone(BaseModel):
patient_cpf: str
value: str
source_updated_at: str

class Config:
dataset_id = "brutos_plataforma_smsrio"
table_id = "paciente_telefone_eventos"
partition_by_date = False
biglake_table = True
dataset_is_public = False


class SMSRioCnsProvisorio(BaseModel):
patient_cpf: str
value: str
source_updated_at: str

class Config:
dataset_id = "brutos_plataforma_smsrio"
table_id = "paciente_cns_eventos"
partition_by_date = False
biglake_table = True
dataset_is_public = False


# ===============
# Vitacare
# ===============
Expand Down

0 comments on commit b0c1938

Please sign in to comment.