Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staging/sms whatsapp #565

Open
wants to merge 76 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
7924afc
Whatsapp SISREG
andremartins31 Oct 18, 2023
fd9e2c1
Adicionado flow da Vitacare
andremartins31 Oct 24, 2023
b7814d3
Correção do pipeline do sisreg
andremartins31 Oct 25, 2023
3fab11b
pipeline patients vitacare
andremartins31 Nov 10, 2023
b098dda
Arquivos de configuração
andremartins31 Nov 17, 2023
eef47f7
Merge remote-tracking branch 'origin/master' into staging/sms-whatsapp
andremartins31 Nov 17, 2023
3bab155
Atualiza metodos pacientes agendados clinica familia
andremartins31 Nov 17, 2023
915ed59
Cria task cloud_function_request
andremartins31 Nov 17, 2023
a2708cc
Update poetry.lock
andremartins31 Nov 17, 2023
e3cc288
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 17, 2023
9d4fc82
Fix import upload_to_datalake
andremartins31 Nov 17, 2023
e0b1c5b
Merge branch 'staging/sms-whatsapp' of https://github.com/prefeitura-…
andremartins31 Nov 17, 2023
b2afe6e
Fix import tasks
andremartins31 Nov 17, 2023
bcb7f58
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 17, 2023
9f13d6b
Fix import sisreg and unidades
andremartins31 Nov 17, 2023
3d44879
Merge branch 'staging/sms-whatsapp' of https://github.com/prefeitura-…
andremartins31 Nov 17, 2023
febd8bc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 17, 2023
3edd9ec
Fix import create_partitions
andremartins31 Nov 17, 2023
90e2d26
Merge branch 'staging/sms-whatsapp' of https://github.com/prefeitura-…
andremartins31 Nov 17, 2023
a26ece5
Fix name pipeline and fix import tasks
andremartins31 Nov 17, 2023
cfd8aea
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 17, 2023
a537b37
Fix call task cloud_function_request
andremartins31 Nov 17, 2023
0301e5f
Merge branch 'staging/sms-whatsapp' of https://github.com/prefeitura-…
andremartins31 Nov 17, 2023
1dfee95
Fix call create_partitions
andremartins31 Nov 17, 2023
ac53c56
Change parameters request cloud function
andremartins31 Nov 18, 2023
991bfa6
Convert response into DataFrame
andremartins31 Nov 18, 2023
57d9e11
Create path to save file
andremartins31 Nov 19, 2023
d6b7552
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 19, 2023
118ba1e
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Nov 19, 2023
1a5925a
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Nov 19, 2023
dab3d5a
Create new pipeline vitacare attended patients
andremartins31 Nov 22, 2023
7a7f44e
Merge branch 'staging/sms-whatsapp' of https://github.com/prefeitura-…
andremartins31 Nov 22, 2023
6a67e8b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 22, 2023
7235662
dump db sivep
andremartins31 Nov 22, 2023
a281b66
Merge branch 'staging/sms-whatsapp' of https://github.com/prefeitura-…
andremartins31 Nov 22, 2023
e226aa6
Get credencial from vault
andremartins31 Nov 24, 2023
f321520
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 24, 2023
5e6d4be
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Nov 24, 2023
822940c
Update tasks.py
andremartins31 Dec 28, 2023
8d361f3
Update tasks.py
andremartins31 Dec 29, 2023
90bc699
Merge remote-tracking branch 'origin/master' into staging/sms-whatsapp
andremartins31 Dec 29, 2023
9fd2b60
Merge com master
andremartins31 Dec 29, 2023
8b40759
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 29, 2023
5da9fd0
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Jan 2, 2024
e83c0bb
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Jan 8, 2024
8a4b818
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Jan 14, 2024
2e03e56
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Jan 15, 2024
1f606ba
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Jan 15, 2024
c577f0a
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Jan 16, 2024
6887330
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Jan 16, 2024
ee75955
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Jan 18, 2024
d8b4bd0
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Jan 19, 2024
d4e43ac
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Jan 22, 2024
ba3e73b
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Jan 23, 2024
c8c13c0
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Jan 24, 2024
b5f0543
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Jan 25, 2024
5c2e535
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Jan 25, 2024
17eff7f
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Jan 26, 2024
491da63
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Feb 5, 2024
c38df17
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Feb 6, 2024
1887e10
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Feb 6, 2024
4c1ab12
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Feb 7, 2024
1c2b1c4
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Feb 7, 2024
60247a2
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Feb 7, 2024
d24ad35
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Feb 8, 2024
964b450
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Feb 8, 2024
9458d05
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Feb 26, 2024
66df75a
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Feb 26, 2024
41a923b
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Feb 28, 2024
f6b063f
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Feb 28, 2024
04eafae
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Mar 1, 2024
96e5300
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Mar 1, 2024
1a2b94a
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Mar 4, 2024
06f0472
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Mar 4, 2024
7abfcc5
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Mar 15, 2024
7d80639
Merge branch 'master' into staging/sms-whatsapp
mergify[bot] Mar 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pipelines/rj_sms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
from pipelines.rj_sms.dump_api_prontuario_vitai.flows import *
from pipelines.rj_sms.dump_api_prontuario_vitacare.flows import *
from pipelines.rj_sms.dump_sheets.flows import *
from pipelines.rj_sms.dump_api_regulacao_sisreg.flows import *
241 changes: 241 additions & 0 deletions pipelines/rj_sms/dump_api_prontuario_vitacare/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,244 @@ class constants(Enum):
"posicao": "/reports/pharmacy/stocks",
"movimento": "/reports/pharmacy/movements",
}
URL_PACIENTES_AGENDADOS = (
"http://saudedigital.pepvitacare.com:8081/health/schedule/nextappointments"
)
URL_PACIENTES_ATENDIDOS = (
"http://saudedigital.pepvitacare.com:8081/health/schedule/lastattendances"
)
CNES = [
"9057722",
"5476607",
"7892802",
"0199338",
"5620287",
"7896204",
"3567567",
"5179726",
"9128867",
"9101764",
"3567540",
"6869009",
"6713564",
"6808077",
"3416321",
"7036914",
"3820599",
"9071385",
"6804209",
"6023320",
"7892810",
"6820018",
"6914152",
"9111344",
"6496989",
"7052049",
"7119798",
"0193089",
"9078983",
"6677711",
"7108265",
"5154197",
"6660185",
"9131884",
"9345515",
"6023975",
"9715444",
"6762042",
"6671020",
"7985657",
"6742130",
"5044685",
"0189200",
"6793231",
"9131795",
"2280310",
"6028233",
"9057706",
"7723296",
"7722494",
"6664075",
"2277298",
"6023916",
"7996675",
"6648371",
"6664040",
"6618863",
"7892829",
"6681379",
"6559727",
"7894554",
"7998678",
"6688152",
"6618871",
"9442251",
"2295237",
"6932916",
"6581994",
"6635709",
"7873565",
"9127100",
"6571956",
"6852203",
"9075143",
"7908237",
"6559735",
"6572014",
"0214949",
"7986505",
"6974708",
"7995520",
"7088574",
"6029965",
"6761704",
"6503772",
"5546591",
"9307265",
"6568491",
"6864708",
"6716598",
"9061401",
"9061398",
"9079939",
"9080163",
"9072640",
"7523246",
"9016805",
"6901042",
"9067078",
"9045023",
"6387152",
"6927289",
"6855709",
"6927319",
"0265233",
"7021771",
"3785025",
"6506232",
"6524486",
"9023089",
"6029841",
"9311661",
"3416372",
"6683851",
"7810172",
"6272053",
"4030990",
"6618855",
"6919626",
"6873960",
"7036884",
"5417708",
"3567559",
"3785009",
"9107835",
"6514022",
"2295253",
"9072659",
"7874162",
"3784975",
"2270323",
"6026737",
"6029922",
"2269937",
"2269848",
"5879655",
"2273551",
"2270277",
"2296551",
"6033121",
"4178602",
"2273225",
"2270463",
"2273179",
"3416356",
"6029825",
"2269309",
"2778696",
"2280744",
"2269732",
"5358612",
"5546583",
"2269929",
"2270013",
"2708167",
"2273578",
"6632831",
"2269295",
"2273616",
"2708183",
"2269651",
"2270072",
"2270579",
"2269562",
"2269546",
"2269538",
"2269503",
"2273586",
"2708426",
"2270250",
"5315026",
"2269759",
"2273543",
"2269511",
"4046307",
"2708213",
"2269376",
"7414226",
"2270439",
"5457009",
"6784720",
"2280795",
"3784959",
"2296543",
"2269902",
"2291274",
"9391983",
"2273640",
"2270315",
"2270366",
"6922031",
"2708434",
"2288346",
"2280760",
"2280272",
"2295032",
"2708205",
"2270633",
"2270560",
"2269805",
"2270307",
"2296535",
"2296586",
"2280779",
"7856954",
"6927254",
"2280280",
"2280787",
"5465877",
"2277328",
"2270455",
"5467136",
"2270641",
"2288370",
"5315050",
"3567508",
"2270293",
"2280736",
"7990286",
"2280205",
"6926797",
"2269953",
"5465885",
"6664164",
"2806320",
"2270552",
"2269627",
"5598435",
"3796310",
"5670357",
"5476844",
"2270420",
"2270285",
]
61 changes: 61 additions & 0 deletions pipelines/rj_sms/dump_api_prontuario_vitacare/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,21 @@
create_partitions,
upload_to_datalake,
)

