Skip to content

Commit

Permalink
Merge pull request #17 from PIH/UHM-6397-rename-columns-to-zlemrid-on…
Browse files Browse the repository at this point in the history
…-all-haiti-warehouse

Uhm 6397 rename columns to zlemrid on all haiti warehouse
  • Loading branch information
dmdesimone authored Apr 15, 2022
2 parents 2b4c91d + edecdd9 commit 9daad22
Show file tree
Hide file tree
Showing 63 changed files with 149 additions and 113 deletions.
2 changes: 1 addition & 1 deletion jobs/sql/extractions/covid_admission.sql
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ UPDATE temp_covid_admission_encounter SET contact_case_14d = OBS_VALUE_CODED_LIS
## EXECUTE FINAL SELECTION
SELECT
encounter_id,
patient_id,
zlemr(patient_id),
encounter_datetime,
date_entered,
user_entered,
Expand Down
4 changes: 2 additions & 2 deletions jobs/sql/extractions/covid_diagnoses.sql
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ ORDER BY person_id;

##### FINAL QUERY EXECUTION
SELECT
ce.patient_id,
zlemr(ce.patient_id),
ce.encounter_id,
ce.encounter_type,
ce.location,
Expand All @@ -230,4 +230,4 @@ LEFT JOIN
temp_covid_diagnosis_confirmation dc ON d.obs_group_id = dc.obs_group_id AND d.encounter_id = dc.encounter_id
LEFT JOIN
temp_covid_diagnosis_order dor ON d.obs_group_id = dor.obs_group_id AND d.encounter_id = dor.encounter_id
ORDER BY ce.patient_id;
ORDER BY ce.patient_id;
2 changes: 1 addition & 1 deletion jobs/sql/extractions/covid_discharge.sql
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ UPDATE temp_covid_discharge SET other_medications = OBS_VALUE_TEXT(encounter_id,
### Final query
SELECT
encounter_id,
patient_id,
zlemr(patient_id),
encounter_date,
encounter_type,
date_entered,
Expand Down
2 changes: 1 addition & 1 deletion jobs/sql/extractions/covid_disposition.sql
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ FROM (SELECT
) index_descending );

SELECT
tcd.patient_id patient_id,
zlemr(tcd.patient_id) emr_id,
tcd.encounter_id encounter_id,
encounter_type,
location,
Expand Down
4 changes: 2 additions & 2 deletions jobs/sql/extractions/covid_lab_test.sql
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ UPDATE temp_covid_lab_app_result tcl INNER JOIN temp_final_covid_lab_encounters
DROP TEMPORARY TABLE IF EXISTS temp_final_query;
CREATE TEMPORARY TABLE temp_final_query AS
SELECT
ls.person_id patient_id,
zlemr(ls.person_id) emr_id,
ls.encounter_id encounter_id,
ls.obs_id,
e.encounter_date,
Expand Down Expand Up @@ -362,4 +362,4 @@ FROM
ORDER BY ls.person_id, ls.encounter_id, lspd.value_datetime;

SELECT * FROM
(SELECT * FROM temp_final_query q UNION ALL SELECT * FROM temp_covid_lab_app_result r) a;
(SELECT * FROM temp_final_query q UNION ALL SELECT * FROM temp_covid_lab_app_result r) a;
2 changes: 1 addition & 1 deletion jobs/sql/extractions/covid_visit.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@ create index temp_index_desc_ei on temp_index_desc(encounter_id);

#### Final query
SELECT
tcv.patient_id patient_id,
zlemr(tcv.patient_id) emr_id,
tcv.encounter_id encounter_id,
encounter_date,
location,
Expand Down
4 changes: 2 additions & 2 deletions jobs/sql/extractions/hiv_dispensing.sql
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ where t.dispense_date_descending = 1;

# final query
Select
t.patient_id,
zlemr(t.patient_id),
t.encounter_id,
t.dispense_date,
t.dispense_site,
Expand Down Expand Up @@ -355,4 +355,4 @@ t.regimen_match,
dispense_date_ascending,
dispense_date_descending
from temp_HIV_dispensing t
order by patient_id, dispense_date asc, encounter_id asc;
order by patient_id, dispense_date asc, encounter_id asc;
1 change: 0 additions & 1 deletion jobs/sql/extractions/hiv_monthly_reporting.sql
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ update temp_eom_appts t
set latest_arv_dispensed_line = obs_value_coded_list(t.latest_arv_dispensed_id, 'PIH','13115',@locale );

