Closed ynodir closed 9 months ago
Notes:
Step 1 First, all of the columns in the table containing dates/times were analyzed to check what times they contain. I.e., if they contain only '00:00:00' times, this column is assumed to be a DATE column, if they contained different times, the it is assumed to be a DATETIME column. And according to our convention, we need to introduce additional _UTC columns for these DATETIME ones.
Below is an example of a query to check times of a single field in a given table:
select extract(time from filing_date_jittered) times, count(*) as cnt
from lpch.clinical_note_meta
group by times
order by cnt desc;
If the times were in STRING typed column, the query changed a bit:
select extract(time from case when noted_date <> '' then parse_datetime('%Y-%m-%d %H:%M:%S', noted_date) else null end) times, count(*) as cnt
from starr_datalake2020.shc_diagnosis
group by times
order by cnt desc;
Step 2
Once the types were determined a SELECT
query was executed with EXCEPT()
and time conversion functions to convert the table.
BigQuery allows storing the query results in a table. This functionality was used to store the SELECT
results in a table.
This is done by clicking More button under the query window (on the same line as Run button) and clicking Query Settings.
Here, choose Set a destination table for query results in Destination section and fill in project/dataset/table name to store the results. Also, select Allow large results (no size limit) in Results section.
Here's an example SELECT
query:
select * except(end_date, start_date, noted_date, hx_date_of_entry, resolved_date),
parse_datetime('%Y-%m-%d %H:%M:%S', case when end_date <> '' then end_date else null end) as end_date,
parse_datetime('%Y-%m-%d %H:%M:%S', case when start_date <> '' then start_date else null end) as start_date,
extract(date from parse_datetime('%Y-%m-%d %H:%M:%S', case when noted_date <> '' then noted_date else null end)) as noted_date,
extract(date from parse_datetime('%Y-%m-%d %H:%M:%S', case when hx_date_of_entry <> '' then hx_date_of_entry else null end)) as hx_date_of_entry,
extract(date from parse_datetime('%Y-%m-%d %H:%M:%S', case when resolved_date <> '' then resolved_date else null end)) as resolved_date,
timestamp(case when end_date <> '' then end_date else null end, "America/Los_Angeles") as end_date_utc,
timestamp(case when start_date <> '' then start_date else null end, "America/Los_Angeles") as start_date_utc,
from starr_datalake2020.shc_diagnosis;
Step 3 After the conversion, we need to check whether it went as expected. This is done by joining both tables (original and a copy) and comparing converted columns. Here's an example join:
select o.anon_id, o.line, o.pat_enc_csn_id_jittered, o.dx_id, o.start_date, o.source, o.dept_id,
o.end_date as o1, o.noted_date as o2, o.hx_date_of_entry as o3, o.resolved_date as o4,
c.end_date, c.noted_date, c.hx_date_of_entry, c.resolved_date
from starr_datalake2020.shc_diagnosis o
join shc_core.diagnosis_code c
on o.anon_id = c.anon_id and o.line = c.line and o.pat_enc_csn_id_jittered = c.pat_enc_csn_id_jittered and o.dx_id = c.dx_id
and o.start_date = format_datetime('%Y-%m-%d %H:%M:%S', c.start_date)
and o.source = c.source
and o.dept_id = c.dept_id
where o.end_date <> format_datetime('%Y-%m-%d %H:%M:%S', c.end_date)
or o.noted_date <> format_date('%Y-%m-%d', c.noted_date)
or o.hx_date_of_entry <> format_date('%Y-%m-%d', c.hx_date_of_entry)
or o.resolved_date <> format_date('%Y-%m-%d', c.resolved_date);
In the above case, a converted field itself was a part of a unique key, so it is omitted from the check as it is used in the JOIN
section. That field is checked separately by sorting it in both original and copy tables and ranking the sorted rows to be able to join the tables:
select *
from (select row_number() over() as o_row, o1.o_start_date, o_cnt
from (select start_date as o_start_date, count(*) as o_cnt
from starr_datalake2020.shc_diagnosis
group by start_date
order by start_date
) o1
) o2
join (select row_number() over() as c_row, c1.start_date, cnt
from (select start_date, count(*) as cnt
from shc_core.diagnosis_code
group by start_date
order by start_date
) c1
) c2 on o2.o_row = c2.c_row
where o2.o_start_date <> format_datetime('%Y-%m-%d %H:%M:%S', c2.start_date);
Sometimes, though, the check is simpler:
select o.anon_id,
o.birth_date_jittered as o1, o.death_date_jittered as o2, o.JITTER_DATE_RECENT_CONF_ENC_JITTER_MINDATE_MAXDATE_ as o3,
c.birth_date_jittered, c.death_date_jittered, c.recent_conf_enc_jittered
from starr_datalake2020.shc_demographic o
join shc_core.demographic c
using (anon_id)
where o.birth_date_jittered <> timestamp(c.birth_date_jittered)
or o.death_date_jittered <> timestamp(c.death_date_jittered)
or o.JITTER_DATE_RECENT_CONF_ENC_JITTER_MINDATE_MAXDATE_ <> timestamp(c.recent_conf_enc_jittered);
If the queries return no rows, the conversion was successful.
Datetime/utc conversion:
[X] 1. adt:
event_time_jittered is string - should be converted
both _utc columns should be timestamps
[X] 2. allergy:
[X] 3. clinical_note_meta:
[X] 4. demographics:
[X] 5. diagnosis:
[X] 6. family_hx:
som-nero-phi-naras-ric.Jon_Chen_data.lpch_family_hx
;som-nero-phi-jonc101.lpch.family_hx
set anon_id = 'JC' || anon_id
where true;som-nero-phi-naras-ric.Jon_Chen_data.lpch_family_hx
order by contact_date_jittered
) o1
) o2
join
(select row_number() over() as c_row, c1.contact_date_jittered
from (
select contact_date_jittered
from som-nero-phi-jonc101.lpch.family_hx
order by contact_date_jittered
) c1
) c2 on o2.o_row = c2.c_row
where o2.o_contact_date_jittered <> c2.contact_date_jittered;[X] 7. lda:
[X] 8. mar:
[X] 9. order_med:
som-nero-phi-naras-ric.Jon_Chen_data.lpch_order_med
;som-nero-phi-naras-ric.Jon_Chen_data.lpch_order_med
o
join lpch.order_med c
using (anon_id, pat_enc_csn_id_coded, order_med_id_coded, medication_id)
where o.order_time_jittered <> format_date('%Y-%m-%d', c.order_time_jittered) || ' 00:00:00'
or o.start_time_jittered <> format_date('%Y-%m-%d', c.start_time_jittered) || ' 00:00:00'
or o.end_time_jittered <> format_date('%Y-%m-%d', c.end_time_jittered) || ' 00:00:00'
or o.discon_time_jittered <> format_datetime('%Y-%m-%d %H:%M:%S', c.discon_time_jittered)
or o.order_inst <> format_datetime('%Y-%m-%d %H:%M:%S', c.order_inst)
or o.order_start_time <> format_datetime('%Y-%m-%d %H:%M:%S', c.order_start_time)
or o.order_end_time <> format_datetime('%Y-%m-%d %H:%M:%S', c.order_end_time);[X] 10. path_report:
[X] 11. procedure:
[X] 12. radiology_meta:
[X] 13. social_hx:
[X] 14. treatment_team:
[X] Copy lpch to som-nero-phi-jonc101: Error copying dataset: User does not have sufficient permission: bigquery.transfers.update is required on project som-nero-phi-jonc101
[X] Upload remaining lpch tables:
culture_sensitivity
Unique key: anon_id, order_proc_id_coded, line
assuming all times are PT - will be creating UTC times for all 4 datetime columns
old conversion script: select *, timestamp(order_time_jittered, "America/Los_Angeles") as order_time_jittered_utc, timestamp(result_time_jittered, "America/Los_Angeles") as result_time_jittered_utc, timestamp(sens_obs_inst_tm_jittered, "America/Los_Angeles") as sens_obs_inst_tm_jittered_utc, timestamp(sens_anl_inst_tm_jittered, "America/Los_Angeles") as sens_anl_inst_tm_jittered_utc from lpch.culture_sensitivity;
old conversion check: select o.anon_id, o.order_proc_id_coded, o.line, o.order_time_jittered as o1, o.result_time_jittered as o2, o.sens_obs_inst_tm_jittered as o3, o.sens_anl_inst_tm_jittered as o4, datetime(c.order_time_jittered_utc, "America/Los_Angeles"), datetime(c.result_time_jittered_utc, "America/Los_Angeles"), datetime(c.sens_obs_inst_tm_jittered_utc, "America/Los_Angeles"), datetime(c.sens_anl_inst_tm_jittered_utc, "America/Los_Angeles"), c.order_time_jittered_utc, c.result_time_jittered_utc, c.sens_obs_inst_tm_jittered_utc, c.sens_anl_inst_tm_jittered_utc from lpch.culture_sensitivity o join lpch.culture_sensitivity_copy c using (anon_id, order_proc_id_coded, line) where datetime(c.order_time_jittered_utc, "America/Los_Angeles") <> o.order_time_jittered or datetime(c.result_time_jittered_utc, "America/Los_Angeles") <> o.result_time_jittered or datetime(c.sens_obs_inst_tm_jittered_utc, "America/Los_Angeles") <> o.sens_obs_inst_tm_jittered or datetime(c.sens_anl_inst_tm_jittered_utc, "America/Los_Angeles") <> o.sens_anl_inst_tm_jittered;
conversion script:
select * except( order_time_jittered, result_time_jittered, sens_obs_inst_tm_jittered, sens_anl_inst_tm_jittered ),
parse_datetime('%Y-%m-%d %H:%M:%S', case when order_time_jittered <> '' then order_time_jittered else null end) as order_time_jittered,
parse_datetime('%Y-%m-%d %H:%M:%S', case when result_time_jittered <> '' then result_time_jittered else null end) as result_time_jittered,
parse_datetime('%Y-%m-%d %H:%M:%S', case when sens_obs_inst_tm_jittered <> '' then sens_obs_inst_tm_jittered else null end) as sens_obs_inst_tm_jittered,
parse_datetime('%Y-%m-%d %H:%M:%S', case when sens_anl_inst_tm_jittered <> '' then sens_anl_inst_tm_jittered else null end) as sens_anl_inst_tm_jittered,
timestamp(case when order_time_jittered <> '' then order_time_jittered else null end, "America/Los_Angeles") as order_time_jittered_utc,
timestamp(case when result_time_jittered <> '' then result_time_jittered else null end, "America/Los_Angeles") as result_time_jittered_utc,
timestamp(case when sens_obs_inst_tm_jittered <> '' then sens_obs_inst_tm_jittered else null end, "America/Los_Angeles") as sens_obs_inst_tm_jittered_utc,
timestamp(case when sens_anl_inst_tm_jittered <> '' then sens_anl_inst_tm_jittered else null end, "America/Los_Angeles") as sens_anl_inst_tm_jittered_utc
from som-nero-phi-naras-ric.Jon_Chen_data.lpch_culture_sensitivity
;
conversion check:
select o.anon_id, o.order_proc_id_coded, o.line, o.order_time_jittered as o1, o.result_time_jittered as o2, o.sens_obs_inst_tm_jittered as o3, o.sens_anl_inst_tm_jittered as o4,
c.order_time_jittered, c.result_time_jittered, c.sens_obs_inst_tm_jittered, c.sens_anl_inst_tm_jittered,
c.order_time_jittered_utc, c.result_time_jittered_utc, c.sens_obs_inst_tm_jittered_utc, c.sens_anl_inst_tm_jittered_utc
from som-nero-phi-naras-ric.Jon_Chen_data.lpch_culture_sensitivity
o
join lpch.culture_sensitivity c
on 'JC' || o.anon_id = c.anon_id and o.order_proc_id_coded = c.order_proc_id_coded and o.line = c.line
where format_datetime('%Y-%m-%d %H:%M:%S', c.order_time_jittered) <> o.order_time_jittered
or format_datetime('%Y-%m-%d %H:%M:%S', c.result_time_jittered) <> o.result_time_jittered
or format_datetime('%Y-%m-%d %H:%M:%S', c.sens_obs_inst_tm_jittered) <> o.sens_obs_inst_tm_jittered
or format_datetime('%Y-%m-%d %H:%M:%S', c.sens_anl_inst_tm_jittered) <> o.sens_anl_inst_tm_jittered;
fixing anon_id:
update som-nero-phi-jonc101.lpch.culture_sensitivity
set anon_id = 'JC' || anon_id
where true;
flowsheets
som-nero-phi-naras-ric.Jon_Chen_data.lpch_flowsheet
;som-nero-phi-jonc101.lpch.flowsheet
set anon_id = 'JC' || anon_id
where true;som-nero-phi-naras-ric.Jon_Chen_data.lpch_flowsheet
group by recorded_time
order by recorded_time
) o1
) o2
join
(select row_number() over() as c_row, c1.recorded_time, cnt
from (
select recorded_time, count(*) as cnt
from lpch.flowsheet
group by recorded_time
order by recorded_time
) c1
) c2 on o2.o_row = c2.c_row
where o2.o_recorded_time <> c2.recorded_time;lab_result
som-nero-phi-naras-ric.Jon_Chen_data.lpch_lab_result
;som-nero-phi-jonc101.lpch.lab_result
set anon_id = 'JC' || anon_id
where true;som-nero-phi-naras-ric.Jon_Chen_data.lpch_lab_result
o
join shc_core.lab_result c
on 'JC' || o.anon_id = c.anon_id and o.pat_enc_csn_id_coded = c.pat_enc_csn_id_coded and o.order_id_coded = c.order_id_coded and o.line = c.line
where o.order_time <> format_datetime('%Y-%m-%d %H:%M:%S', c.order_time)
or o.taken_time <> format_datetime('%Y-%m-%d %H:%M:%S', c.taken_time)
or o.result_time <> format_datetime('%Y-%m-%d %H:%M:%S', c.result_time);pharmacy_lpch_rxcui_map_2019.csv - mapped_meds
[X] latest LPCH tables anon_id needs to be converted to 'JC
[X] lpch_order_quest
select * except(ord_quest_id, ord_quest_date_jittered),
extract(date from parse_datetime('%Y-%m-%d %H:%M:%S', ord_quest_date_jittered)) as ord_quest_date_jittered
from `som-nero-phi-naras-ric.Jon_Chen_data.lpch_order_quest`;
select o.anon_id, o.order_proc_id_coded, o.line,
o.ord_quest_date_jittered as o1,
c.ord_quest_date_jittered
from `som-nero-phi-naras-ric.Jon_Chen_data.lpch_order_quest` o
join `lpch_core.order_quest` c
using (anon_id, order_proc_id_coded, line)
where o.ord_quest_date_jittered <> format_date('%Y-%m-%d', c.ord_quest_date_jittered) || ' 00:00:00';
[X] lpch_order_proc
times check:
select extract(time from case when ordering_date_jittered <> '' then parse_datetime('%Y-%m-%d %H:%M:%S', ordering_date_jittered) else null end) times, count(*) as cnt
from `som-nero-phi-naras-ric.Jon_Chen_data.lpch_order_proc`
group by times
order by cnt desc;
select extract(time from case when standing_exp_date_jittered <> '' then parse_datetime('%Y-%m-%d %H:%M:%S', standing_exp_date_jittered) else null end) times, count(*) as cnt
from `som-nero-phi-naras-ric.Jon_Chen_data.lpch_order_proc`
group by times
order by cnt desc;
select extract(time from case when proc_bgn_time_jittered <> '' then parse_datetime('%Y-%m-%d %H:%M:%S', proc_bgn_time_jittered) else null end) times, count(*) as cnt
from `som-nero-phi-naras-ric.Jon_Chen_data.lpch_order_proc`
group by times
order by cnt desc;
select extract(time from case when proc_end_time_jittered <> '' then parse_datetime('%Y-%m-%d %H:%M:%S', proc_end_time_jittered) else null end) times, count(*) as cnt
from `som-nero-phi-naras-ric.Jon_Chen_data.lpch_order_proc`
group by times
order by cnt desc;
select extract(time from case when order_inst_jittered <> '' then parse_datetime('%Y-%m-%d %H:%M:%S', order_inst_jittered) else null end) times, count(*) as cnt
from `som-nero-phi-naras-ric.Jon_Chen_data.lpch_order_proc`
group by times
order by cnt desc;
select extract(time from case when instantiated_time_jittered <> '' then parse_datetime('%Y-%m-%d %H:%M:%S', instantiated_time_jittered) else null end) times, count(*) as cnt
from `som-nero-phi-naras-ric.Jon_Chen_data.lpch_order_proc`
group by times
order by cnt desc;
select extract(time from case when order_time_jittered <> '' then parse_datetime('%Y-%m-%d %H:%M:%S', order_time_jittered) else null end) times, count(*) as cnt
from `som-nero-phi-naras-ric.Jon_Chen_data.lpch_order_proc`
group by times
order by cnt desc;
select extract(time from case when result_time_jittered <> '' then parse_datetime('%Y-%m-%d %H:%M:%S', result_time_jittered) else null end) times, count(*) as cnt
from `som-nero-phi-naras-ric.Jon_Chen_data.lpch_order_proc`
group by times
order by cnt desc;
select extract(time from case when proc_start_time_jittered <> '' then parse_datetime('%Y-%m-%d %H:%M:%S', proc_start_time_jittered) else null end) times, count(*) as cnt
from `som-nero-phi-naras-ric.Jon_Chen_data.lpch_order_proc`
group by times
order by cnt desc;
select extract(time from case when proc_date_jittered <> '' then parse_datetime('%Y-%m-%d %H:%M:%S', proc_date_jittered) else null end) times, count(*) as cnt
from `som-nero-phi-naras-ric.Jon_Chen_data.lpch_order_proc`
group by times
order by cnt desc;
select extract(time from case when last_stand_perf_dt_jittered <> '' then parse_datetime('%Y-%m-%d %H:%M:%S', last_stand_perf_dt_jittered) else null end) times, count(*) as cnt
from `som-nero-phi-naras-ric.Jon_Chen_data.lpch_order_proc`
group by times
order by cnt desc;
select extract(time from case when last_stand_perf_tm_jittered <> '' then parse_datetime('%Y-%m-%d %H:%M:%S', last_stand_perf_tm_jittered) else null end) times, count(*) as cnt
from `som-nero-phi-naras-ric.Jon_Chen_data.lpch_order_proc`
group by times
order by cnt desc;
conversion script:
select * except(ordering_date_jittered, standing_exp_date_jittered, proc_bgn_time_jittered, proc_end_time_jittered, order_inst_jittered, instantiated_time_jittered,
order_time_jittered, result_time_jittered, proc_start_time_jittered, proc_date_jittered, last_stand_perf_dt_jittered, last_stand_perf_tm_jittered),
extract(date from parse_datetime('%Y-%m-%d %H:%M:%S', case when ordering_date_jittered <> '' then ordering_date_jittered else null end)) as ordering_date_jittered,
extract(date from parse_datetime('%Y-%m-%d %H:%M:%S', case when standing_exp_date_jittered <> '' then standing_exp_date_jittered else null end)) as standing_exp_date_jittered,
parse_datetime('%Y-%m-%d %H:%M:%S', case when proc_bgn_time_jittered <> '' then proc_bgn_time_jittered else null end) as proc_bgn_time_jittered,
parse_datetime('%Y-%m-%d %H:%M:%S', case when proc_end_time_jittered <> '' then proc_end_time_jittered else null end) as proc_end_time_jittered,
parse_datetime('%Y-%m-%d %H:%M:%S', case when order_inst_jittered <> '' then order_inst_jittered else null end) as order_inst_jittered,
parse_datetime('%Y-%m-%d %H:%M:%S', case when instantiated_time_jittered <> '' then instantiated_time_jittered else null end) as instantiated_time_jittered,
parse_datetime('%Y-%m-%d %H:%M:%S', case when order_time_jittered <> '' then order_time_jittered else null end) as order_time_jittered,
parse_datetime('%Y-%m-%d %H:%M:%S', case when result_time_jittered <> '' then result_time_jittered else null end) as result_time_jittered,
parse_datetime('%Y-%m-%d %H:%M:%S', case when proc_start_time_jittered <> '' then proc_start_time_jittered else null end) as proc_start_time_jittered,
extract(date from parse_datetime('%Y-%m-%d %H:%M:%S', case when proc_date_jittered <> '' then proc_date_jittered else null end)) as proc_date_jittered,
extract(date from parse_datetime('%Y-%m-%d %H:%M:%S', case when last_stand_perf_dt_jittered <> '' then last_stand_perf_dt_jittered else null end)) as last_stand_perf_dt_jittered,
parse_datetime('%Y-%m-%d %H:%M:%S', case when last_stand_perf_tm_jittered <> '' then last_stand_perf_tm_jittered else null end) as last_stand_perf_tm_jittered,
timestamp(case when proc_bgn_time_jittered <> '' then proc_bgn_time_jittered else null end, "America/Los_Angeles") as proc_bgn_time_jittered_utc,
timestamp(case when proc_end_time_jittered <> '' then proc_end_time_jittered else null end, "America/Los_Angeles") as proc_end_time_jittered_utc,
timestamp(case when order_inst_jittered <> '' then order_inst_jittered else null end, "America/Los_Angeles") as order_inst_jittered_utc,
timestamp(case when instantiated_time_jittered <> '' then instantiated_time_jittered else null end, "America/Los_Angeles") as instantiated_time_jittered_utc,
timestamp(case when order_time_jittered <> '' then order_time_jittered else null end, "America/Los_Angeles") as order_time_jittered_utc,
timestamp(case when result_time_jittered <> '' then result_time_jittered else null end, "America/Los_Angeles") as result_time_jittered_utc,
timestamp(case when proc_start_time_jittered <> '' then proc_start_time_jittered else null end, "America/Los_Angeles") as proc_start_time_jittered_utc,
timestamp(case when last_stand_perf_tm_jittered <> '' then last_stand_perf_tm_jittered else null end, "America/Los_Angeles") as last_stand_perf_tm_jittered_utc
from `som-nero-phi-naras-ric.Jon_Chen_data.lpch_order_proc` ;
select o.anon_id, o.pat_enc_csn_id_coded,
o.ordering_date_jittered as o1, o.standing_exp_date_jittered as o2, o.proc_bgn_time_jittered as o3, o.proc_end_time_jittered as o4, o.order_inst_jittered as o5, o.instantiated_time_jittered as o6,
o.order_time_jittered as o7, o.result_time_jittered as o8, o.proc_start_time_jittered as o9, o.proc_date_jittered as o10, o.last_stand_perf_dt_jittered as o11, o.last_stand_perf_tm_jittered as o12,
c.ordering_date_jittered, c.standing_exp_date_jittered, c.proc_bgn_time_jittered, c.proc_end_time_jittered, c.order_inst_jittered, c.instantiated_time_jittered,
c.order_time_jittered, c.result_time_jittered, c.proc_start_time_jittered, c.proc_date_jittered, c.last_stand_perf_dt_jittered, c.last_stand_perf_tm_jittered
from `som-nero-phi-naras-ric.Jon_Chen_data.lpch_order_proc` o
join lpch_core.order_proc c
using (anon_id, pat_enc_csn_id_coded, order_proc_id_coded, proc_id, ack_user_id)
where o.ordering_date_jittered <> format_date('%Y-%m-%d', c.ordering_date_jittered) || ' 00:00:00'
or o.standing_exp_date_jittered <> format_date('%Y-%m-%d', c.standing_exp_date_jittered) || ' 00:00:00'
or o.proc_bgn_time_jittered <> format_datetime('%Y-%m-%d %H:%M:%S', c.proc_bgn_time_jittered)
or o.proc_end_time_jittered <> format_datetime('%Y-%m-%d %H:%M:%S', c.proc_end_time_jittered)
or o.order_inst_jittered <> format_datetime('%Y-%m-%d %H:%M:%S', c.order_inst_jittered)
or o.instantiated_time_jittered <> format_datetime('%Y-%m-%d %H:%M:%S', c.instantiated_time_jittered)
or o.order_time_jittered <> format_datetime('%Y-%m-%d %H:%M:%S', c.order_time_jittered)
or o.result_time_jittered <> format_datetime('%Y-%m-%d %H:%M:%S', c.result_time_jittered)
or o.proc_start_time_jittered <> format_datetime('%Y-%m-%d %H:%M:%S', c.proc_start_time_jittered)
or o.proc_date_jittered <> format_date('%Y-%m-%d', c.proc_date_jittered) || ' 00:00:00'
or o.last_stand_perf_dt_jittered <> format_date('%Y-%m-%d', c.last_stand_perf_dt_jittered) || ' 00:00:00'
or o.last_stand_perf_tm_jittered <> format_datetime('%Y-%m-%d %H:%M:%S', c.last_stand_perf_tm_jittered);
som-nero-phi-naras-ric.Jon_Chen_data.lpch_pharmacy_mar
;som-nero-phi-naras-ric.Jon_Chen_data.lpch_pharmacy_mar
o
join lpch_core.mar
c
using (anon_id, order_med_id_coded, mar_enc_csn_coded, line)
where o.taken_time_jittered <> format_datetime('%Y-%m-%d %H:%M:%S', c.taken_time_jittered)
or o.scheduled_time_jittered <> format_datetime('%Y-%m-%d %H:%M:%S', c.scheduled_time_jittered);
Upload remaining LPCH tables from jc_data_bucket or copy them over from naras-ric project. Also check and process UTC times, if necessary.