from pipelines.rj_sms.dump_api_prontuario_vitacare.tasks import (
rename_flow,
build_url,
build_params,
create_filename,
save_data_to_file,
get_patients,
save_patients,
)

from pipelines.rj_sms.dump_api_prontuario_vitacare.schedules import (
vitacare_daily_update_schedule,
vitacare_every_day_at_six_am,
vitacare_every_day_at_seven_am,
)


Expand Down Expand Up @@ -136,3 +141,59 @@
)

dump_vitacare.schedule = vitacare_daily_update_schedule

with Flow(
"SMS: Dump VitaCare - Captura dos pacientes agendados"
) as dump_vitacare_scheduled_patients:
# Tasks
result = get_patients(context="scheduled")
save = save_patients(result, context="scheduled")
save.set_upstream(result)
upload_to_datalake_task = upload_to_datalake(
input_path=f"pipelines/rj_sms/dump_api_prontuario_vitacare/data_partition",
dataset_id="brutos_prontuario_vitacare",
table_id="pacientes_agendados_3_dias",
if_exists="replace",
csv_delimiter=";",
if_storage_data_exists="replace",
biglake_table=True,
)
upload_to_datalake_task.set_upstream(save)

dump_vitacare_scheduled_patients.storage = GCS(constants.GCS_FLOWS_BUCKET.value)
dump_vitacare_scheduled_patients.run_config = KubernetesRun(
image=constants.DOCKER_IMAGE.value,
labels=[
constants.RJ_SMS_DEV_AGENT_LABEL.value,
],
)