SELECT
patient_id,
zlemr(patient_id),
date_enrolled ,
date_completed ,
Expand Down
1 change: 0 additions & 1 deletion jobs/sql/extractions/hiv_patient.sql
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,6 @@ UPDATE temp_hiv_art t set art_regimen = ActiveDrugConceptNameList(t.patient_id,

### Final Query
SELECT
t.patient_id,
t.zl_emr_id,
t.hivemr_v1_id,
t.hiv_dossier_id,
Expand Down
2 changes: 1 addition & 1 deletion jobs/sql/extractions/hiv_patient_program.sql
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ set location = location_name(location_id),

select
patient_program_id,
patient_id,
zlemr(patient_id),
date_enrolled,
date_completed,
location,
Expand Down
2 changes: 1 addition & 1 deletion jobs/sql/extractions/hiv_regimens.sql
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ where t.index_descending_category = 1 and t.drug_category = 'ART';
select
order_id,
previous_order_id,
patient_id,
zlemr(patient_id),
order_action,
encounter_id,
encounter_datetime,
Expand Down
2 changes: 1 addition & 1 deletion jobs/sql/extractions/hiv_status.sql
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ SET transfer_internal_sitename = LOCATION_NAME(th.location_id);
### Final query
SELECT
status_id,
patient_id,
zlemr(patient_id),
ZLEMR(patient_id) "zl_emr_id",
LOCATION_NAME(location_id) "patient_location",
transfer_internal_sitename,
Expand Down
6 changes: 5 additions & 1 deletion jobs/sql/extractions/hiv_tests.sql
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,18 @@ create index temp_hiv_lab_index_asc_test_type on temp_hiv_lab_index_asc(test_typ
create index temp_hiv_lab_index_desc_encounter_id on temp_hiv_lab_index_desc(encounter_id);
create index temp_hiv_lab_index_desc_test_type on temp_hiv_lab_index_desc(test_type);

create index temp_hiv_lab_index_asc_encounter_id on temp_hiv_lab_index_asc(encounter_id);
create index temp_hiv_lab_index_asc_test_type on temp_hiv_lab_index_asc(test_type);
create index temp_hiv_lab_index_desc_encounter_id on temp_hiv_lab_index_desc(encounter_id);
create index temp_hiv_lab_index_desc_test_type on temp_hiv_lab_index_desc(test_type);

UPDATE temp_lab_tests_final tbf JOIN temp_hiv_lab_index_asc tbia ON tbf.encounter_id = tbia.encounter_id AND tbf.test_type = tbia.test_type
SET tbf.index_asc = tbia.index_asc;

UPDATE temp_lab_tests_final tbf JOIN temp_hiv_lab_index_desc tbia ON tbf.encounter_id = tbia.encounter_id AND tbf.test_type = tbia.test_type
SET tbf.index_desc = tbia.index_desc;

SELECT
person_id,
emr_id,
patient_identifier(person_id, '139766e8-15f5-102d-96e4-000c29c2a5d7') hivemr_v1_id,
encounter_id,
Expand Down
2 changes: 1 addition & 1 deletion jobs/sql/extractions/hiv_viral_load.sql
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ FROM (SELECT

### Final query
SELECT
tvl.patient_id,
zlemr(tvl.patient_id),
tvl.encounter_id,
tvl.visit_location,
tvl.date_entered,
Expand Down
15 changes: 14 additions & 1 deletion jobs/sql/extractions/hiv_visit.sql
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,17 @@ update temp_hiv_visit t
inner join temp_visit_index_desc tvid on tvid.encounter_id = t.encounter_id
set t.index_desc = tvid.index_desc;

SELECT * FROM temp_hiv_visit;
SELECT
encounter_id,
emr_id,
hivemr_v1,
encounter_type,
date_entered,
user_entered,
pregnant,
visit_date,
next_visit_date,
visit_location,
index_asc,
index_desc
FROM temp_hiv_visit;
4 changes: 2 additions & 2 deletions jobs/sql/extractions/mch_birth.sql
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ UPDATE temp_mch_birth_final SET mother_emr_id = ZLEMR(patient_id);
UPDATE temp_mch_birth_final tf SET multiples = (SELECT COUNT(patient_id) FROM temp_mch_birth_stage ts WHERE tf.encounter_id = ts.encounter_id GROUP BY ts.encounter_id);

SELECT
patient_id,
zlemr(patient_id),
mother_emr_id,
encounter_date,
date_entered,
Expand All @@ -148,4 +148,4 @@ birth_outcome,
birth_weight,
birth_neonatal_resuscitation,
birth_macerated_fetus
FROM temp_mch_birth_final ORDER BY patient_id, encounter_id, birth_number;
FROM temp_mch_birth_final ORDER BY patient_id, encounter_id, birth_number;
2 changes: 1 addition & 1 deletion jobs/sql/extractions/mch_j9_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ set prenatal_teas = value_coded_name(latest_obs(t.patient_id, 'PIH','13737'),@lo

-- final output
Select
patient_id,
zlemr(patient_id),
patient_age,
education_level,
able_read_write,
Expand Down
5 changes: 2 additions & 3 deletions jobs/sql/extractions/mch_patient.sql
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@ UPDATE temp_mch_patient tm SET tm.dossier_id = dosId(tm.patient_id);

### Final query
SELECT
patient_id,
mch_emr_id pih_emr_id,
mch_emr_id emr_id,
dossier_id dossier_id,
initial_encounter_type_name first_encounter_type,
encounter_type_name last_encounter_type,
Expand All @@ -200,4 +199,4 @@ SELECT
antenatal_visit,
estimated_delivery_date,
pregnant
FROM temp_mch_patient;
FROM temp_mch_patient;
48 changes: 47 additions & 1 deletion jobs/sql/extractions/mch_pregnancy.sql
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,50 @@ UPDATE temp_mch_pregnancy t SET pregnancy_10_outcome = OBS_FROM_GROUP_ID_VALUE_C
UPDATE temp_mch_pregnancy t SET pmtct_club = OBS_VALUE_CODED_LIST(t.encounter_id, 'PIH', '13262', 'en');
UPDATE temp_mch_pregnancy t SET delivery_location_plan = OBS_VALUE_CODED_LIST(t.encounter_id, 'CIEL', '159758', 'en');

SELECT * FROM temp_mch_pregnancy;
SELECT
pregnancy_id,
encounter_id,
emr_id,
encounter_date,
date_entered,
user_entered,
gravidity,
parity,
num_abortions,
num_living_children,
last_period_date,
expected_delivery_date,
calculated_gestational_age,
pregnancy_1_birth_order,
pregnancy_1_delivery_type,
pregnancy_1_outcome,
pregnancy_2_birth_order,
pregnancy_2_delivery_type,
pregnancy_2_outcome,
pregnancy_3_birth_order,
pregnancy_3_delivery_type,
pregnancy_3_outcome,
pregnancy_4_birth_order,
pregnancy_4_delivery_type,
pregnancy_4_outcome,
pregnancy_5_birth_order,
pregnancy_5_delivery_type,
pregnancy_5_outcome,
pregnancy_6_birth_order,
pregnancy_6_delivery_type,
pregnancy_6_outcome,
pregnancy_7_birth_order,
pregnancy_7_delivery_type,
pregnancy_7_outcome,
pregnancy_8_birth_order,
pregnancy_8_delivery_type,
pregnancy_8_outcome,
pregnancy_9_birth_order,
pregnancy_9_delivery_type,
pregnancy_9_outcome,
pregnancy_10_birth_order,
pregnancy_10_delivery_type,
pregnancy_10_outcome,
pmtct_club,
delivery_location_plan
FROM temp_mch_pregnancy;
10 changes: 1 addition & 9 deletions jobs/sql/extractions/mch_status.sql
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,7 @@ patient_id IN (

-- ZL EMR ID
UPDATE temp_mch_status t
INNER JOIN
(SELECT patient_id, GROUP_CONCAT(identifier) 'ids'
FROM patient_identifier pid
WHERE pid.voided = 0
AND pid.identifier_type = @mch_emr_id
GROUP BY patient_id
) ids ON ids.patient_id = t.patient_id
SET t.mch_emr_id = ids.ids;
SET t.mch_emr_id = zlemr(t.patient_id);

######### index count
########## indexes
Expand Down Expand Up @@ -228,7 +221,6 @@ SET tmp.encounter_location_name = tme.encounter_location_name,

### Final Query
SELECT
patient_id,
mch_emr_id,
enrollment_location,
encounter_location_name,
Expand Down
3 changes: 1 addition & 2 deletions jobs/sql/extractions/mch_visit.sql
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,6 @@ SET
fp_counseling_received = OBS_VALUE_CODED_LIST(te.encounter_id, 'CIEL', '165309', 'en');

SELECT
patient_id,
ZLEMR(patient_id),
encounter_id,
visit_date,
Expand Down Expand Up @@ -858,4 +857,4 @@ SELECT
index_desc
FROM
temp_obgyn_visit
ORDER BY patient_id , index_asc;
ORDER BY patient_id , index_asc;
3 changes: 1 addition & 2 deletions jobs/sql/extractions/ovc_program_encounters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,6 @@ select * from temp_program_no_statuses_encounters;

###### Final query #######
SELECT
person_id,
ZLEMR(person_id),
patient_program_id,
LOCATION_NAME(location_id),
Expand All @@ -549,4 +548,4 @@ SELECT
index_desc_program_status,
index_asc_enrollment,
index_desc_enrollment
FROM temp_ovc_program_status_encounters ORDER BY person_id, patient_program_id, state, encounter_date;
FROM temp_ovc_program_status_encounters ORDER BY person_id, patient_program_id, state, encounter_date;
1 change: 0 additions & 1 deletion jobs/sql/extractions/pmtct_contacts.sql
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ update temp_contacts t inner join obs o on t.concept_obs_group_id = o.obs_id
set t.date_entered = o.date_created, t.user_entered = username(o.creator);

select
patient_id,
zlemrid,
age,
hiv_enrollment_date,
Expand Down
1 change: 0 additions & 1 deletion jobs/sql/extractions/pmtct_infant_delivery.sql
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ set health_facility = (select location_name(value_text) from obs where voided =
update temp_eid t set t.breastfeeding_status = value_coded_name(latest_obs(t.patient_id, 'CIEL', '1151'), 'en');

select
patient_id,
zlemr(patient_id),
infant_age_in_months,
age_cat_infant,
Expand Down
1 change: 0 additions & 1 deletion jobs/sql/extractions/pmtct_labs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ order by patient_id asc, test_date desc, obs_id desc;

-- final output
select
patient_id,
zlemr(patient_id),
test_date,
test_result_date,
Expand Down
3 changes: 1 addition & 2 deletions jobs/sql/extractions/pmtct_pregnancy.sql
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ UPDATE temp_pmtct_pregnancy t SET index_desc = (SELECT index_desc FROM temp_pmtc

## final query
SELECT
patient_id,
zlemr,
start_date,
pmtct_enrollment_date,
Expand All @@ -228,4 +227,4 @@ SELECT
hiv_known_before_current_pregnancy,
index_asc,
index_desc
FROM temp_pmtct_pregnancy;
FROM temp_pmtct_pregnancy;
15 changes: 14 additions & 1 deletion jobs/sql/extractions/pmtct_visits.sql
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,17 @@ CREATE TEMPORARY TABLE temp_pmtct_visit_index_desc
UPDATE temp_pmtct_visit t SET t.index_asc = (SELECT index_asc FROM temp_pmtct_visit_index_asc a WHERE t.visit_id = a.visit_id);
UPDATE temp_pmtct_visit t SET t.index_desc = (SELECT index_desc FROM temp_pmtct_visit_index_desc b WHERE t.visit_id = b.visit_id);

SELECT * FROM temp_pmtct_visit ORDER BY patient_id, visit_date, visit_id;
SELECT
visit_id,
encounter_id,
emr_id,
visit_date,
health_facility,
date_entered,
user_entered,
hiv_test_date,
tb_screening_date,
has_provided_contact,
index_asc,
index_desc
FROM temp_pmtct_visit ORDER BY patient_id, visit_date, visit_id;
1 change: 0 additions & 1 deletion jobs/sql/extractions/tb_lab_results.sql
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,6 @@ UPDATE temp_tb_final_query tbf

## Final query
SELECT
patient_id,
zlemr(patient_id),
dosId(patient_id),
encounter_id,
Expand Down
1 change: 0 additions & 1 deletion jobs/sql/extractions/tb_screening.sql
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ SET t.index_descending = tsid.index_desc;


SELECT
patient_id,
ZLEMR(patient_id) emr_id,
DOSID(patient_id) dossier_id,
encounter_id,
Expand Down
Loading

0 comments on commit 9daad22

Please sign in to comment.