Skip to content

Commit

Permalink
Add stored procedure to ensure RTC date is set
Browse files Browse the repository at this point in the history
  • Loading branch information
ibacher committed Apr 5, 2024
1 parent d73e3f4 commit 74b1d18
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions SQL/stored_procedures/update_encounter_rtc_dates_v1_0.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- Theoretically, this procedure should not be necessary but, for whatever reason, the model
-- update doesn't always add the expected RTC date, so we add it here.
drop procedure if exists update_encounter_rtc_dates_v1_0;
create definer = analytics procedure predictions.update_encounter_rtc_dates_v1_0()
begin
update predictions.ml_weekly_predictions mp
left join etl.flat_hiv_summary_v15b fs_next
on mlp.encounter_id = fs.encounter_id
set mlp.rtc_date = fs.rtc_date
where mlp.rtc_date is null;
end
5 changes: 5 additions & 0 deletions docker-resources/dailyStoredProcedures.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ my_pool <- dbPool(
dbname = dbConfig$defaultDb
)

DBI::dbExecute(
my_pool,
"CALL predictions.update_encounter_rtc_dates_v1_0();"
)

DBI::dbExecute(
my_pool,
"CALL predictions.generate_flat_ml_baseline_visit_v1_0();"
Expand Down

0 comments on commit 74b1d18

Please sign in to comment.