dump_vitacare_scheduled_patients.schedule = vitacare_every_day_at_six_am

with Flow(
"SMS: Dump VitaCare - Captura dos pacientes atendidos"
) as dump_vitacare_attended_patients:
# Tasks
result = get_patients(context="attended")
save = save_patients(result, context="attended")
save.set_upstream(result)
upload_to_datalake_task = upload_to_datalake(
input_path=f"pipelines/rj_sms/dump_api_prontuario_vitacare/data_partition",
dataset_id="brutos_prontuario_vitacare",
table_id="paciente_atendido_dia_anterior",
if_exists="replace",
csv_delimiter=";",
if_storage_data_exists="replace",
biglake_table=True,
)
upload_to_datalake_task.set_upstream(save)

dump_vitacare_attended_patients.storage = GCS(constants.GCS_FLOWS_BUCKET.value)
dump_vitacare_attended_patients.run_config = KubernetesRun(
image=constants.DOCKER_IMAGE.value,
labels=[
constants.RJ_SMS_DEV_AGENT_LABEL.value,
],
)

dump_vitacare_attended_patients.schedule = vitacare_every_day_at_seven_am
5 changes: 5 additions & 0 deletions pipelines/rj_sms/dump_api_prontuario_vitacare/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
from flows import dump_vitacare_attended_patients
from pipelines.utils.utils import run_local

run_local(dump_vitacare_attended_patients)
27 changes: 26 additions & 1 deletion pipelines/rj_sms/dump_api_prontuario_vitacare/schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
"""

from datetime import timedelta, datetime

from prefect.schedules.clocks import IntervalClock
from prefect.schedules import Schedule
import pytz
import pendulum


from pipelines.constants import constants
Expand Down Expand Up @@ -56,3 +57,27 @@
)

vitacare_daily_update_schedule = Schedule(clocks=untuple(vitacare_clocks))

vitacare_every_day_at_six_am = Schedule(
clocks=[
IntervalClock(
interval=timedelta(days=1),
start_date=pendulum.datetime(2023, 1, 1, 6, 0, 0, tz="America/Sao_Paulo"),
labels=[
constants.RJ_SMS_DEV_AGENT_LABEL.value,
],
)
]
)

vitacare_every_day_at_seven_am = Schedule(
clocks=[
IntervalClock(
interval=timedelta(days=1),
start_date=pendulum.datetime(2023, 1, 1, 7, 0, 0, tz="America/Sao_Paulo"),
labels=[
constants.RJ_SMS_DEV_AGENT_LABEL.value,
],
)
]
)
Loading
Loading